diff -Nru eresi-0.8a25/build/defs/.svn/all-wcprops eresi-0.0.20110516/build/defs/.svn/all-wcprops --- eresi-0.8a25/build/defs/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/build/defs/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/950/trunk/build/defs -END -dep-rules.def -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/950/trunk/build/defs/dep-rules.def -END diff -Nru eresi-0.8a25/build/defs/.svn/entries eresi-0.0.20110516/build/defs/.svn/entries --- eresi-0.8a25/build/defs/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/build/defs/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/build/defs -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -dep-rules.def -file - - - - -2008-04-06T23:15:44.940876Z -a4bcc12e96dc2a4590b2f2705e1675fd -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/build/defs/.svn/format eresi-0.0.20110516/build/defs/.svn/format --- eresi-0.8a25/build/defs/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/build/defs/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/build/defs/.svn/text-base/dep-rules.def.svn-base eresi-0.0.20110516/build/defs/.svn/text-base/dep-rules.def.svn-base --- eresi-0.8a25/build/defs/.svn/text-base/dep-rules.def.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/build/defs/.svn/text-base/dep-rules.def.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ - -dep-liballocproxy: - @echo 'Building liballocproxy ..' - @cd liballocproxy && $(MAKE) - @echo 'Liballoc-proxy has been built successfully.' - -dep-libaspect: - @echo 'Building libaspect..' - @cd libaspect && $(MAKE) $(BUILD_TARGET) - @echo 'Libaspect has been built successfully.' - -dep-libasm: dep-libaspect - @echo 'Building libasm...' - @cd libasm && sh configure - @cd libasm && $(MAKE) - @echo 'Libasm has been built successfully.' - -dep-libelfsh: dep-liballocproxy dep-libaspect - @echo 'Building libelfsh...' - @cd libelfsh && $(MAKE) $(BUILD_TARGET) - @echo 'Libelfsh has been built successfully.' - -dep-libetrace: dep-liballocproxy - @echo 'Building libetrace...' - @cd libetrace && $(MAKE) $(BUILD_TARGET) - @echo 'Libetrace has been built successfully.' - -dep-libedfmt: dep-liballocproxy dep-libelfsh dep-libaspect - @echo 'Building libedfmt...' - @cd libedfmt && $(MAKE) $(BUILD_TARGET) - @echo 'Libedfmt has been built successfully.' - -dep-libkernsh: - @echo 'Building libkernsh...' - @cd libkernsh && $(MAKE) $(BUILD_TARGET) - @echo 'Libkernsh has been built successfully.' - -dep-libui: - @echo 'Building libui...' - @cd libui && $(MAKE) $(BUILD_TARGET) - @echo 'Libui has been built successfully.' - -dep-libmjollnir: - @echo 'Building libmjollnir...' - @cd libmjollnir && $(MAKE) $(BUILD_TARGET) - @echo 'Libmjollnir has been built successfully.' - -dep-librevm: - @echo 'Building librevm...' - @cd librevm && $(MAKE) $(BUILD_TARGET) - @echo 'Librevm has been built successfully.' - -dep-libstderesi: dep-libasm dep-libmjollnir dep-libetrace dep-librevm - @echo 'Building libstderesi...' - @cd libstderesi && $(MAKE) $(BUILD_TARGET) - @echo 'Libstderesi has been built successfully.' - -dep-libe2dbg: - @echo 'Building libe2dbg...' - @cd libe2dbg && $(MAKE) $(BUILD_TARGET) - @echo 'Libe2dbg has been built successfully.' -dep-elfsh: dep-libstderesi - @echo 'Building ELFsh ET_EXEC' - @cd elfsh && $(MAKE) $(BUILD_TARGET) - @echo 'ELFsh ET_EXEC has been built successfully.' - -dep-e2dbg: - @echo 'Building E2dbg' - @cd e2dbg && $(MAKE) $(BUILD_TARGET) - @echo 'E2dbg has been built successfully.' - -dep-etrace: dep-libedfmt dep-libstderesi dep-libelfsh dep-libui - @echo 'Building Etrace' - @cd etrace && $(MAKE) $(BUILD_TARGET) - @echo 'ETrace has been built successfully.' - -dep-evarista: - @echo 'Building Evarista' - @cd evarista && $(MAKE) $(BUILD_TARGET) - @echo 'Evarista has been built successfully.' - -dep-kernsh: dep-libkernsh - @echo 'Building kernsh...' - @cd kernsh && $(MAKE) $(BUILD_TARGET) - @echo 'Kernsh has been built successfully.' diff -Nru eresi-0.8a25/build/.svn/all-wcprops eresi-0.0.20110516/build/.svn/all-wcprops --- eresi-0.8a25/build/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/build/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 29 -/svn/!svn/ver/950/trunk/build -END diff -Nru eresi-0.8a25/build/.svn/entries eresi-0.0.20110516/build/.svn/entries --- eresi-0.8a25/build/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/build/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/build -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -defs -dir - diff -Nru eresi-0.8a25/build/.svn/format eresi-0.0.20110516/build/.svn/format --- eresi-0.8a25/build/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/build/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/configure eresi-0.0.20110516/configure --- eresi-0.8a25/configure 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/configure 2011-05-16 11:35:07.000000000 +0000 @@ -1,14 +1,15 @@ #!/bin/sh # # Homemade configure file for the ERESI project +# The ERESI team 2001-2010 # -# The ELFsh crew. -# +# $Id: configure 1408 2010-04-18 21:34:12Z thorkill $ CHOSENBIT="0" STATIC="0" READLN="0" -ELFSHNET="0" +KERNSH="0" +ERESI_NET="0" LIBMJOLLNIR="1" TESTING="0" GSTABS="" @@ -20,10 +21,7 @@ LIBVARSFILE="libelfsh/include/libvars.h" LPTHREAD="-lpthread" SHELL=`which bash` - -if [ $0 = "bash" ]; then - function printHelp -fi +GENTOO=` uname -a | grep gentoo` printHelp() { @@ -35,7 +33,7 @@ echo " --enable-32 : Build a ELF32 capable shell." echo " --enable-64 : Build a ELF64 capable shell." echo " --enable-readline : Link with readline" -# echo " --enable-network : Build the distributed extension." + echo " --enable-network : Build eresi server capability" echo " --enable-static : Link in static." echo " --enable-testing : Test ERESI without install" echo " --enable-dmalloc : Link with Electric Fence." @@ -46,6 +44,14 @@ echo " --use-etags : Use etags" echo " --use-ctags : Use ctags" echo " --use-cpp : Build the project as C++" + echo " --no-stackprot : Use -fno-stack-protector gcc option" + echo + echo " --libasm-ia32 : Enable libasm INTEL engine" + echo " --libasm-sparc : Enable libasm SPARC engine" + echo " --libasm-mips : Enable libasm MIPS engine" + echo " --libasm-arm : Enable libasm ARM engine" + echo " --libasm-packed : Pack handlers in a single file" + echo " --libasm-unpacked : Keep handlers per source file" echo echo " Available variables :" echo @@ -53,11 +59,11 @@ echo " --set-compiler : Set your compiler path." echo " --set-editor : Set your editor path." echo " --set-modpath : Set your ELFsh modules path." - echo " --prefix : Set prefix." + echo " --prefix : Set prefix." echo echo " All options are disabled by default." echo - exit + exit 1 } if [ "$1" = "-h" -o "$1" = "--help" ] ; then @@ -68,7 +74,8 @@ echo > $VARSFILE echo > $CONFIGFILE - +echo "CFLAGS32 += -Wall " >> $CONFIGFILE +echo "CFLAGS64 += -Wall " >> $CONFIGFILE while [ $# -ne 0 ]; do @@ -85,8 +92,8 @@ fi echo " [*] Enabling ELF64/ELF32 support" -BITS="-DELFSH64" -echo "//#define ELFSH64 1" >> $LIBVARSFILE +#BITS="-DERESI64" +#echo "//#define ELFSH64 1" >> $LIBVARSFILE CHOSENBIT="1" BUILD_TARGET="" ;; @@ -100,8 +107,8 @@ exit fi echo " [*] Enabling ELF64 support" -BITS="-DERESI64" -echo "//#define ELFSH64 1" >> $LIBVARSFILE +#BITS="-DERESI64" +#echo "//#define ELFSH64 1" >> $LIBVARSFILE CHOSENBIT="1" BUILD_TARGET=all64 MOD_TARGET=mod64 @@ -117,7 +124,7 @@ exit fi echo " [*] Enabling ELF32 support" -BITS="-DERESI32" +#BITS="-DERESI32" echo "//#define ELFSH32 1" >> $LIBVARSFILE CHOSENBIT="1" @@ -126,29 +133,75 @@ ;; -#Not supported anymore at least since version 0.78 -#--enable-network*) -#echo " [*] Enable distributed ELFsh" -#ELFSHNET="1" -#echo "LDDUMPOPT = -ldump" >> $CONFIGFILE -#echo "LDDUMPOBJ = ../libdump/libdump.o" >> $CONFIGFILE -#BITS=$BITS" -DELFSHNET" -#;; +--enable-network*) +echo " [*] Enable ERESI client/server capability" +ERESI_NET="1" +echo "LDDUMPOPT32 = -ldump32" >> $CONFIGFILE +echo "LDDUMPOBJ32 = ../libdump/libdump32.o" >> $CONFIGFILE +echo "LDDUMPOPT64 = -ldump64" >> $CONFIGFILE +echo "LDDUMPOBJ64 = ../libdump/libdump64.o" >> $CONFIGFILE +BITS=$BITS" -DERESI_NET" +;; + +--libasm-ia32) +echo " [*] Libasm IA32 engine" +echo "LIBASM_ENABLE_IA32 = 1" >> $CONFIGFILE +echo "CFLAGS_libasm += -DLIBASM_ENABLE_IA32=1" >> $CONFIGFILE +LIBASM_ENABLE_CHOOSEN=1 +;; + +--libasm-sparc) +echo " [*] Libasm SPARC engine" +echo "LIBASM_ENABLE_SPARC = 1" >> $CONFIGFILE +echo "CFLAGS_libasm += -DLIBASM_ENABLE_SPARC=1" >> $CONFIGFILE +LIBASM_ENABLE_CHOOSEN=1 +;; + +--libasm-mips) +echo " [*] Libasm MIPS engine" +echo "LIBASM_ENABLE_MIPS = 1" >> $CONFIGFILE +echo "CFLAGS_libasm += -DLIBASM_ENABLE_MIPS=1" >> $CONFIGFILE +LIBASM_ENABLE_CHOOSEN=1 +;; + +--libasm-arm) +echo " [*] Libasm ARM engine" +echo "LIBASM_ENABLE_ARM = 1" >> $CONFIGFILE +echo "CFLAGS_libasm += -DLIBASM_ENABLE_ARM=1" >> $CONFIGFILE +LIBASM_ENABLE_CHOOSEN=1 +;; + +--libasm-packed) +LIBASM_PACKED_HANDLERS=1 +;; + +--libasm-unpacked) +LIBASM_PACKED_HANDLERS=0 +;; --enable-testing*) echo " [*] Enable compilation without install" -echo "#define ELFSH_DBGPATH " \"`pwd`/libe2dbg/\" >> $VARSFILE +echo "#define E2DBG_PATH " \"`pwd`/libe2dbg/\" >> $VARSFILE +echo "EXTRACFLAGS += -g3" >> $CONFIGFILE TESTING="1" ;; --enable-readline*) echo " [*] Enabling readline support" READLN="1" + +if [ -z "$GENTOO" ] ; then +TERMCAP="-ltermcap" +else +TERMCAP="" +fi + if [ "${OSNAME}" != OpenBSD ] ; then +echo "READLN = 1" >> $CONFIGFILE echo "READLNOPT = -DUSE_READLN" >> $CONFIGFILE -echo "LDREADLNOPT = -L/opt/sfw/lib/ -lreadline -ltermcap" >> $CONFIGFILE +echo "LDREADLNOPT = -L/opt/sfw/lib/ -lreadline $TERMCAP" >> $CONFIGFILE else -echo "LDREADLNOPT = -lreadline -ltermcap" >> $CONFIGFILE +echo "LDREADLNOPT = -lreadline $TERMCAP" >> $CONFIGFILE fi echo "LDUIOPT32 = -L../libui -lui32" >> $CONFIGFILE echo "LDUIOPT64 = -L../libui -lui64" >> $CONFIGFILE @@ -206,17 +259,22 @@ echo "CC = g++" >> $CONFIGFILE ;; +--no-stackprot*) +echo " [*] Disabling gcc stack protection" +echo "EXTRACFLAGS += -fno-stack-protector" >> $CONFIGFILE +;; + --set-shell*) shift echo " [*] Setting UNIX shell to " $1 -echo "#define ELFSH_SHELL " \"$1\" >> $VARSFILE +echo "#define ERESI_EXTSHELL " \"$1\" >> $VARSFILE SHELLSET="1" ;; --set-editor*) shift echo " [*] Setting editor to " $1 -echo "#define ELFSH_EDITOR " \"$1\" >> $VARSFILE +echo "#define ERESI_EDITOR " \"$1\" >> $VARSFILE EDITORSET="1" ;; @@ -230,21 +288,21 @@ --set-modpath*) shift echo " [*] Setting ELFsh modules path to " $1 -echo "#define ELFSH_MODPATH " \"$1\" >> $VARSFILE +echo "#define ERESI_MODPATH " \"$1\" >> $VARSFILE MODPATHSET="1" ;; --set-lib-path*) shift echo " [*] Setting ELFsh library search path to " $1 -echo "#define ELFSH_LIBPATH " \"$1\" >> $VARSFILE +echo "#define ERESI_LIBPATH " \"$1\" >> $VARSFILE LIBPATHSET="1" ;; --enable-stripped-log*) shift echo " [*] Enable stripped log" -echo "#define ELFSH_SLOG 1" >> $VARSFILE +echo "#define ERESI_SLOG 1" >> $VARSFILE SLOGSET="1"; ;; @@ -261,19 +319,21 @@ echo "#define ARCH \"$arch\"" >> kernsh/include/info.h echo "#define OS \"$os\"" >> kernsh/include/info.h echo "#define RELEASE \"$release\"" >> kernsh/include/info.h + if [ $os = 'Linux' ]; then echo "" > libkernsh/include/libkernsh-info.h echo "#ifndef __LIBKERNSH_INFO_H__" >> libkernsh/include/libkernsh-info.h echo " #define __LIBKERNSH_INFO_H__" >> libkernsh/include/libkernsh-info.h res=`expr match "$release" '2.4.*'` - if [ $res == 8 ]; then + if [ $res = 8 ]; then echo "#define __LINUX_2_4__ 1" >> libkernsh/include/libkernsh-info.h else echo "#define __LINUX_2_4__ 0" >> libkernsh/include/libkernsh-info.h fi echo "" >> libkernsh/include/libkernsh-info.h echo "#endif" >> libkernsh/include/libkernsh-info.h -fi +fi + echo "" >> kernsh/include/info.h echo "#endif" >> kernsh/include/info.h KERNSH="1" @@ -293,7 +353,6 @@ --prefix*) shift -echo " [*] Prefix: " $1 PREFIX=$1 ;; @@ -306,7 +365,7 @@ echo "Invalid configure '$1' option. Try --help." echo rm -f $CONFIGFILE Makefile -exit +exit 1 esac; @@ -314,6 +373,26 @@ done +if [ ! "$LIBASM_ENABLE_CHOOSEN" = 1 ]; +then +echo " [*] Libasm IA32 engine" +echo " [*] Libasm SPARC engine" +echo " [*] Libasm MIPS engine" +echo " [*] Libasm ARM engine" +echo "LIBASM_ENABLE_IA32 = 1" >> $CONFIGFILE +echo "LIBASM_ENABLE_SPARC = 1" >> $CONFIGFILE +echo "LIBASM_ENABLE_MIPS = 1" >> $CONFIGFILE +echo "LIBASM_ENABLE_ARM = 1" >> $CONFIGFILE +fi + +if [ "$LIBASM_PACKED_HANDLERS" != "0" ] ; then +echo " [*] Libasm Packed handlers" +echo "LIBASM_PACKED_HANDLERS = 1" >> $CONFIGFILE +else +echo " [*] Libasm Unpacked handlers" +echo "LIBASM_PACKED_HANDLERS = 0" >> $CONFIGFILE +fi + # # test for make/gmake support # @@ -327,13 +406,13 @@ printHelp fi -#if [ $READLN = "1" -a $ELFSHNET = "1" ]; then -# echo -# echo "Error: Readline and Distributed ELFsh are incompatible." -# echo -# rm -f $CONFIGFILE $VARSFILE -# exit -#fi +if [ $READLN = "1" -a $ERESI_NET = "1" ]; then + echo + echo "Error: Readline and Distributed ELFsh are incompatible." + echo + rm -f $CONFIGFILE $VARSFILE + exit +fi # Now do the OS dependant configuration case `uname` in @@ -353,18 +432,23 @@ Linux*) - echo "RANLIB = ranlib" >> $CONFIGFILE + echo "RANLIB = ranlib" >> $CONFIGFILE + echo "DLOPT = -ldl" >> $CONFIGFILE if [ "$STATIC" = "0" ]; then echo " [*] Enabling dynamic linking." - echo "DLOPT = -ldl" >> $CONFIGFILE echo "DYNOPT = -rdynamic" >> $CONFIGFILE fi -if [ "$ELFSHNET" = "1" ]; then +if [ "$ERESI_NET" = "1" ]; then EXTRAOPT="$EXTRAOPT -lutil" echo "EXTRAOPT = " $EXTRAOPT >> $CONFIGFILE fi +if [ "$PREFIX" = "" ]; then + PREFIX="/usr" +fi + + ;; FreeBSD*) @@ -372,12 +456,17 @@ echo " [*] OS Version: $OSVER" echo "RANLIB = ranlib" >> $CONFIGFILE SHELL="/bin/sh" + + if [ "$PREFIX" = "" ]; then + PREFIX="/usr/local/" + fi + if [ "$STATIC" = "0" ]; then echo " [*] Enabling dynamic linking." echo "DYNOPT = -rdynamic" >> $CONFIGFILE fi -if [ "$ELFSHNET" = "1" ]; then +if [ "$ERESI_NET" = "1" ]; then EXTRAOPT="$EXTRAOPT -lutil" echo "EXTRAOPT = " $EXTRAOPT >> $CONFIGFILE fi @@ -386,9 +475,7 @@ LPTHREAD="-lc_r" fi -echo "#define ELFSH_MODPATH \"/usr/local/share/elfsh/\" " >> $VARSFILE - -MODPATHSET="1"; +MODPATHSET="0"; FREEBSD="1"; ;; @@ -412,10 +499,10 @@ ;; IRIX*) - echo "#define ELFSH_SHELL \"/usr/freeware/bin/bash\"" >> $VARSFILE + echo "#define ERESI_EXTSHELL \"/usr/freeware/bin/bash\"" >> $VARSFILE if [ "$SHELLSET" != "1" ]; then - echo "#define ELFSH_SHELL \"/usr/freeware/bin/bash\"" >> $VARSFILE + echo "#define ERESI_EXTSHELL \"/usr/freeware/bin/bash\"" >> $VARSFILE SHELLSET="1" fi SHELL="/usr/freeware/bin/bash" @@ -424,6 +511,14 @@ echo "CC = gcc" >> $CONFIGFILE ;; +Haiku*|BeOS*) + SHELL="/bin/sh" + echo "#define BEOS 1" >> $LIBVARSFILE + echo "RANLIB = ranlib" >> $CONFIGFILE + LPTHREAD="" + BEOS=1; +;; + *) if [ "$STATIC" = "0" ]; then @@ -431,52 +526,49 @@ echo "DYNOPT = -rdynamic" >> $CONFIGFILE fi -if [ "$ELFSHNET" = "1" ]; then +if [ "$ERESI_NET" = "1" ]; then EXTRAOPT="$EXTRAOPT -lutil" echo "EXTRAOPT = " $EXTRAOPT >> $CONFIGFILE fi ;; - esac - # Set default variables in case it was not precised if [ "$MODPATHSET" != "1" ]; then - echo "#define ELFSH_MODPATH \"/usr/local/share/elfsh/\"" >> $VARSFILE + echo "#define ERESI_MODPATH \"$BASEPATH/share/eresi/\"" >> $VARSFILE fi if [ "$LIBPATHSET" != "1" ]; then - echo "#define ELFSH_LIBPATH \"/lib;/usr/lib;/usr/local/lib\"" >> $VARSFILE + echo "#define ERESI_LIBPATH \"/lib;/usr/lib;/usr/local/lib:$BASEPATH/lib/\"" >> $VARSFILE fi if [ "$TESTING" != "1" ]; then - echo "#define ELFSH_DBGPATH \"$PREFIX/usr/local/lib/\"" >> $VARSFILE + echo "#define E2DBG_PATH \"$BASEPATH/lib/\"" >> $VARSFILE fi if [ "$SLOGSET" != "1" ]; then - echo "#define ELFSH_SLOG 0" >> $VARSFILE + echo "#define ERESI_SLOG 0" >> $VARSFILE fi if [ "$SHELLSET" != "1" ]; then - echo "#define ELFSH_SHELL \"/bin/bash\"" >> $VARSFILE + echo "#define ERESI_EXTSHELL \"/bin/bash\"" >> $VARSFILE fi if [ "$EDITORSET" != "1" ]; then - echo "#define ELFSH_EDITOR \"emacs\"" >> $VARSFILE + echo "#define ERESI_EDITOR \"emacs\"" >> $VARSFILE fi if [ "$BUILDOP" != "1" ]; then echo "BUILDOP = -DM32" >> $CONFIGFILE fi +echo " [*] Prefix: " $PREFIX + echo " [*] Enabling libasm support" echo "LDASMOPT = -lasm" >> $CONFIGFILE - echo "LPTHREAD= $LPTHREAD" >> $CONFIGFILE - -## Save BITS= echo "BITS = " $BITS >> $CONFIGFILE echo "SHELL= " $SHELL >> $CONFIGFILE @@ -488,14 +580,6 @@ echo "KERNSHINCINC = -I../../libkernsh/include" >> $CONFIGFILE fi -#case "$(uname -m)" in -#i686) -#LOCALBITS=32 -#*) -#LOCALBITS=32 -#;;; -#esac - echo "##" > Makefile echo "## Makefile " >> Makefile echo "## " >> Makefile @@ -507,39 +591,53 @@ echo "" >> Makefile echo "CC = gcc " >> Makefile echo "RM = rm -f " >> Makefile -echo "ETAGS = etags " >> Makefile +if which etags 2>/dev/null; then + echo "ETAGS = etags " >> Makefile +elif which etags.emacs 2>/dev/null; then + echo "ETAGS = etags.emacs " >> Makefile +fi + echo "CTAGS = ctags " >> Makefile echo "DESTDIR = $PREFIX" >> Makefile echo "BUILD_TARGET = $BUILD_TARGET" >> Makefile echo "MOD_TARGET = $MOD_TARGET" >> Makefile if [ "$FREEBSD" = "1" ]; then -echo "BASEPATH = \$(DESTDIR)/usr/local" >> Makefile +echo "BASEPATH = \$(DESTDIR)/" >> Makefile +echo "MANPATH = \$(BASEPATH)/man" >> Makefile + +elif [ "$BEOS" = "1" ]; then +echo "BASEPATH = \$(DESTDIR)/" >> Makefile echo "MANPATH = \$(BASEPATH)/man" >> Makefile + else -echo "BASEPATH = \$(DESTDIR)/usr/local" >> Makefile +echo "BASEPATH = \$(DESTDIR)/" >> Makefile echo "MANPATH = \$(BASEPATH)/share/man" >> Makefile fi echo "MODPATH = \$(BASEPATH)/share/elfsh/" >> Makefile echo "BINPATH = \$(BASEPATH)/bin/" >> Makefile echo "LIBPATH = \$(BASEPATH)/lib/" >> Makefile -echo "#define LIBPATH \"$PREFIX/usr/local/lib/\"" >> $VARSFILE + +echo "#define LIBPATH \"$PREFIX/lib/\"" >> $VARSFILE + echo "INCPATH = \$(BASEPATH)/include/" >> Makefile echo "RM = rm -f " >> Makefile echo "" >> Makefile -echo "all : world modules tags" >> Makefile +echo "all : world modules testsuite tags" >> Makefile cat >> Makefile <> Makefile echo " @echo 'Building libasm...' " >> Makefile echo " @cd libasm && sh configure " >> Makefile -echo " @cd libasm && \$(MAKE) " >> Makefile +echo " @cd libasm && \$(MAKE) \$(BUILD_TARGET)" >> Makefile echo " @echo 'Libasm has been built successfully.' " >> Makefile + if [ "$KERNSH" = "1" ]; then echo " @echo 'Building libkernsh...' " >> Makefile echo " @cd libkernsh && \$(MAKE) \$(BUILD_TARGET) " >> Makefile echo " @echo 'Libkernsh has been built successfully.' " >> Makefile fi + echo " @echo 'Building libelfsh...' " >> Makefile echo " @cd libelfsh && \$(MAKE) \$(BUILD_TARGET)" >> Makefile echo " @echo 'Libelfsh has been built successfully.' " >> Makefile echo " @echo 'Building libetrace...' " >> Makefile echo " @cd libetrace && \$(MAKE) \$(BUILD_TARGET)" >> Makefile -echo " @echo 'Libetrace has been built successfully.' " >> Makefile +echo " @echo 'Libetrace has been built successfully.' " >> Makefile echo " @echo 'Building libedfmt...' " >> Makefile echo " @cd libedfmt && \$(MAKE) \$(BUILD_TARGET) " >> Makefile echo " @echo 'Libedfmt has been built successfully.' " >> Makefile -if [ "$ELFSHNET" = "1" ]; then +if [ "$ERESI_NET" = "1" ]; then echo " @echo 'Building libdump...' " >> Makefile -echo " @cd libdump && \$(MAKE) -s " >> Makefile +echo " @cd libdump && \$(MAKE) \$(BUILD_TARGET)" >> Makefile echo " @echo 'Libdump has been built successfully.' " >> Makefile fi @@ -595,12 +695,12 @@ # If we compiled librevm with readline, we need to compile it a second # time without it, to be linked with libe2dbg in the embedded debugger if [ "$READLN" = "1" ]; then -# echo " test -f config.h && cp config.h config.back" >> Makefile -# echo " cat $CONFIGFILE | grep -v READLN > t && mv t $CONFIGFILE" >> Makefile -# echo " @echo 'Rebuilding librevm/io/ without readline'">> Makefile -# echo " @cd librevm/io/ && \$(MAKE) clean " >> Makefile + echo " test -f config.h && cp config.h config.back" >> Makefile + echo " cat $CONFIGFILE | grep -v READLN > t && mv t $CONFIGFILE" >> Makefile + echo " @echo 'Rebuilding librevm/io/ without readline'">> Makefile + echo " @cd librevm/io/ && \$(MAKE) clean " >> Makefile echo " @cd librevm/io/ && \$(MAKE) \$(BUILD_TARGET) " >> Makefile -# echo " cp config.back config.h" >> Makefile + echo " cp config.back config.h" >> Makefile echo " @echo 'Librevm has been rebuilt successfully.'" >> Makefile fi @@ -632,6 +732,16 @@ echo " @echo 'Evarista has been built successfully.' " >> Makefile echo "" >> Makefile +echo " @echo 'Building libgdbwrap' " >> Makefile +echo " @cd libgdbwrap && \$(MAKE) \$(BUILD_TARGET) " >> Makefile +echo " @echo 'libgdbwrap has been built successfully.' " >> Makefile +echo "" >> Makefile + +echo " @echo 'Building Kedbg' " >> Makefile +echo " @cd kedbg && \$(MAKE) \$(BUILD_TARGET) " >> Makefile +echo " @echo 'Kedbg has been built successfully.' " >> Makefile +echo "" >> Makefile + if [ "$KERNSH" = "1" ]; then echo " @echo 'Building kernsh...' " >> Makefile echo " @cd kernsh && \$(MAKE) \$(BUILD_TARGET) " >> Makefile @@ -641,13 +751,34 @@ if [ ! -e ~/.eresirc ]; then echo " @cp doc/eresirc.example ~/.eresirc " >> Makefile fi +if [ ! -e ~/.elfshrc ]; then +echo " @ln -sf ~/.eresirc ~/.elfshrc" >> Makefile +fi +if [ ! -e ~/.e2dbgrc ]; then +echo " @ln -sf ~/.eresirc ~/.e2dbgrc" >> Makefile +fi +if [ ! -e ~/.etracerc ]; then +echo " @ln -sf ~/.eresirc ~/.etracerc" >> Makefile +fi +if [ ! -e ~/.kernshrc ]; then +echo " @ln -sf ~/.eresirc ~/.kernshrc" >> Makefile +fi echo ".PHONY: modules " >> Makefile echo "modules: " >> Makefile -echo "# @echo 'Building ELFsh modules suite...' " >> Makefile -echo "# @cd modules && \$(MAKE) " >> Makefile -echo "# @echo 'ELFsh modules suite built successfully.' " >> Makefile +echo " @echo 'Building ERESI modules...' " >> Makefile +echo " @cd modules && \$(MAKE) -s \$(BUILD_TARGET)" >> Makefile +echo " @echo 'ERESI modules built successfully.' " >> Makefile + +if [ "$TESTING" = "1" ]; then echo "" >> Makefile +echo ".PHONY: testsuite " >> Makefile +echo "testsuite:" >> Makefile +echo " \$(shell source env.sh)" >> Makefile +echo " @echo 'Building ERESI testsuite...' " >> Makefile +echo " cd testsuite && \$(MAKE) -s \$(BUILD_TARGET)" >> Makefile +echo " @echo 'ERESI testsuite built successfully.' " >> Makefile +fi if [ "$TESTING" = "1" ]; then echo " @echo" >> Makefile @@ -661,14 +792,25 @@ echo " @ln -sf \$(BINPATH)e2dbg64 \$(BINPATH)e2dbg" >> Makefile echo " @ln -sf \$(BINPATH)etrace64 \$(BINPATH)etrace" >> Makefile echo " @ln -sf \$(BINPATH)evarista64 \$(BINPATH)evarista" >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @ln -sf \$(BINPATH)kernsh64 \$(BINPATH)kernsh" >> Makefile +fi +echo " @ln -sf \$(BINPATH)kedbg64 \$(BINPATH)kedbg" >> Makefile +echo " @ln -sf \$(BINPATH)eresi-config64 \$(BINPATH)eresi-config" >> Makefile + echo " @ln -sf \$(LIBPATH)libaspect64.a \$(LIBPATH)libaspect.a" >> Makefile echo " @ln -sf \$(LIBPATH)libelfsh64.a \$(LIBPATH)libelfsh.a" >> Makefile +echo " @ln -sf \$(LIBPATH)libetrace64.a \$(LIBPATH)libetrace.a " >> Makefile echo " @ln -sf \$(LIBPATH)libe2dbg64.a \$(LIBPATH)libe2dbg.a" >> Makefile echo " @ln -sf \$(LIBPATH)libmjollnir64.a \$(LIBPATH)libmjollnir.a" >> Makefile echo " @ln -sf \$(LIBPATH)librevm64.a \$(LIBPATH)librevm.a" >> Makefile echo " @ln -sf \$(LIBPATH)libstderesi64.a \$(LIBPATH)libstderesi.a" >> Makefile echo " @ln -sf \$(LIBPATH)libedfmt64.a \$(LIBPATH)libedfmt.a" >> Makefile echo " @ln -sf \$(LIBPATH)libui64.a \$(LIBPATH)libui.a" >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @ln -sf \$(LIBPATH)libkernsh64.a \$(LIBPATH)libkernsh.a" >> Makefile +fi +echo " @ln -sf \$(LIBPATH)libgdbwrap64.a \$(LIBPATH)libgdbwrap.a" >> Makefile echo " @ln -sf \$(LIBPATH)libaspect64.so \$(LIBPATH)libaspect.so" >> Makefile echo " @ln -sf \$(LIBPATH)libelfsh64.so \$(LIBPATH)libelfsh.so" >> Makefile @@ -679,18 +821,32 @@ echo " @ln -sf \$(LIBPATH)libstderesi64.so \$(LIBPATH)libstderesi.so" >> Makefile echo " @ln -sf \$(LIBPATH)libedfmt64.so \$(LIBPATH)libedfmt.so" >> Makefile echo " @ln -sf \$(LIBPATH)libui64.so \$(LIBPATH)libui.so" >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @ln -sf \$(LIBPATH)libkernsh64.so \$(LIBPATH)libkernsh.so" >> Makefile +fi +echo " @ln -sf \$(LIBPATH)libgdbwrap64.so \$(LIBPATH)libgdbwrap.so" >> Makefile echo "install : prepareDir #mod_install " >> Makefile echo " @cp elfsh/elfsh?? \$(BINPATH)/ " >> Makefile echo " @cp e2dbg/e2dbg?? \$(BINPATH)/ " >> Makefile echo " @cp etrace/etrace?? \$(BINPATH)/ " >> Makefile echo " @cp evarista/evarista?? \$(BINPATH)/ " >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @cp kernsh/kernsh?? \$(BINPATH)/ " >> Makefile +fi +echo " @cp kedbg/kedbg?? \$(BINPATH)/ " >> Makefile +echo " @cp eresi-config?? \$(BINPATH)/ " >> Makefile + +if [ "$KERNSH" = "1" ]; then +echo " @cp libkernsh/libkernsh*.a libkernsh/libkernsh*.so \$(LIBPATH) " >> Makefile +fi +echo " @cp libgdbwrap/libgdbwrap*.a libgdbwrap/libgdbwrap*.so \$(LIBPATH) " >> Makefile echo " @cp libaspect/libaspect*.a libaspect/libaspect*.so \$(LIBPATH) " >> Makefile echo " @cp liballocproxy/liballocproxy.a \$(LIBPATH) " >> Makefile echo " @cp libelfsh/libelfsh*.a libelfsh/libelfsh*.so \$(LIBPATH) " >> Makefile echo " @cp libetrace/libetrace*.a libetrace/libetrace*.so \$(LIBPATH) " >> Makefile echo " @cp libe2dbg/libe2dbg*.a libe2dbg/libe2dbg*.so \$(LIBPATH) " >> Makefile -echo " @cp libasm/libasm.a libasm/libasm.so \$(LIBPATH) " >> Makefile +echo " @cp libasm/libasm*.a libasm/libasm*.so \$(LIBPATH) " >> Makefile echo " @cp libmjollnir/libmjollnir*.a \$(LIBPATH) " >> Makefile echo " @cp libmjollnir/libmjollnir*.so \$(LIBPATH) " >> Makefile echo " @cp librevm/librevm*.a librevm/librevm*.so \$(LIBPATH)" >> Makefile @@ -703,13 +859,17 @@ echo " @cp kernsh/kernsh?? \$(BINPATH)/ " >> Makefile fi - # Create links echo " @ln -sf \$(BINPATH)elfsh32 \$(BINPATH)elfsh" >> Makefile echo " @ln -sf \$(BINPATH)e2dbg32 \$(BINPATH)e2dbg" >> Makefile echo " @ln -sf \$(BINPATH)etrace32 \$(BINPATH)etrace" >> Makefile -echo " @ln -sf \$(BINPATH)evarista32 \$(BINPATH)evarista" >> Makefile -echo " @ln -sf \$(BINPATH)kernsh32 \$(BINPATH)kernsh" >> Makefile +echo " @ln -sf \$(BINPATH)evarista32 \$(BINPATH)evarista" >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @ln -sf \$(BINPATH)kernsh32 \$(BINPATH)kernsh" >> Makefile +fi +echo " @ln -sf \$(BINPATH)kedbg32 \$(BINPATH)kedbg" >> Makefile +echo " @ln -sf \$(BINPATH)eresi-config32 \$(BINPATH)eresi-config" >> Makefile + echo " @ln -sf \$(LIBPATH)libaspect32.a \$(LIBPATH)libaspect.a" >> Makefile echo " @ln -sf \$(LIBPATH)libelfsh32.a \$(LIBPATH)libelfsh.a" >> Makefile echo " @ln -sf \$(LIBPATH)libetrace32.a \$(LIBPATH)libetrace.a" >> Makefile @@ -719,17 +879,24 @@ echo " @ln -sf \$(LIBPATH)libstderesi32.a \$(LIBPATH)libstderesi.a" >> Makefile echo " @ln -sf \$(LIBPATH)libedfmt32.a \$(LIBPATH)libedfmt.a" >> Makefile echo " @ln -sf \$(LIBPATH)libui32.a \$(LIBPATH)libui.a" >> Makefile +if [ "$KERNSH" = "1" ]; then +echo " @ln -sf \$(LIBPATH)libkernsh32.a \$(LIBPATH)libkernsh.a" >> Makefile +fi +echo " @ln -sf \$(LIBPATH)libgdbwrap32.a \$(LIBPATH)libgdbwrap.a" >> Makefile + echo " @ln -sf \$(LIBPATH)libaspect32.so \$(LIBPATH)libaspect.so" >> Makefile echo " @ln -sf \$(LIBPATH)libelfsh32.so \$(LIBPATH)libelfsh.so" >> Makefile -echo " @ln -sf \$(LIBPATH)libetrace32.so \$(LIBPATH)libetrace.so" >> Makefile +echo " @ln -sf \$(LIBPATH)libetrace32.so \$(LIBPATH)libetrace.so" >> Makefile echo " @ln -sf \$(LIBPATH)libe2dbg32.so \$(LIBPATH)libe2dbg.so" >> Makefile echo " @ln -sf \$(LIBPATH)libmjollnir32.so \$(LIBPATH)libmjollnir.so" >> Makefile echo " @ln -sf \$(LIBPATH)librevm32.so \$(LIBPATH)librevm.so" >> Makefile echo " @ln -sf \$(LIBPATH)libstderesi32.so \$(LIBPATH)libstderesi.so" >> Makefile echo " @ln -sf \$(LIBPATH)libedfmt32.so \$(LIBPATH)libedfmt.so" >> Makefile echo " @ln -sf \$(LIBPATH)libui32.so \$(LIBPATH)libui.so" >> Makefile -echo " @ln -sf \$(LIBPATH)libkernsh32.a \$(LIBPATH)libkernsh.a" >> Makefile +if [ "$KERNSH" = "1" ]; then echo " @ln -sf \$(LIBPATH)libkernsh32.so \$(LIBPATH)libkernsh.so" >> Makefile +fi +echo " @ln -sf \$(LIBPATH)libgdbwrap32.so \$(LIBPATH)libgdbwrap.so" >> Makefile # Install headers echo " @cp -R libelfsh/include/* \$(INCPATH) " >> Makefile @@ -775,7 +942,7 @@ echo " @chmod 644 \$(INCPATH)libui.h " >> Makefile echo " @chmod 644 \$(INCPATH)libelfsh*.h " >> Makefile echo " @chmod 644 \$(LIBPATH)libelfsh*.a " >> Makefile -echo " @chmod 644 \$(LIBPATH)libasm.a " >> Makefile +echo " @chmod 644 \$(LIBPATH)libasm*.a " >> Makefile echo " @chmod 644 \$(INCPATH)libedfmt*.h " >> Makefile echo " @chmod 644 \$(INCPATH)libasm*.h " >> Makefile echo " @chmod 644 \$(INCPATH)libmjollnir.h " >> Makefile @@ -810,6 +977,8 @@ echo " rm -f \$(BINPATH)/e2dbg*" >> Makefile echo " rm -f \$(BINPATH)/etrace*" >> Makefile echo " rm -f \$(BINPATH)/evarista*" >> Makefile +echo " rm -f \$(BINPATH)/eresi-config*" >> Makefile +echo " rm -f \$(BINPATH)/kedbg*" >> Makefile echo " rm -f \$(LIBPATH)/libelfsh*" >> Makefile echo " rm -f \$(LIBPATH)/libetrace*" >> Makefile echo " rm -f \$(LIBPATH)/libe2dbg*" >> Makefile @@ -821,17 +990,22 @@ echo " rm -f \$(LIBPATH)/libstderesi*" >> Makefile echo " rm -f \$(LIBPATH)/libedfmt*" >> Makefile echo " rm -f \$(LIBPATH)/libasm*" >> Makefile +echo " rm -f \$(LIBPATH)/libgdbwrap*" >> Makefile echo " rm -f \$(LIBPATH)/libmalloc-e2dbg*" >> Makefile echo " rm -fr \$(MODPATH) " >> Makefile echo " rm -f \$(MANPATH)/man1/elfsh.1 " >> Makefile echo " rm -f \$(INCPATH)/libasm*.h " >> Makefile echo " rm -f \$(INCPATH)/libmjollnir*.h " >> Makefile echo " rm -f \$(INCPATH)/libui.h " >> Makefile +echo " rm -f \$(INCPATH)/aproxy.h " >> Makefile echo " rm -fr \$(INCPATH)/libelfsh*" >> Makefile echo " rm -fr \$(INCPATH)/libaspect*" >> Makefile echo " rm -fr \$(INCPATH)/librevm*" >> Makefile echo " rm -fr \$(INCPATH)/libstderesi*" >> Makefile echo " rm -fr \$(INCPATH)/libedfmt*" >> Makefile +echo " rm -fr \$(INCPATH)/libetrace*" >> Makefile +echo " rm -fr \$(INCPATH)/revm*" >> Makefile +echo " rm -f \$(INCPATH)/libvars.h" >> Makefile if [ "$KERNSH" = "1" ]; then echo " rm -f \$(BINPATH)/kernsh*" >> Makefile echo " rm -f \$(LIBPATH)/libkernsh*" >> Makefile @@ -849,6 +1023,8 @@ echo " cd e2dbg && \$(MAKE) -s clean " >> Makefile echo " cd etrace && \$(MAKE) -s clean " >> Makefile echo " cd evarista && \$(MAKE) -s clean " >> Makefile +echo " cd libgdbwrap && \$(MAKE) -s clean " >> Makefile +echo " cd kedbg && \$(MAKE) -s clean " >> Makefile if [ "$KERNSH" = "1" ]; then echo " cd kernsh && \$(MAKE) -s clean" >> Makefile echo " cd libkernsh && \$(MAKE) -s clean" >> Makefile @@ -867,6 +1043,7 @@ echo " cd liballocproxy && \$(MAKE) -s clean " >> Makefile echo " cd libdump && \$(MAKE) -s clean " >> Makefile echo " cd modules && \$(MAKE) -s clean " >> Makefile +echo " cd testsuite && \$(MAKE) -s clean " >> Makefile echo " @echo 'Tree cleaned .' " >> Makefile echo "" >> Makefile @@ -876,6 +1053,7 @@ echo " cd e2dbg && \$(MAKE) -s fclean " >> Makefile echo " cd etrace && \$(MAKE) -s fclean " >> Makefile echo " cd evarista && \$(MAKE) -s fclean " >> Makefile +echo " cd kedbg && \$(MAKE) -s fclean " >> Makefile if [ "$KERNSH" = "1" ]; then echo " cd kernsh && \$(MAKE) -s fclean" >> Makefile echo " cd libkernsh && \$(MAKE) -s fclean" >> Makefile @@ -893,6 +1071,7 @@ echo " cd libmjollnir && \$(MAKE) -s fclean " >> Makefile echo " cd libdump && \$(MAKE) -s fclean " >> Makefile echo " cd libui && \$(MAKE) -s fclean " >> Makefile +echo " cd libgdbwrap && \$(MAKE) -s fclean " >> Makefile echo " cd modules && \$(MAKE) -s fclean " >> Makefile echo " cd testsuite && \$(MAKE) -s fclean " >> Makefile @@ -911,20 +1090,27 @@ if [ "$ETAGS" = "1" ]; then echo " @\$(ETAGS) elfsh/*.c elfsh/include/*.h libelfsh/*.c \\" >> Makefile echo " libelfsh/include/*.h e2dbg/include/*.h \\" >> Makefile -echo " libetrace/*.c libetrace/include/*.h \\" >> Makefile +echo " libetrace/*.c libetrace/include/*.h \\" >> Makefile echo " modules/*.c liballocproxy/*.c libdump/*.c e2dbg/*.c \\" >> Makefile echo " libasm/src/*.c liballocproxy/include/*.h \\" >> Makefile echo " libaspect/*.c libe2dbg/*/*.c libaspect/include/*.h \\" >> Makefile echo " librevm/*/*.c librevm/include/*.h libe2dbg/include/*.h \\" >> Makefile echo " libedfmt/*.c libedfmt/include/*.h \\" >> Makefile echo " libasm/src/arch/ia32/*.c libmjollnir/src/*.c \\" >> Makefile -echo " libasm/include/*.h libui/*.c libui/include/*.h \\" >> Makefile +echo " libasm/src/arch/arm/*.c libasm/src/arch/sparc/*.c \\" >> Makefile +echo " libasm/src/arch/mips/*.c libasm/include/*.h \\" >> Makefile +echo " libui/*.c libui/include/*.h \\" >> Makefile echo " libdump/include/*.h libmjollnir/include/*.h \\" >> Makefile echo " etrace/*.c evarista/*.c libstderesi/*/*.c \\" >> Makefile echo " libstderesi/include/*.h \\" >> Makefile +echo " libgdbwrap/include/*.h \\" >> Makefile +echo " libgdbwrap/*.c \\" >> Makefile +echo " kedbg/include/*.h \\" >> Makefile +echo " kedbg/*.c \\" >> Makefile + if [ "$KERNSH" = "1" ]; then echo " kernsh/*.c kernsh/include/*.h \\" >> Makefile -echo " libkernsh/*.c libkernsh/include/*.h \\" >> Mafefile +echo " libkernsh/*/*.c libkernsh/include/*.h \\" >> Makefile fi echo " etrace/include/*.h evarista/include/*.h " >> Makefile fi @@ -950,9 +1136,14 @@ echo " libui/*.c libui/include/*.h \\" >> Makefile echo " elfsh/*.c elfsh/include/*.h \\" >> Makefile echo " etrace/*.c etrace/include/*.h \\" >> Makefile +echo " libgdbwrap/include/*.h \\" >> Makefile +echo " libgdbwrap/*.c \\" >> Makefile +echo " kedbg/include/*.h \\" >> Makefile +echo " kedbg/*.c \\" >> Makefile + if [ "$KERNSH" = "1" ]; then echo " kernsh/*.c kernsh/include/*.h \\" >> Makefile -echo " libkernsh/*.c libkernsh/include/*.h \\" >> Mafefile +echo " libkernsh/*.c libkernsh/include/*.h \\" >> Makefile fi echo " evarista/*.c evarista/include/*.h " >> Makefile echo "" >> Makefile @@ -964,6 +1155,7 @@ echo " libetrace/*.c libetrace/include/*.h \\" >> Makefile echo " elfsh/include/*.h modules/*.c libasm/src/*.c \\" >> Makefile echo " libasm/src/arch/*/*.c e2dbg/*.c e2dbg/include/*.h \\" >> Makefile +echo " libasm/src/arch/*/*/*.c \\" >> Makefile echo " libaspect/*.c libmjollnir/src/*.c libaspect/*/*.h \\" >> Makefile echo " librevm/*/*.c librevm/include/*.h libdump/*.c \\" >> Makefile echo " libstderesi/*/*.c libstderesi/include/*.h \\" >> Makefile @@ -988,8 +1180,8 @@ echo " @echo '#############' LIBE2DBG ONLY '#######'" >> Makefile echo " @wc -l libe2dbg/*/*.c " >> Makefile echo " @echo '###############' LIBASM ONLY '##########'" >> Makefile -echo " @wc -l libasm/src/*.c libasm/src/arch/ia32/*.c \\" >> Makefile -echo " libasm/src/arch/sparc/*.c" >> Makefile +echo " @wc -l libasm/src/*.c libasm/src/arch/*/*.c \\" >> Makefile +echo " libasm/src/arch/*/*/*.c " >> Makefile echo " @echo '###############' LIBMJOLLNIR ONLY '##########'" >> Makefile echo " @wc -l libmjollnir/src/*.c " >> Makefile echo " @echo '###############' LIBREVM ONLY '##########'" >> Makefile @@ -1017,14 +1209,14 @@ echo "docs:" >> Makefile echo " doxygen doc/doxygen.conf" >> Makefile echo " #(cd libasm && \$(MAKE) docs)" >> Makefile -echo " #(cd libelfsh && \$(MAKE) docs)" >> Makefile +echo " #(cd libelfsh && \$(MAKE) docs)" >> Makefile echo " #(cd librevm && \$(MAKE) docs)" >> Makefile -echo " #(cd libstderesi && \$(MAKE) docs)" >> Makefile -echo " #(cd libmjollnir && \$(MAKE) docs)" >> Makefile +echo " #(cd libstderesi && \$(MAKE) docs)" >> Makefile +echo " #(cd libmjollnir && \$(MAKE) docs)" >> Makefile echo " #(cd libui && \$(MAKE) docs)" >> Makefile -echo " #(cd libedfmt && \$(MAKE) docs)" >> Makefile +echo " #(cd libedfmt && \$(MAKE) docs)" >> Makefile if [ "$KERNSH" = "1" ]; then -echo " #(cd libkernsh && \$(MAKE) docs)" >> Makefile +echo " #(cd libkernsh && \$(MAKE) docs)" >> Makefile fi echo echo " Now make && make install" diff -Nru eresi-0.8a25/debian/changelog eresi-0.0.20110516/debian/changelog --- eresi-0.8a25/debian/changelog 2011-05-16 12:00:54.000000000 +0000 +++ eresi-0.0.20110516/debian/changelog 2011-05-16 12:00:55.000000000 +0000 @@ -1,3 +1,15 @@ +eresi (0.0.20110516-0~rzr2) oneiric; urgency=low + + * + + -- Philippe Coval Mon, 16 May 2011 13:46:59 +0200 + +eresi (0.0.20110516-0~rzr1) natty; urgency=low + + * New upstream release + + -- Philippe Coval Mon, 16 May 2011 13:45:18 +0200 + eresi (1:0.8a25-3) unstable; urgency=low * debian/paches/01_fix_gcc4.4.dpatch: diff -Nru eresi-0.8a25/doc/AUTHOR eresi-0.0.20110516/doc/AUTHOR --- eresi-0.8a25/doc/AUTHOR 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/AUTHOR 2011-05-16 11:34:14.000000000 +0000 @@ -1,8 +1,12 @@ -The ERESI team +The ERESI team : - Julien Vanegue - Sebastien Roy -- Thomas Garnier -- Julien Auto - Rafal Lesniak +- Julien Auto +- Thomas Garnier +- Anthony Desnos +- Adam Zabrocki +- Sebastien Soudan +- Rafal Wojtczuk diff -Nru eresi-0.8a25/doc/ERESI.NEWHOOKS eresi-0.0.20110516/doc/ERESI.NEWHOOKS --- eresi-0.8a25/doc/ERESI.NEWHOOKS 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/doc/ERESI.NEWHOOKS 2011-05-16 11:34:14.000000000 +0000 @@ -0,0 +1,35 @@ + +Those are the new hooks to be created in LIBELFSH: + +MEMALLOC (u_int size, eresi_Addr*) (libelfsh) +-------- + + KERNEL USER + +LINUX kernsh_alloc elfsh_runtime_map_unix +BSD / elfsh_runtime_map_unix +SOLARIS / elfsh_runtime_map_unix +IRIX / elfsh_runtime_map_irix + + +MPROTECT (eresi_Addr addr, uint32_t size, int prot) (libelfsh) +-------- + + KERNEL USER + +LINUX empty elfsh_mprotect +BSD empty elfsh_mprotect +SOLARIS empty elfsh_mprotect +IRIX empty elfsh_mprotect + + +MUNPROTECT (elfshobj_t *file, eresi_Addr addr, uint32_t size) (libelfsh) +-------- + + KERNEL USER + +LINUX empty elfsh_munprotect +BSD empty elfsh_munprotect +SOLARIS empty elfsh_munprotect +IRIX empty elfsh_munprotect + diff -Nru eresi-0.8a25/doc/KERNSH.bugs eresi-0.0.20110516/doc/KERNSH.bugs --- eresi-0.8a25/doc/KERNSH.bugs 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/doc/KERNSH.bugs 2011-05-16 11:34:14.000000000 +0000 @@ -0,0 +1,18 @@ + +- iskernel flag dans le elfshobj_t nest jamais sette ! + +- openmem devrait etre appele automatiquement. + +- Les symboles devraient etre injectes automatiquement en lisant le System.map. + +- faire les hooks alloc, mprotect, munprotect dans libelfsh + +- les handlers readmema ne sont pas prevus pour economiser +la memoire (buf = NULL en static mode) et segfault si buf = NULL. + +- reladd ne fonctionne pas sur vmlinuz car cest un ET_REL + +- kern_disasm devrait etre remplace par la commande D + +- la commande sym segfault sur le vmlinuz decompresse + diff -Nru eresi-0.8a25/doc/.svn/all-wcprops eresi-0.0.20110516/doc/.svn/all-wcprops --- eresi-0.8a25/doc/.svn/all-wcprops 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,143 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 27 -/svn/!svn/ver/928/trunk/doc -END -libelfsh.i -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/297/trunk/doc/libelfsh.i -END -libelfsh-ref.txt -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/3/trunk/doc/libelfsh-ref.txt -END -LICENSE -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/12/trunk/doc/LICENSE -END -HOWTO-port-elfsh-0.7a2.txt -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/231/trunk/doc/HOWTO-port-elfsh-0.7a2.txt -END -VERSION -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/846/trunk/doc/VERSION -END -eresirc.example -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/722/trunk/doc/eresirc.example -END -Changelog -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/242/trunk/doc/Changelog -END -graphers.txt -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/3/trunk/doc/graphers.txt -END -elfsh-ref.txt -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/3/trunk/doc/elfsh-ref.txt -END -header.html -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/896/trunk/doc/header.html -END -CREDITS -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/21/trunk/doc/CREDITS -END -footer.html -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/896/trunk/doc/footer.html -END -ERESI-coding_style-README.txt -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/847/trunk/doc/ERESI-coding_style-README.txt -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/928/trunk/doc/doxygen.conf -END -AUTHOR -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/785/trunk/doc/AUTHOR -END -elfsh-network-0.3.txt -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/21/trunk/doc/elfsh-network-0.3.txt -END -TODO -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/221/trunk/doc/TODO -END -eresi.1 -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/796/trunk/doc/eresi.1 -END -HOWTO-port-ERESI-0.8.txt -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/797/trunk/doc/HOWTO-port-ERESI-0.8.txt -END -rtld-multiarch.txt -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/21/trunk/doc/rtld-multiarch.txt -END -cerberus2.txt -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/21/trunk/doc/cerberus2.txt -END -libasm_TODO.txt -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/12/trunk/doc/libasm_TODO.txt -END -elfsh-draft.txt -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/3/trunk/doc/elfsh-draft.txt -END diff -Nru eresi-0.8a25/doc/.svn/entries eresi-0.0.20110516/doc/.svn/entries --- eresi-0.8a25/doc/.svn/entries 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,306 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/doc -http://svn.eresi-project.org/svn - - - -2008-03-24T21:14:05.011662Z -928 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libelfsh.i -file - - - - -2008-04-06T23:15:52.082886Z -facf581337c368ebff3a73f8ac4d5517 -2006-12-27T17:21:57.000000Z -297 -may -has-props - -libelfsh-ref.txt -file - - - - -2008-04-06T23:15:52.103897Z -3eaaae3f64fcfff587a99bf99c9cc407 -2003-08-21T01:13:15.000000Z -3 -thor - -LICENSE -file - - - - -2008-04-06T23:15:52.115175Z -393a5ca445f6965873eca0259a17f833 -2005-08-02T06:43:53.000000Z -12 -thor - -HOWTO-port-elfsh-0.7a2.txt -file - - - - -2008-04-06T23:15:52.126974Z -c1cffaff7bcccae988c2203a91ca96c0 -2006-10-28T21:10:20.000000Z -231 -may - -VERSION -file - - - - -2008-04-06T23:15:52.138184Z -c8c40e3dd26cba2e8cd9500c8ec989d4 -2008-02-19T15:23:40.424997Z -846 -thorkill - -eresirc.example -file - - - - -2008-04-06T23:15:52.150012Z -76891f69cafef0b5b04d8a28fb87e9a1 -2007-07-12T23:56:31.000000Z -722 -may - -Changelog -file - - - - -2008-04-06T23:15:52.161645Z -0843ba402921d8b54d677dc4396f7ed8 -2006-11-26T01:00:41.000000Z -242 -may - -graphers.txt -file - - - - -2008-04-06T23:15:52.184882Z -d2b96d267c0fbaf02ede05ad7a01de77 -2003-08-21T01:13:15.000000Z -3 -thor - -elfsh-ref.txt -file - - - - -2008-04-06T23:15:52.172900Z -9cb040e2d7ed4cff3709bfe844ed0f8a -2003-08-21T01:13:15.000000Z -3 -thor - -header.html -file - - - - -2008-04-06T23:15:52.195899Z -e1c06d85ae7b8b032bef47e42e4c08f9 -2008-03-07T17:49:34.750118Z -896 -thorkill - -CREDITS -file - - - - -2008-04-06T23:15:52.207884Z -2ac88802aa8198fad857e5e06ef35b55 -2005-10-02T22:30:24.000000Z -21 -thor - -footer.html -file - - - - -2008-04-06T23:15:52.241900Z -e1c06d85ae7b8b032bef47e42e4c08f9 -2008-03-07T17:49:34.750118Z -896 -thorkill - -ERESI-coding_style-README.txt -file - - - - -2008-04-06T23:15:52.231032Z -b0bca42f6f7a9ad653864a1c3d2cd241 -2008-02-19T15:42:44.068818Z -847 -thorkill - -doxygen.conf -file - - - - -2008-04-06T23:15:52.219457Z -804161f3de51f52491f207c2dd96ce61 -2008-03-24T21:14:05.011662Z -928 -enioh - -AUTHOR -file - - - - -2008-04-06T23:15:52.254181Z -cea26c087ec505183d96557f735ed2a0 -2007-09-17T02:26:03.000000Z -785 -may - -elfsh-network-0.3.txt -file - - - - -2008-04-06T23:15:52.265756Z -1ec7a453dfa77c2d427e3cbd9868747a -2005-10-02T22:30:24.000000Z -21 -thor - -TODO -file - - - - -2008-04-06T23:15:52.277329Z -65cff369e8c85209cb06ba471bfd8aef -2006-07-24T14:20:33.000000Z -221 -may - -eresi.1 -file - - - - -2008-04-06T23:15:52.288899Z -c335a8606924c928edcd52058cbb6dd9 -2007-10-06T16:48:51.000000Z -796 -pouik - -HOWTO-port-ERESI-0.8.txt -file - - - - -2008-04-06T23:15:52.302098Z -c84849ec3e9a3865785909245805d59b -2007-10-07T18:16:06.000000Z -797 -heroine -has-props - -rtld-multiarch.txt -file - - - - -2008-04-06T23:15:52.313673Z -fc591cd3cc48a431239ce78cc4fa05a0 -2005-10-02T22:30:24.000000Z -21 -thor - -cerberus2.txt -file - - - - -2008-04-06T23:15:52.325246Z -79476375e1040d280cc2c3142cbcc2c9 -2005-10-02T22:30:24.000000Z -21 -thor - -libasm_TODO.txt -file - - - - -2008-04-06T23:15:52.336882Z -ef1cc7d6e96d767832556dc763676505 -2005-08-02T06:43:53.000000Z -12 -thor - -elfsh-draft.txt -file - - - - -2008-04-06T23:15:52.359912Z -7850e5a395febddf2c768aa6c4339393 -2003-08-21T01:13:15.000000Z -3 -thor - diff -Nru eresi-0.8a25/doc/.svn/format eresi-0.0.20110516/doc/.svn/format --- eresi-0.8a25/doc/.svn/format 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/doc/.svn/prop-base/HOWTO-port-ERESI-0.8.txt.svn-base eresi-0.0.20110516/doc/.svn/prop-base/HOWTO-port-ERESI-0.8.txt.svn-base --- eresi-0.8a25/doc/.svn/prop-base/HOWTO-port-ERESI-0.8.txt.svn-base 2008-04-06 23:15:51.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/prop-base/HOWTO-port-ERESI-0.8.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/doc/.svn/prop-base/libelfsh.i.svn-base eresi-0.0.20110516/doc/.svn/prop-base/libelfsh.i.svn-base --- eresi-0.8a25/doc/.svn/prop-base/libelfsh.i.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/prop-base/libelfsh.i.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/doc/.svn/text-base/AUTHOR.svn-base eresi-0.0.20110516/doc/.svn/text-base/AUTHOR.svn-base --- eresi-0.8a25/doc/.svn/text-base/AUTHOR.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/AUTHOR.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -The ERESI team - -- Julien Vanegue -- Sebastien Roy -- Thomas Garnier -- Julien Auto -- Rafal Lesniak - diff -Nru eresi-0.8a25/doc/.svn/text-base/cerberus2.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/cerberus2.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/cerberus2.txt.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/cerberus2.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,3601 +0,0 @@ - - ==Phrack Inc.== - - Volume 0x0b, Issue 0x3f, Phile #0x09 of 0x14 - -|=------=[ Embedded ELF Debugging : the middle head of Cerberus ]=------=| -|=----------------------------------------------------------------------=| -|=------------=[ The ELF shell crew ]=--------------=| -|=----------------------------------------------------------------------=| - - -I. Hardened software debugging introduction - a. Previous work & limits - b. Beyond PaX and ptrace() - c. Interface improvements -II. The embedded debugging playground - a. In-process injection - b. Alternate ondisk and memory ELF scripting (feat. linkmap) - c. Real debugging : dumping, backtrace, breakpoints - d. A note on dynamic analyzers generation -III. Better multiarchitecture ELF redirections - a. CFLOW: PaX-safe static functions redirection - b. ALTPLT technique revised - c. ALTGOT technique : the RISC complement - d. EXTPLT technique : unknown function postlinking - e. IA32, SPARC32/64, ALPHA64, MIPS32 compliant algorithms -V. Constrained Debugging - a. ET_REL relocation in memory - b. ET_REL injection for Hardened Gentoo (ET_DYN + pie + ssp) - c. Extending static executables - d. Architecture independant algorithms -VI. Past and present -VII. Greetings -VIII. References - - - --------[ I. Hardened software debugging introduction - - - In the past, binary manipulation work has focussed on virii - writing, software cracking, backdoors deployment, or creation of - tiny or obfuscated executables. Besides the tools from the GNU - project such as the GNU binutils that includes the GNU debugger [1] - (which focus more on portability than functionalities), no major - binary manipulation framework does exist. For almost ten years, - the ELF format has been a success and most UNIX Operating Systems - and distributions rely on it. - - However, the existing tools do not take advantage of the format - and most of the reverse engineering or debugging softwares are - either very architecture specific, or simply do not care about - binary internals for extracting and redirecting information. - - Since our first published work on the ELF shell, we improved so - much the new framework that it is now time to publish a second - deep article focussing on advances in static and runtime - ELF techniques. We will explain in great details the 8 new - binary manipulation functionalities that intersect with the - existing reverse engineering methodology. Those techniques allow - for a new type of approach on debugging and extending closed - source software in hardened environments. - - We worked on many architectures (x86, alpha, sparc, mips) and - focussed on constrained environments where binaries are linked - for including security protections (such as hardened gentoo - binaries) in PaX [2] protected machines. It means that our - debugger can stay safe if it is injected inside a (local or) - remote process. - - -----[ A. Previous work & limits - - - In the first part of the Cerberus articles serie, we introduced - a new residency technique called ET_REL injection. It consisted - in compiling C code into relocatable (.o) files and injecting - them into existing closed source binary programs. This technique - was proposed for INTEL and SPARC architectures on the ELF32 - format. - - We improved this technique so that both 32 and 64 bits binaries - are supported so we added alpha64 and sparc64 support. We also - worked on the MIPS r5000 architecture and now provide a nearly - complete environment for it as well. We now also allow for ET_REL - injection into ET_DYN objects (shared libraries) so that our - technique is compatible with fully randomized environments such - as provided by Hardened Gentoo with the PaX protection enabled - on the Linux Operating System. We also worked on other OS such as - BSD based ones, Solaris, and HP-UX and the code was compiled and - tested regulary on those as well. - - A major innovation of our binary manipulation based debugging - framework is the absence of ptrace. We do not use kernel residency - like in [8] so that even unprivilegied users can use this and it - is not Operating System dependent. - - Existing debuggers use to rely on the ptrace system call so that - the debugger process can attach the debuggee program and enable - various internal processes manipulations such as dumping memory, - putting breakpoints, backtracing, and so on. We propose the same - features without using the system call. - - The reasons why we do not use ptrace are multiple and simple. - First of all, a lot of hardened or embedded systems do not - implement it, or just disable it. That's the case for grsecurity - based systems, production systems, or phone systems whoose - Operating System is ELF based but without a ptrace interface. - - The second major reason for not using ptrace is the performance - penalties of such a debugging system. We do not suffer from - performance penalties since the debugger resides in the same - process. We provide a full userland technique that does not have - to access the kernel memory, thus it is useful in all stages of - a penetration testing when debugging sensitive software on - hardened environment is needed and no system update is possible. - - We allow for plain C code injection inside new binary files (in - the static perspective) and processes (in the runtime mode) using - a unified software. When requested, we only use ELF techniques that - reduce forensics evidences on the disk and only works in memory. - - -----[ B. Beyond PaX and ptrace - - - Another key point in our framework are the greatly improved - redirection techniques. We can redirect almost all control flow, - wether or not the function code is placed inside the binary - itself (CFLOW technique) or in a library on which the binary - depends (Our previous work presented new hijacking techniques - such that ALTPLT). - - We improved this techniques and passed through many rewrites - and now allow a complete architecture independant implementation. - We completed ALTPLT by a new technique called ALTGOT so that - hijacking a function and calling back the original copy from the - hooking function is possible on Alpha and Mips RISC machines as - well. - - We also created a new technique called EXTPLT which allow for - unknown function (for which no dynamic linking information is - available at all in the ELF file) using a new postlinking - algorithm compatible with ET_EXEC and ET_DYN objets. - - -----[ C. Interface improvements - - - Our Embedded ELF debugger implementation is a prototype. - Understand that it is really usable but we are still in the - development process. All the code presented here is known to - work. However we are not omniscient and you might encounter a - problem. In that case, drop us an email so that we can figure - out how to create a patch. - - The only assumption that we made is the ability to read the - debuggee program. In all case, you can also debug in memory - the unreadable binaries on disk by loading the debugger using - the LD_PRELOAD variable. Nevertheless, e2dbg is enhanced - when binary files are readable. Because the debugger run in the - same address space, you can still read memory [3] [4] and - restore the binary program even though we do not implement it - yet. - - The central communication language in the Embedded ELF Debugger - (e2dbg) framework is the ELFsh scripting language. We augmented - it with loop and conditional control flow, transparent support - for lazy typed variables (like perl). The source command (for - executing a script inside the current session) and user-defined - macros (scriptdir command) are also supported. - - We also developed a peer2peer stack so called Distributed - Update Management Protocol - DUMP - that allow for linking - multiple debugger instances using the network, but this - capability is not covered by the article. For completeness, we - now support multiusers (parallel or shared) sessions and - environment swapping using the workspace command. - - We will go through the use of such interface in the first part - of the paper. In the second part, we give technical details - about the implementation of such features on multiple - architectures. The last part is dedicated to the most recent - and advanced techniques we developed in the last weeks for - constrained debugging in protected binaries. The last algorithms - of the paper are architecture independant and constitute the - core of the relocation engine in ELFsh. - - - --------[ II. The embedded debugging playground - - - ----[ A. In-process injection - - - - We have different techniques for injecting the debugger - inside the debuggee process. Thus it will share the address - space and the debugger will be able to read its own data - and code for getting (and changing) information in the - debuggee process. - - Because the ELF shell is composed of 40000 lines of code, - we did not want to recode everything for allowing process - modification. We used some trick that allow us to select - wether the modifications are done in memory or on disk. The - trick consists in 10 lines of code. Considering the PROFILE - macros not beeing mandatory, here is the exact stuff : - - - (libelfsh/section.c) - - - ========= BEGIN DUMP 0 ========= - - void *elfsh_get_raw(elfshsect_t *sect) - { - ELFSH_PROFILE_IN(__FILE__, __FUNCTION__, __LINE__); - - /* sect->parent->base is always NULL for ET_EXEC */ - if (elfsh_is_debug_mode()) - { - sect->pdata = (void *) sect->parent->base + sect->shdr->sh_addr; - ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->pdata)); - } - if (sect) - ELFSH_PROFILE_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->data)); - - ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - } - - ========= END DUMP 0 ========= - - - What is the technique about ? It is quite simple : if the debugger - internal flag is set to static mode (on-disk modification), then we - return the pointer on the ELFsh internal data cache for the section - data we want to access. - - However if we are in dynamic mode (process modification), then we - just return the address of that section. The debugger runs in the - same process and thus will think that the returned address is a - readable (or writable) buffer. We can reuse all the ELF shell - API by just taking care of using the elfsh_get_raw() function when - accessing the ->data pointer. The process/ondisk selection is then - transparent for all the debugger/elfsh code. - - The idea of injecting code directly inside the process is not - new and we studied it for some years now. Embedded code injection - is also used in the Windows cracking community [12] for bypassing - most of the protections against tracing and debugging, but nowhere - else we have seen an implementation of a full debugger, capable - of such advanced features like ET_REL injection or function - redirection on multiple architectures, both on disk and in memory, - with a single code. - - - ----[ B. Alternate ondisk and memory ELF scripting (feat. linkmap) - - - - We have 2 approaches for inserting the debugger inside the debuggee - program. When using a DT_NEEDED entry and redirecting the main - debuggee function onto the main entry point of the ET_DYN debugger, - we also inject various sections so that we can perform core - techniques such as EXTPLT. That will be described in details in - the next part. - - The second approach is about using LD_PRELOAD on the debuggee - program and putting breakpoints (either by 0xCC opcode on x86 or - the equivalent opcode on another architecture, or by function - redirection which is available on many architectures and for many - kind of functions in the framework). - - Since binary modification is needed anyway, we are using the - DT_NEEDED technique for adding the library dependance, and all - other sections injections or redirection described in this article, - before starting the real debugging. - - The LD_PRELOAD technique is particulary more useful when you - cannot read the binary you want to debug. It is left to the user - the choice of debugger injection technique, depending on the needs - of the moment. - - Let's see how to use the embedded debugger and its 'mode' command - that does the memory/disk selection. Then we print the Global - Offset Table (.got). First the memory GOT is displayed, then we - get back in static mode and the ondisk GOT is printed : - - - ========= BEGIN DUMP 1 ========= - - (e2dbg-0.65) list - - .::. Working files .::. - [001] Sun Jul 31 19:23:33 2005 D ID: 9 /lib/libncurses.so.5 - [002] Sun Jul 31 19:23:33 2005 D ID: 8 /lib/libdl.so.2 - [003] Sun Jul 31 19:23:33 2005 D ID: 7 /lib/libtermcap.so.2 - [004] Sun Jul 31 19:23:33 2005 D ID: 6 /lib/libreadline.so.5 - [005] Sun Jul 31 19:23:33 2005 D ID: 5 /lib/libelfsh.so - [006] Sun Jul 31 19:23:33 2005 D ID: 4 /lib/ld-linux.so.2 - [007] Sun Jul 31 19:23:33 2005 D ID: 3 ./ibc.so.6 # e2dbg.so renamed - [008] Sun Jul 31 19:23:33 2005 D ID: 2 /lib/tls/libc.so.6 - [009] Sun Jul 31 19:23:33 2005 *D ID: 1 ./a.out_e2dbg # debuggee - - .::. ELFsh modules .::. - [*] No loaded module - - (e2dbg-0.65) mode - - [*] e2dbg is in DYNAMIC MODE - - (e2dbg-0.65) got - - [Global Offset Table .::. GOT : .got ] - [Object ./a.out_e2dbg] - - 0x080498E4: [0] 0x00000000 - - [Global Offset Table .::. GOT : .got.plt ] - [Object ./a.out_e2dbg] - - 0x080498E8: [0] 0x0804981C <_DYNAMIC@a.out_e2dbg> - 0x080498EC: [1] 0x00000000 - 0x080498F0: [2] 0x00000000 - 0x080498F4: [3] 0x0804839E - 0x080498F8: [4] 0x080483AE - 0x080498FC: [5] 0x080483BE - 0x08049900: [6] 0x080483CE - 0x08049904: [7] 0x080483DE <__libc_start_main@a.out_e2dbg> - 0x08049908: [8] 0x080483EE - 0x0804990C: [9] 0x080483FE - 0x08049910: [10] 0x0804840E - - [Global Offset Table .::. GOT : .elfsh.altgot ] - [Object ./a.out_e2dbg] - - 0x08049928: [0] 0x0804981C <_DYNAMIC@a.out_e2dbg> - 0x0804992C: [1] 0xB7F4A4E8 <_r_debug@ld-linux.so.2 + 24> - 0x08049930: [2] 0xB7F3EEC0 <_dl_rtld_di_serinfo@ld-linux.so.2 + 477> - 0x08049934: [3] 0x0804839E - 0x08049938: [4] 0x080483AE - 0x0804993C: [5] 0xB7E515F0 <__libc_malloc@libc.so.6> - 0x08049940: [6] 0x080483CE - 0x08049944: [7] 0xB7E01E50 <__libc_start_main@libc.so.6> - 0x08049948: [8] 0x080483EE - 0x0804994C: [9] 0x080483FE - 0x08049950: [10] 0x0804840E - 0x08049954: [11] 0xB7DAFFF6 - - (e2dbg-0.65) mode static - - [*] e2dbg is now in STATIC mode - - (e2dbg-0.65) # Here we switched in ondisk perspective - (e2dbg-0.65) got - - [Global Offset Table .::. GOT : .got ] - [Object ./a.out_e2dbg] - - 0x080498E4: [0] 0x00000000 - - [Global Offset Table .::. GOT : .got.plt ] - [Object ./a.out_e2dbg] - - 0x080498E8: [0] 0x0804981C <_DYNAMIC> - 0x080498EC: [1] 0x00000000 - 0x080498F0: [2] 0x00000000 - 0x080498F4: [3] 0x0804839E - 0x080498F8: [4] 0x080483AE - 0x080498FC: [5] 0x080483BE - 0x08049900: [6] 0x080483CE - 0x08049904: [7] 0x080483DE <__libc_start_main> - 0x08049908: [8] 0x080483EE - 0x0804990C: [9] 0x080483FE - 0x08049910: [10] 0x0804840E - - [Global Offset Table .::. GOT : .elfsh.altgot ] - [Object ./a.out_e2dbg] - - 0x08049928: [0] 0x0804981C <_DYNAMIC> - 0x0804992C: [1] 0x00000000 - 0x08049930: [2] 0x00000000 - 0x08049934: [3] 0x0804839E - 0x08049938: [4] 0x080483AE - 0x0804993C: [5] 0x080483BE - 0x08049940: [6] 0x080483CE - 0x08049944: [7] 0x080483DE <__libc_start_main> - 0x08049948: [8] 0x080483EE - 0x0804994C: [9] 0x080483FE - 0x08049950: [10] 0x0804840E - 0x08049954: [11] 0x0804614A - - ========= END DUMP 1 ========= - - - There are many things to notice in this dump. First you can - verify that it actually does what it is supposed to by - looking the first GOT entries which are reserved for the - linkmap and the rtld dl-resolve function. Those entries are - filled at runtime, so the static GOT version contains NULL - pointers for them. However the GOT which stands in memory has - them filled. - - Also, the new version of the GNU linker does insert multiple - GOT sections inside ELF binaries. The .got section handles - the pointer for external variables, while .got.plt handles - the external function pointers. In earlier versions of LD, - those 2 sections were merged. We support both conventions. - - Finally, you can see in last the .elfsh.altgot section. - That is part of the ALTGOT technique and it will be - explained as a standalone algorithm in the next parts - of this paper. The ALTGOT technique allow for a size - extension of the Global Offset Table. It allows different - things depending on the architecture. On x86, ALTGOT is - only used when EXTPLT is used, so that we can add extra - function to the host file. On MIPS and ALPHA, ALTGOT - allows to redirect an extern (PLT) function without losing - the real function address. We will develop both of these - techniques in the next parts. - - - ----[ C. Real debugging : dumping, backtrace, breakpoints - - - When performing debugging using a debugger embedded in the - debuggee process, we do not need ptrace so we cannot - modify so easily the process address space. That's why - we have to do small static changes : we add the debugger - as a DT_NEEDED dependancy. The debugger will also overload some - signal handlers (SIGTRAP, SIGINT, SIGSEGV ..) so that it - can takes control on those events. - - We can redirect functions as well using either the CFLOW or - ALTPLT technique using on-disk modification, so that we takes - control at the desired moment. Obviously we can also set - breakpoints in runtime but that need to mprotect the code zone - if it was not writable for the moment. We have idea about how - to get rid of mprotect but this was not implemented in that - version (0.65). Indeed, many uses of the mprotect system call - are incompatible with one of the PaX option). Fortunately - we assume for now that we have read access to the debuggee - program, which means that we can copy the file and disable - that option. - - This is how the DT_NEEDED dependence is added : - - - ========= BEGIN DUMP 2 ========= - - elfsh@WTH $ cat inject_e2dbg.esh - #!../../vm/elfsh - load a.out - set 1.dynamic[08].val 0x2 - set 1.dynamic[08].tag DT_NEEDED - redir main e2dbg_run - save a.out_e2dbg - - ========= END DUMP 2 ========= - - - Let's see the modified binary .dynamic section, where the - extra DT_NEEDED entries were added using the DT_DEBUG - technique that we published 2 years ago [0] : - - - ========= BEGIN DUMP 3 ========= - - elfsh@WTH $ ../../vm/elfsh -f ./a.out -d DT_NEEDED - - [*] Object ./a.out has been loaded (O_RDONLY) - - [SHT_DYNAMIC] - [Object ./a.out] - - [00] Name of needed library => libc.so.6 {DT_NEEDED} - - [*] Object ./a.out unloaded - - elfsh@WTH $ ../../vm/elfsh -f ./a.out_e2dbg -d DT_NEEDED - - [*] Object ./a.out_e2dbg has been loaded (O_RDONLY) - - [SHT_DYNAMIC] - [Object ./a.out_e2dbg] - - [00] Name of needed library => libc.so.6 {DT_NEEDED} - [08] Name of needed library => ibc.so.6 {DT_NEEDED} - - [*] Object ./a.out_e2dbg unloaded - - ========= END DUMP 3 ========= - - - Let's see how we redirected the main function to the hook_main - function. You can notice the overwritten bytes between the 2 jmp - of the hook_main function. This technique is also available MIPS - architecture, but this dump is from the IA32 implementation : - - - ========= BEGIN DUMP 4 ========= - - elfsh@WTH $ ../../vm/elfsh -f ./a.out_e2dbg -D main%40 - - [*] Object ./a.out_e2dbg has been loaded (O_RDONLY) - - 08045134 [foff: 308] hook_main + 0 jmp - 08045139 [foff: 313] hook_main + 5 push %ebp - 0804513A [foff: 314] hook_main + 6 mov %esp,%ebp - 0804513C [foff: 316] hook_main + 8 push %esi - 0804513D [foff: 317] hook_main + 9 push %ebx - 0804513E [foff: 318] hook_main + 10 jmp
- - 08045139 [foff: 313] old_main + 0 push %ebp - 0804513A [foff: 314] old_main + 1 mov %esp,%ebp - 0804513C [foff: 316] old_main + 3 push %esi - 0804513D [foff: 317] old_main + 4 push %ebx - 0804513E [foff: 318] old_main + 5 jmp
- - 08048530 [foff: 13616] main + 0 jmp - 08048535 [foff: 13621] main + 5 sub $2010,%esp - 0804853B [foff: 13627] main + 11 mov 8(%ebp),%ebx - 0804853E [foff: 13630] main + 14 mov C(%ebp),%esi - 08048541 [foff: 13633] main + 17 and $FFFFFFF0,%esp - 08048544 [foff: 13636] main + 20 sub $10,%esp - 08048547 [foff: 13639] main + 23 mov %ebx,4(%esp,1) - 0804854B [foff: 13643] main + 27 mov $<_IO_stdin_used + 43>,(%esp,1) - 08048552 [foff: 13650] main + 34 call - 08048557 [foff: 13655] main + 39 mov (%esi),%eax - - [*] No binary pattern was specified - - [*] Object ./a.out_e2dbg unloaded - - ========= END DUMP 4 ========= - - - Let's now execute the debuggee program, in which the - debugger was injected. - - - ========= BEGIN DUMP 5 ========= - - elfsh@WTH $ ./a.out_e2dbg - - - The Embedded ELF Debugger 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - [*] Sun Jul 31 17:56:52 2005 - New object ./a.out_e2dbg loaded - [*] Sun Jul 31 17:56:52 2005 - New object /lib/tls/libc.so.6 loaded - [*] Sun Jul 31 17:56:53 2005 - New object ./ibc.so.6 loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/ld-linux.so.2 loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/libelfsh.so loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/libreadline.so.5 loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/libtermcap.so.2 loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/libdl.so.2 loaded - [*] Sun Jul 31 17:56:53 2005 - New object /lib/libncurses.so.5 loaded - - (e2dbg-0.65) b puts - - [*] Breakpoint added at (0x080483A8) - - (e2dbg-0.65) continue - - [..: Embedded ELF Debugger returns to the grave :...] - - [e2dbg_run] returning to 0x08045139 - [host] main argc 1 - [host] argv[0] is : ./a.out_e2dbg - - First_printf test - - The Embedded ELF Debugger 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - [*] Sun Jul 31 17:57:03 2005 - New object /lib/tls/libc.so.6 loaded - - (e2dbg-0.65) bt - - .:: Backtrace ::. - [00] 0xB7DC1EC5 - [01] 0xB7DC207F - [02] 0xB7DBC88C - [03] 0xB7DAB4DE - [04] 0xB7DAB943 - [05] 0xB7DA5FF0 - [06] 0xB7DA68D6 - [07] 0xFFFFE440 <_r_debug@ld-linux.so.2 + 1208737648> # sigtrap retaddr - [08] 0xB7DF7F3B <__libc_start_main@libc.so.6 + 235> - [09] 0x08048441 <_start@a.out_e2dbg + 33> - - (e2dbg-0.65) b - - .:: Breakpoints ::. - - [00] 0x080483A8 - - (e2dbg-0.65) delete 0x080483A8 - - [*] Breakpoint at 080483A8 removed - - (e2dbg-0.65) b - - .:: Breakpoints ::. - - [*] No breakpoints - - (e2dbg-0.65) b printf - - [*] Breakpoint added at (0x080483E8) - - (e2dbg-0.65) dumpregs - - .:: Registers ::. - - [EAX] 00000000 (0000000000) - [EBX] 08203F48 (0136331080) <.elfsh.relplt@a.out_e2dbg + 1811272> - [ECX] 00000000 (0000000000) - [EDX] B7F0C7C0 (3086010304) <__guard@libc.so.6 + 1656> - [ESI] BFE3B7C4 (3219371972) <_r_debug@ld-linux.so.2 + 133149428> - [EDI] BFE3B750 (3219371856) <_r_debug@ld-linux.so.2 + 133149312> - [ESP] BFE3970C (3219363596) <_r_debug@ld-linux.so.2 + 133141052> - [EBP] BFE3B738 (3219371832) <_r_debug@ld-linux.so.2 + 133149288> - [EIP] 080483A9 (0134513577) - - (e2dbg-0.65) stack 20 - - .:: Stack ::. - 0xBFE37200 0x00000000 <(null)> - 0xBFE37204 0xB7DC2091 - 0xBFE37208 0xB7DDF5F0 <_GLOBAL_OFFSET_TABLE_@ibc.so.6> - 0xBFE3720C 0xBFE3723C <_r_debug@ld-linux.so.2 + 133131628> - 0xBFE37210 0xB7DC22E7 - 0xBFE37214 0x00000014 <_r_debug@ld-linux.so.2 + 1208744772> - 0xBFE37218 0xB7DDDD90 <__FUNCTION__.5@ibc.so.6 + 49> - 0xBFE3721C 0xBFE37230 <_r_debug@ld-linux.so.2 + 133131616> - 0xBFE37220 0xB7DB9DF9 - 0xBFE37224 0xB7DE1A7C - 0xBFE37228 0xB7DA8176 - 0xBFE3722C 0x080530B8 <.elfsh.relplt@a.out_e2dbg + 38072> - 0xBFE37230 0x00000014 <_r_debug@ld-linux.so.2 + 1208744772> - 0xBFE37234 0x08264FF6 <.elfsh.relplt@a.out_e2dbg + 2208758> - 0xBFE37238 0xB7DDF5F0 <_GLOBAL_OFFSET_TABLE_@ibc.so.6> - 0xBFE3723C 0xBFE3726C <_r_debug@ld-linux.so.2 + 133131676> - 0xBFE37240 0xB7DBC88C - 0xBFE37244 0x0804F208 <.elfsh.relplt@a.out_e2dbg + 22024> - 0xBFE37248 0x00000000 <(null)> - 0xBFE3724C 0x00000000 <(null)> - - (e2dbg-0.65) continue - - [..: Embedded ELF Debugger returns to the grave :...] - - First_puts - - The Embedded ELF Debugger 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - [*] Sun Jul 31 18:00:47 2005 - /lib/tls/libc.so.6 loaded - [*] Sun Jul 31 18:00:47 2005 - /usr/lib/gconv/ISO8859-1.so loaded - - (e2dbg-0.65) dumpregs - - .:: Registers ::. - - [EAX] 0000000B (0000000011) <_r_debug@ld-linux.so.2 + 1208744763> - [EBX] 08203F48 (0136331080) <.elfsh.relplt@a.out_e2dbg + 1811272> - [ECX] 0000000B (0000000011) <_r_debug@ld-linux.so.2 + 1208744763> - [EDX] B7F0C7C0 (3086010304) <__guard@libc.so.6 + 1656> - [ESI] BFE3B7C4 (3219371972) <_r_debug@ld-linux.so.2 + 133149428> - [EDI] BFE3B750 (3219371856) <_r_debug@ld-linux.so.2 + 133149312> - [ESP] BFE3970C (3219363596) <_r_debug@ld-linux.so.2 + 133141052> - [EBP] BFE3B738 (3219371832) <_r_debug@ld-linux.so.2 + 133149288> - [EIP] 080483E9 (0134513641) - - (e2dbg-0.65) linkmap - - .::. Linkmap entries .::. - [01] addr : 0x00000000 dyn : 0x0804981C - - [02] addr : 0x00000000 dyn : 0xFFFFE590 - - [03] addr : 0xB7DE3000 dyn : 0xB7F0AD3C - /lib/tls/libc.so.6 - [04] addr : 0xB7D95000 dyn : 0xB7DDF01C - ./ibc.so.6 - [05] addr : 0xB7F29000 dyn : 0xB7F3FF14 - /lib/ld-linux.so.2 - [06] addr : 0xB7D62000 dyn : 0xB7D93018 - /lib/libelfsh.so - [07] addr : 0xB7D35000 dyn : 0xB7D5D46C - /lib/libreadline.so.5 - [08] addr : 0xB7D31000 dyn : 0xB7D34BB4 - /lib/libtermcap.so.2 - [09] addr : 0xB7D2D000 dyn : 0xB7D2FEEC - /lib/libdl.so.2 - [10] addr : 0xB7CEB000 dyn : 0xB7D2A1C0 - /lib/libncurses.so.5 - [11] addr : 0xB6D84000 dyn : 0xB6D85F28 - /usr/lib/gconv/ISO8859-1.so - - (e2dbg-0.65) exit - - [*] Unloading object 1 (/usr/lib/gconv/ISO8859-1.so) - [*] Unloading object 2 (/lib/tls/libc.so.6) - [*] Unloading object 3 (/lib/tls/libc.so.6) - [*] Unloading object 4 (/lib/libncurses.so.5) - [*] Unloading object 5 (/lib/libdl.so.2) - [*] Unloading object 6 (/lib/libtermcap.so.2) - [*] Unloading object 7 (/lib/libreadline.so.5) - [*] Unloading object 8 (/home/elfsh/WTH/elfsh/libelfsh/libelfsh.so) - [*] Unloading object 9 (/lib/ld-linux.so.2) - [*] Unloading object 10 (./ibc.so.6) - [*] Unloading object 11 (/lib/tls/libc.so.6) - [*] Unloading object 12 (./a.out_e2dbg) * - - .:: Bye -:: The Embedded ELF Debugger 0.65 - - ========= END DUMP 5 ========= - - - As you see, the use of the debugger is quite similar to other - debuggers. The difference is about the implementation technique - which allows for hardened and embedded systems debugging where - ptrace is not present or disabled. - - We were told [9] that the sigaction system call enables the - possibility of doing step by step execution without using - ptrace. We did not have time to implement it but we will - provide a step-capable debugger in the very near future. Since - that call is not filtered by grsecurity and seems to be quite - portable on Linux, BSD, Solaris and HP-UX, it is definitely - worth testing it. - - ----[ D. Dynamic analyzers generation - - - Obviously, tools like ltrace [7] can be now done in elfsh - scripts for multiple architectures since all the redirection - stuff is available. - - We also think that the framework can be used in dynamic - software instrumentation. Since we support multiple - architectures, we let the door open to other development - team to develop such modules or extension inside the ELF - shell framework. - - We did not have time to include an example script for now that - can do this, but we will soon. The kind of interresting stuff - that could be done and improved using the framework would - take its inspiration in projects like fenris [6]. That could - be done for multiple architectures as soon as the instruction - format type is integrated in the script engine, using the code - abstraction of libasm (which is now included as sources in - elfsh). - - We do not deal with encryption for now, but some promising API - [5] could be implemented as well for multiple architectures - very easily. - - - --------[ III. Better multiarchitecture ELF redirections - - - In the first issue of the Cerberus ELF interface [0], we - presented a redirection technique that we called ALTPLT. This - technique is not enough since it allows only for PLT - redirection on existing function of the binary program so - the software extension usable functions set is limited. - - Morever, we noticed a bug in the previously released - implementation of the ALTPLT technique : On the SPARC - architecture, when calling the original function, the - redirection was removed and the program continued to work as if - no hook was installed. This bug came from the fact that Solaris - does not use the r_offset field for computing its relocation - but get the file offset by multiplying the PLT entry size by the - pushed relocation offset on the stack at the moment of dynamic - resolution. - - We found a solution for this problem. That solution consisted in - adding some architecture specific fixes at the beginning of the - ALTPLT section. However, such a fix is too much architecture - dependant and we started to think about an alternative technique - for implementing ALTPLT. As we had implemented the DT_DEBUG - technique by modifying some entries in the .dynamic sections, we - discovered that many other entries are erasable and allow for - a very strong and architecture independant technique for - redirecting access to various sections. More precisely, when - patching the DT_PLTREL entry, we are able to provide our own - pointer. DT_PLTREL is an architecture dependant entry and the - documentation about it is quite weak, not to say inexistant. - - It actually points on the section of the executable beeing - runtime relocated (e.g. GOT on x86 or mips, PLT on sparc and - alpha). By changing this entry we are able to provide our own - PLT or GOT, which leads to possibly extending it. - - Let's first have look at the CFLOW technique and then comes - back on the PLT related redirections using the DT_PLTREL - modification. - - - ----[ A. CFLOW: PaX-safe static functions redirection - - - CFLOW is a simple but efficient technique for function - redirection that are located in the host file and not - having a PLT entry. - - Let's see the host file that we use for this test: - - - - ========= BEGIN DUMP 6 ========= - - elfsh@WTH $ cat host.c - #include - #include - #include - - int legit_func(char *str) - { - printf("legit func (%s) !\n", str); - return (0); - } - - int main() - { - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); - } - - ========= END DUMP 6 ========= - - - We will here redirect the function legit_func, which is located - inside host.c by the hook_func function located in the - relocatable object. - - Let's look at the relocatable file that we are going to inject - in the above binary. - - - ========= BEGIN DUMP 7 ========= - - elfsh@WTH $ cat rel.c - #include - #include - #include - - int glvar_testreloc = 42; - int glvar_testreloc_bss; - char glvar_testreloc_bss2; - short glvar_testreloc_bss3; - - int hook_func(char *str) - { - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); - } - - int puts_troj(char *str) - { - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now " - "[%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - putchar('e'); - putchar('x'); - putchar('t'); - putchar('c'); - putchar('a'); - putchar('l'); - putchar('l'); - putchar('!'); - putchar('\n'); - - old_puts(str); - - write(1, "calling write\n", 14); - fflush(stdout); - return (0); - } - - int func2() - { - return (42); - } - - ========= END DUMP 7 ========= - - - As you can see, the relocatable object use of unknown functions - like write and putchar. Those functions do not have a symbol, plt - entry, got entry, or even relocatable entry in the host file. - - We can call it however using the EXTPLT technique that will be - described as a standalone technique in the next part of this paper. - For now we focuss on the CFLOW technique that allow for redirection - of the legit_func on the hook_func. This function does not have a - PLT entry and we cannot use simple PLT infection for this. - - We developped a technique that is PaX safe for ondisk redirection of - this kind of function. It consists of putting the good old jmp - instruction at the beginning of the legit_func and redirect the flow - on our own code. ELFsh will take care of executing the overwritten - bytes somewhere else and gives back control to the redirected - function, just after the jmp hook, so that no runtime restoration is - needed and it stays PaX safe on disk. - - When these techniques are used in the debugger directly in memory - and not on disk, they all break the mprotect protection of PaX, - which means that this flag must be disabled if you want to redirect - the flow directly into memory. We use use the mprotect syscall on - small code zone for beeing able to changes some specific instructions - for redirection. However, we think that this technique is mostly - interresting for debugging and not for other things, so it is not - our priority to improve this for now. - - Let's see the small ELFsh script for this example : - - - ========= BEGIN DUMP 8 ========= - - elfsh@WTH $ file a.out - a.out: ELF 32-bit LSB executable, Intel 80386, dynamically linked, \ - not stripped - elfsh@WTH $ cat relinject.esh - #!../../../vm/elfsh - - load a.out - load rel.o - - reladd 1 2 - - redir puts puts_troj - redir legit_func hook_func - - save fake_aout - - quit - - ========= END EXAMPLE 8 ========= - - - The output of the ORIGINAL binary is as follow: - - - ========= BEGIN DUMP 9 ========= - - elfsh@WTH $ ./a.out - - First_printf test - First_puts - Second_printf test - Second_puts - LEGIT FUNC - legit func (test) ! - - ========= END DUMP 9 =========== - - - Now let's inject the stuff: - - - ========= BEGIN DUMP 10 ======== - - elfsh@WTH $ ./relinject.esh - - - The ELF shell 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - ~load a.out - - [*] Sun Jul 31 15:30:14 2005 - New object a.out loaded - - ~load rel.o - - [*] Sun Jul 31 15:30:14 2005 - New object rel.o loaded - - ~reladd 1 2 - Section Mirrored Successfully ! - - [*] ET_REL rel.o injected succesfully in ET_EXEC a.out - - ~redir puts puts_troj - - [*] Function puts redirected to addr 0x08047164 - - ~redir legit_func hook_func - - [*] Function legit_func redirected to addr 0x08047134 - - ~save fake_aout - - [*] Object fake_aout saved successfully - - ~quit - - [*] Unloading object 1 (rel.o) - [*] Unloading object 2 (a.out) * - .:: Bye -:: The ELF shell 0.65 - - ========= END DUMP 10 ========= - - - Let's now execute the modified binary. - - - ========= BEGIN DUMP 11 ========= - - elfsh@WTH $ ./fake_aout - - First_printf test - Trojan injected ET_REL takes control now [Z:First_puts:42:43:44:45:1] - extcall! - First_puts - calling write - Second_printf test - Trojan injected ET_REL takes control now [Z:Second_puts:42:43:44:45:1] - extcall! - Second_puts - calling write - HOOK FUNC test ! - Trojan injected ET_REL takes control now [Z:LEGIT FUNC:42:43:44:45:1] - extcall! - calling write - legit func (test) ! - elfsh@WTH $ - - ========= END DUMP 11 ========= - - - Fine. Clearly legit_func has been redirected on the hook - function, and hook_func takes care of calling back the - legit_func using the old symbol technique described in - the first issue of the Cerberus articles serie. - - Let's see the original legit_func code which is redirected - using the CFLOW technique on the x86 architecture : - - - ========= BEGIN DUMP 12 ========= - - 080484C0 legit_func + 0 push %ebp - 080484C1 legit_func + 1 mov %esp,%ebp - 080484C3 legit_func + 3 sub $8,%esp - 080484C6 legit_func + 6 mov $<_IO_stdin_used + 4>,(%esp,1) - 080484CD legit_func + 13 call <.plt + 32> - 080484D2 legit_func + 18 mov $<_IO_stdin_used + 15>,(%esp,1) - - ========= END DUMP 12 ========= - - - Now the modified code: - - - ========= BEGIN DUMP 13 ========= - - 080484C0 legit_func + 0 jmp - 080484C5 legit_func + 5 nop - 080484C6 legit_func + 6 mov $<_IO_stdin_used + 4>,(%esp,1) - 080484CD legit_func + 13 call - 080484D2 legit_func + 18 mov $<_IO_stdin_used + 15>,(%esp,1) - 080484D9 legit_func + 25 mov 8(%ebp),%eax - 080484DC legit_func + 28 mov %eax,4(%esp,1) - 080484E0 legit_func + 32 call - 080484E5 legit_func + 37 leave - 080484E6 legit_func + 38 xor %eax,%eax - - ========= END DUMP 13 ========= - - - We create a new section .elfsh.hooks whoose data is an array - of hook code stubs like this one: - - - ========= BEGIN DUMP 14 ========= - - 08042134 hook_legit_func + 0 jmp - 08042139 old_legit_func + 0 push %ebp - 0804213A old_legit_func + 1 mov %esp,%ebp - 0804213C old_legit_func + 3 sub $8,%esp - 0804213F old_legit_func + 6 jmp - - ========= END DUMP 14 ========= - - - Because we want to be able to recall the original function - (legit_func), we add the erased bytes of it, just after the - first jmp. Then we call back the legit_func at the good offset - (so that we do not recurse inside the hook because the function - was hijacked), as you can see starting at the old_legit_func - symbol of example 14. - - This old symbols technique is coherent with the ALTPLT technique - that we published in the first article. We can as well use - the old_funcname() call inside the injected C code for - calling back the good hijacked function, and we do that without - a single byte restoration at runtime. That is why the CFLOW - technique is PaX compatible. - - For the MIPS architecture, the CFLOW technique is quite similar, - we can see the result of it as well (DUMP 15 is the original - binary and DUMP 16 the modified one): - - - ======== BEGIN DUMP 15 ========= - - 400400 : lui gp,0xfc1 - 400404 : addiu gp,gp,-21696 - 400408 : addu gp,gp,t9 - 40040c : addiu sp,sp,-40 - 400410 : sw ra,36(sp) - [...] - - ======== END DUMP 15 ========= - - - The modified func code is now : - - - ======== BEGIN DUMP 16 ========= - - - 400400: addi t9,t9,104 # Register T9 as target function - 400404: j 0x400468 # Direct JMP on hook function - 400408: nop # Delay slot - 40040c: addiu sp,sp,-40 # The original func code - 400410: sw ra,36(sp) - 400414: sw s8,32(sp) - 400418: move s8,sp - 40041c: sw gp,16(sp) - 400420: sw a0,40(s8) - - ======== END DUMP 16 ========= - - - The func2 function can be anything we want, provided that it has - the same number and type of parameters. When the func2 function - wants to call the original function (func), then it jumps on - the old_func symbol that points inside the .elfsh.hooks section - entry for this CFLOW hook. That is how looks like such a hooks - entry on the MIPS architecture : - - - ======== BEGIN DUMP 17 ========= - - - 3ff0f4 addi t9,t9,4876 - 3ff0f8 lui gp,0xfc1 - 3ff0fc addiu gp,gp,-21696 - 3ff100 addu gp,gp,t9 - 3ff104 j 0x400408 - 3ff108 nop - 3ff10c nop - - ======== END DUMP 17 =========== - - - As you can see, the three instructions that got erased for - installing the CFLOW hook at the beginning of func() are - now located in the hook entry for func(), pointed by - the old_func symbol. The T9 register is also reset so that - we can come back to a safe situation before jumping back - on func + 8. - - - ----[ B. ALTPLT technique revised - - - ALTPLT technique v1 was presented in the Cerberus ELF Interface [0] - paper. As already stated, it was not satisfying because it was - removing the hook on SPARC at the first original function call. - - Since on SPARC the first 4 PLT entries are reserved, there is - room for 12 instructions that would fix anything needed (actually - the first PLT entry) at the moment when ALTPLT+0 takes control. - - ALTPLTv2 is working indeed in 12 instructions but it needed to - reencode the first ALTPLT section entry with the code from PLT+0 - (which is relocated in runtime on SPARC before the main takes - control, which explains why we cannot patch this on the disk - statically). - - By this behavior, it breaks PaX, and the implementation is - very architecture dependant since its SPARC assembly. For those - who want to see it, we let the code of this in the ELFsh source - tree in libelfsh/sparc32.c . - - For the ALPHA64 architecture, it gives pretty much the same in its - respective instructions set, and this time the implementation is - located in libelfsh/alpha64.c . - - As you can see in the code (that we will not reproduce here for - clarity of the article), ALTPLTv2 is a real pain and we needed to - get rid of all this assembly code that was requesting too much - efforts for potential future ports of this technique to other - architectures. - - Then we found the .dynamic DT_PLTREL trick and we tried to see what - happened when changing this .dynamic entry inside the host binary. - Changing the DT_PLTREL entry is very attractive since this is - completely architecture independant so it works everywhere. - - Let's see how look like the section header table and the .dynamic - section used in the really simple ALTPLTv3 technique. We use the - .elfsh.altplt section as a mirror of the original .plt as explained - in our first paper. The other .elfsh.* sections has been explained - already or will be just after the log. - - The output (modified) binary looks like : - - - =============== BEGIN DUMP 18 ================ - - [SECTION HEADER TABLE .::. SHT is not stripped] - [Object fake_aout] - - [000] 0x00000000 ------- foff:00000000 sz:0000000 link:00 - [001] 0x08042134 a-x---- .elfsh.hooks foff:00000308 sz:0000016 link:00 - [002] 0x08043134 a-x---- .elfsh.extplt foff:00004404 sz:0000048 link:00 - [003] 0x08044134 a-x---- .elfsh.altplt foff:00008500 sz:0004096 link:00 - [004] 0x08045134 a--ms-- rel.o.rodata.str1.32 foff:12596 sz:4096 link:00 - [005] 0x08046134 a--ms-- rel.o.rodata.str1.1 foff:16692 sz:4096 link:00 - [006] 0x08047134 a-x---- rel.o.text foff:00020788 sz:0004096 link:00 - [007] 0x08048134 a------ .interp foff:00024884 sz:0000019 link:00 - [008] 0x08048148 a------ .note.ABI-tag foff:00024904 sz:0000032 link:00 - [009] 0x08048168 a------ .hash foff:00024936 sz:0000064 link:10 - [010] 0x080481A8 a------ .dynsym foff:00025000 sz:0000176 link:11 - [011] 0x08048258 a------ .dynstr foff:00025176 sz:0000112 link:00 - [012] 0x080482C8 a------ .gnu.version foff:00025288 sz:0000022 link:10 - [013] 0x080482E0 a------ .gnu.version_r foff:00025312 sz:0000032 link:11 - [014] 0x08048300 a------ .rel.dyn foff:00025344 sz:0000016 link:10 - [015] 0x08048310 a------ .rel.plt foff:00025360 sz:0000056 link:10 - [016] 0x08048348 a-x---- .init foff:00025416 sz:0000023 link:00 - [017] 0x08048360 a-x---- .plt foff:00025440 sz:0000128 link:00 - [018] 0x08048400 a-x---- .text foff:00025600 sz:0000736 link:00 - [019] 0x080486E0 a-x---- .fini foff:00026336 sz:0000027 link:00 - [020] 0x080486FC a------ .rodata foff:00026364 sz:0000116 link:00 - [021] 0x08048770 a------ .eh_frame foff:00026480 sz:0000004 link:00 - [022] 0x08049774 aw----- .ctors foff:00026484 sz:0000008 link:00 - [023] 0x0804977C aw----- .dtors foff:00026492 sz:0000008 link:00 - [024] 0x08049784 aw----- .jcr foff:00026500 sz:0000004 link:00 - [025] 0x08049788 aw----- .dynamic foff:00026504 sz:0000200 link:11 - [026] 0x08049850 aw----- .got foff:00026704 sz:0000004 link:00 - [027] 0x08049854 aw----- .got.plt foff:00026708 sz:0000040 link:00 - [028] 0x0804987C aw----- .data foff:00026748 sz:0000012 link:00 - [029] 0x08049888 aw----- .bss foff:00026760 sz:0000008 link:00 - [030] 0x08049890 aw----- rel.o.bss foff:00026768 sz:0004096 link:00 - [031] 0x0804A890 aw----- rel.o.data foff:00030864 sz:0000004 link:00 - [032] 0x0804A894 aw----- .elfsh.altgot foff:00030868 sz:0000048 link:00 - [033] 0x0804A8E4 aw----- .elfsh.dynsym foff:00030948 sz:0000208 link:34 - [034] 0x0804AA44 aw----- .elfsh.dynstr foff:00031300 sz:0000127 link:33 - [035] 0x0804AB24 aw----- .elfsh.reldyn foff:00031524 sz:0000016 link:00 - [036] 0x0804AB34 aw----- .elfsh.relplt foff:00031540 sz:0000072 link:00 - [037] 0x00000000 ------- .comment foff:00031652 sz:0000665 link:00 - [038] 0x00000000 ------- .debug_aranges foff:00032324 sz:0000120 link:00 - [039] 0x00000000 ------- .debug_pubnames foff:00032444 sz:0000042 link:00 - [040] 0x00000000 ------- .debug_info foff:00032486 sz:0006871 link:00 - [041] 0x00000000 ------- .debug_abbrev foff:00039357 sz:0000511 link:00 - [042] 0x00000000 ------- .debug_line foff:00039868 sz:0000961 link:00 - [043] 0x00000000 ------- .debug_frame foff:00040832 sz:0000072 link:00 - [044] 0x00000000 ---ms-- .debug_str foff:00040904 sz:0008067 link:00 - [045] 0x00000000 ------- .debug_macinfo foff:00048971 sz:0029295 link:00 - [046] 0x00000000 ------- .shstrtab foff:00078266 sz:0000507 link:00 - [047] 0x00000000 ------- .symtab foff:00080736 sz:0002368 link:48 - [048] 0x00000000 ------- .strtab foff:00083104 sz:0001785 link:47 - - [SHT_DYNAMIC] - [Object ./testsuite/etrel_inject/etrel_original/fake_aout] - - [00] Name of needed library => libc.so.6 {DT_NEEDED} - [01] Address of init function => 0x08048348 {DT_INIT} - [02] Address of fini function => 0x080486E0 {DT_FINI} - [03] Address of symbol hash table => 0x08048168 {DT_HASH} - [04] Address of dynamic string table => 0x0804AA44 {DT_STRTAB} - [05] Address of dynamic symbol table => 0x0804A8E4 {DT_SYMTAB} - [06] Size of string table => 00000127 bytes {DT_STRSZ} - [07] Size of symbol table entry => 00000016 bytes {DT_SYMENT} - [08] Debugging entry (unknown) => 0x00000000 {DT_DEBUG} - [09] Processor defined value => 0x0804A894 {DT_PLTGOT} - [10] Size in bytes for .rel.plt => 000072 bytes {DT_PLTRELSZ} - [11] Type of reloc in PLT => 00000017 {DT_PLTREL} - [12] Address of .rel.plt => 0x0804AB34 {DT_JMPREL} - [13] Address of .rel.got section => 0x0804AB24 {DT_REL} - [14] Total size of .rel section => 00000016 bytes {DT_RELSZ} - [15] Size of a REL entry => 00000008 bytes {DT_RELENT} - [16] SUN needed version table => 0x80482E0 {DT_VERNEED} - [17] SUN needed version number => 001 {DT_VERNEEDNUM} - [18] GNU version VERSYM => 0x080482C8 {DT_VERSYM} - - =============== END DUMP 18 ================ - - - As you can see, various sections has been copied and extended, - and their entries in .dynamic changed. That holds for .got - (DT_PLTGOT), .rel.plt (DT_JMPREL), .dynsym (DT_SYMTAB), and - .dynstr (DT_STRTAB). Changing those entries allow for the - new ALTPLT technique without any line of assembly. - - Of course the ALTPLT technique version 3 does not need any - non-mandatory information like debug sections. It may sound - obvious but some peoples really asked this question. - - - ----[ C. ALTGOT technique : the RISC complement - - - On the MIPS architecture, calls to PLT entries are - done differently. Indeed, instead of a direct call instruction on - the entry, an indirect jump is used for using the GOT entry linked - to the desired function. If such entry is filled, then the - function is called directly. By default, the GOT entries contains - the pointer on the PLT entries. During the execution eventually, - the dynamic linker is called for relocating the GOT section (MIPS, - x86) or the PLT section (on SPARC or ALPHA). - - Here is the MIPS assembly log that prove this on some dumb - helloworld program using printf : - - 00400790
: - 400790: 3c1c0fc0 lui gp,0xfc0 # Set GP to GOT base - 400794: 279c78c0 addiu gp,gp,30912 # address + 0x7ff0 - 400798: 0399e021 addu gp,gp,t9 # using t9 (= main) - 40079c: 27bdffe0 addiu sp,sp,-32 - 4007a0: afbf001c sw ra,28(sp) - 4007a4: afbe0018 sw s8,24(sp) - 4007a8: 03a0f021 move s8,sp - 4007ac: afbc0010 sw gp,16(sp) - 4007b0: 8f828018 lw v0,-32744(gp) - 4007b4: 00000000 nop - 4007b8: 24440a50 addiu a0,v0,2640 - 4007bc: 2405002a li a1,42 - 4007c0: 8f828018 lw v0,-32744(gp) - 4007c4: 00000000 nop - 4007c8: 24460a74 addiu a2,v0,2676 - 4007cc: 8f99803c lw t9,-32708(gp) # Load printf GOT entry - 4007d0: 00000000 nop - 4007d4: 0320f809 jalr t9 # and jump on it - 4007d8: 00000000 nop - 4007dc: 8fdc0010 lw gp,16(s8) - 4007e0: 00001021 move v0,zero - 4007e4: 03c0e821 move sp,s8 - 4007e8: 8fbf001c lw ra,28(sp) - 4007ec: 8fbe0018 lw s8,24(sp) - 4007f0: 27bd0020 addiu sp,sp,32 - 4007f4: 03e00008 jr ra # return from the func - 4007f8: 00000000 nop - 4007fc: 00000000 nop - - We note that the global pointer register %gp is always set - on the GOT section base address on MIPS, more or less some - fixed signed offset, in our case 0x7ff0 (0x8000 on ALPHA). - - In order to call a function whoose address is unknown, the GOT - entries are filled and then the indirect jump instruction - on MIPS does not use the PLT entry anymore. What do we learn - from this ? Simply that we cannot rely on a classical PLT - hijacking because the PLT entry code wont be called if the GOT - entry is already filled, which means that we will hijack the - function only the first time. - - Because of this, we will hijack functions using GOT patching - on MIPS. However it does not resolve the problem of recalling - the original function. In order to allow such recall, we will - just insert the old_ symbols on the real PLT entry, so that - we can still access the dynamic linking mechanism code stub - even if the GOT has been modified. - - Let's see the detailed results of the ALTGOT technique on the - ALPHA and MIPS architecture. It was done without a single - line of assembly code which makes it very portable : - - - ========= BEGIN DUMP 19 ========= - - elfsh@alpha$ cat host.c - #include - #include - #include - - int main() - { - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %u\n", 42); - puts("Second_puts"); - fflush(stdout); - return (0); - err: - printf("Malloc problem %u\n", 42); - return (-1); - } - - elfsh@alpha$ gcc host.c -o a.out - elfsh@alpha$ file ./a.out - a.out: ELF 64-bit LSB executable, Alpha (unofficial), for NetBSD 2.0G, - dynamically linked, not stripped - - ========= END DUMP 19 ========= - - - The original binary executes: - - - ========= BEGIN DUMP 20 ========= - - elfsh@alpha$ ./a.out - First_printf test - First_puts - Second_printf 42 - Second_puts - - ========= END DUMP 20 ========== - - - Let's look again the relocatable object we are injecting: - - - ========= BEGIN DUMP 21 ========= - - elfsh@alpha$ cat rel.c - #include - #include - #include - - int glvar_testreloc = 42; - - int glvar_testreloc_bss; - char glvar_testreloc_bss2; - short glvar_testreloc_bss3; - - - int puts_troj(char *str) - { - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now " - "[%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - old_puts(str); - fflush(stdout); - return (0); - } - - int func2() - { - return (42); - } - - ========= END DUMP 21 ========= - - - As you can see, the relocatable object rel.c uses old_ symbols - which means that it relies on the ALTPLT technique. However - we do not perform EXTPLT technique on ALPHA and MIPS yet so - we are not able to call unknown function from the binary on - those architectures for now. Our rel.c is a copy from the one - in example 7 without the calls to the unknown functions - write and putchar of example 7. - - Now we inject the stuff: - - - ========= BEGIN DUMP 22 ========= - - elfsh@alpha$ ./relinject.esh > relinject.out - elfsh@alpha$ ./fake_aout - First_printf test - Trojan injected ET_REL takes control now [Z:First_puts:42:43:44:45:1] - First_puts - Second_printf 42 - Trojan injected ET_REL takes control now [Z:Second_puts:42:43:44:45:1] - Second_puts - - ========= END DUMP 22 ========== - - - The section list on ALPHA is then as follow. A particular - look at the injected sections is recommended : - - - ========= BEGIN DUMP 23 ========= - - elfsh@alpha$ elfsh -f fake_aout -s -p - - [*] Object fake_aout has been loaded (O_RDONLY) - - [SECTION HEADER TABLE .::. SHT is not stripped] - [Object fake_aout] - - [000] 0x000000000 ------- foff:00000 sz:00000 - [001] 0x120000190 a------ .interp foff:00400 sz:00023 - [002] 0x1200001A8 a------ .note.netbsd.ident foff:00424 sz:00024 - [003] 0x1200001C0 a------ .hash foff:00448 sz:00544 - [004] 0x1200003E0 a------ .dynsym foff:00992 sz:00552 - [005] 0x120000608 a------ .dynstr foff:01544 sz:00251 - [006] 0x120000708 a------ .rela.dyn foff:01800 sz:00096 - [007] 0x120000768 a------ .rela.plt foff:01896 sz:00168 - [008] 0x120000820 a-x---- .init foff:02080 sz:00128 - [009] 0x1200008A0 a-x---- .text foff:02208 sz:01312 - [010] 0x120000DC0 a-x---- .fini foff:03520 sz:00104 - [011] 0x120000E28 a------ .rodata foff:03624 sz:00162 - [012] 0x120010ED0 aw----- .data foff:03792 sz:00000 - [013] 0x120010ED0 a------ .eh_frame foff:03792 sz:00004 - [014] 0x120010ED8 aw----- .dynamic foff:03800 sz:00352 - [015] 0x120011038 aw----- .ctors foff:04152 sz:00016 - [016] 0x120011048 aw----- .dtors foff:04168 sz:00016 - [017] 0x120011058 aw----- .jcr foff:04184 sz:00008 - [018] 0x120011060 awx---- .plt foff:04192 sz:00116 - [019] 0x1200110D8 aw----- .got foff:04312 sz:00240 - [020] 0x1200111C8 aw----- .sdata foff:04552 sz:00024 - [021] 0x1200111E0 aw----- .sbss foff:04576 sz:00024 - [022] 0x1200111F8 aw----- .bss foff:04600 sz:00056 - [023] 0x120011230 a-x---- rel.o.text foff:04656 sz:00320 - [024] 0x120011370 aw----- rel.o.sdata foff:04976 sz:00008 - [025] 0x120011378 a--ms-- rel.o.rodata.str1.1 foff:04984 sz:00072 - [026] 0x1200113C0 a-x---- .alt.plt.prolog foff:05056 sz:00048 - [027] 0x1200113F0 a-x---- .alt.plt foff:05104 sz:00120 - [028] 0x120011468 a------ .alt.got foff:05224 sz:00072 - [029] 0x1200114B0 aw----- rel.o.got foff:05296 sz:00080 - [030] 0x000000000 ------- .comment foff:05376 sz:00240 - [031] 0x000000000 ------- .debug_aranges foff:05616 sz:00048 - [032] 0x000000000 ------- .debug_pubnames foff:05664 sz:00027 - [033] 0x000000000 ------- .debug_info foff:05691 sz:02994 - [034] 0x000000000 ------- .debug_abbrev foff:08685 sz:00337 - [035] 0x000000000 ------- .debug_line foff:09022 sz:00373 - [036] 0x000000000 ------- .debug_frame foff:09400 sz:00048 - [037] 0x000000000 ---ms-- .debug_str foff:09448 sz:01940 - [038] 0x000000000 ------- .debug_macinfo foff:11388 sz:12937 - [039] 0x000000000 ------- .ident foff:24325 sz:00054 - [040] 0x000000000 ------- .shstrtab foff:24379 sz:00393 - [041] 0x000000000 ------- .symtab foff:27527 sz:02400 - [042] 0x000000000 ------- .strtab foff:29927 sz:00948 - - [Program header table .::. PHT] - [Object fake_aout] - - [00] 0x120000040 -> 0x120000190 r-x => Program header table - [01] 0x120000190 -> 0x1200001A7 r-- => Program interpreter - [02] 0x120000000 -> 0x120000ECA r-x => Loadable segment - [03] 0x120010ED0 -> 0x120011510 rwx => Loadable segment - [04] 0x120010ED8 -> 0x120011038 rw- => Dynamic linking info - [05] 0x1200001A8 -> 0x1200001C0 r-- => Auxiliary information - - [Program header table .::. SHT correlation] - [Object fake_aout] - - [*] SHT is not stripped - - [00] PT_PHDR - [01] PT_INTERP .interp - [02] PT_LOAD .interp .note.netbsd.ident .hash .dynsym .dynstr - .rela.dyn .rela.plt .init .text .fini .rodata - [03] PT_LOAD .data .eh_frame .dynamic .ctors .dtors .jcr .plt - .got .sdata .sbss .bss rel.o.text rel.o.sdata - rel.o.rodata.str1.1 .alt.plt.prolog .alt.plt - .alt.got rel.o.got - [04] PT_DYNAMIC .dynamic - [05] PT_NOTE .note.netbsd.ident - - [*] Object fake_aout unloaded - - ========= END DUMP 23 ========= - - - Segments are extended the good way. We see this because of - the correlation between SHT and PHT : all bounds are correct. - the end. The .alt.plt.prolog section is there for implementing - the ALTPLTv2 on ALPHA. This could will patch in runtime the - first ALTPLT entry bytes with the first PLT entry bytes on - the first time that ALTPLT first entry is called (when calling - some original function from a hook function for the first time). - - When we discovered how to do the ALTPLTv3 (without a line - of assembly), then .alt.plt.prolog just became a padding - section so that GOT and ALTGOT were well aligned on some - size that was necessary for setting up ALTPLT because of - the ALPHA instruction encoding of indirect control flow - jumps. - - ----[ D. EXTPLT technique : unknown function postlinking - - - This technique is one of the major one of the new ELFsh - version. It works on ET_EXEC and ET_DYN files, including - when the injection is done directly in memory. EXTPLT - consists in adding a new section (.elfsh.extplt) so that - we can add entries for new functions. - - When coupled to .rel.plt, .got, .dynsym, and .dynstr mirroring - extensions, it allows for placing relocation entries that match - the needs of the new ALTPLT/ALTGOT couple. Let's look at the - additional relocation information using the elfsh -r command. - - First, let see the original binary relocation table: - - - ========= BEGIN DUMP 24 ========= - - [*] Object ./a.out has been loaded (O_RDONLY) - - [RELOCATION TABLES] - [Object ./a.out] - - {Section .rel.dyn} - [000] R_386_GLOB_DAT 0x08049850 sym[010] : __gmon_start__ - [001] R_386_COPY 0x08049888 sym[004] : stdout - - {Section .rel.plt} - [000] R_386_JMP_SLOT 0x08049860 sym[001] : fflush - [001] R_386_JMP_SLOT 0x08049864 sym[002] : puts - [002] R_386_JMP_SLOT 0x08049868 sym[003] : malloc - [003] R_386_JMP_SLOT 0x0804986C sym[005] : __libc_start_main - [004] R_386_JMP_SLOT 0x08049870 sym[006] : printf - [005] R_386_JMP_SLOT 0x08049874 sym[007] : free - [006] R_386_JMP_SLOT 0x08049878 sym[009] : read - - [*] Object ./testsuite/etrel_inject/etrel_original/a.out unloaded - - ========= END DUMP 24 ========= - - - Let's now see the modified binary relocation tables: - - - ========= BEGIN DUMP 25 ========= - - [*] Object fake_aout has been loaded (O_RDONLY) - - [RELOCATION TABLES] - [Object ./fake_aout] - - {Section .rel.dyn} - [000] R_386_GLOB_DAT 0x08049850 sym[010] : __gmon_start__ - [001] R_386_COPY 0x08049888 sym[004] : stdout - - {Section .rel.plt} - [000] R_386_JMP_SLOT 0x0804A8A0 sym[001] : fflush - [001] R_386_JMP_SLOT 0x0804A8A4 sym[002] : puts - [002] R_386_JMP_SLOT 0x0804A8A8 sym[003] : malloc - [003] R_386_JMP_SLOT 0x0804A8AC sym[005] : __libc_start_main - [004] R_386_JMP_SLOT 0x0804A8B0 sym[006] : printf - [005] R_386_JMP_SLOT 0x0804A8B4 sym[007] : free - [006] R_386_JMP_SLOT 0x0804A8B8 sym[009] : read - - {Section .elfsh.reldyn} - [000] R_386_GLOB_DAT 0x08049850 sym[010] : __gmon_start__ - [001] R_386_COPY 0x08049888 sym[004] : stdout - - {Section .elfsh.relplt} - [000] R_386_JMP_SLOT 0x0804A8A0 sym[001] : fflush - [001] R_386_JMP_SLOT 0x0804A8A4 sym[002] : puts - [002] R_386_JMP_SLOT 0x0804A8A8 sym[003] : malloc - [003] R_386_JMP_SLOT 0x0804A8AC sym[005] : __libc_start_main - [004] R_386_JMP_SLOT 0x0804A8B0 sym[006] : printf - [005] R_386_JMP_SLOT 0x0804A8B4 sym[007] : free - [006] R_386_JMP_SLOT 0x0804A8B8 sym[009] : read - [007] R_386_JMP_SLOT 0x0804A8BC sym[011] : _IO_putc - [008] R_386_JMP_SLOT 0x0804A8C0 sym[012] : write - - [*] Object fake_aout unloaded - - ========= END DUMP 25 ========= - - - As you see, _IO_putc (internal name for putchar) and write - functions has been used in the injected object. We had to - insert them inside the host binary so that the output binary - can work. - - The .elfsh.relplt section is copied from the .rel.plt - section but with a doubled size so that we have room - for additional entries. Even if we extend only one of the - relocation table, both tables needs to be copied, because - on ET_DYN files, the rtld will assume that both tables - are adjacent in memory, so we cannot just copy .rel.plt - but also need to keep .rel.dyn (aka .rel.got) near the - .rel.plt copy. That is why you can see with .elfsh.reldyn - and .elfsh.relplt . - - When extra symbols are needed, more sections are moved - after the BSS, including .dynsym and .dynstr. - - ----[ E. IA32, SPARC32/64, ALPHA64, MIPS32 compliant algorithms - - - Let's now give all algorithms details about the techniques we - introduced by the practice in the previous paragraphs. We - cover here all pseudos algorithms for ELF redirections. More - constrained debugging detailed algorithms are given at the end - of the next part. - - Because of ALTPLT and ALTGOT techniques are so complementary, - we implemented them inside only one algorithm that we give - now. There is no conditions on the SPARC architecture since - it is the default architecture case in the listing. - - The main ALTPLTv3 / ALTGOT algorithm (libelfsh/altplt.c) can be - found in elfsh_build_plt() and elfsh_relink_plt(), is as - follow. - - It could probably be cleaned if all the code go in architecture - dependant handlers but that would duplicate some code, so we - keep it like this : - - Multiarchitecture ALTPLT / ALTGOT algorithm - +-------------------------------------------+ - - 0/ IF [ ARCH is MIPS AND PLT is not found AND File is dynamic ] - [ - - Get .text section base address - - Find MIPS opcodes fingerprint for embedded PLT - located inside .text - - Fixup SHT to include PLT section header - ] - - 1/ SWITCH on ELF architecture - [ - MIPS: - * Insert mapped .elfsh.gotprolog section - * Insert mapped .elfsh.padgot section - ALPHA: - * Insert mapped .elfsh.pltprolog section - DEFAULT: - * Insert mapped .elfsh.altplt section (copy of .plt) - ] - - 2/ IF [ ARCH is (MIPS or ALPHA or IA32) ] - [ - * Insert .elfsh.altgot section (copy of .got) - ] - - 3/ FOREACH (ALT)PLT ENTRY: - [ - IF [ FIRST PLT entry ] - [ - IF [ARCH is MIPS ] - [ - * Insert pairs of ld/st instructions in - .elfsh.gotprolog for copying extern variables - addresses fixed in GOT by the RTLD inside - ALTGOT section. See MIPS altplt handler - in libelfsh/mips32.c - ] - ELSE IF [ ARCH is IA32 ] - [ - * Reencode the first PLT entry using GOT - ALTGOT - address difference (so we relocate into ALTGOT - instead of GOT) - ] - ] - - IF [ ARCH is MIPS ] - * Inject OLD symbol on current PLT entry - ELSE - * Inject OLD symbol on current ALTPLT entry - - IF [ ARCH is ALPHA ] - * Shift relocation entry pointing at current location - - IF [ ARCH is IA32 ] - * Reencode PLT and ALTPLT current entry - ] - - 4/ SWITCH on ELF architecture - [ - MIPS: - IA32: - * Change DT_PLTGOT entry from GOT to ALTGOT address - * Shift GOT related relocation - SPARC: - * Change DT_PLTGOT entry from PLT to ALTPLT address - * Shift PLT related relocations - ] - - - - On MIPS, there is no relocation tables inside ET_EXEC binaries. - If we want to shift the relocations that make reference to GOT - inside the MIPS code, we need to fingerprint such code patterns - so that we fix them using the ALTGOT - GOT difference. They are - easily found since the needed patches are always on the same - binary instructions pattern : - - 3c1c0000 lui gp,0x0 - 279c0000 addiu gp,gp,0 - - The zero fields in those instructions should be patched at - linking time when they match HI16 and LO16 MIPS relocations. - However this information is not available in a table for - ET_EXEC files, so we had to find them back in the binary code. - It way easier to do this on RISC architectures since all - instructions are the same length so false positives are very - unlikely to happen. Once we found all those patterns, we fix - them using the ALTGOT-GOT difference in the relocatable fields. - Of course, we wont change ALL references to GOT inside the - code, because that would result in just moving the GOT without - performing any hijack. We just fix those references in the - first 0x100 bytes of .text, and in .init, .fini, that means - only the references at the reserved GOT entries (filled with - dl-resolve virtual address and linkmap address). That way, we - make the original code use the ALTGOT section when accessing - reserved entries (since they have been runtime relocated in - ALTGOT and not GOT) and the original GOT entries when accessing - the function entries (so that we can hijack functions using - GOT modification). - - - EXTPLT algorithm - +----------------+ - - The EXTPLT algorithm fits well in the previous algorithm. We - just needed to add 2 steps in the previous listing : - - - Step 2 BIS : Insert the EXTPLT (copy of PLT) section on - supported architectures. - - Step 5 : Mirror (and extend) dynamic linking sections on - supported architectures. Let's give more details - about this algorithm implemented in - libelfsh/extplt.c. - - * Mirror .rel.got (.rel.dyn) and .rel.plt sections after BSS, - with a double sized mirror sections. Those 2 sections needs to - stay adjacent in memory so that EXTPLT works on ET_DYN objects - as well. - - * Update DT_REL and DT_JMPREL entries in .dynamic - - * Mirror .dynsym and .dynstr sections with a double size - - * Update DT_SYMTAB and DT_STRTAB entries in .dynamic - - Once those operations are done, we have room in all the various - dynamic linking oriented sections and we can add on-demand - dynamic symbols, symbols names, and relocation entry necessary - for adding extra PLT entries in the EXTPLT section. - - Then, each time we encounter a unknown symbol in the process of - relocating a ET_REL object inside a ET_EXEC or ET_DYN object, - we can use the REQUESTPLT algorithm, as implemented in - elfsh_request_pltent() function in the libelfsh/extplt.c file : - - * Check room in EXTPLT, RELPLT, DYNSYM, DYNSTR, and - ALTGOT sections. - - * Initialize ALTGOT entry to EXTPLT allocated new entry. - - * Encode EXTPLT entry for using the ALTGOT entry. - - * Insert relocation entry inside .elfsh.relplt for ALTGOT - new entry. - - * Add relocation entry size to DT_PLTRELSZ entry value in - .dynamic section. - - * Insert missing symbol in .elfsh.dynsym, with name inserted in - .elfsh.dynstr section. - - * Add symbol name length to DT_STRSZ entry value in .dynamic - section. - - This algorithm is called from the main ET_REL injection and - relocation algorithm each time the ET_REL object use an unknown - function whoose symbol is not present in the host file. The - new ET_REL injection algorithm is given at the end of the - constrained debugging part of the article. - - - CFLOW algorithm - +----------------+ - - This technique is implemented using an architecture dependant - backend but the global algorithm stays the same for all - architectures : - - - Create .elfsh.hooks sections (only 1 time) - - Find number of bytes aligned on instruction size : - * Using libasm on IA32 - * Manually on RISC machines - - Insert HOOK entry on demand (see CFLOW dump for format) - - Insert JMP to hook entry in hijacked function prolog - - Align JUMP hook on instruction size with NOP in hijacked prolog - - Insert hook_funcname and old_funcname symbols in hook entry for - beeing able to call back the original function. - - - The technique is PaX safe since it does not need any runtime - bytes restoration step. We can hook the address of our choice - using the CFLOW technique, however executing the original bytes - in the hook entry instead of their original place will not work - when placing hooks on relative branching instructions. Indeed, - relatives branching will be resolved to a wrong virtual address - if we execute their opcodes at the wrong place (inside - .elfsh.hooks instead of their original place) inside the - process. Remember this when placing CFLOW hooks : it is not - intended to hook relative branch instructions. - - - --------[ V. Constrained Debugging - - - In nowadays environment, hardened binaries are usually - of type ET_DYN. We had to support this kind of injection - since it allows for library files modification as much - powerful as the the executable files modification. Moreover - some distribution comes with a default binary set compiled - in ET_DYN, such as hardened gentoo. - - Another improvement that we wanted to be done is the ET_REL - relocation in memory. The algorithm for it is the same than - the ondisk injection, but this time the disk is not changed - so it reduces forensics evidences like in [12]. It is believed - that this kind of injection can be used in exploits and direct - process backdooring without touching the hard disk. Evil eh ? - - We are aware of another implementation of the ET_REL injection - into memory [10]. Ours supports a wider range of architecture and - couples with the EXTPLT technique directly in memory, which - was not previously implemented to our knowledge. - - A last technique that we wanted to develop was about extending - and debugging static executables. We developed this new technique - that we called EXTSTATIC algorithm. It allows for static - injections by taking parts of libc.a when functions or code is - missing. The same ET_REL injection algorithm is used except - that more than one relocatable file taken from libc.a is - injected at a time using a recursive dependency algorithm. - - ----[ A. ET_REL relocation in memory - - - Because we want to be able to provide a handler for breakpoints - as they are specified, we allow for direct mapping of an ET_REL - object into memory. We use extra mmap zone for this, always - taking care that it does not break PaX : we do not map any zone - beeing both executable and writable. - - In e2dbg, breakpoints can be implemented in 2 ways. Either an - architecture specific opcode (like 0xCC on IA32) is used on the - desired redirected access, or the CFLOW/ALTPLT primitives can be - used in runtime. In the second case, the mprotect system - call must be used to be able to modify code at runtime. However - we may be able to get rid of mprotect soon for runtime injections - as the CFLOW techniques improves for beeing both static and - runtime PaX safe. - - Let's look at some simple binary that does just use printf and - and puts to understand more those concepts: - - - ========= BEGIN DUMP 26 ========= - - elfsh@WTH $ ./a.out - [host] main argc 1 - [host] argv[0] is : ./a.out - - First_printf test - First_puts - Second_printf test - Second_puts - LEGIT FUNC - legit func (test) ! - ========= END DUMP 26 ========= - - - We use a small elfsh script as e2dbg so that it creates - another file with the debugger injected inside it, using - regular elfsh techniques. Let's look at it : - - - - ========= BEGIN DUMP 27 ========= - elfsh@WTH $ cat inject_e2dbg.esh - #!../../vm/elfsh - load a.out - set 1.dynamic[08].val 0x2 # entry for DT_DEBUG - set 1.dynamic[08].tag DT_NEEDED - redir main e2dbg_run - save a.out_e2dbg - ========= END DUMP 27 ========= - - - We then execute the modified binary. - - - ========= BEGIN DUMP 28 ========= - - elfsh@WTH $ ./aout_e2dbg - - - The Embedded ELF Debugger 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - [*] Sun Jul 31 16:24:00 2005 - New object ./a.out_e2dbg loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/tls/libc.so.6 loaded - [*] Sun Jul 31 16:24:00 2005 - New object ./ibc.so.6 loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/ld-linux.so.2 loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/libelfsh.so loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/libreadline.so.5 loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/libtermcap.so.2 loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/libdl.so.2 loaded - [*] Sun Jul 31 16:24:00 2005 - New object /lib/libncurses.so.5 loaded - - (e2dbg-0.65) quit - - [..: Embedded ELF Debugger returns to the grave :...] - - [e2dbg_run] returning to 0x08045139 - [host] main argc 1 - [host] argv[0] is : ./a.out_e2dbg - - First_printf test - First_puts - Second_printf test - Second_puts - LEGIT FUNC - legit func (test) ! - - elfsh@WTH $ - -========= END DUMP 28 ========= - - - Okay, that was easy. What if we want to do something more - interresting like ET_REL object injection into memory. We - will make use of the profile command so that we can see - the autoprofiling feature of e2dbg. This command is always - useful to learn more about the internals of the debugger, - and for internal debugging problems that may occur while - developping it. - - Our cheap function calls pattern matching makes the output - more understandable than a raw print of profiling information - and took only a few hours to implement using the - ELFSH_PROFILE_{OUT,ERR,ROUT} macros in libelfsh-internals.h - and libelfsh/error.c - - We will also print the linkmap list. The linkmap first fields - are OS independant. There are a lot of other internal fields - that we do not display here but a lot of information could - be grabbed from there as well. - - See the stuff in action : - - - ========= BEGIN DUMP 29 ========= - - elfsh@WTH $ ./a.out_e2dbg - - The Embedded ELF Debugger 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - [*] Sun Jul 31 16:12:48 2005 - New object ./a.out_e2dbg loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/tls/libc.so.6 loaded - [*] Sun Jul 31 16:12:48 2005 - New object ./ibc.so.6 loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/ld-linux.so.2 loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/libelfsh.so loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/libreadline.so.5 loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/libtermcap.so.2 loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/libdl.so.2 loaded - [*] Sun Jul 31 16:12:48 2005 - New object /lib/libncurses.so.5 loaded - - (e2dbg-0.65) linkmap - - .::. Linkmap entries .::. - [01] addr : 0x00000000 dyn : 0x080497D4 - - [02] addr : 0x00000000 dyn : 0xFFFFE590 - - [03] addr : 0xB7E73000 dyn : 0xB7F9AD3C - /lib/tls/libc.so.6 - [04] addr : 0xB7E26000 dyn : 0xB7E6F01C - ./ibc.so.6 - [05] addr : 0xB7FB9000 dyn : 0xB7FCFF14 - /lib/ld-linux.so.2 - [06] addr : 0xB7DF3000 dyn : 0xB7E24018 - /lib/libelfsh.so - [07] addr : 0xB7DC6000 dyn : 0xB7DEE46C - /lib/libreadline.so.5 - [08] addr : 0xB7DC2000 dyn : 0xB7DC5BB4 - /lib/libtermcap.so.2 - [09] addr : 0xB7DBE000 dyn : 0xB7DC0EEC - /lib/libdl.so.2 - [10] addr : 0xB7D7C000 dyn : 0xB7DBB1C0 - /lib/libncurses.so.5 - - (e2dbg-0.65) list - - .::. Working files .::. - [001] Sun Jul 31 16:24:00 2005 D ID: 9 /lib/libncurses.so.5 - [002] Sun Jul 31 16:24:00 2005 D ID: 8 /lib/libdl.so.2 - [003] Sun Jul 31 16:24:00 2005 D ID: 7 /lib/libtermcap.so.2 - [004] Sun Jul 31 16:24:00 2005 D ID: 6 /lib/libreadline.so.5 - [005] Sun Jul 31 16:24:00 2005 D ID: 5 /lib/libelfsh.so - [006] Sun Jul 31 16:24:00 2005 D ID: 4 /lib/ld-linux.so.2 - [007] Sun Jul 31 16:24:00 2005 D ID: 3 ./ibc.so.6 - [008] Sun Jul 31 16:24:00 2005 D ID: 2 /lib/tls/libc.so.6 - [009] Sun Jul 31 16:24:00 2005 *D ID: 1 ./a.out_e2dbg - - .::. ELFsh modules .::. - [*] No loaded module - - (e2dbg-0.65) source ./etrelmem.esh - - ~load myputs.o - - [*] Sun Jul 31 16:13:32 2005 - New object myputs.o loaded - - [!!] Loaded file is not the linkmap, switching to STATIC mode - - ~switch 1 - - [*] Switched on object 1 (./a.out_e2dbg) - - ~mode dynamic - - [*] e2dbg is now in DYNAMIC mode - - ~reladd 1 10 - - [*] ET_REL myputs.o injected succesfully in ET_EXEC ./a.out_e2dbg - - ~profile - .:: Profiling enable - - + - ~redir puts myputs - + - + - + - + - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - [W] Symbol not found - [P] --[ - [P] --[ - [P] --- Last 2 function(s) recalled 12 time(s) --- - + - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 114 time(s) --- - + - + - + - + - + - + - + - + - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 4 time(s) --- - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - + - [P] --[ - [P] --[ - [P] --[ - [P] --- Last 3 function(s) recalled 1 time(s) --- - + - + - + - + - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - + - + - [W] Symbol not found - [P] --[ - [P] --- Last 1 function(s) recalled 114 time(s) --- - + - [W] Invalid NULL parameter - + - + - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - [P] --[ - [P] --[ - [P] --[ - [P] --[ - [P] --[ - [P] --- Last 5 function(s) recalled 1 time(s) --- - + - + - + - + - [P] --[ - [P] --[ - [P] --[ - [P] --- Last 3 function(s) recalled 3 time(s) --- - + - + - [P] --[ - [P] --[ - [P] --[ - [P] --[ - [P] --[ - [P] --- Last 5 function(s) recalled 44 time(s) --- - + - [P] --[ - [P] --- Last 1 function(s) recalled 1 time(s) --- - + - + - + - [P] --[ - [P] --[ - [P] --[ - [P] --[ - [P] --- Last 4 function(s) recalled 1 time(s) --- - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - [*] Function puts redirected to addr 0xB7FB6000 - - + - ~profile - + - .:: Profiling disable - - - [*] ./etrelmem.esh sourcing -OK- - - (e2dbg-0.65) continue - - - [..: Embedded ELF Debugger returns to the grave :...] - - [e2dbg_run] returning to 0x08045139 - [host] main argc 1 - [host] argv[0] is : ./a.out_e2dbg - - First_printf test - Hijacked puts !!! arg = First_puts - First_puts - Second_printf test - Hijacked puts !!! arg = Second_puts - Second_puts - Hijacked puts !!! arg = LEGIT FUNC - LEGIT FUNC - legit func (test) ! - elfsh@WTH $ - - ========= END DUMP 29 ========= - - - Really cool. We hijacked 2 functions (puts and legit_func) using - the 2 different (ALTPLT and CFLOW) techniques. For this, we - did not have to inject an additional ET_REL file inside the - ET_EXEC host, but we directly injected the hook module inside - memory using mmap. - - We could have printed the SHT and PHT as well just after the - ET_REL injection into memory. We keep track of all mapping - when we inject such relocatable objects, so that we can - eventually unmap them in the future or remap them later : - - - ========= BEGIN DUMP 30 ========= - - (e2dbg-0.65) s - - [SECTION HEADER TABLE .::. SHT is not stripped] - [Object ./a.out_e2dbg] - - [000] 0x00000000 ------- foff:00000 size:00308 - [001] 0x08045134 a-x---- .elfsh.hooks foff:00308 size:00015 - [002] 0x08046134 a-x---- .elfsh.extplt foff:04404 size:00032 - [003] 0x08047134 a-x---- .elfsh.altplt foff:08500 size:04096 - [004] 0x08048134 a------ .interp foff:12596 size:00019 - [005] 0x08048148 a------ .note.ABI-tag foff:12616 size:00032 - [006] 0x08048168 a------ .hash foff:12648 size:00064 - [007] 0x080481A8 a------ .dynsym foff:12712 size:00176 - [008] 0x08048258 a------ .dynstr foff:12888 size:00112 - [009] 0x080482C8 a------ .gnu.version foff:13000 size:00022 - [010] 0x080482E0 a------ .gnu.version_r foff:13024 size:00032 - [011] 0x08048300 a------ .rel.dyn foff:13056 size:00016 - [012] 0x08048310 a------ .rel.plt foff:13072 size:00056 - [013] 0x08048348 a-x---- .init foff:13128 size:00023 - [014] 0x08048360 a-x---- .plt foff:13152 size:00128 - [015] 0x08048400 a-x---- .text foff:13312 size:00800 - [016] 0x08048720 a-x---- .fini foff:14112 size:00027 - [017] 0x0804873C a------ .rodata foff:14140 size:00185 - [018] 0x080487F8 a------ .eh_frame foff:14328 size:00004 - [019] 0x080497FC aw----- .ctors foff:14332 size:00008 - [020] 0x08049804 aw----- .dtors foff:14340 size:00008 - [021] 0x0804980C aw----- .jcr foff:14348 size:00004 - [022] 0x08049810 aw----- .dynamic foff:14352 size:00200 - [023] 0x080498D8 aw----- .got foff:14552 size:00004 - [024] 0x080498DC aw----- .got.plt foff:14556 size:00040 - [025] 0x08049904 aw----- .data foff:14596 size:00012 - [026] 0x08049910 aw----- .bss foff:14608 size:00008 - [027] 0x08049918 aw----- .elfsh.altgot foff:14616 size:00044 - [028] 0x08049968 aw----- .elfsh.dynsym foff:14696 size:00192 - [029] 0x08049AC8 aw----- .elfsh.dynstr foff:15048 size:00122 - [030] 0x08049BA8 aw----- .elfsh.reldyn foff:15272 size:00016 - [031] 0x08049BB8 aw----- .elfsh.relplt foff:15288 size:00064 - [032] 0x00000000 ------- .comment foff:15400 size:00665 - [033] 0x00000000 ------- .debug_aranges foff:16072 size:00120 - [034] 0x00000000 ------- .debug_pubnames foff:16192 size:00042 - [035] 0x00000000 ------- .debug_info foff:16234 size:06904 - [036] 0x00000000 ------- .debug_abbrev foff:23138 size:00503 - [037] 0x00000000 ------- .debug_line foff:23641 size:00967 - [038] 0x00000000 ------- .debug_frame foff:24608 size:00076 - [039] 0x00000000 ---ms-- .debug_str foff:24684 size:08075 - [040] 0x00000000 ------- .debug_macinfo foff:32759 size:29295 - [041] 0x00000000 ------- .shstrtab foff:62054 size:00496 - [042] 0x00000000 ------- .symtab foff:64473 size:02256 - [043] 0x00000000 ------- .strtab foff:66729 size:01665 - [044] 0x40019000 aw----- myputs.o.bss foff:68394 size:04096 - [045] 0x00000000 ------- .elfsh.rpht foff:72493 size:04096 - [046] 0x4001A000 a-x---- myputs.o.text foff:76589 size:04096 - [047] 0x4001B000 a--ms-- myputs.o.rodata.str1.1 foff:80685 size:04096 - - (e2dbg-0.65) p - - [Program Header Table .::. PHT] - [Object ./a.out_e2dbg] - - [00] 0x08045034 -> 0x08045134 r-x memsz(00256) filesz(00256) - [01] 0x08048134 -> 0x08048147 r-- memsz(00019) filesz(00019) - [02] 0x08045000 -> 0x080487FC r-x memsz(14332) filesz(14332) - [03] 0x080497FC -> 0x08049C30 rw- memsz(01076) filesz(01068) - [04] 0x08049810 -> 0x080498D8 rw- memsz(00200) filesz(00200) - [05] 0x08048148 -> 0x08048168 r-- memsz(00032) filesz(00032) - [06] 0x00000000 -> 0x00000000 rw- memsz(00000) filesz(00000) - [07] 0x00000000 -> 0x00000000 --- memsz(00000) filesz(00000) - - [SHT correlation] - [Object ./a.out_e2dbg] - - [*] SHT is not stripped - - [00] PT_PHDR - [01] PT_INTERP .interp - [02] PT_LOAD .elfsh.hooks .elfsh.extplt .elfsh.altplt .interp - .note.ABI-tag .hash .dynsym .dynstr .gnu.version - .gnu.version_r .rel.dyn .rel.plt .init .plt - .text .fini .rodata .eh_frame - [03] PT_LOAD .ctors .dtors .jcr .dynamic .got .got.plt .data - .bss .elfsh.altgot .elfsh.dynsym .elfsh.dynstr - .elfsh.reldyn .elfsh.relplt - [04] PT_DYNAMIC .dynamic - [05] PT_NOTE .note.ABI-tag - [06] PT_GNU_STACK - [07] PT_PAX_FLAGS - - [Runtime Program Header Table .::. RPHT] - [Object ./a.out_e2dbg] - - [00] 0x40019000 -> 0x4001A000 rw- memsz(4096) filesz(4096) - [01] 0x4001A000 -> 0x4001B000 r-x memsz(4096) filesz(4096) - [02] 0x4001B000 -> 0x4001C000 r-x memsz(4096) filesz(4096) - - [SHT correlation] - [Object ./a.out_e2dbg] - - [*] SHT is not stripped - - [00] PT_LOAD myputs.o.bss - [01] PT_LOAD myputs.o.text - [02] PT_LOAD myputs.o.rodata.str1.1 - - (e2dbg-0.65) - - - ========= BEGIN DUMP 30 ========= - - - - Our algorithm is not really optimized since it allocates - a new PT_LOAD by section. Here, we created a new table RPHT - (Runtime PHT) which handle the list of all runtime injected - pages. This table has no legal existance in the ELF file, - but that avoid to extend the real PHT with additional - runtime memory areas. The technique does not break PaX - since all zones are allocated using the strict necessary - rights. However, if you want to redirect existing functions - on the newly injected functions from myputs.o, then you - will have to change some code in runtime, and then it - becomes necessary to disable mprotect option to avoid - breaking PaX. - - - ----[ B. ET_REL relocation into ET_DYN - - - - We ported the ET_REL injection and the EXTPLT technique to - ET_DYN files. The biggest difference is that ET_DYN files have - a relative address space ondisk. Of course, stripped binaries - have no effect on our algorithms and we dont need any - non-mandatory information such as debug sections or anything - (it may be obvious but some peoples really asked this). - - Let's see what happens on this ET_DYN host file: - - - ========= BEGIN DUMP 31 ========= - - elfsh@WTH $ file main - main: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), - stripped - - elfsh@WTH $ ./main - 0x800008c8 main(argc=0xbfa238d0, argv=0xbfa2387c, envp=0xbfa23878, - auxv=0xbfa23874) __guard=0xb7ef4148 - ssp-all (Stack) Triggering an overflow by copying [20] of data into [10] - of space - main: stack smashing attack in function main() - Aborted - - elfsh@WTH $ ./main AAAAA - 0x800008c8 main(argc=0xbf898e40, argv=0xbf898dec, envp=0xbf898de8, - auxv=0xbf898de4) __guard=0xb7f6a148 - ssp-all (Stack) Copying [5] of data into [10] of space - - elfsh@WTH $ ./main AAAAAAAAAAAAAAAAAAAAAAAAAAA - 0x800008c8 main(argc=0xbfd3c8e0, argv=0xbfd3c88c, envp=0xbfd3c888, - auxv=0xbfd3c884) __guard=0xb7f0b148 - ssp-all (Stack) Copying [27] of data into [10] of space - main: stack smashing attack in function main() - Aborted - - ========= END DUMP 31 ========= - - - For the sake of fun, we decided to study in priority the - hardened gentoo binaries [11] . Those comes with PIE (Position - Independant Executable) and SSP (Stack Smashing Protection) - built in. It does not change a line of our algorithm. Here - are some tests done on a stack smashing protected binary - with an overflow in the first parameter, triggering the - stack smashing handler. We will redirect that handler - to show that it is a normal function that use classical - PLT mechanisms. - - This is the code that we are going to inject : - - - ========= BEGIN DUMP 32 ========= - - elfsh@WTH $ cat simple.c - #include - #include - #include - - int fake_main(int argc, char **argv) - { - old_printf("I am the main function, I have %d argc and my " - "argv is %08X yupeelala \n", - argc, argv); - - write(1, "fake_main is calling write ! \n", 30); - - old_main(argc, argv); - - return (0); - } - - char* fake_strcpy(char *dst, char *src) - { - printf("The fucker wants to copy %s at address %08X \n", src, dst); - return ((char *) old_strcpy(dst, src)); - } - - void fake_stack_smash_handler(char func[], int damaged) - { - static int i = 0; - printf("calling printf from stack smashing handler %u\n", i++); - if (i>3) - old___stack_smash_handler(func, damaged); - else - printf("Same player play again [damaged = %08X] \n", damaged); - printf("A second (%d) printf from the handler \n", 2); - } - - int fake_libc_start_main(void *one, void *two, void *three, void *four, - void *five, void *six, void *seven) - { - static int i = 0; - - old_printf("fake_libc_start_main \n"); - printf("start_main has been run %u \n", i++); - return (old___libc_start_main(one, two, three, four, - five, six, seven)); - } - - ========= END DUMP 32 ========= - - - The elfsh script that allow for the modification is : - - - ========= BEGIN DUMP 33 ========= - - elfsh@WTH $ cat relinject.esh - #!../../../vm/elfsh - - load main - load simple.o - - reladd 1 2 - - redir main fake_main - redir __stack_smash_handler fake_stack_smash_handler - redir __libc_start_main fake_libc_start_main - redir strcpy fake_strcpy - - save fake_main - - quit - - ========= END DUMP 33 ========= - - - Now let's see this in action ! - - - ========= BEGIN DUMP 34 ========= - elfsh@WTH $ ./relinject.esh - - - The ELF shell 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - ~load main - - [*] Sun Jul 31 17:24:20 2005 - New object main loaded - - ~load simple.o - - [*] Sun Jul 31 17:24:20 2005 - New object simple.o loaded - - ~reladd 1 2 - - [*] ET_REL simple.o injected succesfully in ET_DYN main - - ~redir main fake_main - - [*] Function main redirected to addr 0x00005154 - - ~redir __stack_smash_handler fake_stack_smash_handler - - [*] Function __stack_smash_handler redirected to addr - 0x00005203 - - ~redir __libc_start_main fake_libc_start_main - - [*] Function __libc_start_main redirected to addr - 0x00005281 - - ~redir strcpy fake_strcpy - - [*] Function strcpy redirected to addr 0x000051BD - - ~save fake_main - - [*] Object fake_main saved successfully - - ~quit - - [*] Unloading object 1 (simple.o) - [*] Unloading object 2 (main) * - .:: Bye -:: The ELF shell 0.65 - - ========= END DUMP 34 ========= - - - What about the result ? - - - ========= BEGIN DUMP 35 ========= - - elfsh@WTH $ ./fake_main - fake_libc_start_main - start_main has been run 0 - I am the main function, I have 1 argc and my argv is BF9A6F54 yupeelala - fake_main is calling write ! - 0x800068c8 main(argc=0xbf9a6e80, argv=0xbf9a6e2c, envp=0xbf9a6e28, - auxv=0xbf9a6e24) __guard=0xb7f78148 - ssp-all (Stack) Triggering an overflow by copying [20] of data into [10] - of space - The fucker wants to copy 01234567890123456789 at address BF9A6E50 - calling printf from stack smashing handler 0 - Same player play again [damaged = 39383736] - A second (2) printf from the handler - - elfsh@WTH $ ./fake_main AAAA - fake_libc_start_main - start_main has been run 0 - I am the main function, I have 2 argc and my argv is BF83A164 yupeelala - fake_main is calling write ! - 0x800068c8 main(argc=0xbf83a090, argv=0xbf83a03c, envp=0xbf83a038, - auxv=0xbf83a034) __guard=0xb7f09148 - ssp-all (Stack) Copying [4] of data into [10] of space - The fucker wants to copy AAAA at address BF83A060 - - elfsh@WTH $ ./fake_main AAAAAAAAAAAAAAA - fake_libc_start_main - start_main has been run 0 - I am the main function, I have 2 argc and my argv is BF8C7F24 yupeelala - fake_main is calling write ! - 0x800068c8 main(argc=0xbf8c7e50, argv=0xbf8c7dfc, envp=0xbf8c7df8, - auxv=0xbf8c7df4) __guard=0xb7f97148 - ssp-all (Stack) Copying [15] of data into [10] of space - The fucker wants to copy AAAAAAAAAAAAAAA at address BF8C7E20 - - ========= END DUMP 35 ========= - - - No problem there : strcpy, main, libc_start_main and - __stack_smash_handler are redirected on our own routines - as the output shows. We also call write that was not available - in the original binary, which show that EXTPLT also works on - ET_DYN objects, the cool stuff beeing that it worked without - any modification. - - In the current release (0.65rc1) there is a limitation on ET_DYN - however. We have to avoid non-initialized variables because - that would add some entries in relocation tables. This is not - a problem to add some since we also copy .rel.got (rel.dyn) in - EXTPLT on ET_DYN, but it is not implemented for now. - - - ----[ C. Extending static executables - - - - Now we would like to be able to debug static binary the same way - we do for dynamic ones. Since we cannot inject e2dbg using - DT_NEEDED dependances on static binaries, the idea is to inject - e2dbg as ET_REL into ET_EXEC since it is possible on static - binaries. E2dbg as many more dependancies than a simple host.c - program. The extended idea is to inject the missing part of - static libraries when it is necessary. - - We have to resolve dependancies on-the-fly while ET_REL injection - is performed. For that we will use a simple recursive algorithm - on the existing relocation code : when a symbol is not found - at relocation time, either it is a old_* symbol so it is delayed - in a second stage relocation time (Indeed, old symbols appears - at redirection time, which is done after the injection of the - ET_REL file so we miss that symbol at first stage), or the - function symbol is definitely unknown and we need to add - information so that the rtld can resolve it as well. - - To be able to find the suitable ET_REL to inject, ELFsh load all - the ET_REL from static library (.a) then the resolution is done - using this pool of binaries. The workspace feature of elfsh is - quite useful for this, when sessions are performed on more than - a thousand of ET_EXEC ELF files at a time (after extracting - modules from libc.a and others static librairies, for instance). - - Circular dependancies are solved by using second stage relocation - when the required symbol is in a file that is being injected after - the current file. The same second stage relocation mechanism - is used when we need to relocate ET_REL objects that use OLD - symbols. Since OLD symbols are injected at redirection time and - ET_REL files should be injected before (so that we can use - functions from the ET_REL object as hook functions), we do not - have OLD symbols at relocation time. The second stage relocation - is then triggered at save time (for on disk modifications) or - recursively solved when injecting multiple ET_REL with circular - relocation dependances. - - A problem is remaining, as for now we had one PT_LOAD by injected - section, we quickly reach more than 500 PT_LOAD. This seems to be - a bit too much for a regular ELF static file. We need to improve - the PT_LOAD allocation mechanism so that we can inject bigger - extension to such host binaries. - - This technique provide the same features as EXTPLT but for static - binaries : we can inject what we want (regardless of what the host - binary contains). - - So here is a smaller working example: - - - ========= BEGIN DUMP 36 ========= - - elfsh@WTH $ cat host.c - #include - #include - #include - - int legit_func(char *str) - { - puts("legit func !"); - return (0); - } - - int main() - { - char *str; - char buff[BUFSIZ]; - read(0, buff, BUFSIZ-1); - - puts("First_puts"); - - puts("Second_puts"); - - fflush(stdout); - - legit_func("test"); - - return (0); - } - - elfsh@WTH $ file a.out - a.out: ELF 32-bit LSB executable, Intel 80386, statically linked, - not stripped - - elfsh@WTH $ ./a.out - - First_puts - Second_puts - legit func ! - - ========= END DUMP 36 ========= - - - The injected file source code is as follow : - - - ========= BEGIN DUMP 37 ========= - - elfsh@WTH $ cat rel2.c - #include - #include - #include - #include - #include - - - int glvar_testreloc = 42; - int glvar_testreloc_bss; - char glvar_testreloc_bss2; - short glvar_testreloc_bss3; - - - int hook_func(char *str) - { - int sd; - - printf("hook func %s !\n", str); - - return (old_legit_func(str)); - } - - - int puts_troj(char *str) - { - int local = 1; - char *str2; - int fd; - char name[16]; - void *a; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - memset(name, 0, 16); - - printf("Trojan injected ET_REL takes control now " - "[%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - gethostname(name, 15); - printf("hostname : %s\n", name); - - printf("printf called from puts_troj [%s] \n", str); - - fd = open("/etc/services", 0, O_RDONLY); - - if (fd) - { - if ((a = mmap(0, 100, PROT_READ, MAP_PRIVATE, fd, 0)) == (void *) -1) - { - perror("mmap"); - close(fd); - printf("mmap failed : fd: %d\n", fd); - return (-1); - } - printf("-=-=-=-=-=- BEGIN /etc/services %d -=-=-=-=-=\n", fd); - printf("host : %.60s\n", (char *) a); - printf("-=-=-=-=-=- END /etc/services %d -=-=-=-=-=\n", fd); - printf("mmap succeed fd : %d\n", fd); - close(fd); - } - - - old_puts(str); - fflush(stdout); - return (0); - } - - ========= END DUMP 37 ========= - - - The load_lib.esh script, generated using a small bash - script, looks like this : - - - ========= BEGIN DUMP 38 ========= - - elfsh@WTH $ head -n 10 load_lib.esh - #!../../../vm/elfsh - load libc/init-first.o - load libc/libc-start.o - load libc/sysdep.o - load libc/version.o - load libc/check_fds.o - load libc/libc-tls.o - load libc/elf-init.o - load libc/dso_handle.o - load libc/errno.o - - ========= END DUMP 38 ========= - - - Here is the injection ELFsh script: - - - ========= BEGIN DUMP 39 ========= - - elfsh@WTH $ cat relinject.esh - #!../../../vm/elfsh - - exec gcc -g3 -static host.c - exec gcc -g3 -static rel2.c -c - - load a.out - load rel2.o - - source ./load_lib.esh - - reladd 1 2 - - redir puts puts_troj - redir legit_func hook_func - - save fake_aout - - quit - - ========= END DUMP 39 ========= - - - Stripped output of the injection : - - - ========= BEGIN DUMP 40 ========= - elfsh@WTH $ ./relinject.esh - - The ELF shell 0.65 (32 bits built) .::. - - .::. This software is under the General Public License V.2 - .::. Please visit http://www.gnu.org - - ~exec gcc -g3 -static host.c - - [*] Command executed successfully - - ~exec gcc -g3 -static rel2.c -c - - [*] Command executed successfully - - ~load a.out - [*] Sun Jul 31 16:37:32 2005 - New object a.out loaded - - ~load rel2.o - [*] Sun Jul 31 16:37:32 2005 - New object rel2.o loaded - - ~source ./load_lib.esh - ~load libc/init-first.o - [*] Sun Jul 31 16:37:33 2005 - New object libc/init-first.o loaded - - ~load libc/libc-start.o - [*] Sun Jul 31 16:37:33 2005 - New object libc/libc-start.o loaded - - ~load libc/sysdep.o - [*] Sun Jul 31 16:37:33 2005 - New object libc/sysdep.o loaded - - ~load libc/version.o - [*] Sun Jul 31 16:37:33 2005 - New object libc/version.o loaded - - [[... 1414 files later ...]] - - [*] ./load_lib.esh sourcing -OK- - - ~reladd 1 2 - - [*] ET_REL rel2.o injected succesfully in ET_EXEC a.out - - ~redir puts puts_troj - - [*] Function puts redirected to addr 0x080B7026 - - ~redir legit_func hook_func - - [*] Function legit_func redirected to addr 0x080B7000 - - ~save fake_aout - - [*] Object fake_aout saved successfully - - ~quit - - [*] Unloading object 1 (libpthreadnonshared/pthread_atfork.oS) - [*] Unloading object 2 (libpthread/ptcleanup.o) - [*] Unloading object 3 (libpthread/pthread_atfork.o) - [*] Unloading object 4 (libpthread/old_pthread_atfork.o) - - [[... 1416 files later ...]] - - .:: Bye -:: The ELF shell 0.65 - - ========= END DUMP 40 ========= - - - Does it works ? - - - ========= BEGIN DUMP 41 ========= - - elfsh@WTH $ ./fake_aout - - Trojan injected ET_REL takes control now [Z:First_puts:42:43:44:45:1] - hostname : WTH - printf called from puts_troj [First_puts] - -=-=-=-=-=- BEGIN /etc/services 3 -=-=-=-=-= - host : # /etc/services - # - # Network services, Internet style - # - # Not - -=-=-=-=-=- END /etc/services 3 -=-=-=-=-= - mmap succeed fd : 3 - First_puts - Trojan injected ET_REL takes control now [Z:Second_puts:42:43:44:45:1] - hostname : WTH - printf called from puts_troj [Second_puts] - -=-=-=-=-=- BEGIN /etc/services 3 -=-=-=-=-= - host : # /etc/services - # - # Network services, Internet style - # - # Not - -=-=-=-=-=- END /etc/services 3 -=-=-=-=-= - mmap succeed fd : 3 - Second_puts - hook func test ! - Trojan injected ET_REL takes control now [Z:legit func !:42:43:44:45:1] - hostname : WTH - printf called from puts_troj [legit func !] - -=-=-=-=-=- BEGIN /etc/services 3 -=-=-=-=-= - host : # /etc/services - # - # Network services, Internet style - # - # Not - -=-=-=-=-=- END /etc/services 3 -=-=-=-=-= - mmap succeed fd : 3 - legit func ! - ========= END DUMP 41 ========= - - - Yes, It's working. Now have a look at the fake_aout static - file : - - - - ========= BEGIN DUMP 42 ========= - - elfsh@WTH $ ../../../vm/elfsh -f ./fake_aout -s - - [*] Object ./fake_aout has been loaded (O_RDONLY) - - [SECTION HEADER TABLE .::. SHT is not stripped] - [Object ./fake_aout] - - [000] 0x00000000 ------- foff:000000 sz:00000 - [001] 0x080480D4 a------ .note.ABI-tag foff:069844 sz:00032 - [002] 0x08048100 a-x---- .init foff:069888 sz:00023 - [003] 0x08048120 a-x---- .text foff:69920 sz:347364 - [004] 0x0809CE10 a-x---- __libc_freeres_fn foff:417296 sz:02222 - [005] 0x0809D6C0 a-x---- .fini foff:419520 sz:00029 - [006] 0x0809D6E0 a------ .rodata foff:419552 sz:88238 - [007] 0x080B2F90 a------ __libc_atexit foff:507792 sz:00004 - [008] 0x080B2F94 a------ __libc_subfreeres foff:507796 sz:00036 - [009] 0x080B2FB8 a------ .eh_frame foff:507832 sz:03556 - [010] 0x080B4000 aw----- .ctors foff:512000 sz:00012 - [011] 0x080B400C aw----- .dtors foff:512012 sz:00012 - [012] 0x080B4018 aw----- .jcr foff:512024 sz:00004 - [013] 0x080B401C aw----- .data.rel.ro foff:512028 sz:00044 - [014] 0x080B4048 aw----- .got foff:512072 sz:00004 - [015] 0x080B404C aw----- .got.plt foff:512076 sz:00012 - [016] 0x080B4060 aw----- .data foff:512096 sz:03284 - [017] 0x080B4D40 aw----- .bss foff:515380 sz:04736 - [018] 0x080B5FC0 aw----- __libc_freeres_ptrs foff:520116 sz:00024 - [019] 0x080B6000 aw----- rel2.o.bss foff:520192 sz:04096 - [020] 0x080B7000 a-x---- rel2.o.text foff:524288 sz:04096 - [021] 0x080B8000 aw----- rel2.o.data foff:528384 sz:00004 - [022] 0x080B9000 a------ rel2.o.rodata foff:532480 sz:04096 - [023] 0x080BA000 a-x---- .elfsh.hooks foff:536576 sz:00032 - [024] 0x080BB000 aw----- libc/printf.o.bss foff:540672 sz:04096 - [025] 0x080BC000 a-x---- libc/printf.o.text foff:544768 sz:04096 - [026] 0x080BD000 aw----- libc/gethostname.o.bss foff:548864 sz:04096 - [027] 0x080BE000 a-x---- libc/gethostname.o.text foff:552960 sz:04096 - [028] 0x080BF000 aw----- libc/perror.o.bss foff:557056 sz:04096 - [029] 0x080C0000 a-x---- libc/perror.o.text foff:561152 sz:04096 - [030] 0x080C1000 a--ms-- libc/perror.o.rodata.str1.1 foff:565248 sz:04096 - [031] 0x080C2000 a--ms-- libc/perror.o.rodata.str4.4 foff:569344 sz:04096 - [032] 0x080C3000 aw----- libc/dup.o.bss foff:573440 sz:04096 - [033] 0x080C4000 a-x---- libc/dup.o.text foff:577536 sz:04096 - [034] 0x080C5000 aw----- libc/iofdopen.o.bss foff:581632 sz:04096 - [035] 0x00000000 ------- .comment foff:585680 sz:20400 - [036] 0x080C6000 a-x---- libc/iofdopen.o.text foff:585728 sz:04096 - [037] 0x00000000 ------- .debug_aranges foff:606084 sz:00136 - [038] 0x00000000 ------- .debug_pubnames foff:606220 sz:00042 - [039] 0x00000000 ------- .debug_info foff:606262 sz:01600 - [040] 0x00000000 ------- .debug_abbrev foff:607862 sz:00298 - [041] 0x00000000 ------- .debug_line foff:608160 sz:00965 - [042] 0x00000000 ------- .debug_frame foff:609128 sz:00068 - [043] 0x00000000 ------- .debug_str foff:609196 sz:00022 - [044] 0x00000000 ------- .debug_macinfo foff:609218 sz:28414 - [045] 0x00000000 ------- .shstrtab foff:637632 sz:00632 - [046] 0x00000000 ------- .symtab foff:640187 sz:30192 - [047] 0x00000000 ------- .strtab foff:670379 sz:25442 - - [*] Object ./fake_aout unloaded - - elfsh@WTH $ ../../../vm/elfsh -f ./fake_aout -p - - [*] Object ./fake_aout has been loaded (O_RDONLY) - - [Program Header Table .::. PHT] - [Object ./fake_aout] - - [00] 0x8037000 -> 0x80B3D9C r-x memsz(511388) foff(000000) =>Loadable seg - [01] 0x80B4000 -> 0x80B7258 rw- memsz(012888) foff(512000) =>Loadable seg - [02] 0x80480D4 -> 0x80480F4 r-- memsz(000032) foff(069844) =>Aux. info. - [03] 0x0000000 -> 0x0000000 rw- memsz(000000) foff(000000) =>Stackflags - [04] 0x0000000 -> 0x0000000 --- memsz(000000) foff(000000) =>New PaXflags - [05] 0x80B6000 -> 0x80B7000 rwx memsz(004096) foff(520192) =>Loadable seg - [06] 0x80B7000 -> 0x80B8000 rwx memsz(004096) foff(524288) =>Loadable seg - [07] 0x80B8000 -> 0x80B8004 rwx memsz(000004) foff(528384) =>Loadable seg - [08] 0x80B9000 -> 0x80BA000 rwx memsz(004096) foff(532480) =>Loadable seg - [09] 0x80BA000 -> 0x80BB000 rwx memsz(004096) foff(536576) =>Loadable seg - [10] 0x80BB000 -> 0x80BC000 rwx memsz(004096) foff(540672) =>Loadable seg - [11] 0x80BC000 -> 0x80BD000 rwx memsz(004096) foff(544768) =>Loadable seg - [12] 0x80BD000 -> 0x80BE000 rwx memsz(004096) foff(548864) =>Loadable seg - [13] 0x80BE000 -> 0x80BF000 rwx memsz(004096) foff(552960) =>Loadable seg - [14] 0x80BF000 -> 0x80C0000 rwx memsz(004096) foff(557056) =>Loadable seg - [15] 0x80C0000 -> 0x80C1000 rwx memsz(004096) foff(561152) =>Loadable seg - [16] 0x80C1000 -> 0x80C2000 rwx memsz(004096) foff(565248) =>Loadable seg - [17] 0x80C2000 -> 0x80C3000 rwx memsz(004096) foff(569344) =>Loadable seg - [18] 0x80C3000 -> 0x80C4000 rwx memsz(004096) foff(573440) =>Loadable seg - [19] 0x80C4000 -> 0x80C5000 rwx memsz(004096) foff(577536) =>Loadable seg - [20] 0x80C5000 -> 0x80C6000 rwx memsz(004096) foff(581632) =>Loadable seg - [21] 0x80C6000 -> 0x80C7000 rwx memsz(004096) foff(585728) =>Loadable seg - - [SHT correlation] - [Object ./fake_aout] - - [*] SHT is not stripped - - [00] PT_LOAD .note.ABI-tag .init .text __libc_freeres_fn .fini - .rodata __libc_atexit __libc_subfreeres .eh_frame - [01] PT_LOAD .ctors .dtors .jcr .data.rel.ro .got .got.plt - .data - .bss __libc_freeres_ptrs - [02] PT_NOTE .note.ABI-tag - [03] PT_GNU_STACK - [04] PT_PAX_FLAGS - [05] PT_LOAD rel2.o.bss - [06] PT_LOAD rel2.o.text - [07] PT_LOAD rel2.o.data - [08] PT_LOAD rel2.o.rodata - [09] PT_LOAD .elfsh.hooks - [10] PT_LOAD libc/printf.o.bss - [11] PT_LOAD libc/printf.o.text - [12] PT_LOAD libc/gethostname.o.bss - [13] PT_LOAD libc/gethostname.o.text - [14] PT_LOAD libc/perror.o.bss - [15] PT_LOAD libc/perror.o.text - [16] PT_LOAD libc/perror.o.rodata.str1.1 - [17] PT_LOAD libc/perror.o.rodata.str4.4 - [18] PT_LOAD libc/dup.o.bss - [19] PT_LOAD libc/dup.o.text - [20] PT_LOAD libc/iofdopen.o.bss |.comment - [21] PT_LOAD libc/iofdopen.o.text - [*] Object ./fake_aout unloaded - - ========= END DUMP 42 ========= - - - We can notice the ET_REL really injected : printf.o@libc, - dup.o@libc, gethostname.o@libc, perror.o@libc and - iofdopen.o@libc. - - Each injected file create several PT_LOAD segments. For this - example it is okay, but for injecting E2dbg that is really too - much. - - This technique will be improved as soon as possible by reusing - PT_LOAD entry when this is possible. - - - -----[ D. Architecture independant algorithms - - - - In this part, we give all the architecture independent algorithms - that were developed for the new residency techniques in memory, - ET_DYN libraries, or static executables. - - The new generic ET_REL injection algorithm is not that different - from the one presented in the first Cerberus Interface article [0], - that is why we only give it again in its short form. However, the - new algorithm has improved in modularity and portability. We will - detail some parts of the algorithm that were not explained in - previous articles. The implementation mainly takes place in - elfsh_inject_etrel() in the relinject.c file : - - - New generic relocation algorithm - +--------------------------------+ - - 1/ Inject ET_REL BSS after the HOST BSS in a dedicated section (new) - - 2/ FOREACH section in ET_REL object - [ - IF [ Section is allocatable and Section is not BSS ] - [ - - Inject section in Host file or memory - ] - ] - - 3/ Fuze ET_REL and host file symbol tables - - 4/ Relocate the ET_REL object (STAGE 1) - - 5/ At save time, relocate the ET_REL object - (STAGE 2 for old symbols relocations) - - - We only had one relocation stage in the past. We had to use another - one since not all requested symbols are available (like old symbols - gained from CFLOW redirections that may happen after the ET_REL - injection). For ondisk modifications, the second stage relocation - is done at save time. - - Some steps in this algorithm are quite straightforward, such as - step 1 and step 3. They have been explained in the first Cerberus - article [0], however the BSS algorithm has changed for compatibility - with ET_DYN files and multiple ET_REL injections. Now the BSS is - injected just as other sections, instead of adding a complex BSS - zones algorithm for always keeping one bss in the program. - - - ET_DYN / ET_EXEC section injection algorithm - +--------------------------------------------+ - - - Injection algorithm for DATA sections does not change between ET_EXEC - and ET_DYN files. However, code sections injection slighly changed - for supporting both binaries and libraries host files. Here is the - new algorithm for this operation : - - * Find executable PT_LOAD - * Fix injected section size for page size congruence - - IF [ Hostfile is ET_EXEC ] - [ - * Set injected section vaddr to lowest mapped section vaddr - * Substract new section size to new section virtual address - ] - ELSE IF [ Hostfile is ET_DYN ] - [ - * Set injected section vaddr to lowest mapped section vaddr - ] - - * Extend code segment size by newly injected section size - - IF [ Hostfile is ET_EXEC ] - [ - * Substract injected section vaddr to executable PT_LOAD vaddr - ] - - FOREACH [ Entry in PHT ] - [ - IF [ Segment is PT_PHDR and Hostfile is ET_EXEC ] - [ - * Substract injected section size to segment p_vaddr / p_paddr - ] - ELSE IF [ Segment stands after extended PT_LOAD ] - [ - * Add injected section size to segment p_offset - IF [ Hostfile is ET_DYN ] - [ - * Add injected section size to segment p_vaddr and p_paddr - ] - ] - ] - - IF [ Hostfile is ET_DYN ] - [ - FOREACH [ Relocation entry in every relocation table ] - [ - IF [ Relocation offset points after injected section ] - [ - * Shift relocation offset from injected section size - ] - ] - - * Shift symbols from injected section size when pointing after it - * Shift dynamic syms from injected section size (same condition) - * Shift dynamic entries D_PTR's from injected section size - * Shift GOT entries from injected section size - * If existing, Shift ALTGOT entries from injected section size - * Shift DTORS and CTORS the same way - * Shift the entry point in ELF header the same way - ] - - * Inject new SECTION symbol on injected code - - - Static ET_EXEC section injection algorithm - +------------------------------------------+ - - - This algorithm is used to insert sections inside static binaries. It - can be found in libelfsh/inject.c in elfsh_insert_static_section() : - - * Pad the injected section size to stay congruent to page size - * Create a new PT_LOAD program header whoose bounds match the - new section bounds. - * Insert new section using classical algorithm - * Insert new program header in PHT - - - Runtime section injection algorithm in memory - +---------------------------------------------+ - - - This algorithm can be found in libelfsh/inject.c in the function - elfsh_insert_runtime_section() : - - * Create a new PT_LOAD program header - * Insert SHT entry for new runtime section - (so we keep a static map up-to-date) - * Insert new section using the classical algorithm - * Insert new PT_LOAD in Runtime PHT table (RPHT) with same bounds - - - Runtime PHT is a new table that we introduced so that we can - separate segments regulary mapped by the dynamic linker (original - PHT segments) from runtime injected segments. This may lead to an - easier algorithm for binary reconstruction from its memory image - in the future. - - We will detail now the core (high level) relocation algorithm as - implemented in elfsh_relocate_object() and - elfsh_relocate_etrel_section() functions in libelfsh/relinject.c . - This code is common for all types of host files and for all - relocation stages. It is used at STEP 4 of the general algorithm: - - - Core portable relocation algorithm - +----------------------------------+ - - This algorithm has never been explained in any paper. Here it is : - - - FOREACH Injected ET_REL sections inside the host file - [ - FOREACH relocation entry in ET_REL file - [ - * Find needed symbol in ET_REL for this relocation - IF [ Symbol is COMMON or NOTYPE ] - [ - * Find the corresponding symbol in Host file. - IF [ Symbol is NOT FOUND ] - [ - IF [ symbol is OLD and RELOCSTAGE == 1 ] - [ - * Delay relocation for it - ] - ELSE - [ - IF [ ET_REL symbol type is NOTYPE ] - [ - * Request a new PLT entry and use its address - for performing relocation (EXTPLT algorithm) - ] - ELSE IF [ Host file is STATIC ] - [ - * Perform EXTSTATIC technique (next algorithm) - ] - ELSE - [ - * Algorithm failed, return ERROR - ] - ] - ] - ELSE - [ - * Use host file's symbol value - ] - ] - ELSE - [ - * Use injected section base address as symbol value - ] - - Relocate entry (switch/case architecture dependant handler) - ] - ] - - - EXTSTATIC relocation extension algorithm - +----------------------------------------+ - - In case the host file is a static file, we can try to get the - unknown symbol from relocatables files from static libraries that - are available on disk. An example of use of this EXTSTATIC technique - is located in the testsuite/etrel_inject/ directory. - - Here is the EXTSTATIC algorithm that comes at the specified place - in the previous algorithm for providing the same functionality as - EXTPLT but for static binaries : - - - FOREACH loaded ET_REL objects in ELFSH - [ - IF [ Symbol is found anywhere in current analyzed ET_REL ] - [ - IF [ Found symbol is strongest than current result ] - [ - * Update best symbol result and associated ET_REL file - ] - ELSE - [ - * Discard current iteration result - ] - ] - ] - * Inject the ET_REL dependency inside Host file - * Use newly injected symbol in hostfile as relocation symbol in core - relocation algorithm. - - - Strongest symbol algorithm - +--------------------------+ - - When we have to choose between multiple symbols that have the same - name in different objects (either during static or runtime - injection), we use this simple algorithm to determine which one - to use : - - - IF [ Current chosen symbol has STT_NOTYPE ] - [ - * Symbol becomes temporary choice - ] - ELSE IF [ Candidate symbol has STT_NOTYPE ] - [ - * Symbol becomes temporary choice - ] - ELSE IF [ Candidate symbol binding > Chosen symbol binding ] - [ - * Candidate symbol becomes Chosen symbol - ] - - - --------[ VI. Past and present - - - In the past we have shown that ET_REL injection into - non-relocatable ET_EXEC object is possible. This paper presented - multiple extensions and ports to this residency technique - (ET_DYN and static executables target). Coupled to the EXTPLT - technique that allow for a complete post-linking of the host - file, we can add function definitions and use unknown functions - in the software extension. All those static injection - techniques worse when all PaX options are enabled on the - modified binary. Of course, the position independant and stack - smashing protection features of hardened Gentoo does not protect - anything when it comes to binary manipulation, either performed - on disk or at runtime. - - We have also shown that it is possible to debug without using - the ptrace system call, which open the door for new reverse - engineering and embedded debugging methodology that bypass known - anti-debugging techniques. The embedded debugger is not - completely PaX proof and it is still necessary to disable the - mprotect flag. Even if it does not sound like a real problem, - we are still investigating on how to put breakpoints (e.g. - redirections) without disabling it. - - Our core techniques are portable to many architectures (x86, - alpha, mips, sparc) on both 32bits and 64bits files. However - our proof of concept debugger was done for x86 only. We believe - that our techniques are portable enough to be able to provide - the debugger for other architectures without much troubles. - - Share and enjoy the framework, contributions are welcome. - - --------[ VII. Greetings - - - We thank all the peoples at the WhatTheHack party 2005 in - Netherlands. We add much fun with you guys and again we will - come in the future. - - Special thanks go to andrewg for teaching us the sigaction - technique, dvorak for his interest in the optimization on the - the ALTPLT technique version 2 for the SPARC architecture, - sk for libasm, and solar for providing us the ET_DYN pie/ssp - testsuite. - - Respects go to Devhell Labs, the PaX team, Phrackstaff, GOBBLES, - MMHS, ADM, and Synnergy Networks. Final shoutouts to s/ash from - RTC for driving us to WTH and the Coconut Crew for everything - and the rest, you know who you are. - - --------[ VIII. References - - - [0] The Cerberus ELF Interface mayhem - http://www.phrack.org/show.php?p=61&a=8 - - [1] The GNU debugger GNU project - http://www.gnu.org/software/gdb/ - - [2] PaX / grsecurity The PaX team - http://pax.grsecurity.net/ - - [3] binary reconstruction from a core image Silvio Cesare - http://vx.netlux.org/lib/vsc03.html - - [4] Antiforensic evolution: Self Ripe & Pluf - http://www.phrack.org/show.php?p=63&a=11 - - [5] Next-Gen. Runtime binary encryption Zeljko Vbra - http://www.phrack.org/show.php?p=63&a=13 - - [6] Fenris Michal Zalewski - http://lcamtuf.coredump.cx/fenris/ - - [7] Ltrace Ltrace team - http://freshmeat.net/projects/ltrace/ - - [8] The dude (replacement to ptrace) Mammon - http://www.eccentrix.com/members/mammon/Text/d\ - ude_paper.txt - - [9] Binary protection schemes Andrewg - http://www.codebreakers-journal.com/viewar\ - ticle.php?id=51&layout=abstract - - [10] ET_REL injection in memory JP - http://www.whatever.org.ar/~cuco/MERCANO.TXT - - [11] Hardened Gentoo project Hardened team - http://www.gentoo.org/proj/en/hardened/ - - [12] Unpacking by Code Injection Eduardo Labir - http://www.codebreakers-journal.com/viewart\ - icle.php?id=36&layout=abstract - \ No newline at end of file diff -Nru eresi-0.8a25/doc/.svn/text-base/Changelog.svn-base eresi-0.0.20110516/doc/.svn/text-base/Changelog.svn-base --- eresi-0.8a25/doc/.svn/text-base/Changelog.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/Changelog.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,404 +0,0 @@ - - ------------------------ - Changelog file for ELFsh - ------------------------ - - -Changes in intermediate beta versions are listed in the first public version -they appear. - -0.71a1: -------- - - Added : Now loads dependences when loading a file (also added deps API) - - Core : Change in the id naming scheme of objects - - Core : Changed elfsh_inject_etrel_withlist for using hashes - - Core : Removed lists a bit everywhere (elfshjob, elfshobj) to use hashes - - Added : Improved libhash API (5 more functions !) - -0.7a10-cela: ------------- - - Bugfix : Added sanity checks to elfsh_load_hdr() - - Core : Now save memory as much as possible when top-injecting sections - -0.7a9-anjo: ------------ - - Core : Improved the symbol priority resolving using linkmap in e2dbg - -0.7a8-moto: ------------ - - Bugfix : fixed pre-interp issues on relinjection (bug #18) - - Added : ELFSH_SELECT_INJECTION macro - -0.7a7p2: --------- - - Bugfix : bss.c - Fixed SIGSEGV on fixup with enabled debugging - - Bugfix : libelfsh/include/libelfsh-internat.h - fixed ELFSH_PROFILE_ERR and XCLOSE - - removed compilation warnings - - added support for strerror for FreeBSD - - Bugfix : copy.c - added missing file->fstat, file->fd, file->shtrb - - Bugfix : bug #3 fixed - - Bugfix : Modflow - fixed profiling error when recognition of ptr functions was enabled - -0.7a7p1: --------- - - Bugfix : Added missing libmjollnir - - Bugfix : Removed double definition of ELFSH_EDITION - - Bugfix : Fixed SIGSEGV after strip/save (by zg) - - Added : New opperand in libasm - i386_jp/0x8a - - Core : elfshobj_t contains struct stat for fstat() of the object - - Core : switched sht_rebuild.c to file->fstat.st_size - - Bugfix : Fixed SIGSEGV on set 1.hdr.arch 3 on corrupted binaries - - Bugfix : Fixed SIGSEGV after sstrip/save - -0.7a6p3: --------- - - Added : libmjollnir for dress-like features and other usefull stuff (WIP) - -0.7a6p2: --------- - - - Bugfix : Modflow profiling errors - - Added : New opperands in libasm on x86 i386_bswap/i386_shld_rmv_rv_cl/ - => i386_bsf - - Bugfix : libui/color.c vm_colorget segfaults if curtok > COLOR_TOKENS - - Added : Prototype of recognisince of pointer functions in modflow - - Bugfix : vm/disasm.c display_instr, world.curjob->proc was not initialised - - Core : small code cleanup - -0.7a6p1: --------- - - Added : Support for FreeBSD - -0.7a : ------- - - Added : Dynamic entries lookup by type - - Core : Now hijack __libc_start_main instead of main (works on stripped) - - Added : Full stepping support on x86 - - Bugfix : Corrected backtrace onthefly (e2dbg/user separation) - - Added : Registers as variables on breakpoint/step hit - - Added : vm_lookup_bp (breakpoint lookup by symbol / id) - - Added : display command - - Core : Now 2 different commands for stack dumping (stack vs dbgstack) - - Core : Now supporting static and runtime scripts - - Core : New help system - - Added : redir without parameters print redirections list in current file - - Core : Included libhashelfsh in libelfsh - - Added : Watchpoints - - Bugfix : Various bugs related to the variables type system - - Added : Runtime SHT/PHT extension for the ELF format - - Added : rsht/rpht commands and scripting objects - - Bugfix : corrected elfsh_error and io.buf accesses when not using readline - - Added : --More-- - - Added : Colors (by mxatone) - - Added : log command (can save sessions i/o) - - Bugfix : full testsuite working again - - Added : a Real e2dbg command for the debugger - - Added : More variable API (vm/variables.c) - - Added : Added variable $SHELL and $EDITOR with adaptation of configure - - Added : better completion (constants, ELF objects ..) - - Added : Multiple workspaces with hotkey (^X) - - Added : alert command for color events - - Added : Full support (elf + scripting) for version tables (by mxatone) - - Core : Dedicated heap for the debugger (now link with libmalloc-e2dbg.a) - - Core : Dedicated thread for the debugger - - Added : start command for starting the debuggee program - - Added : empty line will now repeat the last command - - Core : Support of aspect vectors (array of hooks) saved in vectors hash table - -0.65rc1 (August 1st 2005) : ---------------------------- - - Added : Support for variables (and $_ variable) - - Core : Slighly modified vm_lookup_param() interface for variable support - - Added : compare (cmp) command - - Added : control flow (jmp, je, jne, jg, jl, jge, jle commands) - - Added : Label support for jmp instructions - - Added : Variable indexes capability - - Added : Script parameters support - - Added : implicit variable conversions from string to integer - - Added : flowjack command in modflow - - Added : double variables ($$var) : assign variables to the names of others - - Added : $# variable (argc) - - Core : print without parameter now goes to next line - - Added : Possible dynamic convertion into RAW object - - Core : More checks before launching script (resolve bug reported by truff) - - Added : insert command (can insert sections and symbols in scripting) - - Core : OpenBSD fixes (by mjc) and BeoS patch (by zadig) - - Added : remove command (can remove symbols and sections in scripting) - - Bugfix : Stripping now OK - - Added : Flush command - - Added : Optional size parameter to 'write' command - - Added : Help handler for modules (with modhelp command) - - Added : elfsh_symtab_endianize (for advanced cross endianness support) - - Added : configure by hand - - Bugfix : Better cross-endianizing support - - Core : ELF64 support - - Added : Sparc64 relocation types ASCII tables - - Core : ET_REL injection / PLT infection hooks support - - Core : internal hook API (vm_register_plthook / vm_register_relhook) - - Added : ELF binaries mere-OS fingerprinting - - Bugfix : Now copy file before saving (avoid unwanted stripping in CWF) - - Bugfix : SPARC ALTPLT 'relplt bug' fixed on solaris. (thx dvorak for help ;) - - Added : Support for extended PHT types (recent pax/binutils compat) - - Added : PHDR insertion API - - Bugfix : No more 'quit' at the end of script necessary - - Core : Virtual interface for I/O (vm/io.c) - - Bugfix : Module commands were not well executed in loops (reported by yannmalcom) - - Added : Network support (initiated by yannmalcom) - - Added : Shared working files - - Bugfix : $_ value were not assigned correctly on non-immed types in atomic commands - - Core : Lazy types for CHAR, SHORT, LONG (part of 32/64bits interface) - - Added : ASCII tables relocations types for MIPS, ALPHA and IA64 - - Added : PLT hijacking on ALPHA - - Core : Extended elfsh hooks to static hijack and altplt hijack handlers - - Core : Changed elfsh_insert_section() return type (now elfshsect_t *) - - Core : Changed option handler for allowing multiple regexp for D command - - Added : 'source' command now execute an external script in the same job - - Added : "$!' command now contain the last loaded file id - - Added : remove command and API for PHT entries - - Added : New PaX safe control flow hook for x86 - - Added : Now compute dynsym symbols vaddr when new version of ld let them blanks - - Core : (sk) 20/04/2005 display_instr prototype and function modification - - Added : CFLOW on MIPS - - Core : In-process scripting capability - - Added : Macros using the scriptsdir command - - Core : Compatibility with the most recent binutils/glibc - - Added : vm_exec_str() function API - - Core : elfsh/e2dbg profiler implied changes in the error handling - - Added : EXTPLT technique on x86 - - Added : workspace support - - Core : Now 2 stage relocation engine - - Added : EXTSTATIC technique (static files extension) - - Added : ET_REL injection into memory - - Added : EXTPLT is now compatible with ET_REL injection into memory - - Added : Insertion and removing of breakpoints for x86 - - -0.51b3 (August, 21, 2003) ------------------------- - - Bugfix : Fixed 'Malloc problem' on Solaris when using postbss injection - - Bugfix : patched cmdline bug when displaying sections after injecting symbols - => no segfault in r, c, and st commands on solaris :> - - Added : 'r' command now print addend on Sparc - - Fixed paths in Makefile as requested by Gentoo - - Bugfix : Take care that SHT do not overlap newly injected unmapped section - - -0.51b2 (August, 15, 2003) -------------------------- - - Core : new elfsh_sort_symtab(), now use libc's quicksort (by spacewalker) - - Bugfix : now detect bad scripts looking at the first line - - Bugfix : Fixed incorrect size check in elfsh_get_dynentry_string() - - Bugfix : Fixed missing' -D' in readline Makefile variables - - Bugfix : Fixed section link when reconstructing the symtab - - Core : Clarified strtab interface (now elfsh_get_strtab()); - - Bugfix : Fixed injected symbol string bug on stripped binaries. - - Added : Full support for .dynamic flags and non-standard tags - - Added : elfsh_reverse_metasym(elfshobj_t *file, u_int vaddr, int *off) - - Added : modflow : a control flow block builder - - Added : modgraph : can output control flow graph generated by modflow - - Added : command 'redir' (for function hijacking) - - Added : New ALTPLT technique (build .orig.plt and inject old_funcname symbols) - - Bugfix : Special case for STT_SECTION symbols used in ET_REL injection/relocation - - Added : working ET_REL injection on SPARC - - -0.5b8 (May, 19, 2003) ---------------------- - - Added : Section injection by index - - Added : Relocation entry insertion - - Core : Better .rel* output (now print only symname) - - Added : SHT sorting for ET_REL object - - Bugfix : Added missing space in command 'print' - - Added : handlers for sctndx field of symtab ent - - Added : Wrote elfsh-ref.txt - - Added : ET_REL injection into ET_EXEC - - Added : Fix _end when injected symbol st_value > _end - - Added : ~ before every command in the script output file - - Bugfix : Check if dyn.val < dynstr.size before printing dynamic string - - Added : stop command (useful for debugging) - - Core : New arch independant GOT interface - - Added : SET/GET by name for SHT, Sections, GOT, CTORS, DTORS, SYMTAB, DYNSYM - - Added : Support for cross-endianess binaries (by phix@hush.com) - - Added : Sparc relocation switch (by thegrugq) - - Core : merged various code stubs into elfsh_shift_symtab() - - Bugfix : fix disasm.c compilation problem when libasm is not used - - Core : elfsh_create_symbol() now takes one more parameter - - Core : elfsh_create_section_header() is now elfsh_create_shdr() - - -0.5b6 (March, 23, 2003) ------------------------ - - Added : A lot of tiny function to get/set fields in various headers . - - Added : scripting - - Added : .interp write access - - Added : File access by index in file table - - Added : RW script API for got/ctors/dtors/symtab/dynsym/ehdr/shdr/phdr/dynamic - - Added : print and info commands - - Added : info target in root Makefile - - Added : comments support in scripts - - Added : regression tests script in testsuite - - Added : atomic arithmetic commands (add/sub/mul/div/mod) - - Added : symbol resolve as immediate value - - Added : ELFMACROS can be resolved as immediate value (new struct : t_const) - - Added : elfsh_dyn target in the elfsh's Makefile (for embedded elfshellz ;) - - Core : RW support for new PAX flags emplacement(and code moved in libelfsh) - - Core : New API for RW section flags access . - - Core : Now print numerical value if field type is unknown - - Core : Fixup command - - Core : Timestamp on all entries - - Added : Compile without readline possible - - Core : Changed option fetching engine (even more clean now) - - Core : Created the world structure (useful for modules engine) - - Added : Variable parameter command support (print and exec commands uses it) - - Added : findrel command : display all the absolute reference of the file - - Added : command redirection API - - Core : Changed elfsh typenames, the object name format is now : elfshobjname_t - - Added : Full module support - - Change : Better (un)load and switch (no list parsing, now use hashtable) - - Added : support for ELF objects with buggy header - - Added : support for \xNNN patterns in string constants - - Added : strip and sstrip command (sstrip = strip + shtrm) - - Change : Moved elfsh_get_dynentry_info() into vm_dynentinfo() - - Change : Now can X and D on section[0] (at file offset = 0 and vaddr = 0) - - Added : ELF API for .dynsym, .symtab, and SHT entries name - - Added : Shell modif for section data, section name and symbols name - - Added : Raw data RW in scripting (offset possible, no specified size needed ;) - - Added : Append and Extend commands - - Added : Better sorting code and symtab SECTION entry synchro with SHT values - - Change : Changed print so that we can print objects values in the string - - Contrib: modremap.c (by spacewalker) - - Added : Lazy object typing - - Change : Improved remapping code using section type based heuristics - - -0.5b3 (ML release on January, 26, 2003) ---------------------------------------- - - Bugfix : Better SHT reconstruction . - - Bugfix : Fixed some warning due to -Wall . - - Added : regx for PHT view . - - Added : Tell if the sht has been reconstructed or not . - - Added : disassembly (using libasm by sk@devhell.org) - - Added : regx in disassembling command line option . - - Added : Inverse symbol lookup using libasm-callback feature . - - Added : RVA disassembling (precise RVA with :rva at the end of regex) - - Added : Range scanning (precise size with %size at the total end of regx) - - Added : elfsh_get_symbol_by_value(); - - Added : int elfsh_get_vaddr_from_foffset(Elfsh32_Obj *file, u_int foffset); - - Added : elfsh_insert_section_header() now returns used range - - Added : elfsh_get_sym_from_shtentry(); - - Added : elfsh_create_symbol() now returns a symbol instead of a ptr - - Added : int elfsh_fixup_symtab(Elfsh32_Obj *file); - - Added : Elfsh32_Sect *elfsh_rebuild_strtab(Elfsh32_Obj *file) - - Added : -w option to acknowledge file modification - - Added : support range scanning using file offsets and vaddr for -D option - - Added : -q (quiet) option, for tiny screens :-) - - Added : PAX bits support in ELF header - - Added : First interactive mode (load/unload/list/save/switch/quit) - - Change : Better Makefile hierarchy for testsuite - - Added : Comment section support - - Change : elfsh_get_symbol_offset() is now elfsh_get_symbol_value() - - Change : More cross-reference in .symtab and .rel.* displays . - - Added : Arrays/variables support with .rodata match in -X - - Added : Section injection by top cap (gr33ts to zilvio for the tekn1k) - - Added : Hashtables support - - Change : Option name scanner rewrite (now hash based) - -0.43b (June, 05, 2002) ----------------------- - - Bugfix : Improved documentation and fixed typos . - - Added : SHT reconstruction code example in the testsuite . - - Bugfix : Added chmod in the install target of the main Makefile . - -0.43a (June, 01, 2002) ---------------------- - - Added : Elfsh32_Obj *elfsh_map_obj(char *new_filename); - - Added : int elfsh_save_obj(Elfsh32_Obj *file, char *new_filename); - - Added : Support full hexdump for object without symtab . - - Added : elfsh_raw_write() . - - Added : GOT rw API . - - Core : Improved PLT interface . - - Added : CTORS and DTORS rw API . - - Added : ELF header rw API - - Added : .sh_strtab and .strtab string rw API . - - Bugfix : Now support hexdump on non mapped sections (thx to kad for report) - - Bugfix : Special output case for PLT entry - - Added : Symtab rw API . - - Added : testsuite for GOT, CTORS, DTORS and SYMTAB EXTEND . - - Added : Program header rw API and Section header rw API . - - Added : Section mapped/unmapped injection support with testsuite - - Added : Section header table removing support . - - Output : Dynamic entry types short print . - - Output : Double output for program header table . - - Core : Improved pht interface : elfsh_get_parent_segment() and elfsh_segment_is_parent() . - - Output : Inproved Relocation outputs . - - Bugfix : Forgotten the shortcut -st for -sym, thanks to kad again ;-) - - Added : Minimal SHT reconstruction . - - Added : True documentation ! - -0.39 (March, 02, 2002) ----------------------- - - Core : Now use homemade Elf32_Sect object to describe sections - - Core : Every homemade structure are now called Elfsh32_name . - - Added : ctors/dtors view and got/ctors/dtors symbol matching with regx . - - Added : symbol and dynamic symbol names output for STT_SECTION symbols when using -sym and -dynsym - - Added : parent section name in the (dyn) symbol table output . - - Added : better symbol matching in the relocation sections output . - - Core : Now performing match on the whole line - - Added : alignement print for sections and program headers . - - Added : Using section names in lfsh_reverse_symbol() if no symtab - - Added : General improved output . - - Added : elfsh_raw_read() . - - Added : variables printing with symbol matching - - Added : hexadecimal/ascii viewer for Function and Sections (-X) - -0.3 (December, 12, 2001) ------------------------- - - section loading API major update (look at the doc !) - - rights retreiving API major update (look at the doc !) - - name retreiving API major update (look at the doc !) - - better error handling code - - symbol -hash- lookup debugged :) - - global offset table API and displaying - - stabs displaying cleaning - - multiple relocation section support - - multiple notes sections support - - libname change ! elflib is now elfshlib - - no more elfdump ! here is elfsh - - corrected bug in relocation sections displaying for relocatable objects - - "elf_" prefixed functions are now prefixed with "elfsh_" - - Makefile sources tree cleaning - - ELFOBJ is now ELf32_Obj - - New objects: Elf32_Func, Elf32_Sect, Elf32_Plt, ELf32_PLTent - - syscall wrapping MINI-API : XALLOC, XSEEK, XREAD, XOPEN - - moved constant arrays from libelfsh to elfsh . - - added an interval macro . - - change the error system a bit . - - changed the lookup method for .interp and .dynamic (use pht now) - - coded sort function for symbols (sort by size or by addr) - - coded symbol table merging functions . - - libelfsh now use automake and autoconf . - - ported to solaris !! (stabs unimplemented on solaris) . - -0.21b (June, 13, 2001) ----------------------- - - netbsd/freebsd/openbsd port - - .interp support - - .note support - - ELFsh syntax improved - - First documentation writing - -0.2b (May 2001) ---------------- - - section search by name - - dynamic section analysis - - symbol/dynsymbol inverse lookup - - section and segments right retreiver - - stabs support - - relocation entries analysis - - pattern matching - - elf magic checking - - better error handling - - cool options handling macros system - - better dependancies checks - - shared library (libelf.so) in Makefile - - Extra free() removed in elf_unload_obj (elf.c) diff -Nru eresi-0.8a25/doc/.svn/text-base/CREDITS.svn-base eresi-0.0.20110516/doc/.svn/text-base/CREDITS.svn-base --- eresi-0.8a25/doc/.svn/text-base/CREDITS.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/CREDITS.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ - -Credits go to these peoples for contributing, finding and -fixing bugs and giving reliable advices and ideas, those -who are the first target audience. - - dot .:: - dvorak .:: - emper0r .:: - grugq .:: - kad .:: - kil3r .:: - ptah .:: - Fred Raynal .:: - Phil Biondi .:: - PaX team .:: - rix .:: - sauron .:: - scut .:: - Shaun Clowes .:: - silvio .:: - yannmalcom .:: - zadig .:: - zorgon .:: - -Honours go to all the researchers for the great -litterature provided on the Internet. Special -shoutouts to Devhell Labs, and all the peoples -not quoted here who know who they are. diff -Nru eresi-0.8a25/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1141 +0,0 @@ -# Doxyfile 1.5.2 - -###################### -# General options. -# -# - -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = eresi -PROJECT_NUMBER = $ -OUTPUT_DIRECTORY = ./doxygen -CREATE_SUBDIRS = YES -OUTPUT_LANGUAGE = English - -############## -# Output rendering options. -# -# - -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = YES - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = ./doxygen-warns.log - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = liballocproxy/ libasm/ libaspect/ libe2dbg/ libedfmt/ \ - libetrace/ libkernsh/ libelfsh/ libregex/ libmjollnir/ \ - libstderesi/ librevm/ libui kernsh/ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = */.svn/* - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html/ - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -#HTML_HEADER = doc/header.html - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -#HTML_FOOTER = doc/footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -#HTML_STYLESHEET = http://s.eresi-project.org/inc/doxy.css - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = NO - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = YES diff -Nru eresi-0.8a25/doc/.svn/text-base/elfsh-draft.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/elfsh-draft.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/elfsh-draft.txt.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/elfsh-draft.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,186 +0,0 @@ - - ----------- - ELFSH DRAFT - ----------- - - -This is not a documentation, but a draft paper for developers who -want to take part of the development process of ELFsh . This file -describes the present and future orientation of the ELF shell from -an instruction based scripting point of view . The syntax is not -definitive and may change if we need it, so please contact the -team if you plan to contribute to the project . - -For the current exhaustive ELFsh commands list and descriptions, use -'help' and 'info' commands from within the shell . - - -Token : - -REGX : REGEX_T:INDEX%SIZE -OBJ : ELFSHPATH_T | VALUE -VALUE : NAME | NUMBER -NAME : [a-zA-Z0-9-_]+ -NUMBER : [0-9]+ - - -The shell scanner and parser need to be rewritten using flex and bison . - - -List of commands : - - -quit - - Quit the shell without saving anything . - -help - - Print the help scren . - -list - Print the list of loaded files, ELFsh modules, and variables - or the bean . - -info - Print detailed information about the commands syntax . - - -exec command with arguments - - Execute a elfsh script or a command line . - - -switch VALUE - - Switch on another elf object (the object must have been loaded first) . - - -load NAME - - Load a new file in the shell . - - -save VALUE - - Save the object in foreground . - - -unload VALUE - - Unload the object from foreground without saving changes . - - -get OBJ -set OBJ OBJ -add OBJ OBJ -sub OBJ OBJ -mul OBJ OBJ -div OBJ OBJ -mod OBJ OBJ - SYMBOL/DYNSYMBOL/SECTION name (lookup_immed) - IMMEDIATE 1/2/4 bytes values (lookup_immed) - CONSTANT_FROM_ELF_H (lookup_immed) - hdr.field (lookup3) - got[index] (lookup3_index) - ctors[index] (lookup3_index) - dtors[index] (lookup3_index) - pht[index].field (lookup4) - sht[index].field (lookup4) - symtab[index].field (lookup4) - dynsym[index].field (lookup4) - dynamic[index].field (lookup4) - symtab[index].name (lookup4) - dynsym[index].name (lookup4) - section[index].name (lookup4) - section[index].raw (lookup4) - section[index:byte_offset].raw (lookup4) - rel[index][index2].field (lookup5_index) - - section[index].{byte,word,long}[index] (4) no handler (good) - section[index:byte_offset].{byte,word,long}[index] (5) no handler (good) - - section[index].instr[index].field (5) no handler (good) - section[index:byte_offset].instr[index].field (6) no handler (good) - - - - GET print the field of the chosen object . - SET modify the value of the first object by the value of the second one . - ADD/SUB/MUL/DIB/MOD are the usual arithmetic operations . - - -write - - OBJ OBJ - - Raw write in an object - - -delete - $OBJ - - Delete an object from the bean . - - -insert - OBJ NUM - - Insert an object from the bean to the current working file . $OBJ - can be typed the same as GET/SET parameters . NUM is the range to - be used for the insertion . - - -mode NAME - - Switch to simple/expert mode . When elfsh runs in simple mode, implicit changes - are done and printed if the verbose mode is ON . For instance, if you add - a function, the section size and the segment size are modified . - - - -%$£%$£%$£%$£%$£%$£%$£%$£%$££%$£ LIST OF NECESSITY %$£%$£%$£%$£%$£%$£%$£%$£%$£%$£%$£%$£ - - -Everything has a name . We use a special prefix for each type of object followed -by an underscore and the object name . - -Prefix: -~~~~~~~ - -Symbols : "SYM_" -Dynamic symbols : "DSYM_" -Sections : "SCT_" -Segments : "SEG_" -Functions : "FCT_" -Relocation entries : "REL_" -Dynamic entries : "DYN_" -Elf Header : "HDR_" - - -Dynamic variable allocation is needed . - - - -What is simple/expert mode ? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to add or remove an object in the binary, like a function, -there's many changes you have to do . Simple mode do the changes for you, - -Expert mode does only what you explicitely asked . By default, the ELF shell -is in simple mode . Here is an exhaustive list of what the shell does for -you in simple mode, but not in expert mode : - -- Add .plt , .got, .rel.plt , .dynsym and .hash entries when accessing external functions . -- Add .rel.got, .dynsym and .hash entries when accessing external data . -- Relocate the code with our rebuilt .rel.text equilavent table when you insect a mapped section . -- Modify the PT_LOAD size and addr when inserting a section . -- Update the dynamic section with the new parameters . - - -Comments : elfsh@devhell.org - - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/elfsh-network-0.3.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/elfsh-network-0.3.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/elfsh-network-0.3.txt.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/elfsh-network-0.3.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,129 +0,0 @@ - - Created Wed Mar 10 18:39:35 CET 2004 yann malcom - Updated Fri Mar 12 14:12:48 CET 2004 mayhem - - ________________________________________ - - ELFsh .::. Road to distributed computing - - ________________________________________ - - -___________host1____________________ _________host2_________________ -| ________________ | | ________________ | -| | elfsh | (3a,b) | | | elfsh | | -| | parent |- - - - - - - - - -| parent | | -| | | | | _/| | | -| |______________| | |_/ |_______________| | -| / | | _/ / \ | -| / (1) | (1) |_/ | | (1) | | -| ___|___ ___|___ _/ | ----- ----- | -| | | | | _/ | | | | | | | -| |child| |child|---------/ | | |child| |child| | -| |_____| |_____| (c) | | |_____| |_____| | -| |(2) |(2) | | | | | -| | | | | | (2) | | -| [terminal] | | | . . | -| | | | . . | -------------------|----------------- ------------------------------- - | - [telnet/nc/whatever] - -(1) - The parent never act on elfsh object, he just handle request from - other elfsh parents. In that way all break the waiting state will - quickly be answered. The children act on elfsh object. They use shared - memory in order to do that. (1) is just a fork() . - -(2) - Children can be attached either to one terminal (using std{in,out}) either - across TCP sockets (remote client). If a child has to delegate a part of the - computing, he broadcast a UDP request on the peer2peer network, multiple remote - agents may compute the request, the fastest computer will reply in first (digital - darwinism) and will by the same time invalidate the computing request on the - peer to peer network using canal (3a) and a I_DID_COMPUTE message. - -(3) The elfsh parents are waiting for UDP requests, which can be either I_AM_HERE (a) - messages, I_DID_COMPUTE (b) messages, or I_NEED_TO_COMPUTE (c) messages. Messages - in this category may not block the source process for an answer, since they are - one-way canals. Actions in the process includes: - - For (a), simply add the received information in the list of known nodes. This list - can be used when sending (3c) messages. - - For (b), communicate computing answer to children using shared memory. In case the - child process havent got an answer to the computing he requested at the moment when - the necessity is critical, the child process which emmited the request may compute it - itself, and send (c) message to kill all the remote process that were created for - computing this request. - - FIXME: how to associate a given request to the child process who did requested - it ? (without pipes would be better). - - For (c), the receiver process checks its computing power, eventually create - a new child process and send a (b) message when the computing is over (if we - are not killed before) - - - -[:. Ideas .:] - - The followind ideas where inspired by 'A Unified Peer-to-Peer Database Framework - for Scalable Service and Resource Discovery' by Wolfgang Hoschek. - - [> Timeouts are important : <] - - Dynamic Abort Timeout is used to avoid that a request spread for - a while on the network. - - Static Loop Timeout is used to not proceed the same request - more than one time. - - [> Several unique identifier : <] - - Request Identifier : They are needed to Loop detection. - - Object Identifier : To identify ELFsh Objects ( Note : one - structure can be modified along its life ) - - Node Identifier - FIXME : how to choose these unique identifiers ? - - - [> Objects spreading : <] - - Compute are done on object. To increase the number of nodes - which can do this compute at a given time, it would be - interresting to spread objects over the network when nodes are unused - and network load is low. - - In order to do that, a broadcasting of aviable object could be done - at the same time of annoucing itself. - - So that each node can have a list of node which can handle a - request. This list is not complete because of objects - spreading but it can be a good approximation. - - Objects dependancy shall be translate into Object Identifier. - So that, a node can ask another node do give him a result - concerning this object if he hasn't it. - - [> Various : <] - - the protocol version should be announced to accpted futur - modification. - - the same with the node version - - [> Details : <] - - possibility to set a hook on the recv/send fonction in order - to encapsulate data in another protocol like DNS :) - - [> Future or no future ? <] - - Can we imagine a robust open protocol that another people may - use to join our reversing network with nodes which have - another capabilities ? We can imagine of spreading - Capabilities informations in additions of others. - - - Multi-agent system is the future :) - -1) le fait que renvoyer les resultats par le meme chemin que les -requetes offre l'avantage de moins de tracabilit ce qui peut etre un -avantage. - -2) que l'id e de requetes recursives est sympa aussi : - genre chaque node peut decouper la tache en plus petites taches et -demander a d'autres noeuds de faire le calculs, puis il rassemble les -info qui correspondent au resultat qu'on lui a demand et le retourne a -celui qui lui a demand . - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/elfsh-ref.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/elfsh-ref.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/elfsh-ref.txt.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/elfsh-ref.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,330 +0,0 @@ - -Last update Tue Apr 8 08:21:25 2003 mayhem - - - ---------------------------------- - ELFsh 0.5b6 INTERNAL API reference - ---------------------------------- - - -1/ Command API -2/ Object manipulation API -3/ Object creation API -4/ Hash API -5/ Option API -6/ Execution API - - - -The Full API can be used in modules . You should consider writing a module instead -of patching ELFsh when you need to extend it without patching it . - - - - -1/ You want to add your own commands . You can register and unregister new -commands, or hijack an existing command handlers to your own routines . -vm_setcmd() is the same than vm_addcmd() except it doesnt create a new command, -but change an existing command parameters ; use special value ELFSH_ORIG for -vm_setcmd() parameters to keep them to their original value . - -int vm_setcmd(char *cmd, void *exec, void *reg, u_int needcur); -int vm_addcmd(char *cmd, void *exec, void *reg, u_int needcur); -int vm_delcmd(char *cmd); - -- cmd : Name of the command -- exec : Execution handler (see script API below) -- reg : Registration handler (see option API below) -- needcur : The command need a valid current ELF object - -Return value : 0 (OK), -1 (ERR) - - - - -2/ You want to create, convert, lookup, register, or unregister ELFsh objects : - - -int vm_convert_object(elfshpath_t *obj, u_int objtype); - -- obj : An existing abtract ELFsh object returned by vm_lookup_param() -- objtype : The requested output type - - ELFSH_OBJINT (double word) - ELFSH_OBJRAW (raw data) - ELFSH_OBJSTR (string) - - -Return : 0 (OK), -1 (ERR) - - -int vm_lookup_param(char *path, elfshpath_t *pobj, u_int mode); - -Returns the abstract object giving its path . See ELFsh 'info' command for -objects path format . Second parameter 'pobj' need to point on allocated -memory . When 'mode' is 1, vm_lookup_param() do not print error in case -of invalid path (PROBE MODE) . Returns 0 or -1 in case of error . - - -elfshobj_t *vm_getfile(u_int id); - -Returns the ELF object descriptor giving its object ID . Returns NULL in case -of error . - - -elfshmod_t *vm_getmod(u_int id); - -Returns the ELFsh module descriptor giving its object ID . Returns NULL in -case of error . - - -int vm_check_object(elfshpath_t *pobj); - -Check the object sanity (check handlers sanity depending on the object type) . -Returns 0 (Sane), -1 (Corrupted) - - - - -3/ You want to add your own object into the ELFsh hierarchy : - - - -elfshL1_t *vm_create_L1ENT(void *(*get_obj)(elfshobj_t *file), - void *(*get_obj_idx)(elfshobj_t *file, u_int range, - u_int *nbr) - hash_t *l2_hash, - void *(*get_entptr)(void *table, int index), - u_int *(*get_entval)(void *table) - u_int *(*set_entval)(void *table, u_int elem) - u_int elem_size); - - -a - get_obj() : Returns a pointer on the L1 object table -b - get_obj_idx() : Returns a pointer on the L1 object table giving its index -c - l2_hash : Pointer on the child L2 objects hash table -d - get_entptr() : Returns a pointer on the requested L1 object table entry -e - get_entval() : Returns the value of requested L1 object table entry -f - set_entval() : Change the requested L1 object table entry value -g - elem_size : Size of table element - - -You need : - - * Mandatory a (used by * except .rel*) OR mandatory b (used by .rel*) - * Mandatory c and g (used by *) - * Optional d/f/g (used by got/ctors/dtors) - - -This function create a Level 1 object . Default L1 objects are : - - - ELF header (label : 'hdr') - - Program header table (label : 'pht') - - Symbol table (label : 'symtab') - - Dynamic symbol table (label : 'dynsym') - - Dynamic section (label : 'dynamic') - - Global Offset Table (label : 'got') - - CTORS (label : 'ctors') - - DTORS (label : 'dtors') - - Relocation tables (label : 'rel') - - Section list (lavel : 'section') - - -elfshL2_t *vm_create_L2ENT(u_int (*get_obj)(void *ptr), - u_int (*set_obj)(void *ptr, u_int val), - char type, - char *(*get_name)(elfshobj_t *file, void *ptr), - int *(*set_name)(elfshobj_t *file, void *ptr, - char *name), - void *(*get_data)(elfshsect_t *obj, u_int off, - u_int sizelem), - void *(*set_data)(elfshsect_t *sect, u_int off, - char *data, u_int sz, - u_int szelem)); - - -Create a L2 object . Each L1 object has a family of L2 objects . See ELFsh -'info' command for a complete list of L2 objects . Returns the object or -NULL if error . - - -a - get_obj : Return the leaf object value [ptr: the parent L1 object ptr] -b - set_obj : Set the leaf object value -c - type : ELFSH_OBJINT, ELFSH_OBJSTR, ELFSH_OBJRAW -d - get_name : Return the leaf object name [ptr: the actual L2 object ptr] -e - set_name : Change the leaf object name -f - get_data : Read data from object -g - set_data : Write data in object - -You need : - - * Mandatory a, b, c - * Optional d, e (used for symbol and sections names) - * Optional f, g (used for reading/writing section's data) - - - - -4/ Modify ELFsh hash tables . ELFsh hashes everything, you need to register -objects using the hash table API : - - -int hash_init(hash_t *h, int size); /* Allocate new table */ -void hash_destroy(hash_t *h); /* Free table */ -int hash_add(hash_t *h, char *key, void *data); /* Add entry */ -int hash_del(hash_t *h, char *key); /* Delete entry */ - -- h : The hash table -- size : The hash table entry number (big tables are faster) -- key : The hash table entry name -- data : The data object to be indexed - -See libhash/*.c for the complete hash code . - - - -Existing hash tables are : - -The command hash table : hash_t cmd_hash; -Hash ELFsh command names and returns elfshcmd_t pointers. - -The constants hash table : hash_t const_hash; -Hash [elf.h/elfsh.h] constant names and returns elfshconst_t pointers. - -The ELFsh modules table : hash_t mod_hash; -Hash modules pathes and returns elfshmod_t pointers. - -The loaded ELF objects table : hash_t file_hash; -Hash Loaded ELF object pathes and returns elfshobj_t pointers. - -The Level 1 objects table : hash_t L1_hash; -Hash L1 objects labels and returns elfshL1_t pointers. - -Level2 ELF header table : hash_t elf_L2_hash; -Hash ELF header field labels and returns elfshL2_t pointers. - -Level2 Section objects : hash_t sht_L2_hash; -Hash SHT entry fields labels and returns elfshL2_t pointers. - -Level2 PHT objects : hash_t pht_L2_hash; -Hash PHT entry fields labels and returns elfshL2_t object pointers. - -Level2 .symtab objects : hash_t sym_L2_hash; -Hash Symbol table entry fields labels and returns elfshL2_t object pointers. - -Level2 .rel* objects : hash_t rel_L2_hash; -Hash Relocation tables entry fields labels and returns elfshL2_t object pointers. - -Level2 .dynsym objects : hash_t dynsym_L2_hash; -Hash Dynamic symbol table entry fields names and returns elfshL2_t object pointers. - -Level2 .dynamic objects : hash_t dyn_L2_hash; -Hash Dynamic Linker section entry fields labels and returns elfshL2_t pointers. - -Level2 Section data objs : hash_t sct_L2_hash; -Hash Sections elfshL2_t objects labels and returns elfshL2_t pointers. - - - -You should _not_ manipulate cmd_hash, mod_hash and file_hash manually, since -a special command and ELF objects API is available (see 1/ and 2/) . - -See elfsh/tables.c for initialization calls of those tables . - - - - - -5/ Option fetching API - - -ELFsh provides many default commands parameters fetching registration handlers, -mainly used to specify the parameters number and type for a given command . The -'reg' command handler (see 1/) should be filled with one of those : - -- vm_getoption() .::. the command need 1 regular parameter -- vm_getregxoption() .::. the command need 1 regex parameter -- vm_getoption2() .::. the command need 2 regular parameters -- vm_getoption3() .::. the command need 3 regular parameters -- vm_getvarparams() .::. the command need at least 1 regular parameter - -See elfsh/opt.c - - - - -6/ Execution API - -ELFsh provides one function per command, the execution handler 'exec' -is called _after_ the option fetching 'reg' handler (see 1/) . Here are -the core commands execution handlers : - -int cmd_dyn(); -int cmd_sht(); -int cmd_rel(); -int cmd_dynsym(); -int cmd_symtab(); -int cmd_pht(); -int cmd_got(); -int cmd_dtors(); -int cmd_ctors(); -int cmd_elf(); -int cmd_interp(); -int cmd_list(); -int cmd_notes(); -int cmd_sym(); -int cmd_stab(); -int cmd_hexa(); -int cmd_disasm(); -int cmd_shtrm(); -int cmd_comments(); -int cmd_help(); -int cmd_quit(); -int cmd_load(); -int cmd_unload(); -int cmd_save(); -int cmd_dolist(); -int cmd_doswitch(); -int cmd_set(); -int cmd_get(); -int cmd_print(); -int cmd_info(); -int cmd_add(); -int cmd_sub(); -int cmd_mul(); -int cmd_div(); -int cmd_mod(); -int cmd_meta(); -int cmd_write(); -int cmd_append(); -int cmd_extend(); -int cmd_fixup(); -int cmd_quiet(); -int cmd_verb(); -int cmd_exec(); -int cmd_findrel(); -int cmd_modload(); -int cmd_modunload(); - -Your own execution handlers must have the same prototypes . See 'help' -command output for complete description of existing commands . - - -*EOF* - - - - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/eresi.1.svn-base eresi-0.0.20110516/doc/.svn/text-base/eresi.1.svn-base --- eresi-0.8a25/doc/.svn/text-base/eresi.1.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/eresi.1.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,942 +0,0 @@ -.\" define indentation for suboptions -.\" .nr SS 5 -.\" default indentation is 7, don't change! -.\" .nr IN 7 -.\" add new suboption -.\" .de IPs -.\" .IP "\\$1" \n(SS -.\" .. -.\" begin of first level suboptions, end with .RE -.\" .de RSs -.\" .RS \n(IN+3 -.\" .. -.\" begin of 2nd level suboptions -.\" .de RSss -.\" .PD 0 -.\" .RS \n(SS+3 -.\" .. -.\" end of 2nd level suboptions -.\" .de REss -.\" .RE -.\" .PD 1 -.\" .. -.TH "ERESI" "1" "May 2007" "ERESI 0.78" "User commands" -.SH "NAME" -ERESI \- The ERESI Reverse Engineering Software Interface -.SH "SYNOPSIS" -.B elfsh [\fIOPTIONS\fR] - -.B etrace [\fIOPTIONS\fR] - -.B e2dbg \fIprogramtodebug\fR - -.B kernsh -.SH "DESCRIPTION" -The ERESI Reverse Engineering Software Interface is a unified reverse engineering framework for UNIX operating systems based on the Executable & Linking Format (ELF) such as Linux, BSD, Solaris, IRIX, and BeOS. It has a command line interface that make it useful remotely, and can generate graph images from code analysis on demand. It has a real dedicated reverse engineering language that makes it scriptable and adaptable to the precise needs of the users. ERESI contains more than 10 innovative and exclusive features that turns it into an environment of choice for the instrumentation, analysis, debugging, tracing, hooking, or simply integrity checking and events logging of binary programs. ERESI is composed of ELFsh (the ELF shell), E2dbg (The Embedded ELF debugger) and Etrace (The Embedded ELF tracer). This documentation applies on all of the components. -.SH "OPTIONS" -The ELF shell (part of ERESI) can take the following command line parameters: - -.B -.IP \-f -input file -.B -.IP \-w -output file - - -Note that the command line is slightly different for E2dbg and Etrace which do -NOT take those parameters. -.SH "COMMANDS" -E2dbg and Etrace have to be executed using a unique command line parameter (the program file to be debugged or traced). The following primitives can be used interactively in E2dbg, Etrace, and ELFsh, but also on command line when preceded by a \- (ELFsh only) at the UNIX shell command prompt. - -.TP -\fBGeneral purpose commands\fP - -\fIcat edit exec exit help info list load lscripts nocolor profile quit sdir setcolor switch unload workspace\fR - -.TP -\fBcat\fP -print the file argument - -.TP -\fBedit\fP -Edit the file given in parameter - -.TP -\fBexec\fP -Fork and execute parameter command (with args) - -.TP -\fBhelp\fP -Print the help screen - -.TP -\fBinfo\fP -Print the extra details help screen - -.TP -\fBlist\fP -List the loaded files and their ID - -.TP -\fBload\fP \fIfilename\fR -Load input file \fIfilename\fR - -.TP -\fBlscripts\fP -List macro commands - -.TP -\fBnocolor\fP -Toggle color status - -.TP -\fBprofile\fP (\fIenable\fR | \fIdisable\fR) (\fItraces\fR | \fIwarns\fR | \fIalloc\fR | \fIdebug\fR | \fIall\fR) - -Change the ELFsh profiling behavior. Traces profiling print all the internal function calls done by the framework. Warning profiling prints all the (fatal and non\-fatal) warnings reported by the internal API : it very useful for tracking bugs and it should be used when reporting issues on the bugtracking system. Allocation and debug profiling are experimental and should only be used by experienced ERESI developers. - -.TP -\fBquit\fP -Quit the shell without saving - -.TP -\fBsdir\fP -Change the script directory. This allows to make precise the location of complete ERESI library and bind script files on command names in the shell. - -.TP -\fBsetcolor\fP \fIAssociates data types to colors\fR - -\fBsetcolor\fP \fItype [bg,fg] color\fR - -\fBsetcolor\fP \fItype [underline,bold] (1=on,0=off)\fR - -\fBAvailable types :\fP \fIaddress, number, string, endstring, warnstring typestring, fieldstring, instr, pspecial, psname pspecial, pversion, prelease, pedition\fR - -\fBAvailable colors :\fP \fIblack red green yellow blue magenta cyan white\fR - -.TP -\fBswitch\fP (\fIfilename\fR | \fIfileID\fR) -Change the current file to work on to \fIfilename\fR or \fIfileID\fR - -.TP -\fBunload\fP (\fIfilename\fR | \fIfileID\fR) -Unload file \fIfilename\fR or \fIfileID\fR without saving - -.TP -\fBworkspace\fP [\fIwname\fR] -When executed without parameter, this command list existing workspaces. When given an existing workspace name, this command switch to that workspace. If given a non\-existing workspace name, this command creates a new workspace and switch to it. - -.TP -\fBtables\fP [\fIregex\fR] -If given without parameter, list all the existing hash tables in the ERESI framework. If given with a parameter, -print the content of hash tables whoose name match the regular expression. - - -.TP -\fBvectors\fP [\fIvname\fR[\fI:idx1:...:idxN\fR]] [\fIsymbol|addr\fR] -If given without parameter, list all the existing vectors in the ERESI framework. If given with a parameter, -print the content of this vector. If given one long parameter, print the content of a given vector entry. If -given 2 parameters, modify the vector entry with a user provided address or resolved symbol address. - -.TP -\fB========================================================================\fP - -.TP -\fBOndisk/Memory ELF commands\fP - -Those commands works in all components of the ERESI framework (ELFsh, E2dbg, and Etrace). - -\fIadd cmp ctors disasm div dtors dyn dynsym elf findrel get got hexa interp mod mul notes pht print redir rel reladd set sht sub write test\fR - -.TP -\fBadd\fP -Add the 2 parameters and put the result in variable $_ - -.TP -\fBcmp\fP -Compare 2 parameters. The difference is put in variable $_ - -.TP -\fBct ctors\fP [\fIRegex\fR] -Print .ctors section entries matching \fIRegex\fR - -.TP -\fBD disasm\fP [\fIRegex\fR] -Disassemble matching binary objects in current file - -\fBdisasm parameter\fP - -Allowed parameter format : \fIregx regx:rva regx:rva%size regx%size\fR - \- regx : Regular expression (mandatory) - \- rva : Byte offset from the beginning (optional) - \- size : Bytes number limit (optional) - -.TP -\fBdiv\fP -Divide first param by second one and put the result in the first one - -.TP -\fBdt dtors\fP [\fIRegex\fR] -Print .dtors section entries matching \fIRegex\fR - -.TP -\fBdyn\fP -Print the ELF dynamic section - -.TP -\fBds dynsym\fP [\fIRegex\fR] -Print dynamic symtab (.dynsym) entries matching \fIRegex\fR - -.TP -\fBe elf\fP -Print the ELF header - -.TP -\fBfindrel\fP -Try to find back stripped relocation information. Note: retreiving this information in a -very exact manner is very difficult, this command only gives you an approximative list -of pointer accesses in the binary code. It does not deal either with constructed addresses -using multiple arithmetic and logic instructions, or with false positives that appear to -be valid mapped pointers but are not in reality (ex: Hashed data) - -.TP -\fBget\fP -Print parameter object value. The parameter can be a constant or defined value, a variable or any -ELF object that is part of any file loaded in the shell, provided you give its id at the beginning -of the object path. See info command for the exact grammar of object paths. - -.TP -\fBg got\fP [\fIRegex\fR] -Print the entries of the Global Offset Table (GOT) matching \fIRegex\fR. The regex can apply on -either an address, an entry index, or a resolved symbol from the entry address (or contained -address). - -.TP -\fBX hexa\fP [\fIRegex\fR] -Dump matching binary objects in current file. This has the same syntax than D/disasm command. - -\fBX parameter\fP - -ParamFormat : \fIregx regx:rva regx:rva%size regx%size\fR - \- regx : Regular expression (mandatory) - \- rva : Byte offset from the beginning (optional) - \- size : Bytes number limit (optional) - -.TP -\fBinterp\fP -Print ELF interpreter path standing in .interp section. - -.TP -\fBmod\fP -Modulo operation between 2 parameters. The result is put in the destination variable. - -.TP -\fBmul\fP -Multiply the 2 parameters. The result is put in the destination variable. - -.TP -\fBn notes\fP [\fIRegex\fR] -Print the Notes sections entries matching \fIRegex\fR - -.TP -\fBp pht\fP -Print the Program Header Table (PHT) - -.TP -\fBprint\fP [\fIObjectPath1 ObjectPath2 ... ObjectPathN\fR] -Print the values of objects \fIObjectPath1 ObjectPath2 ... ObjectPathN\fR. Objects can be -constant strings, ELF objects, variables, defined values, and so on. - -.TP -\fBredir\fP \fIfunc\fR (\fIfunc2\fR | \fIaddr\fR) -Redirect calls to function \fIfunc\fR to \fIfunc2\fR or address \fIaddr\fR. If the original function has a PLT entry, the ALTPLT technique is used to perform the redirection. If the function is internal (or if we are in a static binary) the CFLOW technique is used to perform the redirection. ALTPLT technique is available on INTEL, SPARC, MIPS, and ALPHA architectures. CFLOW technique is currently not available on the SPARC architecture. The hook (second) function is usually an injected C code provided by the user and injected using the \fIreladd\fR primitive. In case the provided hook function calls other function which are not in the host binary, ERESI will use the EXTPLT technique (or EXTSTATIC technique on static binaries) to relink the host binary in order to add new relocation entries, dynamic symbols with their names, symbol versions, extra GOT and PLT entries (using additionally the ALTGOT technique on RISC architectures), and will fixup the .dynamic section to reflect those changes on the section list. - -.TP -\fBr rel\fP [\fIRegex\fR] -Print the relocation entries matching \fIRegex\fR - -.TP -\fBreladd\fP (\fIDestFilePath | \fIDestfileID\fR) (\fIRelocFilePath | \fIRelocFileID\fR) -Inject the ELF relocatable object \fIRelocFileID\fR into the ELF executable object \fIDestFileID\fR. This command is used for injecting plain C compiled code linked into a .o file into a host ET_EXEC (executable) or ET_DYN (shared library) ELF file. - -.TP -\fBset\fP \fIDestObjectPath SourceObjectPath\fR -Set the value of object \fIDestObjectPath\fR to \fISourceObjectPath\fR. The $_ variable gets modified depending on the result. See the \fBinfo\fP command for a list of all accessible objects using the set command. - -.TP -\fBs sht\fP [\fIRegex\fR] -Print the sections in the Section Header Table (SHT) matching \fIRegex\fR - -.TP -\fBsub\fP -Substract 2nd parameter to the first one. The $_ variable is modified depending on the result. - -.TP -\fBwrite\fP \fIDestObjectPath SourceObjectPath\fR -Copy data from \fISourceObjectPath\fR to \fIDestObjectPath\fR. The destination object has to be of type RAW (the data field of a section) and the source object has to be of type RAW or STRING. See the info command for more detail about this. - -.TP -\fB========================================================================\fP - -.TP -\fBDebugger commands\fP - -\fIbacktrace break continue dbgstack delete dumpregs linkmap stack step display threads itrace\fR - -.TP -\fBbacktrace\fR -Print backtrace (needs frame pointer). - -.TP -\fBbreak (\fIBPsymbol\fR | \fI0xaddress\fR)\fR -Put a breakpoint on symbol or address. Print all breakpoints if given without parameter. - -.TP -\fBstep\fP - -Enable or disable stepping of debuggee program. Use \fBcontinue\fP for singlestepping. - -.TP -\fBcontinue\fP - -Continue executing debuggee program after breakpoint or singlestep. - -.TP -\fBdelete\fP (\fIBPID\fR | \fIBPsymbol\fR | \fI0xaddress\fR) - -Delete breakpoint by symbol, address, or ID. - -.TP -\fBdbgstack\fP \fIWordsNBR\fR - -Dump N words (N given as first parameter) from the debugger stack. We can do that because the debugger is embedded into the debuggee process. - -.TP -\fBstack\fR \fIWordsNBR\fR - -Dump \fIWordsNBR\fR words on debuggee stack. - -.TP -\fBdumpregs\fR - -Dump registers of debuggee at breakpoint or step. - -.TP -\fBlinkmap\fR - -Print Linkmap list for the debuggee process. - -.TP -\fBdisplay\fR \fIBPid\fR \fIFull_ERESI_command\fR -Set a command to be executed on event. The first parameter must be the breakpoint id that correspond to the event. The ERESI command can be any valid ERESI command, including the sourcing of an ERESI script. - -.TP -\fBthreads\fR [\fIThreadID\fR] -If called without parameter, this command list existing threads in the debuggee process. If called with a thread ID parameter, the current thread is switched to the thread indicated by the ID. - -.TP -\fBitrace\fR -Singlestep the debuggee program until next breakpoint event, printing all executed instructions until it stops. - - -.TP -\fB========================================================================\fP - -.TP -\fBELFsh modules commands\fP - -\fImodhelp modload modunload\fR - -.TP -\fBmodhelp\fP \fIModuleFilePath\fR -Print help for a loaded ERESI module. - -.TP -\fBmodload\fP \fIModuleFilePath\fR -Load an ERESI module. The path has to be absolute or relative to the registered module path. - -.TP -\fBmodunload\fP \fIModuleFilePath\fR -Unload an ERESI module. The path has to be absolute or relative to the registered module path. - -.TP -\fB========================================================================\fP - -.TP -\fBELF objects flags\fP - -\fIfixup shtrm sstrip\fR - -.TP -\fBfixup\fP -Mark BSS section to be included in disk file. The BSS gets immediately fixed in the ELFsh internal descriptor -of the object. - -.TP -\fBshtrm\fP -Mark Section Header Table as removed. The SHT will be removed only when the file is saved. - -.TP -\fBsstrip\fP -Mark the Section Header Table (SHT) and Symbol Table (.symtab) as stripped. They will be removed only when the -file is saved. - -.TP -\fB========================================================================\fP - -.TP -\fBOndisk only ELF commands\fP - -Those commands only works in ELFsh, or in E2dbg when switched to the static mode using the mode command. - -\fIappend extend flush insert remove save stab sym\fR - -.TP -\fBappend\fP \fISectionName\fR \fISourceObjectPath\fR -Append the data of object \fISourceObjectPath\fR to section \fISectionName\fR - -.TP -\fBextend\fP \fISectionName\fR \fIlength\fR -Extend section \fISectionName\fR with \fIlength\fR zero bytes - -.TP -\fBflush\fP -Flush all injected .o files from current file. - -.TP -\fBinsert\fP -Inject new object (section, symbol, or program header) in current working file. - -insert sect name code|data|unmap [sz] [align] - sym name value [sz] - phdr type vaddr [sz] - -.TP -\fBremove\fP -Remove ELF object (section, symbol, or program header) from current working file - -remove sect name - sym name - phdr index - -.TP -\fBsave\fP \fIfilename\fR -Dump current selected file to output file \fIfilename\fR. This command writes a file on disk. - -.TP -\fBdebug\fP -Print unified debug format information for the current file. - -.TP -\fBst sym\fP [\fIRegex\fR] -Print the symtab (.symtab) entries matching \fIRegex\fR. - -.TP -\fB========================================================================\fP - -.TP -\fBKernsh modules commands\fP - -Those commands only works in Kernsh. - -.TP -\fBopenmem\fP -Open kernel memory and static kernel - -.TP -\fBclosemem\fP -Close kernel memory and static kernel - -.TP -\fBsct\fP -Display the syscall table - -.TP -\fBidt\fP -Display the interrupt descriptor table - -.TP -\fBgdt\fP -Display the global descriptor table - -.TP -\fBalloc\fP -Alloc contiguous kernel memory - -.TP -\fBfree\fP -Free contiguous kernel memory - -.TP -\fBalloc_nc\fP -Alloc non contiguous kernel memory - -.TP -\fBfree_nc\fP -Free non contiguous kernel memory - -.TP -\fBkmodule\fP -Handle kernel module - -kmodule -l module : load a lkm - -kmodule -u module : unload a lkm - -kmodule -r module1 module2 moduleout : link module with another - -kmodule -i module original_name evil_name : change lkm init (original_name) with another function (evil_name) - -.TP -\fBksym\fP -Get an address of a kernel symbol - -.TP -\fBkmd5\fP \fIsa output\fR | \fIsa:rva output\fR | \fIsa%rva%size output\fR | \fIsa%size output\fR -Make a md5sum. - -sa : Symbol or addr - -rva : Byte offset form the beginning (optional) - -size : Bytes number limit (optional) (if size is 0 or not put, we search the end of the function) - -output : file output (optional) - - -.TP -\fBkcmd5\fP \fIformat\fR | \fIfile\fR -Check a md5. - -format : addr:mode:size:off:md5 - -file : filename - - - -.TP -\fB========================================================================\fP - -.TP -\fBType related primitives\fP - -Those primitives allow to define and habitate types in the ERESI meta\-language: - -.TP -\fBtype\fP [\fIregex\fR] - -Print list of types (only those matching the regular expression if given in parameter). - -.TP -\fBtype\fP \fIname\fR = \fIfield1:type1\fR ... \fIfieldN:typeN\fR - -Define a new type in the ERESI meta\-language. Predefined types include byte, short, int, -caddr, daddr, long, hash, vector, string, and raw. - -.TP -\fBtypedef\fP \fItname\fR \fItname2\fR - -Copy and rename a type. Any modification on one of the types will \fBnot\fP affect the other. - -.TP -\fBinform\fP \fItype\fR [\fIname\fR | \fIaddress\fR] - -Make type \fIname\fR habitated by the variable standing at address \fIname\fR. If called with -a single type name parameter, the command list all variables that habitate this type. If given -2 parameters, the name is interpreted as a symbol pointing on a variable. Its address is resolved -and the type is informed about this variable. If only an address is given, its symbol is looked up -and the variable corresponding to the symbol is informed. If no symbol corresponds to this address, -a new one is created that points on the address, and the newly symbolic variable is informed. - -.TP -\fBuninform\fP \fItype\fR [\fIname\fR] - -Uninform a given variable from a type. If no variable name is given, all variables previously -informed are removed from the type habitation. - - -.TP -\fB========================================================================\fP - - -.TP -\fBNetwork commands\fP - -\fIconnect disconnect net netkill netlist peerslist rcmd\fR - -.TP -\fBconnect\fR -Add a DUMP connection to given host - -.TP -\fBdisconnect\fR -Kill the DUMP connection from IP - -.TP -\fBnet\fR -Activate networking capabilities - -.TP -\fBnetkill\fR -Kill a network client by IP - -.TP -\fBnetlist\fR -List connected network clients - -.TP -\fBpeerslist\fR -List connected DUMP peers - -.TP -\fBrcmd\fR -Execute a command on a remote machine - -.TP -\fB========================================================================\fP - -.TP -\fBAvailable prefixes\fP - -\fIalert all quiet sort verb\fR - -.TP -\fBalert\fP -Alert prefix : change alert regular expression - -.TP -\fBa all\fP \fIregex\fR -Set a global regular expression. All commands which take a regular expression as a parameter will default to use this global regular expression. - -.TP -\fBquiet\fP -Toggle quiet flag (do not print executed commands) - -.TP -\fBsort\fP -Sorting prefix (use a \-addr\- or s \-size\-) - -.TP -\fBverb\fP -Toggle verbose flag (undo the quiet flag) - -.TP -\fB========================================================================\fP - -.TP -\fBAvailable Script jumps\fP - -A certain number of jumps construct are available: - -\fIje jg jge jl jle jmp jne\fR - -.TP -\fBje\fP -Jump on label if equal (use last cmp result) - -.TP -\fBjg\fP -Jump on label if greater (use last cmp result) - -.TP -\fBjge\fP -Jump on label if greater or equal (use last cmp result) - -.TP -\fBjl\fP -Jump on label if lower (use last cmp result) - -.TP -\fBjle\fP -Jump on label if lower or equal (use last cmp result) - -.TP -\fBjmp\fP -Unconditional jump to script label - -.TP -\fBjne\fP -Jump on label if nont equal (use last cmp result) - -You might also consider using a \fBforeach\fP construct, which is not -described in this manual page. - -.TP -\fB========================================================================\fP - -.TP -\fBAvailable modules\fP - -\fImodflow modremap modtest\fR - -.TP -\fBmodflow\fR -Modflow is an ELFsh module designed to perform control flow analysis on ELF binaries -for detailed examples and usage see README in ELFsh/modules/modflow - -.TP -\fBmodremap\fR -Modflow is an ELFsh module designed to perform remapping sections in Elf binaries see ELFsh/modules/modremap for further details - -.TP -\fBmodtest\fR -Modtest is a ElFsh module designed to show the usage of adding new commands to ELFsh see ELFsh/modules/modtest for further details - -.TP -\fB========================================================================\fP - -.SH "OBJECT PATH FORMAT" -This section explains how to access different objects in an ELF file. For most commands the object can also be a decimal or hexadecimal numbers. In this case the ObjectPath is the number. - -.TP -\fBELF Header\fP -filename.hdrfield - -ELF header fields are : - - -.IP \fBmagic\fP -Magic number - -.IP \fBclass\fP -File class - -.IP \fBtype\fP -Object file type - -.IP \fBmachine\fP -Architecture - -.IP \fBversion\fP -Object file version - -.IP \fBentry\fP -Entry point virtual address - -.IP \fBphoff\fP -Program header table file offset - -.IP \fBshoff\fP -Section header table file offset - -.IP \fBflags\fP -Processor\-specific Flags - -.IP \fBehsize\fP -Size of the ELF header in bytes - -.IP \fBphentsize\fP -Size of the program headers - -.IP \fBshentsize\fP -Size of the section headers - -.IP \fBphnum\fP -Number of program headers - -.IP \fBshnum\fP -Number of section headers - -.IP \fBshstrndx\fP -Section header string table index - -.IP \fBpax_pageexec\fP -PAX use paging based non\-executable pages - -.IP \fBpax_emultramp\fP -PAX emulate trampolines - -.IP \fBpax_mprotect\fP -PAX restrict mmap - -.IP \fBpax_randmmap\fP -PAX randomize mmap - -.IP \fBpax_randexec\fP -PAX randomly map executable address - -.IP \fBpax_segmexec\fP -PAX use segmentation based non\-executable pages - -.TP -\fBgot/ctors/dtors tables\fP -(filename | fileID).(got|ctors|dtors)[index] - -In this command, the index can also be a symbol -name that corresponds to the requested GOT, CTORS, OR DTORS entry. - -.TP -\fBProgram segment header table\fP -(filename | fileID).pht[index].fi eld - -Program segment header table entry fields are : - -.IP \fBtype\fP -Segment type - -.IP \fBoffset\fP -Segment file offset - -.IP \fBpaddr\fP -Segment physical address - -.IP \fBvaddr\fP -Segment virtual address - -.IP \fBfilesz\fP -Segment size in file - -.IP \fBmemsz\fP -Segment size in memory - -.IP \fBflags\fP -Segment flags - -.IP \fBalign\fP -Segment alignment - -.TP -\fBSymbol/Dynamic symbol tables\fP -(filename | fileID).(symtab|dynsym)[index].fi eld - -Symbol/Dynamic symbol table entry fields are : - -.IP \fBname\fP -Symbol name - -.IP \fBvalue\fP -Symbol value - -.IP \fBsize\fP -Symbol size - -.IP \fBbind\fP -Symbol binding - -.IP \fBtype\fP -Symbol type - -.IP \fBother\fP -Symbol visibility - - -.TP -\fBDynamic section\fP -(filename | fileID).dynamic[index].fi eld - -The .dynamic section entry fields are : - -.IP \fBval\fP -Integer or address value - -.IP \fBtag\fP -Dynamic entry type - -.TP - - -\fBSection header table\fP -(filename | fileID).sht[index].fi eld - -The index can be the name of the section. Section Header Table entries fields are : - -.IP \fBtype\fP -Section type - -.IP \fBoffset\fP -Section Offset in ELF file - -.IP \fBaddr\fP -Section Address - -.IP \fBsize\fP -Section Size in bytes - -.IP \fBlink\fP -Link to another section - -.IP \fBinfo\fP -Additional Info - -.IP \fBalign\fP -Section Alignment - -.IP \fBentsize\fP -Entry size if section holds table - -.IP \fBflags\fP -.RSss - -.IP a -Section occupies memory during execution - -.IP w -Section is Writeable - -.IP x -Section is Executable - -.IP s -Contains nul\-terminated strings - -.IP m -Section might be merged - -.IP l -Preserve order after combining - -.IP o -OS specific - - -.TP -\fBRelocation table\fP -(filename | fileID).rel[indextable][indexentry].fi eld - -Relocation entry fields are : - -.IP \fBtype\fP -Relocation Type - -.IP \fBsym\fP -Relocation symbol index - -.IP \fBoffset\fP -Address - -.TP - -\fBAdditional sections information\fP -(filename | fileID).section[sectionindex].fi eld - -The section object is not a real object of the binary, but a kind of -virtual one. It holds all the information about a section that do not stand -in the sectoin header table entries. Section fields are : - -.IP \fBname\fP -Section name - -.IP \fBraw\fP -Section Raw data - -To access use following path format : - -.IP filename.section[index[:offset[%elemsize]]].raw - - - -.SH "AUTHOR" -ERESI was created by Julien Vanegue and developed by the ERESI team - - - -The complete list of ERESI contributors can be found on the website: - - http://www.eresi-project.org - -This manual page was created by Julien Vanegue, from previous work on the ELFsh man page by Peter De Schrijver -for the Debian GNU/Linux system. Additional improvements were made by stingduk for version 0.7. - - -.SH "SEE ALSO" -readelf(1), objdump(1), objcopy(1), gdb(1), ltrace(1), strace(1) diff -Nru eresi-0.8a25/doc/.svn/text-base/ERESI-coding_style-README.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/ERESI-coding_style-README.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/ERESI-coding_style-README.txt.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/ERESI-coding_style-README.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,460 +0,0 @@ - -$ID - - ------------------------------------------------------ - ERESI : The ELF Reverse Engineering Software Interface - ------------------------------------------------------ - * CODING STYLE & MANDATORY PRACTICES * - ****************************************************** - -Hi guys, - -I compiled a few of the documentation that I wrote incrementally on -the Mailing list of the ERESI project. Those points only concerns the -coding style inside the project, and the mandatory practices to hope -getting your code working without breaking anything. - -Please read those recommendations carefully before submitting any patch -or commiting something to the CVS. - -Feel free to use any editors to acheive this presentation, but we strongly -recommand to use emacs-21 or a more recent version. - -Here are the most important recommandations : - - -A/ INDENTATION - - 1. The variables definition should be aligned with the function name - 2. The indentation must be of 2 characters in the body of functions - 3. Braces { and } should always be put at next line - 4. Never use automatic indentation unless you know what you are doing - 5. Your code must fit on 80 colums - 6. Your code shoud be compact be clear - -B/ DEVELOPMENT - - 1. Never use syscalls directly but use defined macros - 2. Use the profiler macros carefully ! - 3. Your code should not generate any warnings - 4. Your code should be portable - 5. Your code shoud take advantage of the existing API - 6. Your code should be modular - 7. Your code should be formated - -C/ TESTING - - 1. Your code must be tested before commiting - 2. Be reactive to the crew CVS alerts - -D/ DOCUMENTATION - - 1. Write text files to explain the API of what you have done - 2. Comment your code in a reasonable fashion - 3. Use doxygen tags - - - -A/ INDENTATION --------------- --------------- - - - 1. The variables definition should be aligned with the function name - -------------------------------------------------------------------- - - GOOD: - - int my_function() - { - int var; - char c; - (...) - - - BAD: - - int my_function() { - int var; - char c; - (...) - - - 2. The indentation must be of 2 characters in the body of functions - ------------------------------------------------------------------- - - /* Return the ELF header flags field */ - elfsh_Word elfsh_get_flags(elfsh_Ehdr *hdr) - { - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Word) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_flags)); - } - - BAD: - - /* Change the section header table file offset */ - int elfsh_set_shtoff(elfsh_Ehdr *hdr, elfsh_Addr off) { - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_shoff = (elfsh_Off) off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - - 3. Braces { and } should always be put at next line - --------------------------------------------------- - - GOOD: - - if (test) - var++; - else - { - dosomething; - anotherthing; - } - - BAD: - - if(test) { var++ } else { otherthing; } - - - 4. Never use automatic indentation unless you know what you are doing - --------------------------------------------------------------------- - - Never use an automatic indentation tool external to your editor : unless - you configure it to make the whole code compatible with the project coding - style of course. This is very important point as we dont have complete files - of many thousands of lines have changed indentation which is not the one - of the project. - - Additionally, this makes the cvs-web diff system to be completely inefficient - as it will make appear all the lines where indentation has been modified. - - - 5. Your code must fit on 80 colums - ---------------------------------- - - Each line of your code must fit in a small terminal, so make sure you put - a maximum width of 80 columns for each line. - - GOOD: - - sect = elfsh_get_section_by_name(world.curjob->current, - world.curjob->curcmd->param[0], - NULL, NULL, NULL); - - BAD : - - sect = elfsh_get_section_by_name(world.curjob->current, world.curjob->curcmd->param[0], NULL, NULL, NULL); - - - - 6. Your code shoud be compact be clear - -------------------------------------- - - Dont add any additional new break line if its not necessary, but put - spaces between keywords of the langage or operators. That includes : - - - if, else, for, while, sizeof - - - Put space after , but not before. - - - Put space on both sides of arithmetic or logic operands. That - includes +, -, *, /, <<, >>, % , &, | and = signs - - - Never put additional spaces because of parenthesis ( ) or [ ] - - - Always put a space after a non-line-terminating ; or a , but not before. - - - ** DONT LET DEAD CODE IN THE CVS ** - - You can keep that code as commented only, in case you plan to reuse it - in the future or you are not sure it should be removed because you are - not the author. In that case, ask on the mailing list. - - -B/ DEVELOPMENT --------------- --------------- - - 1. Never use syscalls directly but use defined macros - ----------------------------------------------------- - - BAD: - - case NT_PRPSINFO: - if(read(file->fd, &file->core.prpsinfo, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - break; - - GOOD: - - case NT_PRPSINFO: - XREAD(file->fd, &file->core.prpsinfo, descsz, -1); - - The same holds for malloc (XALLOC), realloc (XREALLOC), - free (XFREE), lseek (XSEEK), write (XWRITE), and close (XCLOSE). - - See: ./libaspect/include/libaspect-profiler.h for all macros. - - - 2. Use the profiler macros carefully ! - -------------------------------------- - - Those allow your functions and allocations to be present in the - profiling (profile command) BUT take care if you are coding I/O - functions, as we dont want them to be present in the profiling - (else we will see profile output each time we type a key, which - is very disturbing). - - Those macros are the one starting with PROFILER_* and NOPROFILER_* - macros. If you have any doubt on using those macros, ask for help. - - They are defined in the file : libaspect/include/libaspect-profiler.h - - If you have any doubt if you should use the profiler in your function, - use it and check in the result if it brings too much unwanted profile - output inside elfsh. - - - 3. Your code should not generate warnings - ----------------------------------------- - - You should make sure that you dont let : - - - unused or uninitialized variables (use a decent version of gcc, - for instance gcc 4.x. - - - Make sure your code at least compiles when beeing compiled using - g++. This way, it can be used in C++ projects. The configure file - has a --use-cpp option that helps you for testing this. - - - 4. Your code should be portable - ------------------------------- - - If you just have access to your development machine, please get more - accounts or ask us to help you doing the portability checks before you - submit a patch for inclusion to cvs. For instance, if you develop on - Linux, try to make sure your code at least does not break the BSD - tree. In the best case scenario, make your code portable directly, - so that all your work is also available on FreeBSD, NetBSD, OpenBSD, - and Solaris (the main target operating systems of the project). - - - 5. Your code shoud take advantage of the existing API - ----------------------------------------------------- - - The API of the project has more than 500 functions. - - Well often, you will find inside it the function that you need. Dont - duplicate code, your patch will make the project bigger and harder - to maintain in the future. - - If you need to reuse an API but you need to change a small detail inside its - code, make sur you dont break any feature that used this function before by - testing the project. Make your change in the respect of the coding style - defined earlier in that document. - - If you have to change more than a third of a function code, then you may - break it into smaller pieces, and call those smaller functions where you - need them. - - If you add any function you must add its prototype at the correct place - in the correct header file. - - - 6. Your code should be modular - ------------------------------ - - If you have to do big changes and if you are coding a new big feature - inside the project, think about using VECTORS. Vectors are multidimensional - arrays that allow for discriminating objects inside the framework. - For instance, if you add a feature that has a different implementation - depending on the architecture of the Operating System, you might want - to call a different - function depending on the local parameters of the machine you are running - ERESI on. The Vector data structures helps you at this. Additionally, vectors - are reflective objects inside - - More detailed use of vectors will be soon described in the HOWTO-port-ERESI - documentation, describing all the hooks that allow for reflection inside - the framework. - - Reflection is the technique that allow for internal objects of the framework - to be bound directly in the ERESI language. In other words, you can modify - the content of framework objects as well, but for this you need to use - HASH TABLES (hash_t) and VECTORS (vector_t) objects, whoose API is both - implemented in the LIBASPECT component. - - - 7. Your code should be formated - ------------------------------- - - - Use explicit variable and function names ! - - BAD: - - int f(int a, int r, int m) - { - if (!a) - return (r % m); - r *= a--; - return (f(a, r, m)); - } - - GOOD: - - int factorial_modulo(int nbr, int result, int modulo) - { - if (!nbr) - return (result % modulo); - result *= nbr--; - return (factorial_modulo(nbr, result, modulo)); - } - - - Dont use meaningless suffixes like _adv : use a function - name that self-describes the content of it. - - - Always prefix your functions name depending on the name - of the component you are working into. Prefixes are : - - aproxy_ : for liballocproxy - aspect_ : for libaspect - asm_ : for libasm - elfsh_ : for libelfsh - mjr_ : for libmjollnir - edfmt_ : for the eresi debug format lib - dump_ : for libdump - vm_ : for librevm - e2dbg_ : for the debugger - - Sometimes, special functions have special prefixing that get - out of this scheme. For exemple: - - profiler_ : for profiler functions inside libaspect - parse_ : for parsing handlers (librevm/lang/grammar.c) - cmd_ : for command handlers (librevm/cmd/*) - - Libui does not have yet a prefix scheme, but a good candidate - is certainly: ui_ (to be determined) - - -C/ TESTING ----------- ----------- - - - 1. Your code must be tested before commiting - -------------------------------------------- - - There is nothing that makes loose our time more than being blocked - because one of the developer did not test (and sometimes even compiled) - correctly his work, and this can block a whole team for many hours. - - - 2. Be reactive to the crew CVS alerts - ------------------------------------- - - If unfortunately your code is not working after following all those - advices (for instance you commited code that worked on linux but - its not even compiling on BSD or Solaris), then ask for access to - BSD or solaris machines if you dont have one, to resolve the problem - quickly. The project aims to be multi-OS and multi-architecture and - you cannot state that you did a multi-OS/arch work, or even a real - group project, if you dont follow this rule. - - - - -D/ DOCUMENTATION : ------------------- - - 1. Write text files to explain the API of what you have done - ------------------------------------------------------------ - - That includes how to use it from the shell or from the ERESI language, if - you bound your features inside the language. - - - 2. Comment your code in a reasonable fashion - -------------------------------------------- - - You should always have at least one line of comment for each function, if - its small, or more comments in the body of the function if the function is - more complex. The good way to put comments is : - - /** <--- double star allow for doxygen outputs - *** This is the sumup of my comment - *** - *** More details about what Im talking about - **/ - int my_function() - { - if (test) - myvar++; - else - { - I_do_something_else; - } - return (blah); - } - - 3. Use doxygen tags - ------------------- - The eresi project grows and evolves too much to be kept appart from the source code. - To facilitate documentation process, an effort has been made to migrate source code from - comments with no constitency to doxygen commented source files. - - Use doxygen tags at last for files and functions. - This will provide an API reference for future developpers which can be browsed online. - Following tags are mandatory : - - Each .c file must begin with a section like this: - - /** - * @file path/to/the/file.c - * Quick description fo file content. - */ - - Functions must be preceded by comments like this: - - /** - * Brief description of behavior - * - * Extended description. - * - * @param obj Pointer to data object - * @param str String describing element - * @return Returns variable lenght or NULL on error - */ - int extract_length(objet_t *obj, char *str) - { - // ... - } - - ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- - - - -That is all for now. This documentation is updated and completed soon, so -please check the CVS for new versions ! - -Thanks for your attention and your comprehension. - --may - - - - \ No newline at end of file diff -Nru eresi-0.8a25/doc/.svn/text-base/eresirc.example.svn-base eresi-0.0.20110516/doc/.svn/text-base/eresirc.example.svn-base --- eresi-0.8a25/doc/.svn/text-base/eresirc.example.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/eresirc.example.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!/home/tyler/elfsh/vm/elfsh - -quiet -setcolor address fg green -#setcolor address bold 1 -setcolor string fg cyan -setcolor number fg cyan -setcolor fieldstring fg black -setcolor fieldstring bold 1 -setcolor typestring fg yellow -setcolor typestring bold 1 -setcolor endstring fg blue -setcolor warnstring fg red -setcolor warnstring bold 1 -setcolor pspecial fg black -setcolor pspecial bold 1 -setcolor psname fg yellow -setcolor psname bold 1 -setcolor pversion fg red -setcolor pversion bold 1 -setcolor prelease fg red -setcolor prelease bold 1 -setcolor pedition fg green -setcolor pedition bold 1 - -setcolor instr fg blue -setcolor instr bold 1 - -setcolor function fg red -setcolor filename fg green - -print \x20[*] Set ELFsh default color theme (use nocolor to disable) -verb -#profile -#profile - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/footer.html.svn-base eresi-0.0.20110516/doc/.svn/text-base/footer.html.svn-base --- eresi-0.8a25/doc/.svn/text-base/footer.html.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/footer.html.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ - - diff -Nru eresi-0.8a25/doc/.svn/text-base/graphers.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/graphers.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/graphers.txt.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/graphers.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -http://www.datarescue.com/idabase/wingraph32/ -http://rw4.cs.uni-sb.de/users/sander/html/gsvcg1.html -http://www.research.att.com/sw/tools/graphviz/ diff -Nru eresi-0.8a25/doc/.svn/text-base/header.html.svn-base eresi-0.0.20110516/doc/.svn/text-base/header.html.svn-base --- eresi-0.8a25/doc/.svn/text-base/header.html.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/header.html.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ - - diff -Nru eresi-0.8a25/doc/.svn/text-base/HOWTO-port-elfsh-0.7a2.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/HOWTO-port-elfsh-0.7a2.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/HOWTO-port-elfsh-0.7a2.txt.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/HOWTO-port-elfsh-0.7a2.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,283 +0,0 @@ - - - $ HOWTO-port-ELFsh/E2dbg version 0.7a2 Fri Oct 14 17:13:18 2005 mm - - ------------------------------------------------------------------ - - -ELF monkeys, ugh - -Since The ELF shell and the Embedded ELF debugger starts to be -really modular and we now have all the handlers we are looking for, -let's see how to port it on a new architecture or a new OS. - -Both E2DBG and ELFSH have internal hooks that can be registered -for a given architecture, OS, or object type. Each feature has -a dedicated hook. Some hooks are directly inside libelfsh, others -are inside the debugger library directly when they are not purely -ELF related. - -Here is the list of hooks to be implemented as backends in order to -complete a full port on some unsupported OS or architecture : - - -I. LIBELFSH ------------ - - -/* 3 dimensional matrixes for PLT infection and ET_REL injection techniques */ -int (*hook_altplt[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfshobj_t *f, - elfsh_Sym *s, - elfsh_Addr a); -int (*hook_plt[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfshobj_t *f, - elfsh_Sym *s, - elfsh_Addr a); -int (*hook_rel[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfshsect_t *s, - elfsh_Rel *r, - elfsh_Addr *l, - elfsh_Addr a, - elfshsect_t *m); -int (*hook_cflow[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfshobj_t *f, - char *name, - elfsh_Sym *old, - elfsh_Addr new); -int (*hook_break[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfshobj_t *f, - elfshbp_t *b); - - -Those 5 hooks are used respectively for : - -- Adding the ALTPLT handler for ALTPLT redirection for an architecture/OS/filetype -- Adding the PLT handler for PLT redirection for extern functions for an architecture/OS/filetype -- Adding the ET_REL relocation function for an architecture/OS/filetype -- Adding the CFLOW (static) function redirection handler for the architecture/OS/filetype -- Adding the Breakpoint installation handler for the architecture/OS/filetype - -Be also sure to add a 'case' in those information switch located in the functions : - -int elfsh_get_pagesize(elfshobj_t *file) -u_int elfsh_get_breaksize(elfshobj_t *file) - -If you add the support for a new OS, do the same in : - -u_char elfsh_get_ostype(elfshobj_t *file) -u_char elfsh_get_real_ostype(elfshobj_t *file) - -and add your OS in : - -u_char elfsh_ostype[5] = { - ELFOSABI_LINUX, - [....] - ADD YOUR OS HERE -}; - -If you add the support for a new architecture, do the same in : - -u_char elfsh_get_archtype(elfshobj_t *file); - - -All of this beeing located in libelfsh/hooks.c. - - -You can use this internal API for adding your own hooks entries directly in the -elfsh_setup_hooks() function : - -int elfsh_register_breakhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_cflowhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_relhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_plthook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_altplthook(u_char archtype, u_char objtype, u_char ostype, void *fct); - - -In the libelfsh code, the registered features handlers are called using those functions, and from -those functions (you should NOT have to modify this) : - -libelfsh/relinject.c:31: ret = elfsh_rel(new->parent, new, reloc, dword, addr, mod); - -libelfsh/hijack.c:119: ret = elfsh_plt(file, symbol, addr); -libelfsh/hijack.c:164: ret = elfsh_plt(file, symbol, addr); - -libelfsh/altplt.c:59: if (elfsh_altplt(file, &newsym, addr) < 0) - -libelfsh/bp.c:43: ret = elfsh_setbreak(file, bp); - -libelfsh/hijack.c:97: ret = elfsh_cflow(file, name, symbol, addr); -libelfsh/hijack.c:129: ret = elfsh_cflow(file, name, symbol, addr); - - - -II. E2DBG ---------- - - -Now we have a certain number of hooks inside e2dbg directly. Those are most related -to the scripting language and the relations with stepping and access to registers -context or processor state for all architectures. The list of hooks in e2dbg/vmhooks -is as follow : - -elfsh_Addr* (*hook_getpc[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); -elfsh_Addr* (*hook_getfp[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); -elfsh_Addr (*hook_nextfp[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfsh_Addr bp); -elfsh_Addr (*hook_getret[ELFSH_ARCHNUM][ELFSH_TYPENUM][ELFSH_OSNUM])(elfsh_Addr bp); -void (*hook_setregs[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); -void (*hook_getregs[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); -void (*hook_setstep[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); -void (*hook_resetstep[ELFSH_ARCHNUM][E2DBG_HOSTNUM][ELFSH_OSNUM])(); - -Those hooks are used for : - -- Returning a pointer on the Program Counter context entry for later read or write -- Returning a pointer on the Frame Pointer context entry for later read or write -- Returning the next Frame Pointer giving the actual Frame Pointer -- Returning the current Return Value depending on the actual Frame Pointer -- Update the ucontext registers entries for further reuse by the debuggee program -- Obtain the ucontext registers entries for further modifications in the debugger -- Enable the singlestep mode on the processor -- Disable the singlestep mode on the processor - -Again, we have an API that allow for registering hooks for a given architecture, host type -(user, kernel ..) and OS type : - -int e2dbg_register_sregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a setreg handler -int e2dbg_register_gregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getreg handler -int e2dbg_register_getpchook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getpc handler -int e2dbg_register_setstephook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a setstep handler -int e2dbg_register_resetstephook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a resetstep handler -int e2dbg_register_nextfphook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a nextfp handler -int e2dbg_register_getrethook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getret handler - - -Those e2dbg hooks, once registered, are called from e2dbg at various place, that you should not have to modify : - - -e2dbg/signal.c:58: e2dbg_getregs(); -e2dbg/signal.c:128: e2dbg_getregs(); - -e2dbg/continue.c:60: e2dbg_setregs(); - -e2dbg/signal.c:129: pc = e2dbg_getpc(); - -e2dbg/backtrace.c:34: frame = (elfsh_Addr) e2dbg_getfp(); - -e2dbg/signal.c:235: e2dbg_setstep(); -e2dbg/step.c:42: if (e2dbg_setstep() < 0) - -e2dbg/signal.c:213: e2dbg_resetstep(); -e2dbg/step.c:34: if (e2dbg_resetstep() < 0) - -e2dbg/backtrace.c:61: frame = e2dbg_nextfp(world.curjob->current, (elfsh_Addr) frame); - -e2dbg/backtrace.c:42: ret = (elfsh_Addr) e2dbg_getret(world.curjob->current, (elfsh_Addr) frame); - - - -You can add your registers in e2dbg/vmhooks.c:e2dbg_setup_hooks() . - - - - -III. LIST OF REFERENCE, SUPPORTED, UNTESTED, UNSUPPORTED ARCHITECTURES ----------------------------------------------------------------------- - - -In this section you can find the list of ALL hooks (libelfsh + e2dbg) with their -respective porting state. The reference architecture is the one where the feature -has been proved to work the first time. - -A SUPPORTED architecture means that the feature is known to work on this arch. - -A UNTESTED archiecture means that the feature should work without (or few) -modification but it is still work in progress or in testing phase. Modifications -may range to nothing until small arch dependant fixes like adding entries in -the various architecture switch's, or at worse, adding a hook entry in an existing -hook interface for a particular feature. - -A UNSUPPORTED architecture means there is no support at all for this architecture -on this feature and remains in the TODO. - -If an architecture appears no where in the list, it means the feature is not useful -or not revelant on this architecture. - -The number in the beginning of the line range over 1-4 for the complexity level of -the feature - -4 ET_REL injection : REFERENCE(ia32), SUPPORTED(alpha, sparc32, sparc64), UNTESTED(mips), UNSUPPORTED(ppc, hppa, arm, ia64, amd64) -3 ALTPLT redirection : REFERENCE(ia32), SUPPORTED(alpha, sparc32, sparc64, mips), UNSUPPORTED(ppc, hppa, arm, ia64, amd64) -2 PLT redirection : REFERENCE(ia32), SUPPORTED(alpha, sparc32), UNSUPPORTED(ppc, hppa, arm, ia64, amd64) -2 CFLOW redirection : REFERENCE(ia32), SUPPORTED(mips), UNSUPPORTED(sparc, alpha, ppc, hppa, arm, ia64, amd64) - -1 GETPC dbghook -1 GETFP dbghook -1 NEXTFP dbghook -1 GETREGS dbghook ALL : REFERENCE(ia32), UNSUPPORTED(sparc32, sparc64, alpha, mips, ppc, hppa, arm, ia64, amd64) -1 SETREGS dbghook -1 SETSTEP dbghook -1 RESETSTEP dbghook -1 GETRET dbghook - - -V. MAIN ALGORITHMS SOURCE CODE LOCATION INFORMATION ---------------------------------------------------- - -Some features like ALTGOT, ALTPLT, and EXTPLT are kind of complementary and more easily implemented -in a single algorithm. This algorithm is located in libelfsh/altplt.c:elfsh_relink_plt() and more -generally the functions located in that file are used for it. It is work in progress to think how -this function could be modularized more than how it currently done. If you feel like adding small -fixes for your architecture, please do it in proper conditions, respecting the convention used in -the file. - -- ALTGOT redirection (see altplt.c + libelfsh/altgot.c for that), works on MIPS & ALPHA for now, -and UNTESTED ALL RISC architectures. Should not need a dedicated hook. - -- EXTPLT postlinking (see altplt.c + libelfsh/extplt.c for that), works on IA32, UNTESTED on all -other architectures, one hook will be added to virtualize the PLT reencoding. - -In libelfsh, all architecture dependant hooks entry are located in a file dedicated to the -architecture. You can find those in libelfsh/ia*,mips*,sparc*,alpha64.c files. Please place -your hooks functions entries there in libelfsh. - -In e2dbg, if you do the support for a new architecture, create a new file and add it in the Makefile -of the local directory. - - -VI. SPECIAL ELFSH/E2DBG PORTING CONSIDERATIONS ----------------------------------------------- - -You may want to know special considerations on porting stuff on exotic architectures: - -* If the architecture does not support singlestepping natively (like MIPS), you may need to add a state -to the counter variable in the generic breakpoint handler for obtaining the correct result in the debugger. -This is located in e2dbg/signal.c:e2dbg_generic_breakpoint() . - -* ALTGOT and ALTPLT are complementary, if you implement one of them on an architecture, you dont need the -other one. - -* All quoted features works on both ET_EXEC and ET_DYN ELF objects. Please verify that your handlers -works on both types as well, or precise which kind of ELF object your handlers are manipulating while -you register them. - -* Be careful with the difference between a libelfsh hook and a e2dbg hook. The first is parametrised by a -ELF file type (ET_EXEC, ET_DYN, ..), the second is parametrized by a HOST type (for now, only PROC, but -will be used in the future for the KERNEL target. We could imagine more specialized target as well, like -the NOFP target, or stuff like that). - -* If you want to add a hook, there is not yet an API to do that but you can copy an existing one, located -in libelfsh/hooks.c or e2dbg/vmhooks.c, depending on the interaction level of it (pure ELF vs DEBUG hooks). - -The new framework following exactly this interface will be ported on the elfdev mailing list hosted -on Devhell in the next days. It will be compatible with Linux and start to be compatible again with -BSD and Solaris. HPUX and IRIX compilation are confirmed but no special support was done on them -for now. If you received this file, wish to participate in the porting, and you are not subscribed -on this list, mail elfsh@devhell.org and ask for your duty. - -Thats all for now. This small paper is not public for now. It will be published when 0.7 is -released. Soon I hope ;) - -Enjoy the framework and happy ELF hacking $ - - --elfsh crew - - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/HOWTO-port-ERESI-0.8.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/HOWTO-port-ERESI-0.8.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/HOWTO-port-ERESI-0.8.txt.svn-base 2008-04-06 23:15:51.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/HOWTO-port-ERESI-0.8.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,491 +0,0 @@ - - - $ HOWTO-port-ERESI version 0.8 Thu Sep 20 17:13:18 2007 jfv - - ------------------------------------------------------------------ - -Dear ERESI users and developers, - -Since The ELF shell and the Embedded ELF debugger starts to be -really modular and we now have a complete separation between -portable parts and non-portable parts using our handlers system, -let's see how to port it on a new architecture or a new OS. This -system is also now used in the Kernel shell and it has proven -perfectly adapted to develop highly portable software in the -ERESI framework. - -Each of these componant has a certain number of internal hooks, -called "aspect vector" in the code, that can be created to -demultiplex a particular non-standard feature for which the -implementation is different from one OS to another, or from -one architecture to another, or from one binary target file to -another, and so on. - - -1. THE VECTOR API ------------------ - -The structure of a vector is vector_t. All vectors are stored -and looked up using a hash table. The vector name can lookup -the vector data structure in the hash table. Each vector is a -multi-dimensional array of function pointers. Each function pointer -corresponds to the implementation for a given combination -of architecture, OS, file type, (or more generally, any -information you wish to discriminate on). - - -/* Retreive pointer on the vector hash table */ -hash_t* aspect_vecthash_get(); - -/* Retreive a vector from the vectors hash table */ -vector_t* aspect_vector_get(char *name); - -/* Add a new vector in the vectors hash table */ -int aspect_register_vector(char *, void*, - unsigned int*, - char **, unsigned int, - unsigned int); - -/* Add the function pointer to the vector at requested coordonates */ -void aspect_vectors_insert(vector_t *vect, - unsigned int *dim, - unsigned long fct); - -/* Get the function pointer at given position in the vector */ -void* aspect_vectors_select(vector_t *vect, - unsigned int *dim); - - -Additionally, another API can be useful, but you certainly -dont need it if you dont touch in the scripting engine: - - -/* Project each dimension and get the cell pointer containing - the desired element in the vector (useful for update) */ -void *aspect_vectors_selectptr(vector_t *vect, - unsigned int *dim); - - -Here is the list of hooks to be implemented as backends in order to -complete a full port on some unsupported OS or architecture. - -2. LIBELFSH PORTING -------------------- - - -Adding the ALTPLT handler for ALTPLT redirection for an architecture/OS/filetype - -* ELFSH_HOOK_REL : The relocation function used in ET_REL injection -* ELFSH_HOOK_CFLOW : The routine performing static function hijacking -* ELFSH_HOOK_PLT : The routine performing external function hijacking -* ELFSH_HOOK_ALTPLT : The routine performing a more elaborate external function hijacking -* ELFSH_HOOK_EXTPLT : The routine performing partial binary relinking -* ELFSH_HOOK_ENCODEPLT : The routine encoding a new PLT entry -* ELFSH_HOOK_ENCODEPLT1 : The routine reencoding the first PLT entry -* ELFSH_HOOK_ARGC : The routine performig function argument counting - - -Be also sure to add a 'case' in those information switch located in the functions : - -int elfsh_get_pagesize(elfshobj_t *file) -u_int elfsh_get_breaksize(elfshobj_t *file) - -If you add the support for a new OS, do the same in : - -u_char elfsh_get_ostype(elfshobj_t *file) -u_char elfsh_get_real_ostype(elfshobj_t *file) - -and add your OS in : - -u_char elfsh_ostype[5] = { - ELFOSABI_LINUX, - [....] - ADD YOUR OS HERE -}; - - - -If you add the support for a new architecture, do the same in : - -u_char elfsh_get_archtype(elfshobj_t *file); - -All of this beeing located in libelfsh/hooks.c. - - - -You can use this internal API for adding your own hooks entries directly in the -elfsh_setup_hooks() function, without having to use the vector API directly: - -int elfsh_register_breakhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_cflowhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_relhook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_plthook(u_char archtype, u_char objtype, u_char ostype, void *fct); -int elfsh_register_altplthook(u_char archtype, u_char objtype, u_char ostype, void *fct); - - -When requesting a feature from one of the command in elfsh/e2dbg/etrace/kernsh, the code -implementing this command remains in librevm/cmd/commandname.c . Such code calls the internal -libelfsh API. On its turn, the libelfsh API calls the vector API provided by libaspect. For -each portable feature architectured using a vector, there is one libelfsh function which is -called: - - -libelfsh/relinject.c ret = elfsh_rel(new->parent, new, reloc, dword, addr, mod); - -libelfsh/hijack.c ret = elfsh_plt(file, symbol, addr); - -libelfsh/altplt.c if (elfsh_altplt(file, &newsym, addr) < 0) - -libelfsh/bp.c ret = elfsh_setbreak(file, bp); - -libelfsh/hijack.c ret = elfsh_cflow(file, name, symbol, addr); - -libelfsh/hijack.c ret = elfsh_cflow(file, name, symbol, addr); - - - -II. E2DBG PORTING ------------------ - - -Now we have a certain number of hooks inside e2dbg directly. Those are most related -to the scripting language and the relations with stepping and access to registers -context or processor state for all architectures. The list of hooks in e2dbg/vmhooks -is as follow : - -./libe2dbg/dbghooks.c: getpc = aspect_vector_get(E2DBG_HOOK_GETPC); -./libe2dbg/dbghooks.c: getfp = aspect_vector_get(E2DBG_HOOK_GETFP); -./libe2dbg/dbghooks.c: nextfp = aspect_vector_get(E2DBG_HOOK_NEXTFP); -./libe2dbg/dbghooks.c: getret = aspect_vector_get(E2DBG_HOOK_GETRET); -./libe2dbg/dbghooks.c: setregs = aspect_vector_get(E2DBG_HOOK_SETREGS); -./libe2dbg/dbghooks.c: getregs = aspect_vector_get(E2DBG_HOOK_GETREGS); -./libe2dbg/dbghooks.c: setstep = aspect_vector_get(E2DBG_HOOK_SETSTEP); -./libe2dbg/dbghooks.c: resetstep = aspect_vector_get(E2DBG_HOOK_RESETSTEP); -./libe2dbg/dbghooks.c: breakp = aspect_vector_get(E2DBG_HOOK_BREAK); - -Those hooks are used for : - -- E2DBG_HOOK_GETPC : Returning a pointer on the Program Counter context entry for later read or write -- E2DBG_HOOK_GETFP : Returning a pointer on the Frame Pointer context entry for later read or write -- E2DBG_HOOK_NEXTFP : Returning the next Frame Pointer giving the actual Frame Pointer -- E2DBG_HOOK_GETRET : Returning the current Return address depending on the actual Frame Pointer -- E2DBG_HOOK_SETREGS : Update the ucontext registers entries for further reuse by the debuggee program -- E2DBG_HOOK_GETREGS : Obtain the ucontext registers entries for further modifications in the debugger -- E2DBG_HOOK_SETSTEP : Enable the singlestep mode on the processor -- E2DBG_HOOK_RESETSTEP : Disable the singlestep mode on the processor -- E2DBG_HOOK_BREAK : Install a breakpoint - -Again, we have an API that allow for registering hooks for a given architecture, host type (user, kernel.. ) and OS type : - -int e2dbg_register_sregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a setreg handler -int e2dbg_register_gregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getreg handler -int e2dbg_register_getpchook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getpc handler -int e2dbg_register_setstephook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a setstep handler -int e2dbg_register_resetstephook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a resetstep handler -int e2dbg_register_nextfphook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a nextfp handler -int e2dbg_register_getrethook(u_char archtype, u_char hosttype, u_char ostype, void *fct); # register a getret handler - - -Those e2dbg hooks, once registered, are called from e2dbg at various place, that you should not have to modify. -As stated before, the only thing you have to do when adding a new handler for a new combination of OS/arch/binarytype -for a given feature is to use the above mentioned API for the correct feature. The location of the libelfsh interface -for *calling* your function pointer or retreiving it from the vector is hidden, even to the programmer, using these -functions: - - -e2dbg/signal.c e2dbg_getregs(); - -e2dbg/continue.c e2dbg_setregs(); - -e2dbg/signal.c pc = e2dbg_getpc(); - -e2dbg/backtrace.c frame = (elfsh_Addr) e2dbg_getfp(); - -e2dbg/signal.c e2dbg_setstep(); - -e2dbg/signal.c e2dbg_resetstep(); - -e2dbg/backtrace.c frame = e2dbg_nextfp(world.curjob->current, (elfsh_Addr) frame); - -e2dbg/backtrace.c ret = (elfsh_Addr) e2dbg_getret(world.curjob->current, (elfsh_Addr) frame); - - -You can add your additional support directly in e2dbg/dbghooks.c:e2dbg_setup_hooks() -in the form of calls to e2dbg_register_*() function calls (depending on the feature you -are porting). - - - -III. LIBASM PORTING: --------------------- - -Architecture disassembling is managed throught vectors of handlers, one to disassemble instructions, -and the other to decode operands. Each architecture has its own two vectors. -To add support for a new architecture, you have to create thoses two vectors and associated handlers. - -Three functions have to be defined : -1/ The asm_processor initializing function -2/ The fetching handler. -3/ The opcode handlers. -4/ The operand handlers. -5/ The output handler. - -Create a new directory src/arch/newarch/ -All the code related to that new architecture will be in this directory. - -You will also have to create a new header file for your architecture. -Name it libasm-newarch.h in the include directory. - -You have then three functions to implement : -int asm_init_arch(asm_processor *proc); -int asm_fetch_arch(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) -int asm_free_i386(asm_processor *proc) - - -III.1) Initializing libasm: -~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Create a function to initilize an asm_processor structure: - -int asm_init_newarch() -{ - /** - * You must call asm_init_vectors() to initialize libaspect. - */ - asm_init_vectors(); - /** - * Setting the disassembling handlers. - */ - proc->fcn_etch = asm_fetch_newarch; - /** - * Setting - */ - proc->fcn_display = asm_display_; - proc->type = ASM_PROC_NEWARCH; -} - -You have to call your own architecture initialization function in src/register.c in function -asm_arch_register(). - -III.2) The fetching handler: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - int asm_fetch_newarch(asm_instr *ins, u_char *opcode, u_int len, asm_processor *proc); - -This handler is the main entry point to disassemble opcodes. It is called by asm_read_instr(). -In that function, you have to use your own vectors to disassemble data. -Once instruction is disassembled, any operand decoding by type must be implemented in the operand -handlers. - -III.3) Disassembling handlers: -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -In that subdirectory, opcode handlers are stored in the subdirectory src/arch/handlers. - -opcode handler prototype : - -int asm_opcode_fetch_xxx(asm_instr *ins, u_char *opcode, u_int len, asm_processor *proc); - - ins is a pointer to the instruction structure to fill. - opcode is a pointer to data to disassemble. - len is the length of buffer pointed to. - proc is a pointer to the processor structure. - - -III.4) Operand handlers: -~~~~~~~~~~~~~~~~~~~~~~~~ - -Note about operand order in asm_instr structure. -The first element of the operand array is considered as the destination operand. -The second element of the operand array is considered as the source operand. -The third element of the operand array is a possible second source operand. -The - -operand handler prototype : - -int asm_operand_fetch_xxx(asm_operand *op, u_char *opcode, int otype, asm_instr *ins, in opt); - - op is a pointer to current opcode to decode. - opcode is a pointer to operand data to decode. - otype is the operand type. - ins is a pointer to the current instruction being disassembled. - opt is a optional parameter. You may use this for anything you want. - -III.5) The output handler: -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You then have to implement the ascii output function: - -char *asm_display_newarch(asm_instr *ins, int vaddr); - - ins is a pointer to the instruction structure to display. - vaddr is the current virtual address of the instruction. This may be used to compute relative jump. - - -This function stores an ascii representation of an instruction in a static lenght -buffer returned to function caller. - - -IV. LIBKERNSH PORTING: ----------------------- - - -Due to the diffence between each systems, we have a lot's of hooks : - -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_OPENMEM, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_CLOSEMEM, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_READMEM, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_WRITEMEM, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_SCT, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_CALLSC, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_IDT, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_GDT, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_INFO, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_DECOMPKERNEL, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_ADDRBYNAME, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_NAMEBYADDR, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_AUTOTYPES, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_RELINKMODULE, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_INFECTMODULE, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_KLOADMODULE, -vectors.c: aspect_register_vector(LIBKERNSH_VECTOR_NAME_KUNLOADMODULE, - -Those hooks are used for : - -- LIBKERNSH_VECTOR_NAME_OPENMEM : Opening the static kernel and the system/kernel memory -- LIBKERNSH_VECTOR_NAME_CLOSEMEM : Closing the static kernel and the system/kernel memory -- LIBKERNSH_VECTOR_NAME_READMEM : Reading the system/kernel memory -- LIBKERNSH_VECTOR_NAME_WRITEMEM : Writing in the system/kernel memory -- LIBKERNSH_VECTOR_NAME_SCT : Returning the system call table -- LIBKERNSH_VECTOR_NAME_CALLSC : Calling a system call -- LIBKERNSH_VECTOR_NAME_IDT : Returning the Interrupt Descriptor Table -- LIBKERNSH_VECTOR_NAME_GDT : Returning the Global Descriptor Table -- LIBKERNSH_VECTOR_NAME_INFO : Returning basic information on the kernel -- LIBKERNSH_VECTOR_NAME_DECOMPKERNEL : Reconstruct the compress kernel -- LIBKERNSH_VECTOR_NAME_ADDRBYNAME : Resolving a symbol with his name -- LIBKERNSH_VECTOR_NAME_NAMEBYADDR : Resolving a symbol with his addr -- LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS : Allocating contiguous kernel's memory -- LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS : Allocating non contiguous kernel's memory -- LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS : Free contiguous kernel's memory -- LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS : Free non contiguous kernel's memory -- LIBKERNSH_VECTOR_NAME_AUTOTYPES : Making automatic type -- LIBKERNSH_VECTOR_NAME_RELINKMODULE : Relinking two LKM -- LIBKERNSH_VECTOR_NAME_INFECTMODULE : Infecting LKM init -- LIBKERNSH_VECTOR_NAME_KLOADMODULE : Loading LKM -- LIBKERNSH_VECTOR_NAME_KUNLOADMODULE : Unloading LKM - -This is the API that allow for registering hooks for a given architecture and OS type : - -int kernsh_register_openmem(u_int, u_int, u_int, void *); # register a openmem handler -int kernsh_register_closemem(u_int, u_int, u_int, void *); # register a closemem handler -int kernsh_register_readmem(u_int, u_int, u_int, void *); # register a readmem handler -int kernsh_register_writemem(u_int, u_int, u_int, void *); # register a writemem handler -int kernsh_register_sct(u_int, u_int, void *); # register a sct handler -int kernsh_register_callsc(u_int, void *); # register a callsc handler -int kernsh_register_idt(u_int, u_int, void *); # register a idt handler -int kernsh_register_gdt(u_int, u_int, void *); # register a gdt handler -int kernsh_register_info(u_int, u_int, void *); # register a info handler -int kernsh_register_decompkernel(u_int, void *); # register a decompkernel handler -int kernsh_register_symbs_abn(u_int, u_int, void *); # register a addrbyname handler -int kernsh_register_symbs_nba(u_int, u_int, void *); # register a namebyaddr handler -int kernsh_register_alloc_contiguous(u_int, void *); # register a alloc_contiguous handler -int kernsh_register_alloc_noncontiguous(u_int, void *); # register a alloc_noncontiguous handler -int kernsh_register_free_contiguous(u_int, void *); # register a free contiguous handler -int kernsh_register_free_noncontiguous(u_int, void *); # register a free non contiguous handler -int kernsh_register_autotypes(u_int, u_int, void *); # register a autotypes handler -int kernsh_register_relink(u_int, void *); # register a relink handler -int kernsh_register_infect(u_int, void *); # register a infect handler -int kernsh_register_kload(u_int, void *); # register a kload handler -int kernsh_register_kunload(u_int, void *); # register a kunload handler - -These hooks are called from libkernsh at various place : - -alloc.c: alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS); -alloc.c: alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS); -alloc.c: alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS); -alloc.c: alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS); -autotypes.c: autotypes = aspect_vector_get(LIBKERNSH_VECTOR_NAME_AUTOTYPES); -gdt.c: gdt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_GDT); -idt.c: idt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_IDT); -kernel.c: decomp = aspect_vector_get(LIBKERNSH_VECTOR_NAME_DECOMPKERNEL); -kernsh.c: info = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFO); -memory.c: mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_OPENMEM); -memory.c: mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CLOSEMEM); -memory.c: mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_READMEM); -memory.c: mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_WRITEMEM); -module.c: kload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KLOADMODULE); -module.c: kunload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KUNLOADMODULE); -module.c: rel = aspect_vector_get(LIBKERNSH_VECTOR_NAME_RELINKMODULE); -module.c: inf = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFECTMODULE); -sct.c: sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_SCT); -sct.c: csct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CALLSC); -symbs.c: symbs = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ADDRBYNAME); -symbs.c: symbs = aspect_vector_get(LIBKERNSH_VECTOR_NAME_NAMEBYADDR); - - - -V. ALGORITHM INFORMATION RELEVANT TO PORTING ----------------------------------------------- - -Some features like ALTGOT, ALTPLT, and EXTPLT are kind of complementary and more easily implemented -in a single algorithm. This algorithm is located in libelfsh/altplt.c:elfsh_relink_plt() and more -generally the functions located in that file are used for it. It is work in progress to think how -this function could be modularized more than how it currently done. If you feel like adding small -fixes for your architecture, please do it in proper conditions, respecting the convention used in -the file. - -- ALTGOT redirection (see altplt.c + libelfsh/altgot.c for that), works on MIPS & ALPHA for now, -and UNTESTED ALL RISC architectures. Should not need a dedicated hook. - -- EXTPLT postlinking (see altplt.c + libelfsh/extplt.c for that), works on IA32, UNTESTED on all -other architectures, one hook will be added to virtualize the PLT reencoding. - -In libelfsh, all architecture dependant hooks entry are located in a file dedicated to the -architecture. You can find those in libelfsh/ia*,mips*,sparc*,alpha64.c files. Please place -your handler functions entries there in libelfsh. - -In e2dbg, if you do the support for a new architecture, create a new file and add it in the Makefile -of the local directory. Current supported architectures are INTEL (dbg-intel.c) and SPARC (dbg-sparc32.c). - - -VI. OTHER SPECIAL PORTING CONSIDERATIONS ----------------------------------------- - -You may want to know special considerations on porting stuff on exotic architectures: - -* If the architecture does not support singlestepping natively (like MIPS), you may need to add a state -to the counter variable in the generic breakpoint handler for obtaining the correct result in the debugger. -This is located in e2dbg/signal.c:e2dbg_generic_breakpoint() . - -* ALTGOT and ALTPLT are complementary, if you implement one of them on an architecture, you dont need the -other one. - -* All quoted features works on both ET_EXEC and ET_DYN ELF objects. Please verify that your handlers -works on both types as well, or precise which kind of ELF object your handlers are manipulating while -you register them. - -* Be careful with the difference between a libelfsh hook and a e2dbg hook. The first is parametrised by a -ELF file type (ET_EXEC, ET_DYN, ..), the second is parametrized by a HOST type (for now, only PROC, but -will be used in the future for the KERNEL target. We could imagine more specialized target as well, like -the NOFP target, or stuff like that). - -* If you want to add a hook, there is not yet an API to do that but you can copy an existing one, located -in libelfsh/hooks.c or e2dbg/dbghooks.c, depending on the interaction level of it (ONDISK vs MEMORY hooks). - -If you read this file and wish to participate in the porting of ERESI, and you are not subscribed -on the mailing list, consult the ERESI website: http://www.eresi-project.org for more information on -how to subscribe. - - -Enjoy the framework and happy reversing $ - - -The ERESI team - - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/libasm_TODO.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/libasm_TODO.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/libasm_TODO.txt.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/libasm_TODO.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ - -Grammar : 1.graph[symbol|root].{truechild,falsechild} - --> API graph (those stocked into .control section by ELFsh module modflow) --> Need a new ELFsh L1 object (graph) - ------ - -Grammar : 1.graph[symbol|root].instr[idx].{mnemonic,type,len,prefix} - - - int asm_instruction_get(asm_instr *instr, int option, void *value); - int asm_instruction_set(asm_instr *instr, int option, void *value); - --> Need a new ELFsh L2 object (instr) --> Need a new ELFsh object type (L3 , for core instruction fields) - ------ - -Grammar : 1.graph[symbol|root].instr[idx].{dst|src|ter}[type|size|immediate|basereg|indexreg|scale] - - int asm_operand_get(asm_instr *instr, int num_operand, int option, void *value); - int asm_operand_set(asm_instr *instr, int num_operand, int option, void *value); - - num_operand : 1, 2, 3, 4 (src), 5 (dst) - option : immediate(basereg,indexreg,scale) - --> Need a new ELFsh object type (L3, same as previous grammar rule) for operands. - diff -Nru eresi-0.8a25/doc/.svn/text-base/libelfsh.i.svn-base eresi-0.0.20110516/doc/.svn/text-base/libelfsh.i.svn-base --- eresi-0.8a25/doc/.svn/text-base/libelfsh.i.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/libelfsh.i.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -%module libelfsh - -%include "typemaps.i" -%apply int *INOUT { int *offset }; -%apply int *INOUT { int *num }; -%apply int *INOUT { int *off }; - - - -%{ -#include - -/* "Typecasts" to make void* references usable in Python: */ -Elf32_Rel* toElf32_Rel( void *input) { - return input; -} - -Elf32_Rela* toElf32_Rela( void *input) { - return input; -} - -Elf32_Sym* toElf32_Sym( void *input) { - printf( "toElf32_Sym(): %x \n", input); - return input; -} - -Elf32_Dyn* toElf32_Dyn( void *input) { - return input; -} - -elfsh_Sym* to_elfsh_Sym( void *input) { - return input; -} -%} - -//typedef u_long uint32_t; -//#define elfsh_Sym Elf32_Sym - -%rename(__secthash) secthash; -%rename(secthash) getsecthash; - -%include -%include - - -/* "Typecasts" to make void* references usable in Python: */ -Elf32_Rel* toElf32_Rel( void *input); -Elf32_Rela* toElf32_Rela( void *input); -Elf32_Sym* toElf32_Sym( void *input); -Elf32_Dyn* toElf32_Dyn( void *input); -elfsh_Sym* to_elfsh_Sym( void *input); - -%extend elfshobj_t { - elfshsect_t *getsecthash( int index) { - return (self->secthash)[index]; - } -} - -%extend elfshsect_t { - char *getdata() { - return (self->data); - } - - - void *getdata(int index) { - int sh_entsize; - if(self->shdr->sh_entsize == 0) { - sh_entsize = 1; - } else { - sh_entsize = self->shdr->sh_entsize; - } - if( (self->data != 0) && ((sh_entsize * index) < self->shdr->sh_size)) { - return (self->data+sh_entsize*index); - } else { - return(0); - } - } - - char *getaltdata() { - return (self->terdata); - } - - char *getterdata() { - return (self->altdata); - } - -} - - -/* -11:06 <@Kasperle> but do you need to do that with elfshsect_t.data? -11:08 <@heroine> hmm .. i don't understand what you ask for :) -11:08 <@thorkill> if you want to use data as universal container then yes -11:08 <@thorkill> becouse .data can be verething -11:09 <@Kasperle> i'm working on python mappings for libelfsh with swig. and that has some trouble with void*, because it can't map that to useful python - types -11:09 <@thorkill> it depends on what a section represents ;-) afaik -11:10 <@thorkill> if you want to put controlflow binarytree into .data so you have to map it into binarytree -11:11 <@thorkill> if you are plaing with strings then map it into char * -11:11 <@novasilvr> Kasperle, the void * pointer is usually casted to something else before using, since that buffer can contain various kind of array of - different element type depending on the section type -11:12 <@thorkill> void represends a universal data type, which can be mapped into another type it depends on context ;-) -11:13 <@Kasperle> i thought maybe libelfsh uses it in one way only -11:13 <@novasilvr> no -11:14 <@novasilvr> can be array of char (casted to char*), array of elfsh_Sym*, array of everything that may be contained within a section -11:14 <@Kasperle> ok. is its size stored somewhere? -11:15 <@novasilvr> sect->shdr->sh_size -11:15 <@thorkill> ptr size ;-) -11:15 <@novasilvr> Kasperle, size of what ? -11:15 <@novasilvr> of the elem ? -11:15 <@Kasperle> of the structure that data points to -11:15 <@novasilvr> sect->shdr->sh_entsz may do the job -11:15 <@Kasperle> ok -11:16 <@novasilvr> sect beeing the elfshsect_t that contains the *data -11:17 <@novasilvr> Kasperle, sect->shdr->sh_entsz is the size of 1 element of the section -11:17 <@novasilvr> the section size is in sect->shdr->sh_size -11:17 <@novasilvr> with those 2 info you can compute the number of elemes -11:17 <@novasilvr> for that section -11:18 <@Kasperle> ok -11:18 <@novasilvr> if sect->shdr->sh_entsz == 0 -11:18 <@novasilvr> consider it = 1 -11:18 <@novasilvr> meaning the section is raw data .. or ascii .. -*/ \ No newline at end of file diff -Nru eresi-0.8a25/doc/.svn/text-base/libelfsh-ref.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/libelfsh-ref.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/libelfsh-ref.txt.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/libelfsh-ref.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,588 +0,0 @@ - - - ---------------------------- - Libelfsh 0.43b API reference - ---------------------------- - - -XXX: Need to be updated to 0.5 . For a complete list of the libelfsh 0.5 serie -API calls, read ../libelfsh/include/libelfsh.h . - - -------- - - -This is the first documentation for libelfsh-0.43b . You should definitely look at -the testsuite to understand how to do basic things . - -Structures has been created : - -- Elfsh32_Obj is the main object, describing the object itself, look at libelfsh.h for details . -- Elfsh32_Sect describes a section in the binary, contains a field pointing to its SHT entry . -- Elfsh32_Func describe a function . For the moment, Elf32_Func are created using .symtab . -- All structures beginning with Elfsh32_ are not OS native, they are elfsh specifics . - - - -An ELFsh object look like that : - - -/* ELF object structure */ -typedef struct s_obj -{ - - int fd; /* File descriptor for the original file */ - char *name; /* Object path */ - int type; /* ELFSH_OBJECT_CORE, ELFSH_OBJECT_SHARED, ELFSH_OBJECT_RELOC or ELFSH_OBJECT_EXEC */ - - /* Elf headers */ - Elf32_Ehdr *hdr; - Elf32_Shdr *sht; - Elf32_Phdr *pht; - - /* Section linked list */ - Elfsh32_Sect *sections; - - /* Unlinked sections */ - Elfsh32_Sect *sections_bean; - - /* ********************************************************************************** */ - /* The following variables point to their respective entry in the section linked list */ - /* ********************************************************************************** */ - - /* Symbol table related fields */ - Elfsh32_Sect *symtab; - - /* Dynamic symbol table related fields */ - Elfsh32_Sect *dynsym; - - /* Stab section fields (debugging symbols) */ - Elfsh32_Sect *stab; - - /* Symbol Hash (.hash) table fields */ - Elfsh32_Sect *hash; - - /* Dynamic structure fields (PT_DYNAMIC) */ - Elfsh32_Sect *dynamic; - - /* Constructors */ - Elfsh32_Sect *ctors; - - /* Destructors */ - Elfsh32_Sect *dtors; - - /* Global Offset Table fields */ - Elfsh32_Sect *got; - - /* Procedure Linkage Table (.plt) object */ - Elfsh32_Sect *plt; - - /* Interpretor section (PT_INTERP) */ - Elfsh32_Sect *interp; - - /* Symbol string table (.strtab) */ - Elfsh32_Sect *strtab; - - /* Stab string table (.stabstr) */ - Elfsh32_Sect *stab_strtab; - - /* Dynamic symbol string table (.dynstr) */ - Elfsh32_Sect *dyn_strtab; - - /* Section string table (.shstrtab) */ - Elfsh32_Sect *sh_strtab; - - /* Various internal fields for error handling */ - char buff[ELFSH_RULEZ_THE_WORLD]; - const char *error; - - /* Has the object already been function scanned ? */ - char scanned; - - /* Do we include the sht in the output file ? Default is YES (1) */ - char remove_sht_on_exit; - - /* The list is double linked */ - void *next; - void *prev; - -} Elfsh32_Obj; - - - -The Elfsh32_Sect object looks like this : - - -/* Section data type */ -typedef struct s_sect -{ - - /* Filled at creation */ - Elf32_Phdr *phdr; /* the first parent segment */ - Elf32_Shdr *shdr; /* section header for this section */ - struct s_sect *next; /* next section in the list */ - struct s_sect *prev; /* prev section in the list */ - struct s_obj *parent; /* parent ELF object file */ - int index; /* Section index in sht */ - char flags; /* Analysed/Raw, Orphelin/Child */ - char *name; /* Cached name */ - - /* Filled at loading */ - void *data; /* section's data cache */ - int nbr; /* Number of units (section type dependant) */ - - /* Filled at analysing */ - void *altdata; /* symtab stores a sorted table here, +x section stores the fht */ - int altnbr; /* Number of units for altdata */ - -} Elfsh32_Sect; - - - - - -Now lets look at the API itself : - - - -############## -ERROR HANDLING -############## - -On errors, the incriminated API call will return (-1) or NULL, depending on the return type . - -Print the last error message on STDERR : - -void elfsh_error(); - - - - -################################ -MAIN OBJECTS ACCESSIBILITY CALLS -################################ - - -These 2 first functions are used to create the Elfsh32_Obj entity in memory, if you plan -to modify the file, then you have to use elfsh_map_obj() . If you just want to read things, -then use elfsh_load_obj() . The main difference between them is that elfsh_load_obj() fills -data field on demand, whereas elfsh_map_obj() loads everything . - -Elfsh32_Obj *elfsh_load_obj(char *name); -Elfsh32_Obj *elfsh_map_obj(char *name); - - -Unload an object without saving : - -void elfsh_unload_obj(Elfsh32_Obj *file); - -Save changes and unload an object : - -int elfsh_save_obj(Elfsh32_Obj *file, char *name); - - -Retreive the ELF header, the returned type is (Elf32_Ehdr *) : - -void *elfsh_get_hdr(Elfsh32_Obj *file); - - -Get/Set various ELF header fields : - -u_int elfsh_get_objtype(Elf32_Ehdr *e); -u_int elfsh_get_arch(Elf32_Ehdr *e); -void elfsh_set_entry_point(Elfsh32_Obj *file, int addr); - - - - -##################### -SYMBOLS RELATED CALLS -##################### - - - -Some calls are identical for .dynsym symbols and .symtab symbols . Here is the list : - -Elf32_Sym *elfsh_create_symbol(int value, int size, int type, int binding, int visibility); -Elf32_Sym *elfsh_copy_symtab(void *addr, int size); -Elf32_Sym *elfsh_merge_symtabs(Elf32_Sym *one, Elf32_Sym *two, int size_one, int size_two); -void *elfsh_get_symbol_offset(Elf32_Sym *s); -u_int elfsh_get_symbol_bind(Elf32_Sym *s); -u_int elfsh_get_symbol_type(Elf32_Sym *s); -int elfsh_insert_symbol(Elfsh32_Sect *sect, Elf32_Sym *sym, char *name); -int elfsh_get_symbol_foffset(Elfsh32_Obj *file, Elf32_Sym *sym); -int elfsh_get_symbol_size(Elf32_Sym *s); - -There is 2 sorts possible : - . ELFSH_SORT_BY_ADDR sort symbols by address . - . ELFSH_SORT_BY_SIZE sort symbols by size . - -int elfsh_sort_symtab(Elf32_Sym *symtab, int size, int type); - - - - - * These are especialy for 'static' symbols (.symtab entries) : - -Useful function : It returns the nearest symbol name matching with sym_value and fill the -difference in *offset : - -Elf32_Sym *elfsh_get_symbol_by_name(Elfsh32_Obj *file, char *name); -char *elfsh_get_symbol_name(Elfsh32_Obj *file, Elf32_Sym *s); -char *elfsh_reverse_symbol(Elfsh32_Obj *file, u_int sym_value, int *offset); -void *elfsh_get_symtab(Elfsh32_Obj *file, int *num); - - - - * These are especially for dynamic symbols (.dynsym entries) : - - -Elf32_Sym *elfsh_get_dynsymbol_by_name(Elfsh32_Obj *file, char *name); -void *elfsh_get_dynsymtab(Elfsh32_Obj *file, int *num); -char *elfsh_reverse_dynsymbol(Elfsh32_Obj *file, u_int sym_value, int *offset); -char *elfsh_get_dynsymbol_name(Elfsh32_Obj *file, Elf32_Sym *s); -Elf32_Sym *elfsh_get_symbol_from_reloc(Elfsh32_Obj *file, Elf32_Rel *s); - - - - -################################ -SECTION HEADER TABLE (SHT) CALLS -################################ - - -Return the section header giving a STT_SECTION symbols found in .symtab : - -Elf32_Shdr *elfsh_get_shtentry_from_sym(Elfsh32_Obj *file, Elf32_Sym *sym); - - -Return the section header table (Elf32_Shdr *) and fill the number of entries in *num : - -void *elfsh_get_sht(Elfsh32_Obj *file, int *num); - - -Theses calls returns info about a given section header : - -int elfsh_section_is_executable(Elf32_Shdr *s); -int elfsh_section_is_writable(Elf32_Shdr *s); -int elfsh_section_is_allocatable(Elf32_Shdr *s); -int elfsh_section_is_mergeable(Elf32_Shdr *s); -int elfsh_section_is_strtab(Elf32_Shdr *s); -int elfsh_section_has_link(Elf32_Shdr *s); -int elfsh_section_has_order(Elf32_Shdr *s); -int elfsh_get_section_size(Elf32_Shdr *s); -int elfsh_get_section_align(Elf32_Shdr *s); -int elfsh_get_section_vaddr(Elf32_Shdr *s); -int elfsh_get_section_foffset(Elf32_Shdr *s); -u_int elfsh_get_section_type(Elf32_Shdr *s); -u_int elfsh_get_section_info(Elf32_Shdr *s); -u_int elfsh_get_section_entsize(Elf32_Shdr *s); -u_int elfsh_get_section_link(Elf32_Shdr *s); - - -Returns the section names provided .shstrtab is loaded (true by default ;) : - -char *elfsh_get_section_name(Elfsh32_Obj *file, Elf32_Shdr *s); - - -Changes fields in a SHT entry : - -void elfsh_set_sht_offset(Elfsh32_Obj *file, int num); -void elfsh_set_sht_nbr(Elfsh32_Obj *file, int num); -void elfsh_set_section_info(Elf32_Shdr *s, Elf32_Word info); -void elfsh_set_section_entsize(Elf32_Shdr *s, Elf32_Word entsize); -void elfsh_set_section_link(Elf32_Shdr *s, Elf32_Word link); -void elfsh_set_section_foffset(Elf32_Shdr *s, Elf32_Off offset); -void elfsh_set_section_addr(Elf32_Shdr *s, Elf32_Addr addr); - - -These 2 calls exists because the section injection and the section header table entry injection -are not the same . You need to insert a SHT entry before inserting the Section itself . Look at -the testsuite to know the exact syntax for Section injection . - -Elf32_Shdr elfsh_create_section_header(Elf32_Word name, Elf32_Word type, Elf32_Word flags, - Elf32_Addr addr, Elf32_Off offset, Elf32_Word size, - Elf32_Word link, Elf32_Word info, Elf32_Word align, - Elf32_Word entsize); - -You shouldnt use this one except if you know exactly what you are doing . If you want to insert a section -you should look at elfsh_insert_(un)mapped_section() in the next paragraph . This call insert a Section -header exactly where you want it to be inserted : - -int elfsh_insert_section_header(Elfsh32_Obj *file, Elf32_Shdr hdr, u_int range, char *name); - - -Rebuild a minimal Section header table if not present anymore . Very useful to disassemble -using bfd based tools (BFD doesnt rekognize ELF binary without SHT ;( : - -int elfsh_rebuild_sht(Elfsh32_Obj *file); - - -Used to indicate elfsh not to insert SHT when relinking using elfsh_save_obj() : - -void elfsh_remove_sht(Elfsh32_Obj *file); - - - -###################### -SECTION RELATED CALLS -###################### - - -Search for a 'range'th section whoose type is 'type', filling the index, strindex and num field if ptr are non null : - - - 'index' is the index for this section . - - 'strindex' is the section index for the linked string section (if one) . - - 'num' is the number of element for this section . - -Elfsh32_Sect *elfsh_get_section_by_type(Elfsh32_Obj *, u_int type, int *index, int *strindex, int *num, int range); - - -Search a section using its index in SHT : - -Elfsh32_Sect *elfsh_get_section_by_index(Elfsh32_Obj *, int index, int *strindex, int *num); - - -Search a section giving its name : - - -Elfsh32_Sect *elfsh_get_section_by_name(Elfsh32_Obj *, char *name, int *idx, int *strindex, int *num); - - -Return the parent Section giving a virtual address . The difference is filled in *offset : - -Elfsh32_Sect *elfsh_get_parent_section(Elfsh32_Obj *file, u_int value, int *offset); - - -The same function, this time using a file offset (useful for non mapped sections) : - -Elfsh32_Sect *elfsh_get_parent_section_by_foffset(Elfsh32_Obj *file, u_int value, int *offset); - - -Create a section in order to inject it (or not) . Look at the testsuite for exact syntax : - -Elfsh32_Sect *elfsh_create_section(char *name); - - -Load (force read related data in the file) a section in the Elfsh32_Obj structure : - -void *elfsh_get_anonymous_section(Elfsh32_Obj *file, Elfsh32_Sect *sect); - - -Insert a memory mapped section in the binary, and inject byts pointed by 'data' in it . Inject the number -of byte indicated in hdr.sh_size . The difference between the 2 is that the last one have to put the .bss -section physically in the file before (if not already done) . - -int elfsh_insert_unmapped_section(Elfsh32_Obj *file, Elfsh32_Sect *sect, Elf32_Shdr hdr, void *data) -int elfsh_insert_mapped_section(Elfsh32_Obj *file, Elfsh32_Sect *sect, Elf32_Shdr hdr, void *data) - -Append random data to a section : - -int elfsh_append_data_to_section(Elfsh32_Sect *sect, void *input, int len); - - - -################################### -PROGRAM HEADER RELATED (PHT) CALLS -################################### - - -Return a (Elf32_Phdr *) and fill *num with the PHT entries number : - -void *elfsh_get_pht(Elfsh32_Obj *file, int *num); -Elf32_Phdr *elfsh_get_segment_by_type(Elfsh32_Obj *file, int type, int range); -Elf32_Phdr *elfsh_get_parent_segment(Elfsh32_Obj *file, Elfsh32_Sect *new); -int elfsh_load_pht(Elfsh32_Obj *file); -int elfsh_segment_is_writable(Elf32_Phdr *p); -int elfsh_segment_is_readable(Elf32_Phdr *p); -int elfsh_segment_is_executable(Elf32_Phdr *p); -int elfsh_segment_is_parent(Elfsh32_Sect *new, Elf32_Phdr *p); -u_int elfsh_get_segment_type(Elf32_Phdr *p); - -This change values in the ELF header : - -void elfsh_set_pht_offset(Elfsh32_Obj *file, int num); -void elfsh_set_pht_nbr(Elfsh32_Obj *file, int num); - - - - -############################## -.DYNAMIC SECTION RELATED CALLS -############################## - - - -Elf32_Dyn *elfsh_get_dynamic(Elfsh32_Obj *file, int *num); -Elf32_Dyn *elfsh_get_dynamic_entry_by_type(Elfsh32_Obj *file, char type); -char *elfsh_get_dynentry_info(Elfsh32_Obj *file, Elf32_Dyn *d); -u_int elfsh_get_dynentry_type(Elf32_Dyn *d); - - - - - -################################# -GOT / DTORS / CTORS RELATED CALLS -################################# - -In all cases, the 'num' parameter is filled by the called function and indicate the number -of entries for this section (in this case, the number of 4 bytes dwords in the section, -in other word, section->sh_size / 4 . - -Modify an entry in the .got section, used to hijack library calls : - -void *elfsh_get_got(Elfsh32_Obj *file, int *num); -int elfsh_set_got_entry_by_name(Elfsh32_Obj *file, char *name, int new_addr); -int elfsh_set_got_entry_by_index(Elfsh32_Obj *file, int index, int new_addr); - - -Modify an entry in the .dtors section, used to hijack destructors functions : - -void *elfsh_get_dtors(Elfsh32_Obj *file, int *num); -int elfsh_set_dtors_entry_by_index(Elfsh32_Obj *file, int index, int new_addr); -int elfsh_set_dtors_entry_by_name(Elfsh32_Obj *file, char *name, int new_addr); - -Modify an entry in the .ctors section, used to hijack constructors functions : - -void *elfsh_get_ctors(Elfsh32_Obj *file, int *num); -int elfsh_set_ctors_entry_by_name(Elfsh32_Obj *file, char *name, int new_addr); -int elfsh_set_ctors_entry_by_index(Elfsh32_Obj *file, int index, int new_addr); - - - - -################### -STABS RELATED CALLS -################### - -'Num' is filled by the called function with the number of stab entries in the -returned section . - -Read-only interface for STABS : - -void *elfsh_get_stab(Elfsh32_Obj *file, int *num); -void *elfsh_get_stab_offset(Elfsh32_Stab_ent *s); -char *elfsh_get_stab_name(Elfsh32_Obj *file, Elfsh32_Stab_ent *s); -u_int elfsh_get_stab_type(Elfsh32_Stab_ent *s); - - - - -################### -.HASH RELATED CALLS -################### - - -These implement a wrapper for .hash as described in the ELF reference . - -int elfsh_get_symbol_hash(char *sym_name); -int elfsh_get_dynsymbol_by_hash(Elfsh32_Obj *file, char *sym_name); - - - - -######################## -RELOCATION RELATED CALLS -######################## - -Elfsh32_Sect *elfsh_get_reloc(Elfsh32_Obj *file, u_int range, char *name, u_int *num); -void *elfsh_get_reloffset(Elfsh32_Obj *file, Elf32_Rel *r); -void elfsh_free_reloc_list(Elfsh32_Obj *file); -u_int elfsh_get_reloc_type(Elf32_Rel *r); - - - -##################### -.INTERP RELATED CALLS -##################### - -char *elfsh_get_interp(Elfsh32_Obj *file); - - - -#################### -.NOTES RELATED CALLS -#################### - - -Elfsh32_Sect *elfsh_get_notes(Elfsh32_Obj *file, u_int range, char *name); -void elfsh_free_notes_list(Elfsh32_Obj *file); - - - -####################### -FUNCTIONS RELATED CALLS -####################### - -You may not use for writing purpose since the interface for it is not clearly -defined for the moment . The implementation of this is pretty weak since it -relies on .symtab instead of parsing the code, but this is in the TODO list . - -Elfsh32_Func *elfsh_get_function_by_addr(Elfsh32_Obj *file, int addr); -Elfsh32_Func *elfsh_get_function_by_name(Elfsh32_Obj *file, char *name); -int elfsh_get_function_len(Elfsh32_Func *func); -int elfsh_get_function_addr(Elfsh32_Func *func); - - - -########################################### -PROCEDURE LINKAGE TABLE (PLT) RELATED CALLS -########################################### - - -Elfsh32_Sect *elfsh_get_plt(Elfsh32_Obj *file, int *num); - -Useful to fingerprint STT_FUNCTION typed symbols and guess if its pointing in .plt : - -int elfsh_is_pltentry(Elfsh32_Obj *file, Elf32_Sym *sym); -int elfsh_is_plt(Elfsh32_Obj *file, Elf32_Shdr *s); - - - - -################################### -RAW READ/WRITE ACCESS RELATED CALLS -################################### - - -Use this for multiple purpose : - -int elfsh_raw_write(Elfsh32_Obj *file, u_int dst, void *src, int len); -int elfsh_raw_read(Elfsh32_Obj *file, u_int dst, void *src, int len); -int elfsh_get_foffset_from_vaddr(Elfsh32_Obj *file, u_int vaddr); - - - -######################### -.(SH)STRTAB RELATED CALLS -######################### - - - -Useful to add a just-inserted symbol name in the binary : - -int elfsh_insert_in_strtab(Elfsh32_Obj *file, char *name); - -Useful to add a just_inserted section name in the binary : - -int elfsh_insert_in_shstrtab(Elfsh32_Obj *file, char *name); - - - - - - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/doc/.svn/text-base/LICENSE.svn-base eresi-0.0.20110516/doc/.svn/text-base/LICENSE.svn-base --- eresi-0.8a25/doc/.svn/text-base/LICENSE.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/LICENSE.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff -Nru eresi-0.8a25/doc/.svn/text-base/rtld-multiarch.txt.svn-base eresi-0.0.20110516/doc/.svn/text-base/rtld-multiarch.txt.svn-base --- eresi-0.8a25/doc/.svn/text-base/rtld-multiarch.txt.svn-base 2008-04-06 23:15:51.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/rtld-multiarch.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ - - -Sous Linux/MIPS: - -- on load got+8 (= *[%gp - 0x8000 + 8]) dans un registre (ex: %a0) -- on ajoute un offset pour arriver a la bonne entree de la got - --> utilise pour les pointeurs passes en param (ex: ptr sur des .rodata) - -- on load la bonne entre de got dans un registre (ex: %t9) - Pour cela on fait : *[%gp - 0x8000 + off] calcule direct depuis .text - --> on load l'addr de la func a appeler dans le registre - - * Si on est pas deja resolve, on execute lentree de la plt pour la - fonction: - - 0x400680 : lw t9,-32752(gp) - 0x400684 : move t7,ra - 0x400688 : jalr t9 - 0x40068c : li t8,9 - -Il n'y a pas de vrai plt, cest juste ce morceau de code qui est duplique -autant de fois qu'il le faut et ajoute dans .text juste apres le _start. - - On fait une sauvegarde de $ra dans $t7 ce qui va identifier - l'entree de la pseudo-plt au dynamic linker. L'offset dans $t8 - est un offset dans .dynsym - - - - * Si on etait deja resolve (donc la .got deja remplie pour cette - fonction), alors on appelera directement la bonne fonction car - la got aura ete renseignee et le call indirect depuis .text ira - directement au bon endroit. - - diff -Nru eresi-0.8a25/doc/.svn/text-base/TODO.svn-base eresi-0.0.20110516/doc/.svn/text-base/TODO.svn-base --- eresi-0.8a25/doc/.svn/text-base/TODO.svn-base 2008-04-06 23:15:50.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/TODO.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ - - # # # # # # ## - ## - #### - ######## - ################ - ######################## - ELFsh TODO phile # - ######################## - - . TLS variables API - . Use MMAP_FIXED mappings in debugger heap - . Better rights than rwx for runtime injected phdr (try double-map) - . Fix all warnings on all OS and (re)compile on HPUX - -[quick] . Use sigaction's context to populate reg's var on SIGINT/SIGSEGV -[quick] . be able to change the compiler and compiling options -!!! . Multiple BSS : symbol injected many times in find_bsslen (fixup_sctndx really useful ?) -!!! . Put doxygen comments and generate the ELF shell reference manual -!!! . Update manpage - - <----- Here release 0.7-portable - -[Main TODO] - . Support step over, step into, step in sources - . Conditions on breakpoints - . Add ALTGOT vector (need a small fix in the alpha algorithm) - . Finish ET_REL for MIPS - . Complete MIPS SHT/DYNAMIC types ASCII's - . Better function hijacking to replace breakpoint opcodes - . Be able to add new internal types using the script language - . Be able to breakpoint a debugger function - . More high level control flow : while if else if endif end - . Hash tables working with 'foreachof' and 'eol' - . File reconstruction from memory - . Support file building from scratch and support ET_REL injection on it - . Signal proxying working in multithreads - . SUN Version section rw API (and add it to the hierarchy) - . DWARF support and step in sources - . Packer/Unpacker hook interface (Generalized hooking VM interface) - . Hook command (include hlist) - . Watchpoints on memory (problem: debug registers are ring0 only) - . Use a runtime symtab/strtab for memory modifications - . Signal proxying (when the debuggee set signals) - . support X/x number types [regx] command and D regx regx commands - . Replace all #ifdef __DEBUG*__ by ELFSH_PROFILE_DEBUG() calls - . e2dbg scripts from cmdline (filexist, $var1_blabla$var2 format) - . Better runtime EXTPLT (without mprotect) - . unredir and undisplay command - . b __guard@libc.so.6 format - . Be able to bt without fp - . Include hooks in scripting language - . ltrace multiarch - . add syntax explaination in help - . e2dbg VS gdb (undisplay, bt with core, frame command, call command) - . uuprint command - . add ~ expansion - . Recode paxctl in elfsh script - . add vsyscall table support : http://lwn.net/Articles/30258/ - . Execution of script located in .elfsh.d/ from IMODE - . Leave command : exit the debugger by unmapping it - -[porting] - . Debug PaX-safe third-type injection on SPARC / ALPHA - . CFLOW for SPARC and ALPHA - . Dumpregs, Breakpoints, Backtrace on SPARC - . EXTPLT / ET_REL into ET_DYN for SPARC - . Dumpregs, Breakpoints, Backtrace on ALPHA - . EXTPLT / ET_REL to ET_DYN on ALPHA - . Dumpregs, Breakpoints, Backtrace on MIPS - . EXTPLT / ET_REL into ET_DYN for MIPS - . Full support for HPPA, PPC, ARM, IA64, AMD64 - -[minor bugs] -. BUG : remove memleaks (VALGRIND!) -. BUG : reported by emperor (shnum, phnum, shsize modifs without data insertion) -. BUG : Check cmd_connect error handling -. BUG : NET client's (private) objects aren't unloaded on disconnection -. BUG : NET shell prompt displayed twice (! cmd) -. BUG : multiple workspace on DUMP connection (actual->data->active && network.c:761) -. BUG : DUMP + e2dbg + cont/b/... -. BUG : Cannot list notes anymore - -[less important features TODO] - . LKM & static kernel infection - . DYNAMIC insertion API - . Be able to call dtrace on Solaris - . Support ELF32 / ELF64 at the same time - . Improve completion (do better tables in tables.c) - . CTORS, DTORS entry insertion API (need to change code references ..) - . Section data, got, ctors, dtors, dynamic, rel*, plt removing ELF API - . REMOVE VM commands for section data, dynsyms, got, ctors, dtors, dynamic, rel*, plt - . md5 known blocks to rebuild true symbol names in static binaries - . SUN/x86 objets translation into GNU/x86 - . Libasm handlers scripting - . Support 'addr' L2 field for got, ctors, dtors, rel, dynsym, sym (return the object address) - . Advanced relocation entries lookup in grammar.c - . INSERT VM commands for dynsyms, got, ctors, dtors, dynamic, rel*, plt, function - . elfsh_export_symbol() (copy .symtab entry as a .dynsym entry) - -[SHT RECONSTRUCTION] -[SHT rebuilding : use ELFsh 0.43b for a better implem of this feature] - - . Bad .dynamic insertion => .shstrtab sh_offset += 9 (why ?) - . fix bug in mapped_offset (offset not updated) - . Bad sh_off in elfsh_rebuild_sht() => bad output file (why ?) - . rebuild .text and .data using PHT (warn: size unknown!) - . rebuild .init and .fini using .dynamic (warn: size unknown!) - . consider the padding (max 3 bytes) in SHT reconstruct . - . correct the '|' thing in PHT linking perspective . - . Reconstruct .shstrtab if missing but SHT is present - . SHT reconstruction paper - - diff -Nru eresi-0.8a25/doc/.svn/text-base/VERSION.svn-base eresi-0.0.20110516/doc/.svn/text-base/VERSION.svn-base --- eresi-0.8a25/doc/.svn/text-base/VERSION.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/doc/.svn/text-base/VERSION.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -0.8a25 diff -Nru eresi-0.8a25/doc/TODO eresi-0.0.20110516/doc/TODO --- eresi-0.8a25/doc/TODO 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/TODO 2011-05-16 11:34:14.000000000 +0000 @@ -5,9 +5,12 @@ ######## ################ ######################## - ELFsh TODO phile # + ERESI TODO File # ######################## +This file is grouping a couple of features that could be implemented +in the future. + . TLS variables API . Use MMAP_FIXED mappings in debugger heap . Better rights than rwx for runtime injected phdr (try double-map) diff -Nru eresi-0.8a25/doc/VERSION eresi-0.0.20110516/doc/VERSION --- eresi-0.8a25/doc/VERSION 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/doc/VERSION 2011-05-16 11:34:14.000000000 +0000 @@ -1 +1,2 @@ -0.8a25 +0.82b2 + diff -Nru eresi-0.8a25/doxygen.conf eresi-0.0.20110516/doxygen.conf --- eresi-0.8a25/doxygen.conf 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/doxygen.conf 2011-05-16 11:35:08.000000000 +0000 @@ -0,0 +1,1510 @@ +# Doxyfile 1.5.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = ERESI + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.82 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = html + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, +# Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = NO + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = NO + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = YES + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = YES + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = YES + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. + +GENERATE_TREEVIEW = HIERARCHIES + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = NO + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = NO + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = NO + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = NO + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Options related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = YES diff -Nru eresi-0.8a25/e2dbg/include/e2dbg.h eresi-0.0.20110516/e2dbg/include/e2dbg.h --- eresi-0.8a25/e2dbg/include/e2dbg.h 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/include/e2dbg.h 2011-05-16 11:34:08.000000000 +0000 @@ -1,9 +1,9 @@ /** - * @file e2dbg.h +* @file e2dbg/include/e2dbg.h * * Started on Thu Feb 22 07:19:04 2001 jfv * - * $Id: e2dbg.h,v 1.24 2008-02-16 12:30:37 thor Exp $ + * $Id: e2dbg.h 1397 2009-09-13 02:19:08Z may $ * */ #ifndef __E2DBG_H_ diff -Nru eresi-0.8a25/e2dbg/include/.svn/all-wcprops eresi-0.0.20110516/e2dbg/include/.svn/all-wcprops --- eresi-0.8a25/e2dbg/include/.svn/all-wcprops 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/925/trunk/e2dbg/include -END -e2dbg.h -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/925/trunk/e2dbg/include/e2dbg.h -END diff -Nru eresi-0.8a25/e2dbg/include/.svn/entries eresi-0.0.20110516/e2dbg/include/.svn/entries --- eresi-0.8a25/e2dbg/include/.svn/entries 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/e2dbg/include -http://svn.eresi-project.org/svn - - - -2008-03-24T18:25:11.790287Z -925 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -e2dbg.h -file - - - - -2008-04-06T23:15:30.272894Z -fb55611a6796dcd1534a8bc58d2dfeab -2008-03-24T18:25:11.790287Z -925 -enioh - diff -Nru eresi-0.8a25/e2dbg/include/.svn/format eresi-0.0.20110516/e2dbg/include/.svn/format --- eresi-0.8a25/e2dbg/include/.svn/format 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/e2dbg/include/.svn/text-base/e2dbg.h.svn-base eresi-0.0.20110516/e2dbg/include/.svn/text-base/e2dbg.h.svn-base --- eresi-0.8a25/e2dbg/include/.svn/text-base/e2dbg.h.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/include/.svn/text-base/e2dbg.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/** - * @file e2dbg.h - * - * Started on Thu Feb 22 07:19:04 2001 jfv - * - * $Id: e2dbg.h,v 1.24 2008-02-16 12:30:37 thor Exp $ - * - */ -#ifndef __E2DBG_H_ -#define __E2DBG_H_ - -/* User defined configuration */ -#include "revm.h" - -#define E2DBG_CONFIG ".e2dbgrc" - -#if defined(__FreeBSD__) || defined(sun) || defined(__NetBSD__) || defined(__OpenBSD__) - extern char **environ; -#endif - -/* Top skeleton functions */ -int revm_main(int ac, char **av); - -#endif /* __E2DBG_H_ */ - diff -Nru eresi-0.8a25/e2dbg/main.c eresi-0.0.20110516/e2dbg/main.c --- eresi-0.8a25/e2dbg/main.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/main.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,27 +1,23 @@ /** - * @defgroup e2dbg e2dbg + * @defgroup e2dbg e2dbg: The Embedded ERESI debugger. */ -/* - * @file main.c +/** +* @file e2dbg/main.c * @ingroup e2dbg - * The embedded ELF debugger + * @brief Implement E2DBG client side entry points. * * Started on Wed Feb 21 22:02:36 2001 jfv - * Updated on Wed Jan 03 17:51:04 2007 jfv - * - * $Id: main.c,v 1.20 2008-02-16 12:30:23 thor Exp $ - * + * $Id: main.c 1397 2009-09-13 02:19:08Z may $ */ #include "e2dbg.h" char *version; -//#undef ELFSH_DBGPATH -//#define ELFSH_DBGPATH "/home/enioreh/devhell/eresi/libe2dbg" /** - * Setup LD_PRELOAD for dynamic binaries debugging + * Setup LD_PRELOAD for dynamic binaries debugging + * @ingroup e2dbg */ void revm_debugger_preload() { @@ -32,12 +28,13 @@ char buf[BUFSIZ / 2]; char *str; - /* Prepare the new LD_PRELOAD */ + /* Prepare the new LD_PRELOAD -- + use --enable-testing to test e2dbg without install */ str = getenv("LD_PRELOAD"); if (!str || !*str) - snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so", ELFSH_DBGPATH, version); + snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so", E2DBG_PATH, version); else - snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so:%s", ELFSH_DBGPATH, version, str); + snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so:%s", E2DBG_PATH, version, str); #if !defined(sun) ret = setenv("LD_PRELOAD", buf, 1); @@ -58,6 +55,7 @@ * Inject the .o debugger file into the static binary * @param file * @return + * @ingroup e2dbg */ char* revm_debugger_inject(elfshobj_t *file) { @@ -69,15 +67,15 @@ /* Map host file */ ptr = ptr2 = NULL; - buflen = strlen(ELFSH_DBGPATH) + strlen(file->name) + 20; + buflen = strlen(E2DBG_PATH) + strlen(file->name) + 20; buf = calloc(buflen, 1); - snprintf(buf, buflen, "%s/e2dbg-rel%s.o", ELFSH_DBGPATH, version); + snprintf(buf, buflen, "%s/e2dbg-rel%s.o", E2DBG_PATH, version); reloc = elfsh_map_obj(buf); if (!reloc) { fprintf(stderr, " [E] Static target and unable to load %s/e2dbg-rel%s.o \n", - ELFSH_DBGPATH, version); + E2DBG_PATH, version); return (NULL); } fprintf(stderr, " [*] Now injecting debugger in target binary .. please wait .. \n"); @@ -116,7 +114,7 @@ return (NULL); } - return (buf); + return buf; } @@ -126,6 +124,7 @@ * @param ac Number of arguments. * @param av Array of arguments. * @return + * @ingroup e2dbg */ int revm_execute_debuggee(int ac, char **av) { @@ -168,13 +167,14 @@ * @param ac * @param av * @return + * @ingroup e2dbg */ int e2dbg_main(int ac, char **av) { pid_t pid; int status; - revm_setup(ac, av, REVM_STATE_DEBUGGER, REVM_SIDE_CLIENT); + revm_setup(ac, av, REVM_STATE_EMBEDDED, REVM_SIDE_CLIENT); revm_config(E2DBG_CONFIG); pid = fork(); if (!pid) @@ -198,21 +198,20 @@ } revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); + revm_run(ac, av); + return (0); } /** - * The main ELFsh routine + * The starting E2dbg routine * @param ac * @param av * @return + * @ingroup e2dbg */ int main(int ac, char **av) { //fprintf(stderr, "e2dbg client main -----------> \n"); return (e2dbg_main(ac, av)); } - - - diff -Nru eresi-0.8a25/e2dbg/Makefile eresi-0.0.20110516/e2dbg/Makefile --- eresi-0.8a25/e2dbg/Makefile 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/Makefile 2011-05-16 11:34:09.000000000 +0000 @@ -2,7 +2,7 @@ ## Makefile for e2dbg in ERESI ## ## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id +## $Id: Makefile 1428 2010-07-09 21:12:29Z thorkill $ ## include ../config.h @@ -24,7 +24,7 @@ -I../libui/include/ -I../libmjollnir/include/ \ -I../libaspect/include -I../librevm/include/ \ -I../libedfmt/include/ -I../liballocproxy/include/ \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ + -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ -DERESI32 CFLAGS64 += -fPIC -g3 -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ @@ -34,46 +34,48 @@ -I../libui/include/ -I../libmjollnir/include/ \ -I../libaspect/include -I../librevm/include/ \ -I../libedfmt/include/ -I../liballocproxy/include/ \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ + -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ -DERESI64 LDFLAGS32 += -L../liballocproxy -lallocproxy -L../libelfsh/ -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi -lstderesi32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm \ + -L../libetrace/ -letrace32 \ + -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm32 \ -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ + -L../libstderesi -lstderesi32 \ -L../libmjollnir -lmjollnir32 -g3 \ - -L../libui/ -lui32 -L../libedfmt -ledfmt32 $(LDASMOPT) \ + -L../libui/ -lui32 -L../libedfmt -ledfmt32 \ $(LDREADLNOPT) $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) \ - -DERESI32 $(EXTRAOPT) $(LDDUMPOPT) $(LPTHREAD) $(LDMJOLLNIR) $(KERNSHLIB32)\ - $(NCURSESLNOPT) $(READLNOPT) + -DERESI32 $(EXTRAOPT) $(LDDUMPOPT32) $(LPTHREAD) \ + $(LDMJOLLNIR) $(NCURSESLNOPT) $(READLNOPT) LDFLAGS64 += -L../liballocproxy -lallocproxy -L../libelfsh/ -lelfsh64 \ - -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm \ + -L../libetrace/ -letrace64 \ + -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm64 \ -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ + -L../libstderesi -lstderesi64 \ -L../libmjollnir -lmjollnir64 -g3 \ - -L../libui/ -lui64 -L../libedfmt -ledfmt64 $(LDASMOPT) \ + -L../libui/ -lui64 -L../libedfmt -ledfmt64 \ $(LDREADLNOPT) $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) \ - -DERESI64 $(EXTRAOPT) $(LDDUMPOPT) $(LPTHREAD) $(LDMJOLLNIR) $(KERNSHLIB64)\ - $(NCURSESLNOPT) $(READLNOPT) + -DERESI64 $(EXTRAOPT) $(LDDUMPOPT64) $(LPTHREAD) \ + $(LDMJOLLNIR) $(NCURSESLNOPT) $(READLNOPT) all : all32 all64 all32 : ${OBJ32} - @$(CC) $(OBJ32) $(LDFLAGS32) -o $(DBGNAME32) + $(CC) $(OBJ32) $(LDFLAGS32) -o $(DBGNAME32) all64 : ${OBJ64} - @$(CC) $(OBJ64) $(LDFLAGS64) -o $(DBGNAME64) + $(CC) $(OBJ64) $(LDFLAGS64) -o $(DBGNAME64) clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - @$(RM) *.??.o + $(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + $(RM) include/*~ include/\#* include/*\# include/.\#* + $(RM) *.??.o fclean : clean - @$(RM) $(NAME) $(OBJ_DYN) $(DBGNAME) - @$(RM) $(NAME32) $(OBJ_DYN32) $(DBGNAME32) - @$(RM) $(NAME64) $(OBJ_DYN64) $(DBGNAME64) + $(RM) $(NAME) $(OBJ_DYN) $(DBGNAME) + $(RM) $(NAME32) $(OBJ_DYN32) $(DBGNAME32) + $(RM) $(NAME64) $(OBJ_DYN64) $(DBGNAME64) %.32.o : %.c $(CC) $(CFLAGS32) -c -o $@ $< diff -Nru eresi-0.8a25/e2dbg/.svn/all-wcprops eresi-0.0.20110516/e2dbg/.svn/all-wcprops --- eresi-0.8a25/e2dbg/.svn/all-wcprops 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 29 -/svn/!svn/ver/925/trunk/e2dbg -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/914/trunk/e2dbg/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/830/trunk/e2dbg/Makefile -END diff -Nru eresi-0.8a25/e2dbg/.svn/entries eresi-0.0.20110516/e2dbg/.svn/entries --- eresi-0.8a25/e2dbg/.svn/entries 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/e2dbg -http://svn.eresi-project.org/svn - - - -2008-03-24T18:25:11.790287Z -925 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -main.c -file - - - - -2008-04-06T23:15:30.306142Z -2097caa85511154a393838f7dff34c37 -2008-03-18T16:49:26.066981Z -914 -pouik - -Makefile -file - - - - -2008-04-06T23:15:30.316398Z -ad88135905e2b93acfd94f0477984bfe -2007-11-29T14:01:56.000000Z -830 -may - diff -Nru eresi-0.8a25/e2dbg/.svn/format eresi-0.0.20110516/e2dbg/.svn/format --- eresi-0.8a25/e2dbg/.svn/format 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/e2dbg/.svn/text-base/main.c.svn-base eresi-0.0.20110516/e2dbg/.svn/text-base/main.c.svn-base --- eresi-0.8a25/e2dbg/.svn/text-base/main.c.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,218 +0,0 @@ -/** - * @defgroup e2dbg e2dbg - */ -/* - * @file main.c - * @ingroup e2dbg - * The embedded ELF debugger - * - * Started on Wed Feb 21 22:02:36 2001 jfv - * Updated on Wed Jan 03 17:51:04 2007 jfv - * - * $Id: main.c,v 1.20 2008-02-16 12:30:23 thor Exp $ - * - */ -#include "e2dbg.h" - - -char *version; - -//#undef ELFSH_DBGPATH -//#define ELFSH_DBGPATH "/home/enioreh/devhell/eresi/libe2dbg" - -/** - * Setup LD_PRELOAD for dynamic binaries debugging - */ -void revm_debugger_preload() -{ -#if defined(sun) - char envbuf[BUFSIZ / 2]; -#endif - int ret; - char buf[BUFSIZ / 2]; - char *str; - - /* Prepare the new LD_PRELOAD */ - str = getenv("LD_PRELOAD"); - if (!str || !*str) - snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so", ELFSH_DBGPATH, version); - else - snprintf(buf, sizeof(buf), "%s/libe2dbg%s.so:%s", ELFSH_DBGPATH, version, str); - -#if !defined(sun) - ret = setenv("LD_PRELOAD", buf, 1); -#else - snprintf(envbuf, sizeof(envbuf), "LD_PRELOAD=%s", buf); - ret = putenv(envbuf); -#endif - - if (ret) - fprintf(stderr, "Failed to preload libe2dbg\n"); - else - fprintf(stderr, " [*] Preloading %s \n", buf); -} - - - -/** - * Inject the .o debugger file into the static binary - * @param file - * @return - */ -char* revm_debugger_inject(elfshobj_t *file) -{ - char *buf; - elfshobj_t *reloc; - int buflen; - char *ptr; - char *ptr2; - - /* Map host file */ - ptr = ptr2 = NULL; - buflen = strlen(ELFSH_DBGPATH) + strlen(file->name) + 20; - buf = calloc(buflen, 1); - snprintf(buf, buflen, "%s/e2dbg-rel%s.o", ELFSH_DBGPATH, version); - reloc = elfsh_map_obj(buf); - if (!reloc) - { - fprintf(stderr, - " [E] Static target and unable to load %s/e2dbg-rel%s.o \n", - ELFSH_DBGPATH, version); - return (NULL); - } - fprintf(stderr, " [*] Now injecting debugger in target binary .. please wait .. \n"); - - /* Inject debugger in target file */ - //profiler_enable_err(); - //profiler_enable_out(); - - //sleep(5); - - if (elfsh_inject_etrel(file, reloc) < 0) - { - fprintf(stderr, - " [E] Target binary is static and unable to inject e2dbg-rel%s.o \n", - version); - return (NULL); - } - - //profiler_disable_err(); - //profiler_disable_out(); - - snprintf(buf, buflen, "%s.dbg", file->name); - fprintf(stderr, " [*] Now saving target binary : %s \n", buf); - - /* Save object to be debugged */ - if (elfsh_save_obj(file, buf) < 0) - { - ptr = file->name; - while ((ptr = strchr(ptr, '/'))) - ptr2 = ++ptr; - if (!ptr2) - ptr2 = file->name; - snprintf(buf, buflen, "/tmp/%s.dbg", ptr2); - fprintf(stderr, " [*] Now saving target binary : %s \n", buf); - if (elfsh_save_obj(file, buf) < 0) - return (NULL); - } - - return (buf); -} - - - -/** - * Execute the debuggee program - * @param ac Number of arguments. - * @param av Array of arguments. - * @return - */ -int revm_execute_debuggee(int ac, char **av) -{ - char **args; - int index; - elfshobj_t *file; - -#if defined(ERESI32) - version = "32"; -#elif defined(ERESI64) - version = "64"; -#else - printf("Unknown debugger version : fatal error \n"); - exit(-1); -#endif - - /* Map the debugger in the debuggee */ - file = elfsh_map_obj(av[1]); - if (!file || !elfsh_static_file(file)) - revm_debugger_preload(); - else - { - av[1] = revm_debugger_inject(file); - if (av[1] == NULL) - exit(-1); - } - - /* Execute the debuggee program */ - args = alloca(ac * sizeof(char *)); - for (index = 1; index < ac; index++) - args[index - 1] = av[index]; - args[index - 1] = NULL; - execve(args[0], args, environ); - exit(-1); -} - - -/** - * The real main function - * @param ac - * @param av - * @return - */ -int e2dbg_main(int ac, char **av) -{ - pid_t pid; - int status; - - revm_setup(ac, av, REVM_STATE_DEBUGGER, REVM_SIDE_CLIENT); - revm_config(E2DBG_CONFIG); - pid = fork(); - if (!pid) - revm_execute_debuggee(ac, av); - else - { - - usleep(50000); - - // debugging purpose - //sleep(20); - - if (waitpid(pid, &status, WNOHANG) != 0) - { - revm_output("\n [E] Target binary not found\n"); - revm_output("\n Syntax : "); - revm_output(av[0]); - revm_output(" target_binary \n\n"); - exit(-1); - } - } - - revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); -} - - -/** - * The main ELFsh routine - * @param ac - * @param av - * @return - */ -int main(int ac, char **av) -{ - //fprintf(stderr, "e2dbg client main -----------> \n"); - return (e2dbg_main(ac, av)); -} - - - diff -Nru eresi-0.8a25/e2dbg/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/e2dbg/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/e2dbg/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/e2dbg/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -## -## Makefile for e2dbg in ERESI -## -## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id -## - -include ../config.h - -SRC = main.c -OBJ = $(SRC:.c=.o) -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f -DBGNAME = e2dbg -DBGNAME32 = e2dbg32 -DBGNAME64 = e2dbg64 - -CFLAGS32 += -fPIC -g3 -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../libdump/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libasm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include -I../librevm/include/ \ - -I../libedfmt/include/ -I../liballocproxy/include/ \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ - -DERESI32 - -CFLAGS64 += -fPIC -g3 -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../libdump/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libasm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include -I../librevm/include/ \ - -I../libedfmt/include/ -I../liballocproxy/include/ \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) $(READLNOPT) \ - -DERESI64 - -LDFLAGS32 += -L../liballocproxy -lallocproxy -L../libelfsh/ -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi -lstderesi32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -L../libmjollnir -lmjollnir32 -g3 \ - -L../libui/ -lui32 -L../libedfmt -ledfmt32 $(LDASMOPT) \ - $(LDREADLNOPT) $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) \ - -DERESI32 $(EXTRAOPT) $(LDDUMPOPT) $(LPTHREAD) $(LDMJOLLNIR) $(KERNSHLIB32)\ - $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS64 += -L../liballocproxy -lallocproxy -L../libelfsh/ -lelfsh64 \ - -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libasm/ -lasm \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -L../libmjollnir -lmjollnir64 -g3 \ - -L../libui/ -lui64 -L../libedfmt -ledfmt64 $(LDASMOPT) \ - $(LDREADLNOPT) $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) \ - -DERESI64 $(EXTRAOPT) $(LDDUMPOPT) $(LPTHREAD) $(LDMJOLLNIR) $(KERNSHLIB64)\ - $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -all32 : ${OBJ32} - @$(CC) $(OBJ32) $(LDFLAGS32) -o $(DBGNAME32) - -all64 : ${OBJ64} - @$(CC) $(OBJ64) $(LDFLAGS64) -o $(DBGNAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - @$(RM) *.??.o - -fclean : clean - @$(RM) $(NAME) $(OBJ_DYN) $(DBGNAME) - @$(RM) $(NAME32) $(OBJ_DYN32) $(DBGNAME32) - @$(RM) $(NAME64) $(OBJ_DYN64) $(DBGNAME64) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - - diff -Nru eresi-0.8a25/elfsh/cleanup.c eresi-0.0.20110516/elfsh/cleanup.c --- eresi-0.8a25/elfsh/cleanup.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/cleanup.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file cleanup.c +* @file elfsh/cleanup.c * @ingroup elfsh * @brief This command cleanup a file by marking as removed all injected sections. * * Started on Sat May 31 23:48:41 2005 jfv * - * $Id: cleanup.c,v 1.6 2008-02-16 12:31:34 thor Exp $ + * $Id: cleanup.c 1397 2009-09-13 02:19:08Z may $ * */ #include "elfsh.h" diff -Nru eresi-0.8a25/elfsh/include/elfsh.h eresi-0.0.20110516/elfsh/include/elfsh.h --- eresi-0.8a25/elfsh/include/elfsh.h 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/elfsh.h 2011-05-16 11:35:01.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file elfsh.h +* @file elfsh/include/elfsh.h * @ingroup elfsh * * Started on Thu Feb 22 07:19:04 2001 jfv * * - * $Id: elfsh.h,v 1.41 2007-11-29 14:01:55 may Exp $ + * $Id: elfsh.h 1397 2009-09-13 02:19:08Z may $ * */ #ifndef __ELFSH_H_ diff -Nru eresi-0.8a25/elfsh/include/elfsh-help.h eresi-0.0.20110516/elfsh/include/elfsh-help.h --- eresi-0.8a25/elfsh/include/elfsh-help.h 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/elfsh-help.h 2011-05-16 11:35:01.000000000 +0000 @@ -1,10 +1,10 @@ -/* -** elfsh-help.h for elfsh -** -** Started on Thu Aug 15 07:19:04 2005 jfv -** -** $Id: elfsh-help.h,v 1.15 2007-07-31 03:28:46 may Exp $ +/** +** @file elfsh-help.h +** @ingroup libelfsh +** @brief Help strings for elfsh specific commands. ** +** Started on Thu Aug 15 07:19:04 2005 jfv +** $Id: elfsh-help.h 1398 2009-09-13 07:00:08Z may $ */ #ifndef __ELFSH_HELP_H_ #define __ELFSH_HELP_H_ diff -Nru eresi-0.8a25/elfsh/include/.svn/all-wcprops eresi-0.0.20110516/elfsh/include/.svn/all-wcprops --- eresi-0.8a25/elfsh/include/.svn/all-wcprops 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/925/trunk/elfsh/include -END -elfsh.h -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/925/trunk/elfsh/include/elfsh.h -END -elfsh-help.h -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/749/trunk/elfsh/include/elfsh-help.h -END diff -Nru eresi-0.8a25/elfsh/include/.svn/entries eresi-0.0.20110516/elfsh/include/.svn/entries --- eresi-0.8a25/elfsh/include/.svn/entries 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/elfsh/include -http://svn.eresi-project.org/svn - - - -2008-03-24T18:25:11.790287Z -925 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -elfsh.h -file - - - - -2008-04-06T23:15:46.683126Z -6ad34c49ff28cbbfe1e97b549f50fd9f -2008-03-24T18:25:11.790287Z -925 -enioh - -elfsh-help.h -file - - - - -2008-04-06T23:15:46.693559Z -4632554d12b7a26d71eb9c87c2f56275 -2007-07-31T03:28:48.000000Z -749 -may - diff -Nru eresi-0.8a25/elfsh/include/.svn/format eresi-0.0.20110516/elfsh/include/.svn/format --- eresi-0.8a25/elfsh/include/.svn/format 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/elfsh/include/.svn/text-base/elfsh-help.h.svn-base eresi-0.0.20110516/elfsh/include/.svn/text-base/elfsh-help.h.svn-base --- eresi-0.8a25/elfsh/include/.svn/text-base/elfsh-help.h.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/.svn/text-base/elfsh-help.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** elfsh-help.h for elfsh -** -** Started on Thu Aug 15 07:19:04 2005 jfv -** -** $Id: elfsh-help.h,v 1.15 2007-07-31 03:28:46 may Exp $ -** -*/ -#ifndef __ELFSH_HELP_H_ - #define __ELFSH_HELP_H_ - -/* Commands */ -#define HLP_SHTRM "Mark Section Header Table as removed" -#define HLP_STRIP "Mark the symbol table (.symtab) as stripped" -#define HLP_SSTRIP "Mark the Section Header Table (SHT) and Symbol Table (.symtab) as stripped" -#define HLP_RUN "Run the analyzed program/process again" - -#endif diff -Nru eresi-0.8a25/elfsh/include/.svn/text-base/elfsh.h.svn-base eresi-0.0.20110516/elfsh/include/.svn/text-base/elfsh.h.svn-base --- eresi-0.8a25/elfsh/include/.svn/text-base/elfsh.h.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/include/.svn/text-base/elfsh.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file elfsh.h - * @ingroup elfsh - * - * Started on Thu Feb 22 07:19:04 2001 jfv - * - * - * $Id: elfsh.h,v 1.41 2007-11-29 14:01:55 may Exp $ - * - */ -#ifndef __ELFSH_H_ - #define __ELFSH_H_ - -/* User defined configuration */ -#include "libstderesi.h" - -/* Help strings */ -#include "elfsh-help.h" - -/* Constants */ -#define ELFSH_NAME "ELF shell" -#define ELFSH_SNAME "elfsh" -#define ELFSH_CONFIG ".elfshrc" - -/* Commands */ -#define CMD_STRIP "strip" -#define CMD_SSTRIP "sstrip" -#define CMD_CLEANUP "cleanup" -#define CMD_SHTRM "shtrm" -#define CMD_RUN "run" - -/* Commands execution handlers, each in their respective file */ -int cmd_strip(); -int cmd_sstrip(); -int cmd_cleanup(); -int cmd_run(); - -/* Top skeleton functions */ -int esh_main(int ac, char **av); - -/* Commands registration */ -void setup_local_cmdhash(); - -#endif /* __ELFSH_H_ */ - diff -Nru eresi-0.8a25/elfsh/main.c eresi-0.0.20110516/elfsh/main.c --- eresi-0.8a25/elfsh/main.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/main.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file main.c +* @file elfsh/main.c * @ingroup elfsh * Started on Wed Feb 21 22:02:36 2001 jfv * Updated on Wed Jan 03 17:51:04 2007 jfv * - * $Id: main.c,v 1.21 2008-02-16 12:31:34 thor Exp $ + * $Id: main.c 1397 2009-09-13 02:19:08Z may $ * */ #include "elfsh.h" @@ -97,7 +97,8 @@ revm_config(ELFSH_CONFIG); setup_local_cmdhash(); revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); + revm_run(ac, av); + return (0); } diff -Nru eresi-0.8a25/elfsh/Makefile eresi-0.0.20110516/elfsh/Makefile --- eresi-0.8a25/elfsh/Makefile 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -17,56 +17,55 @@ NAME64 = elfsh64 CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../elibc/include/ \ - -I../libetrace/include/ -I../libstderesi/include \ + -I../libelfsh/include/ -I../libetrace/include/ \ + -I../libstderesi/include \ -I../libdump/include/ -I../libasm/include/ \ -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ -I../elibc/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi/ -lstderesi32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ - $(KERNSHLIB32) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libetrace/ -letrace64 -L../libstderesi/ -lstderesi64 \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) \ - $(READLNOPT) + -I../libaspect/include/ -I../librevm/include/ \ + -I../libui/include/ -I../libmjollnir/include/ \ + -I../libedfmt/include/ $(STATOPT2) \ + $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) + +CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ + -I../libelfsh/include/ -I../elibc/include/ \ + -I../libetrace/include/ -I../libstderesi/include/ \ + -I../libdump/include/ -I../libasm/include/ \ + -I../e2dbg/include/ -I/usr/pkg/include/ \ + -I../libaspect/include/ -I../librevm/include/ \ + -I../libui/include/ -I../libmjollnir/include/ \ + -I../libedfmt/include/ $(STATOPT2) \ + $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) + +LDFLAGS32 += -L../libstderesi/ -lstderesi32 -L../librevm/ -lrevm32 \ + -L../libedfmt/ -ledfmt32 \ + -L../libelfsh/ -lelfsh32 -L../libetrace/ -letrace32 \ + -L/usr/pkg/lib/ -L../libmjollnir/ -lmjollnir32 \ + -L../libetrace -letrace32 $(LPTHREAD) -L../libasm/ -lasm32 \ + $(LDUIOPT32) -g3 $(STATOPT) -L../liballocproxy -lallocproxy \ + -L../libaspect/ -laspect32 -lcrypto \ + $(LDMJOLLNIR) $(DLOPT) \ + -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) + + +LDFLAGS64 += -L../libstderesi/ -lstderesi64 -L../librevm/ -lrevm64 \ + -L../libedfmt/ -ledfmt64 \ + -L../libelfsh/ -lelfsh64 -L../libetrace/ -letrace64 \ + -L/usr/pkg/lib/ -L../libmjollnir/ -lmjollnir64 \ + -L../libetrace -letrace64 $(LPTHREAD) -L../libasm/ -lasm64 \ + $(LDUIOPT32) -g3 $(STATOPT) -L../liballocproxy -lallocproxy \ + -L../libaspect/ -laspect64 -lcrypto \ + $(LDMJOLLNIR) $(DLOPT) \ + -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) all : all32 all64 -$(NAME32) : $(OBJ32) - @$(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) +$(NAME32) : $(OBJ32) + $(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) -$(NAME64) : $(OBJ64) - @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) +$(NAME64) : $(OBJ64) + $(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) all32: $(NAME32) all64: $(NAME64) diff -Nru eresi-0.8a25/elfsh/misc.c eresi-0.0.20110516/elfsh/misc.c --- eresi-0.8a25/elfsh/misc.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/misc.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file misc.c +* @file elfsh/misc.c * @ingroup elfsh * Started on Fri Nov 2 15:21:56 2001 jfv * Updated on Wed Jan 03 17:31:11 2007 jfv * - * $Id: misc.c,v 1.17 2008-02-16 12:31:34 thor Exp $ + * $Id: misc.c 1397 2009-09-13 02:19:08Z may $ * */ #include "elfsh.h" diff -Nru eresi-0.8a25/elfsh/rlheap.c eresi-0.0.20110516/elfsh/rlheap.c --- eresi-0.8a25/elfsh/rlheap.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/rlheap.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,11 +1,11 @@ /** -* @file readlnheap.c +* @file elfsh/rlheap.c * @ingroup elfsh * @brief Handle the readline malloc/free to avoid messing with the alloc proxy. * * Started on Sat Jul 1 10:10:53 2006 jfv * -* $Id: rlheap.c,v 1.5 2008-02-16 12:31:34 thor Exp $ +* $Id: rlheap.c 1388 2009-09-04 15:43:55Z thorkill $ * */ #include "elfsh.h" diff -Nru eresi-0.8a25/elfsh/run.c eresi-0.0.20110516/elfsh/run.c --- eresi-0.8a25/elfsh/run.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/run.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,9 +1,9 @@ /** - * @file run.c +* @file elfsh/run.c * @ingroup elfsh * Started on Wed Feb 21 22:02:36 2001 jfv * - * $Id: run.c,v 1.10 2008-02-16 12:31:34 thor Exp $ + * $Id: run.c 1397 2009-09-13 02:19:08Z may $ * */ #include "elfsh.h" @@ -11,7 +11,8 @@ /** - * Run the binary + * Run the binary + * @ingroup elfsh */ int cmd_run() { diff -Nru eresi-0.8a25/elfsh/.svn/all-wcprops eresi-0.0.20110516/elfsh/.svn/all-wcprops --- eresi-0.8a25/elfsh/.svn/all-wcprops 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 29 -/svn/!svn/ver/950/trunk/elfsh -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/914/trunk/elfsh/main.c -END -run.c -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/909/trunk/elfsh/run.c -END -cleanup.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/909/trunk/elfsh/cleanup.c -END -tables.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/909/trunk/elfsh/tables.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/909/trunk/elfsh/misc.c -END -rlheap.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/909/trunk/elfsh/rlheap.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/950/trunk/elfsh/Makefile -END diff -Nru eresi-0.8a25/elfsh/.svn/entries eresi-0.0.20110516/elfsh/.svn/entries --- eresi-0.8a25/elfsh/.svn/entries 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/elfsh -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -main.c -file - - - - -2008-04-06T23:15:46.732883Z -592aa9371e2ae1635f588253c594d753 -2008-03-18T16:49:26.066981Z -914 -pouik - -run.c -file - - - - -2008-04-06T23:15:46.764138Z -f39f9136833a504ec2b871583a43eee1 -2008-03-14T09:48:44.987521Z -909 -enioh - -cleanup.c -file - - - - -2008-04-06T23:15:46.775876Z -98e7dad8cbc49cd6ee35a17f0dbf54bb -2008-03-14T09:48:44.987521Z -909 -enioh - -tables.c -file - - - - -2008-04-06T23:15:46.786901Z -a140667660d12688729a11f78eda7959 -2008-03-14T09:48:44.987521Z -909 -enioh - -misc.c -file - - - - -2008-04-06T23:15:46.798711Z -816cb2edc0e22db66793d66757f00ab6 -2008-03-14T09:48:44.987521Z -909 -enioh - -rlheap.c -file - - - - -2008-04-06T23:15:46.810171Z -e9f0801ade1bce523bb8a6202fa34b2e -2008-03-14T09:48:44.987521Z -909 -enioh - -Makefile -file - - - - -2008-04-06T23:15:46.821126Z -88dfb54dddb93a563d8e864448bc5a9c -2008-03-29T07:54:04.209482Z -950 -enioh -has-props - diff -Nru eresi-0.8a25/elfsh/.svn/format eresi-0.0.20110516/elfsh/.svn/format --- eresi-0.8a25/elfsh/.svn/format 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/elfsh/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/elfsh/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/elfsh/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/elfsh/.svn/text-base/cleanup.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/cleanup.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/cleanup.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/cleanup.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/** - * @file cleanup.c - * @ingroup elfsh - * @brief This command cleanup a file by marking as removed all injected sections. - * - * Started on Sat May 31 23:48:41 2005 jfv - * - * $Id: cleanup.c,v 1.6 2008-02-16 12:31:34 thor Exp $ - * - */ -#include "elfsh.h" - - -/** - * FIXME - * @return - */ -int cmd_cleanup() -{ - elfshobj_t *obj; - elfshsect_t *sect; - int index; - uint32_t nbr; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - obj = revm_lookup_file(world.curjob->curcmd->param[0]); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - sect = world.curjob->curfile->sectlist; - nbr = 0; - for (index = 0; index < obj->hdr->e_shnum; index++, sect = sect->next) - if (strstr(sect->name, ".o.") || strstr(sect->name, "elfsh")) - { - snprintf(buf, BUFSIZ, "Set section header %u as removed \n", index); - revm_output(buf); - sect->flags = sect->flags | ELFSH_SECTION_REMOVED; - nbr++; - } - - world.curjob->curfile->nbrm = nbr; - //world.curjob->curfile->strip = 1; - - revm_output("\n [*] File marked for cleanup-on-save \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/elfsh/.svn/text-base/main.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/main.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/main.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -/** - * @file main.c - * @ingroup elfsh - * Started on Wed Feb 21 22:02:36 2001 jfv - * Updated on Wed Jan 03 17:51:04 2007 jfv - * - * $Id: main.c,v 1.21 2008-02-16 12:31:34 thor Exp $ - * - */ -#include "elfsh.h" - - - -/** - * Prompt related functions for elfsh - */ -void esh_setup_quit_msg() -{ - char logbuf[BUFSIZ]; - - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - ELFSH_NAME, REVM_VERSION); - revm_quitmsg_set(logbuf); -} - -/** - * FIXME - * @param buf - * @param size - */ -void esh_create_prompt(char *buf, u_int size) -{ - snprintf(buf, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - revm_colorget("%s", "psname" , ELFSH_SNAME), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", REVM_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", REVM_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", REVM_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->ws.name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -/** - * FIXME - */ -void esh_setup_prompt() -{ - revm_set_prompt(esh_create_prompt); -} - - -/** - * Print the etrace banner - */ -void esh_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - ELFSH_NAME, - REVM_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - revm_output(logbuf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * The real main function - * @param ac - * @param av - * @return - */ -int esh_main(int ac, char **av) -{ - esh_setup_quit_msg(); - esh_setup_prompt(); - revm_setup(ac, av, 0, 0); - if (world.state.revm_mode != REVM_STATE_CMDLINE) - esh_banner_print(av[1]); - revm_config(ELFSH_CONFIG); - setup_local_cmdhash(); - revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); -} - - -/** - * The main ELFsh routine - * @param ac - * @param av - * @return - */ -int main(int ac, char **av) -{ - return (esh_main(ac, av)); -} - - - diff -Nru eresi-0.8a25/elfsh/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## - -include ../config.h - -SRC = main.c tables.c rlheap.c cleanup.c run.c misc.c -OBJ = $(SRC:.c=.o) -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f -NAME = elfsh -NAME32 = elfsh32 -NAME64 = elfsh64 - -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../elibc/include/ \ - -I../libetrace/include/ -I../libstderesi/include \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ -I../elibc/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi/ -lstderesi32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ - $(KERNSHLIB32) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libetrace/ -letrace64 -L../libstderesi/ -lstderesi64 \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) \ - $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - @$(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) - -$(NAME64) : $(OBJ64) - @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) *~ \#* *\# .\#* *.32.o *.64.o - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) $(NAME) $(NAME32) $(NAME64) $(OBJ_DYN) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/elfsh/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/** - * @file misc.c - * @ingroup elfsh - * Started on Fri Nov 2 15:21:56 2001 jfv - * Updated on Wed Jan 03 17:31:11 2007 jfv - * - * $Id: misc.c,v 1.17 2008-02-16 12:31:34 thor Exp $ - * - */ -#include "elfsh.h" - - -/** - * Mark the current object SHT to be removed on savnig - * @return - */ -int cmd_shtrm() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->shtrm = 1; - if (!world.state.revm_quiet) - revm_output(" [*] SHT marked as removed, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Mark the file as stripped - * @return - */ -int cmd_strip() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->strip = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Object marked as stripped, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Mark SHT as removed and file as stripped - * @return - */ -int cmd_sstrip() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->strip = 1; - world.curjob->curfile->shtrm = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Object marked as sstripped, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/elfsh/.svn/text-base/rlheap.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/rlheap.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/rlheap.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/rlheap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** -* @file readlnheap.c -* @ingroup elfsh -* @brief Handle the readline malloc/free to avoid messing with the alloc proxy. -* -* Started on Sat Jul 1 10:10:53 2006 jfv -* -* $Id: rlheap.c,v 1.5 2008-02-16 12:31:34 thor Exp $ -* -*/ -#include "elfsh.h" - - - -/** - * When inside elfsh and not e2dbg, readline should allocate - * with the real malloc. - * @param sz - * @return - */ -void *revm_readline_malloc(unsigned int sz) -{ - return (malloc(sz)); -} - -/** - * When inside elfsh and not e2dbg, readline should free with - * the real malloc - * @param ptr -*/ -void revm_readline_free(void *ptr) -{ - free(ptr); -} - diff -Nru eresi-0.8a25/elfsh/.svn/text-base/run.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/run.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/run.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/run.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/** - * @file run.c - * @ingroup elfsh - * Started on Wed Feb 21 22:02:36 2001 jfv - * - * $Id: run.c,v 1.10 2008-02-16 12:31:34 thor Exp $ - * - */ -#include "elfsh.h" - - - -/** - * Run the binary - */ -int cmd_run() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!world.curjob->curcmd->param[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - revm_callback_handler_remove(); - ret = execv(world.curjob->curcmd->param[0], - world.curjob->curcmd->param); - revm_callback_handler_install(revm_get_prompt(), revm_line_handler); - revm_column_update(); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot execute ELF binary", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/elfsh/.svn/text-base/tables.c.svn-base eresi-0.0.20110516/elfsh/.svn/text-base/tables.c.svn-base --- eresi-0.8a25/elfsh/.svn/text-base/tables.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/.svn/text-base/tables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** - * @defgroup elfsh Elfsh - */ -/** - * @file tables.c - * @ingroup elfsh - * This file contains all command and objects definitions for scripting - * - * Started on Sat Jan 25 07:48:41 2003 jfv - * - * $Id: tables.c,v 1.18 2008-02-16 12:31:34 thor Exp $ - * - */ -#include "elfsh.h" - - -/** - * Setup the command hash table - * - */ -void setup_local_cmdhash() -{ - - /* Interactive mode / Scripting mode commands */ - if (world.state.revm_mode != REVM_STATE_CMDLINE) - revm_command_add(CMD_RUN , (void *) cmd_run , (void *) revm_getvarparams, 0, HLP_RUN); - revm_command_add(CMD_STRIP , (void *) cmd_strip , (void *) NULL , 1, HLP_STRIP); - revm_command_add(CMD_SSTRIP, (void *) cmd_sstrip, (void *) NULL , 1, HLP_SSTRIP); - revm_command_add(CMD_SHTRM , (void *) cmd_shtrm , (void *) NULL , 1, HLP_SHTRM); -} diff -Nru eresi-0.8a25/elfsh/tables.c eresi-0.0.20110516/elfsh/tables.c --- eresi-0.8a25/elfsh/tables.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/elfsh/tables.c 2011-05-16 11:35:01.000000000 +0000 @@ -1,22 +1,20 @@ /** - * @defgroup elfsh Elfsh + * @defgroup elfsh elfsh: The ELF shell. */ /** - * @file tables.c +* @file elfsh/tables.c * @ingroup elfsh - * This file contains all command and objects definitions for scripting + * @brief This file contains all command and objects definitions for scripting * * Started on Sat Jan 25 07:48:41 2003 jfv - * - * $Id: tables.c,v 1.18 2008-02-16 12:31:34 thor Exp $ - * + * $Id: tables.c 1397 2009-09-13 02:19:08Z may $ */ #include "elfsh.h" /** * Setup the command hash table - * + * @ingroup elfsh */ void setup_local_cmdhash() { diff -Nru eresi-0.8a25/env.sh eresi-0.0.20110516/env.sh --- eresi-0.8a25/env.sh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/env.sh 2011-05-16 11:35:08.000000000 +0000 @@ -1,8 +1,16 @@ #!/bin/sh # -# Environment script for using ERESI without install +# Envir script for using ERESI without install # +# Doesnt work properly +#if [ ! "_$ERESI_ENV" == "_" ] ; +#then +#echo Eresi env already set to $ERESI_ENV +#else + +export ERESI_ENV=`pwd` + export LD_LIBRARY_PATH=`pwd`/libelfsh export LD_LIBRARY_PATH=`pwd`/libetrace:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/libstderesi:$LD_LIBRARY_PATH @@ -11,12 +19,17 @@ export LD_LIBRARY_PATH=`pwd`/librevm/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/e2dbg:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/libmjollnir:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH=`pwd`/testsuite/e2dbg-multithread:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/libaspect:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/libedfmt/:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH=`pwd`/testsuite/e2dbg_multithreads/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/lib/debug/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=`pwd`/libkernsh/:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=`pwd`/evarista/:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=`pwd`/libgdbwrap/:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=`pwd`/testsuite/debugging/binaries-multithreads/:$LD_LIBRARY_PATH - -echo Environment now ready for testing ERESI without install +export PATH=`pwd`/elfsh:$PATH +export PATH=`pwd`/etrace:$PATH +export PATH=`pwd`/e2dbg:$PATH +export PATH=`pwd`/kernsh:$PATH +export PATH=`pwd`/evarista:$PATH +export PATH=`pwd`:$PATH diff -Nru eresi-0.8a25/eresi-config32 eresi-0.0.20110516/eresi-config32 --- eresi-0.8a25/eresi-config32 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/eresi-config32 2011-05-16 11:35:08.000000000 +0000 @@ -0,0 +1,314 @@ +#!/bin/sh +# +# @todo +# +# + +# +# If TESTING is set to 1, eresi-config will be usable without installing eresi. +# TESTING_ROOT is then the path to your working directory. + +TESTING=1 + +# FIXME: incorrect ! ERESI can be present anywhere, or even already installed +TESTING_ROOT=${ERESI_ENV} + +# Those variables are path were eresi headers and libraries were installed. +# + +INCDIR=/usr/local/include +LIBDIR=/usr/local/lib + +# @todo check if argument is --help +# +#echo "Usage " + +# +# Command lines options for each component without dependancies. +# Dependancies is managed next in the ouput part of the script. + +if [ $TESTING = 1 ] ; then +LIBASM_CFLAGS="-I ${TESTING_ROOT}/libasm/include" +LIBASM_DEFINES= +LIBASM_LIBS="-L ${TESTING_ROOT}/libasm/ -lasm32" + +LIBASPECT_CFLAGS="-DERESI32 -I ${TESTING_ROOT}/libaspect/include" +LIBASPECT_DEFINES= +LIBASPECT_LIBS="-L ${TESTING_ROOT}/libaspect/ -laspect32" + +LIBGDBWRAP_CFLAGS="-I ${TESTING_ROOT}/libgdbwrap/include" +LIBGDBWRAP_DEFINES= +LIBGDBWRAP_LIBS="-L ${TESTING_ROOT}/libgdbwrap/ -lgdbwrap32" + +LIBELFSH_CFLAGS="-I ${TESTING_ROOT}/libelfsh/include" +LIBELFSH_DEFINES= +LIBELFSH_LIBS="-L ${TESTING_ROOT}/libelfsh/ -lelfsh32" + +LIBKERNSH_CFLAGS="-I ${TESTING_ROOT}/libkernsh/include" +LIBKERNSH_DEFINES= +LIBKERNSH_LIBS="-L ${TESTING_ROOT}/libkernsh/ -lkernsh32" + +LIBREVM_CFLAGS="-I ${TESTING_ROOT}/librevm/include" +LIBREVM_DEFINES= +LIBREVM_LIBS="-L ${TESTING_ROOT}/librevm/ -lrevm32" + +LIBSTDERESI_CFLAGS="-I ${TESTING_ROOT}/libstderesi/include" +LIBSTDERESI_DEFINES= +LIBSTDERESI_LIBS="-L ${TESTING_ROOT}/libstderesi/ -lstderesi32" + +LIBETRACE_CFLAGS="-I ${TESTING_ROOT}/libetrace/include" +LIBETRACE_DEFINES= +LIBETRACE_LIBS="-L ${TESTING_ROOT}/libetrace/ -letrace32" + +LIBEDFMT_CFLAGS="-I ${TESTING_ROOT}/libedfmt/include" +LIBEDFMT_DEFINES= +LIBEDFMT_LIBS="-L ${TESTING_ROOT}/libedfmt/ -ledfmt32" + +LIBMJOLLNIR_CFLAGS="-I ${TESTING_ROOT}/libmjollnir/include" +LIBMJOLLNIR_DEFINES= +LIBMJOLLNIR_LIBS="-L ${TESTING_ROOT}/libmjollnir/ -lmjollnir32" + +else + +LIBASM_CFLAGS="-DERESI32 -I ${INCDIR}" +LIBASM_DEFINES= +LIBASM_LIBS="-L ${LIBDIR} -lasm32" + +LIBASPECT_CFLAGS="-I ${INCDIR}" +LIBASPECT_DEFINES= +LIBASPECT_LIBS="-L ${LIBDIR} -laspect32" + +LIBGDBWRAP_CFLAGS="-I ${INCDIR}" +LIBGDBWRAP_DEFINES= +LIBGDBWRAP_LIBS="-L ${LIBDIR} -lgdbwrap32" + +LIBKERHSH_CFLAGS="-I ${INCDIR}" +LIBKERNSH_DEFINES= +LIBKERNSH_LIBS="-L ${LIBDIR} -lkernsh32" + +LIBREVM_CFLAGS="-I ${INCDIR}" +LIBREVM_DEFINES= +LIBREVM_LIBS="-L ${LIBDIR} -lrevm32" + +LIBSTDERESI_CFLAGS="-I ${INCDIR}" +LIBSTDERESI_DEFINES= +LIBSTDERESI_LIBS="-L ${LIBDIR} -lstderesi32" + +LIBELFSH_CFLAGS="-I ${INCDIR}" +LIBELFSH_DEFINES= +LIBELFSH_LIBS="-L ${LIBDIR} -lelfsh32" + +LIBEDFMT_CFLAGS="-I ${INCDIR}" +LIBEDFMT_DEFINES= +LIBEDFMT_LIBS="-L ${LIBDIR} -ledfmt32" + +LIBETRACE_CFLAGS="-I ${INCDIR}" +LIBETRACE_DEFINES= +LIBETRACE_LIBS="-L ${LIBDIR} -letrace32" + +LIBMJOLLNIR_CFLAGS="-I ${INCDIR}" +LIBMJOLLNIR_DEFINES= +LIBMJOLLNIR_LIBS="-L ${LIBDIR} -lmjollnir32" + +fi + +# +# Loop throught arguments +# + +while [ "_$1" != "_" ] ; do + case "$1" in + libasm) + LIBASM=1 + ;; + libelfsh) + LIBELFSH=1 + ;; + libmjollnir) + LIBMJOLLNIR=1 + ;; + libedfmt) + LIBEDFMT=1 + ;; + libaspect) + LIBASPECT=1 + ;; + libgdbwrap) + LIBGDBWRAP=1 + ;; + libkernsh) + LIBKERNSH=1 + ;; + librevm) + LIBREVM=1 + ;; + libstderesi) + LIBSTDERESI=1 + ;; + + --libs) + showLIBS=1 + ;; + --cflags) + showCFLAGS=1 + ;; + --defines) + showDEFINES=1 + ;; + esac + shift 1 +done + +# +# Print required arguments. +# + +########################################## +############ LIBMJOLLNIR #################### + +if [ "$LIBMJOLLNIR" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBELFSH_CFLAGS} ${LIBETRACE_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBELFSH_LIBS} ${LIBETRACE_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBELFSH_DEFINES} ${LIBETRACE_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi +fi + +########################################## +############ LIBASM #################### + +if [ "$LIBASM" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi +fi + +########################################## +############ LIBELFSH #################### + +if [ "$LIBELFSH" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBELFSH_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBELFSH_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBELFSH_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi + +fi + + +########################################## +############ LIBASPECT #################### + +if [ "$LIBASPECT" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBASPECT_DEFINES} +fi + +fi + +########################################## +############ LIBEDFMT #################### + +if [ "$LIBEDFMT" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBEDFMT_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBEDFMT_LIBS} ${LIBELFSH_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBEDFMT_DEFINES} ${LIBELFSH_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi + +fi + +########################################## +############ LIBGDBWRAP ################## + +if [ "$LIBGDBWRAP" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBGDBWRAP_CFLAGS} ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBGDBWRAP_LIBS} ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBGDBWRAP_DEFINES} ${LIBASPECT_DEFINES} +fi + +fi + + +########################################## +############ LIBKERNSH ################## + +if [ "$LIBKERNSH" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBKERNSH_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASM_CFLAGS} ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBKERNSH_LIBS} ${LIBELFSH_LIBS} ${LIBASM_LIBS} ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBGDBWRAP_DEFINES} ${LIBELFSH_DEFINES} ${LIBASM_DEFINES} ${LIBASPECT_DEFINES} +fi + +fi + +########################################## +############ LIBREVM ################## + +if [ "$LIBREVM" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBREVM_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASM_CFLAGS} \ + ${LIBASPECT_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBREVM_LIBS} ${LIBELFSH_LIBS} ${LIBASM_LIBS} ${LIBASPECT_LIBS} \ + ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBREVM_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} \ + ${LIBASPECT_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi + +fi + +########################################## +############ LIBSTDERESI ################# + +if [ "$LIBSTDERESI" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBSTDERESI_CFLAGS} ${LIBREVM_CFLAGS} ${LIBELFSH_CFLAGS} \ + ${LIBASM_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBEDFMT_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBSTDERESI_LIBS} ${LIBREVM_LIBS} ${LIBELFSH_LIBS} \ + ${LIBASM_LIBS} ${LIBASPECT_LIBS} ${LIBEDFMT_LIBS} ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBSTDERESI_DEFINES} ${LIBREVM_DEFINES} ${LIBELFSH_DEFINES} \ + ${LIBASM_DEFINES} ${LIBASPECT_DEFINES} ${LIBEDFMT_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi + +fi diff -Nru eresi-0.8a25/eresi-config64 eresi-0.0.20110516/eresi-config64 --- eresi-0.8a25/eresi-config64 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/eresi-config64 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,314 @@ +#!/bin/sh +# +# @todo +# +# + +# +# If TESTING is set to 1, eresi-config will be usable without installing eresi. +# TESTING_ROOT is then the path to your working directory. + +TESTING=1 + +# FIXME: incorrect ! ERESI can be present anywhere, or even already installed +TESTING_ROOT=${ERESI_ENV} + +# Those variables are path were eresi headers and libraries were installed. +# + +INCDIR=/usr/local/include +LIBDIR=/usr/local/lib + +# @todo check if argument is --help +# +#echo "Usage " + +# +# Command lines options for each component without dependancies. +# Dependancies is managed next in the ouput part of the script. + +if [ $TESTING = 1 ] ; then +LIBASM_CFLAGS="-I ${TESTING_ROOT}/libasm/include" +LIBASM_DEFINES= +LIBASM_LIBS="-L ${TESTING_ROOT}/libasm/ -lasm64" + +LIBASPECT_CFLAGS="-DERESI64 -I ${TESTING_ROOT}/libaspect/include" +LIBASPECT_DEFINES= +LIBASPECT_LIBS="-L ${TESTING_ROOT}/libaspect/ -laspect64" + +LIBGDBWRAP_CFLAGS="-I ${TESTING_ROOT}/libgdbwrap/include" +LIBGDBWRAP_DEFINES= +LIBGDBWRAP_LIBS="-L ${TESTING_ROOT}/libgdbwrap/ -lgdbwrap64" + +LIBELFSH_CFLAGS="-I ${TESTING_ROOT}/libelfsh/include" +LIBELFSH_DEFINES= +LIBELFSH_LIBS="-L ${TESTING_ROOT}/libelfsh/ -lelfsh64" + +LIBKERNSH_CFLAGS="-I ${TESTING_ROOT}/libkernsh/include" +LIBKERNSH_DEFINES= +LIBKERNSH_LIBS="-L ${TESTING_ROOT}/libkernsh/ -lkernsh64" + +LIBREVM_CFLAGS="-I ${TESTING_ROOT}/librevm/include" +LIBREVM_DEFINES= +LIBREVM_LIBS="-L ${TESTING_ROOT}/librevm/ -lrevm64" + +LIBSTDERESI_CFLAGS="-I ${TESTING_ROOT}/libstderesi/include" +LIBSTDERESI_DEFINES= +LIBSTDERESI_LIBS="-L ${TESTING_ROOT}/libstderesi/ -lstderesi64" + +LIBETRACE_CFLAGS="-I ${TESTING_ROOT}/libetrace/include" +LIBETRACE_DEFINES= +LIBETRACE_LIBS="-L ${TESTING_ROOT}/libetrace/ -letrace64" + +LIBEDFMT_CFLAGS="-I ${TESTING_ROOT}/libedfmt/include" +LIBEDFMT_DEFINES= +LIBEDFMT_LIBS="-L ${TESTING_ROOT}/libedfmt/ -ledfmt64" + +LIBMJOLLNIR_CFLAGS="-I ${TESTING_ROOT}/libmjollnir/include" +LIBMJOLLNIR_DEFINES= +LIBMJOLLNIR_LIBS="-L ${TESTING_ROOT}/libmjollnir/ -lmjollnir64" + +else + +LIBASM_CFLAGS="-DERESI64 -I ${INCDIR}" +LIBASM_DEFINES= +LIBASM_LIBS="-L ${LIBDIR} -lasm64" + +LIBASPECT_CFLAGS="-I ${INCDIR}" +LIBASPECT_DEFINES= +LIBASPECT_LIBS="-L ${LIBDIR} -laspect64" + +LIBGDBWRAP_CFLAGS="-I ${INCDIR}" +LIBGDBWRAP_DEFINES= +LIBGDBWRAP_LIBS="-L ${LIBDIR} -lgdbwrap64" + +LIBKERHSH_CFLAGS="-I ${INCDIR}" +LIBKERNSH_DEFINES= +LIBKERNSH_LIBS="-L ${LIBDIR} -lkernsh64" + +LIBREVM_CFLAGS="-I ${INCDIR}" +LIBREVM_DEFINES= +LIBREVM_LIBS="-L ${LIBDIR} -lrevm64" + +LIBSTDERESI_CFLAGS="-I ${INCDIR}" +LIBSTDERESI_DEFINES= +LIBSTDERESI_LIBS="-L ${LIBDIR} -lstderesi64" + +LIBELFSH_CFLAGS="-I ${INCDIR}" +LIBELFSH_DEFINES= +LIBELFSH_LIBS="-L ${LIBDIR} -lelfsh64" + +LIBEDFMT_CFLAGS="-I ${INCDIR}" +LIBEDFMT_DEFINES= +LIBEDFMT_LIBS="-L ${LIBDIR} -ledfmt64" + +LIBETRACE_CFLAGS="-I ${INCDIR}" +LIBETRACE_DEFINES= +LIBETRACE_LIBS="-L ${LIBDIR} -letrace64" + +LIBMJOLLNIR_CFLAGS="-I ${INCDIR}" +LIBMJOLLNIR_DEFINES= +LIBMJOLLNIR_LIBS="-L ${LIBDIR} -lmjollnir64" + +fi + +# +# Loop throught arguments +# + +while [ "_$1" != "_" ] ; do + case "$1" in + libasm) + LIBASM=1 + ;; + libelfsh) + LIBELFSH=1 + ;; + libmjollnir) + LIBMJOLLNIR=1 + ;; + libedfmt) + LIBEDFMT=1 + ;; + libaspect) + LIBASPECT=1 + ;; + libgdbwrap) + LIBGDBWRAP=1 + ;; + libkernsh) + LIBKERNSH=1 + ;; + librevm) + LIBREVM=1 + ;; + libstderesi) + LIBSTDERESI=1 + ;; + + --libs) + showLIBS=1 + ;; + --cflags) + showCFLAGS=1 + ;; + --defines) + showDEFINES=1 + ;; + esac + shift 1 +done + +# +# Print required arguments. +# + +########################################## +############ LIBMJOLLNIR #################### + +if [ "$LIBMJOLLNIR" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBELFSH_CFLAGS} ${LIBETRACE_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBELFSH_LIBS} ${LIBETRACE_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBELFSH_DEFINES} ${LIBETRACE_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi +fi + +########################################## +############ LIBASM #################### + +if [ "$LIBASM" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi +fi + +########################################## +############ LIBELFSH #################### + +if [ "$LIBELFSH" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBELFSH_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBELFSH_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBELFSH_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi + +fi + + +########################################## +############ LIBASPECT #################### + +if [ "$LIBASPECT" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBASPECT_DEFINES} +fi + +fi + +########################################## +############ LIBEDFMT #################### + +if [ "$LIBEDFMT" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBEDFMT_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBASM_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBEDFMT_LIBS} ${LIBELFSH_LIBS} ${LIBASPECT_LIBS} ${LIBASM_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBEDFMT_DEFINES} ${LIBELFSH_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} +fi + +fi + +########################################## +############ LIBGDBWRAP ################## + +if [ "$LIBGDBWRAP" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBGDBWRAP_CFLAGS} ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBGDBWRAP_LIBS} ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBGDBWRAP_DEFINES} ${LIBASPECT_DEFINES} +fi + +fi + + +########################################## +############ LIBKERNSH ################## + +if [ "$LIBKERNSH" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBKERNSH_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASM_CFLAGS} ${LIBASPECT_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBKERNSH_LIBS} ${LIBELFSH_LIBS} ${LIBASM_LIBS} ${LIBASPECT_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBGDBWRAP_DEFINES} ${LIBELFSH_DEFINES} ${LIBASM_DEFINES} ${LIBASPECT_DEFINES} +fi + +fi + +########################################## +############ LIBREVM ################## + +if [ "$LIBREVM" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBREVM_CFLAGS} ${LIBELFSH_CFLAGS} ${LIBASM_CFLAGS} \ + ${LIBASPECT_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBREVM_LIBS} ${LIBELFSH_LIBS} ${LIBASM_LIBS} ${LIBASPECT_LIBS} \ + ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBREVM_DEFINES} ${LIBASPECT_DEFINES} ${LIBASM_DEFINES} \ + ${LIBASPECT_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi + +fi + +########################################## +############ LIBSTDERESI ################# + +if [ "$LIBSTDERESI" = 1 ] ; then +if [ "$showCFLAGS" = 1 ] ; then + echo ${LIBSTDERESI_CFLAGS} ${LIBREVM_CFLAGS} ${LIBELFSH_CFLAGS} \ + ${LIBASM_CFLAGS} ${LIBASPECT_CFLAGS} ${LIBEDFMT_CFLAGS} ${LIBMJOLLNIR_CFLAGS} +fi +if [ "$showLIBS" = 1 ] ; then + echo ${LIBSTDERESI_LIBS} ${LIBREVM_LIBS} ${LIBELFSH_LIBS} \ + ${LIBASM_LIBS} ${LIBASPECT_LIBS} ${LIBEDFMT_LIBS} ${LIBMJOLLNIR_LIBS} +fi +if [ "$showDEFINES" = 1 ] ; then + echo ${LIBSTDERESI_DEFINES} ${LIBREVM_DEFINES} ${LIBELFSH_DEFINES} \ + ${LIBASM_DEFINES} ${LIBASPECT_DEFINES} ${LIBEDFMT_DEFINES} ${LIBMJOLLNIR_DEFINES} +fi + +fi diff -Nru eresi-0.8a25/etrace/cleanup.c eresi-0.0.20110516/etrace/cleanup.c --- eresi-0.8a25/etrace/cleanup.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/cleanup.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,13 +1,12 @@ -/* -** cleanup.c for etrace -** @file cleanup.c -** This command cleanup a file by marking as removed all injected sections -** -** Started on Sat May 31 23:48:41 2005 mxatone -** -** $Id: cleanup.c,v 1.4 2008-02-16 12:32:20 thor Exp $ -** -*/ +/** +* @file etrace/cleanup.c + * This command cleanup a file by marking as removed all injected sections + * + * Started on Sat May 31 23:48:41 2005 mxatone + * + * $Id: cleanup.c 1397 2009-09-13 02:19:08Z may $ + * + */ #include "etrace.h" /** diff -Nru eresi-0.8a25/etrace/include/etrace.h eresi-0.0.20110516/etrace/include/etrace.h --- eresi-0.8a25/etrace/include/etrace.h 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/etrace.h 2011-05-16 11:35:02.000000000 +0000 @@ -1,11 +1,14 @@ -/* -** etrace.h for etrace -** -** Started on Thu Feb 22 07:19:04 2001 mxatone -** -** $Id: etrace.h,v 1.5 2007-11-29 14:01:55 may Exp $ -** -*/ +/** + * @defgroup etrace etrace: The Embedded ERESI tracer. + */ +/** +* @file etrace/include/etrace.h + * @brief Header file for ETRACE. + * @ingroup etrace + * + * Started on Thu Feb 22 07:19:04 2001 mxatone + * $Id: etrace.h 1397 2009-09-13 02:19:08Z may $ + */ #ifndef __ETRACE_H_ #define __ETRACE_H_ diff -Nru eresi-0.8a25/etrace/include/etrace-help.h eresi-0.0.20110516/etrace/include/etrace-help.h --- eresi-0.8a25/etrace/include/etrace-help.h 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/etrace-help.h 2011-05-16 11:35:02.000000000 +0000 @@ -1,11 +1,13 @@ -/* -** etrace-help.h for etrace -** -** Started on Thu Aug 15 07:19:04 2005 mxatone -** -** $Id: etrace-help.h,v 1.2 2007-03-07 16:45:34 thor Exp $ -** -*/ +/** +* @file etrace/include/etrace-help.h + * @ingroup etrace + * etrace-help.h for etrace + * + * Started on Thu Aug 15 07:19:04 2005 mxatone + * + * $Id: etrace-help.h 1397 2009-09-13 02:19:08Z may $ + * + */ #ifndef __ETRACE_HELP_H_ #define __ETRACE_HELP_H_ diff -Nru eresi-0.8a25/etrace/include/.svn/all-wcprops eresi-0.0.20110516/etrace/include/.svn/all-wcprops --- eresi-0.8a25/etrace/include/.svn/all-wcprops 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/914/trunk/etrace/include -END -etrace-help.h -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/502/trunk/etrace/include/etrace-help.h -END -etrace.h -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/914/trunk/etrace/include/etrace.h -END diff -Nru eresi-0.8a25/etrace/include/.svn/entries eresi-0.0.20110516/etrace/include/.svn/entries --- eresi-0.8a25/etrace/include/.svn/entries 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/etrace/include -http://svn.eresi-project.org/svn - - - -2008-03-18T16:49:26.066981Z -914 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -etrace-help.h -file - - - - -2008-04-06T23:15:48.679899Z -d926497e85045e49bea1c3472a199008 -2007-03-07T16:45:36.000000Z -502 -thor - -etrace.h -file - - - - -2008-04-06T23:15:48.690877Z -dbee3c0918514b98228a317edc48bc0f -2008-03-18T16:49:26.066981Z -914 -pouik - diff -Nru eresi-0.8a25/etrace/include/.svn/format eresi-0.0.20110516/etrace/include/.svn/format --- eresi-0.8a25/etrace/include/.svn/format 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/etrace/include/.svn/text-base/etrace-help.h.svn-base eresi-0.0.20110516/etrace/include/.svn/text-base/etrace-help.h.svn-base --- eresi-0.8a25/etrace/include/.svn/text-base/etrace-help.h.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/.svn/text-base/etrace-help.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** etrace-help.h for etrace -** -** Started on Thu Aug 15 07:19:04 2005 mxatone -** -** $Id: etrace-help.h,v 1.2 2007-03-07 16:45:34 thor Exp $ -** -*/ -#ifndef __ETRACE_HELP_H_ - #define __ETRACE_HELP_H_ - -/* Commands */ -#define HLP_SHTRM "Mark Section Header Table as removed" -#define HLP_STRIP "Mark the symbol table (.symtab) as stripped" -#define HLP_SSTRIP "Mark the Section Header Table (SHT) and Symbol Table (.symtab) as stripped" -#define HLP_RUN "Run the analyzed program/process again" - -#endif diff -Nru eresi-0.8a25/etrace/include/.svn/text-base/etrace.h.svn-base eresi-0.0.20110516/etrace/include/.svn/text-base/etrace.h.svn-base --- eresi-0.8a25/etrace/include/.svn/text-base/etrace.h.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/include/.svn/text-base/etrace.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** etrace.h for etrace -** -** Started on Thu Feb 22 07:19:04 2001 mxatone -** -** $Id: etrace.h,v 1.5 2007-11-29 14:01:55 may Exp $ -** -*/ -#ifndef __ETRACE_H_ - #define __ETRACE_H_ - -/* User defined configuration */ -#include "libstderesi.h" - -/* Help strings */ -#include "etrace-help.h" - -#define ETRACE_NAME "Embedded ELF Tracer" -#define ETRACE_SNAME "etrace" -#define ETRACE_CONFIG ".etracerc" - -/* Commands */ -#define CMD_STRIP "strip" -#define CMD_SSTRIP "sstrip" -#define CMD_CLEANUP "cleanup" -#define CMD_SHTRM "shtrm" -#define CMD_RUN "run" - -/* Commands execution handlers, each in their respective file */ -int cmd_strip(); -int cmd_sstrip(); -int cmd_cleanup(); -int cmd_run(); - -/* Top skeleton functions */ -int revm_main(int ac, char **av); - -/* Commands registration */ -void setup_local_cmdhash(); - -#endif /* __ETRACE_H_ */ - diff -Nru eresi-0.8a25/etrace/main.c eresi-0.0.20110516/etrace/main.c --- eresi-0.8a25/etrace/main.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/main.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,16 +1,17 @@ -/* -** main.c for etrace -** @file main.c -** Updated on Wed Jan 03 17:51:04 2007 mxatone -** -** $Id: main.c,v 1.12 2007-07-31 23:30:35 may Exp $ -** -*/ +/** +* @file etrace/main.c + * @ingroup etrace + * Updated on Wed Jan 03 17:51:04 2007 mxatone + * + * $Id: main.c 1397 2009-09-13 02:19:08Z may $ + * + */ #include "etrace.h" /** * Prompt related functions -*/ + * @ingroup etrace + */ void etrace_setup_quit_msg() { char logbuf[BUFSIZ]; @@ -24,6 +25,7 @@ * Create etrace prompt. * @param buf * @param size + * @ingroup etrace */ void etrace_create_prompt(char *buf, u_int size) { @@ -45,6 +47,7 @@ /** * Setup etrace prompt + * @ingroup etrace */ void etrace_setup_prompt() { @@ -53,6 +56,7 @@ /** * Print the etrace banner + * @ingroup etrace */ void etrace_banner_print() { @@ -81,9 +85,11 @@ * The real main function * @param ac Number of arguments * @param av Array of arguments + * @ingroup etrace */ int etrace_main(int ac, char **av) { + elfshobj_t *last; char logbuf[BUFSIZ]; int ret; char **argv; @@ -94,6 +100,7 @@ char **exav = NULL; int exac; u_int index; + char *bugfunc; /* Interface tweak */ etrace_setup_quit_msg(); @@ -169,9 +176,9 @@ if (ret < 0) return ret; - + if (argc > 1) - revm_traces_add_arguments(argc - 1, argv+1); + trace_param_add(argc - 1, argv+1); XFREE(__FILE__, __FUNCTION__, __LINE__, argv); @@ -184,7 +191,21 @@ revm_config(ETRACE_CONFIG); setup_local_cmdhash(); revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); + last = revm_run(ac, av); + + /* Register binary files to work on */ + elfsh_register_working_objects(&world.curjob->loaded, + &world.shared_hash); + + bugfunc = etrace_start_tracing(last); + if (bugfunc) + { + snprintf(logbuf, BUFSIZ, " [!] There is an issue with tracing this function: %s\n", + bugfunc); + revm_output(logbuf); + return (-1); + } + return (0); } @@ -192,6 +213,7 @@ * The main Etrace routine * @param ac Number of arguments * @param av Array of arguments + * @ingroup etrace */ int main(int ac, char **av) { diff -Nru eresi-0.8a25/etrace/Makefile eresi-0.0.20110516/etrace/Makefile --- eresi-0.8a25/etrace/Makefile 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/Makefile 2011-05-16 11:35:02.000000000 +0000 @@ -23,7 +23,7 @@ -I../e2dbg/include/ -I/usr/pkg/include/ \ -I../libui/include/ -I../libmjollnir/include/ \ -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../libedfmt/include/ $(STATOPT2) \ $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ @@ -33,30 +33,33 @@ -I../e2dbg/include/ -I/usr/pkg/include/ \ -I../libui/include/ -I../libmjollnir/include/ \ -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../libedfmt/include/ $(STATOPT2) \ $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi -lstderesi32 \ + +LDFLAGS32 += -L../libstderesi/ -lstderesi32 -L../librevm/ -lrevm32 \ + -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ + -L../libetrace/ -letrace32 \ -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui32 -g3 \ + -lmjollnir32 -lcrypto $(LPTHREAD) \ + -L../libasm/ -lasm32 -L../libui/ -lui32 -g3 \ -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -lallocproxy $(LDMJOLLNIR) $(KERNSHLIB32) $(DLOPT) \ + -L../libaspect/ -laspect32 \ + -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui64 -g3 \ +LDFLAGS64 += -L../libstderesi/ -lstderesi64 -L../librevm/ -lrevm64 \ + -L../libedfmt/ -L../libelfsh/ -ledfmt64 -lelfsh64 \ + -L../libetrace/ -letrace64 \ + -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ + -lmjollnir64 -lcrypto $(LPTHREAD) \ + -L../libasm/ -lasm64 -L../libui/ -lui64 -g3 \ -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + -L../libaspect/ -laspect64 \ + -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ + -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/etrace/misc.c eresi-0.0.20110516/etrace/misc.c --- eresi-0.8a25/etrace/misc.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/misc.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,16 +1,17 @@ -/* -** misc.c for etrace -** @file misc.c -** Updated on Wed Jan 03 17:31:11 2007 mxatone -** -** $Id: misc.c,v 1.4 2008-02-16 12:32:20 thor Exp $ -** -*/ +/** +* @file etrace/misc.c + * @ingroup etrace + * Updated on Wed Jan 03 17:31:11 2007 mxatone + * + * $Id: misc.c 1397 2009-09-13 02:19:08Z may $ + * + */ #include "etrace.h" /** - * Mark the current object SHT to be removed on savnig + * Mark the current object SHT to be removed on savnig + * @ingroup etrace */ int cmd_shtrm() { @@ -22,8 +23,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * Mark the file as stripped +/** + * Mark the file as stripped + * @ingroup etrace */ int cmd_strip() { @@ -36,8 +38,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * Mark SHT as removed and file as stripped +/** + * Mark SHT as removed and file as stripped + * @ingroup etrace */ int cmd_sstrip() { diff -Nru eresi-0.8a25/etrace/rlheap.c eresi-0.0.20110516/etrace/rlheap.c --- eresi-0.8a25/etrace/rlheap.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/rlheap.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,12 +1,11 @@ /** ** readlnheap.c for etrace - ** @file readlnheap.c - ** Handle the readline malloc/free to avoid messing with the alloc proxy +* @file etrace/rlheap.c + ** @ingroup etrace + ** @brief Handle the readline malloc/free to avoid messing with the alloc proxy ** ** Started on Sat Jul 1 10:10:53 2006 mxatone - ** - ** $Id: rlheap.c,v 1.3 2007-07-17 18:11:24 may Exp $ - ** + ** $Id: rlheap.c 1397 2009-09-13 02:19:08Z may $ */ #include "etrace.h" diff -Nru eresi-0.8a25/etrace/run.c eresi-0.0.20110516/etrace/run.c --- eresi-0.8a25/etrace/run.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/run.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,10 +1,10 @@ /* ** run.c for etrace -** @file run.c -** Started on Wed Feb 21 22:02:36 2001 mxatone -** -** $Id: run.c,v 1.6 2007-11-29 15:33:39 may Exp $ +* @file etrace/run.c +** @ingroup etrace ** +** Started on Wed Feb 21 22:02:36 2001 mxatone +** $Id: run.c 1397 2009-09-13 02:19:08Z may $ */ #include "etrace.h" diff -Nru eresi-0.8a25/etrace/.svn/all-wcprops eresi-0.0.20110516/etrace/.svn/all-wcprops --- eresi-0.8a25/etrace/.svn/all-wcprops 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 30 -/svn/!svn/ver/950/trunk/etrace -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/914/trunk/etrace/main.c -END -run.c -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/886/trunk/etrace/run.c -END -cleanup.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/886/trunk/etrace/cleanup.c -END -tables.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/886/trunk/etrace/tables.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/886/trunk/etrace/misc.c -END -rlheap.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/886/trunk/etrace/rlheap.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/etrace/Makefile -END diff -Nru eresi-0.8a25/etrace/.svn/entries eresi-0.0.20110516/etrace/.svn/entries --- eresi-0.8a25/etrace/.svn/entries 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,116 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/etrace -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -main.c -file - - - - -2008-04-06T23:15:48.727902Z -12cef3114df1f8abd839117bc8c2fd40 -2008-03-18T16:49:26.066981Z -914 -pouik - -run.c -file - - - - -2008-04-06T23:15:48.759903Z -c6a7d5cc3c3428377e100d9b9669bb9d -2008-03-04T23:43:36.991211Z -886 -enioh - -cleanup.c -file - - - - -2008-04-06T23:15:48.771149Z -d6eef20c11fd9d4f7ed375253aa2c190 -2008-03-04T23:43:36.991211Z -886 -enioh - -tables.c -file - - - - -2008-04-06T23:15:48.782945Z -6310e9df4dd1dea996472e6ff1f236e1 -2008-03-04T23:43:36.991211Z -886 -enioh - -misc.c -file - - - - -2008-04-06T23:15:48.794403Z -1ac02f6a8eab32519232801ce1cceeb5 -2008-03-04T23:43:36.991211Z -886 -enioh - -rlheap.c -file - - - - -2008-04-06T23:15:48.805877Z -8ff2069f4aaed7e678cd0b5d5a309f86 -2008-03-04T23:43:36.991211Z -886 -enioh - -Makefile -file - - - - -2008-04-06T23:15:48.817149Z -9e1e9aff484b9543ac643c26b4c2ee5d -2008-03-29T07:54:04.209482Z -950 -enioh -has-props - diff -Nru eresi-0.8a25/etrace/.svn/format eresi-0.0.20110516/etrace/.svn/format --- eresi-0.8a25/etrace/.svn/format 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/etrace/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/etrace/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/etrace/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/etrace/.svn/text-base/cleanup.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/cleanup.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/cleanup.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/cleanup.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* -** cleanup.c for etrace -** @file cleanup.c -** This command cleanup a file by marking as removed all injected sections -** -** Started on Sat May 31 23:48:41 2005 mxatone -** -** $Id: cleanup.c,v 1.4 2008-02-16 12:32:20 thor Exp $ -** -*/ -#include "etrace.h" - -/** - * Need doxygen comments. - */ -int cmd_cleanup() -{ - elfshobj_t *obj; - elfshsect_t *sect; - int index; - uint32_t nbr; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - obj = revm_lookup_file(world.curjob->curcmd->param[0]); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - sect = world.curjob->curfile->sectlist; - nbr = 0; - for (index = 0; index < obj->hdr->e_shnum; index++, sect = sect->next) - if (strstr(sect->name, ".o.") || strstr(sect->name, "elfsh")) - { - snprintf(buf, BUFSIZ, "Set section header %u as removed \n", index); - revm_output(buf); - sect->flags = sect->flags | ELFSH_SECTION_REMOVED; - nbr++; - } - - world.curjob->curfile->nbrm = nbr; - //world.curjob->curfile->strip = 1; - - revm_output("\n [*] File marked for cleanup-on-save \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/etrace/.svn/text-base/main.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/main.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/main.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,0 @@ -/* -** main.c for etrace -** @file main.c -** Updated on Wed Jan 03 17:51:04 2007 mxatone -** -** $Id: main.c,v 1.12 2007-07-31 23:30:35 may Exp $ -** -*/ -#include "etrace.h" - -/** - * Prompt related functions -*/ -void etrace_setup_quit_msg() -{ - char logbuf[BUFSIZ]; - - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - ETRACE_NAME, REVM_VERSION); - revm_quitmsg_set(logbuf); -} - -/** - * Create etrace prompt. - * @param buf - * @param size - */ -void etrace_create_prompt(char *buf, u_int size) -{ - snprintf(buf, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - revm_colorget("%s", "psname" , ETRACE_SNAME), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", REVM_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", REVM_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", REVM_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->ws.name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -/** - * Setup etrace prompt - */ -void etrace_setup_prompt() -{ - revm_set_prompt(etrace_create_prompt); -} - -/** - * Print the etrace banner - */ -void etrace_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - ETRACE_NAME, - REVM_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - revm_output(logbuf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * The real main function - * @param ac Number of arguments - * @param av Array of arguments - */ -int etrace_main(int ac, char **av) -{ - char logbuf[BUFSIZ]; - int ret; - char **argv; - u_int argc; - char *str; - u_int state; - u_char trace_all = 0; - char **exav = NULL; - int exac; - u_int index; - - /* Interface tweak */ - etrace_setup_quit_msg(); - etrace_setup_prompt(); - - /* Which state ? */ - state = REVM_STATE_INTERACTIVE; - - /* If we found the trace command we toggle to tracer state */ - if (ac > 2) - { - snprintf(logbuf, BUFSIZ - 1, "-%s", CMD_TRACEADD_CMDLINE); - for (index = 2; index < ac; index++) - { - if (!strcmp(av[index], logbuf)) - { - state = REVM_STATE_TRACER; - break; - } - } - } - - revm_setup(ac, av, state, 0); - - /* In this case we will trace all function of the binary */ - if (ac > 1 && state == REVM_STATE_INTERACTIVE - && world.state.revm_mode != REVM_STATE_SCRIPT) - { - trace_all = 1; - exav = av; - - /* Switch to tracer mode */ - world.state.revm_mode = state = REVM_STATE_TRACER; - exac = ac; - ac += 2; - - /* Allocated new argument list */ - if ((av = (void*) calloc(sizeof(char*)*(ac+1), 1)) == NULL) - { - write(1, "Out of memory\n", 14); - exit(1); - } - - memcpy(av, exav, sizeof(char*)*exac); - - /* As we done a etrace -t .* */ - av[exac] = "-t"; - av[exac+1] = ".*"; - } - - etrace_banner_print(); - - /* Tracer state parsing */ - if (state == REVM_STATE_TRACER) - { - /* Parse first argument */ - if (revm_trans_speblank(av[1], &argv, &argc) < 0) - return -1; - - world.state.input = argv[0]; - str = revm_lookup_string(world.state.input); - - if (!str) - { - revm_output("Unable to lookup file\n"); - return -1; - } - - /* Load submited file */ - revm_output("\n"); - ret = revm_file_load(str, 0, NULL); - revm_output("\n"); - - if (ret < 0) - return ret; - - if (argc > 1) - revm_traces_add_arguments(argc - 1, argv+1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, argv); - - /* Update pointer */ - ac--; - av[1] = av[0]; - av++; - } - - revm_config(ETRACE_CONFIG); - setup_local_cmdhash(); - revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); -} - - -/** - * The main Etrace routine - * @param ac Number of arguments - * @param av Array of arguments - */ -int main(int ac, char **av) -{ - return (etrace_main(ac, av)); -} - - - diff -Nru eresi-0.8a25/etrace/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/etrace/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/etrace/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -## -## Makefile for etrace -## -## Started on Fri Nov 2 16:32:29 2001 mxatone -## - -include ../config.h - -SRC = main.c tables.c rlheap.c cleanup.c run.c misc.c -OBJ = $(SRC:.c=.o) -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f -NAME = etrace -NAME32 = etrace32 -NAME64 = etrace64 - -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libetrace/include/ -I../libstderesi/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libetrace/ -letrace32 -L../libstderesi -lstderesi32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui32 -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -lallocproxy $(LDMJOLLNIR) $(KERNSHLIB32) $(DLOPT) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui64 -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) - -$(NAME64) : $(OBJ64) - @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) *~ \#* *\# .\#* *.32.o *.64.o - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) $(NAME) $(NAME32) $(NAME64) $(OBJ_DYN) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/etrace/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* -** misc.c for etrace -** @file misc.c -** Updated on Wed Jan 03 17:31:11 2007 mxatone -** -** $Id: misc.c,v 1.4 2008-02-16 12:32:20 thor Exp $ -** -*/ -#include "etrace.h" - - -/** - * Mark the current object SHT to be removed on savnig - */ -int cmd_shtrm() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->shtrm = 1; - if (!world.state.revm_quiet) - revm_output(" [*] SHT marked as removed, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Mark the file as stripped - */ -int cmd_strip() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->strip = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Object marked as stripped, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Mark SHT as removed and file as stripped - */ -int cmd_sstrip() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->curfile->strip = 1; - world.curjob->curfile->shtrm = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Object marked as sstripped, you need to save\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/etrace/.svn/text-base/rlheap.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/rlheap.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/rlheap.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/rlheap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/** - ** readlnheap.c for etrace - ** @file readlnheap.c - ** Handle the readline malloc/free to avoid messing with the alloc proxy - ** - ** Started on Sat Jul 1 10:10:53 2006 mxatone - ** - ** $Id: rlheap.c,v 1.3 2007-07-17 18:11:24 may Exp $ - ** - */ -#include "etrace.h" - - - -/* When inside elfsh and not e2dbg, readline should allocate with the real malloc */ -void *revm_readline_malloc(unsigned int sz) -{ - return (malloc(sz)); -} - -/* When inside elfsh and not e2dbg, readline should free with the real malloc */ -void revm_readline_free(void *ptr) -{ - free(ptr); -} - diff -Nru eresi-0.8a25/etrace/.svn/text-base/run.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/run.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/run.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/run.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** run.c for etrace -** @file run.c -** Started on Wed Feb 21 22:02:36 2001 mxatone -** -** $Id: run.c,v 1.6 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "etrace.h" - - - -/** - * Run the binary - */ -int cmd_run() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!world.curjob->curcmd->param[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - revm_callback_handler_remove(); - ret = execv(world.curjob->curcmd->param[0], - world.curjob->curcmd->param); - revm_callback_handler_install(revm_get_prompt(), revm_line_handler); - revm_column_update(); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot execute ELF binary", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/etrace/.svn/text-base/tables.c.svn-base eresi-0.0.20110516/etrace/.svn/text-base/tables.c.svn-base --- eresi-0.8a25/etrace/.svn/text-base/tables.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/.svn/text-base/tables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - ** tables.c for etrace - ** - ** @file tables.c - ** This file contains all command and objects definitions for scripting - ** - ** Started on Sat Jan 25 07:48:41 2003 mxatone - ** - ** $Id: tables.c,v 1.6 2007-07-17 18:11:24 may Exp $ - ** - */ -#include "etrace.h" - - -/** - * Setup the command hash table - */ -void setup_local_cmdhash() -{ - - /* Interactive mode / Scripting mode commands */ - if (world.state.revm_mode != REVM_STATE_CMDLINE) - revm_command_add(CMD_RUN , (void *) cmd_run , (void *) revm_getvarparams, 0, HLP_RUN); - revm_command_add(CMD_STRIP , (void *) cmd_strip , (void *) NULL , 1, HLP_STRIP); - revm_command_add(CMD_SSTRIP, (void *) cmd_sstrip, (void *) NULL , 1, HLP_SSTRIP); - revm_command_add(CMD_SHTRM , (void *) cmd_shtrm , (void *) NULL , 1, HLP_SHTRM); - - /* Trace commands */ - revm_command_add(CMD_TRACES , (void *) cmd_traces , (void *) revm_getvarparams , 1, HLP_TRACES); - revm_command_add(CMD_TRACEADD , (void *) cmd_traceadd , (void *) revm_getvarparams , 1, HLP_TRACEADD); - revm_command_add(CMD_TRACEEXCLUDE, (void *) cmd_traceexclude, (void *) revm_getvarparams , 1, HLP_TRACEEXCLUDE);; - revm_command_add(CMD_TRACERUN , (void *) cmd_tracerun , (void *) revm_getvarparams , 1, HLP_TRACERUN); - - if (world.state.revm_mode == REVM_STATE_TRACER) - { - /* Traces aliases */ - revm_command_add(CMD_TRACEADD_CMDLINE , (void *) cmd_traceadd , (void *) revm_getvarparams, 1, HLP_TRACEADD); - revm_command_add(CMD_TRACEEXCL_CMDLINE, (void *) cmd_traceexclude, (void *) revm_getvarparams, 1, HLP_TRACEEXCLUDE); - } -} diff -Nru eresi-0.8a25/etrace/tables.c eresi-0.0.20110516/etrace/tables.c --- eresi-0.8a25/etrace/tables.c 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/etrace/tables.c 2011-05-16 11:35:02.000000000 +0000 @@ -1,13 +1,12 @@ /** ** tables.c for etrace ** - ** @file tables.c - ** This file contains all command and objects definitions for scripting +* @file etrace/tables.c + ** @ingroup etrace + ** @brief All command and objects definitions for scripting ** ** Started on Sat Jan 25 07:48:41 2003 mxatone - ** - ** $Id: tables.c,v 1.6 2007-07-17 18:11:24 may Exp $ - ** + ** $Id: tables.c 1397 2009-09-13 02:19:08Z may $ */ #include "etrace.h" diff -Nru eresi-0.8a25/evarista/bin2lir.esh eresi-0.0.20110516/evarista/bin2lir.esh --- eresi-0.8a25/evarista/bin2lir.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/evarista/bin2lir.esh 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,42 @@ +#!evarista/evarista32 + +#quiet + +cmp 1.hdr.machine EM_SPARC +je sparc +cmp 1.hdr.machine EM_SPARC32PLUS +je sparc +cmp 1.hdr.machine EM_SPARCV9 +je sparc + +print 1.hdr.machine +print EM_386 +print EM_486 + +cmp 1.hdr.machine EM_386 +je intel +cmp 1.hdr.machine EM_486 +je intel + +cmp 1.hdr.machine EM_MIPS +je mips +cmp 1.hdr.machine EM_MIPS_RS3_LE +je mips + +print Unsupported architecture in Evarista. Quitting. +quit + +sparc: +print Detected SPARC architecture +sparc2lir $1 +return 0 + +intel: +print Detected INTEL architecture +intel2lir $1 +return 0 + +mips: +print Detected MIPS architecture +mips2lir $1 +return 0 diff -Nru eresi-0.8a25/evarista/callgraph-walk.esh eresi-0.0.20110516/evarista/callgraph-walk.esh --- eresi-0.8a25/evarista/callgraph-walk.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/evarista/callgraph-walk.esh 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,39 @@ +#!evarista + +#print ENTERED CALLGRAPH-WALK + +cmp $# 2 +jne end + +set $func $hash[$2_functions:$1] +set $hash[visitedfuncs:$1] 1 +print Entering FUNCTION: $func + +#graph bloc $func.vaddr +cfg-walk $func.vaddr $2 +graph bloc $func.vaddr + +quiet + +foreach $link of $func.outlinks + + # Dont analyse extern functions + cmp $link.scope SCOPE_GLOBAL + je next + + set $nextfunc $link.id + + set $addr $nextfunc.vaddr + set $found $hash[visitedfuncs:$addr] + cmp $found 1 + je next + + callgraph-walk $addr $2 + +next: forend + +return 0 + +end: +print This function needs two parameters +quit diff -Nru eresi-0.8a25/evarista/cfg-walk.esh eresi-0.0.20110516/evarista/cfg-walk.esh --- eresi-0.8a25/evarista/cfg-walk.esh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/cfg-walk.esh 2011-05-16 11:35:07.000000000 +0000 @@ -1,54 +1,48 @@ -#!evarista/evarista32 +#!evarista32 -print Now entered cfg-walk +#quiet +#print ENTERED CFG-WALK -#profile enable warn - -cmp $# 1 +cmp $# 2 jne end -# debug -print $1 -sym main -sort a -sym bloc -sym FUNC -tables blocks -# - -#profile enable warn - -set $block $hash[blocks:$1] -print $1 +set $block $hash[$2_blocks:$1] set $hash[visitedblocks:$1] 1 -print $block + print Now ASM to ELIR on block at $block.vaddr -print $hash[visitedblocks:$1] -sparc2lir $1 +bin2lir $1 + #lir-dataflow $1 -tables blocks -print $block -#tables expressions -print $block.outlinks +foreach $link of $block.outlinks -tables expressions 100A34 -exec sleep 10 + set $nextblock $link.id + set $addr $nextblock.vaddr -foreach $nextblock of $block.outlinks + # Dont analyse blocks outside current function + cmp $link.scope SCOPE_GLOBAL - print *nextblock + jne ok + print Block SCOPE GLOBAL passed at $addr + jmp next - set $addr $nextblock.curaddr - set $found $hash[visitedblocks:$curaddr] +ok: + set $found $hash[visitedblocks:$addr] cmp $found 1 - je next - cfg-walk $nextblock.curaddr + jne ok2 + + print Block already VISITED at $addr + jmp next + +ok2: + + cfg-walk $addr $2 - print *nextblock +next: +forend -next: forend +return 0 end: print This function needs two parameters diff -Nru eresi-0.8a25/evarista/eva-run32.esh eresi-0.0.20110516/evarista/eva-run32.esh --- eresi-0.8a25/evarista/eva-run32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/evarista/eva-run32.esh 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,58 @@ +#!evarista32 + +#by default, fast print the main function only -- uncomment lines for whole program analysis +#config mjr.cfg_depth 0 + +# disable synthetic instructions as they make IR less easy to generate +config libasm.output.synth.instrs 0 + +vlist +cmp $# 1 +jne end + +sdir . + +quiet +eva-typedecl 42 + +print +print ******************** The Evarista static analyzer .::. Welcome ********************* +print +#verb +#vlist + +load $1 +analyse main + +#graph +#graph bloc main + +sym main +set $mainaddr main +print Main-Function found at addr $mainaddr + +set $mainfunc $hash[$1_functions:$mainaddr] + +#tables expressions +#print $hash[$1_functions:$mainaddr] +#print $mainfunc +#print $mainfunc.vaddr + +callgraph-walk $mainfunc.vaddr $1 + +quiet +print +print ******************** The Evarista static analyzer .::. Good bye ********************* +print +quit + +end: +print Evarista cmd-line syntax: +print +print For 32b binaries: eva-run32.esh +print For 64b binaries: eva-run64.esh +print +print Quitting. +print +quit + \ No newline at end of file diff -Nru eresi-0.8a25/evarista/eva-run64.esh eresi-0.0.20110516/evarista/eva-run64.esh --- eresi-0.8a25/evarista/eva-run64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/evarista/eva-run64.esh 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,42 @@ +#!evarista64 + +vlist +cmp $# 1 +jne end +sdir . + +eva-typedecl 42 +quiet + +print +print ******************** The Evarista static analyzer .::. Welcome ********************* +print + +load $1 +configure mjr.cfg_depth 2 +analyse main + +#graph func main + +set $mainaddr main +print Main-Function found at addr $mainaddr + +set $mainfunc $hash[$1_functions:$mainaddr] + +callgraph-walk $mainfunc.vaddr $1 + +print +print ******************** The Evarista static analyzer .::. Good bye ********************* +print +quit + +end: + +print Evarista cmd-line syntax: +print +print For 32b binaries: eva-run32.esh +print For 64b binaries: eva-run64.esh +print +print Quitting. +print +quit diff -Nru eresi-0.8a25/evarista/eva-run.esh eresi-0.0.20110516/evarista/eva-run.esh --- eresi-0.8a25/evarista/eva-run.esh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/eva-run.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -#!evarista64 - -#quiet -#print $# -#profile enable warn - -vlist -cmp $# 1 -jne end -sdir . - -eva-typedecl 42 - -print -print ******************** The Evarista static analyzer .::. Welcome ********************* -print -#verb -#vlist - -load $1 -analyse - -sym main -set $mainaddr main -print Main-Function found at addr $mainaddr - -#vlist -set $mainfunc $hash[functions:$mainaddr] - -tables expressions -print $hash[functions:$mainaddr] -print $mainfunc -print $mainfunc.vaddr - -cfg-walk $mainfunc.vaddr - -quiet -print -print ******************** The Evarista static analyzer .::. Good bye ********************* -print -quit - -end: -print Syntax: evarista -print -quit - \ No newline at end of file diff -Nru eresi-0.8a25/evarista/eva-typedecl.esh eresi-0.0.20110516/evarista/eva-typedecl.esh --- eresi-0.8a25/evarista/eva-typedecl.esh 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/eva-typedecl.esh 2011-05-16 11:35:07.000000000 +0000 @@ -8,11 +8,11 @@ type list = head:*listent elmnbr:int type:int linearity:byte name:string type hash = ent:*listent size:int elmnbr:int type:int linearity:byte name:string type container = id:int type:int nbrinlinks:int nbroutlinks:int inlinks:*list outlinks:*list data:long -type op = len:int ptr:*byte sem:int name:string size:int content:int regset:int prefix:int imm:int baser:int indexr:int sbaser:string sindex:string address_space:int scale:int - -type instr::container = ptrins:*byte proc%4 name:string icode:int sem:int prefix:int spdiff:int flagswritten:int flagsread:int ptr_prefix:*byte annul:int prediction:int nb_op:int op1:op op2:op op3:op len:int -type bloc::container = vaddr:long size:int symoff:int seen:byte -type func::container = vaddr:long size:int name:byte[64] first:*bloc md5:byte[34] +type op = len:int ptr:*byte sem:int name:string size:int content:int regset:int prefix:int imm:int baser:int indexr:int sbaser:string sindex:string isdst:int aspace:int scale:int st:int it:int oa:int +type instr::container = ptrins:long proc:long name:string icode:int sem:long prefix:int spdiff:int wflags:int rflags:int ptr_prefix:long annul:int prediction:int nb_op:int op1:op op2:op op3:op op4:op op5:op op6:op len:int aop:int +type bloc::container = vaddr:caddr size:int symoff:int seen:byte +type func::container = vaddr:caddr size:int name:byte[64] first:*bloc md5:byte[34] +type link = id:oid type:byte scope:byte source lir-definition.esh diff -Nru eresi-0.8a25/evarista/include/evarista.h eresi-0.0.20110516/evarista/include/evarista.h --- eresi-0.8a25/evarista/include/evarista.h 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/evarista.h 2011-05-16 11:35:07.000000000 +0000 @@ -1,9 +1,14 @@ -/* -** evarista.h for evarista in ERESI -** -** Started on Fri Jun 22 14:19:04 2007 jfv -** $Id: evarista.h,v 1.3 2007-07-31 03:28:46 may Exp $ -*/ +/** + * @defgroup evarista evarista: a binary program transformer. + */ +/** +* @file evarista/include/evarista.h + * @ingroup evarista + * @brief The evarista header file. + * + * Started on Fri Jun 22 14:19:04 2007 jfv + * $Id: evarista.h 1397 2009-09-13 02:19:08Z may $ + */ #ifndef __EVARISTA_H_ #define __EVARISTA_H_ diff -Nru eresi-0.8a25/evarista/include/evarista-help.h eresi-0.0.20110516/evarista/include/evarista-help.h --- eresi-0.8a25/evarista/include/evarista-help.h 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/evarista-help.h 2011-05-16 11:35:07.000000000 +0000 @@ -1,9 +1,10 @@ -/* -** evarista-help.h for evarista in ERESI -** -** Started on Fri Jun 22 14:19:04 2007 jfv -** $Id: evarista-help.h,v 1.2 2007-07-31 03:28:46 may Exp $ -*/ +/** +* @file evarista/include/evarista-help.h + * @ingroup evarista + * + * Started on Fri Jun 22 14:19:04 2007 jfv + * $Id: evarista-help.h 1397 2009-09-13 02:19:08Z may $ + */ #ifndef __EVARISTA_HELP_H_ #define __EVARISTA_HELP_H_ diff -Nru eresi-0.8a25/evarista/include/.svn/all-wcprops eresi-0.0.20110516/evarista/include/.svn/all-wcprops --- eresi-0.8a25/evarista/include/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/914/trunk/evarista/include -END -evarista.h -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/914/trunk/evarista/include/evarista.h -END -evarista-help.h -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/749/trunk/evarista/include/evarista-help.h -END diff -Nru eresi-0.8a25/evarista/include/.svn/entries eresi-0.0.20110516/evarista/include/.svn/entries --- eresi-0.8a25/evarista/include/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/evarista/include -http://svn.eresi-project.org/svn - - - -2008-03-18T16:49:26.066981Z -914 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -evarista.h -file - - - - -2008-04-06T23:16:30.899128Z -b0cb8be56ca52b73bc9a5c3af374024b -2008-03-18T16:49:26.066981Z -914 -pouik - -evarista-help.h -file - - - - -2008-04-06T23:16:30.904136Z -50155c5f211f615b24ee18fe8161285a -2007-07-31T03:28:48.000000Z -749 -may - diff -Nru eresi-0.8a25/evarista/include/.svn/format eresi-0.0.20110516/evarista/include/.svn/format --- eresi-0.8a25/evarista/include/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/evarista/include/.svn/text-base/evarista-help.h.svn-base eresi-0.0.20110516/evarista/include/.svn/text-base/evarista-help.h.svn-base --- eresi-0.8a25/evarista/include/.svn/text-base/evarista-help.h.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/.svn/text-base/evarista-help.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -/* -** evarista-help.h for evarista in ERESI -** -** Started on Fri Jun 22 14:19:04 2007 jfv -** $Id: evarista-help.h,v 1.2 2007-07-31 03:28:46 may Exp $ -*/ -#ifndef __EVARISTA_HELP_H_ - #define __EVARISTA_HELP_H_ - -/* Commands */ - -#endif diff -Nru eresi-0.8a25/evarista/include/.svn/text-base/evarista.h.svn-base eresi-0.0.20110516/evarista/include/.svn/text-base/evarista.h.svn-base --- eresi-0.8a25/evarista/include/.svn/text-base/evarista.h.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/include/.svn/text-base/evarista.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** evarista.h for evarista in ERESI -** -** Started on Fri Jun 22 14:19:04 2007 jfv -** $Id: evarista.h,v 1.3 2007-07-31 03:28:46 may Exp $ -*/ -#ifndef __EVARISTA_H_ - #define __EVARISTA_H_ - -/* User defined configuration */ -#include "revm.h" - -/* Help strings */ -#include "evarista-help.h" - -#define EVARISTA_NAME "Evarista static analyzer" -#define EVARISTA_SNAME "evarista" -#define EVARISTA_CONFIG ".evaristarc" - -/* Top skeleton functions */ -int eva_main(int ac, char **av); - -/* Commands registration */ -void setup_local_cmdhash(); - -#endif /* __EVARISTA_H_ */ - diff -Nru eresi-0.8a25/evarista/intel2lir.esh eresi-0.0.20110516/evarista/intel2lir.esh --- eresi-0.8a25/evarista/intel2lir.esh 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/intel2lir.esh 2011-05-16 11:35:07.000000000 +0000 @@ -1,301 +1,364 @@ -#!evarista/evarista32 -#intel-backend.esh - -# IA-32 registers -define EAX 0 -define ECX 1 -define EDX 2 -define EBX 3 -define ESP 4 -define EBP 5 -define ESI 6 -define EDI 7 -define EFLAGS -1 - -# IA-32 exceptional instruction -define NEG ASM_NEG - -# IA-32 prolog instruction -define SUB ASM_SUB - -# IA-32 epilog instruction -define MOV ASM_MOV - -# This create on-demand the block instruction list in the eresi runtime -reflect $1 - -set $curblock $_ -set $curaddr $curblock.vaddr - -# Just debug printing -#inspect $curblock -#profile enable warn - -# Start the transformation -foreach $instr in $hash[instrlists:$curaddr] - -print Transforming instruction: $instr - -transform $instr into - -# INC, DEC (reg) -case instr_t(type:ar-id-wf, nb_op:1, op1(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op1.baser), rsrc(id:$instr.op1.baser), isrc(val:1), uflags:$instr.wflags) - -# INC, DEC (mem) -case instr_t(type:ar-id-wf, nb_op:1, op1(type:mem)) -into TernopMI(addr:$curaddr, dst(id:$instr.op1.baser), msrc(name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), isrc(val:1), uflags:$instr.wflags) - -# AAA, AAD, AAM, AAS, DAD, DAS -case instr_t(type:ar-wf, nb_op:0) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:EAX), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, reg) -case instr_t(type:ar-wf, nb_op:2, op1(type:reg), op2(type:reg)) -into TernopR3(addr:$curaddr, dst(id:$instr.op2.baser), src1(id:$instr.op2.baser), src2(id:$instr.op1.baser), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, imm) -case instr_t(type:ar-wf, nb_op:2, op1(type:imm), op2(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, mem) -case instr_t(type:ar-wf, nb_op:2, op1(type:mem), op2(type:reg)) -into TernopRM(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), msrc(name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, imm) -case instr_t(type:ar-wf, nb_op:2, op1(type:imm), op2(type:mem)) -into TernopMI(addr:$curaddr, dst(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, reg) -case instr_t(type:ar-wf, nb_op:2, op1(type:reg), op2(type:mem)) -into TernopMR(addr:$curaddr, dst(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), rsrc(id:$instr.op1.baser), uflags:$instr.wflags) - -# IMUL (reg, reg, imm) -case instr_t(type:ar-wf, nb_op:3, op1(type:imm), op2(type:reg), op3(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op3.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# IMUL (reg, mem, imm) -case instr_t(type:ar-wf, nb_op:3, op1(type:imm), op2(type:mem), op3(type:reg)) -into TernopRMI(addr:$curaddr, dst(id:$instr.op3.baser), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# NEG (reg) -case instr_t(instr:NEG, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:$instr.op1.baser), src1(id:$instr.op1.baser), src2(id:$instr.op1.baser), uflags:$instr.wflags) - -# NEG (mem) -case instr_t(instr:NEG, op1(type:mem)) -into TernopM3(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), msrc1((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), msrc2((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:$instr.wflags) - -# MUL, IMUL (reg) -case instr_t(type:ar-wf, nb_op:1, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:$instr.op1.baser), src2(id:EAX), uflags:$instr.wflags) - -# MUL, IMUL (mem) -case instr_t(type:ar-wf, nb_op:1, op1(type:mem)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), src2(id:EAX), uflags:$instr.wflags) - -# CWD, CBW -case instr_t(type:ar, nb_op:0) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:EAX), uflags:0) - -# LEA (reg, mem) -case instr_t(type:ar, nb_op:2) -into TernopRM(addr:$curaddr, dst(id:$instr.op1.baser), rsrc(id:$instr.op1.baser), msrc((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# NOT, DIV, IDIV (reg) -case instr_t(type:ar, nb_op:1, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:$instr.op1.baser), uflags:0) - -# NOT, DIV, IDIV (mem) -case instr_t(type:ar, nb_op:1, op1(type:mem)) -into TernopRM(addr:$curaddr, dst(id:EAX), rsrc(id:EAX), msrc((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# CALL (reg) -case instr_t(type:c, op1(type:reg)) -into IndCallR(addr:$curaddr, dst(id:$instr.op1.baser), uflags:0) - -# CALL (mem) -case instr_t(type:c, op1(type:mem)) -into IndCallM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# CALL (imm) -case instr_t(type:c, op1(type:imm)) -into Call(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# CMP, TEST (reg, imm) -case instr_t(type:cmp-wr, op1(type:imm), op2(type:reg)) -into CmpRI(addr:$curaddr, snd(id:$instr.op2.baser), fst(val:$instr.op1.imm), uflags:$instr.wflags) - -# CMP, TEST, CMPSB, CMPSD, SCASB, SCASD (reg, reg) -case instr_t(type:cmp-wr, op1(type:reg), op2(type:reg)) -into CmpRR(addr:$curaddr, snd(id:$instr.op2.baser), fst(id:$instr.op1.baser), uflags:$instr.wflags) - -# CMP (reg, mem) -case instr_t(type:cmp-wr, op1(type:mem), op2(type:reg)) -into CmpRM(addr:$curaddr, snd(id:$instr.op2.baser), fst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:$instr.wflags) - -# CMP, TEST (mem, reg) -case instr_t(type:cmp-wr, op1(type:reg), op2(type:mem)) -into CmpMR(addr:$curaddr, snd((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), fst(id:$instr.op1.baser), uflags:$instr.wflags) - -# TEST (mem, imm) -case instr_t(type:cmp-wr, op1(type:imm), op2(type:mem)) -into CmpMI(addr:$curaddr, snd((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), fst(val:$instr.op1.imm), uflags:$instr.wflags) - -# HLT -case instr_t(type:s) -into Stop(addr:$curaddr, uflags:0) - -# IN (reg, reg) -case instr_t(type:io-rm, op1(type:reg)) -into IoRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# IN (reg, imm) -case instr_t(type:io-rm, op1(type:imm)) -into IoRI(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# INTO -case instr_t(type:i-rf-bt) -into Interrupt(addr:$curaddr, dst(val:4), uflags:0) - -# IRET -case instr_t(type:i-r) -into IReturn(addr:$curaddr, uflags:0) - -# INT3 -case inst_t(type:i, nb_op:0) -into Interrupt(addr:$curaddr, dst(val:3), uflags:0) - -# INT (imm) -case instr_t(type:i) -into Interrupt(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# Jxx, LOOP, LOOPE, LOOPNE (imm) -# Jxx = JA, JAE, JB, JBE, JE, JECXZ, JG, JGE, JL, JLE, JNE, JNO, JNP, JNS, JO, JP, JS -case instr_t(type:cb) -into Branch(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# JMP (imm) -case instr_t(type:b, op1(type:imm)) -into Branch(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# JMP (reg) -case instr_t(type:b, op1(type:reg)) -into IndBranchR(addr:$curaddr, dst(id:$instr.op1.baser), uflags:0) - -# JMP (mem) -case instr_t(type:b, op1(type:mem)) -into IndBranchM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# MOVSB, MOVSD (mem, mem) -case instr_t(type:a-rm-wm) -into AssignMM(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# NOP, WAIT/FWAIT -case instr_t(type:n) -into Nop(addr:$curaddr, uflags:0) - -# OUT (reg, reg) -case instr_t(type:io-wm, op2(type:reg)) -into IoRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# OUT (imm, reg) -case instr_t(type:io-wm, op2(type:imm)) -into IoIR(addr:$curaddr, dst(val:$instr.op2.imm), src(id:$instr.op1.baser), uflags:0) - -# POP (reg) -case instr_t(type:sp-rm, op1(type:reg)) -into AssignRM(addr:$curaddr, dst(id:$instr.op1.baser), src(base(id:ESP)), uflags:0) - -# POP (mem) -case instr_t(type:sp-rm, op1(type:mem)) -into AssignMM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), src(base(id:ESP)), uflags:0) - -# PUSH (reg) -case instr_t(type:sp-wm, op1(type:reg)) -into AssignMR(addr:$curaddr, dst(base(id:ESP)), src(id:$instr.op1.baser), uflags:0) - -# PUSH (imm) -case instr_t(type:sp-wm, op1(type:imm)) -into AssignIM(addr:$curaddr, dst(base(id:ESP)), src(val:$instr.op1.imm), uflags:0) - -# POPF -case instr_t(type:sp-rm-wf) -into AssignRM(addr:$curaddr, dst(id:EFLAGS), src(base(id:ESP)), uflags:$instr.wflags) - -# PUSHF -case instr_t(type:sp-wm-rf) -into AssignMR(addr:$curaddr, dst(base(id:ESP)), src(id:EFLAGS), uflags:$instr.rflags) - -# RET, RETF -case instr_t(type:r) -into Return(addr:$curaddr, dst(val:0), uflags:0) - -# XCHG (reg, reg) -case instr_t(type:wm-rm, op2(type:reg)) -into XchgRR(addr:$curaddr, fst(id:$instr.op2.baser), snd(id:$instr.op1.baser), uflags:0) - -# XCHG (mem, reg) -case instr_t(type:wm-rm, op2(type:mem)) -into XchgMR(addr:$curaddr, fst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), snd(id:$instr.op1.baser), uflags:0) - -# XLATB -case instr_t(type:a-rm) -into AssignRM(addr:$curaddr, dst(id:EAX), src(base(id:EBX), index(id:EAX)), uflags:0) - -# STOSB, STOSD (mem, reg) -case instr_t(type:wm) -into AssignMR(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(id:$instr.op1.baser), uflags:0) - -# MOV (reg, imm) -case instr_t(type:a, op1(type:imm), op2(type:reg)) -into AssignIR(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# MOV (reg, mem) -case instr_t(type:a, op1(type:mem), op2(type:reg)) -into AssignRM(addr:$curaddr, dst(id:$instr.op2.baser), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# MOV (reg, reg) -case instr_t(type:a, op1(type:reg), op2(type:reg)) -into AssignRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# MOV (mem, reg) -case instr_t(type:a, op1(type:reg), op2(type:mem)) -into AssignMR(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(id:$instr.op1.baser), uflags:0) - -# MOV (mem, imm) -case instr_t(type:a, op1(type:imm), op2(type:mem)) -into AssignIM(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(val:$instr.op1.imm), uflags:0) - -# LDS, LES (reg, imm) -case instr_t(type:rm, op1(type:imm)) -into AssignIR(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# LODSB, LODSD (reg, mem) -case instr_t(type:rm) -into AssignRM(addr:$curaddr, dst(id:$instr.op2.baser), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# LAHF -case instr_t(type:rf) -into FlagR(addr:$curaddr, uflags:$instr.rflags) - -# CLC, CLD, CLI, CMC, SAHF, STC, STD, STI -case instr_t(type:wf) -into FlagW(addr:$curaddr, uflags:$instr.rflags) - -# Prolog - SUB (ESP, imm) -case instr_t(instr:SUB, op2(baser:ESP), op1(type:imm)) -into Prolog(addr:$curaddr, framesz(val:$instr.op1.imm), uflags:0) - -# Epilog - MOV (ESP, EBP) -case instr_t(instr:MOV, op2(baser:ESP), op1(baser:EBP)) -into Epilog(addr:$curaddr, uflags:0) - -# Defaultcase -default print Unsupported instruction at address $curaddr - -endtrans - -add $curaddr $instr.len - -endfor \ No newline at end of file +#!evarista/evarista32 + +# IA-32 general purpose registers -- must be set and not defined because they are string +set $EAX "eax" +set $EBX "ebx" +set $ECX "ecx" +set $EDX "edx" +set $ESP "esp" +set $EBP "ebp" +set $ESI "esi" +set $EDI "edi" +set $EFLAGS "eflags" + +# IA-32 exceptional instruction +define NEG ASM_NEG + +# IA-32 prolog instruction +define SUB ASM_SUB + +# IA-32 epilog instruction +define MOV ASM_MOV + +# This create on-demand the block instruction list in the eresi runtime +set $curaddr $1 +set $begaddr $1 +reflect $curaddr + +# Just debug printing +#verb +#profile enable warn + +# Start the transformation +foreach $instr of $hash[instrlists:$begaddr] + +#print Transforming instruction: $instr +set $curlen $instr.len + +D $begaddr%1 + +rewrite $instr into + +# Prolog - SUB (ESP, imm) +case instr(instr:SUB, op2.name:$ESP), op1(sem:imm)) +into Prolog(addr:$curaddr, framesz(val:$instr.op1.imm)) + +# Epilog - MOV (ESP, EBP) +case instr(instr:MOV, op2.name:$ESP), op1.name:$EBP)) +into Epilog(addr:$curaddr) + +# NEG (reg) +case instr(instr:NEG, op1(sem:reg)) +into TernopR3(addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op1.name), + src2(rid:$instr.op1.name), uflags(val:$instr.wflags)) + +# NEG (mem) +case instr(instr:NEG, op1(sem:mem)) +into TernopM3(addr:$curaddr, dst(name:$instr.op1.name base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), + msrc1(name:$instr.op1.name base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), + msrc2(name:$instr.op1.name base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), uflags(val:$instr.wflags)) + +# INC, DEC (reg) +case instr(sem:ar-id-wf, nb_op:1, op1(sem:reg)) +into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), rsrc(rid:$instr.op1.name), + isrc(val:1), uflags(val:$instr.wflags)) + +# INC, DEC (mem) +case instr(sem:ar-id-wf, nb_op:1, op1(sem:mem)) +into TernopMI(addr:$curaddr, dst(rid:$instr.op1.name), + msrc(name:$instr.op1.name base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), isrc(val:1), + uflags(val:$instr.wflags)) + +# AAA, AAD, AAM, AAS, DAD, DAS +case instr(sem:ar-wf, nb_op:0) +into TernopR3(addr:$curaddr, dst(rid:$EAX), src1(rid:$EAX), src2(rid:$EAX), uflags(val:$instr.wflags)) + +# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, reg) +case instr(sem:ar-wf, nb_op:2, op1(sem:reg), op2(sem:reg)) +into TernopR3(addr:$curaddr, dst(rid:$instr.op2.name), src1(rid:$instr.op2.name), + src2(rid:$instr.op1.name), uflags(val:$instr.wflags)) + +# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, imm) +case instr(sem:ar-wf, nb_op:2, op1(sem:imm), op2(sem:reg)) +into TernopRI(addr:$curaddr, dst(rid:$instr.op2.name), rsrc(rid:$instr.op2.name), + isrc(val:$instr.op1.imm), uflags(val:$instr.wflags)) + +# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, mem) +case instr(sem:ar-wf, nb_op:2, op1(sem:mem), op2(sem:reg)) +into TernopRM(addr:$curaddr, dst(rid:$instr.op2.name), rsrc(rid:$instr.op2.name), + msrc(name:$instr.op1.name base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), uflags(val:$instr.wflags)) + +# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, imm) +case instr(sem:ar-wf, nb_op:2, op1(sem:imm), op2(sem:mem)) +into TernopMI(addr:$curaddr, dst(name:$instr.op2.name, base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), + msrc(name:$instr.op2.name, base(rid:$instr.op2.name), index(rid:$instr.op2.name), + scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), + uflags(val:$instr.wflags)) + +# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, reg) +case instr(sem:ar-wf, nb_op:2, op1(sem:reg), op2(sem:mem)) +into TernopMR(addr:$curaddr, dst(name:$instr.op2.name base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), + msrc(name:$instr.op2.name base(rid:$instr.op2.name), index(rid:$instr.op2.name), + scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), rsrc(rid:$instr.op1.name), + uflags(val:$instr.wflags)) + +# IMUL (reg, reg, imm) +case instr(sem:ar-wf, nb_op:3, op1(sem:imm), op2(sem:reg), op3(sem:reg)) +into TernopRI(addr:$curaddr, dst(rid:$instr.op3.name), rsrc(rid:$instr.op2.name), + isrc(val:$instr.op1.imm), uflags(val:$instr.wflags)) + +# IMUL (reg, mem, imm) +case instr(sem:ar-wf, nb_op:3, op1(sem:imm), op2(sem:mem), op3(sem:reg)) +into TernopRMI(addr:$curaddr, dst(rid:$instr.op3.name), + msrc(name:$instr.op2.name base(rid:$instr.op2.name), index(rid:$instr.op2.name), + scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), + uflags(val:$instr.wflags)) + +# MUL, IMUL (reg) +case instr(sem:ar-wf, nb_op:1, op1(sem:reg)) +into TernopR3(addr:$curaddr, dst(rid:$EAX), src1(rid:$instr.op1.name), src2(rid:$EAX), + uflags(val:$instr.wflags) + +# MUL, IMUL (mem) +case instr(sem:ar-wf, nb_op:1, op1(sem:mem)) +into TernopR3(addr:$curaddr, dst(rid:$EAX), src1((name:$instr.op1.name base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), + src2(rid:$EAX), uflags(val:$instr.wflags)) + +# CWD, CBW +case instr(sem:ar, nb_op:0) +into TernopR3(addr:$curaddr, dst(rid:$EAX), src1(rid:$EAX), src2(rid:$EAX)) + +# LEA (reg, mem) +case instr(sem:ar, nb_op:2) +into TernopRM(addr:$curaddr, dst(rid:$instr.op1.name), rsrc(rid:$instr.op1.name), + msrc((name:$instr.op1.name, base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)))) + +# NOT, DIV, IDIV (reg) +case instr(sem:ar, nb_op:1, op1(sem:reg)) +into TernopR3(addr:$curaddr, dst(rid:$EAX), src1(rid:$EAX), src2(rid:$instr.op1.name)) + +# NOT, DIV, IDIV (mem) +case instr(sem:ar, nb_op:1, op1(sem:mem)) +into TernopRM(addr:$curaddr, dst(rid:$EAX), rsrc(rid:$EAX), + msrc((name:$instr.op1.name base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)))) + +# CALL (reg) -- FIXME manque le store de la valeur de retour +case instr(sem:wm-c, op1(sem:reg)) +into IndCallR(addr:$curaddr, dst(rid:$instr.op1.name), uflags(val:0)) + +# CALL (mem) -- FIXME manque le store de la valeur de retour +case instr(sem:wm-c, op1(sem:mem)) +into IndCallM(addr:$curaddr, dst(name:$instr.op1.name, base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))) + +# CALL (imm) -- FIXME manque le store de la valeur de retour +case instr(sem:wm-c, op1(sem:imm)) +into Call(addr:$curaddr, dst(val:$instr.op1.imm), uflags(val:0)) + +# CMP, TEST (reg, imm) +case instr(sem:wm-cmp-wr, op1(sem:imm), op2(sem:reg)) +into CmpRI(addr:$curaddr, snd(rid:$instr.op2.name), fst(val:$instr.op1.imm), uflags(val:$instr.wflags)) + +# CMP, TEST, CMPSB, CMPSD, SCASB, SCASD (reg, reg) +case instr(sem:cmp-wr, op1(sem:reg), op2(sem:reg)) +into CmpRR(addr:$curaddr, snd(rid:$instr.op2.name), fst(rid:$instr.op1.name), uflags(val:$instr.wflags)) + +# CMP (reg, mem) +case instr(sem:cmp-wr, op1(sem:mem), op2(sem:reg)) +into CmpRM(addr:$curaddr, snd(rid:$instr.op2.name), fst(name:$instr.op1.name, base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), + uflags(val:$instr.wflags)) + +# CMP, TEST (mem, reg) +case instr(sem:cmp-wr, op1(sem:reg), op2(sem:mem)) +into CmpMR(addr:$curaddr, snd((name:$instr.op2.name, base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), + fst(rid:$instr.op1.name), uflags(val:$instr.wflags)) + +# TEST (mem, imm) +case instr(sem:cmp-wr, op1(sem:imm), op2(sem:mem)) +into CmpMI(addr:$curaddr, snd(name:$instr.op2.name, base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), + fst(val:$instr.op1.imm), uflags(val:$instr.wflags)) + +# HLT +case instr(sem:s) +into Stop(addr:$curaddr) + +# IN (reg, reg) +case instr(sem:io-rm, op1(sem:reg)) +into IoRR(addr:$curaddr, dst(rid:$instr.op2.name), src(rid:$instr.op1.name)) + +# IN (reg, imm) +case instr(sem:io-rm, op1(sem:imm)) +into IoRI(addr:$curaddr, dst(rid:$instr.op2.name), src(val:$instr.op1.imm)) + +# INTO +case instr(sem:i-rf-bt) +into Interrupt(addr:$curaddr, dst(val:4)) + +# IRET +case instr(sem:i-r) +into IReturn(addr:$curaddr) + +# INT3 +case inst_t(sem:i, nb_op:0) +into Interrupt(addr:$curaddr, dst(val:3)) + +# INT (imm) +case instr(sem:i) +into Interrupt(addr:$curaddr, dst(val:$instr.op1.imm)) + +# Jxx, LOOP, LOOPE, LOOPNE (imm) +# Jxx = JA, JAE, JB, JBE, JE, JECXZ, JG, JGE, JL, JLE, JNE, JNO, JNP, JNS, JO, JP, JS +case instr(sem:b-cnd) +into Branch(addr:$curaddr, dst(val:$instr.op1.imm)) + +# JMP (imm) +case instr(sem:b, op1(sem:imm)) +into Branch(addr:$curaddr, dst(val:$instr.op1.imm)) + +# JMP (reg) +case instr(sem:b, op1(sem:reg)) +into IndBranchR(addr:$curaddr, dst(rid:$instr.op1.name)) + +# JMP (mem) +case instr(sem:b, op1(sem:mem)) +into IndBranchM(addr:$curaddr, dst((name:$instr.op1.name, base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)))) + +# MOVSB, MOVSD (mem, mem) +case instr(sem:a-rm-wm) +into AssignMM(addr:$curaddr, dst((name:$instr.op2.name, base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), + src((name:$instr.op1.name, base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm)))) + +# NOP, WAIT/FWAIT +case instr(sem:n) +into Nop(addr:$curaddr, uflags(val:0) + +# OUT (reg, reg) +case instr(sem:io-wm, op2(sem:reg)) +into IoRR(addr:$curaddr, dst(rid:$instr.op2.name), src(rid:$instr.op1.name)) + +# OUT (imm, reg) +case instr(sem:io-wm, op2(sem:imm)) +into IoIR(addr:$curaddr, dst(val:$instr.op2.imm), src(rid:$instr.op1.name)) + +# POP (reg) +case instr(sem:sp-rm, op1(sem:reg)) +into AssignRM(addr:$curaddr, dst(rid:$instr.op1.name), src(base(rid:$ESP))) + +# POP (mem) +case instr(sem:sp-rm, op1(sem:mem)) +into AssignMM(addr:$curaddr, dst((name:$instr.op1.name base(rid:$instr.op1.name), + index(rid:$instr.op1.name), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), + src(base(rid:$ESP))) + +# PUSH (reg) +case instr(sem:sp-wm, op1(sem:reg)) +into AssignMR(addr:$curaddr, dst(base(rid:$ESP)), src(rid:$instr.op1.name)) + +# PUSH (imm) +case instr(sem:sp-wm, op1(sem:imm)) +into AssignIM(addr:$curaddr, dst(base(rid:$ESP)), src(val:$instr.op1.imm)) + +# PUSHF +case instr(sem:sp-wm-rf) +into AssignMR(addr:$curaddr, dst(base(rid:$ESP)), src(rid:$EFLAGS), uflags(val:$instr.rflags)) + +# POPF +case instr(sem:sp-rm-wf) +into AssignRM(addr:$curaddr, dst(rid:$EFLAGS), src(base(rid:$ESP)), uflags(val:$instr.wflags)) + +# RET, RETF +case instr(sem:r) +into Return(addr:$curaddr, dst(val:0)) + +# XCHG (reg, reg) +case instr(sem:wm-rm, op2(sem:reg)) +into XchgRR(addr:$curaddr, fst(rid:$instr.op2.name), snd(rid:$instr.op1.name), uflags(val:0)) + +# XCHG (mem, reg) +case instr(sem:wm-rm, op2(sem:mem)) +into XchgMR(addr:$curaddr, fst((name:$instr.op2.name base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), + snd(rid:$instr.op1.name)) + +# XLATB +case instr(sem:a-rm) +into AssignRM(addr:$curaddr, dst(rid:$EAX), src(base(rid:$EBX), index(rid:$EAX)), uflags(val:0)) + +# STOSB, STOSD (mem, reg) +case instr(sem:wm) +into AssignMR(addr:$curaddr, dst((name:$instr.op2.name base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), + src(rid:$instr.op1.name)) + +# MOV (imm, reg) +case instr(sem:a, op1(sem:imm), op2(sem:reg)) +into AssignIR(addr:$curaddr, dst(rid:$instr.op2.name), src(val:$instr.op1.imm), uflags(val:0)) + +# MOV (mem, reg) +case instr(sem:a, op1(sem:mem), op2(sem:reg)) +into AssignRM(addr:$curaddr, dst(rid:$instr.op2.name), src(name:$instr.op1.name, + base(rid:$instr.op1.name), index(rid:$instr.op1.name), scale(val:$instr.op1.scale), + off(val:$instr.op1.imm)), uflags(val:0)) + +# MOV (reg, reg) +case instr(sem:a, op1(sem:reg), op2(sem:reg)) +into AssignRR(addr:$curaddr, dst(rid:$instr.op2.name), src(rid:$instr.op1.name), uflags(val:0)) + +# MOV (reg, mem) +case instr(sem:a, op1(sem:reg), op2(sem:mem)) +into AssignMR(addr:$curaddr, dst((name:$instr.op2.name, base(rid:$instr.op2.name), + index(rid:$instr.op2.name), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), + src(rid:$instr.op1.name), uflags(val:0)) + +# MOV (mem, imm) +case instr(sem:a, op1(sem:mem), op2(sem:imm)) +into AssignIM(addr:$curaddr, dst((name:$instr.op1.name, base(rid:$instr.op1.sbaser), + index(rid:$instr.op1.sindex), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), + src(val:$instr.op2.imm), uflags(val:0)) + +# LDS, LES (reg, imm) +case instr(sem:rm, op1(sem:imm)) +into AssignIR(addr:$curaddr, dst(rid:$instr.op2.name), src(val:$instr.op1.imm), uflags(val:0)) + +# LODSB, LODSD (reg, mem) +case instr(sem:rm) +into AssignRM(addr:$curaddr, dst(rid:$instr.op2.name), + src((name:$instr.op1.name, base(rid:$instr.op1.name), index(rid:$instr.op1.name), + scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags(val:0)) + +# LAHF +case instr(sem:rf) +into FlagR(addr:$curaddr, uflags(val:$instr.rflags)) + +# CLC, CLD, CLI, CMC, SAHF, STC, STD, STI +case instr(sem:wf) +into FlagW(addr:$curaddr, uflags(val:$instr.rflags)) + +# Defaultcase +#profile enable warn +default print Unsupported instruction $instr + +rwtend + +add $curaddr $curlen + +forend + +quiet + diff -Nru eresi-0.8a25/evarista/lir2ssi.esh eresi-0.0.20110516/evarista/lir2ssi.esh --- eresi-0.8a25/evarista/lir2ssi.esh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/lir2ssi.esh 2011-05-16 11:35:07.000000000 +0000 @@ -11,7 +11,6 @@ #inspect $curb #profile enable warn - # Start the transformation for the current block # Note : do we need rdst(inlist/innbr) linked to rsrc ? diff -Nru eresi-0.8a25/evarista/lir-definition.esh eresi-0.0.20110516/evarista/lir-definition.esh --- eresi-0.8a25/evarista/lir-definition.esh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/lir-definition.esh 2011-05-16 11:35:07.000000000 +0000 @@ -4,43 +4,32 @@ # # Attributes for ASM instructions -define b ASM_TYPE_IMPBRANCH -define cb ASM_TYPE_CONDBRANCH -define c ASM_TYPE_CALLPROC -define i ASM_TYPE_INT -define r ASM_TYPE_RETPROC -define p ASM_TYPE_PROLOG -define cmp ASM_TYPE_COMPARISON -define bs ASM_TYPE_BITSET -define a ASM_TYPE_ASSIGN -define wm ASM_TYPE_STORE -define rm ASM_TYPE_LOAD -define e ASM_TYPE_EPILOG -define s ASM_TYPE_STOP -define n ASM_TYPE_NOP -define ar ASM_TYPE_ARITH -define wf ASM_TYPE_WRITEFLAG -define rf ASM_TYPE_READFLAG -define io ASM_TYPE_IO -define sp ASM_TYPE_TOUCHSP - -# Combinations of flags -define i-r i r -define ar-wf ar wf -define ar-wm ar wm -define a-rm a rm -define a-wm a wm -define cmp-wf cmp wf -define io-rm io rm -define io-wm io wm -define i-rf-bt i rf bt -define a-rm-wm a rm wm -define sp-rm sp rm -define sp-rm-wf sp rm wf -define sp-wm-rf sp wm rf -define wm-rm wm rm - -#return 0 +define non ASM_TYPE_NONE +define b ASM_TYPE_BRANCH +define c ASM_TYPE_CALLPROC +define r ASM_TYPE_RETPROC +define ar ASM_TYPE_ARITH +define rm ASM_TYPE_LOAD +define wm ASM_TYPE_STORE +define arch ASM_TYPE_ARCH +define wf ASM_TYPE_WRITEFLAG +define rf ASM_TYPE_READFLAG +define i ASM_TYPE_INT +define a ASM_TYPE_ASSIGN +define cmp ASM_TYPE_COMPARISON +define ctrl ASM_TYPE_CONTROL +define n ASM_TYPE_NOP +define sp ASM_TYPE_TOUCHSP +define bt ASM_TYPE_BITTEST +define bs ASM_TYPE_BITSET +define id ASM_TYPE_INCDEC +define p ASM_TYPE_PROLOG +define e ASM_TYPE_EPILOG +define s ASM_TYPE_STOP +define io ASM_TYPE_IO +define cnd ASM_TYPE_CONDCONTROL +define ind ASM_TYPE_INDCONTROL +define oth ASM_TYPE_OTHER # Attributes for ASM operands define reg ASM_OPTYPE_REG @@ -49,36 +38,38 @@ # Types of LIR operands type Immed = val:long +type Addr = val:caddr type Reg::container = rid:string type Mem::container = base:Reg off:Immed name:string index:Reg scale:Immed -type Ins = uflags:Immed addr:Immed +type Ins = uflags:Immed addr:caddr szaffect:byte # Types of LIR instructions # Control-flow operations type IndBranchR::Ins = dst:Reg type IndBranchM::Ins = dst:Mem -type Branch::Ins = dst:Immed -type Call::Ins = dst:Immed +type Branch::Ins = dst:Addr +type Call::Ins = dst:Addr type IndCallR::Ins = dst:Reg type IndCallM::Ins = dst:Mem type Interrupt::Ins = dst:Immed type Return::Ins = dst:Immed # Ternary operations -type TernopMI::Ins = dst:Mem msrc:Mem isrc:Immed -type TernopMR::Ins = dst:Mem msrc:Mem rsrc:Reg -type TernopRM::Ins = dst:Reg rsrc:Reg msrc:Mem -type TernopRMI::Ins = dst:Reg rsrc:Reg msrc:Mem isrc:Immed -type TernopR3::Ins = dst:Reg src1:Reg src2:Reg -type TernopM3::Ins = dst:Mem msrc1:Mem msrc2:Mem -type TernopRI::Ins = dst:Reg rsrc:Reg isrc:Immed +type Ternop::Ins = op:int +type TernopMI::Ternop = dst:Mem msrc:Mem isrc:Immed +type TernopMR::Ternop = dst:Mem msrc:Mem rsrc:Reg +type TernopRM::Ternop = dst:Reg rsrc:Reg msrc:Mem +type TernopRMI::Ternop = dst:Reg rsrc:Reg msrc:Mem isrc:Immed +type TernopR3::Ternop = dst:Reg src1:Reg src2:Reg +type TernopM3::Ternop = dst:Mem msrc1:Mem msrc2:Mem +type TernopRI::Ternop = dst:Reg rsrc:Reg isrc:Immed # Assignments type AssignIR::Ins = dst:Reg src:Immed type AssignIM::Ins = dst:Mem src:Immed -type AssignMR::Ins = dst:Mem src:Reg -type AssignRM::Ins = dst:Reg src:Mem +type AssignMR::Ins = dst:Reg src:Mem +type AssignRM::Ins = dst:Mem src:Reg type AssignMM::Ins = dst:Mem src:Mem type AssignRR::Ins = dst:Reg src:Reg @@ -105,3 +96,5 @@ typedef Ins Epilog typedef Ins Stop typedef Ins Nop + +quiet \ No newline at end of file diff -Nru eresi-0.8a25/evarista/main.c eresi-0.0.20110516/evarista/main.c --- eresi-0.8a25/evarista/main.c 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/main.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,15 +1,19 @@ -/* -** main.c for evarista -** -** The entry point of the static analyzer -** -** Started on Fri Jun 22 14:42:36 2007 jfv -** $Id: main.c,v 1.5 2007-07-31 23:30:35 may Exp $ -*/ +/** +* @file evarista/main.c + * @ingroup evarista + * + * The entry point of the static analyzer + * + * Started on Fri Jun 22 14:42:36 2007 jfv + * $Id: main.c 1397 2009-09-13 02:19:08Z may $ + */ #include "evarista.h" -/* Prompt related functions for evarista */ +/** + * Prompt related functions for evarista + * @ingroup evarista + */ void eva_setup_quit_msg() { char logbuf[BUFSIZ]; @@ -18,7 +22,10 @@ EVARISTA_NAME, REVM_VERSION); revm_quitmsg_set(logbuf); } - +/** + * + * @ingroup evarista + */ void eva_create_prompt(char *buf, u_int size) { snprintf(buf, size - 1, @@ -37,13 +44,19 @@ revm_endline(); } +/** + * @ingroup evarista + */ void eva_setup_prompt() { revm_set_prompt(eva_create_prompt); } -/* Print the etrace banner */ +/** + * Print the etrace banner + * @ingroup evarista + */ void eva_banner_print() { char logbuf[BUFSIZ]; @@ -69,7 +82,10 @@ -/* The real main function */ +/** + * The real main function + * @ingroup evarista + */ int eva_main(int ac, char **av) { /* Interface tweak */ @@ -83,11 +99,15 @@ revm_config(EVARISTA_CONFIG); setup_local_cmdhash(); revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); + revm_run(ac, av); + return (0); } -/* The main ELFsh routine */ +/** + * The main ELFsh routine + * @ingroup evarista + */ int main(int ac, char **av) { return (eva_main(ac, av)); diff -Nru eresi-0.8a25/evarista/Makefile eresi-0.0.20110516/evarista/Makefile --- eresi-0.8a25/evarista/Makefile 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/Makefile 2011-05-16 11:35:07.000000000 +0000 @@ -23,7 +23,7 @@ -I../e2dbg/include/ -I/usr/pkg/include/ \ -I../libaspect/include/ -I../librevm/include/ \ -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../libedfmt/include/ $(STATOPT2) \ $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ @@ -33,31 +33,30 @@ -I../e2dbg/include/ -I/usr/pkg/include/ \ -I../libaspect/include/ -I../librevm/include/ \ -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../libedfmt/include/ $(STATOPT2) \ $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ +LDFLAGS32 += -L../libstderesi -lstderesi32 -L../librevm/ -lrevm32 \ + -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ -L../libetrace/ -letrace32 \ -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ -lmjollnir32 $(LPTHREAD) -L../libstderesi -lstderesi32 \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ + -L../libasm/ -lasm32 $(LDUIOPT32) -g3 -lcrypto \ -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ + -L../libaspect/ -laspect32 \ -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ - $(KERNSHLIB32) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ + -L../libasm/ -lasm64 $(LDUIOPT64) -g3 \ -L../liballocproxy -L../libmjollnir/ \ -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) \ + $(EXTRAOPT) $(LDDUMPOPT64) $(LDNCURSESLNOPT) $(LDREADLNOPT) \ $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/evarista/mips2lir.esh eresi-0.0.20110516/evarista/mips2lir.esh --- eresi-0.8a25/evarista/mips2lir.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/evarista/mips2lir.esh 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,39 @@ +#!evarista/evarista32 + +# This create on-demand the block instruction list in the eresi runtime + +quiet +set $curaddr $1 +set $begaddr $1 +reflect $curaddr + +#tables instrlists + +# Start the transformation +foreach $instr of $hash[instrlists:$begaddr] + +#print TRANSFORMING instruction +#D $curaddr%1 +#print $instr + +#profile enable warn +#quiet +#verb + +rewrite $instr into + +# Defaultcase +default print Unsupported instruction at address $curaddr $instr + +rwtend + +#print TRANSFORMED instruction: +#print $instr + +add $curaddr 4 + +forend + +quiet + +print diff -Nru eresi-0.8a25/evarista/sparc2lir.esh eresi-0.0.20110516/evarista/sparc2lir.esh --- eresi-0.8a25/evarista/sparc2lir.esh 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/sparc2lir.esh 2011-05-16 11:35:07.000000000 +0000 @@ -1,70 +1,92 @@ #!evarista/evarista32 - +# # This create on-demand the block instruction list in the eresi runtime +# + +#print Now SPARC2LIR at addr $curaddr +#quiet +#verb set $curaddr $1 set $begaddr $1 -D $curaddr + +verb + +#profile enable warn reflect $curaddr -tables instrlists +#profile disable warn + +#tables instrlists 0001076C +#exec sleep 20 # Start the transformation foreach $instr of $hash[instrlists:$begaddr] -print TRANSFORMING instruction -print $instr +#print TRANSFORMING instruction $instr at addr $curaddr +#D $curaddr%1 +#print $instr + #profile enable warn -#quiet rewrite $instr into # indirect always branch without link case instr(sem:b, nb_op:1, op1(sem:reg)) -into IndBranchR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) +into IndBranchR(addr:$curaddr, dst(rid:$instr.op1.baser)) # direct always branch (b, bp) case instr(sem:b, nb_op:1, op1(sem:imm)) -into Branch(addr:$curaddr, dst:Immed($instr.op1.imm)) +into Branch(addr:$curaddr, dst(val:$curaddr+($instr.op1.imm*4))) + +# direct always branch (b, bp) with 2 parameters +# XXX lacks flag translation +case instr(sem:b, nb_op:2, op1(sem:imm)) +into Branch(addr:$curaddr, dst(val:$curaddr+($instr.op1.imm*4))) # indirect conditional branch without link # XXX lacks flag translation -case instr(sem:cb, nb_op:1, op1(sem:reg)) -into IndBranchR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) +case instr(sem:b|cnd, nb_op:1, op1(sem:reg)) +into IndBranchR(addr:$curaddr, dst(rid:$instr.op1.baser)) # direct always branch (bcc, bpcc) # XXX lacks flag translation -case instr(sem:cb, nb_op:1, op1(sem:imm)) -into Branch(addr:$curaddr, dst:Immed($instr.op1.imm)) +case instr(sem:b|cnd, nb_op:1, op1(sem:imm)) +into Branch(addr:$curaddr, dst(val:$curaddr+($instr.op1.imm*4))) + + +# direct always branch (bcc, bpcc) with 2 args +# XXX lacks flag translation +case instr(sem:b|cnd, nb_op:2, op1(sem:imm)) +#into Branch(addr:$curaddr, dst(val:$curaddr+$instr.op1.imm))::Nop(addr:$curaddr) +into Branch(addr:$curaddr, dst(val:$curaddr+($instr.op1.imm*4))) # indirect call (op1 reg) case instr(sem:c, nb_op:1, op1(sem:reg)) -into IndCallR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) +into IndCallR(addr:$curaddr, dst(rid:$instr.op1.baser)) # direct call (op1 addr) case instr(sem:c, nb_op:1, op1(sem:imm)) -into Call(addr:$curaddr, dst(val:$instr.op1.imm)) +into Call(addr:$curaddr, dst(val:$curaddr+($instr.op1.imm*4))) # ta* (traps) case instr(sem:i) -into Interrupt(addr:$curaddr, dst:Immed(val:$instr.op1.imm)) +into Interrupt(addr:$curaddr, dst(val:$instr.op1.imm)) # ret, retl case instr(sem:r) -into Return(addr:$curaddr, dst:Immed(val:$instr.op1.imm)) +into Return(addr:$curaddr, dst(val:$instr.op1.imm)) # save case instr(sem:p) -#profile enable warn -into Prolog(addr:$curaddr) -#varlist instr +into Prolog(addr:$curaddr, framesz:$instr.op2.imm) # restore -case instr(sem:e) -into Epilog(addr:$curaddr) +case instr(sem:e) +into Epilog(addr:$curaddr) # illtrap -case instr(sem:s) -into Stop(addr:$curaddr) +case instr(sem:s) +into Stop(addr:$curaddr) # nop case instr(sem:n) @@ -72,82 +94,90 @@ # andcc,subcc,orcc,addcc,inccc,deccc (op2 = reg) # XXX: lack flags translation -case instr(sem:ar-wf, nb_op:3, op2(sem:reg)) -into TernopR3(addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name), uflags:$instr.flags) +case instr(sem:ar|wf, nb_op:3, op2(sem:reg)) +into TernopR3(op:$instr.aop, addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name), uflags:$instr.wflags) # andcc,subcc,orcc,addcc,inccc,deccc (op2 = immed) # XXX: lack flags translation -case instr(sem:ar-wf, nb_op:3, op2(sem:imm)) -into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name), uflags:$instr.flags) +case instr(sem:ar|wf, nb_op:3, op2(sem:imm)) +into TernopRI(op:$instr.aop, addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name), uflags:$instr.wflags) # sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 immed) case instr(sem:ar, nb_op:3, op2(sem:imm)) -into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name)) +into TernopRI(op:$instr.aop, addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name)) # sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 reg) case instr(sem:ar, nb_op:3, op2(sem:reg)) -into TernopR3(addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name)) +into TernopR3(op:$instr.aop, addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name)) # clrx, clrh, clrb, clr (op1 = reg) -case instr(sem:ar, nb_op:1, op1(sem:reg)) -into AssignIR(addr:$curaddr, dst(rid:$instr.op1.name), src(val:0)) +#case instr(sem:ar, nb_op:1, op1(sem:reg)) +#into AssignIR(addr:$curaddr, dst(rid:$instr.op1.name), src(val:0)) # clrx, clrh, clrb, clr (op1 = mem) -case instr(sem:ar-wm, nb_op:1, op1(sem:mem)) -into AssignIM(addr:$curaddr, dst(name:$instr.op1.name base(rid:$instr.op1.name), off(val:$instr.op1.imm)), isrc(val:0)) +#case instr(sem:ar-wm, nb_op:1, op1(sem:mem)) +#into AssignIM(addr:$curaddr, dst(name:$instr.op1.name base(rid:$instr.op1.sbaser), off(val:$instr.op1.imm)), isrc(val:0)) # set(hi) case instr(sem:a, nb_op:2, op1(sem:reg), op2(sem:imm)) -#profile enable warn -pre print $instr.op2.imm into AssignIR(addr:$curaddr, dst(rid:$instr.op1.name), src(val:$instr.op2.imm)) +# mov +case instr(sem:a, nb_op:2, op1(sem:reg), op2(sem:reg)) +into AssignRR(addr:$curaddr, dst(rid:$instr.op1.name), src(rid:$instr.op2.name)) + # btog immed -case instr(sem:ar, nb_op:2, op1(sem:imm)) -into TernopRI(addr:$curaddr, dst:Reg(rid:$instr.op2.name), isrc:Immed(val:$instr.op1.imm), rsrc:Reg(rid:$instr.op2.name)) +#case instr(sem:ar, nb_op:2, op1(sem:imm)) +#into TernopRI(addr:$curaddr, dst(rid:$instr.op2.name), isrc(val:$instr.op1.imm), rsrc(rid:$instr.op2.name)) # btog register -case instr(sem:ar, nb_op:2, op1(sem:reg)) -into TernopR3(addr:$curaddr, dst:Reg(rid:$instr.op2.name), src1:Reg(rid:$instr.op1.name), src2:Reg(rid:$instr.op2.name)) +#case instr(sem:ar, nb_op:2, op1(sem:reg), op2(sem:reg)) +#into TernopR3(addr:$curaddr, dst(rid:$instr.op2.name), src1(rid:$instr.op1.name), src2(rid:$instr.op2.name)) + +# inc reg +#case instr(sem:ar, nb_op:2, op1(sem:reg), op2(sem:imm)) +#into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(imm:$instr.op1.name)) # ld,ldd,ldub,ldx,lduw,lduh,ldsw,ldsb -case instr(sem:a-rm) -into AssignMR(addr:$curaddr, src(name:$instr.op1.name base(rid:$instr.op1.name), off(val:$instr.op1.imm)), dst(rid:$instr.op2.name)) +case instr(sem:a|rm) +into AssignMR(addr:$curaddr, src(name:$instr.op2.name, base(rid:$instr.op2.sbaser), off(val:$instr.op2.imm)), dst(rid:$instr.op1.name)) # st,stb,stw,sth,std,stx (src = reg) -case instr(sem:a-wm, op1(sem:reg)) -into AssignRM(addr:$curaddr, src(rid:$instr.op1.name), dst(name:$instr.op2.name base(rid:$instr.op2.name), off(val:$instr.op2.imm))) +case instr(sem:a|wm, op2(sem:reg)) +into AssignRM(addr:$curaddr, src(rid:$instr.op2.name), dst(name:$instr.op1.name, base(rid:$instr.op1.sbaser), off(val:$instr.op1.imm))) # st,stb,stw,sth,std,stx (src = immed) -case instr(sem:a-wm, op1(sem:imm)) -into AssignIM(addr:$curaddr, src(val:$instr.op1.imm), dst(name:$instr.op2.name base(rid:$instr.op2.name), off(val:$instr.op2.imm))) +case instr(sem:a|wm, op2(sem:imm)) +into AssignIM(addr:$curaddr, src(val:$instr.op2.imm), dst(name:$instr.op1.name base(rid:$instr.op1.sbaser), off(val:$instr.op1.imm))) # bset (op1 immed) -case instr(sem:bs, op1(sem:imm)) -into BitSet(addr:$curaddr, src(val:$instr.op1.imm), dst(rid:$instr.op2.name)) +case instr(sem:bs, op1(sem:reg), op2(sem:imm)) +into BitSet(addr:$curaddr, src(val:$instr.op2.imm), dst(rid:$instr.op1.name)) # tst (implicit 2e operand = immed 0 !) case instr(sem:cmp, nb_op:1, op1(sem:reg)) -into CmpRI(addr:$curaddr, snd(rid:$instr.op1.name), fst(val:0)) +into CmpRI(addr:$curaddr, snd(rid:$instr.op1.name), fst(val:0)) # cmp (op2 register) -case instr(sem:cmp, nb_op:2, op1(sem:reg), op2(sem:reg)) -into CmpRR(addr:$curaddr, fst(rid:$instr.op1.name), snd(rid:$instr.op2.name)) +# XXX lacks flag translation +case instr(sem:cmp|wf, nb_op:2, op1(sem:reg), op2(sem:reg)) +into CmpRR(addr:$curaddr, fst(rid:$instr.op1.name), snd(rid:$instr.op2.name)) # cmp (op2 immed) -case instr(sem:cmp, nb_op:2, op1(sem:reg), op2(sem:imm)) -into CmpRI(addr:$curaddr, snd(rid:$instr.op1.name), snd(val:$instr.op2.imm)) +# XXX lacks flag translation +case instr(sem:cmp|wf, nb_op:2, op1(sem:imm), op2(sem:reg)) +into CmpRI(addr:$curaddr, snd(rid:$instr.op2.name), fst(val:$instr.op1.imm)) -# Defaultcase -default print Unsupported instruction at address $curaddr +# Defaultcase +default print Unsupported instruction at address $curaddr $instr rwtend -print TRANSFORMED instruction: -print $instr +#print TRANSFORMED instruction: +#print $instr add $curaddr 4 forend -print +quiet diff -Nru eresi-0.8a25/evarista/sparc2lir-OLD.esh eresi-0.0.20110516/evarista/sparc2lir-OLD.esh --- eresi-0.8a25/evarista/sparc2lir-OLD.esh 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/sparc2lir-OLD.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -#!evarista/evarista32 - -# This create on-demand the block instruction list in the eresi runtime - -reflect _start - -profile enable warn - -set $curblock $_ -set $curaddr $curblock.vaddr -set $list[curinstrlist] $instrlists[$curaddr] - -# Just debug -inspect $curblock - -# Start the transformation -transform $list[curinstrlist] into - -print Transforming instruction: $matchme - -# indirect always branch (call, jmpl) -case instr_t(type:b, nb_op:1, op1(content:reg)) -> Branch(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct always branch (b, bp) -case instr_t(type:b, nb_op:1, op1(content:imm)) -> Branch(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# indirect always branch (callcc, jmplcc) -case instr_t(type:cb, nb_op:1, op1(content:reg)) -> Branch(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct always branch (bcc, bpcc) -case instr_t(type:cb, nb_op:1, op1(content:imm)) -> Branch(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# indirect call (op1 reg) -case instr_t(type:c, nb_op:1, op1(content:reg)) -> Call(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct call (op1 addr) -case instr_t(type:c, nb_op:1, op1(content:imm)) -> Call(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# traps -case instr_t(type:i) -> Interrupt(addr:$curaddr, Immed(val:$instr.op1.imm), uflags:0) - -# return, ret, retl -case instr_t(type:r) -> Return(addr:$curaddr, Immed(val:$instr.op1.imm), uflags:0) - -# rett -case instr_t(type:i-r) -> IReturn(addr:$curaddr, Reg(id:$instr.op1.baser), uflags:0) - -# save -case instr_t(type:p) -> Prolog(addr:$curaddr, uflags:0) - -# restore -case instr_t(type:e) -> Epilog(addr:$curaddr, uflags:0) - -# illtrap -case instr_t(type:s) -> Stop(addr:$curaddr, uflags:0) - -# nop -case instr_t(type:n) -> Nop(addr:$curaddr, uflags:0) - -# inc,dec (op1 = register) -#case instr_t(type:ar-id, nb_op:1, op1(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op1.baser), Immed(id:1), uflags:0) - -# inc,dec (op1 = imm, op2 = reg) -#case instr_t(type:ar-id-wm, nb_op:2, op1(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:0) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = reg) -case instr_t(type:ar-wf, nb_op:3, op2(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op2.baser), rsrc2(id:$instr.op3.baser), uflags:$instr.flags) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = immed) -case instr_t(type:ar-wf, nb_op:3, op2(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), isrc1(val:$instr.op2.imm), rsrc1(id:$instr.op3.baser), uflags:$instr.flags) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 immed) -case instr_t(type:ar, nb_op:3, op2(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), isrc1(val:$instr.op2.imm), rsrc1(id:$instr.op3.baser), uflags:0) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 reg) -case instr_t(type:ar, nb_op:3, op2(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op2.baser), rsrc2(id:$instr.op3.baser), uflags:0) - -# clrx, clrh, clrb, clr (op1 = reg) -case instr_t(type:ar, nb_op:1, op1(content:reg)) -> Assign(addr:$curaddr, dst(id:$instr.op1.baser), isrc(val:0), uflags:0) - -# clrx, clrh, clrb, clr (op1 = mem) -case instr_t(type:ar-wm, nb_op:1, op1(content:mem)) -> WMAssign(addr:$curaddr, dst(base(id:$instr.op1.baser), off(val:$instr.op1.imm)), isrc(val:0), uflags:0) - -# btog immed -case instr_t(type:ar, nb_op:2, op1(content:imm)) -> Ternop(addr:$curaddr, Reg(id:$instr.op2.baser), Immed(val:$instr.op1.imm), Reg(id:$instr.op2.baser), uflags:0) - -# btog register -case instr_t(type:ar, nb_op:2, op1(content:reg)) -> Ternop(addr:$curaddr, Reg(id:$instr.op2.baser), Reg(id:$instr.op1.baser), Reg(id:$instr.op2.baser), uflags:0) - -# ld,ldd,ldub,ldx,lduw,lduh,ldsw,ldsb -case instr_t(type:a-rm) -> RMAssign(addr:$curaddr, src(base(id:$instr.op1.baser), off(val:$instr.op1.imm)), rsrc(id:$instr.op2.baser), uflags:0) - -# st,stb,stw,sth,std,stx (src = reg) -case instr_t(type:a-wm, op1(content:reg)) -> WMAssign(addr:$curaddr, rsrc(id:$instr.op1.baser), dst(base(id:$instr.op2.baser), off(val:$instr.op2.imm)), uflags:0) - -# st,stb,stw,sth,std,stx (src = reg) -case instr_t(type:a-wm, op1(content:imm)) -> WMAssign(addr:$curaddr, isrc(val:$instr.op1.imm), dst(base(id:$instr.op2.baser), off(val:$instr.op2.imm)), uflags:0) - -# bset (op1 immed) -case instr_t(type:bs, op1(content:imm)) -> BitSet(addr:$curaddr, fst(val:$instr.op1.imm), snd(id:$instr.op2.baser), uflags:0) - -# tst (implicit 2e operand = immed 0 !) -case instr_t(type:cmp, nb_op:1, op1(content:reg)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), snd:0, uflags:0) - -# cmp (op2 register) -case instr_t(type:cmp, nb_op:2, op1(content:reg), op2(content:reg)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), rsnd(id:$instr.op2.baser), uflags:0) - -# cmp (op2 immed) -case instr_t(type:cmp, nb_op:2, op1(content:reg), op2(content:imm)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), snd(val:$instr.op2.imm), uflags:0) - -# Defaultcase -default print Unsupported instruction at address $curaddr - -endtrans add $curaddr 4 - diff -Nru eresi-0.8a25/evarista/.svn/all-wcprops eresi-0.0.20110516/evarista/.svn/all-wcprops --- eresi-0.8a25/evarista/.svn/all-wcprops 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/945/trunk/evarista -END -sparc2lir.esh -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/945/trunk/evarista/sparc2lir.esh -END -eva-typedecl.esh -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/945/trunk/evarista/eva-typedecl.esh -END -intel2lir.esh -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/785/trunk/evarista/intel2lir.esh -END -ssi-definition.esh -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/785/trunk/evarista/ssi-definition.esh -END -lir-dataflow.esh -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/778/trunk/evarista/lir-dataflow.esh -END -lir2ssi.esh -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/785/trunk/evarista/lir2ssi.esh -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/914/trunk/evarista/main.c -END -cfg-walk.esh -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/945/trunk/evarista/cfg-walk.esh -END -lir-definition.esh -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/915/trunk/evarista/lir-definition.esh -END -eva-run.esh -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/843/trunk/evarista/eva-run.esh -END -sparc2lir-OLD.esh -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/768/trunk/evarista/sparc2lir-OLD.esh -END -tables.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/749/trunk/evarista/tables.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/830/trunk/evarista/Makefile -END diff -Nru eresi-0.8a25/evarista/.svn/entries eresi-0.0.20110516/evarista/.svn/entries --- eresi-0.8a25/evarista/.svn/entries 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,191 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/evarista -http://svn.eresi-project.org/svn - - - -2008-03-27T22:24:43.639027Z -945 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -sparc2lir.esh -file - - - - -2008-04-06T23:16:30.943887Z -76cce004341f78a0ad48fa0141e35684 -2008-03-27T22:24:43.639027Z -945 -may - -eva-typedecl.esh -file - - - - -2008-04-06T23:16:30.973876Z -6d10f0c96376f6d8aba50474d020af85 -2008-03-27T22:24:43.639027Z -945 -may -has-props - -intel2lir.esh -file - - - - -2008-04-06T23:16:30.985123Z -37317820966bcc64cfebdc11830fe2f3 -2007-09-17T02:26:03.000000Z -785 -may - -ssi-definition.esh -file - - - - -2008-04-06T23:16:30.996406Z -9a9917089038fc2ba91d7cc5c9051276 -2007-09-17T02:26:03.000000Z -785 -may - -include -dir - -lir-dataflow.esh -file - - - - -2008-04-06T23:16:31.007692Z -4cb1e0bc7f55c979a76503cab32500aa -2007-08-23T03:17:09.000000Z -778 -may - -lir2ssi.esh -file - - - - -2008-04-06T23:16:31.019092Z -92fabd9234df98c046b543088b36401d -2007-09-17T02:26:03.000000Z -785 -may - -main.c -file - - - - -2008-04-06T23:16:31.030493Z -362cae9ab84553ebd11f91952fbcd480 -2008-03-18T16:49:26.066981Z -914 -pouik - -cfg-walk.esh -file - - - - -2008-04-06T23:16:31.041835Z -4e9772a44d774340d1c190704416426c -2008-03-27T22:24:43.639027Z -945 -may -has-props - -lir-definition.esh -file - - - - -2008-04-06T23:16:31.108877Z -9d94cce8d735e17fdee1e161853f1853 -2008-03-18T17:48:47.427281Z -915 -may - -eva-run.esh -file - - - - -2008-04-06T23:16:31.120078Z -1c7261a56b635ad8ef9250aa0177487c -2008-02-16T12:32:28.000000Z -843 -thor -has-props - -sparc2lir-OLD.esh -file - - - - -2008-04-06T23:16:31.131363Z -b9e5eb108e7ba5e74846b29ede3a142e -2007-08-11T08:53:49.000000Z -768 -may - -tables.c -file - - - - -2008-04-06T23:16:31.142706Z -fc744a9652ea4e9601b0552bbae041d8 -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:16:31.154048Z -5f167498a636ba9f35369547e3c664a4 -2007-11-29T14:01:56.000000Z -830 -may -has-props - diff -Nru eresi-0.8a25/evarista/.svn/format eresi-0.0.20110516/evarista/.svn/format --- eresi-0.8a25/evarista/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/evarista/.svn/prop-base/cfg-walk.esh.svn-base eresi-0.0.20110516/evarista/.svn/prop-base/cfg-walk.esh.svn-base --- eresi-0.8a25/evarista/.svn/prop-base/cfg-walk.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/prop-base/cfg-walk.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/evarista/.svn/prop-base/eva-run.esh.svn-base eresi-0.0.20110516/evarista/.svn/prop-base/eva-run.esh.svn-base --- eresi-0.8a25/evarista/.svn/prop-base/eva-run.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/prop-base/eva-run.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/evarista/.svn/prop-base/eva-typedecl.esh.svn-base eresi-0.0.20110516/evarista/.svn/prop-base/eva-typedecl.esh.svn-base --- eresi-0.8a25/evarista/.svn/prop-base/eva-typedecl.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/prop-base/eva-typedecl.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/evarista/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/evarista/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/evarista/.svn/prop-base/Makefile.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/evarista/.svn/text-base/cfg-walk.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/cfg-walk.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/cfg-walk.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/cfg-walk.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -#!evarista/evarista32 - -print Now entered cfg-walk - -#profile enable warn - -cmp $# 1 -jne end - -# debug -print $1 -sym main -sort a -sym bloc -sym FUNC -tables blocks -# - -#profile enable warn - -set $block $hash[blocks:$1] -print $1 -set $hash[visitedblocks:$1] 1 -print $block -print Now ASM to ELIR on block at $block.vaddr -print $hash[visitedblocks:$1] - -sparc2lir $1 -#lir-dataflow $1 - -tables blocks -print $block -#tables expressions -print $block.outlinks - -tables expressions 100A34 -exec sleep 10 - -foreach $nextblock of $block.outlinks - - print *nextblock - - set $addr $nextblock.curaddr - set $found $hash[visitedblocks:$curaddr] - cmp $found 1 - je next - cfg-walk $nextblock.curaddr - - print *nextblock - -next: forend - -end: -print This function needs two parameters -quit diff -Nru eresi-0.8a25/evarista/.svn/text-base/eva-run.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/eva-run.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/eva-run.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/eva-run.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -#!evarista64 - -#quiet -#print $# -#profile enable warn - -vlist -cmp $# 1 -jne end -sdir . - -eva-typedecl 42 - -print -print ******************** The Evarista static analyzer .::. Welcome ********************* -print -#verb -#vlist - -load $1 -analyse - -sym main -set $mainaddr main -print Main-Function found at addr $mainaddr - -#vlist -set $mainfunc $hash[functions:$mainaddr] - -tables expressions -print $hash[functions:$mainaddr] -print $mainfunc -print $mainfunc.vaddr - -cfg-walk $mainfunc.vaddr - -quiet -print -print ******************** The Evarista static analyzer .::. Good bye ********************* -print -quit - -end: -print Syntax: evarista -print -quit - \ No newline at end of file diff -Nru eresi-0.8a25/evarista/.svn/text-base/eva-typedecl.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/eva-typedecl.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/eva-typedecl.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/eva-typedecl.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#!evarista32 - -#quiet -#print Dans eva-typedecl -#vlist \$1 - -type listent = key:string data:long next:*listent -type list = head:*listent elmnbr:int type:int linearity:byte name:string -type hash = ent:*listent size:int elmnbr:int type:int linearity:byte name:string -type container = id:int type:int nbrinlinks:int nbroutlinks:int inlinks:*list outlinks:*list data:long -type op = len:int ptr:*byte sem:int name:string size:int content:int regset:int prefix:int imm:int baser:int indexr:int sbaser:string sindex:string address_space:int scale:int - -type instr::container = ptrins:*byte proc%4 name:string icode:int sem:int prefix:int spdiff:int flagswritten:int flagsread:int ptr_prefix:*byte annul:int prediction:int nb_op:int op1:op op2:op op3:op len:int -type bloc::container = vaddr:long size:int symoff:int seen:byte -type func::container = vaddr:long size:int name:byte[64] first:*bloc md5:byte[34] - -source lir-definition.esh - -type diff -Nru eresi-0.8a25/evarista/.svn/text-base/intel2lir.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/intel2lir.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/intel2lir.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/intel2lir.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,301 +0,0 @@ -#!evarista/evarista32 -#intel-backend.esh - -# IA-32 registers -define EAX 0 -define ECX 1 -define EDX 2 -define EBX 3 -define ESP 4 -define EBP 5 -define ESI 6 -define EDI 7 -define EFLAGS -1 - -# IA-32 exceptional instruction -define NEG ASM_NEG - -# IA-32 prolog instruction -define SUB ASM_SUB - -# IA-32 epilog instruction -define MOV ASM_MOV - -# This create on-demand the block instruction list in the eresi runtime -reflect $1 - -set $curblock $_ -set $curaddr $curblock.vaddr - -# Just debug printing -#inspect $curblock -#profile enable warn - -# Start the transformation -foreach $instr in $hash[instrlists:$curaddr] - -print Transforming instruction: $instr - -transform $instr into - -# INC, DEC (reg) -case instr_t(type:ar-id-wf, nb_op:1, op1(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op1.baser), rsrc(id:$instr.op1.baser), isrc(val:1), uflags:$instr.wflags) - -# INC, DEC (mem) -case instr_t(type:ar-id-wf, nb_op:1, op1(type:mem)) -into TernopMI(addr:$curaddr, dst(id:$instr.op1.baser), msrc(name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), isrc(val:1), uflags:$instr.wflags) - -# AAA, AAD, AAM, AAS, DAD, DAS -case instr_t(type:ar-wf, nb_op:0) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:EAX), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, reg) -case instr_t(type:ar-wf, nb_op:2, op1(type:reg), op2(type:reg)) -into TernopR3(addr:$curaddr, dst(id:$instr.op2.baser), src1(id:$instr.op2.baser), src2(id:$instr.op1.baser), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, imm) -case instr_t(type:ar-wf, nb_op:2, op1(type:imm), op2(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (reg, mem) -case instr_t(type:ar-wf, nb_op:2, op1(type:mem), op2(type:reg)) -into TernopRM(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), msrc(name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm)), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, imm) -case instr_t(type:ar-wf, nb_op:2, op1(type:imm), op2(type:mem)) -into TernopMI(addr:$curaddr, dst(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# ADC, ADD, AND, OR, RCR, ROL ROR, SAR, SBB, SHL, SHR, SUB, XOR (mem, reg) -case instr_t(type:ar-wf, nb_op:2, op1(type:reg), op2(type:mem)) -into TernopMR(addr:$curaddr, dst(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), rsrc(id:$instr.op1.baser), uflags:$instr.wflags) - -# IMUL (reg, reg, imm) -case instr_t(type:ar-wf, nb_op:3, op1(type:imm), op2(type:reg), op3(type:reg)) -into TernopRI(addr:$curaddr, dst(id:$instr.op3.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# IMUL (reg, mem, imm) -case instr_t(type:ar-wf, nb_op:3, op1(type:imm), op2(type:mem), op3(type:reg)) -into TernopRMI(addr:$curaddr, dst(id:$instr.op3.baser), msrc(name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm)), isrc(val:$instr.op1.imm), uflags:$instr.wflags) - -# NEG (reg) -case instr_t(instr:NEG, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:$instr.op1.baser), src1(id:$instr.op1.baser), src2(id:$instr.op1.baser), uflags:$instr.wflags) - -# NEG (mem) -case instr_t(instr:NEG, op1(type:mem)) -into TernopM3(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), msrc1((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), msrc2((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:$instr.wflags) - -# MUL, IMUL (reg) -case instr_t(type:ar-wf, nb_op:1, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:$instr.op1.baser), src2(id:EAX), uflags:$instr.wflags) - -# MUL, IMUL (mem) -case instr_t(type:ar-wf, nb_op:1, op1(type:mem)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), src2(id:EAX), uflags:$instr.wflags) - -# CWD, CBW -case instr_t(type:ar, nb_op:0) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:EAX), uflags:0) - -# LEA (reg, mem) -case instr_t(type:ar, nb_op:2) -into TernopRM(addr:$curaddr, dst(id:$instr.op1.baser), rsrc(id:$instr.op1.baser), msrc((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# NOT, DIV, IDIV (reg) -case instr_t(type:ar, nb_op:1, op1(type:reg)) -into TernopR3(addr:$curaddr, dst(id:EAX), src1(id:EAX), src2(id:$instr.op1.baser), uflags:0) - -# NOT, DIV, IDIV (mem) -case instr_t(type:ar, nb_op:1, op1(type:mem)) -into TernopRM(addr:$curaddr, dst(id:EAX), rsrc(id:EAX), msrc((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# CALL (reg) -case instr_t(type:c, op1(type:reg)) -into IndCallR(addr:$curaddr, dst(id:$instr.op1.baser), uflags:0) - -# CALL (mem) -case instr_t(type:c, op1(type:mem)) -into IndCallM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# CALL (imm) -case instr_t(type:c, op1(type:imm)) -into Call(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# CMP, TEST (reg, imm) -case instr_t(type:cmp-wr, op1(type:imm), op2(type:reg)) -into CmpRI(addr:$curaddr, snd(id:$instr.op2.baser), fst(val:$instr.op1.imm), uflags:$instr.wflags) - -# CMP, TEST, CMPSB, CMPSD, SCASB, SCASD (reg, reg) -case instr_t(type:cmp-wr, op1(type:reg), op2(type:reg)) -into CmpRR(addr:$curaddr, snd(id:$instr.op2.baser), fst(id:$instr.op1.baser), uflags:$instr.wflags) - -# CMP (reg, mem) -case instr_t(type:cmp-wr, op1(type:mem), op2(type:reg)) -into CmpRM(addr:$curaddr, snd(id:$instr.op2.baser), fst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:$instr.wflags) - -# CMP, TEST (mem, reg) -case instr_t(type:cmp-wr, op1(type:reg), op2(type:mem)) -into CmpMR(addr:$curaddr, snd((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), fst(id:$instr.op1.baser), uflags:$instr.wflags) - -# TEST (mem, imm) -case instr_t(type:cmp-wr, op1(type:imm), op2(type:mem)) -into CmpMI(addr:$curaddr, snd((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), fst(val:$instr.op1.imm), uflags:$instr.wflags) - -# HLT -case instr_t(type:s) -into Stop(addr:$curaddr, uflags:0) - -# IN (reg, reg) -case instr_t(type:io-rm, op1(type:reg)) -into IoRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# IN (reg, imm) -case instr_t(type:io-rm, op1(type:imm)) -into IoRI(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# INTO -case instr_t(type:i-rf-bt) -into Interrupt(addr:$curaddr, dst(val:4), uflags:0) - -# IRET -case instr_t(type:i-r) -into IReturn(addr:$curaddr, uflags:0) - -# INT3 -case inst_t(type:i, nb_op:0) -into Interrupt(addr:$curaddr, dst(val:3), uflags:0) - -# INT (imm) -case instr_t(type:i) -into Interrupt(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# Jxx, LOOP, LOOPE, LOOPNE (imm) -# Jxx = JA, JAE, JB, JBE, JE, JECXZ, JG, JGE, JL, JLE, JNE, JNO, JNP, JNS, JO, JP, JS -case instr_t(type:cb) -into Branch(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# JMP (imm) -case instr_t(type:b, op1(type:imm)) -into Branch(addr:$curaddr, dst(val:$instr.op1.imm), uflags:0) - -# JMP (reg) -case instr_t(type:b, op1(type:reg)) -into IndBranchR(addr:$curaddr, dst(id:$instr.op1.baser), uflags:0) - -# JMP (mem) -case instr_t(type:b, op1(type:mem)) -into IndBranchM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# MOVSB, MOVSD (mem, mem) -case instr_t(type:a-rm-wm) -into AssignMM(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# NOP, WAIT/FWAIT -case instr_t(type:n) -into Nop(addr:$curaddr, uflags:0) - -# OUT (reg, reg) -case instr_t(type:io-wm, op2(type:reg)) -into IoRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# OUT (imm, reg) -case instr_t(type:io-wm, op2(type:imm)) -into IoIR(addr:$curaddr, dst(val:$instr.op2.imm), src(id:$instr.op1.baser), uflags:0) - -# POP (reg) -case instr_t(type:sp-rm, op1(type:reg)) -into AssignRM(addr:$curaddr, dst(id:$instr.op1.baser), src(base(id:ESP)), uflags:0) - -# POP (mem) -case instr_t(type:sp-rm, op1(type:mem)) -into AssignMM(addr:$curaddr, dst((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), src(base(id:ESP)), uflags:0) - -# PUSH (reg) -case instr_t(type:sp-wm, op1(type:reg)) -into AssignMR(addr:$curaddr, dst(base(id:ESP)), src(id:$instr.op1.baser), uflags:0) - -# PUSH (imm) -case instr_t(type:sp-wm, op1(type:imm)) -into AssignIM(addr:$curaddr, dst(base(id:ESP)), src(val:$instr.op1.imm), uflags:0) - -# POPF -case instr_t(type:sp-rm-wf) -into AssignRM(addr:$curaddr, dst(id:EFLAGS), src(base(id:ESP)), uflags:$instr.wflags) - -# PUSHF -case instr_t(type:sp-wm-rf) -into AssignMR(addr:$curaddr, dst(base(id:ESP)), src(id:EFLAGS), uflags:$instr.rflags) - -# RET, RETF -case instr_t(type:r) -into Return(addr:$curaddr, dst(val:0), uflags:0) - -# XCHG (reg, reg) -case instr_t(type:wm-rm, op2(type:reg)) -into XchgRR(addr:$curaddr, fst(id:$instr.op2.baser), snd(id:$instr.op1.baser), uflags:0) - -# XCHG (mem, reg) -case instr_t(type:wm-rm, op2(type:mem)) -into XchgMR(addr:$curaddr, fst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), snd(id:$instr.op1.baser), uflags:0) - -# XLATB -case instr_t(type:a-rm) -into AssignRM(addr:$curaddr, dst(id:EAX), src(base(id:EBX), index(id:EAX)), uflags:0) - -# STOSB, STOSD (mem, reg) -case instr_t(type:wm) -into AssignMR(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(id:$instr.op1.baser), uflags:0) - -# MOV (reg, imm) -case instr_t(type:a, op1(type:imm), op2(type:reg)) -into AssignIR(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# MOV (reg, mem) -case instr_t(type:a, op1(type:mem), op2(type:reg)) -into AssignRM(addr:$curaddr, dst(id:$instr.op2.baser), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# MOV (reg, reg) -case instr_t(type:a, op1(type:reg), op2(type:reg)) -into AssignRR(addr:$curaddr, dst(id:$instr.op2.baser), src(id:$instr.op1.baser), uflags:0) - -# MOV (mem, reg) -case instr_t(type:a, op1(type:reg), op2(type:mem)) -into AssignMR(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(id:$instr.op1.baser), uflags:0) - -# MOV (mem, imm) -case instr_t(type:a, op1(type:imm), op2(type:mem)) -into AssignIM(addr:$curaddr, dst((name:$instr.op2.name base(id:$instr.op2.baser), index(id:$instr.op2.indexr), scale(val:$instr.op2.scale), off(val:$instr.op2.imm))), src(val:$instr.op1.imm), uflags:0) - -# LDS, LES (reg, imm) -case instr_t(type:rm, op1(type:imm)) -into AssignIR(addr:$curaddr, dst(id:$instr.op2.baser), src(val:$instr.op1.imm), uflags:0) - -# LODSB, LODSD (reg, mem) -case instr_t(type:rm) -into AssignRM(addr:$curaddr, dst(id:$instr.op2.baser), src((name:$instr.op1.name base(id:$instr.op1.baser), index(id:$instr.op1.indexr), scale(val:$instr.op1.scale), off(val:$instr.op1.imm))), uflags:0) - -# LAHF -case instr_t(type:rf) -into FlagR(addr:$curaddr, uflags:$instr.rflags) - -# CLC, CLD, CLI, CMC, SAHF, STC, STD, STI -case instr_t(type:wf) -into FlagW(addr:$curaddr, uflags:$instr.rflags) - -# Prolog - SUB (ESP, imm) -case instr_t(instr:SUB, op2(baser:ESP), op1(type:imm)) -into Prolog(addr:$curaddr, framesz(val:$instr.op1.imm), uflags:0) - -# Epilog - MOV (ESP, EBP) -case instr_t(instr:MOV, op2(baser:ESP), op1(baser:EBP)) -into Epilog(addr:$curaddr, uflags:0) - -# Defaultcase -default print Unsupported instruction at address $curaddr - -endtrans - -add $curaddr $instr.len - -endfor \ No newline at end of file diff -Nru eresi-0.8a25/evarista/.svn/text-base/lir2ssi.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/lir2ssi.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/lir2ssi.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/lir2ssi.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -#!evarista/evarista32 -# -# Conversion from ELIR to SSI form -# - -reflect $1 - -set $curb $_ -set $curaddr $curb.vaddr - -#inspect $curb -#profile enable warn - - -# Start the transformation for the current block - -# Note : do we need rdst(inlist/innbr) linked to rsrc ? -# Note2 : inlink and outlink can points on ELIR instructions, not SSI ! - -foreach $instr in $instrlists[$curaddr] - - # Rewrite the current instruction in the bloc - rewrite $instr - - case IndBranch(dst(nbrin:1)) - pre namegen $nam1 $instr.dst.id - into IGoto(dst(name:$nam1 id:$instr.dst.id - inlist:$instr.dst.inlist nbrin:$instr.dst.nbrin - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout)) - post print Rewriting IndBranch into IGoto at $curaddr - - case IndBranch() - pre namegen $nam1 $instr.dst.id - pre namegen $nam2 $instr.dst.id - into RPhi(dst(name:$nam1 id:$instr.dst.id inlist:$instr.dst.inlist - in_nbr:$instr.dst.nbrin))::IGoto(dst(name:$nam2 id:$instr.dst.id)) - post link @2.dst @1.dst - post print Rewriting IndBranch into RPhi::IGoto at $curaddr - - case IndCall(dst(nbrin:1)) - pre namegen $nam1 $instr.dst.id - into ICall(dst(name:$nam1 id:$instr.dst.id - inlist:$instr.dst.inlist nbrin:$instr.dst.nbrin - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout)) - post print Rewriting IndCall into ICall at $curaddr - - case IndCall() - pre namegen $nam1 $instr.dst.id - pre namegen $nam2 $instr.dst.id - into RPhi(dst(name:$nam1 id:$instr.dst.id inlist:$instr.dst.inlist - nbrin:$instr.dst.nbrin))::ICall(dst(name:$nam2 id:$instr.dst.id)) - post link @2.dst @1.dst - post print Rewriting IndCall into RPhi::ICall at $curaddr - - case TernopRI(rsrc(nbrin:1)) - pre namegen $nam1 $instr.rsrc.id - pre namegen $nam2 $instr.dst.id - into RITernop(isrc:$instr.isrc, rsrc(id:$instr.rsrc.id name:$nam1 inlist:$instr.rsrc.inlist - nbrin:$instr.dst.nbrin) dst(id:$instr.dst.id name:$nam2 - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout)) - post Rewriting TernopRI into RITernop at $curaddr - - case TernopRI() - pre namegen $nam1 $instr.rsrc.id - pre namegen $nam2 $instr.rsrc.id - pre namegen $nam3 $instr.dst.id - into RPhi(dst(name:$nam1 id:$instr.rsrc.id inlist:$instr.rsrc.inlist - nbrin:$instr.rsrc.nbrin)):: - RITernop(isrc:$instr.isrc rsrc(id:$instr.rsrc.id name:$nam2 inlist:$instr.rsrc.inlist - nbrin:$instr.rsrc.nbrin) dst(id:$instr.dst.id name:$nam3 - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout)) - post link @2.rsrc @1.dst - post Rewriting TernopRI into Phi::RITernop at $curaddr - - case BitSet(dst(nbrin:1)) - pre namegen $nam1 $instr.dst.id - into SetBit(dst(name:$nam1 id:$instr.dst.id inlist:$instr.dst.inlist nbrin:1 - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout) src($instr.src)) - post Rewriting BitSet into SetBit at $curaddr - - case BitSet() - pre namegen $nam1 $instr.dst.id - pre namegen $nam2 $instr.dst.id - into RPhi(dst(name:$nam1 id:$instr.dst.id inlist:$instr.dst.inlist - nbrin:$instr.dst.nbrin)) - ::SetBit(src($instr.src) dst(name:$nam2 id:$instr.dst.id - outlist:$instr.dst.outlist nbrout:$instr.dst.nbrout)) - post link @2.dst @1.dst - post Rewriting BitSet into SetBit at $curaddr - - case CmpRI(snd(nbrin:1)) - pre namegen $nam1 $instr.snd.id - into RICmp(snd(name:$nam1 id:$instr.snd.id inlist:$instr.snd.inlist nbrin:1 - outlist:$instr.snd.outlist nbrout:$instr.snd.nbrout) fst($instr.fst)) - post Rewriting CmpRI into RICmp at $curaddr - - case CmpRI() - pre namegen $nam1 $instr.snd.id - pre namegen $nam2 $instr.snd.id - into RPhi(dst(name:$nam1 id:$instr.snd.id inlist:$instr.snd.inlist - nbrin:$instr.snd.nbrin)) - ::RICmp(fst($instr.fst) snd(name:$nam2 id:$instr.snd.id - outlist:$instr.snd.outlist nbrout:$instr.snd.nbrout)) - post link @2.snd @1.dst - post Rewriting BitSet into SetBit at $curaddr - - # Intermediate complicated : memory access - # -> Multiple input operands so nbrin can be > 2 on different operands - case AssignMR(src(base(nbrin:1) nbrin:1)) - pre namegen $nam1 $instr.dst.id - pre namegen $nam2 $instr.src.base.id - pre namegen $nam3 $instr.src.name - into MRAssign(dst(name:$nam1 id:$instr.dst.id nbrout:$instr.dst.nbrout - outlist:$instr.dst.outlist) - src(name:$nam3 base(id:$instr.src.base.id name:$nam2) off:$instr.src.off - nbrin:$instr.src.nbrin inlist:$instr.src.inlist)) - post print Rewriting of AssignMR into MRAssign at $curaddr - - # Phi function inserted on the base register of the memory access - case AssignMR(src(nbrin:1)) - pre namegen $nam1 $instr.src.base.id - pre namegen $nam2 $instr.src.base.id - pre namegen $nam3 $instr.dst.id - pre namegen $nam4 $instr.src.name - into RPhi(dst(name:$nam1 id:$instr.src.base.id inlist:$instr.src.base.inlist - in_nbr:$instr.src.base.nbrin)) - ::MRAssign(dst(name:$nam3 id:$instr.dst.id nbrout:$instr.dst.nbrout - outlist:$instr.dst.outlist) src(name:$nam4 off:$instr.src.off - base(id:$instr.src.base.id name:$nam2))) - post link @2.src.base @1.dst - post print Inserted Phi on base register for AssignMR at $curaddr - - # Phi function inserted on the full memory name - case AssignMR(src(base(nbrin:1))) - pre namegen $nam1 $instr.src.name - pre namegen $nam2 $instr.src.name - pre namegen $nam3 $instr.dst.id - pre namegen $nam4 $instr.src.base.id - pre namegen $nam5 $instr.src.base.id - into MPhi(dst(name:$nam1 base(id:$instr.src.base.id name:$nam4) inlist:$instr.src.inlist - in_nbr:$instr.src.nbrin)) - ::MRAssign(dst(name:$nam3 id:$instr.dst.id nbrout:$instr.dst.nbrout - outlist:$instr.dst.outlist) src(name:$nam2 off:$instr.src.off - base(id:$instr.src.base.id name:$nam5))) - post link @2.src @1.dst - post print Inserted Phi on base register for AssignMR at $curaddr - - # Ici il faut RPhi::MPhi::MRAssign - case AssignMR() - pre namegen $nam1 $instr.src.name - pre namegen $nam2 $instr.src.name - pre namegen $nam3 $instr.src.base.id - pre namegen $nam4 $instr.src.base.id - pre namegen $nam5 $instr.src.base.id - pre namegen $nam6 $instr.dst.id - into MPhi(dst(name:$nam1 base(id:$instr.src.base.id name:$nam3) inlist:$instr.src.inlist - in_nbr:$instr.src.nbrin)) - ::RPhi(dst(name:$nam5 id:$instr.src.base.id inlist:$instr.src.base.inlist - in_nbr:$instr.src.base.nbrin))) - ::MRAssign(dst(name:$nam6 id:$instr.dst.id nbrout:$instr.dst.nbrout - outlist:$instr.dst.outlist) src(name:$nam2 base(id:$instr.src.base.id - name:$nam4) off:$instr.src.off)) - post link @3.src @1.dst - post link @3.src.base @2.dst - post print Inserted MPhi::RPhi for AssignMR at $curaddr - - # TODO - - case CmpRR() - case AssignRM() - case AssignIM() - case TernopR3() - - case _ - post print Unsupported LIR instruction at address $curaddr - - endrwt - - add $curaddr 4 - -eend: endfor - diff -Nru eresi-0.8a25/evarista/.svn/text-base/lir-dataflow.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/lir-dataflow.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/lir-dataflow.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/lir-dataflow.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -#!evarista/evarista32 -# -# Intra-bloc LIR data-flow analysis -# - -reflect $1 - -set $curb $_ -set $curaddr $curb.vaddr - -# Just debug printing -#inspect $curb -#profile enable warn - -# Start the transformation -foreach $instr in $hash[instrlists:$curaddr] - -print Dataflow on instr : $instr - -rewrite $instr into - -case IndBranch() -> . ? use $instr.dst $curb.registry -case Branch() -> . -case IndCall() -> . ? use $instr.dst $curb.registry -case Call() -> . -case Interrupt() -> . -case Return() -> . -case Prolog() -> . -case Epilog() -> . -case Stop() -> . -case Nop() -> . -case TernopR3() -> . ? use $instr.src1 $instr.src2 $curb.registry; def $instr.dst $curb.registry -case TernopRI() -> . ? use $instr.rsrc $curb.registry; def $instr.dst $curb.registry -case AssignIR() -> . ? def $instr.dst $curb.registry -case AssignIM() -> . ? use $instr.dst.base $curb.registry; def $instr.dst.name $curb.registry -case AssignMR() -> . ? use $instr.src.base $instr.src.name $curb.registry; def $instr.dst $curb.registry -case AssignRM() -> . ? use $instr.dst.base $instr.src $curb.registry; def $instr.dst.name $curb.registry -case BitSet() -> . ? def $instr.dst $curb.registry -case CmpRI() -> . ? use $instr.snd $curb.registry -case CmpRR() -> . ? use $instr.fst $instr.snd $curb.registry - -default print Unsupported LIR instruction at address $curaddr - -endrwt - -add $curaddr 4 - -endfor - diff -Nru eresi-0.8a25/evarista/.svn/text-base/lir-definition.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/lir-definition.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/lir-definition.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/lir-definition.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -#!evarista/evarista32 -# -# Definition for the ELIR form -# - -# Attributes for ASM instructions -define b ASM_TYPE_IMPBRANCH -define cb ASM_TYPE_CONDBRANCH -define c ASM_TYPE_CALLPROC -define i ASM_TYPE_INT -define r ASM_TYPE_RETPROC -define p ASM_TYPE_PROLOG -define cmp ASM_TYPE_COMPARISON -define bs ASM_TYPE_BITSET -define a ASM_TYPE_ASSIGN -define wm ASM_TYPE_STORE -define rm ASM_TYPE_LOAD -define e ASM_TYPE_EPILOG -define s ASM_TYPE_STOP -define n ASM_TYPE_NOP -define ar ASM_TYPE_ARITH -define wf ASM_TYPE_WRITEFLAG -define rf ASM_TYPE_READFLAG -define io ASM_TYPE_IO -define sp ASM_TYPE_TOUCHSP - -# Combinations of flags -define i-r i r -define ar-wf ar wf -define ar-wm ar wm -define a-rm a rm -define a-wm a wm -define cmp-wf cmp wf -define io-rm io rm -define io-wm io wm -define i-rf-bt i rf bt -define a-rm-wm a rm wm -define sp-rm sp rm -define sp-rm-wf sp rm wf -define sp-wm-rf sp wm rf -define wm-rm wm rm - -#return 0 - -# Attributes for ASM operands -define reg ASM_OPTYPE_REG -define imm ASM_OPTYPE_IMM -define mem ASM_OPTYPE_MEM - -# Types of LIR operands -type Immed = val:long -type Reg::container = rid:string -type Mem::container = base:Reg off:Immed name:string index:Reg scale:Immed -type Ins = uflags:Immed addr:Immed - -# Types of LIR instructions - -# Control-flow operations -type IndBranchR::Ins = dst:Reg -type IndBranchM::Ins = dst:Mem -type Branch::Ins = dst:Immed -type Call::Ins = dst:Immed -type IndCallR::Ins = dst:Reg -type IndCallM::Ins = dst:Mem -type Interrupt::Ins = dst:Immed -type Return::Ins = dst:Immed - -# Ternary operations -type TernopMI::Ins = dst:Mem msrc:Mem isrc:Immed -type TernopMR::Ins = dst:Mem msrc:Mem rsrc:Reg -type TernopRM::Ins = dst:Reg rsrc:Reg msrc:Mem -type TernopRMI::Ins = dst:Reg rsrc:Reg msrc:Mem isrc:Immed -type TernopR3::Ins = dst:Reg src1:Reg src2:Reg -type TernopM3::Ins = dst:Mem msrc1:Mem msrc2:Mem -type TernopRI::Ins = dst:Reg rsrc:Reg isrc:Immed - -# Assignments -type AssignIR::Ins = dst:Reg src:Immed -type AssignIM::Ins = dst:Mem src:Immed -type AssignMR::Ins = dst:Mem src:Reg -type AssignRM::Ins = dst:Reg src:Mem -type AssignMM::Ins = dst:Mem src:Mem -type AssignRR::Ins = dst:Reg src:Reg - -# Comparisons -type CmpRI::Ins = fst:Immed snd:Reg -type CmpRR::Ins = fst:Reg snd:Reg -type CmpRM::Ins = fst:Mem snd:Reg -type CmpMR::Ins = fst:Reg snd:Mem -type CmpMI::Ins = fst:Immed snd:Mem - -# Other special operations -type XchgRR::Ins = fst:Reg snd:Reg -type XchgMR::Ins = fst:Mem snd:Reg -type Prolog::Ins = framesz:Immed -type BitSet::Ins = src:Immed dst:Reg -type IoRR::Ins = dst:Reg src:Reg -type IoIR::Ins = dst:Immed src:Reg -type IoRI::Ins = dst:Reg src:Immed - -# Types that have no additional info than an instruction -typedef Ins IReturn -typedef Ins FlagR -typedef Ins FlagW -typedef Ins Epilog -typedef Ins Stop -typedef Ins Nop diff -Nru eresi-0.8a25/evarista/.svn/text-base/main.c.svn-base eresi-0.0.20110516/evarista/.svn/text-base/main.c.svn-base --- eresi-0.8a25/evarista/.svn/text-base/main.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* -** main.c for evarista -** -** The entry point of the static analyzer -** -** Started on Fri Jun 22 14:42:36 2007 jfv -** $Id: main.c,v 1.5 2007-07-31 23:30:35 may Exp $ -*/ -#include "evarista.h" - - -/* Prompt related functions for evarista */ -void eva_setup_quit_msg() -{ - char logbuf[BUFSIZ]; - - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - EVARISTA_NAME, REVM_VERSION); - revm_quitmsg_set(logbuf); -} - -void eva_create_prompt(char *buf, u_int size) -{ - snprintf(buf, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - revm_colorget("%s", "psname" , EVARISTA_SNAME), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", REVM_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", REVM_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", REVM_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->ws.name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -void eva_setup_prompt() -{ - revm_set_prompt(eva_create_prompt); -} - - -/* Print the etrace banner */ -void eva_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - EVARISTA_NAME, - REVM_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - revm_output(logbuf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* The real main function */ -int eva_main(int ac, char **av) -{ - /* Interface tweak */ - eva_setup_quit_msg(); - eva_setup_prompt(); - - revm_setup(ac, av, 0, 0); - if (world.state.revm_mode != REVM_STATE_CMDLINE) - eva_banner_print(av[1]); - - revm_config(EVARISTA_CONFIG); - setup_local_cmdhash(); - revm_output(" [*] Type help for regular commands \n\n"); - return (revm_run(ac, av)); -} - - -/* The main ELFsh routine */ -int main(int ac, char **av) -{ - return (eva_main(ac, av)); -} - - - diff -Nru eresi-0.8a25/evarista/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/evarista/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/evarista/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## - -include ../config.h - -SRC = main.c tables.c -OBJ = $(SRC:.c=.o) -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f -NAME = evarista -NAME32 = evarista32 -NAME64 = evarista64 - -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ -I../libstderesi/include/ \ - -I../libetrace/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ -I../libstderesi/include/ \ - -I../libetrace/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libetrace/ -letrace32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) -L../libstderesi -lstderesi32 \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ - $(KERNSHLIB32) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libetrace/ -letrace64 -L../libstderesi -lstderesi64 \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(KERNSHLIB64) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) \ - $(READLNOPT) - -all : all32 all64 - -all32 : $(OBJ32) - @$(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) - -all64 : $(OBJ64) - @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) - -clean : - @$(RM) $(OBJ) *~ \#* *\# .\#* *.32.o *.64.o - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) $(NAME) $(NAME32) $(NAME64) $(OBJ_DYN) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/evarista/.svn/text-base/sparc2lir.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/sparc2lir.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/sparc2lir.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/sparc2lir.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,153 +0,0 @@ -#!evarista/evarista32 - -# This create on-demand the block instruction list in the eresi runtime - -set $curaddr $1 -set $begaddr $1 -D $curaddr -reflect $curaddr -tables instrlists - -# Start the transformation -foreach $instr of $hash[instrlists:$begaddr] - -print TRANSFORMING instruction -print $instr -#profile enable warn -#quiet - -rewrite $instr into - -# indirect always branch without link -case instr(sem:b, nb_op:1, op1(sem:reg)) -into IndBranchR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) - -# direct always branch (b, bp) -case instr(sem:b, nb_op:1, op1(sem:imm)) -into Branch(addr:$curaddr, dst:Immed($instr.op1.imm)) - -# indirect conditional branch without link -# XXX lacks flag translation -case instr(sem:cb, nb_op:1, op1(sem:reg)) -into IndBranchR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) - -# direct always branch (bcc, bpcc) -# XXX lacks flag translation -case instr(sem:cb, nb_op:1, op1(sem:imm)) -into Branch(addr:$curaddr, dst:Immed($instr.op1.imm)) - -# indirect call (op1 reg) -case instr(sem:c, nb_op:1, op1(sem:reg)) -into IndCallR(addr:$curaddr, dst:Reg(rid:$instr.op1.baser)) - -# direct call (op1 addr) -case instr(sem:c, nb_op:1, op1(sem:imm)) -into Call(addr:$curaddr, dst(val:$instr.op1.imm)) - -# ta* (traps) -case instr(sem:i) -into Interrupt(addr:$curaddr, dst:Immed(val:$instr.op1.imm)) - -# ret, retl -case instr(sem:r) -into Return(addr:$curaddr, dst:Immed(val:$instr.op1.imm)) - -# save -case instr(sem:p) -#profile enable warn -into Prolog(addr:$curaddr) -#varlist instr - -# restore -case instr(sem:e) -into Epilog(addr:$curaddr) - -# illtrap -case instr(sem:s) -into Stop(addr:$curaddr) - -# nop -case instr(sem:n) -into Nop(addr:$curaddr) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = reg) -# XXX: lack flags translation -case instr(sem:ar-wf, nb_op:3, op2(sem:reg)) -into TernopR3(addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name), uflags:$instr.flags) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = immed) -# XXX: lack flags translation -case instr(sem:ar-wf, nb_op:3, op2(sem:imm)) -into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name), uflags:$instr.flags) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 immed) -case instr(sem:ar, nb_op:3, op2(sem:imm)) -into TernopRI(addr:$curaddr, dst(rid:$instr.op1.name), isrc(val:$instr.op2.imm), rsrc(rid:$instr.op3.name)) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 reg) -case instr(sem:ar, nb_op:3, op2(sem:reg)) -into TernopR3(addr:$curaddr, dst(rid:$instr.op1.name), src1(rid:$instr.op2.name), src2(rid:$instr.op3.name)) - -# clrx, clrh, clrb, clr (op1 = reg) -case instr(sem:ar, nb_op:1, op1(sem:reg)) -into AssignIR(addr:$curaddr, dst(rid:$instr.op1.name), src(val:0)) - -# clrx, clrh, clrb, clr (op1 = mem) -case instr(sem:ar-wm, nb_op:1, op1(sem:mem)) -into AssignIM(addr:$curaddr, dst(name:$instr.op1.name base(rid:$instr.op1.name), off(val:$instr.op1.imm)), isrc(val:0)) - -# set(hi) -case instr(sem:a, nb_op:2, op1(sem:reg), op2(sem:imm)) -#profile enable warn -pre print $instr.op2.imm -into AssignIR(addr:$curaddr, dst(rid:$instr.op1.name), src(val:$instr.op2.imm)) - -# btog immed -case instr(sem:ar, nb_op:2, op1(sem:imm)) -into TernopRI(addr:$curaddr, dst:Reg(rid:$instr.op2.name), isrc:Immed(val:$instr.op1.imm), rsrc:Reg(rid:$instr.op2.name)) - -# btog register -case instr(sem:ar, nb_op:2, op1(sem:reg)) -into TernopR3(addr:$curaddr, dst:Reg(rid:$instr.op2.name), src1:Reg(rid:$instr.op1.name), src2:Reg(rid:$instr.op2.name)) - -# ld,ldd,ldub,ldx,lduw,lduh,ldsw,ldsb -case instr(sem:a-rm) -into AssignMR(addr:$curaddr, src(name:$instr.op1.name base(rid:$instr.op1.name), off(val:$instr.op1.imm)), dst(rid:$instr.op2.name)) - -# st,stb,stw,sth,std,stx (src = reg) -case instr(sem:a-wm, op1(sem:reg)) -into AssignRM(addr:$curaddr, src(rid:$instr.op1.name), dst(name:$instr.op2.name base(rid:$instr.op2.name), off(val:$instr.op2.imm))) - -# st,stb,stw,sth,std,stx (src = immed) -case instr(sem:a-wm, op1(sem:imm)) -into AssignIM(addr:$curaddr, src(val:$instr.op1.imm), dst(name:$instr.op2.name base(rid:$instr.op2.name), off(val:$instr.op2.imm))) - -# bset (op1 immed) -case instr(sem:bs, op1(sem:imm)) -into BitSet(addr:$curaddr, src(val:$instr.op1.imm), dst(rid:$instr.op2.name)) - -# tst (implicit 2e operand = immed 0 !) -case instr(sem:cmp, nb_op:1, op1(sem:reg)) -into CmpRI(addr:$curaddr, snd(rid:$instr.op1.name), fst(val:0)) - -# cmp (op2 register) -case instr(sem:cmp, nb_op:2, op1(sem:reg), op2(sem:reg)) -into CmpRR(addr:$curaddr, fst(rid:$instr.op1.name), snd(rid:$instr.op2.name)) - -# cmp (op2 immed) -case instr(sem:cmp, nb_op:2, op1(sem:reg), op2(sem:imm)) -into CmpRI(addr:$curaddr, snd(rid:$instr.op1.name), snd(val:$instr.op2.imm)) - -# Defaultcase -default print Unsupported instruction at address $curaddr - -rwtend - -print TRANSFORMED instruction: -print $instr - -add $curaddr 4 - -forend - -print diff -Nru eresi-0.8a25/evarista/.svn/text-base/sparc2lir-OLD.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/sparc2lir-OLD.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/sparc2lir-OLD.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/sparc2lir-OLD.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -#!evarista/evarista32 - -# This create on-demand the block instruction list in the eresi runtime - -reflect _start - -profile enable warn - -set $curblock $_ -set $curaddr $curblock.vaddr -set $list[curinstrlist] $instrlists[$curaddr] - -# Just debug -inspect $curblock - -# Start the transformation -transform $list[curinstrlist] into - -print Transforming instruction: $matchme - -# indirect always branch (call, jmpl) -case instr_t(type:b, nb_op:1, op1(content:reg)) -> Branch(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct always branch (b, bp) -case instr_t(type:b, nb_op:1, op1(content:imm)) -> Branch(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# indirect always branch (callcc, jmplcc) -case instr_t(type:cb, nb_op:1, op1(content:reg)) -> Branch(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct always branch (bcc, bpcc) -case instr_t(type:cb, nb_op:1, op1(content:imm)) -> Branch(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# indirect call (op1 reg) -case instr_t(type:c, nb_op:1, op1(content:reg)) -> Call(addr:$curaddr, rdest:Reg(id:$instr.op1.baser), uflags:0) - -# direct call (op1 addr) -case instr_t(type:c, nb_op:1, op1(content:imm)) -> Call(addr:$curaddr, idest:Addr($instr.op1.imm), uflags:0) - -# traps -case instr_t(type:i) -> Interrupt(addr:$curaddr, Immed(val:$instr.op1.imm), uflags:0) - -# return, ret, retl -case instr_t(type:r) -> Return(addr:$curaddr, Immed(val:$instr.op1.imm), uflags:0) - -# rett -case instr_t(type:i-r) -> IReturn(addr:$curaddr, Reg(id:$instr.op1.baser), uflags:0) - -# save -case instr_t(type:p) -> Prolog(addr:$curaddr, uflags:0) - -# restore -case instr_t(type:e) -> Epilog(addr:$curaddr, uflags:0) - -# illtrap -case instr_t(type:s) -> Stop(addr:$curaddr, uflags:0) - -# nop -case instr_t(type:n) -> Nop(addr:$curaddr, uflags:0) - -# inc,dec (op1 = register) -#case instr_t(type:ar-id, nb_op:1, op1(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op1.baser), Immed(id:1), uflags:0) - -# inc,dec (op1 = imm, op2 = reg) -#case instr_t(type:ar-id-wm, nb_op:2, op1(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op2.baser), rsrc(id:$instr.op2.baser), isrc(val:$instr.op1.imm), uflags:0) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = reg) -case instr_t(type:ar-wf, nb_op:3, op2(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op2.baser), rsrc2(id:$instr.op3.baser), uflags:$instr.flags) - -# andcc,subcc,orcc,addcc,inccc,deccc (op2 = immed) -case instr_t(type:ar-wf, nb_op:3, op2(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), isrc1(val:$instr.op2.imm), rsrc1(id:$instr.op3.baser), uflags:$instr.flags) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 immed) -case instr_t(type:ar, nb_op:3, op2(content:imm)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), isrc1(val:$instr.op2.imm), rsrc1(id:$instr.op3.baser), uflags:0) - -# sllx,sll,srl,srlx,add,sub,or,xor,and,sdivx,udivx,sra,srax,mulx (op2 reg) -case instr_t(type:ar, nb_op:3, op2(content:reg)) -> Ternop(addr:$curaddr, dst(id:$instr.op1.baser), rsrc1(id:$instr.op2.baser), rsrc2(id:$instr.op3.baser), uflags:0) - -# clrx, clrh, clrb, clr (op1 = reg) -case instr_t(type:ar, nb_op:1, op1(content:reg)) -> Assign(addr:$curaddr, dst(id:$instr.op1.baser), isrc(val:0), uflags:0) - -# clrx, clrh, clrb, clr (op1 = mem) -case instr_t(type:ar-wm, nb_op:1, op1(content:mem)) -> WMAssign(addr:$curaddr, dst(base(id:$instr.op1.baser), off(val:$instr.op1.imm)), isrc(val:0), uflags:0) - -# btog immed -case instr_t(type:ar, nb_op:2, op1(content:imm)) -> Ternop(addr:$curaddr, Reg(id:$instr.op2.baser), Immed(val:$instr.op1.imm), Reg(id:$instr.op2.baser), uflags:0) - -# btog register -case instr_t(type:ar, nb_op:2, op1(content:reg)) -> Ternop(addr:$curaddr, Reg(id:$instr.op2.baser), Reg(id:$instr.op1.baser), Reg(id:$instr.op2.baser), uflags:0) - -# ld,ldd,ldub,ldx,lduw,lduh,ldsw,ldsb -case instr_t(type:a-rm) -> RMAssign(addr:$curaddr, src(base(id:$instr.op1.baser), off(val:$instr.op1.imm)), rsrc(id:$instr.op2.baser), uflags:0) - -# st,stb,stw,sth,std,stx (src = reg) -case instr_t(type:a-wm, op1(content:reg)) -> WMAssign(addr:$curaddr, rsrc(id:$instr.op1.baser), dst(base(id:$instr.op2.baser), off(val:$instr.op2.imm)), uflags:0) - -# st,stb,stw,sth,std,stx (src = reg) -case instr_t(type:a-wm, op1(content:imm)) -> WMAssign(addr:$curaddr, isrc(val:$instr.op1.imm), dst(base(id:$instr.op2.baser), off(val:$instr.op2.imm)), uflags:0) - -# bset (op1 immed) -case instr_t(type:bs, op1(content:imm)) -> BitSet(addr:$curaddr, fst(val:$instr.op1.imm), snd(id:$instr.op2.baser), uflags:0) - -# tst (implicit 2e operand = immed 0 !) -case instr_t(type:cmp, nb_op:1, op1(content:reg)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), snd:0, uflags:0) - -# cmp (op2 register) -case instr_t(type:cmp, nb_op:2, op1(content:reg), op2(content:reg)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), rsnd(id:$instr.op2.baser), uflags:0) - -# cmp (op2 immed) -case instr_t(type:cmp, nb_op:2, op1(content:reg), op2(content:imm)) -> Cmp(addr:$curaddr, rfst(id:$instr.op1.baser), snd(val:$instr.op2.imm), uflags:0) - -# Defaultcase -default print Unsupported instruction at address $curaddr - -endtrans add $curaddr 4 - diff -Nru eresi-0.8a25/evarista/.svn/text-base/ssi-definition.esh.svn-base eresi-0.0.20110516/evarista/.svn/text-base/ssi-definition.esh.svn-base --- eresi-0.8a25/evarista/.svn/text-base/ssi-definition.esh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/ssi-definition.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -#!evarista/evarista32 -# -# Type definitions for the SSI form -# - -# Types of variables in SSI - -type RVar::container = name:string id:int -#type MVar::container = name:string baseid:int off:int -type MVar::container = name:string base:RVar off:int - -# Types of operations in SSI - -type IGoto::Ins = dst:RVar -type ICall::Ins = dst:RVar -type RITernop::Ins = dst:RVar rsrc:RVar isrc:Immed -type IRAssign::Ins = dst:RVar src:Immed -type SetBit::Ins = src:Immed dst:RVar -type RICmp::Ins = fst:Immed snd:RVar - -type MRAssign::Ins = dst:RVar src:MVar -type RRCmp::Ins = fst:RVar snd:RVar -type RMAssign::Ins = dst:MVar src:RVar -type IMAssign::Ins = dst:MVar src:Immed -type RRRTernop::Ins = dst:RVar src1:RVar src2:RVar - -type RPhi::Ins = dst:RVar -type RSigma::Ins = src:RVar -type MPhi::Ins = dst:MVar -type MSigma::Ins = src:MVar diff -Nru eresi-0.8a25/evarista/.svn/text-base/tables.c.svn-base eresi-0.0.20110516/evarista/.svn/text-base/tables.c.svn-base --- eresi-0.8a25/evarista/.svn/text-base/tables.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/evarista/.svn/text-base/tables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** tables.c for evarista in ERESI -** -** This file contains all command and objects definitions for specific Evarista scripting -** -** Started on Fri Jun 22 07:48:41 2007 jfv -** $Id: tables.c,v 1.3 2007-07-31 03:28:46 may Exp $ -** -*/ -#include "evarista.h" - - -/* Setup the command hash table */ -void setup_local_cmdhash() -{ - - /* Interactive mode / Scripting mode commands */ - //revm_command_add(CMD_SHTRM , (void *) cmd_shtrm , (void *) NULL , 1, HLP_SHTRM); -} diff -Nru eresi-0.8a25/evarista/tables.c eresi-0.0.20110516/evarista/tables.c --- eresi-0.8a25/evarista/tables.c 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/evarista/tables.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,16 +1,20 @@ -/* -** tables.c for evarista in ERESI -** -** This file contains all command and objects definitions for specific Evarista scripting -** -** Started on Fri Jun 22 07:48:41 2007 jfv -** $Id: tables.c,v 1.3 2007-07-31 03:28:46 may Exp $ -** -*/ +/** +* @file evarista/tables.c + * @ingroup evarista + * + * This file contains all command and objects definitions for specific Evarista scripting + * + * Started on Fri Jun 22 07:48:41 2007 jfv + * $Id: tables.c 1397 2009-09-13 02:19:08Z may $ + * + */ #include "evarista.h" -/* Setup the command hash table */ +/** + * Setup the command hash table + * @ingroup evarista + */ void setup_local_cmdhash() { diff -Nru eresi-0.8a25/INSTALL eresi-0.0.20110516/INSTALL --- eresi-0.8a25/INSTALL 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/INSTALL 2011-05-16 11:35:08.000000000 +0000 @@ -1,9 +1,11 @@ How to build the ERESI framework. This includes: -- elfsh, e2dbg, and etrace +- elfsh, e2dbg, etrace, kernsh, evarista and kedbg. - the language interpreter and type system libraries : librevm and libaspect -- analysis libraries : libelfsh, libe2dbg, libedfmt, libasm, and libmjollnir +- analysis libraries : libelfsh, libedfmt, libasm, libkernsh, and libmjollnir +- debugging libraries : libe2dbg and libgdbwrap +- the standard eresi library : libstderesi - the interface library (readline based) : libui You will need openssl headers. Debian users should install openssl-dev. @@ -18,10 +20,13 @@ If you want to test without installing, you need to do : +1. ./configure --enable-testing [--otheropts] +[...] 5. source env.sh from the root directory of the project. This will change your LD_LIBRARY_PATH variable for using uninstalled libraries. - Read each directory README file for more information. + +Have fun! diff -Nru eresi-0.8a25/kedbg/cmd.c eresi-0.0.20110516/kedbg/cmd.c --- eresi-0.8a25/kedbg/cmd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/cmd.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,312 @@ +/** + * @ingroup kedbg +* @file kedbg/cmd.c + */ + +#include "kedbg.h" +#include "interface.h" + +/** + * @ingroup kedbg + */ +static void kedbg_stepandprint(void) +{ + char *instr; + gdbwrap_t *loc = gdbwrap_current_get(); + int off; + char *name; + + gdbwrap_stepi(loc); + kedbg_isrealmode(); + revm_clean(); + gdbwrap_readgenreg(loc); + e2dbg_display(e2dbgworld.displaycmd, e2dbgworld.displaynbr); + name = revm_resolve(world.curjob->curfile, + (eresi_Addr)(uintptr_t) loc->reg32.eip, (elfsh_SAddr *)&off); + instr = alloca(20); + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t)loc->reg32.eip, instr, 20); + revm_instr_display(-1, loc->reg32.eip, 0, 20, name, off, instr); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbg_dump_regs(void) +{ + PROFILER_INQ(); + e2dbg_output(" .:: Registers ::. \n\n"); + kedbg_get_regvars_ia32(); + e2dbg_printregs(); + e2dbg_output("\n"); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +static void kedbg_step_over_bp(eresi_Addr addr) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + elfshbp_t *bp; + char addrchar[20]; + + snprintf(addrchar, sizeof(addrchar), XFMT, addr); + bp = hash_get(&e2dbgworld.bp, addrchar); + + if (bp != NULL) + { + e2dbg_deletebreak(bp); + gdbwrap_stepi(loc); + e2dbg_setbreak(world.curjob->curfile, bp); + } +} + + +/** + * Continue command. + * @ingroup kedbg + */ +int cmd_kedbgcont(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + elfshbp_t *bp; + char addr[20]; + int off; + char *name; + char eip_pos; + + PROFILER_INQ(); + kedbg_set_regvars_ia32(); + kedbg_shipallreg(); + revm_output("[*] Continuing process\n"); + + kedbg_step_over_bp(loc->reg32.eip); + + if (!e2dbgworld.curthread->step) + { + gdbwrap_continue(loc); + if (gdbwrap_is_active(loc)) + { + if (kedbgworld.interrupted) + { + name = revm_resolve(world.curjob->curfile, loc->reg32.eip, + (elfsh_SAddr *) &off); + printf("\n[*] Stopped at %#x <%s + %u>\n", loc->reg32.eip, name, off); + kedbgworld.interrupted = FALSE; + } + else + if (gdbwrap_lastsignal(loc) == SIGTRAP) + { + + if (kedbgworld.offset) + { + eip_pos = offsetof(struct gdbwrap_gdbreg32, eip) / sizeof(ureg32); + kedbg_writereg(eip_pos, loc->reg32.eip - kedbgworld.offset); + } + snprintf(addr, sizeof(addr), XFMT, (eresi_Addr)loc->reg32.eip); + bp = e2dbg_breakpoint_lookup(addr); + if (bp != NULL) + { + revm_clean(); + if (bp->cmdnbr) + e2dbg_display(bp->cmd, bp->cmdnbr); + else + e2dbg_display(e2dbgworld.displaycmd, e2dbgworld.displaynbr); + + name = revm_resolve(world.curjob->curfile, loc->reg32.eip, + (elfsh_SAddr *)&off); + if (!off) + printf("[*] Breakpoint found at %#x <%s>\n", loc->reg32.eip, name); + else + printf("[*] Breakpoint found at %#x <%s + %u>\n", loc->reg32.eip, + name, off); + } + else + printf("[W] SIGTRAP received but not defined.\n"); + } + else + printf("Signal received: %s (IP: %#x) \n", + get_signal(gdbwrap_lastsignal(loc)), loc->reg32.eip); + } + } + else + kedbg_stepandprint(); + + if (!gdbwrap_is_active(loc)) + cmd_quit(); + + kedbg_get_regvars_ia32(); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbgstep(void) +{ + static Bool enable; + + PROFILER_INQ(); + if (enable) + { + kedbg_resetstep(); + revm_output("[*] Disabling stepping\n"); + } + else + { + kedbg_setstep(); + revm_output("[*] Enabling stepping\n"); + } + enable = !enable; + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbgquit(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + gdbwrap_bye(loc); + cmd_quit(); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbgprintivt(void) +{ + uint32_t ivt[256]; + short i; + + PROFILER_INQ(); + kedbg_readmema(NULL, 0, ivt, 256 * sizeof(uint32_t)); + e2dbg_output(" .:: IVT ::. \n\n"); + for (i = 0; i < 256; i++) + { + if (!(i % 8)) + printf("\n0x%02x | ", i); + printf("0x%08x ", ivt[i]); + } + printf("\n\n"); + PROFILER_ROUTQ(0); +} + + +/** + * Wrapper to cmd_disasm, but checks wether we are in realmode or + * not. It will set internal variable in case we change mode. + * @ingroup kedbg + */ +int cmd_kedbgdisasm(void) +{ + PROFILER_INQ(); + kedbg_isrealmode(); + cmd_disasm(); + PROFILER_ROUTQ(0); +} + + +/** + * Hooks all the IVT entries. Since a lot of entries are the same, we + * check before adding the breakpoint on the server side. + * @ingroup kedbg + */ +int cmd_kedbghookivt(void) +{ + char addr[50]; + uint32_t ivt[256]; + u_short ivtinc; + uint32_t finaladdr; + elfshbp_t *bp; + + PROFILER_INQ(); + kedbg_readmema(NULL, 0, ivt, 256 * sizeof(uint32_t)); + for (ivtinc = 0; ivtinc < 256; ivtinc++) + { + finaladdr = (ivt[ivtinc] & 0xFFFF0000) >> 12; + finaladdr += ivt[ivtinc] & 0xFFFF; + finaladdr &= 0xFFFFF; + snprintf(addr, sizeof(addr), XFMT, (eresi_Addr)finaladdr); + bp = hash_get(&e2dbgworld.bp, addr); + + if (bp == NULL && finaladdr != 0x0) + e2dbg_breakpoint_add((eresi_Addr)(uintptr_t) finaladdr); + + } + + printf("[*] Entries of the IVT have been hooked.\n"); + PROFILER_ROUTQ(0); +} + + +/** + * In case you get pissed of with the itrace... + * @ingroup kedbg + */ +void kedbg_itracesigint(int sig) +{ + PROFILER_INQ(); + NOT_USED(sig); + e2dbgworld.curthread->trace = FALSE; + PROFILER_OUTQ(); +} + + +/** + * Do steppig until we reach a known breakpoint. + * @ingroup kedbg + */ +int cmd_kedbgitrace(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + elfshbp_t *bp; + char addr[50]; + + PROFILER_INQ(); + e2dbgworld.curthread->trace = TRUE; + signal(SIGINT, kedbg_itracesigint); + while (e2dbgworld.curthread->trace == TRUE) + { + kedbg_stepandprint(); + snprintf(addr, sizeof(addr), XFMT, (eresi_Addr)loc->reg32.eip); + bp = hash_get(&e2dbgworld.bp, addr); + + if (bp != NULL) + { + e2dbg_deletebreak(bp); + gdbwrap_stepi(loc); + e2dbg_setbreak(world.curjob->curfile, bp); + e2dbgworld.curthread->trace = FALSE; + printf("[*] Breakpoint found at %#x\n", loc->reg32.eip); + } + } + signal(SIGINT, kedbg_sigint); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbgproc(void) +{ + PROFILER_INQ(); + kedbg_isrealmode(); + cmd_proc(); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int cmd_kedbggraph(void) +{ + PROFILER_INQ(); + kedbg_isrealmode(); + cmd_graph(); + PROFILER_ROUTQ(0); +} diff -Nru eresi-0.8a25/kedbg/handlers.c eresi-0.0.20110516/kedbg/handlers.c --- eresi-0.8a25/kedbg/handlers.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/handlers.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,587 @@ +/** +* @file kedbg/handlers.c +** @ingroup kedbg +** @brief Implement kedbg-specific vector handlers. +** +** $Id: handlers.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "kedbg.h" +#include "interface.h" +#include "kedbg.h" +#include "interface.h" + + +/** + * This function emulates the "monitor r cr0" we can send in VMWare to + * check the cr0 register. However, when the server replies, the first + * 0 has to be discarded. + * @ingroup kedbg + */ +static Bool kedbg_isrealmodewmon(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + char reply[100]; + char *ret; + uint8_t i; + static Bool passed; + + PROFILER_INQ(); + ret = gdbwrap_remotecmd(loc, MONITOREMUL); + + if (strlen(ret) > sizeof(reply) || !strstr(ret, CR0STR)) + { + if (passed == FALSE) + printf("If you are in VMWare: Impossible to detect the mode. Upgrade your" + "VMWare version and use the proc to switch manually to" + "protected mode.\n"); + passed = TRUE; + PROFILER_ERRQ("Impossible to determine CPU mode", FALSE); + } + if (gdbwrap_cmdnotsup(loc)) + PROFILER_ROUTQ(FALSE); + + /* We add +1 to discard the first char.*/ + for (i = 0; ret[i] != '\0'; i++) + reply[i] = (char)gdbwrap_atoh(ret + BYTE_IN_CHAR * i + 1, 2); + + + /* Last bit is 0. */ + if (!(gdbwrap_atoh(reply + strlen(reply) - 2, 1) & 0x1)) + { + kedbgworld.pmode = FALSE; + PROFILER_ROUTQ(TRUE); + } + else + { + kedbgworld.pmode = TRUE; + PROFILER_ROUTQ(FALSE); + } +} + + +/** + * When the monitor doesn't work, we inject directly a "mov %cr0, + * %eax" and we check the last bit of %eax. We save the state of all + * the general purpose registers that we restore afterwards. We + * inject the code at address 0x500 to be less intrusive. If we cannot + * access this memory area, it means that we already are un protected + * mode. + * @ingroup kedbg + */ +static Bool kedbg_isrealmodeinject(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + char code[]="\x0f\x20\xc0"; + gdbwrap_gdbreg32 regs; + + PROFILER_INQ(); + + kedbg_writemem(NULL, MEMINJECT, code, strlen(code)); + + if (gdbwrap_erroroccured(loc)) + { + kedbgworld.pmode = TRUE; + PROFILER_ROUTQ(kedbgworld.pmode); + } + + memcpy(®s, &loc->reg32, sizeof(regs)); + kedbg_writereg(offsetof(gdbwrap_gdbreg32, eip) / sizeof(ureg32), MEMINJECT); + gdbwrap_stepi(loc); + gdbwrap_readgenreg(loc); + if (loc->reg32.eax & 0x1) + kedbgworld.pmode = TRUE; + else + kedbgworld.pmode = FALSE; + + memcpy(&loc->reg32, ®s, sizeof(regs)); + gdbwrap_shipallreg(loc); + + PROFILER_ROUTQ(kedbgworld.pmode); +} + +/** + * @ingroup kedbg + */ +Bool kedbg_isrealmode(void) +{ + static u_char choice = 0; + static Bool first_time = TRUE; + gdbwrap_t *loc = gdbwrap_current_get(); + Bool ret; + + PROFILER_INQ(); + + /* If we are not running in a VM, we've nothing to do here. */ + if (kedbgworld.state != KEDBG_VM) + { + asm_ia32_switch_mode(&world.proc_ia32, INTEL_PROT); + PROFILER_ROUTQ(FALSE); + } + + do + { + switch (choice) + { + case 0: + ret = kedbg_isrealmodewmon(); + if (gdbwrap_cmdnotsup(loc)) + { + if (first_time == TRUE) + choice++; + else + goto exit; + } + break; + + case 1: + ret = kedbg_isrealmodeinject(); + if (gdbwrap_cmdnotsup(loc)) + { + if (first_time == TRUE) + choice++; + else + goto exit; + } + break; + + default: + fprintf(stderr, "Impossible to determine the mode.\n"); + break; + } + } while (gdbwrap_cmdnotsup(loc)); + + exit: + if (kedbgworld.pmode == TRUE) + asm_ia32_switch_mode(&world.proc_ia32, INTEL_PROT); + + first_time = FALSE; + + PROFILER_ROUTQ(ret); +} + +/** + * @ingroup kedbg + */ +void kedbg_resetstep(void) +{ + PROFILER_INQ(); + e2dbgworld.curthread->step = FALSE; + + PROFILER_OUTQ(); +} + + +/** + * @ingroup kedbg + */ +void kedbg_setstep(void) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + e2dbgworld.curthread->step = TRUE; + + PROFILER_OUTQ(); +} + +/** + * @ingroup kedbg + */ +void *kedbg_bt_ia32(void *frame) +{ + la32 ptr = 0; + + PROFILER_INQ(); + + if (kedbg_isrealmode()) + kedbg_readmema(NULL,(eresi_Addr)(uintptr_t)frame, &ptr, WORD_IN_BYTE); + else + kedbg_readmema(NULL,(eresi_Addr)(uintptr_t)frame, &ptr, DWORD_IN_BYTE); + + PROFILER_ROUTQ((void *)ptr); +} + +/** + * @ingroup kedbg + */ +eresi_Addr *kedbg_getfp(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + /* First update all the reg. */ + gdbwrap_readgenreg(loc); + PROFILER_ROUTQ((eresi_Addr *)loc->reg32.ebp); +} + +/** + * @ingroup kedbg + */ +void *kedbg_getret_ia32(void *frame) +{ + la32 ptr = 0; + + PROFILER_INQ(); + if (kedbg_isrealmode()) + kedbg_readmema(NULL, (la32)((la32 *)frame + 1), &ptr, WORD_IN_BYTE); + else + kedbg_readmema(NULL, (la32)((la32 *)frame + 1), &ptr, DWORD_IN_BYTE); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (void *)ptr); +} + +/** + * @ingroup kedbg + */ +static int kedbg_simplesetbp(elfshobj_t *f, elfshbp_t *bp) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + NOT_USED(f); + gdbwrap_simplesetbp(loc, bp->addr); + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +static int kedbg_setbpwint3(elfshobj_t *f, elfshbp_t *bp) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + NOT_USED(f); + gdbwrap_setbp(loc, bp->addr, bp->savedinstr); + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int kedbg_setbp(elfshobj_t *f, elfshbp_t *bp) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + static u_char choice ; + static Bool first_time = TRUE; + + PROFILER_INQ(); + do + { + switch (choice) + { + case 0: + kedbg_simplesetbp(f, bp); + kedbgworld.offset = 0; + if (gdbwrap_cmdnotsup(loc)) + { + if (first_time == TRUE) + choice++; + else + goto exit; + } + break; + + case 1: + kedbg_setbpwint3(f, bp); + kedbgworld.offset = 1; + if (gdbwrap_cmdnotsup(loc)) + { + if (first_time == TRUE) + choice++; + else + goto exit; + } + break; + + default: + /* Should not occur */ + PROFILER_ERRQ("Bp not supported", -1); + } + } while (gdbwrap_cmdnotsup(loc)); + + exit: + first_time = FALSE; + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +static int kedbg_delbpwint3(elfshbp_t *bp) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + gdbwrap_delbp(loc, bp->addr, bp->savedinstr); + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +static int kedbg_simpledelbp(elfshbp_t *bp) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + gdbwrap_simpledelbp(loc, bp->addr); + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int kedbg_delbp(elfshbp_t *bp) +{ + PROFILER_INQ(); + + if (!kedbgworld.offset) + kedbg_simpledelbp(bp); + else if (kedbgworld.offset == 1) + kedbg_delbpwint3(bp); + else + ASSERT(FALSE); + + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +void kedbg_print_reg(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + gdbwrap_gdbreg32 *reg; + + PROFILER_INQ(); + reg = &loc->reg32; + e2dbg_register_dump("EAX", reg->eax); + e2dbg_register_dump("EBX", reg->ebx); + e2dbg_register_dump("ECX", reg->ecx); + e2dbg_register_dump("EDX", reg->edx); + e2dbg_register_dump("ESI", reg->esi); + e2dbg_register_dump("EDI", reg->edi); + e2dbg_register_dump("ESP", reg->esp); + e2dbg_register_dump("EBP", reg->ebp); + e2dbg_register_dump("EIP", reg->eip); + e2dbg_register_dump("EFLAGS", reg->eflags); + e2dbg_register_dump("CS", reg->cs); + e2dbg_register_dump("DS", reg->ds); + e2dbg_register_dump("SS", reg->ss); + e2dbg_register_dump("ES", reg->es); + e2dbg_register_dump("FS", reg->fs); + e2dbg_register_dump("GS", reg->gs); + + PROFILER_OUTQ(); +} + +/** + * @ingroup kedbg + */ +void kedbg_sigint(int sig) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + NOT_USED(sig); + gdbwrap_ctrl_c(loc); + fflush(stdout); + kedbgworld.interrupted = TRUE; + PROFILER_OUTQ(); +} + + +/** + * Reads the content of the memory and returns it as binary. + * @ingroup kedbg + */ +void *kedbg_readmema(elfshobj_t *file, eresi_Addr addr, + void *buf, u_int size) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + char *ret; + char *charbuf = buf; + u_int i; + + PROFILER_INQ(); + NOT_USED(file); + + if (size) + { + if (buf == NULL) + PROFILER_ERRQ("buf is NULL !", buf); + ASSERT(buf != NULL); + ret = gdbwrap_readmem(loc, addr, size); + + /* gdbserver sends a string, we need to convert it. Note that 2 + characters = 1 real Byte.*/ + for (i = 0; i < size; i++) + charbuf[i] = (u_char) gdbwrap_atoh(ret + 2 * i, 2); + } + + PROFILER_ROUTQ(charbuf); +} + +/** + * @ingroup kedbg + */ +void *kedbg_readmem(elfshsect_t *sect) +{ + void *ptr; + + PROFILER_INQ(); + if(!elfsh_get_section_writableflag(sect->shdr) || + !elfsh_get_section_allocflag(sect->shdr)) + ptr = sect->data; + else + { + ptr = malloc(sect->shdr->sh_size); + kedbg_readmema(sect->parent, sect->shdr->sh_addr, ptr, + sect->shdr->sh_size); + } + + PROFILER_ROUTQ(ptr); +} + +/** + * @ingroup kedbg + */ +int kedbg_writemem(elfshobj_t *file, eresi_Addr addr, void *data, + u_int size) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + NOT_USED(file); + PROFILER_INQ(); + gdbwrap_writemem(loc, addr, data, size); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +eresi_Addr *kedbg_getpc_ia32(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + /* First update all the reg. */ + gdbwrap_readgenreg(loc); + PROFILER_ROUTQ((eresi_Addr *)&loc->reg32.eip); +} + + +/** + * We first sync the registers with the server, then we write the new + * set ones. They'll be sent to the server when we'll do a "cont". + * @ingroup kedbg + */ +void kedbg_set_regvars_ia32(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + gdbwrap_gdbreg32 *reg; + + PROFILER_INQ(); + reg = gdbwrap_readgenreg(loc); + if (reg != NULL) + { + + E2DBG_SETREG(E2DBG_EAX_VAR, reg->eax); + E2DBG_SETREG(E2DBG_EBX_VAR, reg->ebx); + E2DBG_SETREG(E2DBG_ECX_VAR, reg->ecx); + E2DBG_SETREG(E2DBG_EDX_VAR, reg->edx); + E2DBG_SETREG(E2DBG_ESI_VAR, reg->esi); + E2DBG_SETREG(E2DBG_EDI_VAR, reg->edi); + E2DBG_SETREG(E2DBG_SP_VAR, reg->esp); + E2DBG_SETREG(E2DBG_FP_VAR, reg->ebp); + E2DBG_SETREG(E2DBG_PC_VAR, reg->eip); + } + PROFILER_OUTQ(); +} + +/** + * @ingroup kedbg + */ +void kedbg_get_regvars_ia32(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + gdbwrap_readgenreg(loc); + + + E2DBG_GETREG(E2DBG_EAX_VAR, loc->reg32.eax); + E2DBG_GETREG(E2DBG_EBX_VAR, loc->reg32.ebx); + E2DBG_GETREG(E2DBG_ECX_VAR, loc->reg32.ecx); + E2DBG_GETREG(E2DBG_EDX_VAR, loc->reg32.edx); + E2DBG_GETREG(E2DBG_ESI_VAR, loc->reg32.esi); + E2DBG_GETREG(E2DBG_EDI_VAR, loc->reg32.edi); + E2DBG_GETREG(E2DBG_SP_VAR, loc->reg32.esp); + //E2DBG_GETREG(E2DBG_SSP_VAR, loc->reg32.eax); + E2DBG_GETREG(E2DBG_FP_VAR, loc->reg32.ebp); + E2DBG_GETREG(E2DBG_PC_VAR, loc->reg32.eip); + PROFILER_OUTQ(); +} + +/** + * @ingroup kedbg + */ +void kedbg_shipallreg(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + static Bool activated = TRUE; + + if (activated) + { + gdbwrap_shipallreg(loc); + if (gdbwrap_erroroccured(loc)) + { + fprintf(stderr, "Desactivating the set registers" + "(not supported by the server).\n"); + activated = FALSE; + } + } +} + +/** + * @ingroup kedbg + */ +int kedbg_writereg(ureg32 regNum, la32 val) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_INQ(); + gdbwrap_writereg(loc, regNum, val); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +eresi_Addr kedbg_realmode_memalloc(u_int size, u_int prot) +{ + char *ret = alloca(size + 1); + eresi_Addr addr = 0x504; + u_int i; + u_int result = 0; + + NOT_USED(prot); + PROFILER_INQ(); + do + { + kedbg_readmema(NULL, addr, ret, size); + for (i = 0; i < size; i++) + result += ret[i]; + if (result) + addr += size; + } while (result && addr < 0xffff0); + + if (!result) + PROFILER_ROUTQ(addr); + else + PROFILER_ROUTQ(ELFSH_INVALID_ADDR); +} diff -Nru eresi-0.8a25/kedbg/include/interface.h eresi-0.0.20110516/kedbg/include/interface.h --- eresi-0.8a25/kedbg/include/interface.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/include/interface.h 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,47 @@ +/** +* @file kedbg/include/interface.h + * @ingroup kedbg + */ + + +#include +#include "revm.h" +#include "libe2dbg.h" + +/* Commands */ +int cmd_com1(void); +int cmd_kedbgcont(void); +int cmd_kedbg_dump_regs(void); +int cmd_kedbgprintivt(void); + +/* #include "gdbwrapper.h" */ +int gdbwrap_simpleconnect(char *host, int port); +eresi_Addr *kedbg_getfp(void); +void *kedbg_bt_ia32(void *frame); +void *kedbg_getret_ia32(void *frame); +void kedbg_setstep(void); +void kedbg_resetstep(void); +int kedbg_setbp(elfshobj_t *f, elfshbp_t *bp); +int kedbg_delbp(elfshbp_t *bp); +void *kedbg_readmema(elfshobj_t *file, eresi_Addr addr, + void *buf, unsigned size); +int kedbg_writemem(elfshobj_t *file, eresi_Addr addr, void *data, + unsigned size); +void *kedbg_readmem(elfshsect_t *base); +eresi_Addr *kedbg_getpc_ia32(void); +void kedbg_set_regvars_ia32(void); +void kedbg_get_regvars_ia32(void); +void kedbg_print_reg(void); +void kedbg_sigint(int sig); +void kedbg_continue(void); +void kedbg_shipallreg(void); +int kedbg_writereg(ureg32 regNum, la32 val); +Bool kedbg_isrealmode(void); +eresi_Addr kedbg_realmode_memalloc(u_int sizem, u_int prot); + +/* Miscellaneous functions. */ +char *kedbg_getstr(void *addr, char *buf, unsigned maxsize); + + +/* Linkmap related functions */ +elfshlinkmap_t *kedbg_linkmap_getaddr(void); diff -Nru eresi-0.8a25/kedbg/include/kedbg.h eresi-0.0.20110516/kedbg/include/kedbg.h --- eresi-0.8a25/kedbg/include/kedbg.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/include/kedbg.h 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,81 @@ +/** + * @defgroup kedbg kedbg: The ERESI kernel debugger. + */ +/** +* @file kedbg/include/kedbg.h + * @brief The kernel ERESI debugger header file. + * @ingroup kedbg + */ + +#if !defined(__KEDBG_H__) + #define __KEDBG_H__ + +#include "libe2dbg.h" +#include "libasm-int.h" +#include "gdbwrapper.h" +#include "interface.h" + +#define ERROR_CONNECTION "problem when connecting... exiting\n" +#define USAGE "Usage: ./netgdb <[server]:port> \n" +#define KEDBGNAME "kedbg" +/* The commands are for internal debuging purpose. */ +#define COM1 "youpla" +#define HELPCOM1 "Not much to say..." + +#define CMD_IVT "ivt" +#define CMD_HOOKIVT "ivthook" + +#define HLP_IVT "Displays the IVT of the remote VM" +#define HLP_HOOKIVT "Adds breakpoints to all addresses defined in the IVT" + +/* State definitions */ +#define KEDBG_USERLAND 0 +#define KEDBG_VM 1 +#define KEDBG_EMBEDDED 2 + +/* Various defined values */ +#define KERBASEADDR 0xc0000000 +#define BPCODE 0xcc +#define MEMINJECT 0x500 +#define CR0STR "637230" +#define MONITOREMUL "r cr0" + + +/* Debug flags */ +#define __DEBUG_KEDBG__ FALSE + +#if __DEBUG_KEDBG__ +#define DEBUGMSG(_command) \ +do \ +{ \ + _command; \ +} while(0) +#else +#define DEBUGMSG(_command) +#endif + +typedef struct +{ + /* Offset for the bp (see cmd_kedbgcont). */ + u_char offset; + Bool interrupted; + u_char state; + Bool pmode; +} kedbgworld_t; + +extern kedbgworld_t kedbgworld; +void kedbg_register_command(void); +void kedbg_register_vector(void); +int cmd_linkmap(void); +int e2dbg_linkmap_load(char *name); +int cmd_com1(void); +int cmd_kedbgcont(void); +int cmd_kedbgstep(void); +int cmd_kedbgquit(void); +int cmd_kedbgdisasm(void); +int cmd_kedbghookivt(void); +int cmd_kedbgitrace(void); +int cmd_kedbgproc(void); +int cmd_kedbggraph(void); + +#endif diff -Nru eresi-0.8a25/kedbg/main.c eresi-0.0.20110516/kedbg/main.c --- eresi-0.8a25/kedbg/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/main.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,400 @@ +/** +* @file kedbg/main.c + * @ingroup kedbg + */ + +#include "kedbg.h" + +kedbgworld_t kedbgworld; + + +/**************** Main stuff ****************/ +static void kedbg_create_prompt(char *buf, u_int size) +{ + snprintf(buf, size - 1, + "%s%s%s%s%s%s%s%s%s%s%s ", + revm_colorget("%s", "pspecial", "("), + revm_colorget("%s", "psname" , KEDBGNAME), + revm_colorget("%s", "pspecial", "-"), + revm_colorget("%s", "pversion", REVM_VERSION), + revm_colorget("%s", "pspecial", "-"), + revm_colorget("%s", "prelease", REVM_RELEASE), + revm_colorget("%s", "pspecial", "-"), + revm_colorget("%s", "pedition", REVM_EDITION), + revm_colorget("%s", "pspecial", "@"), + revm_colorget("%s", "psname", world.curjob->ws.name), + revm_colorget("%s", "pspecial", ")")); + revm_endline(); +} + + +/** + * Only called when running a monothread program + * @return + * @ingroup kedbg + */ +static int kedbg_curthread_init(void) +{ + e2dbgthread_t *new; + char *key; + gdbwrap_t *loc = gdbwrap_current_get(); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + XALLOC(__FILE__, __FUNCTION__, __LINE__, new, sizeof(e2dbgthread_t), -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, key, 15, -1); + snprintf(key, 15, "%u", (u_int) getpid()); + new->tid = 0; + new->entry = (void *) e2dbgworld.real_main; + new->initial = 1; + new->context = (ucontext_t *)loc; + time(&new->stime); + hash_add(&e2dbgworld.threads, key, new); + e2dbgworld.curthread = new; + e2dbgworld.threadnbr = 1; + e2dbgworld.curthread->stacksize = 0xffffffff; + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @ingroup kedbg + */ +static void kedbg_find_linkmap(void) +{ + elfshlinkmap_t linkmap_copy; + elfshlinkmap_t *linkmap_addr; + char lmstring[300]; + elfshobj_t *actual; + char **keys; + int keynbr; + int i; + char *base1; + char *base2; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + e2dbgworld.syms.map = kedbg_linkmap_getaddr(); + world.curjob->curfile->linkmap = e2dbgworld.syms.map; + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t) e2dbgworld.syms.map, + &linkmap_copy, sizeof(elfshlinkmap_t)); + + /* Let's take the first entry, by following the prev. */ + while (linkmap_copy.lprev != NULL) + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t) linkmap_copy.lprev, + &linkmap_copy, sizeof(elfshlinkmap_t)); + + /* And now, we read all the entries from the first one. */ + do + { + /* We read 40B at a time. It'll accelerate the boot. */ + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t) linkmap_copy.lname, + lmstring, 40); + DEBUGMSG(fprintf(stderr, "linkmap->lnext: %p, linkmap->laddr: %#x, " + "lmstring: %s\n", linkmap_copy.lnext, + linkmap_copy.laddr, lmstring)); + + if (lmstring != NULL && lmstring[0] != '\0') + { + for (i = 0; i < keynbr; i++) + { + actual = hash_get(&world.curjob->loaded, keys[i]); + if (!actual) + continue; + base1 = revm_basename(lmstring); + base2 = revm_basename(actual->name); + if (!strcmp(base1, base2)) + { + XALLOC(__FILE__, __FUNCTION__, __LINE__, + actual->linkmap, sizeof(linkmap_copy), ); + memcpy(actual->linkmap, &linkmap_copy, sizeof(linkmap_copy)); + actual->rhdr.base = linkmap_copy.laddr; + + DEBUGMSG(fprintf(stderr, "file->name: %s, is gonna take " + "the base addr: %#x\n\n", actual->name, + actual->rhdr.base)); + break; + } + } + } + linkmap_addr = linkmap_copy.lnext; + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t) linkmap_copy.lnext, + &linkmap_copy, sizeof(elfshlinkmap_t)); + + } while (linkmap_copy.lnext != NULL); + hash_free_keys(keys); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** + * Propagate the hostype and iotype to all loaded files. + * @ingroup kedbg + */ +static void kedbg_propagate_type(void) +{ + int keynbr; + char **keys; + int index; + elfshobj_t *actual; + + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + for (index = 0; index < keynbr; index++) + { + actual = hash_get(&world.curjob->loaded, keys[index]); + actual->hostype = ELFSH_HOST_GDB; + actual->iotype = ELFSH_IOTYPE_GDBPROT; + } + hash_free_keys(keys); +} + + +/** + * Load the BIOS map + * @ingroup kedbg + */ +static void kedbg_biosmap_load() +{ + elfshobj_t *file; + + file = elfsh_create_obj("BIOS", 0, 0x100000, EM_386, ET_EXEC, + ELFDATA2LSB, ELFCLASS32); + world.curjob->curfile = file; + hash_add(&world.curjob->loaded, file->name, file); + file->loadtime = time(&file->loadtime); + file->iotype = ELFSH_IOTYPE_GDBPROT; + file->hostype = ELFSH_HOST_GDB; + file->id = ++world.state.lastid; +} + + +/** + * If the symbol __ksymtab is found in the file we are analyzing, then + * we are analyzing a kernel. + * @ingroup kedbg + */ +static Bool kedbg_file_is_kernel(elfshobj_t *file) +{ + elfshsect_t *textsct; + + textsct = elfsh_get_section_by_name(file, "__ksymtab", NULL, NULL, NULL); + if (textsct != NULL) + return TRUE; + else + return FALSE; +} + + +/** + * If the file has only one segment of 1MB, we have loaded the biosmap. + * @ingroup kedbg + */ +static Bool kedbg_file_is_bios(elfshobj_t *file) +{ + elfsh_Phdr *phdr; + + phdr = elfsh_get_segment_by_type(file, PT_LOAD, 0); + if (phdr == NULL || + phdr->p_memsz != 0x100000 || + !elfsh_segment_is_writable(phdr) || + !elfsh_segment_is_readable(phdr) || + !elfsh_segment_is_executable(phdr)) + return FALSE; + else + return TRUE; +} + +/** + * @ingroup kedbg + */ +static eresi_Addr kedbg_find_entrypoint(elfshobj_t *file) +{ + eresi_Addr addr; + elfshsect_t *textsct; + + textsct = elfsh_get_section_by_name(file, ".text", NULL, NULL, NULL); + //already initialized in librevm + //asm_init_arch(&proc, elfsh_get_archtype(file)); + addr = textsct->shdr->sh_addr; + + DEBUGMSG(fprintf(stderr, "Entry point found: %#x\n", addr)); + + return addr; +} + + +/** + * The got[1] entry is filled in at runtime. The idea is to add a + * breakpoint on the entry point, then "start" and stop when getting + * the SIGTRAP. We don't use the cmd_bp to avoid extra messages that + * might seem suspicious. + * @ingroup kedbg + */ +static void kedbg_run_to_entrypoint(elfshobj_t *file) +{ + + elfshbp_t bp; + gdbwrap_t *loc = gdbwrap_current_get(); + uint8_t eip_pos; + + PROFILER_INQ(); + memset(bp.savedinstr, 0, 16); + bp.addr = kedbg_find_entrypoint(file); + kedbg_setbp(file, &bp); + kedbg_continue(); + kedbg_delbp(&bp); + eip_pos = offsetof(struct gdbwrap_gdbreg32, eip) / sizeof(ureg32); + gdbwrap_writereg(loc, eip_pos, bp.addr); + kedbg_get_regvars_ia32(); + PROFILER_OUTQ(); +} + + +/** + * There is a mapped symbol table in the kernel that we can try to map, + * but its format is awkward. This function is never used for now + * @ingroup kedbg + */ +#if 0 +static int kedbg_ksymtab_fixup() +{ + elfshsect_t *ksymtab; + elfshsect_t *ksymtab_strings; + + PROFILER_INQ(); + ksymtab = elfsh_get_section_by_name(world.curjob->curfile, "__ksymtab", + NULL, NULL, NULL); + ksymtab_strings = elfsh_get_section_by_name(world.curjob->curfile, + "__ksymtab_strings", + NULL, NULL, NULL); + if (!ksymtab_strings || !ksymtab) + PROFILER_ERRQ("[E] Unable to find mapped kernel symtab\n", -1); + elfsh_set_section_type(ksymtab->shdr, SHT_DYNSYM); + elfsh_set_section_type(ksymtab_strings->shdr, SHT_STRTAB); + elfsh_set_section_link(ksymtab->shdr, ksymtab_strings->index); + elfsh_set_section_link(ksymtab_strings->shdr, ksymtab->index); + PROFILER_ROUTQ(0); +} +#endif + + +/** + * Shell related stuff. + * @ingroup kedbg + */ +static int kedbg_main(int argc, char **argv) +{ + int ret; + struct sigaction sa; + + PROFILER_INQ(); + /* The "1" stands for interactive. */ + revm_setup(1, argv, REVM_STATE_INTERACTIVE, REVM_SIDE_CLIENT); + revm_config(".kedbgrc"); + revm_set_prompt(kedbg_create_prompt); + + /* Overwrite of some commands. */ + eresi_commands_init(); + kedbg_register_command(); + hash_init(&e2dbgworld.threads, "threads", 5, ASPECT_TYPE_UNKNOW); + hash_init(&e2dbgworld.bp, "breakpoints", 51, ASPECT_TYPE_UNKNOW); + kedbg_curthread_init(); + e2dbg_setup_hooks(); + kedbg_register_vector(); + ret = revm_file_load(argv[2], 0, NULL); + if (ret) + { + fprintf(stderr, "Wrong file - exiting\n"); + PROFILER_ERRQ("[E] Wrong file - exiting\n", -1); + } + + elfsh_set_runtime_mode(); + e2dbg_presence_set(); + world.curjob->curfile->hostype = ELFSH_HOST_GDB; + world.curjob->curfile->iotype = ELFSH_IOTYPE_GDBPROT; + + /* Put all files as being debugged within a VM */ + kedbg_propagate_type(); + + /* Set as 16b code. */ + asm_ia32_switch_mode(&world.proc_ia32, INTEL_REAL); + + ret = kedbg_file_is_bios(world.curjob->curfile); + if (!kedbg_file_is_kernel(world.curjob->curfile) && !ret) + { + /* The process might already be running. If the got[1] is + filled, we don't run to the entry point. */ + kedbgworld.state = KEDBG_USERLAND; + if (kedbg_linkmap_getaddr() == NULL) + kedbg_run_to_entrypoint(world.curjob->curfile); + kedbg_find_linkmap(); + } + else + { + char **keys; + elfshobj_t *actual; + int keynbr; + + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + actual = hash_get(&world.curjob->loaded, keys[0]); + + world.curjob->curfile->linkmap = E2DBG_ABSENT_LINKMAP; + kedbgworld.state = KEDBG_VM; + kedbg_isrealmode(); + /* If we have not loaded the bios but the kernel, load the BIOS map. */ + if (!ret) + kedbg_biosmap_load(); + } + + /* Signal handler: We want primitives to return EINTR, hence sa_flags = 0. */ + sa.sa_handler = kedbg_sigint; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + sigaction(SIGINT, &sa, NULL); + + revm_run_no_handler(argc, argv); + PROFILER_ROUTQ(0); +} + +/** + * @ingroup kedbg + */ +int main(int argc, char **argv) +{ + int fd; + char *a; + char *b; + + + /* Input checks */ + if (argc != 3) + { + printf(USAGE); + return -1; + } + + a = strtok(argv[1], ":"); + b = strtok(NULL, ":"); + + if (b == NULL) + fd = gdbwrap_simpleconnect("127.0.0.1", atoi(a)); + else + fd = gdbwrap_simpleconnect(a, atoi(b)); + + if (fd == -1) + { + fprintf(stderr, ERROR_CONNECTION); + return -1; + } + + /* Initialize and set the gdbwrap global variable. */ + gdbwrap_current_set(gdbwrap_init(fd)); + + /* Let's say hello to the server, gdbstyle 8) */ + gdbwrap_hello(gdbwrap_current_get()); + + /* Why did it stop ? */ + gdbwrap_reason_halted(gdbwrap_current_get()); + kedbg_get_regvars_ia32(); + kedbg_present_set(); + return kedbg_main(argc, argv); +} diff -Nru eresi-0.8a25/kedbg/Makefile eresi-0.0.20110516/kedbg/Makefile --- eresi-0.8a25/kedbg/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/Makefile 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,96 @@ +## +## Makefile for kedbg in ERESI +## +## Started on Tue Aug 16 06:32:29 2005 jfv +## $Id: Makefile 1405 2010-03-30 22:31:27Z thorkill $ +## + +include ../config.h + +SRC = main.c handlers.c cmd.c misc.c register.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CC ?= gcc +RM = rm -f +DBGNAME32 = kedbg32 +DBGNAME64 = kedbg64 + +CFLAGS32 += -fPIC -g3 -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ + -I../libgdbwrap/include/ \ + -I../libaspect/include/ \ + -I../librevm/include/ \ + -I../libelfsh/include/ \ + -I../libedfmt/include/ \ + -I../libasm/include/ \ + -I../libui/include/ \ + -I../libmjollnir/include/ \ + -I../libe2dbg/include/ \ + -I../libstderesi/include \ + -I../libetrace/include/ \ + -DERESI32 -DJEDBG -DKEDBG + +LDFLAGS32 += -L../libstderesi/ -lstderesi32 \ + -L../librevm/ -lrevm32 \ + -L../libedfmt/ -ledfmt32 \ + -L../libelfsh/ -lelfsh32 \ + -L../libetrace/ -letrace32 \ + -L/usr/pkg/lib/ \ + -L../libmjollnir/ -lmjollnir32 -lcrypto $(DLOPT) \ + -L../libetrace -letrace32 $(LPTHREAD) \ + -L../libasm/ -lasm32 $(LDUIOPT32) -g3 $(STATOPT) \ + -L../libaspect/ -laspect32 \ + -L../libgdbwrap/ -lgdbwrap32 \ + -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) \ + ../libe2dbg/common/libe2dbg-common32.o + +CFLAGS64 += -fPIC -g3 -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ + -I../libgdbwrap/include/ \ + -I../libaspect/include/ \ + -I../librevm/include/ \ + -I../libelfsh/include/ \ + -I../libedfmt/include/ \ + -I../libasm/include/ \ + -I../libui/include/ \ + -I../libmjollnir/include/ \ + -I../libe2dbg/include/ \ + -I../libstderesi/include \ + -I../libetrace/include/ \ + -DERESI64 -DJEDBG -DKEDBG + +LDFLAGS64 += -L../libstderesi/ -lstderesi64 \ + -L../librevm/ -lrevm64 \ + -L../libedfmt/ -ledfmt64 \ + -L../libelfsh/ -lelfsh64 \ + -L../libetrace/ -letrace64 \ + -L/usr/pkg/lib/ \ + -L../libmjollnir/ -lmjollnir64 -lcrypto $(DLOPT) \ + -L../libetrace -letrace64 $(LPTHREAD) \ + -L../libasm/ -lasm64 $(LDUIOPT32) -g3 $(STATOPT) \ + -L../libaspect/ -laspect64 \ + -L../libgdbwrap/ -lgdbwrap64 \ + -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ + $(LDDUMPOPT64) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(READLNOPT) \ + ../libe2dbg/common/libe2dbg-common64.o + +all : all32 all64 + +all32 : ${OBJ32} + $(CC) $(OBJ32) $(LDFLAGS32) -o $(DBGNAME32) + +all64 : ${OBJ64} + $(CC) $(OBJ64) $(LDFLAGS64) -o $(DBGNAME64) + +clean : + $(RM) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + $(RM) include/*~ include/\#* include/*\# include/.\#* + +fclean : clean + $(RM) $(DBGNAME32) $(DBGNAME64) + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< + + diff -Nru eresi-0.8a25/kedbg/misc.c eresi-0.0.20110516/kedbg/misc.c --- eresi-0.8a25/kedbg/misc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/misc.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,72 @@ +/* +* @file kedbg/misc.c +** @ingroup kedbg +** @brief Internal API for KEDBG. +** +** $Id: misc.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "kedbg.h" +#include "interface.h" + +/** + * Retrieve a character string from the remote server. + * @param addr : address to retreive + * @param buf : buffer to write in + */ +char *kedbg_getstr(void *addr, char *buf, unsigned maxsize) +{ + unsigned i = 0; + char c; + + do + { + kedbg_readmema(NULL, (eresi_Addr)(uintptr_t)((char *)addr + i), &c, sizeof(char)); + buf[i] = c; + } while (c != '\0' && ++i <= maxsize); + + return buf; +} + + +elfshlinkmap_t *kedbg_linkmap_getaddr(void) +{ + elfshsect_t *got; + void *data; + elfshlinkmap_t *lm; + got = elfsh_get_gotsct(world.curjob->curfile); + data = elfsh_readmem(got); + lm = (elfshlinkmap_t *)(uintptr_t)(*elfsh_get_got_entry_by_index(data, 1)); + + DEBUGMSG(fprintf(stderr, "Found got[1]: %#x\n", (eresi_Addr)lm)); + return lm; + // kedbg_readmema(NULL, linkmap_entry, &linkmap_copy, sizeof(elfshlinkmap_t)); +} + + +void kedbg_continue(void) +{ + gdbwrap_t *loc = gdbwrap_current_get(); + + gdbwrap_continue(loc); +} + + +/* void *kedbg_linkmap_lnext() */ +/* { */ +/* } */ + + +/* void *kedbg_linkmap_lprev() */ +/* { */ +/* } */ + + +/* void *kedbg_linkmap_laddr() */ +/* { */ +/* } */ + + +/* void *kedbg_linkmap_lname() */ +/* { */ +/* } */ + diff -Nru eresi-0.8a25/kedbg/register.c eresi-0.0.20110516/kedbg/register.c --- eresi-0.8a25/kedbg/register.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/register.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,94 @@ +/* +* @file kedbg/register.c +** @ingroup kedbg +** @brief Implement registration of vector handlers +** +** $Id: register.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "kedbg.h" + +void kedbg_register_command(void) +{ + revm_command_add(CMD_START, cmd_kedbgcont, NULL, 0, HLP_START); + revm_command_add(CMD_CONTINUE, cmd_kedbgcont, NULL, 0, HLP_CONTINUE); + revm_command_add(CMD_CONTINUE2, cmd_kedbgcont, NULL, 0, HLP_CONTINUE); + + /* Debugger only script commands */ + revm_command_add(CMD_MODE, cmd_mode, revm_getvarparams, 0, HLP_MODE); + revm_command_add(CMD_BP, cmd_bp, revm_getvarparams, 0, HLP_BP); + revm_command_add(CMD_BP2, cmd_bp, revm_getvarparams, 0, HLP_BP); + revm_command_add(CMD_DELETE, cmd_delete, revm_getvarparams, 0, HLP_DELETE); + revm_command_add(CMD_LINKMAP, cmd_linkmap, revm_getvarparams, 1, HLP_LINKMAP); + revm_command_add(CMD_GOT, cmd_got, revm_getvarparams, 1, HLP_GOT); + revm_command_add(CMD_DUMPREGS, cmd_kedbg_dump_regs, revm_getvarparams, 0, HLP_DUMPREGS); + revm_command_add(CMD_STEP, cmd_kedbgstep, revm_getvarparams, 0, HLP_STEP); + revm_command_add(CMD_BT, cmd_bt, NULL, 0, HLP_BT); + revm_command_add(CMD_BT2, cmd_bt, NULL, 0, HLP_BT); + revm_command_add(CMD_DISPLAY, cmd_display, revm_getvarparams, 0, HLP_DISPLAY); + revm_command_add(CMD_UNDISPLAY, cmd_undisplay, revm_getvarparams, 0, HLP_UNDISPLAY); + revm_command_add(CMD_RSHT, cmd_rsht, revm_getregxoption, 1, HLP_RSHT); + revm_command_add(CMD_RPHT, cmd_rpht, revm_getregxoption, 1, HLP_RPHT); + revm_command_add(CMD_QUIT, cmd_kedbgquit, NULL, 0, HLP_QUIT); + revm_command_add(CMD_QUIT2, cmd_kedbgquit, NULL, 0, HLP_QUIT); + revm_command_add(CMD_DISASM, cmd_kedbgdisasm, revm_getdisasm, 0, HLP_DISASM); + revm_command_add(CMD_DISASM2, cmd_kedbgdisasm, revm_getdisasm, 0, HLP_DISASM); + revm_command_add(CMD_HEXA, cmd_kedbgdisasm, revm_gethexa, 1, HLP_HEXA); + revm_command_add(CMD_HEXA2, cmd_kedbgdisasm, revm_gethexa, 1, HLP_HEXA); + revm_command_add(CMD_IVT, cmd_kedbgprintivt, NULL, 0, HLP_IVT); + revm_command_add(CMD_HOOKIVT, cmd_kedbghookivt, NULL, 0, HLP_HOOKIVT); + revm_command_add(CMD_WRITE, cmd_write, revm_getvarparams, 1, HLP_WRITE); + revm_command_add(CMD_PROC, cmd_kedbgproc , NULL, 0, HLP_PROC); + revm_command_add(CMD_GRAPH, cmd_kedbggraph, revm_getvarparams, 1, HLP_GRAPH); + + /* Type related commands */ + revm_command_add(CMD_TYPE , cmd_type , revm_getvarparams, 0, HLP_TYPE); + revm_command_add(CMD_UNION , cmd_type , revm_getvarparams, 0, HLP_TYPE); + revm_command_add(CMD_TYPEDEF , cmd_typedef , revm_getvarparams, 0, HLP_TYPEDEF); + revm_command_add(CMD_INFORM , cmd_inform , revm_getvarparams, 1, HLP_INFORM); + revm_command_add(CMD_UNINFORM , cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); + revm_command_add(CMD_INFORM2 , cmd_inform , revm_getvarparams, 1, HLP_INFORM); + revm_command_add(CMD_UNINFORM2, cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); + + /* Flow analysis commands */ + revm_command_add(CMD_ANALYSE , cmd_analyse , revm_getvarparams, 1, HLP_ANALYSE); + revm_command_add(CMD_UNSTRIP , cmd_unstrip , NULL, 1, HLP_UNSTRIP); + revm_command_add(CMD_GRAPH , cmd_graph , revm_getvarparams, 1, HLP_GRAPH); + revm_command_add(CMD_INSPECT , cmd_inspect , revm_getoption, 1, HLP_INSPECT); + revm_command_add(CMD_FLOWJACK , cmd_flowjack , revm_getoption2, 1, HLP_FLOWJACK); + revm_command_add(CMD_ADDGOTO , cmd_addgoto , revm_getoption2, 1, HLP_ADDGOTO); + revm_command_add(CMD_SETGVL , cmd_setgvl , revm_getoption, 1, HLP_SETGVL); + revm_command_add(CMD_RENAME , cmd_rename , revm_getoption2, 1, HLP_RENAME); + revm_command_add(CMD_CONTROL , cmd_control , NULL, 1, HLP_CONTROL); + + revm_command_add(CMD_ITRACE, cmd_kedbgitrace, NULL, 0, HLP_ITRACE); + /* revm_command_add(CMD_WATCH , (void *) cmd_watch , revm_getvarparams, 1, HLP_WATCH); */ + /* revm_command_add(CMD_STACK , (void *) cmd_stack , revm_getoption, 1, HLP_STACK); */ + /* revm_command_add(CMD_THREADS , (void *) cmd_threads , revm_getvarparams, 1, HLP_THREADS); */ + +} + + +/**************** Vector registration ****************/ +void kedbg_register_vector(void) +{ + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_GDBPROT, kedbg_readmema); + elfsh_register_readmem(ELFSH_OS_LINUX, ELFSH_IOTYPE_GDBPROT, kedbg_readmem); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_GDBPROT, kedbg_writemem); + e2dbg_register_pregshook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, ELFSH_OS_LINUX, + kedbg_print_reg); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, ELFSH_OS_LINUX, + kedbg_getfp); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, ELFSH_OS_LINUX, + kedbg_bt_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, ELFSH_OS_LINUX, + kedbg_getret_ia32); + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, + ELFSH_OS_LINUX, kedbg_set_regvars_ia32); + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, + ELFSH_OS_LINUX, kedbg_get_regvars_ia32); + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, + ELFSH_OS_LINUX, kedbg_getpc_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_HOST_GDB, ELFSH_OS_LINUX, + kedbg_setbp); + e2dbg_register_delbreakhook(ELFSH_HOST_GDB, kedbg_delbp); +} diff -Nru eresi-0.8a25/kedbg/test.c eresi-0.0.20110516/kedbg/test.c --- eresi-0.8a25/kedbg/test.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/kedbg/test.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,30 @@ +#include +#include +#include + +void bar(int num) +{ + fflush(stdout); + printf("bar %u", num); +} + +void foo(int num) +{ + printf("foo %u ", num); + fflush(stdout); + bar(num + 1); +} + +void plop(void) +{ + __asm__ __volatile__("movl $0xff, %eax"); +} + +int main(void) +{ + plop(); + foo(rand()); + puts(""); + sleep(10); + return 0; +} diff -Nru eresi-0.8a25/kernsh/alloc.c eresi-0.0.20110516/kernsh/alloc.c --- eresi-0.8a25/kernsh/alloc.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/alloc.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file alloc.c +* @file kernsh/alloc.c ** @ingroup kernsh -** $Id: alloc.c,v 1.3 2007-11-29 15:33:39 may Exp $ +** $Id: alloc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -13,7 +13,7 @@ { char *param; char buff[BUFSIZ]; - unsigned long addr; + eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -21,11 +21,11 @@ if (param) { if (kernsh_alloc_contiguous(atoi(param), &addr)) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot alloc contiguous memory", -1); - } + { + revm_setvar_int("_", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot alloc contiguous memory", -1); + } memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s %s %s %s %s %s\n\n", @@ -49,7 +49,7 @@ { char *param; char buff[BUFSIZ]; - unsigned long addr; + eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -85,7 +85,7 @@ { char *param; char buff[BUFSIZ]; - unsigned long addr; + eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -121,7 +121,7 @@ { char *param; char buff[BUFSIZ]; - unsigned long addr; + eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -130,7 +130,7 @@ if (param) { addr = strtoul( param, NULL, 16 ); - if(kernsh_free_noncontiguous(addr)) + if (kernsh_free_noncontiguous(addr)) { revm_setvar_int("_", -1); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, diff -Nru eresi-0.8a25/kernsh/autotypes.c eresi-0.0.20110516/kernsh/autotypes.c --- eresi-0.8a25/kernsh/autotypes.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/autotypes.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file autotypes.c +* @file kernsh/autotypes.c ** @ingroup kernsh -** $Id: autotypes.c,v 1.4 2007-11-29 15:33:39 may Exp $ +** $Id: autotypes.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" diff -Nru eresi-0.8a25/kernsh/close.c eresi-0.0.20110516/kernsh/close.c --- eresi-0.8a25/kernsh/close.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/close.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file close.c +* @file kernsh/close.c ** @ingroup kernsh -** $Id: close.c,v 1.4 2007-11-29 15:33:39 may Exp $ +** $Id: close.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -32,9 +32,6 @@ if (hash_size(&libkernshworld.root->parent_hash)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unload parent object first", -1); - if (libkernshworld.root->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You cannot unload a mapped object", -1); ret = revm_unload_dep(libkernshworld.root, libkernshworld.root); if (!world.state.revm_quiet) { diff -Nru eresi-0.8a25/kernsh/doc/.svn/all-wcprops eresi-0.0.20110516/kernsh/doc/.svn/all-wcprops --- eresi-0.8a25/kernsh/doc/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/800/trunk/kernsh/doc -END -kernshrc-2.4.example -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/750/trunk/kernsh/doc/kernshrc-2.4.example -END -kernshrc-2.6.example -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/800/trunk/kernsh/doc/kernshrc-2.6.example -END diff -Nru eresi-0.8a25/kernsh/doc/.svn/entries eresi-0.0.20110516/kernsh/doc/.svn/entries --- eresi-0.8a25/kernsh/doc/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/doc -http://svn.eresi-project.org/svn - - - -2007-10-11T18:25:17.000000Z -800 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -types -dir - -kernshrc-2.4.example -file - - - - -2008-04-06T23:15:42.921892Z -eb123f6c545b5454cd571f4fdcc5b20a -2007-07-31T12:31:54.000000Z -750 -pouik - -kernshrc-2.6.example -file - - - - -2008-04-06T23:15:42.932150Z -5fd4e84f51263c9021694017ffdcc6b2 -2007-10-11T18:25:17.000000Z -800 -pouik - diff -Nru eresi-0.8a25/kernsh/doc/.svn/format eresi-0.0.20110516/kernsh/doc/.svn/format --- eresi-0.8a25/kernsh/doc/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/doc/.svn/text-base/kernshrc-2.4.example.svn-base eresi-0.0.20110516/kernsh/doc/.svn/text-base/kernshrc-2.4.example.svn-base --- eresi-0.8a25/kernsh/doc/.svn/text-base/kernshrc-2.4.example.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/.svn/text-base/kernshrc-2.4.example.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!elfsh - -quiet - -print \x20[*] Load Kernshrc 2.4 - -# My systemmap -# configure libkernsh.systemmap /boot/System.map-2.4.33 - -# Use debug kernel ? -# configure libkernsh.use_kernel 1 - -# Do not use any kernel ? -# configure libkernsh.without_kernel 1 - -# Make all type - -type ksct = sys:long[320] -type kint = off1:short sel:short none:byte flags:byte off2:short -type kidt = idt:kint[256] - -# Open memory -openmem - -# Inform type -inform ksct sys_call_table -inform kidt idt_table diff -Nru eresi-0.8a25/kernsh/doc/.svn/text-base/kernshrc-2.6.example.svn-base eresi-0.0.20110516/kernsh/doc/.svn/text-base/kernshrc-2.6.example.svn-base --- eresi-0.8a25/kernsh/doc/.svn/text-base/kernshrc-2.6.example.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/.svn/text-base/kernshrc-2.6.example.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#!elfsh - -quiet - -print \x20[*] Load Kernshrc 2.6 - -# My systemmap -# configure libkernsh.systemmap /boot/System.map-genkernel-x86-2.6.22.4 - -# Use debug kernel ? -# configure libkernsh.use_kernel 1 - -# Do not use any kernel ? -# configure libkernsh.without_kernel 1 - -type ksct = sys:long[320] -type kint = off1:short sel:short none:byte flags:byte off2:short -type kidt = idt:kint[256] - -# Open memory -openmem - -# Inform type -inform ksct sys_call_table -inform kidt idt_table diff -Nru eresi-0.8a25/kernsh/doc/types/.svn/all-wcprops eresi-0.0.20110516/kernsh/doc/types/.svn/all-wcprops --- eresi-0.8a25/kernsh/doc/types/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/types/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/800/trunk/kernsh/doc/types -END -kernel_2_6_types -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/800/trunk/kernsh/doc/types/kernel_2_6_types -END diff -Nru eresi-0.8a25/kernsh/doc/types/.svn/entries eresi-0.0.20110516/kernsh/doc/types/.svn/entries --- eresi-0.8a25/kernsh/doc/types/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/types/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/doc/types -http://svn.eresi-project.org/svn - - - -2007-10-11T18:25:17.000000Z -800 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kernel_2_6_types -file - - - - -2008-04-06T23:15:42.854900Z -b693f6e02a9ffe1f6af384e197563343 -2007-10-11T18:25:17.000000Z -800 -pouik - diff -Nru eresi-0.8a25/kernsh/doc/types/.svn/format eresi-0.0.20110516/kernsh/doc/types/.svn/format --- eresi-0.8a25/kernsh/doc/types/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/types/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/doc/types/.svn/text-base/kernel_2_6_types.svn-base eresi-0.0.20110516/kernsh/doc/types/.svn/text-base/kernel_2_6_types.svn-base --- eresi-0.8a25/kernsh/doc/types/.svn/text-base/kernel_2_6_types.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/doc/types/.svn/text-base/kernel_2_6_types.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -# Make all type - -type atomic_t = counter:int -#define asm/atomic.h - -type list_head = next:*list_head prev:*list_head -#define linux/list.h - -type prio_array = nr_active:int bitmap:long[5] queue:list_head[140] -#define kernel/sched.c - -type cpumask_t = bits:long[2] -#define linux/cpumask.h - -type mm_struct = entier:int - -type module = entier:int - -type linux_binfmt = next:*linux_binfmt module:*module load_binary:long load_shlib:long core_dump:long min_coredump:long hasvdso:int -#define linux/binfmts.h - -type hlist_node = next:*hlist_node pprev:**hlist_node -#define linux/list.h - -type hlist_head = first:*hlist_node -#define linux/list.h - -type plist_head = prio_list:list_head node_list:list_head -#define linux/plist.h - -type rcu_head = next:*rcu_head func:long -#define linux/rcupdate.h - -type pid = count:atomic_t nr:int pid_chain:hlist_node tasks:hlist_head[3] rcu:rcu_head -#define linux/pid.h - -type pid_link = node:hlist_node pid:*pid -#define linux/pid.h - -type raw_spinlock_t = slock:int -#define linux/spinlock_types_up.h - -type spinlock_t = raw_lock:raw_spinlock_t break_lock:int -#define linux/spinlock_types.h - -type wait_queue_t = flags:int private:*long func:*long task_list:list_head -#define linux/wait.h - -type wait_queue_head_t = lock:spinlock_t task_list:list_head -#define linux/wait.h - -type completion = done:int wait:wait_queue_head_t -#define linux/completion.h - -#type cputime_t = long -#define asm-generic/cputime.h - -#type time_t = long -type timespec = tv_sec:long tv_nsec:long -#define linux/time.h - -type group_info = ngroups:int usage:atomic_t small_block:int[32] nblocks:int blocks:*int -#define linux/sched.h - -type kernel_cap_t = cap:int -#define linux/capability.h - -type user_struct = __count:atomic_t processes:atomic_t files:atomic_t sigpending:atomic_t mq_bytes:long locked_shm:long uidhash_list:list_head uid:int -#define linux/sched.h - -type thread_info = entier:int -#define asm/thread_info.h - -type desc_struct = entier:int - -type i387_union = entier:int - -type vm86_struct = entier:int - -type thread_struct = tls_array:desc_struct[3] esp0:long sysenter_cs:long eip:long esp:long fs:long gs:long debugreg:long[8] cr2:long trap_no:long error_code:long i387:i387_union vm86_info:*vm86_struct screen_bitmap:long v86flags:long v86mask:long saved_esp0:long saved_fs:long saved_gs:long io_bitmap_ptr:*long iopl:long io_bitmap_max:long -#define asm/processor.h - -type rwlock_t = entier:int - -type dentry = entier:int - -type vfsmount = entier:int - -type fs_struct = count:atomic_t lock:rwlock_t umask:int root:*dentry pwd:*dentry altroot:*dentry rootmnt:*vfsmount pwdmnt:*vfsmount altrootmnt:*vfsmount -#define linux/fs_struct.h - -type fdtable = entier:int - -type embedded_fd_set = entier:int - -type file = entier:int - -type files_struct = count:atomic_t fdt:*fdtable fdtab:fdtable ____cacheline_aligned_in_smp:spinlock_t next_fd:int close_on_exec_init:embedded_fd_set open_fds_init:embedded_fd_set fd_array:*file[32] -#define linux/file.h - -type uts_namespace = entier:int -type ipc_namespace = entier:int -type mnt_namespace = entier:int -type pid_namespace = entier:int - -type nsproxy = count:atomic_t nslock:spinlock_t uts_ns:*uts_namespace ipc_ns:*ipc_namespace mnt_ns:*mnt_namespace pid_ns:*pid_namespace -#define linux/nsproxy.h - -type sigpending = entier:int - -type signal_struct = count:atomic_t live:atomic_t wait_chldexit:wait_queue_head_t curr_target:*task_struct shared_pending:sigpending group_exit_code:int group_exit_task:*task_struct notify_count:int group_stop_count:int flags:int posix_timers:list_head -#define linux/sched.h NOT FINISH - -type __sighandler_t = entier:int - -type __sigrestore_t = entier:int - -type sa_mask = entier:int - -type sigset_t = entier:int - -type sigaction = sa_handler:__sighandler_t sa_flags:long sa_restorer:__sigrestore_t sa_mask:sigset_t -#define asm/signal.h - -type k_sigaction = sa:sigaction -#define asm/signal.h - -type sighand_struct = count:atomic_t action:k_sigaction[64] siglock:spinlock_t -#define linux/sched.h - -type audit_context = entier:int - -type seccomp_t = mode:int -#define linux/seccomp.h - -type reclaim_state = reclaimed_slab:long -#define linux/swap.h - -type backing_dev_info = ra_pages:long state:long capabilities:int congested_fn:*long congested_data:*long unplug_io_fn:*long unplug_io_data:*long -#define linux/backing-dev.h - -type as_io_context = lock:spinlock_t dtor:*long exit:*long state:long nr_queud:atomic_t nr_dispatched:atomic_t last_end_request:long ttime_total:long ttime_samples:long ttime_mean:long seek_samples:int last_request_pas:long seek_total:long seek_mean:long -#define linux/blkdev.h - -type rb_node = rb_parent_color:long rb_right:*rb_node rb_left:*rb_node -#define linux/rbtree.h - -type rb_root = rb_node:*rb_node -#define linux/rbtree.h - -type io_context = refcount:atomic_t task:*task_struct ioprio_changed:int last_waited:long nr_batch_requests:int aic:*as_io_context cic_root:rb_root -#define linux/blkdev.h - -type siginfo_t = si_signo:int si_errno:int si_code:int -#define asm-generic/siginfo.h NOT FINISH - -type task_io_accounting = read_bytes:long write_bytes:long cancelled_write_bytes:long -#define linux/task_io_accounting.h - -type robust_list = next:*robust_list -#define linux/futex.h - -type robust_list_head = list:robust_list futex_offset:long list_op_pending:*robust_list -#define linux/futex.h - -type rt_mutex = wait_lock:spinlock_t wait_list:plist_head owner:*task_struct -#define linux/rt_mutex.h - -type futex_pi_state = list:list_head pi_mutex:rt_mutex owned:*task_struct refcount:atomic_t key:int -#define kernel/futex.c NOT FINISH - -type page = entier:int - -type fasync_struct = entier:int - -type inode = entier:int - -type pipe_buf_operations = can_merge:int map:*long unmap:*long pin:*long release:*long steal:*long get:*long -#define linux/pipe_fs_i.h - -type pipe_buffer = page:*page offset:int len:int ops:*pipe_buf_operations flags:int -#define linux/pipe_fs_i.h - -type pipe_inode_info = wait:wait_queue_head_t nrbufs:int curbuf:int tmp_page:*page readers:int writers:int waiting_writers:int r_counter:int w_counter:int fasync_readers:*fasync_struct fasync_writers:*fasync_struct inode:*inode bufs:pipe_buffer[16] -#define linux/pipe_fs_i.h - -type task_struct = state:long thread_info:*thread_info usage:atomic_t flags:long ptrace:long lock_depth:int load_weight:int prio:int static_prio:int normal_prio:int run_list:list_head array:*prio_array ioprio:short sleep_avg:long timestamp:long last_ran:long sched_time:long sleep_type:int policy:long cpus_allowed:cpumask_t time_slice:int first_time_slice:int tasks:list_head ptrace_children:list_head ptrace_list:list_head mm:*mm_struct active_mm:*mm_struct binfmt:*linux_binfmt exit_state:long exit_code:int exit_signal:int pdeath_signal:int personality:long did_exec:int pid:int tgid:int real_parent:*task_struct parent:*task_struct children:list_head sibling:list_head group_leader:*task_struct pids:pid_link[3] thread_group:list_head vfork_done:*completion set_child_tid:*int clear_child_tid:*int rt_priority:long utime:long stime:long nvcsw:long nivcsw:long start_time:timespec min_flt:long maj_flt:long if_prof_expires:long it_virt_expires:long it_sched_expires:long cpu_timers:list_head[3] uid:int euid:int suid:int fsuid:int gid:int egid:int sgid:int fsgid:int group_info:*group_info cap_effective:kernel_cap_t cap_inheritable:kernel_cap_t cap_permitted:kernel_cap_t keep_capabilites:int user:*user_struct fpu_counter:byte oomkilladj:int comm:string[16] link_count:int total_link_count:int thread:thread_struct fs:*fs_struct files:*files_struct nsproxy:*nsproxy signal:*signal_struct sighand:*sighand_struct blocked:sigset_t real_blocked:sigset_t saved_sigmask:sigset_t pending:sigpending sas_ss_sp:long sas_ss_size:int notifier:long notifier_data:long notifier_mask:*sigset_t security:*long audit_context:*audit_context seccomp:seccomp_t parent_exec_id:int self_exec_id:int allock_lock:spinlock_t pi_lock:spinlock_t journal_info:*long reclaim_state:*reclaim_state backing_dev_info:*backing_dev_info io_context:*io_context ptrace_message:long last_siginfo:*siginfo_t io_wait:*wait_queue_t ioac:task_io_accounting robust_list:*robust_list_head pi_state_list:list_head pi_state_cache:*futex_pi_state fs_execl:atomic_t rcu:rcu_head splice_pipe:*pipe_inode_info -#define linux/sched.h diff -Nru eresi-0.8a25/kernsh/dump.c eresi-0.0.20110516/kernsh/dump.c --- eresi-0.8a25/kernsh/dump.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/dump.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,5 +1,5 @@ /* -** @file dump.c +* @file kernsh/dump.c ** @ingroup kernsh ** */ @@ -78,15 +78,15 @@ snprintf(buff, sizeof(buff), "Dumped into %s%s%s%s\n\n", - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH)), - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX)), + revm_colorstr((char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH)), + revm_colorstr((char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX)), revm_colorstr("_"), revm_colornumber("%u", atoi(world.curjob->curcmd->param[0]))); revm_output(buff); snprintf(buff, sizeof(buff), "Check the metadata file %s%s%s%s/metadata*\n\n", - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH)), - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX)), + revm_colorstr((char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH)), + revm_colorstr((char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX)), revm_colorstr("_"), revm_colornumber("%u", atoi(world.curjob->curcmd->param[0]))); revm_output(buff); diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/kmodules/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/kmodules/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/921/trunk/kernsh/examples/kmodules -END -example1.ksh -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/921/trunk/kernsh/examples/kmodules/example1.ksh -END -example2.ksh -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/801/trunk/kernsh/examples/kmodules/example2.ksh -END diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/entries eresi-0.0.20110516/kernsh/examples/kmodules/.svn/entries --- eresi-0.8a25/kernsh/examples/kmodules/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples/kmodules -http://svn.eresi-project.org/svn - - - -2008-03-20T17:30:14.443495Z -921 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -example1.ksh -file - - - - -2008-04-06T23:15:43.234155Z -8f27b39a2232dd1933237c3e83cd2b70 -2008-03-20T17:30:14.443495Z -921 -pouik -has-props - -example2.ksh -file - - - - -2008-04-06T23:15:43.260876Z -b7b6eaa7b061bd67ff545694299e19c6 -2007-10-11T18:37:47.000000Z -801 -pouik -has-props - diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/format eresi-0.0.20110516/kernsh/examples/kmodules/.svn/format --- eresi-0.8a25/kernsh/examples/kmodules/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/prop-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/kmodules/.svn/prop-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/kmodules/.svn/prop-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/prop-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/prop-base/example2.ksh.svn-base eresi-0.0.20110516/kernsh/examples/kmodules/.svn/prop-base/example2.ksh.svn-base --- eresi-0.8a25/kernsh/examples/kmodules/.svn/prop-base/example2.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/prop-base/example2.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/text-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/kmodules/.svn/text-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/kmodules/.svn/text-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/text-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -#!/usr/local/bin/kernsh -# Linked tow module and hijack function init_module with an evil (inject) function - -kmodule_relink lkm-original.ko lkm-inject.ko lkm-evil.ko -exec mv -f lkm-evil.ko lkm-original.ko - -load lkm-original.ko -rel -unload lkm-original.ko - -kmodule_infect lkm-original.ko init_module inject - -load lkm-original.ko -rel -unload lkm-original.ko - diff -Nru eresi-0.8a25/kernsh/examples/kmodules/.svn/text-base/example2.ksh.svn-base eresi-0.0.20110516/kernsh/examples/kmodules/.svn/text-base/example2.ksh.svn-base --- eresi-0.8a25/kernsh/examples/kmodules/.svn/text-base/example2.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/kmodules/.svn/text-base/example2.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -#!/usr/local/bin/kernsh -# Insert ET_REL inside kernel memory - -configure libkernsh.use_kernel 1 - -openmem - -load ./lkm-sys_setdomainname.ko -mode dynamic -reladd 1 2 - -closemem diff -Nru eresi-0.8a25/kernsh/examples/md5/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/md5/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/md5/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/md5/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/921/trunk/kernsh/examples/md5 -END -example1.ksh -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/921/trunk/kernsh/examples/md5/example1.ksh -END diff -Nru eresi-0.8a25/kernsh/examples/md5/.svn/entries eresi-0.0.20110516/kernsh/examples/md5/.svn/entries --- eresi-0.8a25/kernsh/examples/md5/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/md5/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples/md5 -http://svn.eresi-project.org/svn - - - -2008-03-20T17:30:14.443495Z -921 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -example1.ksh -file - - - - -2008-04-06T23:15:43.369887Z -f2397d2c79c7b07e58003883480f83bf -2008-03-20T17:30:14.443495Z -921 -pouik -has-props - diff -Nru eresi-0.8a25/kernsh/examples/md5/.svn/format eresi-0.0.20110516/kernsh/examples/md5/.svn/format --- eresi-0.8a25/kernsh/examples/md5/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/md5/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/examples/md5/.svn/prop-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/md5/.svn/prop-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/md5/.svn/prop-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/md5/.svn/prop-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/examples/md5/.svn/text-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/md5/.svn/text-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/md5/.svn/text-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/md5/.svn/text-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!/usr/local/bin/kernsh -# Hijack a syscall and check it - -configure libkernsh.use_kernel 1 - -openmem - -type example1 = sys:int[320] -print "Sys_call_table " $sct -inform example1 toto $sct - -mode dynamic - -set $save_addr 1.example1[toto].sys[17] -print $save_addr - -kmem_hash $sct%1280 -set $md5save $$_ - -print "Hijack syscall 17" -set 1.example1[toto].sys[17] 0x44444444 -kmem_chash $md5save - -print "CMP MD5" -cmp $_ 0 -je good -print "MD5 MISMATCH !!!" -jmp end - -good: -print "MD5 MATCH!!!" -end: - -#RESTORE -set 1.example1[toto].sys[17] $save_addr -print 1.example1[toto].sys[17] - -closemem diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/814/trunk/kernsh/examples/modules/linux2_6 -END -lkm-sys_setdomainname.c -K 25 -svn:wc:ra_dav:version-url -V 80 -/svn/!svn/ver/814/trunk/kernsh/examples/modules/linux2_6/lkm-sys_setdomainname.c -END -lkm-original.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/800/trunk/kernsh/examples/modules/linux2_6/lkm-original.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/800/trunk/kernsh/examples/modules/linux2_6/Makefile -END -lkm-inject.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/800/trunk/kernsh/examples/modules/linux2_6/lkm-inject.c -END diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/entries eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/entries --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples/modules/linux2_6 -http://svn.eresi-project.org/svn - - - -2007-10-21T09:28:48.000000Z -814 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -lkm-sys_setdomainname.c -file - - - - -2008-04-06T23:15:43.612133Z -0d44b1d8684364dd854d4e2d08dda72f -2007-10-21T09:28:48.000000Z -814 -pouik - -lkm-original.c -file - - - - -2008-04-06T23:15:43.622875Z -332c32bb2dd3d2676c211cc869baf594 -2007-10-11T18:25:17.000000Z -800 -pouik - -Makefile -file - - - - -2008-04-06T23:15:43.633901Z -a8f0272ab692cbe56e0dd92ea52715be -2007-10-11T18:25:17.000000Z -800 -pouik -has-props - -lkm-inject.c -file - - - - -2008-04-06T23:15:43.645424Z -7ed60ab4e5d25f950b18e4720edae6ee -2007-10-11T18:25:17.000000Z -800 -pouik - diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/format eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/format --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-inject.c.svn-base eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-inject.c.svn-base --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-inject.c.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -#include -#include -#include - -extern int init_module(void); - -int inject(void) -{ - printk(KERN_ALERT "INJECT !!!\n"); - init_module(); - return 0; -} diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-original.c.svn-base eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-original.c.svn-base --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-original.c.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-original.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#include -#include -#include - -static int original_init(void) -{ - printk(KERN_ALERT "ORIGINAL INIT\n"); - return 0; -} - -static void original_exit(void) -{ - printk(KERN_ALERT "ORIGINAL END\n"); -} - - -module_init(original_init); -module_exit(original_exit); diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-sys_setdomainname.c.svn-base eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-sys_setdomainname.c.svn-base --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-sys_setdomainname.c.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/lkm-sys_setdomainname.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#include -#include -#include - -int asmlinkage new_sys_setdomainname(const char *name, size_t len) -{ - printk("NEW SYS DOMAINNAME\n"); - - return old_sys_setdomainname(name, len); -} - -static int testreladd_init(void) -{ - printk(KERN_ALERT "TEST REL ADD INIT\n"); - return 0; -} - -static void testreladd_exit(void) -{ - printk(KERN_ALERT "TEST REL ADD EXIT\n"); -} - - -module_init(testreladd_init); -module_exit(testreladd_exit); diff -Nru eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/kernsh/examples/modules/linux2_6/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/linux2_6/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -KDIR:=/lib/modules/$(shell uname -r)/build - -obj-m:=lkm-original.o lkm-inject.o lkm-sys_setdomainname.o - -default: - $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules - -clean: - @rm -f Module.symvers - @rm -f *.o - @rm -f *.ko - @rm -f *.mod.c - @rm -fr .tmp_versions - @rm -fr .*.cmd diff -Nru eresi-0.8a25/kernsh/examples/modules/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/modules/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/modules/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/814/trunk/kernsh/examples/modules -END diff -Nru eresi-0.8a25/kernsh/examples/modules/.svn/entries eresi-0.0.20110516/kernsh/examples/modules/.svn/entries --- eresi-0.8a25/kernsh/examples/modules/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples/modules -http://svn.eresi-project.org/svn - - - -2007-10-21T09:28:48.000000Z -814 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -linux2_6 -dir - diff -Nru eresi-0.8a25/kernsh/examples/modules/.svn/format eresi-0.0.20110516/kernsh/examples/modules/.svn/format --- eresi-0.8a25/kernsh/examples/modules/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/modules/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/examples/redir/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/redir/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/redir/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/redir/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/814/trunk/kernsh/examples/redir -END -example1.ksh -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/814/trunk/kernsh/examples/redir/example1.ksh -END diff -Nru eresi-0.8a25/kernsh/examples/redir/.svn/entries eresi-0.0.20110516/kernsh/examples/redir/.svn/entries --- eresi-0.8a25/kernsh/examples/redir/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/redir/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples/redir -http://svn.eresi-project.org/svn - - - -2007-10-21T09:28:48.000000Z -814 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -example1.ksh -file - - - - -2008-04-06T23:15:43.508886Z -32070a3e038f9ac1c54c691daebf4fad -2007-10-21T09:28:48.000000Z -814 -pouik -has-props - diff -Nru eresi-0.8a25/kernsh/examples/redir/.svn/format eresi-0.0.20110516/kernsh/examples/redir/.svn/format --- eresi-0.8a25/kernsh/examples/redir/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/redir/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/examples/redir/.svn/prop-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/redir/.svn/prop-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/redir/.svn/prop-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/redir/.svn/prop-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/examples/redir/.svn/text-base/example1.ksh.svn-base eresi-0.0.20110516/kernsh/examples/redir/.svn/text-base/example1.ksh.svn-base --- eresi-0.8a25/kernsh/examples/redir/.svn/text-base/example1.ksh.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/redir/.svn/text-base/example1.ksh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!/usr/local/bin/kernsh - -#openmem - -load lkm-sys_setdomainname.ko - -D sys_setdomainname - -mode dynamic - -reladd 1 2 - -redir sys_setdomainname new_sys_setdomainname - -D sys_setdomainname -D old_sys_setdomainname - -redir - -closemem -quit - diff -Nru eresi-0.8a25/kernsh/examples/.svn/all-wcprops eresi-0.0.20110516/kernsh/examples/.svn/all-wcprops --- eresi-0.8a25/kernsh/examples/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/921/trunk/kernsh/examples -END diff -Nru eresi-0.8a25/kernsh/examples/.svn/entries eresi-0.0.20110516/kernsh/examples/.svn/entries --- eresi-0.8a25/kernsh/examples/.svn/entries 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/examples -http://svn.eresi-project.org/svn - - - -2008-03-20T17:30:14.443495Z -921 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kmodules -dir - -md5 -dir - -redir -dir - -modules -dir - diff -Nru eresi-0.8a25/kernsh/examples/.svn/format eresi-0.0.20110516/kernsh/examples/.svn/format --- eresi-0.8a25/kernsh/examples/.svn/format 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/examples/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/hash.c eresi-0.0.20110516/kernsh/hash.c --- eresi-0.8a25/kernsh/hash.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/hash.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,8 +1,8 @@ /* -** @file hash.c +* @file kernsh/hash.c * @ingroup kernsh ** -** $Id: hash.c,v 1.4 2007-11-29 15:33:39 may Exp $ +** $Id: hash.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -59,7 +59,7 @@ "%s:%s:%s:%s:%s:%s\n\n", revm_coloraddress(XFMT, (eresi_Addr) vaddr), revm_colornumber("%u", libkernshworld.mem), - revm_colornumber("%u", (int)config_get_data(LIBKERNSH_VMCONFIG_HASH)), + revm_colornumber("%u", (int)config_get_data(LIBKERNSH_CONFIG_HASH)), revm_colornumber("%u", new_size), revm_colornumber("%u", actual->off), revm_colorstr((char *)buffhash)); @@ -69,7 +69,7 @@ "0x%lx:%d:%d:%d:%d:%s\n", (unsigned long) vaddr, libkernshworld.mem, - (int)config_get_data(LIBKERNSH_VMCONFIG_HASH), + (int)config_get_data(LIBKERNSH_CONFIG_HASH), new_size, actual->off, buffhash); @@ -88,7 +88,7 @@ "0x%lx:%d:%d:%d:%d:%s\n", (unsigned long) vaddr, libkernshworld.mem, - (int)config_get_data(LIBKERNSH_VMCONFIG_HASH), + (int)config_get_data(LIBKERNSH_CONFIG_HASH), new_size, actual->off, buffhash); @@ -184,11 +184,11 @@ param = world.curjob->curcmd->param[0]; - stype = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); + stype = (int)config_get_data(LIBKERNSH_CONFIG_HASH); if (param != NULL) { - expr = revm_lookup_param(param); + expr = revm_lookup_param(param, 1); obj = expr->value; if (obj->otype->type == ASPECT_TYPE_STR) @@ -232,13 +232,13 @@ "Bad format", -1); } /* Switch to the mode where the hash has been done */ - origmode = kernsh_get_mode(); - kernsh_set_mode(mode); + origmode = elfsh_get_mode(); + elfsh_set_mode(mode); - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)type); + config_update_key(LIBKERNSH_CONFIG_HASH, (void *)type); hashbuffer = kernsh_hash(addr+off, size, &nsize); - kernsh_set_mode(origmode); + elfsh_set_mode(origmode); i = 0; tmp = buffhash; @@ -298,12 +298,12 @@ "Bad format", -1); } - origmode = kernsh_get_mode(); - kernsh_set_mode(mode); - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)type); + origmode = elfsh_get_mode(); + elfsh_set_mode(mode); + config_update_key(LIBKERNSH_CONFIG_HASH, (void *)type); hashbuffer = kernsh_hash(addr+off, size, &nsize); - kernsh_set_mode(origmode); + elfsh_set_mode(origmode); i = 0; tmp = buffhash; while((i < sizeof(buffhash)) && (hashbuffer[i] != '\0')) @@ -349,7 +349,7 @@ } } - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)stype); + config_update_key(LIBKERNSH_CONFIG_HASH, (void *)stype); revm_setvar_int(REVM_VAR_RESULT, val); diff -Nru eresi-0.8a25/kernsh/include/kernsh.h eresi-0.0.20110516/kernsh/include/kernsh.h --- eresi-0.8a25/kernsh/include/kernsh.h 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/kernsh.h 2011-05-16 11:34:09.000000000 +0000 @@ -1,9 +1,13 @@ -/* -** kernsh.h for kernsh -** -** $Id: kernsh.h,v 1.6 2007-09-02 21:47:25 pouik Exp $ -** +/** +* @defgroup kernsh kernsh: The kernel shell. */ +/** +* @file kernsh/include/kernsh.h + * @ingroup kernsh + * @brief The kernel shell header file. + * + * $Id: kernsh.h 1397 2009-09-13 02:19:08Z may $ + */ #ifndef __KERNSH_H__ #define __KERNSH_H__ diff -Nru eresi-0.8a25/kernsh/include/kernsh-help.h eresi-0.0.20110516/kernsh/include/kernsh-help.h --- eresi-0.8a25/kernsh/include/kernsh-help.h 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/kernsh-help.h 2011-05-16 11:34:10.000000000 +0000 @@ -1,9 +1,9 @@ -/* -** kernsh-help.h for kernsh -** -** $Id: kernsh-help.h,v 1.5 2007-09-02 21:47:25 pouik Exp $ -** -*/ +/** +* @file kernsh/include/kernsh-help.h + * @ingroup kernsh + * $Id: kernsh-help.h 1397 2009-09-13 02:19:08Z may $ + * + */ #ifndef __KERNSH_HELP_H_ #define __KERNSH_HELP_H_ diff -Nru eresi-0.8a25/kernsh/include/.svn/all-wcprops eresi-0.0.20110516/kernsh/include/.svn/all-wcprops --- eresi-0.8a25/kernsh/include/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/kernsh/include -END -kernsh.h -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/kernsh/include/kernsh.h -END -kernsh-help.h -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/923/trunk/kernsh/include/kernsh-help.h -END diff -Nru eresi-0.8a25/kernsh/include/.svn/entries eresi-0.0.20110516/kernsh/include/.svn/entries --- eresi-0.8a25/kernsh/include/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kernsh.h -file - - - - -2008-04-06T23:15:42.638892Z -29dd62d207429e71069ba8059485d48c -2008-03-27T22:53:48.747992Z -946 -may - -kernsh-help.h -file - - - - -2008-04-06T23:15:42.649055Z -9b5abd84e7904024d20ed16be65df1d4 -2008-03-23T21:44:25.073610Z -923 -pouik - diff -Nru eresi-0.8a25/kernsh/include/.svn/format eresi-0.0.20110516/kernsh/include/.svn/format --- eresi-0.8a25/kernsh/include/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/include/.svn/text-base/kernsh-help.h.svn-base eresi-0.0.20110516/kernsh/include/.svn/text-base/kernsh-help.h.svn-base --- eresi-0.8a25/kernsh/include/.svn/text-base/kernsh-help.h.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/.svn/text-base/kernsh-help.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/* -** kernsh-help.h for kernsh -** -** $Id: kernsh-help.h,v 1.5 2007-09-02 21:47:25 pouik Exp $ -** -*/ -#ifndef __KERNSH_HELP_H_ - #define __KERNSH_HELP_H_ - -/* Commands */ -#define HLP_OPENMEM "open kernel's memory" -#define HLP_CLOSEMEM "close kernel's memory" -#define HLP_KMODE "switch mode : static, dynamic" - -#define HLP_SCT "display the syscalltable" -#define HLP_IDT "display the idt" -#define HLP_GDT "display the gdt" - -#define HLP_KALLOC "alloc contiguous kernel memory" -#define HLP_KFREE "free contiguous kernel memory" -#define HLP_KALLOCNC "alloc non contiguous kernel memory" -#define HLP_KFREENC "free non contiguous kernel memory" - -#define HLP_KSYM "search kernel symbol" - -#define HLP_KMODULE_RELINK "Relink a loadable kernel module\n\n"\ - "Parameter format : original_module evil_module new_module\n\n" - -#define HLP_KMODULE_INFECT "Infect a loadable kernel module\n\n"\ - "Parameter format : original_fname evil_fname module\n\n" - -#define HLP_KMODULE_LOAD "Load a loadable kernel module\n\n"\ - "Parameter format : module\n\n" - -#define HLP_KMODULE_UNLOAD "Unload a loadable kernel module\n\n"\ - "Parameter format : module\n\n" - -#define HLP_AUTOTYPES "autotypes" - -#define HLP_KMEM_HASH "Make hash at a specific addr\n\n"\ - "Parameter format : sa output, sa:rva output, sa%rva%size output, sa%size output\n"\ - "- sa : Symbol or addr\n"\ - "- rva : Byte offset form the beginning (optional)\n"\ - "- size : Bytes number limit (optional)"\ - "- If size is 0 or not specified, we search the end of the function\n"\ - "- output : file output (optional)\n\n" - -#define HLP_KMEM_CHASH "Check hash\n\n"\ - "Parameter format : format, file\n"\ - "- format : addr:mode:type:size:off:hash\n"\ - "- file : filename\n\n" - -#define HLP_KVIRTM_INFO "Kernel virtual memory informations" -#define HLP_KVIRTM_LOADME "Load the kernel virtual memory automatically\n"\ - "Parameter format : module\n\n" - - -#define HLP_KVIRTM_READ_PID "handle kernel virtual memory" -#define HLP_KVIRTM_WRITE_PID "handle kernel virtual memory" -#define HLP_KVIRTM_DISASM_PID "handle kernel virtual memory" -#define HLP_KVIRTM_TASK_PID "handle kernel virtual memory" -#define HLP_KVIRTM_DUMP "handle kernel virtual memory" - - -#define HLP_KMEM_READ "Read kernel memory\n\n"\ - "Parameter format : sa, sa:rva, sa%rva%size, sa%size\n"\ - "- sa : Symbol or addr\n"\ - "- rva : Byte offset form the beginning (optional)\n"\ - "- size : Bytes number limit\n\n" - -#define HLP_KMEM_WRITE "handle kernel memory" -#define HLP_KMEM_DISASM "Disasm kernel memory\n\n"\ - "Parameter format : sa, sa:rva, sa%rva%size, sa%size\n" \ - "- sa : Symbol or addr\n"\ - "- rva : Byte offset form the beginning (optional)\n"\ - "- size : Bytes number limit\n\n" - -#define HLP_KMEM_INFO "Kernel memory informations" - -#define HLP_KDUMP_GET_VMA "vma" -#define HLP_KDUMP_VMA "vma" - -#endif diff -Nru eresi-0.8a25/kernsh/include/.svn/text-base/kernsh.h.svn-base eresi-0.0.20110516/kernsh/include/.svn/text-base/kernsh.h.svn-base --- eresi-0.8a25/kernsh/include/.svn/text-base/kernsh.h.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/include/.svn/text-base/kernsh.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -/* -** kernsh.h for kernsh -** -** $Id: kernsh.h,v 1.6 2007-09-02 21:47:25 pouik Exp $ -** -*/ -#ifndef __KERNSH_H__ - #define __KERNSH_H__ - -/* User defined configuration */ -#include "libstderesi.h" - -/* Help strings */ -#include "kernsh-help.h" - -#define KERNSH_SNAME "kernsh" -#define KERNSH_NAME "Kernel shell" -#define KERNSH_CONFIG ".kernshrc" - - -/* Commands */ -#define CMD_OPENMEM "openmem" -#define CMD_CLOSEMEM "closemem" -#define CMD_KMODE "mode" - -#define CMD_SCT "sct" -#define CMD_IDT "idt" -#define CMD_GDT "gdt" - -#define CMD_KALLOC "kalloc" -#define CMD_KFREE "kfree" -#define CMD_KALLOCNC "kallocnc" -#define CMD_KFREENC "kfreenc" - -#define CMD_KSYM "ksym" - -#define CMD_KMODULE_RELINK "kmodule_relink" -#define CMD_KMODULE_INFECT "kmodule_infect" -#define CMD_KMODULE_LOAD "kmodule_load" -#define CMD_KMODULE_UNLOAD "kmodule_unload" - -#define CMD_AUTOTYPES "autotypes" - -#define CMD_KMEM_HASH "kmem_hash" -#define CMD_KMEM_CHASH "kmem_chash" - -#define CMD_KVIRTM_INFO "kvirtm_info" -#define CMD_KVIRTM_LOADME "kvirtm_loadme" -#define CMD_KVIRTM_READ_PID "kvirtm_read_pid" -#define CMD_KVIRTM_WRITE_PID "kvirtm_write_pid" -#define CMD_KVIRTM_DISASM_PID "kvirtm_disasm_pid" -#define CMD_KVIRTM_DUMP "kvirtm_dump" -#define CMD_KVIRTM_TASK_PID "kvirtm_task_pid" - -#define CMD_KMEM_READ "kmem_read" -#define CMD_KMEM_WRITE "kmem_write" -#define CMD_KMEM_DISASM "kmem_disasm" -#define CMD_KMEM_INFO "kmem_info" - -#define CMD_KDUMP_GET_VMA "kdump_get_vma" -#define CMD_KDUMP_VMA "kdump_vma" - -/* Commands execution handlers, each in their respective file */ -int cmd_openmem(); -int cmd_closemem(); -int cmd_kmode(); -int cmd_sct(); -int cmd_idt(); -int cmd_gdt(); -int cmd_kalloc(); -int cmd_kfree(); -int cmd_kallocnc(); -int cmd_kfreenc(); -int cmd_ksym(); -int cmd_kmodule_relink(); -int cmd_kmodule_infect(); -int cmd_kmodule_load(); -int cmd_kmodule_unload(); -int cmd_autotypes(); -int cmd_kmem_hash(); -int cmd_kmem_chash(); -int cmd_kvirtm_info(); -int cmd_kvirtm_loadme(); -int cmd_kvirtm_read_pid(); -int cmd_kvirtm_write_pid(); -int cmd_kvirtm_disasm_pid(); -int cmd_kvirtm_dump(); -int cmd_kvirtm_task_pid(); - -int cmd_kmem_read(); -int cmd_kmem_write(); -int cmd_kmem_disasm(); -int cmd_kmem_info(); - -int cmd_kdump_get_vma(); -int cmd_kdump_vma(); - -int kernsh_virtm_dump_elf(pid_t, char *); -int kernsh_virtm_view_vmaps(pid_t); -int kernsh_virtm_get_virtaddr(pid_t); -int kernsh_virtm_read_pid(pid_t, unsigned long, int); -int kernsh_virtm_write_pid(pid_t, unsigned long, char *, int); -int kernsh_virtm_disasm_pid(pid_t, unsigned long, int); -int kernsh_virtm_task_pid(pid_t, list_t *); - -int export_var(char *, unsigned long, int, char *, int); -int extract_info(char *, - unsigned long *, - int *, - int *, - int *, - int *, - unsigned char *, size_t); - -int kernsh_hexdump(unsigned char *, unsigned int, size_t); -int kernsh_disasm(char *, int, unsigned long); -int kernsh_addrlen(revmlist_t *, eresi_Addr *, int *); - -/* Top skeleton functions */ -int vm_main(int ac, char **av); - -/* Commands registration */ -void setup_local_cmdhash(); - -#endif /* __KERNSH_H_ */ - diff -Nru eresi-0.8a25/kernsh/main.c eresi-0.0.20110516/kernsh/main.c --- eresi-0.8a25/kernsh/main.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/main.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file main.c +* @file kernsh/main.c ** @ingroup kernsh -** $Id: main.c,v 1.7 2007-10-11 18:25:17 pouik Exp $ +** $Id: main.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -121,13 +121,19 @@ if (world.state.revm_mode != REVM_STATE_CMDLINE) kernsh_banner_print(av[1]); - return (revm_run(ac, av)); + revm_run(ac, av); + return (0); } /* The main Kernsh routine */ int main(int ac, char **av) { + if (geteuid() || getuid()) + { + fprintf(stderr, "You need to be root to execute kernsh\n"); + exit(-1); + } return (kernsh_main(ac, av)); } diff -Nru eresi-0.8a25/kernsh/Makefile eresi-0.0.20110516/kernsh/Makefile --- eresi-0.8a25/kernsh/Makefile 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/Makefile 2011-05-16 11:34:11.000000000 +0000 @@ -16,57 +16,54 @@ NAME32 = kernsh32 NAME64 = kernsh64 -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -I../libstderesi/include/ \ - -I../libkernsh/include/ \ - -DELFSH_INTERN $(STATOPT2) \ +CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ + -I../libelfsh/include/ $(STATOPT2) \ + -I../libdump/include/ -I../libasm/include/ \ + -I../e2dbg/include/ -I/usr/pkg/include/ \ + -I../libui/include/ -I../libmjollnir/include/ \ + -I../libaspect/include/ -I../librevm/include/ \ + -I../libedfmt/include/ -I../libstderesi/include/ \ + -I../libkernsh/include/ -I../libetrace/include/ \ $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -I../libstderesi/include/ \ - -I../libkernsh/include/ \ - -DELFSH_INTERN $(STATOPT2) \ +CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ + -I../libelfsh/include/ -I../libetrace/include/ \ + -I../libdump/include/ -I../libasm/include/ \ + -I../e2dbg/include/ -I/usr/pkg/include/ \ + -I../libui/include/ -I../libmjollnir/include/ \ + -I../libaspect/include/ -I../librevm/include/ \ + -I../libedfmt/include/ -I../libstderesi/include/ \ + -I../libkernsh/include/ $(STATOPT2) \ $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui32 -g3 \ - -L../liballocproxy -L../libmjollnir/ \ + -lmjollnir32 $(LPTHREAD) -L../libasm/ -lasm32 \ + -L../liballocproxy -L../libmjollnir/ -L../libui/ -lui32 \ -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ -L../libetrace/ -letrace32 \ -L../libkernsh/ -lkernsh32 -L../libstderesi/ -lstderesi32 \ - -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ + -lallocproxy $(LDMJOLLNIR) $(DLOPT) -g3 \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui64 -g3 \ + -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ + -L../libasm/ -lasm64 -L../libui/ -lui64 -g3 \ -L../liballocproxy -L../libmjollnir/ \ -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ -L../libetrace/ -letrace64 \ -L../libkernsh/ -lkernsh64 -L../libstderesi/ -lstderesi64 \ -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + $(EXTRAOPT) $(LDDUMPOPT64) $(LDNCURSESLNOPT) $(LDREADLNOPT) all : all32 -$(NAME32) : $(OBJ32) +$(NAME32) : $(OBJ32) $(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) -$(NAME64) : $(OBJ64) +$(NAME64) : $(OBJ64) @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) all32: $(NAME32) diff -Nru eresi-0.8a25/kernsh/mem.c eresi-0.0.20110516/kernsh/mem.c --- eresi-0.8a25/kernsh/mem.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/mem.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file mem.c +* @file kernsh/mem.c ** @ingroup kernsh -** $Id: mem.c,v 1.14 2008-02-16 12:32:26 thor Exp $ +** $Id: mem.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -162,14 +162,14 @@ { char *param; char buff[BUFSIZ]; - unsigned long addr; + eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); param = world.curjob->curcmd->param[0]; if (param) { - if(kernsh_get_addr_by_name(param, &addr, strlen(param))) + if (kernsh_get_addr_by_name(param, &addr, strlen(param))) { revm_setvar_int("_", -1); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -316,13 +316,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_DEVICE); + data = (char *)config_get_data(LIBKERNSH_CONFIG_DEVICE); snprintf(buff, sizeof(buff), "DEVICE : %s\n", data); revm_output(buff); - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_MODE); + data = (char *)config_get_data(LIBKERNSH_CONFIG_MODE); snprintf(buff, sizeof(buff), "FLAGS : %s\n", data); @@ -341,13 +341,13 @@ } revm_output(buff); - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP); + data = (char *)config_get_data(LIBKERNSH_CONFIG_SYSTEMMAP); snprintf(buff, sizeof(buff), "SYSTEMMAP : %s\n", data); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_MMAP); + val = (int)config_get_data(LIBKERNSH_CONFIG_MMAP); switch (val) { case 0 : @@ -361,31 +361,31 @@ } revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_MMAP_SIZE); + val = (int)config_get_data(LIBKERNSH_CONFIG_MMAP_SIZE); snprintf(buff, sizeof(buff), "MMAP_SIZE : 0x%lx\n", (unsigned long)val); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_KERNEL_START); + val = (int)config_get_data(LIBKERNSH_CONFIG_KERNEL_START); snprintf(buff, sizeof(buff), "KERNEL_START : 0x%lx\n", (unsigned long)val); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_KERNEL_END); + val = (int)config_get_data(LIBKERNSH_CONFIG_KERNEL_END); snprintf(buff, sizeof(buff), "KERNEL_END : 0x%lx\n", (unsigned long)val); revm_output(buff); - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_KERNEL); + data = (char *)config_get_data(LIBKERNSH_CONFIG_KERNEL); snprintf(buff, sizeof(buff), "KERNEL : %s\n", data); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_USE_KERNEL); + val = (int)config_get_data(LIBKERNSH_CONFIG_USE_KERNEL); switch (val) { case 0 : @@ -400,7 +400,7 @@ revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_ALLOC); + val = (int)config_get_data(LIBKERNSH_CONFIG_ALLOC); switch (val) { case 0 : @@ -414,19 +414,19 @@ } revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS); + val = (int)config_get_data(LIBKERNSH_CONFIG_NB_SYSCALLS); snprintf(buff, sizeof(buff), "NB_SYSCALLS : %d\n", val); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL); + val = (int)config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL); snprintf(buff, sizeof(buff), "NIL_SYSCALL : %d\n", val); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_USEVM); + val = (int)config_get_data(LIBKERNSH_CONFIG_USEVM); switch (val) { case 0 : @@ -440,7 +440,7 @@ } revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + val = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); switch (val) { case LIBKERNSH_KERNEL_MODE: @@ -454,13 +454,13 @@ } revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL); + val = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL); snprintf(buff, sizeof(buff), "VIRTM_NIL_SYSCALL : %d\n", val); revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); + val = (int)config_get_data(LIBKERNSH_CONFIG_HASH); switch (val) { case LIBKERNSH_HASH_MD5: @@ -474,7 +474,7 @@ } revm_output(buff); - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); + val = (int)config_get_data(LIBKERNSH_CONFIG_VMA); switch (val) { case LIBKERNSH_VMA_USERLAND: @@ -525,8 +525,8 @@ revm_colornumber("%u", len)); revm_output(buff); - ret = kernsh_readmem(addr, new_buff, len); - + ret = elfsh_readmema(libkernshworld.root, addr, new_buff, len); + kernsh_hexdump((unsigned char *)new_buff, len, addr); XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); @@ -570,7 +570,7 @@ } else { - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); o1 = e1->value; switch (o1->otype->type) { @@ -586,7 +586,7 @@ } } - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); o2 = e2->value; @@ -623,7 +623,7 @@ revm_output(buff); kernsh_hexdump((unsigned char *)dat, size, (unsigned int)dat); - ret = kernsh_writemem(addr, dat, size); + ret = elfsh_writemem(libkernshworld.root, addr, dat, size); if (ret != size) { @@ -661,7 +661,10 @@ memset(new_buff, '\0', len); - ret = kernsh_readmem(addr, new_buff, len); + ret = elfsh_readmema(libkernshworld.root, addr, new_buff, len); + if (ret == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Impossible to read mem", -1); memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), @@ -676,12 +679,5 @@ XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); } - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to read mem", - -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/kernsh/misc.c eresi-0.0.20110516/kernsh/misc.c --- eresi-0.8a25/kernsh/misc.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/misc.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,5 +1,5 @@ /* -** @file misc.c +* @file kernsh/misc.c ** @ingroup kernsh */ #include "kernsh.h" @@ -131,7 +131,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); index = 0; - while(index < len && len > 0) + while (index < len && len > 0) { value = kernsh_instr_display(index, addr, index, len, NULL, 0, buffer); if (value <= 0) @@ -171,7 +171,7 @@ /* Get the value of the object */ else { - expr = revm_lookup_param(actual->rname); + expr = revm_lookup_param(actual->rname, 1); obj = expr->value; diff -Nru eresi-0.8a25/kernsh/mode.c eresi-0.0.20110516/kernsh/mode.c --- eresi-0.8a25/kernsh/mode.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/mode.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file mode.c +* @file kernsh/mode.c ** @ingroup kernsh -** $Id: mode.c,v 1.4 2007-11-29 15:33:39 may Exp $ +** $Id: mode.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -24,7 +24,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Static kernel is not loaded !", -1); - kernsh_set_static_mode(); + elfsh_set_static_mode(); revm_output("[*] kernsh is now in STATIC mode\n\n"); } else if (*param == 'd' || *param == 'D') @@ -33,7 +33,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to switch to dynamic mode, please open the memory !", -1); - kernsh_set_mem_mode(); + elfsh_set_runtime_mode(); revm_output("[*] kernsh is now in DYNAMIC mode\n\n"); } @@ -45,10 +45,10 @@ } else { - if (kernsh_is_static_mode()) + if (elfsh_is_static_mode()) param = "STATIC"; - else if (kernsh_is_mem_mode()) + else if (elfsh_is_runtime_mode()) param = "DYNAMIC"; else diff -Nru eresi-0.8a25/kernsh/open.c eresi-0.0.20110516/kernsh/open.c --- eresi-0.8a25/kernsh/open.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/open.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,7 +1,7 @@ /* -** @file open.c +* @file kernsh/open.c ** @ingroup kernsh -** $Id: open.c,v 1.10 2007-11-29 15:33:39 may Exp $ +** $Id: open.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "kernsh.h" @@ -88,13 +88,14 @@ { int ret; char buff[BUFSIZ]; + elfshsect_t *cur; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Check if no static is set */ - if (!(int) config_get_data(LIBKERNSH_VMCONFIG_WITHOUT_KERNEL)) + if (!(int) config_get_data(LIBKERNSH_CONFIG_WITHOUT_KERNEL)) { - if(!(int) config_get_data(LIBKERNSH_VMCONFIG_USE_KERNEL)) + if(!(int) config_get_data(LIBKERNSH_CONFIG_USE_KERNEL)) { /* Gunzip/Extract the kernel */ ret = kernsh_decompkernel(); @@ -104,39 +105,36 @@ snprintf(buff, sizeof(buff), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNELELF)); ret = revm_file_load(buff, 0, NULL); - if (ret) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to load kernel", -1); libkernshworld.root = revm_lookup_file(buff); if (libkernshworld.root == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get elf file", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get elf file", -1); + libkernshworld.root->hostype = ELFSH_HOST_KERN; libkernshworld.open_static = 1; } - else - { - kernsh_set_mem_mode(); - } - + /* Open memory */ + elfsh_set_runtime_mode(); ret = kernsh_openmem(); - if (ret) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot open memory", -1); + /* Fixup decompressed kernel sections base address */ + for (cur = libkernshworld.root->sectlist; cur; cur = cur->next) + if (elfsh_get_section_allocflag(cur->shdr) && !cur->shdr->sh_addr) + cur->shdr->sh_addr = libkernshworld.kernel_start; + memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] OPEN MEMORY")); + snprintf(buff, sizeof(buff), "%s\n\n", revm_colorfieldstr(" [*] Kernel memory opened")); revm_output(buff); revm_endline(); export_vars(); diff -Nru eresi-0.8a25/kernsh/.svn/all-wcprops eresi-0.0.20110516/kernsh/.svn/all-wcprops --- eresi-0.8a25/kernsh/.svn/all-wcprops 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 30 -/svn/!svn/ver/952/trunk/kernsh -END -README.vectors -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/948/trunk/kernsh/README.vectors -END -virtm.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/kernsh/virtm.c -END -open.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/909/trunk/kernsh/open.c -END -close.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/909/trunk/kernsh/close.c -END -dump.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/924/trunk/kernsh/dump.c -END -tables.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/923/trunk/kernsh/tables.c -END -README -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/952/trunk/kernsh/README -END -mem.c -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/946/trunk/kernsh/mem.c -END -hash.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/946/trunk/kernsh/hash.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/918/trunk/kernsh/main.c -END -mode.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/909/trunk/kernsh/mode.c -END -alloc.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/kernsh/alloc.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/946/trunk/kernsh/misc.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/kernsh/Makefile -END -README.configure -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/948/trunk/kernsh/README.configure -END -autotypes.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/909/trunk/kernsh/autotypes.c -END diff -Nru eresi-0.8a25/kernsh/.svn/entries eresi-0.0.20110516/kernsh/.svn/entries --- eresi-0.8a25/kernsh/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/kernsh -http://svn.eresi-project.org/svn - - - -2008-03-29T16:01:15.895002Z -952 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -README.vectors -file - - - - -2008-04-06T23:15:43.724876Z -ba9d67b1d6293357812b9f0a4b53c968 -2008-03-28T20:58:34.677020Z -948 -pouik - -virtm.c -file - - - - -2008-04-06T23:15:43.761136Z -80853b3f704adf1f6a3439242184307a -2008-03-27T22:53:48.747992Z -946 -may - -open.c -file - - - - -2008-04-06T23:15:43.749149Z -308423ed789bddcdee2ba7d7677369dd -2008-03-14T09:48:44.987521Z -909 -enioh - -include -dir - -close.c -file - - - - -2008-04-06T23:15:43.784919Z -7261b2605e63614d0f805e2fafda0488 -2008-03-14T09:48:44.987521Z -909 -enioh - -dump.c -file - - - - -2008-04-06T23:15:43.772899Z -489bdc28948fdc48380b567fa4440e9d -2008-03-24T13:43:31.172355Z -924 -pouik - -tables.c -file - - - - -2008-04-06T23:15:43.796644Z -509392a20177935f58f479e01433806d -2008-03-23T21:44:25.073610Z -923 -pouik - -README -file - - - - -2008-04-06T23:15:43.807878Z -1cabda9ff3dd9f3dbbae4d33f0838cd5 -2008-03-29T16:01:15.895002Z -952 -pouik - -mem.c -file - - - - -2008-04-06T23:15:43.819899Z -acdc9f9d4da239f37c5b439dbc234bf0 -2008-03-27T22:53:48.747992Z -946 -may - -hash.c -file - - - - -2008-04-06T23:15:43.832061Z -d924de31f790e3704946496fd87c81a1 -2008-03-27T22:53:48.747992Z -946 -may - -main.c -file - - - - -2008-04-06T23:15:43.855559Z -85c194d8c344286e2c35fa2f2d4d0c89 -2008-03-19T16:29:31.050819Z -918 -pouik - -mode.c -file - - - - -2008-04-06T23:15:43.843876Z -0ec949c8e3d501dbcf3035f4f4b7d94b -2008-03-14T09:48:44.987521Z -909 -enioh - -doc -dir - -alloc.c -file - - - - -2008-04-06T23:15:43.866905Z -ea73db073948d69d87578e235f88daee -2008-03-27T22:53:48.747992Z -946 -may - -misc.c -file - - - - -2008-04-06T23:15:43.878904Z -409527a918458afc11fbd52bfd68f390 -2008-03-27T22:53:48.747992Z -946 -may - -README.configure -file - - - - -2008-04-06T23:15:43.890877Z -687bc70fdf0c9ab3e0d780f5ebde53df -2008-03-28T20:58:34.677020Z -948 -pouik - -Makefile -file - - - - -2008-04-06T23:15:43.902470Z -9b7b835837238a3163b92a8663194893 -2008-03-29T07:54:04.209482Z -950 -enioh -has-props - -examples -dir - -autotypes.c -file - - - - -2008-04-06T23:15:43.914413Z -2cca3f6c7732cd62dd338341bed04abd -2008-03-14T09:48:44.987521Z -909 -enioh - diff -Nru eresi-0.8a25/kernsh/.svn/format eresi-0.0.20110516/kernsh/.svn/format --- eresi-0.8a25/kernsh/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/kernsh/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/kernsh/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/kernsh/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/kernsh/.svn/text-base/alloc.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/alloc.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/alloc.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/alloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -/* -** @file alloc.c -** @ingroup kernsh -** $Id: alloc.c,v 1.3 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - - -/* Alloc contiguous kernel memory */ -int cmd_kalloc() -{ - char *param; - char buff[BUFSIZ]; - unsigned long addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - param = world.curjob->curcmd->param[0]; - if (param) - { - if (kernsh_alloc_contiguous(atoi(param), &addr)) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot alloc contiguous memory", -1); - } - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %s %s %s %s %s\n\n", - revm_colorfieldstr("ALLOCATE"), - revm_colornumber("%u", (unsigned int)atoi(param)), - revm_colorfieldstr("octet(s)"), - revm_colorfieldstr("OF CONTIGUOUS MEMORY"), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr)); - revm_output(buff); - revm_setvar_long("_", addr); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Free contiguous kernel memory */ -int cmd_kfree() -{ - char *param; - char buff[BUFSIZ]; - unsigned long addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - param = world.curjob->curcmd->param[0]; - - if (param) - { - addr = strtoul( param, NULL, 16 ); - if(kernsh_free_contiguous(addr)) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot free contiguous memory", -1); - } - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %s %s %s\n\n", - revm_colorfieldstr("FREE"), - revm_colorfieldstr("CONTIGUOUS MEMORY"), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr)); - revm_output(buff); - revm_setvar_int("_", 0); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Alloc non contiguous kernel memory */ -int cmd_kallocnc() -{ - char *param; - char buff[BUFSIZ]; - unsigned long addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - param = world.curjob->curcmd->param[0]; - - if (param) - { - if(kernsh_alloc_noncontiguous(atoi(param), &addr)) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get alloc non contiguous memory", -1); - } - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %s %s %s %s %s\n\n", - revm_colorfieldstr("ALLOCATE"), - revm_colornumber("%u", (unsigned int)atoi(param)), - revm_colorfieldstr("octet(s)"), - revm_colorfieldstr("OF NON CONTIGUOUS MEMORY"), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr)); - revm_output(buff); - revm_setvar_long("_", addr); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Free non contiguous kernel memory */ -int cmd_kfreenc() -{ - char *param; - char buff[BUFSIZ]; - unsigned long addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - param = world.curjob->curcmd->param[0]; - - if (param) - { - addr = strtoul( param, NULL, 16 ); - if(kernsh_free_noncontiguous(addr)) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get free non contiguous memory", -1); - } - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %s %s %s\n\n", - revm_colorfieldstr("FREE"), - revm_colorfieldstr("NONCONTIGUOUS MEMORY"), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr)); - revm_output(buff); - revm_setvar_int("_", 0); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/autotypes.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/autotypes.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/autotypes.c.svn-base 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/autotypes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* -** @file autotypes.c -** @ingroup kernsh -** $Id: autotypes.c,v 1.4 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -/* */ -int cmd_autotypes() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = kernsh_autotypes(); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot autotypes", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/close.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/close.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/close.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/close.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* -** @file close.c -** @ingroup kernsh -** $Id: close.c,v 1.4 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -/* Close the memory device */ -int cmd_closemem() -{ - int ret; - char buff[BUFSIZ]; - char logbuf[BUFSIZ]; - time_t uloadt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Close memory */ - ret = kernsh_closemem(); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot close memory", -1); - - if (libkernshworld.open_static) - { - /* Rip from cmd_unload */ - - /* Do not unload dependences of files or objects with linkmap entry */ - if (hash_size(&libkernshworld.root->parent_hash)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unload parent object first", -1); - if (libkernshworld.root->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You cannot unload a mapped object", -1); - ret = revm_unload_dep(libkernshworld.root, libkernshworld.root); - if (!world.state.revm_quiet) - { - time(&uloadt); - snprintf(logbuf, BUFSIZ - 1, "%s [*] Object %-40s unloaded on %s \n", - (ret ? "" : "\n"), libkernshworld.root->name, ctime(&uloadt)); - revm_output(logbuf); - } - - /* Clean various hash tables of this binary entry and return OK */ - hash_del(&file_hash, libkernshworld.root->name); - if (hash_get(&world.shared_hash, libkernshworld.root->name)) - hash_del(&world.shared_hash, libkernshworld.root->name); - else - hash_del(&world.curjob->loaded, libkernshworld.root->name); - elfsh_unload_obj(libkernshworld.root); - - libkernshworld.open_static = 0; - } - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] CLOSE MEMORY")); - revm_output(buff); - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/dump.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/dump.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/dump.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/dump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/* -** @file dump.c -** @ingroup kernsh -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -int cmd_kdump_get_vma() -{ - int ret; - char buff[BUFSIZ]; - int index, index2; - listent_t *actual, *second; - list_t *l; - hash_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - l = kernsh_kdump_get_vma(atoi(world.curjob->curcmd->param[0])); - - if (l == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get vma", -1); - } - - for (index = 0, actual = l->head; - index < l->elmnbr; - index++, actual = actual->next) - { - h = (hash_t *) actual->data; - printf("%s[%d]", l->name, index); - if (h) - { - printf("[%s] ", h->name); - for (index2 = 0; index2 < h->size; index2++) - { - for (second = &h->ent[index2]; - second != NULL && second->key != NULL; - second = second->next) - { - printf("[%s] => [%p] ", - second->key, second->data); - } - } - printf("\n"); - } - } - - snprintf(buff, sizeof(buff), - "Vma for pid %s is in list %s\n\n", - revm_colornumber("%u", atoi(world.curjob->curcmd->param[0])), - revm_colorstr(l->name)); - revm_output(buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kdump_vma() -{ - int ret; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->param[0]) - { - ret = kernsh_kdump_vma(atoi(world.curjob->curcmd->param[0])); - - if (ret < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to dump vma", -1); - } - - snprintf(buff, sizeof(buff), - "Dumped into %s%s%s%s\n\n", - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH)), - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX)), - revm_colorstr("_"), - revm_colornumber("%u", atoi(world.curjob->curcmd->param[0]))); - revm_output(buff); - snprintf(buff, sizeof(buff), - "Check the metadata file %s%s%s%s/metadata*\n\n", - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH)), - revm_colorstr((char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX)), - revm_colorstr("_"), - revm_colornumber("%u", atoi(world.curjob->curcmd->param[0]))); - revm_output(buff); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/hash.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/hash.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/hash.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/hash.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,358 +0,0 @@ -/* -** @file hash.c -* @ingroup kernsh -** -** $Id: hash.c,v 1.4 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -/* Make hash ! */ -int cmd_kmem_hash() -{ - int i, fd, len, new_size; - revmlist_t *actual, *second; - char buff[BUFSIZ]; - char buffhash[BUFSIZ]; - eresi_Addr vaddr; - unsigned char *hashbuffer; - char *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - memset(buffhash, '\0', sizeof(buffhash)); - - vaddr = -1; - actual = world.curjob->curcmd->disasm + 0; - second = world.curjob->curcmd->disasm + 1; - - if (actual->rname) - { - kernsh_addrlen(actual, &vaddr, &len); - - hashbuffer = kernsh_hash(vaddr+actual->off, len, &new_size); - - if (hashbuffer == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to make hash", -1); - } - - i = 0; - tmp = buffhash; - while(hashbuffer[i] != '\0') - { - sprintf(tmp, "%02x", hashbuffer[i]); - i++; - tmp += 2; - } - - snprintf(buff, sizeof(buff), - "MD5 @ %s : \n\t%s\n\n", - revm_coloraddress(XFMT, (eresi_Addr) vaddr), - revm_colorstr((char *)buffhash)); - revm_output(buff); - - snprintf(buff, sizeof(buff), - "%s:%s:%s:%s:%s:%s\n\n", - revm_coloraddress(XFMT, (eresi_Addr) vaddr), - revm_colornumber("%u", libkernshworld.mem), - revm_colornumber("%u", (int)config_get_data(LIBKERNSH_VMCONFIG_HASH)), - revm_colornumber("%u", new_size), - revm_colornumber("%u", actual->off), - revm_colorstr((char *)buffhash)); - revm_output(buff); - - snprintf(buff, sizeof(buff), - "0x%lx:%d:%d:%d:%d:%s\n", - (unsigned long) vaddr, - libkernshworld.mem, - (int)config_get_data(LIBKERNSH_VMCONFIG_HASH), - new_size, - actual->off, - buffhash); - - - revm_setvar_str(REVM_VAR_RESULT, (char *)buffhash); - - export_var((char *)buffhash, 0, 0, buff, 2); - - if (second != NULL && second->rname != NULL) - { - XOPEN(fd, second->rname, O_CREAT|O_APPEND|O_RDWR, 0777, -1); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "0x%lx:%d:%d:%d:%d:%s\n", - (unsigned long) vaddr, - libkernshworld.mem, - (int)config_get_data(LIBKERNSH_VMCONFIG_HASH), - new_size, - actual->off, - buffhash); - XWRITE(fd, buff, strlen(buff), -1); - XCLOSE(fd, -1); - } - } - - XFREE(__FILE__, __FUNCTION__, __LINE__, hashbuffer); - - revm_endline(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int extract_info(char *origbuf, - unsigned long *addr, - int *mode, - int *type, - int *size, - int *off, - unsigned char *buffer, - size_t sizeb) -{ - int i; - char *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - i = 0; - p = (char *)strtok(origbuf, ":"); - while (p != NULL) - { - switch(i) - { - case 0 : - *addr = strtoul(p, NULL, 16); - break; - - case 1 : - *mode = atoi(p); - break; - - case 2 : - *type = atoi(p); - break; - - case 3 : - *size = atoi(p); - break; - - case 4 : - *off = atoi(p); - break; - - case 5 : - memset(buffer, '\0', sizeb); - memcpy(buffer, p, sizeb); - break; - } - - p = (char *)strtok(NULL, ":"); - i++; - } - - if (i != 6) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Check a hash */ -int cmd_kmem_chash() -{ - int i, ret, mode, stype, type, nsize, size, off, origmode, val; - char buff[BUFSIZ], buff2[256]; - char *param, *str; - unsigned long addr; - revmexpr_t *expr; - revmobj_t *obj; - - unsigned char origbuffer[BUFSIZ]; - char buffhash[BUFSIZ]; - unsigned char *hashbuffer; - char *tmp; - - FILE *fd; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - val = 0; - memset(buff, '\0', sizeof(buff)); - memset(buff2, '\0', sizeof(buff2)); - - param = world.curjob->curcmd->param[0]; - - stype = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); - - if (param != NULL) - { - expr = revm_lookup_param(param); - obj = expr->value; - - if (obj->otype->type == ASPECT_TYPE_STR) - { - str = (obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent)); - - memcpy(buff2, str, sizeof(buff2)); - param = buff2; - } - - /* We must get hash in a file ? */ - if (!strstr(param, ":")) - { - fd = fopen(param, "r"); - if (fd == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to open file", - -1); - } - - while(fgets(buff, sizeof(buff), fd) != NULL) - { - buff[strlen(buff) - 1] = '\0'; - - if (buff[0] == '#') - continue; - - if (extract_info(buff, - &addr, - &mode, - &type, - &size, - &off, - origbuffer, - sizeof(origbuffer))) - { - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bad format", -1); - } - /* Switch to the mode where the hash has been done */ - origmode = kernsh_get_mode(); - kernsh_set_mode(mode); - - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)type); - hashbuffer = kernsh_hash(addr+off, size, &nsize); - - kernsh_set_mode(origmode); - - i = 0; - tmp = buffhash; - while((i < sizeof(buffhash)) && (hashbuffer[i] != '\0')) - { - sprintf(tmp, "%02x", hashbuffer[i]); - i++; - tmp += 2; - } - - memset(buff, '\0', sizeof(buff)); - - if (!strncmp((const char *)origbuffer, - (const char *)buffhash, - sizeof(origbuffer))) - { - snprintf(buff, sizeof(buff), - "%s @ %s with size = %s and offset = %s\n", - revm_colorstr("HASH MATCH @ !"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size), - revm_colornumber("%u", off)); - revm_output(buff); - revm_endline(); - } - else - { - snprintf(buff, sizeof(buff), - "%s @ %s with size = %s and offset = %s\n %s != %s\n", - revm_colorstr("HASH MISMATCH @ !"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size), - revm_colornumber("%u", off), - revm_colorstr((char *)origbuffer), - revm_colorstr((char *)buffhash)); - revm_output(buff); - revm_endline(); - val++; - } - } - - fclose(fd); - } - else - { - if (extract_info(param, - &addr, - &mode, - &type, - &size, - &off, - origbuffer, - sizeof(origbuffer))) - { - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bad format", -1); - } - - origmode = kernsh_get_mode(); - kernsh_set_mode(mode); - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)type); - hashbuffer = kernsh_hash(addr+off, size, &nsize); - - kernsh_set_mode(origmode); - i = 0; - tmp = buffhash; - while((i < sizeof(buffhash)) && (hashbuffer[i] != '\0')) - { - sprintf(tmp, "%02x", hashbuffer[i]); - i++; - tmp += 2; - } - - if (hashbuffer == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to make hash", -1); - } - - memset(buff, '\0', sizeof(buff)); - - if (!strncmp((const char *)origbuffer, - (const char *)buffhash, - sizeof(origbuffer))) - { - snprintf(buff, sizeof(buff), - "%s @ %s with size = %s and offset = %s\n\n", - revm_colorstr("HASH MATCH @ !"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size), - revm_colornumber("%u", off)); - revm_output(buff); - } - else - { - snprintf(buff, sizeof(buff), - "%s @ %s with size = %s and offset = %s\n %s != %s\n\n", - revm_colorstr("HASH MISMATCH @ !"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size), - revm_colornumber("%u", off), - revm_colorstr((char *)origbuffer), - revm_colorstr((char *)buffhash)); - revm_output(buff); - val++; - } - } - } - - config_update_key(LIBKERNSH_VMCONFIG_HASH, (void *)stype); - - revm_setvar_int(REVM_VAR_RESULT, val); - - revm_endline(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/main.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/main.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/main.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/* -** @file main.c -** @ingroup kernsh -** $Id: main.c,v 1.7 2007-10-11 18:25:17 pouik Exp $ -** -*/ -#include "kernsh.h" -#include "info.h" - -#include "libkernsh.h" - -void kernsh_setup_quit_msg() -{ - char logbuf[BUFSIZ]; - - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - KERNSH_NAME, REVM_VERSION); - revm_quitmsg_set(logbuf); -} - -void kernsh_create_prompt(char *buf, u_int size) -{ - snprintf(buf, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - revm_colorget("%s", "psname" , KERNSH_SNAME), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", REVM_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", REVM_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", REVM_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->ws.name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -void kernsh_setup_prompt() -{ - revm_set_prompt(kernsh_create_prompt); -} - -/* Print the kernsh banner */ -void kernsh_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - KERNSH_NAME, - REVM_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - revm_output(logbuf); - - memset(logbuf, '\0', sizeof(logbuf)); - snprintf(logbuf, - sizeof(logbuf), - "\t%s\n \t%s\n \t%s\n \t%s\n \t%s\n \t%s\n\n", - revm_colorget("%s", "psname"," __ ___"), - revm_colorget("%s", "psname"," / \\ /\\ ____ ____ ____ ____ / /"), - revm_colorget("%s", "pversion"," \\ / / _\\ \\/ \\/ __\\/ /_ "), - revm_colorget("%s", "pversion"," / \\ \\ ___/ \\_/ \\ \\__ \\ \\ \\"), - revm_colorget("%s", "pedition"," \\__\\ /___ \\__/ /___/ /\\__ /__/ /"), - revm_colorget("%s", "pedition"," \\/ \\/ \\/ \\/ \\/")); - revm_output(logbuf); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* The real main function */ -int kernsh_main(int ac, char **av) -{ - int ret; - char logbuf[BUFSIZ]; - - memset(logbuf, '\0', sizeof(logbuf)); - - /* Interface tweak */ - kernsh_setup_quit_msg(); - kernsh_setup_prompt(); - - revm_setup(ac, av, 0, 0); - - setup_local_cmdhash(); - - if (strstr(ARCH, "i")) - { - ret = kernsh_init_ia32(OS, RELEASE); - if (ret == -1) - { - snprintf(logbuf, - sizeof(logbuf), - "Sorry, your os is not yet supported"); - revm_output(logbuf); - exit(-1); - } - } - /* Other arch ?? */ - else - { - snprintf(logbuf, - sizeof(logbuf), - "Sorry, your architecture is not yet supported"); - revm_output(logbuf); - exit(-1); - } - - revm_config(KERNSH_CONFIG); - - if (world.state.revm_mode != REVM_STATE_CMDLINE) - kernsh_banner_print(av[1]); - - return (revm_run(ac, av)); -} - - -/* The main Kernsh routine */ -int main(int ac, char **av) -{ - return (kernsh_main(ac, av)); -} - - - diff -Nru eresi-0.8a25/kernsh/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -## -## Makefile for kernsh -## -## Started on Mon Jun 4 21:49:42 2007 pouik -## - -include ../config.h - -SRC = main.c open.c close.c mem.c hash.c alloc.c mode.c autotypes.c tables.c misc.c virtm.c dump.c -OBJ = $(SRC:.c=.o) -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f -NAME = kernsh -NAME32 = kernsh32 -NAME64 = kernsh64 - -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -I../libstderesi/include/ \ - -I../libkernsh/include/ \ - -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI32 $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP)\ - -I../libelfsh/include/ \ - -I../libdump/include/ -I../libasm/include/ \ - -I../e2dbg/include/ -I/usr/pkg/include/ \ - -I../libui/include/ -I../libmjollnir/include/ \ - -I../libaspect/include/ -I../librevm/include/ \ - -I../libedfmt/include/ -I../libstderesi/include/ \ - -I../libkernsh/include/ \ - -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) -DERESI64 $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libedfmt/ -L../libelfsh/ -ledfmt32 -lelfsh32 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui32 -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -L../librevm/ -lrevm32 \ - -L../libetrace/ -letrace32 \ - -L../libkernsh/ -lkernsh32 -L../libstderesi/ -lstderesi32 \ - -lallocproxy $(LDMJOLLNIR) $(DLOPT) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm -L../libui/ -lui64 -g3 \ - -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -L../librevm/ -lrevm64 \ - -L../libetrace/ -letrace64 \ - -L../libkernsh/ -lkernsh64 -L../libstderesi/ -lstderesi64 \ - -lallocproxy -L../libedfmt/ -ledfmt64 $(LDMJOLLNIR) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) \ - $(EXTRAOPT) $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -all : all32 - -$(NAME32) : $(OBJ32) - $(CC) $(OBJ32) -o $(NAME32) $(LDFLAGS32) $(STATOPT) - -$(NAME64) : $(OBJ64) - @$(CC) $(OBJ64) -o $(NAME64) $(LDFLAGS64) $(STATOPT) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) *~ \#* *\# .\#* *.32.o *.64.o - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) $(NAME) $(NAME32) $(NAME64) $(OBJ_DYN) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/kernsh/.svn/text-base/mem.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/mem.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/mem.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/mem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,687 +0,0 @@ -/* -** @file mem.c -** @ingroup kernsh -** $Id: mem.c,v 1.14 2008-02-16 12:32:26 thor Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -/* Handle the sys_call_table */ -int cmd_sct() -{ - int ret; - int index; - listent_t *actual; - list_t *h; - libkernshsyscall_t *sct; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); - elist_init(h, "cmd_sct_list", ASPECT_TYPE_UNKNOW); - ret = kernsh_sct(h); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] SYS_CALL_TABLE")); - revm_output(buff); - - for (index = 0, actual = h->head; - index < h->elmnbr; - index++, actual = actual->next) - { - sct = (libkernshsyscall_t *) actual->data; - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %-40s %s %s\n", - revm_colornumber("id:%-10u", (unsigned int)index), - revm_colortypestr_fmt("%s", sct->name), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) sct->addr)); - revm_output(buff); - revm_endline(); - - } - - revm_output("\n"); - elist_destroy(h); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get syscalltable", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Handle the idt */ -int cmd_idt() -{ - int ret; - int index; - listent_t *actual; - list_t *h; - libkernshint_t *dint; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); - elist_init(h, "cmd_idt_list", ASPECT_TYPE_UNKNOW); - ret = kernsh_idt(h); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] IDT")); - revm_output(buff); - - for (index = 0, actual = h->head; - index < h->elmnbr; - index++, actual = actual->next) - { - dint = (libkernshint_t *) actual->data; - - snprintf(buff, sizeof(buff), - "%s %-40s %s %s\n", - revm_colornumber("id:%-10u", (unsigned int)index), - revm_colortypestr_fmt("%s", dint->name), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) dint->addr)); - revm_output(buff); - revm_endline(); - } - - revm_output("\n"); - elist_destroy(h); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get idt", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Handle the gdt */ -int cmd_gdt() -{ - int ret; - int index; - int i; - listent_t *actual; - list_t *h; - libkernshsgdt_t *sgdt; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); - - elist_init(h, "cmd_gdt_list", ASPECT_TYPE_UNKNOW); - - ret = kernsh_gdt(h); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] GDT")); - revm_output(buff); - - for (i = 0, index = 0, actual = h->head; - index < h->elmnbr; - i+=8, index++, actual = actual->next) - { - sgdt = (libkernshsgdt_t *) actual->data; - - snprintf(buff, sizeof(buff), - "%s%s %s %s\n", - revm_coloraddress("%.8lX", (eresi_Addr) sgdt->deb), - revm_coloraddress("%.8lX", (eresi_Addr) sgdt->fin), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) sgdt->addr)); - - revm_output(buff); - - revm_endline(); - } - - revm_output("\n"); - elist_destroy(h); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get gdt", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Handle kernel symbol */ -int cmd_ksym() -{ - char *param; - char buff[BUFSIZ]; - unsigned long addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - param = world.curjob->curcmd->param[0]; - - if (param) - { - if(kernsh_get_addr_by_name(param, &addr, strlen(param))) - { - revm_setvar_int("_", -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get symbol", -1); - } - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s %s %s %s %s\n\n", - revm_colorfieldstr("SYMBOL"), - revm_colorstr(param), - revm_colorfieldstr("is"), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr)); - revm_output(buff); - revm_setvar_long("_", addr); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_kmodule_relink() -{ - int ret; - char *param, *param2, *param3; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - param = world.curjob->curcmd->param[0]; - param2 = world.curjob->curcmd->param[1]; - param3 = world.curjob->curcmd->param[2]; - - if (param && param2) - { - ret = kernsh_relink_module(param, param2, param3); - if (ret == 0) - { - if (param3 == NULL) - param3 = param; - snprintf(buff, sizeof(buff), - "Module %s and %s is linked in %s\n\n", - revm_colorstr(param), - revm_colorstr(param2), - revm_colorstr(param3)); - revm_output(buff); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kmodule_infect() -{ - int ret; - char *param, *param2, *param3; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - param = world.curjob->curcmd->param[0]; - param2 = world.curjob->curcmd->param[1]; - param3 = world.curjob->curcmd->param[2]; - - if (param && param2 && param3) - { - ret = kernsh_infect_module(param, param2, param3); - if (ret == 0) - { - snprintf(buff, sizeof(buff), - "%s have been replaced by %s in %s\n\n", - revm_colorstr(param), - revm_colorstr(param2), - revm_colorstr(param3)); - revm_output(buff); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kmodule_load() -{ - int ret; - char *filename; - char buff[BUFSIZ]; - - ret = -1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - filename = world.curjob->curcmd->param[0]; - - if (filename) - { - ret = kernsh_kload_module(filename); - if (ret == 0) - { - snprintf(buff, sizeof(buff), - "Module %s is loaded\n\n", - revm_colorstr(filename)); - revm_output(buff); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kmodule_unload() -{ - int ret; - char *filename; - char buff[BUFSIZ]; - - ret = -1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - filename = world.curjob->curcmd->param[0]; - - if (filename) - { - ret = kernsh_kunload_module(filename); - if (ret == 0) - { - snprintf(buff, sizeof(buff), - "Module %s is unloaded\n\n", - revm_colorstr(filename)); - revm_output(buff); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kmem_info() -{ - char buff[BUFSIZ]; - char *data; - int val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_DEVICE); - snprintf(buff, sizeof(buff), - "DEVICE : %s\n", - data); - revm_output(buff); - - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_MODE); - snprintf(buff, sizeof(buff), - "FLAGS : %s\n", - data); - revm_output(buff); - - switch(libkernshworld.mem) - { - case LIBKERNSH_MEM_MODE : - snprintf(buff, sizeof(buff), - "MODE : DYNAMIC\n"); - break; - case LIBKERNSH_STATIC_MODE : - snprintf(buff, sizeof(buff), - "MODE : STATIC\n"); - break; - } - revm_output(buff); - - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP); - snprintf(buff, sizeof(buff), - "SYSTEMMAP : %s\n", - data); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_MMAP); - switch (val) - { - case 0 : - snprintf(buff, sizeof(buff), - "MMAP : OFF\n"); - break; - case 1 : - snprintf(buff, sizeof(buff), - "MMAP : ON\n"); - break; - } - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_MMAP_SIZE); - snprintf(buff, sizeof(buff), - "MMAP_SIZE : 0x%lx\n", - (unsigned long)val); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_KERNEL_START); - snprintf(buff, sizeof(buff), - "KERNEL_START : 0x%lx\n", - (unsigned long)val); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_KERNEL_END); - snprintf(buff, sizeof(buff), - "KERNEL_END : 0x%lx\n", - (unsigned long)val); - revm_output(buff); - - data = (char *)config_get_data(LIBKERNSH_VMCONFIG_KERNEL); - snprintf(buff, sizeof(buff), - "KERNEL : %s\n", - data); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_USE_KERNEL); - switch (val) - { - case 0 : - snprintf(buff, sizeof(buff), - "USE_KERNEL : OFF\n"); - break; - case 1 : - snprintf(buff, sizeof(buff), - "USE_KERNEL : ON\n"); - break; - } - revm_output(buff); - - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_ALLOC); - switch (val) - { - case 0 : - snprintf(buff, sizeof(buff), - "ALLOC : CONTIGUOUS\n"); - break; - case 1 : - snprintf(buff, sizeof(buff), - "ALLOC : NO CONTIGUOUS\n"); - break; - } - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS); - snprintf(buff, sizeof(buff), - "NB_SYSCALLS : %d\n", - val); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL); - snprintf(buff, sizeof(buff), - "NIL_SYSCALL : %d\n", - val); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_USEVM); - switch (val) - { - case 0 : - snprintf(buff, sizeof(buff), - "USE_VM : OFF\n"); - break; - case 1 : - snprintf(buff, sizeof(buff), - "USE_VM : ON\n"); - break; - } - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - switch (val) - { - case LIBKERNSH_KERNEL_MODE: - snprintf(buff, sizeof(buff), - "VIRTM : PROC\n"); - break; - case LIBKERNSH_USER_MODE : - snprintf(buff, sizeof(buff), - "VIRTM : SYSCALL\n"); - break; - } - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL); - snprintf(buff, sizeof(buff), - "VIRTM_NIL_SYSCALL : %d\n", - val); - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); - switch (val) - { - case LIBKERNSH_HASH_MD5: - snprintf(buff, sizeof(buff), - "HASH : MD5\n"); - break; - case LIBKERNSH_HASH_SHA1 : - snprintf(buff, sizeof(buff), - "HASH : SHA1\n"); - break; - } - revm_output(buff); - - val = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); - switch (val) - { - case LIBKERNSH_VMA_USERLAND: - snprintf(buff, sizeof(buff), - "VMA : USERLAND\n"); - break; - case LIBKERNSH_VMA_KERNELLAND : - snprintf(buff, sizeof(buff), - "VMA : KERNELLAND\n"); - break; - } - revm_output(buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_kmem_read() -{ - int ret, len; - char *new_buff; - eresi_Addr addr; - revmlist_t *actual; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = len = 0; - addr = 0; - - actual = world.curjob->curcmd->disasm + 0; - - if (actual) - { - kernsh_addrlen(actual, &addr, &len); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new_buff, - len, - -1); - - memset(new_buff, '\0', len); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Reading kernel memory %s %s strlen(%s)\n\n", - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", len)); - revm_output(buff); - - ret = kernsh_readmem(addr, new_buff, len); - - kernsh_hexdump((unsigned char *)new_buff, len, addr); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); - } - - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to read mem", - -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_kmem_write() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - void *dat; - int ret, size; - eresi_Addr addr; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Needs 2 parameters", -1); - - if (IS_VADDR(world.curjob->curcmd->param[0])) - { - if (sscanf(world.curjob->curcmd->param[0] + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", - -1); - } - else - { - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - o1 = e1->value; - switch (o1->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - addr = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - break; - - case ASPECT_TYPE_INT: - addr = (o1->immed ? o1->immed_val.word : o1->get_obj(o1->parent)); - break; - } - } - - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - - o2 = e2->value; - - /* Convert Integers into raw data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - if (revm_convert_object(e2, ASPECT_TYPE_RAW) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert dest object to RAW", (-1)); - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - size = o2->size; - - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - printf("WRITE @ 0x%lx %d %d %s\n", - (unsigned long)addr, - size, - strlen(world.curjob->curcmd->param[1]), - world.curjob->curcmd->param[1]); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Writing into kernel memory %s %s strlen(%s)\n\n", - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size)); - revm_output(buff); - - kernsh_hexdump((unsigned char *)dat, size, (unsigned int)dat); - ret = kernsh_writemem(addr, dat, size); - - if (ret != size) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to write mem", - -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_kmem_disasm() -{ - int ret, len; - eresi_Addr addr; - char *new_buff; - revmlist_t *actual; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = len = 0; - addr = 0; - - actual = world.curjob->curcmd->disasm + 0; - - if (actual) - { - kernsh_addrlen(actual, &addr, &len); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new_buff, - len, - -1); - - memset(new_buff, '\0', len); - - ret = kernsh_readmem(addr, new_buff, len); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Disassembling kernel memory %s %s strlen(%s)\n\n", - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", len)); - revm_output(buff); - - kernsh_disasm(new_buff, len, addr); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); - } - - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to read mem", - -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,195 +0,0 @@ -/* -** @file misc.c -** @ingroup kernsh -*/ -#include "kernsh.h" -#include "libkernsh.h" - -int kernsh_hexdump(unsigned char * data, - unsigned int amount, - size_t addr) -{ - unsigned int dp; - unsigned int p; - const char trans[] = - "................................ !\"#$%&'()*+,-./0123456789" - ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklm" - "nopqrstuvwxyz{|}~...................................." - "....................................................." - "........................................"; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for ( dp = 1; dp <= amount; dp++ ) - { - if ( (dp % 16) == 1 ) - { - fprintf( stdout, "%#08x | ", addr+dp-1 ); - } - - fprintf( stdout, "%02x ", data[dp-1] ); - if ( (dp % 8) == 0 && (dp % 16) != 0 ) - { - fputs( " ", stdout ); - } - if ( (dp % 16) == 0 ) - { - fputs( "| ", stdout ); - p = dp; - for ( dp -= 16; dp < p; dp++ ) - { - fprintf( stdout, "%c", trans[data[dp]] ); - } - fputs( "\n", stdout ); - } - } - - if ( (amount % 16) != 0 ) - { - p = dp = 16 - ( amount % 16 ); - for ( dp = p; dp > 0; dp-- ) - { - fputs( " ", stdout ); - if ( ((dp % 8) == 0) && (p != 8) ) - { - fputs( " ", stdout ); - } - } - fputs( "| ", stdout ); - for ( dp = (amount - (16 - p)); dp < amount; dp++ ) { - fprintf( stdout, "%c", trans[data[dp]] ); - } - } - - fputs( "\n", stdout ); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -u_int kernsh_instr_display(u_int index, eresi_Addr vaddr, - u_int foffset, u_int size, char *name, - u_int nindex, char *buff) - -{ - char *s; - char buf[256]; - u_int idx_bytes; - u_int ret; - asm_instr ptr; - char base[16] = "0123456789ABCDEF"; - char logbuf[BUFSIZ]; - char c1[2]; - char c2[2]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!buff) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - - /* Print the instr. itself : vaddr and relative symbol resolution */ - ret = asm_read_instr(&ptr, (u_char *)buff + index, size - index, - &libkernshworld.proc); - if (ret == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "asm_read_instruction faild (-1)", (ret)); - - s = (!ret ? "(bad)" : asm_display_instr_att(&ptr, (vaddr))); - - snprintf(buf, sizeof(buf), "%s", - revm_coloraddress(XFMT, vaddr + index)); - size = snprintf(logbuf, BUFSIZ, "%-40s %-30s ", - buf, revm_colorinstr(s)); - - /* Print bytes in hexa for this instruction */ - ret = asm_instr_len(&ptr); - if (!ret) - ret++; - - for (idx_bytes = 0; idx_bytes < ret; idx_bytes++) - { - c1[0] = base[(buff[index + idx_bytes] >> 4) & 0x0F]; - c2[0] = base[buff[index + idx_bytes] & 0x0F]; - c1[1] = c2[1] = 0x00; - size += snprintf(logbuf + size, sizeof(logbuf) - size, "%s%s ", - revm_colorfieldstr(c1), - revm_colorfieldstr(c2)); - } - - revm_output(logbuf); - revm_output("\n"); - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -int kernsh_disasm(char *buffer, int len, unsigned long addr) -{ - - int index, value; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - index = 0; - while(index < len && len > 0) - { - value = kernsh_instr_display(index, addr, index, len, NULL, 0, buffer); - if (value <= 0) - break; - - index += value; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_addrlen(revmlist_t *actual, eresi_Addr *addr, int *len) -{ - revmexpr_t *expr; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!actual) - { - *addr = 0; - *len = 0; - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid revmlist", - -1); - } - - /* Is it directly an addr ? */ - if (IS_VADDR(actual->rname)) - { - if (sscanf(actual->rname + 2, AFMT, addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", - -1); - } - /* Get the value of the object */ - else - { - expr = revm_lookup_param(actual->rname); - - obj = expr->value; - - switch (obj->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - *addr = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - break; - - case ASPECT_TYPE_INT: - *addr = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - break; - } - } - - *len = actual->size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/mode.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/mode.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/mode.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/mode.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* -** @file mode.c -** @ingroup kernsh -** $Id: mode.c,v 1.4 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -/* Switch mode : static/dynamic */ -int cmd_kmode() -{ - char *param; - char buf[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - param = world.curjob->curcmd->param[0]; - - if (param) - { - if (*param == 's' || *param == 'S') - { - if (!libkernshworld.open_static) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Static kernel is not loaded !", -1); - - kernsh_set_static_mode(); - revm_output("[*] kernsh is now in STATIC mode\n\n"); - } - else if (*param == 'd' || *param == 'D') - { - if (!libkernshworld.open) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to switch to dynamic mode, please open the memory !", -1); - - kernsh_set_mem_mode(); - revm_output("[*] kernsh is now in DYNAMIC mode\n\n"); - } - - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown mode for kernsh !", -1); - } - } - else - { - if (kernsh_is_static_mode()) - param = "STATIC"; - - else if (kernsh_is_mem_mode()) - param = "DYNAMIC"; - - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown kernsh mode", -1); - - snprintf(buf, sizeof(buf), "[*] kernsh is in %s MODE\n\n", param); - revm_output(buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/open.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/open.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/open.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/open.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,145 +0,0 @@ -/* -** @file open.c -** @ingroup kernsh -** $Id: open.c,v 1.10 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "kernsh.h" -#include "libkernsh.h" - -int export_var(char *name, - unsigned long vallong, - int valint, - char *valstr, - int choice) -{ - char param1[BUFSIZ]; - char param2[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(param1, '\0', sizeof(param1)); - memset(param1, '\0', sizeof(param2)); - - snprintf(param1, - sizeof(param1), - "$%s", - name); - - switch (choice) - { - case 0 : - snprintf(param2, - sizeof(param2), - "%d", - valint); - break; - - case 1 : - snprintf(param2, - sizeof(param2), - "0x%lx", - vallong); - break; - - case 2 : - snprintf(param2, - sizeof(param2), - "%s", - valstr); - break; - - default : - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid choice", (-1)); - } - - world.curjob->curcmd->param[0] = param1; - world.curjob->curcmd->param[1] = param2; - - cmd_set(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int export_vars() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __KERNSH_DEBUG__ - printf("EXPORT VARS\n"); -#endif - - export_var("sct", libkernshworld.sct, 0, NULL, 1); - export_var("idt_base", libkernshworld.idt_base, 0, NULL, 1); - export_var("idt_limit", 0, libkernshworld.idt_limit, NULL, 0); - export_var("gdt_base", libkernshworld.gdt_base, 0, NULL, 1); - export_var("gdt_limit", 0, libkernshworld.gdt_limit, NULL, 0); - -#if defined (__linux__) - export_var("system_call", libkernshworld.system_call, 0, NULL, 1); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Open the memory device */ -int cmd_openmem() -{ - int ret; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if no static is set */ - if (!(int) config_get_data(LIBKERNSH_VMCONFIG_WITHOUT_KERNEL)) - { - if(!(int) config_get_data(LIBKERNSH_VMCONFIG_USE_KERNEL)) - { - /* Gunzip/Extract the kernel */ - ret = kernsh_decompkernel(); - } - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, - sizeof(buff), - "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); - - ret = revm_file_load(buff, 0, NULL); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load kernel", -1); - - libkernshworld.root = revm_lookup_file(buff); - if (libkernshworld.root == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get elf file", -1); - } - libkernshworld.open_static = 1; - } - else - { - kernsh_set_mem_mode(); - } - - /* Open memory */ - ret = kernsh_openmem(); - - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot open memory", -1); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "%s\n\n", - revm_colorfieldstr("[+] OPEN MEMORY")); - revm_output(buff); - revm_endline(); - export_vars(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/README.configure.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/README.configure.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/README.configure.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/README.configure.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -------[ Kernsh Configure ]------ - -[+] Options : - -An option can be set directly in the shell or in the .kernshrc : - configure libkernsh.OPTION VALUE - -[ - legends : (D) => default, - (L) => specific to Linux, - (N) => specific to Netbsd, - (F) => specific to Freebsd - - [S*] => any string value - [I*] => any integer value - [L*] => any long value -] - - - libkernsh.device : The memory device which will be opened - - /dev/mem (D) - - /dev/kmem (L) - - /proc/kcore (L) - - kvirtm (L) - - - libkernsh.mode : The mode to open the memory - - read - - write (D) - - - libkernsh.mmap : Mmap the memory - - 0 - - 1 (D) - - - libkernsh.mmap_size : Mmap's size of the main memory - - 1000 * 1024 * 1024 (D) - - [I*] - - - libkernsh.systemmap : (L) Path of the system map - - /boot/System.map-`uname -r` (D) - - [S*] - - - libkernsh.kernel : Path of the gzip kernel - - /boot/vmlinuz (D) (L) - - [S*] - - - libkernsh.gzipcmd : Which is the gzid command - - /bin/gzip (D) (L) - - [S*] - - - libkernsh.objcopycmd : Which is the objcopy command - - /bin/objcopy (D) (L) - - [S*] - - - - libkernsh.ldcmd : Which is the ld command - - /bin/ld (D) (L) - - [S*] - - - libkernsh.kload : Which is the insert kernel module command - - /bin/insmod (D) (L) - - [S*] - - - libkernsh.kunload : Which is the remove kernel module command - - /bin/rmmod (D) (L) - - [S*] - - - libkernsh.kernelgz : The name to save the extract gzip kernel - - vmlinuz.gz (D) (L) - - [S*] - - - libkernsh.kernelelf : The name of the extract/gunzip kernel - - vmlinux (D) (L) - - [S*] - - - libkernsh.storagepath : A path to store kernel and to - open debug kernel - - /tmp/ (D) - - [S*] - - - libkernsh.nbsyscalls : The number of syscalls - - 320 (D) (L) - - [I*] - - - libkernsh.nilsyscalls : A position inside the syscall table - of a free syscall - - 17 (D) (L) - - [I*] - - - libkernsh.use_kernel : use the full debug kernel(not the gzip kernel) - - 0 (D) - - 1 - - - libkernsh.without_kernel : not use the kernel, only memory - - 0 (D) - - 1 - - - libkernsh.kernel_start : address of kernel start - - 0xc0000000 (D) (L) - - [L*] - - - libkernsh.kernel_end : address of kernel end - - 0xc1000000 (D) (L) - - [L*] - - - libkernsh.alloc : alloc/free contiguous memory(0) - or non contiguous(1) - - 0 (D) - - 1 - - - libkernsh.fendsize : maximum size of a function - - 0x1000 (D) - - [L*] - - - libkernsh.usevm : To inform kernsh that we are in a virtual machine - - 0 (D) - - 1 - - - libkernsh.specify_idtbase : Specify idt base address and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.specify_idtlimit : Specify idt limit value and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.specify_gdtbase : Specify gdt base address and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.specify_gdtlimit : Specify gdt limit value and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.specify_systemcall : Specify system call address and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.specify_sct : Specify syscall table address and not allow libkernsh to search - - 0 (D) - - [L*] - - - libkernsh.virtm : Communication type (/proc or syscall) with kernsh-virtm module - - LIBKERNSH_KERNEL_MODE 0 (D) {/proc} - - LIBKERNSH_USER_MODE 1 {syscall} - - - libkernsh.virtm_nil_syscall : A position inside the syscall table of a free syscall for virtm - - 31 (D) (L) - - [I*] - - - libkernsh.hash : The type of hash - - LIBKERNSH_HASH_MD5 0 (D) - - LIBKERNSH_HASH_SHA1 1 - - - libkernsh.vma : In which context(kernel/user) to use VMA - - LIBKERNSH_VMA_USERLAND 0 (D) - - LIBKERNSH_VMA_KERNELLAND 1 - - - libkernsh.vma_prefix : VMA prefix string to export list_t (and hash_t) - - vma (D) - - [S*] - - - libkernsh.dump_vma_prefix : Dump VMA prefix to export dump file - - kernsh_dump (D) - - [S*] - -Add new configure ? No problems, send me mail (or your patch :)) ! \ No newline at end of file diff -Nru eresi-0.8a25/kernsh/.svn/text-base/README.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/README.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/README.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/README.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,401 +0,0 @@ - ]=------ Kernsh ------=[ - - -Kernsh uses Libkernsh which is a library to play with kernel image in real -time or on disk. - -You can obtain all information necessary about kernel(syscalls, idt, gdt, -symbols, ...), insert module inside the memory, hijack functions, etc - -You can profite of eresi's language to define you own structure and -communicate with the kernel. - -Features : - - Read/Write anywhere in the kernel (static/memory ((/dev/(k)mem, - /proc/kcore, lkm (/proc, syscall))), direcly in ERESI language - - Consultation and modification of Linux 2.4 and 2.6 kernel structures - (syscall table, etc) and symbols - - Consultation and modification of INTEL specific kernel structures - (IDT, GDT, etc) - - Disassembling kernel memory - - Read and modify the static kernel image - - Alloc/Free kernel memory (contiguous and non contiguous) - - Inject new compiled LKM code into a static kernel or kernel memory - - Make hash of kernel function and portion of code - - Redirect initialisation of loadable kernel module - - Kernel function redirection - - Read/Write into process virtual memory (/proc, syscall) - - Dump Virtual Memory Area of process id (/proc, syscall) - -Depends libkernsh : libaspect, libstderesi, libelfsh -Depends kernsh : libkernsh, librevm, libaspect, libstderesi - - -[+] Installation - - -Compile Eresi with --enable-kernsh during configure. "make" and "make install". - - -By default, Libkernsh do the following action : - - Load ~/.kernshrc - - If libkernsh.without_kernel is set to 0 - - If libkernsh.use_kernel is set to 1 : - - Open libkernsh.storagepath + libkernsh.kernelelf - - - Else : - - Open libkernsh.storagepath + libkernsh.kernel - - Extract/Gunzip it - - Open the final kernel - - - Open memory device in libkernsh.device with mode libkernsh.mode - and mmap it if libkernsh.mmap is set to 1 (with a size of - libkernsh.mmap_size). - - - Have fun ! - -You can configure all libkernsh.*, see file README.configure - -[+] Portability : - - ------------------------------------------------------------- -| \ ARCH | IA32 | SPARC | SPARC64 | MIPS | ALPHA | -| OS \ | | | | | | - ------------------------------------------------------------- -| LINUX 2.4 | DONE | UT | UT | UT | UT | -| | | | | | | - ------------------------------------------------------------- -| LINUX 2.6 | DONE | UT | UT | UT | UT | -| | | | | | | - ------------------------------------------------------------- -| NETBSD | WIP | / | / | / | / | -| | | | | | | - ------------------------------------------------------------- -| FREEBSD | WIP | / | / | / | / | -| | | | | | | - ------------------------------------------------------------- - - -[ - legends : - - WIP : Work In Progress - - UT : Untested -] - - -[+] Commands : - - openmem : Done - func : open kernel memory and by default - gzip static kernel - args : no - return : / - configure : LIBKERNSH_VMCONFIG_KERNEL_START, LIBKERNSH_VMCONFIG_KERNEL_END, - LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_MODE, - LIBKERNSH_VMCONFIG_MMAP, LIBKERNSH_VMCONFIG_MMAP_SIZE, - LIBKERNSH_VMCONFIG_SYSTEMMAP, LIBKERNSH_VMCONFIG_USEVM, - LIBKERNSH_VMCONFIG_VIRTM - mode : / - - - closemem : Done - func : close kernel memory and static kernel - args : no - return : int - configure : LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_VIRTM - mode : / - - - mode : Done - func : with no args display the mode - args : yes (not obligatory), "static" and "dynamic" - return : / - configure : - mode : / - - - kmem_read : Done - func : Read kernel memory - args : sa%size - - sa : Symbol or addr - - size : Bytes number limit - - return : / - configure : LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kmem_write : Done - func : Write in kernel memory - args : sa buffer - - sa : Symbol or addr - - buffer : the string to write - return : / - configure : LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kmem_disasm : Done - func : Disasm kernel memory - args : sa%size - - sa : Symbol or addr - - size : Bytes number limit - return : / - configure : LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kmem_info : Done - func : Display configure in human mode :) - args : / - return : / - configure : / - mode : / - - - sct : Done - func : handle the syscall table - args : display syscall table - return : / - configure : LIBKERNSH_VMCONFIG_NB_SYSCALLS - mode : static/dynamic - - - idt : Done - func : handle the idt - args : display the idt - return : / - options : / - mode : dynamic - - - gdt : Done - func : handle the gdt - args : display the gdt - return : no - options : / - mode : static/dynamic - - - alloc : Done - func : alloc contiguous kernel memory - args : size (mandatory) - return : $_ is set with the return address - configure : LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL - mode : dynamic - - - free : Done - func : free contiguous kernel memory - args : addr (mandatory) - return : $_ is set with the return value - configure : LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL - mode : dynamic - - - alloc_nc : Done - func : alloc non contiguous kernel memory - args : size (mandatory) - return : $_ is set with the return address - configure : LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL - mode : dynamic - - - free_nc : Done - func : free non contiguous kernel memory - args : addr (mandatory) - return : $_ is set with the return value - configure : LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL - mode : dynamic - - - kmodule_relink : Done - func : link module with another - args : module1 module2 moduleres - - module1 : first module's pathname (mandatory) - - module2 : second module's pathname (mandatory) - - moduleres : result of two modules (mandatory) - return : / - configure : LIBKERNSH_VMCONFIG_LD - mode : / - - - kmodule_infect : Done - func : infect a module - args : module original_name evil_name - - module : module's pathname (mandatory) - - original_name : name of the hijacked function - - evil_name : name of the hijack function - return : / - configure : / - mode : static - - - kmodule_load : Done - func : load a module - args : module - - module : module's pathname (mandatory) - return : / - configure : LIBKERNSH_VMCONFIG_KLOAD - mode : / - - - kmodule_unload : Done - func : unload a module - args : module - - module : module's name (mandatory) - return : / - configure : LIBKERNSH_VMCONFIG_KUNLOAD - mode : / - - - ksym : Done - func : get an address of a kernel symbol - args : symbol's name - return : $_ is set with the return address - configure : / - mode : dynamic - - - autotypes : WIP - func : / - args : / - return : / - configure : / - mode : / - - - kvirtm_info : WIP - func : / - args : / - return : / - configure : / - mode : / - - - kvirtm_loadme : Done - func : Load kernsh virtm module automatically with hijack syscall table ! - args : module - - module : module's pathname (mandatory) - return : / - configure : LIBKERNSH_VMCONFIG_KLOAD, LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL - mode : / - - - kvirtm_read_pid : Done - func : Read virtual memory of a pid - args : pid sa%size - - pid : process id - - sa : Symbol or addr - - size : Bytes number limit - return : / - configure : LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kvirtm_write_pid : Done - func : Write virtual memory of a pid - args : pid sa buffer - - pid : process id - - sa : Symbol or addr - - buffer : the string to write - return : / - configure : LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kvirtm_disasm_pid : Done - func : Disasm virtual memory of a pid - args : pid sa%size - - pid : process id - - sa : Symbol or addr - - size : Bytes number limit - return : / - configure : LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - kvirtm_dump : Done - func : Dump elf binary pid - args : pid filename - - pid : process id - - filename : dump's path - return : / - configure : / - mode : dynamic - - - kvirtm_task_pid : Done - func : Get task struct of a process id - args : pid - - pid : process id - return : / - configure : LIBKERNSH_VMCONFIG_VIRTM - mode : dynamic - - - process : WIP - - - kmem_hash : - func : Make a hash message digest - args : sa output, sa:rva output, sa%rva%size output, sa%size output - - sa : Symbol or addr - - rva : Byte offset form the beginning (optional) - - size : Bytes number limit (optional) - - If size is 0 or not put, we search - the end of the function. - - output : file output (optional) - - return : $_ contains the hash and $hash contains the format - options : / - mode : static/dynamic - - - kmem_chash : - func : Check a hash message diges - args : format, file - - format : addr:mode:size:off:hash - - file : filename - return : $_ is egal to the number of mismatch - options : / - mode : static/dynamic - - - kdump_get_vma : WIP - func : Get vma of a process id - args : pid - - pid : process id - return : / - configure : LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA - mode : dynamic - - - kdump_vma : Done - func : Dump vma of a process id - args : pid - - pid : process id - return : / - configure : LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA, - LIBKERNSH_VMCONFIG_STORAGE_PATH - mode : dynamic - -[+] Variables - -Some variables are available when the memory device is opened : - $sct (D) - $idt_base (D) - $idt_limit (D) - $gdt_base (D) - $gdt_limit (D) - $system_call (D) (L) - -[+] Kernshrc - -You can use a .kernshrc in your home directory. There is some kernshrc in doc directory. - -[+] Examples - -See examples directory. - -[+] Authors - -Original version (0.1 => 0.2c) started in 2001 and original authors (Thanks !) : - sauron, zorgon, kstat - -The project has been transfered to pouik in 2007. - -[+] Contacts - -Information about kernsh : desnos at -nospam-eresi-project.org - -[+] Bugs - -Please use trac's ticket at http://www.eresi-project.org/ - -Compile libkernsh in debug mode, change in libkernsh/include/libkernsh.h -the define : - #define __DEBUG_KERNSH__ 0 -=> - #define __DEBUG_KERNSH__ 1 - -and in libkernsh/kernel/include/libkernsh-kernel.h the define : - #define __DEBUG_LIBKERNSH_KERNEL__ 0 -=> - #define __DEBUG_LIBKERNSH_KERNEL__ 1 - -and with --enable-testing to avoid old library - -[+] Url - -eresi : http://www.eresi-project.org - -kernsh : http://www.kernsh.org diff -Nru eresi-0.8a25/kernsh/.svn/text-base/README.vectors.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/README.vectors.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/README.vectors.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/README.vectors.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ - ------[ Kernsh Vectors ]------ - - -{OPEN/CLOSE/READ/WRITE}MEM => Open/Close/Read/Write Kernel Memory - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -DEVICETYPE : LIBKERNSH_DEVICE_KMEM, LIBKERNSH_DEVICE_MEM, - LIBKERNSH_DEVICE_KCORE, LIBKERNSH_DEVICE_KVIRTM - -STATE : Done - -LIBKERNSH_VECTOR_NAME_SCT : handle the syscall table - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_CALLSC : Call a syscall - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_IDT : handle the idt - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_GDT : handle the gdt - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_INFO : Get information about kernel variables - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_DECOMPKERNEL : Unzip the kernel image - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : WIP - -LIBKERNSH_VECTOR_NAME_ADDRBYNAME : Get an address of a kernel symbol - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_NAMEBYADDR : Get a symbol's name of a kernel address - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_ALLOC{NON}CONTIGUOUS : Alloc {non}contiguous kernel memory - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_FREE{NON}CONTIGUOUS : Free {non}contiguous kernel memor - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_AUTOTYPES : Create kernel struct without include - -ARCHTYPE : LIBKERNSH_ARCH_I386 -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : WIP - -LIBKERNSH_VECTOR_NAME_{RELINK/INFECT/KLOAD/KUNLOAD}MODULE : Relink/Infect/Load/Unload loadable kernel module - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 - -STATE : Done - -LIBKERNSH_VECTOR_NAME_KVIRTM{READ/WRITE}VIRTM : Read/Write into process virtual memory - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -VIRTMTYPE : LIBKERNSH_KERNEL_MODE, LIBKERNSH_USER_MODE - -STATE : Done - -LIBKERNSH_VECTOR_NAME_KVIRTM{READ/WRITE}MEM : Read/Write into kernel memory with LKM - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -VIRTMTYPE : LIBKERNSH_KERNEL_MODE, LIBKERNSH_USER_MODE - -STATE : Done - -LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID : Get task struct - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -VIRTMTYPE : LIBKERNSH_KERNEL_MODE, LIBKERNSH_USER_MODE - -STATE : Done - -LIBKERNSH_VECTOR_NAME_KDUMPGETVMA : Get VMA of a process - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -VMATYPE : LIBKERNSH_VMA_KERNELLAND, LIBKERNSH_VMA_USERLAND - -STATE : Done LIBKERNSH_VMA_USERLAND - : WIP LIBKERNSH_VMA_KERNELLAND - -LIBKERNSH_VECTOR_NAME_KDUMPVMA : Dump VMA of a process - -OSTYPE : LIBKERNSH_OS_LINUX_2_6, LIBKERNSH_OS_LINUX_2_4 -VMATYPE : LIBKERNSH_VMA_KERNELLAND, LIBKERNSH_VMA_USERLAND - -STATE : Done \ No newline at end of file diff -Nru eresi-0.8a25/kernsh/.svn/text-base/tables.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/tables.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/tables.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/tables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,167 +0,0 @@ -/* -** @file tables.c -** @ingroup kernsh -** -*/ -#include "kernsh.h" - -/* Setup the command hash table */ -void setup_local_cmdhash() -{ - revm_command_add(CMD_OPENMEM , (void *) cmd_openmem, - (void *) NULL, - 0, - HLP_OPENMEM); - - revm_command_add(CMD_CLOSEMEM, (void *) cmd_closemem, - (void *) NULL, - 0, - HLP_CLOSEMEM); - - revm_command_add(CMD_KMODE, (void *)cmd_kmode, - (void*) revm_getvarparams, - 0, - HLP_KMODE); - - revm_command_add(CMD_SCT, (void *)cmd_sct, (void *) NULL, 0, HLP_SCT); - - revm_command_add(CMD_IDT, (void *)cmd_idt, (void *) NULL, 0, HLP_IDT); - - revm_command_add(CMD_GDT, (void *)cmd_gdt, (void *) NULL, 0, HLP_GDT); - - revm_command_add(CMD_KALLOC, (void *)cmd_kalloc, - (void*) revm_getvarparams, - 0, - HLP_KALLOC); - - revm_command_add(CMD_KFREE, (void *)cmd_kfree, - (void*) revm_getvarparams, - 0, - HLP_KFREE); - - revm_command_add(CMD_KALLOCNC, (void *)cmd_kallocnc, - (void*) revm_getvarparams, - 0, - HLP_KALLOCNC); - - revm_command_add(CMD_KFREENC, (void *)cmd_kfreenc, - (void*) revm_getvarparams, - 0, - HLP_KFREENC); - - revm_command_add(CMD_KSYM, (void *)cmd_ksym, - (void*) revm_getvarparams, - 0, - HLP_KSYM); - - revm_command_add(CMD_KMODULE_RELINK, (void *)cmd_kmodule_relink, - (void*) revm_getvarparams, - 0, - HLP_KMODULE_RELINK); - - revm_command_add(CMD_KMODULE_INFECT, (void *)cmd_kmodule_infect, - (void*) revm_getvarparams, - 0, - HLP_KMODULE_INFECT); - - revm_command_add(CMD_KMODULE_LOAD, (void *)cmd_kmodule_load, - (void*) revm_getvarparams, - 0, - HLP_KMODULE_LOAD); - - revm_command_add(CMD_KMODULE_UNLOAD, (void *)cmd_kmodule_unload, - (void*) revm_getvarparams, - 0, - HLP_KMODULE_UNLOAD); - - revm_command_add(CMD_AUTOTYPES, (void *)cmd_autotypes, - (void *) NULL, - 0, - HLP_AUTOTYPES); - - revm_command_add(CMD_KMEM_HASH, (void *)cmd_kmem_hash, - (void *) revm_getdisasm, - 0, - HLP_KMEM_HASH); - - revm_command_add(CMD_KMEM_CHASH, (void *)cmd_kmem_chash, - (void*) revm_getvarparams, - 0, - HLP_KMEM_CHASH); - - - revm_command_add(CMD_KVIRTM_INFO, (void *)cmd_kvirtm_info, - (void*) revm_getvarparams, - 0, - HLP_KVIRTM_INFO); - - revm_command_add(CMD_KVIRTM_LOADME, (void *)cmd_kvirtm_loadme, - (void*) revm_getvarparams, - 0, - HLP_KVIRTM_LOADME); - - revm_command_add(CMD_KVIRTM_READ_PID, (void *)cmd_kvirtm_read_pid, - (void*) revm_getdisasm, - 0, - HLP_KVIRTM_READ_PID); - - revm_command_add(CMD_KVIRTM_WRITE_PID, (void *)cmd_kvirtm_write_pid, - (void*) revm_getvarparams, - 0, - HLP_KVIRTM_WRITE_PID); - - revm_command_add(CMD_KVIRTM_DISASM_PID, (void *)cmd_kvirtm_disasm_pid, - (void*) revm_getdisasm, - 0, - HLP_KVIRTM_DISASM_PID); - - revm_command_add(CMD_KVIRTM_TASK_PID, (void *)cmd_kvirtm_task_pid, - (void*) revm_getvarparams, - 0, - HLP_KVIRTM_TASK_PID); - - revm_command_add(CMD_KVIRTM_DUMP, (void *)cmd_kvirtm_dump, - (void*) revm_getvarparams, - 0, - HLP_KVIRTM_DUMP); - - revm_command_add(CMD_KMEM_READ, (void *)cmd_kmem_read, - (void *) revm_getdisasm, - 0, - HLP_KMEM_READ); - - revm_command_add(CMD_KMEM_WRITE, (void *)cmd_kmem_write, - (void*) revm_getvarparams, - 0, - HLP_KMEM_WRITE); - - revm_command_add(CMD_KMEM_DISASM, (void *)cmd_kmem_disasm, - (void *) revm_getdisasm, - 0, - HLP_KMEM_DISASM); - - revm_command_add(CMD_KMEM_INFO, (void *)cmd_kmem_info, - (void *) NULL, - 0, - HLP_KMEM_INFO); - - revm_command_add(CMD_KDUMP_GET_VMA, (void *)cmd_kdump_get_vma, - (void*) revm_getvarparams, - 0, - HLP_KDUMP_GET_VMA); - - revm_command_add(CMD_KDUMP_VMA, (void *)cmd_kdump_vma, - (void*) revm_getvarparams, - 0, - HLP_KDUMP_VMA); - - revm_command_add(CMD_RPHT, (void *) cmd_rpht, - revm_getregxoption, - 1, - HLP_RPHT); - - revm_command_add(CMD_RSHT, (void *) cmd_rsht, - revm_getregxoption, - 1, - HLP_RSHT); -} diff -Nru eresi-0.8a25/kernsh/.svn/text-base/virtm.c.svn-base eresi-0.0.20110516/kernsh/.svn/text-base/virtm.c.svn-base --- eresi-0.8a25/kernsh/.svn/text-base/virtm.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/kernsh/.svn/text-base/virtm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,497 +0,0 @@ -/** - * @defgroup kernsh Kernsh - */ -/** - * -** @file virtm.c -** @ingroup kernsh -** -*/ - -#include "kernsh.h" -#include "libkernsh.h" -#include "libkernsh-virtm.h" - -int cmd_kvirtm_info() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kvirtm_loadme() -{ - int ret; - char buff[BUFSIZ]; - char buff2[BUFSIZ]; - char *filename; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - memset(buff, '\0', sizeof(buff)); - memset(buff2, '\0', sizeof(buff2)); - - filename = world.curjob->curcmd->param[0]; - - if (filename != NULL) - { - snprintf(buff, sizeof(buff), "%s %s hijack_sct=1 sct_value=0x%lx free_syscall=%d", - (char *)config_get_data(LIBKERNSH_VMCONFIG_KLOAD), - filename, - libkernshworld.sct, - (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL)); - - snprintf(buff2, sizeof(buff2), - "Loading %s with : %s\n\n", - filename, - revm_colorstr(buff)); - revm_output(buff2); - - ret = revm_system(buff); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kvirtm_dump() -{ - int ret; - char *pid, *filename; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - pid = filename = NULL; - - pid = world.curjob->curcmd->param[0]; - filename = world.curjob->curcmd->param[1]; - - if (pid && filename) - { - ret = kernsh_virtm_dump_elf(atoi(pid), filename); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - - return 0; -} - -int cmd_kvirtm_read_pid() -{ - int ret, len, pid, tmp; - eresi_Addr vaddr; - char buff[BUFSIZ]; - revmlist_t *actual, *second; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - - actual = world.curjob->curcmd->disasm + 0; - second = world.curjob->curcmd->disasm + 1; - - if (actual->rname && second->rname) - { - kernsh_addrlen(actual, (eresi_Addr *)&pid, &tmp); - kernsh_addrlen(second, &vaddr, &len); - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Reading %s %s %s strlen(%s)\n", - revm_colornumber("pid:%u", (unsigned int)pid), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) vaddr), - revm_colornumber("%u", len)); - revm_output(buff); - ret = kernsh_virtm_read_pid(pid, vaddr, len); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -int cmd_kvirtm_write_pid() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - void *dat; - int ret, pid, size; - eresi_Addr addr; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL || - world.curjob->curcmd->param[2] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Needs 3 parameters", -1); - - pid = atoi(world.curjob->curcmd->param[0]); - - if (IS_VADDR(world.curjob->curcmd->param[1])) - { - if (sscanf(world.curjob->curcmd->param[1] + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", - -1); - } - else - { - e1 = revm_lookup_param(world.curjob->curcmd->param[1]); - o1 = e1->value; - switch (o1->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - addr = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - break; - - case ASPECT_TYPE_INT: - addr = (o1->immed ? o1->immed_val.word : o1->get_obj(o1->parent)); - break; - } - } - - e2 = revm_lookup_param(world.curjob->curcmd->param[2]); - - o2 = e2->value; - - /* Convert Integers into raw data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - if (revm_convert_object(e2, ASPECT_TYPE_RAW) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert dest object to RAW", (-1)); - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - size = o2->size; - - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Writing into %s %s %s strlen(%s)\n", - revm_colornumber("pid:%u", (unsigned int)pid), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) addr), - revm_colornumber("%u", size)); - revm_output(buff); - - ret = kernsh_virtm_write_pid(pid, addr, (char *)dat, size); - - if (ret != size) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to write mem", - -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_kvirtm_task_pid() -{ - int ret; - char buff[BUFSIZ]; - char *pid; - list_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - pid = NULL; - - pid = world.curjob->curcmd->param[0]; - - memset(buff, '\0', sizeof(buff)); - - if (pid) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); - snprintf(buff, sizeof(buff), "list_task_pid_%d", atoi(pid)); - elist_init(h, buff, ASPECT_TYPE_UNKNOW); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Getting task_struct %s\n\n", - revm_colornumber("pid:%u", (unsigned int)pid)); - revm_output(buff); - - ret = kernsh_virtm_task_pid(atoi(pid), h); - - elist_destroy(h); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int cmd_kvirtm_disasm_pid() -{ - int ret, pid, len, tmp; - eresi_Addr vaddr; - revmlist_t *actual, *second; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - pid = vaddr = len = 0; - - actual = world.curjob->curcmd->disasm + 0; - second = world.curjob->curcmd->disasm + 1; - - if (actual->rname && second->rname) - { - kernsh_addrlen(actual, (eresi_Addr *)&pid, &tmp); - kernsh_addrlen(second, &vaddr, &len); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), - "Disasambling %s %s %s strlen(%s)\n", - revm_colornumber("pid:%u", (unsigned int)pid), - revm_colorstr("@"), - revm_coloraddress(XFMT, (eresi_Addr) vaddr), - revm_colornumber("%u", len)); - revm_output(buff); - - ret = kernsh_virtm_disasm_pid(pid, vaddr, len); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int kernsh_virtm_dump_elf(pid_t pid, char *filename) -{ - int fd, len, ret; - char *proc_entry_root_tmp; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - if (filename == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "filename is empty", - -1); - } - - len = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - len, - -1); - - memset(proc_entry_root_tmp, '\0', len); - - snprintf(proc_entry_root_tmp, len, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_INFO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:%s:", pid, filename); - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set info", - -1); - } - - XCLOSE(fd, -1); - - snprintf(proc_entry_root_tmp, len, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_DUMP_ELF); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "1"); - ret = write(fd, buff, strlen(buff)); - XCLOSE(fd, -1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, proc_entry_root_tmp); - - if (ret != 1) - { - snprintf(buff, sizeof(buff), - "%s !!!\n\n", - revm_colorstr("Dump failed")); - revm_output(buff); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Dump failed", - -1); - } - - snprintf(buff, sizeof(buff), - "%s PID %s @ %s\n\n", - revm_colorstr("DUMP"), - revm_colornumber("%u", pid), - revm_colorstr((char *)filename)); - revm_output(buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_virtm_read_pid(pid_t pid, unsigned long addr, int len) -{ - int ret; - char *new_buff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new_buff, - len, - -1); - - memset(new_buff, '\0', len); - - ret = kernsh_kvirtm_read_virtm(pid, addr, new_buff, len); - - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read virtm", - -1); - } - - kernsh_hexdump((unsigned char *)new_buff, len, addr); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int kernsh_virtm_write_pid(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - kernsh_virtm_read_pid(pid, addr, len); - - ret = kernsh_kvirtm_write_virtm(pid, addr, buffer, len); - - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to write in virtm", - -1); - } - - kernsh_virtm_read_pid(pid, addr, len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int kernsh_virtm_task_pid(pid_t pid, list_t *h) -{ - int index, ret; - listent_t *actual; - kvirtm_virtual_task_struct_t *kvtst; - hash_t *h1; - char buff[BUFSIZ], buff2[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - ret = kernsh_kvirtm_task_pid(pid, h); - - if (ret < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get task pid", - -1); - } - - for (index = 0, actual = h->head; - index < h->elmnbr; - index++, actual = actual->next) - { - kvtst = (kvirtm_virtual_task_struct_t *) actual->data; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - h1, - sizeof(hash_t), - -1); - - snprintf(buff, sizeof(buff), "task_pid_%d", pid); - - hash_init(h1, - buff, - (sizeof(kvirtm_virtual_task_struct_t) / sizeof(unsigned long)) + 1, - ASPECT_TYPE_UNKNOW); - - hash_add(h1, "state", (void *)kvtst->state); - hash_add(h1, "flags", (void *)kvtst->flags); - hash_add(h1, "ptrace", (void *)kvtst->ptrace); - hash_add(h1, "mmap_base", (void *)kvtst->mmap_base); - hash_add(h1, "task_size", (void *)kvtst->task_size); - hash_add(h1, "start_code", (void *)kvtst->start_code); - hash_add(h1, "start_data", (void *)kvtst->start_data); - hash_add(h1, "end_code", (void *)kvtst->end_code); - hash_add(h1, "end_data", (void *)kvtst->end_data); - - memset(buff2, '\0', sizeof(buff2)); - snprintf(buff2, sizeof(buff2), - "... in hash table %s\n\n", - revm_colorstr(buff)); - revm_output(buff2); - - hash_print(h1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int kernsh_virtm_disasm_pid(pid_t pid, unsigned long addr, int len) -{ - int ret; - char *new_buff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new_buff, - len, - -1); - - memset(new_buff, '\0', len); - - ret = kernsh_kvirtm_read_virtm(pid, addr, new_buff, len); - if (ret != len) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to disasm virtm", - -1); - } - - kernsh_disasm(new_buff, len, addr); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/kernsh/tables.c eresi-0.0.20110516/kernsh/tables.c --- eresi-0.8a25/kernsh/tables.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/tables.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,5 +1,5 @@ /* -** @file tables.c +* @file kernsh/tables.c ** @ingroup kernsh ** */ @@ -23,11 +23,9 @@ 0, HLP_KMODE); - revm_command_add(CMD_SCT, (void *)cmd_sct, (void *) NULL, 0, HLP_SCT); - - revm_command_add(CMD_IDT, (void *)cmd_idt, (void *) NULL, 0, HLP_IDT); - - revm_command_add(CMD_GDT, (void *)cmd_gdt, (void *) NULL, 0, HLP_GDT); + revm_command_add(CMD_SCT, (void *) cmd_sct, (void *) NULL, 0, HLP_SCT); + revm_command_add(CMD_IDT, (void *) cmd_idt, (void *) NULL, 0, HLP_IDT); + revm_command_add(CMD_GDT, (void *) cmd_gdt, (void *) NULL, 0, HLP_GDT); revm_command_add(CMD_KALLOC, (void *)cmd_kalloc, (void*) revm_getvarparams, @@ -145,23 +143,15 @@ 0, HLP_KMEM_INFO); - revm_command_add(CMD_KDUMP_GET_VMA, (void *)cmd_kdump_get_vma, - (void*) revm_getvarparams, - 0, - HLP_KDUMP_GET_VMA); + revm_command_add(CMD_KDUMP_GET_VMA, (void *) cmd_kdump_get_vma, + (void*) revm_getoption, 0, HLP_KDUMP_GET_VMA); - revm_command_add(CMD_KDUMP_VMA, (void *)cmd_kdump_vma, - (void*) revm_getvarparams, - 0, - HLP_KDUMP_VMA); + revm_command_add(CMD_KDUMP_VMA, (void *) cmd_kdump_vma, + (void*) revm_getoption, 0, HLP_KDUMP_VMA); revm_command_add(CMD_RPHT, (void *) cmd_rpht, - revm_getregxoption, - 1, - HLP_RPHT); + revm_getregxoption, 1, HLP_RPHT); revm_command_add(CMD_RSHT, (void *) cmd_rsht, - revm_getregxoption, - 1, - HLP_RSHT); + revm_getregxoption, 1, HLP_RSHT); } diff -Nru eresi-0.8a25/kernsh/virtm.c eresi-0.0.20110516/kernsh/virtm.c --- eresi-0.8a25/kernsh/virtm.c 2008-04-06 23:15:43.000000000 +0000 +++ eresi-0.0.20110516/kernsh/virtm.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,17 +1,17 @@ /** - * @defgroup kernsh Kernsh - */ -/** * -** @file virtm.c -** @ingroup kernsh -** -*/ +* @file kernsh/virtm.c + * @ingroup kernsh + * + */ #include "kernsh.h" #include "libkernsh.h" #include "libkernsh-virtm.h" +/** + * @ingroup kernsh + */ int cmd_kvirtm_info() { int ret; @@ -22,6 +22,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int cmd_kvirtm_loadme() { int ret; @@ -39,11 +42,11 @@ if (filename != NULL) { - snprintf(buff, sizeof(buff), "%s %s hijack_sct=1 sct_value=0x%lx free_syscall=%d", - (char *)config_get_data(LIBKERNSH_VMCONFIG_KLOAD), + snprintf(buff, sizeof(buff), "%s %s hijack_sct=1 sct_value="XFMT" free_syscall=%d", + (char *)config_get_data(LIBKERNSH_CONFIG_KLOAD), filename, libkernshworld.sct, - (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL)); + (int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL)); snprintf(buff2, sizeof(buff2), "Loading %s with : %s\n\n", @@ -57,6 +60,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int cmd_kvirtm_dump() { int ret; @@ -80,6 +86,9 @@ return 0; } +/** + * @ingroup kernsh + */ int cmd_kvirtm_read_pid() { int ret, len, pid, tmp; @@ -112,7 +121,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } - +/** + * @ingroup kernsh + */ int cmd_kvirtm_write_pid() { revmexpr_t *e1; @@ -144,7 +155,7 @@ } else { - e1 = revm_lookup_param(world.curjob->curcmd->param[1]); + e1 = revm_lookup_param(world.curjob->curcmd->param[1], 1); o1 = e1->value; switch (o1->otype->type) { @@ -160,7 +171,7 @@ } } - e2 = revm_lookup_param(world.curjob->curcmd->param[2]); + e2 = revm_lookup_param(world.curjob->curcmd->param[2], 1); o2 = e2->value; @@ -203,6 +214,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +/** + * @ingroup kernsh + */ int cmd_kvirtm_task_pid() { int ret; @@ -239,6 +253,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int cmd_kvirtm_disasm_pid() { int ret, pid, len, tmp; @@ -274,6 +291,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int kernsh_virtm_dump_elf(pid_t pid, char *filename) { int fd, len, ret; @@ -354,6 +374,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +/** + * @ingroup kernsh + */ int kernsh_virtm_read_pid(pid_t pid, unsigned long addr, int len) { int ret; @@ -384,6 +407,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int kernsh_virtm_write_pid(pid_t pid, unsigned long addr, char *buffer, int len) { int ret; @@ -406,6 +432,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int kernsh_virtm_task_pid(pid_t pid, list_t *h) { int index, ret; @@ -467,6 +496,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/** + * @ingroup kernsh + */ int kernsh_virtm_disasm_pid(pid_t pid, unsigned long addr, int len) { int ret; diff -Nru eresi-0.8a25/liballocproxy/aproxy_arena.c eresi-0.0.20110516/liballocproxy/aproxy_arena.c --- eresi-0.8a25/liballocproxy/aproxy_arena.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/aproxy_arena.c 2011-05-16 11:34:51.000000000 +0000 @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: aproxy_arena.c,v 1.2 2007-02-25 22:13:33 may Exp $ */ +/* $Id: aproxy_arena.c 1311 2009-01-14 20:36:48Z may $ /* Compile-time constants. */ diff -Nru eresi-0.8a25/liballocproxy/aproxy_hooks.c eresi-0.0.20110516/liballocproxy/aproxy_hooks.c --- eresi-0.8a25/liballocproxy/aproxy_hooks.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/aproxy_hooks.c 2011-05-16 11:34:51.000000000 +0000 @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: aproxy_hooks.c,v 1.2 2007-02-25 22:13:33 may Exp $ */ +/* $Id: aproxy_hooks.c 1311 2009-01-14 20:36:48Z may $ /* What to do if the standard debugging hooks are in place and a corrupt pointer is detected: do nothing (0), print an error message diff -Nru eresi-0.8a25/liballocproxy/aproxy_malloc.c eresi-0.0.20110516/liballocproxy/aproxy_malloc.c --- eresi-0.8a25/liballocproxy/aproxy_malloc.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/aproxy_malloc.c 2011-05-16 11:34:51.000000000 +0000 @@ -24,7 +24,7 @@ Doug Lea and adapted to multiple threads/arenas by Wolfram Gloger. * Version ptmalloc2-20011215 - $Id: aproxy_malloc.c,v 1.5 2007-05-11 10:48:29 may Exp $ + $Id: aproxy_malloc.c 1311 2009-01-14 20:36:48Z may $ based on: VERSION 2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) @@ -311,8 +311,13 @@ /* For writev and struct iovec. */ #include + /* For syslog. */ -#include +#ifdef __BEOS__ +#include +#else + #include +#endif /* For various dynamic linking things. */ #include diff -Nru eresi-0.8a25/liballocproxy/aproxy_strdup.c eresi-0.0.20110516/liballocproxy/aproxy_strdup.c --- eresi-0.8a25/liballocproxy/aproxy_strdup.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/aproxy_strdup.c 2011-05-16 11:34:51.000000000 +0000 @@ -4,7 +4,7 @@ ** Made by jfv for the ERESI project ** ** -** $Id: aproxy_strdup.c,v 1.5 2007-07-31 03:28:46 may Exp $ +** $Id: aproxy_strdup.c 1311 2009-01-14 20:36:48Z may $ ** */ #include "aproxy.h" diff -Nru eresi-0.8a25/liballocproxy/elfsh_hooks.c eresi-0.0.20110516/liballocproxy/elfsh_hooks.c --- eresi-0.8a25/liballocproxy/elfsh_hooks.c 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/elfsh_hooks.c 2011-05-16 11:34:51.000000000 +0000 @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: elfsh_hooks.c,v 1.2 2007-02-18 17:01:03 may Exp $ */ +/* $Id: elfsh_hooks.c 1311 2009-01-14 20:36:48Z may $ /* What to do if the standard debugging hooks are in place and a corrupt pointer is detected: do nothing (0), print an error message diff -Nru eresi-0.8a25/liballocproxy/include/aproxy.h eresi-0.0.20110516/liballocproxy/include/aproxy.h --- eresi-0.8a25/liballocproxy/include/aproxy.h 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/aproxy.h 2011-05-16 11:34:51.000000000 +0000 @@ -25,7 +25,7 @@ #endif /* - $Id: aproxy.h,v 1.2 2007-07-13 18:37:42 may Exp $ + $Id: aproxy.h 1311 2009-01-14 20:36:48Z may $ `ptmalloc2', a malloc implementation for multiple threads without lock contention, by Wolfram Gloger . diff -Nru eresi-0.8a25/liballocproxy/include/.svn/all-wcprops eresi-0.0.20110516/liballocproxy/include/.svn/all-wcprops --- eresi-0.8a25/liballocproxy/include/.svn/all-wcprops 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/725/trunk/liballocproxy/include -END -aproxy.h -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/725/trunk/liballocproxy/include/aproxy.h -END -aproxy-machine.h -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/706/trunk/liballocproxy/include/aproxy-machine.h -END diff -Nru eresi-0.8a25/liballocproxy/include/.svn/entries eresi-0.0.20110516/liballocproxy/include/.svn/entries --- eresi-0.8a25/liballocproxy/include/.svn/entries 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/liballocproxy/include -http://svn.eresi-project.org/svn - - - -2007-07-13T18:37:42.000000Z -725 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -aproxy.h -file - - - - -2008-04-06T23:15:28.620126Z -2d042dab8c85a567eba3dcc6ffb9a146 -2007-07-13T18:37:42.000000Z -725 -may - -aproxy-machine.h -file - - - - -2008-04-06T23:15:28.630144Z -6f92518c2c3ef55abc455bdc7c51dd77 -2007-06-27T11:25:12.000000Z -706 -heroine - diff -Nru eresi-0.8a25/liballocproxy/include/.svn/format eresi-0.0.20110516/liballocproxy/include/.svn/format --- eresi-0.8a25/liballocproxy/include/.svn/format 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/liballocproxy/include/.svn/text-base/aproxy.h.svn-base eresi-0.0.20110516/liballocproxy/include/.svn/text-base/aproxy.h.svn-base --- eresi-0.8a25/liballocproxy/include/.svn/text-base/aproxy.h.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/.svn/text-base/aproxy.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,256 +0,0 @@ -/* Prototypes and definition for malloc implementation. - Copyright (C) 1996,97,99,2000,2002,2003,2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MALLOC_H -#define _MALLOC_H 1 - -#ifdef _LIBC -#include -#endif - -/* - $Id: aproxy.h,v 1.2 2007-07-13 18:37:42 may Exp $ - `ptmalloc2', a malloc implementation for multiple threads without - lock contention, by Wolfram Gloger . - - VERSION 2.7.0 - - This work is mainly derived from malloc-2.7.0 by Doug Lea - , which is available from: - - ftp://gee.cs.oswego.edu/pub/misc/malloc.c - - This trimmed-down header file only provides function prototypes and - the exported data structures. For more detailed function - descriptions and compile-time options, see the source file - `malloc.c'. -*/ - -//#include "malloc-machine.h" - -/* Forward declarations. */ - -struct malloc_chunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_state * mstate; -//typedef unsigned short pid_t; - - -#if defined(__STDC__) || defined (__cplusplus) -# include -# define __malloc_ptr_t void * -#else -# undef size_t -# define size_t unsigned int -# undef ptrdiff_t -# define ptrdiff_t int -# define __malloc_ptr_t char * -#endif - -#ifdef _LIBC - -/* Used by GNU libc internals. */ -# define __malloc_size_t size_t -# define __malloc_ptrdiff_t ptrdiff_t -#elif !defined __attribute_malloc__ -# define __attribute_malloc__ -#endif - -#ifdef __GNUC__ - -/* GCC can always grok prototypes. For C++ programs we add throw() - to help it optimize the function calls. But this works only with - gcc 2.8.x and egcs. */ -# ifndef __THROW -# if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8) -# define __THROW throw () -# else -# define __THROW -# endif -# endif -# define __MALLOC_P(args) args __THROW -/* This macro will be used for functions which might take C++ callback - functions. */ -# define __MALLOC_PMT(args) args - -#else /* Not GCC. */ - -# define __THROW - -# if (defined __STDC__ && __STDC__) || defined __cplusplus - -# define __MALLOC_P(args) args -# define __MALLOC_PMT(args) args - -# ifndef __const -# define __const const -# endif - -# else /* Not ANSI C or C++. */ - -# define __MALLOC_P(args) () /* No prototypes. */ -# define __MALLOC_PMT(args) () - -# ifndef __const -# define __const -# endif - -# endif /* ANSI C or C++. */ - -#endif /* GCC. */ - -#ifndef NULL -# ifdef __cplusplus -# define NULL 0 -# else -# define NULL ((__malloc_ptr_t) 0) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Allocate SIZE bytes of memory. */ -extern __malloc_ptr_t aproxy_malloc __MALLOC_P ((size_t __size)) __attribute_malloc__; - -/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ -extern __malloc_ptr_t aproxy_calloc __MALLOC_P ((size_t __nmemb, size_t __size)) - __attribute_malloc__; - -/* Re-allocate the previously allocated block in __ptr, making the new - block SIZE bytes long. */ -extern __malloc_ptr_t aproxy_realloc __MALLOC_P ((__malloc_ptr_t __ptr, - size_t __size)) - __attribute_malloc__; - -/* Free a block allocated by `malloc', `realloc' or `calloc'. */ -extern void aproxy_free __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Free a block allocated by `calloc'. */ -extern void aproxy_cfree __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ -extern __malloc_ptr_t aproxy_memalign __MALLOC_P ((size_t __alignment, size_t __size)); - -/* Allocate SIZE bytes on a page boundary. */ -extern __malloc_ptr_t aproxy_valloc __MALLOC_P ((size_t __size)) __attribute_malloc__; - -/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up - __size to nearest pagesize. */ -extern __malloc_ptr_t aproxy_pvalloc __MALLOC_P ((size_t __size)) - __attribute_malloc__; - -/* Underlying allocation function; successive calls should return - contiguous pieces of memory. */ -extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size)); - -/* Default value of `__morecore'. */ -extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size)) - __attribute_malloc__; - -/* SVID2/XPG mallinfo structure */ - -struct mallinfo { - int arena; /* non-mmapped space allocated from system */ - int ordblks; /* number of free chunks */ - int smblks; /* number of fastbin blocks */ - int hblks; /* number of mmapped regions */ - int hblkhd; /* space in mmapped regions */ - int usmblks; /* maximum total allocated space */ - int fsmblks; /* space available in freed fastbin blocks */ - int uordblks; /* total allocated space */ - int fordblks; /* total free space */ - int keepcost; /* top-most, releasable (via malloc_trim) space */ -}; - -/* Returns a copy of the updated current mallinfo. */ -extern struct mallinfo mallinfo __MALLOC_P ((void)); - -/* SVID2/XPG mallopt options */ -#ifndef M_MXFAST -# define M_MXFAST 1 /* maximum request size for "fastbins" */ -#endif -#ifndef M_NLBLKS -# define M_NLBLKS 2 /* UNUSED in this malloc */ -#endif -#ifndef M_GRAIN -# define M_GRAIN 3 /* UNUSED in this malloc */ -#endif -#ifndef M_KEEP -# define M_KEEP 4 /* UNUSED in this malloc */ -#endif - -/* mallopt options that actually do something */ -#define M_TRIM_THRESHOLD -1 -#define M_TOP_PAD -2 -#define M_MMAP_THRESHOLD -3 -#define M_MMAP_MAX -4 -#define M_CHECK_ACTION -5 - -/* General SVID/XPG interface to tunable parameters. */ -extern int mallopt __MALLOC_P ((int __param, int __val)); - -/* Release all but __pad bytes of freed top-most memory back to the - system. Return 1 if successful, else 0. */ -extern int malloc_trim __MALLOC_P ((size_t __pad)); - -/* Report the number of usable allocated bytes associated with allocated - chunk __ptr. */ -extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Prints brief summary statistics on stderr. */ -extern void malloc_stats __MALLOC_P ((void)); - -/* Record the state of all malloc variables in an opaque data structure. */ -extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void)); - -/* Restore the state of all malloc variables from data obtained with - malloc_get_state(). */ -extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Called once when malloc is initialized; redefining this variable in - the application provides the preferred way to set up the hook - pointers. */ -extern void (*__aproxy_initialize_hook) __MALLOC_PMT ((void)); -/* Hooks for debugging and user-defined versions. */ -extern void (*__aproxy_free_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_hook) __MALLOC_PMT ((size_t __size, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_realloc_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr, - size_t __size, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_memalign_hook) __MALLOC_PMT ((size_t __alignment, - size_t __size, - __const __malloc_ptr_t)); -extern void (*__aproxy_after_morecore_hook) __MALLOC_PMT ((void)); - -/* Activate a standard set of debugging hooks. */ -extern void __aproxy_check_init __MALLOC_P ((void)); - - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -/* Missing prototype */ -char *aproxy_strdup(const char *s); - -#endif /* malloc.h */ diff -Nru eresi-0.8a25/liballocproxy/include/.svn/text-base/aproxy-machine.h.svn-base eresi-0.0.20110516/liballocproxy/include/.svn/text-base/aproxy-machine.h.svn-base --- eresi-0.8a25/liballocproxy/include/.svn/text-base/aproxy-machine.h.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/include/.svn/text-base/aproxy-machine.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/* Basic platform-independent macro definitions for mutexes, - thread-specific data and parameters for malloc. - Copyright (C) 2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _GENERIC_MALLOC_MACHINE_H -#define _GENERIC_MALLOC_MACHINE_H - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - #include -#elif !defined(IRIX) && !defined(sun) -// #include -#endif - -//#if 0 - -#ifndef pthread_mutex_init /* No threads, provide dummy macros */ - -//# error "No thread !" - -# define NO_THREADS - -/* The mutex functions used to do absolutely nothing, i.e. lock, - trylock and unlock would always just return 0. However, even - without any concurrently active threads, a mutex can be used - legitimately as an `in use' flag. To make the code that is - protected by a mutex async-signal safe, these macros would have to - be based on atomic test-and-set operations, for example. */ -typedef int mutex_t; - -# define mutex_init(m) (*(m) = 0) -# define mutex_lock(m) ((*(m) = 1), 0) -# define mutex_trylock(m) (*(m) ? 1 : ((*(m) = 1), 0)) -# define mutex_unlock(m) (*(m) = 0) - -typedef void *tsd_key_t; -# define tsd_key_create(key, destr) do {} while(0) -# define tsd_setspecific(key, data) ((key) = (data)) -# define tsd_getspecific(key, vptr) (vptr = (key)) - -# define thread_atfork(prepare, parent, child) do {} while(0) - -//#endif /* !defined mutex_init */ - -#else - -#include - -typedef pthread_mutex_t mutex_t; - -# define mutex_init(m) pthread_mutex_init(m, NULL) -# define mutex_lock(m) pthread_mutex_lock(m) -# define mutex_trylock(m) pthread_mutex_trylock(m) -# define mutex_unlock(m) pthread_mutex_unlock(m) - -typedef void *tsd_key_t; - -# define tsd_key_create(key, destr) do {} while(0) -# define tsd_setspecific(key, data) ((key) = (data)) -# define tsd_getspecific(key, vptr) (vptr = (key)) -# define thread_atfork(prepare, parent, child) do {} while(0) - - -#endif - -#ifndef atomic_full_barrier -# define atomic_full_barrier() __asm ("" ::: "memory") -#endif - -#ifndef atomic_read_barrier -# define atomic_read_barrier() atomic_full_barrier () -#endif - -#ifndef atomic_write_barrier -# define atomic_write_barrier() atomic_full_barrier () -#endif - -#ifndef DEFAULT_TOP_PAD -# define DEFAULT_TOP_PAD 131072 -#endif - -#endif /* !defined(_GENERIC_MALLOC_MACHINE_H) */ diff -Nru eresi-0.8a25/liballocproxy/Makefile eresi-0.0.20110516/liballocproxy/Makefile --- eresi-0.8a25/liballocproxy/Makefile 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/Makefile 2011-05-16 11:34:51.000000000 +0000 @@ -1,7 +1,5 @@ # -# Makefile for libmalloc-e2dbg -# -# The ELF shell project +# Makefile for liballocproxy in the ERESI project # # Started Tue Oct 04 15:13:19 2005 mm # diff -Nru eresi-0.8a25/liballocproxy/.svn/all-wcprops eresi-0.0.20110516/liballocproxy/.svn/all-wcprops --- eresi-0.8a25/liballocproxy/.svn/all-wcprops 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/950/trunk/liballocproxy -END -aproxy_strdup.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/749/trunk/liballocproxy/aproxy_strdup.c -END -elfsh_hooks.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/431/trunk/liballocproxy/elfsh_hooks.c -END -aproxy_hooks.c -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/456/trunk/liballocproxy/aproxy_hooks.c -END -aproxy_arena.c -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/456/trunk/liballocproxy/aproxy_arena.c -END -aproxy_malloc.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/600/trunk/liballocproxy/aproxy_malloc.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/950/trunk/liballocproxy/Makefile -END -README -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/446/trunk/liballocproxy/README -END diff -Nru eresi-0.8a25/liballocproxy/.svn/entries eresi-0.0.20110516/liballocproxy/.svn/entries --- eresi-0.8a25/liballocproxy/.svn/entries 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/liballocproxy -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -aproxy_strdup.c -file - - - - -2008-04-06T23:15:30.075886Z -ed77ec2e66d3a5dfdb24b43085c0d084 -2007-07-31T03:28:48.000000Z -749 -may - -elfsh_hooks.c -file - - - - -2008-04-06T23:15:30.131903Z -e6ea9e92e6b8b8b772513aabbab74150 -2007-02-18T17:01:03.000000Z -431 -may - -aproxy_hooks.c -file - - - - -2008-04-06T23:15:30.143247Z -d150577d4a407b64ea9715e050c4136d -2007-02-25T22:13:33.000000Z -456 -may - -aproxy_arena.c -file - - - - -2008-04-06T23:15:30.154590Z -e9e7c3eb46f2ec6889cd5a394b9209e6 -2007-02-25T22:13:33.000000Z -456 -may - -aproxy_malloc.c -file - - - - -2008-04-06T23:15:30.165875Z -b39ed9854c3cabccdcee7a4b4019cfac -2007-05-11T10:48:29.000000Z -600 -may - -Makefile -file - - - - -2008-04-06T23:15:30.177361Z -f14e1e847a6d64c8fd3ccc1026dcdd93 -2008-03-29T07:54:04.209482Z -950 -enioh - -README -file - - - - -2008-04-06T23:15:30.188676Z -0732290eb775889bc59572fcd1cfb378 -2007-02-23T05:27:48.000000Z -446 -may - diff -Nru eresi-0.8a25/liballocproxy/.svn/format eresi-0.0.20110516/liballocproxy/.svn/format --- eresi-0.8a25/liballocproxy/.svn/format 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_arena.c.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_arena.c.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_arena.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_arena.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,899 +0,0 @@ -/* Malloc implementation for multiple threads without lock contention. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Wolfram Gloger , 2001. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* $Id: aproxy_arena.c,v 1.2 2007-02-25 22:13:33 may Exp $ */ - -/* Compile-time constants. */ - -#define HEAP_MIN_SIZE (32*1024) -#ifndef HEAP_MAX_SIZE -#define HEAP_MAX_SIZE (1024*1024) /* must be a power of two */ -#endif - -#include "aproxy.h" - -mstate aproxy_int_new_arena(size_t); - -/* HEAP_MIN_SIZE and HEAP_MAX_SIZE limit the size of mmap()ed heaps - that are dynamically created for multi-threaded programs. The - maximum size must be a power of two, for fast determination of - which heap belongs to a chunk. It should be much larger than the - mmap threshold, so that requests with a size just below that - threshold can be fulfilled without creating too many heaps. */ - -/* The type `bool' must promote to `int' or `unsigned int'. The constants - `true' and `false' must have the value 0 and 1 respectively. */ -typedef enum - { - False = 0, - True = 1 - } Bool; - -/* The names `True' and `False' must also be made available as macros. */ -#define False False -#define True True - -#ifndef THREAD_STATS -#define THREAD_STATS 0 -#endif - -/* If THREAD_STATS is non-zero, some statistics on mutex locking are - computed. */ - -/***************************************************************************/ - -#define top(ar_ptr) ((ar_ptr)->top) - -/* A heap is a single contiguous memory region holding (coalesceable) - malloc_chunks. It is allocated with mmap() and always starts at an - address aligned to HEAP_MAX_SIZE. Not used unless compiling with - USE_ARENAS. */ - -typedef struct _heap_info { - mstate ar_ptr; /* Arena for this heap. */ - struct _heap_info *prev; /* Previous heap. */ - size_t size; /* Current size in bytes. */ - size_t pad; /* Make sure the following data is properly aligned. */ -} heap_info; - -/* Thread specific data */ -static tsd_key_t arena_key; -static mutex_t list_lock; - -#if THREAD_STATS -static int stat_n_heaps; -#define THREAD_STAT(x) x -#else -#define THREAD_STAT(x) do ; while(0) -#endif - -/* Mapped memory in non-main arenas (reliable only for NO_THREADS). */ -static unsigned long arena_mem; - -/* Already initialized? */ -int __aproxy_initialized = -1; - -/**************************************************************************/ - -#if USE_ARENAS - -/* arena_get() acquires an arena and locks the corresponding mutex. - First, try the one last locked successfully by this thread. (This - is the common case and handled with a macro for speed.) Then, loop - once over the circularly linked list of arenas. If no arena is - readily available, create a new one. In this latter case, `size' - is just a hint as to how much memory will be required immediately - in the new arena. */ - -#define arena_get(ptr, size) do { \ - Void_t *vptr = NULL; \ - /*if (malloc_dbgpid_get() != pthread_self())*/ \ - ptr = (mstate)tsd_getspecific(arena_key, vptr); \ - /*else \ - { \ - if (!debug_key) \ - debug_key = aproxy_int_new_arena(size); \ - ptr = (mstate)tsd_getspecific(debug_key, vptr); \ - } */ \ - if (ptr && !mutex_trylock(&ptr->mutex)) { \ - THREAD_STAT(++(ptr->stat_lock_direct)); \ - } else { \ - ptr = arena_get2(ptr, (size)); } \ -} while(0) - - -/* find the heap and corresponding arena for a given ptr */ -#define heap_for_ptr(ptr) \ - ((heap_info *)((unsigned long)(ptr) & ~(HEAP_MAX_SIZE-1))) -#define arena_for_chunk(ptr) \ - (chunk_non_main_arena(ptr) ? heap_for_ptr(ptr)->ar_ptr : &main_arena) - -#else /* !USE_ARENAS */ - -/* There is only one arena, main_arena. */ -#if THREAD_STATS -#define arena_get(ar_ptr, sz) do { \ - ar_ptr = &main_arena; \ - if(!mutex_trylock(&ar_ptr->mutex)) \ - ++(ar_ptr->stat_lock_direct); \ - else { \ - (void)mutex_lock(&ar_ptr->mutex); \ - ++(ar_ptr->stat_lock_wait); \ - } \ -} while(0) -#else -#define arena_get(ar_ptr, sz) do { \ - ar_ptr = &main_arena; \ - (void)mutex_lock(&ar_ptr->mutex); \ -} while(0) -#endif -#define arena_for_chunk(ptr) (&main_arena) - -#endif /* USE_ARENAS */ - -/**************************************************************************/ - -#ifndef NO_THREADS - -/* atfork support. */ - -static __malloc_ptr_t (*save_malloc_hook) (size_t __size, - __const __malloc_ptr_t); -# if !defined _LIBC || !defined USE_TLS || (defined SHARED && !USE___THREAD) -static __malloc_ptr_t (*save_memalign_hook) (size_t __align, size_t __size, - __const __malloc_ptr_t); -# endif -static void (*save_free_hook) (__malloc_ptr_t __ptr, - __const __malloc_ptr_t); -static Void_t* save_arena; - -/* Magic value for the thread-specific arena pointer when - malloc_atfork() is in use. */ - -#define ATFORK_ARENA_PTR ((Void_t*)-1) - -/* The following hooks are used while the `atfork' handling mechanism - is active. */ - -static Void_t* -malloc_atfork(size_t sz, const Void_t *caller) -{ - Void_t *vptr = NULL; - Void_t *victim; - - tsd_getspecific(arena_key, vptr); - if(vptr == ATFORK_ARENA_PTR) { - /* We are the only thread that may allocate at all. */ - if(save_malloc_hook != malloc_check) { - return aproxy_int_malloc(&main_arena, sz); - } else { - if(top_check()<0) - return 0; - victim = aproxy_int_malloc(&main_arena, sz+1); - return mem2mem_check(victim, sz); - } - } else { - /* Suspend the thread until the `atfork' handlers have completed. - By that time, the hooks will have been reset as well, so that - mALLOc() can be used again. */ - (void)mutex_lock(&list_lock); - (void)mutex_unlock(&list_lock); - return public_mALLOc(sz); - } -} - -static void -free_atfork(Void_t* mem, const Void_t *caller) -{ - Void_t *vptr = NULL; - mstate ar_ptr; - mchunkptr p; /* chunk corresponding to mem */ - - if (mem == 0) /* free(0) has no effect */ - return; - - p = mem2chunk(mem); /* do not bother to replicate free_check here */ - -#if HAVE_MMAP - if (chunk_is_mmapped(p)) /* release mmapped memory. */ - { - munmap_chunk(p); - return; - } -#endif - - ar_ptr = arena_for_chunk(p); - tsd_getspecific(arena_key, vptr); - if(vptr != ATFORK_ARENA_PTR) - (void)mutex_lock(&ar_ptr->mutex); - aproxy_int_free(ar_ptr, mem); - if(vptr != ATFORK_ARENA_PTR) - (void)mutex_unlock(&ar_ptr->mutex); -} - -/* The following two functions are registered via thread_atfork() to - make sure that the mutexes remain in a consistent state in the - fork()ed version of a thread. Also adapt the malloc and free hooks - temporarily, because the `atfork' handler mechanism may use - malloc/free internally (e.g. in LinuxThreads). */ - -static void -ptmalloc_lock_all (void) -{ - mstate ar_ptr; - - if(__aproxy_initialized < 1) - return; - (void)mutex_lock(&list_lock); - for(ar_ptr = &main_arena;;) { - (void)mutex_lock(&ar_ptr->mutex); - ar_ptr = ar_ptr->next; - if(ar_ptr == &main_arena) break; - } - save_malloc_hook = __aproxy_hook; - save_free_hook = __aproxy_free_hook; - __aproxy_hook = malloc_atfork; - __aproxy_free_hook = free_atfork; - /* Only the current thread may perform malloc/free calls now. */ - tsd_getspecific(arena_key, save_arena); - tsd_setspecific(arena_key, ATFORK_ARENA_PTR); -} - -static void -ptmalloc_unlock_all (void) -{ - mstate ar_ptr; - - if(__aproxy_initialized < 1) - return; - tsd_setspecific(arena_key, save_arena); - __aproxy_hook = save_malloc_hook; - __aproxy_free_hook = save_free_hook; - for(ar_ptr = &main_arena;;) { - (void)mutex_unlock(&ar_ptr->mutex); - ar_ptr = ar_ptr->next; - if(ar_ptr == &main_arena) break; - } - (void)mutex_unlock(&list_lock); -} - -#ifdef __linux__ - -/* In LinuxThreads, unlocking a mutex in the child process after a - fork() is currently unsafe, whereas re-initializing it is safe and - does not leak resources. Therefore, a special atfork handler is - installed for the child. */ - -static void -ptmalloc_unlock_all2 (void) -{ - mstate ar_ptr; - - if(__aproxy_initialized < 1) - return; -#if defined _LIBC || defined MALLOC_HOOKS - tsd_setspecific(arena_key, save_arena); - __aproxy_hook = save_malloc_hook; - __aproxy_free_hook = save_free_hook; -#endif - for(ar_ptr = &main_arena;;) { - mutex_init(&ar_ptr->mutex); - ar_ptr = ar_ptr->next; - if(ar_ptr == &main_arena) break; - } - mutex_init(&list_lock); -} - -#else - -#define ptmalloc_unlock_all2 ptmalloc_unlock_all - -#endif - -#endif /* !defined NO_THREADS */ - -/* Initialization routine. */ -#ifdef _LIBC -#include -extern char **_environ; - -static char * -internal_function -next_env_entry (char ***position) -{ - char **current = *position; - char *result = NULL; - - while (*current != NULL) - { - if (__builtin_expect ((*current)[0] == 'M', 0) - && (*current)[1] == 'A' - && (*current)[2] == 'L' - && (*current)[3] == 'L' - && (*current)[4] == 'O' - && (*current)[5] == 'C' - && (*current)[6] == '_') - { - result = &(*current)[7]; - - /* Save current position for next visit. */ - *position = ++current; - - break; - } - - ++current; - } - - return result; -} -#endif /* _LIBC */ - -/* Set up basic state so that aproxy_int_malloc et al can work. */ -static void -aproxy_ptmalloc_init_minimal (void) -{ -#if DEFAULT_TOP_PAD != 0 - mp_.top_pad = DEFAULT_TOP_PAD; -#endif - mp_.n_mmaps_max = DEFAULT_MMAP_MAX; - mp_.mmap_threshold = DEFAULT_MMAP_THRESHOLD; - mp_.trim_threshold = DEFAULT_TRIM_THRESHOLD; - mp_.pagesize = malloc_getpagesize; -} - - -#ifdef _LIBC -# ifdef SHARED -static void * -__failing_morecore (ptrdiff_t d) -{ - return (void *) MORECORE_FAILURE; -} - -extern struct dl_open_hook *_dl_open_hook; -libc_hidden_proto (_dl_open_hook); -# endif - -# if defined SHARED && defined USE_TLS && !USE___THREAD - -/* This is called by __pthread_initialize_minimal when it needs to use - malloc to set up the TLS state. We cannot do the full work of - aproxy_ptmalloc_init (below) until __pthread_initialize_minimal has finished, - so it has to switch to using the special startup-time hooks while doing - those allocations. */ -void -__aproxy_libc_malloc_pthread_startup (Bool first_time) -{ - if (first_time) - { - aproxy_ptmalloc_init_minimal (); - save_malloc_hook = __aproxy_hook; - save_memalign_hook = __aproxy_memalign_hook; - save_free_hook = __aproxy_free_hook; - __aproxy_hook = malloc_starter; - __aproxy_memalign_hook = memalign_starter; - __aproxy_free_hook = free_starter; - } - else - { - __aproxy_hook = save_malloc_hook; - __aproxy_memalign_hook = save_memalign_hook; - __aproxy_free_hook = save_free_hook; - } -} -# endif -#endif - -static void -aproxy_ptmalloc_init (void) -{ -#if __STD_C - const char* s; -#else - char* s; -#endif - int secure = 0; - - if(__aproxy_initialized >= 0) return; - __aproxy_initialized = 0; - -#ifdef _LIBC -# if defined SHARED && defined USE_TLS && !USE___THREAD - /* aproxy_ptmalloc_init_minimal may already have been called via - __libc_malloc_pthread_startup, above. */ - if (mp_.pagesize == 0) -# endif -#endif - aproxy_ptmalloc_init_minimal(); - -#ifndef NO_THREADS -# if defined _LIBC && defined USE_TLS - /* We know __pthread_initialize_minimal has already been called, - and that is enough. */ -# define NO_STARTER -# endif -# ifndef NO_STARTER - /* With some threads implementations, creating thread-specific data - or initializing a mutex may call malloc() itself. Provide a - simple starter version (realloc() won't work). */ - save_malloc_hook = __aproxy_hook; - save_memalign_hook = __aproxy_memalign_hook; - save_free_hook = __aproxy_free_hook; - __aproxy_hook = malloc_starter; - __aproxy_memalign_hook = memalign_starter; - __aproxy_free_hook = free_starter; -# ifdef _LIBC - /* Initialize the pthreads interface. */ - if (__pthread_initialize != NULL) - __pthread_initialize(); -# endif /* !defined _LIBC */ -# endif /* !defined NO_STARTER */ -#endif /* !defined NO_THREADS */ - mutex_init(&main_arena.mutex); - main_arena.next = &main_arena; - -#if defined _LIBC && defined SHARED - /* In case this libc copy is in a non-default namespace, never use brk. - Likewise if dlopened from statically linked program. */ - Dl_info di; - struct link_map *l; - - if (_dl_open_hook != NULL - || (_dl_addr (aproxy_ptmalloc_init, &di, &l, NULL) != 0 - && l->l_ns != LM_ID_BASE)) - __morecore = __failing_morecore; -#endif - - mutex_init(&list_lock); - tsd_key_create(&arena_key, NULL); - tsd_setspecific(arena_key, (Void_t *)&main_arena); - thread_atfork(ptmalloc_lock_all, ptmalloc_unlock_all, ptmalloc_unlock_all2); -#ifndef NO_THREADS -# ifndef NO_STARTER - __aproxy_hook = save_malloc_hook; - __aproxy_memalign_hook = save_memalign_hook; - __aproxy_free_hook = save_free_hook; -# else -# undef NO_STARTER -# endif -#endif -#ifdef _LIBC - secure = __libc_enable_secure; - s = NULL; - if (__builtin_expect (_environ != NULL, 1)) - { - char **runp = _environ; - char *envline; - - while (__builtin_expect ((envline = next_env_entry (&runp)) != NULL, - 0)) - { - size_t len = strcspn (envline, "="); - - if (envline[len] != '=') - /* This is a "MALLOC_" variable at the end of the string - without a '=' character. Ignore it since otherwise we - will access invalid memory below. */ - continue; - - switch (len) - { - case 6: - if (memcmp (envline, "CHECK_", 6) == 0) - s = &envline[7]; - break; - case 8: - if (! secure && memcmp (envline, "TOP_PAD_", 8) == 0) - mALLOPt(M_TOP_PAD, atoi(&envline[9])); - break; - case 9: - if (! secure && memcmp (envline, "MMAP_MAX_", 9) == 0) - mALLOPt(M_MMAP_MAX, atoi(&envline[10])); - break; - case 15: - if (! secure) - { - if (memcmp (envline, "TRIM_THRESHOLD_", 15) == 0) - mALLOPt(M_TRIM_THRESHOLD, atoi(&envline[16])); - else if (memcmp (envline, "MMAP_THRESHOLD_", 15) == 0) - mALLOPt(M_MMAP_THRESHOLD, atoi(&envline[16])); - } - break; - default: - break; - } - } - } -#else - if (! secure) - { - if((s = getenv("MALLOC_TRIM_THRESHOLD_"))) - mALLOPt(M_TRIM_THRESHOLD, atoi(s)); - if((s = getenv("MALLOC_TOP_PAD_"))) - mALLOPt(M_TOP_PAD, atoi(s)); - if((s = getenv("MALLOC_MMAP_THRESHOLD_"))) - mALLOPt(M_MMAP_THRESHOLD, atoi(s)); - if((s = getenv("MALLOC_MMAP_MAX_"))) - mALLOPt(M_MMAP_MAX, atoi(s)); - } - s = getenv("MALLOC_CHECK_"); -#endif - if(s) { - if(s[0]) mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0')); - if (check_action != 0) - __aproxy_check_init(); - } - if(__aproxy_initialize_hook != NULL) - (*__aproxy_initialize_hook)(); - __aproxy_initialized = 1; -} - -/* There are platforms (e.g. Hurd) with a link-time hook mechanism. */ -#ifdef thread_atfork_static -thread_atfork_static(ptmalloc_lock_all, ptmalloc_unlock_all, \ - ptmalloc_unlock_all2) -#endif - - - -/* Managing heaps and arenas (for concurrent threads) */ - -#if USE_ARENAS - -#if MALLOC_DEBUG > 1 - -/* Print the complete contents of a single heap to stderr. */ - -static void -#if __STD_C -dump_heap(heap_info *heap) -#else -dump_heap(heap) heap_info *heap; -#endif -{ - char *ptr; - mchunkptr p; - - fprintf(stderr, "Heap %p, size %10lx:\n", heap, (long)heap->size); - ptr = (heap->ar_ptr != (mstate)(heap+1)) ? - (char*)(heap + 1) : (char*)(heap + 1) + sizeof(struct malloc_state); - p = (mchunkptr)(((unsigned long)ptr + MALLOC_ALIGN_MASK) & - ~MALLOC_ALIGN_MASK); - for(;;) { - fprintf(stderr, "chunk %p size %10lx", p, (long)p->size); - if(p == top(heap->ar_ptr)) { - fprintf(stderr, " (top)\n"); - break; - } else if(p->size == (0|PREV_INUSE)) { - fprintf(stderr, " (fence)\n"); - break; - } - fprintf(stderr, "\n"); - p = next_chunk(p); - } -} - -#endif /* MALLOC_DEBUG > 1 */ - -/* If consecutive mmap (0, HEAP_MAX_SIZE << 1, ...) calls return decreasing - addresses as opposed to increasing, new_heap would badly fragment the - address space. In that case remember the second HEAP_MAX_SIZE part - aligned to HEAP_MAX_SIZE from last mmap (0, HEAP_MAX_SIZE << 1, ...) - call (if it is already aligned) and try to reuse it next time. We need - no locking for it, as kernel ensures the atomicity for us - worst case - we'll call mmap (addr, HEAP_MAX_SIZE, ...) for some value of addr in - multiple threads, but only one will succeed. */ -static char *aligned_heap_area; - -/* Create a new heap. size is automatically rounded up to a multiple - of the page size. */ - -static heap_info * -internal_function -#if __STD_C -new_heap(size_t size, size_t top_pad) -#else -new_heap(size, top_pad) size_t size, top_pad; -#endif -{ - size_t page_mask = malloc_getpagesize - 1; - char *p1, *p2; - unsigned long ul; - heap_info *h; - - if(size+top_pad < HEAP_MIN_SIZE) - size = HEAP_MIN_SIZE; - else if(size+top_pad <= HEAP_MAX_SIZE) - size += top_pad; - else if(size > HEAP_MAX_SIZE) - return 0; - else - size = HEAP_MAX_SIZE; - size = (size + page_mask) & ~page_mask; - - /* A memory region aligned to a multiple of HEAP_MAX_SIZE is needed. - No swap space needs to be reserved for the following large - mapping (on Linux, this is the case for all non-writable mappings - anyway). */ - p2 = (char *) (MAP_FAILED); - if(aligned_heap_area) { - p2 = (char *)MMAP(aligned_heap_area, HEAP_MAX_SIZE, PROT_NONE, - MAP_PRIVATE|MAP_NORESERVE); - aligned_heap_area = NULL; - if (p2 != MAP_FAILED && ((unsigned long)p2 & (HEAP_MAX_SIZE-1))) { - munmap(p2, HEAP_MAX_SIZE); - p2 = (char *) (MAP_FAILED); - } - } - if(p2 == MAP_FAILED) { - p1 = (char *)MMAP(0, HEAP_MAX_SIZE<<1, PROT_NONE, - MAP_PRIVATE|MAP_NORESERVE); - if(p1 != MAP_FAILED) { - p2 = (char *)(((unsigned long)p1 + (HEAP_MAX_SIZE-1)) - & ~(HEAP_MAX_SIZE-1)); - ul = p2 - p1; - if (ul) - munmap(p1, ul); - else - aligned_heap_area = p2 + HEAP_MAX_SIZE; - munmap(p2 + HEAP_MAX_SIZE, HEAP_MAX_SIZE - ul); - } else { - /* Try to take the chance that an allocation of only HEAP_MAX_SIZE - is already aligned. */ - p2 = (char *)MMAP(0, HEAP_MAX_SIZE, PROT_NONE, MAP_PRIVATE|MAP_NORESERVE); - if(p2 == MAP_FAILED) - return 0; - if((unsigned long)p2 & (HEAP_MAX_SIZE-1)) { - munmap(p2, HEAP_MAX_SIZE); - return 0; - } - } - } - if(mprotect(p2, size, PROT_READ|PROT_WRITE) != 0) { - munmap(p2, HEAP_MAX_SIZE); - return 0; - } - h = (heap_info *)p2; - h->size = size; - THREAD_STAT(stat_n_heaps++); - return h; -} - -/* Grow or shrink a heap. size is automatically rounded up to a - multiple of the page size if it is positive. */ - -static int -#if __STD_C -grow_heap(heap_info *h, long diff) -#else -grow_heap(h, diff) heap_info *h; long diff; -#endif -{ - size_t page_mask = malloc_getpagesize - 1; - long new_size; - - if(diff >= 0) { - diff = (diff + page_mask) & ~page_mask; - new_size = (long)h->size + diff; - if(new_size > HEAP_MAX_SIZE) - return -1; - if(mprotect((char *)h + h->size, diff, PROT_READ|PROT_WRITE) != 0) - return -2; - } else { - new_size = (long)h->size + diff; - if(new_size < (long)sizeof(*h)) - return -1; - /* Try to re-map the extra heap space freshly to save memory, and - make it inaccessible. */ - if((char *)MMAP((char *)h + new_size, -diff, PROT_NONE, - MAP_PRIVATE|MAP_FIXED) == (char *) MAP_FAILED) - return -2; - /*fprintf(stderr, "shrink %p %08lx\n", h, new_size);*/ - } - h->size = new_size; - return 0; -} - -/* Delete a heap. */ - -#define delete_heap(heap) \ - do { \ - if ((char *)(heap) + HEAP_MAX_SIZE == aligned_heap_area) \ - aligned_heap_area = NULL; \ - munmap((char*)(heap), HEAP_MAX_SIZE); \ - } while (0) - -static int -internal_function -#if __STD_C -heap_trim(heap_info *heap, size_t pad) -#else -heap_trim(heap, pad) heap_info *heap; size_t pad; -#endif -{ - mstate ar_ptr = heap->ar_ptr; - unsigned long pagesz = mp_.pagesize; - mchunkptr top_chunk = top(ar_ptr), p, bck, fwd; - heap_info *prev_heap; - long new_size, top_size, extra; - - /* Can this heap go away completely? */ - while(top_chunk == chunk_at_offset(heap, sizeof(*heap))) { - prev_heap = heap->prev; - p = chunk_at_offset(prev_heap, prev_heap->size - (MINSIZE-2*SIZE_SZ)); - assert(p->size == (0|PREV_INUSE)); /* must be fencepost */ - p = prev_chunk(p); - new_size = chunksize(p) + (MINSIZE-2*SIZE_SZ); - assert(new_size>0 && new_size<(long)(2*MINSIZE)); - if(!prev_inuse(p)) - new_size += p->prev_size; - assert(new_size>0 && new_sizesize) < pad + MINSIZE + pagesz) - break; - ar_ptr->system_mem -= heap->size; - arena_mem -= heap->size; - delete_heap(heap); - heap = prev_heap; - if(!prev_inuse(p)) { /* consolidate backward */ - p = prev_chunk(p); - unlink(p, bck, fwd); - } - assert(((unsigned long)((char*)p + new_size) & (pagesz-1)) == 0); - assert( ((char*)p + new_size) == ((char*)heap + heap->size) ); - top(ar_ptr) = top_chunk = p; - set_head(top_chunk, new_size | PREV_INUSE); - /*check_chunk(ar_ptr, top_chunk);*/ - } - top_size = chunksize(top_chunk); - extra = ((top_size - pad - MINSIZE + (pagesz-1))/pagesz - 1) * pagesz; - if(extra < (long)pagesz) - return 0; - /* Try to shrink. */ - if(grow_heap(heap, -extra) != 0) - return 0; - ar_ptr->system_mem -= extra; - arena_mem -= extra; - - /* Success. Adjust top accordingly. */ - set_head(top_chunk, (top_size - extra) | PREV_INUSE); - /*check_chunk(ar_ptr, top_chunk);*/ - return 1; -} - -static mstate -internal_function -#if __STD_C -arena_get2(mstate a_tsd, size_t size) -#else -arena_get2(a_tsd, size) mstate a_tsd; size_t size; -#endif -{ - mstate a; - Bool retried = False; - - if(!a_tsd) - a = a_tsd = &main_arena; - else { - a = a_tsd->next; - if(!a) { - /* This can only happen while initializing the new arena. */ - (void)mutex_lock(&main_arena.mutex); - THREAD_STAT(++(main_arena.stat_lock_wait)); - return &main_arena; - } - } - - /* Check the global, circularly linked list for available arenas. */ - repeat: - do { - if(!mutex_trylock(&a->mutex)) { - if (retried) - (void)mutex_unlock(&list_lock); - THREAD_STAT(++(a->stat_lock_loop)); - tsd_setspecific(arena_key, (Void_t *)a); - return a; - } - a = a->next; - } while(a != a_tsd); - - /* If not even the list_lock can be obtained, try again. This can - happen during `atfork', or for example on systems where thread - creation makes it temporarily impossible to obtain _any_ - locks. */ - if(!retried && mutex_trylock(&list_lock)) { - /* We will block to not run in a busy loop. */ - (void)mutex_lock(&list_lock); - - /* Since we blocked there might be an arena available now. */ - retried = True; - a = a_tsd; - goto repeat; - } - - /* Nothing immediately available, so generate a new arena. */ - a = aproxy_int_new_arena(size); - if(a) - { - tsd_setspecific(arena_key, (Void_t *)a); - mutex_init(&a->mutex); - mutex_lock(&a->mutex); /* remember result */ - - /* Add the new arena to the global list. */ - a->next = main_arena.next; - atomic_write_barrier (); - main_arena.next = a; - - THREAD_STAT(++(a->stat_lock_loop)); - } - (void)mutex_unlock(&list_lock); - - return a; -} - -/* Create a new arena with initial size "size". */ - -mstate -aproxy_int_new_arena(size_t size) -{ - mstate a; - heap_info *h; - char *ptr; - unsigned long misalign; - - h = new_heap(size + (sizeof(*h) + sizeof(*a) + MALLOC_ALIGNMENT), - mp_.top_pad); - if(!h) { - /* Maybe size is too large to fit in a single heap. So, just try - to create a minimally-sized arena and let aproxy_int_malloc() attempt - to deal with the large request via mmap_chunk(). */ - h = new_heap(sizeof(*h) + sizeof(*a) + MALLOC_ALIGNMENT, mp_.top_pad); - if(!h) - return 0; - } - a = h->ar_ptr = (mstate)(h+1); - malloc_init_state(a); - /*a->next = NULL;*/ - a->system_mem = a->max_system_mem = h->size; - arena_mem += h->size; -#ifdef NO_THREADS - if((unsigned long)(mp_.mmapped_mem + arena_mem + main_arena.system_mem) > - mp_.max_total_mem) - mp_.max_total_mem = mp_.mmapped_mem + arena_mem + main_arena.system_mem; -#endif - - /* Set up the top chunk, with proper alignment. */ - ptr = (char *)(a + 1); - misalign = (unsigned long)chunk2mem(ptr) & MALLOC_ALIGN_MASK; - if (misalign > 0) - ptr += MALLOC_ALIGNMENT - misalign; - top(a) = (mchunkptr)ptr; - set_head(top(a), (((char*)h + h->size) - ptr) | PREV_INUSE); - - return a; -} - -#endif /* USE_ARENAS */ - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_hooks.c.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_hooks.c.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_hooks.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_hooks.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,632 +0,0 @@ -/* Malloc implementation for multiple threads without lock contention. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Wolfram Gloger , 2001. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* $Id: aproxy_hooks.c,v 1.2 2007-02-25 22:13:33 may Exp $ */ - -/* What to do if the standard debugging hooks are in place and a - corrupt pointer is detected: do nothing (0), print an error message - (1), or call abort() (2). */ - -/* Hooks for debugging versions. The initial hooks just call the - initialization routine, then do the normal work. */ - -static Void_t* -#if __STD_C -malloc_hook_ini(size_t sz, const __malloc_ptr_t caller) -#else -malloc_hook_ini(sz, caller) - size_t sz; const __malloc_ptr_t caller; -#endif -{ - __aproxy_hook = NULL; - aproxy_ptmalloc_init(); - return public_mALLOc(sz); -} - -static Void_t* -#if __STD_C -realloc_hook_ini(Void_t* ptr, size_t sz, const __malloc_ptr_t caller) -#else -realloc_hook_ini(ptr, sz, caller) - Void_t* ptr; size_t sz; const __malloc_ptr_t caller; -#endif -{ - __aproxy_hook = NULL; - __aproxy_realloc_hook = NULL; - aproxy_ptmalloc_init(); - return public_rEALLOc(ptr, sz); -} - -static Void_t* -#if __STD_C -memalign_hook_ini(size_t alignment, size_t sz, const __malloc_ptr_t caller) -#else -memalign_hook_ini(alignment, sz, caller) - size_t alignment; size_t sz; const __malloc_ptr_t caller; -#endif -{ - __aproxy_memalign_hook = NULL; - aproxy_ptmalloc_init(); - return public_mEMALIGn(alignment, sz); -} - -/* Whether we are using malloc checking. */ -static int using_malloc_checking; - -/* A flag that is set by aproxy_set_state, to signal that malloc checking - must not be enabled on the request from the user (via the MALLOC_CHECK_ - environment variable). It is reset by __aproxy_check_init to tell - aproxy_set_state that the user has requested malloc checking. - - The purpose of this flag is to make sure that malloc checking is not - enabled when the heap to be restored was constructed without malloc - checking, and thus does not contain the required magic bytes. - Otherwise the heap would be corrupted by calls to free and realloc. If - it turns out that the heap was created with malloc checking and the - user has requested it aproxy_set_state just calls __aproxy_check_init - again to enable it. On the other hand, reusing such a heap without - further malloc checking is safe. */ -static int disallow_malloc_check; - -/* Activate a standard set of debugging hooks. */ -void -__aproxy_check_init() -{ - if (disallow_malloc_check) { - disallow_malloc_check = 0; - return; - } - using_malloc_checking = 1; - __aproxy_hook = malloc_check; - __aproxy_free_hook = free_check; - __aproxy_realloc_hook = realloc_check; - __aproxy_memalign_hook = memalign_check; - if(check_action & 1) - malloc_printerr (5, "malloc: using debugging hooks", NULL); -} - -/* A simple, standard set of debugging hooks. Overhead is `only' one - byte per chunk; still this will catch most cases of double frees or - overruns. The goal here is to avoid obscure crashes due to invalid - usage, unlike in the MALLOC_DEBUG code. */ - -#define MAGICBYTE(p) ( ( ((size_t)p >> 3) ^ ((size_t)p >> 11)) & 0xFF ) - -/* Instrument a chunk with overrun detector byte(s) and convert it - into a user pointer with requested size sz. */ - -static Void_t* -internal_function -#if __STD_C -mem2mem_check(Void_t *ptr, size_t sz) -#else -mem2mem_check(ptr, sz) Void_t *ptr; size_t sz; -#endif -{ - mchunkptr p; - unsigned char* m_ptr = (unsigned char*)BOUNDED_N(ptr, sz); - size_t i; - - if (!ptr) - return ptr; - p = mem2chunk(ptr); - for(i = chunksize(p) - (chunk_is_mmapped(p) ? 2*SIZE_SZ+1 : SIZE_SZ+1); - i > sz; - i -= 0xFF) { - if(i-sz < 0x100) { - m_ptr[i] = (unsigned char)(i-sz); - break; - } - m_ptr[i] = 0xFF; - } - m_ptr[sz] = MAGICBYTE(p); - return (Void_t*)m_ptr; -} - -/* Convert a pointer to be free()d or realloc()ed to a valid chunk - pointer. If the provided pointer is not valid, return NULL. */ - -static mchunkptr -internal_function -#if __STD_C -mem2chunk_check(Void_t* mem) -#else -mem2chunk_check(mem) Void_t* mem; -#endif -{ - mchunkptr p; - INTERNAL_SIZE_T sz, c; - unsigned char magic; - - if(!aligned_OK(mem)) return NULL; - p = mem2chunk(mem); - if (!chunk_is_mmapped(p)) { - /* Must be a chunk in conventional heap memory. */ - int contig = contiguous(&main_arena); - sz = chunksize(p); - if((contig && - ((char*)p=(mp_.sbrk_base+main_arena.system_mem) )) || - szprev_size&MALLOC_ALIGN_MASK || - (contig && (char*)prev_chunk(p)size & PREV_INUSE) || - ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || - ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) - return NULL; - magic = MAGICBYTE(p); - for(sz -= 1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; - } - ((unsigned char*)p)[sz] ^= 0xFF; - } - return p; -} - -/* Check for corruption of the top chunk, and try to recover if - necessary. */ - -static int -internal_function -#if __STD_C -top_check(void) -#else -top_check() -#endif -{ - mchunkptr t = top(&main_arena); - char* brk, * new_brk; - INTERNAL_SIZE_T front_misalign, sbrk_size; - unsigned long pagesz = malloc_getpagesize; - - if (t == initial_top(&main_arena) || - (!chunk_is_mmapped(t) && - chunksize(t)>=MINSIZE && - prev_inuse(t) && - (!contiguous(&main_arena) || - (char*)t + chunksize(t) == mp_.sbrk_base + main_arena.system_mem))) - return 0; - - malloc_printerr (check_action, "malloc: top chunk is corrupt", t); - - /* Try to set up a new top chunk. */ - brk = (char *) (MORECORE(0)); - front_misalign = (unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - front_misalign = MALLOC_ALIGNMENT - front_misalign; - sbrk_size = front_misalign + mp_.top_pad + MINSIZE; - sbrk_size += pagesz - ((unsigned long)(brk + sbrk_size) & (pagesz - 1)); - new_brk = (char*)(MORECORE (sbrk_size)); - if (new_brk == (char*)(MORECORE_FAILURE)) return -1; - /* Call the `morecore' hook if necessary. */ - if (__aproxy_after_morecore_hook) - (*__aproxy_after_morecore_hook) (); - main_arena.system_mem = (new_brk - mp_.sbrk_base) + sbrk_size; - - top(&main_arena) = (mchunkptr)(brk + front_misalign); - set_head(top(&main_arena), (sbrk_size - front_misalign) | PREV_INUSE); - - return 0; -} - -static Void_t* -#if __STD_C -malloc_check(size_t sz, const Void_t *caller) -#else -malloc_check(sz, caller) size_t sz; const Void_t *caller; -#endif -{ - Void_t *victim; - - (void)mutex_lock(&main_arena.mutex); - victim = (top_check() >= 0) ? aproxy_int_malloc(&main_arena, sz+1) : NULL; - (void)mutex_unlock(&main_arena.mutex); - return mem2mem_check(victim, sz); -} - -static void -#if __STD_C -free_check(Void_t* mem, const Void_t *caller) -#else -free_check(mem, caller) Void_t* mem; const Void_t *caller; -#endif -{ - mchunkptr p; - - if(!mem) return; - (void)mutex_lock(&main_arena.mutex); - p = mem2chunk_check(mem); - if(!p) { - (void)mutex_unlock(&main_arena.mutex); - - malloc_printerr(check_action, "free(): invalid pointer", mem); - return; - } -#if HAVE_MMAP - if (chunk_is_mmapped(p)) { - (void)mutex_unlock(&main_arena.mutex); - munmap_chunk(p); - return; - } -#endif -#if 0 /* Erase freed memory. */ - memset(mem, 0, chunksize(p) - (SIZE_SZ+1)); -#endif - aproxy_int_free(&main_arena, mem); - (void)mutex_unlock(&main_arena.mutex); -} - -static Void_t* -#if __STD_C -realloc_check(Void_t* oldmem, size_t bytes, const Void_t *caller) -#else -realloc_check(oldmem, bytes, caller) - Void_t* oldmem; size_t bytes; const Void_t *caller; -#endif -{ - mchunkptr oldp; - INTERNAL_SIZE_T nb, oldsize; - Void_t* newmem = 0; - - if (oldmem == 0) return malloc_check(bytes, NULL); - (void)mutex_lock(&main_arena.mutex); - oldp = mem2chunk_check(oldmem); - (void)mutex_unlock(&main_arena.mutex); - if(!oldp) { - malloc_printerr(check_action, "realloc(): invalid pointer", oldmem); - return malloc_check(bytes, NULL); - } - oldsize = chunksize(oldp); - - checked_request2size(bytes+1, nb); - (void)mutex_lock(&main_arena.mutex); - -#if HAVE_MMAP - if (chunk_is_mmapped(oldp)) { -#if HAVE_MREMAP - mchunkptr newp = mremap_chunk(oldp, nb); - if(newp) - newmem = chunk2mem(newp); - else -#endif - { - /* Note the extra SIZE_SZ overhead. */ - if(oldsize - SIZE_SZ >= nb) - newmem = oldmem; /* do nothing */ - else { - /* Must alloc, copy, free. */ - if (top_check() >= 0) - newmem = aproxy_int_malloc(&main_arena, bytes+1); - if (newmem) { - MALLOC_COPY(BOUNDED_N(newmem, bytes+1), oldmem, oldsize - 2*SIZE_SZ); - munmap_chunk(oldp); - } - } - } - } else { -#endif /* HAVE_MMAP */ - if (top_check() >= 0) - newmem = aproxy_int_realloc(&main_arena, oldmem, bytes+1); -#if 0 /* Erase freed memory. */ - if(newmem) - newp = mem2chunk(newmem); - nb = chunksize(newp); - if(oldp=chunk_at_offset(newp, nb)) { - memset((char*)oldmem + 2*sizeof(mbinptr), 0, - oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1)); - } else if(nb > oldsize+SIZE_SZ) { - memset((char*)BOUNDED_N(chunk2mem(newp), bytes) + oldsize, - 0, nb - (oldsize+SIZE_SZ)); - } -#endif -#if HAVE_MMAP - } -#endif - (void)mutex_unlock(&main_arena.mutex); - - return mem2mem_check(newmem, bytes); -} - -static Void_t* -#if __STD_C -memalign_check(size_t alignment, size_t bytes, const Void_t *caller) -#else -memalign_check(alignment, bytes, caller) - size_t alignment; size_t bytes; const Void_t *caller; -#endif -{ - INTERNAL_SIZE_T nb; - Void_t* mem; - - if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, NULL); - if (alignment < MINSIZE) alignment = MINSIZE; - - checked_request2size(bytes+1, nb); - (void)mutex_lock(&main_arena.mutex); - mem = (top_check() >= 0) ? aproxy_int_memalign(&main_arena, alignment, bytes+1) : - NULL; - (void)mutex_unlock(&main_arena.mutex); - return mem2mem_check(mem, bytes); -} - -#ifndef NO_THREADS - -# ifdef _LIBC -# if USE___THREAD || (defined USE_TLS && !defined SHARED) - /* These routines are never needed in this configuration. */ -# define NO_STARTER -# endif -# endif - -# ifdef NO_STARTER -# undef NO_STARTER -# else - -/* The following hooks are used when the global initialization in - aproxy_ptmalloc_init() hasn't completed yet. */ - -static Void_t* -#if __STD_C -malloc_starter(size_t sz, const Void_t *caller) -#else -malloc_starter(sz, caller) size_t sz; const Void_t *caller; -#endif -{ - Void_t* victim; - - victim = aproxy_int_malloc(&main_arena, sz); - - return victim ? BOUNDED_N(victim, sz) : 0; -} - -static Void_t* -#if __STD_C -memalign_starter(size_t align, size_t sz, const Void_t *caller) -#else -memalign_starter(align, sz, caller) size_t align, sz; const Void_t *caller; -#endif -{ - Void_t* victim; - - victim = aproxy_int_memalign(&main_arena, align, sz); - - return victim ? BOUNDED_N(victim, sz) : 0; -} - -static void -#if __STD_C -free_starter(Void_t* mem, const Void_t *caller) -#else -free_starter(mem, caller) Void_t* mem; const Void_t *caller; -#endif -{ - mchunkptr p; - - if(!mem) return; - p = mem2chunk(mem); -#if HAVE_MMAP - if (chunk_is_mmapped(p)) { - munmap_chunk(p); - return; - } -#endif - aproxy_int_free(&main_arena, mem); -} - -# endif /* !defiend NO_STARTER */ -#endif /* NO_THREADS */ - - -/* Get/set state: aproxy_get_state() records the current state of all - malloc variables (_except_ for the actual heap contents and `hook' - function pointers) in a system dependent, opaque data structure. - This data structure is dynamically allocated and can be free()d - after use. aproxy_set_state() restores the state of all malloc - variables to the previously obtained state. This is especially - useful when using this malloc as part of a shared library, and when - the heap contents are saved/restored via some other method. The - primary example for this is GNU Emacs with its `dumping' procedure. - `Hook' function pointers are never saved or restored by these - functions, with two exceptions: If malloc checking was in use when - aproxy_get_state() was called, then aproxy_set_state() calls - __aproxy_check_init() if possible; if malloc checking was not in - use in the recorded state but the user requested malloc checking, - then the hooks are reset to 0. */ - -#define MALLOC_STATE_MAGIC 0x444c4541l -#define MALLOC_STATE_VERSION (0*0x100l + 2l) /* major*0x100 + minor */ - -struct malloc_save_state { - long magic; - long version; - mbinptr av[NBINS * 2 + 2]; - char* sbrk_base; - int sbrked_mem_bytes; - unsigned long trim_threshold; - unsigned long top_pad; - unsigned int n_mmaps_max; - unsigned long mmap_threshold; - int check_action; - unsigned long max_sbrked_mem; - unsigned long max_total_mem; - unsigned int n_mmaps; - unsigned int max_n_mmaps; - unsigned long mmapped_mem; - unsigned long max_mmapped_mem; - int using_malloc_checking; -}; - -Void_t* -public_gET_STATe(void) -{ - struct malloc_save_state* ms; - int i; - mbinptr b; - - ms = (struct malloc_save_state*)public_mALLOc(sizeof(*ms)); - if (!ms) - return 0; - (void)mutex_lock(&main_arena.mutex); - malloc_consolidate(&main_arena); - ms->magic = MALLOC_STATE_MAGIC; - ms->version = MALLOC_STATE_VERSION; - ms->av[0] = 0; - ms->av[1] = 0; /* used to be binblocks, now no longer used */ - ms->av[2] = top(&main_arena); - ms->av[3] = 0; /* used to be undefined */ - for(i=1; iav[2*i+2] = ms->av[2*i+3] = 0; /* empty bin */ - else { - ms->av[2*i+2] = first(b); - ms->av[2*i+3] = last(b); - } - } - ms->sbrk_base = mp_.sbrk_base; - ms->sbrked_mem_bytes = main_arena.system_mem; - ms->trim_threshold = mp_.trim_threshold; - ms->top_pad = mp_.top_pad; - ms->n_mmaps_max = mp_.n_mmaps_max; - ms->mmap_threshold = mp_.mmap_threshold; - ms->check_action = check_action; - ms->max_sbrked_mem = main_arena.max_system_mem; -#ifdef NO_THREADS - ms->max_total_mem = mp_.max_total_mem; -#else - ms->max_total_mem = 0; -#endif - ms->n_mmaps = mp_.n_mmaps; - ms->max_n_mmaps = mp_.max_n_mmaps; - ms->mmapped_mem = mp_.mmapped_mem; - ms->max_mmapped_mem = mp_.max_mmapped_mem; - ms->using_malloc_checking = using_malloc_checking; - (void)mutex_unlock(&main_arena.mutex); - return (Void_t*)ms; -} - -int -public_sET_STATe(Void_t* msptr) -{ - struct malloc_save_state* ms = (struct malloc_save_state*)msptr; - size_t i; - mbinptr b; - - disallow_malloc_check = 1; - aproxy_ptmalloc_init(); - if(ms->magic != MALLOC_STATE_MAGIC) return -1; - /* Must fail if the major version is too high. */ - if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2; - (void)mutex_lock(&main_arena.mutex); - /* There are no fastchunks. */ - clear_fastchunks(&main_arena); - set_max_fast(&main_arena, DEFAULT_MXFAST); - for (i=0; iav[2]; - main_arena.last_remainder = 0; - for(i=1; iav[2*i+2] == 0) { - assert(ms->av[2*i+3] == 0); - first(b) = last(b) = b; - } else { - if(iav[2*i+2]))==i && - largebin_index(chunksize(ms->av[2*i+3]))==i)) { - first(b) = ms->av[2*i+2]; - last(b) = ms->av[2*i+3]; - /* Make sure the links to the bins within the heap are correct. */ - first(b)->bk = b; - last(b)->fd = b; - /* Set bit in binblocks. */ - mark_bin(&main_arena, i); - } else { - /* Oops, index computation from chunksize must have changed. - Link the whole list into unsorted_chunks. */ - first(b) = last(b) = b; - b = unsorted_chunks(&main_arena); - ms->av[2*i+2]->bk = b; - ms->av[2*i+3]->fd = b->fd; - b->fd->bk = ms->av[2*i+3]; - b->fd = ms->av[2*i+2]; - } - } - } - mp_.sbrk_base = ms->sbrk_base; - main_arena.system_mem = ms->sbrked_mem_bytes; - mp_.trim_threshold = ms->trim_threshold; - mp_.top_pad = ms->top_pad; - mp_.n_mmaps_max = ms->n_mmaps_max; - mp_.mmap_threshold = ms->mmap_threshold; - check_action = ms->check_action; - main_arena.max_system_mem = ms->max_sbrked_mem; -#ifdef NO_THREADS - mp_.max_total_mem = ms->max_total_mem; -#endif - mp_.n_mmaps = ms->n_mmaps; - mp_.max_n_mmaps = ms->max_n_mmaps; - mp_.mmapped_mem = ms->mmapped_mem; - mp_.max_mmapped_mem = ms->max_mmapped_mem; - /* add version-dependent code here */ - if (ms->version >= 1) { - /* Check whether it is safe to enable malloc checking, or whether - it is necessary to disable it. */ - if (ms->using_malloc_checking && !using_malloc_checking && - !disallow_malloc_check) - __aproxy_check_init (); - else if (!ms->using_malloc_checking && using_malloc_checking) { - __aproxy_hook = 0; - __aproxy_free_hook = 0; - __aproxy_realloc_hook = 0; - __aproxy_memalign_hook = 0; - using_malloc_checking = 0; - } - } - check_malloc_state(&main_arena); - - (void)mutex_unlock(&main_arena.mutex); - return 0; -} - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_malloc.c.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_malloc.c.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_malloc.c.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_malloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5631 +0,0 @@ - /* Malloc implementation for multiple threads without lock contention. - Copyright (C) 1996-2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Wolfram Gloger - and Doug Lea , 2001. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* - This is a version (aka ptmalloc2) of malloc/free/realloc written by - Doug Lea and adapted to multiple threads/arenas by Wolfram Gloger. - -* Version ptmalloc2-20011215 - $Id: aproxy_malloc.c,v 1.5 2007-05-11 10:48:29 may Exp $ - based on: - VERSION 2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) - - Note: There may be an updated version of this malloc obtainable at - http://www.malloc.de/malloc/ptmalloc2.tar.gz - Check before installing! - -* Quickstart - - In order to compile this implementation, a Makefile is provided with - the ptmalloc2 distribution, which has pre-defined targets for some - popular systems (e.g. "make posix" for Posix threads). All that is - typically required with regard to compiler flags is the selection of - the thread package via defining one out of USE_PTHREADS, USE_THR or - USE_SPROC. Check the thread-m.h file for what effects this has. - Many/most systems will additionally require USE_TSD_DATA_HACK to be - defined, so this is the default for "make posix". - -* Why use this malloc? - - This is not the fastest, most space-conserving, most portable, or - most tunable malloc ever written. However it is among the fastest - while also being among the most space-conserving, portable and tunable. - Consistent balance across these factors results in a good general-purpose - allocator for malloc-intensive programs. - - The main properties of the algorithms are: - * For large (>= 512 bytes) requests, it is a pure best-fit allocator, - with ties normally decided via FIFO (i.e. least recently used). - * For small (<= 64 bytes by default) requests, it is a caching - allocator, that maintains pools of quickly recycled chunks. - * In between, and for combinations of large and small requests, it does - the best it can trying to meet both goals at once. - * For very large requests (>= 128KB by default), it relies on system - memory mapping facilities, if supported. - - For a longer but slightly out of date high-level description, see - http://gee.cs.oswego.edu/dl/html/malloc.html - - You may already by default be using a C library containing a malloc - that is based on some version of this malloc (for example in - linux). You might still want to use the one in this file in order to - customize settings or to avoid overheads associated with library - versions. - -* Contents, described in more detail in "description of public routines" below. - - Standard (ANSI/SVID/...) functions: - malloc(size_t n); - calloc(size_t n_elements, size_t element_size); - free(Void_t* p); - realloc(Void_t* p, size_t n); - memalign(size_t alignment, size_t n); - valloc(size_t n); - mallinfo() - mallopt(int parameter_number, int parameter_value) - - Additional functions: - independent_calloc(size_t n_elements, size_t size, Void_t* chunks[]); - independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]); - pvalloc(size_t n); - cfree(Void_t* p); - malloc_trim(size_t pad); - malloc_usable_size(Void_t* p); - malloc_stats(); - -* Vital statistics: - - Supported pointer representation: 4 or 8 bytes - Supported size_t representation: 4 or 8 bytes - Note that size_t is allowed to be 4 bytes even if pointers are 8. - You can adjust this by defining INTERNAL_SIZE_T - - Alignment: 2 * sizeof(size_t) (default) - (i.e., 8 byte alignment with 4byte size_t). This suffices for - nearly all current machines and C compilers. However, you can - define MALLOC_ALIGNMENT to be wider than this if necessary. - - Minimum overhead per allocated chunk: 4 or 8 bytes - Each malloced chunk has a hidden word of overhead holding size - and status information. - - Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead) - 8-byte ptrs: 24/32 bytes (including, 4/8 overhead) - - When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte - ptrs but 4 byte size) or 24 (for 8/8) additional bytes are - needed; 4 (8) for a trailing size field and 8 (16) bytes for - free list pointers. Thus, the minimum allocatable size is - 16/24/32 bytes. - - Even a request for zero bytes (i.e., malloc(0)) returns a - pointer to something of the minimum allocatable size. - - The maximum overhead wastage (i.e., number of extra bytes - allocated than were requested in malloc) is less than or equal - to the minimum size, except for requests >= mmap_threshold that - are serviced via mmap(), where the worst case wastage is 2 * - sizeof(size_t) bytes plus the remainder from a system page (the - minimal mmap unit); typically 4096 or 8192 bytes. - - Maximum allocated size: 4-byte size_t: 2^32 minus about two pages - 8-byte size_t: 2^64 minus about two pages - - It is assumed that (possibly signed) size_t values suffice to - represent chunk sizes. `Possibly signed' is due to the fact - that `size_t' may be defined on a system as either a signed or - an unsigned type. The ISO C standard says that it must be - unsigned, but a few systems are known not to adhere to this. - Additionally, even when size_t is unsigned, sbrk (which is by - default used to obtain memory from system) accepts signed - arguments, and may not be able to handle size_t-wide arguments - with negative sign bit. Generally, values that would - appear as negative after accounting for overhead and alignment - are supported only via mmap(), which does not have this - limitation. - - Requests for sizes outside the allowed range will perform an optional - failure action and then return null. (Requests may also - also fail because a system is out of memory.) - - Thread-safety: thread-safe unless NO_THREADS is defined - - Compliance: I believe it is compliant with the 1997 Single Unix Specification - (See http://www.opennc.org). Also SVID/XPG, ANSI C, and probably - others as well. - -* Synopsis of compile-time options: - - People have reported using previous versions of this malloc on all - versions of Unix, sometimes by tweaking some of the defines - below. It has been tested most extensively on Solaris and - Linux. It is also reported to work on WIN32 platforms. - People also report using it in stand-alone embedded systems. - - The implementation is in straight, hand-tuned ANSI C. It is not - at all modular. (Sorry!) It uses a lot of macros. To be at all - usable, this code should be compiled using an optimizing compiler - (for example gcc -O3) that can simplify expressions and control - paths. (FAQ: some macros import variables as arguments rather than - declare locals because people reported that some debuggers - otherwise get confused.) - - OPTION DEFAULT VALUE - - Compilation Environment options: - - __STD_C derived from C compiler defines - WIN32 NOT defined - HAVE_MEMCPY defined - USE_MEMCPY 1 if HAVE_MEMCPY is defined - HAVE_MMAP defined as 1 - MMAP_CLEARS 1 - HAVE_MREMAP 0 unless linux defined - USE_ARENAS the same as HAVE_MMAP - malloc_getpagesize derived from system #includes, or 4096 if not - HAVE_USR_INCLUDE_MALLOC_H NOT defined - LACKS_UNISTD_H NOT defined unless WIN32 - LACKS_SYS_PARAM_H NOT defined unless WIN32 - LACKS_SYS_MMAN_H NOT defined unless WIN32 - - Changing default word sizes: - - INTERNAL_SIZE_T size_t - MALLOC_ALIGNMENT 2 * sizeof(INTERNAL_SIZE_T) - - Configuration and functionality options: - - USE_DL_PREFIX NOT defined - USE_PUBLIC_MALLOC_WRAPPERS NOT defined - USE_MALLOC_LOCK NOT defined - MALLOC_DEBUG NOT defined - REALLOC_ZERO_BYTES_FREES 1 - MALLOC_FAILURE_ACTION errno = ENOMEM, if __STD_C defined, else no-op - TRIM_FASTBINS 0 - - Options for customizing MORECORE: - - MORECORE sbrk - MORECORE_FAILURE -1 - MORECORE_CONTIGUOUS 1 - MORECORE_CANNOT_TRIM NOT defined - MORECORE_CLEARS 1 - MMAP_AS_MORECORE_SIZE (1024 * 1024) - - Tuning options that are also dynamically changeable via mallopt: - - DEFAULT_MXFAST 64 - DEFAULT_TRIM_THRESHOLD 128 * 1024 - DEFAULT_TOP_PAD 0 - DEFAULT_MMAP_THRESHOLD 128 * 1024 - DEFAULT_MMAP_MAX 65536 - - There are several other #defined constants and macros that you - probably don't want to touch unless you are extending or adapting malloc. */ - -/* - __STD_C should be nonzero if using ANSI-standard C compiler, a C++ - compiler, or a C compiler sufficiently close to ANSI to get away - with it. -*/ - - -#include "libvars.h" - -/* -** for MREMAP_MAYMOVE -*/ -#if !defined(_GNU_SOURCE) - #define _GNU_SOURCE -#endif - -#include -#include - - -#ifndef INTERNAL_SIZE_T -#define INTERNAL_SIZE_T size_t -#endif - - - -#ifndef __STD_C -#if defined(__STDC__) || defined(__cplusplus) -#define __STD_C 1 -#else -#define __STD_C 0 -#endif -#endif /*__STD_C*/ - - -/* - Void_t* is the pointer type that malloc should say it returns -*/ - -#ifndef Void_t -#if (__STD_C || defined(WIN32)) -#define Void_t void -#else -#define Void_t char -#endif -#endif /*Void_t*/ - -#if __STD_C -#include /* for size_t */ -#include /* for getenv(), abort() */ -#else -#include -#endif - -#include - -#ifdef _LIBC -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* define LACKS_UNISTD_H if your system does not have a . */ - -/* #define LACKS_UNISTD_H */ - -#ifndef LACKS_UNISTD_H -#include -#endif - -/* define LACKS_SYS_PARAM_H if your system does not have a . */ - -/* #define LACKS_SYS_PARAM_H */ - - -#include /* needed for malloc_stats */ -#include /* needed for optional MALLOC_FAILURE_ACTION */ - -/* For uintptr_t. */ -#if !defined(IRIX) && !defined(__FreeBSD__) && !defined(sun) -#include -#endif - -/* For va_arg, va_start, va_end. */ -#include - -/* For writev and struct iovec. */ -#include -/* For syslog. */ -#include - -/* For various dynamic linking things. */ -#include - -/* - Debugging: - - Because freed chunks may be overwritten with bookkeeping fields, this - malloc will often die when freed memory is overwritten by user - programs. This can be very effective (albeit in an annoying way) - in helping track down dangling pointers. - - If you compile with -DMALLOC_DEBUG, a number of assertion checks are - enabled that will catch more memory errors. You probably won't be - able to make much sense of the actual assertion errors, but they - should help you locate incorrectly overwritten memory. The checking - is fairly extensive, and will slow down execution - noticeably. Calling malloc_stats or mallinfo with MALLOC_DEBUG set - will attempt to check every non-mmapped allocated and free chunk in - the course of computing the summmaries. (By nature, mmapped regions - cannot be checked very much automatically.) - - Setting MALLOC_DEBUG may also be helpful if you are trying to modify - this code. The assertions in the check routines spell out in more - detail the assumptions and invariants underlying the algorithms. - - Setting MALLOC_DEBUG does NOT provide an automated mechanism for - checking that all accesses to malloced memory stay within their - bounds. However, there are several add-ons and adaptations of this - or other mallocs available that do this. -*/ - -#if MALLOC_DEBUG -#include -#else -#undef assert -#define assert(x) ((void)0) -#endif - - -/* - INTERNAL_SIZE_T is the word-size used for internal bookkeeping - of chunk sizes. - - The default version is the same as size_t. - - While not strictly necessary, it is best to define this as an - unsigned type, even if size_t is a signed type. This may avoid some - artificial size limitations on some systems. - - On a 64-bit machine, you may be able to reduce malloc overhead by - defining INTERNAL_SIZE_T to be a 32 bit `unsigned int' at the - expense of not being able to handle more than 2^32 of malloced - space. If this limitation is acceptable, you are encouraged to set - this unless you are on a platform requiring 16byte alignments. In - this case the alignment requirements turn out to negate any - potential advantages of decreasing size_t word size. - - Implementors: Beware of the possible combinations of: - - INTERNAL_SIZE_T might be signed or unsigned, might be 32 or 64 bits, - and might be the same width as int or as long - - size_t might have different width and signedness as INTERNAL_SIZE_T - - int and long might be 32 or 64 bits, and might be the same width - To deal with this, most comparisons and difference computations - among INTERNAL_SIZE_Ts should cast them to unsigned long, being - aware of the fact that casting an unsigned int to a wider long does - not sign-extend. (This also makes checking for negative numbers - awkward.) Some of these casts result in harmless compiler warnings - on some systems. -*/ - -#ifndef INTERNAL_SIZE_T -#define INTERNAL_SIZE_T size_t -#endif - -/* The corresponding word size */ -#define SIZE_SZ (sizeof(INTERNAL_SIZE_T)) - - -/* - MALLOC_ALIGNMENT is the minimum alignment for malloc'ed chunks. - It must be a power of two at least 2 * SIZE_SZ, even on machines - for which smaller alignments would suffice. It may be defined as - larger than this though. Note however that code and data structures - are optimized for the case of 8-byte alignment. -*/ - - -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT (2 * SIZE_SZ) -#endif - -/* The corresponding bit mask value */ -#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1) - - - -/* - REALLOC_ZERO_BYTES_FREES should be set if a call to - realloc with zero bytes should be the same as a call to free. - This is required by the C standard. Otherwise, since this malloc - returns a unique pointer for malloc(0), so does realloc(p, 0). -*/ - -#ifndef REALLOC_ZERO_BYTES_FREES -#define REALLOC_ZERO_BYTES_FREES 1 -#endif - -/* - TRIM_FASTBINS controls whether free() of a very small chunk can - immediately lead to trimming. Setting to true (1) can reduce memory - footprint, but will almost always slow down programs that use a lot - of small chunks. - - Define this only if you are willing to give up some speed to more - aggressively reduce system-level memory footprint when releasing - memory in programs that use many small chunks. You can get - essentially the same effect by setting MXFAST to 0, but this can - lead to even greater slowdowns in programs using many small chunks. - TRIM_FASTBINS is an in-between compile-time option, that disables - only those chunks bordering topmost memory from being placed in - fastbins. -*/ - -#ifndef TRIM_FASTBINS -#define TRIM_FASTBINS 0 -#endif - - -/* - USE_DL_PREFIX will prefix all public routines with the string 'dl'. - This is necessary when you only want to use this malloc in one part - of a program, using your regular system malloc elsewhere. -*/ - -/* #define USE_DL_PREFIX */ - - -/* - Two-phase name translation. - All of the actual routines are given mangled names. - When wrappers are used, they become the public callable versions. - When DL_PREFIX is used, the callable names are prefixed. -*/ - -#ifdef USE_DL_PREFIX -#define public_cALLOc dlcalloc -#define public_fREe dlfree -#define public_cFREe dlcfree -#define public_mALLOc dlmalloc -#define public_mEMALIGn dlmemalign -#define public_rEALLOc dlrealloc -#define public_vALLOc dlvalloc -#define public_pVALLOc dlpvalloc -#define public_mALLINFo dlmallinfo -#define public_mALLOPt dlmallopt -#define public_mTRIm dlmalloc_trim -#define public_mSTATs dlmalloc_stats -#define public_mUSABLe dlmalloc_usable_size -#define public_iCALLOc dlindependent_calloc -#define public_iCOMALLOc dlindependent_comalloc -#define public_gET_STATe dlget_state -#define public_sET_STATe dlset_state -#else /* USE_DL_PREFIX */ -#ifdef _LIBC - -/* Special defines for the GNU C library. */ -#define public_cALLOc __libc_calloc -#define public_fREe __libc_free -#define public_cFREe __libc_cfree -#define public_mALLOc __libc_malloc -#define public_mEMALIGn __libc_memalign -#define public_rEALLOc __libc_realloc -#define public_vALLOc __libc_valloc -#define public_pVALLOc __libc_pvalloc -#define public_mALLINFo __libc_mallinfo -#define public_mALLOPt __libc_mallopt -#define public_mTRIm __malloc_trim -#define public_mSTATs __malloc_stats -#define public_mUSABLe __malloc_usable_size -#define public_iCALLOc __libc_independent_calloc -#define public_iCOMALLOc __libc_independent_comalloc -#define public_gET_STATe __aproxy_get_state -#define public_sET_STATe __aproxy_set_state -#define malloc_getpagesize __getpagesize() -#define open __open -#define mmap __mmap -#define munmap __munmap -#define mremap __mremap -#define mprotect __mprotect -#define MORECORE (*__morecore) -#define MORECORE_FAILURE 0 - -Void_t * __default_morecore (ptrdiff_t); -Void_t *(*__morecore)(ptrdiff_t) = __default_morecore; - -#else /* !_LIBC */ -#define public_cALLOc aproxy_calloc -#define public_fREe aproxy_free -#define public_cFREe aproxy_cfree -#define public_mALLOc aproxy_malloc -#define public_mEMALIGn aproxy_memalign -#define public_rEALLOc aproxy_realloc -#define public_vALLOc aproxy_valloc -#define public_pVALLOc aproxy_pvalloc -#define public_mALLINFo aproxy_mallinfo -#define public_mALLOPt aproxy_mallopt -#define public_mTRIm aproxy_trim -#define public_mSTATs aproxy_stats -#define public_mUSABLe aproxy_usable_size -#define public_iCALLOc aproxy_independent_calloc -#define public_iCOMALLOc aproxy_independent_comalloc -#define public_gET_STATe aproxy_aproxy_get_state -#define public_sET_STATe aproxy_set_state -#endif /* _LIBC */ -#endif /* USE_DL_PREFIX */ - -#ifndef _LIBC -#define __builtin_expect(expr, val) (expr) - -#define fwrite(buf, size, count, fp) _IO_fwrite (buf, size, count, fp) -#endif - -/* - HAVE_MEMCPY should be defined if you are not otherwise using - ANSI STD C, but still have memcpy and memset in your C library - and want to use them in calloc and realloc. Otherwise simple - macro versions are defined below. - - USE_MEMCPY should be defined as 1 if you actually want to - have memset and memcpy called. People report that the macro - versions are faster than libc versions on some systems. - - Even if USE_MEMCPY is set to 1, loops to copy/clear small chunks - (of <= 36 bytes) are manually unrolled in realloc and calloc. -*/ - -#define HAVE_MEMCPY - -#ifndef USE_MEMCPY -#ifdef HAVE_MEMCPY -#define USE_MEMCPY 1 -#else -#define USE_MEMCPY 0 -#endif -#endif - - -#if (__STD_C || defined(HAVE_MEMCPY)) - -#ifdef _LIBC -# include -#else -#ifdef WIN32 -/* On Win32 memset and memcpy are already declared in windows.h */ -#else -#if __STD_C -void* memset(void*, int, size_t); -void* memcpy(void*, const void*, size_t); -#else -Void_t* memset(); -Void_t* memcpy(); -#endif -#endif -#endif -#endif - -/* - MALLOC_FAILURE_ACTION is the action to take before "return 0" when - malloc fails to be able to return memory, either because memory is - exhausted or because of illegal arguments. - - By default, sets errno if running on STD_C platform, else does nothing. -*/ - -#ifndef MALLOC_FAILURE_ACTION -#if __STD_C -#define MALLOC_FAILURE_ACTION \ - errno = ENOMEM; - -#else -#define MALLOC_FAILURE_ACTION -#endif -#endif - -/* - MORECORE-related declarations. By default, rely on sbrk -*/ - -#ifdef LACKS_UNISTD_H -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -#if __STD_C -extern Void_t* sbrk(ptrdiff_t); -#else -extern Void_t* sbrk(); -#endif -#endif -#endif - - -/* - MORECORE_FAILURE is the value returned upon failure of MORECORE - as well as mmap. Since it cannot be an otherwise valid memory address, - and must reflect values of standard sys calls, you probably ought not - try to redefine it. -*/ - -#ifndef MORECORE_FAILURE -#define MORECORE_FAILURE (-1) -#endif - -/* - MORECORE is the name of the routine to call to obtain more memory - from the system. See below for general guidance on writing - alternative MORECORE functions, as well as a version for WIN32 and a - sample version for pre-OSX macos. -*/ - -void *aproxy_sbrk(intptr_t increment) { return ((void *) MORECORE_FAILURE); } - -#ifndef MORECORE -//#define MORECORE sbrk -#define MORECORE aproxy_sbrk -#endif - -/* - If MORECORE_CONTIGUOUS is true, take advantage of fact that - consecutive calls to MORECORE with positive arguments always return - contiguous increasing addresses. This is true of unix sbrk. Even - if not defined, when regions happen to be contiguous, malloc will - permit allocations spanning regions obtained from different - calls. But defining this when applicable enables some stronger - consistency checks and space efficiencies. -*/ - -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif - -/* - Define MORECORE_CANNOT_TRIM if your version of MORECORE - cannot release space back to the system when given negative - arguments. This is generally necessary only if you are using - a hand-crafted MORECORE function that cannot handle negative arguments. -*/ - -/* #define MORECORE_CANNOT_TRIM */ - -/* MORECORE_CLEARS (default 1) - The degree to which the routine mapped to MORECORE zeroes out - memory: never (0), only for newly allocated space (1) or always - (2). The distinction between (1) and (2) is necessary because on - some systems, if the application first decrements and then - increments the break value, the contents of the reallocated space - are unspecified. -*/ - -#ifndef MORECORE_CLEARS -#define MORECORE_CLEARS 1 -#endif - - -/* - Define HAVE_MMAP as true to optionally make malloc() use mmap() to - allocate very large blocks. These will be returned to the - operating system immediately after a free(). Also, if mmap - is available, it is used as a backup strategy in cases where - MORECORE fails to provide space from system. - - This malloc is best tuned to work with mmap for large requests. - If you do not have mmap, operations involving very large chunks (1MB - or so) may be slower than you'd like. -*/ - -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 - -/* - Standard unix mmap using /dev/zero clears memory so calloc doesn't - need to. -*/ - -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif - -#else /* no mmap */ -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 0 -#endif -#endif - - -/* - MMAP_AS_MORECORE_SIZE is the minimum mmap size argument to use if - sbrk fails, and mmap is used as a backup (which is done only if - HAVE_MMAP). The value must be a multiple of page size. This - backup strategy generally applies only when systems have "holes" in - address space, so sbrk cannot perform contiguous expansion, but - there is still space available on system. On systems for which - this is known to be useful (i.e. most linux kernels), this occurs - only when programs allocate huge amounts of memory. Between this, - and the fact that mmap regions tend to be limited, the size should - be large, to avoid too many mmap calls and thus avoid running out - of kernel resources. -*/ - -#ifndef MMAP_AS_MORECORE_SIZE - //#define MMAP_AS_MORECORE_SIZE (1024 * 1024) -#define MMAP_AS_MORECORE_SIZE (1024 * 4096) -#endif - -/* - Define HAVE_MREMAP to make realloc() use mremap() to re-allocate - large blocks. This is currently only possible on Linux with - kernel versions newer than 1.3.77. -*/ - -#ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#else -#define HAVE_MREMAP 0 -#endif - -#endif /* HAVE_MMAP */ - -/* Define USE_ARENAS to enable support for multiple `arenas'. These - are allocated using mmap(), are necessary for threads and - occasionally useful to overcome address space limitations affecting - sbrk(). */ - -#ifndef USE_ARENAS -#define USE_ARENAS HAVE_MMAP -#endif - - -/* - The system page size. To the extent possible, this malloc manages - memory from the system in page-size units. Note that this value is - cached during initialization into a field of malloc_state. So even - if malloc_getpagesize is a function, it is only called once. - - The following mechanics for getpagesize were adapted from bsd/gnu - getpagesize.h. If none of the system-probes here apply, a value of - 4096 is used, which should be OK: If they don't apply, then using - the actual value probably doesn't impact performance. -*/ - - -#ifndef malloc_getpagesize - -#ifndef LACKS_UNISTD_H -# include -#endif - -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif - -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize (4096) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif - -/* - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing usage properties and - statistics. It should work on any SVID/XPG compliant system that has - a /usr/include/malloc.h defining struct mallinfo. (If you'd like to - install such a thing yourself, cut out the preliminary declarations - as described above and below and save them in a malloc.h file. But - there's no compelling reason to bother to do this.) - - The main declaration needed is the mallinfo struct that is returned - (by-copy) by mallinfo(). The SVID/XPG malloinfo struct contains a - bunch of fields that are not even meaningful in this version of - malloc. These fields are are instead filled by mallinfo() with - other numbers that might be of interest. - - HAVE_USR_INCLUDE_MALLOC_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else an SVID2/XPG2 compliant - version is declared below. These must be precisely the same for - mallinfo() to work. The original SVID version of this struct, - defined on most systems with mallinfo, declares all fields as - ints. But some others define as unsigned long. If your system - defines the fields using a type of different width than listed here, - you must #include your system version and #define - HAVE_USR_INCLUDE_MALLOC_H. -*/ - -/* #define HAVE_USR_INCLUDE_MALLOC_H */ - -#ifdef HAVE_USR_INCLUDE_MALLOC_H -#include "/usr/include/malloc.h" -#endif - - -/* ---------- description of public routines ------------ */ - -/* - malloc(size_t n) - Returns a pointer to a newly allocated chunk of at least n bytes, or null - if no space is available. Additionally, on failure, errno is - set to ENOMEM on ANSI C systems. - - If n is zero, malloc returns a minumum-sized chunk. (The minimum - size is 16 bytes on most 32bit systems, and 24 or 32 bytes on 64bit - systems.) On most systems, size_t is an unsigned type, so calls - with negative arguments are interpreted as requests for huge amounts - of space, which will often fail. The maximum supported value of n - differs across systems, but is in all cases less than the maximum - representable value of a size_t. -*/ -#if __STD_C -Void_t* public_mALLOc(size_t); -#else -Void_t* public_mALLOc(); -#endif -#ifdef libc_hidden_proto -libc_hidden_proto (public_mALLOc) -#endif - -/* - free(Void_t* p) - Releases the chunk of memory pointed to by p, that had been previously - allocated using malloc or a related routine such as realloc. - It has no effect if p is null. It can have arbitrary (i.e., bad!) - effects if p has already been freed. - - Unless disabled (using mallopt), freeing very large spaces will - when possible, automatically trigger operations that give - back unused memory to the system, thus reducing program footprint. -*/ -#if __STD_C -void public_fREe(Void_t*); -#else -void public_fREe(); -#endif -#ifdef libc_hidden_proto -libc_hidden_proto (public_fREe) -#endif - -/* - calloc(size_t n_elements, size_t element_size); - Returns a pointer to n_elements * element_size bytes, with all locations - set to zero. -*/ -#if __STD_C -Void_t* public_cALLOc(size_t, size_t); -#else -Void_t* public_cALLOc(); -#endif - -/* - realloc(Void_t* p, size_t n) - Returns a pointer to a chunk of size n that contains the same data - as does chunk p up to the minimum of (n, p's size) bytes, or null - if no space is available. - - The returned pointer may or may not be the same as p. The algorithm - prefers extending p when possible, otherwise it employs the - equivalent of a malloc-copy-free sequence. - - If p is null, realloc is equivalent to malloc. - - If space is not available, realloc returns null, errno is set (if on - ANSI) and p is NOT freed. - - if n is for fewer bytes than already held by p, the newly unused - space is lopped off and freed if possible. Unless the #define - REALLOC_ZERO_BYTES_FREES is set, realloc with a size argument of - zero (re)allocates a minimum-sized chunk. - - Large chunks that were internally obtained via mmap will always - be reallocated using malloc-copy-free sequences unless - the system supports MREMAP (currently only linux). - - The old unix realloc convention of allowing the last-free'd chunk - to be used as an argument to realloc is not supported. -*/ -#if __STD_C -Void_t* public_rEALLOc(Void_t*, size_t); -#else -Void_t* public_rEALLOc(); -#endif -#ifdef libc_hidden_proto -libc_hidden_proto (public_rEALLOc) -#endif - -/* - memalign(size_t alignment, size_t n); - Returns a pointer to a newly allocated chunk of n bytes, aligned - in accord with the alignment argument. - - The alignment argument should be a power of two. If the argument is - not a power of two, the nearest greater power is used. - 8-byte alignment is guaranteed by normal malloc calls, so don't - bother calling memalign with an argument of 8 or less. - - Overreliance on memalign is a sure way to fragment space. -*/ -#if __STD_C -Void_t* public_mEMALIGn(size_t, size_t); -#else -Void_t* public_mEMALIGn(); -#endif -#ifdef libc_hidden_proto -libc_hidden_proto (public_mEMALIGn) -#endif - -/* - valloc(size_t n); - Equivalent to memalign(pagesize, n), where pagesize is the page - size of the system. If the pagesize is unknown, 4096 is used. -*/ -#if __STD_C -Void_t* public_vALLOc(size_t); -#else -Void_t* public_vALLOc(); -#endif - - - -/* - mallopt(int parameter_number, int parameter_value) - Sets tunable parameters The format is to provide a - (parameter-number, parameter-value) pair. mallopt then sets the - corresponding parameter to the argument value if it can (i.e., so - long as the value is meaningful), and returns 1 if successful else - 0. SVID/XPG/ANSI defines four standard param numbers for mallopt, - normally defined in malloc.h. Only one of these (M_MXFAST) is used - in this malloc. The others (M_NLBLKS, M_GRAIN, M_KEEP) don't apply, - so setting them has no effect. But this malloc also supports four - other options in mallopt. See below for details. Briefly, supported - parameters are as follows (listed defaults are for "typical" - configurations). - - Symbol param # default allowed param values - M_MXFAST 1 64 0-80 (0 disables fastbins) - M_TRIM_THRESHOLD -1 128*1024 any (-1U disables trimming) - M_TOP_PAD -2 0 any - M_MMAP_THRESHOLD -3 128*1024 any (or 0 if no MMAP support) - M_MMAP_MAX -4 65536 any (0 disables use of mmap) -*/ -#if __STD_C -int public_mALLOPt(int, int); -#else -int public_mALLOPt(); -#endif - - -/* - mallinfo() - Returns (by copy) a struct containing various summary statistics: - - arena: current total non-mmapped bytes allocated from system - ordblks: the number of free chunks - smblks: the number of fastbin blocks (i.e., small chunks that - have been freed but not use resused or consolidated) - hblks: current number of mmapped regions - hblkhd: total bytes held in mmapped regions - usmblks: the maximum total allocated space. This will be greater - than current total if trimming has occurred. - fsmblks: total bytes held in fastbin blocks - uordblks: current total allocated space (normal or mmapped) - fordblks: total free space - keepcost: the maximum number of bytes that could ideally be released - back to system via malloc_trim. ("ideally" means that - it ignores page restrictions etc.) - - Because these fields are ints, but internal bookkeeping may - be kept as longs, the reported values may wrap around zero and - thus be inaccurate. -*/ -#if __STD_C -struct mallinfo public_mALLINFo(void); -#else -struct mallinfo public_mALLINFo(); -#endif - -/* - independent_calloc(size_t n_elements, size_t element_size, Void_t* chunks[]); - - independent_calloc is similar to calloc, but instead of returning a - single cleared space, it returns an array of pointers to n_elements - independent elements that can hold contents of size elem_size, each - of which starts out cleared, and can be independently freed, - realloc'ed etc. The elements are guaranteed to be adjacently - allocated (this is not guaranteed to occur with multiple callocs or - mallocs), which may also improve cache locality in some - applications. - - The "chunks" argument is optional (i.e., may be null, which is - probably the most typical usage). If it is null, the returned array - is itself dynamically allocated and should also be freed when it is - no longer needed. Otherwise, the chunks array must be of at least - n_elements in length. It is filled in with the pointers to the - chunks. - - In either case, independent_calloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and "chunks" - is null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use regular calloc and assign pointers into this - space to represent elements. (In this case though, you cannot - independently free elements.) - - independent_calloc simplifies and speeds up implementations of many - kinds of pools. It may also be useful when constructing large data - structures that initially have a fixed number of fixed-sized nodes, - but the number is not known at compile time, and some of the nodes - may later need to be freed. For example: - - struct Node { int item; struct Node* next; }; - - struct Node* build_list() { - struct Node** pool; - int n = read_number_of_nodes_needed(); - if (n <= 0) return 0; - pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); - if (pool == 0) die(); - // organize into a linked list... - struct Node* first = pool[0]; - for (i = 0; i < n-1; ++i) - pool[i]->next = pool[i+1]; - free(pool); // Can now free the array (or not, if it is needed later) - return first; - } -*/ -#if __STD_C -Void_t** public_iCALLOc(size_t, size_t, Void_t**); -#else -Void_t** public_iCALLOc(); -#endif - -/* - independent_comalloc(size_t n_elements, size_t sizes[], Void_t* chunks[]); - - independent_comalloc allocates, all at once, a set of n_elements - chunks with sizes indicated in the "sizes" array. It returns - an array of pointers to these elements, each of which can be - independently freed, realloc'ed etc. The elements are guaranteed to - be adjacently allocated (this is not guaranteed to occur with - multiple callocs or mallocs), which may also improve cache locality - in some applications. - - The "chunks" argument is optional (i.e., may be null). If it is null - the returned array is itself dynamically allocated and should also - be freed when it is no longer needed. Otherwise, the chunks array - must be of at least n_elements in length. It is filled in with the - pointers to the chunks. - - In either case, independent_comalloc returns this pointer array, or - null if the allocation failed. If n_elements is zero and chunks is - null, it returns a chunk representing an array with zero elements - (which should be freed if not wanted). - - Each element must be individually freed when it is no longer - needed. If you'd like to instead be able to free all at once, you - should instead use a single regular malloc, and assign pointers at - particular offsets in the aggregate space. (In this case though, you - cannot independently free elements.) - - independent_comallac differs from independent_calloc in that each - element may have a different size, and also that it does not - automatically clear elements. - - independent_comalloc can be used to speed up allocation in cases - where several structs or objects must always be allocated at the - same time. For example: - - struct Head { ... } - struct Foot { ... } - - void send_message(char* msg) { - int msglen = strlen(msg); - size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; - void* chunks[3]; - if (independent_comalloc(3, sizes, chunks) == 0) - die(); - struct Head* head = (struct Head*)(chunks[0]); - char* body = (char*)(chunks[1]); - struct Foot* foot = (struct Foot*)(chunks[2]); - // ... - } - - In general though, independent_comalloc is worth using only for - larger values of n_elements. For small values, you probably won't - detect enough difference from series of malloc calls to bother. - - Overuse of independent_comalloc can increase overall memory usage, - since it cannot reuse existing noncontiguous small chunks that - might be available for some of the elements. -*/ -#if __STD_C -Void_t** public_iCOMALLOc(size_t, size_t*, Void_t**); -#else -Void_t** public_iCOMALLOc(); -#endif - - -/* - pvalloc(size_t n); - Equivalent to valloc(minimum-page-that-holds(n)), that is, - round up n to nearest pagesize. - */ -#if __STD_C -Void_t* public_pVALLOc(size_t); -#else -Void_t* public_pVALLOc(); -#endif - -/* - cfree(Void_t* p); - Equivalent to free(p). - - cfree is needed/defined on some systems that pair it with calloc, - for odd historical reasons (such as: cfree is used in example - code in the first edition of K&R). -*/ -#if __STD_C -void public_cFREe(Void_t*); -#else -void public_cFREe(); -#endif - -/* - malloc_trim(size_t pad); - - If possible, gives memory back to the system (via negative - arguments to sbrk) if there is unused memory at the `high' end of - the malloc pool. You can call this after freeing large blocks of - memory to potentially reduce the system-level memory requirements - of a program. However, it cannot guarantee to reduce memory. Under - some allocation patterns, some large free blocks of memory will be - locked between two used chunks, so they cannot be given back to - the system. - - The `pad' argument to malloc_trim represents the amount of free - trailing space to leave untrimmed. If this argument is zero, - only the minimum amount of memory to maintain internal data - structures will be left (one page or less). Non-zero arguments - can be supplied to maintain enough trailing space to service - future expected allocations without having to re-obtain memory - from the system. - - Malloc_trim returns 1 if it actually released any memory, else 0. - On systems that do not support "negative sbrks", it will always - rreturn 0. -*/ -#if __STD_C -int public_mTRIm(size_t); -#else -int public_mTRIm(); -#endif - -/* - malloc_usable_size(Void_t* p); - - Returns the number of bytes you can actually use in - an allocated chunk, which may be more than you requested (although - often not) due to alignment and minimum size constraints. - You can use this many bytes without worrying about - overwriting other allocated objects. This is not a particularly great - programming practice. malloc_usable_size can be more useful in - debugging and assertions, for example: - - p = malloc(n); - assert(malloc_usable_size(p) >= 256); - -*/ -#if __STD_C -size_t public_mUSABLe(Void_t*); -#else -size_t public_mUSABLe(); -#endif - -/* - malloc_stats(); - Prints on stderr the amount of space obtained from the system (both - via sbrk and mmap), the maximum amount (which may be more than - current if malloc_trim and/or munmap got called), and the current - number of bytes allocated via malloc (or realloc, etc) but not yet - freed. Note that this is the number of bytes allocated, not the - number requested. It will be larger than the number requested - because of alignment and bookkeeping overhead. Because it includes - alignment wastage as being in use, this figure may be greater than - zero even when no user-level chunks are allocated. - - The reported current and maximum system memory can be inaccurate if - a program makes other calls to system memory allocation functions - (normally sbrk) outside of malloc. - - malloc_stats prints only the most commonly interesting statistics. - More information can be obtained by calling mallinfo. - -*/ -#if __STD_C -void public_mSTATs(void); -#else -void public_mSTATs(); -#endif - -/* - aproxy_get_state(void); - - Returns the state of all malloc variables in an opaque data - structure. -*/ -#if __STD_C -Void_t* public_gET_STATe(void); -#else -Void_t* public_gET_STATe(); -#endif - -/* - aproxy_set_state(Void_t* state); - - Restore the state of all malloc variables from data obtained with - aproxy_get_state(). -*/ -#if __STD_C -int public_sET_STATe(Void_t*); -#else -int public_sET_STATe(); -#endif - -#ifdef _LIBC -/* - posix_memalign(void **memptr, size_t alignment, size_t size); - - POSIX wrapper like memalign(), checking for validity of size. -*/ -int __posix_memalign(void **, size_t, size_t); -#endif - -/* mallopt tuning options */ - -/* - M_MXFAST is the maximum request size used for "fastbins", special bins - that hold returned chunks without consolidating their spaces. This - enables future requests for chunks of the same size to be handled - very quickly, but can increase fragmentation, and thus increase the - overall memory footprint of a program. - - This malloc manages fastbins very conservatively yet still - efficiently, so fragmentation is rarely a problem for values less - than or equal to the default. The maximum supported value of MXFAST - is 80. You wouldn't want it any higher than this anyway. Fastbins - are designed especially for use with many small structs, objects or - strings -- the default handles structs/objects/arrays with sizes up - to 8 4byte fields, or small strings representing words, tokens, - etc. Using fastbins for larger objects normally worsens - fragmentation without improving speed. - - M_MXFAST is set in REQUEST size units. It is internally used in - chunksize units, which adds padding and alignment. You can reduce - M_MXFAST to 0 to disable all use of fastbins. This causes the malloc - algorithm to be a closer approximation of fifo-best-fit in all cases, - not just for larger requests, but will generally cause it to be - slower. -*/ - - -/* M_MXFAST is a standard SVID/XPG tuning option, usually listed in malloc.h */ -#ifndef M_MXFAST -#define M_MXFAST 1 -#endif - -#ifndef DEFAULT_MXFAST -#define DEFAULT_MXFAST 64 -#endif - - -/* - M_TRIM_THRESHOLD is the maximum amount of unused top-most memory - to keep before releasing via malloc_trim in free(). - - Automatic trimming is mainly useful in long-lived programs. - Because trimming via sbrk can be slow on some systems, and can - sometimes be wasteful (in cases where programs immediately - afterward allocate more large chunks) the value should be high - enough so that your overall system performance would improve by - releasing this much memory. - - The trim threshold and the mmap control parameters (see below) - can be traded off with one another. Trimming and mmapping are - two different ways of releasing unused memory back to the - system. Between these two, it is often possible to keep - system-level demands of a long-lived program down to a bare - minimum. For example, in one test suite of sessions measuring - the XF86 X server on Linux, using a trim threshold of 128K and a - mmap threshold of 192K led to near-minimal long term resource - consumption. - - If you are using this malloc in a long-lived program, it should - pay to experiment with these values. As a rough guide, you - might set to a value close to the average size of a process - (program) running on your system. Releasing this much memory - would allow such a process to run in memory. Generally, it's - worth it to tune for trimming rather tham memory mapping when a - program undergoes phases where several large chunks are - allocated and released in ways that can reuse each other's - storage, perhaps mixed with phases where there are no such - chunks at all. And in well-behaved long-lived programs, - controlling release of large blocks via trimming versus mapping - is usually faster. - - However, in most programs, these parameters serve mainly as - protection against the system-level effects of carrying around - massive amounts of unneeded memory. Since frequent calls to - sbrk, mmap, and munmap otherwise degrade performance, the default - parameters are set to relatively high values that serve only as - safeguards. - - The trim value It must be greater than page size to have any useful - effect. To disable trimming completely, you can set to - (unsigned long)(-1) - - Trim settings interact with fastbin (MXFAST) settings: Unless - TRIM_FASTBINS is defined, automatic trimming never takes place upon - freeing a chunk with size less than or equal to MXFAST. Trimming is - instead delayed until subsequent freeing of larger chunks. However, - you can still force an attempted trim by calling malloc_trim. - - Also, trimming is not generally possible in cases where - the main arena is obtained via mmap. - - Note that the trick some people use of mallocing a huge space and - then freeing it at program startup, in an attempt to reserve system - memory, doesn't have the intended effect under automatic trimming, - since that memory will immediately be returned to the system. -*/ - -#define M_TRIM_THRESHOLD -1 - -#ifndef DEFAULT_TRIM_THRESHOLD -#define DEFAULT_TRIM_THRESHOLD (128 * 1024) -#endif - -/* - M_TOP_PAD is the amount of extra `padding' space to allocate or - retain whenever sbrk is called. It is used in two ways internally: - - * When sbrk is called to extend the top of the arena to satisfy - a new malloc request, this much padding is added to the sbrk - request. - - * When malloc_trim is called automatically from free(), - it is used as the `pad' argument. - - In both cases, the actual amount of padding is rounded - so that the end of the arena is always a system page boundary. - - The main reason for using padding is to avoid calling sbrk so - often. Having even a small pad greatly reduces the likelihood - that nearly every malloc request during program start-up (or - after trimming) will invoke sbrk, which needlessly wastes - time. - - Automatic rounding-up to page-size units is normally sufficient - to avoid measurable overhead, so the default is 0. However, in - systems where sbrk is relatively slow, it can pay to increase - this value, at the expense of carrying around more memory than - the program needs. -*/ - -#define M_TOP_PAD -2 - -#ifndef DEFAULT_TOP_PAD -#define DEFAULT_TOP_PAD (0) -#endif - -/* - M_MMAP_THRESHOLD is the request size threshold for using mmap() - to service a request. Requests of at least this size that cannot - be allocated using already-existing space will be serviced via mmap. - (If enough normal freed space already exists it is used instead.) - - Using mmap segregates relatively large chunks of memory so that - they can be individually obtained and released from the host - system. A request serviced through mmap is never reused by any - other request (at least not directly; the system may just so - happen to remap successive requests to the same locations). - - Segregating space in this way has the benefits that: - - 1. Mmapped space can ALWAYS be individually released back - to the system, which helps keep the system level memory - demands of a long-lived program low. - 2. Mapped memory can never become `locked' between - other chunks, as can happen with normally allocated chunks, which - means that even trimming via malloc_trim would not release them. - 3. On some systems with "holes" in address spaces, mmap can obtain - memory that sbrk cannot. - - However, it has the disadvantages that: - - 1. The space cannot be reclaimed, consolidated, and then - used to service later requests, as happens with normal chunks. - 2. It can lead to more wastage because of mmap page alignment - requirements - 3. It causes malloc performance to be more dependent on host - system memory management support routines which may vary in - implementation quality and may impose arbitrary - limitations. Generally, servicing a request via normal - malloc steps is faster than going through a system's mmap. - - The advantages of mmap nearly always outweigh disadvantages for - "large" chunks, but the value of "large" varies across systems. The - default is an empirically derived value that works well in most - systems. -*/ - -#define M_MMAP_THRESHOLD -3 - -#ifndef DEFAULT_MMAP_THRESHOLD -#define DEFAULT_MMAP_THRESHOLD (128 * 1024) -#endif - -/* - M_MMAP_MAX is the maximum number of requests to simultaneously - service using mmap. This parameter exists because - some systems have a limited number of internal tables for - use by mmap, and using more than a few of them may degrade - performance. - - The default is set to a value that serves only as a safeguard. - Setting to 0 disables use of mmap for servicing large requests. If - HAVE_MMAP is not set, the default value is 0, and attempts to set it - to non-zero values in mallopt will fail. -*/ - -#define M_MMAP_MAX -4 - -#ifndef DEFAULT_MMAP_MAX -#if HAVE_MMAP -#define DEFAULT_MMAP_MAX (65536) -#else -#define DEFAULT_MMAP_MAX (0) -#endif -#endif - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -#include "aproxy.h" - -#ifndef BOUNDED_N -#define BOUNDED_N(ptr, sz) (ptr) -#endif -#ifndef RETURN_ADDRESS -#define RETURN_ADDRESS(X_) (NULL) -#endif - -/* On some platforms we can compile internal, not exported functions better. - Let the environment provide a macro and define it to be empty if it - is not available. */ -#ifndef internal_function -# define internal_function -#endif - -/* Internal routines. */ - -#if __STD_C - -Void_t* aproxy_int_malloc(mstate, size_t); -void aproxy_int_free(mstate, Void_t*); -Void_t* aproxy_int_realloc(mstate, Void_t*, size_t); -Void_t* aproxy_int_memalign(mstate, size_t, size_t); -Void_t* aproxy_int_valloc(mstate, size_t); -static Void_t* aproxy_int_pvalloc(mstate, size_t); -/*static Void_t* cALLOc(size_t, size_t);*/ -static Void_t** aproxy_int_icalloc(mstate, size_t, size_t, Void_t**); -static Void_t** aproxy_int_icomalloc(mstate, size_t, size_t*, Void_t**); -static int mTRIm(size_t); -static size_t mUSABLe(Void_t*); -static void mSTATs(void); -static int mALLOPt(int, int); -static struct mallinfo mALLINFo(mstate); -static void malloc_printerr(int action, const char *str, void *ptr); - -static Void_t* internal_function mem2mem_check(Void_t *p, size_t sz); -static int internal_function top_check(void); -static void internal_function munmap_chunk(mchunkptr p); -#if HAVE_MREMAP -static mchunkptr internal_function mremap_chunk(mchunkptr p, size_t new_size); -#endif - -static Void_t* malloc_check(size_t sz, const Void_t *caller); -static void free_check(Void_t* mem, const Void_t *caller); -static Void_t* realloc_check(Void_t* oldmem, size_t bytes, - const Void_t *caller); -static Void_t* memalign_check(size_t alignment, size_t bytes, - const Void_t *caller); -#ifndef NO_THREADS -# ifdef _LIBC -# if USE___THREAD || (defined USE_TLS && !defined SHARED) - /* These routines are never needed in this configuration. */ -# define NO_STARTER -# endif -# endif -# ifdef NO_STARTER -# undef NO_STARTER -# else -static Void_t* malloc_starter(size_t sz, const Void_t *caller); -static Void_t* memalign_starter(size_t aln, size_t sz, const Void_t *caller); -static void free_starter(Void_t* mem, const Void_t *caller); -# endif -static Void_t* malloc_atfork(size_t sz, const Void_t *caller); -static void free_atfork(Void_t* mem, const Void_t *caller); -#endif - -#else - -Void_t* aproxy_int_malloc(); -void aproxy_int_free(); -Void_t* aproxy_int_realloc(); -Void_t* aproxy_int_memalign(); -Void_t* aproxy_int_valloc(); -Void_t* aproxy_int_pvalloc(); -/*static Void_t* cALLOc();*/ -static Void_t** aproxy_int_icalloc(); -static Void_t** aproxy_int_icomalloc(); -static int mTRIm(); -static size_t mUSABLe(); -static void mSTATs(); -static int mALLOPt(); -static struct mallinfo mALLINFo(); - -#endif - - - - -/* ------------- Optional versions of memcopy ---------------- */ - - -#if USE_MEMCPY - -/* - Note: memcpy is ONLY invoked with non-overlapping regions, - so the (usually slower) memmove is not needed. -*/ - -#define MALLOC_COPY(dest, src, nbytes) memcpy(dest, src, nbytes) -#define MALLOC_ZERO(dest, nbytes) memset(dest, 0, nbytes) - -#else /* !USE_MEMCPY */ - -/* Use Duff's device for good zeroing/copying performance. */ - -#define MALLOC_ZERO(charp, nbytes) \ -do { \ - INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp); \ - unsigned long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T); \ - long mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mzp++ = 0; \ - case 7: *mzp++ = 0; \ - case 6: *mzp++ = 0; \ - case 5: *mzp++ = 0; \ - case 4: *mzp++ = 0; \ - case 3: *mzp++ = 0; \ - case 2: *mzp++ = 0; \ - case 1: *mzp++ = 0; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#define MALLOC_COPY(dest,src,nbytes) \ -do { \ - INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src; \ - INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest; \ - unsigned long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T); \ - long mcn; \ - if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \ - switch (mctmp) { \ - case 0: for(;;) { *mcdst++ = *mcsrc++; \ - case 7: *mcdst++ = *mcsrc++; \ - case 6: *mcdst++ = *mcsrc++; \ - case 5: *mcdst++ = *mcsrc++; \ - case 4: *mcdst++ = *mcsrc++; \ - case 3: *mcdst++ = *mcsrc++; \ - case 2: *mcdst++ = *mcsrc++; \ - case 1: *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; } \ - } \ -} while(0) - -#endif - -/* ------------------ MMAP support ------------------ */ - - -#if HAVE_MMAP - -#include -#ifndef LACKS_SYS_MMAN_H -#include -#endif - -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -# define MAP_ANONYMOUS MAP_ANON -#endif -#if !defined(MAP_FAILED) -# define MAP_FAILED ((char*)-1) -#endif - -#ifndef MAP_NORESERVE -# ifdef MAP_AUTORESRV -# define MAP_NORESERVE MAP_AUTORESRV -# else -# define MAP_NORESERVE 0 -# endif -#endif - -/* - Nearly all versions of mmap support MAP_ANONYMOUS, - so the following is unlikely to be needed, but is - supplied just in case. -*/ - -#ifndef MAP_ANONYMOUS - -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ - -#define MMAP(addr, size, prot, flags) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) : \ - mmap((addr), (size), (prot), (flags), dev_zero_fd, 0)) - -#else - -#define MMAP(addr, size, prot, flags) \ - (mmap((addr), (size), (prot), (flags)|MAP_ANONYMOUS, -1, 0)) - -#endif - - -#endif /* HAVE_MMAP */ - - -/* - ----------------------- Chunk representations ----------------------- -*/ - - -/* - This struct declaration is misleading (but accurate and necessary). - It declares a "view" into memory allowing access to necessary - fields at known offsets from a given base. See explanation below. -*/ - -struct malloc_chunk { - - INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */ - INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */ - - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; -}; - - -/* - malloc_chunk details: - - (The following includes lightly edited explanations by Colin Plumb.) - - Chunks of memory are maintained using a `boundary tag' method as - described in e.g., Knuth or Standish. (See the paper by Paul - Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a - survey of such techniques.) Sizes of free chunks are stored both - in the front of each chunk and at the end. This makes - consolidating fragmented chunks into bigger chunks very fast. The - size fields also hold bits representing whether chunks are free or - in use. - - An allocated chunk looks like this: - - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk, if allocated | | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk, in bytes |M|P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | User data starts here... . - . . - . (malloc_usable_space() bytes) . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - - Where "chunk" is the front of the chunk for the purpose of most of - the malloc code, but "mem" is the pointer that is returned to the - user. "Nextchunk" is the beginning of the next contiguous chunk. - - Chunks always begin on even word boundries, so the mem portion - (which is returned to the user) is also on an even word boundary, and - thus at least double-word aligned. - - Free chunks are stored in circular doubly-linked lists, and look like this: - - chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Size of previous chunk | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `head:' | Size of chunk, in bytes |P| - mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Forward pointer to next chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Back pointer to previous chunk in list | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - | Unused space (may be 0 bytes long) . - . . - . | -nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - `foot:' | Size of chunk, in bytes | - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ - - The P (PREV_INUSE) bit, stored in the unused low-order bit of the - chunk size (which is always a multiple of two words), is an in-use - bit for the *previous* chunk. If that bit is *clear*, then the - word before the current chunk size contains the previous chunk - size, and can be used to find the front of the previous chunk. - The very first chunk allocated always has this bit set, - preventing access to non-existent (or non-owned) memory. If - prev_inuse is set for any given chunk, then you CANNOT determine - the size of the previous chunk, and might even get a memory - addressing fault when trying to do so. - - Note that the `foot' of the current chunk is actually represented - as the prev_size of the NEXT chunk. This makes it easier to - deal with alignments etc but can be very confusing when trying - to extend or adapt this code. - - The two exceptions to all this are - - 1. The special chunk `top' doesn't bother using the - trailing size field since there is no next contiguous chunk - that would have to index off it. After initialization, `top' - is forced to always exist. If it would become less than - MINSIZE bytes long, it is replenished. - - 2. Chunks allocated via mmap, which have the second-lowest-order - bit M (IS_MMAPPED) set in their size fields. Because they are - allocated one-by-one, each must contain its own trailing size field. - -*/ - -/* - ---------- Size and alignment checks and conversions ---------- -*/ - -/* conversion from malloc headers to user pointers, and back */ - -#define chunk2mem(p) ((Void_t*)((char*)(p) + 2*SIZE_SZ)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*SIZE_SZ)) - -/* The smallest possible chunk */ -#define MIN_CHUNK_SIZE (sizeof(struct malloc_chunk)) - -/* The smallest size we can malloc is an aligned minimal chunk */ - -#define MINSIZE \ - (unsigned long)(((MIN_CHUNK_SIZE+MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK)) - -/* Check if m has acceptable alignment */ - -#define aligned_OK(m) (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0) - - -/* - Check if a request is so large that it would wrap around zero when - padded and aligned. To simplify some other code, the bound is made - low enough so that adding MINSIZE will also not wrap around zero. -*/ - -#define REQUEST_OUT_OF_RANGE(req) \ - ((unsigned long)(req) >= \ - (unsigned long)(INTERNAL_SIZE_T)(-2 * MINSIZE)) - -/* pad request bytes into a usable size -- internal version */ - -#define request2size(req) \ - (((req) + SIZE_SZ + MALLOC_ALIGN_MASK < MINSIZE) ? \ - MINSIZE : \ - ((req) + SIZE_SZ + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK) - -/* Same, except also perform argument check */ - -#define checked_request2size(req, sz) \ - if (REQUEST_OUT_OF_RANGE(req)) { \ - MALLOC_FAILURE_ACTION; \ - return 0; \ - } \ - (sz) = request2size(req); - -/* - --------------- Physical chunk operations --------------- -*/ - - -/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */ -#define PREV_INUSE 0x1 - -/* extract inuse bit of previous chunk */ -#define prev_inuse(p) ((p)->size & PREV_INUSE) - - -/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */ -#define IS_MMAPPED 0x2 - -/* check for mmap()'ed chunk */ -#define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED) - - -/* size field is or'ed with NON_MAIN_ARENA if the chunk was obtained - from a non-main arena. This is only set immediately before handing - the chunk to the user, if necessary. */ -#define NON_MAIN_ARENA 0x4 - -/* check for chunk from non-main arena */ -#define chunk_non_main_arena(p) ((p)->size & NON_MAIN_ARENA) - - -/* - Bits to mask off when extracting size - - Note: IS_MMAPPED is intentionally not masked off from size field in - macros for which mmapped chunks should never be seen. This should - cause helpful core dumps to occur if it is tried by accident by - people extending or adapting this malloc. -*/ -#define SIZE_BITS (PREV_INUSE|IS_MMAPPED|NON_MAIN_ARENA) - -/* Get size, ignoring use bits */ -#define chunksize(p) ((p)->size & ~(SIZE_BITS)) - - -/* Ptr to next physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~SIZE_BITS) )) - -/* Ptr to previous physical malloc_chunk */ -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) )) - -/* Treat space at ptr + offset as a chunk */ -#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) - -/* extract p's inuse bit */ -#define inuse(p)\ -((((mchunkptr)(((char*)(p))+((p)->size & ~SIZE_BITS)))->size) & PREV_INUSE) - -/* set/clear chunk as being inuse without otherwise disturbing */ -#define set_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~SIZE_BITS)))->size |= PREV_INUSE - -#define clear_inuse(p)\ -((mchunkptr)(((char*)(p)) + ((p)->size & ~SIZE_BITS)))->size &= ~(PREV_INUSE) - - -/* check/set/clear inuse bits in known places */ -#define inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size & PREV_INUSE) - -#define set_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size |= PREV_INUSE) - -#define clear_inuse_bit_at_offset(p, s)\ - (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE)) - - -/* Set size at head, without disturbing its use bit */ -#define set_head_size(p, s) ((p)->size = (((p)->size & SIZE_BITS) | (s))) - -/* Set size/use field */ -#define set_head(p, s) ((p)->size = (s)) - -/* Set size at footer (only when chunk is not in use) */ -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s)) - - -/* - -------------------- Internal data structures -------------------- - - All internal state is held in an instance of malloc_state defined - below. There are no other static variables, except in two optional - cases: - * If USE_MALLOC_LOCK is defined, the mALLOC_MUTEx declared above. - * If HAVE_MMAP is true, but mmap doesn't support - MAP_ANONYMOUS, a dummy file descriptor for mmap. - - Beware of lots of tricks that minimize the total bookkeeping space - requirements. The result is a little over 1K bytes (for 4byte - pointers and size_t.) -*/ - -/* - Bins - - An array of bin headers for free chunks. Each bin is doubly - linked. The bins are approximately proportionally (log) spaced. - There are a lot of these bins (128). This may look excessive, but - works very well in practice. Most bins hold sizes that are - unusual as malloc request sizes, but are more usual for fragments - and consolidated sets of chunks, which is what these bins hold, so - they can be found quickly. All procedures maintain the invariant - that no consolidated chunk physically borders another one, so each - chunk in a list is known to be preceeded and followed by either - inuse chunks or the ends of memory. - - Chunks in bins are kept in size order, with ties going to the - approximately least recently used chunk. Ordering isn't needed - for the small bins, which all contain the same-sized chunks, but - facilitates best-fit allocation for larger chunks. These lists - are just sequential. Keeping them in order almost never requires - enough traversal to warrant using fancier ordered data - structures. - - Chunks of the same size are linked with the most - recently freed at the front, and allocations are taken from the - back. This results in LRU (FIFO) allocation order, which tends - to give each chunk an equal opportunity to be consolidated with - adjacent freed chunks, resulting in larger free chunks and less - fragmentation. - - To simplify use in double-linked lists, each bin header acts - as a malloc_chunk. This avoids special-casing for headers. - But to conserve space and improve locality, we allocate - only the fd/bk pointers of bins, and then use repositioning tricks - to treat these as the fields of a malloc_chunk*. -*/ - -typedef struct malloc_chunk* mbinptr; - -/* addressing -- note that bin_at(0) does not exist */ -#define bin_at(m, i) ((mbinptr)((char*)&((m)->bins[(i)<<1]) - (SIZE_SZ<<1))) - -/* analog of ++bin */ -#define next_bin(b) ((mbinptr)((char*)(b) + (sizeof(mchunkptr)<<1))) - -/* Reminders about list directionality within bins */ -#define first(b) ((b)->fd) -#define last(b) ((b)->bk) - -/* Take a chunk off a bin list */ -#define unlink(P, BK, FD) { \ - FD = P->fd; \ - BK = P->bk; \ - if (__builtin_expect (FD->bk != P || BK->fd != P, 0)) \ - malloc_printerr (check_action, "corrupted double-linked list", P); \ - else { \ - FD->bk = BK; \ - BK->fd = FD; \ - } \ -} - -/* - Indexing - - Bins for sizes < 512 bytes contain chunks of all the same size, spaced - 8 bytes apart. Larger bins are approximately logarithmically spaced: - - 64 bins of size 8 - 32 bins of size 64 - 16 bins of size 512 - 8 bins of size 4096 - 4 bins of size 32768 - 2 bins of size 262144 - 1 bin of size what's left - - There is actually a little bit of slop in the numbers in bin_index - for the sake of speed. This makes no difference elsewhere. - - The bins top out around 1MB because we expect to service large - requests via mmap. -*/ - -#define NBINS 128 -#define NSMALLBINS 64 -#define SMALLBIN_WIDTH 8 -#define MIN_LARGE_SIZE 512 - -#define in_smallbin_range(sz) \ - ((unsigned long)(sz) < (unsigned long)MIN_LARGE_SIZE) - -#define smallbin_index(sz) (((unsigned)(sz)) >> 3) - -#define largebin_index(sz) \ -(((((unsigned long)(sz)) >> 6) <= 32)? 56 + (((unsigned long)(sz)) >> 6): \ - ((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \ - ((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \ - ((((unsigned long)(sz)) >> 15) <= 4)? 119 + (((unsigned long)(sz)) >> 15): \ - ((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \ - 126) - -#define bin_index(sz) \ - ((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz)) - - -/* - Unsorted chunks - - All remainders from chunk splits, as well as all returned chunks, - are first placed in the "unsorted" bin. They are then placed - in regular bins after malloc gives them ONE chance to be used before - binning. So, basically, the unsorted_chunks list acts as a queue, - with chunks being placed on it in free (and malloc_consolidate), - and taken off (to be either used or placed in bins) in malloc. - - The NON_MAIN_ARENA flag is never set for unsorted chunks, so it - does not have to be taken into account in size comparisons. -*/ - -/* The otherwise unindexable 1-bin is used to hold unsorted chunks. */ -#define unsorted_chunks(M) (bin_at(M, 1)) - -/* - Top - - The top-most available chunk (i.e., the one bordering the end of - available memory) is treated specially. It is never included in - any bin, is used only if no other chunk is available, and is - released back to the system if it is very large (see - M_TRIM_THRESHOLD). Because top initially - points to its own bin with initial zero size, thus forcing - extension on the first malloc request, we avoid having any special - code in malloc to check whether it even exists yet. But we still - need to do so when getting memory from system, so we make - initial_top treat the bin as a legal but unusable chunk during the - interval between initialization and the first call to - sYSMALLOc. (This is somewhat delicate, since it relies on - the 2 preceding words to be zero during this interval as well.) -*/ - -/* Conveniently, the unsorted bin can be used as dummy top on first call */ -#define initial_top(M) (unsorted_chunks(M)) - -/* - Binmap - - To help compensate for the large number of bins, a one-level index - structure is used for bin-by-bin searching. `binmap' is a - bitvector recording whether bins are definitely empty so they can - be skipped over during during traversals. The bits are NOT always - cleared as soon as bins are empty, but instead only - when they are noticed to be empty during traversal in malloc. -*/ - -/* Conservatively use 32 bits per map word, even if on 64bit system */ -#define BINMAPSHIFT 5 -#define BITSPERMAP (1U << BINMAPSHIFT) -#define BINMAPSIZE (NBINS / BITSPERMAP) - -#define idx2block(i) ((i) >> BINMAPSHIFT) -#define idx2bit(i) ((1U << ((i) & ((1U << BINMAPSHIFT)-1)))) - -#define mark_bin(m,i) ((m)->binmap[idx2block(i)] |= idx2bit(i)) -#define unmark_bin(m,i) ((m)->binmap[idx2block(i)] &= ~(idx2bit(i))) -#define get_binmap(m,i) ((m)->binmap[idx2block(i)] & idx2bit(i)) - -/* - Fastbins - - An array of lists holding recently freed small chunks. Fastbins - are not doubly linked. It is faster to single-link them, and - since chunks are never removed from the middles of these lists, - double linking is not necessary. Also, unlike regular bins, they - are not even processed in FIFO order (they use faster LIFO) since - ordering doesn't much matter in the transient contexts in which - fastbins are normally used. - - Chunks in fastbins keep their inuse bit set, so they cannot - be consolidated with other free chunks. malloc_consolidate - releases all chunks in fastbins and consolidates them with - other free chunks. -*/ - -typedef struct malloc_chunk* mfastbinptr; - -/* offset 2 to use otherwise unindexable first 2 bins */ -#define fastbin_index(sz) ((((unsigned int)(sz)) >> 3) - 2) - -/* The maximum fastbin request size we support */ -#define MAX_FAST_SIZE 80 - -#define NFASTBINS (fastbin_index(request2size(MAX_FAST_SIZE))+1) - -/* - FASTBIN_CONSOLIDATION_THRESHOLD is the size of a chunk in free() - that triggers automatic consolidation of possibly-surrounding - fastbin chunks. This is a heuristic, so the exact value should not - matter too much. It is defined at half the default trim threshold as a - compromise heuristic to only attempt consolidation if it is likely - to lead to trimming. However, it is not dynamically tunable, since - consolidation reduces fragmentation surrounding large chunks even - if trimming is not used. -*/ - -#define FASTBIN_CONSOLIDATION_THRESHOLD (65536UL) - -/* - Since the lowest 2 bits in max_fast don't matter in size comparisons, - they are used as flags. -*/ - -/* - FASTCHUNKS_BIT held in max_fast indicates that there are probably - some fastbin chunks. It is set true on entering a chunk into any - fastbin, and cleared only in malloc_consolidate. - - The truth value is inverted so that have_fastchunks will be true - upon startup (since statics are zero-filled), simplifying - initialization checks. -*/ - -#define FASTCHUNKS_BIT (1U) - -#define have_fastchunks(M) (((M)->max_fast & FASTCHUNKS_BIT) == 0) -#define clear_fastchunks(M) ((M)->max_fast |= FASTCHUNKS_BIT) -#define set_fastchunks(M) ((M)->max_fast &= ~FASTCHUNKS_BIT) - -/* - NONCONTIGUOUS_BIT indicates that MORECORE does not return contiguous - regions. Otherwise, contiguity is exploited in merging together, - when possible, results from consecutive MORECORE calls. - - The initial value comes from MORECORE_CONTIGUOUS, but is - changed dynamically if mmap is ever used as an sbrk substitute. -*/ - -#define NONCONTIGUOUS_BIT (2U) - -#define contiguous(M) (((M)->max_fast & NONCONTIGUOUS_BIT) == 0) -#define noncontiguous(M) (((M)->max_fast & NONCONTIGUOUS_BIT) != 0) -#define set_noncontiguous(M) ((M)->max_fast |= NONCONTIGUOUS_BIT) -#define set_contiguous(M) ((M)->max_fast &= ~NONCONTIGUOUS_BIT) - -/* - Set value of max_fast. - Use impossibly small value if 0. - Precondition: there are no existing fastbin chunks. - Setting the value clears fastchunk bit but preserves noncontiguous bit. -*/ - -#define set_max_fast(M, s) \ - (M)->max_fast = (((s) == 0)? SMALLBIN_WIDTH: request2size(s)) | \ - FASTCHUNKS_BIT | \ - ((M)->max_fast & NONCONTIGUOUS_BIT) - - -/* - ----------- Internal state representation and initialization ----------- -*/ - -struct malloc_state { - /* Serialize access. */ - mutex_t mutex; - // Should we have padding to move the mutex to its own cache line? - -#if THREAD_STATS - /* Statistics for locking. Only used if THREAD_STATS is defined. */ - long stat_lock_direct, stat_lock_loop, stat_lock_wait; -#endif - - /* The maximum chunk size to be eligible for fastbin */ - INTERNAL_SIZE_T max_fast; /* low 2 bits used as flags */ - - /* Fastbins */ - mfastbinptr fastbins[NFASTBINS]; - - /* Base of the topmost chunk -- not otherwise kept in a bin */ - mchunkptr top; - - /* The remainder from the most recent split of a small request */ - mchunkptr last_remainder; - - /* Normal bins packed as described above */ - mchunkptr bins[NBINS * 2]; - - /* Bitmap of bins */ - unsigned int binmap[BINMAPSIZE]; - - /* Linked list */ - struct malloc_state *next; - - /* Memory allocated from the system in this arena. */ - INTERNAL_SIZE_T system_mem; - INTERNAL_SIZE_T max_system_mem; -}; - -struct malloc_par { - - /* Tunable parameters */ - unsigned long trim_threshold; - INTERNAL_SIZE_T top_pad; - INTERNAL_SIZE_T mmap_threshold; - - /* Memory map support */ - int n_mmaps; - int n_mmaps_max; - int max_n_mmaps; - - /* Cache malloc_getpagesize */ - unsigned int pagesize; - - /* Statistics */ - INTERNAL_SIZE_T mmapped_mem; - /*INTERNAL_SIZE_T sbrked_mem;*/ - /*INTERNAL_SIZE_T max_sbrked_mem;*/ - INTERNAL_SIZE_T max_mmapped_mem; - INTERNAL_SIZE_T max_total_mem; /* only kept for NO_THREADS */ - - /* First address handed out by MORECORE/sbrk. */ - char* sbrk_base; -}; - -/* There are several instances of this struct ("arenas") in this - malloc. If you are adapting this malloc in a way that does NOT use - a static or mmapped malloc_state, you MUST explicitly zero-fill it - before using. This malloc relies on the property that malloc_state - is initialized to all zeroes (as is true of C statics). */ - -static struct malloc_state main_arena; - -/* There is only one instance of the malloc parameters. */ - -static struct malloc_par mp_; - -/* - Initialize a malloc_state struct. - - This is called only from within malloc_consolidate, which needs - be called in the same contexts anyway. It is never called directly - outside of malloc_consolidate because some optimizing compilers try - to inline it at all call points, which turns out not to be an - optimization at all. (Inlining it in malloc_consolidate is fine though.) -*/ - -#if __STD_C -static void malloc_init_state(mstate av) -#else -static void malloc_init_state(av) mstate av; -#endif -{ - int i; - mbinptr bin; - - /* Establish circular links for normal bins */ - for (i = 1; i < NBINS; ++i) { - bin = bin_at(av,i); - bin->fd = bin->bk = bin; - } - -#if MORECORE_CONTIGUOUS - if (av != &main_arena) -#endif - set_noncontiguous(av); - - set_max_fast(av, DEFAULT_MXFAST); - - av->top = initial_top(av); -} - -/* - Other internal utilities operating on mstates -*/ - -#if __STD_C -static Void_t* sYSMALLOc(INTERNAL_SIZE_T, mstate); -static int sYSTRIm(size_t, mstate); -static void malloc_consolidate(mstate); -static Void_t** iALLOc(mstate, size_t, size_t*, int, Void_t**); -#else -static Void_t* sYSMALLOc(); -static int sYSTRIm(); -static void malloc_consolidate(); -static Void_t** iALLOc(); -#endif - - -/* -------------- Early definitions for debugging hooks ---------------- */ - -/* Define and initialize the hook variables. These weak definitions must - appear before any use of the variables in a function (arena.c uses one). */ -#ifndef weak_variable -#ifndef _LIBC -#define weak_variable /**/ -#else -/* In GNU libc we want the hook variables to be weak definitions to - avoid a problem with Emacs. */ -#define weak_variable weak_function -#endif -#endif - -/* Forward declarations. */ -static Void_t* malloc_hook_ini __MALLOC_P ((size_t sz, - const __malloc_ptr_t caller)); -static Void_t* realloc_hook_ini __MALLOC_P ((Void_t* ptr, size_t sz, - const __malloc_ptr_t caller)); -static Void_t* memalign_hook_ini __MALLOC_P ((size_t alignment, size_t sz, - const __malloc_ptr_t caller)); - -void weak_variable (*__aproxy_initialize_hook) (void) = NULL; -void weak_variable (*__aproxy_free_hook) (__malloc_ptr_t __ptr, - const __malloc_ptr_t) = NULL; -__malloc_ptr_t weak_variable (*__aproxy_hook) - (size_t __size, const __malloc_ptr_t) = malloc_hook_ini; -__malloc_ptr_t weak_variable (*__aproxy_realloc_hook) - (__malloc_ptr_t __ptr, size_t __size, const __malloc_ptr_t) - = realloc_hook_ini; -__malloc_ptr_t weak_variable (*__aproxy_memalign_hook) - (size_t __alignment, size_t __size, const __malloc_ptr_t) - = memalign_hook_ini; -void weak_variable (*__aproxy_after_morecore_hook) (void) = NULL; - - -/* ---------------- Error behavior ------------------------------------ */ - -#ifndef DEFAULT_CHECK_ACTION -#define DEFAULT_CHECK_ACTION 3 -#endif - -static int check_action = DEFAULT_CHECK_ACTION; - - -/* ------------------- Support for multiple arenas -------------------- */ -#include "aproxy_arena.c" - -/* - Debugging support - - These routines make a number of assertions about the states - of data structures that should be true at all times. If any - are not true, it's very likely that a user program has somehow - trashed memory. (It's also possible that there is a coding error - in malloc. In which case, please report it!) -*/ - -#if ! MALLOC_DEBUG - -#define check_chunk(A,P) -#define check_free_chunk(A,P) -#define check_inuse_chunk(A,P) -#define check_remalloced_chunk(A,P,N) -#define check_malloced_chunk(A,P,N) -#define check_malloc_state(A) - -#else - -#define check_chunk(A,P) do_check_chunk(A,P) -#define check_free_chunk(A,P) do_check_free_chunk(A,P) -#define check_inuse_chunk(A,P) do_check_inuse_chunk(A,P) -#define check_remalloced_chunk(A,P,N) do_check_remalloced_chunk(A,P,N) -#define check_malloced_chunk(A,P,N) do_check_malloced_chunk(A,P,N) -#define check_malloc_state(A) do_check_malloc_state(A) - -/* - Properties of all chunks -*/ - -#if __STD_C -static void do_check_chunk(mstate av, mchunkptr p) -#else -static void do_check_chunk(av, p) mstate av; mchunkptr p; -#endif -{ - unsigned long sz = chunksize(p); - /* min and max possible addresses assuming contiguous allocation */ - char* max_address = (char*)(av->top) + chunksize(av->top); - char* min_address = max_address - av->system_mem; - - if (!chunk_is_mmapped(p)) { - - /* Has legal address ... */ - if (p != av->top) { - if (contiguous(av)) { - assert(((char*)p) >= min_address); - assert(((char*)p + sz) <= ((char*)(av->top))); - } - } - else { - /* top size is always at least MINSIZE */ - assert((unsigned long)(sz) >= MINSIZE); - /* top predecessor always marked inuse */ - assert(prev_inuse(p)); - } - - } - else { -#if HAVE_MMAP - /* address is outside main heap */ - if (contiguous(av) && av->top != initial_top(av)) { - assert(((char*)p) < min_address || ((char*)p) > max_address); - } - /* chunk is page-aligned */ - assert(((p->prev_size + sz) & (mp_.pagesize-1)) == 0); - /* mem is aligned */ - assert(aligned_OK(chunk2mem(p))); -#else - /* force an appropriate assert violation if debug set */ - assert(!chunk_is_mmapped(p)); -#endif - } -} - -/* - Properties of free chunks -*/ - -#if __STD_C -static void do_check_free_chunk(mstate av, mchunkptr p) -#else -static void do_check_free_chunk(av, p) mstate av; mchunkptr p; -#endif -{ - INTERNAL_SIZE_T sz = p->size & ~(PREV_INUSE|NON_MAIN_ARENA); - mchunkptr next = chunk_at_offset(p, sz); - - do_check_chunk(av, p); - - /* Chunk must claim to be free ... */ - assert(!inuse(p)); - assert (!chunk_is_mmapped(p)); - - /* Unless a special marker, must have OK fields */ - if ((unsigned long)(sz) >= MINSIZE) - { - assert((sz & MALLOC_ALIGN_MASK) == 0); - assert(aligned_OK(chunk2mem(p))); - /* ... matching footer field */ - assert(next->prev_size == sz); - /* ... and is fully consolidated */ - assert(prev_inuse(p)); - assert (next == av->top || inuse(next)); - - /* ... and has minimally sane links */ - assert(p->fd->bk == p); - assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_SZ */ - assert(sz == SIZE_SZ); -} - -/* - Properties of inuse chunks -*/ - -#if __STD_C -static void do_check_inuse_chunk(mstate av, mchunkptr p) -#else -static void do_check_inuse_chunk(av, p) mstate av; mchunkptr p; -#endif -{ - mchunkptr next; - - do_check_chunk(av, p); - - if (chunk_is_mmapped(p)) - return; /* mmapped chunks have no next/prev */ - - /* Check whether it claims to be in use ... */ - assert(inuse(p)); - - next = next_chunk(p); - - /* ... and is surrounded by OK chunks. - Since more things can be checked with free chunks than inuse ones, - if an inuse chunk borders them and debug is on, it's worth doing them. - */ - if (!prev_inuse(p)) { - /* Note that we cannot even look at prev unless it is not inuse */ - mchunkptr prv = prev_chunk(p); - assert(next_chunk(prv) == p); - do_check_free_chunk(av, prv); - } - - if (next == av->top) { - assert(prev_inuse(next)); - assert(chunksize(next) >= MINSIZE); - } - else if (!inuse(next)) - do_check_free_chunk(av, next); -} - -/* - Properties of chunks recycled from fastbins -*/ - -#if __STD_C -static void do_check_remalloced_chunk(mstate av, mchunkptr p, INTERNAL_SIZE_T s) -#else -static void do_check_remalloced_chunk(av, p, s) -mstate av; mchunkptr p; INTERNAL_SIZE_T s; -#endif -{ - INTERNAL_SIZE_T sz = p->size & ~(PREV_INUSE|NON_MAIN_ARENA); - - if (!chunk_is_mmapped(p)) { - assert(av == arena_for_chunk(p)); - if (chunk_non_main_arena(p)) - assert(av != &main_arena); - else - assert(av == &main_arena); - } - - do_check_inuse_chunk(av, p); - - /* Legal size ... */ - assert((sz & MALLOC_ALIGN_MASK) == 0); - assert((unsigned long)(sz) >= MINSIZE); - /* ... and alignment */ - assert(aligned_OK(chunk2mem(p))); - /* chunk is less than MINSIZE more than request */ - assert((long)(sz) - (long)(s) >= 0); - assert((long)(sz) - (long)(s + MINSIZE) < 0); -} - -/* - Properties of nonrecycled chunks at the point they are malloced -*/ - -#if __STD_C -static void do_check_malloced_chunk(mstate av, mchunkptr p, INTERNAL_SIZE_T s) -#else -static void do_check_malloced_chunk(av, p, s) -mstate av; mchunkptr p; INTERNAL_SIZE_T s; -#endif -{ - /* same as recycled case ... */ - do_check_remalloced_chunk(av, p, s); - - /* - ... plus, must obey implementation invariant that prev_inuse is - always true of any allocated chunk; i.e., that each allocated - chunk borders either a previously allocated and still in-use - chunk, or the base of its memory arena. This is ensured - by making all allocations from the the `lowest' part of any found - chunk. This does not necessarily hold however for chunks - recycled via fastbins. - */ - - assert(prev_inuse(p)); -} - - -/* - Properties of malloc_state. - - This may be useful for debugging malloc, as well as detecting user - programmer errors that somehow write into malloc_state. - - If you are extending or experimenting with this malloc, you can - probably figure out how to hack this routine to print out or - display chunk addresses, sizes, bins, and other instrumentation. -*/ - -static void do_check_malloc_state(mstate av) -{ - int i; - mchunkptr p; - mchunkptr q; - mbinptr b; - unsigned int binbit; - int empty; - unsigned int idx; - INTERNAL_SIZE_T size; - unsigned long total = 0; - int max_fast_bin; - - /* internal size_t must be no wider than pointer type */ - assert(sizeof(INTERNAL_SIZE_T) <= sizeof(char*)); - - /* alignment is a power of 2 */ - assert((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-1)) == 0); - - /* cannot run remaining checks until fully initialized */ - if (av->top == 0 || av->top == initial_top(av)) - return; - - /* pagesize is a power of 2 */ - assert((mp_.pagesize & (mp_.pagesize-1)) == 0); - - /* A contiguous main_arena is consistent with sbrk_base. */ - if (av == &main_arena && contiguous(av)) - assert((char*)mp_.sbrk_base + av->system_mem == - (char*)av->top + chunksize(av->top)); - - /* properties of fastbins */ - - /* max_fast is in allowed range */ - assert((av->max_fast & ~1) <= request2size(MAX_FAST_SIZE)); - - max_fast_bin = fastbin_index(av->max_fast); - - for (i = 0; i < NFASTBINS; ++i) { - p = av->fastbins[i]; - - /* all bins past max_fast are empty */ - if (i > max_fast_bin) - assert(p == 0); - - while (p != 0) { - /* each chunk claims to be inuse */ - do_check_inuse_chunk(av, p); - total += chunksize(p); - /* chunk belongs in this bin */ - assert(fastbin_index(chunksize(p)) == i); - p = p->fd; - } - } - - if (total != 0) - assert(have_fastchunks(av)); - else if (!have_fastchunks(av)) - assert(total == 0); - - /* check normal bins */ - for (i = 1; i < NBINS; ++i) { - b = bin_at(av,i); - - /* binmap is accurate (except for bin 1 == unsorted_chunks) */ - if (i >= 2) { - binbit = get_binmap(av,i); - empty = last(b) == b; - if (!binbit) - assert(empty); - else if (!empty) - assert(binbit); - } - - for (p = last(b); p != b; p = p->bk) { - /* each chunk claims to be free */ - do_check_free_chunk(av, p); - size = chunksize(p); - total += size; - if (i >= 2) { - /* chunk belongs in bin */ - idx = bin_index(size); - assert(idx == i); - /* lists are sorted */ - assert(p->bk == b || - (unsigned long)chunksize(p->bk) >= (unsigned long)chunksize(p)); - } - /* chunk is followed by a legal chain of inuse chunks */ - for (q = next_chunk(p); - (q != av->top && inuse(q) && - (unsigned long)(chunksize(q)) >= MINSIZE); - q = next_chunk(q)) - do_check_inuse_chunk(av, q); - } - } - - /* top chunk is OK */ - check_chunk(av, av->top); - - /* sanity checks for statistics */ - -#ifdef NO_THREADS - assert(total <= (unsigned long)(mp_.max_total_mem)); - assert(mp_.n_mmaps >= 0); -#endif - assert(mp_.n_mmaps <= mp_.n_mmaps_max); - assert(mp_.n_mmaps <= mp_.max_n_mmaps); - - assert((unsigned long)(av->system_mem) <= - (unsigned long)(av->max_system_mem)); - - assert((unsigned long)(mp_.mmapped_mem) <= - (unsigned long)(mp_.max_mmapped_mem)); - -#ifdef NO_THREADS - assert((unsigned long)(mp_.max_total_mem) >= - (unsigned long)(mp_.mmapped_mem) + (unsigned long)(av->system_mem)); -#endif -} -#endif - - -/* ----------------- Support for debugging hooks -------------------- */ -#include "aproxy_hooks.c" - - -/* ----------- Routines dealing with system allocation -------------- */ - -/* - sysmalloc handles malloc cases requiring more memory from the system. - On entry, it is assumed that av->top does not have enough - space to service request for nb bytes, thus requiring that av->top - be extended or replaced. -*/ - -#if __STD_C -static Void_t* sYSMALLOc(INTERNAL_SIZE_T nb, mstate av) -#else -static Void_t* sYSMALLOc(nb, av) INTERNAL_SIZE_T nb; mstate av; -#endif -{ - mchunkptr old_top; /* incoming value of av->top */ - INTERNAL_SIZE_T old_size; /* its size */ - char* old_end; /* its end address */ - - long size; /* arg to first MORECORE or mmap call */ - char* brk; /* return value from MORECORE */ - - long correction; /* arg to 2nd MORECORE call */ - char* snd_brk; /* 2nd return val */ - - INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of new space */ - INTERNAL_SIZE_T end_misalign; /* partial page left at end of new space */ - char* aligned_brk; /* aligned offset into brk */ - - mchunkptr p; /* the allocated/returned chunk */ - mchunkptr remainder; /* remainder from allocation */ - unsigned long remainder_size; /* its size */ - - unsigned long sum; /* for updating stats */ - - size_t pagemask = mp_.pagesize - 1; - - -#if HAVE_MMAP - - /* - If have mmap, and the request size meets the mmap threshold, and - the system supports mmap, and there are few enough currently - allocated mmapped regions, try to directly map this request - rather than expanding top. - */ - - if ((unsigned long)(nb) >= (unsigned long)(mp_.mmap_threshold) && - (mp_.n_mmaps < mp_.n_mmaps_max)) { - - char* mm; /* return value from mmap call*/ - - /* - Round up size to nearest page. For mmapped chunks, the overhead - is one SIZE_SZ unit larger than for normal chunks, because there - is no following chunk whose prev_size field could be used. - */ - size = (nb + SIZE_SZ + MALLOC_ALIGN_MASK + pagemask) & ~pagemask; - - /* Don't try if size wraps around 0 */ - if ((unsigned long)(size) > (unsigned long)(nb)) { - - mm = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); - - if (mm != MAP_FAILED) { - - /* - The offset to the start of the mmapped region is stored - in the prev_size field of the chunk. This allows us to adjust - returned start address to meet alignment requirements here - and in memalign(), and still be able to compute proper - address argument for later munmap in free() and realloc(). - */ - - front_misalign = (INTERNAL_SIZE_T)chunk2mem(mm) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) { - correction = MALLOC_ALIGNMENT - front_misalign; - p = (mchunkptr)(mm + correction); - p->prev_size = correction; - set_head(p, (size - correction) |IS_MMAPPED); - } - else { - p = (mchunkptr)mm; - set_head(p, size|IS_MMAPPED); - } - - /* update statistics */ - - if (++mp_.n_mmaps > mp_.max_n_mmaps) - mp_.max_n_mmaps = mp_.n_mmaps; - - sum = mp_.mmapped_mem += size; - if (sum > (unsigned long)(mp_.max_mmapped_mem)) - mp_.max_mmapped_mem = sum; -#ifdef NO_THREADS - sum += av->system_mem; - if (sum > (unsigned long)(mp_.max_total_mem)) - mp_.max_total_mem = sum; -#endif - - check_chunk(av, p); - - return chunk2mem(p); - } - } - } -#endif - - /* Record incoming configuration of top */ - - old_top = av->top; - old_size = chunksize(old_top); - old_end = (char*)(chunk_at_offset(old_top, old_size)); - - brk = snd_brk = (char*)(MORECORE_FAILURE); - - /* - If not the first time through, we require old_size to be - at least MINSIZE and to have prev_inuse set. - */ - - assert((old_top == initial_top(av) && old_size == 0) || - ((unsigned long) (old_size) >= MINSIZE && - prev_inuse(old_top) && - ((unsigned long)old_end & pagemask) == 0)); - - /* Precondition: not enough current space to satisfy nb request */ - assert((unsigned long)(old_size) < (unsigned long)(nb + MINSIZE)); - - /* Precondition: all fastbins are consolidated */ - assert(!have_fastchunks(av)); - - - if (av != &main_arena) { - - heap_info *old_heap, *heap; - size_t old_heap_size; - - /* First try to extend the current heap. */ - old_heap = heap_for_ptr(old_top); - old_heap_size = old_heap->size; - if (grow_heap(old_heap, MINSIZE + nb - old_size) == 0) { - av->system_mem += old_heap->size - old_heap_size; - arena_mem += old_heap->size - old_heap_size; -#if 0 - if(mmapped_mem + arena_mem + sbrked_mem > max_total_mem) - max_total_mem = mmapped_mem + arena_mem + sbrked_mem; -#endif - set_head(old_top, (((char *)old_heap + old_heap->size) - (char *)old_top) - | PREV_INUSE); - } - else if ((heap = new_heap(nb + (MINSIZE + sizeof(*heap)), mp_.top_pad))) { - /* Use a newly allocated heap. */ - heap->ar_ptr = av; - heap->prev = old_heap; - av->system_mem += heap->size; - arena_mem += heap->size; -#if 0 - if((unsigned long)(mmapped_mem + arena_mem + sbrked_mem) > max_total_mem) - max_total_mem = mmapped_mem + arena_mem + sbrked_mem; -#endif - /* Set up the new top. */ - top(av) = chunk_at_offset(heap, sizeof(*heap)); - set_head(top(av), (heap->size - sizeof(*heap)) | PREV_INUSE); - - /* Setup fencepost and free the old top chunk. */ - /* The fencepost takes at least MINSIZE bytes, because it might - become the top chunk again later. Note that a footer is set - up, too, although the chunk is marked in use. */ - old_size -= MINSIZE; - set_head(chunk_at_offset(old_top, old_size + 2*SIZE_SZ), 0|PREV_INUSE); - if (old_size >= MINSIZE) { - set_head(chunk_at_offset(old_top, old_size), (2*SIZE_SZ)|PREV_INUSE); - set_foot(chunk_at_offset(old_top, old_size), (2*SIZE_SZ)); - set_head(old_top, old_size|PREV_INUSE|NON_MAIN_ARENA); - aproxy_int_free(av, chunk2mem(old_top)); - } else { - set_head(old_top, (old_size + 2*SIZE_SZ)|PREV_INUSE); - set_foot(old_top, (old_size + 2*SIZE_SZ)); - } - } - - } else { /* av == main_arena */ - - - /* Request enough space for nb + pad + overhead */ - - size = nb + mp_.top_pad + MINSIZE; - - /* - If contiguous, we can subtract out existing space that we hope to - combine with new space. We add it back later only if - we don't actually get contiguous space. - */ - - if (contiguous(av)) - size -= old_size; - - /* - Round to a multiple of page size. - If MORECORE is not contiguous, this ensures that we only call it - with whole-page arguments. And if MORECORE is contiguous and - this is not first time through, this preserves page-alignment of - previous calls. Otherwise, we correct to page-align below. - */ - - size = (size + pagemask) & ~pagemask; - - /* - Don't try to call MORECORE if argument is so big as to appear - negative. Note that since mmap takes size_t arg, it may succeed - below even if we cannot call MORECORE. - */ - - if (size > 0) - brk = (char*)(MORECORE(size)); - - if (brk != (char*)(MORECORE_FAILURE)) { - /* Call the `morecore' hook if necessary. */ - if (__aproxy_after_morecore_hook) - (*__aproxy_after_morecore_hook) (); - } else { - /* - If have mmap, try using it as a backup when MORECORE fails or - cannot be used. This is worth doing on systems that have "holes" in - address space, so sbrk cannot extend to give contiguous space, but - space is available elsewhere. Note that we ignore mmap max count - and threshold limits, since the space will not be used as a - segregated mmap region. - */ - -#if HAVE_MMAP - /* Cannot merge with old top, so add its size back in */ - if (contiguous(av)) - size = (size + old_size + pagemask) & ~pagemask; - - /* If we are relying on mmap as backup, then use larger units */ - if ((unsigned long)(size) < (unsigned long)(MMAP_AS_MORECORE_SIZE)) - size = MMAP_AS_MORECORE_SIZE; - - /* Don't try if size wraps around 0 */ - if ((unsigned long)(size) > (unsigned long)(nb)) { - - - // Here change to fix the address of MMAP - - char *mbrk = (char*)(MMAP(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE)); - - if (mbrk != MAP_FAILED) { - - /* We do not need, and cannot use, another sbrk call to find end */ - brk = mbrk; - snd_brk = brk + size; - - /* - Record that we no longer have a contiguous sbrk region. - After the first time mmap is used as backup, we do not - ever rely on contiguous space since this could incorrectly - bridge regions. - */ - set_noncontiguous(av); - } - } -#endif - } - - if (brk != (char*)(MORECORE_FAILURE)) { - if (mp_.sbrk_base == 0) - mp_.sbrk_base = brk; - av->system_mem += size; - - /* - If MORECORE extends previous space, we can likewise extend top size. - */ - - if (brk == old_end && snd_brk == (char*)(MORECORE_FAILURE)) - set_head(old_top, (size + old_size) | PREV_INUSE); - - else if (contiguous(av) && old_size && brk < old_end) { - /* Oops! Someone else killed our space.. Can't touch anything. */ - assert(0); - } - - /* - Otherwise, make adjustments: - - * If the first time through or noncontiguous, we need to call sbrk - just to find out where the end of memory lies. - - * We need to ensure that all returned chunks from malloc will meet - MALLOC_ALIGNMENT - - * If there was an intervening foreign sbrk, we need to adjust sbrk - request size to account for fact that we will not be able to - combine new space with existing space in old_top. - - * Almost all systems internally allocate whole pages at a time, in - which case we might as well use the whole last page of request. - So we allocate enough more memory to hit a page boundary now, - which in turn causes future contiguous calls to page-align. - */ - - else { - front_misalign = 0; - end_misalign = 0; - correction = 0; - aligned_brk = brk; - - /* handle contiguous cases */ - if (contiguous(av)) { - - /* Count foreign sbrk as system_mem. */ - if (old_size) - av->system_mem += brk - old_end; - - /* Guarantee alignment of first new chunk made from this space */ - - front_misalign = (INTERNAL_SIZE_T)chunk2mem(brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) { - - /* - Skip over some bytes to arrive at an aligned position. - We don't need to specially mark these wasted front bytes. - They will never be accessed anyway because - prev_inuse of av->top (and any chunk created from its start) - is always true after initialization. - */ - - correction = MALLOC_ALIGNMENT - front_misalign; - aligned_brk += correction; - } - - /* - If this isn't adjacent to existing space, then we will not - be able to merge with old_top space, so must add to 2nd request. - */ - - correction += old_size; - - /* Extend the end address to hit a page boundary */ - end_misalign = (INTERNAL_SIZE_T)(brk + size + correction); - correction += ((end_misalign + pagemask) & ~pagemask) - end_misalign; - - assert(correction >= 0); - snd_brk = (char*)(MORECORE(correction)); - - /* - If can't allocate correction, try to at least find out current - brk. It might be enough to proceed without failing. - - Note that if second sbrk did NOT fail, we assume that space - is contiguous with first sbrk. This is a safe assumption unless - program is multithreaded but doesn't use locks and a foreign sbrk - occurred between our first and second calls. - */ - - if (snd_brk == (char*)(MORECORE_FAILURE)) { - correction = 0; - snd_brk = (char*)(MORECORE(0)); - } else - /* Call the `morecore' hook if necessary. */ - if (__aproxy_after_morecore_hook) - (*__aproxy_after_morecore_hook) (); - } - - /* handle non-contiguous cases */ - else { - /* MORECORE/mmap must correctly align */ - assert(((unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK) == 0); - - /* Find out current end of memory */ - if (snd_brk == (char*)(MORECORE_FAILURE)) { - snd_brk = (char*)(MORECORE(0)); - } - } - - /* Adjust top based on results of second sbrk */ - if (snd_brk != (char*)(MORECORE_FAILURE)) { - av->top = (mchunkptr)aligned_brk; - set_head(av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); - av->system_mem += correction; - - /* - If not the first time through, we either have a - gap due to foreign sbrk or a non-contiguous region. Insert a - double fencepost at old_top to prevent consolidation with space - we don't own. These fenceposts are artificial chunks that are - marked as inuse and are in any case too small to use. We need - two to make sizes and alignments work out. - */ - - if (old_size != 0) { - /* - Shrink old_top to insert fenceposts, keeping size a - multiple of MALLOC_ALIGNMENT. We know there is at least - enough space in old_top to do this. - */ - old_size = (old_size - 4*SIZE_SZ) & ~MALLOC_ALIGN_MASK; - set_head(old_top, old_size | PREV_INUSE); - - /* - Note that the following assignments completely overwrite - old_top when old_size was previously MINSIZE. This is - intentional. We need the fencepost, even if old_top otherwise gets - lost. - */ - chunk_at_offset(old_top, old_size )->size = - (2*SIZE_SZ)|PREV_INUSE; - - chunk_at_offset(old_top, old_size + 2*SIZE_SZ)->size = - (2*SIZE_SZ)|PREV_INUSE; - - /* If possible, release the rest. */ - if (old_size >= MINSIZE) { - aproxy_int_free(av, chunk2mem(old_top)); - } - - } - } - } - - /* Update statistics */ -#ifdef NO_THREADS - sum = av->system_mem + mp_.mmapped_mem; - if (sum > (unsigned long)(mp_.max_total_mem)) - mp_.max_total_mem = sum; -#endif - - } - - } /* if (av != &main_arena) */ - - if ((unsigned long)av->system_mem > (unsigned long)(av->max_system_mem)) - av->max_system_mem = av->system_mem; - check_malloc_state(av); - - /* finally, do the allocation */ - p = av->top; - size = chunksize(p); - - /* check that one of the above allocation paths succeeded */ - if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(p, nb); - av->top = remainder; - set_head(p, nb | PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE); - check_malloced_chunk(av, p, nb); - return chunk2mem(p); - } - - /* catch all failure paths */ - MALLOC_FAILURE_ACTION; - return 0; -} - - -/* - sYSTRIm is an inverse of sorts to sYSMALLOc. It gives memory back - to the system (via negative arguments to sbrk) if there is unused - memory at the `high' end of the malloc pool. It is called - automatically by free() when top space exceeds the trim - threshold. It is also called by the public malloc_trim routine. It - returns 1 if it actually released any memory, else 0. -*/ - -#if __STD_C -static int sYSTRIm(size_t pad, mstate av) -#else -static int sYSTRIm(pad, av) size_t pad; mstate av; -#endif -{ - long top_size; /* Amount of top-most memory */ - long extra; /* Amount to release */ - long released; /* Amount actually released */ - char* current_brk; /* address returned by pre-check sbrk call */ - char* new_brk; /* address returned by post-check sbrk call */ - size_t pagesz; - - pagesz = mp_.pagesize; - top_size = chunksize(av->top); - - /* Release in pagesize units, keeping at least one page */ - extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz; - - if (extra > 0) { - - /* - Only proceed if end of memory is where we last set it. - This avoids problems if there were foreign sbrk calls. - */ - current_brk = (char*)(MORECORE(0)); - if (current_brk == (char*)(av->top) + top_size) { - - /* - Attempt to release memory. We ignore MORECORE return value, - and instead call again to find out where new end of memory is. - This avoids problems if first call releases less than we asked, - of if failure somehow altered brk value. (We could still - encounter problems if it altered brk in some very bad way, - but the only thing we can do is adjust anyway, which will cause - some downstream failure.) - */ - - MORECORE(-extra); - /* Call the `morecore' hook if necessary. */ - if (__aproxy_after_morecore_hook) - (*__aproxy_after_morecore_hook) (); - new_brk = (char*)(MORECORE(0)); - - if (new_brk != (char*)MORECORE_FAILURE) { - released = (long)(current_brk - new_brk); - - if (released != 0) { - /* Success. Adjust top. */ - av->system_mem -= released; - set_head(av->top, (top_size - released) | PREV_INUSE); - check_malloc_state(av); - return 1; - } - } - } - } - return 0; -} - -#ifdef HAVE_MMAP - -static void -internal_function -#if __STD_C -munmap_chunk(mchunkptr p) -#else -munmap_chunk(p) mchunkptr p; -#endif -{ - INTERNAL_SIZE_T size = chunksize(p); - int ret; - - assert (chunk_is_mmapped(p)); -#if 0 - assert(! ((char*)p >= mp_.sbrk_base && (char*)p < mp_.sbrk_base + mp_.sbrked_mem)); - assert((mp_.n_mmaps > 0)); -#endif - assert(((p->prev_size + size) & (mp_.pagesize-1)) == 0); - - mp_.n_mmaps--; - mp_.mmapped_mem -= (size + p->prev_size); - - ret = munmap((char *)p - p->prev_size, size + p->prev_size); - - /* munmap returns non-zero on failure */ - assert(ret == 0); -} - -#if HAVE_MREMAP - -static mchunkptr -internal_function -#if __STD_C -mremap_chunk(mchunkptr p, size_t new_size) -#else -mremap_chunk(p, new_size) mchunkptr p; size_t new_size; -#endif -{ - size_t page_mask = mp_.pagesize - 1; - INTERNAL_SIZE_T offset = p->prev_size; - INTERNAL_SIZE_T size = chunksize(p); - char *cp; - - assert (chunk_is_mmapped(p)); -#if 0 - assert(! ((char*)p >= mp_.sbrk_base && (char*)p < mp_.sbrk_base + mp_.sbrked_mem)); - assert((mp_.n_mmaps > 0)); -#endif - assert(((size + offset) & (mp_.pagesize-1)) == 0); - - /* Note the extra SIZE_SZ overhead as in mmap_chunk(). */ - new_size = (new_size + offset + SIZE_SZ + page_mask) & ~page_mask; - - cp = (char *)mremap((char *)p - offset, size + offset, new_size, - MREMAP_MAYMOVE); - - if (cp == MAP_FAILED) return 0; - - p = (mchunkptr)(cp + offset); - - assert(aligned_OK(chunk2mem(p))); - - assert((p->prev_size == offset)); - set_head(p, (new_size - offset)|IS_MMAPPED); - - mp_.mmapped_mem -= size + offset; - mp_.mmapped_mem += new_size; - if ((unsigned long)mp_.mmapped_mem > (unsigned long)mp_.max_mmapped_mem) - mp_.max_mmapped_mem = mp_.mmapped_mem; -#ifdef NO_THREADS - if ((unsigned long)(mp_.mmapped_mem + arena_mem + main_arena.system_mem) > - mp_.max_total_mem) - mp_.max_total_mem = mp_.mmapped_mem + arena_mem + main_arena.system_mem; -#endif - return p; -} - -#endif /* HAVE_MREMAP */ - -#endif /* HAVE_MMAP */ - -/*------------------------ Public wrappers. --------------------------------*/ - -Void_t* -public_mALLOc(size_t bytes) -{ - mstate ar_ptr; - Void_t *victim; - - __malloc_ptr_t (*hook) (size_t, __const __malloc_ptr_t) = __aproxy_hook; - if (hook != NULL) - return (*hook)(bytes, RETURN_ADDRESS (0)); - - arena_get(ar_ptr, bytes); - if(!ar_ptr) - return 0; - victim = aproxy_int_malloc(ar_ptr, bytes); - if(!victim) { - /* Maybe the failure is due to running out of mmapped areas. */ - if(ar_ptr != &main_arena) { - (void)mutex_unlock(&ar_ptr->mutex); - (void)mutex_lock(&main_arena.mutex); - victim = aproxy_int_malloc(&main_arena, bytes); - (void)mutex_unlock(&main_arena.mutex); - } else { -#if USE_ARENAS - /* ... or sbrk() has failed and there is still a chance to mmap() */ - ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes); - (void)mutex_unlock(&main_arena.mutex); - if(ar_ptr) { - victim = aproxy_int_malloc(ar_ptr, bytes); - (void)mutex_unlock(&ar_ptr->mutex); - } -#endif - } - } else - (void)mutex_unlock(&ar_ptr->mutex); - assert(!victim || chunk_is_mmapped(mem2chunk(victim)) || - ar_ptr == arena_for_chunk(mem2chunk(victim))); - return victim; -} -#ifdef libc_hidden_def -libc_hidden_def(public_mALLOc) -#endif - -void -public_fREe(Void_t* mem) -{ - mstate ar_ptr; - mchunkptr p; /* chunk corresponding to mem */ - - void (*hook) (__malloc_ptr_t, __const __malloc_ptr_t) = __aproxy_free_hook; - if (hook != NULL) { - (*hook)(mem, RETURN_ADDRESS (0)); - return; - } - - if (mem == 0) /* free(0) has no effect */ - return; - - p = mem2chunk(mem); - -#if HAVE_MMAP - if (chunk_is_mmapped(p)) /* release mmapped memory. */ - { - munmap_chunk(p); - return; - } -#endif - - ar_ptr = arena_for_chunk(p); -#if THREAD_STATS - if(!mutex_trylock(&ar_ptr->mutex)) - ++(ar_ptr->stat_lock_direct); - else { - (void)mutex_lock(&ar_ptr->mutex); - ++(ar_ptr->stat_lock_wait); - } -#else - (void)mutex_lock(&ar_ptr->mutex); -#endif - aproxy_int_free(ar_ptr, mem); - (void)mutex_unlock(&ar_ptr->mutex); -} -#ifdef libc_hidden_def -libc_hidden_def (public_fREe) -#endif - -Void_t* -public_rEALLOc(Void_t* oldmem, size_t bytes) -{ - mstate ar_ptr; - INTERNAL_SIZE_T nb; /* padded request size */ - - mchunkptr oldp; /* chunk corresponding to oldmem */ - INTERNAL_SIZE_T oldsize; /* its size */ - - Void_t* newp; /* chunk to return */ - - __malloc_ptr_t (*hook) (__malloc_ptr_t, size_t, __const __malloc_ptr_t) = - __aproxy_realloc_hook; - if (hook != NULL) - return (*hook)(oldmem, bytes, RETURN_ADDRESS (0)); - -#if REALLOC_ZERO_BYTES_FREES - if (bytes == 0 && oldmem != NULL) { public_fREe(oldmem); return 0; } -#endif - - /* realloc of null is supposed to be same as malloc */ - if (oldmem == 0) return public_mALLOc(bytes); - - oldp = mem2chunk(oldmem); - oldsize = chunksize(oldp); - - /* Little security check which won't hurt performance: the - allocator never wrapps around at the end of the address space. - Therefore we can exclude some size values which might appear - here by accident or by "design" from some intruder. */ - if (__builtin_expect ((uintptr_t) oldp > (uintptr_t) -oldsize, 0) - || __builtin_expect ((uintptr_t) oldp & MALLOC_ALIGN_MASK, 0)) - { - malloc_printerr (check_action, "realloc(): invalid pointer", oldmem); - return NULL; - } - - checked_request2size(bytes, nb); - -#if HAVE_MMAP - if (chunk_is_mmapped(oldp)) - { - Void_t* newmem; - -#if HAVE_MREMAP - newp = mremap_chunk(oldp, nb); - if(newp) return chunk2mem(newp); -#endif - /* Note the extra SIZE_SZ overhead. */ - if(oldsize - SIZE_SZ >= nb) return oldmem; /* do nothing */ - /* Must alloc, copy, free. */ - newmem = public_mALLOc(bytes); - if (newmem == 0) return 0; /* propagate failure */ - MALLOC_COPY(newmem, oldmem, oldsize - 2*SIZE_SZ); - munmap_chunk(oldp); - return newmem; - } -#endif - - ar_ptr = arena_for_chunk(oldp); -#if THREAD_STATS - if(!mutex_trylock(&ar_ptr->mutex)) - ++(ar_ptr->stat_lock_direct); - else { - (void)mutex_lock(&ar_ptr->mutex); - ++(ar_ptr->stat_lock_wait); - } -#else - (void)mutex_lock(&ar_ptr->mutex); -#endif - -#ifndef NO_THREADS - /* As in malloc(), remember this arena for the next allocation. */ - tsd_setspecific(arena_key, (Void_t *)ar_ptr); -#endif - - newp = aproxy_int_realloc(ar_ptr, oldmem, bytes); - - (void)mutex_unlock(&ar_ptr->mutex); - assert(!newp || chunk_is_mmapped(mem2chunk(newp)) || - ar_ptr == arena_for_chunk(mem2chunk(newp))); - return newp; -} -#ifdef libc_hidden_def -libc_hidden_def (public_rEALLOc) -#endif - -Void_t* -public_mEMALIGn(size_t alignment, size_t bytes) -{ - mstate ar_ptr; - Void_t *p; - - __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, - __const __malloc_ptr_t)) = - __aproxy_memalign_hook; - if (hook != NULL) - return (*hook)(alignment, bytes, RETURN_ADDRESS (0)); - - /* If need less alignment than we give anyway, just relay to malloc */ - if (alignment <= MALLOC_ALIGNMENT) return public_mALLOc(bytes); - - /* Otherwise, ensure that it is at least a minimum chunk size */ - if (alignment < MINSIZE) alignment = MINSIZE; - - arena_get(ar_ptr, bytes + alignment + MINSIZE); - if(!ar_ptr) - return 0; - p = aproxy_int_memalign(ar_ptr, alignment, bytes); - (void)mutex_unlock(&ar_ptr->mutex); - if(!p) { - /* Maybe the failure is due to running out of mmapped areas. */ - if(ar_ptr != &main_arena) { - (void)mutex_lock(&main_arena.mutex); - p = aproxy_int_memalign(&main_arena, alignment, bytes); - (void)mutex_unlock(&main_arena.mutex); - } else { -#if USE_ARENAS - /* ... or sbrk() has failed and there is still a chance to mmap() */ - ar_ptr = arena_get2(ar_ptr->next ? ar_ptr : 0, bytes); - if(ar_ptr) { - p = aproxy_int_memalign(ar_ptr, alignment, bytes); - (void)mutex_unlock(&ar_ptr->mutex); - } -#endif - } - } - assert(!p || chunk_is_mmapped(mem2chunk(p)) || - ar_ptr == arena_for_chunk(mem2chunk(p))); - return p; -} -#ifdef libc_hidden_def -libc_hidden_def (public_mEMALIGn) -#endif - -Void_t* -public_vALLOc(size_t bytes) -{ - mstate ar_ptr; - Void_t *p; - __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, - __const __malloc_ptr_t)) = - __aproxy_memalign_hook; - - if(__aproxy_initialized < 0) - aproxy_ptmalloc_init (); - - if (hook != NULL) - return (*hook)(mp_.pagesize, bytes, RETURN_ADDRESS (0)); - - arena_get(ar_ptr, bytes + mp_.pagesize + MINSIZE); - if(!ar_ptr) - return 0; - p = aproxy_int_valloc(ar_ptr, bytes); - (void)mutex_unlock(&ar_ptr->mutex); - return p; -} - -Void_t* -public_pVALLOc(size_t bytes) -{ - mstate ar_ptr; - Void_t *p; - - __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, - __const __malloc_ptr_t)) = - __aproxy_memalign_hook; - - if(__aproxy_initialized < 0) - aproxy_ptmalloc_init (); - if (hook != NULL) - return (*hook)(mp_.pagesize, - (bytes + mp_.pagesize - 1) & ~(mp_.pagesize - 1), - RETURN_ADDRESS (0)); - - arena_get(ar_ptr, bytes + 2*mp_.pagesize + MINSIZE); - p = aproxy_int_pvalloc(ar_ptr, bytes); - (void)mutex_unlock(&ar_ptr->mutex); - return p; -} - -Void_t* -public_cALLOc(size_t n, size_t elem_size) -{ - mstate av; - mchunkptr oldtop, p; - INTERNAL_SIZE_T bytes, sz, csz, oldtopsize; - Void_t* mem; - unsigned long clearsize; - unsigned long nclears; - INTERNAL_SIZE_T* d; - __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) = - __aproxy_hook; - - /* size_t is unsigned so the behavior on overflow is defined. */ - bytes = n * elem_size; -#define HALF_INTERNAL_SIZE_T \ - (((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2)) - if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) { - if (elem_size != 0 && bytes / elem_size != n) { - MALLOC_FAILURE_ACTION; - return 0; - } - } - - if (hook != NULL) { - sz = bytes; - mem = (*hook)(sz, RETURN_ADDRESS (0)); - if(mem == 0) - return 0; -#ifdef HAVE_MEMCPY - return memset(mem, 0, sz); -#else - while(sz > 0) ((char*)mem)[--sz] = 0; /* rather inefficient */ - return mem; -#endif - } - - sz = bytes; - - arena_get(av, sz); - if(!av) - return 0; - - /* Check if we hand out the top chunk, in which case there may be no - need to clear. */ -#if MORECORE_CLEARS - oldtop = top(av); - oldtopsize = chunksize(top(av)); -#if MORECORE_CLEARS < 2 - /* Only newly allocated memory is guaranteed to be cleared. */ - if (av == &main_arena && - oldtopsize < mp_.sbrk_base + av->max_system_mem - (char *)oldtop) - oldtopsize = (mp_.sbrk_base + av->max_system_mem - (char *)oldtop); -#endif -#endif - mem = aproxy_int_malloc(av, sz); - - /* Only clearing follows, so we can unlock early. */ - (void)mutex_unlock(&av->mutex); - - assert(!mem || chunk_is_mmapped(mem2chunk(mem)) || - av == arena_for_chunk(mem2chunk(mem))); - - if (mem == 0) { - /* Maybe the failure is due to running out of mmapped areas. */ - if(av != &main_arena) { - (void)mutex_lock(&main_arena.mutex); - mem = aproxy_int_malloc(&main_arena, sz); - (void)mutex_unlock(&main_arena.mutex); - } else { -#if USE_ARENAS - /* ... or sbrk() has failed and there is still a chance to mmap() */ - (void)mutex_lock(&main_arena.mutex); - av = arena_get2(av->next ? av : 0, sz); - (void)mutex_unlock(&main_arena.mutex); - if(av) { - mem = aproxy_int_malloc(av, sz); - (void)mutex_unlock(&av->mutex); - } -#endif - } - if (mem == 0) return 0; - } - p = mem2chunk(mem); - - /* Two optional cases in which clearing not necessary */ -#if HAVE_MMAP - if (chunk_is_mmapped(p)) - return mem; -#endif - - csz = chunksize(p); - -#if MORECORE_CLEARS - if (p == oldtop && csz > oldtopsize) { - /* clear only the bytes from non-freshly-sbrked memory */ - csz = oldtopsize; - } -#endif - - /* Unroll clear of <= 36 bytes (72 if 8byte sizes). We know that - contents have an odd number of INTERNAL_SIZE_T-sized words; - minimally 3. */ - d = (INTERNAL_SIZE_T*)mem; - clearsize = csz - SIZE_SZ; - nclears = clearsize / sizeof(INTERNAL_SIZE_T); - assert(nclears >= 3); - - if (nclears > 9) - MALLOC_ZERO(d, clearsize); - - else { - *(d+0) = 0; - *(d+1) = 0; - *(d+2) = 0; - if (nclears > 4) { - *(d+3) = 0; - *(d+4) = 0; - if (nclears > 6) { - *(d+5) = 0; - *(d+6) = 0; - if (nclears > 8) { - *(d+7) = 0; - *(d+8) = 0; - } - } - } - } - - return mem; -} - -Void_t** -public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks) -{ - mstate ar_ptr; - Void_t** m; - - arena_get(ar_ptr, n*elem_size); - if(!ar_ptr) - return 0; - - m = aproxy_int_icalloc(ar_ptr, n, elem_size, chunks); - (void)mutex_unlock(&ar_ptr->mutex); - return m; -} - -Void_t** -public_iCOMALLOc(size_t n, size_t sizes[], Void_t** chunks) -{ - mstate ar_ptr; - Void_t** m; - - arena_get(ar_ptr, 0); - if(!ar_ptr) - return 0; - - m = aproxy_int_icomalloc(ar_ptr, n, sizes, chunks); - (void)mutex_unlock(&ar_ptr->mutex); - return m; -} - -#ifndef _LIBC - -void -public_cFREe(Void_t* m) -{ - public_fREe(m); -} - -#endif /* _LIBC */ - -int -public_mTRIm(size_t s) -{ - int result; - - (void)mutex_lock(&main_arena.mutex); - result = mTRIm(s); - (void)mutex_unlock(&main_arena.mutex); - return result; -} - -size_t -public_mUSABLe(Void_t* m) -{ - size_t result; - - result = mUSABLe(m); - return result; -} - -void -public_mSTATs() -{ - mSTATs(); -} - -struct mallinfo public_mALLINFo() -{ - struct mallinfo m; - - if(__aproxy_initialized < 0) - aproxy_ptmalloc_init (); - (void)mutex_lock(&main_arena.mutex); - m = mALLINFo(&main_arena); - (void)mutex_unlock(&main_arena.mutex); - return m; -} - -int -public_mALLOPt(int p, int v) -{ - int result; - result = mALLOPt(p, v); - return result; -} - -/* - ------------------------------ malloc ------------------------------ -*/ - -Void_t* -aproxy_int_malloc(mstate av, size_t bytes) -{ - INTERNAL_SIZE_T nb; /* normalized request size */ - unsigned int idx; /* associated bin index */ - mbinptr bin; /* associated bin */ - mfastbinptr* fb; /* associated fastbin */ - - mchunkptr victim; /* inspected/selected chunk */ - INTERNAL_SIZE_T size; /* its size */ - int victim_index; /* its bin index */ - - mchunkptr remainder; /* remainder from a split */ - unsigned long remainder_size; /* its size */ - - unsigned int block; /* bit map traverser */ - unsigned int bit; /* bit map traverser */ - unsigned int map; /* current word of binmap */ - - mchunkptr fwd; /* misc temp for linking */ - mchunkptr bck; /* misc temp for linking */ - - /* - Convert request size to internal form by adding SIZE_SZ bytes - overhead plus possibly more to obtain necessary alignment and/or - to obtain a size of at least MINSIZE, the smallest allocatable - size. Also, checked_request2size traps (returning 0) request sizes - that are so large that they wrap around zero when padded and - aligned. - */ - - checked_request2size(bytes, nb); - - /* - If the size qualifies as a fastbin, first check corresponding bin. - This code is safe to execute even if av is not yet initialized, so we - can try it without checking, which saves some time on this fast path. - */ - - if ((unsigned long)(nb) <= (unsigned long)(av->max_fast)) { - long int idx = fastbin_index(nb); - fb = &(av->fastbins[idx]); - if ( (victim = *fb) != 0) { - if (__builtin_expect (fastbin_index (chunksize (victim)) != idx, 0)) - malloc_printerr (check_action, "malloc(): memory corruption (fast)", - chunk2mem (victim)); - *fb = victim->fd; - check_remalloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - } - - /* - If a small request, check regular bin. Since these "smallbins" - hold one size each, no searching within bins is necessary. - (For a large request, we need to wait until unsorted chunks are - processed to find best fit. But for small ones, fits are exact - anyway, so we can check now, which is faster.) - */ - - if (in_smallbin_range(nb)) { - idx = smallbin_index(nb); - bin = bin_at(av,idx); - - if ( (victim = last(bin)) != bin) { - if (victim == 0) /* initialization check */ - malloc_consolidate(av); - else { - bck = victim->bk; - set_inuse_bit_at_offset(victim, nb); - bin->bk = bck; - bck->fd = bin; - - if (av != &main_arena) - victim->size |= NON_MAIN_ARENA; - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - } - } - - /* - If this is a large request, consolidate fastbins before continuing. - While it might look excessive to kill all fastbins before - even seeing if there is space available, this avoids - fragmentation problems normally associated with fastbins. - Also, in practice, programs tend to have runs of either small or - large requests, but less often mixtures, so consolidation is not - invoked all that often in most programs. And the programs that - it is called frequently in otherwise tend to fragment. - */ - - else { - idx = largebin_index(nb); - if (have_fastchunks(av)) - malloc_consolidate(av); - } - - /* - Process recently freed or remaindered chunks, taking one only if - it is exact fit, or, if this a small request, the chunk is remainder from - the most recent non-exact fit. Place other traversed chunks in - bins. Note that this step is the only place in any routine where - chunks are placed in bins. - - The outer loop here is needed because we might not realize until - near the end of malloc that we should have consolidated, so must - do so and retry. This happens at most once, and only when we would - otherwise need to expand memory to service a "small" request. - */ - - for(;;) { - - while ( (victim = unsorted_chunks(av)->bk) != unsorted_chunks(av)) { - bck = victim->bk; - if (__builtin_expect (victim->size <= 2 * SIZE_SZ, 0) - || __builtin_expect (victim->size > av->system_mem, 0)) - malloc_printerr (check_action, "malloc(): memory corruption", - chunk2mem (victim)); - size = chunksize(victim); - - /* - If a small request, try to use last remainder if it is the - only chunk in unsorted bin. This helps promote locality for - runs of consecutive small requests. This is the only - exception to best-fit, and applies only when there is - no exact fit for a small chunk. - */ - - if (in_smallbin_range(nb) && - bck == unsorted_chunks(av) && - victim == av->last_remainder && - (unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { - - /* split and reattach remainder */ - remainder_size = size - nb; - remainder = chunk_at_offset(victim, nb); - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - av->last_remainder = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - - set_head(victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - - /* remove from unsorted list */ - unsorted_chunks(av)->bk = bck; - bck->fd = unsorted_chunks(av); - - /* Take now instead of binning if exact fit */ - - if (size == nb) { - set_inuse_bit_at_offset(victim, size); - if (av != &main_arena) - victim->size |= NON_MAIN_ARENA; - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - - /* place chunk in bin */ - - if (in_smallbin_range(size)) { - victim_index = smallbin_index(size); - bck = bin_at(av, victim_index); - fwd = bck->fd; - } - else { - victim_index = largebin_index(size); - bck = bin_at(av, victim_index); - fwd = bck->fd; - - /* maintain large bins in sorted order */ - if (fwd != bck) { - /* Or with inuse bit to speed comparisons */ - size |= PREV_INUSE; - /* if smaller than smallest, bypass loop below */ - assert((bck->bk->size & NON_MAIN_ARENA) == 0); - if ((unsigned long)(size) <= (unsigned long)(bck->bk->size)) { - fwd = bck; - bck = bck->bk; - } - else { - assert((fwd->size & NON_MAIN_ARENA) == 0); - while ((unsigned long)(size) < (unsigned long)(fwd->size)) { - fwd = fwd->fd; - assert((fwd->size & NON_MAIN_ARENA) == 0); - } - bck = fwd->bk; - } - } - } - - mark_bin(av, victim_index); - victim->bk = bck; - victim->fd = fwd; - fwd->bk = victim; - bck->fd = victim; - } - - /* - If a large request, scan through the chunks of current bin in - sorted order to find smallest that fits. This is the only step - where an unbounded number of chunks might be scanned without doing - anything useful with them. However the lists tend to be short. - */ - - if (!in_smallbin_range(nb)) { - bin = bin_at(av, idx); - - /* skip scan if empty or largest chunk is too small */ - if ((victim = last(bin)) != bin && - (unsigned long)(first(bin)->size) >= (unsigned long)(nb)) { - - while (((unsigned long)(size = chunksize(victim)) < - (unsigned long)(nb))) - victim = victim->bk; - - remainder_size = size - nb; - unlink(victim, bck, fwd); - - /* Exhaust */ - if (remainder_size < MINSIZE) { - set_inuse_bit_at_offset(victim, size); - if (av != &main_arena) - victim->size |= NON_MAIN_ARENA; - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - /* Split */ - else { - remainder = chunk_at_offset(victim, nb); - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - set_head(victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - } - } - - /* - Search for a chunk by scanning bins, starting with next largest - bin. This search is strictly by best-fit; i.e., the smallest - (with ties going to approximately the least recently used) chunk - that fits is selected. - - The bitmap avoids needing to check that most blocks are nonempty. - The particular case of skipping all bins during warm-up phases - when no chunks have been returned yet is faster than it might look. - */ - - ++idx; - bin = bin_at(av,idx); - block = idx2block(idx); - map = av->binmap[block]; - bit = idx2bit(idx); - - for (;;) { - - /* Skip rest of block if there are no more set bits in this block. */ - if (bit > map || bit == 0) { - do { - if (++block >= BINMAPSIZE) /* out of bins */ - goto use_top; - } while ( (map = av->binmap[block]) == 0); - - bin = bin_at(av, (block << BINMAPSHIFT)); - bit = 1; - } - - /* Advance to bin with set bit. There must be one. */ - while ((bit & map) == 0) { - bin = next_bin(bin); - bit <<= 1; - assert(bit != 0); - } - - /* Inspect the bin. It is likely to be non-empty */ - victim = last(bin); - - /* If a false alarm (empty bin), clear the bit. */ - if (victim == bin) { - av->binmap[block] = map &= ~bit; /* Write through */ - bin = next_bin(bin); - bit <<= 1; - } - - else { - size = chunksize(victim); - - /* We know the first chunk in this bin is big enough to use. */ - assert((unsigned long)(size) >= (unsigned long)(nb)); - - remainder_size = size - nb; - - /* unlink */ - bck = victim->bk; - bin->bk = bck; - bck->fd = bin; - - /* Exhaust */ - if (remainder_size < MINSIZE) { - set_inuse_bit_at_offset(victim, size); - if (av != &main_arena) - victim->size |= NON_MAIN_ARENA; - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - - /* Split */ - else { - remainder = chunk_at_offset(victim, nb); - - unsorted_chunks(av)->bk = unsorted_chunks(av)->fd = remainder; - remainder->bk = remainder->fd = unsorted_chunks(av); - /* advertise as last remainder */ - if (in_smallbin_range(nb)) - av->last_remainder = remainder; - - set_head(victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE); - set_foot(remainder, remainder_size); - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - } - } - - use_top: - /* - If large enough, split off the chunk bordering the end of memory - (held in av->top). Note that this is in accord with the best-fit - search rule. In effect, av->top is treated as larger (and thus - less well fitting) than any other available chunk since it can - be extended to be as large as necessary (up to system - limitations). - - We require that av->top always exists (i.e., has size >= - MINSIZE) after initialization, so if it would otherwise be - exhuasted by current request, it is replenished. (The main - reason for ensuring it exists is that we may need MINSIZE space - to put in fenceposts in sysmalloc.) - */ - - victim = av->top; - size = chunksize(victim); - - if ((unsigned long)(size) >= (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(victim, nb); - av->top = remainder; - set_head(victim, nb | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE); - - check_malloced_chunk(av, victim, nb); - return chunk2mem(victim); - } - - /* - If there is space available in fastbins, consolidate and retry, - to possibly avoid expanding memory. This can occur only if nb is - in smallbin range so we didn't consolidate upon entry. - */ - - else if (have_fastchunks(av)) { - assert(in_smallbin_range(nb)); - malloc_consolidate(av); - idx = smallbin_index(nb); /* restore original bin index */ - } - - /* - Otherwise, relay to handle system-dependent cases - */ - else - return sYSMALLOc(nb, av); - } -} - -/* - ------------------------------ free ------------------------------ -*/ - -void -aproxy_int_free(mstate av, Void_t* mem) -{ - mchunkptr p; /* chunk corresponding to mem */ - INTERNAL_SIZE_T size; /* its size */ - mfastbinptr* fb; /* associated fastbin */ - mchunkptr nextchunk; /* next contiguous chunk */ - INTERNAL_SIZE_T nextsize; /* its size */ - int nextinuse; /* true if nextchunk is used */ - INTERNAL_SIZE_T prevsize; /* size of previous contiguous chunk */ - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - - const char *errstr = NULL; - - p = mem2chunk(mem); - size = chunksize(p); - - /* Little security check which won't hurt performance: the - allocator never wrapps around at the end of the address space. - Therefore we can exclude some size values which might appear - here by accident or by "design" from some intruder. */ - if (__builtin_expect ((uintptr_t) p > (uintptr_t) -size, 0) - || __builtin_expect ((uintptr_t) p & MALLOC_ALIGN_MASK, 0)) - { - errstr = "free(): invalid pointer"; - errout: - malloc_printerr (check_action, errstr, mem); - return; - } - - check_inuse_chunk(av, p); - - /* - If eligible, place chunk on a fastbin so it can be found - and used quickly in malloc. - */ - - if ((unsigned long)(size) <= (unsigned long)(av->max_fast) - -#if TRIM_FASTBINS - /* - If TRIM_FASTBINS set, don't place chunks - bordering top into fastbins - */ - && (chunk_at_offset(p, size) != av->top) -#endif - ) { - - if (__builtin_expect (chunk_at_offset (p, size)->size <= 2 * SIZE_SZ, 0) - || __builtin_expect (chunksize (chunk_at_offset (p, size)) - >= av->system_mem, 0)) - { - errstr = "free(): invalid next size (fast)"; - goto errout; - } - - set_fastchunks(av); - fb = &(av->fastbins[fastbin_index(size)]); - /* Another simple check: make sure the top of the bin is not the - record we are going to add (i.e., double free). */ - if (__builtin_expect (*fb == p, 0)) - { - errstr = "double free or corruption (fasttop)"; - goto errout; - } - p->fd = *fb; - *fb = p; - } - - /* - Consolidate other non-mmapped chunks as they arrive. - */ - - else if (!chunk_is_mmapped(p)) { - nextchunk = chunk_at_offset(p, size); - - /* Lightweight tests: check whether the block is already the - top block. */ - if (__builtin_expect (p == av->top, 0)) - { - errstr = "double free or corruption (top)"; - goto errout; - } - /* Or whether the next chunk is beyond the boundaries of the arena. */ - if (__builtin_expect (contiguous (av) - && (char *) nextchunk - >= ((char *) av->top + chunksize(av->top)), 0)) - { - errstr = "double free or corruption (out)"; - goto errout; - } - /* Or whether the block is actually not marked used. */ - if (__builtin_expect (!prev_inuse(nextchunk), 0)) - { - errstr = "double free or corruption (!prev)"; - goto errout; - } - - nextsize = chunksize(nextchunk); - if (__builtin_expect (nextchunk->size <= 2 * SIZE_SZ, 0) - || __builtin_expect (nextsize >= av->system_mem, 0)) - { - errstr = "free(): invalid next size (normal)"; - goto errout; - } - - /* consolidate backward */ - if (!prev_inuse(p)) { - prevsize = p->prev_size; - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - unlink(p, bck, fwd); - } - - if (nextchunk != av->top) { - /* get and clear inuse bit */ - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - - /* consolidate forward */ - if (!nextinuse) { - unlink(nextchunk, bck, fwd); - size += nextsize; - } else - clear_inuse_bit_at_offset(nextchunk, 0); - - /* - Place the chunk in unsorted chunk list. Chunks are - not placed into regular bins until after they have - been given one chance to be used in malloc. - */ - - bck = unsorted_chunks(av); - fwd = bck->fd; - p->bk = bck; - p->fd = fwd; - bck->fd = p; - fwd->bk = p; - - set_head(p, size | PREV_INUSE); - set_foot(p, size); - - check_free_chunk(av, p); - } - - /* - If the chunk borders the current high end of memory, - consolidate into top - */ - - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - check_chunk(av, p); - } - - /* - If freeing a large space, consolidate possibly-surrounding - chunks. Then, if the total unused topmost memory exceeds trim - threshold, ask malloc_trim to reduce top. - - Unless max_fast is 0, we don't know if there are fastbins - bordering top, so we cannot tell for sure whether threshold - has been reached unless fastbins are consolidated. But we - don't want to consolidate on each free. As a compromise, - consolidation is performed if FASTBIN_CONSOLIDATION_THRESHOLD - is reached. - */ - - if ((unsigned long)(size) >= FASTBIN_CONSOLIDATION_THRESHOLD) { - if (have_fastchunks(av)) - malloc_consolidate(av); - - if (av == &main_arena) { -#ifndef MORECORE_CANNOT_TRIM - if ((unsigned long)(chunksize(av->top)) >= - (unsigned long)(mp_.trim_threshold)) - sYSTRIm(mp_.top_pad, av); -#endif - } else { - /* Always try heap_trim(), even if the top chunk is not - large, because the corresponding heap might go away. */ - heap_info *heap = heap_for_ptr(top(av)); - - assert(heap->ar_ptr == av); - heap_trim(heap, mp_.top_pad); - } - } - - } - /* - If the chunk was allocated via mmap, release via munmap(). Note - that if HAVE_MMAP is false but chunk_is_mmapped is true, then - user must have overwritten memory. There's nothing we can do to - catch this error unless MALLOC_DEBUG is set, in which case - check_inuse_chunk (above) will have triggered error. - */ - - else { -#if HAVE_MMAP - munmap_chunk (p); -#endif - } -} - -/* - ------------------------- malloc_consolidate ------------------------- - - malloc_consolidate is a specialized version of free() that tears - down chunks held in fastbins. Free itself cannot be used for this - purpose since, among other things, it might place chunks back onto - fastbins. So, instead, we need to use a minor variant of the same - code. - - Also, because this routine needs to be called the first time through - malloc anyway, it turns out to be the perfect place to trigger - initialization code. -*/ - -#if __STD_C -static void malloc_consolidate(mstate av) -#else -static void malloc_consolidate(av) mstate av; -#endif -{ - mfastbinptr* fb; /* current fastbin being consolidated */ - mfastbinptr* maxfb; /* last fastbin (for loop control) */ - mchunkptr p; /* current chunk being consolidated */ - mchunkptr nextp; /* next chunk to consolidate */ - mchunkptr unsorted_bin; /* bin header */ - mchunkptr first_unsorted; /* chunk to link to */ - - /* These have same use as in free() */ - mchunkptr nextchunk; - INTERNAL_SIZE_T size; - INTERNAL_SIZE_T nextsize; - INTERNAL_SIZE_T prevsize; - int nextinuse; - mchunkptr bck; - mchunkptr fwd; - - /* - If max_fast is 0, we know that av hasn't - yet been initialized, in which case do so below - */ - - if (av->max_fast != 0) { - clear_fastchunks(av); - - unsorted_bin = unsorted_chunks(av); - - /* - Remove each chunk from fast bin and consolidate it, placing it - then in unsorted bin. Among other reasons for doing this, - placing in unsorted bin avoids needing to calculate actual bins - until malloc is sure that chunks aren't immediately going to be - reused anyway. - */ - - maxfb = &(av->fastbins[fastbin_index(av->max_fast)]); - fb = &(av->fastbins[0]); - do { - if ( (p = *fb) != 0) { - *fb = 0; - - do { - check_inuse_chunk(av, p); - nextp = p->fd; - - /* Slightly streamlined version of consolidation code in free() */ - size = p->size & ~(PREV_INUSE|NON_MAIN_ARENA); - nextchunk = chunk_at_offset(p, size); - nextsize = chunksize(nextchunk); - - if (!prev_inuse(p)) { - prevsize = p->prev_size; - size += prevsize; - p = chunk_at_offset(p, -((long) prevsize)); - unlink(p, bck, fwd); - } - - if (nextchunk != av->top) { - nextinuse = inuse_bit_at_offset(nextchunk, nextsize); - - if (!nextinuse) { - size += nextsize; - unlink(nextchunk, bck, fwd); - } else - clear_inuse_bit_at_offset(nextchunk, 0); - - first_unsorted = unsorted_bin->fd; - unsorted_bin->fd = p; - first_unsorted->bk = p; - - set_head(p, size | PREV_INUSE); - p->bk = unsorted_bin; - p->fd = first_unsorted; - set_foot(p, size); - } - - else { - size += nextsize; - set_head(p, size | PREV_INUSE); - av->top = p; - } - - } while ( (p = nextp) != 0); - - } - } while (fb++ != maxfb); - } - else { - malloc_init_state(av); - check_malloc_state(av); - } -} - -/* - ------------------------------ realloc ------------------------------ -*/ - -Void_t* -aproxy_int_realloc(mstate av, Void_t* oldmem, size_t bytes) -{ - INTERNAL_SIZE_T nb; /* padded request size */ - - mchunkptr oldp; /* chunk corresponding to oldmem */ - INTERNAL_SIZE_T oldsize; /* its size */ - - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - Void_t* newmem; /* corresponding user mem */ - - mchunkptr next; /* next contiguous chunk after oldp */ - - mchunkptr remainder; /* extra space at end of newp */ - unsigned long remainder_size; /* its size */ - - mchunkptr bck; /* misc temp for linking */ - mchunkptr fwd; /* misc temp for linking */ - - unsigned long copysize; /* bytes to copy */ - unsigned int ncopies; /* INTERNAL_SIZE_T words to copy */ - INTERNAL_SIZE_T* s; /* copy source */ - INTERNAL_SIZE_T* d; /* copy destination */ - - const char *errstr = NULL; - INTERNAL_SIZE_T nextsize; - - char intbuf[256]; - int intlen; - - checked_request2size(bytes, nb); - - oldp = mem2chunk(oldmem); - oldsize = chunksize(oldp); - - /* Simple tests for old block integrity. */ - if (__builtin_expect ((uintptr_t) oldp & MALLOC_ALIGN_MASK, 0)) - { - errstr = "realloc(): invalid pointer"; - - fprintf(stderr, "MALLOC_ALIGN_MASK = %08X (%u) -> align = %u\n", - MALLOC_ALIGN_MASK, MALLOC_ALIGN_MASK, - (uintptr_t) oldp & MALLOC_ALIGN_MASK); - - errout: - malloc_printerr (check_action, errstr, oldmem); - return NULL; - } - - if (__builtin_expect (oldp->size <= 2 * SIZE_SZ, 0) - || __builtin_expect (oldsize >= av->system_mem, 0)) - { - - intlen = snprintf(intbuf, sizeof(intbuf), - "FAILURE WITH: oldsize = %u, av->system_mem = %u \n", - oldsize, av->system_mem); - write(1, intbuf, intlen); - - errstr = "realloc(): invalid size"; - goto errout; - } - - check_inuse_chunk(av, oldp); - - if (!chunk_is_mmapped(oldp)) { - - next = chunk_at_offset(oldp, oldsize); - nextsize = chunksize(next); - if (__builtin_expect (next->size <= 2 * SIZE_SZ, 0) - || __builtin_expect (nextsize >= av->system_mem, 0)) - { - - intlen = snprintf(intbuf, sizeof(intbuf), - "FAILURE2 WITH: oldsize = %u, av->system_mem = %u \n", - oldsize, av->system_mem); - write(1, intbuf, intlen); - - errstr = "realloc(): invalid next size"; - goto errout; - } - - if ((unsigned long)(oldsize) >= (unsigned long)(nb)) { - /* already big enough; split below */ - newp = oldp; - newsize = oldsize; - } - - else { - /* Try to expand forward into top */ - if (next == av->top && - (unsigned long)(newsize = oldsize + nextsize) >= - (unsigned long)(nb + MINSIZE)) { - set_head_size(oldp, nb | (av != &main_arena ? NON_MAIN_ARENA : 0)); - av->top = chunk_at_offset(oldp, nb); - set_head(av->top, (newsize - nb) | PREV_INUSE); - check_inuse_chunk(av, oldp); - return chunk2mem(oldp); - } - - /* Try to expand forward into next chunk; split off remainder below */ - else if (next != av->top && - !inuse(next) && - (unsigned long)(newsize = oldsize + nextsize) >= - (unsigned long)(nb)) { - newp = oldp; - unlink(next, bck, fwd); - } - - /* allocate, copy, free */ - else { - newmem = aproxy_int_malloc(av, nb - MALLOC_ALIGN_MASK); - if (newmem == 0) - return 0; /* propagate failure */ - - newp = mem2chunk(newmem); - newsize = chunksize(newp); - - /* - Avoid copy if newp is next chunk after oldp. - */ - if (newp == next) { - newsize += oldsize; - newp = oldp; - } - else { - /* - Unroll copy of <= 36 bytes (72 if 8byte sizes) - We know that contents have an odd number of - INTERNAL_SIZE_T-sized words; minimally 3. - */ - - copysize = oldsize - SIZE_SZ; - s = (INTERNAL_SIZE_T*)(oldmem); - d = (INTERNAL_SIZE_T*)(newmem); - ncopies = copysize / sizeof(INTERNAL_SIZE_T); - assert(ncopies >= 3); - - if (ncopies > 9) - MALLOC_COPY(d, s, copysize); - - else { - *(d+0) = *(s+0); - *(d+1) = *(s+1); - *(d+2) = *(s+2); - if (ncopies > 4) { - *(d+3) = *(s+3); - *(d+4) = *(s+4); - if (ncopies > 6) { - *(d+5) = *(s+5); - *(d+6) = *(s+6); - if (ncopies > 8) { - *(d+7) = *(s+7); - *(d+8) = *(s+8); - } - } - } - } - - aproxy_int_free(av, oldmem); - check_inuse_chunk(av, newp); - return chunk2mem(newp); - } - } - } - - /* If possible, free extra space in old or extended chunk */ - - assert((unsigned long)(newsize) >= (unsigned long)(nb)); - - remainder_size = newsize - nb; - - if (remainder_size < MINSIZE) { /* not enough extra to split off */ - set_head_size(newp, newsize | (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_inuse_bit_at_offset(newp, newsize); - } - else { /* split remainder */ - remainder = chunk_at_offset(newp, nb); - set_head_size(newp, nb | (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head(remainder, remainder_size | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - /* Mark remainder as inuse so free() won't complain */ - set_inuse_bit_at_offset(remainder, remainder_size); - aproxy_int_free(av, chunk2mem(remainder)); - } - - check_inuse_chunk(av, newp); - return chunk2mem(newp); - } - - /* - Handle mmap cases - */ - - else { -#if HAVE_MMAP - -#if HAVE_MREMAP - INTERNAL_SIZE_T offset = oldp->prev_size; - size_t pagemask = mp_.pagesize - 1; - char *cp; - unsigned long sum; - - /* Note the extra SIZE_SZ overhead */ - newsize = (nb + offset + SIZE_SZ + pagemask) & ~pagemask; - - /* don't need to remap if still within same page */ - if (oldsize == newsize - offset) - return oldmem; - - cp = (char*)mremap((char*)oldp - offset, oldsize + offset, newsize, 1); - - if (cp != MAP_FAILED) { - - newp = (mchunkptr)(cp + offset); - set_head(newp, (newsize - offset)|IS_MMAPPED); - - assert(aligned_OK(chunk2mem(newp))); - assert((newp->prev_size == offset)); - - /* update statistics */ - sum = mp_.mmapped_mem += newsize - oldsize; - if (sum > (unsigned long)(mp_.max_mmapped_mem)) - mp_.max_mmapped_mem = sum; -#ifdef NO_THREADS - sum += main_arena.system_mem; - if (sum > (unsigned long)(mp_.max_total_mem)) - mp_.max_total_mem = sum; -#endif - - return chunk2mem(newp); - } -#endif - - /* Note the extra SIZE_SZ overhead. */ - if ((unsigned long)(oldsize) >= (unsigned long)(nb + SIZE_SZ)) - newmem = oldmem; /* do nothing */ - else { - /* Must alloc, copy, free. */ - newmem = aproxy_int_malloc(av, nb - MALLOC_ALIGN_MASK); - if (newmem != 0) { - MALLOC_COPY(newmem, oldmem, oldsize - 2*SIZE_SZ); - aproxy_int_free(av, oldmem); - } - } - return newmem; - -#else - /* If !HAVE_MMAP, but chunk_is_mmapped, user must have overwritten mem */ - check_malloc_state(av); - MALLOC_FAILURE_ACTION; - return 0; -#endif - } -} - -/* - ------------------------------ memalign ------------------------------ -*/ - -Void_t* -aproxy_int_memalign(mstate av, size_t alignment, size_t bytes) -{ - INTERNAL_SIZE_T nb; /* padded request size */ - char* m; /* memory returned by malloc call */ - mchunkptr p; /* corresponding chunk */ - char* brk; /* alignment point within p */ - mchunkptr newp; /* chunk to return */ - INTERNAL_SIZE_T newsize; /* its size */ - INTERNAL_SIZE_T leadsize; /* leading space before alignment point */ - mchunkptr remainder; /* spare room at end to split off */ - unsigned long remainder_size; /* its size */ - INTERNAL_SIZE_T size; - - /* If need less alignment than we give anyway, just relay to malloc */ - - if (alignment <= MALLOC_ALIGNMENT) return aproxy_int_malloc(av, bytes); - - /* Otherwise, ensure that it is at least a minimum chunk size */ - - if (alignment < MINSIZE) alignment = MINSIZE; - - /* Make sure alignment is power of 2 (in case MINSIZE is not). */ - if ((alignment & (alignment - 1)) != 0) { - size_t a = MALLOC_ALIGNMENT * 2; - while ((unsigned long)a < (unsigned long)alignment) a <<= 1; - alignment = a; - } - - checked_request2size(bytes, nb); - - /* - Strategy: find a spot within that chunk that meets the alignment - request, and then possibly free the leading and trailing space. - */ - - - /* Call malloc with worst case padding to hit alignment. */ - - m = (char*)(aproxy_int_malloc(av, nb + alignment + MINSIZE)); - - if (m == 0) return 0; /* propagate failure */ - - p = mem2chunk(m); - - if ((((unsigned long)(m)) % alignment) != 0) { /* misaligned */ - - /* - Find an aligned spot inside chunk. Since we need to give back - leading space in a chunk of at least MINSIZE, if the first - calculation places us at a spot with less than MINSIZE leader, - we can move to the next aligned spot -- we've allocated enough - total room so that this is always possible. - */ - - brk = (char*)mem2chunk(((unsigned long)(m + alignment - 1)) & - -((signed long) alignment)); - if ((unsigned long)(brk - (char*)(p)) < MINSIZE) - brk += alignment; - - newp = (mchunkptr)brk; - leadsize = brk - (char*)(p); - newsize = chunksize(p) - leadsize; - - /* For mmapped chunks, just adjust offset */ - if (chunk_is_mmapped(p)) { - newp->prev_size = p->prev_size + leadsize; - set_head(newp, newsize|IS_MMAPPED); - return chunk2mem(newp); - } - - /* Otherwise, give back leader, use the rest */ - set_head(newp, newsize | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_inuse_bit_at_offset(newp, newsize); - set_head_size(p, leadsize | (av != &main_arena ? NON_MAIN_ARENA : 0)); - aproxy_int_free(av, chunk2mem(p)); - p = newp; - - assert (newsize >= nb && - (((unsigned long)(chunk2mem(p))) % alignment) == 0); - } - - /* Also give back spare room at the end */ - if (!chunk_is_mmapped(p)) { - size = chunksize(p); - if ((unsigned long)(size) > (unsigned long)(nb + MINSIZE)) { - remainder_size = size - nb; - remainder = chunk_at_offset(p, nb); - set_head(remainder, remainder_size | PREV_INUSE | - (av != &main_arena ? NON_MAIN_ARENA : 0)); - set_head_size(p, nb); - aproxy_int_free(av, chunk2mem(remainder)); - } - } - - check_inuse_chunk(av, p); - return chunk2mem(p); -} - -#if 0 -/* - ------------------------------ calloc ------------------------------ -*/ - -#if __STD_C -Void_t* cALLOc(size_t n_elements, size_t elem_size) -#else -Void_t* cALLOc(n_elements, elem_size) size_t n_elements; size_t elem_size; -#endif -{ - mchunkptr p; - unsigned long clearsize; - unsigned long nclears; - INTERNAL_SIZE_T* d; - - Void_t* mem = mALLOc(n_elements * elem_size); - - if (mem != 0) { - p = mem2chunk(mem); - -#if MMAP_CLEARS - if (!chunk_is_mmapped(p)) /* don't need to clear mmapped space */ -#endif - { - /* - Unroll clear of <= 36 bytes (72 if 8byte sizes) - We know that contents have an odd number of - INTERNAL_SIZE_T-sized words; minimally 3. - */ - - d = (INTERNAL_SIZE_T*)mem; - clearsize = chunksize(p) - SIZE_SZ; - nclears = clearsize / sizeof(INTERNAL_SIZE_T); - assert(nclears >= 3); - - if (nclears > 9) - MALLOC_ZERO(d, clearsize); - - else { - *(d+0) = 0; - *(d+1) = 0; - *(d+2) = 0; - if (nclears > 4) { - *(d+3) = 0; - *(d+4) = 0; - if (nclears > 6) { - *(d+5) = 0; - *(d+6) = 0; - if (nclears > 8) { - *(d+7) = 0; - *(d+8) = 0; - } - } - } - } - } - } - return mem; -} -#endif /* 0 */ - -/* - ------------------------- independent_calloc ------------------------- -*/ - -Void_t** -#if __STD_C -aproxy_int_icalloc(mstate av, size_t n_elements, size_t elem_size, Void_t* chunks[]) -#else -aproxy_int_icalloc(av, n_elements, elem_size, chunks) -mstate av; size_t n_elements; size_t elem_size; Void_t* chunks[]; -#endif -{ - size_t sz = elem_size; /* serves as 1-element array */ - /* opts arg of 3 means all elements are same size, and should be cleared */ - return iALLOc(av, n_elements, &sz, 3, chunks); -} - -/* - ------------------------- independent_comalloc ------------------------- -*/ - -Void_t** -#if __STD_C -aproxy_int_icomalloc(mstate av, size_t n_elements, size_t sizes[], Void_t* chunks[]) -#else -aproxy_int_icomalloc(av, n_elements, sizes, chunks) -mstate av; size_t n_elements; size_t sizes[]; Void_t* chunks[]; -#endif -{ - return iALLOc(av, n_elements, sizes, 0, chunks); -} - - -/* - ------------------------------ ialloc ------------------------------ - ialloc provides common support for independent_X routines, handling all of - the combinations that can result. - - The opts arg has: - bit 0 set if all elements are same size (using sizes[0]) - bit 1 set if elements should be zeroed -*/ - - -static Void_t** -#if __STD_C -iALLOc(mstate av, size_t n_elements, size_t* sizes, int opts, Void_t* chunks[]) -#else -iALLOc(av, n_elements, sizes, opts, chunks) -mstate av; size_t n_elements; size_t* sizes; int opts; Void_t* chunks[]; -#endif -{ - INTERNAL_SIZE_T element_size; /* chunksize of each element, if all same */ - INTERNAL_SIZE_T contents_size; /* total size of elements */ - INTERNAL_SIZE_T array_size; /* request size of pointer array */ - Void_t* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - INTERNAL_SIZE_T remainder_size; /* remaining bytes while splitting */ - Void_t** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - int mmx; /* to disable mmap */ - INTERNAL_SIZE_T size; - INTERNAL_SIZE_T size_flags; - size_t i; - - /* Ensure initialization/consolidation */ - if (have_fastchunks(av)) malloc_consolidate(av); - - /* compute array length, if needed */ - if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ - marray = chunks; - array_size = 0; - } - else { - /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (Void_t**) aproxy_int_malloc(av, 0); - marray = 0; - array_size = request2size(n_elements * (sizeof(Void_t*))); - } - - /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ - element_size = request2size(*sizes); - contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ - element_size = 0; - contents_size = 0; - for (i = 0; i != n_elements; ++i) - contents_size += request2size(sizes[i]); - } - - /* subtract out alignment bytes from total to minimize overallocation */ - size = contents_size + array_size - MALLOC_ALIGN_MASK; - - /* - Allocate the aggregate chunk. - But first disable mmap so malloc won't use it, since - we would not be able to later free/realloc space internal - to a segregated mmap region. - */ - mmx = mp_.n_mmaps_max; /* disable mmap */ - mp_.n_mmaps_max = 0; - mem = aproxy_int_malloc(av, size); - mp_.n_mmaps_max = mmx; /* reset mmap */ - if (mem == 0) - return 0; - - p = mem2chunk(mem); - assert(!chunk_is_mmapped(p)); - remainder_size = chunksize(p); - - if (opts & 0x2) { /* optionally clear the elements */ - MALLOC_ZERO(mem, remainder_size - SIZE_SZ - array_size); - } - - size_flags = PREV_INUSE | (av != &main_arena ? NON_MAIN_ARENA : 0); - - /* If not provided, allocate the pointer array as final part of chunk */ - if (marray == 0) { - array_chunk = chunk_at_offset(p, contents_size); - marray = (Void_t**) (chunk2mem(array_chunk)); - set_head(array_chunk, (remainder_size - contents_size) | size_flags); - remainder_size = contents_size; - } - - /* split out elements */ - for (i = 0; ; ++i) { - marray[i] = chunk2mem(p); - if (i != n_elements-1) { - if (element_size != 0) - size = element_size; - else - size = request2size(sizes[i]); - remainder_size -= size; - set_head(p, size | size_flags); - p = chunk_at_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ - set_head(p, remainder_size | size_flags); - break; - } - } - -#if MALLOC_DEBUG - if (marray != chunks) { - /* final element must have exactly exhausted chunk */ - if (element_size != 0) - assert(remainder_size == element_size); - else - assert(remainder_size == request2size(sizes[i])); - check_inuse_chunk(av, mem2chunk(marray)); - } - - for (i = 0; i != n_elements; ++i) - check_inuse_chunk(av, mem2chunk(marray[i])); -#endif - - return marray; -} - - -/* - ------------------------------ valloc ------------------------------ -*/ - -Void_t* -#if __STD_C -aproxy_int_valloc(mstate av, size_t bytes) -#else -aproxy_int_valloc(av, bytes) mstate av; size_t bytes; -#endif -{ - /* Ensure initialization/consolidation */ - if (have_fastchunks(av)) malloc_consolidate(av); - return aproxy_int_memalign(av, mp_.pagesize, bytes); -} - -/* - ------------------------------ pvalloc ------------------------------ -*/ - - -Void_t* -#if __STD_C -aproxy_int_pvalloc(mstate av, size_t bytes) -#else -aproxy_int_pvalloc(av, bytes) mstate av, size_t bytes; -#endif -{ - size_t pagesz; - - /* Ensure initialization/consolidation */ - if (have_fastchunks(av)) malloc_consolidate(av); - pagesz = mp_.pagesize; - return aproxy_int_memalign(av, pagesz, (bytes + pagesz - 1) & ~(pagesz - 1)); -} - - -/* - ------------------------------ malloc_trim ------------------------------ -*/ - -#if __STD_C -int mTRIm(size_t pad) -#else -int mTRIm(pad) size_t pad; -#endif -{ - mstate av = &main_arena; /* already locked */ - - /* Ensure initialization/consolidation */ - malloc_consolidate(av); - -#ifndef MORECORE_CANNOT_TRIM - return sYSTRIm(pad, av); -#else - return 0; -#endif -} - - -/* - ------------------------- malloc_usable_size ------------------------- -*/ - -#if __STD_C -size_t mUSABLe(Void_t* mem) -#else -size_t mUSABLe(mem) Void_t* mem; -#endif -{ - mchunkptr p; - if (mem != 0) { - p = mem2chunk(mem); - if (chunk_is_mmapped(p)) - return chunksize(p) - 2*SIZE_SZ; - else if (inuse(p)) - return chunksize(p) - SIZE_SZ; - } - return 0; -} - -/* - ------------------------------ mallinfo ------------------------------ -*/ - -struct mallinfo mALLINFo(mstate av) -{ - struct mallinfo mi; - size_t i; - mbinptr b; - mchunkptr p; - INTERNAL_SIZE_T avail; - INTERNAL_SIZE_T fastavail; - int nblocks; - int nfastblocks; - - /* Ensure initialization */ - if (av->top == 0) malloc_consolidate(av); - - check_malloc_state(av); - - /* Account for top */ - avail = chunksize(av->top); - nblocks = 1; /* top always exists */ - - /* traverse fastbins */ - nfastblocks = 0; - fastavail = 0; - - for (i = 0; i < NFASTBINS; ++i) { - for (p = av->fastbins[i]; p != 0; p = p->fd) { - ++nfastblocks; - fastavail += chunksize(p); - } - } - - avail += fastavail; - - /* traverse regular bins */ - for (i = 1; i < NBINS; ++i) { - b = bin_at(av, i); - for (p = last(b); p != b; p = p->bk) { - ++nblocks; - avail += chunksize(p); - } - } - - mi.smblks = nfastblocks; - mi.ordblks = nblocks; - mi.fordblks = avail; - mi.uordblks = av->system_mem - avail; - mi.arena = av->system_mem; - mi.hblks = mp_.n_mmaps; - mi.hblkhd = mp_.mmapped_mem; - mi.fsmblks = fastavail; - mi.keepcost = chunksize(av->top); - mi.usmblks = mp_.max_total_mem; - return mi; -} - -/* - ------------------------------ malloc_stats ------------------------------ -*/ - -void mSTATs() -{ - int i; - mstate ar_ptr; - struct mallinfo mi; - unsigned int in_use_b = mp_.mmapped_mem, system_b = in_use_b; -#if THREAD_STATS - long stat_lock_direct = 0, stat_lock_loop = 0, stat_lock_wait = 0; -#endif - - if(__aproxy_initialized < 0) - aproxy_ptmalloc_init (); -#ifdef _LIBC - _IO_flockfile (stderr); - int old_flags2 = ((_IO_FILE *) stderr)->_flags2; - ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; -#endif - for (i=0, ar_ptr = &main_arena;; i++) { - (void)mutex_lock(&ar_ptr->mutex); - mi = mALLINFo(ar_ptr); - fprintf(stderr, "Arena %d:\n", i); - fprintf(stderr, "system bytes = %10u\n", (unsigned int)mi.arena); - fprintf(stderr, "in use bytes = %10u\n", (unsigned int)mi.uordblks); -#if MALLOC_DEBUG > 1 - if (i > 0) - dump_heap(heap_for_ptr(top(ar_ptr))); -#endif - system_b += mi.arena; - in_use_b += mi.uordblks; -#if THREAD_STATS - stat_lock_direct += ar_ptr->stat_lock_direct; - stat_lock_loop += ar_ptr->stat_lock_loop; - stat_lock_wait += ar_ptr->stat_lock_wait; -#endif - (void)mutex_unlock(&ar_ptr->mutex); - ar_ptr = ar_ptr->next; - if(ar_ptr == &main_arena) break; - } -#if HAVE_MMAP - fprintf(stderr, "Total (incl. mmap):\n"); -#else - fprintf(stderr, "Total:\n"); -#endif - fprintf(stderr, "system bytes = %10u\n", system_b); - fprintf(stderr, "in use bytes = %10u\n", in_use_b); -#ifdef NO_THREADS - fprintf(stderr, "max system bytes = %10u\n", (unsigned int)mp_.max_total_mem); -#endif -#if HAVE_MMAP - fprintf(stderr, "max mmap regions = %10u\n", (unsigned int)mp_.max_n_mmaps); - fprintf(stderr, "max mmap bytes = %10lu\n", - (unsigned long)mp_.max_mmapped_mem); -#endif -#if THREAD_STATS - fprintf(stderr, "heaps created = %10d\n", stat_n_heaps); - fprintf(stderr, "locked directly = %10ld\n", stat_lock_direct); - fprintf(stderr, "locked in loop = %10ld\n", stat_lock_loop); - fprintf(stderr, "locked waiting = %10ld\n", stat_lock_wait); - fprintf(stderr, "locked total = %10ld\n", - stat_lock_direct + stat_lock_loop + stat_lock_wait); -#endif -#ifdef _LIBC - ((_IO_FILE *) stderr)->_flags2 |= old_flags2; - _IO_funlockfile (stderr); -#endif -} - - -/* - ------------------------------ mallopt ------------------------------ -*/ - -#if __STD_C -int mALLOPt(int param_number, int value) -#else -int mALLOPt(param_number, value) int param_number; int value; -#endif -{ - mstate av = &main_arena; - int res = 1; - - if(__aproxy_initialized < 0) - aproxy_ptmalloc_init (); - (void)mutex_lock(&av->mutex); - /* Ensure initialization/consolidation */ - malloc_consolidate(av); - - switch(param_number) { - case M_MXFAST: - if (value >= 0 && value <= MAX_FAST_SIZE) { - set_max_fast(av, value); - } - else - res = 0; - break; - - case M_TRIM_THRESHOLD: - mp_.trim_threshold = value; - break; - - case M_TOP_PAD: - mp_.top_pad = value; - break; - - case M_MMAP_THRESHOLD: -#if USE_ARENAS - /* Forbid setting the threshold too high. */ - if((unsigned long)value > HEAP_MAX_SIZE/2) - res = 0; - else -#endif - mp_.mmap_threshold = value; - break; - - case M_MMAP_MAX: -#if !HAVE_MMAP - if (value != 0) - res = 0; - else -#endif - mp_.n_mmaps_max = value; - break; - - case M_CHECK_ACTION: - check_action = value; - break; - } - (void)mutex_unlock(&av->mutex); - return res; -} - - -/* - -------------------- Alternative MORECORE functions -------------------- -*/ - - -/* - General Requirements for MORECORE. - - The MORECORE function must have the following properties: - - If MORECORE_CONTIGUOUS is false: - - * MORECORE must allocate in multiples of pagesize. It will - only be called with arguments that are multiples of pagesize. - - * MORECORE(0) must return an address that is at least - MALLOC_ALIGNMENT aligned. (Page-aligning always suffices.) - - else (i.e. If MORECORE_CONTIGUOUS is true): - - * Consecutive calls to MORECORE with positive arguments - return increasing addresses, indicating that space has been - contiguously extended. - - * MORECORE need not allocate in multiples of pagesize. - Calls to MORECORE need not have args of multiples of pagesize. - - * MORECORE need not page-align. - - In either case: - - * MORECORE may allocate more memory than requested. (Or even less, - but this will generally result in a malloc failure.) - - * MORECORE must not allocate memory when given argument zero, but - instead return one past the end address of memory from previous - nonzero call. This malloc does NOT call MORECORE(0) - until at least one call with positive arguments is made, so - the initial value returned is not important. - - * Even though consecutive calls to MORECORE need not return contiguous - addresses, it must be OK for malloc'ed chunks to span multiple - regions in those cases where they do happen to be contiguous. - - * MORECORE need not handle negative arguments -- it may instead - just return MORECORE_FAILURE when given negative arguments. - Negative arguments are always multiples of pagesize. MORECORE - must not misinterpret negative args as large positive unsigned - args. You can suppress all such calls from even occurring by defining - MORECORE_CANNOT_TRIM, - - There is some variation across systems about the type of the - argument to sbrk/MORECORE. If size_t is unsigned, then it cannot - actually be size_t, because sbrk supports negative args, so it is - normally the signed type of the same width as size_t (sometimes - declared as "intptr_t", and sometimes "ptrdiff_t"). It doesn't much - matter though. Internally, we use "long" as arguments, which should - work across all reasonable possibilities. - - Additionally, if MORECORE ever returns failure for a positive - request, and HAVE_MMAP is true, then mmap is used as a noncontiguous - system allocator. This is a useful backup strategy for systems with - holes in address spaces -- in this case sbrk cannot contiguously - expand the heap, but mmap may be able to map noncontiguous space. - - If you'd like mmap to ALWAYS be used, you can define MORECORE to be - a function that always returns MORECORE_FAILURE. - - If you are using this malloc with something other than sbrk (or its - emulation) to supply memory regions, you probably want to set - MORECORE_CONTIGUOUS as false. As an example, here is a custom - allocator kindly contributed for pre-OSX macOS. It uses virtually - but not necessarily physically contiguous non-paged memory (locked - in, present and won't get swapped out). You can use it by - uncommenting this section, adding some #includes, and setting up the - appropriate defines above: - - #define MORECORE osMoreCore - #define MORECORE_CONTIGUOUS 0 - - There is also a shutdown routine that should somehow be called for - cleanup upon program exit. - - #define MAX_POOL_ENTRIES 100 - #define MINIMUM_MORECORE_SIZE (64 * 1024) - static int next_os_pool; - void *our_os_pools[MAX_POOL_ENTRIES]; - - void *osMoreCore(int size) - { - void *ptr = 0; - static void *sbrk_top = 0; - - if (size > 0) - { - if (size < MINIMUM_MORECORE_SIZE) - size = MINIMUM_MORECORE_SIZE; - if (CurrentExecutionLevel() == kTaskLevel) - ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); - if (ptr == 0) - { - return (void *) MORECORE_FAILURE; - } - // save ptrs so they can be freed during cleanup - our_os_pools[next_os_pool] = ptr; - next_os_pool++; - ptr = (void *) ((((unsigned long) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); - sbrk_top = (char *) ptr + size; - return ptr; - } - else if (size < 0) - { - // we don't currently support shrink behavior - return (void *) MORECORE_FAILURE; - } - else - { - return sbrk_top; - } - } - - // cleanup any allocated memory pools - // called as last thing before shutting down driver - - void osCleanupMem(void) - { - void **ptr; - - for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) - if (*ptr) - { - PoolDeallocate(*ptr); - *ptr = 0; - } - } - -*/ - - -/* Helper code. */ - -static void -malloc_printerr(int action, const char *str, void *ptr) -{ - fprintf (stderr, "*** glibc detected *** %s: 0x%x ***\n", - str, ptr); - abort (); -} - -#ifdef _LIBC -# include - -/* We need a wrapper function for one of the additions of POSIX. */ -int -__posix_memalign (void **memptr, size_t alignment, size_t size) -{ - void *mem; - __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t, - __const __malloc_ptr_t)) = - __aproxy_memalign_hook; - - /* Test whether the SIZE argument is valid. It must be a power of - two multiple of sizeof (void *). */ - if (alignment % sizeof (void *) != 0 - || !powerof2 (alignment / sizeof (void *)) != 0 - || alignment == 0) - return EINVAL; - - /* Call the hook here, so that caller is posix_memalign's caller - and not posix_memalign itself. */ - if (hook != NULL) - mem = (*hook)(alignment, size, RETURN_ADDRESS (0)); - else - mem = public_mEMALIGn (alignment, size); - - if (mem != NULL) { - *memptr = mem; - return 0; - } - - return ENOMEM; -} -weak_alias (__posix_memalign, posix_memalign) - -strong_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc) -strong_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree) -strong_alias (__libc_free, __free) strong_alias (__libc_free, free) -strong_alias (__libc_malloc, __malloc) strong_alias (__libc_malloc, malloc) -strong_alias (__libc_memalign, __memalign) -weak_alias (__libc_memalign, memalign) -strong_alias (__libc_realloc, __realloc) strong_alias (__libc_realloc, realloc) -strong_alias (__libc_valloc, __valloc) weak_alias (__libc_valloc, valloc) -strong_alias (__libc_pvalloc, __pvalloc) weak_alias (__libc_pvalloc, pvalloc) -strong_alias (__libc_mallinfo, __mallinfo) -weak_alias (__libc_mallinfo, mallinfo) -strong_alias (__libc_mallopt, __mallopt) weak_alias (__libc_mallopt, mallopt) - -weak_alias (__malloc_stats, malloc_stats) -weak_alias (__malloc_usable_size, malloc_usable_size) -weak_alias (__malloc_trim, malloc_trim) -weak_alias (__aproxy_get_state, aproxy_get_state) -weak_alias (__aproxy_set_state, aproxy_set_state) - -#endif /* _LIBC */ - -/* ------------------------------------------------------------ -History: - -[see ftp://g.oswego.edu/pub/misc/malloc.c for the history of dlmalloc] - -*/ -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_strdup.c.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_strdup.c.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/aproxy_strdup.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/aproxy_strdup.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** A version of the strdup function that proxy allocation -** -** Made by jfv for the ERESI project -** -** -** $Id: aproxy_strdup.c,v 1.5 2007-07-31 03:28:46 may Exp $ -** -*/ -#include "aproxy.h" -#include - -char *aproxy_strdup(const char *s) -{ - size_t size; - void *dup; - - if (!s) - return (NULL); - size = strlen((char *) s); - dup = (void *) aproxy_malloc(size + 1); - if (!dup) - return (NULL); - memcpy(dup, (char *) s, size + 1); - return ((char *) dup); -} diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/elfsh_hooks.c.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/elfsh_hooks.c.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/elfsh_hooks.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/elfsh_hooks.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,632 +0,0 @@ -/* Malloc implementation for multiple threads without lock contention. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Wolfram Gloger , 2001. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation; either version 2.1 of the - License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* $Id: elfsh_hooks.c,v 1.2 2007-02-18 17:01:03 may Exp $ */ - -/* What to do if the standard debugging hooks are in place and a - corrupt pointer is detected: do nothing (0), print an error message - (1), or call abort() (2). */ - -/* Hooks for debugging versions. The initial hooks just call the - initialization routine, then do the normal work. */ - -static Void_t* -#if __STD_C -malloc_hook_ini(size_t sz, const __malloc_ptr_t caller) -#else -malloc_hook_ini(sz, caller) - size_t sz; const __malloc_ptr_t caller; -#endif -{ - __elfsh_malloc_hook = NULL; - elfsh_ptmalloc_init(); - return public_mALLOc(sz); -} - -static Void_t* -#if __STD_C -realloc_hook_ini(Void_t* ptr, size_t sz, const __malloc_ptr_t caller) -#else -realloc_hook_ini(ptr, sz, caller) - Void_t* ptr; size_t sz; const __malloc_ptr_t caller; -#endif -{ - __elfsh_malloc_hook = NULL; - __elfsh_realloc_hook = NULL; - elfsh_ptmalloc_init(); - return public_rEALLOc(ptr, sz); -} - -static Void_t* -#if __STD_C -memalign_hook_ini(size_t alignment, size_t sz, const __malloc_ptr_t caller) -#else -memalign_hook_ini(alignment, sz, caller) - size_t alignment; size_t sz; const __malloc_ptr_t caller; -#endif -{ - __elfsh_memalign_hook = NULL; - elfsh_ptmalloc_init(); - return public_mEMALIGn(alignment, sz); -} - -/* Whether we are using malloc checking. */ -static int using_malloc_checking; - -/* A flag that is set by elfsh_malloc_set_state, to signal that malloc checking - must not be enabled on the request from the user (via the MALLOC_CHECK_ - environment variable). It is reset by __elfsh_malloc_check_init to tell - elfsh_malloc_set_state that the user has requested malloc checking. - - The purpose of this flag is to make sure that malloc checking is not - enabled when the heap to be restored was constructed without malloc - checking, and thus does not contain the required magic bytes. - Otherwise the heap would be corrupted by calls to free and realloc. If - it turns out that the heap was created with malloc checking and the - user has requested it elfsh_malloc_set_state just calls __elfsh_malloc_check_init - again to enable it. On the other hand, reusing such a heap without - further malloc checking is safe. */ -static int disallow_malloc_check; - -/* Activate a standard set of debugging hooks. */ -void -__elfsh_malloc_check_init() -{ - if (disallow_malloc_check) { - disallow_malloc_check = 0; - return; - } - using_malloc_checking = 1; - __elfsh_malloc_hook = malloc_check; - __elfsh_free_hook = free_check; - __elfsh_realloc_hook = realloc_check; - __elfsh_memalign_hook = memalign_check; - if(check_action & 1) - malloc_printerr (5, "malloc: using debugging hooks", NULL); -} - -/* A simple, standard set of debugging hooks. Overhead is `only' one - byte per chunk; still this will catch most cases of double frees or - overruns. The goal here is to avoid obscure crashes due to invalid - usage, unlike in the MALLOC_DEBUG code. */ - -#define MAGICBYTE(p) ( ( ((size_t)p >> 3) ^ ((size_t)p >> 11)) & 0xFF ) - -/* Instrument a chunk with overrun detector byte(s) and convert it - into a user pointer with requested size sz. */ - -static Void_t* -internal_function -#if __STD_C -mem2mem_check(Void_t *ptr, size_t sz) -#else -mem2mem_check(ptr, sz) Void_t *ptr; size_t sz; -#endif -{ - mchunkptr p; - unsigned char* m_ptr = (unsigned char*)BOUNDED_N(ptr, sz); - size_t i; - - if (!ptr) - return ptr; - p = mem2chunk(ptr); - for(i = chunksize(p) - (chunk_is_mmapped(p) ? 2*SIZE_SZ+1 : SIZE_SZ+1); - i > sz; - i -= 0xFF) { - if(i-sz < 0x100) { - m_ptr[i] = (unsigned char)(i-sz); - break; - } - m_ptr[i] = 0xFF; - } - m_ptr[sz] = MAGICBYTE(p); - return (Void_t*)m_ptr; -} - -/* Convert a pointer to be free()d or realloc()ed to a valid chunk - pointer. If the provided pointer is not valid, return NULL. */ - -static mchunkptr -internal_function -#if __STD_C -mem2chunk_check(Void_t* mem) -#else -mem2chunk_check(mem) Void_t* mem; -#endif -{ - mchunkptr p; - INTERNAL_SIZE_T sz, c; - unsigned char magic; - - if(!aligned_OK(mem)) return NULL; - p = mem2chunk(mem); - if (!chunk_is_mmapped(p)) { - /* Must be a chunk in conventional heap memory. */ - int contig = contiguous(&main_arena); - sz = chunksize(p); - if((contig && - ((char*)p=(mp_.sbrk_base+main_arena.system_mem) )) || - szprev_size&MALLOC_ALIGN_MASK || - (contig && (char*)prev_chunk(p)size & PREV_INUSE) || - ( (((unsigned long)p - p->prev_size) & page_mask) != 0 ) || - ( (sz = chunksize(p)), ((p->prev_size + sz) & page_mask) != 0 ) ) - return NULL; - magic = MAGICBYTE(p); - for(sz -= 1; (c = ((unsigned char*)p)[sz]) != magic; sz -= c) { - if(c<=0 || sz<(c+2*SIZE_SZ)) return NULL; - } - ((unsigned char*)p)[sz] ^= 0xFF; - } - return p; -} - -/* Check for corruption of the top chunk, and try to recover if - necessary. */ - -static int -internal_function -#if __STD_C -top_check(void) -#else -top_check() -#endif -{ - mchunkptr t = top(&main_arena); - char* brk, * new_brk; - INTERNAL_SIZE_T front_misalign, sbrk_size; - unsigned long pagesz = malloc_getpagesize; - - if (t == initial_top(&main_arena) || - (!chunk_is_mmapped(t) && - chunksize(t)>=MINSIZE && - prev_inuse(t) && - (!contiguous(&main_arena) || - (char*)t + chunksize(t) == mp_.sbrk_base + main_arena.system_mem))) - return 0; - - malloc_printerr (check_action, "malloc: top chunk is corrupt", t); - - /* Try to set up a new top chunk. */ - brk = (char *) (MORECORE(0)); - front_misalign = (unsigned long)chunk2mem(brk) & MALLOC_ALIGN_MASK; - if (front_misalign > 0) - front_misalign = MALLOC_ALIGNMENT - front_misalign; - sbrk_size = front_misalign + mp_.top_pad + MINSIZE; - sbrk_size += pagesz - ((unsigned long)(brk + sbrk_size) & (pagesz - 1)); - new_brk = (char*)(MORECORE (sbrk_size)); - if (new_brk == (char*)(MORECORE_FAILURE)) return -1; - /* Call the `morecore' hook if necessary. */ - if (__elfsh_after_morecore_hook) - (*__elfsh_after_morecore_hook) (); - main_arena.system_mem = (new_brk - mp_.sbrk_base) + sbrk_size; - - top(&main_arena) = (mchunkptr)(brk + front_misalign); - set_head(top(&main_arena), (sbrk_size - front_misalign) | PREV_INUSE); - - return 0; -} - -static Void_t* -#if __STD_C -malloc_check(size_t sz, const Void_t *caller) -#else -malloc_check(sz, caller) size_t sz; const Void_t *caller; -#endif -{ - Void_t *victim; - - (void)mutex_lock(&main_arena.mutex); - victim = (top_check() >= 0) ? elfsh_int_malloc(&main_arena, sz+1) : NULL; - (void)mutex_unlock(&main_arena.mutex); - return mem2mem_check(victim, sz); -} - -static void -#if __STD_C -free_check(Void_t* mem, const Void_t *caller) -#else -free_check(mem, caller) Void_t* mem; const Void_t *caller; -#endif -{ - mchunkptr p; - - if(!mem) return; - (void)mutex_lock(&main_arena.mutex); - p = mem2chunk_check(mem); - if(!p) { - (void)mutex_unlock(&main_arena.mutex); - - malloc_printerr(check_action, "free(): invalid pointer", mem); - return; - } -#if HAVE_MMAP - if (chunk_is_mmapped(p)) { - (void)mutex_unlock(&main_arena.mutex); - munmap_chunk(p); - return; - } -#endif -#if 0 /* Erase freed memory. */ - memset(mem, 0, chunksize(p) - (SIZE_SZ+1)); -#endif - elfsh_int_free(&main_arena, mem); - (void)mutex_unlock(&main_arena.mutex); -} - -static Void_t* -#if __STD_C -realloc_check(Void_t* oldmem, size_t bytes, const Void_t *caller) -#else -realloc_check(oldmem, bytes, caller) - Void_t* oldmem; size_t bytes; const Void_t *caller; -#endif -{ - mchunkptr oldp; - INTERNAL_SIZE_T nb, oldsize; - Void_t* newmem = 0; - - if (oldmem == 0) return malloc_check(bytes, NULL); - (void)mutex_lock(&main_arena.mutex); - oldp = mem2chunk_check(oldmem); - (void)mutex_unlock(&main_arena.mutex); - if(!oldp) { - malloc_printerr(check_action, "realloc(): invalid pointer", oldmem); - return malloc_check(bytes, NULL); - } - oldsize = chunksize(oldp); - - checked_request2size(bytes+1, nb); - (void)mutex_lock(&main_arena.mutex); - -#if HAVE_MMAP - if (chunk_is_mmapped(oldp)) { -#if HAVE_MREMAP - mchunkptr newp = mremap_chunk(oldp, nb); - if(newp) - newmem = chunk2mem(newp); - else -#endif - { - /* Note the extra SIZE_SZ overhead. */ - if(oldsize - SIZE_SZ >= nb) - newmem = oldmem; /* do nothing */ - else { - /* Must alloc, copy, free. */ - if (top_check() >= 0) - newmem = elfsh_int_malloc(&main_arena, bytes+1); - if (newmem) { - MALLOC_COPY(BOUNDED_N(newmem, bytes+1), oldmem, oldsize - 2*SIZE_SZ); - munmap_chunk(oldp); - } - } - } - } else { -#endif /* HAVE_MMAP */ - if (top_check() >= 0) - newmem = elfsh_int_realloc(&main_arena, oldmem, bytes+1); -#if 0 /* Erase freed memory. */ - if(newmem) - newp = mem2chunk(newmem); - nb = chunksize(newp); - if(oldp=chunk_at_offset(newp, nb)) { - memset((char*)oldmem + 2*sizeof(mbinptr), 0, - oldsize - (2*sizeof(mbinptr)+2*SIZE_SZ+1)); - } else if(nb > oldsize+SIZE_SZ) { - memset((char*)BOUNDED_N(chunk2mem(newp), bytes) + oldsize, - 0, nb - (oldsize+SIZE_SZ)); - } -#endif -#if HAVE_MMAP - } -#endif - (void)mutex_unlock(&main_arena.mutex); - - return mem2mem_check(newmem, bytes); -} - -static Void_t* -#if __STD_C -memalign_check(size_t alignment, size_t bytes, const Void_t *caller) -#else -memalign_check(alignment, bytes, caller) - size_t alignment; size_t bytes; const Void_t *caller; -#endif -{ - INTERNAL_SIZE_T nb; - Void_t* mem; - - if (alignment <= MALLOC_ALIGNMENT) return malloc_check(bytes, NULL); - if (alignment < MINSIZE) alignment = MINSIZE; - - checked_request2size(bytes+1, nb); - (void)mutex_lock(&main_arena.mutex); - mem = (top_check() >= 0) ? elfsh_int_memalign(&main_arena, alignment, bytes+1) : - NULL; - (void)mutex_unlock(&main_arena.mutex); - return mem2mem_check(mem, bytes); -} - -#ifndef NO_THREADS - -# ifdef _LIBC -# if USE___THREAD || (defined USE_TLS && !defined SHARED) - /* These routines are never needed in this configuration. */ -# define NO_STARTER -# endif -# endif - -# ifdef NO_STARTER -# undef NO_STARTER -# else - -/* The following hooks are used when the global initialization in - elfsh_ptmalloc_init() hasn't completed yet. */ - -static Void_t* -#if __STD_C -malloc_starter(size_t sz, const Void_t *caller) -#else -malloc_starter(sz, caller) size_t sz; const Void_t *caller; -#endif -{ - Void_t* victim; - - victim = elfsh_int_malloc(&main_arena, sz); - - return victim ? BOUNDED_N(victim, sz) : 0; -} - -static Void_t* -#if __STD_C -memalign_starter(size_t align, size_t sz, const Void_t *caller) -#else -memalign_starter(align, sz, caller) size_t align, sz; const Void_t *caller; -#endif -{ - Void_t* victim; - - victim = elfsh_int_memalign(&main_arena, align, sz); - - return victim ? BOUNDED_N(victim, sz) : 0; -} - -static void -#if __STD_C -free_starter(Void_t* mem, const Void_t *caller) -#else -free_starter(mem, caller) Void_t* mem; const Void_t *caller; -#endif -{ - mchunkptr p; - - if(!mem) return; - p = mem2chunk(mem); -#if HAVE_MMAP - if (chunk_is_mmapped(p)) { - munmap_chunk(p); - return; - } -#endif - elfsh_int_free(&main_arena, mem); -} - -# endif /* !defiend NO_STARTER */ -#endif /* NO_THREADS */ - - -/* Get/set state: elfsh_malloc_get_state() records the current state of all - malloc variables (_except_ for the actual heap contents and `hook' - function pointers) in a system dependent, opaque data structure. - This data structure is dynamically allocated and can be free()d - after use. elfsh_malloc_set_state() restores the state of all malloc - variables to the previously obtained state. This is especially - useful when using this malloc as part of a shared library, and when - the heap contents are saved/restored via some other method. The - primary example for this is GNU Emacs with its `dumping' procedure. - `Hook' function pointers are never saved or restored by these - functions, with two exceptions: If malloc checking was in use when - elfsh_malloc_get_state() was called, then elfsh_malloc_set_state() calls - __elfsh_malloc_check_init() if possible; if malloc checking was not in - use in the recorded state but the user requested malloc checking, - then the hooks are reset to 0. */ - -#define MALLOC_STATE_MAGIC 0x444c4541l -#define MALLOC_STATE_VERSION (0*0x100l + 2l) /* major*0x100 + minor */ - -struct malloc_save_state { - long magic; - long version; - mbinptr av[NBINS * 2 + 2]; - char* sbrk_base; - int sbrked_mem_bytes; - unsigned long trim_threshold; - unsigned long top_pad; - unsigned int n_mmaps_max; - unsigned long mmap_threshold; - int check_action; - unsigned long max_sbrked_mem; - unsigned long max_total_mem; - unsigned int n_mmaps; - unsigned int max_n_mmaps; - unsigned long mmapped_mem; - unsigned long max_mmapped_mem; - int using_malloc_checking; -}; - -Void_t* -public_gET_STATe(void) -{ - struct malloc_save_state* ms; - int i; - mbinptr b; - - ms = (struct malloc_save_state*)public_mALLOc(sizeof(*ms)); - if (!ms) - return 0; - (void)mutex_lock(&main_arena.mutex); - malloc_consolidate(&main_arena); - ms->magic = MALLOC_STATE_MAGIC; - ms->version = MALLOC_STATE_VERSION; - ms->av[0] = 0; - ms->av[1] = 0; /* used to be binblocks, now no longer used */ - ms->av[2] = top(&main_arena); - ms->av[3] = 0; /* used to be undefined */ - for(i=1; iav[2*i+2] = ms->av[2*i+3] = 0; /* empty bin */ - else { - ms->av[2*i+2] = first(b); - ms->av[2*i+3] = last(b); - } - } - ms->sbrk_base = mp_.sbrk_base; - ms->sbrked_mem_bytes = main_arena.system_mem; - ms->trim_threshold = mp_.trim_threshold; - ms->top_pad = mp_.top_pad; - ms->n_mmaps_max = mp_.n_mmaps_max; - ms->mmap_threshold = mp_.mmap_threshold; - ms->check_action = check_action; - ms->max_sbrked_mem = main_arena.max_system_mem; -#ifdef NO_THREADS - ms->max_total_mem = mp_.max_total_mem; -#else - ms->max_total_mem = 0; -#endif - ms->n_mmaps = mp_.n_mmaps; - ms->max_n_mmaps = mp_.max_n_mmaps; - ms->mmapped_mem = mp_.mmapped_mem; - ms->max_mmapped_mem = mp_.max_mmapped_mem; - ms->using_malloc_checking = using_malloc_checking; - (void)mutex_unlock(&main_arena.mutex); - return (Void_t*)ms; -} - -int -public_sET_STATe(Void_t* msptr) -{ - struct malloc_save_state* ms = (struct malloc_save_state*)msptr; - size_t i; - mbinptr b; - - disallow_malloc_check = 1; - elfsh_ptmalloc_init(); - if(ms->magic != MALLOC_STATE_MAGIC) return -1; - /* Must fail if the major version is too high. */ - if((ms->version & ~0xffl) > (MALLOC_STATE_VERSION & ~0xffl)) return -2; - (void)mutex_lock(&main_arena.mutex); - /* There are no fastchunks. */ - clear_fastchunks(&main_arena); - set_max_fast(&main_arena, DEFAULT_MXFAST); - for (i=0; iav[2]; - main_arena.last_remainder = 0; - for(i=1; iav[2*i+2] == 0) { - assert(ms->av[2*i+3] == 0); - first(b) = last(b) = b; - } else { - if(iav[2*i+2]))==i && - largebin_index(chunksize(ms->av[2*i+3]))==i)) { - first(b) = ms->av[2*i+2]; - last(b) = ms->av[2*i+3]; - /* Make sure the links to the bins within the heap are correct. */ - first(b)->bk = b; - last(b)->fd = b; - /* Set bit in binblocks. */ - mark_bin(&main_arena, i); - } else { - /* Oops, index computation from chunksize must have changed. - Link the whole list into unsorted_chunks. */ - first(b) = last(b) = b; - b = unsorted_chunks(&main_arena); - ms->av[2*i+2]->bk = b; - ms->av[2*i+3]->fd = b->fd; - b->fd->bk = ms->av[2*i+3]; - b->fd = ms->av[2*i+2]; - } - } - } - mp_.sbrk_base = ms->sbrk_base; - main_arena.system_mem = ms->sbrked_mem_bytes; - mp_.trim_threshold = ms->trim_threshold; - mp_.top_pad = ms->top_pad; - mp_.n_mmaps_max = ms->n_mmaps_max; - mp_.mmap_threshold = ms->mmap_threshold; - check_action = ms->check_action; - main_arena.max_system_mem = ms->max_sbrked_mem; -#ifdef NO_THREADS - mp_.max_total_mem = ms->max_total_mem; -#endif - mp_.n_mmaps = ms->n_mmaps; - mp_.max_n_mmaps = ms->max_n_mmaps; - mp_.mmapped_mem = ms->mmapped_mem; - mp_.max_mmapped_mem = ms->max_mmapped_mem; - /* add version-dependent code here */ - if (ms->version >= 1) { - /* Check whether it is safe to enable malloc checking, or whether - it is necessary to disable it. */ - if (ms->using_malloc_checking && !using_malloc_checking && - !disallow_malloc_check) - __elfsh_malloc_check_init (); - else if (!ms->using_malloc_checking && using_malloc_checking) { - __elfsh_malloc_hook = 0; - __elfsh_free_hook = 0; - __elfsh_realloc_hook = 0; - __elfsh_memalign_hook = 0; - using_malloc_checking = 0; - } - } - check_malloc_state(&main_arena); - - (void)mutex_unlock(&main_arena.mutex); - return 0; -} - -/* - * Local variables: - * c-basic-offset: 2 - * End: - */ diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -# -# Makefile for libmalloc-e2dbg -# -# The ELF shell project -# -# Started Tue Oct 04 15:13:19 2005 mm -# - -include ../config.h - -CC ?= gcc -LD ?= ld -SRC = aproxy_malloc.c aproxy_strdup.c -OBJ = $(SRC:.c=.o) -CFLAGS += -D__STD_C -DMALLOC_DEBUG -DUSE_ARENAS -DSHARED -DUSE_TLS \ - -fPIC -g3 -Iinclude -I../libelfsh/include/ -NAME = allocproxy - -all : heap - -lib$(NAME).o : $(OBJ) - $(AR) rc lib$(NAME).a $(OBJ) - $(RANLIB) lib$(NAME).a - $(LD) -r $(OBJ) -o lib$(NAME).o - -heap: lib$(NAME).o - -clean : - rm -f $(OBJ) *~ \#* *\# - -fclean : clean - rm -f lib$(NAME).a lib$(NAME).o diff -Nru eresi-0.8a25/liballocproxy/.svn/text-base/README.svn-base eresi-0.0.20110516/liballocproxy/.svn/text-base/README.svn-base --- eresi-0.8a25/liballocproxy/.svn/text-base/README.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/liballocproxy/.svn/text-base/README.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ - -The ERESI allocator library README file ---------------------------------------- - -This allocator is ptmalloc2 (http://www.malloc.de/malloc/ptmalloc2.tar.gz) patched -in quite a straightforward manner to allow only using mmap and no sbrk. The second -feature added is the ability to register a thread ID that will use a separate arena -and will leave the original process use the original heap as if the current thread -was not existing. - -The implementation is independant of any thread library (it was tested on Solaris, -BSD, and Linux with different thread implementations) and allow the Embedded ELF -Debugger (e2dbg) to be non-intrusive on the legit program heap management. - --crew diff -Nru eresi-0.8a25/libasm/doc/.svn/all-wcprops eresi-0.0.20110516/libasm/doc/.svn/all-wcprops --- eresi-0.8a25/libasm/doc/.svn/all-wcprops 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/843/trunk/libasm/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libasm/doc/doxygen.conf -END -footer.html -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libasm/doc/footer.html -END -header.html -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libasm/doc/header.html -END diff -Nru eresi-0.8a25/libasm/doc/.svn/entries eresi-0.0.20110516/libasm/doc/.svn/entries --- eresi-0.8a25/libasm/doc/.svn/entries 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/doc -http://svn.eresi-project.org/svn - - - -2008-02-16T12:32:28.000000Z -843 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:54.471200Z -a76a5b8aa1217a4a4b61b2795d8b8dc8 -2008-02-16T12:32:28.000000Z -843 -thor - -footer.html -file - - - - -2008-04-06T23:15:54.491887Z -18e94a98b218b0e2a8af422ccd5440f2 -2008-02-16T12:32:28.000000Z -843 -thor - -header.html -file - - - - -2008-04-06T23:15:54.503925Z -d86447c4d720e535e19fb2ae2b86225d -2008-02-16T12:32:28.000000Z -843 -thor - diff -Nru eresi-0.8a25/libasm/doc/.svn/format eresi-0.0.20110516/libasm/doc/.svn/format --- eresi-0.8a25/libasm/doc/.svn/format 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libasm/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libasm/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1215 +0,0 @@ -# Doxyfile 1.5.2 - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -PROJECT_NAME = libasm - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = CVS HEAD - -OUTPUT_DIRECTORY = ../doxygen - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = src/ include/ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libasm - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = doc/header.html - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = doc/footer.html - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = YES diff -Nru eresi-0.8a25/libasm/doc/.svn/text-base/footer.html.svn-base eresi-0.0.20110516/libasm/doc/.svn/text-base/footer.html.svn-base --- eresi-0.8a25/libasm/doc/.svn/text-base/footer.html.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/text-base/footer.html.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ - - -

- - - -
-

Copyright (c) 2007 ERESI Project

-
- -

Web design by Marcela Machi

-
-
- - - - diff -Nru eresi-0.8a25/libasm/doc/.svn/text-base/header.html.svn-base eresi-0.0.20110516/libasm/doc/.svn/text-base/header.html.svn-base --- eresi-0.8a25/libasm/doc/.svn/text-base/header.html.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/doc/.svn/text-base/header.html.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ - - - - - - The ERESI Reverse Engineering Software Interface - - - - - - - - - - - - - - -
-

- -

- -

-
-
The ERESI Reverse Engineering Software Interface

- - - - - - - - - - - -
- - - - - - - - - - - - - - -
- - - - diff -Nru eresi-0.8a25/libasm/include/libasm-arm-decode.h eresi-0.0.20110516/libasm/include/libasm-arm-decode.h --- eresi-0.8a25/libasm/include/libasm-arm-decode.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-arm-decode.h 2011-05-16 11:34:17.000000000 +0000 @@ -0,0 +1,186 @@ +/** + * @defgroup ARM_instrs ARM instructions disassembler. + * @ingroup arm + */ +/** +* @file libasm/include/libasm-arm-decode.h + * @ingroup arm + */ +#ifndef LIBASM_ARM_DECODE_H +#define LIBASM_ARM_DECODE_H + + +/* B, BL, BLX(1) */ +struct s_arm_decode_branch1 +{ + u_int32_t cond:4; + u_int32_t op:3; + u_int32_t l_h:1; + u_int32_t signed_imm:24; +}; + +/* BLX(2), BX */ +struct s_arm_decode_branch2 +{ + u_int32_t cond:4; + u_int32_t none1:22; + u_int32_t op:1; + u_int32_t none2:1; + u_int32_t rm:4; +}; + +struct s_arm_decode_dataproc +{ + u_int32_t cond:4; + u_int32_t op:2; + u_int32_t i:1; + u_int32_t op2:4; + u_int32_t s:1; + u_int32_t rn:4; + u_int32_t rd:4; + u_int32_t shifter_operand:12; + + u_int32_t rm; + u_int32_t rs; + u_int32_t immed; + u_int32_t shift; + u_int32_t shift_imm; + u_int32_t rotate_imm; + u_int32_t reg_shift; + + /* MRS/MSR */ + u_int8_t r; + u_int8_t topsr; + u_int8_t field_mask; +}; + +struct s_arm_decode_multiply +{ + u_int32_t cond:4; + u_int32_t none:4; + u_int32_t op:3; + u_int32_t s:1; + u_int32_t r1:4; + u_int32_t r2:4; + u_int32_t r3:4; + u_int32_t none2:1; + u_int32_t y:1; + u_int32_t x:1; + u_int32_t none3:1; + u_int32_t r4:4; +}; + +struct s_arm_decode_ldst +{ + u_int32_t cond:4; + u_int32_t op:2; + u_int32_t reg_offset:1; + u_int32_t p:1; + u_int32_t u:1; + u_int32_t b:1; + u_int32_t w:1; + u_int32_t l:1; + u_int32_t rn:4; + u_int32_t rd:4; + u_int32_t imm_offset:12; + + u_int8_t rm; + u_int8_t shift_imm; + u_int8_t shift; +}; + +struct s_arm_decode_ldst_misc +{ + u_int32_t cond:4; + u_int32_t op:3; + u_int32_t p:1; + u_int32_t u:1; + u_int32_t i:1; + u_int32_t w:1; + u_int32_t l:1; + u_int32_t rn:4; + u_int32_t rd:4; + u_int32_t immedH:4; + u_int32_t none1:1; + u_int32_t s:1; + u_int32_t h:1; + u_int32_t none2:1; + u_int32_t immedL_rm:4; +}; + +struct s_arm_decode_ldst_mult +{ + u_int32_t cond:4; + u_int32_t op:3; + u_int32_t p:1; + u_int32_t u:1; + u_int32_t s:1; + u_int32_t w:1; + u_int32_t l:1; + u_int32_t rn:4; + u_int32_t reg_list:16; +}; + +struct s_arm_decode_bkpt +{ + u_int32_t none1:12; + u_int32_t immed1:12; + u_int32_t none2:4; + u_int32_t immed2:4; +}; + +struct s_arm_decode_coproc_dataproc +{ + u_int32_t cond:4; + u_int32_t none:4; + u_int32_t op1:4; + u_int32_t crn:4; + u_int32_t crd:4; + u_int32_t cpnum:4; + u_int32_t op2:3; + u_int32_t zero:1; + u_int32_t crm:4; +}; + +struct s_arm_decode_coproc_mov +{ + u_int32_t cond:4; + u_int32_t none:4; + u_int32_t op1:3; + u_int32_t toarm:1; + u_int32_t crn:4; + u_int32_t rd:4; + u_int32_t cpnum:4; + u_int32_t op2:3; + u_int32_t one:1; + u_int32_t crm:4; +}; + +struct s_arm_decode_coproc_mov2 +{ + u_int32_t cond:4; + u_int32_t none:7; + u_int32_t toarm:1; + u_int32_t rn:4; + u_int32_t rd:4; + u_int32_t cpnum:4; + u_int32_t op:4; + u_int32_t crm:4; +}; + +struct s_arm_decode_coproc_ldst +{ + u_int32_t cond:4; + u_int32_t none:3; + u_int32_t p:1; + u_int32_t u:1; + u_int32_t n:1; + u_int32_t w:1; + u_int32_t l:1; + u_int32_t rn:4; + u_int32_t crd:4; + u_int32_t cpnum:4; + u_int32_t offset:8; +}; + +#endif /* LIBASM_ARM_DECODE_H */ diff -Nru eresi-0.8a25/libasm/include/libasm-arm.h eresi-0.0.20110516/libasm/include/libasm-arm.h --- eresi-0.8a25/libasm/include/libasm-arm.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-arm.h 2011-05-16 11:34:17.000000000 +0000 @@ -0,0 +1,2013 @@ +/** + * @defgroup arm Libasm ARM support + * @ingroup libasm + */ +/** +* @file libasm/include/libasm-arm.h + * @ingroup arm + */ +#ifndef _LIBASM_ARM_H_ +#define _LIBASM_ARM_H_ + +#include + +#define MGETBYTE(val, byte) ((val >> (byte*8)) & 0x00FF) +#define MGETNIBBLE(val, nibble) ((val >> (nibble*4)) & 0x000F) + +#define MASSIGNTYPE(insptr, instype) ((insptr->type) |= (instype)) +#define MUNASSIGNTYPE(insptr, instype) ((insptr->type) &= ~(instype)) +#define MISTYPE(insptr, instype) ((insptr->type) & (instype)) + +/* Registration functions */ +int asm_register_arm(); + +/* Resolve address */ +void asm_resolve_arm(void *d, eresi_Addr val, char *buf, u_int len); +eresi_Addr asm_dest_resolve_arm(eresi_Addr addr, u_int disp, u_char half); + +/* Output functions */ +char *asm_arm_display_instr(asm_instr *instr, eresi_Addr addr); +char *asm_arm_get_op_name(asm_operand *op); +char *asm_arm_get_register(int reg); +char *asm_arm_get_psr_fields(u_int field_mask); +char *asm_arm_get_regset_suffix(int regset); +char *asm_arm_get_shift_type(u_int shift_type); +char *asm_arm_get_coprocessor(int coproc); +char *asm_arm_get_coprocessor_register(int reg); +void asm_arm_dump_operand(asm_instr *ins, int num, eresi_Addr addr, char *buf, u_int len); + +/* Instruction handlers */ +int asm_arm_illegal(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_undef(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_adc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_add(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_and(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_b(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_bic(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_bkpt(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_bl(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_blx1(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_blx2(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_bx(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_cdp(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_clz(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_cmn(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_cmp(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_eor(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldm1(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldm2(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldm3(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldr(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrb(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrbt(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrd(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrh(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrsb(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrsh(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_ldrt(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mcr(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mcrr(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mla(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mov(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mrc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mrrc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mrs(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_msr(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mul(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_mvn(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_orr(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_pld(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_qadd(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_qdadd(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_qdsub(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_qsub(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_rsb(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_rsc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_sbc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smlal(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smlalxy(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smlawy(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smlaxy(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smull(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smulwy(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_smulxy(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_stc(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_stm1(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_stm2(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_str(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_strb(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_strbt(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_strd(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_strh(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_strt(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_sub(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_swi(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_swp(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_swpb(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_teq(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_tst(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_umlal(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); +int asm_arm_umull(asm_instr * ins, u_char * buf, u_int len, asm_processor * proc); + +/* ARM operand handlers */ +int asm_arm_op_fetch(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_immediate(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_register(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_reg_scaled(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_reg_offset(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_reg_list(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_disp(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_disp_half(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_coprocessor(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); +int asm_arm_op_fetch_coprocessor_register(asm_operand *operand, u_char *opcode, int otype, asm_instr *ins); + +/* Decoding helper functions */ +void arm_convert_dataproc(struct s_arm_decode_dataproc *opcode, u_char *buf); +void arm_convert_ldst(struct s_arm_decode_ldst *opcode, u_char *buf); +void arm_convert_ldst_misc(struct s_arm_decode_ldst_misc *opcode, u_char *buf); +void arm_convert_ldst_mult(struct s_arm_decode_ldst_mult *opcode, u_char *buf); +void arm_convert_swap(struct s_arm_decode_ldst *opcode, u_char *buf); +void arm_convert_multiply(struct s_arm_decode_multiply *opcode, u_char *buf); +void arm_convert_branch1(struct s_arm_decode_branch1 *opcode, u_char *buf); +void arm_convert_branch2(struct s_arm_decode_branch2 *opcode, u_char *buf); +void arm_convert_bkpt(struct s_arm_decode_bkpt *opcode, u_char *buf); +void arm_convert_coproc_dataproc(struct s_arm_decode_coproc_dataproc* opcode, u_char *buf); +void arm_convert_coproc_mov(struct s_arm_decode_coproc_mov* opcode, u_char *buf); +void arm_convert_coproc_mov2(struct s_arm_decode_coproc_mov2* opcode, u_char *buf); +void arm_convert_coproc_ldst(struct s_arm_decode_coproc_ldst* opcode, u_char *buf); + + +void arm_decode_condition(asm_instr *ins, u_char condition); +void arm_decode_dataproc_flagswritten(asm_instr *ins, struct s_arm_decode_dataproc *opcode); + +void arm_decode_dataproc_shfop(asm_instr *ins, u_char *buf, u_int op_nr, struct s_arm_decode_dataproc *opcode); +void arm_decode_ldst_offop(asm_instr *ins, u_char *buf, u_int op_nr, struct s_arm_decode_ldst *opcode); +void arm_decode_ldst_misc_offop(asm_instr *ins, u_char *buf, u_int op_nr, struct s_arm_decode_ldst_misc *opcode); +void arm_decode_multiply_long(asm_instr *ins, u_char *buf, struct s_arm_decode_multiply *opcode); +void arm_decode_coproc_ldst_offop(asm_instr *ins, u_char *buf, u_int op_nr, struct s_arm_decode_coproc_ldst *opcode); + +struct s_asm_proc_arm +{ + int *dataproc_table; + int *movpsr_table; + int *clz_table; + int *swi_table; + int *ldst_table; + int *ldst_mult_table; + int *ldst_misc_table; + int *swap_table; + int *multiply_table; + int *dsp_arith_table; + int *dsp_multiply_table; + int *branch1_table; + int *branch2_table; + int *coproc_dataproc_table; + int *coproc_mov_table; + int *coproc_mov2_table; + int *coproc_ldst_table; +}; + +enum e_arm_shift + { + ASM_ARM_SHIFT_LSL, + ASM_ARM_SHIFT_LSR, + ASM_ARM_SHIFT_ASR, + ASM_ARM_SHIFT_ROR, + ASM_ARM_SHIFT_RRX, + + ASM_ARM_SHIFT_NUM + }; + +enum e_arm_addressing + { + ASM_ARM_ADDRESSING_OFFSET, + ASM_ARM_ADDRESSING_PREINDEXED, + ASM_ARM_ADDRESSING_POSTINDEXED, + ASM_ARM_ADDRESSING_UNINDEXED, /* Coprocessor only */ + + ASM_ARM_ADDRESSING_NUM + }; + +enum e_arm_operand + { + ASM_ARM_OTYPE_REGISTER, + ASM_ARM_OTYPE_IMMEDIATE, + ASM_ARM_OTYPE_REG_SCALED, + ASM_ARM_OTYPE_REG_OFFSET, + ASM_ARM_OTYPE_REG_LIST, + ASM_ARM_OTYPE_DISP, + ASM_ARM_OTYPE_DISP_HALF, + ASM_ARM_OTYPE_COPROC, + ASM_ARM_OTYPE_COPROC_REGISTER, + + ASM_ARM_OTYPE_NUM + }; + +enum e_arm_registers + { + ASM_ARM_REG_R0, + ASM_ARM_REG_R1, + ASM_ARM_REG_R2, + ASM_ARM_REG_R3, + ASM_ARM_REG_R4, + ASM_ARM_REG_R5, + ASM_ARM_REG_R6, + ASM_ARM_REG_R7, + ASM_ARM_REG_R8, + ASM_ARM_REG_R9, + ASM_ARM_REG_R10, + ASM_ARM_REG_R11, + ASM_ARM_REG_R12, + ASM_ARM_REG_R13, + ASM_ARM_REG_R14, + ASM_ARM_REG_PC, + ASM_ARM_REG_CPSR, + ASM_ARM_REG_SPSR, + + ASM_ARM_REG_NUM + }; + +enum e_arm_regset + { + ASM_ARM_REGSET_USR, /* User/System registers */ + ASM_ARM_REGSET_SVC, /* Supervisor registers */ + ASM_ARM_REGSET_ABT, /* Abort registers */ + ASM_ARM_REGSET_UND, /* Undefined registers */ + ASM_ARM_REGSET_IRQ, /* IRQ register */ + ASM_ARM_REGSET_FIQ, /* FIQ registers */ + + ASM_ARM_REGSET_NUM + }; + +/* ARM Flags - values correspond to the bit in the CPSR/SPSR register */ +enum e_arm_flags + { + ASM_ARM_FLAG_NONE = 0x00, + + ASM_ARM_FLAG_N = 1 << 31, /* Negative */ + ASM_ARM_FLAG_Z = 1 << 30, /* Zero */ + ASM_ARM_FLAG_C = 1 << 29, /* Carry */ + ASM_ARM_FLAG_V = 1 << 28, /* Overflow */ + ASM_ARM_FLAG_Q = 1 << 27 /* Enhanced DSP Overflow (ARMv5E and superior) */ + }; + +enum e_arm_conditions + { + ASM_ARM_COND_EQ, + ASM_ARM_COND_NE, + ASM_ARM_COND_CS, + ASM_ARM_COND_CC, + ASM_ARM_COND_MI, + ASM_ARM_COND_PL, + ASM_ARM_COND_VS, + ASM_ARM_COND_VC, + ASM_ARM_COND_HI, + ASM_ARM_COND_LS, + ASM_ARM_COND_GE, + ASM_ARM_COND_LT, + ASM_ARM_COND_GT, + ASM_ARM_COND_LE, + ASM_ARM_COND_AL, + ASM_ARM_COND_NV + }; + +/* Coprocessor related */ +enum e_arm_coprocessor + { + ASM_ARM_COPROC_P0, + ASM_ARM_COPROC_P1, + ASM_ARM_COPROC_P2, + ASM_ARM_COPROC_P3, + ASM_ARM_COPROC_P4, + ASM_ARM_COPROC_P5, + ASM_ARM_COPROC_P6, + ASM_ARM_COPROC_P7, + ASM_ARM_COPROC_P8, + ASM_ARM_COPROC_P9, + ASM_ARM_COPROC_P10, + ASM_ARM_COPROC_P11, + ASM_ARM_COPROC_P12, + ASM_ARM_COPROC_P13, + ASM_ARM_COPROC_P14, + ASM_ARM_COPROC_P15, + + ASM_ARM_COPROC_NUM + }; + +enum e_arm_coprocessor_registers + { + ASM_ARM_COPROC_REG_CR0, + ASM_ARM_COPROC_REG_CR1, + ASM_ARM_COPROC_REG_CR2, + ASM_ARM_COPROC_REG_CR3, + ASM_ARM_COPROC_REG_CR4, + ASM_ARM_COPROC_REG_CR5, + ASM_ARM_COPROC_REG_CR6, + ASM_ARM_COPROC_REG_CR7, + ASM_ARM_COPROC_REG_CR8, + ASM_ARM_COPROC_REG_CR9, + ASM_ARM_COPROC_REG_CR10, + ASM_ARM_COPROC_REG_CR11, + ASM_ARM_COPROC_REG_CR12, + ASM_ARM_COPROC_REG_CR13, + ASM_ARM_COPROC_REG_CR14, + ASM_ARM_COPROC_REG_CR15, + + ASM_ARM_COPROC_REG_NUM + }; + +/*** + * Instruction list + * + * Last instruction must be ASM_ARM_BAD + */ + +enum e_arm_instr + { + ASM_ARM_, + + /* ADC */ + ASM_ARM_ADCEQ, + ASM_ARM_ADCEQS, + ASM_ARM_ADCNE, + ASM_ARM_ADCNES, + ASM_ARM_ADCCS, + ASM_ARM_ADCCSS, + ASM_ARM_ADCCC, + ASM_ARM_ADCCCS, + ASM_ARM_ADCMI, + ASM_ARM_ADCMIS, + ASM_ARM_ADCPL, + ASM_ARM_ADCPLS, + ASM_ARM_ADCVS, + ASM_ARM_ADCVSS, + ASM_ARM_ADCVC, + ASM_ARM_ADCVCS, + ASM_ARM_ADCHI, + ASM_ARM_ADCHIS, + ASM_ARM_ADCLS, + ASM_ARM_ADCLSS, + ASM_ARM_ADCGE, + ASM_ARM_ADCGES, + ASM_ARM_ADCLT, + ASM_ARM_ADCLTS, + ASM_ARM_ADCGT, + ASM_ARM_ADCGTS, + ASM_ARM_ADCLE, + ASM_ARM_ADCLES, + ASM_ARM_ADC, + ASM_ARM_ADCS, + + /* ADD */ + ASM_ARM_ADDEQ, + ASM_ARM_ADDEQS, + ASM_ARM_ADDNE, + ASM_ARM_ADDNES, + ASM_ARM_ADDCS, + ASM_ARM_ADDCSS, + ASM_ARM_ADDCC, + ASM_ARM_ADDCCS, + ASM_ARM_ADDMI, + ASM_ARM_ADDMIS, + ASM_ARM_ADDPL, + ASM_ARM_ADDPLS, + ASM_ARM_ADDVS, + ASM_ARM_ADDVSS, + ASM_ARM_ADDVC, + ASM_ARM_ADDVCS, + ASM_ARM_ADDHI, + ASM_ARM_ADDHIS, + ASM_ARM_ADDLS, + ASM_ARM_ADDLSS, + ASM_ARM_ADDGE, + ASM_ARM_ADDGES, + ASM_ARM_ADDLT, + ASM_ARM_ADDLTS, + ASM_ARM_ADDGT, + ASM_ARM_ADDGTS, + ASM_ARM_ADDLE, + ASM_ARM_ADDLES, + ASM_ARM_ADD, + ASM_ARM_ADDS, + + /* AND */ + ASM_ARM_ANDEQ, + ASM_ARM_ANDEQS, + ASM_ARM_ANDNE, + ASM_ARM_ANDNES, + ASM_ARM_ANDCS, + ASM_ARM_ANDCSS, + ASM_ARM_ANDCC, + ASM_ARM_ANDCCS, + ASM_ARM_ANDMI, + ASM_ARM_ANDMIS, + ASM_ARM_ANDPL, + ASM_ARM_ANDPLS, + ASM_ARM_ANDVS, + ASM_ARM_ANDVSS, + ASM_ARM_ANDVC, + ASM_ARM_ANDVCS, + ASM_ARM_ANDHI, + ASM_ARM_ANDHIS, + ASM_ARM_ANDLS, + ASM_ARM_ANDLSS, + ASM_ARM_ANDGE, + ASM_ARM_ANDGES, + ASM_ARM_ANDLT, + ASM_ARM_ANDLTS, + ASM_ARM_ANDGT, + ASM_ARM_ANDGTS, + ASM_ARM_ANDLE, + ASM_ARM_ANDLES, + ASM_ARM_AND, + ASM_ARM_ANDS, + + /* B */ + ASM_ARM_BEQ, + ASM_ARM_BNE, + ASM_ARM_BCS, + ASM_ARM_BCC, + ASM_ARM_BMI, + ASM_ARM_BPL, + ASM_ARM_BVS, + ASM_ARM_BVC, + ASM_ARM_BHI, + ASM_ARM_BLS, + ASM_ARM_BGE, + ASM_ARM_BLT, + ASM_ARM_BGT, + ASM_ARM_BLE, + ASM_ARM_B, + + /* BIC */ + ASM_ARM_BICEQ, + ASM_ARM_BICEQS, + ASM_ARM_BICNE, + ASM_ARM_BICNES, + ASM_ARM_BICCS, + ASM_ARM_BICCSS, + ASM_ARM_BICCC, + ASM_ARM_BICCCS, + ASM_ARM_BICMI, + ASM_ARM_BICMIS, + ASM_ARM_BICPL, + ASM_ARM_BICPLS, + ASM_ARM_BICVS, + ASM_ARM_BICVSS, + ASM_ARM_BICVC, + ASM_ARM_BICVCS, + ASM_ARM_BICHI, + ASM_ARM_BICHIS, + ASM_ARM_BICLS, + ASM_ARM_BICLSS, + ASM_ARM_BICGE, + ASM_ARM_BICGES, + ASM_ARM_BICLT, + ASM_ARM_BICLTS, + ASM_ARM_BICGT, + ASM_ARM_BICGTS, + ASM_ARM_BICLE, + ASM_ARM_BICLES, + ASM_ARM_BIC, + ASM_ARM_BICS, + + ASM_ARM_BKPT, /* uncond TEQ */ + + /* BL */ + ASM_ARM_BLEQ, + ASM_ARM_BLNE, + ASM_ARM_BLCS, + ASM_ARM_BLCC, + ASM_ARM_BLMI, + ASM_ARM_BLPL, + ASM_ARM_BLVS, + ASM_ARM_BLVC, + ASM_ARM_BLHI, + ASM_ARM_BLLS, + ASM_ARM_BLGE, + ASM_ARM_BLLT, + ASM_ARM_BLGT, + ASM_ARM_BLLE, + ASM_ARM_BL, + + /* BLX(1) */ + ASM_ARM_BLX1, /* blx(1): uncond b/bl */ + + /* BLX(2) */ + ASM_ARM_BLX2EQ, + ASM_ARM_BLX2NE, + ASM_ARM_BLX2CS, + ASM_ARM_BLX2CC, + ASM_ARM_BLX2MI, + ASM_ARM_BLX2PL, + ASM_ARM_BLX2VS, + ASM_ARM_BLX2VC, + ASM_ARM_BLX2HI, + ASM_ARM_BLX2LS, + ASM_ARM_BLX2GE, + ASM_ARM_BLX2LT, + ASM_ARM_BLX2GT, + ASM_ARM_BLX2LE, + ASM_ARM_BLX2, + + /* BX */ + ASM_ARM_BXEQ, + ASM_ARM_BXNE, + ASM_ARM_BXCS, + ASM_ARM_BXCC, + ASM_ARM_BXMI, + ASM_ARM_BXPL, + ASM_ARM_BXVS, + ASM_ARM_BXVC, + ASM_ARM_BXHI, + ASM_ARM_BXLS, + ASM_ARM_BXGE, + ASM_ARM_BXLT, + ASM_ARM_BXGT, + ASM_ARM_BXLE, + ASM_ARM_BX, + + /* CDP/CDP2 */ + ASM_ARM_CDPEQ, + ASM_ARM_CDPNE, + ASM_ARM_CDPCS, + ASM_ARM_CDPCC, + ASM_ARM_CDPMI, + ASM_ARM_CDPPL, + ASM_ARM_CDPVS, + ASM_ARM_CDPVC, + ASM_ARM_CDPHI, + ASM_ARM_CDPLS, + ASM_ARM_CDPGE, + ASM_ARM_CDPLT, + ASM_ARM_CDPGT, + ASM_ARM_CDPLE, + ASM_ARM_CDP, + ASM_ARM_CDP2, + + /* CLZ */ + ASM_ARM_CLZEQ, + ASM_ARM_CLZNE, + ASM_ARM_CLZCS, + ASM_ARM_CLZCC, + ASM_ARM_CLZMI, + ASM_ARM_CLZPL, + ASM_ARM_CLZVS, + ASM_ARM_CLZVC, + ASM_ARM_CLZHI, + ASM_ARM_CLZLS, + ASM_ARM_CLZGE, + ASM_ARM_CLZLT, + ASM_ARM_CLZGT, + ASM_ARM_CLZLE, + ASM_ARM_CLZ, + + /* CMN */ + ASM_ARM_CMNEQ, + ASM_ARM_CMNNE, + ASM_ARM_CMNCS, + ASM_ARM_CMNCC, + ASM_ARM_CMNMI, + ASM_ARM_CMNPL, + ASM_ARM_CMNVS, + ASM_ARM_CMNVC, + ASM_ARM_CMNHI, + ASM_ARM_CMNLS, + ASM_ARM_CMNGE, + ASM_ARM_CMNLT, + ASM_ARM_CMNGT, + ASM_ARM_CMNLE, + ASM_ARM_CMN, + + /* CMP */ + ASM_ARM_CMPEQ, + ASM_ARM_CMPNE, + ASM_ARM_CMPCS, + ASM_ARM_CMPCC, + ASM_ARM_CMPMI, + ASM_ARM_CMPPL, + ASM_ARM_CMPVS, + ASM_ARM_CMPVC, + ASM_ARM_CMPHI, + ASM_ARM_CMPLS, + ASM_ARM_CMPGE, + ASM_ARM_CMPLT, + ASM_ARM_CMPGT, + ASM_ARM_CMPLE, + ASM_ARM_CMP, + + /* EOR */ + ASM_ARM_EOREQ, + ASM_ARM_EOREQS, + ASM_ARM_EORNE, + ASM_ARM_EORNES, + ASM_ARM_EORCS, + ASM_ARM_EORCSS, + ASM_ARM_EORCC, + ASM_ARM_EORCCS, + ASM_ARM_EORMI, + ASM_ARM_EORMIS, + ASM_ARM_EORPL, + ASM_ARM_EORPLS, + ASM_ARM_EORVS, + ASM_ARM_EORVSS, + ASM_ARM_EORVC, + ASM_ARM_EORVCS, + ASM_ARM_EORHI, + ASM_ARM_EORHIS, + ASM_ARM_EORLS, + ASM_ARM_EORLSS, + ASM_ARM_EORGE, + ASM_ARM_EORGES, + ASM_ARM_EORLT, + ASM_ARM_EORLTS, + ASM_ARM_EORGT, + ASM_ARM_EORGTS, + ASM_ARM_EORLE, + ASM_ARM_EORLES, + ASM_ARM_EOR, + ASM_ARM_EORS, + + /* LDC/LDC2 */ + ASM_ARM_LDCEQ, + ASM_ARM_LDCEQL, + ASM_ARM_LDCNE, + ASM_ARM_LDCNEL, + ASM_ARM_LDCCS, + ASM_ARM_LDCCSL, + ASM_ARM_LDCCC, + ASM_ARM_LDCCCL, + ASM_ARM_LDCMI, + ASM_ARM_LDCMIL, + ASM_ARM_LDCPL, + ASM_ARM_LDCPLL, + ASM_ARM_LDCVS, + ASM_ARM_LDCVSL, + ASM_ARM_LDCVC, + ASM_ARM_LDCVCL, + ASM_ARM_LDCHI, + ASM_ARM_LDCHIL, + ASM_ARM_LDCLS, + ASM_ARM_LDCLSL, + ASM_ARM_LDCGE, + ASM_ARM_LDCGEL, + ASM_ARM_LDCLT, + ASM_ARM_LDCLTL, + ASM_ARM_LDCGT, + ASM_ARM_LDCGTL, + ASM_ARM_LDCLE, + ASM_ARM_LDCLEL, + ASM_ARM_LDC, + ASM_ARM_LDCL, + ASM_ARM_LDC2, + ASM_ARM_LDC2L, + + /* LDM */ + ASM_ARM_LDMEQIA, + ASM_ARM_LDMEQIB, + ASM_ARM_LDMEQDA, + ASM_ARM_LDMEQDB, + ASM_ARM_LDMNEIA, + ASM_ARM_LDMNEIB, + ASM_ARM_LDMNEDA, + ASM_ARM_LDMNEDB, + ASM_ARM_LDMCSIA, + ASM_ARM_LDMCSIB, + ASM_ARM_LDMCSDA, + ASM_ARM_LDMCSDB, + ASM_ARM_LDMCCIA, + ASM_ARM_LDMCCIB, + ASM_ARM_LDMCCDA, + ASM_ARM_LDMCCDB, + ASM_ARM_LDMMIIA, + ASM_ARM_LDMMIIB, + ASM_ARM_LDMMIDA, + ASM_ARM_LDMMIDB, + ASM_ARM_LDMPLIA, + ASM_ARM_LDMPLIB, + ASM_ARM_LDMPLDA, + ASM_ARM_LDMPLDB, + ASM_ARM_LDMVSIA, + ASM_ARM_LDMVSIB, + ASM_ARM_LDMVSDA, + ASM_ARM_LDMVSDB, + ASM_ARM_LDMVCIA, + ASM_ARM_LDMVCIB, + ASM_ARM_LDMVCDA, + ASM_ARM_LDMVCDB, + ASM_ARM_LDMHIIA, + ASM_ARM_LDMHIIB, + ASM_ARM_LDMHIDA, + ASM_ARM_LDMHIDB, + ASM_ARM_LDMLSIA, + ASM_ARM_LDMLSIB, + ASM_ARM_LDMLSDA, + ASM_ARM_LDMLSDB, + ASM_ARM_LDMGEIA, + ASM_ARM_LDMGEIB, + ASM_ARM_LDMGEDA, + ASM_ARM_LDMGEDB, + ASM_ARM_LDMLTIA, + ASM_ARM_LDMLTIB, + ASM_ARM_LDMLTDA, + ASM_ARM_LDMLTDB, + ASM_ARM_LDMGTIA, + ASM_ARM_LDMGTIB, + ASM_ARM_LDMGTDA, + ASM_ARM_LDMGTDB, + ASM_ARM_LDMLEIA, + ASM_ARM_LDMLEIB, + ASM_ARM_LDMLEDA, + ASM_ARM_LDMLEDB, + ASM_ARM_LDMIA, + ASM_ARM_LDMIB, + ASM_ARM_LDMDA, + ASM_ARM_LDMDB, + + /* LDR */ + ASM_ARM_LDREQ, + ASM_ARM_LDRNE, + ASM_ARM_LDRCS, + ASM_ARM_LDRCC, + ASM_ARM_LDRMI, + ASM_ARM_LDRPL, + ASM_ARM_LDRVS, + ASM_ARM_LDRVC, + ASM_ARM_LDRHI, + ASM_ARM_LDRLS, + ASM_ARM_LDRGE, + ASM_ARM_LDRLT, + ASM_ARM_LDRGT, + ASM_ARM_LDRLE, + ASM_ARM_LDR, + + /* LDRB */ + ASM_ARM_LDREQB, + ASM_ARM_LDRNEB, + ASM_ARM_LDRCSB, + ASM_ARM_LDRCCB, + ASM_ARM_LDRMIB, + ASM_ARM_LDRPLB, + ASM_ARM_LDRVSB, + ASM_ARM_LDRVCB, + ASM_ARM_LDRHIB, + ASM_ARM_LDRLSB, + ASM_ARM_LDRGEB, + ASM_ARM_LDRLTB, + ASM_ARM_LDRGTB, + ASM_ARM_LDRLEB, + ASM_ARM_LDRB, + + /* LDRBT */ + ASM_ARM_LDREQBT, + ASM_ARM_LDRNEBT, + ASM_ARM_LDRCSBT, + ASM_ARM_LDRCCBT, + ASM_ARM_LDRMIBT, + ASM_ARM_LDRPLBT, + ASM_ARM_LDRVSBT, + ASM_ARM_LDRVCBT, + ASM_ARM_LDRHIBT, + ASM_ARM_LDRLSBT, + ASM_ARM_LDRGEBT, + ASM_ARM_LDRLTBT, + ASM_ARM_LDRGTBT, + ASM_ARM_LDRLEBT, + ASM_ARM_LDRBT, + + /* LDRD */ + ASM_ARM_LDREQD, + ASM_ARM_LDRNED, + ASM_ARM_LDRCSD, + ASM_ARM_LDRCCD, + ASM_ARM_LDRMID, + ASM_ARM_LDRPLD, + ASM_ARM_LDRVSD, + ASM_ARM_LDRVCD, + ASM_ARM_LDRHID, + ASM_ARM_LDRLSD, + ASM_ARM_LDRGED, + ASM_ARM_LDRLTD, + ASM_ARM_LDRGTD, + ASM_ARM_LDRLED, + ASM_ARM_LDRD, + + /* LDRH */ + ASM_ARM_LDREQH, + ASM_ARM_LDRNEH, + ASM_ARM_LDRCSH, + ASM_ARM_LDRCCH, + ASM_ARM_LDRMIH, + ASM_ARM_LDRPLH, + ASM_ARM_LDRVSH, + ASM_ARM_LDRVCH, + ASM_ARM_LDRHIH, + ASM_ARM_LDRLSH, + ASM_ARM_LDRGEH, + ASM_ARM_LDRLTH, + ASM_ARM_LDRGTH, + ASM_ARM_LDRLEH, + ASM_ARM_LDRH, + + /* LDRSB */ + ASM_ARM_LDREQSB, + ASM_ARM_LDRNESB, + ASM_ARM_LDRCSSB, + ASM_ARM_LDRCCSB, + ASM_ARM_LDRMISB, + ASM_ARM_LDRPLSB, + ASM_ARM_LDRVSSB, + ASM_ARM_LDRVCSB, + ASM_ARM_LDRHISB, + ASM_ARM_LDRLSSB, + ASM_ARM_LDRGESB, + ASM_ARM_LDRLTSB, + ASM_ARM_LDRGTSB, + ASM_ARM_LDRLESB, + ASM_ARM_LDRSB, + + /* LDRSH */ + ASM_ARM_LDREQSH, + ASM_ARM_LDRNESH, + ASM_ARM_LDRCSSH, + ASM_ARM_LDRCCSH, + ASM_ARM_LDRMISH, + ASM_ARM_LDRPLSH, + ASM_ARM_LDRVSSH, + ASM_ARM_LDRVCSH, + ASM_ARM_LDRHISH, + ASM_ARM_LDRLSSH, + ASM_ARM_LDRGESH, + ASM_ARM_LDRLTSH, + ASM_ARM_LDRGTSH, + ASM_ARM_LDRLESH, + ASM_ARM_LDRSH, + + /* LDRT */ + ASM_ARM_LDREQT, + ASM_ARM_LDRNET, + ASM_ARM_LDRCST, + ASM_ARM_LDRCCT, + ASM_ARM_LDRMIT, + ASM_ARM_LDRPLT, + ASM_ARM_LDRVST, + ASM_ARM_LDRVCT, + ASM_ARM_LDRHIT, + ASM_ARM_LDRLST, + ASM_ARM_LDRGET, + ASM_ARM_LDRLTT, + ASM_ARM_LDRGTT, + ASM_ARM_LDRLET, + ASM_ARM_LDRT, + + /* MCR/MCR2 */ + ASM_ARM_MCREQ, + ASM_ARM_MCRNE, + ASM_ARM_MCRCS, + ASM_ARM_MCRCC, + ASM_ARM_MCRMI, + ASM_ARM_MCRPL, + ASM_ARM_MCRVS, + ASM_ARM_MCRVC, + ASM_ARM_MCRHI, + ASM_ARM_MCRLS, + ASM_ARM_MCRGE, + ASM_ARM_MCRLT, + ASM_ARM_MCRGT, + ASM_ARM_MCRLE, + ASM_ARM_MCR, + ASM_ARM_MCR2, + + /* MCRR */ + ASM_ARM_MCRREQ, + ASM_ARM_MCRRNE, + ASM_ARM_MCRRCS, + ASM_ARM_MCRRCC, + ASM_ARM_MCRRMI, + ASM_ARM_MCRRPL, + ASM_ARM_MCRRVS, + ASM_ARM_MCRRVC, + ASM_ARM_MCRRHI, + ASM_ARM_MCRRLS, + ASM_ARM_MCRRGE, + ASM_ARM_MCRRLT, + ASM_ARM_MCRRGT, + ASM_ARM_MCRRLE, + ASM_ARM_MCRR, + + /* MLA */ + ASM_ARM_MLAEQ, + ASM_ARM_MLAEQS, + ASM_ARM_MLANE, + ASM_ARM_MLANES, + ASM_ARM_MLACS, + ASM_ARM_MLACSS, + ASM_ARM_MLACC, + ASM_ARM_MLACCS, + ASM_ARM_MLAMI, + ASM_ARM_MLAMIS, + ASM_ARM_MLAPL, + ASM_ARM_MLAPLS, + ASM_ARM_MLAVS, + ASM_ARM_MLAVSS, + ASM_ARM_MLAVC, + ASM_ARM_MLAVCS, + ASM_ARM_MLAHI, + ASM_ARM_MLAHIS, + ASM_ARM_MLALS, + ASM_ARM_MLALSS, + ASM_ARM_MLAGE, + ASM_ARM_MLAGES, + ASM_ARM_MLALT, + ASM_ARM_MLALTS, + ASM_ARM_MLAGT, + ASM_ARM_MLAGTS, + ASM_ARM_MLALE, + ASM_ARM_MLALES, + ASM_ARM_MLA, + ASM_ARM_MLAS, + + /* MOV */ + ASM_ARM_MOVEQ, + ASM_ARM_MOVEQS, + ASM_ARM_MOVNE, + ASM_ARM_MOVNES, + ASM_ARM_MOVCS, + ASM_ARM_MOVCSS, + ASM_ARM_MOVCC, + ASM_ARM_MOVCCS, + ASM_ARM_MOVMI, + ASM_ARM_MOVMIS, + ASM_ARM_MOVPL, + ASM_ARM_MOVPLS, + ASM_ARM_MOVVS, + ASM_ARM_MOVVSS, + ASM_ARM_MOVVC, + ASM_ARM_MOVVCS, + ASM_ARM_MOVHI, + ASM_ARM_MOVHIS, + ASM_ARM_MOVLS, + ASM_ARM_MOVLSS, + ASM_ARM_MOVGE, + ASM_ARM_MOVGES, + ASM_ARM_MOVLT, + ASM_ARM_MOVLTS, + ASM_ARM_MOVGT, + ASM_ARM_MOVGTS, + ASM_ARM_MOVLE, + ASM_ARM_MOVLES, + ASM_ARM_MOV, + ASM_ARM_MOVS, + + /* MRC/MRC2 */ + ASM_ARM_MRCEQ, + ASM_ARM_MRCNE, + ASM_ARM_MRCCS, + ASM_ARM_MRCCC, + ASM_ARM_MRCMI, + ASM_ARM_MRCPL, + ASM_ARM_MRCVS, + ASM_ARM_MRCVC, + ASM_ARM_MRCHI, + ASM_ARM_MRCLS, + ASM_ARM_MRCGE, + ASM_ARM_MRCLT, + ASM_ARM_MRCGT, + ASM_ARM_MRCLE, + ASM_ARM_MRC, + ASM_ARM_MRC2, + + /* MRRC */ + ASM_ARM_MRRCEQ, + ASM_ARM_MRRCNE, + ASM_ARM_MRRCCS, + ASM_ARM_MRRCCC, + ASM_ARM_MRRCMI, + ASM_ARM_MRRCPL, + ASM_ARM_MRRCVS, + ASM_ARM_MRRCVC, + ASM_ARM_MRRCHI, + ASM_ARM_MRRCLS, + ASM_ARM_MRRCGE, + ASM_ARM_MRRCLT, + ASM_ARM_MRRCGT, + ASM_ARM_MRRCLE, + ASM_ARM_MRRC, + + /* MRS */ + ASM_ARM_MRSEQ, + ASM_ARM_MRSNE, + ASM_ARM_MRSCS, + ASM_ARM_MRSCC, + ASM_ARM_MRSMI, + ASM_ARM_MRSPL, + ASM_ARM_MRSVS, + ASM_ARM_MRSVC, + ASM_ARM_MRSHI, + ASM_ARM_MRSLS, + ASM_ARM_MRSGE, + ASM_ARM_MRSLT, + ASM_ARM_MRSGT, + ASM_ARM_MRSLE, + ASM_ARM_MRS, + + /* MSR */ + ASM_ARM_MSREQ, + ASM_ARM_MSRNE, + ASM_ARM_MSRCS, + ASM_ARM_MSRCC, + ASM_ARM_MSRMI, + ASM_ARM_MSRPL, + ASM_ARM_MSRVS, + ASM_ARM_MSRVC, + ASM_ARM_MSRHI, + ASM_ARM_MSRLS, + ASM_ARM_MSRGE, + ASM_ARM_MSRLT, + ASM_ARM_MSRGT, + ASM_ARM_MSRLE, + ASM_ARM_MSR, + + /* MUL */ + ASM_ARM_MULEQ, + ASM_ARM_MULEQS, + ASM_ARM_MULNE, + ASM_ARM_MULNES, + ASM_ARM_MULCS, + ASM_ARM_MULCSS, + ASM_ARM_MULCC, + ASM_ARM_MULCCS, + ASM_ARM_MULMI, + ASM_ARM_MULMIS, + ASM_ARM_MULPL, + ASM_ARM_MULPLS, + ASM_ARM_MULVS, + ASM_ARM_MULVSS, + ASM_ARM_MULVC, + ASM_ARM_MULVCS, + ASM_ARM_MULHI, + ASM_ARM_MULHIS, + ASM_ARM_MULLS, + ASM_ARM_MULLSS, + ASM_ARM_MULGE, + ASM_ARM_MULGES, + ASM_ARM_MULLT, + ASM_ARM_MULLTS, + ASM_ARM_MULGT, + ASM_ARM_MULGTS, + ASM_ARM_MULLE, + ASM_ARM_MULLES, + ASM_ARM_MUL, + ASM_ARM_MULS, + + /* MVN */ + ASM_ARM_MVNEQ, + ASM_ARM_MVNEQS, + ASM_ARM_MVNNE, + ASM_ARM_MVNNES, + ASM_ARM_MVNCS, + ASM_ARM_MVNCSS, + ASM_ARM_MVNCC, + ASM_ARM_MVNCCS, + ASM_ARM_MVNMI, + ASM_ARM_MVNMIS, + ASM_ARM_MVNPL, + ASM_ARM_MVNPLS, + ASM_ARM_MVNVS, + ASM_ARM_MVNVSS, + ASM_ARM_MVNVC, + ASM_ARM_MVNVCS, + ASM_ARM_MVNHI, + ASM_ARM_MVNHIS, + ASM_ARM_MVNLS, + ASM_ARM_MVNLSS, + ASM_ARM_MVNGE, + ASM_ARM_MVNGES, + ASM_ARM_MVNLT, + ASM_ARM_MVNLTS, + ASM_ARM_MVNGT, + ASM_ARM_MVNGTS, + ASM_ARM_MVNLE, + ASM_ARM_MVNLES, + ASM_ARM_MVN, + ASM_ARM_MVNS, + + /* ORR */ + ASM_ARM_ORREQ, + ASM_ARM_ORREQS, + ASM_ARM_ORRNE, + ASM_ARM_ORRNES, + ASM_ARM_ORRCS, + ASM_ARM_ORRCSS, + ASM_ARM_ORRCC, + ASM_ARM_ORRCCS, + ASM_ARM_ORRMI, + ASM_ARM_ORRMIS, + ASM_ARM_ORRPL, + ASM_ARM_ORRPLS, + ASM_ARM_ORRVS, + ASM_ARM_ORRVSS, + ASM_ARM_ORRVC, + ASM_ARM_ORRVCS, + ASM_ARM_ORRHI, + ASM_ARM_ORRHIS, + ASM_ARM_ORRLS, + ASM_ARM_ORRLSS, + ASM_ARM_ORRGE, + ASM_ARM_ORRGES, + ASM_ARM_ORRLT, + ASM_ARM_ORRLTS, + ASM_ARM_ORRGT, + ASM_ARM_ORRGTS, + ASM_ARM_ORRLE, + ASM_ARM_ORRLES, + ASM_ARM_ORR, + ASM_ARM_ORRS, + + ASM_ARM_PLD, /* uncond LDRB */ + + /* QADD */ + ASM_ARM_QADDEQ, + ASM_ARM_QADDNE, + ASM_ARM_QADDCS, + ASM_ARM_QADDCC, + ASM_ARM_QADDMI, + ASM_ARM_QADDPL, + ASM_ARM_QADDVS, + ASM_ARM_QADDVC, + ASM_ARM_QADDHI, + ASM_ARM_QADDLS, + ASM_ARM_QADDGE, + ASM_ARM_QADDLT, + ASM_ARM_QADDGT, + ASM_ARM_QADDLE, + ASM_ARM_QADD, + + /* QDADD */ + ASM_ARM_QDADDEQ, + ASM_ARM_QDADDNE, + ASM_ARM_QDADDCS, + ASM_ARM_QDADDCC, + ASM_ARM_QDADDMI, + ASM_ARM_QDADDPL, + ASM_ARM_QDADDVS, + ASM_ARM_QDADDVC, + ASM_ARM_QDADDHI, + ASM_ARM_QDADDLS, + ASM_ARM_QDADDGE, + ASM_ARM_QDADDLT, + ASM_ARM_QDADDGT, + ASM_ARM_QDADDLE, + ASM_ARM_QDADD, + + /* QDSUB */ + ASM_ARM_QDSUBEQ, + ASM_ARM_QDSUBNE, + ASM_ARM_QDSUBCS, + ASM_ARM_QDSUBCC, + ASM_ARM_QDSUBMI, + ASM_ARM_QDSUBPL, + ASM_ARM_QDSUBVS, + ASM_ARM_QDSUBVC, + ASM_ARM_QDSUBHI, + ASM_ARM_QDSUBLS, + ASM_ARM_QDSUBGE, + ASM_ARM_QDSUBLT, + ASM_ARM_QDSUBGT, + ASM_ARM_QDSUBLE, + ASM_ARM_QDSUB, + + /* QSUB */ + ASM_ARM_QSUBEQ, + ASM_ARM_QSUBNE, + ASM_ARM_QSUBCS, + ASM_ARM_QSUBCC, + ASM_ARM_QSUBMI, + ASM_ARM_QSUBPL, + ASM_ARM_QSUBVS, + ASM_ARM_QSUBVC, + ASM_ARM_QSUBHI, + ASM_ARM_QSUBLS, + ASM_ARM_QSUBGE, + ASM_ARM_QSUBLT, + ASM_ARM_QSUBGT, + ASM_ARM_QSUBLE, + ASM_ARM_QSUB, + + /* RSB */ + ASM_ARM_RSBEQ, + ASM_ARM_RSBEQS, + ASM_ARM_RSBNE, + ASM_ARM_RSBNES, + ASM_ARM_RSBCS, + ASM_ARM_RSBCSS, + ASM_ARM_RSBCC, + ASM_ARM_RSBCCS, + ASM_ARM_RSBMI, + ASM_ARM_RSBMIS, + ASM_ARM_RSBPL, + ASM_ARM_RSBPLS, + ASM_ARM_RSBVS, + ASM_ARM_RSBVSS, + ASM_ARM_RSBVC, + ASM_ARM_RSBVCS, + ASM_ARM_RSBHI, + ASM_ARM_RSBHIS, + ASM_ARM_RSBLS, + ASM_ARM_RSBLSS, + ASM_ARM_RSBGE, + ASM_ARM_RSBGES, + ASM_ARM_RSBLT, + ASM_ARM_RSBLTS, + ASM_ARM_RSBGT, + ASM_ARM_RSBGTS, + ASM_ARM_RSBLE, + ASM_ARM_RSBLES, + ASM_ARM_RSB, + ASM_ARM_RSBS, + + /* RSC */ + ASM_ARM_RSCEQ, + ASM_ARM_RSCEQS, + ASM_ARM_RSCNE, + ASM_ARM_RSCNES, + ASM_ARM_RSCCS, + ASM_ARM_RSCCSS, + ASM_ARM_RSCCC, + ASM_ARM_RSCCCS, + ASM_ARM_RSCMI, + ASM_ARM_RSCMIS, + ASM_ARM_RSCPL, + ASM_ARM_RSCPLS, + ASM_ARM_RSCVS, + ASM_ARM_RSCVSS, + ASM_ARM_RSCVC, + ASM_ARM_RSCVCS, + ASM_ARM_RSCHI, + ASM_ARM_RSCHIS, + ASM_ARM_RSCLS, + ASM_ARM_RSCLSS, + ASM_ARM_RSCGE, + ASM_ARM_RSCGES, + ASM_ARM_RSCLT, + ASM_ARM_RSCLTS, + ASM_ARM_RSCGT, + ASM_ARM_RSCGTS, + ASM_ARM_RSCLE, + ASM_ARM_RSCLES, + ASM_ARM_RSC, + ASM_ARM_RSCS, + + /* SBC */ + ASM_ARM_SBCEQ, + ASM_ARM_SBCEQS, + ASM_ARM_SBCNE, + ASM_ARM_SBCNES, + ASM_ARM_SBCCS, + ASM_ARM_SBCCSS, + ASM_ARM_SBCCC, + ASM_ARM_SBCCCS, + ASM_ARM_SBCMI, + ASM_ARM_SBCMIS, + ASM_ARM_SBCPL, + ASM_ARM_SBCPLS, + ASM_ARM_SBCVS, + ASM_ARM_SBCVSS, + ASM_ARM_SBCVC, + ASM_ARM_SBCVCS, + ASM_ARM_SBCHI, + ASM_ARM_SBCHIS, + ASM_ARM_SBCLS, + ASM_ARM_SBCLSS, + ASM_ARM_SBCGE, + ASM_ARM_SBCGES, + ASM_ARM_SBCLT, + ASM_ARM_SBCLTS, + ASM_ARM_SBCGT, + ASM_ARM_SBCGTS, + ASM_ARM_SBCLE, + ASM_ARM_SBCLES, + ASM_ARM_SBC, + ASM_ARM_SBCS, + + /* SMLAL */ + ASM_ARM_SMLALEQ, + ASM_ARM_SMLALEQS, + ASM_ARM_SMLALNE, + ASM_ARM_SMLALNES, + ASM_ARM_SMLALCS, + ASM_ARM_SMLALCSS, + ASM_ARM_SMLALCC, + ASM_ARM_SMLALCCS, + ASM_ARM_SMLALMI, + ASM_ARM_SMLALMIS, + ASM_ARM_SMLALPL, + ASM_ARM_SMLALPLS, + ASM_ARM_SMLALVS, + ASM_ARM_SMLALVSS, + ASM_ARM_SMLALVC, + ASM_ARM_SMLALVCS, + ASM_ARM_SMLALHI, + ASM_ARM_SMLALHIS, + ASM_ARM_SMLALLS, + ASM_ARM_SMLALLSS, + ASM_ARM_SMLALGE, + ASM_ARM_SMLALGES, + ASM_ARM_SMLALLT, + ASM_ARM_SMLALLTS, + ASM_ARM_SMLALGT, + ASM_ARM_SMLALGTS, + ASM_ARM_SMLALLE, + ASM_ARM_SMLALLES, + ASM_ARM_SMLAL, + ASM_ARM_SMLALS, + + /* SMLALXY */ + ASM_ARM_SMLALBBEQ, + ASM_ARM_SMLALTBEQ, + ASM_ARM_SMLALBTEQ, + ASM_ARM_SMLALTTEQ, + ASM_ARM_SMLALBBNE, + ASM_ARM_SMLALTBNE, + ASM_ARM_SMLALBTNE, + ASM_ARM_SMLALTTNE, + ASM_ARM_SMLALBBCS, + ASM_ARM_SMLALTBCS, + ASM_ARM_SMLALBTCS, + ASM_ARM_SMLALTTCS, + ASM_ARM_SMLALBBCC, + ASM_ARM_SMLALTBCC, + ASM_ARM_SMLALBTCC, + ASM_ARM_SMLALTTCC, + ASM_ARM_SMLALBBMI, + ASM_ARM_SMLALTBMI, + ASM_ARM_SMLALBTMI, + ASM_ARM_SMLALTTMI, + ASM_ARM_SMLALBBPL, + ASM_ARM_SMLALTBPL, + ASM_ARM_SMLALBTPL, + ASM_ARM_SMLALTTPL, + ASM_ARM_SMLALBBVS, + ASM_ARM_SMLALTBVS, + ASM_ARM_SMLALBTVS, + ASM_ARM_SMLALTTVS, + ASM_ARM_SMLALBBVC, + ASM_ARM_SMLALTBVC, + ASM_ARM_SMLALBTVC, + ASM_ARM_SMLALTTVC, + ASM_ARM_SMLALBBHI, + ASM_ARM_SMLALTBHI, + ASM_ARM_SMLALBTHI, + ASM_ARM_SMLALTTHI, + ASM_ARM_SMLALBBLS, + ASM_ARM_SMLALTBLS, + ASM_ARM_SMLALBTLS, + ASM_ARM_SMLALTTLS, + ASM_ARM_SMLALBBGE, + ASM_ARM_SMLALTBGE, + ASM_ARM_SMLALBTGE, + ASM_ARM_SMLALTTGE, + ASM_ARM_SMLALBBLT, + ASM_ARM_SMLALTBLT, + ASM_ARM_SMLALBTLT, + ASM_ARM_SMLALTTLT, + ASM_ARM_SMLALBBGT, + ASM_ARM_SMLALTBGT, + ASM_ARM_SMLALBTGT, + ASM_ARM_SMLALTTGT, + ASM_ARM_SMLALBBLE, + ASM_ARM_SMLALTBLE, + ASM_ARM_SMLALBTLE, + ASM_ARM_SMLALTTLE, + ASM_ARM_SMLALBB, + ASM_ARM_SMLALTB, + ASM_ARM_SMLALBT, + ASM_ARM_SMLALTT, + + /* SMLAWY */ + ASM_ARM_SMLAWBEQ, + ASM_ARM_SMLAWTEQ, + ASM_ARM_SMLAWBNE, + ASM_ARM_SMLAWTNE, + ASM_ARM_SMLAWBCS, + ASM_ARM_SMLAWTCS, + ASM_ARM_SMLAWBCC, + ASM_ARM_SMLAWTCC, + ASM_ARM_SMLAWBMI, + ASM_ARM_SMLAWTMI, + ASM_ARM_SMLAWBPL, + ASM_ARM_SMLAWTPL, + ASM_ARM_SMLAWBVS, + ASM_ARM_SMLAWTVS, + ASM_ARM_SMLAWBVC, + ASM_ARM_SMLAWTVC, + ASM_ARM_SMLAWBHI, + ASM_ARM_SMLAWTHI, + ASM_ARM_SMLAWBLS, + ASM_ARM_SMLAWTLS, + ASM_ARM_SMLAWBGE, + ASM_ARM_SMLAWTGE, + ASM_ARM_SMLAWBLT, + ASM_ARM_SMLAWTLT, + ASM_ARM_SMLAWBGT, + ASM_ARM_SMLAWTGT, + ASM_ARM_SMLAWBLE, + ASM_ARM_SMLAWTLE, + ASM_ARM_SMLAWB, + ASM_ARM_SMLAWT, + + /* SMLAXY */ + ASM_ARM_SMLABBEQ, + ASM_ARM_SMLATBEQ, + ASM_ARM_SMLABTEQ, + ASM_ARM_SMLATTEQ, + ASM_ARM_SMLABBNE, + ASM_ARM_SMLATBNE, + ASM_ARM_SMLABTNE, + ASM_ARM_SMLATTNE, + ASM_ARM_SMLABBCS, + ASM_ARM_SMLATBCS, + ASM_ARM_SMLABTCS, + ASM_ARM_SMLATTCS, + ASM_ARM_SMLABBCC, + ASM_ARM_SMLATBCC, + ASM_ARM_SMLABTCC, + ASM_ARM_SMLATTCC, + ASM_ARM_SMLABBMI, + ASM_ARM_SMLATBMI, + ASM_ARM_SMLABTMI, + ASM_ARM_SMLATTMI, + ASM_ARM_SMLABBPL, + ASM_ARM_SMLATBPL, + ASM_ARM_SMLABTPL, + ASM_ARM_SMLATTPL, + ASM_ARM_SMLABBVS, + ASM_ARM_SMLATBVS, + ASM_ARM_SMLABTVS, + ASM_ARM_SMLATTVS, + ASM_ARM_SMLABBVC, + ASM_ARM_SMLATBVC, + ASM_ARM_SMLABTVC, + ASM_ARM_SMLATTVC, + ASM_ARM_SMLABBHI, + ASM_ARM_SMLATBHI, + ASM_ARM_SMLABTHI, + ASM_ARM_SMLATTHI, + ASM_ARM_SMLABBLS, + ASM_ARM_SMLATBLS, + ASM_ARM_SMLABTLS, + ASM_ARM_SMLATTLS, + ASM_ARM_SMLABBGE, + ASM_ARM_SMLATBGE, + ASM_ARM_SMLABTGE, + ASM_ARM_SMLATTGE, + ASM_ARM_SMLABBLT, + ASM_ARM_SMLATBLT, + ASM_ARM_SMLABTLT, + ASM_ARM_SMLATTLT, + ASM_ARM_SMLABBGT, + ASM_ARM_SMLATBGT, + ASM_ARM_SMLABTGT, + ASM_ARM_SMLATTGT, + ASM_ARM_SMLABBLE, + ASM_ARM_SMLATBLE, + ASM_ARM_SMLABTLE, + ASM_ARM_SMLATTLE, + ASM_ARM_SMLABB, + ASM_ARM_SMLATB, + ASM_ARM_SMLABT, + ASM_ARM_SMLATT, + + /* SMULL */ + ASM_ARM_SMULLEQ, + ASM_ARM_SMULLEQS, + ASM_ARM_SMULLNE, + ASM_ARM_SMULLNES, + ASM_ARM_SMULLCS, + ASM_ARM_SMULLCSS, + ASM_ARM_SMULLCC, + ASM_ARM_SMULLCCS, + ASM_ARM_SMULLMI, + ASM_ARM_SMULLMIS, + ASM_ARM_SMULLPL, + ASM_ARM_SMULLPLS, + ASM_ARM_SMULLVS, + ASM_ARM_SMULLVSS, + ASM_ARM_SMULLVC, + ASM_ARM_SMULLVCS, + ASM_ARM_SMULLHI, + ASM_ARM_SMULLHIS, + ASM_ARM_SMULLLS, + ASM_ARM_SMULLLSS, + ASM_ARM_SMULLGE, + ASM_ARM_SMULLGES, + ASM_ARM_SMULLLT, + ASM_ARM_SMULLLTS, + ASM_ARM_SMULLGT, + ASM_ARM_SMULLGTS, + ASM_ARM_SMULLLE, + ASM_ARM_SMULLLES, + ASM_ARM_SMULL, + ASM_ARM_SMULLS, + + /* SMULWY */ + ASM_ARM_SMULWBEQ, + ASM_ARM_SMULWTEQ, + ASM_ARM_SMULWBNE, + ASM_ARM_SMULWTNE, + ASM_ARM_SMULWBCS, + ASM_ARM_SMULWTCS, + ASM_ARM_SMULWBCC, + ASM_ARM_SMULWTCC, + ASM_ARM_SMULWBMI, + ASM_ARM_SMULWTMI, + ASM_ARM_SMULWBPL, + ASM_ARM_SMULWTPL, + ASM_ARM_SMULWBVS, + ASM_ARM_SMULWTVS, + ASM_ARM_SMULWBVC, + ASM_ARM_SMULWTVC, + ASM_ARM_SMULWBHI, + ASM_ARM_SMULWTHI, + ASM_ARM_SMULWBLS, + ASM_ARM_SMULWTLS, + ASM_ARM_SMULWBGE, + ASM_ARM_SMULWTGE, + ASM_ARM_SMULWBLT, + ASM_ARM_SMULWTLT, + ASM_ARM_SMULWBGT, + ASM_ARM_SMULWTGT, + ASM_ARM_SMULWBLE, + ASM_ARM_SMULWTLE, + ASM_ARM_SMULWB, + ASM_ARM_SMULWT, + + /* SMULXY */ + ASM_ARM_SMULBBEQ, + ASM_ARM_SMULTBEQ, + ASM_ARM_SMULBTEQ, + ASM_ARM_SMULTTEQ, + ASM_ARM_SMULBBNE, + ASM_ARM_SMULTBNE, + ASM_ARM_SMULBTNE, + ASM_ARM_SMULTTNE, + ASM_ARM_SMULBBCS, + ASM_ARM_SMULTBCS, + ASM_ARM_SMULBTCS, + ASM_ARM_SMULTTCS, + ASM_ARM_SMULBBCC, + ASM_ARM_SMULTBCC, + ASM_ARM_SMULBTCC, + ASM_ARM_SMULTTCC, + ASM_ARM_SMULBBMI, + ASM_ARM_SMULTBMI, + ASM_ARM_SMULBTMI, + ASM_ARM_SMULTTMI, + ASM_ARM_SMULBBPL, + ASM_ARM_SMULTBPL, + ASM_ARM_SMULBTPL, + ASM_ARM_SMULTTPL, + ASM_ARM_SMULBBVS, + ASM_ARM_SMULTBVS, + ASM_ARM_SMULBTVS, + ASM_ARM_SMULTTVS, + ASM_ARM_SMULBBVC, + ASM_ARM_SMULTBVC, + ASM_ARM_SMULBTVC, + ASM_ARM_SMULTTVC, + ASM_ARM_SMULBBHI, + ASM_ARM_SMULTBHI, + ASM_ARM_SMULBTHI, + ASM_ARM_SMULTTHI, + ASM_ARM_SMULBBLS, + ASM_ARM_SMULTBLS, + ASM_ARM_SMULBTLS, + ASM_ARM_SMULTTLS, + ASM_ARM_SMULBBGE, + ASM_ARM_SMULTBGE, + ASM_ARM_SMULBTGE, + ASM_ARM_SMULTTGE, + ASM_ARM_SMULBBLT, + ASM_ARM_SMULTBLT, + ASM_ARM_SMULBTLT, + ASM_ARM_SMULTTLT, + ASM_ARM_SMULBBGT, + ASM_ARM_SMULTBGT, + ASM_ARM_SMULBTGT, + ASM_ARM_SMULTTGT, + ASM_ARM_SMULBBLE, + ASM_ARM_SMULTBLE, + ASM_ARM_SMULBTLE, + ASM_ARM_SMULTTLE, + ASM_ARM_SMULBB, + ASM_ARM_SMULTB, + ASM_ARM_SMULBT, + ASM_ARM_SMULTT, + + /* STC/STC2 */ + ASM_ARM_STCEQ, + ASM_ARM_STCEQL, + ASM_ARM_STCNE, + ASM_ARM_STCNEL, + ASM_ARM_STCCS, + ASM_ARM_STCCSL, + ASM_ARM_STCCC, + ASM_ARM_STCCCL, + ASM_ARM_STCMI, + ASM_ARM_STCMIL, + ASM_ARM_STCPL, + ASM_ARM_STCPLL, + ASM_ARM_STCVS, + ASM_ARM_STCVSL, + ASM_ARM_STCVC, + ASM_ARM_STCVCL, + ASM_ARM_STCHI, + ASM_ARM_STCHIL, + ASM_ARM_STCLS, + ASM_ARM_STCLSL, + ASM_ARM_STCGE, + ASM_ARM_STCGEL, + ASM_ARM_STCLT, + ASM_ARM_STCLTL, + ASM_ARM_STCGT, + ASM_ARM_STCGTL, + ASM_ARM_STCLE, + ASM_ARM_STCLEL, + ASM_ARM_STC, + ASM_ARM_STCL, + ASM_ARM_STC2, + ASM_ARM_STC2L, + + /* STM */ + ASM_ARM_STMEQIA, + ASM_ARM_STMEQIB, + ASM_ARM_STMEQDA, + ASM_ARM_STMEQDB, + ASM_ARM_STMNEIA, + ASM_ARM_STMNEIB, + ASM_ARM_STMNEDA, + ASM_ARM_STMNEDB, + ASM_ARM_STMCSIA, + ASM_ARM_STMCSIB, + ASM_ARM_STMCSDA, + ASM_ARM_STMCSDB, + ASM_ARM_STMCCIA, + ASM_ARM_STMCCIB, + ASM_ARM_STMCCDA, + ASM_ARM_STMCCDB, + ASM_ARM_STMMIIA, + ASM_ARM_STMMIIB, + ASM_ARM_STMMIDA, + ASM_ARM_STMMIDB, + ASM_ARM_STMPLIA, + ASM_ARM_STMPLIB, + ASM_ARM_STMPLDA, + ASM_ARM_STMPLDB, + ASM_ARM_STMVSIA, + ASM_ARM_STMVSIB, + ASM_ARM_STMVSDA, + ASM_ARM_STMVSDB, + ASM_ARM_STMVCIA, + ASM_ARM_STMVCIB, + ASM_ARM_STMVCDA, + ASM_ARM_STMVCDB, + ASM_ARM_STMHIIA, + ASM_ARM_STMHIIB, + ASM_ARM_STMHIDA, + ASM_ARM_STMHIDB, + ASM_ARM_STMLSIA, + ASM_ARM_STMLSIB, + ASM_ARM_STMLSDA, + ASM_ARM_STMLSDB, + ASM_ARM_STMGEIA, + ASM_ARM_STMGEIB, + ASM_ARM_STMGEDA, + ASM_ARM_STMGEDB, + ASM_ARM_STMLTIA, + ASM_ARM_STMLTIB, + ASM_ARM_STMLTDA, + ASM_ARM_STMLTDB, + ASM_ARM_STMGTIA, + ASM_ARM_STMGTIB, + ASM_ARM_STMGTDA, + ASM_ARM_STMGTDB, + ASM_ARM_STMLEIA, + ASM_ARM_STMLEIB, + ASM_ARM_STMLEDA, + ASM_ARM_STMLEDB, + ASM_ARM_STMIA, + ASM_ARM_STMIB, + ASM_ARM_STMDA, + ASM_ARM_STMDB, + + /* STR */ + ASM_ARM_STREQ, + ASM_ARM_STRNE, + ASM_ARM_STRCS, + ASM_ARM_STRCC, + ASM_ARM_STRMI, + ASM_ARM_STRPL, + ASM_ARM_STRVS, + ASM_ARM_STRVC, + ASM_ARM_STRHI, + ASM_ARM_STRLS, + ASM_ARM_STRGE, + ASM_ARM_STRLT, + ASM_ARM_STRGT, + ASM_ARM_STRLE, + ASM_ARM_STR, + + /* STRB */ + ASM_ARM_STREQB, + ASM_ARM_STRNEB, + ASM_ARM_STRCSB, + ASM_ARM_STRCCB, + ASM_ARM_STRMIB, + ASM_ARM_STRPLB, + ASM_ARM_STRVSB, + ASM_ARM_STRVCB, + ASM_ARM_STRHIB, + ASM_ARM_STRLSB, + ASM_ARM_STRGEB, + ASM_ARM_STRLTB, + ASM_ARM_STRGTB, + ASM_ARM_STRLEB, + ASM_ARM_STRB, + + /* STRBT */ + ASM_ARM_STREQBT, + ASM_ARM_STRNEBT, + ASM_ARM_STRCSBT, + ASM_ARM_STRCCBT, + ASM_ARM_STRMIBT, + ASM_ARM_STRPLBT, + ASM_ARM_STRVSBT, + ASM_ARM_STRVCBT, + ASM_ARM_STRHIBT, + ASM_ARM_STRLSBT, + ASM_ARM_STRGEBT, + ASM_ARM_STRLTBT, + ASM_ARM_STRGTBT, + ASM_ARM_STRLEBT, + ASM_ARM_STRBT, + + /* STRD */ + ASM_ARM_STREQD, + ASM_ARM_STRNED, + ASM_ARM_STRCSD, + ASM_ARM_STRCCD, + ASM_ARM_STRMID, + ASM_ARM_STRPLD, + ASM_ARM_STRVSD, + ASM_ARM_STRVCD, + ASM_ARM_STRHID, + ASM_ARM_STRLSD, + ASM_ARM_STRGED, + ASM_ARM_STRLTD, + ASM_ARM_STRGTD, + ASM_ARM_STRLED, + ASM_ARM_STRD, + + /* STRH */ + ASM_ARM_STREQH, + ASM_ARM_STRNEH, + ASM_ARM_STRCSH, + ASM_ARM_STRCCH, + ASM_ARM_STRMIH, + ASM_ARM_STRPLH, + ASM_ARM_STRVSH, + ASM_ARM_STRVCH, + ASM_ARM_STRHIH, + ASM_ARM_STRLSH, + ASM_ARM_STRGEH, + ASM_ARM_STRLTH, + ASM_ARM_STRGTH, + ASM_ARM_STRLEH, + ASM_ARM_STRH, + + /* STRT */ + ASM_ARM_STREQT, + ASM_ARM_STRNET, + ASM_ARM_STRCST, + ASM_ARM_STRCCT, + ASM_ARM_STRMIT, + ASM_ARM_STRPLT, + ASM_ARM_STRVST, + ASM_ARM_STRVCT, + ASM_ARM_STRHIT, + ASM_ARM_STRLST, + ASM_ARM_STRGET, + ASM_ARM_STRLTT, + ASM_ARM_STRGTT, + ASM_ARM_STRLET, + ASM_ARM_STRT, + + /* SUB */ + ASM_ARM_SUBEQ, + ASM_ARM_SUBEQS, + ASM_ARM_SUBNE, + ASM_ARM_SUBNES, + ASM_ARM_SUBCS, + ASM_ARM_SUBCSS, + ASM_ARM_SUBCC, + ASM_ARM_SUBCCS, + ASM_ARM_SUBMI, + ASM_ARM_SUBMIS, + ASM_ARM_SUBPL, + ASM_ARM_SUBPLS, + ASM_ARM_SUBVS, + ASM_ARM_SUBVSS, + ASM_ARM_SUBVC, + ASM_ARM_SUBVCS, + ASM_ARM_SUBHI, + ASM_ARM_SUBHIS, + ASM_ARM_SUBLS, + ASM_ARM_SUBLSS, + ASM_ARM_SUBGE, + ASM_ARM_SUBGES, + ASM_ARM_SUBLT, + ASM_ARM_SUBLTS, + ASM_ARM_SUBGT, + ASM_ARM_SUBGTS, + ASM_ARM_SUBLE, + ASM_ARM_SUBLES, + ASM_ARM_SUB, + ASM_ARM_SUBS, + + /* SWI */ + ASM_ARM_SWIEQ, + ASM_ARM_SWINE, + ASM_ARM_SWICS, + ASM_ARM_SWICC, + ASM_ARM_SWIMI, + ASM_ARM_SWIPL, + ASM_ARM_SWIVS, + ASM_ARM_SWIVC, + ASM_ARM_SWIHI, + ASM_ARM_SWILS, + ASM_ARM_SWIGE, + ASM_ARM_SWILT, + ASM_ARM_SWIGT, + ASM_ARM_SWILE, + ASM_ARM_SWI, + + /* SWP */ + ASM_ARM_SWPEQ, + ASM_ARM_SWPNE, + ASM_ARM_SWPCS, + ASM_ARM_SWPCC, + ASM_ARM_SWPMI, + ASM_ARM_SWPPL, + ASM_ARM_SWPVS, + ASM_ARM_SWPVC, + ASM_ARM_SWPHI, + ASM_ARM_SWPLS, + ASM_ARM_SWPGE, + ASM_ARM_SWPLT, + ASM_ARM_SWPGT, + ASM_ARM_SWPLE, + ASM_ARM_SWP, + + /* SWPB */ + ASM_ARM_SWPEQB, + ASM_ARM_SWPNEB, + ASM_ARM_SWPCSB, + ASM_ARM_SWPCCB, + ASM_ARM_SWPMIB, + ASM_ARM_SWPPLB, + ASM_ARM_SWPVSB, + ASM_ARM_SWPVCB, + ASM_ARM_SWPHIB, + ASM_ARM_SWPLSB, + ASM_ARM_SWPGEB, + ASM_ARM_SWPLTB, + ASM_ARM_SWPGTB, + ASM_ARM_SWPLEB, + ASM_ARM_SWPB, + + /* TEQ */ + ASM_ARM_TEQEQ, + ASM_ARM_TEQNE, + ASM_ARM_TEQCS, + ASM_ARM_TEQCC, + ASM_ARM_TEQMI, + ASM_ARM_TEQPL, + ASM_ARM_TEQVS, + ASM_ARM_TEQVC, + ASM_ARM_TEQHI, + ASM_ARM_TEQLS, + ASM_ARM_TEQGE, + ASM_ARM_TEQLT, + ASM_ARM_TEQGT, + ASM_ARM_TEQLE, + ASM_ARM_TEQ, + + /* TST */ + ASM_ARM_TSTEQ, + ASM_ARM_TSTNE, + ASM_ARM_TSTCS, + ASM_ARM_TSTCC, + ASM_ARM_TSTMI, + ASM_ARM_TSTPL, + ASM_ARM_TSTVS, + ASM_ARM_TSTVC, + ASM_ARM_TSTHI, + ASM_ARM_TSTLS, + ASM_ARM_TSTGE, + ASM_ARM_TSTLT, + ASM_ARM_TSTGT, + ASM_ARM_TSTLE, + ASM_ARM_TST, + + /* UMLAL */ + ASM_ARM_UMLALEQ, + ASM_ARM_UMLALEQS, + ASM_ARM_UMLALNE, + ASM_ARM_UMLALNES, + ASM_ARM_UMLALCS, + ASM_ARM_UMLALCSS, + ASM_ARM_UMLALCC, + ASM_ARM_UMLALCCS, + ASM_ARM_UMLALMI, + ASM_ARM_UMLALMIS, + ASM_ARM_UMLALPL, + ASM_ARM_UMLALPLS, + ASM_ARM_UMLALVS, + ASM_ARM_UMLALVSS, + ASM_ARM_UMLALVC, + ASM_ARM_UMLALVCS, + ASM_ARM_UMLALHI, + ASM_ARM_UMLALHIS, + ASM_ARM_UMLALLS, + ASM_ARM_UMLALLSS, + ASM_ARM_UMLALGE, + ASM_ARM_UMLALGES, + ASM_ARM_UMLALLT, + ASM_ARM_UMLALLTS, + ASM_ARM_UMLALGT, + ASM_ARM_UMLALGTS, + ASM_ARM_UMLALLE, + ASM_ARM_UMLALLES, + ASM_ARM_UMLAL, + ASM_ARM_UMLALS, + + /* UMULL */ + ASM_ARM_UMULLEQ, + ASM_ARM_UMULLEQS, + ASM_ARM_UMULLNE, + ASM_ARM_UMULLNES, + ASM_ARM_UMULLCS, + ASM_ARM_UMULLCSS, + ASM_ARM_UMULLCC, + ASM_ARM_UMULLCCS, + ASM_ARM_UMULLMI, + ASM_ARM_UMULLMIS, + ASM_ARM_UMULLPL, + ASM_ARM_UMULLPLS, + ASM_ARM_UMULLVS, + ASM_ARM_UMULLVSS, + ASM_ARM_UMULLVC, + ASM_ARM_UMULLVCS, + ASM_ARM_UMULLHI, + ASM_ARM_UMULLHIS, + ASM_ARM_UMULLLS, + ASM_ARM_UMULLLSS, + ASM_ARM_UMULLGE, + ASM_ARM_UMULLGES, + ASM_ARM_UMULLLT, + ASM_ARM_UMULLLTS, + ASM_ARM_UMULLGT, + ASM_ARM_UMULLGTS, + ASM_ARM_UMULLLE, + ASM_ARM_UMULLLES, + ASM_ARM_UMULL, + ASM_ARM_UMULLS, + + ASM_ARM_BAD, + }; + +extern char *arm_instr_list[ASM_ARM_BAD + 1]; +extern int arm_dataproc_table[512]; +extern int arm_movpsr_table[32]; +extern int arm_clz_table[16]; +extern int arm_swi_table[16]; +extern int arm_ldst_table[128]; +extern int arm_ldst_misc_table[128]; +extern int arm_ldst_mult_table[128]; +extern int arm_swap_table[32]; +extern int arm_multiply_table[256]; +extern int arm_dsp_multiply_table[256]; +extern int arm_dsp_arith_table[64]; +extern int arm_branch1_table[32]; +extern int arm_branch2_table[32]; +extern int arm_coproc_dataproc_table[16]; +extern int arm_coproc_mov_table[32]; +extern int arm_coproc_mov2_table[32]; +extern int arm_coproc_ldst_table[64]; + + +extern int arm_cond_flagsread_table[17]; +extern int arm_dataproc_flagswritten_table[16]; + +#endif /* _LIBASM_ARM_H_ */ diff -Nru eresi-0.8a25/libasm/include/libasm.h eresi-0.0.20110516/libasm/include/libasm.h --- eresi-0.8a25/libasm/include/libasm.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,17 +1,19 @@ /** - * @file libasm.h - * $Id: libasm.h,v 1.31 2008/02/01 01:56:53 heroine Exp $ + * @defgroup libasm libasm: the disassembling library. + */ +/** +* @file libasm/include/libasm.h + * @ingroup libasm * * Author : * Started : Sat Oct 26 01:18:46 2002 - * Updated : Thu Apr 8 00:45:41 2004 * * This is the main definition file for libasm.h * Definitions, enums, prototypes or anything related * to a specific architecture MUST be stored in that specific * architecture include files. * - * + * $Id: libasm.h 1311 2009-01-14 20:36:48Z may */ /** @@ -19,14 +21,6 @@ * @todo Reorganize include files content. */ -/** - * @defgroup operands Operands related API - */ - -/** - * @defgroup handlers_ia32 IA32 Fechting handlers. - */ - #ifndef LIBASM_H_ #define LIBASM_H_ @@ -53,13 +47,15 @@ #define LIBASM_SUPPORT_IA32 1 #define LIBASM_SUPPORT_MIPS 0 /*) + * @return 1 on success, 0 on error. + */ +int asm_init_arch(asm_processor *proc, int arch); /** * Return endianess */ int asm_config_get_endian(); + +/** + * Return synthetic instructions enabled flag + */ +int asm_config_get_synthinstr(); + /** * return build date. */ @@ -234,7 +265,7 @@ * Return instruction length. * */ -int asm_instruction_get_len(asm_instr *, int, void *); +int asm_instruction_get_len(asm_instr *, int, void *); /** * Return instruction mnemonic. @@ -245,9 +276,7 @@ /** * Return a pointer */ - -char *asm_display_instr_att(asm_instr *, int); - +char *asm_display_instr_att(asm_instr *, eresi_Addr); void asm_clear_instr(asm_instr *); /** @@ -267,36 +296,33 @@ * */ -int asm_operand_get_count(asm_instr *instr, int num, int, void *); +int asm_operand_get_count(asm_instr *instr, int num, int, void *); /** * Return operand content. */ -int asm_operand_get_content(asm_instr *, int, int, void *); +int asm_operand_get_content(asm_instr *, int, int, void *); /****************** * */ -void *asm_opcode_fetch(const char *vector_name, int opcode); +void *asm_opcode_fetch(const char *vector_name, int opcode); /** * Return operand type. */ -int asm_operand_get_type(asm_instr *, int, int, void *); +int asm_operand_get_type(asm_instr *, int, int, void *); /** * Return operand size */ - -int asm_operand_get_size(asm_instr *, int, int, void *); - -int asm_operand_get_len(asm_instr *, int, int, void *); -int asm_operand_set_value(asm_instr *, int, int, void *); -int asm_operand_get_value(asm_instr *, int, int, void *); - +int asm_operand_get_size(asm_instr *, int, int, void *); +int asm_operand_get_len(asm_instr *, int, int, void *); +int asm_operand_set_value(asm_instr *, int, int, void *); +int asm_operand_get_value(asm_instr *, int, int, void *); #ifndef __KERNEL__ @@ -322,7 +348,6 @@ /** * Get immediate value stored in operand. */ - int asm_operand_get_immediate(asm_instr *, int, int, void *); /** @@ -368,7 +393,7 @@ * Set resolve handler used by asm_display_instr() to resolve immediate value. */ void asm_set_resolve_handler(asm_processor *, - void (*)(void *, u_int, char *, u_int), + void (*)(void *, eresi_Addr, char *, u_int), void *); /** @@ -442,6 +467,7 @@ #include #include #include +#include #endif diff -Nru eresi-0.8a25/libasm/include/libasm-i386.h eresi-0.0.20110516/libasm/include/libasm-i386.h --- eresi-0.8a25/libasm/include/libasm-i386.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-i386.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,50 +1,63 @@ /** - * @file libasm-i386.h + * @defgroup ia32 Libasm IA32 support + * @ingroup libasm + */ +/** +* @file libasm/include/libasm-i386.h + * @ingroup ia32 * @brief Contains structures,prototypes and defines/enum related to ia32. - * $Id: libasm-i386.h,v 1.14 2008/01/07 01:29:53 heroine Exp $ + * $Id: libasm-i386.h 1403 2010-03-30 20:26:42Z thorkill $ */ #ifndef LIBASM_I386_H_ #define LIBASM_I386_H_ #include + typedef struct s_asm_i386_processor asm_i386_processor; typedef struct s_asm_i386_table asm_i386_table; -void asm_resolve_ia32(void *d, u_int, char *, u_int); - -/** - * ia32 related functions. - */ - +/* Prototypes for IA32 specific API */ +void asm_resolve_ia32(void *d, eresi_Addr, char *, u_int); +int asm_ia32_get_mode(asm_processor *proc); +eresi_Addr asm_dest_resolve(asm_processor *proc, eresi_Addr, u_int shift); +int asm_ia32_switch_mode(asm_processor *proc, int mode); + +/** Are we in protected mode or real mode ? */ +enum e_asm_proc_mode +{ + INTEL_REAL, + INTEL_PROT +}; +/** IA32 related functions */ int asm_content_pack(asm_operand *, int, int); int asm_fixed_pack(int, int, int, int); - /** * this structure is internal and may not be accessed by user * directly. it contains reference to each table describing i386 opcodes * refer to sandpile.org */ -struct s_asm_proc_i386 { - /* compatibility */ - - int mode; /*!< processor state: opsize actived or not */ - - int vect_size; - int addsize; /*!< WIPcurrent state of the processor addsize prefix */ - int opsize; /*!< WIPcurrent state of the processor addsize prefix */ - - int type; /*!< WIPcurrent state of the processor addsize prefix */ - //int (*get_vect_size)(asm_processor *); /*!< Internal handler unused */ +struct s_asm_proc_i386 +{ + int mode; /*!< processor state: opsize actived or not */ + int vect_size; + int addsize; /*!< WIPcurrent state of the processor addsize prefix */ + int opsize; /*!< WIPcurrent state of the processor addsize prefix */ + int type; /*!< WIPcurrent state of the processor addsize prefix */ + //int (*get_vect_size)(asm_processor *); /*!< Internal handler unused */ }; /** * Content of the operand. * Those flags are stored in asm_operand.content field. + * + * FIXME: MUST BE UNIFIED WITH libasm.h:156 e_op_types + * WARNING: used for pretty printing in libasm/ia32/ + * Never used on others. */ #define ASM_OP_VALUE 1 /*!< immediate value present */ #define ASM_OP_BASE 2 /*!< base register present */ @@ -476,7 +489,7 @@ * Refer to init_instr_table in tables_i386.c */ -enum asm_instr { +enum e_asm_instr { ASM_NONE, /* special instr id */ ASM_IPREFIX_MIN, diff -Nru eresi-0.8a25/libasm/include/libasm-ia32-hdl.h eresi-0.0.20110516/libasm/include/libasm-ia32-hdl.h --- eresi-0.8a25/libasm/include/libasm-ia32-hdl.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-ia32-hdl.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,3 +1,12 @@ +/** + * @defgroup IA32_instrs Libasm IA32 instructions handlers. + * @ingroup ia32 + */ +/** + * @file libasm/include/libasm-ia32-hdl.h + * @ingroup ia32 + */ + #ifndef _LIBASM_IA32_HDL_H_ #define _LIBASM_IA32_HDL_H_ diff -Nru eresi-0.8a25/libasm/include/libasm-int.h eresi-0.0.20110516/libasm/include/libasm-int.h --- eresi-0.8a25/libasm/include/libasm-int.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-int.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,67 +1,50 @@ /** - * @file libasm-int.h - * $Id: libasm-int.h,v 1.8 2008/01/07 01:29:53 heroine Exp $ +* @file libasm/include/libasm-int.h + * $Id: libasm-int.h 1397 2009-09-13 02:19:08Z may $ * * This file contains the forward declarations of i386 instruction * handlers and some internal functions prototypes. */ #ifndef LIBASM_INT_H -#define LIBASM_INT_H + #define LIBASM_INT_H + +/* Debug flags */ +#define __DEBUG_MODRM__ 0 /** * Structure describing the modrm byte. */ - -typedef struct s_modrm { +typedef struct s_modrm +{ u_char m:3; u_char r:3; u_char mod:2; -} asm_modrm; +} asm_modrm; /** * Structure describing the sid byte. */ - -typedef struct s_sidbyte { +typedef struct s_sidbyte +{ u_char base:3; u_char index:3; u_char sid:2; +} asm_sidbyte; -} asm_sidbyte; - -/** - * - */ - -enum e_asm_proc_mode { - INTEL_REAL, - INTEL_PROT -}; - - -int asm_int_pow2(int); - -int fetch_i386(asm_instr *, u_char *, u_int, asm_processor *); - -void asm_resolve_immediate(asm_processor *proc, u_int val, char *buffer, u_int len); - - -char *asm_ia32_display_instr_att(asm_instr *ins, int addr); -char *asm_sparc_display_instr(asm_instr *, int addr); - - -int asm_proc_opsize(asm_processor *proc); -int asm_proc_addsize(asm_processor *proc); -int asm_proc_vector_size(asm_processor *proc); -int asm_proc_vector_len(asm_processor *); -int asm_proc_is_protected(asm_processor *); +int asm_int_pow2(int); +int fetch_i386(asm_instr *, u_char *, u_int, asm_processor *); +void asm_resolve_immediate(asm_processor *proc, eresi_Addr val, char *buffer, u_int len); +char *asm_ia32_display_instr_att(asm_instr *ins, eresi_Addr addr); +char *asm_sparc_display_instr(asm_instr *, eresi_Addr addr); +int asm_ia32_switch_mode(asm_processor *proc, int mode); +int asm_proc_opsize(asm_processor *proc); +int asm_proc_addsize(asm_processor *proc); +int asm_proc_vector_size(asm_processor *proc); +int asm_proc_vector_len(asm_processor *); +int asm_proc_is_protected(asm_processor *); /** * Internal functions to extract operands. - * - * - * - * */ int operand_rmb_rb(asm_instr *, u_char *, int, asm_processor *); @@ -69,15 +52,11 @@ int operand_rb_rmb(asm_instr *, u_char *, int, asm_processor *); int operand_rv_rmv(asm_instr *, u_char *, int, asm_processor *); int operand_rv_rmb(asm_instr *, u_char *, int, asm_processor *); - int operand_rmb_ib(asm_instr *, u_char *, int, asm_processor *); int operand_rmv_iv(asm_instr *, u_char *, int, asm_processor *); int operand_rmv_ib(asm_instr *, u_char *, int, asm_processor *); - int operand_rv_rm2(asm_instr *, u_char *, int, asm_processor *); - int operand_rv_m(asm_instr *, u_char *, int, asm_processor *); - int operand_rmv(asm_operand *, u_char *, u_int, asm_processor *); int operand_rmb(asm_operand *, u_char *, u_int, asm_processor *); diff -Nru eresi-0.8a25/libasm/include/libasm-mips.h eresi-0.0.20110516/libasm/include/libasm-mips.h --- eresi-0.8a25/libasm/include/libasm-mips.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-mips.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,11 +1,15 @@ /** - * @file libasm-mips.h - * $Id: libasm-mips.h,v 1.5 2008/01/07 01:29:53 heroine Exp $ - * - * fix and fill - * - Adam 'pi3' Zabrocki + * @defgroup mips Libasm MIPS support + * @ingroup libasm + */ +/** +* @file libasm/include/libasm-mips.h + * @ingroup mips * - * Manuel Martin - 2007 + * - Sebastien Roy - 2006 + * - Manuel Martin - 2007 + * - Adam Zabrocki - 2008 + * $Id: libasm-mips.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef LIBASM_MIPS_H_ @@ -23,7 +27,7 @@ #define ASM_MIPS_REG_FPU ASM_CONFIG_MIPS_EXTENDED_REGISTERS -char *asm_mips_display_instr(asm_instr *, int); +char *asm_mips_display_instr(asm_instr *, eresi_Addr a); void mips_convert_format_r(struct s_mips_decode_reg *opcode, u_char *buf); void mips_convert_format_i(struct s_mips_decode_imm *opcode, u_char *buf); void mips_convert_format_j(struct s_mips_decode_jump *opcode, u_char *buf); @@ -32,6 +36,8 @@ void mips_convert_format_mov(struct s_mips_decode_mov *opcode, u_char *buf); void mips_convert_format_cop1x(struct s_mips_decode_cop1x *opcode, u_char *buf); +#define mips_convert_format_priv mips_convert_format_cop2 + int asm_fetch_mips(asm_instr *, u_char *, u_int, asm_processor *); int asm_register_mips(); @@ -148,6 +154,7 @@ #define ASM_MIPS_TABLE_END -1 enum opcode_field_encoding { + MIPS_OPCODE_SPECIAL, /* class */ MIPS_OPCODE_REGIMM, /* class */ MIPS_OPCODE_J, @@ -211,9 +218,11 @@ MIPS_OPCODE_SD = Ob(111111), MIPS_OPCODE_SDL = Ob(101100), MIPS_OPCODE_SDR + }; enum SPECIAL_function_field_encoding { + MIPS_OPCODE_SLL, MIPS_OPCODE_MOVCI, /* class */ MIPS_OPCODE_SRL, /* class */ @@ -270,9 +279,11 @@ MIPS_OPCODE_DSRA32, MIPS_OPCODE_DSRLV = Ob(010110), MIPS_OPCODE_DSRAV + }; enum REGIMM_rt_field_encoding { + MIPS_OPCODE_BLTZ, MIPS_OPCODE_BGEZ, MIPS_OPCODE_BLTZL, /* obsolete */ @@ -288,9 +299,11 @@ MIPS_OPCODE_BLTZALL, /* obsolete */ MIPS_OPCODE_BGEZALL, /* obsolete */ MIPS_OPCODE_SYNCI = Ob(11111) /* release 2 */ + }; enum SPECIAL2_function_field_encoding { + MIPS_OPCODE_MADD, MIPS_OPCODE_MADDU, MIPS_OPCODE_MUL, @@ -302,50 +315,64 @@ MIPS_OPCODE_DCLZ = Ob(100100), MIPS_OPCODE_DCLO + }; /* only for release 2*/ enum SPECIAL3_function_field_encoding { + MIPS_OPCODE_EXT, MIPS_OPCODE_INS = Ob(000100), MIPS_OPCODE_BSHFL = Ob(100000), /* class */ MIPS_OPCODE_RDHWR = Ob(111011), + }; enum MOVCI_tf_field_encoding { + MIPS_OPCODE_MOVF, MIPS_OPCODE_MOVT + }; enum SRL_shiftrotate_field_encoding { + // XXX: _42 was added to allow compiling because MIPS_OPCODE_SRL is already in an other enum. MIPS_OPCODE_SRL_42, MIPS_OPCODE_ROTR + }; enum SRLV_shiftrotate_field_ecoding { + // XXX: _42 was added to allow compiling because MIPS_OPCODE_SRL is already in an other enum. MIPS_OPCODE_SRLV_42, MIPS_OPCODE_ROTRV + }; enum BSHFL_sa_field_encoding { + MIPS_OPCODE_WSBH = Ob(00010), MIPS_OPCODE_SEB = Ob(10000), MIPS_OPCODE_SEH = Ob(11000) + }; enum COP2_func { - MIPS_OPCODE_MF, - MIPS_OPCODE_DMF, - MIPS_OPCODE_CF, - MIPS_OPCODE_MT = Ob(00100), - MIPS_OPCODE_DMT, - MIPS_OPCODE_CT, - MIPS_OPCODE_BC = Ob(01000) + + MIPS_OPCODE_MFC2, + MIPS_OPCODE_DMFC2, + MIPS_OPCODE_CFC2, + MIPS_OPCODE_MTC2 = Ob(00100), + MIPS_OPCODE_DMTC2, + MIPS_OPCODE_CTC2, + MIPS_OPCODE_BCC2 = Ob(01000) + }; enum COP1X_func { + MIPS_OPCODE_LWXC1 = Ob(000000), MIPS_OPCODE_LDXC1, MIPS_OPCODE_LUXC1 = Ob(000101), @@ -370,8 +397,90 @@ MIPS_OPCODE_NMSUB_S = Ob(111000), MIPS_OPCODE_NMSUB_D, MIPS_OPCODE_NMSUB_PS = Ob(111110) + +}; + +enum COP0_func { + + MIPS_OPCODE_MFC0, + MIPS_OPCODE_DMFC0, + MIPS_OPCODE_TLBWI, + MIPS_OPCODE_MTC0 = Ob(00100), + MIPS_OPCODE_DMTC0, + MIPS_OPCODE_TLBWR, + MIPS_OPCODE_ERET = Ob(011000), + MIPS_OPCODE_TLBP = Ob(001000), + MIPS_OPCODE_TLBR = Ob(000001), + MIPS_OPCODE_DERET = Ob(011111), + MIPS_OPCODE_WAIT +}; + +enum COP1_func { + + MIPS_OPCODE_F_ADD, + MIPS_OPCODE_F_SUB, + MIPS_OPCODE_F_MUL,// = Ob(000010), + MIPS_OPCODE_F_DIV, + MIPS_OPCODE_F_SQRT, + MIPS_OPCODE_ABS,// = Ob(000101), + MIPS_OPCODE_F_MOV, //=Ob(000110) + MIPS_OPCODE_F_NEG,// = Ob(000111), + MIPS_OPCODE_F_ROUND_L, + MIPS_OPCODE_F_TRUNC_L, + MIPS_OPCODE_F_ROUND_W = Ob(001100), + MIPS_OPCODE_F_TRUNC_W, + MIPS_OPCODE_F_CEIL_L = Ob(001010), + MIPS_OPCODE_F_FLOOR_L, + MIPS_OPCODE_F_CEIL_W = Ob(001110), + MIPS_OPCODE_F_FLOOR_W, + MIPS_OPCODE_F_RECIP = Ob(010101), + MIPS_OPCODE_F_RSQRT, + MIPS_OPCODE_F_MOVCF = Ob(010001), + MIPS_OPCODE_F_MOVZ, + MIPS_OPCODE_F_MOVN, + MIPS_OPCODE_F_CVT_S = Ob(100000), + MIPS_OPCODE_F_CVT_D,// = Ob(100001), + MIPS_OPCODE_F_CVT_W = Ob(100100), + MIPS_OPCODE_F_CVT_L,// = Ob(100101), + MIPS_OPCODE_F_CVT_PS_S, + MIPS_OPCODE_F_CVT_S_PL = Ob(101000), + MIPS_OPCODE_F_MFC1 = Ob(00000), + MIPS_OPCODE_F_CFC1 = Ob(00010), + MIPS_OPCODE_F_MTC1 = Ob(00100), + MIPS_OPCODE_F_CTC1 = Ob(00110) + +}; + +enum COP1_fmt { + + MIPS_OPCODE_FMT_S = Ob(10000), + MIPS_OPCODE_FMT_D, + MIPS_OPCODE_FMT_W = Ob(10100), + MIPS_OPCODE_FMT_L,// = Ob(10101), + MIPS_OPCODE_FMT_PS// = Ob(10110) + }; +enum COP1_cond { + + MIPS_OPCODE_COND_F, + MIPS_OPCODE_COND_UN, + MIPS_OPCODE_COND_EQ, + MIPS_OPCODE_COND_UEQ, + MIPS_OPCODE_COND_OLT, + MIPS_OPCODE_COND_ULT, + MIPS_OPCODE_COND_OLE, + MIPS_OPCODE_COND_ULE, + MIPS_OPCODE_COND_SF, + MIPS_OPCODE_COND_NGLE, + MIPS_OPCODE_COND_SEQ, + MIPS_OPCODE_COND_NGL, + MIPS_OPCODE_COND_LT, + MIPS_OPCODE_COND_NGE, + MIPS_OPCODE_COND_LE, + MIPS_OPCODE_COND_NGT + +}; /* XXX: privileged and fpu stuff.. not implemented yet*/ /* @@ -593,11 +702,192 @@ ASM_MIPS_NMSUB_S, ASM_MIPS_NMSUB_D, ASM_MIPS_NMSUB_PS, + + /* Chuj doklikalem to bo sie wkurwilem, jebane gowno - zycie to bagno... */ + /* Privileged instructions... */ +// ASM_MIPS_CACHE, + ASM_MIPS_MFC0, + ASM_MIPS_DMFC0, + ASM_MIPS_TLBWI, + ASM_MIPS_MTC0, + ASM_MIPS_DMTC0, + ASM_MIPS_TLBWR, + ASM_MIPS_ERET, + ASM_MIPS_TLBP, + ASM_MIPS_TLBR, + ASM_MIPS_WAIT, + + /* EJTAG Instructions... */ + ASM_MIPS_DERET, + ASM_MIPS_SDBBP, + /*TODO: * - FPU insns - * - privileged insns * */ + /* FPU arithmetics */ + ASM_MIPS_ABS_S, + ASM_MIPS_ABS_D, + ASM_MIPS_ABS_PS, + ASM_MIPS_ADD_S, + ASM_MIPS_ADD_D, + ASM_MIPS_ADD_PS, + + ASM_MIPS_DIV_S, + ASM_MIPS_DIV_D, + ASM_MIPS_MUL_S, + ASM_MIPS_MUL_D, + ASM_MIPS_MUL_PS, + ASM_MIPS_NEG_S, + ASM_MIPS_NEG_D, + ASM_MIPS_NEG_PS, + ASM_MIPS_RECIP_S, + ASM_MIPS_RECIP_D, + ASM_MIPS_RSQRT_S, + ASM_MIPS_RSQRT_D, + ASM_MIPS_SQRT_S, + ASM_MIPS_SQRT_D, + ASM_MIPS_SUB_S, + ASM_MIPS_SUB_D, + ASM_MIPS_SUB_PS, + + /* FPU Branch Instructions */ + + ASM_MIPS_BC1F, + ASM_MIPS_BC1T, + + /* FPU Compare Instruction */ +// ASM_MIPS_C.cond.fmt, + + /* FPU Convert Instructions */ + + ASM_MIPS_CEIL_L_S, + ASM_MIPS_CEIL_L_D, + ASM_MIPS_CEIL_W_S, + ASM_MIPS_CEIL_W_D, + + ASM_MIPS_CVT_D_S, + ASM_MIPS_CVT_D_W, + ASM_MIPS_CVT_D_L, + ASM_MIPS_CVT_L_S, + ASM_MIPS_CVT_L_D, + ASM_MIPS_CVT_PS_S, + ASM_MIPS_CVT_S_D, + ASM_MIPS_CVT_S_W, + ASM_MIPS_CVT_S_L, + ASM_MIPS_CVT_S_PL, + ASM_MIPS_CVT_S_PU, + ASM_MIPS_CVT_W_S, + ASM_MIPS_CVT_W_D, + + ASM_MIPS_FLOOR_L_S, + ASM_MIPS_FLOOR_L_D, + ASM_MIPS_FLOOR_W_S, + ASM_MIPS_FLOOR_W_D, + + ASM_MIPS_ROUND_L_S, + ASM_MIPS_ROUND_L_D, + ASM_MIPS_ROUND_W_S, + ASM_MIPS_ROUND_W_D, + + ASM_MIPS_TRUNC_L_S, + ASM_MIPS_TRUNC_L_D, + ASM_MIPS_TRUNC_W_S, + ASM_MIPS_TRUNC_W_D, + + /* FPU Load, Store and Memory Control Instructions */ + + ASM_MIPS_LDC1, + ASM_MIPS_LWC1, + ASM_MIPS_SDC1, + ASM_MIPS_SWC1, + + /* FPU Move Instructions */ + + ASM_MIPS_CFC1, + ASM_MIPS_CTC1, + ASM_MIPS_MFC1, + ASM_MIPS_MTC1, + + ASM_MIPS_MOV_S, + ASM_MIPS_MOV_D, + ASM_MIPS_MOV_PS, + + ASM_MIPS_MOVF_S, + ASM_MIPS_MOVF_D, + ASM_MIPS_MOVF_PS, + + ASM_MIPS_MOVT_S, + ASM_MIPS_MOVT_D, + ASM_MIPS_MOVT_PS, + + ASM_MIPS_MOVN_S, + ASM_MIPS_MOVN_D, + ASM_MIPS_MOVN_PS, + + ASM_MIPS_MOVZ_S, + ASM_MIPS_MOVZ_D, + ASM_MIPS_MOVZ_PS, + + /* FPU Absolute Branch Instructions */ + + ASM_MIPS_BC1FL, + ASM_MIPS_BC1TL, + + /* BUGFIX */ + ASM_MIPS_DMTC1, + ASM_MIPS_DMFC1, + + /* C.cond.fmt glupie instrukcje :) */ + ASM_MIPS_C_F_S, + ASM_MIPS_C_F_D, + ASM_MIPS_C_F_PS, + ASM_MIPS_C_UN_S, + ASM_MIPS_C_UN_D, + ASM_MIPS_C_UN_PS, + ASM_MIPS_C_EQ_S, + ASM_MIPS_C_EQ_D, + ASM_MIPS_C_EQ_PS, + ASM_MIPS_C_UEQ_S, + ASM_MIPS_C_UEQ_D, + ASM_MIPS_C_UEQ_PS, + ASM_MIPS_C_OLT_S, + ASM_MIPS_C_OLT_D, + ASM_MIPS_C_OLT_PS, + ASM_MIPS_C_ULT_S, + ASM_MIPS_C_ULT_D, + ASM_MIPS_C_ULT_PS, + ASM_MIPS_C_OLE_S, + ASM_MIPS_C_OLE_D, + ASM_MIPS_C_OLE_PS, + ASM_MIPS_C_ULE_S, + ASM_MIPS_C_ULE_D, + ASM_MIPS_C_ULE_PS, + ASM_MIPS_C_SF_S, + ASM_MIPS_C_SF_D, + ASM_MIPS_C_SF_PS, + ASM_MIPS_C_NGLE_S, + ASM_MIPS_C_NGLE_D, + ASM_MIPS_C_NGLE_PS, + ASM_MIPS_C_SEQ_S, + ASM_MIPS_C_SEQ_D, + ASM_MIPS_C_SEQ_PS, + ASM_MIPS_C_NGL_S, + ASM_MIPS_C_NGL_D, + ASM_MIPS_C_NGL_PS, + ASM_MIPS_C_LT_S, + ASM_MIPS_C_LT_D, + ASM_MIPS_C_LT_PS, + ASM_MIPS_C_NGE_S, + ASM_MIPS_C_NGE_D, + ASM_MIPS_C_NGE_PS, + ASM_MIPS_C_LE_S, + ASM_MIPS_C_LE_D, + ASM_MIPS_C_LE_PS, + ASM_MIPS_C_NGT_S, + ASM_MIPS_C_NGT_D, + ASM_MIPS_C_NGT_PS, + ASM_MIPS_BAD }; @@ -912,3 +1202,160 @@ int asm_mips_nmsub_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); int asm_mips_nmsub_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); int asm_mips_nmsub_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// Privilaged Instructions - COP0 + +int asm_mips_mfc0(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_dmfc0(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_tlbwi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mtc0(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_dmtc0(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_tlbwr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_eret(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_tlbp(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_tlbr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_wait(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_deret(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sdbbp(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU - arithmetic... +int asm_mips_abs_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_abs_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_abs_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_add_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_add_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_add_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_div_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_div_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mul_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mul_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mul_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_neg_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_neg_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_neg_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_recip_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_recip_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_rsqrt_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_rsqrt_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sqrt_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sqrt_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sub_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sub_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sub_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU Branch Instructions +int asm_mips_bc1f(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_bc1t(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU Convert Instructions +int asm_mips_ceil_l_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_ceil_l_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_ceil_w_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_ceil_w_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_d_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_d_w(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_d_l(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_l_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_l_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_ps_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_s_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_s_w(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_s_l(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_s_pl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_s_pu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_w_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_cvt_w_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_floor_l_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_floor_l_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_floor_w_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_floor_w_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_round_l_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_round_l_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_round_w_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_round_w_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_trunc_l_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_trunc_l_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_trunc_w_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_trunc_w_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU Load, Store and Memory Control Instructions +int asm_mips_ldc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_lwc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_sdc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_swc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU Move Instructions +int asm_mips_cfc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_ctc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mfc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mtc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mov_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mov_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_mov_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movcf_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movcf_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movcf_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movn_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movn_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movn_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movz_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movz_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_movz_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// FPU Absolute Branch Instructions +int asm_mips_bc1fl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_bc1tl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// BUGFIX +int asm_mips_dmtc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_dmfc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); + +// C.cond.fmt glupie instrukcje :) +int asm_mips_c_f_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_f_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_f_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_un_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_un_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_un_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_eq_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_eq_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_eq_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ueq_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ueq_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ueq_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_olt_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_olt_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_olt_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ult_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ult_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ult_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ole_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ole_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ole_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ule_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ule_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ule_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_sf_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_sf_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_sf_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngle_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngle_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngle_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_seq_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_seq_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_seq_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngl_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngl_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngl_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_lt_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_lt_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_lt_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_nge_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_nge_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_nge_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_le_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_le_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_le_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngt_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngt_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); +int asm_mips_c_ngt_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); diff -Nru eresi-0.8a25/libasm/include/libasm-mips-structs.h eresi-0.0.20110516/libasm/include/libasm-mips-structs.h --- eresi-0.8a25/libasm/include/libasm-mips-structs.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-mips-structs.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,9 +1,14 @@ /** - * $Id: libasm-mips-structs.h,v 1.1 2007/01/23 09:53:03 heroine Exp $ - * - * fix and fill + * @defgroup MIPS_instrs MIPS instructions disassembler. + * @ingroup mips + */ +/** +* @file libasm/include/libasm-mips-structs.h + * @ingroup mips + * fix and fill * - Adam 'pi3' Zabrocki * + * $Id: libasm-mips-structs.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef LIBASM_MIPS_STRUCTS_H #define LIBASM_MIPS_STRUCTS_H @@ -81,6 +86,8 @@ u_int32_t sl:3; }; +#define s_mips_decode_priv s_mips_decode_cop2 + /** * Structure used to decode COP1X format instructions */ diff -Nru eresi-0.8a25/libasm/include/libasm-sparc-decode.h eresi-0.0.20110516/libasm/include/libasm-sparc-decode.h --- eresi-0.8a25/libasm/include/libasm-sparc-decode.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-sparc-decode.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,14 +1,13 @@ -/* -** libasm-sparc-decode.h for in /hate/home/hate/code/libasm_current -** -** Made by #!HATE#@! -** Login -** -** Started on Tue Jun 14 05:02:37 2005 #!HATE#@! -** Last update Tue Jun 14 06:06:32 2005 #!HATE#@! -** -** $Id: libasm-sparc-decode.h,v 1.4 2007/03/07 16:45:34 thor Exp $ +/** + * @defgroup SPARC_instrs SPARC instructions API. + * @ingroup sparc + */ +/** +* @file libasm/include/libasm-sparc-decode.h +** @ingroup sparc ** +** Started by sroy on Tue Jun 14 05:02:37 2005 +** $Id: libasm-sparc-decode.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef LIBASM_SPARC_DECODE_H_ diff -Nru eresi-0.8a25/libasm/include/libasm-sparc.h eresi-0.0.20110516/libasm/include/libasm-sparc.h --- eresi-0.8a25/libasm/include/libasm-sparc.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-sparc.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,13 +1,14 @@ -/* -** -** sparc.h in +/** + * @defgroup sparc Libasm SPARC support. + * @ingroup libasm + */ + +/** +* @file libasm/include/libasm-sparc.h +** @ingroup sparc ** -** Author : -** Started : Tue Dec 2 22:43:08 2003 -** Updated : Thu Dec 4 03:29:25 2003 -** -** $Id: libasm-sparc.h,v 1.14 2008/01/07 01:29:53 heroine Exp $ -** +** Started by sroy on Tue Dec 2 22:43:08 2003 +** $Id: libasm-sparc.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef LIBASM_SPARC_H_ @@ -159,7 +160,7 @@ void sparc_convert_format3(struct s_decode_format3 *, u_char *); void sparc_convert_format4(struct s_decode_format4 *, u_char *); -void asm_resolve_sparc(void *, u_int, char *, u_int); +void asm_resolve_sparc(void *, eresi_Addr, char *, u_int); /* Get operand name */ char *asm_sparc_get_op_name (asm_operand *op); diff -Nru eresi-0.8a25/libasm/include/libasm-structs.h eresi-0.0.20110516/libasm/include/libasm-structs.h --- eresi-0.8a25/libasm/include/libasm-structs.h 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/libasm-structs.h 2011-05-16 11:34:17.000000000 +0000 @@ -1,14 +1,8 @@ /** - * @file libasm-structs.h +* @file libasm/include/libasm-structs.h * - * Made by #!HATE#@! - * Login - * - * Started on Tue Jun 14 05:00:05 2005 #!HATE#@! - * Last update Thu Jun 16 04:56:41 2005 #!HATE#@! - * - * $Id: libasm-structs.h,v 1.15 2007/10/29 11:26:44 heroine Exp $ - * + * Started on Tue Jun 14 05:00:05 2005 Sebastien Roy + * $Id: libasm-structs.h 1440 2010-12-29 02:22:03Z may $ */ /** @@ -16,14 +10,13 @@ */ struct s_asm_op { - /* pointer to processor structure. - to remove - */ - //asm_processor *proc; + /** operand length. (usefull on ia32 only). * operands expressed in R byte from ModRM byte have a null size. */ u_int len; /* pointer to operand in buffer */ u_char *ptr; - /* operand type: contain operand type flags */ + /* operand type: contain operandb type flags */ u_int type; /* a pointer to the operand name in string format */ char *name; @@ -31,8 +24,8 @@ u_int size; /* Operand content flags */ u_int content; - /* register set: 8/16/32 bits general registers, segment registers .. - * (ia32 only) */ + /* register set: 8/16/32 bits general registers, segment registers .. (IA32 only) */ + /* register set: usr, svc, abt, und, irq, fiq (arm) */ int regset; /* operand prefix (ia32 only) */ int prefix; @@ -42,10 +35,13 @@ int baser; /* index register: auxiliary register */ int indexr; - /* */ + /* String for base register */ char *sbaser; - /* */ + /* String for index register */ char *sindex; + /* Determines if this register is source or destination */ + int destination; + /* address space (sparc only) * * has to be different than ASM_SP_ASI_P for ASM_SP_OTYPE_IMM_ADDRESS @@ -54,6 +50,12 @@ int address_space; /* scale factor (ia32 only) */ unsigned int scale; + /* shift type (arm only) */ + u_int shift_type; + /* indexing type (arm only) */ + u_int indexing; + /* determines if offset is added or subtracted from the base (arm only) */ + u_int offset_added; }; @@ -89,13 +91,15 @@ /* annul bit (sparc only) */ int annul; /* prediction bit (sparc only) */ - int prediction; + int prediction; /* number of operand */ int nb_op; /* Array of operands */ - asm_operand op[4]; + asm_operand op[6]; /* instruction/operands full lengh */ u_int len; + /* If arithmetic, make explicit what kind of operation is done */ + u_int arith; }; @@ -113,22 +117,26 @@ struct s_asm_processor { /* handler to resolving function */ - void (*resolve_immediate)(void *, u_int, char *, u_int); + void (*resolve_immediate)(void *, eresi_Addr, char *, u_int); + /* handler data pointer */ void *resolve_data; + /* processor type */ int type; + /* array to instruction memonic by instr field of asm_instr */ char **instr_table; + /* fetching instruction. points to processor fetching function. */ LIBASM_HANDLER_FETCH(fetch); - //int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *proc); + /* output handler. print instruction in a readable string */ - char *(*display_handle)(asm_instr *instr, int addr); + char *(*display_handle)(asm_instr *instr, eresi_Addr addr); + /* pointer to an internal structure. */ void *internals; + /* Last operation error code */ int error_code; - - }; diff -Nru eresi-0.8a25/libasm/include/.svn/all-wcprops eresi-0.0.20110516/libasm/include/.svn/all-wcprops --- eresi-0.8a25/libasm/include/.svn/all-wcprops 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/945/trunk/libasm/include -END -libasm-structs.h -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/945/trunk/libasm/include/libasm-structs.h -END -libasm-mips.h -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/938/trunk/libasm/include/libasm-mips.h -END -libasm-sparc.h -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/849/trunk/libasm/include/libasm-sparc.h -END -libasm-i386.h -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/896/trunk/libasm/include/libasm-i386.h -END -libasm-sparc-decode.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/849/trunk/libasm/include/libasm-sparc-decode.h -END -libasm-int.h -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/849/trunk/libasm/include/libasm-int.h -END -libasm-mips-structs.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/938/trunk/libasm/include/libasm-mips-structs.h -END -libasm.h -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/896/trunk/libasm/include/libasm.h -END -libasm-ia32-hdl.h -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/843/trunk/libasm/include/libasm-ia32-hdl.h -END diff -Nru eresi-0.8a25/libasm/include/.svn/entries eresi-0.0.20110516/libasm/include/.svn/entries --- eresi-0.8a25/libasm/include/.svn/entries 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,136 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:24:43.639027Z -945 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libasm-structs.h -file - - - - -2008-04-06T23:15:54.091887Z -2f9ce74c0f749ab611a3c9639b9b2858 -2008-03-27T22:24:43.639027Z -945 -may - -libasm-mips.h -file - - - - -2008-04-06T23:15:54.209368Z -44e59c84fcb300d5454276a6ae63580b -2008-03-26T17:25:46.832365Z -938 -pi3 - -libasm-sparc.h -file - - - - -2008-04-06T23:15:54.220876Z -c4a76b021b1ea1736ad67dfc93bfe137 -2008-02-19T17:09:59.893936Z -849 -may - -libasm-i386.h -file - - - - -2008-04-06T23:15:54.231899Z -f184a209869c7d5e1d7498f8789bdaef -2008-03-07T17:49:34.750118Z -896 -thorkill - -libasm-sparc-decode.h -file - - - - -2008-04-06T23:15:54.243503Z -9977c173a38dce9b721dff51ccdecf1d -2008-02-19T17:09:59.893936Z -849 -may - -libasm-int.h -file - - - - -2008-04-06T23:15:54.254966Z -24096971a78376c9a223e9433494d3b3 -2008-02-19T17:09:59.893936Z -849 -may - -libasm-mips-structs.h -file - - - - -2008-04-06T23:15:54.266367Z -ebfdcc8d8a1f24f1947f93fbc8bf7dec -2008-03-26T17:25:46.832365Z -938 -pi3 - -libasm.h -file - - - - -2008-04-06T23:15:54.277876Z -41896c666a98b08338975e9b361288d7 -2008-03-07T17:49:34.750118Z -896 -thorkill - -libasm-ia32-hdl.h -file - - - - -2008-04-06T23:15:54.289110Z -bee1f57baf342b9e98d4fa13bcf18c76 -2008-02-16T12:32:28.000000Z -843 -thor - diff -Nru eresi-0.8a25/libasm/include/.svn/format eresi-0.0.20110516/libasm/include/.svn/format --- eresi-0.8a25/libasm/include/.svn/format 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm.h.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,450 +0,0 @@ -/** - * @file libasm.h - * $Id: libasm.h,v 1.31 2008/02/01 01:56:53 heroine Exp $ - * - * Author : - * Started : Sat Oct 26 01:18:46 2002 - * Updated : Thu Apr 8 00:45:41 2004 - * - * This is the main definition file for libasm.h - * Definitions, enums, prototypes or anything related - * to a specific architecture MUST be stored in that specific - * architecture include files. - * - * - */ - -/** - * @brief It contains the main define types and prototypes. - * @todo Reorganize include files content. - */ - -/** - * @defgroup operands Operands related API - */ - -/** - * @defgroup handlers_ia32 IA32 Fechting handlers. - */ - -#ifndef LIBASM_H_ -#define LIBASM_H_ - - -#ifndef __KERNEL__ - -#include -#include -#include -#include -#if defined(__OpenBSD__) ||defined(__FreeBSD__) || defined(sgi) || defined(__NetBSD__) -#include -#elif !defined(sun) -#include -#else -#include -#endif - -#endif - -#include - -#define LIBASM_SUPPORT_SPARC 1 -#define LIBASM_SUPPORT_IA32 1 -#define LIBASM_SUPPORT_MIPS 0 /*error_code. - * XXX: Being implemented. Currently not accurate. - */ -enum e_libasm_errorcode - { -#define LIBASM_MSG_ERRORNOTIMPLEMENTED "error message not implemented" - LIBASM_ERROR_SUCCESS, -#define LIBASM_MSG_SUCCESS "success" - LIBASM_ERROR_NSUCH_CONTENT, -#define LIBASM_MSG_NSUCH_CONTENT "no such content" - LIBASM_ERROR_ILLEGAL, -#define LIBASM_MSG_ILLEGAL "illegal instruction" - LIBASM_ERROR_TOOSHORT, -#define LIBASM_MSG_TOOSHORT "data length too short" - }; - -#include -#include -#include -#include - -#endif - - - - diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-i386.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-i386.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-i386.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-i386.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,958 +0,0 @@ -/** - * @file libasm-i386.h - * @brief Contains structures,prototypes and defines/enum related to ia32. - * $Id: libasm-i386.h,v 1.14 2008/01/07 01:29:53 heroine Exp $ - */ - -#ifndef LIBASM_I386_H_ -#define LIBASM_I386_H_ - -#include -typedef struct s_asm_i386_processor asm_i386_processor; -typedef struct s_asm_i386_table asm_i386_table; - -void asm_resolve_ia32(void *d, u_int, char *, u_int); - -/** - * ia32 related functions. - */ - - -int asm_content_pack(asm_operand *, int, int); -int asm_fixed_pack(int, int, int, int); - - -/** - * this structure is internal and may not be accessed by user - * directly. it contains reference to each table describing i386 opcodes - * refer to sandpile.org - */ - -struct s_asm_proc_i386 { - /* compatibility */ - - int mode; /*!< processor state: opsize actived or not */ - - int vect_size; - int addsize; /*!< WIPcurrent state of the processor addsize prefix */ - int opsize; /*!< WIPcurrent state of the processor addsize prefix */ - - int type; /*!< WIPcurrent state of the processor addsize prefix */ - //int (*get_vect_size)(asm_processor *); /*!< Internal handler unused */ -}; - - -/** - * Content of the operand. - * Those flags are stored in asm_operand.content field. - */ -#define ASM_OP_VALUE 1 /*!< immediate value present */ -#define ASM_OP_BASE 2 /*!< base register present */ -#define ASM_OP_INDEX 4 /*!< index register present */ -#define ASM_OP_SCALE 8 /*!< scale factor present */ - -#define ASM_OP_FIXED 16 -#define ASM_OP_REFERENCE 32 /*!< reference */ -#define ASM_OP_ADDRESS 64 /*!< reference to a reference */ -#define ASM_OP_FPU 128 /*!< operand is a FPU reference */ - -/** - * prefix - * |F|E|D|C|B|A|9|8|7|6|5|4|3|2|1|0| - * - * 0: rep - * 1: repne - * 2345: - * 0001: DS - * 0010: ES - * 0011: SS - * 0100: CS - * 0101: FS - * 0110: GS - * 6: lock - * 7: opsize - * 8: addsize - */ - -/** - * Enum of the intel available prefixes. - */ - -enum e_ia32_prefix - { - ASM_PREFIX_REP = 1, /*!< rep prefix */ - ASM_PREFIX_REPNE = 2, /*!< repne prefix */ - - ASM_PREFIX_SEG = 60, /*!< Segment prefix mask */ - - ASM_PREFIX_DS = 4, /*!< ds prefix */ - ASM_PREFIX_ES = 8, /*!< es prefix */ - ASM_PREFIX_SS = 12, /*!< ss prefix */ - ASM_PREFIX_CS = 16, /*!< cs prefix */ - ASM_PREFIX_FS = 20, /*!< fs prefix */ - ASM_PREFIX_GS = 24, - - ASM_PREFIX_MASK = 60, - - ASM_PREFIX_LOCK = 64, - ASM_PREFIX_OPSIZE = 128, - ASM_PREFIX_ADDSIZE = 256, - ASM_PREFIX_FWAIT = 512, - }; - -/** - * Control register bit flags - * - */ -enum e_ia32_flags - { - ASM_FLAG_CF = 1 << 0, /*!< carry flag */ - ASM_FLAG_PF = 1 << 2, /*!< parity flag */ - ASM_FLAG_AF = 1 << 4, /*!< ?? flag */ - ASM_FLAG_ZF = 1 << 6, /*!< zero flag */ - ASM_FLAG_SF = 1 << 7, /*!< signed flag */ - ASM_FLAG_TF = 1 << 8, /*!< ?? flag */ - ASM_FLAG_IF = 1 << 9, /*!< interrupt flag */ - ASM_FLAG_DF = 1 << 10, /*!< debug flag ? */ - ASM_FLAG_OF = 1 << 11, - ASM_FLAG_IOPL = 1 << 12, - ASM_FLAG_NT = 1 << 14, - - ASM_FLAG_RF = 1 << 16, - ASM_FLAG_VM = 1 << 17, - ASM_FLAG_AC = 1 << 18, - ASM_FLAG_VIF = 1 << 19, - ASM_FLAG_VIP = 1 << 20, - ASM_FLAG_ID = 1 << 21 - }; - - -/** - * Content of the struct s_operand type field - */ - -enum e_asm_operand_type { - /* no operand - */ - ASM_OTYPE_NONE, - /* operand is fixed in instruction coded by this opcode; - */ - ASM_OTYPE_FIXED, - /* register is coded in mod field of instruction opcode. - */ - ASM_OTYPE_OPMOD, - /* direct address; no mod R/M byte; - * address of operand is encoded in instruction; - * no base register, index register, or scaling factor can be applied - */ - ASM_OTYPE_ADDRESS, - /* reg field of mod R/M byte selects a control register - */ - ASM_OTYPE_CONTROL, - /* reg field of mod R/M byte selects a debug register - */ - ASM_OTYPE_DEBUG, - /* mod R/M byte follows opcode and specifies operand; - * operand is either a general register or a memory address; - * if it is a memory address, the address is computed from - * a segment register and any of the following values: - * a base register, an index register, a scaling factor, a displacement - */ - ASM_OTYPE_ENCODED, - ASM_OTYPE_ENCODEDBYTE, - /* flags registers - */ - ASM_OTYPE_FLAGS, - /* reg field of mod R/M byte selelcts a general register. - */ - ASM_OTYPE_GENERAL, - ASM_OTYPE_GENERALBYTE, - /* immediate data; value of operand is encoded in subsequent bytes - * of instruction - */ - ASM_OTYPE_IMMEDIATE, - ASM_OTYPE_IMMEDIATEWORD, - /* immediate data; value of operand is encoded in subsequent bytes - * of instruction - */ - ASM_OTYPE_IMMEDIATEBYTE, - /* instruction contains a relative offset to be added - * to the instruction pointer register - */ - ASM_OTYPE_SHORTJUMP, - /* instruction contains a relative one byte offset to be added - * to the instruction pointer register - */ - ASM_OTYPE_JUMP, - /* mod R/M only refer to memory - */ - ASM_OTYPE_MEMORY, - /* instruction has no mod R/M byte; | - * offset of operand is coded as a word or double word (depending on - * address size attribute) in instruction; | - * no base register, index register, or scaling factor can be applied; - * eg. MOV (A0..A3h) - */ - ASM_OTYPE_OFFSET, - /* reg field of mod R/M byte selects a packed quadword MMX register - */ - ASM_OTYPE_PMMX, - /* mod R/M byte follows opcode and specifies operand; operand is - * either an MMX register or a memory address; - * if it is a memory address, the address is computed - * from a segment register and any of the following values: - * |a base register, an index register, a scaling factor, a displacement - */ - ASM_OTYPE_QMMX, - /* - * mod field of mod R/M byte may refer only to a general register - */ - ASM_OTYPE_REGISTER, - /* reg field of mod R/M byte selects a segment register - */ - ASM_OTYPE_SEGMENT, - /* no operand - */ - ASM_OTYPE_TEST, - /* no operand - */ - ASM_OTYPE_VSFP, - /* no operand - */ - ASM_OTYPE_WSFP, - /* memory addressed by ds:si - */ - ASM_OTYPE_XSRC, - /* memory addressed by es:di - */ - ASM_OTYPE_YDEST, - /* immediate value encoded in instruction - */ - ASM_OTYPE_VALUE, - ASM_OTYPE_REG0, - ASM_OTYPE_REG1, - ASM_OTYPE_REG2, - ASM_OTYPE_REG3, - ASM_OTYPE_REG4, - ASM_OTYPE_REG5, - ASM_OTYPE_REG6, - ASM_OTYPE_REG7, - - ASM_OTYPE_ST, - ASM_OTYPE_ST_0, - ASM_OTYPE_ST_1, - ASM_OTYPE_ST_2, - ASM_OTYPE_ST_3, - ASM_OTYPE_ST_4, - ASM_OTYPE_ST_5, - ASM_OTYPE_ST_6, - ASM_OTYPE_ST_7, - ASM_OTYPE_NUM -}; - -/** - * Content of the struct s_operand size field - * - */ - -enum e_asm_operand_size { - ASM_OSIZE_NONE, - ASM_OSIZE_BYTE, - ASM_OSIZE_WORD, - ASM_OSIZE_DWORD, - ASM_OSIZE_QWORD, - ASM_OSIZE_OWORD, - ASM_OSIZE_CHAR, - ASM_OSIZE_VECTOR, - ASM_OSIZE_POINTER, - ASM_OSIZE_ADDRESS, - ASM_OSIZE_6BYTES -}; - - -/** - * Currently unsupported. - */ -enum e_asm_enc { - ASM_ENC_NONE, - ASM_ENC_ADDRESS, - ASM_ENC_CONTROL, - ASM_ENC_DEBUG, - ASM_ENC_ENCODED, - ASM_ENC_FLAGS, - ASM_ENC_GENERAL, - ASM_ENC_IMMEDIATE, - ASM_ENC_JUMP, - ASM_ENC_MEMORY, - ASM_ENC_OFFSET, - ASM_ENC_P, - ASM_ENC_Q, - ASM_ENC_R, - ASM_ENC_SEGREG, - ASM_ENC_TEST, - ASM_ENC_VREGPACKEDFP, - ASM_ENC_WMOD, - ASM_ENC_SRC, - ASM_ENC_DST, - /* */ - ASM_ENC_REG0, - ASM_ENC_REG1, - ASM_ENC_REG2, - ASM_ENC_REG3, - ASM_ENC_REG4, - ASM_ENC_REG5, - ASM_ENC_REG6, - ASM_ENC_REG7 -}; - -#define ASM_ENC_ANY ( ASM_ENC_ADDRESS | ASM_ENC_CONTROL | ASM_ENC_DEBUG | \ - ASM_ENC_ENCODED | ASM_ENC_FLAGS | ASM_ENC_GENERAL | ASM_ENC_IMMEDIATE | \ - ASM_ENC_JUMP | ASM_ENC_MEMORY | ASM_ENC_OFFSET | ASM_ENC_P | ASM_ENC_Q | \ - ASM_ENC_R | ASM_ENC_SEGREG | ASM_ENC_TEST | ASM_ENC_VREGPACKEDFP | ASM_ENC_WMOD | \ - ASM_ENC_SRC | ASM_ENC_DST | \ - ASM_ENC_REG0 | ASM_ENC_REG1 | ASM_ENC_REG2 | ASM_ENC_REG3 | ASM_ENC_REG4 | \ - ASM_ENC_REG5 | ASM_ENC_REG6 | ASM_ENC_REG7) - -enum e_asm_size { - ASM_SIZE_BYTE, - ASM_SIZE_WORD, - ASM_SIZE_DWORD, - ASM_SIZE_QWORD, - ASM_SIZE_OWORD, - ASM_SIZE_CWORD, - ASM_SIZE_VECTOR, - ASM_SIZE_30BITS -}; - -#define ASM_SIZE_ANY (ASM_SIZE_BYTE | ASM_SIZE_WORD | ASM_SIZE_DWORD |\ - ASM_SIZE_QWORD | ASM_SIZE_CWORD | ASM_SIZE_VECTOR) - -/** - * regset - * - */ - -#define ASM_REGSET_R8 256 /* al,cl,dl... */ -#define ASM_REGSET_R16 512 /* ax,cx,dx... */ -#define ASM_REGSET_R32 1024 /* eax,ecx,edx... */ -#define ASM_REGSET_MM 2048 /* mm0, mm1, mm2 */ -#define ASM_REGSET_XMM 4096 /* xmm0, xmm1... */ -#define ASM_REGSET_SREG 8192 /* es, cs, ss ... */ -#define ASM_REGSET_CREG 16384 /* cr0, cr1 ... */ -#define ASM_REGSET_DREG 32768 /* dr0, dr1, ... */ - - -/** - * enum - * - * here follows enums for each regsets. - * - **/ - -/** - * 8 bits registers set. - */ - -enum e_asm_reg8 { - ASM_REG_AL, /* 000 */ - ASM_REG_CL, /* 001 */ - ASM_REG_DL, /* 010 */ - ASM_REG_BL, /* 011 */ - ASM_REG_AH, /* 100 */ - ASM_REG_CH, /* 101 */ - ASM_REG_DH, /* 110 */ - ASM_REG_BH /* 111 */ -}; - -/** - * 16 bits registers set. - */ - -enum e_asm_reg16 { - ASM_REG_AX, /* 000 */ - ASM_REG_CX, /* 001 */ - ASM_REG_DX, /* 010 */ - ASM_REG_BX, /* 011 */ - ASM_REG_SP, /* 100 */ - ASM_REG_BP, /* 101 */ - ASM_REG_SI, /* 110 */ - ASM_REG_DI /* 111 */ -}; - -/** - * @brief 32 bits registers set. - */ - -enum e_regset_r32 { - ASM_REG_EAX, /* 000 */ - ASM_REG_ECX, /* 001 */ - ASM_REG_EDX, /* 010 */ - ASM_REG_EBX, /* 011 */ - ASM_REG_ESP, /* 100 */ - ASM_REG_EBP, /* 101 */ - ASM_REG_ESI, /* 110 */ - ASM_REG_EDI /* 111 */ - }; - -/** - * @brief MM registers set. - */ - -enum e_asm_regmm { - ASM_REG_MM0, /* 110 */ - ASM_REG_MM1, /* 110 */ - ASM_REG_MM2, /* 110 */ - ASM_REG_MM3, /* 110 */ - ASM_REG_MM4, /* 110 */ - ASM_REG_MM6, /* 110 */ - ASM_REG_MM7 /* 110 */ -}; - -/** - * @brief XMMS registers set. - */ -enum e_asm_regxmm { - ASM_REG_XMM0, /* 110 */ - ASM_REG_XMM1, /* 110 */ - ASM_REG_XMM2, /* 110 */ - ASM_REG_XMM3, /* 110 */ - ASM_REG_XMM4, /* 110 */ - ASM_REG_XMM5, /* 110 */ - ASM_REG_XMM6, /* 110 */ - ASM_REG_XMM7 /* 110 */ -}; - -/** - * @brief Segment registers set. - */ - -enum e_asm_sreg { - ASM_REG_ES, /* 000 */ - ASM_REG_CS, /* 001 */ - ASM_REG_SS, /* 010 */ - ASM_REG_DS, /* 011 */ - ASM_REG_FS, /* 100 */ - ASM_REG_GS, /* 101 */ - ASM_REG_SREGRES1, - ASM_REG_SREGRES2 - -}; - -/** - * @brief Control registers set. - */ - -enum e_asm_creg { - ASM_REG_CR0, /* 000 */ - ASM_REG_CR1, /* 001 */ - ASM_REG_CR2, /* 010 */ - ASM_REG_CR3, /* 011 */ - ASM_REG_CR4, /* 100 */ - ASM_REG_CR5, /* 101 */ - ASM_REG_CR6, /* 110 */ - ASM_REG_CR7 /* 111 */ -}; - -/** - * @brief Debug registers set - */ - -enum e_asm_dreg { - ASM_REG_DR0, /* 000 */ - ASM_REG_DR1, /* 001 */ - ASM_REG_DR2, /* 010 */ - ASM_REG_DR3, /* 011 */ - ASM_REG_DR4, /* 100 */ - ASM_REG_DR5, /* 101 */ - ASM_REG_DR6, /* 110 */ - ASM_REG_DR7 /* 111 */ -}; - -/** - * @brief Instruction list. - * Last instruction must be ASM_BAD - * If NOT, this may produce allocation error as ASM_BAD is used to allocate - * size of the instruction label array. - * Refer to init_instr_table in tables_i386.c - */ - -enum asm_instr { - ASM_NONE, - /* special instr id */ - ASM_IPREFIX_MIN, - ASM_IPREFIX_CS, - ASM_IPREFIX_DS, - ASM_IPREFIX_ES, - ASM_IPREFIX_FS, - ASM_IPREFIX_GS, - ASM_IPREFIX_SS, - ASM_IPREFIX_OPSIZE, - ASM_IPREFIX_ADSIZE, - ASM_IPREFIX_MAX, - ASM_GROUP_MIN, - ASM_GROUP1, - ASM_GROUP2, - ASM_GROUP3, - ASM_GROUP4, - ASM_GROUP5, - ASM_GROUP6, - ASM_GROUP7, - ASM_GROUP8, - ASM_GROUP9, - ASM_GROUP10, - ASM_GROUP11, - ASM_GROUP12, - ASM_GROUP13, - ASM_GROUP14, - ASM_GROUP15, - ASM_GROUP16, - ASM_GROUP17, - ASM_ESC0, - ASM_ESC1, - ASM_ESC2, - ASM_ESC3, - ASM_ESC4, - ASM_ESC5, - ASM_ESC6, - ASM_ESC7, - ASM_GROUP_MAX, - ASM_2BYTES, - - /* instructions */ - - ASM_CALL, - ASM_BRANCH, - ASM_BRANCH_U_LESS, - ASM_BRANCH_U_LESS_EQUAL, - ASM_BRANCH_S_LESS, - ASM_BRANCH_S_LESS_EQUAL, - ASM_BRANCH_U_GREATER, - ASM_BRANCH_U_GREATER_EQUAL, - ASM_BRANCH_S_GREATER, - ASM_BRANCH_S_GREATER_EQUAL, - /* 10 */ - ASM_BRANCH_EQUAL, - ASM_BRANCH_NOT_EQUAL, - /* x86 specific */ - ASM_BRANCH_PARITY, - ASM_BRANCH_NOT_PARITY, - ASM_BRANCH_OVERFLOW, - /* 15 */ - ASM_BRANCH_NOT_OVERFLOW, - ASM_BRANCH_SIGNED, - ASM_BRANCH_NOT_SIGNED, - ASM_BRANCH_CXZ, - /* */ - ASM_JO, - ASM_JNO, - ASM_JB, - ASM_JNB, - ASM_JZ, - ASM_JNZ, - ASM_JBE, - ASM_JNBE, - ASM_JS, - ASM_JNS, - ASM_JP, - ASM_JNP, - ASM_JL, - ASM_JNL, - ASM_JLE, - ASM_JNLE, - /* generic instruction */ - ASM_ADD, - ASM_CBW, - ASM_CWD, - /* 20 */ - ASM_LEA, - ASM_OR, - ASM_ADC, - ASM_SBB, - ASM_AND, - /* 25 */ - ASM_SUB, - ASM_XOR, - ASM_XADD, - ASM_CLFLUSH, - ASM_CMP, - ASM_IN, - ASM_INC, - /* 30 */ - ASM_DEC, - ASM_PUSH, - ASM_PUSHF, - ASM_CWTD, - ASM_CBTW, - ASM_POP, - ASM_POPF, - /* 35 */ - ASM_TEST, - ASM_NOP, - ASM_LOAD, - ASM_STORE, - ASM_MOV, - ASM_MOVW, - /* 40 */ - ASM_INT, - ASM_RET, - ASM_XCHG, - ASM_INSB, - ASM_INSW, - ASM_INSD, - ASM_PUSHA, - ASM_POPA, - /* 45 */ - ASM_AAM, - ASM_AAD, - ASM_LOCK, - ASM_LOOP, - ASM_LOOPE, - /* 50 */ - ASM_LOOPNE, - ASM_JECX, - ASM_SALC, - ASM_LEAVE, - ASM_HLT, - ASM_SHR, - ASM_DIV, - /* 55 */ - ASM_IDIV, - ASM_MUL, - ASM_IMUL, - ASM_NOT, - ASM_NEG, - /* 60 */ - ASM_SAHF, - ASM_LAHF, - ASM_MOVSB, - ASM_MOVSBW, - ASM_MOVSD, - ASM_CMPSB, - ASM_CMPSW, - /* 65 */ - ASM_CMPSD, - ASM_STOSB, - ASM_STOSW, - ASM_STOSD, - ASM_LODSB, - ASM_LODSD, - /* 70 */ - ASM_SCASB, - ASM_SCASD, - ASM_INTO, - ASM_IRET, - ASM_SHIFT, - /* 75 */ - ASM_XLATB, - ASM_XLAT, - ASM_ORB, - /* 80 */ - ASM_MOVZWL, - ASM_CLD, - ASM_SMSW, - ASM_LMSW, - /* 85 */ - ASM_STD, - ASM_OUT, - ASM_SHL, - ASM_RETF, - /* 90 */ - ASM_ENTER, - ASM_MOVZBL, - ASM_REPNZ, - ASM_REPZ, - ASM_SET_OVERFLOW, - /* 95 */ - ASM_SET_NOT_OVERFLOW, - ASM_SET_PARITY, - ASM_SET_NOT_PARITY, - ASM_SET_SIGNED, - ASM_SET_NOT_SIGNED, - ASM_SET_EQUAL, - ASM_SET_NOT_EQUAL, - ASM_SET_U_LESS, - ASM_SET_U_LESS_EQUAL, - ASM_SET_S_LESS, - ASM_SET_S_LESS_EQUAL, - ASM_SET_U_GREATER, - ASM_SET_U_GREATER_EQUAL, - ASM_SET_S_GREATER, - ASM_SET_S_GREATER_EQUAL, - ASM_CPUID, - ASM_SHRD, - ASM_SHLD, - ASM_CLTD, - ASM_SAR, - ASM_ROR, - ASM_BT, - ASM_BTS, - ASM_INT3, - ASM_CMC, - ASM_RCL, - ASM_SAL, - ASM_ROL, - ASM_SCASW, - ASM_WAIT, - ASM_FWAIT, - ASM_BSR, - ASM_BSF, - ASM_RCR, - ASM_CLI, - ASM_CWTL, - ASM_OUTSB, - ASM_OUTSW, - ASM_OUTSD, - ASM_STI, - ASM_CMOVNE, - ASM_LSS, - ASM_MOVSW, - ASM_MOVZBW, - ASM_BOUND, - ASM_LES, - ASM_LDS, - ASM_AAA, - ASM_DAA, - ASM_ARPL, - ASM_CLC, - ASM_STC, - ASM_INT1, - - ASM_VERR, - ASM_VERW, - ASM_BRANCHE, - - ASM_AAS, - ASM_DAS, - ASM_UD2A, - ASM_UD2, - ASM_BTC, - ASM_CMPXCHG, - ASM_LIDT, - ASM_LGDT, - - ASM_FXSAVE, - ASM_FXRSTOR, - ASM_LDMXCSR, - ASM_STMXCSR, - ASM_LFENCE, - ASM_MLENCE, - ASM_SLENCE, - - ASM_WBINVD, - ASM_RDMSR, - ASM_XSTORERNG, - ASM_XCRYPTCBC, - ASM_XCRYPTCFB, - ASM_XCRYPTOFB, - ASM_BTRL, - - ASM_PREFETCH_NTA, - ASM_PREFETCH_T0, - ASM_PREFETCH_T1, - ASM_PREFETCH_T2, - ASM_HINT_NOP, - - ASM_SGDT, - ASM_SIDT, - ASM_STR, - ASM_BTR, - ASM_LTR, - ASM_SLDT, - ASM_INVLPG, - /* 150 */ - ASM_RDTSC, - ASM_LLDT, - ASM_LBRANCH, - ASM_CMOVA, - ASM_CMOVE, - ASM_CMOVAE, - ASM_CMOVO, - ASM_CMOVNO, - ASM_CMOVB, - ASM_CMOVBE, - ASM_CMOVS, - ASM_CMOVNS, - ASM_CMOVP, - ASM_CMOVNP, - ASM_CMOVL, - ASM_CMOVNL, - ASM_CMOVLE, - ASM_CMOVNLE, - ASM_MOVSBL, - ASM_MOVSWL, - ASM_MOVD, - ASM_MOVQ, - ASM_BSWAP, - ASM_PAND, - ASM_POR, - ASM_PXOR, - ASM_PSLLQ, - ASM_PSRLQ, - ASM_PSRLW, - ASM_PSRAW, - ASM_PSLLW, - ASM_PMULLW, - ASM_PADDUSW, - ASM_PADDUSB, - ASM_PUNPCKLBW, - ASM_PUNPCKHBW, - ASM_PACKUSWB, - ASM_EMMS, - - /* - * - */ - - ASM_FXRSTORE, - ASM_MFENCE, - ASM_SFENCE, - - /* - * FPU INSTRUCTIONS - */ - ASM_F2XM1, /* Function 2^X Minus 1 */ - ASM_FABS, /* Function ABSolute value */ - ASM_FADD, /* Function ADD */ - ASM_FADDP, /* Function ADD and Pop */ - ASM_FBLD, /* Function BCD LoaD */ - ASM_FBSTP, /* Function BCD STore and Pop */ - ASM_FCHS, /* Function CHange Sign */ - ASM_FCLEX, /* Function CLear EXceptions with wait */ - ASM_FCMOVB, - ASM_FCMOVU, - ASM_FCOM, /* Functioon COMpare real */ - ASM_FCOMP, /* Function COMpare reald and Pop */ - ASM_FCOMPP, /* Function COMpare reald and PoP twice */ - ASM_FCOMPS, /* */ - ASM_FDECSTP, /* Function DECrement STack Pointer */ - ASM_FDISI, /* Function DISable Interrupts with wait */ - ASM_FDIV, /* Function real DIVide */ - ASM_FDIVP, /* Function real DIVide and Pop */ - ASM_FDIVR, /* Function real DIVide Reversed */ - ASM_DIVRP, /* Function real DIVide Reversed and Pop */ - ASM_FENI, /* Function ENable Interrupts with wait */ - ASM_FFREE, /* Function FREE register */ - ASM_FIADD, /* Function Integer ADD */ - ASM_FICOM, /* Function Integer COMpare */ - ASM_FICOMP, /* Function Integer COMpare and Pop */ - ASM_FIDIV, /* Function Integer DIVide */ - ASM_FIDIVR, /* Function Integer DIVide Reversed */ - ASM_FILD, /* Function Integer LoaD */ - ASM_FIMUL, /* Function Integer Multiply */ - ASM_FINCSTP, /* Function INCrement STac Pointer */ - ASM_FINIT, /* Function INITialize coprocessor with wait */ - ASM_FIST, /* Function Integer STore */ - ASM_FISTP, /* Function Integer STore and Pop */ - ASM_FISUB, /* */ - ASM_FISUBR, /* */ - ASM_FUCOM, /* */ - ASM_FUCOMP, /* */ - ASM_FUCOMPP, /* */ - ASM_FLDLN2, - ASM_FTST, - ASM_FPREM, - ASM_FRNDINT, - ASM_FNOP, - ASM_FCMOVNE, - ASM_FSTP1, - ASM_FSCALE, - ASM_FSQRT, - ASM_FSIN, - ASM_FCOS, - ASM_FISTTP, - ASM_FDIVRP, /* */ - ASM_FREEP, - ASM_FSUBP, /* */ - ASM_FSUBRP, /* */ - ASM_FCMOVBE, - ASM_FMUL, /* */ - ASM_FMULP, /* */ - ASM_FRSTOR, /* */ - ASM_FSAVE, /* */ - ASM_FNSAVE, /* */ - ASM_FSTP, /* Function STore real and Pop - 8087 */ - ASM_FSUB, /* */ - ASM_FSUBR, /* */ - ASM_FPATAN, - ASM_FST, /* */ - ASM_FXAM, - ASM_FCMOVNBE, - ASM_FCMOVNU, - ASM_FXCH, - ASM_FSINCOS, - ASM_FYL2X, - ASM_FSTENV, - ASM_FLDL2T, - ASM_FLDL2E, - ASM_FLDPI, - ASM_FPTAN, - ASM_FXTRACT, - ASM_FYL2XP1, - ASM_FLD, /* Function LoaD real - 8087 */ - ASM_FLDZ, /* */ - ASM_FLD1, - ASM_FSTSW, /* */ - ASM_FNSTSW, /* */ - AM_FNSTSW, /* Function (No wait) STore Status Word - 8087 */ - ASM_FCMOVE, - ASM_FCMOVNB, - ASM_FLDLG2, - ASM_FSORT, - ASM_FXCH4, - ASM_FTSTP, - ASM_FPEM1, - ASM_FLDCW, /* */ - ASM_FNSTENV, - ASM_FSTCW, - ASM_FNSTCW, - ASM_FLDENV, - ASM_FSETPM, - ASM_FRSTPM, - ASM_FUCOMI, - ASM_FRICHOP, - ASM_FCOMI, - ASM_FCOMP5, - ASM_FRINT2, - ASM_FCOM2, - ASM_FCOMP3, - ASM_FXCH7, - ASM_FSTP8, - ASM_FSTP9, - ASM_FSTDW, - ASM_FSTSG, - ASM_FUCOMIP, - ASM_FRINEAR, - ASM_FCOMIP, - /** - * keep this in last position unless - * you know what you are doing - **/ - ASM_BAD -}; -/* - * specialisation asm_processor for i386 - */ - -struct s_asm_i386_processor { - /* handler to resolving function */ - void (*resolve_immediate)(void *, u_int, char *, u_int); - - /* handler data pointer */ - void *resolve_data; - - /* processor type . I386 supports only */ - int type; - - /* */ - char **instr_table; - - int (*fetch)(asm_instr *, u_char *, u_int, - asm_processor *); - /* output handler. print instruction in a readable string */ - char *(*display_handle)(asm_instr *instr, int addr); - - /* pointer to an internal structure. */ - struct s_asm_proc_i386 *internals; -}; - -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-ia32-hdl.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-ia32-hdl.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-ia32-hdl.h.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-ia32-hdl.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -#ifndef _LIBASM_IA32_HDL_H_ -#define _LIBASM_IA32_HDL_H_ - -/** - * Initializing functions. - */ - -int asm_register_ia32(); -int asm_register_ia32_opcodes(); -int asm_register_ia32_operands(); - -/** - * Operand fetching handlers. - */ -#ifdef WIP -int asm_operand_fetch(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_default(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_opmod(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_encoded(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_encodedbyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_general(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_generalbyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_jump(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_shortjump(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_offset(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_fixed(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_immediate(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_immediatebyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_address(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_register(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_control(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_debug(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_xsrc(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_ydest(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_pmmx(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_memory(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_immediateword(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -int asm_operand_fetch_segment(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins, int opt); -#else -int asm_operand_fetch(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_default(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_opmod(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_encoded(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_encodedbyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_general(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_generalbyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_jump(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_shortjump(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_offset(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_fixed(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_immediate(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_immediatebyte(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_address(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_register(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_control(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_debug(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_xsrc(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_ydest(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_pmmx(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_memory(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_immediateword(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -int asm_operand_fetch_segment(asm_operand *operand, u_char *opcode, int type, - asm_instr *ins); -#endif - - -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-int.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-int.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-int.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-int.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,437 +0,0 @@ -/** - * @file libasm-int.h - * $Id: libasm-int.h,v 1.8 2008/01/07 01:29:53 heroine Exp $ - * - * This file contains the forward declarations of i386 instruction - * handlers and some internal functions prototypes. - */ -#ifndef LIBASM_INT_H -#define LIBASM_INT_H - -/** - * Structure describing the modrm byte. - */ - -typedef struct s_modrm { - u_char m:3; - u_char r:3; - u_char mod:2; -} asm_modrm; - -/** - * Structure describing the sid byte. - */ - -typedef struct s_sidbyte { - u_char base:3; - u_char index:3; - u_char sid:2; - -} asm_sidbyte; - -/** - * - */ - -enum e_asm_proc_mode { - INTEL_REAL, - INTEL_PROT -}; - - -int asm_int_pow2(int); - -int fetch_i386(asm_instr *, u_char *, u_int, asm_processor *); - -void asm_resolve_immediate(asm_processor *proc, u_int val, char *buffer, u_int len); - - -char *asm_ia32_display_instr_att(asm_instr *ins, int addr); -char *asm_sparc_display_instr(asm_instr *, int addr); - - -int asm_proc_opsize(asm_processor *proc); -int asm_proc_addsize(asm_processor *proc); -int asm_proc_vector_size(asm_processor *proc); -int asm_proc_vector_len(asm_processor *); -int asm_proc_is_protected(asm_processor *); - -/** - * Internal functions to extract operands. - * - * - * - * - */ - -int operand_rmb_rb(asm_instr *, u_char *, int, asm_processor *); -int operand_rmv_rv(asm_instr *, u_char *, int, asm_processor *); -int operand_rb_rmb(asm_instr *, u_char *, int, asm_processor *); -int operand_rv_rmv(asm_instr *, u_char *, int, asm_processor *); -int operand_rv_rmb(asm_instr *, u_char *, int, asm_processor *); - -int operand_rmb_ib(asm_instr *, u_char *, int, asm_processor *); -int operand_rmv_iv(asm_instr *, u_char *, int, asm_processor *); -int operand_rmv_ib(asm_instr *, u_char *, int, asm_processor *); - -int operand_rv_rm2(asm_instr *, u_char *, int, asm_processor *); - -int operand_rv_m(asm_instr *, u_char *, int, asm_processor *); - -int operand_rmv(asm_operand *, u_char *, u_int, asm_processor *); -int operand_rmb(asm_operand *, u_char *, u_int, asm_processor *); - -/** - * Handler for the i386 instructions. - */ - -int op_add_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_add_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_add_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_add_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_add_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_add_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_es(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_es(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_or_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_cs(asm_instr *, u_char *, u_int, asm_processor *); -int op_386sp(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_adc_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_ss(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_es(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_sbb_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_ds(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_ds(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_and_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_es(asm_instr *, u_char *, u_int, asm_processor *); -int op_daa(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_sub_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_cs(asm_instr *, u_char *, u_int, asm_processor *); -int op_das(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_xor_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_ss(asm_instr *, u_char *, u_int, asm_processor *); -int op_aaa(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_al_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmp_xchg(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_ds(asm_instr *, u_char *, u_int, asm_processor *); -int op_aas(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_inc_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_dec_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_pusha(asm_instr *, u_char *, u_int, asm_processor *); -int op_popa(asm_instr *, u_char *, u_int, asm_processor *); -int op_bound_gv_ma(asm_instr *, u_char *, u_int, asm_processor *); -int op_arpl_ew_rw(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_fs(asm_instr *, u_char *, u_int, asm_processor *); -int op_prefix_gs(asm_instr *, u_char *, u_int, asm_processor *); -int op_opsize(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_imul_rv_rmv_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_push_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_imul_gv_ev_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_insb(asm_instr *, u_char *, u_int, asm_processor *); -int op_insw(asm_instr *, u_char *, u_int, asm_processor *); -int op_outsb(asm_instr *, u_char *, u_int, asm_processor *); -int op_outsw(asm_instr *, u_char *, u_int, asm_processor *); -int op_jo(asm_instr *, u_char *, u_int, asm_processor *); -int op_jno(asm_instr *, u_char *, u_int, asm_processor *); -int op_jb(asm_instr *, u_char *, u_int, asm_processor *); -int op_jae(asm_instr *, u_char *, u_int, asm_processor *); -int op_je(asm_instr *, u_char *, u_int, asm_processor *); -int op_jne(asm_instr *, u_char *, u_int, asm_processor *); -int op_jbe(asm_instr *, u_char *, u_int, asm_processor *); -int op_ja(asm_instr *, u_char *, u_int, asm_processor *); -int op_js(asm_instr *, u_char *, u_int, asm_processor *); -int op_jns(asm_instr *, u_char *, u_int, asm_processor *); -int op_jp(asm_instr *, u_char *, u_int, asm_processor *); -int op_jnp(asm_instr *, u_char *, u_int, asm_processor *); -int op_jl(asm_instr *, u_char *, u_int, asm_processor *); -int op_jge(asm_instr *, u_char *, u_int, asm_processor *); -int op_jle(asm_instr *, u_char *, u_int, asm_processor *); -int op_jg(asm_instr *, u_char *, u_int, asm_processor *); -int op_immed_rmb_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_immed_rmb_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_immed_rmv_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_immed_rmv_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_test_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_test_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rmb_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rm_segr(asm_instr *, u_char *, u_int, asm_processor *); -int op_lea_rv_m(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_segr_rm(asm_instr *, u_char *, u_int, asm_processor *); -int op_pop_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_nop(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_xchg_eax_reg(asm_instr *, u_char *, u_int, asm_processor *); -int op_cwtl(asm_instr *, u_char *, u_int, asm_processor *); -int op_cltd(asm_instr *, u_char *, u_int, asm_processor *); -int op_fwait(asm_instr *, u_char *, u_int, asm_processor *); -int op_pushf(asm_instr *, u_char *, u_int, asm_processor *); -int op_popf(asm_instr *, u_char *, u_int, asm_processor *); -int op_sahf(asm_instr *, u_char *, u_int, asm_processor *); -int op_lahf(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_al_ref_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_eax_ref_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_ref_iv_al(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_ref_iv_eax(asm_instr *, u_char *, u_int, asm_processor *); -int op_movsb(asm_instr *, u_char *, u_int, asm_processor *); -int op_movsd(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmpsb(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmpsd(asm_instr *, u_char *, u_int, asm_processor *); -int op_test_al_rb(asm_instr *, u_char *, u_int, asm_processor *); -int op_test_eax_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_stosb(asm_instr *, u_char *, u_int, asm_processor *); -int op_stosd(asm_instr *, u_char *, u_int, asm_processor *); -int op_lodsb(asm_instr *, u_char *, u_int, asm_processor *); -int op_lodsd(asm_instr *, u_char *, u_int, asm_processor *); -int op_scasb(asm_instr *, u_char *, u_int, asm_processor *); -int op_scasd(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_subreg_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_reg_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_shr_rmb_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_shr_rmv_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_ret_i2(asm_instr *, u_char *, u_int, asm_processor *); -int op_ret(asm_instr *, u_char *, u_int, asm_processor *); -int op_les_rm_rmp(asm_instr *, u_char *, u_int, asm_processor *); -int op_lds_rm_rmp(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rmb_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_mov_rmv_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_enter(asm_instr *, u_char *, u_int, asm_processor *); -int op_leave(asm_instr *, u_char *, u_int, asm_processor *); -int op_retf_i2(asm_instr *, u_char *, u_int, asm_processor *); -int op_retf(asm_instr *, u_char *, u_int, asm_processor *); -int op_int_3(asm_instr *, u_char *, u_int, asm_processor *); -int op_int_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_into(asm_instr *, u_char *, u_int, asm_processor *); -int op_iret(asm_instr *, u_char *, u_int, asm_processor *); -int op_shift_rmb_1(asm_instr *, u_char *, u_int, asm_processor *); -int op_shift_rmv_1(asm_instr *, u_char *, u_int, asm_processor *); -int op_shift_rmb_cl(asm_instr *, u_char *, u_int, asm_processor *); -int op_shift_rmv_cl(asm_instr *, u_char *, u_int, asm_processor *); -int op_aam(asm_instr *, u_char *, u_int, asm_processor *); -int op_aad(asm_instr *, u_char *, u_int, asm_processor *); -int op_xlatb(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc0(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc1(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc2(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc3(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc4(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc5(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc6(asm_instr *, u_char *, u_int, asm_processor *); -int op_esc7(asm_instr *, u_char *, u_int, asm_processor *); -int op_loopne(asm_instr *, u_char *, u_int, asm_processor *); -int op_loope(asm_instr *, u_char *, u_int, asm_processor *); -int op_loop(asm_instr *, u_char *, u_int, asm_processor *); -int op_je_cxz(asm_instr *, u_char *, u_int, asm_processor *); -int op_in_al_ref_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_in_eax_ref_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_out_ref_ib_al(asm_instr *, u_char *, u_int, asm_processor *); -int op_out_ref_ib_eax(asm_instr *, u_char *, u_int, asm_processor *); -int op_call_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_jmp_iv(asm_instr *, u_char *, u_int, asm_processor *); -int op_jmp_ap(asm_instr *, u_char *, u_int, asm_processor *); -int op_jmp_ib(asm_instr *, u_char *, u_int, asm_processor *); -int op_in_al_dx(asm_instr *, u_char *, u_int, asm_processor *); -int op_in_eax_dx(asm_instr *, u_char *, u_int, asm_processor *); -int op_out_dx_al(asm_instr *, u_char *, u_int, asm_processor *); -int op_out_dx_eax(asm_instr *, u_char *, u_int, asm_processor *); -int op_lock(asm_instr *, u_char *, u_int, asm_processor *); -int op_lock(asm_instr *, u_char *, u_int, asm_processor *); -int op_repnz(asm_instr *, u_char *, u_int, asm_processor *); -int op_repz(asm_instr *, u_char *, u_int, asm_processor *); -int op_hlt(asm_instr *, u_char *, u_int, asm_processor *); -int op_cmc(asm_instr *, u_char *, u_int, asm_processor *); -int op_unary_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_unary_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_clc(asm_instr *, u_char *, u_int, asm_processor *); -int op_stc(asm_instr *, u_char *, u_int, asm_processor *); -int op_cli(asm_instr *, u_char *, u_int, asm_processor *); -int op_sti(asm_instr *, u_char *, u_int, asm_processor *); -int op_cld(asm_instr *, u_char *, u_int, asm_processor *); -int op_std(asm_instr *, u_char *, u_int, asm_processor *); -int op_incdec_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_indir_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_group6(asm_instr *, u_char *, u_int, asm_processor *); -int op_group7(asm_instr *, u_char *, u_int, asm_processor *); -int op_ud2a(asm_instr *, u_char *, u_int, asm_processor *); -int i386_rdtsc(asm_instr *, u_char *, u_int, asm_processor *); -int i386_mov_rm_cr(asm_instr *, u_char *, u_int, asm_processor *); -int i386_mov_cr_rm(asm_instr *, u_char *, u_int, asm_processor *); -int i386_mov_dr_rm(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovae(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmove(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovne(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovno(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovbe(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovo(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmova(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovs(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovns(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovp(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovnp(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovnl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovle(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cmovnle(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jae(asm_instr *, u_char *, u_int, asm_processor *); -int i386_je(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jne(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jbe(asm_instr *, u_char *, u_int, asm_processor *); -int i386_ja(asm_instr *, u_char *, u_int, asm_processor *); -int i386_js(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jp(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jnp(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jns(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jge(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jle(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jg(asm_instr *, u_char *, u_int, asm_processor *); -int i386_jg(asm_instr *, u_char *, u_int, asm_processor *); -int op_setno_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setb_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setae_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sete_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setne_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setbe_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_seta_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_sets_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setns_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setp_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setnp_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setl_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setge_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setle_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int op_setg_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_push_fs(asm_instr *, u_char *, u_int, asm_processor *); -int i386_pop_fs(asm_instr *, u_char *, u_int, asm_processor *); -int i386_cpuid(asm_instr *, u_char *, u_int, asm_processor *); -int i386_bt_rm_r(asm_instr *, u_char *, u_int, asm_processor *); -int i386_xadd(asm_instr *, u_char *, u_int, asm_processor *); -int i386_group12(asm_instr *, u_char *, u_int, asm_processor *); -int i386_group14(asm_instr *, u_char *, u_int, asm_processor *); -int i386_group15(asm_instr *, u_char *, u_int, asm_processor *); -int i386_group16(asm_instr *, u_char *, u_int, asm_processor *); -int i386_bswap(asm_instr *, u_char *, u_int, asm_processor *); -int i386_shld(asm_instr *, u_char *, u_int, asm_processor *); -int i386_shld_rmv_rv_cl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_bts(asm_instr *, u_char *, u_int, asm_processor *); -int i386_shrd_rmv_rv_ib(asm_instr *, u_char *, u_int, asm_processor *); -int i386_shrd_rmv_rv_cl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_imul_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_lss_rv_rmv(asm_instr *, u_char *, u_int, asm_processor *); -int op_btr_rmv_rv(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movzbl_rv_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movzwl_rv_rm2(asm_instr *, u_char *, u_int, asm_processor *); -int i386_bsf(asm_instr *, u_char *, u_int, asm_processor *); -int i386_bsr_rv_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movsbl_rv_rmb(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movswl_rv_rm2(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movd_pd_qd(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movq_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_movq_qq_pq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_pand_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_por_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_pxor_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_pmullw_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_paddusw_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_paddusb_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_punpcklbw_pq_qd(asm_instr *, u_char *, u_int, asm_processor *); -int i386_punpckhbw_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_packuswb_pq_qq(asm_instr *, u_char *, u_int, asm_processor *); -int i386_emms(asm_instr *, u_char *, u_int, asm_processor *); -int op_addsize(asm_instr *, u_char *, u_int, asm_processor *); -int i386_wbinvd(asm_instr *, u_char *, u_int, asm_processor *); -int i386_rdmsr(asm_instr *, u_char *, u_int, asm_processor *); -int i386_btrl(asm_instr *, u_char *, u_int, asm_processor *); -int i386_xstorenrg(asm_instr *, u_char *, u_int, asm_processor *); -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-mips.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-mips.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-mips.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-mips.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,914 +0,0 @@ -/** - * @file libasm-mips.h - * $Id: libasm-mips.h,v 1.5 2008/01/07 01:29:53 heroine Exp $ - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - * Manuel Martin - 2007 - */ - -#ifndef LIBASM_MIPS_H_ -#define LIBASM_MIPS_H_ - -#include -#include - -//LIBASM_HANDLER_DISPLAY(asm_mips_display_instr); -//LIBASM_HANDLER_FETCH(fetch_mips); - -#define ASM_CONFIG_MIPS_REGISTER_FLAVOUR "libasm.mips.output.registers" -#define ASM_CONFIG_MIPS_STANDARD_REGISTERS 0 -#define ASM_CONFIG_MIPS_EXTENDED_REGISTERS 1 - -#define ASM_MIPS_REG_FPU ASM_CONFIG_MIPS_EXTENDED_REGISTERS - -char *asm_mips_display_instr(asm_instr *, int); -void mips_convert_format_r(struct s_mips_decode_reg *opcode, u_char *buf); -void mips_convert_format_i(struct s_mips_decode_imm *opcode, u_char *buf); -void mips_convert_format_j(struct s_mips_decode_jump *opcode, u_char *buf); -void mips_convert_format_t(struct s_mips_decode_trap *opcode, u_char *buf); -void mips_convert_format_cop2(struct s_mips_decode_cop2 *opcode, u_char *buf); -void mips_convert_format_mov(struct s_mips_decode_mov *opcode, u_char *buf); -void mips_convert_format_cop1x(struct s_mips_decode_cop1x *opcode, u_char *buf); - -int asm_fetch_mips(asm_instr *, u_char *, u_int, asm_processor *); - -int asm_register_mips(); -int asm_register_mips_opcodes(); -int asm_register_mips_operands(); -int asm_register_mips_operand(unsigned int type, unsigned long func); - -#define Ob(x) ((unsigned)Ob_(0 ## x ## uL)) -#define Ob_(x) ((x & 1) | ((x >> 2) & 2) | ((x >> 4) & 4) | ((x >> 6) & 8) | \ - ((x >> 8) & 16) | ((x >> 10) & 32) | ((x >> 12) & 64) | ((x >> 14) & 128)) -/* - * funciones - * TODO - */ - -/** - * @page mips.html - * - *
- *  
- * Instruction field meanings, from the
- *  mips32 architecture manual
- * 
- *  opcode         6-bit primary operation code
- *  rd             5-bit specier for the destination register
- *  rs             5-bit spec for the source register
- *  rt             5-bit specr for the target (source/destination) 
- *                 register or used to specify functions within the primary 
- *                 opcode REGIMM
- *  immediate      16-bit signed immediate used for logical operands,
- *                 arithmetic signed operands, load/store address 
- *                 byte offsets, and PC-relative branch signed 
- *                 instruction displacement
- *  instr_index    26-bit index shifted left two bits to supply the 
- *                 low-order 28 bits of the jump target address
- *  sa             5-bit shift amount
- *  function       6-bit function ld used to specify functions 
- *                 within the primary opcode SPECIAL
- * 
- */ - -/* Immediate/(I-type) instruction - * used to work with immediate values (up to 16 bits) */ -//struct s_mips_insn_imm -//{ -// u_int32_t opcode:6; -// u_int32_t rs:5; -// u_int32_t rt:5; /* operation (sometimes) */ -// u_int32_t immediate:16; -//}; - -/* This is a subtype of the type inmmediate, it's used - * in some branch-conditional instructions*/ -//struct s_mips_insn_imm_bc -//{ -// u_int32_t opcode:6; -// u_int32_t rs:5; /* operation */ -// u_int32_t cc:3; /* condition code*/ -// u_int32_t nd:1; /* nullify delay slot*/ -// u_int32_t tf:1; /* true/false*/ -// u_int32_t offset:16; -//}; - -/* Jump/(J-type) instruction - * used for jumps/branches */ -//struct s_mips_insn_jump -//{ -// u_int32_t opcode:6; -// u_int32_t instr_index:26; -//}; - -/* Register/(R-type) instruction - * used to transfer data between registers */ -//struct s_mips_insn_reg -//{ -// u_int32_t opcode:6; -// u_int32_t rs:5; -// u_int32_t rt:5; -// u_int32_t rd:5; -// u_int32_t sa:5; -// u_int32_t function:6; -//}; - -/* This is a subtype of the register type, it's - * used only for the BREAK and SYSCALL instructions */ -//struct s_mips_insn_reg_break_syscall -//{ -// u_int32_t opcode:6; -// u_int32_t code:20; -// u_int32_t function:6; -//}; - -/* This is a subtype of the register type, it's - * used only for the DERET insn*/ -//struct s_mips_insn_reg_deret -//{ -// u_int32_t opcode:6; -// u_int32_t co:1; -// u_int32_t zero:19; -// u_int32_t function:6; -//}; - -#define MIPS_SPECIAL_FUNCTION_NUM 64 -#define MIPS_REGIMM_FUNCTION_NUM 32 -#define MIPS_SPECIAL2_FUNCTION_NUM 64 -#define MIPS_SPECIAL3_FUNCTION_NUM 64 - -#define MIPS_LEVEL0_OPCODES_NUM 64 -#define MIPS_LEVEL1_OPCODES_NUM 224 -#define MIPS_LEVEL2_OPCODES_NUM 38 - - - -#define ASM_MIPS_TABLE_END -1 - -enum opcode_field_encoding { - MIPS_OPCODE_SPECIAL, /* class */ - MIPS_OPCODE_REGIMM, /* class */ - MIPS_OPCODE_J, - MIPS_OPCODE_JAL, - MIPS_OPCODE_BEQ, - MIPS_OPCODE_BNE, - MIPS_OPCODE_BLEZ, - MIPS_OPCODE_BGTZ, - MIPS_OPCODE_ADDI, - MIPS_OPCODE_ADDIU, - MIPS_OPCODE_SLTI, - MIPS_OPCODE_SLTIU, - MIPS_OPCODE_ANDI, - MIPS_OPCODE_ORI, - MIPS_OPCODE_XORI, - MIPS_OPCODE_LUI, - MIPS_OPCODE_COP0, /* class */ - MIPS_OPCODE_COP1, /* class */ - MIPS_OPCODE_COP2, /* class */ - MIPS_OPCODE_COP1X, /* class */ - MIPS_OPCODE_BEQL, /* obsolete */ - MIPS_OPCODE_BNEL, /* obsolete */ - MIPS_OPCODE_BLEZL, /* obsolete*/ - MIPS_OPCODE_BGTZL, /* obsolete */ - MIPS_OPCODE_SPECIAL2 = (Ob(011100)), /* class */ - MIPS_OPCODE_JALX, /* reserved for ASE? */ - MIPS_OPCODE_SPECIAL3 = Ob(011111), /* class / release2 */ - MIPS_OPCODE_LB, - MIPS_OPCODE_LH, - MIPS_OPCODE_LWL, - MIPS_OPCODE_LW, - MIPS_OPCODE_LBU, - MIPS_OPCODE_LHU, - MIPS_OPCODE_LWR, - MIPS_OPCODE_SB = Ob(101000), - MIPS_OPCODE_SH, - MIPS_OPCODE_SWL, - MIPS_OPCODE_SW, - MIPS_OPCODE_SWR = Ob(101110), - MIPS_OPCODE_CACHE, - MIPS_OPCODE_LL, - MIPS_OPCODE_LWC1, - MIPS_OPCODE_LWC2, /* 3rd party */ - MIPS_OPCODE_PREF, - MIPS_OPCODE_LDC1 = Ob(110101), - MIPS_OPCODE_LDC2, /* 3rd party */ - MIPS_OPCODE_SC = Ob(111000), - MIPS_OPCODE_SWC1, - MIPS_OPCODE_SWC2, /* 3rd party */ - MIPS_OPCODE_SDC1 = Ob(111101), - MIPS_OPCODE_SDC2, /* 3rd party */ - - MIPS_OPCODE_DADDI = Ob(011000), - MIPS_OPCODE_DADDIU, - MIPS_OPCODE_LDL,// 011010 - MIPS_OPCODE_LDR, - MIPS_OPCODE_LLD = Ob(110100), - MIPS_OPCODE_LD = Ob(110111), - MIPS_OPCODE_LWU = Ob(100111), - MIPS_OPCODE_SCD = Ob(111100), - MIPS_OPCODE_SD = Ob(111111), - MIPS_OPCODE_SDL = Ob(101100), - MIPS_OPCODE_SDR -}; - -enum SPECIAL_function_field_encoding { - MIPS_OPCODE_SLL, - MIPS_OPCODE_MOVCI, /* class */ - MIPS_OPCODE_SRL, /* class */ - MIPS_OPCODE_SRA, - MIPS_OPCODE_SLLV, - MIPS_OPCODE_SRLV = Ob(000110), /* class */ - MIPS_OPCODE_SRAV, - MIPS_OPCODE_JR, - MIPS_OPCODE_JALR, - MIPS_OPCODE_MOVZ, - MIPS_OPCODE_MOVN, - MIPS_OPCODE_SYSCALL, - MIPS_OPCODE_BREAK, - MIPS_OPCODE_SYNC = Ob(001111), - MIPS_OPCODE_MFHI, - MIPS_OPCODE_MTHI, - MIPS_OPCODE_MFLO, - MIPS_OPCODE_MTLO, - MIPS_OPCODE_MULT = Ob(011000), - MIPS_OPCODE_MULTU, - MIPS_OPCODE_DIV, - MIPS_OPCODE_DIVU, - MIPS_OPCODE_ADD = Ob(100000), - MIPS_OPCODE_ADDU, - MIPS_OPCODE_SUB, - MIPS_OPCODE_SUBU, - MIPS_OPCODE_AND, - MIPS_OPCODE_OR, - MIPS_OPCODE_XOR, - MIPS_OPCODE_NOR, - MIPS_OPCODE_SLT = Ob(101010), - MIPS_OPCODE_SLTU, - MIPS_OPCODE_TGE = Ob(110000), - MIPS_OPCODE_TGEU, - MIPS_OPCODE_TLT, - MIPS_OPCODE_TLTU, - MIPS_OPCODE_TEQ, - MIPS_OPCODE_TNE = Ob(110110), - - MIPS_OPCODE_DADD = Ob(101100), - MIPS_OPCODE_DADDU, - MIPS_OPCODE_DSUB, - MIPS_OPCODE_DSUBU, - MIPS_OPCODE_DMULT = Ob(011100), - MIPS_OPCODE_DMULTU, - MIPS_OPCODE_DDIV, - MIPS_OPCODE_DDIVU, - MIPS_OPCODE_DSLL = Ob(111000), - MIPS_OPCODE_DSLL32 = Ob(111100), - MIPS_OPCODE_DSLLV = Ob(010100), - MIPS_OPCODE_DSRL = Ob(111010), - MIPS_OPCODE_DSRA, - MIPS_OPCODE_DSRL32 = Ob(111110), - MIPS_OPCODE_DSRA32, - MIPS_OPCODE_DSRLV = Ob(010110), - MIPS_OPCODE_DSRAV -}; - -enum REGIMM_rt_field_encoding { - MIPS_OPCODE_BLTZ, - MIPS_OPCODE_BGEZ, - MIPS_OPCODE_BLTZL, /* obsolete */ - MIPS_OPCODE_BGEZL, /* obsolete */ - MIPS_OPCODE_TGEI = Ob(01000), - MIPS_OPCODE_TGEIU, - MIPS_OPCODE_TLTI, - MIPS_OPCODE_TLTIU, - MIPS_OPCODE_TEQI, - MIPS_OPCODE_TNEI = Ob(01110), - MIPS_OPCODE_BLTZAL = Ob(10000), - MIPS_OPCODE_BGEZAL, - MIPS_OPCODE_BLTZALL, /* obsolete */ - MIPS_OPCODE_BGEZALL, /* obsolete */ - MIPS_OPCODE_SYNCI = Ob(11111) /* release 2 */ -}; - -enum SPECIAL2_function_field_encoding { - MIPS_OPCODE_MADD, - MIPS_OPCODE_MADDU, - MIPS_OPCODE_MUL, - MIPS_OPCODE_MSUB = Ob(000100), - MIPS_OPCODE_MSUBU, - MIPS_OPCODE_CLZ = Ob(100000), - MIPS_OPCODE_CLO, - MIPS_OPCODE_SDBBP = Ob(111111), /* EJTAG */ - - MIPS_OPCODE_DCLZ = Ob(100100), - MIPS_OPCODE_DCLO -}; - -/* only for release 2*/ -enum SPECIAL3_function_field_encoding { - MIPS_OPCODE_EXT, - MIPS_OPCODE_INS = Ob(000100), - MIPS_OPCODE_BSHFL = Ob(100000), /* class */ - MIPS_OPCODE_RDHWR = Ob(111011), -}; - -enum MOVCI_tf_field_encoding { - MIPS_OPCODE_MOVF, - MIPS_OPCODE_MOVT -}; - -enum SRL_shiftrotate_field_encoding { - // XXX: _42 was added to allow compiling because MIPS_OPCODE_SRL is already in an other enum. - MIPS_OPCODE_SRL_42, - MIPS_OPCODE_ROTR -}; - -enum SRLV_shiftrotate_field_ecoding { - // XXX: _42 was added to allow compiling because MIPS_OPCODE_SRL is already in an other enum. - MIPS_OPCODE_SRLV_42, - MIPS_OPCODE_ROTRV -}; - -enum BSHFL_sa_field_encoding { - MIPS_OPCODE_WSBH = Ob(00010), - MIPS_OPCODE_SEB = Ob(10000), - MIPS_OPCODE_SEH = Ob(11000) -}; - -enum COP2_func { - MIPS_OPCODE_MF, - MIPS_OPCODE_DMF, - MIPS_OPCODE_CF, - MIPS_OPCODE_MT = Ob(00100), - MIPS_OPCODE_DMT, - MIPS_OPCODE_CT, - MIPS_OPCODE_BC = Ob(01000) -}; - -enum COP1X_func { - MIPS_OPCODE_LWXC1 = Ob(000000), - MIPS_OPCODE_LDXC1, - MIPS_OPCODE_LUXC1 = Ob(000101), - MIPS_OPCODE_SWXC1 = Ob(001000), - MIPS_OPCODE_SDXC1, - MIPS_OPCODE_SUXC1 = Ob(001101), - MIPS_OPCODE_PREFX = Ob(001111), - MIPS_OPCODE_ALNV_PS = Ob(011110), - - MIPS_OPCODE_MADD_S = Ob(100000), - MIPS_OPCODE_MADD_D, - MIPS_OPCODE_MADD_PS = Ob(100110), - - MIPS_OPCODE_MSUB_S = Ob(101000), - MIPS_OPCODE_MSUB_D, - MIPS_OPCODE_MSUB_PS = Ob(101110), - - MIPS_OPCODE_NMADD_S = Ob(110000), - MIPS_OPCODE_NMADD_D, - MIPS_OPCODE_NMADD_PS = Ob(110110), - - MIPS_OPCODE_NMSUB_S = Ob(111000), - MIPS_OPCODE_NMSUB_D, - MIPS_OPCODE_NMSUB_PS = Ob(111110) -}; - - -/* XXX: privileged and fpu stuff.. not implemented yet*/ -/* -enum {} COP0_rs_field_encoding; -enum {} COP0_function_field_encoding_rsCO; -enum {} COP1_rs_field_encoding; -enum {} COP1_function_field_encoding_rsS; -enum {} COP1_function_field_encoding_rsD; -enum{} COP1_function_field_encoding_rsW_or_rsL; -enum {} COP1_function_field_encoding_rsPS; -*/ - -/* - * mips instructions - * r2 after an instruction means that instruction - * is only available in the MIPS32 release 2 specification - * */ -enum e_mips_instr_types -{ - /* arithmetics */ - ASM_MIPS_ADD, - ASM_MIPS_ADDI, - ASM_MIPS_ADDIU, - ASM_MIPS_ADDU, - ASM_MIPS_CLO, - ASM_MIPS_CLZ, - /* mips64v2 */ - ASM_MIPS_DADD, - ASM_MIPS_DADDI, - ASM_MIPS_DADDIU, - ASM_MIPS_DADDU, - ASM_MIPS_DCLO, - ASM_MIPS_DCLZ, - ASM_MIPS_DDIV, - ASM_MIPS_DDIVU, - /* mips64v2 */ - ASM_MIPS_DIV, - ASM_MIPS_DIVU, - /* mips64v2 */ - ASM_MIPS_DMULT, - ASM_MIPS_DMULTU, - ASM_MIPS_DSUB, - ASM_MIPS_DSUBU, - /* mips64v2 */ - ASM_MIPS_MADD, - ASM_MIPS_MADDU, - ASM_MIPS_MSUB, - ASM_MIPS_MSUBU, - ASM_MIPS_MUL, - ASM_MIPS_MULT, - ASM_MIPS_MULTU, - ASM_MIPS_SLT, - ASM_MIPS_SLTI, - ASM_MIPS_SLTIU, - ASM_MIPS_SLTU, - ASM_MIPS_SUB, - ASM_MIPS_SUBU, - ASM_MIPS_SEB, /*r2*/ - ASM_MIPS_SEH, /*r2*/ - /* branch */ - ASM_MIPS_B, - ASM_MIPS_BAL, - ASM_MIPS_BEQ, - ASM_MIPS_BGEZ, - ASM_MIPS_BGEZAL, - ASM_MIPS_BGTZ, - ASM_MIPS_BLEZ, - ASM_MIPS_BLTZ, - ASM_MIPS_BLTZAL, - ASM_MIPS_BNE, - ASM_MIPS_J, - ASM_MIPS_JAL, - ASM_MIPS_JALR, - ASM_MIPS_JR, - ASM_MIPS_JALR_HB, - ASM_MIPS_JR_HB, - /* cpu execution control*/ -// ASM_MIPS_EHB, /*r2*/ - ASM_MIPS_NOP, - ASM_MIPS_SSNOP, - /* memory */ - ASM_MIPS_LB, - ASM_MIPS_LBU, - /* mips64v2 */ - ASM_MIPS_LD, - ASM_MIPS_LDL, - ASM_MIPS_LDR, - /* mips64v2 */ - ASM_MIPS_LH, - ASM_MIPS_LHU, - ASM_MIPS_LL, - /* mips64v2 */ - ASM_MIPS_LLD, - /* mips64v2 */ - ASM_MIPS_LW, - ASM_MIPS_LWL, - ASM_MIPS_LWR, - /* mips64v2 */ - ASM_MIPS_LWU, - /* mips64v2 */ - ASM_MIPS_PREF, - ASM_MIPS_SB, - ASM_MIPS_SC, - /* mips64v2 */ - ASM_MIPS_SCD, - ASM_MIPS_SD, - ASM_MIPS_SDL, - ASM_MIPS_SDR, - /* mips64v2 */ - ASM_MIPS_SH, - ASM_MIPS_SW, - ASM_MIPS_SWL, - ASM_MIPS_SWR, - ASM_MIPS_SYNC, - ASM_MIPS_SYNCI, /*r2*/ - /* logic */ - ASM_MIPS_AND, - ASM_MIPS_ANDI, - ASM_MIPS_LUI, - ASM_MIPS_NOR, - ASM_MIPS_OR, - ASM_MIPS_ORI, - ASM_MIPS_XOR, - ASM_MIPS_XORI, - /* insert/extract */ - ASM_MIPS_EXT, /*r2*/ - ASM_MIPS_INS, /*r2*/ - ASM_MIPS_WSBH, /*r2*/ - /* cpu move */ - ASM_MIPS_MFHI, - ASM_MIPS_MFLO, - ASM_MIPS_MOVF, - ASM_MIPS_MOVN, - ASM_MIPS_MOVT, - ASM_MIPS_MOVZ, - ASM_MIPS_MTHI, - ASM_MIPS_MTLO, - /* shift */ - /* mips64v2 */ - ASM_MIPS_DSLL, - ASM_MIPS_DSLL32, - ASM_MIPS_DSLLV, - ASM_MIPS_DSRA, - ASM_MIPS_DSRA32, - ASM_MIPS_DSRAV, - ASM_MIPS_DSRL, - ASM_MIPS_DSRL32, - ASM_MIPS_DSRLV, - /* mips64v2 */ - ASM_MIPS_SLL, - ASM_MIPS_SLLV, - ASM_MIPS_SRA, - ASM_MIPS_SRAV, - ASM_MIPS_SRL, - ASM_MIPS_SRLV, - ASM_MIPS_RDHWR, /*r2*/ - ASM_MIPS_ROTR, /*r2*/ - ASM_MIPS_ROTRV, /*r2*/ - /* traps */ - ASM_MIPS_BREAK, - ASM_MIPS_SYSCALL, - ASM_MIPS_TEQ, - ASM_MIPS_TEQI, - ASM_MIPS_TGE, - ASM_MIPS_TGEI, - ASM_MIPS_TGEIU, - ASM_MIPS_TGEU, - ASM_MIPS_TLT, - ASM_MIPS_TLTI, - ASM_MIPS_TLTIU, - ASM_MIPS_TLTU, - ASM_MIPS_TNE, - ASM_MIPS_TNEI, - /* obsolete branch */ - ASM_MIPS_BEQL, - ASM_MIPS_BGEZALL, - ASM_MIPS_BGEZL, - ASM_MIPS_BGTZL, - ASM_MIPS_BLEZL, - ASM_MIPS_BLTZALL, - ASM_MIPS_BLTZL, - ASM_MIPS_BNEL, - - /* COP2 Instructions */ - ASM_MIPS_BC2F, - ASM_MIPS_BC2T, - ASM_MIPS_COP2, - ASM_MIPS_LDC2, - ASM_MIPS_LWC2, - ASM_MIPS_SDC2, - ASM_MIPS_SWC2, - ASM_MIPS_CFC2, - ASM_MIPS_CTC2, - ASM_MIPS_DMFC2, - ASM_MIPS_DMTC2, - ASM_MIPS_MFC2, - ASM_MIPS_MTC2, - ASM_MIPS_BC2FL, - ASM_MIPS_BC2TL, - - /* COP1X Instructions */ - ASM_MIPS_LWXC1, - ASM_MIPS_LDXC1, - ASM_MIPS_LUXC1, - ASM_MIPS_SWXC1, - ASM_MIPS_SDXC1, - ASM_MIPS_SUXC1, - ASM_MIPS_PREFX, - ASM_MIPS_ALNV_PS, - ASM_MIPS_MADD_S, - ASM_MIPS_MADD_D, - ASM_MIPS_MADD_PS, - ASM_MIPS_MSUB_S, - ASM_MIPS_MSUB_D, - ASM_MIPS_MSUB_PS, - ASM_MIPS_NMADD_S, - ASM_MIPS_NMADD_D, - ASM_MIPS_NMADD_PS, - ASM_MIPS_NMSUB_S, - ASM_MIPS_NMSUB_D, - ASM_MIPS_NMSUB_PS, - /*TODO: - * - FPU insns - * - privileged insns - * */ - - ASM_MIPS_BAD -}; - -typedef int e_mips_register_type; - -enum e_mips_register_types -{ - ASM_MIPS_REG_ZERO, /* Zero register (always 0)*/ - ASM_MIPS_REG_AT, /* Assembler temporary (reserved) */ - ASM_MIPS_REG_V0, /* V0-V1 Value returned by subroutine*/ - ASM_MIPS_REG_V1, - ASM_MIPS_REG_A0, /* A0-A3 Arguments to subroutine*/ - ASM_MIPS_REG_A1, - ASM_MIPS_REG_A2, - ASM_MIPS_REG_A3, - ASM_MIPS_REG_T0, /* T0-T7 Temporary (local variables) */ - ASM_MIPS_REG_T1, - ASM_MIPS_REG_T2, - ASM_MIPS_REG_T3, - ASM_MIPS_REG_T4, - ASM_MIPS_REG_T5, - ASM_MIPS_REG_T6, - ASM_MIPS_REG_T7, - ASM_MIPS_REG_S0, /* S0-S7 Saved registers */ - ASM_MIPS_REG_S1, /* (preserved across function calls) */ - ASM_MIPS_REG_S2, - ASM_MIPS_REG_S3, - ASM_MIPS_REG_S4, - ASM_MIPS_REG_S5, - ASM_MIPS_REG_S6, - ASM_MIPS_REG_S7, - ASM_MIPS_REG_T8, /* T8-T9 Temporary (local variables) */ - ASM_MIPS_REG_T9, - ASM_MIPS_REG_K0, /* K0-K1 Kernel registers (reserved for OS) */ - ASM_MIPS_REG_K1, - ASM_MIPS_REG_GP, /* Global pointer */ - ASM_MIPS_REG_SP, /* Stack pointer */ - ASM_MIPS_REG_FP, /* Frame pointer */ - ASM_MIPS_REG_RA /* Return Address */ -}; - -/** - * operand types - */ -enum e_mips_operand_type -{ - ASM_MIPS_OTYPE_NONE, - ASM_MIPS_OTYPE_REGISTER, - ASM_MIPS_OTYPE_IMMEDIATE, - ASM_MIPS_OTYPE_JUMP, - ASM_MIPS_OTYPE_NOOP, - ASM_MIPS_OTYPE_BRANCH, - ASM_MIPS_OTYPE_REGBASE, - - ASM_MIPS_OTYPE_LAST -}; - -#define ASM_MIPS_OTYPE_NUM ASM_MIPS_OTYPE_LAST - -/** - * Structure to declare a mips instruction in e_mips_instr table. - */ -struct e_mips_instr -{ - const char *mnemonic; - int code; - int index1; - int index2; - int index3; - int (*func_op)(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -}; - -/** - * Structure to store register in the structure e_mips_register; - */ -struct e_mips_register -{ - const char *ext_mnemonic; - const char *mnemonic; - const char *fpu_mnemonic; - e_mips_register_type code; -}; - -/** - * This enum contains MIPS_OPCODE_ values which - * are not defined upper. - * - * - */ -enum e_fix_compile_errors - { -// MIPS_OPCODE_EHB, - MIPS_OPCODE_NOP = Ob(00000), - MIPS_OPCODE_SSNOP - }; - -/** - * Those structures arrays are declared in src/arch/mips/tables_mips.c - */ -extern struct e_mips_instr e_mips_instrs[]; -extern struct e_mips_register e_mips_registers[]; - -#endif - - -/* Operands fetch */ - -int asm_mips_operand_fetch(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); - - -/* Operands */ - -void asm_mips_operand_none(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_i(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_j(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_r(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_t(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_noop(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_branch(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); -void asm_mips_operand_regbase(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); - - -/* Opcodes */ - -int asm_mips_add(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_addi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_addiu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_addu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_and(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_andi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_b(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bal(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_beq(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_beql(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgez(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgezal(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgezall(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgezl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgtz(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bgtzl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_blez(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_blezl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bltz(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bltzal(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bltzall(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bltzl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bne(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bnel(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_break(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_clo(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_clz(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_div(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_divu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -//int asm_mips_ehb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ext(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ins(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_j(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_jal(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_jalr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_jalr_hb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_jr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_jr_hb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lbu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lh(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lhu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ll(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lui(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lw(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lwl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lwr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_madd(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_maddu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mfhi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mflo(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_movf(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_movn(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_movt(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_movz(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_msub(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_msubu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mthi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mtlo(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mul(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mult(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_multu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nop(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nor(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_or(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ori(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_pref(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_rdhwr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_rotr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_rotrv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sc(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_seb(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_seh(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sh(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sll(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sllv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_slt(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_slti(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sltiu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sltu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sra(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_srav(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_srl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_srlv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ssnop(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sub(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_subu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sw(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_swl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_swr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sync(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_synci(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_syscall(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_teq(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_teqi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tge(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tgei(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tgeiu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tgeu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tlt(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tlti(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tltiu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tltu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tne(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_tnei(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_wsbh(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_xor(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_xori(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -// Hehe... ;-) -int asm_mips_dadd(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_daddi(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_daddiu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_daddu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dclo(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dclz(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ddiv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ddivu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_dmult(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dmultu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsub(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsubu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_ld(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ldl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ldr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_lld(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_lwu(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_scd(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sd(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sdl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sdr(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - -int asm_mips_dsll(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsll32(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsllv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsra(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsra32(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsrav(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsrl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsrl32(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dsrlv(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - - -// Coprocesor 2 functions... - -int asm_mips_bc2f(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bc2t(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_cop2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ldc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_lwc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sdc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_swc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_cfc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ctc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dmfc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_dmtc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mfc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_mtc2(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bc2fl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_bc2tl(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); - - -// COP1X functions... - -int asm_mips_lwxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_ldxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_luxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_swxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_sdxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_suxc1(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_prefx(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_alnv_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_madd_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_madd_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_madd_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_msub_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_msub_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_msub_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmadd_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmadd_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmadd_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmsub_s(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmsub_d(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); -int asm_mips_nmsub_ps(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc); diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-mips-structs.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-mips-structs.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-mips-structs.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-mips-structs.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/** - * $Id: libasm-mips-structs.h,v 1.1 2007/01/23 09:53:03 heroine Exp $ - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - */ -#ifndef LIBASM_MIPS_STRUCTS_H -#define LIBASM_MIPS_STRUCTS_H - -/** - * Structure used to decode format reg instructions - */ -struct s_mips_decode_reg -{ - u_int32_t op:6; /*! opcode field */ - u_int32_t rs:5; /*! 1st source register */ - u_int32_t rt:5; /*! 2nd source register */ - u_int32_t rd:5; /*! destination register */ - u_int32_t sa:5; /*! shift amount (shift instr) */ - u_int32_t fn:6; /*! function to perform */ -}; - -/** - * Structure used to decode format immediate instructions - */ -struct s_mips_decode_imm -{ - u_int32_t op:6; - u_int32_t rs:5; - u_int32_t rt:5; - u_int32_t im:16; -}; - -/** - * Structure used to decode format jump instructions - */ -struct s_mips_decode_jump -{ - u_int32_t op:6; /*! opcode field */ - u_int32_t ta:26; /*! target to jump to */ -}; - -/** - * Structure used to decode format trap instructions - */ -struct s_mips_decode_trap -{ - u_int32_t op:6; - u_int32_t rs:5; - u_int32_t rt:5; - u_int32_t code:10; - u_int32_t fn:6; -}; - -/** - * Structure used to decode format mov* instructions - */ -struct s_mips_decode_mov -{ - u_int32_t op:6; - u_int32_t rs:5; - u_int32_t cc:3; - u_int32_t b1:1; - u_int32_t tf:1; - u_int32_t rd:5; - u_int32_t b2:5; - u_int32_t fn:6; -}; - -/** - * Structure used to decode some coprocesor2 instructions - */ -struct s_mips_decode_cop2 -{ - u_int32_t op:6; - u_int32_t rs:5; - u_int32_t rt:5; - u_int32_t rd:5; - u_int32_t fn:8; - u_int32_t sl:3; -}; - -/** - * Structure used to decode COP1X format instructions - */ -struct s_mips_decode_cop1x -{ - u_int32_t op:6; - u_int32_t bs:5; - u_int32_t in:5; - u_int32_t f1:5; - u_int32_t f2:5; - u_int32_t fn:3; - u_int32_t fmt:3; -}; - -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-sparc-decode.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-sparc-decode.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-sparc-decode.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-sparc-decode.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* -** libasm-sparc-decode.h for in /hate/home/hate/code/libasm_current -** -** Made by #!HATE#@! -** Login -** -** Started on Tue Jun 14 05:02:37 2005 #!HATE#@! -** Last update Tue Jun 14 06:06:32 2005 #!HATE#@! -** -** $Id: libasm-sparc-decode.h,v 1.4 2007/03/07 16:45:34 thor Exp $ -** -*/ - -#ifndef LIBASM_SPARC_DECODE_H_ -#define LIBASM_SPARC_DECODE_H_ - -/* - * sparc instruction formats - */ - -struct s_decode_pbranch { - u_int32_t op:2; - u_int32_t a:1; - u_int32_t cond:4; /* TODO: fix the branches decode to use cc's */ - u_int32_t op2:3; - u_int32_t cc1:1; - u_int32_t cc0:1; - u_int32_t p:1; - u_int32_t immediate:19; - - u_int32_t imm; - u_int32_t cc; -}; - -struct s_decode_rbranch { - u_int32_t op:2; - u_int32_t a:1; - u_int32_t zero:1; - u_int32_t rcond:3; - u_int32_t op2:3; - u_int32_t d16hi:2; - u_int32_t p:1; - u_int32_t rs1:5; - u_int32_t d16lo:14; - - u_int32_t d16; -}; - -struct s_decode_branch { - u_int32_t op:2; - u_int32_t a:1; - u_int32_t cond:4; - u_int32_t op2:3; - u_int32_t immediate:22; - - u_int32_t imm; - u_int32_t rd; -}; - -struct s_decode_call { - u_int32_t op:2; - u_int32_t disp30:30; - - u_int32_t displacement; -}; - -struct s_decode_format3 { - u_int32_t op:2; - u_int32_t rd:5; - u_int32_t op3:6; - u_int32_t rs1:5; - u_int32_t i:1; - u_int32_t none:8; - u_int32_t rs2:5; - - u_int32_t imm; - u_int32_t imm10; - u_int32_t rcond; - u_int32_t shcnt; - u_int32_t opf; - u_int32_t cc; // as used by FCMP* - u_int32_t opf_cc; // as used by FMOV(s,d,q)cc - u_int32_t cond; // as used by FMOV(s,d,q)cc -}; - -struct s_decode_format4 { - u_int32_t op:2; - u_int32_t rd:5; - u_int32_t op3:6; - u_int32_t rs1:5; - u_int32_t i:1; - u_int32_t cc1:1; - u_int32_t cc0:1; - u_int32_t none:6; - u_int32_t rs2:5; - - u_int32_t cond; - u_int32_t cc2; - u_int32_t cc; - u_int32_t imm; - u_int32_t sw_trap; -}; - -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-sparc.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-sparc.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-sparc.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-sparc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,782 +0,0 @@ -/* -** -** sparc.h in -** -** Author : -** Started : Tue Dec 2 22:43:08 2003 -** Updated : Thu Dec 4 03:29:25 2003 -** -** $Id: libasm-sparc.h,v 1.14 2008/01/07 01:29:53 heroine Exp $ -** -*/ - -#ifndef LIBASM_SPARC_H_ -#define LIBASM_SPARC_H_ - -#include - -#define MGETBIT(val, shift) (((val) >> shift) & 1) - -#define ASM_FREG_FSR -1 /* Nasty little hack */ -#define ASM_SP_ASI_P 0x80 /* Primary ASI */ -#define ASM_SP_ASI_P_L 0x88 /* Primary ASI little-endian */ - -/* SPARC Instruction decoders */ -int asm_sparc_add (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_addc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_addcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_addccc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_and (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_andcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_andn (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_andncc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_bicc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_bpcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_bpr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_call (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_casa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_casxa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_done (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fbfcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fbpfcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmpd (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmped (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmpeq (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmpes (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmpq (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fcmps (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_flush (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_flushw (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovdcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovdr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovqcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovqr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovscc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fmovsr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_fpop1 (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_hu (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_hu2 (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_illegal (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_illtrap (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_impdep1 (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_impdep2 (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_jmpl (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldd (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldda (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lddf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lddfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldfsr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldqf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldqfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldsb (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldsba (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldsh (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldsha (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldstub (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldstuba (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldsw (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldswa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldub (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lduba (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lduh (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lduha (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lduw (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_lduwa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldx (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_ldxa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_movcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_movr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_mulscc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_mulx (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_or (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_orcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_orn (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_orncc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_popc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_prefetch (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_prefetcha (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_rd (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_rdpr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_restore (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_return (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_save (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_saved (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sdiv (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sdivcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sdivx (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sethi (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sll (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_smul (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_smulcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sra (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_srl (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stb (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stba (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_std (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stda (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stdf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stdfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stfsr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sth (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stha (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stqf (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stqfa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stw (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stwa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stx (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_stxa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_sub (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_subc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_subcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_subccc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_swap (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_swapa (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_taddcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_taddcctv (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_tcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_tsubcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_tsubcctv (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_udiv (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_udivcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_udivx (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_umul (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_umulcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_wr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_wrpr (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_xnor (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_xnorcc (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_xor (asm_instr *, u_char *, u_int, asm_processor *); -int asm_sparc_xorcc (asm_instr *, u_char *, u_int, asm_processor *); - -void sparc_convert_pbranch(struct s_decode_pbranch *, u_char *); -void sparc_convert_rbranch(struct s_decode_rbranch *, u_char *); -void sparc_convert_branch(struct s_decode_branch *, u_char *); -void sparc_convert_call(struct s_decode_call *, u_char *); -void sparc_convert_format3(struct s_decode_format3 *, u_char *); -void sparc_convert_format4(struct s_decode_format4 *, u_char *); - -void asm_resolve_sparc(void *, u_int, char *, u_int); - -/* Get operand name */ -char *asm_sparc_get_op_name (asm_operand *op); - -char *get_sparc_register(int reg); -char *get_sparc_sregister(int reg); -char *get_sparc_pregister(int reg); -char *get_sparc_fregister(int reg); -char *get_sparc_cc(int cc); - -/* SPARC operand handlers (ie. fetchers) */ -int asm_sparc_op_fetch (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); - -int asm_sparc_op_fetch_register (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_immediate (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_displacement (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_disp30 (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_sethi (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_fregister (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_sregister (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_pregister (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_cc (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_imm_address (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); -int asm_sparc_op_fetch_reg_address (asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins); - -/** - * Registration functions. - * - */ - -int asm_register_sparc(); - -/***** - * sparc processor internals - */ - -struct s_asm_ins_sparc { - int instr; - asm_operand op1; - asm_operand op2; - asm_operand op3; -}; - -/** - * SPARC "flags" (ie. condition codes) - */ -enum e_sparc_flags { - /* Flags inside the integer condition codes (icc, xcc) */ - ASM_SP_FLAG_C = 1 << 0, // Carry - ASM_SP_FLAG_V = 1 << 1, // oVerflow - ASM_SP_FLAG_Z = 1 << 2, // Zero - ASM_SP_FLAG_N = 1 << 3, // Negative - /* Floating-point condition codes */ - ASM_SP_FLAG_FCC0 = 1 << 4, - ASM_SP_FLAG_FCC1 = 1 << 5, - ASM_SP_FLAG_FCC2 = 1 << 6, - ASM_SP_FLAG_FCC3 = 1 << 7 -}; - - -struct s_asm_proc_sparc { - /* handlers for x86 instructions referenced by opcode */ - int *bcc_table; - int *brcc_table; - int *fbcc_table; - int *shift_table; - int *movcc_table; - int *movfcc_table; - int *movr_table; - int *fpop1_table; - int *fmovcc_table; - int *fmovfcc_table; - int *fmovr_table; - int *fcmp_table; - int *tcc_table; - int *op2_table; - int *op3_table; -}; - - -enum e_sparc_gregisters { - ASM_REG_R0, - ASM_REG_R1 -} ; - -enum e_sparc_sregisters { - ASM_REG_G0, - ASM_REG_G1, - ASM_REG_G2, - ASM_REG_G3, - ASM_REG_G4, - ASM_REG_G5, - ASM_REG_G6, - ASM_REG_G7, - ASM_REG_O0, - ASM_REG_O1, - ASM_REG_O2, - ASM_REG_O3, - ASM_REG_O4, - ASM_REG_O5, - ASM_REG_O6, - ASM_REG_O7, - ASM_REG_L0, - ASM_REG_L1, - ASM_REG_L2, - ASM_REG_L3, - ASM_REG_L4, - ASM_REG_L5, - ASM_REG_L6, - ASM_REG_L7, - ASM_REG_I0, - ASM_REG_I1, - ASM_REG_I2, - ASM_REG_I3, - ASM_REG_I4, - ASM_REG_I5, - ASM_REG_I6, - ASM_REG_I7 -} ; - -enum e_sparc_state_registers { - ASM_SREG_Y, - ASM_SREG_BAD, - ASM_SREG_CCR, - ASM_SREG_ASI, - ASM_SREG_TICK, - ASM_SREG_PC, - ASM_SREG_FPRS - /* Values from 7 to 31 are either unused or implementation-specific */ -}; - -enum e_sparc_privileged_registers { - ASM_PREG_TPC, - ASM_PREG_TNPC, - ASM_PREG_TSTATE, - ASM_PREG_TT, - ASM_PREG_TICK, - ASM_PREG_TBA, - ASM_PREG_PSTATE, - ASM_PREG_TL, - ASM_PREG_PIL, - ASM_PREG_CWP, - ASM_PREG_CANSAVE, - ASM_PREG_CANRESTORE, - ASM_PREG_CLEANWIN, - ASM_PREG_OTHERWIN, - ASM_PREG_WSTATE, - ASM_PREG_FQ, - ASM_PREG_BAD16, /* Values from 16 to 30 are reserved */ - ASM_PREG_BAD17, - ASM_PREG_BAD18, - ASM_PREG_BAD19, - ASM_PREG_BAD20, - ASM_PREG_BAD21, - ASM_PREG_BAD22, - ASM_PREG_BAD23, - ASM_PREG_BAD24, - ASM_PREG_BAD25, - ASM_PREG_BAD26, - ASM_PREG_BAD27, - ASM_PREG_BAD28, - ASM_PREG_BAD29, - ASM_PREG_BAD30, - ASM_PREG_VER -}; - -enum e_sparc_condition_codes { - ASM_SP_FCC0, - ASM_SP_FCC1, - ASM_SP_FCC2, - ASM_SP_FCC3, - ASM_SP_ICC, - ASM_SP_BADCC, /* 5 and 7 are reserved */ - ASM_SP_XCC -}; - -/** - * Instruction family, depending on op field - */ -enum e_sparc_opcode { - ASM_SPARC_OP0_BRANCH, - ASM_SPARC_OP1_CALL, - ASM_SPARC_OP2_FORMAT3, - ASM_SPARC_OP3_FORMAT3 -}; - -/* Possible values for SPARC operands' content attribute */ -enum e_sparc_operand { - ASM_SP_OTYPE_REGISTER, - ASM_SP_OTYPE_IMMEDIATE, - ASM_SP_OTYPE_DISPLACEMENT, - ASM_SP_OTYPE_DISP30, - ASM_SP_OTYPE_SETHI, - ASM_SP_OTYPE_FREGISTER, - ASM_SP_OTYPE_SREGISTER, - ASM_SP_OTYPE_PREGISTER, - ASM_SP_OTYPE_CC, - ASM_SP_OTYPE_IMM_ADDRESS, /* [ r[rs1] + imm ] */ - ASM_SP_OTYPE_REG_ADDRESS, /* [ r[rs1] + r[rs2] ] */ - - ASM_SP_OTYPE_NUM /* This element must be the last in the enum */ -}; - - -/*** - * Instruction list - * - * Last instruction must be ASM_SP_BAD - */ -enum e_sparc_instr { - ASM_SP_, - - ASM_SP_ADD, /* ADD */ - ASM_SP_ADDCC, /* ADDcc */ - ASM_SP_ADDC, /* ADDC */ - ASM_SP_ADDCCC, /* ADDCcc */ - ASM_SP_AND, /* AND */ - ASM_SP_ANDCC, /* ANDcc */ - ASM_SP_ANDN, /* ANDN */ - ASM_SP_ANDNCC, /* ANDNcc */ - ASM_SP_BA, /* BPcc, Bicc */ - ASM_SP_BN, - ASM_SP_BNE, - ASM_SP_BE, - ASM_SP_BG, - ASM_SP_BLE, - ASM_SP_BGE, - ASM_SP_BL, - ASM_SP_BGU, - ASM_SP_BLEU, - ASM_SP_BCC, - ASM_SP_BCS, - ASM_SP_BPOS, - ASM_SP_BNEG, - ASM_SP_BVC, - ASM_SP_BVS, - ASM_SP_BRZ, /* BPr */ - ASM_SP_BRLEZ, - ASM_SP_BRLZ, - ASM_SP_BRNZ, - ASM_SP_BRGZ, - ASM_SP_BRGEZ, - ASM_SP_CALL, /* CALL */ - ASM_SP_CASA, /* CASA */ - ASM_SP_CASXA, /* CASXA */ - ASM_SP_DONE, /* DONE */ - ASM_SP_FABSS, /* FABS(s,d,q) */ - ASM_SP_FABSD, - ASM_SP_FABSQ, - ASM_SP_FADDS, /* FADD(s,d,q) */ - ASM_SP_FADDD, - ASM_SP_FADDQ, - ASM_SP_FBA, /* FBfcc, FBPfcc */ - ASM_SP_FBN, - ASM_SP_FBU, - ASM_SP_FBG, - ASM_SP_FBUG, - ASM_SP_FBL, - ASM_SP_FBUL, - ASM_SP_FBLG, - ASM_SP_FBNE, - ASM_SP_FBE, - ASM_SP_FBUE, - ASM_SP_FBGE, - ASM_SP_FBUGE, - ASM_SP_FBLE, - ASM_SP_FBULE, - ASM_SP_FBO, - ASM_SP_FCMPS, /* FCMP(s,d,q) */ - ASM_SP_FCMPD, - ASM_SP_FCMPQ, - ASM_SP_FCMPES, /* FCMPE(s,d,q) */ - ASM_SP_FCMPED, - ASM_SP_FCMPEQ, - ASM_SP_FDIVS, /* FDIV(s,d,q) */ - ASM_SP_FDIVD, - ASM_SP_FDIVQ, - ASM_SP_FDMULQ, /* FdMULq */ - ASM_SP_FITOS, /* FiTO(s,d,q) */ - ASM_SP_FITOD, - ASM_SP_FITOQ, - ASM_SP_FLUSH, /* FLUSH */ - ASM_SP_FLUSHW, /* FLUSHW */ - ASM_SP_FMOVS, /* FMOV(s,d,q) */ - ASM_SP_FMOVD, - ASM_SP_FMOVQ, - ASM_SP_FMOVSA, /* FMOV(s,d,q)cc */ - ASM_SP_FMOVSN, - ASM_SP_FMOVSNE, - ASM_SP_FMOVSE, - ASM_SP_FMOVSG, - ASM_SP_FMOVSLE, - ASM_SP_FMOVSGE, - ASM_SP_FMOVSL, - ASM_SP_FMOVSGU, - ASM_SP_FMOVSLEU, - ASM_SP_FMOVSCC, - ASM_SP_FMOVSCS, - ASM_SP_FMOVSPOS, - ASM_SP_FMOVSNEG, - ASM_SP_FMOVSVC, - ASM_SP_FMOVSVS, - ASM_SP_FMOVSU, - ASM_SP_FMOVSUG, - ASM_SP_FMOVSUL, - ASM_SP_FMOVSLG, - ASM_SP_FMOVSUE, - ASM_SP_FMOVSUGE, - ASM_SP_FMOVSULE, - ASM_SP_FMOVSO, - ASM_SP_FMOVDA, - ASM_SP_FMOVDN, - ASM_SP_FMOVDNE, - ASM_SP_FMOVDE, - ASM_SP_FMOVDG, - ASM_SP_FMOVDLE, - ASM_SP_FMOVDGE, - ASM_SP_FMOVDL, - ASM_SP_FMOVDGU, - ASM_SP_FMOVDLEU, - ASM_SP_FMOVDCC, - ASM_SP_FMOVDCS, - ASM_SP_FMOVDPOS, - ASM_SP_FMOVDNEG, - ASM_SP_FMOVDVC, - ASM_SP_FMOVDVS, - ASM_SP_FMOVDU, - ASM_SP_FMOVDUG, - ASM_SP_FMOVDUL, - ASM_SP_FMOVDLG, - ASM_SP_FMOVDUE, - ASM_SP_FMOVDUGE, - ASM_SP_FMOVDULE, - ASM_SP_FMOVDO, - ASM_SP_FMOVQA, - ASM_SP_FMOVQN, - ASM_SP_FMOVQNE, - ASM_SP_FMOVQE, - ASM_SP_FMOVQG, - ASM_SP_FMOVQLE, - ASM_SP_FMOVQGE, - ASM_SP_FMOVQL, - ASM_SP_FMOVQGU, - ASM_SP_FMOVQLEU, - ASM_SP_FMOVQCC, - ASM_SP_FMOVQCS, - ASM_SP_FMOVQPOS, - ASM_SP_FMOVQNEG, - ASM_SP_FMOVQVC, - ASM_SP_FMOVQVS, - ASM_SP_FMOVQU, - ASM_SP_FMOVQUG, - ASM_SP_FMOVQUL, - ASM_SP_FMOVQLG, - ASM_SP_FMOVQUE, - ASM_SP_FMOVQUGE, - ASM_SP_FMOVQULE, - ASM_SP_FMOVQO, - ASM_SP_FMOVRSZ, /* FMOV(s,d,q)r */ - ASM_SP_FMOVRSLEZ, - ASM_SP_FMOVRSLZ, - ASM_SP_FMOVRSNZ, - ASM_SP_FMOVRSGZ, - ASM_SP_FMOVRSGEZ, - ASM_SP_FMOVRDZ, - ASM_SP_FMOVRDLEZ, - ASM_SP_FMOVRDLZ, - ASM_SP_FMOVRDNZ, - ASM_SP_FMOVRDGZ, - ASM_SP_FMOVRDGEZ, - ASM_SP_FMOVRQZ, - ASM_SP_FMOVRQLEZ, - ASM_SP_FMOVRQLZ, - ASM_SP_FMOVRQNZ, - ASM_SP_FMOVRQGZ, - ASM_SP_FMOVRQGEZ, - ASM_SP_FMULS, /* FMUL(s,d,q) */ - ASM_SP_FMULD, - ASM_SP_FMULQ, - ASM_SP_FNEGS, /* FNEG(s,d,q) */ - ASM_SP_FNEGD, - ASM_SP_FNEGQ, - ASM_SP_FSMULD, /* FsMULd */ - ASM_SP_FSQRTS, /* FSQRT(s,d,q) */ - ASM_SP_FSQRTD, - ASM_SP_FSQRTQ, - ASM_SP_FSTOI, /* F(s,d,q)TOi */ - ASM_SP_FDTOI, - ASM_SP_FQTOI, - ASM_SP_FSTOD, /* F(s,d,q)TO(s,d,q) */ - ASM_SP_FSTOQ, - ASM_SP_FDTOS, - ASM_SP_FDTOQ, - ASM_SP_FQTOS, - ASM_SP_FQTOD, - ASM_SP_FSTOX, /* F(s,d,q)TOx */ - ASM_SP_FDTOX, - ASM_SP_FQTOX, - ASM_SP_FSUBS, /* FSUB(s,d,q) */ - ASM_SP_FSUBD, - ASM_SP_FSUBQ, - ASM_SP_FXTOS, /* FxTO(s,d,q) */ - ASM_SP_FXTOD, - ASM_SP_FXTOQ, - ASM_SP_ILLTRAP, /* ILLTRAP */ - ASM_SP_IMPDEP1, /* IMPDEP1 */ - ASM_SP_IMPDEP2, /* IMPDEP2 */ - ASM_SP_JMPL, /* JMPL, RET, RETL */ - ASM_SP_LDD, /* LDD */ - ASM_SP_LDDA, /* LDDA */ - ASM_SP_LDDF, /* LDFF */ - ASM_SP_LDDFA, /* LDDFA */ - ASM_SP_LDF, /* LDF */ - ASM_SP_LDFA, /* LDFA */ - ASM_SP_LDFSR, /* LDFSR */ - ASM_SP_LDQF, /* LDQF */ - ASM_SP_LDQFA, /* LDQFA */ - ASM_SP_LDSB, /* LDSB */ - ASM_SP_LDSBA, /* LDSBA */ - ASM_SP_LDSH, /* LDSH */ - ASM_SP_LDSHA, /* LDSHA */ - ASM_SP_LDSTUB, /* LDSTUB */ - ASM_SP_LDSTUBA, /* LDSTUBA */ - ASM_SP_LDSW, /* LDSW */ - ASM_SP_LDSWA, /* LDSWA */ - ASM_SP_LDUB, /* LDUB */ - ASM_SP_LDUBA, /*LDUBA */ - ASM_SP_LDUH, /* LDUH */ - ASM_SP_LDUHA, /* LDUHA */ - ASM_SP_LDUW, /* LDUW */ - ASM_SP_LDUWA, /* LDUWA */ - ASM_SP_LDX, /* LDX */ - ASM_SP_LDXA, /* LDXA */ - ASM_SP_LDXFSR, /* LDXFSR */ - ASM_SP_MEMBAR, /* MEMBAR */ - ASM_SP_MOVA, /* MOVcc */ - ASM_SP_MOVN, - ASM_SP_MOVNE, - ASM_SP_MOVE, - ASM_SP_MOVG, - ASM_SP_MOVLE, - ASM_SP_MOVGE, - ASM_SP_MOVL, - ASM_SP_MOVGU, - ASM_SP_MOVLEU, - ASM_SP_MOVCC, - ASM_SP_MOVCS, - ASM_SP_MOVPOS, - ASM_SP_MOVNEG, - ASM_SP_MOVVC, - ASM_SP_MOVVS, - ASM_SP_MOVU, - ASM_SP_MOVUG, - ASM_SP_MOVUL, - ASM_SP_MOVLG, - ASM_SP_MOVUE, - ASM_SP_MOVUGE, - ASM_SP_MOVULE, - ASM_SP_MOVO, - ASM_SP_MOVRZ, /* MOVr */ - ASM_SP_MOVRLEZ, - ASM_SP_MOVRLZ, - ASM_SP_MOVRNZ, - ASM_SP_MOVRGZ, - ASM_SP_MOVRGEZ, - ASM_SP_MULSCC, /* MULScc */ - ASM_SP_MULX, /* MULX */ - ASM_SP_NOP, /* NOP */ - ASM_SP_OR, /* OR */ - ASM_SP_ORCC, /* ORcc */ - ASM_SP_ORN, /* ORC */ - ASM_SP_ORNCC, /* ORNcc */ - ASM_SP_POPC, /* POPC */ - ASM_SP_PREFETCH, /* PREFETCH */ - ASM_SP_PREFETCHA, /* PREFETCHA */ - ASM_SP_RD, /* RDASI, RDASR, RDCCR, RDFPRS, RDPC, RDPR, RDTICK, RDY */ - ASM_SP_RDPR, /* RDPR */ - ASM_SP_RESTORE, /* RESTORE */ - ASM_SP_RESTORED, /* RESTORED */ - ASM_SP_RETRY, /* RETRY */ - ASM_SP_RETURN, /* RETURN */ - ASM_SP_SAVE, /* SAVE */ - ASM_SP_SAVED, /* SAVED */ - ASM_SP_SDIV, /* SDIV */ - ASM_SP_SDIVCC, /* SDIVcc */ - ASM_SP_SDIVX, /* SDIVX */ - ASM_SP_SETHI, /* SETHI */ - ASM_SP_SIR, /* SIR */ - ASM_SP_SLL, /* SLL */ - ASM_SP_SLLX, /* SLLX */ - ASM_SP_SMUL, /* SMUL */ - ASM_SP_SMULCC, /* SMULcc */ - ASM_SP_SQRTS, /* SQRT(s,d,q) */ - ASM_SP_SQRTD, - ASM_SP_SQRTQ, - ASM_SP_SRA, /* SRA */ - ASM_SP_SRAX, /* SRAX */ - ASM_SP_SRL, /* SRL */ - ASM_SP_SRLX, /* SRLX */ - ASM_SP_STB, /* STB */ - ASM_SP_STBA, /* STBA */ - ASM_SP_STBAR, /* STBAR */ - ASM_SP_STD, /* STD */ - ASM_SP_STDA, /* STDA */ - ASM_SP_STDF, /* STDF */ - ASM_SP_STDFA, /* STDFA */ - ASM_SP_STF, /* STF */ - ASM_SP_STFA, /* STFA */ - ASM_SP_STFSR, /* STFSR */ - ASM_SP_STH, /* STH */ - ASM_SP_STHA, /* STHA */ - ASM_SP_STQF, /* STQF */ - ASM_SP_STQFA, /* STQFA */ - ASM_SP_STW, /* STW */ - ASM_SP_STWA, /* STWA */ - ASM_SP_STX, /* STX */ - ASM_SP_STXA, /* STXA */ - ASM_SP_STXFSR, /* STXFSR */ - ASM_SP_SUB, /* SUB */ - ASM_SP_SUBCC, /* SUBcc */ - ASM_SP_SUBC, /* SUBC */ - ASM_SP_SUBCCC, /* SUBCcc */ - ASM_SP_SWAP, /* SWAP */ - ASM_SP_SWAPA, /* SWAPA */ - ASM_SP_TADDCC, /* TADDcc */ - ASM_SP_TADDCCTV, /* TADDccTV */ - ASM_SP_TA, /* Tcc */ - ASM_SP_TN, - ASM_SP_TNE, - ASM_SP_TE, - ASM_SP_TG, - ASM_SP_TLE, - ASM_SP_TGE, - ASM_SP_TL, - ASM_SP_TGU, - ASM_SP_TLEU, - ASM_SP_TCC, - ASM_SP_TCS, - ASM_SP_TPOS, - ASM_SP_TNEG, - ASM_SP_TVC, - ASM_SP_TVS, - ASM_SP_TSUBCC, /* TSUBcc */ - ASM_SP_TSUBCCTV, /* TSUBccTV */ - ASM_SP_UDIV, /* UDIV */ - ASM_SP_UDIVCC, /* UDIVcc */ - ASM_SP_UDIVX, /* UDIVX */ - ASM_SP_UMUL, /* UMUL */ - ASM_SP_UMULCC, /* UMULcc */ - ASM_SP_WR, /* WRASI, WRASR, WRCCR, WRFPRS, WRY */ - ASM_SP_WRPR, /* WRPR */ - ASM_SP_XNOR, /* XNOR */ - ASM_SP_XNORCC, /* XNORcc */ - ASM_SP_XOR, /* XOR */ - ASM_SP_XORCC, /* XORcc */ - ASM_SP_CMP, /* Synthetics */ - ASM_SP_JMP, - ASM_SP_IPREFETCH, - ASM_SP_TST, - ASM_SP_RET, - ASM_SP_RETL, - ASM_SP_SETUW, - ASM_SP_SET, - ASM_SP_SETSW, - ASM_SP_SETX, - ASM_SP_SIGNX, - ASM_SP_NOT, - ASM_SP_NEG, - ASM_SP_CAS, - ASM_SP_CASL, - ASM_SP_CASX, - ASM_SP_CASXL, - ASM_SP_INC, - ASM_SP_INCCC, - ASM_SP_DEC, - ASM_SP_DECCC, - ASM_SP_BTST, - ASM_SP_BSET, - ASM_SP_BCLR, - ASM_SP_BTOG, - ASM_SP_CLR, - ASM_SP_CLRB, - ASM_SP_CLRH, - ASM_SP_CLRX, - ASM_SP_CLRUW, - ASM_SP_MOV, - - ASM_SP_BAD -}; - -extern char *sparc_instr_list[ASM_SP_BAD + 1]; -extern int sparc_bcc_list[16]; -extern int sparc_brcc_list[8]; -extern int sparc_fbcc_list[16]; -extern int sparc_shift_list[6]; -extern int sparc_movcc_list[16]; -extern int sparc_movfcc_list[16]; -extern int sparc_movr_list[8]; -extern int sparc_fpop1_list[256]; -extern int sparc_fmovcc_list[48]; -extern int sparc_fmovfcc_list[48]; -extern int sparc_fmovr_list[24]; -extern int sparc_fcmp_list[8]; -extern int sparc_tcc_list[16]; -extern int sparc_op2_table[64]; -extern int sparc_op3_table[64]; - -#endif diff -Nru eresi-0.8a25/libasm/include/.svn/text-base/libasm-structs.h.svn-base eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-structs.h.svn-base --- eresi-0.8a25/libasm/include/.svn/text-base/libasm-structs.h.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/include/.svn/text-base/libasm-structs.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -/** - * @file libasm-structs.h - * - * Made by #!HATE#@! - * Login - * - * Started on Tue Jun 14 05:00:05 2005 #!HATE#@! - * Last update Thu Jun 16 04:56:41 2005 #!HATE#@! - * - * $Id: libasm-structs.h,v 1.15 2007/10/29 11:26:44 heroine Exp $ - * - */ - -/** - * Operand structure. - */ -struct s_asm_op -{ - /* pointer to processor structure. - to remove - */ - //asm_processor *proc; - /** operand length. (usefull on ia32 only). - * operands expressed in R byte from ModRM byte have a null size. */ - u_int len; - /* pointer to operand in buffer */ - u_char *ptr; - /* operand type: contain operand type flags */ - u_int type; - /* a pointer to the operand name in string format */ - char *name; - /* contain operand size flags */ - u_int size; - /* Operand content flags */ - u_int content; - /* register set: 8/16/32 bits general registers, segment registers .. - * (ia32 only) */ - int regset; - /* operand prefix (ia32 only) */ - int prefix; - /* immediate value extracted from operand */ - int imm; - /* base register: primary register extracted */ - int baser; - /* index register: auxiliary register */ - int indexr; - /* */ - char *sbaser; - /* */ - char *sindex; - /* address space (sparc only) - * - * has to be different than ASM_SP_ASI_P for ASM_SP_OTYPE_IMM_ADDRESS - * operands on "alternate space" instructions so the output can be correct - */ - int address_space; - /* scale factor (ia32 only) */ - unsigned int scale; -}; - - -/** - * Instruction structure. - * - * This contains all the fields related to an instruction: type, mnemonic, - * operand types, contents. - */ - -struct s_asm_instr -{ - /* pointer to instruction buffer -- please let this field in first if using containers */ - u_char *ptr_instr; - /* internal processor structure */ - asm_processor *proc; - /* instruction name */ - char *name; - /* instruction id */ - int instr; - /* instruction type */ - int type; - /* instruction prefix (ia32 only) */ - int prefix; - /* stack offset difference. push/pop/ret/call related */ - int spdiff; - /* bitfield of flags which could have been modified */ - int flagswritten; - /* bitfield of flags which were read */ - int flagsread; - /* Pointer to instruction prefix (ia32 only) */ - void *ptr_prefix; - /* annul bit (sparc only) */ - int annul; - /* prediction bit (sparc only) */ - int prediction; - /* number of operand */ - int nb_op; - /* Array of operands */ - asm_operand op[4]; - /* instruction/operands full lengh */ - u_int len; -}; - - -/** - * Processor structure. - * Contains architecture dependant handler. - * - * This structure contains several functions pointers which are used - * to as handlers to manage each architecture. - * - * NOTE: A vector should be implemented to replace thoses handlers - * by provided functions. - */ - -struct s_asm_processor -{ - /* handler to resolving function */ - void (*resolve_immediate)(void *, u_int, char *, u_int); - /* handler data pointer */ - void *resolve_data; - /* processor type */ - int type; - /* array to instruction memonic by instr field of asm_instr */ - char **instr_table; - /* fetching instruction. points to processor fetching function. */ - LIBASM_HANDLER_FETCH(fetch); - //int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *proc); - /* output handler. print instruction in a readable string */ - char *(*display_handle)(asm_instr *instr, int addr); - /* pointer to an internal structure. */ - void *internals; - /* Last operation error code */ - int error_code; - - -}; diff -Nru eresi-0.8a25/libasm/Makefile eresi-0.0.20110516/libasm/Makefile --- eresi-0.8a25/libasm/Makefile 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/Makefile 2011-05-16 11:34:46.000000000 +0000 @@ -1,16 +1,19 @@ ## -## $Id: Makefile,v 1.31 2008/01/01 17:07:26 heroine Exp $ +## $Id: Makefile 1331 2009-02-17 05:02:42Z figueredo $ ## Author : ## Started : Xxx Xxx xx xx:xx:xx 2002 ## Updated : Sun Mar 21 00:03:07 2004 ## #DBGFLAGS = -ggdb -DDEBUG_SPARC -include Makefile.inc include ../config.h # # Architecture source files # + +#CFLAGS += -ggdb +CFLAGS += $(CFLAGS_libasm) $(EXTRACFLAGS) + SRCS_libasm = \ src/generic.c \ src/output.c \ @@ -19,45 +22,138 @@ src/instruction.c \ src/register.c \ src/build.c \ - src/vectors.c \ - src/arch/ia32/init_i386.c \ + src/vectors.c + +# +# IA32 Support +# + +ifeq ($(LIBASM_ENABLE_IA32), 1) +SRCS_libasm += src/arch/ia32/init_i386.c \ src/arch/ia32/register.c \ src/arch/ia32/tables_i386.c \ src/arch/ia32/output_ia32.c \ - src/arch/ia32/operand_ia32.c \ - src/arch/sparc/init_sparc.c \ + src/arch/ia32/operand_ia32.c +ifeq ($(LIBASM_PACKED_HANDLERS), 1) +$(info IA32 Packed) +PACKED_ARCH += packed_ia32 +SRCS_libasm += src/arch/ia32/packed_handlers.c +else +$(info IA32 Unpacked) +SRCS_libasm += $(foreach dir,src/arch/ia32/handlers/,\ + $(wildcard $(dir)/*.c)) +SRCS_libasm += $(foreach dir,src/arch/ia32/operand_handlers/,\ + $(wildcard $(dir)/*.c)) +endif +CFLAGS += -DLIBASM_ENABLE_IA32 +endif + +# +# Sparc Support +# + +ifeq ($(LIBASM_ENABLE_SPARC), 1) +PACKED_ARCH += packed_sparc +SRCS_libasm += src/arch/sparc/init_sparc.c \ src/arch/sparc/register.c \ src/arch/sparc/tables_sparc.c \ src/arch/sparc/output_sparc.c \ - src/arch/sparc/sparc_convert.c \ - src/arch/mips/init_mips.c \ + src/arch/sparc/sparc_convert.c +ifeq ($(LIBASM_PACKED_HANDLERS),1) +$(info SPARC Packed) +PACKED_ARCH += packed_sparc +SRCS_libasm += src/arch/sparc/packed_handlers.c +else +$(info SPARC Unpacked) +SRCS_libasm += $(foreach dir,src/arch/sparc/handlers/,\ + $(wildcard $(dir)/*.c)) +SRCS_libasm += $(foreach dir,src/arch/sparc/operand_handlers/,\ + $(wildcard $(dir)/*.c)) +endif +CFLAGS += -DLIBASM_ENABLE_SPARC +endif + +# +# Mips Support +# + +ifeq ($(LIBASM_ENABLE_MIPS), 1) +PACKED_ARCH += packed_mips +SRCS_libasm += src/arch/mips/init_mips.c \ src/arch/mips/output_mips.c \ src/arch/mips/tables_mips.c \ src/arch/mips/mips_convert.c \ src/arch/mips/register_mips.c +ifeq ($(LIBASM_PACKED_HANDLERS), 1) +$(info MIPS Packed) +PACKED_ARCH += packed_mips +SRCS_libasm += src/arch/mips/packed_handlers.c +else +$(info MIPS Unpacked) +SRCS_libasm += $(foreach dir,src/arch/mips/handlers/,\ + $(wildcard $(dir)/*.c)) +SRCS_libasm += $(foreach dir,src/arch/mips/operand_handlers/,\ + $(wildcard $(dir)/*.c)) +endif +CFLAGS += -DLIBASM_ENABLE_MIPS +endif +# +# ARM Support +# +ifeq ($(LIBASM_ENABLE_ARM), 1) +PACKED_ARCH += packed_arm +SRCS_libasm += src/arch/arm/init_arm.c \ + src/arch/arm/register_arm.c \ + src/arch/arm/tables_arm.c \ + src/arch/arm/output_arm.c \ + src/arch/arm/decode_arm.c \ + src/arch/arm/arm_convert.c +ifeq ($(LIBASM_PACKED_HANDLERS),1) +$(info ARM Packed) +PACKED_ARCH += packed_arm +SRCS_libasm += src/arch/arm/packed_handlers.c +else +$(info ARM Unpacked) +SRCS_libasm += $(foreach dir,src/arch/arm/handlers/,\ + $(wildcard $(dir)/*.c)) +SRCS_libasm += $(foreach dir,src/arch/arm/operand_handlers/,\ + $(wildcard $(dir)/*.c)) +endif +CFLAGS += -DLIBASM_ENABLE_ARM +endif -OBJS_libasm = ${SRCS_libasm:.c=.o} -OBJS_libasm += ${SRCS_hdl:.c=.o} -NAME_libasm = libasm.a -NAME_libasm_o = libasm.o +OBJS32_libasm = ${SRCS_libasm:.c=.32.o} +OBJS32_libasm += ${SRCS_hdl:.c=.32.o} +OBJS64_libasm = ${SRCS_libasm:.c=.64.o} +OBJS64_libasm += ${SRCS_hdl:.c=.64.o} + +NAME32_libasm = libasm32.a +NAME32_libasm_o = libasm32.o +NAME64_libasm = libasm64.a +NAME64_libasm_o = libasm64.o SRCS_sparc = tools/sparc_mydisasm.c OBJS_sparc = ${SRCS_sparc:.c=.o} NAME_sparc = test_sparc -CFLAGS = -Iinclude -Isrc/include -Wall -g3 -fPIC -DERESI32 \ - -I../libaspect/include -#CFLAGS += -O2 +CFLAGS32 = $(CFLAGS) -Iinclude -Isrc/include -Wall -g3 -fPIC -I../libaspect/include -DERESI32 +CFLAGS64 = $(CFLAGS) -Iinclude -Isrc/include -Wall -g3 -fPIC -I../libaspect/include -DERESI64 + RM = rm -f ETAGS = etags CC ?= gcc -E LD ?= ld CP = cp -all: libasm.so +all: all32 all64 +all32: libasm32.so +all64: libasm64.so + +#src/arch/ia32/packed_handlers.c: +# cat ${SRCS_IA32} > src/arch/ia32/packed_handlers.c install: ${CP} ${NAME_libasm} /usr/lib @@ -69,47 +165,80 @@ @sh configure @rm -f src/build.o -libasm.so: $(OBJS_libasm) - @ar rc ${NAME_libasm} ${OBJS_libasm} - @echo "[AR] ${NAME_libasm}" - @${RANLIB} ${NAME_libasm} - @echo "[RANLIB] ${NAME_libasm}" - @$(LD) -r $(OBJS_libasm) -o ${NAME_libasm_o} - @echo "[CC -shared] libasm.so" +libasm32.so: $(PACKED_ARCH) $(OBJS32_libasm) + ar rc ${NAME32_libasm} ${OBJS32_libasm} +#echo "[AR] ${NAME32_libasm}" + ${RANLIB} ${NAME32_libasm} +#echo "[RANLIB] ${NAME_libasm}" + $(LD) -r $(OBJS32_libasm) -o ${NAME32_libasm_o} +#echo "[CC -shared] libasm32.so" +ifeq ($(IRIX),1) + $(LD) -L../libaspect/ -laspect32 ${OBJS32_libasm} -o libasm32.so -shared +else + $(CC) -L../libaspect/ -laspect32 ${OBJS32_libasm} -o libasm32.so -shared +endif + +libasm64.so: $(PACKED_ARCH) $(OBJS64_libasm) + ar rc ${NAME64_libasm} ${OBJS64_libasm} +#echo "[AR] ${NAME64_libasm}" + ${RANLIB} ${NAME64_libasm} +#echo "[RANLIB] ${NAME64_libasm}" + $(LD) -r $(OBJS64_libasm) -o ${NAME64_libasm_o} +#echo "[CC -shared] libasm64.so" ifeq ($(IRIX),1) - @$(LD) ${OBJS_libasm} -o libasm.so -shared + $(LD) -L../libaspect/ -laspect64 ${OBJS64_libasm} -o libasm64.so -shared else - @$(CC) ${OBJS_libasm} -o libasm.so -shared + $(CC) -L../libaspect/ -laspect64 ${OBJS64_libasm} -o libasm64.so -shared endif clean: - @$(RM) ${OBJS_libasm} ${OBJS_mydisasm} ${OBJS_cmpdump} Makefile.inc - @find . -name '*~' -exec rm -f {} \; - @find src -name '*.o' -exec rm -rf {} \; + $(RM) ${OBJS32_libasm} ${OBJ64_libasm} ${OBJS_mydisasm} ${OBJS_cmpdump} Makefile.inc + find . -name '*~' -exec rm -f {} \; + find src -name '*.o' -exec rm -rf {} \; + find src -name 'packed_handlers.c' -exec rm -rf {} \; fclean: clean - @$(RM) ${NAME_libasm} ${NAME_libasm_o} ${NAME_mydisasm} ${NAME_cmpdump} - @$(RM) *.so *.o *.a - @$(RM) mydisasm + $(RM) ${NAME32_libasm} ${NAME64_libasm} ${NAME_mydisasm} ${NAME_cmpdump} + $(RM) *.so *.o *.a + $(RM) mydisasm tags: - @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c - @echo TAGS generated succesfully + $(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c + echo TAGS generated succesfully -.c.o: - @$(CC) $(CFLAGS) ${DBGFLAGS} -c $*.c -o $*.o - @echo "[CC] $*.o" +#.c.o: +# $(CC) $(CFLAGS) ${DBGFLAGS} -c $*.c -o $*.o +#echo "[CC] $*.o" docs: doxygen doc/doxygen.conf -mydisasm: +mydisasm32: $(CC) -g3 -I../libelfsh/include/ -I../libaspect/include/ -I./include/ \ tools/mydisasm.c -DERESI32 -o ./mydisasm -L ../libelfsh/ -lelfsh32 \ - -L../libaspect/ -laspect32 -L./ -lasm -L../libetrace/ -letrace32 + -L../libaspect/ -laspect32 -L./ -lasm32 + +mydisasm64: + $(CC) -g3 -I../libelfsh/include/ -I../libaspect/include/ -I./include/ \ + tools/mydisasm.c -DERESI64 -o ./mydisasm -L ../libelfsh/ -lelfsh64 \ + -L../libaspect/ -laspect64 -L./ -lasm64 test: (cd testsuite/ia32 && ${SHELL} launch_test.sh) Makefile.inc: $(SHELL) configure + +packed_ia32: + cat src/arch/ia32/handlers/*.c src/arch/ia32/operand_handlers/*.c > src/arch/ia32/packed_handlers.c +packed_sparc: + cat src/arch/sparc/handlers/*.c src/arch/sparc/operand_handlers/*.c > src/arch/sparc/packed_handlers.c +packed_mips: + cat src/arch/mips/handlers/*.c src/arch/mips/operand_handlers/*.c > src/arch/mips/packed_handlers.c +packed_arm: + cat src/arch/arm/handlers/*.c src/arch/arm/operand_handlers/*.c > src/arch/arm/packed_handlers.c +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< + +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libasm/src/arch/arm/arm_convert.c eresi-0.0.20110516/libasm/src/arch/arm/arm_convert.c --- eresi-0.8a25/libasm/src/arch/arm/arm_convert.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/arm_convert.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,305 @@ +/** +* @file libasm/src/arch/arm/arm_convert.c +** @ingroup arm +*/ +#include + +void arm_convert_dataproc(struct s_arm_decode_dataproc *opcode, u_char *buf) +{ + +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->op = (converted >> 26) & 0x03; + opcode->i = (converted >> 25) & 0x01; + opcode->op2 = (converted >> 21) & 0x0F; + opcode->s = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->shifter_operand = converted & 0xFFF; + +#else + memcpy(opcode,buf,4); +#endif + + opcode->rm = (opcode->shifter_operand & 0x0F); + opcode->rs = opcode->rotate_imm = ((opcode->shifter_operand >> 8) & 0x0F); + opcode->immed = (opcode->shifter_operand) & 0x0FF; + opcode->shift = ((opcode->shifter_operand >> 5) & 0x03); + opcode->shift_imm = ((opcode->shifter_operand >> 7) & 0x01F); + opcode->reg_shift = ((opcode->shifter_operand >> 4) & 0x01); + + /* MSR/MRS */ + opcode->r = (opcode->op2 >> 1) & 0x01; + opcode->topsr = opcode->op2 & 0x01; + opcode->field_mask = opcode->rn; +} + +void arm_convert_multiply(struct s_arm_decode_multiply *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none = (converted >> 24) & 0x03; + opcode->op = (converted >> 21) & 0x07; + opcode->s = (converted >> 20) & 0x01; + opcode->r1 = (converted >> 16) & 0x0F; + opcode->r2 = (converted >> 12) & 0x0F; + opcode->r3 = (converted >> 8) & 0x0F; + opcode->none2 = (converted >> 7) & 0x01; + opcode->y = (converted >> 6) & 0x01; + opcode->x = (converted >> 5) & 0x01; + opcode->none3 = (converted >> 4) & 0x01; + opcode->r4 = (converted & 0x0F); + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_ldst(struct s_arm_decode_ldst *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->op = (converted >> 26) & 0x03; + opcode->reg_offset = (converted >> 25) & 0x01; + opcode->p = (converted >> 24) & 0x01; + opcode->u = (converted >> 23) & 0x01; + opcode->b = (converted >> 22) & 0x01; + opcode->w = (converted >> 21) & 0x01; + opcode->l = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->imm_offset = converted & 0xFFF; + +#else + memcpy(opcode,buf,4); +#endif + + opcode->rm = opcode->imm_offset & 0x0F; + opcode->shift_imm = (opcode->imm_offset >> 7) & 0x1F; + opcode->shift = (opcode->imm_offset >> 5) & 0x03; +} + +void arm_convert_ldst_misc(struct s_arm_decode_ldst_misc *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->op = (converted >> 25) & 0x07; + opcode->p = (converted >> 24) & 0x01; + opcode->u = (converted >> 23) & 0x01; + opcode->i = (converted >> 22) & 0x01; + opcode->w = (converted >> 21) & 0x01; + opcode->l = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->immedH = (converted >> 8) & 0x0F; + opcode->none1 = (converted >> 7) & 0x01; + opcode->s = (converted >> 6) & 0x01; + opcode->h = (converted >> 5) & 0x01; + opcode->none2 = (converted >> 4) & 0x01; + opcode->immedL_rm = converted & 0x0F; +#else + memcpy(opcode,buf,4); +#endif + +} + +void arm_convert_ldst_mult(struct s_arm_decode_ldst_mult *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->op = (converted >> 25) & 0x07; + opcode->p = (converted >> 24) & 0x01; + opcode->u = (converted >> 23) & 0x01; + opcode->s = (converted >> 22) & 0x01; + opcode->w = (converted >> 21) & 0x01; + opcode->l = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->reg_list = converted & 0xFFFF; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_swap(struct s_arm_decode_ldst *opcode, u_char *buf) +{ + /* Many fields of the structure aren't used for swap */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->b = (converted >> 22) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->imm_offset = converted & 0xFFF; + +#else + memcpy(opcode,buf,4); +#endif + + opcode->rm = opcode->imm_offset & 0x0F; +} + +void arm_convert_branch1(struct s_arm_decode_branch1 *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->op = (converted >> 25) & 0x07; + opcode->l_h = (converted >> 24) & 0x01; + opcode->signed_imm = converted & 0x00FFFFFF; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_branch2(struct s_arm_decode_branch2 *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none1 = (converted >> 6) & 0x03FFFFF; + opcode->op = (converted >> 5) & 0x01; + opcode->none2 = (converted >> 4) & 0x01; + opcode->rm = converted & 0x0F; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_bkpt(struct s_arm_decode_bkpt *opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->none1 = (converted >> 20) & 0x0FFF; + opcode->immed1 = (converted >> 8) & 0x0FFF; + opcode->none2 = (converted >> 4) & 0x0F; + opcode->immed2 = converted & 0x0F; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_coproc_dataproc(struct s_arm_decode_coproc_dataproc* opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none = (converted >> 24) & 0x0F; + opcode->op1 = (converted >> 20) & 0x0F; + opcode->crn = (converted >> 16) & 0x0F; + opcode->crd = (converted >> 12) & 0x0F; + opcode->cpnum = (converted >> 8) & 0x0F; + opcode->op2 = (converted >> 5) & 0x07; + opcode->zero = (converted >> 4) & 0x01; + opcode->crm = converted & 0x0F; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_coproc_mov(struct s_arm_decode_coproc_mov* opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none = (converted >> 24) & 0x0F; + opcode->op1 = (converted >> 21) & 0x07; + opcode->toarm = (converted >> 20) & 0x01; + opcode->crn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->cpnum = (converted >> 8) & 0x0F; + opcode->op2 = (converted >> 5) & 0x07; + opcode->one = (converted >> 4) & 0x01; + opcode->crm = converted & 0x0F; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_coproc_mov2(struct s_arm_decode_coproc_mov2* opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none = (converted >> 21) & 0x07F; + opcode->toarm = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->rd = (converted >> 12) & 0x0F; + opcode->cpnum = (converted >> 8) & 0x0F; + opcode->op = (converted >> 4) & 0x0F; + opcode->crm = converted & 0x0F; + +#else + memcpy(opcode,buf,4); +#endif +} + +void arm_convert_coproc_ldst(struct s_arm_decode_coproc_ldst* opcode, u_char *buf) +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + int converted; + + memcpy(&converted,buf,4); + + opcode->cond = (converted >> 28) & 0x0F; + opcode->none = (converted >> 25) & 0x07; + opcode->p = (converted >> 24) & 0x01; + opcode->u = (converted >> 23) & 0x01; + opcode->n = (converted >> 22) & 0x01; + opcode->w = (converted >> 21) & 0x01; + opcode->l = (converted >> 20) & 0x01; + opcode->rn = (converted >> 16) & 0x0F; + opcode->crd = (converted >> 12) & 0x0F; + opcode->cpnum = (converted >> 8) & 0x0F; + opcode->offset = converted & 0x0FF; + +#else + memcpy(opcode,buf,4); +#endif +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/decode_arm.c eresi-0.0.20110516/libasm/src/arch/arm/decode_arm.c --- eresi-0.8a25/libasm/src/arch/arm/decode_arm.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/decode_arm.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,211 @@ +/** +* @file libasm/src/arch/arm/decode_arm.c +** @ingroup arm +*/ +#include "libasm.h" + +void arm_decode_condition(asm_instr *ins, u_char condition) +{ + if (condition < 0x0E) + { + MASSIGNTYPE(ins, ASM_TYPE_CONDCONTROL); + MASSIGNTYPE(ins, ASM_TYPE_READFLAG); + ins->flagsread = arm_cond_flagsread_table[condition]; + } +} + +/* Must be called after full decode of opcode structure and operands */ +void arm_decode_dataproc_flagswritten(asm_instr *ins, struct s_arm_decode_dataproc *opcode) +{ + u_char is_pc_dest; + int i; + + /* Verify if PC is a destination register */ + is_pc_dest = 0; + for (i = 0; i < ins->nb_op; i++) + { + if (ins->op[i].destination && ins->op[i].baser == ASM_ARM_REG_PC) + { + is_pc_dest = 1; + } + } + + if (opcode->s) + { + /* Update instruction type */ + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + + /* Determine which flags are written */ + if (is_pc_dest) + { + /* CPSR = SPSR, thus all flags are written */ + /* If any flag is added to e_arm_flags, please update this assignment */ + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V | ASM_ARM_FLAG_Q; + } + else + { + /* Fetch the table for the written flags */ + ins->flagswritten = arm_dataproc_flagswritten_table[opcode->op2]; + } + } +} + +void arm_decode_dataproc_shfop(asm_instr *ins, u_char *buf, u_int op_nr, + struct s_arm_decode_dataproc *opcode) +{ + + asm_operand *op; + + op = &ins->op[op_nr]; + + /* Decode operands */ + if (opcode->i) + { + u_int64_t temp; + + temp = opcode->immed << (32 - opcode->rotate_imm*2); + temp = temp | (temp >> 32); + op->imm = (u_int32_t) temp; + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + } + else + { + op->baser = opcode->rm; + op->shift_type = opcode->shift; + + if (opcode->reg_shift) + { + /* Scaled by register */ + op->indexr = opcode->rs; + op->imm = 0; + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REG_SCALED, ins); + } + else + { + /* Scaled by immediate */ + op->imm = opcode->shift_imm; + op->indexr = ASM_ARM_REG_NUM; + + if (opcode->shift_imm == 0 && opcode->shift == ASM_ARM_SHIFT_LSL) + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REGISTER, ins); + else + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REG_SCALED, ins); + } + } +} + +void arm_decode_ldst_offop(asm_instr *ins, u_char *buf, u_int op_nr, + struct s_arm_decode_ldst *opcode) +{ + asm_operand *op; + + op = &ins->op[op_nr]; + + op->baser = opcode->rn; + /* (Scaled) register offset */ + op->indexr = opcode->rm; + op->imm = opcode->shift_imm; + op->shift_type = opcode->shift; + + op->offset_added = opcode->u; + if (!opcode->p) + op->indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + else + { + if (opcode->w) + op->indexing = ASM_ARM_ADDRESSING_PREINDEXED; + else + op->indexing = ASM_ARM_ADDRESSING_OFFSET; + } + + if (!opcode->reg_offset) + /* Immediate offset */ + { + op->imm = opcode->imm_offset; + op->indexr = ASM_ARM_REG_NUM; + op->shift_type = ASM_ARM_SHIFT_NUM; + } + + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REG_OFFSET, ins); +} + +void arm_decode_ldst_misc_offop(asm_instr *ins, u_char *buf, u_int op_nr, + struct s_arm_decode_ldst_misc *opcode) +{ + asm_operand *op; + + op = &ins->op[op_nr]; + + op->baser = opcode->rn; + + op->offset_added = opcode->u; + if (!opcode->p) + op->indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + else + { + if (opcode->w) + op->indexing = ASM_ARM_ADDRESSING_PREINDEXED; + else + op->indexing = ASM_ARM_ADDRESSING_OFFSET; + } + + if (opcode->i) + /* Immediate offset */ + op->imm = (opcode->immedH << 4) | (opcode->immedL_rm); + else + op->indexr = opcode->immedL_rm; + + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REG_OFFSET, ins); +} + + +// XXX: this can become the handler for smlal, smull, umlal and umull */ +void arm_decode_multiply_long(asm_instr *ins, u_char *buf, + struct s_arm_decode_multiply *opcode) +{ + ins->op[0].baser = opcode->r2; /* This is RdLo */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode->r1; /* This is RdHi */ + ins->op[1].destination = 1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode->r4; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode->r3; /* This is Rm */ + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); +} + +void arm_decode_coproc_ldst_offop(asm_instr *ins, u_char *buf, u_int op_nr, + struct s_arm_decode_coproc_ldst *opcode) +{ + asm_operand *op; + + op = &ins->op[op_nr]; + + op->baser = opcode->rn; + + op->offset_added = opcode->u; + if (!opcode->p) + { + if (opcode->w) + op->indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + else + op->indexing = ASM_ARM_ADDRESSING_UNINDEXED; + } + else + { + if (opcode->w) + op->indexing = ASM_ARM_ADDRESSING_PREINDEXED; + else + op->indexing = ASM_ARM_ADDRESSING_OFFSET; + } + + op->imm = opcode->offset; + if (op->indexing != ASM_ARM_ADDRESSING_UNINDEXED) + op->imm *= 4; + + asm_arm_op_fetch(op, buf, ASM_ARM_OTYPE_REG_OFFSET, ins); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_adc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_adc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_adc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_adc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,50 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_adc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_adc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_READFLAG); + + ins->flagsread |= ASM_ARM_FLAG_C; + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_add.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_add.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_add.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_add.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,49 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_add.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_add(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); + +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_and.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_and.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_and.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_and.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_and.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_and(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_b.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_b.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_b.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_b.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,33 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_b.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_b(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch1 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch1(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->branch1_table[(opcode.l_h << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_BRANCH); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].imm = opcode.signed_imm; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_DISP, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bic.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bic.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bic.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bic.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_bic.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_bic(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_BITSET); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bkpt.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bkpt.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bkpt.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bkpt.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_bkpt.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_bkpt(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_bkpt opcode; + + LIBASM_PROFILE_FIN(); + + arm_convert_bkpt(&opcode, buf); + + ins->instr = ASM_ARM_BKPT; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_INT); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].imm = (opcode.immed1 << 4) | opcode.immed2; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bl.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bl.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bl.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bl.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,33 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_bl.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_bl(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch1 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch1(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->branch1_table[(opcode.l_h << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_CALLPROC); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].imm = opcode.signed_imm; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_DISP, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_blx1.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_blx1.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_blx1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_blx1.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,34 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_blx1.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_blx1(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch1 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch1(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->branch1_table[(opcode.l_h << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + /* Imperative call proc */ + MASSIGNTYPE(ins, (ASM_TYPE_CALLPROC | ASM_TYPE_ARCH)); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].imm = opcode.signed_imm; + asm_arm_op_fetch(&ins->op[0], buf, opcode.l_h ? ASM_ARM_OTYPE_DISP_HALF : ASM_ARM_OTYPE_DISP, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_blx2.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_blx2.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_blx2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_blx2.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,33 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_blx2.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_blx2(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch2 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch2(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->branch2_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, (ASM_TYPE_CALLPROC | ASM_TYPE_INDCONTROL | ASM_TYPE_ARCH)); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].baser = opcode.rm; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bx.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bx.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_bx.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_bx.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_bx.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_bx(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch2 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch2(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->branch2_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + if (opcode.rm == ASM_ARM_REG_R14) + /* This is a return */ + MASSIGNTYPE(ins, ASM_TYPE_RETPROC); + else + MASSIGNTYPE(ins, ASM_TYPE_BRANCH); + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL | ASM_TYPE_ARCH); /* Change to Thumb/ARM */ + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].baser = opcode.rm; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cdp.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cdp.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cdp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cdp.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,49 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_cdp.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_cdp(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_dataproc_table[opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 6; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].imm = opcode.op1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + ins->op[2].baser = opcode.crd; + ins->op[2].destination = 1; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + ins->op[3].baser = opcode.crn; + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + ins->op[4].baser = opcode.crm; + asm_arm_op_fetch(&ins->op[4], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + ins->op[5].imm = opcode.op2; + asm_arm_op_fetch(&ins->op[5], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_clz.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_clz.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_clz.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_clz.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_clz.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_clz(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->clz_table[opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_BITTEST); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.rm; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cmn.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cmn.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cmn.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cmn.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_cmn.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_cmn(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_COMPARISON); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cmp.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cmp.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_cmp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_cmp.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_cmp.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_cmp(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_COMPARISON); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_eor.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_eor.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_eor.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_eor.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_eor.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_eor(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_illegal.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_illegal.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_illegal.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_illegal.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,13 @@ +#include "libasm.h" + +int asm_arm_illegal(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + LIBASM_PROFILE_FIN(); + + ins->instr = ASM_ARM_BAD; + + MASSIGNTYPE(ins, ASM_TYPE_STOP); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,39 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_ldst(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_ldst_table[(opcode.l << 5) | (opcode.cond << 1) | opcode.n]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].baser = opcode.crd; + ins->op[1].destination = 1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + arm_decode_coproc_ldst_offop(ins, buf, 2, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm1.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm1.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm1.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,46 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldm.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldm1(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_mult opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_mult(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_mult_table[(opcode.l << 6) | (opcode.cond << 2) | (opcode.p << 1) | opcode.u]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD | ASM_TYPE_ARCH); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + if (opcode.w) + ins->op[0].indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].imm = opcode.reg_list; + ins->op[1].destination = 1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REG_LIST, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm2.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm2.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm2.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,46 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldm.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldm2(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_mult opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_mult(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_mult_table[(opcode.l << 6) | (opcode.cond << 2) | (opcode.p << 1) | opcode.u]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].imm = opcode.reg_list; + ins->op[1].destination = 1; + /* User mode registers are loaded */ + ins->op[1].regset = ASM_ARM_REGSET_USR; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REG_LIST, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm3.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm3.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldm3.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldm3.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,53 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldm.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldm3(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_mult opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_mult(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_mult_table[(opcode.l << 6) | (opcode.cond << 2) | (opcode.p << 1) | opcode.u]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD | ASM_TYPE_WRITEFLAG | ASM_TYPE_ARCH); + + /* If any flag is added to e_arm_flags, please update this assignment */ + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V | ASM_ARM_FLAG_Q; + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + if (opcode.w) + ins->op[0].indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].imm = opcode.reg_list; + ins->op[1].destination = 1; + /* A small workaround. Actually when PC is present in the list (the case of LDM(3) + CPSR receives current mode SPSR, and all general purpose registers are loaded + */ + ins->op[1].regset = ASM_ARM_REGSET_USR; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REG_LIST, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrb.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrb.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrb.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrb.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrb.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrb(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + /* Result is UNPREDICTABLE if this register is PC */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrbt.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrbt.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrbt.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrbt.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrbt.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrbt(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldr.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldr.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldr.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldr.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldr(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD | ASM_TYPE_ARCH); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrd.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrd.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrd.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrd.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrd(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + // TODO: if rd is odd, this is an UNDEFINED instruction + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrh.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrh.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrh.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrh.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrh.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrh(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrsb.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrsb.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrsb.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrsb.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrsb.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrsb(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrsh.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrsh.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrsh.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrsh.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrsh.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrsh(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrt.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrt.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_ldrt.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_ldrt.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_ldrt.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_ldrt(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond];; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mcr.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mcr.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mcr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mcr.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,54 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mcr.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mcr(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_mov opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_mov(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_mov_table[(opcode.toarm << 4 | opcode.cond)]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 5; + if (opcode.op2 != 0) + ins->nb_op = 6; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].imm = opcode.op1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + ins->op[2].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.crn; + ins->op[3].destination = 1; + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + ins->op[4].baser = opcode.crm; + asm_arm_op_fetch(&ins->op[4], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + if (ins->nb_op > 5) + { + ins->op[5].imm = opcode.op2; + asm_arm_op_fetch(&ins->op[5], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mcrr.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mcrr.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mcrr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mcrr.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,46 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mcrr.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mcrr(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_mov2 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_mov2(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_mov2_table[(opcode.toarm << 4 | opcode.cond)]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 5; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].imm = opcode.op; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + ins->op[2].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[4].baser = opcode.crm; + ins->op[4].destination = 1; + asm_arm_op_fetch(&ins->op[4], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mla.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mla.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mla.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mla.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,55 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mla.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mla(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 4; + + /* Decode operands */ + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.r2; /* This is Rn */ + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mov.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mov.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mov.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mov.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,58 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mov.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mov(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + /* Check if this MOV is a procedure return (MOV PC,LR) */ + if ((ins->op[1].content & ASM_ARM_OTYPE_REGISTER) + && ins->op[1].baser == ASM_ARM_REG_R14 + && ins->op[0].baser == ASM_ARM_REG_PC) + { + /* clear types assigned in the register operand handler */ + MUNASSIGNTYPE(ins, ASM_TYPE_BRANCH); + /* assign the real type */ + MASSIGNTYPE(ins, ASM_TYPE_RETPROC); + } + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + if (!(ins->op[1].content & ASM_ARM_OTYPE_IMMEDIATE)) + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,60 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mrc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mrc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_mov opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_mov(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_mov_table[(opcode.toarm << 4 | opcode.cond)]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 5; + if (opcode.op2 != 0) + ins->nb_op = 6; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].imm = opcode.op1; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + ins->op[2].baser = opcode.rd; + ins->op[2].destination = 1; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.crn; + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + ins->op[4].baser = opcode.crm; + asm_arm_op_fetch(&ins->op[4], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + if (ins->nb_op > 5) + { + ins->op[5].imm = opcode.op2; + asm_arm_op_fetch(&ins->op[5], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + } + + /* If Rd = PC, PC is not written, but the flags instead. */ + /* Remove the BRANCH flag assigned in the operand handler */ + MUNASSIGNTYPE(ins, ASM_TYPE_BRANCH); + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V; + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrrc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrrc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrrc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrrc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,54 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mrrc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mrrc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_mov2 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_mov2(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_mov2_table[(opcode.toarm << 4 | opcode.cond)]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 5; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].imm = opcode.op; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + ins->op[2].baser = opcode.rd; + ins->op[2].destination = 1; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.rn; + ins->op[3].destination = 1; + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[4].baser = opcode.crm; + asm_arm_op_fetch(&ins->op[4], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrs.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrs.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mrs.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mrs.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,37 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mrs.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mrs(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->movpsr_table[(opcode.topsr << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = (opcode.r ? ASM_ARM_REG_SPSR : ASM_ARM_REG_CPSR); + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_msr.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_msr.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_msr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_msr.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,37 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_msr.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_msr(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->movpsr_table[(opcode.topsr << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN | ASM_TYPE_ARCH); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = (opcode.r ? ASM_ARM_REG_SPSR : ASM_ARM_REG_CPSR); + ins->op[0].imm = opcode.field_mask; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mul.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mul.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mul.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mul.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,52 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mul.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mul(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mvn.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mvn.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_mvn.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_mvn.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,47 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_mvn.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_mvn(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ASSIGN); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + if (!(ins->op[1].content & ASM_ARM_OTYPE_IMMEDIATE)) + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_orr.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_orr.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_orr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_orr.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_orr.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_orr(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_pld.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_pld.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_pld.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_pld.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_pld.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_pld(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = ASM_ARM_PLD; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_NOP | ASM_TYPE_ARCH); + + ins->nb_op = 1; + + /* Decode operands */ + arm_decode_ldst_offop(ins, buf, 0, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qadd.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qadd.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qadd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qadd.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_qadd.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_qadd(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_arith_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.r2; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r1; /* This is Rn */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qdadd.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qdadd.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qdadd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qdadd.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,49 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_qdadd.c +n** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_qdadd(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_arith_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 3; + + /* Decode operands */ + + ins->op[0].baser = opcode.r2; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r1; /* This is Rn */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qdsub.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qdsub.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qdsub.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qdsub.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_qdsub.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_qdsub(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_arith_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.r2; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r1; /* This is Rn */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qsub.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qsub.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_qsub.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_qsub.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,49 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_qsub.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_qsub(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_arith_table[(opcode.op << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 3; + + /* Decode operands */ + + ins->op[0].baser = opcode.r2; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r1; /* This is Rn */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_rsb.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_rsb.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_rsb.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_rsb.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,48 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_rsb.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_rsb(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_rsc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_rsc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_rsc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_rsc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,50 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_rsc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_rsc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_READFLAG); + + ins->flagsread |= ASM_ARM_FLAG_C; + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_sbc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_sbc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_sbc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_sbc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,50 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_sbc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_sbc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_READFLAG); + + ins->flagsread |= ASM_ARM_FLAG_C; + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlal.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlal.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlal.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlal.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smlal.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smlal(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 4; + + /* Decode operands */ + arm_decode_multiply_long(ins, buf, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlalxy.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlalxy.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlalxy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlalxy.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,41 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smlalxy.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smlalxy(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_multiply_table[(opcode.op << 6) | (opcode.cond << 2) | (opcode.y << 1) | opcode.x]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 4; + + /* Decode operands */ + arm_decode_multiply_long(ins, buf, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); + +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlawy.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlawy.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlawy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlawy.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,54 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smlawy.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smlawy(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_multiply_table[(opcode.op << 6) | (opcode.cond << 2) | (opcode.y << 1) | opcode.x]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 4; + + /* Decode operands */ + // TODO: create a function for smlawy|smlaxy (mla) + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.r2; /* This is Rn */ + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); + +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlaxy.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlaxy.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smlaxy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smlaxy.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,52 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smlaxy.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smlaxy(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_multiply_table[(opcode.op << 6) | (opcode.cond << 2) | (opcode.y << 1) | opcode.x]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG); + + ins->flagswritten = ASM_ARM_FLAG_Q; + + ins->nb_op = 4; + + /* Decode operands */ + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[3].baser = opcode.r2; /* This is Rn */ + asm_arm_op_fetch(&ins->op[3], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smull.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smull.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smull.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smull.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smull.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smull(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 4; + + /* Decode operands */ + arm_decode_multiply_long(ins, buf, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smulwy.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smulwy.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smulwy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smulwy.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,47 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smulwy.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smulwy(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_multiply_table[(opcode.op << 6) | (opcode.cond << 2) | (opcode.y << 1) | opcode.x]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smulxy.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smulxy.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_smulxy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_smulxy.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,47 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_smulxy.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_smulxy(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dsp_multiply_table[(opcode.op << 6) | (opcode.cond << 2) | (opcode.y << 1) | opcode.x]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.r1; /* This is Rd */ + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.r4; /* This is Rm */ + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[2].baser = opcode.r3; /* This is Rs */ + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REGISTER, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stc.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stc.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stc.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_stc.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_stc(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_coproc_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_coproc_ldst(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->coproc_ldst_table[(opcode.l << 5) | (opcode.cond << 1) | opcode.n]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].imm = opcode.cpnum; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_COPROC, ins); + + ins->op[1].baser = opcode.crd; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_COPROC_REGISTER, ins); + + arm_decode_coproc_ldst_offop(ins, buf, 2, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stm1.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stm1.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stm1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stm1.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,45 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_stm.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_stm1(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_mult opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_mult(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_mult_table[(opcode.l << 6) | (opcode.cond << 2) | (opcode.p << 1) | opcode.u]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + if (opcode.w) + ins->op[0].indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].imm = opcode.reg_list; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REG_LIST, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stm2.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stm2.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_stm2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_stm2.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,46 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_stm.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_stm2(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_mult opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_mult(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_mult_table[(opcode.l << 6) | (opcode.cond << 2) | (opcode.p << 1) | opcode.u]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + if (opcode.w) + ins->op[0].indexing = ASM_ARM_ADDRESSING_POSTINDEXED; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].imm = opcode.reg_list; + ins->op[1].regset = ASM_ARM_REGSET_USR; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REG_LIST, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strb.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strb.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strb.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strb.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_strb.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_strb(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strbt.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strbt.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strbt.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strbt.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_strbt.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_strbt(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_str.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_str.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_str.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_str.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_str.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_str(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strd.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strd.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strd.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,43 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_strd.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_strd(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + // TODO: if rd is odd, this is an UNDEFINED instruction + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strh.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strh.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strh.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strh.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_strh.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_strh(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst_misc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst_misc(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_misc_table[(opcode.l << 6) | (opcode.s << 5) | opcode.h << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_misc_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strt.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strt.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_strt.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_strt.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_strt.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_strt(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_ldst(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->ldst_table[(opcode.l << 6) | ((!opcode.p && opcode.w) << 5) | opcode.b << 4 | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_STORE); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_ldst_offop(ins, buf, 1, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_sub.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_sub.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_sub.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_sub.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,47 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_sub.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_sub(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + ins->op[1].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 2, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swi.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swi.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swi.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swi.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,33 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_swi.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_swi(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_branch1 opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_branch1(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->swi_table[opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_INT); + + ins->nb_op = 1; + + /* Decode operands */ + ins->op[0].imm = opcode.signed_imm; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_IMMEDIATE, ins); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swpb.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swpb.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swpb.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swpb.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,54 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_swpb.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_swpb(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + // TODO: verify the need of two different handlers for swp/swpb + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_swap(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->swap_table[(opcode.b << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD | ASM_TYPE_STORE); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.rm; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + /* Use register offset type to print with [] surrounding + * the register name. + */ + ins->op[2].baser = opcode.rn; + ins->op[2].indexing = ASM_ARM_ADDRESSING_OFFSET; + ins->op[2].imm = 0; + ins->op[2].offset_added = 1; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REG_OFFSET, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swp.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swp.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_swp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_swp.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,53 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_swp.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_swp(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_ldst opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_swap(&opcode,buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->swap_table[(opcode.b << 4) | opcode.cond]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_LOAD | ASM_TYPE_STORE); + + ins->nb_op = 3; + + /* Decode operands */ + ins->op[0].baser = opcode.rd; + ins->op[0].destination = 1; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + ins->op[1].baser = opcode.rm; + asm_arm_op_fetch(&ins->op[1], buf, ASM_ARM_OTYPE_REGISTER, ins); + + /* Use register offset type to print with [] surrounding + * the register name. + */ + ins->op[2].baser = opcode.rn; + ins->op[2].indexing = ASM_ARM_ADDRESSING_OFFSET; + ins->op[2].imm = 0; + ins->op[2].offset_added = 1; + asm_arm_op_fetch(&ins->op[2], buf, ASM_ARM_OTYPE_REG_OFFSET, ins); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_teq.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_teq.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_teq.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_teq.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_teq.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_teq(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_COMPARISON); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_tst.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_tst.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_tst.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_tst.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_tst.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_tst(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_dataproc opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_dataproc(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->dataproc_table[(opcode.op2 << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_COMPARISON | ASM_TYPE_BITTEST); + + ins->nb_op = 2; + + /* Decode operands */ + ins->op[0].baser = opcode.rn; + asm_arm_op_fetch(&ins->op[0], buf, ASM_ARM_OTYPE_REGISTER, ins); + + arm_decode_dataproc_shfop(ins, buf, 1, &opcode); + + /* Decode flags related behaviour */ + arm_decode_dataproc_flagswritten(ins, &opcode); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_umlal.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_umlal.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_umlal.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_umlal.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,45 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_umlal.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_umlal(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 4; + + /* Decode operands */ + arm_decode_multiply_long(ins, buf, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); + +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_umull.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_umull.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_umull.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_umull.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** +* @file libasm/src/arch/arm/handlers/asm_arm_umull.c +** @ingroup ARM_instrs +*/ +#include "libasm.h" + +int asm_arm_umull(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + struct s_arm_decode_multiply opcode; + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + inter = proc->internals; + arm_convert_multiply(&opcode, buf); + + arm_decode_condition(ins, opcode.cond); + + ins->instr = inter->multiply_table[(opcode.op << 5) | (opcode.cond << 1) | opcode.s]; + + ins->name = ins->proc->instr_table[ins->instr]; + + MASSIGNTYPE(ins, ASM_TYPE_ARITH); + if (opcode.s) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z; + } + + ins->nb_op = 4; + + /* Decode operands */ + arm_decode_multiply_long(ins, buf, &opcode); + + if (MISTYPE(ins, ASM_TYPE_BRANCH) + || MISTYPE(ins, ASM_TYPE_CALLPROC) + || MISTYPE(ins, ASM_TYPE_RETPROC)) + { + MASSIGNTYPE(ins, ASM_TYPE_INDCONTROL); + } + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_undef.c eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_undef.c --- eresi-0.8a25/libasm/src/arch/arm/handlers/asm_arm_undef.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/handlers/asm_arm_undef.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,12 @@ +#include "libasm.h" + +int asm_arm_undef(asm_instr * ins, u_char * buf, u_int len, + asm_processor * proc) +{ + LIBASM_PROFILE_FIN(); + + ins->instr = ASM_ARM_; + MASSIGNTYPE(ins, ASM_TYPE_INT); + + LIBASM_PROFILE_FOUT(4); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/init_arm.c eresi-0.0.20110516/libasm/src/arch/arm/init_arm.c --- eresi-0.8a25/libasm/src/arch/arm/init_arm.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/init_arm.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,427 @@ +/** + * @file libasm/src/arch/arm/init_arm.c + * @ingroup arm + */ +// TODO: file comments + +#include + +/* TODO: this can become a vector of functions indexed by the first dimension */ +/* Helper functions prototypes */ +static void fill_dim_vector_type1(int inst, u_int *dim_vec); +static void fill_dim_vector_type2(int inst, u_int *dim_vec); +static void fill_dim_vector_type3(int inst, u_int *dim_vec); +static void fill_dim_vector_type4(int inst, u_int *dim_vec); + +static void clear_operands(asm_instr *ins); + +/* TODO: function comments */ + +/** + * Fetching handler of the arm architecture. + * @param ins + * @param buf + * @param len + * @param proc + */ +int asm_fetch_arm(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) +{ + vector_t *vec; + u_int dim[3]; + int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *); + + int converted; + + LIBASM_PROFILE_FIN(); + +#if __BYTE_ORDER == __LITTLE_ENDIAN + + memcpy(&converted, buf, 4); + +#else + u_char *ptr; + int i; + + ptr = (u_char*) &converted; + + for (i = 0; i < 4; i++) + *(ptr + i) = *(buf + 3 - i); + +#endif + + ins->proc = proc; + ins->len = 4; + ins->ptr_instr = buf; + ins->nb_op = 0; + ins->type = ASM_TYPE_NONE; + ins->flagsread = ASM_ARM_FLAG_NONE; + ins->flagswritten = ASM_ARM_FLAG_NONE; + clear_operands(ins); + + vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_ARM); + /* Undefined instruction is at (0,0,0) */ +// XXX: define if we need ASM_ARM_ and ASM_ARM_BAD (ASM_ARM_ is being used for undefined instruction) +// The undefined instruction in the ARM arch generates an exception. + dim[0] = (converted >> 26) & 0x00000003; + dim[1] = 0; + dim[2] = 0; + + switch (dim[0]) + { + case 0x00: + /* data processing, swap, multiply, status register manipulation */ + /* and extra load/store */ + fill_dim_vector_type1(converted,dim); + break; + case 0x01: + /* load/store */ + fill_dim_vector_type2(converted,dim); + break; + case 0x02: + /* load/store multiple and branch */ + fill_dim_vector_type3(converted,dim); + break; + case 0x03: + /* coprocessor and exception */ + fill_dim_vector_type4(converted,dim); + break; + default: + /* you shouldn't be here! */ + break; + } + + fetch = aspect_vectors_select(vec, dim); + + LIBASM_PROFILE_FOUT(fetch(ins, (u_char*) &converted, len, proc)); +} + +/** + * Initialize the arm processor. + * + */ + +int asm_init_arm(asm_processor *proc) +{ + struct s_asm_proc_arm *inter; + + LIBASM_PROFILE_FIN(); + + proc->instr_table = arm_instr_list; + proc->resolve_immediate = asm_resolve_arm; + proc->resolve_data = 0; + proc->fetch = asm_fetch_arm; + proc->display_handle = asm_arm_display_instr; + proc->type = ASM_PROC_ARM; + + proc->internals = inter = malloc(sizeof (struct s_asm_proc_arm)); + + inter->dataproc_table = arm_dataproc_table; + inter->movpsr_table = arm_movpsr_table; + inter->clz_table = arm_clz_table; + inter->swi_table = arm_swi_table; + inter->ldst_table = arm_ldst_table; + inter->ldst_misc_table = arm_ldst_misc_table; + inter->ldst_mult_table = arm_ldst_mult_table; + inter->swap_table = arm_swap_table; + inter->multiply_table = arm_multiply_table; + inter->dsp_multiply_table = arm_dsp_multiply_table; + inter->dsp_arith_table = arm_dsp_arith_table; + inter->branch1_table = arm_branch1_table; + inter->branch2_table = arm_branch2_table; + inter->coproc_dataproc_table = arm_coproc_dataproc_table; + inter->coproc_mov_table = arm_coproc_mov_table; + inter->coproc_mov2_table = arm_coproc_mov2_table; + inter->coproc_ldst_table = arm_coproc_ldst_table; + + asm_arch_register(proc, 0); + + LIBASM_PROFILE_FOUT(1); +} + +eresi_Addr asm_dest_resolve_arm(eresi_Addr addr, u_int disp, u_char half) +{ + int off; + + /* Addr = PC + (SignExtend(disp) << 2) */ + off = (int) disp; + if (off & 0x0800000) + /* Sign extend */ + off |= 0xFF000000; + off <<= 2; + if (half) + off |= 0x02; + addr += off + 8; /* PC points to current instruction + 8 */ + + return (addr); +} + +// TODO: function doc +/* Helper functions */ +void fill_dim_vector_type1(int inst, u_int *dim_vec) +{ + int sec_nibble, six_nibble, sev_nibble, eig_nibble; + + sec_nibble = MGETNIBBLE(inst,1); + six_nibble = MGETNIBBLE(inst,5); + sev_nibble = MGETNIBBLE(inst,6); + eig_nibble = MGETNIBBLE(inst,7); + + if (eig_nibble == 0x0F + || (sev_nibble == 0x03 && (six_nibble & 0x0B) == 0x00)) + { + /* Undefined */ + /* UNPREDICTABLE prior to ARMv5 if eig_nibble == 0x0F */ + /* UNPREDICTABLE prior to ARMv4 otherwise */ + dim_vec[1] = 0x00; + dim_vec[2] = 0x00; + } + else if (sev_nibble == 0x03 && (six_nibble & 0x0B) == 0x02) + { + /* MSR(1) */ + dim_vec[1] = 0x00; + dim_vec[2] = 0x01; + } + else if ((sev_nibble & 0x0E) == 0x00 + && (sec_nibble & 0x09) == 0x09) + { + /* multiply, swap, extra load/store */ + if (sec_nibble == 0x09) + { + if (sev_nibble == 0x00) + { + /* multiply: 6 instructions */ + dim_vec[1] = 0x01; + dim_vec[2] = six_nibble >> 1; + /* if dim_vec[2] > 1, UNPREDICTABLE prior ARMv4 */ + } + else + { + /* swap: 2 instructions */ + dim_vec[1] = 0x02; + dim_vec[2] = six_nibble >> 2; + // TODO: what if dim_vec[2] > 1? + } + } + else + { + /* extra load/store: 6 instructions */ + /* UNPREDICTABLE prior to ARMv4 */ + /* LDRD/STRD present in E variant (>=ARMv5) excluding TExP */ + dim_vec[1] = 0x03; + dim_vec[2] = (MGETBIT(six_nibble,0) << 2) | ((sec_nibble >> 1) & 0x03); + } + } + else if (sev_nibble == 0x01 + && (six_nibble & 0x09) == 0x00 + && (sec_nibble & 0x09) != 0x09) + { + /* miscellaneous */ + if (MGETBIT(sec_nibble,3)) + { + /* DSP multiply: 5 instructions */ + /* Present in E variant (>= ARMv5) */ + dim_vec[1] = 0x04; + dim_vec[2] = (six_nibble >> 1); + if (dim_vec[2] == 0x01) + dim_vec[2] |= (MGETBIT(sec_nibble,1) << 2); + } + else + { + if ((sec_nibble >> 1) == 0x02) + { + /* DSP add/sub: 4 instructions */ + /* Present in E variant (>= ARMv5) */ + dim_vec[1] = 0x05; + dim_vec[2] = six_nibble >> 1; + } + else + { + /* other: 6 instructions */ + dim_vec[1] = 0x06; + dim_vec[2] = six_nibble; + if (sec_nibble == 0x00) + dim_vec[2] &= 0x0B; + dim_vec[2] += sec_nibble; + } + } + } + else + { + /* data processing: 16 instructions */ + dim_vec[1] = 0x07; + dim_vec[2] = MGETNIBBLE((sev_nibble << 3) | (six_nibble >> 1),0); + } +} + +void fill_dim_vector_type2(int inst, u_int *dim_vec) +{ + int eig_nibble, sev_nibble, sec_nibble; + + eig_nibble = MGETNIBBLE(inst,7); + sev_nibble = MGETNIBBLE(inst,6); + sec_nibble = MGETNIBBLE(inst,1); + + if (eig_nibble == 0x0F) + { + /* UNPREDICTABLE prior to ARMv5 */ + if ((MGETNIBBLE(inst,6) & 0x0D) == 0x05 + && (MGETNIBBLE(inst,5) & 0x07) == 0x05 + && MGETNIBBLE(inst,3) == 0x0F) + { + /* PLD */ + dim_vec[1] = 0x02; + dim_vec[2] = 0x00; + } + else + { + /* Undefined */ + dim_vec[0] = 0x00; + dim_vec[1] = 0x00; + dim_vec[2] = 0x00; + } + } + else + { + if ((sev_nibble & 0x0E) == 0x06 + && (sec_nibble & 0x01) == 0x01) + { + /* Undefined (all versions) */ + dim_vec[0] = 0x00; + dim_vec[1] = 0x00; + dim_vec[2] = 0x00; + } + else + { + /* Load/store */ + /* divides into load and store: 8 instructions */ + dim_vec[1] = MGETBIT(inst,20); + + dim_vec[2] = MGETBIT(inst,22) << 1; + if (!MGETBIT(inst,24) && MGETBIT(inst,21)) + { + dim_vec[2] |= 0x1; + } + } + } +} + +void fill_dim_vector_type3(int inst, u_int *dim_vec) +{ + int eig_nibble, sev_nibble; + + eig_nibble = MGETNIBBLE(inst,7); + sev_nibble = MGETNIBBLE(inst,6); + + if (eig_nibble == 0x0F + && (sev_nibble & 0x0E) == 0x08) + { + /* Undefined */ + /* UNPREDICTABLE prior to ARMv5 */ + dim_vec[0] = 0; + dim_vec[1] = 0; + dim_vec[2] = 0; + } + else + { + /* we could have just the second dimension, but i'll use the third to */ + /* divide into store/load multiple and branch instructions */ + dim_vec[1] = MGETBIT(inst,25); + + if (!dim_vec[1]) + { + /* load/store multiple: 5 instructions */ + dim_vec[2] = MGETBIT(inst,22) << 2 | MGETBIT(inst,20) << 1; + if (!dim_vec[1] && dim_vec[2] == 0x6) + dim_vec[2] |= MGETBIT(inst,15); + } + else + { + /* branch: 3 instructions */ + if (MGETNIBBLE(inst,7) == 0x0F) + /* BLX */ + dim_vec[2] = 0x02; + else + /* B, BL */ + dim_vec[2] = MGETBIT(inst,24); + } + } +} + +void fill_dim_vector_type4(int inst, u_int *dim_vec) +{ + int eig_nibble, sev_nibble, six_nibble; + + eig_nibble = MGETNIBBLE(inst,7); + sev_nibble = MGETNIBBLE(inst,6); + six_nibble = MGETNIBBLE(inst,5); + + if (eig_nibble == 0x0F && sev_nibble == 0x0F) + { + /* Undefined */ + /* UNPREDICTABLE prior to ARMv5 */ + dim_vec[0] = 0; + dim_vec[1] = 0; + dim_vec[2] = 0; + } + else if (sev_nibble < 0x0E) + { + if (sev_nibble == 0x0C + && (six_nibble & 0x0E) == 0x04) + { + /* MRRC & MCRR */ + dim_vec[1] = 0x00; + dim_vec[2] = MGETBIT(six_nibble,0); + } + else + { + /* load/store coprocessor: 4 instructions */ + dim_vec[1] = 0x01; + dim_vec[2] = MGETBIT(six_nibble,0); + if (eig_nibble == 0x0F) + dim_vec[2] += 0x02; + } + } + else if (sev_nibble == 0x0E) + { + if (!MGETBIT(inst,4)) + { + /* CDP, CDP2 */ + dim_vec[1] = 0x02; + dim_vec[2] = 0x00; + if (eig_nibble == 0x0F) + dim_vec[2]++; + } + else + { + /* MCR, MCR2, MRC, MRC2 */ + dim_vec[1] = 0x03; + dim_vec[2] = MGETBIT(sev_nibble,0); + if (eig_nibble == 0x0F) + dim_vec[2] += 0x02; + } + } + else + { + /* eig_nibble != 0x0F && sev_nibble == 0x0F */ + /* SWI */ + dim_vec[1] = 0x04; + dim_vec[2] = 0x00; + } +} + +void clear_operands(asm_instr *ins) +{ + u_int i; + + memset(ins->op, 0, sizeof(ins->op)); + + for (i = 0; i < 4; i++) + { + ins->op[i].destination = 0; + ins->op[i].baser = ASM_ARM_REG_NUM; + ins->op[i].indexr = ASM_ARM_REG_NUM; + ins->op[i].shift_type = ASM_ARM_SHIFT_NUM; + ins->op[i].regset = ASM_ARM_REGSET_NUM; + ins->op[i].indexing = ASM_ARM_ADDRESSING_NUM; + } +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,41 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c +** @ingroup ARM_operands +*/ +#include + + +/** + * Main function, dispatch processing to handler. + * @param op Pointer to operand to fill + * @param opcode Pointer to operand data. + * @param otype Content of operand to fetch : ASM_OTYPE_* + * @param proc Pointer to processor structure. + * @return Operand length or -1 on error (should currently never occur) + */ +int asm_arm_op_fetch(asm_operand *op, u_char *opcode, int otype, + asm_instr *ins) +{ + vector_t *vec; + u_int dim[1]; + int to_ret; + int (*fetch)(asm_operand *, u_char *, int, asm_instr *); + + LIBASM_PROFILE_FIN(); + + vec = aspect_vector_get(LIBASM_VECTOR_OPERAND_ARM); + dim[0] = otype; + + fetch = aspect_vectors_select(vec, dim); + to_ret = fetch(op, opcode, otype, ins); + + if (to_ret == -1) + { + printf("%s:%i Unsupported operand content : %i\n", __FILE__, __LINE__, + otype); + } + + op->name = asm_arm_get_op_name(op); + + LIBASM_PROFILE_FOUT(to_ret); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,16 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_coprocessor(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_COPROC; + operand->type = ASM_OPTYPE_IMM; + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,16 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_coprocessor_register(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_COPROC_REGISTER; + operand->type = ASM_OPTYPE_REG; + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,16 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_disp(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_DISP; + operand->type = ASM_OPTYPE_IMM; + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,16 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_disp_half(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_DISP_HALF; + operand->type = ASM_OPTYPE_IMM; + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,16 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_immediate(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_IMMEDIATE; + operand->type = ASM_OPTYPE_IMM; + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_register(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_REGISTER; + operand->type = ASM_OPTYPE_REG; + + if (operand->destination + || operand->indexing == ASM_ARM_ADDRESSING_POSTINDEXED + || operand->indexing == ASM_ARM_ADDRESSING_PREINDEXED) + { + /* PC shouldn't be used as base address with writeback */ + /* If by any chance someone uses it this way, we will flag the instruction as a branch */ + switch (operand->baser) + { + case ASM_ARM_REG_R13: + /* R13 = SP */ + MASSIGNTYPE(ins, ASM_TYPE_TOUCHSP); + break; + case ASM_ARM_REG_PC: + MASSIGNTYPE(ins, ASM_TYPE_BRANCH); + break; + case ASM_ARM_REG_CPSR: + if (operand->imm & 0x08) + { + MASSIGNTYPE(ins, ASM_TYPE_WRITEFLAG); + /* If any flag is added to e_arm_flags, please update this assignment */ + ins->flagswritten = ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V | ASM_ARM_FLAG_Q; + } + break; + } + } + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,41 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c +** @ingroup ARM_operands +*/ +#include "libasm.h" + +int asm_arm_op_fetch_reg_list(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_REG_LIST; + operand->type = ASM_OPTYPE_REG; + + if (operand->destination) + { + if (operand->imm & (1 << 13)) + { + /* R13 = SP */ + MASSIGNTYPE(ins, ASM_TYPE_TOUCHSP); + } + if (operand->imm & (1 << 15)) + { + /* PC */ + + if (ins->instr == ASM_ARM_LDMIA + && ins->op[0].baser == ASM_ARM_REG_R13 + && ins->op[0].indexing == ASM_ARM_ADDRESSING_POSTINDEXED) + { + /* LDMIA SP!, {Reg list} (POP) is usually used as return of a function */ + MASSIGNTYPE(ins, ASM_TYPE_RETPROC); + } + else + { + MASSIGNTYPE(ins, ASM_TYPE_BRANCH); + } + } + } + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,57 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_reg_offset(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_REG_OFFSET; + operand->type = ASM_OPTYPE_REG; + + if (operand->indexr != ASM_ARM_REG_NUM) + { + if (operand->imm == 0) + { + switch (operand->shift_type) + { + case ASM_ARM_SHIFT_LSL: + /* Register offset */ + operand->shift_type = ASM_ARM_SHIFT_NUM; + break; + case ASM_ARM_SHIFT_ROR: + operand->shift_type = ASM_ARM_SHIFT_RRX; + break; + case ASM_ARM_SHIFT_LSR: + case ASM_ARM_SHIFT_ASR: + operand->imm = 32; + break; + default: + /* TODO: Error! */ + break; + } + } + } + + if (operand->indexing == ASM_ARM_ADDRESSING_PREINDEXED + || operand->indexing == ASM_ARM_ADDRESSING_POSTINDEXED) + { + /* PC shouldn't be used as base address with writeback */ + /* If by any chance someone uses it this way, we will flag the instruction as a branch */ + switch (operand->baser) + { + case ASM_ARM_REG_R13: + /* R13 = SP */ + MASSIGNTYPE(ins, ASM_TYPE_TOUCHSP); + break; + case ASM_ARM_REG_PC: + MASSIGNTYPE(ins, ASM_TYPE_BRANCH); + break; + } + } + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c +** @ingroup ARM_operands +*/ +#include + +int asm_arm_op_fetch_reg_scaled(asm_operand *operand, u_char *opcode, + int otype, asm_instr *ins) +{ + LIBASM_PROFILE_FIN(); + + operand->content = ASM_ARM_OTYPE_REG_SCALED; + operand->type = ASM_OPTYPE_REG; + + if (operand->indexr == ASM_ARM_REG_NUM) + { + if (operand->imm == 0) + { + if (operand->shift_type == ASM_ARM_SHIFT_ROR) + operand->shift_type = ASM_ARM_SHIFT_RRX; + else + operand->imm = 32; + } + } + + LIBASM_PROFILE_FOUT(0); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c --- eresi-0.8a25/libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,44 @@ +/** + * @defgroup ARM_operands ARM operands API. + * @ingroup arm + */ +/** +* @file libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c +** @ingroup ARM_operands +*/ +#include + +/* +#define ASM_POOL_SIZE 100 +#define ASM_OP_NAME_LEN 64 +*/ +/* FIFO sort-of memory manager */ +/* +char *asm_name_pool_alloc() +{ + static char *asm_name_pool[ASM_POOL_SIZE] = {}; + static int index = 0; + + char *ret; + + if (asm_name_pool[index] != NULL) + free(asm_name_pool[index]); + + ret = asm_name_pool[index] = (char *) malloc(ASM_OP_NAME_LEN); + + index = (index+1)%ASM_POOL_SIZE; + + return ret; +} +*/ +char *asm_arm_get_op_name(asm_operand *op) +{ + switch (op->content) + { + case ASM_ARM_OTYPE_REGISTER: + return asm_arm_get_register(op->baser); + // TODO: + default: + return NULL; + } +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/output_arm.c eresi-0.0.20110516/libasm/src/arch/arm/output_arm.c --- eresi-0.8a25/libasm/src/arch/arm/output_arm.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/output_arm.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,265 @@ +/** +* @file libasm/src/arch/arm/output_arm.c +** @ingroup arm +*/ +#include + +void asm_resolve_arm(void *d, eresi_Addr val, char *buf, u_int len) +{ + uint32_t addr; + + addr = (uint32_t) val; + snprintf(buf, len, "0x%X", addr); +} + +char *asm_arm_get_register(int reg) +{ + switch (reg) + { + case ASM_ARM_REG_R0: return "r0"; + case ASM_ARM_REG_R1: return "r1"; + case ASM_ARM_REG_R2: return "r2"; + case ASM_ARM_REG_R3: return "r3"; + case ASM_ARM_REG_R4: return "r4"; + case ASM_ARM_REG_R5: return "r5"; + case ASM_ARM_REG_R6: return "r6"; + case ASM_ARM_REG_R7: return "r7"; + case ASM_ARM_REG_R8: return "r8"; + case ASM_ARM_REG_R9: return "r9"; + case ASM_ARM_REG_R10: return "r10"; + case ASM_ARM_REG_R11: return "r11"; + case ASM_ARM_REG_R12: return "r12"; + case ASM_ARM_REG_R13: return "sp"; + case ASM_ARM_REG_R14: return "lr"; + case ASM_ARM_REG_PC: return "pc"; + case ASM_ARM_REG_CPSR: return "cpsr"; + case ASM_ARM_REG_SPSR: return "spsr"; + default: return "bad"; + } +} + +char *asm_arm_get_psr_fields(u_int field_mask) +{ + static char buf[6]; + + if (!(field_mask & 0x0F)) + return ""; + else + { + sprintf(buf, "_"); + if (field_mask & 0x08) + strcat(buf, "f"); + if (field_mask & 0x04) + strcat(buf, "s"); + if (field_mask & 0x02) + strcat(buf, "x"); + if (field_mask & 0x01) + strcat(buf, "c"); + return buf; + } +} + +char *asm_arm_get_shift_type(u_int shift_type) +{ + switch (shift_type) + { + case ASM_ARM_SHIFT_LSL: return "lsl"; + case ASM_ARM_SHIFT_LSR: return "lsr"; + case ASM_ARM_SHIFT_ASR: return "asr"; + case ASM_ARM_SHIFT_ROR: return "ror"; + case ASM_ARM_SHIFT_RRX: return "rrx"; + default: return "bad"; + } +} + +char *asm_arm_get_coprocessor(int coproc) +{ + switch (coproc) + { + case ASM_ARM_COPROC_P0: return "p0"; + case ASM_ARM_COPROC_P1: return "p1"; + case ASM_ARM_COPROC_P2: return "p2"; + case ASM_ARM_COPROC_P3: return "p3"; + case ASM_ARM_COPROC_P4: return "p4"; + case ASM_ARM_COPROC_P5: return "p5"; + case ASM_ARM_COPROC_P6: return "p6"; + case ASM_ARM_COPROC_P7: return "p7"; + case ASM_ARM_COPROC_P8: return "p8"; + case ASM_ARM_COPROC_P9: return "p9"; + case ASM_ARM_COPROC_P10: return "p10"; + case ASM_ARM_COPROC_P11: return "p11"; + case ASM_ARM_COPROC_P12: return "p12"; + case ASM_ARM_COPROC_P13: return "p13"; + case ASM_ARM_COPROC_P14: return "p14"; + case ASM_ARM_COPROC_P15: return "p15"; + default: return "bad"; + } +} + +char *asm_arm_get_coprocessor_register(int reg) +{ + switch (reg) + { + case ASM_ARM_COPROC_REG_CR0: return "cr0"; + case ASM_ARM_COPROC_REG_CR1: return "cr1"; + case ASM_ARM_COPROC_REG_CR2: return "cr2"; + case ASM_ARM_COPROC_REG_CR3: return "cr3"; + case ASM_ARM_COPROC_REG_CR4: return "cr4"; + case ASM_ARM_COPROC_REG_CR5: return "cr5"; + case ASM_ARM_COPROC_REG_CR6: return "cr6"; + case ASM_ARM_COPROC_REG_CR7: return "cr7"; + case ASM_ARM_COPROC_REG_CR8: return "cr8"; + case ASM_ARM_COPROC_REG_CR9: return "cr9"; + case ASM_ARM_COPROC_REG_CR10: return "cr10"; + case ASM_ARM_COPROC_REG_CR11: return "cr11"; + case ASM_ARM_COPROC_REG_CR12: return "cr12"; + case ASM_ARM_COPROC_REG_CR13: return "cr13"; + case ASM_ARM_COPROC_REG_CR14: return "cr14"; + case ASM_ARM_COPROC_REG_CR15: return "cr15"; + default: return "bad"; + } +} + +/** + * Dump a ARM operand to a buffer. + * @param ins Pointer to instruction structure. + * @param num Number of the operand to dump + * @param addr Address of the instruction + * @param buf Buffer to store operand ascii representation. + */ + +void asm_arm_dump_operand(asm_instr *ins, int num, + eresi_Addr addr, char *buf, u_int len) +{ + asm_operand *op; + eresi_Addr address; + u_int i, temp; + u_char first; + + if (num > ins->nb_op) + return; + + op = &ins->op[num-1]; + + switch (op->content) + { + case ASM_ARM_OTYPE_REGISTER: + sprintf(buf, "%s", asm_arm_get_register(op->baser)); + if (op->baser == ASM_ARM_REG_CPSR || op->baser == ASM_ARM_REG_SPSR) + strcat(buf, asm_arm_get_psr_fields(op->imm)); + if (op->indexing == ASM_ARM_ADDRESSING_PREINDEXED + || op->indexing == ASM_ARM_ADDRESSING_POSTINDEXED) + strcat(buf, "!"); + break; + case ASM_ARM_OTYPE_IMMEDIATE: + sprintf(buf, "#%i", op->imm); + break; + case ASM_ARM_OTYPE_REG_SCALED: + sprintf(buf, "%s, %s", + asm_arm_get_register(op->baser), + asm_arm_get_shift_type(op->shift_type)); + if (op->indexr != ASM_ARM_REG_NUM) + /* Scaled by register */ + sprintf(buf + strlen(buf), " %s", + asm_arm_get_register(op->indexr)); + else if (op->shift_type != ASM_ARM_SHIFT_RRX) + /* Scaled by immediate */ + sprintf(buf + strlen(buf), " #%i", op->imm); + break; + case ASM_ARM_OTYPE_REG_OFFSET: + sprintf(buf, "[%s", asm_arm_get_register(op->baser)); + + if (op->indexing == ASM_ARM_ADDRESSING_POSTINDEXED + || op->indexing == ASM_ARM_ADDRESSING_UNINDEXED) + strcat(buf, "]"); + + if (op->indexr == ASM_ARM_REG_NUM) + { + /* Immediate offset */ + if (op->imm != 0) + sprintf(buf + strlen(buf), ", #%s%i", + (op->offset_added ? "" : "-"), + op->imm); + } + else + { + sprintf(buf + strlen(buf), ", %s%s", + (op->offset_added ? "" : "-"), + asm_arm_get_register(op->indexr)); + if (op->shift_type != ASM_ARM_SHIFT_NUM) + /* Scaled register offset */ + { + sprintf(buf + strlen(buf), ", %s", + asm_arm_get_shift_type(op->shift_type)); + if (op->shift_type != ASM_ARM_SHIFT_RRX) + sprintf(buf + strlen(buf), " #%i", + op->imm); + } + } + + if (op->indexing == ASM_ARM_ADDRESSING_PREINDEXED + || op->indexing == ASM_ARM_ADDRESSING_OFFSET) + strcat(buf, "]"); + + if (op->indexing == ASM_ARM_ADDRESSING_PREINDEXED) + strcat(buf, "!"); + + break; + case ASM_ARM_OTYPE_REG_LIST: + strcat(buf, "{"); + temp = op->imm; + first = 1; + for (i = 0; i < 16; i++) + { + if (temp & 0x01) + { + if (!first) + strcat(buf, ","); + sprintf(buf + strlen(buf), "%s", + asm_arm_get_register(i)); + first = 0; + } + temp = temp >> 1; + } + strcat(buf, "}"); + if (op->regset == ASM_ARM_REGSET_USR) + strcat(buf, "^"); + break; + case ASM_ARM_OTYPE_DISP: + address = asm_dest_resolve_arm(addr, op->imm, 0); + ins->proc->resolve_immediate(ins->proc->resolve_data, address, buf, len); + break; + case ASM_ARM_OTYPE_DISP_HALF: + address = asm_dest_resolve_arm(addr, op->imm, 1); + ins->proc->resolve_immediate(ins->proc->resolve_data, address, buf, len); + break; + case ASM_ARM_OTYPE_COPROC: + sprintf(buf, "%s", asm_arm_get_coprocessor(op->imm)); + break; + case ASM_ARM_OTYPE_COPROC_REGISTER: + sprintf(buf, "%s", asm_arm_get_coprocessor_register(op->baser)); + break; + default: + sprintf(buf, "err"); + break; + } +} + +char *asm_arm_display_instr(asm_instr *instr, eresi_Addr addr) +{ + u_int32_t i; + static char buffer[1024]; + + memset(buffer,0,sizeof(buffer)); + sprintf(buffer,"%s",instr->name); + + strcat(buffer, " "); + for (i = 0; i < instr->nb_op; i++) + { + asm_arm_dump_operand(instr, i+1, addr, buffer + strlen(buffer), 1024 - strlen(buffer)); + if (i < instr->nb_op -1) + strcat(buffer, ", "); + } + + return buffer; +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/register_arm.c eresi-0.0.20110516/libasm/src/arch/arm/register_arm.c --- eresi-0.8a25/libasm/src/arch/arm/register_arm.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/register_arm.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,253 @@ +/** +* @file libasm/src/arch/arm/register_arm.c +** @ingroup arm +*/ +/** +* @file libasm/src/arch/arm/register_arm.c + * @brief + * + */ + +#include + +/* Helper function prototypes */ +static int asm_register_arm_instructions(); +static int asm_register_arm_operands(); + +static int asm_register_arm_opcode(int type, int subtype, + int instruction, unsigned long fcn); +static int asm_register_arm_operand(int operand_type, unsigned long fcn); + +/** + * Initialize arm vector. + * @return Always 1. + */ +int asm_register_arm() +{ + u_int *dims; + char **dimstr; + + LIBASM_PROFILE_FIN(); + + dims = malloc(3 * sizeof (u_int)); + if (!dims) + { + goto out; + } + dimstr = malloc(3 * sizeof (char *)); + if (!dimstr) + { + goto out; + } + + dims[0] = 4; + dims[1] = 8; + dims[2] = 16; + + /* TODO: change these strings */ + dimstr[0] = "TYPE"; + dimstr[1] = "SUBTYPE"; + dimstr[2] = "INSTRUCTION"; + + aspect_register_vector(LIBASM_VECTOR_OPCODE_ARM, asm_fetch_default, + dims, dimstr, 3, ASPECT_TYPE_CADDR); + + /* Initializing ARM operand handler vector */ + dims = malloc(1 * sizeof (u_int)); + + if (!dims) + { + goto out; + } + dimstr = malloc(1 * sizeof (char *)); + if (!dimstr) + { + goto out; + } + + dims[0] = ASM_ARM_OTYPE_NUM; + + dimstr[0] = "OPERAND"; + + aspect_register_vector(LIBASM_VECTOR_OPERAND_ARM, asm_operand_fetch_default, + dims, dimstr, 1, ASPECT_TYPE_CADDR); + + asm_register_arm_instructions(); + asm_register_arm_operands(); + + out: + LIBASM_PROFILE_FOUT(1); +} + +/** + * @brief Create the instruction vector + * @param opcode First opcode + * @param opcode2 Second opcode + * @param fpop + * @param fcn Default handler of the instruction vector. + * @return + */ +int asm_register_arm_opcode(int type, int subtype, int instruction, + unsigned long fcn) +{ + vector_t *vec; + u_int dim[3]; + + LIBASM_PROFILE_FIN(); + vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_ARM); + dim[0] = type; + dim[1] = subtype; + dim[2] = instruction; + + aspect_vectors_insert(vec, dim, fcn); + LIBASM_PROFILE_FOUT(1); +} + +/** + * @brief Register each instruction handler for the arm architecture. + * @return 1 on success, or -1 on error + */ + +int asm_register_arm_instructions() +{ + LIBASM_PROFILE_FIN(); + + // TODO: verify if a different function is needed for different forms of a + // single instruction, such as MCR and MCR2. + // If not, maybe it'll be better to remove the multiple entries used in + // the opcode vector + + /* undefined instruction */ + asm_register_arm_opcode(0x00, 0x00, 0x00, (unsigned long) asm_arm_undef); + + /* multiply */ + asm_register_arm_opcode(0x00, 0x01, 0x00, (unsigned long) asm_arm_mul); + asm_register_arm_opcode(0x00, 0x01, 0x01, (unsigned long) asm_arm_mla); + asm_register_arm_opcode(0x00, 0x01, 0x04, (unsigned long) asm_arm_umull); + asm_register_arm_opcode(0x00, 0x01, 0x05, (unsigned long) asm_arm_umlal); + asm_register_arm_opcode(0x00, 0x01, 0x06, (unsigned long) asm_arm_smull); + asm_register_arm_opcode(0x00, 0x01, 0x07, (unsigned long) asm_arm_smlal); + /* swap */ + asm_register_arm_opcode(0x00, 0x02, 0x00, (unsigned long) asm_arm_swp); + asm_register_arm_opcode(0x00, 0x02, 0x01, (unsigned long) asm_arm_swpb); + /* extra load/store */ + asm_register_arm_opcode(0x00, 0x03, 0x01, (unsigned long) asm_arm_strh); + asm_register_arm_opcode(0x00, 0x03, 0x02, (unsigned long) asm_arm_ldrd); + asm_register_arm_opcode(0x00, 0x03, 0x03, (unsigned long) asm_arm_strd); + asm_register_arm_opcode(0x00, 0x03, 0x05, (unsigned long) asm_arm_ldrh); + asm_register_arm_opcode(0x00, 0x03, 0x06, (unsigned long) asm_arm_ldrsb); + asm_register_arm_opcode(0x00, 0x03, 0x07, (unsigned long) asm_arm_ldrsh); + /* miscellaneous */ + /* .. dsp multiply */ + asm_register_arm_opcode(0x00, 0x04, 0x00, (unsigned long) asm_arm_smlaxy); + asm_register_arm_opcode(0x00, 0x04, 0x01, (unsigned long) asm_arm_smlawy); + asm_register_arm_opcode(0x00, 0x04, 0x02, (unsigned long) asm_arm_smlalxy); + asm_register_arm_opcode(0x00, 0x04, 0x03, (unsigned long) asm_arm_smulxy); + asm_register_arm_opcode(0x00, 0x04, 0x05, (unsigned long) asm_arm_smulwy); + /* .. dsp add/sub */ + asm_register_arm_opcode(0x00, 0x05, 0x00, (unsigned long) asm_arm_qadd); + asm_register_arm_opcode(0x00, 0x05, 0x01, (unsigned long) asm_arm_qsub); + asm_register_arm_opcode(0x00, 0x05, 0x02, (unsigned long) asm_arm_qdadd); + asm_register_arm_opcode(0x00, 0x05, 0x03, (unsigned long) asm_arm_qdsub); + /* .. other */ + /* ... status register manipulation */ + asm_register_arm_opcode(0x00, 0x06, 0x00, (unsigned long) asm_arm_mrs); + asm_register_arm_opcode(0x00, 0x00, 0x01, (unsigned long) asm_arm_msr); /* MSR(1) */ + asm_register_arm_opcode(0x00, 0x06, 0x02, (unsigned long) asm_arm_msr); /* MSR(2) */ + + asm_register_arm_opcode(0x00, 0x06, 0x03, (unsigned long) asm_arm_bx); + asm_register_arm_opcode(0x00, 0x06, 0x07, (unsigned long) asm_arm_clz); + asm_register_arm_opcode(0x00, 0x06, 0x05, (unsigned long) asm_arm_blx2); /* BLX(2) */ + asm_register_arm_opcode(0x00, 0x06, 0x09, (unsigned long) asm_arm_bkpt); + /* data processing */ + asm_register_arm_opcode(0x00, 0x07, 0x00, (unsigned long) asm_arm_and); + asm_register_arm_opcode(0x00, 0x07, 0x01, (unsigned long) asm_arm_eor); + asm_register_arm_opcode(0x00, 0x07, 0x02, (unsigned long) asm_arm_sub); + asm_register_arm_opcode(0x00, 0x07, 0x03, (unsigned long) asm_arm_rsb); + asm_register_arm_opcode(0x00, 0x07, 0x04, (unsigned long) asm_arm_add); + asm_register_arm_opcode(0x00, 0x07, 0x05, (unsigned long) asm_arm_adc); + asm_register_arm_opcode(0x00, 0x07, 0x06, (unsigned long) asm_arm_sbc); + asm_register_arm_opcode(0x00, 0x07, 0x07, (unsigned long) asm_arm_rsc); + asm_register_arm_opcode(0x00, 0x07, 0x08, (unsigned long) asm_arm_tst); + asm_register_arm_opcode(0x00, 0x07, 0x09, (unsigned long) asm_arm_teq); + asm_register_arm_opcode(0x00, 0x07, 0x0A, (unsigned long) asm_arm_cmp); + asm_register_arm_opcode(0x00, 0x07, 0x0B, (unsigned long) asm_arm_cmn); + asm_register_arm_opcode(0x00, 0x07, 0x0C, (unsigned long) asm_arm_orr); + asm_register_arm_opcode(0x00, 0x07, 0x0D, (unsigned long) asm_arm_mov); + asm_register_arm_opcode(0x00, 0x07, 0x0E, (unsigned long) asm_arm_bic); + asm_register_arm_opcode(0x00, 0x07, 0x0F, (unsigned long) asm_arm_mvn); + + /* load/store */ + asm_register_arm_opcode(0x01, 0x00, 0x00, (unsigned long) asm_arm_str); + asm_register_arm_opcode(0x01, 0x00, 0x01, (unsigned long) asm_arm_strt); + asm_register_arm_opcode(0x01, 0x00, 0x02, (unsigned long) asm_arm_strb); + asm_register_arm_opcode(0x01, 0x00, 0x03, (unsigned long) asm_arm_strbt); + asm_register_arm_opcode(0x01, 0x01, 0x00, (unsigned long) asm_arm_ldr); + asm_register_arm_opcode(0x01, 0x01, 0x01, (unsigned long) asm_arm_ldrt); + asm_register_arm_opcode(0x01, 0x01, 0x02, (unsigned long) asm_arm_ldrb); + asm_register_arm_opcode(0x01, 0x01, 0x03, (unsigned long) asm_arm_ldrbt); + /* PLD */ + asm_register_arm_opcode(0x01, 0x02, 0x00, (unsigned long) asm_arm_pld); + + /* load/store multiple */ + asm_register_arm_opcode(0x02, 0x00, 0x00, (unsigned long) asm_arm_stm1); /* STM(1) */ + asm_register_arm_opcode(0x02, 0x00, 0x02, (unsigned long) asm_arm_ldm1); /* LDM(1) */ + asm_register_arm_opcode(0x02, 0x00, 0x04, (unsigned long) asm_arm_stm2); /* STM(2) */ + asm_register_arm_opcode(0x02, 0x00, 0x06, (unsigned long) asm_arm_ldm2); /* LDM(2) */ + asm_register_arm_opcode(0x02, 0x00, 0x07, (unsigned long) asm_arm_ldm3); /* LDM(3) */ + /* branch */ + asm_register_arm_opcode(0x02, 0x01, 0x00, (unsigned long) asm_arm_b); + asm_register_arm_opcode(0x02, 0x01, 0x01, (unsigned long) asm_arm_bl); + asm_register_arm_opcode(0x02, 0x01, 0x02, (unsigned long) asm_arm_blx1); /* BLX(1) */ + + /* coprocessor */ + asm_register_arm_opcode(0x03, 0x00, 0x00, (unsigned long) asm_arm_mcrr); + asm_register_arm_opcode(0x03, 0x00, 0x01, (unsigned long) asm_arm_mrrc); + asm_register_arm_opcode(0x03, 0x01, 0x00, (unsigned long) asm_arm_stc); + asm_register_arm_opcode(0x03, 0x01, 0x01, (unsigned long) asm_arm_ldc); + asm_register_arm_opcode(0x03, 0x01, 0x02, (unsigned long) asm_arm_stc); /* STC2 */ + asm_register_arm_opcode(0x03, 0x01, 0x03, (unsigned long) asm_arm_ldc); /* LDC2 */ + asm_register_arm_opcode(0x03, 0x02, 0x00, (unsigned long) asm_arm_cdp); + asm_register_arm_opcode(0x03, 0x02, 0x01, (unsigned long) asm_arm_cdp); /* CDP2 */ + asm_register_arm_opcode(0x03, 0x03, 0x00, (unsigned long) asm_arm_mcr); + asm_register_arm_opcode(0x03, 0x03, 0x01, (unsigned long) asm_arm_mrc); + asm_register_arm_opcode(0x03, 0x03, 0x02, (unsigned long) asm_arm_mcr); /* MCR2 */ + asm_register_arm_opcode(0x03, 0x03, 0x03, (unsigned long) asm_arm_mrc); /* MRC2 */ + /* exception */ + asm_register_arm_opcode(0x03, 0x04, 0x00, (unsigned long) asm_arm_swi); + + LIBASM_PROFILE_FOUT(1); +} + +/** + * Register an handler for an ARM operand content. + * @param operand_type Content of the operand to register + * @param fcn Function pointer. + * @return 1 on success, 0 on error. + */ +int asm_register_arm_operand(int operand_type, unsigned long fcn) +{ + LIBASM_PROFILE_FIN(); + asm_register_operand(LIBASM_VECTOR_OPERAND_ARM, operand_type, fcn); + LIBASM_PROFILE_FOUT(1); +} + +/** + * Register operands. + * + */ +int asm_register_arm_operands() +{ + asm_register_arm_operand(ASM_ARM_OTYPE_REGISTER, (unsigned long) asm_arm_op_fetch_register); + asm_register_arm_operand(ASM_ARM_OTYPE_IMMEDIATE, (unsigned long) asm_arm_op_fetch_immediate); + asm_register_arm_operand(ASM_ARM_OTYPE_REG_SCALED, (unsigned long) asm_arm_op_fetch_reg_scaled); + asm_register_arm_operand(ASM_ARM_OTYPE_REG_OFFSET, (unsigned long) asm_arm_op_fetch_reg_offset); + asm_register_arm_operand(ASM_ARM_OTYPE_REG_LIST, (unsigned long) asm_arm_op_fetch_reg_list); + asm_register_arm_operand(ASM_ARM_OTYPE_DISP, (unsigned long) asm_arm_op_fetch_disp); + asm_register_arm_operand(ASM_ARM_OTYPE_DISP_HALF, (unsigned long) asm_arm_op_fetch_disp_half); + asm_register_arm_operand(ASM_ARM_OTYPE_COPROC, (unsigned long) asm_arm_op_fetch_coprocessor); + asm_register_arm_operand(ASM_ARM_OTYPE_COPROC_REGISTER, (unsigned long) asm_arm_op_fetch_coprocessor_register); + /* WIP */ + + return (1); +} diff -Nru eresi-0.8a25/libasm/src/arch/arm/tables_arm.c eresi-0.0.20110516/libasm/src/arch/arm/tables_arm.c --- eresi-0.8a25/libasm/src/arch/arm/tables_arm.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/arm/tables_arm.c 2011-05-16 11:34:19.000000000 +0000 @@ -0,0 +1,3692 @@ +/** + * @file libasm/src/arch/arm/tables_arm.c + * @ingroup arm + */ +#include "libasm.h" + +/* Flags read by condition */ +int arm_cond_flagsread_table[17] = + { + ASM_ARM_FLAG_Z, /* ASM_ARM_COND_EQ */ + ASM_ARM_FLAG_Z, /* ASM_ARM_COND_NE */ + ASM_ARM_FLAG_C, /* ASM_ARM_COND_CC */ + ASM_ARM_FLAG_C, /* ASM_ARM_COND_CS */ + ASM_ARM_FLAG_N, /* ASM_ARM_COND_MI */ + ASM_ARM_FLAG_N, /* ASM_ARM_COND_PL */ + ASM_ARM_FLAG_V, /* ASM_ARM_COND_VS */ + ASM_ARM_FLAG_V, /* ASM_ARM_COND_VC */ + ASM_ARM_FLAG_C | ASM_ARM_FLAG_Z, /* ASM_ARM_COND_HI */ + ASM_ARM_FLAG_C | ASM_ARM_FLAG_Z, /* ASM_ARM_COND_LS */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_V, /* ASM_ARM_COND_GE */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_V, /* ASM_ARM_COND_LT */ + ASM_ARM_FLAG_Z | ASM_ARM_FLAG_N | ASM_ARM_FLAG_V, /* ASM_ARM_COND_GT */ + ASM_ARM_FLAG_Z | ASM_ARM_FLAG_N | ASM_ARM_FLAG_V, /* ASM_ARM_COND_LE */ + 0x00, /* ASM_ARM_COND_AL */ + 0x00 /* ASM_ARM_COND_NV */ + }; + +/* Flags written by data processing instructions */ +/* opcode (4bit) */ +int arm_dataproc_flagswritten_table[16] = + { + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* AND */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* EOR */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* SUB */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* RSB */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* ADD */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* ADC */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* SBC */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* RSC */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* TST */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* TEQ */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* CMP */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C | ASM_ARM_FLAG_V, /* CMN */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* ORR */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* MOV */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C, /* BIC */ + ASM_ARM_FLAG_N | ASM_ARM_FLAG_Z | ASM_ARM_FLAG_C /* MVN */ + }; + +/* opcode (4bit) | cond (4bit) | S (1bit) */ +int arm_dataproc_table[512] = + { + /* AND */ + ASM_ARM_ANDEQ, + ASM_ARM_ANDEQS, + ASM_ARM_ANDNE, + ASM_ARM_ANDNES, + ASM_ARM_ANDCS, + ASM_ARM_ANDCSS, + ASM_ARM_ANDCC, + ASM_ARM_ANDCCS, + ASM_ARM_ANDMI, + ASM_ARM_ANDMIS, + ASM_ARM_ANDPL, + ASM_ARM_ANDPLS, + ASM_ARM_ANDVS, + ASM_ARM_ANDVSS, + ASM_ARM_ANDVC, + ASM_ARM_ANDVCS, + ASM_ARM_ANDHI, + ASM_ARM_ANDHIS, + ASM_ARM_ANDLS, + ASM_ARM_ANDLSS, + ASM_ARM_ANDGE, + ASM_ARM_ANDGES, + ASM_ARM_ANDLT, + ASM_ARM_ANDLTS, + ASM_ARM_ANDGT, + ASM_ARM_ANDGTS, + ASM_ARM_ANDLE, + ASM_ARM_ANDLES, + ASM_ARM_AND, + ASM_ARM_ANDS, + ASM_ARM_, + ASM_ARM_, + + /* EOR */ + ASM_ARM_EOREQ, + ASM_ARM_EOREQS, + ASM_ARM_EORNE, + ASM_ARM_EORNES, + ASM_ARM_EORCS, + ASM_ARM_EORCSS, + ASM_ARM_EORCC, + ASM_ARM_EORCCS, + ASM_ARM_EORMI, + ASM_ARM_EORMIS, + ASM_ARM_EORPL, + ASM_ARM_EORPLS, + ASM_ARM_EORVS, + ASM_ARM_EORVSS, + ASM_ARM_EORVC, + ASM_ARM_EORVCS, + ASM_ARM_EORHI, + ASM_ARM_EORHIS, + ASM_ARM_EORLS, + ASM_ARM_EORLSS, + ASM_ARM_EORGE, + ASM_ARM_EORGES, + ASM_ARM_EORLT, + ASM_ARM_EORLTS, + ASM_ARM_EORGT, + ASM_ARM_EORGTS, + ASM_ARM_EORLE, + ASM_ARM_EORLES, + ASM_ARM_EOR, + ASM_ARM_EORS, + ASM_ARM_, + ASM_ARM_, + + /* SUB */ + ASM_ARM_SUBEQ, + ASM_ARM_SUBEQS, + ASM_ARM_SUBNE, + ASM_ARM_SUBNES, + ASM_ARM_SUBCS, + ASM_ARM_SUBCSS, + ASM_ARM_SUBCC, + ASM_ARM_SUBCCS, + ASM_ARM_SUBMI, + ASM_ARM_SUBMIS, + ASM_ARM_SUBPL, + ASM_ARM_SUBPLS, + ASM_ARM_SUBVS, + ASM_ARM_SUBVSS, + ASM_ARM_SUBVC, + ASM_ARM_SUBVCS, + ASM_ARM_SUBHI, + ASM_ARM_SUBHIS, + ASM_ARM_SUBLS, + ASM_ARM_SUBLSS, + ASM_ARM_SUBGE, + ASM_ARM_SUBGES, + ASM_ARM_SUBLT, + ASM_ARM_SUBLTS, + ASM_ARM_SUBGT, + ASM_ARM_SUBGTS, + ASM_ARM_SUBLE, + ASM_ARM_SUBLES, + ASM_ARM_SUB, + ASM_ARM_SUBS, + ASM_ARM_, + ASM_ARM_, + + /* RSB */ + ASM_ARM_RSBEQ, + ASM_ARM_RSBEQS, + ASM_ARM_RSBNE, + ASM_ARM_RSBNES, + ASM_ARM_RSBCS, + ASM_ARM_RSBCSS, + ASM_ARM_RSBCC, + ASM_ARM_RSBCCS, + ASM_ARM_RSBMI, + ASM_ARM_RSBMIS, + ASM_ARM_RSBPL, + ASM_ARM_RSBPLS, + ASM_ARM_RSBVS, + ASM_ARM_RSBVSS, + ASM_ARM_RSBVC, + ASM_ARM_RSBVCS, + ASM_ARM_RSBHI, + ASM_ARM_RSBHIS, + ASM_ARM_RSBLS, + ASM_ARM_RSBLSS, + ASM_ARM_RSBGE, + ASM_ARM_RSBGES, + ASM_ARM_RSBLT, + ASM_ARM_RSBLTS, + ASM_ARM_RSBGT, + ASM_ARM_RSBGTS, + ASM_ARM_RSBLE, + ASM_ARM_RSBLES, + ASM_ARM_RSB, + ASM_ARM_RSBS, + ASM_ARM_, + ASM_ARM_, + + /* ADD */ + ASM_ARM_ADDEQ, + ASM_ARM_ADDEQS, + ASM_ARM_ADDNE, + ASM_ARM_ADDNES, + ASM_ARM_ADDCS, + ASM_ARM_ADDCSS, + ASM_ARM_ADDCC, + ASM_ARM_ADDCCS, + ASM_ARM_ADDMI, + ASM_ARM_ADDMIS, + ASM_ARM_ADDPL, + ASM_ARM_ADDPLS, + ASM_ARM_ADDVS, + ASM_ARM_ADDVSS, + ASM_ARM_ADDVC, + ASM_ARM_ADDVCS, + ASM_ARM_ADDHI, + ASM_ARM_ADDHIS, + ASM_ARM_ADDLS, + ASM_ARM_ADDLSS, + ASM_ARM_ADDGE, + ASM_ARM_ADDGES, + ASM_ARM_ADDLT, + ASM_ARM_ADDLTS, + ASM_ARM_ADDGT, + ASM_ARM_ADDGTS, + ASM_ARM_ADDLE, + ASM_ARM_ADDLES, + ASM_ARM_ADD, + ASM_ARM_ADDS, + ASM_ARM_, + ASM_ARM_, + + /* ADC */ + ASM_ARM_ADCEQ, + ASM_ARM_ADCEQS, + ASM_ARM_ADCNE, + ASM_ARM_ADCNES, + ASM_ARM_ADCCS, + ASM_ARM_ADCCSS, + ASM_ARM_ADCCC, + ASM_ARM_ADCCCS, + ASM_ARM_ADCMI, + ASM_ARM_ADCMIS, + ASM_ARM_ADCPL, + ASM_ARM_ADCPLS, + ASM_ARM_ADCVS, + ASM_ARM_ADCVSS, + ASM_ARM_ADCVC, + ASM_ARM_ADCVCS, + ASM_ARM_ADCHI, + ASM_ARM_ADCHIS, + ASM_ARM_ADCLS, + ASM_ARM_ADCLSS, + ASM_ARM_ADCGE, + ASM_ARM_ADCGES, + ASM_ARM_ADCLT, + ASM_ARM_ADCLTS, + ASM_ARM_ADCGT, + ASM_ARM_ADCGTS, + ASM_ARM_ADCLE, + ASM_ARM_ADCLES, + ASM_ARM_ADC, + ASM_ARM_ADCS, + ASM_ARM_, + ASM_ARM_, + + /* SBC */ + ASM_ARM_SBCEQ, + ASM_ARM_SBCEQS, + ASM_ARM_SBCNE, + ASM_ARM_SBCNES, + ASM_ARM_SBCCS, + ASM_ARM_SBCCSS, + ASM_ARM_SBCCC, + ASM_ARM_SBCCCS, + ASM_ARM_SBCMI, + ASM_ARM_SBCMIS, + ASM_ARM_SBCPL, + ASM_ARM_SBCPLS, + ASM_ARM_SBCVS, + ASM_ARM_SBCVSS, + ASM_ARM_SBCVC, + ASM_ARM_SBCVCS, + ASM_ARM_SBCHI, + ASM_ARM_SBCHIS, + ASM_ARM_SBCLS, + ASM_ARM_SBCLSS, + ASM_ARM_SBCGE, + ASM_ARM_SBCGES, + ASM_ARM_SBCLT, + ASM_ARM_SBCLTS, + ASM_ARM_SBCGT, + ASM_ARM_SBCGTS, + ASM_ARM_SBCLE, + ASM_ARM_SBCLES, + ASM_ARM_SBC, + ASM_ARM_SBCS, + ASM_ARM_, + ASM_ARM_, + + /* RSC */ + ASM_ARM_RSCEQ, + ASM_ARM_RSCEQS, + ASM_ARM_RSCNE, + ASM_ARM_RSCNES, + ASM_ARM_RSCCS, + ASM_ARM_RSCCSS, + ASM_ARM_RSCCC, + ASM_ARM_RSCCCS, + ASM_ARM_RSCMI, + ASM_ARM_RSCMIS, + ASM_ARM_RSCPL, + ASM_ARM_RSCPLS, + ASM_ARM_RSCVS, + ASM_ARM_RSCVSS, + ASM_ARM_RSCVC, + ASM_ARM_RSCVCS, + ASM_ARM_RSCHI, + ASM_ARM_RSCHIS, + ASM_ARM_RSCLS, + ASM_ARM_RSCLSS, + ASM_ARM_RSCGE, + ASM_ARM_RSCGES, + ASM_ARM_RSCLT, + ASM_ARM_RSCLTS, + ASM_ARM_RSCGT, + ASM_ARM_RSCGTS, + ASM_ARM_RSCLE, + ASM_ARM_RSCLES, + ASM_ARM_RSC, + ASM_ARM_RSCS, + ASM_ARM_, + ASM_ARM_, + + /* TST */ + ASM_ARM_, + ASM_ARM_TSTEQ, + ASM_ARM_, + ASM_ARM_TSTNE, + ASM_ARM_, + ASM_ARM_TSTCS, + ASM_ARM_, + ASM_ARM_TSTCC, + ASM_ARM_, + ASM_ARM_TSTMI, + ASM_ARM_, + ASM_ARM_TSTPL, + ASM_ARM_, + ASM_ARM_TSTVS, + ASM_ARM_, + ASM_ARM_TSTVC, + ASM_ARM_, + ASM_ARM_TSTHI, + ASM_ARM_, + ASM_ARM_TSTLS, + ASM_ARM_, + ASM_ARM_TSTGE, + ASM_ARM_, + ASM_ARM_TSTLT, + ASM_ARM_, + ASM_ARM_TSTGT, + ASM_ARM_, + ASM_ARM_TSTLE, + ASM_ARM_, + ASM_ARM_TST, + ASM_ARM_, + ASM_ARM_, + + /* TEQ */ + ASM_ARM_, + ASM_ARM_TEQEQ, + ASM_ARM_, + ASM_ARM_TEQNE, + ASM_ARM_, + ASM_ARM_TEQCS, + ASM_ARM_, + ASM_ARM_TEQCC, + ASM_ARM_, + ASM_ARM_TEQMI, + ASM_ARM_, + ASM_ARM_TEQPL, + ASM_ARM_, + ASM_ARM_TEQVS, + ASM_ARM_, + ASM_ARM_TEQVC, + ASM_ARM_, + ASM_ARM_TEQHI, + ASM_ARM_, + ASM_ARM_TEQLS, + ASM_ARM_, + ASM_ARM_TEQGE, + ASM_ARM_, + ASM_ARM_TEQLT, + ASM_ARM_, + ASM_ARM_TEQGT, + ASM_ARM_, + ASM_ARM_TEQLE, + ASM_ARM_, + ASM_ARM_TEQ, + ASM_ARM_, + ASM_ARM_, + + /* CMP */ + ASM_ARM_, + ASM_ARM_CMPEQ, + ASM_ARM_, + ASM_ARM_CMPNE, + ASM_ARM_, + ASM_ARM_CMPCS, + ASM_ARM_, + ASM_ARM_CMPCC, + ASM_ARM_, + ASM_ARM_CMPMI, + ASM_ARM_, + ASM_ARM_CMPPL, + ASM_ARM_, + ASM_ARM_CMPVS, + ASM_ARM_, + ASM_ARM_CMPVC, + ASM_ARM_, + ASM_ARM_CMPHI, + ASM_ARM_, + ASM_ARM_CMPLS, + ASM_ARM_, + ASM_ARM_CMPGE, + ASM_ARM_, + ASM_ARM_CMPLT, + ASM_ARM_, + ASM_ARM_CMPGT, + ASM_ARM_, + ASM_ARM_CMPLE, + ASM_ARM_, + ASM_ARM_CMP, + ASM_ARM_, + ASM_ARM_, + + /* CMN */ + ASM_ARM_, + ASM_ARM_CMNEQ, + ASM_ARM_, + ASM_ARM_CMNNE, + ASM_ARM_, + ASM_ARM_CMNCS, + ASM_ARM_, + ASM_ARM_CMNCC, + ASM_ARM_, + ASM_ARM_CMNMI, + ASM_ARM_, + ASM_ARM_CMNPL, + ASM_ARM_, + ASM_ARM_CMNVS, + ASM_ARM_, + ASM_ARM_CMNVC, + ASM_ARM_, + ASM_ARM_CMNHI, + ASM_ARM_, + ASM_ARM_CMNLS, + ASM_ARM_, + ASM_ARM_CMNGE, + ASM_ARM_, + ASM_ARM_CMNLT, + ASM_ARM_, + ASM_ARM_CMNGT, + ASM_ARM_, + ASM_ARM_CMNLE, + ASM_ARM_, + ASM_ARM_CMN, + ASM_ARM_, + ASM_ARM_, + + /* ORR */ + ASM_ARM_ORREQ, + ASM_ARM_ORREQS, + ASM_ARM_ORRNE, + ASM_ARM_ORRNES, + ASM_ARM_ORRCS, + ASM_ARM_ORRCSS, + ASM_ARM_ORRCC, + ASM_ARM_ORRCCS, + ASM_ARM_ORRMI, + ASM_ARM_ORRMIS, + ASM_ARM_ORRPL, + ASM_ARM_ORRPLS, + ASM_ARM_ORRVS, + ASM_ARM_ORRVSS, + ASM_ARM_ORRVC, + ASM_ARM_ORRVCS, + ASM_ARM_ORRHI, + ASM_ARM_ORRHIS, + ASM_ARM_ORRLS, + ASM_ARM_ORRLSS, + ASM_ARM_ORRGE, + ASM_ARM_ORRGES, + ASM_ARM_ORRLT, + ASM_ARM_ORRLTS, + ASM_ARM_ORRGT, + ASM_ARM_ORRGTS, + ASM_ARM_ORRLE, + ASM_ARM_ORRLES, + ASM_ARM_ORR, + ASM_ARM_ORRS, + ASM_ARM_, + ASM_ARM_, + + /* MOV */ + ASM_ARM_MOVEQ, + ASM_ARM_MOVEQS, + ASM_ARM_MOVNE, + ASM_ARM_MOVNES, + ASM_ARM_MOVCS, + ASM_ARM_MOVCSS, + ASM_ARM_MOVCC, + ASM_ARM_MOVCCS, + ASM_ARM_MOVMI, + ASM_ARM_MOVMIS, + ASM_ARM_MOVPL, + ASM_ARM_MOVPLS, + ASM_ARM_MOVVS, + ASM_ARM_MOVVSS, + ASM_ARM_MOVVC, + ASM_ARM_MOVVCS, + ASM_ARM_MOVHI, + ASM_ARM_MOVHIS, + ASM_ARM_MOVLS, + ASM_ARM_MOVLSS, + ASM_ARM_MOVGE, + ASM_ARM_MOVGES, + ASM_ARM_MOVLT, + ASM_ARM_MOVLTS, + ASM_ARM_MOVGT, + ASM_ARM_MOVGTS, + ASM_ARM_MOVLE, + ASM_ARM_MOVLES, + ASM_ARM_MOV, + ASM_ARM_MOVS, + ASM_ARM_, + ASM_ARM_, + + /* BIC */ + ASM_ARM_BICEQ, + ASM_ARM_BICEQS, + ASM_ARM_BICNE, + ASM_ARM_BICNES, + ASM_ARM_BICCS, + ASM_ARM_BICCSS, + ASM_ARM_BICCC, + ASM_ARM_BICCCS, + ASM_ARM_BICMI, + ASM_ARM_BICMIS, + ASM_ARM_BICPL, + ASM_ARM_BICPLS, + ASM_ARM_BICVS, + ASM_ARM_BICVSS, + ASM_ARM_BICVC, + ASM_ARM_BICVCS, + ASM_ARM_BICHI, + ASM_ARM_BICHIS, + ASM_ARM_BICLS, + ASM_ARM_BICLSS, + ASM_ARM_BICGE, + ASM_ARM_BICGES, + ASM_ARM_BICLT, + ASM_ARM_BICLTS, + ASM_ARM_BICGT, + ASM_ARM_BICGTS, + ASM_ARM_BICLE, + ASM_ARM_BICLES, + ASM_ARM_BIC, + ASM_ARM_BICS, + ASM_ARM_, + ASM_ARM_, + + /* MVN */ + ASM_ARM_MVNEQ, + ASM_ARM_MVNEQS, + ASM_ARM_MVNNE, + ASM_ARM_MVNNES, + ASM_ARM_MVNCS, + ASM_ARM_MVNCSS, + ASM_ARM_MVNCC, + ASM_ARM_MVNCCS, + ASM_ARM_MVNMI, + ASM_ARM_MVNMIS, + ASM_ARM_MVNPL, + ASM_ARM_MVNPLS, + ASM_ARM_MVNVS, + ASM_ARM_MVNVSS, + ASM_ARM_MVNVC, + ASM_ARM_MVNVCS, + ASM_ARM_MVNHI, + ASM_ARM_MVNHIS, + ASM_ARM_MVNLS, + ASM_ARM_MVNLSS, + ASM_ARM_MVNGE, + ASM_ARM_MVNGES, + ASM_ARM_MVNLT, + ASM_ARM_MVNLTS, + ASM_ARM_MVNGT, + ASM_ARM_MVNGTS, + ASM_ARM_MVNLE, + ASM_ARM_MVNLES, + ASM_ARM_MVN, + ASM_ARM_MVNS, + ASM_ARM_, + ASM_ARM_ + }; + +/* topsr (1bit) | cond (4bit) */ +int arm_movpsr_table[32] = + { + /* MRS */ + ASM_ARM_MRSEQ, + ASM_ARM_MRSNE, + ASM_ARM_MRSCS, + ASM_ARM_MRSCC, + ASM_ARM_MRSMI, + ASM_ARM_MRSPL, + ASM_ARM_MRSVS, + ASM_ARM_MRSVC, + ASM_ARM_MRSHI, + ASM_ARM_MRSLS, + ASM_ARM_MRSGE, + ASM_ARM_MRSLT, + ASM_ARM_MRSGT, + ASM_ARM_MRSLE, + ASM_ARM_MRS, + ASM_ARM_, + + /* MSR */ + ASM_ARM_MSREQ, + ASM_ARM_MSRNE, + ASM_ARM_MSRCS, + ASM_ARM_MSRCC, + ASM_ARM_MSRMI, + ASM_ARM_MSRPL, + ASM_ARM_MSRVS, + ASM_ARM_MSRVC, + ASM_ARM_MSRHI, + ASM_ARM_MSRLS, + ASM_ARM_MSRGE, + ASM_ARM_MSRLT, + ASM_ARM_MSRGT, + ASM_ARM_MSRLE, + ASM_ARM_MSR, + ASM_ARM_ + }; + +/* cond (4bit) */ +int arm_clz_table[16] = + { + /* CLZ */ + ASM_ARM_CLZEQ, + ASM_ARM_CLZNE, + ASM_ARM_CLZCS, + ASM_ARM_CLZCC, + ASM_ARM_CLZMI, + ASM_ARM_CLZPL, + ASM_ARM_CLZVS, + ASM_ARM_CLZVC, + ASM_ARM_CLZHI, + ASM_ARM_CLZLS, + ASM_ARM_CLZGE, + ASM_ARM_CLZLT, + ASM_ARM_CLZGT, + ASM_ARM_CLZLE, + ASM_ARM_CLZ, + ASM_ARM_ + }; + +/* cond (4bit) */ +int arm_swi_table[16] = + { + /* SWI */ + ASM_ARM_SWIEQ, + ASM_ARM_SWINE, + ASM_ARM_SWICS, + ASM_ARM_SWICC, + ASM_ARM_SWIMI, + ASM_ARM_SWIPL, + ASM_ARM_SWIVS, + ASM_ARM_SWIVC, + ASM_ARM_SWIHI, + ASM_ARM_SWILS, + ASM_ARM_SWIGE, + ASM_ARM_SWILT, + ASM_ARM_SWIGT, + ASM_ARM_SWILE, + ASM_ARM_SWI, + ASM_ARM_ + }; + +/* L (1bit) | T (1bit) | B (1bit) | cond (4bit) */ +int arm_ldst_table[128] = + { + /* STR */ + ASM_ARM_STREQ, + ASM_ARM_STRNE, + ASM_ARM_STRCS, + ASM_ARM_STRCC, + ASM_ARM_STRMI, + ASM_ARM_STRPL, + ASM_ARM_STRVS, + ASM_ARM_STRVC, + ASM_ARM_STRHI, + ASM_ARM_STRLS, + ASM_ARM_STRGE, + ASM_ARM_STRLT, + ASM_ARM_STRGT, + ASM_ARM_STRLE, + ASM_ARM_STR, + ASM_ARM_, + + /* STRB */ + ASM_ARM_STREQB, + ASM_ARM_STRNEB, + ASM_ARM_STRCSB, + ASM_ARM_STRCCB, + ASM_ARM_STRMIB, + ASM_ARM_STRPLB, + ASM_ARM_STRVSB, + ASM_ARM_STRVCB, + ASM_ARM_STRHIB, + ASM_ARM_STRLSB, + ASM_ARM_STRGEB, + ASM_ARM_STRLTB, + ASM_ARM_STRGTB, + ASM_ARM_STRLEB, + ASM_ARM_STRB, + ASM_ARM_, + + /* STRT */ + ASM_ARM_STREQT, + ASM_ARM_STRNET, + ASM_ARM_STRCST, + ASM_ARM_STRCCT, + ASM_ARM_STRMIT, + ASM_ARM_STRPLT, + ASM_ARM_STRVST, + ASM_ARM_STRVCT, + ASM_ARM_STRHIT, + ASM_ARM_STRLST, + ASM_ARM_STRGET, + ASM_ARM_STRLTT, + ASM_ARM_STRGTT, + ASM_ARM_STRLET, + ASM_ARM_STRT, + ASM_ARM_, + + /* STRBT */ + ASM_ARM_STREQBT, + ASM_ARM_STRNEBT, + ASM_ARM_STRCSBT, + ASM_ARM_STRCCBT, + ASM_ARM_STRMIBT, + ASM_ARM_STRPLBT, + ASM_ARM_STRVSBT, + ASM_ARM_STRVCBT, + ASM_ARM_STRHIBT, + ASM_ARM_STRLSBT, + ASM_ARM_STRGEBT, + ASM_ARM_STRLTBT, + ASM_ARM_STRGTBT, + ASM_ARM_STRLEBT, + ASM_ARM_STRBT, + ASM_ARM_, + + /* LDR */ + ASM_ARM_LDREQ, + ASM_ARM_LDRNE, + ASM_ARM_LDRCS, + ASM_ARM_LDRCC, + ASM_ARM_LDRMI, + ASM_ARM_LDRPL, + ASM_ARM_LDRVS, + ASM_ARM_LDRVC, + ASM_ARM_LDRHI, + ASM_ARM_LDRLS, + ASM_ARM_LDRGE, + ASM_ARM_LDRLT, + ASM_ARM_LDRGT, + ASM_ARM_LDRLE, + ASM_ARM_LDR, + ASM_ARM_, + + /* LDRB */ + ASM_ARM_LDREQB, + ASM_ARM_LDRNEB, + ASM_ARM_LDRCSB, + ASM_ARM_LDRCCB, + ASM_ARM_LDRMIB, + ASM_ARM_LDRPLB, + ASM_ARM_LDRVSB, + ASM_ARM_LDRVCB, + ASM_ARM_LDRHIB, + ASM_ARM_LDRLSB, + ASM_ARM_LDRGEB, + ASM_ARM_LDRLTB, + ASM_ARM_LDRGTB, + ASM_ARM_LDRLEB, + ASM_ARM_LDRB, + ASM_ARM_, /* PLD */ + + /* LDRT */ + ASM_ARM_LDREQT, + ASM_ARM_LDRNET, + ASM_ARM_LDRCST, + ASM_ARM_LDRCCT, + ASM_ARM_LDRMIT, + ASM_ARM_LDRPLT, + ASM_ARM_LDRVST, + ASM_ARM_LDRVCT, + ASM_ARM_LDRHIT, + ASM_ARM_LDRLST, + ASM_ARM_LDRGET, + ASM_ARM_LDRLTT, + ASM_ARM_LDRGTT, + ASM_ARM_LDRLET, + ASM_ARM_LDRT, + ASM_ARM_, + + /* LDRBT */ + ASM_ARM_LDREQBT, + ASM_ARM_LDRNEBT, + ASM_ARM_LDRCSBT, + ASM_ARM_LDRCCBT, + ASM_ARM_LDRMIBT, + ASM_ARM_LDRPLBT, + ASM_ARM_LDRVSBT, + ASM_ARM_LDRVCBT, + ASM_ARM_LDRHIBT, + ASM_ARM_LDRLSBT, + ASM_ARM_LDRGEBT, + ASM_ARM_LDRLTBT, + ASM_ARM_LDRGTBT, + ASM_ARM_LDRLEBT, + ASM_ARM_LDRBT, + ASM_ARM_ + }; + +/* L (1bit) | S (1bit) | H (1bit) | cond (4bit) */ +int arm_ldst_misc_table[128] = + { + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* STRH */ + ASM_ARM_STREQH, + ASM_ARM_STRNEH, + ASM_ARM_STRCSH, + ASM_ARM_STRCCH, + ASM_ARM_STRMIH, + ASM_ARM_STRPLH, + ASM_ARM_STRVSH, + ASM_ARM_STRVCH, + ASM_ARM_STRHIH, + ASM_ARM_STRLSH, + ASM_ARM_STRGEH, + ASM_ARM_STRLTH, + ASM_ARM_STRGTH, + ASM_ARM_STRLEH, + ASM_ARM_STRH, + ASM_ARM_, + + /* LDRD */ + ASM_ARM_LDREQD, + ASM_ARM_LDRNED, + ASM_ARM_LDRCSD, + ASM_ARM_LDRCCD, + ASM_ARM_LDRMID, + ASM_ARM_LDRPLD, + ASM_ARM_LDRVSD, + ASM_ARM_LDRVCD, + ASM_ARM_LDRHID, + ASM_ARM_LDRLSD, + ASM_ARM_LDRGED, + ASM_ARM_LDRLTD, + ASM_ARM_LDRGTD, + ASM_ARM_LDRLED, + ASM_ARM_LDRD, + ASM_ARM_, + + /* STRD */ + ASM_ARM_STREQD, + ASM_ARM_STRNED, + ASM_ARM_STRCSD, + ASM_ARM_STRCCD, + ASM_ARM_STRMID, + ASM_ARM_STRPLD, + ASM_ARM_STRVSD, + ASM_ARM_STRVCD, + ASM_ARM_STRHID, + ASM_ARM_STRLSD, + ASM_ARM_STRGED, + ASM_ARM_STRLTD, + ASM_ARM_STRGTD, + ASM_ARM_STRLED, + ASM_ARM_STRD, + ASM_ARM_, + + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* LDRH */ + ASM_ARM_LDREQH, + ASM_ARM_LDRNEH, + ASM_ARM_LDRCSH, + ASM_ARM_LDRCCH, + ASM_ARM_LDRMIH, + ASM_ARM_LDRPLH, + ASM_ARM_LDRVSH, + ASM_ARM_LDRVCH, + ASM_ARM_LDRHIH, + ASM_ARM_LDRLSH, + ASM_ARM_LDRGEH, + ASM_ARM_LDRLTH, + ASM_ARM_LDRGTH, + ASM_ARM_LDRLEH, + ASM_ARM_LDRH, + ASM_ARM_, + + /* LDRSB */ + ASM_ARM_LDREQSB, + ASM_ARM_LDRNESB, + ASM_ARM_LDRCSSB, + ASM_ARM_LDRCCSB, + ASM_ARM_LDRMISB, + ASM_ARM_LDRPLSB, + ASM_ARM_LDRVSSB, + ASM_ARM_LDRVCSB, + ASM_ARM_LDRHISB, + ASM_ARM_LDRLSSB, + ASM_ARM_LDRGESB, + ASM_ARM_LDRLTSB, + ASM_ARM_LDRGTSB, + ASM_ARM_LDRLESB, + ASM_ARM_LDRSB, + ASM_ARM_, + + /* LDRSH */ + ASM_ARM_LDREQSH, + ASM_ARM_LDRNESH, + ASM_ARM_LDRCSSH, + ASM_ARM_LDRCCSH, + ASM_ARM_LDRMISH, + ASM_ARM_LDRPLSH, + ASM_ARM_LDRVSSH, + ASM_ARM_LDRVCSH, + ASM_ARM_LDRHISH, + ASM_ARM_LDRLSSH, + ASM_ARM_LDRGESH, + ASM_ARM_LDRLTSH, + ASM_ARM_LDRGTSH, + ASM_ARM_LDRLESH, + ASM_ARM_LDRSH, + ASM_ARM_, + }; + +/* L (1bit) | cond (4bit) | addr (2bit) */ +int arm_ldst_mult_table[128] = + { + /* STM */ + ASM_ARM_STMEQDA, + ASM_ARM_STMEQIA, + ASM_ARM_STMEQDB, + ASM_ARM_STMEQIB, + ASM_ARM_STMNEDA, + ASM_ARM_STMNEIA, + ASM_ARM_STMNEDB, + ASM_ARM_STMNEIB, + ASM_ARM_STMCSDA, + ASM_ARM_STMCSIA, + ASM_ARM_STMCSDB, + ASM_ARM_STMCSIB, + ASM_ARM_STMCCDA, + ASM_ARM_STMCCIA, + ASM_ARM_STMCCDB, + ASM_ARM_STMCCIB, + ASM_ARM_STMMIDA, + ASM_ARM_STMMIIA, + ASM_ARM_STMMIDB, + ASM_ARM_STMMIIB, + ASM_ARM_STMPLDA, + ASM_ARM_STMPLIA, + ASM_ARM_STMPLDB, + ASM_ARM_STMPLIB, + ASM_ARM_STMVSDA, + ASM_ARM_STMVSIA, + ASM_ARM_STMVSDB, + ASM_ARM_STMVSIB, + ASM_ARM_STMVCDA, + ASM_ARM_STMVCIA, + ASM_ARM_STMVCDB, + ASM_ARM_STMVCIB, + ASM_ARM_STMHIDA, + ASM_ARM_STMHIIA, + ASM_ARM_STMHIDB, + ASM_ARM_STMHIIB, + ASM_ARM_STMLSDA, + ASM_ARM_STMLSIA, + ASM_ARM_STMLSDB, + ASM_ARM_STMLSIB, + ASM_ARM_STMGEDA, + ASM_ARM_STMGEIA, + ASM_ARM_STMGEDB, + ASM_ARM_STMGEIB, + ASM_ARM_STMLTDA, + ASM_ARM_STMLTIA, + ASM_ARM_STMLTDB, + ASM_ARM_STMLTIB, + ASM_ARM_STMGTDA, + ASM_ARM_STMGTIA, + ASM_ARM_STMGTDB, + ASM_ARM_STMGTIB, + ASM_ARM_STMLEDA, + ASM_ARM_STMLEIA, + ASM_ARM_STMLEDB, + ASM_ARM_STMLEIB, + ASM_ARM_STMDA, + ASM_ARM_STMIA, + ASM_ARM_STMDB, + ASM_ARM_STMIB, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* LDM */ + ASM_ARM_LDMEQDA, + ASM_ARM_LDMEQIA, + ASM_ARM_LDMEQDB, + ASM_ARM_LDMEQIB, + ASM_ARM_LDMNEDA, + ASM_ARM_LDMNEIA, + ASM_ARM_LDMNEDB, + ASM_ARM_LDMNEIB, + ASM_ARM_LDMCSDA, + ASM_ARM_LDMCSIA, + ASM_ARM_LDMCSDB, + ASM_ARM_LDMCSIB, + ASM_ARM_LDMCCDA, + ASM_ARM_LDMCCIA, + ASM_ARM_LDMCCDB, + ASM_ARM_LDMCCIB, + ASM_ARM_LDMMIDA, + ASM_ARM_LDMMIIA, + ASM_ARM_LDMMIDB, + ASM_ARM_LDMMIIB, + ASM_ARM_LDMPLDA, + ASM_ARM_LDMPLIA, + ASM_ARM_LDMPLDB, + ASM_ARM_LDMPLIB, + ASM_ARM_LDMVSDA, + ASM_ARM_LDMVSIA, + ASM_ARM_LDMVSDB, + ASM_ARM_LDMVSIB, + ASM_ARM_LDMVCDA, + ASM_ARM_LDMVCIA, + ASM_ARM_LDMVCDB, + ASM_ARM_LDMVCIB, + ASM_ARM_LDMHIDA, + ASM_ARM_LDMHIIA, + ASM_ARM_LDMHIDB, + ASM_ARM_LDMHIIB, + ASM_ARM_LDMLSDA, + ASM_ARM_LDMLSIA, + ASM_ARM_LDMLSDB, + ASM_ARM_LDMLSIB, + ASM_ARM_LDMGEDA, + ASM_ARM_LDMGEIA, + ASM_ARM_LDMGEDB, + ASM_ARM_LDMGEIB, + ASM_ARM_LDMLTDA, + ASM_ARM_LDMLTIA, + ASM_ARM_LDMLTDB, + ASM_ARM_LDMLTIB, + ASM_ARM_LDMGTDA, + ASM_ARM_LDMGTIA, + ASM_ARM_LDMGTDB, + ASM_ARM_LDMGTIB, + ASM_ARM_LDMLEDA, + ASM_ARM_LDMLEIA, + ASM_ARM_LDMLEDB, + ASM_ARM_LDMLEIB, + ASM_ARM_LDMDA, + ASM_ARM_LDMIA, + ASM_ARM_LDMDB, + ASM_ARM_LDMIB, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_ + }; + +/* Ba (1bit) | cond (4bit) */ +int arm_swap_table[32] = + { + /* SWP */ + ASM_ARM_SWPEQ, + ASM_ARM_SWPNE, + ASM_ARM_SWPCS, + ASM_ARM_SWPCC, + ASM_ARM_SWPMI, + ASM_ARM_SWPPL, + ASM_ARM_SWPVS, + ASM_ARM_SWPVC, + ASM_ARM_SWPHI, + ASM_ARM_SWPLS, + ASM_ARM_SWPGE, + ASM_ARM_SWPLT, + ASM_ARM_SWPGT, + ASM_ARM_SWPLE, + ASM_ARM_SWP, + ASM_ARM_, + + /* SWPB */ + ASM_ARM_SWPEQB, + ASM_ARM_SWPNEB, + ASM_ARM_SWPCSB, + ASM_ARM_SWPCCB, + ASM_ARM_SWPMIB, + ASM_ARM_SWPPLB, + ASM_ARM_SWPVSB, + ASM_ARM_SWPVCB, + ASM_ARM_SWPHIB, + ASM_ARM_SWPLSB, + ASM_ARM_SWPGEB, + ASM_ARM_SWPLTB, + ASM_ARM_SWPGTB, + ASM_ARM_SWPLEB, + ASM_ARM_SWPB, + ASM_ARM_ + }; + +/* op (3bit) | cond (4bit) | S (1bit) */ +int arm_multiply_table[256] = + { + /* MUL */ + ASM_ARM_MULEQ, + ASM_ARM_MULEQS, + ASM_ARM_MULNE, + ASM_ARM_MULNES, + ASM_ARM_MULCS, + ASM_ARM_MULCSS, + ASM_ARM_MULCC, + ASM_ARM_MULCCS, + ASM_ARM_MULMI, + ASM_ARM_MULMIS, + ASM_ARM_MULPL, + ASM_ARM_MULPLS, + ASM_ARM_MULVS, + ASM_ARM_MULVSS, + ASM_ARM_MULVC, + ASM_ARM_MULVCS, + ASM_ARM_MULHI, + ASM_ARM_MULHIS, + ASM_ARM_MULLS, + ASM_ARM_MULLSS, + ASM_ARM_MULGE, + ASM_ARM_MULGES, + ASM_ARM_MULLT, + ASM_ARM_MULLTS, + ASM_ARM_MULGT, + ASM_ARM_MULGTS, + ASM_ARM_MULLE, + ASM_ARM_MULLES, + ASM_ARM_MUL, + ASM_ARM_MULS, + ASM_ARM_, + ASM_ARM_, + + /* MLA */ + ASM_ARM_MLAEQ, + ASM_ARM_MLAEQS, + ASM_ARM_MLANE, + ASM_ARM_MLANES, + ASM_ARM_MLACS, + ASM_ARM_MLACSS, + ASM_ARM_MLACC, + ASM_ARM_MLACCS, + ASM_ARM_MLAMI, + ASM_ARM_MLAMIS, + ASM_ARM_MLAPL, + ASM_ARM_MLAPLS, + ASM_ARM_MLAVS, + ASM_ARM_MLAVSS, + ASM_ARM_MLAVC, + ASM_ARM_MLAVCS, + ASM_ARM_MLAHI, + ASM_ARM_MLAHIS, + ASM_ARM_MLALS, + ASM_ARM_MLALSS, + ASM_ARM_MLAGE, + ASM_ARM_MLAGES, + ASM_ARM_MLALT, + ASM_ARM_MLALTS, + ASM_ARM_MLAGT, + ASM_ARM_MLAGTS, + ASM_ARM_MLALE, + ASM_ARM_MLALES, + ASM_ARM_MLA, + ASM_ARM_MLAS, + ASM_ARM_, + ASM_ARM_, + + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* UMULL */ + ASM_ARM_UMULLEQ, + ASM_ARM_UMULLEQS, + ASM_ARM_UMULLNE, + ASM_ARM_UMULLNES, + ASM_ARM_UMULLCS, + ASM_ARM_UMULLCSS, + ASM_ARM_UMULLCC, + ASM_ARM_UMULLCCS, + ASM_ARM_UMULLMI, + ASM_ARM_UMULLMIS, + ASM_ARM_UMULLPL, + ASM_ARM_UMULLPLS, + ASM_ARM_UMULLVS, + ASM_ARM_UMULLVSS, + ASM_ARM_UMULLVC, + ASM_ARM_UMULLVCS, + ASM_ARM_UMULLHI, + ASM_ARM_UMULLHIS, + ASM_ARM_UMULLLS, + ASM_ARM_UMULLLSS, + ASM_ARM_UMULLGE, + ASM_ARM_UMULLGES, + ASM_ARM_UMULLLT, + ASM_ARM_UMULLLTS, + ASM_ARM_UMULLGT, + ASM_ARM_UMULLGTS, + ASM_ARM_UMULLLE, + ASM_ARM_UMULLLES, + ASM_ARM_UMULL, + ASM_ARM_UMULLS, + ASM_ARM_, + ASM_ARM_, + + /* UMLAL */ + ASM_ARM_UMLALEQ, + ASM_ARM_UMLALEQS, + ASM_ARM_UMLALNE, + ASM_ARM_UMLALNES, + ASM_ARM_UMLALCS, + ASM_ARM_UMLALCSS, + ASM_ARM_UMLALCC, + ASM_ARM_UMLALCCS, + ASM_ARM_UMLALMI, + ASM_ARM_UMLALMIS, + ASM_ARM_UMLALPL, + ASM_ARM_UMLALPLS, + ASM_ARM_UMLALVS, + ASM_ARM_UMLALVSS, + ASM_ARM_UMLALVC, + ASM_ARM_UMLALVCS, + ASM_ARM_UMLALHI, + ASM_ARM_UMLALHIS, + ASM_ARM_UMLALLS, + ASM_ARM_UMLALLSS, + ASM_ARM_UMLALGE, + ASM_ARM_UMLALGES, + ASM_ARM_UMLALLT, + ASM_ARM_UMLALLTS, + ASM_ARM_UMLALGT, + ASM_ARM_UMLALGTS, + ASM_ARM_UMLALLE, + ASM_ARM_UMLALLES, + ASM_ARM_UMLAL, + ASM_ARM_UMLALS, + ASM_ARM_, + ASM_ARM_, + + /* SMULL */ + ASM_ARM_SMULLEQ, + ASM_ARM_SMULLEQS, + ASM_ARM_SMULLNE, + ASM_ARM_SMULLNES, + ASM_ARM_SMULLCS, + ASM_ARM_SMULLCSS, + ASM_ARM_SMULLCC, + ASM_ARM_SMULLCCS, + ASM_ARM_SMULLMI, + ASM_ARM_SMULLMIS, + ASM_ARM_SMULLPL, + ASM_ARM_SMULLPLS, + ASM_ARM_SMULLVS, + ASM_ARM_SMULLVSS, + ASM_ARM_SMULLVC, + ASM_ARM_SMULLVCS, + ASM_ARM_SMULLHI, + ASM_ARM_SMULLHIS, + ASM_ARM_SMULLLS, + ASM_ARM_SMULLLSS, + ASM_ARM_SMULLGE, + ASM_ARM_SMULLGES, + ASM_ARM_SMULLLT, + ASM_ARM_SMULLLTS, + ASM_ARM_SMULLGT, + ASM_ARM_SMULLGTS, + ASM_ARM_SMULLLE, + ASM_ARM_SMULLLES, + ASM_ARM_SMULL, + ASM_ARM_SMULLS, + ASM_ARM_, + ASM_ARM_, + + /* SMLAL */ + ASM_ARM_SMLALEQ, + ASM_ARM_SMLALEQS, + ASM_ARM_SMLALNE, + ASM_ARM_SMLALNES, + ASM_ARM_SMLALCS, + ASM_ARM_SMLALCSS, + ASM_ARM_SMLALCC, + ASM_ARM_SMLALCCS, + ASM_ARM_SMLALMI, + ASM_ARM_SMLALMIS, + ASM_ARM_SMLALPL, + ASM_ARM_SMLALPLS, + ASM_ARM_SMLALVS, + ASM_ARM_SMLALVSS, + ASM_ARM_SMLALVC, + ASM_ARM_SMLALVCS, + ASM_ARM_SMLALHI, + ASM_ARM_SMLALHIS, + ASM_ARM_SMLALLS, + ASM_ARM_SMLALLSS, + ASM_ARM_SMLALGE, + ASM_ARM_SMLALGES, + ASM_ARM_SMLALLT, + ASM_ARM_SMLALLTS, + ASM_ARM_SMLALGT, + ASM_ARM_SMLALGTS, + ASM_ARM_SMLALLE, + ASM_ARM_SMLALLES, + ASM_ARM_SMLAL, + ASM_ARM_SMLALS, + ASM_ARM_, + ASM_ARM_ + + }; + +/* op (3bit) | cond (4bit) | y (1bit) | x (1bit) */ +/* |_ only using 2bit */ +int arm_dsp_multiply_table[256] = + { + /* SMLAXY */ + ASM_ARM_SMLABBEQ, + ASM_ARM_SMLATBEQ, + ASM_ARM_SMLABTEQ, + ASM_ARM_SMLATTEQ, + ASM_ARM_SMLABBNE, + ASM_ARM_SMLATBNE, + ASM_ARM_SMLABTNE, + ASM_ARM_SMLATTNE, + ASM_ARM_SMLABBCS, + ASM_ARM_SMLATBCS, + ASM_ARM_SMLABTCS, + ASM_ARM_SMLATTCS, + ASM_ARM_SMLABBCC, + ASM_ARM_SMLATBCC, + ASM_ARM_SMLABTCC, + ASM_ARM_SMLATTCC, + ASM_ARM_SMLABBMI, + ASM_ARM_SMLATBMI, + ASM_ARM_SMLABTMI, + ASM_ARM_SMLATTMI, + ASM_ARM_SMLABBPL, + ASM_ARM_SMLATBPL, + ASM_ARM_SMLABTPL, + ASM_ARM_SMLATTPL, + ASM_ARM_SMLABBVS, + ASM_ARM_SMLATBVS, + ASM_ARM_SMLABTVS, + ASM_ARM_SMLATTVS, + ASM_ARM_SMLABBVC, + ASM_ARM_SMLATBVC, + ASM_ARM_SMLABTVC, + ASM_ARM_SMLATTVC, + ASM_ARM_SMLABBHI, + ASM_ARM_SMLATBHI, + ASM_ARM_SMLABTHI, + ASM_ARM_SMLATTHI, + ASM_ARM_SMLABBLS, + ASM_ARM_SMLATBLS, + ASM_ARM_SMLABTLS, + ASM_ARM_SMLATTLS, + ASM_ARM_SMLABBGE, + ASM_ARM_SMLATBGE, + ASM_ARM_SMLABTGE, + ASM_ARM_SMLATTGE, + ASM_ARM_SMLABBLT, + ASM_ARM_SMLATBLT, + ASM_ARM_SMLABTLT, + ASM_ARM_SMLATTLT, + ASM_ARM_SMLABBGT, + ASM_ARM_SMLATBGT, + ASM_ARM_SMLABTGT, + ASM_ARM_SMLATTGT, + ASM_ARM_SMLABBLE, + ASM_ARM_SMLATBLE, + ASM_ARM_SMLABTLE, + ASM_ARM_SMLATTLE, + ASM_ARM_SMLABB, + ASM_ARM_SMLATB, + ASM_ARM_SMLABT, + ASM_ARM_SMLATT, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* SMLAWY & SMULWY */ + ASM_ARM_SMLAWBEQ, + ASM_ARM_SMULWBEQ, + ASM_ARM_SMLAWTEQ, + ASM_ARM_SMULWTEQ, + ASM_ARM_SMLAWBNE, + ASM_ARM_SMULWBNE, + ASM_ARM_SMLAWTNE, + ASM_ARM_SMULWTNE, + ASM_ARM_SMLAWBCS, + ASM_ARM_SMULWBCS, + ASM_ARM_SMLAWTCS, + ASM_ARM_SMULWTCS, + ASM_ARM_SMLAWBCC, + ASM_ARM_SMULWBCC, + ASM_ARM_SMLAWTCC, + ASM_ARM_SMULWTCC, + ASM_ARM_SMLAWBMI, + ASM_ARM_SMULWBMI, + ASM_ARM_SMLAWTMI, + ASM_ARM_SMULWTMI, + ASM_ARM_SMLAWBPL, + ASM_ARM_SMULWBPL, + ASM_ARM_SMLAWTPL, + ASM_ARM_SMULWTPL, + ASM_ARM_SMLAWBVS, + ASM_ARM_SMULWBVS, + ASM_ARM_SMLAWTVS, + ASM_ARM_SMULWTVS, + ASM_ARM_SMLAWBVC, + ASM_ARM_SMULWBVC, + ASM_ARM_SMLAWTVC, + ASM_ARM_SMULWTVC, + ASM_ARM_SMLAWBHI, + ASM_ARM_SMULWBHI, + ASM_ARM_SMLAWTHI, + ASM_ARM_SMULWTHI, + ASM_ARM_SMLAWBLS, + ASM_ARM_SMULWBLS, + ASM_ARM_SMLAWTLS, + ASM_ARM_SMULWTLS, + ASM_ARM_SMLAWBGE, + ASM_ARM_SMULWBGE, + ASM_ARM_SMLAWTGE, + ASM_ARM_SMULWTGE, + ASM_ARM_SMLAWBLT, + ASM_ARM_SMULWBLT, + ASM_ARM_SMLAWTLT, + ASM_ARM_SMULWTLT, + ASM_ARM_SMLAWBGT, + ASM_ARM_SMULWBGT, + ASM_ARM_SMLAWTGT, + ASM_ARM_SMULWTGT, + ASM_ARM_SMLAWBLE, + ASM_ARM_SMULWBLE, + ASM_ARM_SMLAWTLE, + ASM_ARM_SMULWTLE, + ASM_ARM_SMLAWB, + ASM_ARM_SMULWB, + ASM_ARM_SMLAWT, + ASM_ARM_SMULWT, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* SMLALXY */ + ASM_ARM_SMLALBBEQ, + ASM_ARM_SMLALTBEQ, + ASM_ARM_SMLALBTEQ, + ASM_ARM_SMLALTTEQ, + ASM_ARM_SMLALBBNE, + ASM_ARM_SMLALTBNE, + ASM_ARM_SMLALBTNE, + ASM_ARM_SMLALTTNE, + ASM_ARM_SMLALBBCS, + ASM_ARM_SMLALTBCS, + ASM_ARM_SMLALBTCS, + ASM_ARM_SMLALTTCS, + ASM_ARM_SMLALBBCC, + ASM_ARM_SMLALTBCC, + ASM_ARM_SMLALBTCC, + ASM_ARM_SMLALTTCC, + ASM_ARM_SMLALBBMI, + ASM_ARM_SMLALTBMI, + ASM_ARM_SMLALBTMI, + ASM_ARM_SMLALTTMI, + ASM_ARM_SMLALBBPL, + ASM_ARM_SMLALTBPL, + ASM_ARM_SMLALBTPL, + ASM_ARM_SMLALTTPL, + ASM_ARM_SMLALBBVS, + ASM_ARM_SMLALTBVS, + ASM_ARM_SMLALBTVS, + ASM_ARM_SMLALTTVS, + ASM_ARM_SMLALBBVC, + ASM_ARM_SMLALTBVC, + ASM_ARM_SMLALBTVC, + ASM_ARM_SMLALTTVC, + ASM_ARM_SMLALBBHI, + ASM_ARM_SMLALTBHI, + ASM_ARM_SMLALBTHI, + ASM_ARM_SMLALTTHI, + ASM_ARM_SMLALBBLS, + ASM_ARM_SMLALTBLS, + ASM_ARM_SMLALBTLS, + ASM_ARM_SMLALTTLS, + ASM_ARM_SMLALBBGE, + ASM_ARM_SMLALTBGE, + ASM_ARM_SMLALBTGE, + ASM_ARM_SMLALTTGE, + ASM_ARM_SMLALBBLT, + ASM_ARM_SMLALTBLT, + ASM_ARM_SMLALBTLT, + ASM_ARM_SMLALTTLT, + ASM_ARM_SMLALBBGT, + ASM_ARM_SMLALTBGT, + ASM_ARM_SMLALBTGT, + ASM_ARM_SMLALTTGT, + ASM_ARM_SMLALBBLE, + ASM_ARM_SMLALTBLE, + ASM_ARM_SMLALBTLE, + ASM_ARM_SMLALTTLE, + ASM_ARM_SMLALBB, + ASM_ARM_SMLALTB, + ASM_ARM_SMLALBT, + ASM_ARM_SMLALTT, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + /* SMULXY */ + ASM_ARM_SMULBBEQ, + ASM_ARM_SMULTBEQ, + ASM_ARM_SMULBTEQ, + ASM_ARM_SMULTTEQ, + ASM_ARM_SMULBBNE, + ASM_ARM_SMULTBNE, + ASM_ARM_SMULBTNE, + ASM_ARM_SMULTTNE, + ASM_ARM_SMULBBCS, + ASM_ARM_SMULTBCS, + ASM_ARM_SMULBTCS, + ASM_ARM_SMULTTCS, + ASM_ARM_SMULBBCC, + ASM_ARM_SMULTBCC, + ASM_ARM_SMULBTCC, + ASM_ARM_SMULTTCC, + ASM_ARM_SMULBBMI, + ASM_ARM_SMULTBMI, + ASM_ARM_SMULBTMI, + ASM_ARM_SMULTTMI, + ASM_ARM_SMULBBPL, + ASM_ARM_SMULTBPL, + ASM_ARM_SMULBTPL, + ASM_ARM_SMULTTPL, + ASM_ARM_SMULBBVS, + ASM_ARM_SMULTBVS, + ASM_ARM_SMULBTVS, + ASM_ARM_SMULTTVS, + ASM_ARM_SMULBBVC, + ASM_ARM_SMULTBVC, + ASM_ARM_SMULBTVC, + ASM_ARM_SMULTTVC, + ASM_ARM_SMULBBHI, + ASM_ARM_SMULTBHI, + ASM_ARM_SMULBTHI, + ASM_ARM_SMULTTHI, + ASM_ARM_SMULBBLS, + ASM_ARM_SMULTBLS, + ASM_ARM_SMULBTLS, + ASM_ARM_SMULTTLS, + ASM_ARM_SMULBBGE, + ASM_ARM_SMULTBGE, + ASM_ARM_SMULBTGE, + ASM_ARM_SMULTTGE, + ASM_ARM_SMULBBLT, + ASM_ARM_SMULTBLT, + ASM_ARM_SMULBTLT, + ASM_ARM_SMULTTLT, + ASM_ARM_SMULBBGT, + ASM_ARM_SMULTBGT, + ASM_ARM_SMULBTGT, + ASM_ARM_SMULTTGT, + ASM_ARM_SMULBBLE, + ASM_ARM_SMULTBLE, + ASM_ARM_SMULBTLE, + ASM_ARM_SMULTTLE, + ASM_ARM_SMULBB, + ASM_ARM_SMULTB, + ASM_ARM_SMULBT, + ASM_ARM_SMULTT, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + ASM_ARM_, + + }; + +/* op (3bit) | cond (4bit) */ +/* |_ only using 2bit */ +int arm_dsp_arith_table[64] = + { + /* QADD */ + ASM_ARM_QADDEQ, + ASM_ARM_QADDNE, + ASM_ARM_QADDCS, + ASM_ARM_QADDCC, + ASM_ARM_QADDMI, + ASM_ARM_QADDPL, + ASM_ARM_QADDVS, + ASM_ARM_QADDVC, + ASM_ARM_QADDHI, + ASM_ARM_QADDLS, + ASM_ARM_QADDGE, + ASM_ARM_QADDLT, + ASM_ARM_QADDGT, + ASM_ARM_QADDLE, + ASM_ARM_QADD, + ASM_ARM_, + + /* QSUB */ + ASM_ARM_QSUBEQ, + ASM_ARM_QSUBNE, + ASM_ARM_QSUBCS, + ASM_ARM_QSUBCC, + ASM_ARM_QSUBMI, + ASM_ARM_QSUBPL, + ASM_ARM_QSUBVS, + ASM_ARM_QSUBVC, + ASM_ARM_QSUBHI, + ASM_ARM_QSUBLS, + ASM_ARM_QSUBGE, + ASM_ARM_QSUBLT, + ASM_ARM_QSUBGT, + ASM_ARM_QSUBLE, + ASM_ARM_QSUB, + ASM_ARM_, + + /* QDADD */ + ASM_ARM_QDADDEQ, + ASM_ARM_QDADDNE, + ASM_ARM_QDADDCS, + ASM_ARM_QDADDCC, + ASM_ARM_QDADDMI, + ASM_ARM_QDADDPL, + ASM_ARM_QDADDVS, + ASM_ARM_QDADDVC, + ASM_ARM_QDADDHI, + ASM_ARM_QDADDLS, + ASM_ARM_QDADDGE, + ASM_ARM_QDADDLT, + ASM_ARM_QDADDGT, + ASM_ARM_QDADDLE, + ASM_ARM_QDADD, + ASM_ARM_, + + /* QDSUB */ + ASM_ARM_QDSUBEQ, + ASM_ARM_QDSUBNE, + ASM_ARM_QDSUBCS, + ASM_ARM_QDSUBCC, + ASM_ARM_QDSUBMI, + ASM_ARM_QDSUBPL, + ASM_ARM_QDSUBVS, + ASM_ARM_QDSUBVC, + ASM_ARM_QDSUBHI, + ASM_ARM_QDSUBLS, + ASM_ARM_QDSUBGE, + ASM_ARM_QDSUBLT, + ASM_ARM_QDSUBGT, + ASM_ARM_QDSUBLE, + ASM_ARM_QDSUB, + ASM_ARM_, + + }; + +/* l_h (1bit) | cond (4bit) */ +int arm_branch1_table[32] = + { + /* B */ + ASM_ARM_BEQ, + ASM_ARM_BNE, + ASM_ARM_BCS, + ASM_ARM_BCC, + ASM_ARM_BMI, + ASM_ARM_BPL, + ASM_ARM_BVS, + ASM_ARM_BVC, + ASM_ARM_BHI, + ASM_ARM_BLS, + ASM_ARM_BGE, + ASM_ARM_BLT, + ASM_ARM_BGT, + ASM_ARM_BLE, + ASM_ARM_B, + ASM_ARM_BLX1, + + /* BL */ + ASM_ARM_BLEQ, + ASM_ARM_BLNE, + ASM_ARM_BLCS, + ASM_ARM_BLCC, + ASM_ARM_BLMI, + ASM_ARM_BLPL, + ASM_ARM_BLVS, + ASM_ARM_BLVC, + ASM_ARM_BLHI, + ASM_ARM_BLLS, + ASM_ARM_BLGE, + ASM_ARM_BLLT, + ASM_ARM_BLGT, + ASM_ARM_BLLE, + ASM_ARM_BL, + ASM_ARM_BLX1 + }; + +/* op (1bit) | cond (4bit) */ +int arm_branch2_table[32] = + { + /* BX */ + ASM_ARM_BXEQ, + ASM_ARM_BXNE, + ASM_ARM_BXCS, + ASM_ARM_BXCC, + ASM_ARM_BXMI, + ASM_ARM_BXPL, + ASM_ARM_BXVS, + ASM_ARM_BXVC, + ASM_ARM_BXHI, + ASM_ARM_BXLS, + ASM_ARM_BXGE, + ASM_ARM_BXLT, + ASM_ARM_BXGT, + ASM_ARM_BXLE, + ASM_ARM_BX, + ASM_ARM_, + + /* BLX(2) */ + ASM_ARM_BLX2EQ, + ASM_ARM_BLX2NE, + ASM_ARM_BLX2CS, + ASM_ARM_BLX2CC, + ASM_ARM_BLX2MI, + ASM_ARM_BLX2PL, + ASM_ARM_BLX2VS, + ASM_ARM_BLX2VC, + ASM_ARM_BLX2HI, + ASM_ARM_BLX2LS, + ASM_ARM_BLX2GE, + ASM_ARM_BLX2LT, + ASM_ARM_BLX2GT, + ASM_ARM_BLX2LE, + ASM_ARM_BLX2, + ASM_ARM_ + }; + +/* cond (4bit) */ +int arm_coproc_dataproc_table[16] = + { + ASM_ARM_CDPEQ, + ASM_ARM_CDPNE, + ASM_ARM_CDPCS, + ASM_ARM_CDPCC, + ASM_ARM_CDPMI, + ASM_ARM_CDPPL, + ASM_ARM_CDPVS, + ASM_ARM_CDPVC, + ASM_ARM_CDPHI, + ASM_ARM_CDPLS, + ASM_ARM_CDPGE, + ASM_ARM_CDPLT, + ASM_ARM_CDPGT, + ASM_ARM_CDPLE, + ASM_ARM_CDP, + ASM_ARM_CDP2 + }; + +/* toarm (1bit) | cond (4bit) */ +int arm_coproc_mov_table[32] = + { + /* MCR/MCR2 */ + ASM_ARM_MCREQ, + ASM_ARM_MCRNE, + ASM_ARM_MCRCS, + ASM_ARM_MCRCC, + ASM_ARM_MCRMI, + ASM_ARM_MCRPL, + ASM_ARM_MCRVS, + ASM_ARM_MCRVC, + ASM_ARM_MCRHI, + ASM_ARM_MCRLS, + ASM_ARM_MCRGE, + ASM_ARM_MCRLT, + ASM_ARM_MCRGT, + ASM_ARM_MCRLE, + ASM_ARM_MCR, + ASM_ARM_MCR2, + + /* MRC/MRC2 */ + ASM_ARM_MRCEQ, + ASM_ARM_MRCNE, + ASM_ARM_MRCCS, + ASM_ARM_MRCCC, + ASM_ARM_MRCMI, + ASM_ARM_MRCPL, + ASM_ARM_MRCVS, + ASM_ARM_MRCVC, + ASM_ARM_MRCHI, + ASM_ARM_MRCLS, + ASM_ARM_MRCGE, + ASM_ARM_MRCLT, + ASM_ARM_MRCGT, + ASM_ARM_MRCLE, + ASM_ARM_MRC, + ASM_ARM_MRC2 + }; + +/* toarm (1bit) | cond (4bit) */ +int arm_coproc_mov2_table[32] = + { + /* MCRR */ + ASM_ARM_MCRREQ, + ASM_ARM_MCRRNE, + ASM_ARM_MCRRCS, + ASM_ARM_MCRRCC, + ASM_ARM_MCRRMI, + ASM_ARM_MCRRPL, + ASM_ARM_MCRRVS, + ASM_ARM_MCRRVC, + ASM_ARM_MCRRHI, + ASM_ARM_MCRRLS, + ASM_ARM_MCRRGE, + ASM_ARM_MCRRLT, + ASM_ARM_MCRRGT, + ASM_ARM_MCRRLE, + ASM_ARM_MCRR, + ASM_ARM_, + + /* MRRC */ + ASM_ARM_MRRCEQ, + ASM_ARM_MRRCNE, + ASM_ARM_MRRCCS, + ASM_ARM_MRRCCC, + ASM_ARM_MRRCMI, + ASM_ARM_MRRCPL, + ASM_ARM_MRRCVS, + ASM_ARM_MRRCVC, + ASM_ARM_MRRCHI, + ASM_ARM_MRRCLS, + ASM_ARM_MRRCGE, + ASM_ARM_MRRCLT, + ASM_ARM_MRRCGT, + ASM_ARM_MRRCLE, + ASM_ARM_MRRC, + ASM_ARM_ + }; + +/* load/store (1bit) | cond (4bit) | long (1bit) */ +int arm_coproc_ldst_table[64] = + { + /* STC/STC2 */ + ASM_ARM_STCEQ, + ASM_ARM_STCEQL, + ASM_ARM_STCNE, + ASM_ARM_STCNEL, + ASM_ARM_STCCS, + ASM_ARM_STCCSL, + ASM_ARM_STCCC, + ASM_ARM_STCCCL, + ASM_ARM_STCMI, + ASM_ARM_STCMIL, + ASM_ARM_STCPL, + ASM_ARM_STCPLL, + ASM_ARM_STCVS, + ASM_ARM_STCVSL, + ASM_ARM_STCVC, + ASM_ARM_STCVCL, + ASM_ARM_STCHI, + ASM_ARM_STCHIL, + ASM_ARM_STCLS, + ASM_ARM_STCLSL, + ASM_ARM_STCGE, + ASM_ARM_STCGEL, + ASM_ARM_STCLT, + ASM_ARM_STCLTL, + ASM_ARM_STCGT, + ASM_ARM_STCGTL, + ASM_ARM_STCLE, + ASM_ARM_STCLEL, + ASM_ARM_STC, + ASM_ARM_STCL, + ASM_ARM_STC2, + ASM_ARM_STC2L, + + /* LDC/LDC2 */ + ASM_ARM_LDCEQ, + ASM_ARM_LDCEQL, + ASM_ARM_LDCNE, + ASM_ARM_LDCNEL, + ASM_ARM_LDCCS, + ASM_ARM_LDCCSL, + ASM_ARM_LDCCC, + ASM_ARM_LDCCCL, + ASM_ARM_LDCMI, + ASM_ARM_LDCMIL, + ASM_ARM_LDCPL, + ASM_ARM_LDCPLL, + ASM_ARM_LDCVS, + ASM_ARM_LDCVSL, + ASM_ARM_LDCVC, + ASM_ARM_LDCVCL, + ASM_ARM_LDCHI, + ASM_ARM_LDCHIL, + ASM_ARM_LDCLS, + ASM_ARM_LDCLSL, + ASM_ARM_LDCGE, + ASM_ARM_LDCGEL, + ASM_ARM_LDCLT, + ASM_ARM_LDCLTL, + ASM_ARM_LDCGT, + ASM_ARM_LDCGTL, + ASM_ARM_LDCLE, + ASM_ARM_LDCLEL, + ASM_ARM_LDC, + ASM_ARM_LDCL, + ASM_ARM_LDC2, + ASM_ARM_LDC2L + }; + +char *arm_instr_list[ASM_ARM_BAD + 1] = + { + "(unimpl)", + + /* ADC */ + "adceq", + "adceqs", + "adcne", + "adcnes", + "adccs", + "adccss", + "adccc", + "adcccs", + "adcmi", + "adcmis", + "adcpl", + "adcpls", + "adcvs", + "adcvss", + "adcvc", + "adcvcs", + "adchi", + "adchis", + "adcls", + "adclss", + "adcge", + "adcges", + "adclt", + "adclts", + "adcgt", + "adcgts", + "adcle", + "adcles", + "adc", + "adcs", + + /* ADD */ + "addeq", + "addeqs", + "addne", + "addnes", + "addcs", + "addcss", + "addcc", + "addccs", + "addmi", + "addmis", + "addpl", + "addpls", + "addvs", + "addvss", + "addvc", + "addvcs", + "addhi", + "addhis", + "addls", + "addlss", + "addge", + "addges", + "addlt", + "addlts", + "addgt", + "addgts", + "addle", + "addles", + "add", + "adds", + + /* AND */ + "andeq", + "andeqs", + "andne", + "andnes", + "andcs", + "andcss", + "andcc", + "andccs", + "andmi", + "andmis", + "andpl", + "andpls", + "andvs", + "andvss", + "andvc", + "andvcs", + "andhi", + "andhis", + "andls", + "andlss", + "andge", + "andges", + "andlt", + "andlts", + "andgt", + "andgts", + "andle", + "andles", + "and", + "ands", + + /* B */ + "beq", + "bne", + "bcs", + "bcc", + "bmi", + "bpl", + "bvs", + "bvc", + "bhi", + "bls", + "bge", + "blt", + "bgt", + "ble", + "b", + + /* BIC */ + "biceq", + "biceqs", + "bicne", + "bicnes", + "biccs", + "biccss", + "biccc", + "bicccs", + "bicmi", + "bicmis", + "bicpl", + "bicpls", + "bicvs", + "bicvss", + "bicvc", + "bicvcs", + "bichi", + "bichis", + "bicls", + "biclss", + "bicge", + "bicges", + "biclt", + "biclts", + "bicgt", + "bicgts", + "bicle", + "bicles", + "bic", + "bics", + + /* BKPT */ + "bkpt", + + /* BL */ + "bleq", + "blne", + "blcs", + "blcc", + "blmi", + "blpl", + "blvs", + "blvc", + "blhi", + "blls", + "blge", + "bllt", + "blgt", + "blle", + "bl", + + /* BLX(1) */ + "blx", + + /* BLX(2) */ + "blxeq", + "blxne", + "blxcs", + "blxcc", + "blxmi", + "blxpl", + "blxvs", + "blxvc", + "blxhi", + "blxls", + "blxge", + "blxlt", + "blxgt", + "blxle", + "blx", + + /* BX */ + "bxeq", + "bxne", + "bxcs", + "bxcc", + "bxmi", + "bxpl", + "bxvs", + "bxvc", + "bxhi", + "bxls", + "bxge", + "bxlt", + "bxgt", + "bxle", + "bx", + + /* CDP/CDP2 */ + "cdpeq", + "cdpne", + "cdpcs", + "cdpcc", + "cdpmi", + "cdppl", + "cdpvs", + "cdpvc", + "cdphi", + "cdpls", + "cdpge", + "cdplt", + "cdpgt", + "cdple", + "cdp", + "cdp2", + + /* CLZ */ + "clzeq", + "clzne", + "clzcs", + "clzcc", + "clzmi", + "clzpl", + "clzvs", + "clzvc", + "clzhi", + "clzls", + "clzge", + "clzlt", + "clzgt", + "clzle", + "clz", + + /* CMN */ + "cmneq", + "cmnne", + "cmncs", + "cmncc", + "cmnmi", + "cmnpl", + "cmnvs", + "cmnvc", + "cmnhi", + "cmnls", + "cmnge", + "cmnlt", + "cmngt", + "cmnle", + "cmn", + + /* CMP */ + "cmpeq", + "cmpne", + "cmpcs", + "cmpcc", + "cmpmi", + "cmppl", + "cmpvs", + "cmpvc", + "cmphi", + "cmpls", + "cmpge", + "cmplt", + "cmpgt", + "cmple", + "cmp", + + /* EOR */ + "eoreq", + "eoreqs", + "eorne", + "eornes", + "eorcs", + "eorcss", + "eorcc", + "eorccs", + "eormi", + "eormis", + "eorpl", + "eorpls", + "eorvs", + "eorvss", + "eorvc", + "eorvcs", + "eorhi", + "eorhis", + "eorls", + "eorlss", + "eorge", + "eorges", + "eorlt", + "eorlts", + "eorgt", + "eorgts", + "eorle", + "eorles", + "eor", + "eors", + + /* LDC/LDC2 */ + "ldceq", + "ldceql", + "ldcne", + "ldcnel", + "ldccs", + "ldccsl", + "ldccc", + "ldcccl", + "ldcmi", + "ldcmil", + "ldcpl", + "ldcpll", + "ldcvs", + "ldcvsl", + "ldcvc", + "ldcvcl", + "ldchi", + "ldchil", + "ldcls", + "ldclsl", + "ldcge", + "ldcgel", + "ldclt", + "ldcltl", + "ldcgt", + "ldcgtl", + "ldcle", + "ldclel", + "ldc", + "ldcl", + "ldc2", + "ldc2l", + + /* LDM */ + "ldmeqia", + "ldmeqib", + "ldmeqda", + "ldmeqdb", + "ldmneia", + "ldmneib", + "ldmneda", + "ldmnedb", + "ldmcsia", + "ldmcsib", + "ldmcsda", + "ldmcsdb", + "ldmccia", + "ldmccib", + "ldmccda", + "ldmccdb", + "ldmmiia", + "ldmmiib", + "ldmmida", + "ldmmidb", + "ldmplia", + "ldmplib", + "ldmplda", + "ldmpldb", + "ldmvsia", + "ldmvsib", + "ldmvsda", + "ldmvsdb", + "ldmvcia", + "ldmvcib", + "ldmvcda", + "ldmvcdb", + "ldmhiia", + "ldmhiib", + "ldmhida", + "ldmhidb", + "ldmlsia", + "ldmlsib", + "ldmlsda", + "ldmlsdb", + "ldmgeia", + "ldmgeib", + "ldmgeda", + "ldmgedb", + "ldmltia", + "ldmltib", + "ldmltda", + "ldmltdb", + "ldmgtia", + "ldmgtib", + "ldmgtda", + "ldmgtdb", + "ldmleia", + "ldmleib", + "ldmleda", + "ldmledb", + "ldmia", + "ldmib", + "ldmda", + "ldmdb", + + /* LDR */ + "ldreq", + "ldrne", + "ldrcs", + "ldrcc", + "ldrmi", + "ldrpl", + "ldrvs", + "ldrvc", + "ldrhi", + "ldrls", + "ldrge", + "ldrlt", + "ldrgt", + "ldrle", + "ldr", + + /* LDRB */ + "ldreqb", + "ldrneb", + "ldrcsb", + "ldrccb", + "ldrmib", + "ldrplb", + "ldrvsb", + "ldrvcb", + "ldrhib", + "ldrlsb", + "ldrgeb", + "ldrltb", + "ldrgtb", + "ldrleb", + "ldrb", + + /* LDRBT */ + "ldreqbt", + "ldrnebt", + "ldrcsbt", + "ldrccbt", + "ldrmibt", + "ldrplbt", + "ldrvsbt", + "ldrvcbt", + "ldrhibt", + "ldrlsbt", + "ldrgebt", + "ldrltbt", + "ldrgtbt", + "ldrlebt", + "ldrbt", + + /* LDRD */ + "ldreqd", + "ldrned", + "ldrcsd", + "ldrccd", + "ldrmid", + "ldrpld", + "ldrvsd", + "ldrvcd", + "ldrhid", + "ldrlsd", + "ldrged", + "ldrltd", + "ldrgtd", + "ldrled", + "ldrd", + + /* LDRH */ + "ldreqh", + "ldrneh", + "ldrcsh", + "ldrcch", + "ldrmih", + "ldrplh", + "ldrvsh", + "ldrvch", + "ldrhih", + "ldrlsh", + "ldrgeh", + "ldrlth", + "ldrgth", + "ldrleh", + "ldrh", + + /* LDRSB */ + "ldreqsb", + "ldrnesb", + "ldrcssb", + "ldrccsb", + "ldrmisb", + "ldrplsb", + "ldrvssb", + "ldrvcsb", + "ldrhisb", + "ldrlssb", + "ldrgesb", + "ldrltsb", + "ldrgtsb", + "ldrlesb", + "ldrsb", + + /* LDRSH */ + "ldreqsh", + "ldrnesh", + "ldrcssh", + "ldrccsh", + "ldrmish", + "ldrplsh", + "ldrvssh", + "ldrvcsh", + "ldrhish", + "ldrlssh", + "ldrgesh", + "ldrltsh", + "ldrgtsh", + "ldrlesh", + "ldrsh", + + /* LDRT */ + "ldreqt", + "ldrnet", + "ldrcst", + "ldrcct", + "ldrmit", + "ldrplt", + "ldrvst", + "ldrvct", + "ldrhit", + "ldrlst", + "ldrget", + "ldrltt", + "ldrgtt", + "ldrlet", + "ldrt", + + /* MCR/MCR2 */ + "mcreq", + "mcrne", + "mcrcs", + "mcrcc", + "mcrmi", + "mcrpl", + "mcrvs", + "mcrvc", + "mcrhi", + "mcrls", + "mcrge", + "mcrlt", + "mcrgt", + "mcrle", + "mcr", + "mcr2", + + /* MCRR */ + "mcrreq", + "mcrrne", + "mcrrcs", + "mcrrcc", + "mcrrmi", + "mcrrpl", + "mcrrvs", + "mcrrvc", + "mcrrhi", + "mcrrls", + "mcrrge", + "mcrrlt", + "mcrrgt", + "mcrrle", + "mcrr", + + /* MLA */ + "mlaeq", + "mlaeqs", + "mlane", + "mlanes", + "mlacs", + "mlacss", + "mlacc", + "mlaccs", + "mlami", + "mlamis", + "mlapl", + "mlapls", + "mlavs", + "mlavss", + "mlavc", + "mlavcs", + "mlahi", + "mlahis", + "mlals", + "mlalss", + "mlage", + "mlages", + "mlalt", + "mlalts", + "mlagt", + "mlagts", + "mlale", + "mlales", + "mla", + "mlas", + + /* MOV */ + "moveq", + "moveqs", + "movne", + "movnes", + "movcs", + "movcss", + "movcc", + "movccs", + "movmi", + "movmis", + "movpl", + "movpls", + "movvs", + "movvss", + "movvc", + "movvcs", + "movhi", + "movhis", + "movls", + "movlss", + "movge", + "movges", + "movlt", + "movlts", + "movgt", + "movgts", + "movle", + "movles", + "mov", + "movs", + + /* MRC/MRC2 */ + "mrceq", + "mrcne", + "mrccs", + "mrccc", + "mrcmi", + "mrcpl", + "mrcvs", + "mrcvc", + "mrchi", + "mrcls", + "mrcge", + "mrclt", + "mrcgt", + "mrcle", + "mrc", + "mrc2", + + /* MRRC */ + "mrrceq", + "mrrcne", + "mrrccs", + "mrrccc", + "mrrcmi", + "mrrcpl", + "mrrcvs", + "mrrcvc", + "mrrchi", + "mrrcls", + "mrrcge", + "mrrclt", + "mrrcgt", + "mrrcle", + "mrrc", + + /* MRS */ + "mrseq", + "mrsne", + "mrscs", + "mrscc", + "mrsmi", + "mrspl", + "mrsvs", + "mrsvc", + "mrshi", + "mrsls", + "mrsge", + "mrslt", + "mrsgt", + "mrsle", + "mrs", + + /* MSR */ + "msreq", + "msrne", + "msrcs", + "msrcc", + "msrmi", + "msrpl", + "msrvs", + "msrvc", + "msrhi", + "msrls", + "msrge", + "msrlt", + "msrgt", + "msrle", + "msr", + + /* MUL */ + "muleq", + "muleqs", + "mulne", + "mulnes", + "mulcs", + "mulcss", + "mulcc", + "mulccs", + "mulmi", + "mulmis", + "mulpl", + "mulpls", + "mulvs", + "mulvss", + "mulvc", + "mulvcs", + "mulhi", + "mulhis", + "mulls", + "mullss", + "mulge", + "mulges", + "mullt", + "mullts", + "mulgt", + "mulgts", + "mulle", + "mulles", + "mul", + "muls", + + /* MVN */ + "mvneq", + "mvneqs", + "mvnne", + "mvnnes", + "mvncs", + "mvncss", + "mvncc", + "mvnccs", + "mvnmi", + "mvnmis", + "mvnpl", + "mvnpls", + "mvnvs", + "mvnvss", + "mvnvc", + "mvnvcs", + "mvnhi", + "mvnhis", + "mvnls", + "mvnlss", + "mvnge", + "mvnges", + "mvnlt", + "mvnlts", + "mvngt", + "mvngts", + "mvnle", + "mvnles", + "mvn", + "mvns", + + /* ORR */ + "orreq", + "orreqs", + "orrne", + "orrnes", + "orrcs", + "orrcss", + "orrcc", + "orrccs", + "orrmi", + "orrmis", + "orrpl", + "orrpls", + "orrvs", + "orrvss", + "orrvc", + "orrvcs", + "orrhi", + "orrhis", + "orrls", + "orrlss", + "orrge", + "orrges", + "orrlt", + "orrlts", + "orrgt", + "orrgts", + "orrle", + "orrles", + "orr", + "orrs", + + /* PLD */ + "pld", + + /* QADD */ + "qaddeq", + "qaddne", + "qaddcs", + "qaddcc", + "qaddmi", + "qaddpl", + "qaddvs", + "qaddvc", + "qaddhi", + "qaddls", + "qaddge", + "qaddlt", + "qaddgt", + "qaddle", + "qadd", + + /* QDADD */ + "qdaddeq", + "qdaddne", + "qdaddcs", + "qdaddcc", + "qdaddmi", + "qdaddpl", + "qdaddvs", + "qdaddvc", + "qdaddhi", + "qdaddls", + "qdaddge", + "qdaddlt", + "qdaddgt", + "qdaddle", + "qdadd", + + /* QDSUB */ + "qdsubeq", + "qdsubne", + "qdsubcs", + "qdsubcc", + "qdsubmi", + "qdsubpl", + "qdsubvs", + "qdsubvc", + "qdsubhi", + "qdsubls", + "qdsubge", + "qdsublt", + "qdsubgt", + "qdsuble", + "qdsub", + + /* QSUB */ + "qsubeq", + "qsubne", + "qsubcs", + "qsubcc", + "qsubmi", + "qsubpl", + "qsubvs", + "qsubvc", + "qsubhi", + "qsubls", + "qsubge", + "qsublt", + "qsubgt", + "qsuble", + "qsub", + + /* RSB */ + "rsbeq", + "rsbeqs", + "rsbne", + "rsbnes", + "rsbcs", + "rsbcss", + "rsbcc", + "rsbccs", + "rsbmi", + "rsbmis", + "rsbpl", + "rsbpls", + "rsbvs", + "rsbvss", + "rsbvc", + "rsbvcs", + "rsbhi", + "rsbhis", + "rsbls", + "rsblss", + "rsbge", + "rsbges", + "rsblt", + "rsblts", + "rsbgt", + "rsbgts", + "rsble", + "rsbles", + "rsb", + "rsbs", + + /* RSC */ + "rsceq", + "rsceqs", + "rscne", + "rscnes", + "rsccs", + "rsccss", + "rsccc", + "rscccs", + "rscmi", + "rscmis", + "rscpl", + "rscpls", + "rscvs", + "rscvss", + "rscvc", + "rscvcs", + "rschi", + "rschis", + "rscls", + "rsclss", + "rscge", + "rscges", + "rsclt", + "rsclts", + "rscgt", + "rscgts", + "rscle", + "rscles", + "rsc", + "rscs", + + /* SBC */ + "sbceq", + "sbceqs", + "sbcne", + "sbcnes", + "sbccs", + "sbccss", + "sbccc", + "sbcccs", + "sbcmi", + "sbcmis", + "sbcpl", + "sbcpls", + "sbcvs", + "sbcvss", + "sbcvc", + "sbcvcs", + "sbchi", + "sbchis", + "sbcls", + "sbclss", + "sbcge", + "sbcges", + "sbclt", + "sbclts", + "sbcgt", + "sbcgts", + "sbcle", + "sbcles", + "sbc", + "sbcs", + + /* SMLAL */ + "smlaleq", + "smlaleqs", + "smlalne", + "smlalnes", + "smlalcs", + "smlalcss", + "smlalcc", + "smlalccs", + "smlalmi", + "smlalmis", + "smlalpl", + "smlalpls", + "smlalvs", + "smlalvss", + "smlalvc", + "smlalvcs", + "smlalhi", + "smlalhis", + "smlalls", + "smlallss", + "smlalge", + "smlalges", + "smlallt", + "smlallts", + "smlalgt", + "smlalgts", + "smlalle", + "smlalles", + "smlal", + "smlals", + + /* SMLALXY */ + "smlalbbeq", + "smlaltbeq", + "smlalbteq", + "smlaltteq", + "smlalbbne", + "smlaltbne", + "smlalbtne", + "smlalttne", + "smlalbbcs", + "smlaltbcs", + "smlalbtcs", + "smlalttcs", + "smlalbbcc", + "smlaltbcc", + "smlalbtcc", + "smlalttcc", + "smlalbbmi", + "smlaltbmi", + "smlalbtmi", + "smlalttmi", + "smlalbbpl", + "smlaltbpl", + "smlalbtpl", + "smlalttpl", + "smlalbbvs", + "smlaltbvs", + "smlalbtvs", + "smlalttvs", + "smlalbbvc", + "smlaltbvc", + "smlalbtvc", + "smlalttvc", + "smlalbbhi", + "smlaltbhi", + "smlalbthi", + "smlaltthi", + "smlalbbls", + "smlaltbls", + "smlalbtls", + "smlalttls", + "smlalbbge", + "smlaltbge", + "smlalbtge", + "smlalttge", + "smlalbblt", + "smlaltblt", + "smlalbtlt", + "smlalttlt", + "smlalbbgt", + "smlaltbgt", + "smlalbtgt", + "smlalttgt", + "smlalbble", + "smlaltble", + "smlalbtle", + "smlalttle", + "smlalbb", + "smlaltb", + "smlalbt", + "smlaltt", + + /* SMLAWY */ + "smlawbeq", + "smlawteq", + "smlawbne", + "smlawtne", + "smlawbcs", + "smlawtcs", + "smlawbcc", + "smlawtcc", + "smlawbmi", + "smlawtmi", + "smlawbpl", + "smlawtpl", + "smlawbvs", + "smlawtvs", + "smlawbvc", + "smlawtvc", + "smlawbhi", + "smlawthi", + "smlawbls", + "smlawtls", + "smlawbge", + "smlawtge", + "smlawblt", + "smlawtlt", + "smlawbgt", + "smlawtgt", + "smlawble", + "smlawtle", + "smlawb", + "smlawt", + + /* SMLAXY */ + "smlabbeq", + "smlatbeq", + "smlabteq", + "smlatteq", + "smlabbne", + "smlatbne", + "smlabtne", + "smlattne", + "smlabbcs", + "smlatbcs", + "smlabtcs", + "smlattcs", + "smlabbcc", + "smlatbcc", + "smlabtcc", + "smlattcc", + "smlabbmi", + "smlatbmi", + "smlabtmi", + "smlattmi", + "smlabbpl", + "smlatbpl", + "smlabtpl", + "smlattpl", + "smlabbvs", + "smlatbvs", + "smlabtvs", + "smlattvs", + "smlabbvc", + "smlatbvc", + "smlabtvc", + "smlattvc", + "smlabbhi", + "smlatbhi", + "smlabthi", + "smlatthi", + "smlabbls", + "smlatbls", + "smlabtls", + "smlattls", + "smlabbge", + "smlatbge", + "smlabtge", + "smlattge", + "smlabblt", + "smlatblt", + "smlabtlt", + "smlattlt", + "smlabbgt", + "smlatbgt", + "smlabtgt", + "smlattgt", + "smlabble", + "smlatble", + "smlabtle", + "smlattle", + "smlabb", + "smlatb", + "smlabt", + "smlatt", + + /* SMULL */ + "smulleq", + "smulleqs", + "smullne", + "smullnes", + "smullcs", + "smullcss", + "smullcc", + "smullccs", + "smullmi", + "smullmis", + "smullpl", + "smullpls", + "smullvs", + "smullvss", + "smullvc", + "smullvcs", + "smullhi", + "smullhis", + "smullls", + "smulllss", + "smullge", + "smullges", + "smulllt", + "smulllts", + "smullgt", + "smullgts", + "smullle", + "smullles", + "smull", + "smulls", + + /* SMULWY */ + "smulwbeq", + "smulwteq", + "smulwbne", + "smulwtne", + "smulwbcs", + "smulwtcs", + "smulwbcc", + "smulwtcc", + "smulwbmi", + "smulwtmi", + "smulwbpl", + "smulwtpl", + "smulwbvs", + "smulwtvs", + "smulwbvc", + "smulwtvc", + "smulwbhi", + "smulwthi", + "smulwbls", + "smulwtls", + "smulwbge", + "smulwtge", + "smulwblt", + "smulwtlt", + "smulwbgt", + "smulwtgt", + "smulwble", + "smulwtle", + "smulwb", + "smulwt", + + /* SMULXY */ + "smulbbeq", + "smultbeq", + "smulbteq", + "smultteq", + "smulbbne", + "smultbne", + "smulbtne", + "smulttne", + "smulbbcs", + "smultbcs", + "smulbtcs", + "smulttcs", + "smulbbcc", + "smultbcc", + "smulbtcc", + "smulttcc", + "smulbbmi", + "smultbmi", + "smulbtmi", + "smulttmi", + "smulbbpl", + "smultbpl", + "smulbtpl", + "smulttpl", + "smulbbvs", + "smultbvs", + "smulbtvs", + "smulttvs", + "smulbbvc", + "smultbvc", + "smulbtvc", + "smulttvc", + "smulbbhi", + "smultbhi", + "smulbthi", + "smultthi", + "smulbbls", + "smultbls", + "smulbtls", + "smulttls", + "smulbbge", + "smultbge", + "smulbtge", + "smulttge", + "smulbblt", + "smultblt", + "smulbtlt", + "smulttlt", + "smulbbgt", + "smultbgt", + "smulbtgt", + "smulttgt", + "smulbble", + "smultble", + "smulbtle", + "smulttle", + "smulbb", + "smultb", + "smulbt", + "smultt", + + /* STC/STC2 */ + "stceq", + "stceql", + "stcne", + "stcnel", + "stccs", + "stccsl", + "stccc", + "stcccl", + "stcmi", + "stcmil", + "stcpl", + "stcpll", + "stcvs", + "stcvsl", + "stcvc", + "stcvcl", + "stchi", + "stchil", + "stcls", + "stclsl", + "stcge", + "stcgel", + "stclt", + "stcltl", + "stcgt", + "stcgtl", + "stcle", + "stclel", + "stc", + "stcl", + "stc2", + "stc2l", + + /* STM */ + "stmeqia", + "stmeqib", + "stmeqda", + "stmeqdb", + "stmneia", + "stmneib", + "stmneda", + "stmnedb", + "stmcsia", + "stmcsib", + "stmcsda", + "stmcsdb", + "stmccia", + "stmccib", + "stmccda", + "stmccdb", + "stmmiia", + "stmmiib", + "stmmida", + "stmmidb", + "stmplia", + "stmplib", + "stmplda", + "stmpldb", + "stmvsia", + "stmvsib", + "stmvsda", + "stmvsdb", + "stmvcia", + "stmvcib", + "stmvcda", + "stmvcdb", + "stmhiia", + "stmhiib", + "stmhida", + "stmhidb", + "stmlsia", + "stmlsib", + "stmlsda", + "stmlsdb", + "stmgeia", + "stmgeib", + "stmgeda", + "stmgedb", + "stmltia", + "stmltib", + "stmltda", + "stmltdb", + "stmgtia", + "stmgtib", + "stmgtda", + "stmgtdb", + "stmleia", + "stmleib", + "stmleda", + "stmledb", + "stmia", + "stmib", + "stmda", + "stmdb", + + /* STR */ + "streq", + "strne", + "strcs", + "strcc", + "strmi", + "strpl", + "strvs", + "strvc", + "strhi", + "strls", + "strge", + "strlt", + "strgt", + "strle", + "str", + + /* STRB */ + "streqb", + "strneb", + "strcsb", + "strccb", + "strmib", + "strplb", + "strvsb", + "strvcb", + "strhib", + "strlsb", + "strgeb", + "strltb", + "strgtb", + "strleb", + "strb", + + /* STRBT */ + "streqbt", + "strnebt", + "strcsbt", + "strccbt", + "strmibt", + "strplbt", + "strvsbt", + "strvcbt", + "strhibt", + "strlsbt", + "strgebt", + "strltbt", + "strgtbt", + "strlebt", + "strbt", + + /* STRD */ + "streqd", + "strned", + "strcsd", + "strccd", + "strmid", + "strpld", + "strvsd", + "strvcd", + "strhid", + "strlsd", + "strged", + "strltd", + "strgtd", + "strled", + "strd", + + /* STRH */ + "streqh", + "strneh", + "strcsh", + "strcch", + "strmih", + "strplh", + "strvsh", + "strvch", + "strhih", + "strlsh", + "strgeh", + "strlth", + "strgth", + "strleh", + "strh", + + /* STRT */ + "streqt", + "strnet", + "strcst", + "strcct", + "strmit", + "strplt", + "strvst", + "strvct", + "strhit", + "strlst", + "strget", + "strltt", + "strgtt", + "strlet", + "strt", + + /* SUB */ + "subeq", + "subeqs", + "subne", + "subnes", + "subcs", + "subcss", + "subcc", + "subccs", + "submi", + "submis", + "subpl", + "subpls", + "subvs", + "subvss", + "subvc", + "subvcs", + "subhi", + "subhis", + "subls", + "sublss", + "subge", + "subges", + "sublt", + "sublts", + "subgt", + "subgts", + "suble", + "subles", + "sub", + "subs", + + /* SWI */ + "swieq", + "swine", + "swics", + "swicc", + "swimi", + "swipl", + "swivs", + "swivc", + "swihi", + "swils", + "swige", + "swilt", + "swigt", + "swile", + "swi", + + /* SWP */ + "swpeq", + "swpne", + "swpcs", + "swpcc", + "swpmi", + "swppl", + "swpvs", + "swpvc", + "swphi", + "swpls", + "swpge", + "swplt", + "swpgt", + "swple", + "swp", + + /* SWPB */ + "swpeqb", + "swpneb", + "swpcsb", + "swpccb", + "swpmib", + "swpplb", + "swpvsb", + "swpvcb", + "swphib", + "swplsb", + "swpgeb", + "swpltb", + "swpgtb", + "swpleb", + "swpb", + + /* TEQ */ + "teqeq", + "teqne", + "teqcs", + "teqcc", + "teqmi", + "teqpl", + "teqvs", + "teqvc", + "teqhi", + "teqls", + "teqge", + "teqlt", + "teqgt", + "teqle", + "teq", + + /* TST */ + "tsteq", + "tstne", + "tstcs", + "tstcc", + "tstmi", + "tstpl", + "tstvs", + "tstvc", + "tsthi", + "tstls", + "tstge", + "tstlt", + "tstgt", + "tstle", + "tst", + + /* UMLAL */ + "umlaleq", + "umlaleqs", + "umlalne", + "umlalnes", + "umlalcs", + "umlalcss", + "umlalcc", + "umlalccs", + "umlalmi", + "umlalmis", + "umlalpl", + "umlalpls", + "umlalvs", + "umlalvss", + "umlalvc", + "umlalvcs", + "umlalhi", + "umlalhis", + "umlalls", + "umlallss", + "umlalge", + "umlalges", + "umlallt", + "umlallts", + "umlalgt", + "umlalgts", + "umlalle", + "umlalles", + "umlal", + "umlals", + + /* UMULL */ + "umulleq", + "umulleqs", + "umullne", + "umullnes", + "umullcs", + "umullcss", + "umullcc", + "umullccs", + "umullmi", + "umullmis", + "umullpl", + "umullpls", + "umullvs", + "umullvss", + "umullvc", + "umullvcs", + "umullhi", + "umullhis", + "umullls", + "umulllss", + "umullge", + "umullges", + "umulllt", + "umulllts", + "umullgt", + "umullgts", + "umullle", + "umullles", + "umull", + "umulls", + + "(bad)", + }; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bsf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bsf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bsf.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bsf.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_bsf.c - * @ingroup handlers_ia32 - * $Id: i386_bsf.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_bsf.c + * + * @ingroup IA32_instrs + * $Id: i386_bsf.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_bsr_rv_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_bsr_rv_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bswap.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bswap.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bswap.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bswap.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_bswap.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_bswap.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_btrl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_btrl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_btrl.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_btrl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_btrl.c - * @ingroup handlers_ia32 - * $Id: i386_btrl.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_btrl.c + * + * @ingroup IA32_instrs + * $Id: i386_btrl.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bt_rm_r.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bt_rm_r.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bt_rm_r.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bt_rm_r.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_bt_rm_r.c - * @ingroup handlers_ia32 - * $Id: i386_bt_rm_r.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_bt_rm_r.c + * + * @ingroup IA32_instrs + * $Id: i386_bt_rm_r.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bts.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bts.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_bts.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_bts.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_bts.c - * @ingroup handlers_ia32 - * $Id: i386_bts.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_bts.c + * + * @ingroup IA32_instrs + * $Id: i386_bts.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmova.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmova.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmova.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmova.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmova.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmova.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovae.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovae.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovae.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovae.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovae.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovae.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovbe.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovbe.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovbe.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovbe.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovbe.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovbe.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmove.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmove.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmove.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmove.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_cmove.c - * @ingroup handlers_ia32 - * $Id: i386_cmove.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_cmove.c + * + * @ingroup IA32_instrs + * $Id: i386_cmove.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovl.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovl.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovle.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovle.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovle.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovle.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovle.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovne.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovne.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovne.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovne.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovne.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovne.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnl.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovnl.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovnl.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnle.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnle.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnle.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnle.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovnle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovnle.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovno.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovno.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovno.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovno.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovno.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovno.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovnp.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovnp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovnp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovnp.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovns.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovns.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovns.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovns.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovns.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovns.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovo.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovo.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovo.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovo.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovo.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovo.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovp.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovp.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cmovs.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cmovs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cmovs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cmovs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cpuid.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cpuid.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_cpuid.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_cpuid.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_cpuid.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_cpuid.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_emms.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_emms.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_emms.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_emms.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_emms.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_emms.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group12.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group12.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group12.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group12.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_group12.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_group12.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group14.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group14.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group14.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group14.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_group14.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_group14.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group15.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group15.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group15.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group15.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_group15.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_group15.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group16.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group16.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_group16.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_group16.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_group16.c - * @ingroup handlers_ia32 - * $Id: i386_group16.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_group16.c + * + * @ingroup IA32_instrs + * $Id: i386_group16.c 1397 2009-09-13 02:19:08Z may $ * * Changelog * 2007-05-29: operand type fixed. diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_imul_rv_rmv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_imul_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_ja.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_ja.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_ja.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_ja.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_ja.c - * @ingroup handlers_ia32 - * $Id: i386_ja.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_ja.c + * + * @ingroup IA32_instrs + * $Id: i386_ja.c 1413 2010-05-21 03:41:25Z figueredo $ * */ #include @@ -20,7 +21,7 @@ int i386_ja(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_U_GREATER; new->len += 1; #if LIBASM_USE_OPERAND_VECTOR diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jae.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jae.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jae.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jae.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jae.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jae.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jbe.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jbe.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jbe.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jbe.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jbe.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jbe.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_je.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_je.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_je.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_je.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_je.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_je.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_je(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - // new->type = IS_COND_BRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_EQUAL; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jg.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jg.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jg.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,23 +12,24 @@ int i386_jg(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_GREATER; - new->len += 1; + new->len += 1; - #if LIBASM_USE_OPERAND_VECTOR +#if LIBASM_USE_OPERAND_VECTOR #if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); + new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); #else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); + new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); #endif - #else +#else new->op[0].type = ASM_OTYPE_JUMP; new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; + new->op[0].ptr = opcode + 1; + new->op[0].len = 4; + memcpy(&new->op[0].imm, opcode + 1, 4); + new->len += 4; #endif return (new->len); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jge.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jge.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jge.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jge.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jge.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jge.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_jge(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - // new->type = IS_COND_BRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_GREATER_EQUAL; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jl.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jl.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jl.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,9 +12,8 @@ int i386_jl(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - // new->type = IS_COND_BRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_LESS; - new->len += 1; #if LIBASM_USE_OPERAND_VECTOR diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jle.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jle.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jle.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jle.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jle.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_jle(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_LESS_EQUAL; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jne.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jne.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jne.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jne.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jne.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jne.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,6 +13,7 @@ int i386_jne(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { // new->type = IS_COND_BRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_EQUAL; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jnp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jnp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jnp.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jnp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jnp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jnp.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_jnp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_PARITY; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jns.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jns.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jns.c 2008-04-06 23:16:12.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jns.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jns.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jns.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_jns(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_SIGNED; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_jp.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_jp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_jp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_jp.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int i386_jp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_PARITY; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_js.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_js.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_js.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_js.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_js.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_js.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_mov_cr_rm.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_mov_cr_rm.c 1311 2009-01-14 20:36:48Z may $ ** */ #include @@ -16,14 +16,14 @@ #if LIBASM_USE_OPERAND_VECTOR #if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new, 0); + new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new, 0); #else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new); + new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new); #endif #if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new, 0); + new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new, 0); #else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new); + new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new); #endif #else new->op[0].type = ASM_OTYPE_CONTROL; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movd_pd_qd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movd_pd_qd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_mov_dr_rm.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_mov_dr_rm.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movq_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movq_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movq_qq_pq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movq_qq_pq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_mov_rm_cr.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_mov_rm_cr.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movsbl_rv_rmb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movsbl_rv_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movswl_rv_rm2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movswl_rv_rm2.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movzbl_rv_rmb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movzbl_rv_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_movzwl_rv_rm2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_movzwl_rv_rm2.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_packuswb_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_packuswb_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_paddusb_pq_qq.c - * @ingroup handlers_ia32 -* $Id: i386_paddusb_pq_qq.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c + * + * @ingroup IA32_instrs +* $Id: i386_paddusb_pq_qq.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_paddusw_pq_qq.c - * @ingroup handlers_ia32 - * $Id: i386_paddusw_pq_qq.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c + * + * @ingroup IA32_instrs + * $Id: i386_paddusw_pq_qq.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_pand_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_pand_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_pmullw_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_pmullw_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pop_fs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pop_fs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pop_fs.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pop_fs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_pop_fs.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_pop_fs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_por_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_por_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_por_pq_qq.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_por_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_por_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_por_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_punpckhbw_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_punpckhbw_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_punpcklbw_pq_qd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_punpcklbw_pq_qd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_push_fs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_push_fs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_push_fs.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_push_fs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_push_fs.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_push_fs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_pxor_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_pxor_pq_qq.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_rdmsr.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_rdmsr.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_rdmsr.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_rdmsr.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_rdmsr.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_rdmsr.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_rdtsc.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_rdtsc.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_rdtsc.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_rdtsc.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_rdtsc.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_rdtsc.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shld.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shld.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shld.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shld.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_shld.c - * @ingroup handlers_ia32 - * $Id: i386_shld.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_shld.c + * + * @ingroup IA32_instrs + * $Id: i386_shld.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_shld_rmv_rv_cl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_shld_rmv_rv_cl.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_shrd_rmv_rv_cl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_shrd_rmv_rv_cl.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_shrd_rmv_rv_ib.c - * @ingroup handlers_ia32 - * $Id: i386_shrd_rmv_rv_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c + * + * @ingroup IA32_instrs + * $Id: i386_shrd_rmv_rv_ib.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_wbinvd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_wbinvd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_wbinvd.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_wbinvd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_wbinvd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_wbinvd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_xadd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_xadd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_xadd.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_xadd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file i386_xadd.c - * @ingroup handlers_ia32 - * $Id: i386_xadd.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/i386_xadd.c + * + * @ingroup IA32_instrs + * $Id: i386_xadd.c 1397 2009-09-13 02:19:08Z may $ */ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_xstorenrg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_xstorenrg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/i386_xstorenrg.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/i386_xstorenrg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: i386_xstorenrg.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: i386_xstorenrg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_386sp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_386sp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_386sp.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_386sp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_386sp.c - * @ingroup handlers_ia32 - * $Id: op_386sp.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_386sp.c + * + * @ingroup IA32_instrs + * $Id: op_386sp.c 1397 2009-09-13 02:19:08Z may $ * ChangeLog: * 2007-05-30 Fixed a bug in fetching. The vector used was the previously defined. * strauss set up a new disasm vector and didn't know about it which diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aaa.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aaa.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aaa.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aaa.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_aaa.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_aaa.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aad.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aad.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aad.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aad.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_aad.c - * @ingroup handlers_ia32 - * $Id: op_aad.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_aad.c + * + * @ingroup IA32_instrs + * $Id: op_aad.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aam.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aam.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aam.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aam.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_aam.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_aam.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aas.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aas.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_aas.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_aas.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_aas.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_aas.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_al_ib.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_al_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_eax_iv.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_eax_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_rb_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_rb_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_rmb_rb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_rmb_rb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_rmv_rv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_adc_rv_rmv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_adc_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_al_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_al_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_eax_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_eax_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_eax_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rb_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_rb_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rmb_rb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_rmb_rb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rmv_rv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_add_rv_rmv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_add_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_add_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_add_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_addsize.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_addsize.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_addsize.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_addsize.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_addsize.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_addsize.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_al_ib.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_al_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_eax_iv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_eax_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rb_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_rb_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rmb_rb.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_rmb_rb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rmv_rv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_and_rv_rmv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_and_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_and_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_and_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_arpl_ew_rw.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_arpl_ew_rw.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_bound_gv_ma.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_bound_gv_ma.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_bound_gv_ma.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_bound_gv_ma.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_bound_gv_ma.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_bound_gv_ma.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_btr_rmv_rv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_btr_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_call_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_call_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_call_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_call_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_call_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_call_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_clc.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_clc.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_clc.c 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_clc.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_clc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_clc.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cld.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cld.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cld.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cld.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cld.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cld.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cli.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cli.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cli.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cli.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cli.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cli.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cltd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cltd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cltd.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cltd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cltd.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ +** $Id: op_cltd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmc.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmc.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmc.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmc.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmc.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_al_ib.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_al_ib.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_al_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_eax_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_eax_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_rb_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_rmb_rb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_rmv_rv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_rv_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmpsb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmpsb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmpsb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmpsb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_cmpsb.c +* @file libasm/src/arch/ia32/handlers/op_cmpsb.c * @brief Handler for instruction cmpsb opcode 0xa6 - * @ingroup handlers_ia32 - * $Id: op_cmpsb.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs + * $Id: op_cmpsb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmpsd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmpsd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmpsd.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmpsd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmpsd.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmpsd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_xchg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_xchg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cmp_xchg.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cmp_xchg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cmp_xchg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_cmp_xchg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cwtl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cwtl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_cwtl.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_cwtl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_cwtl.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ +** $Id: op_cwtl.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_daa.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_daa.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_daa.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_daa.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_daa.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ +** $Id: op_daa.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_das.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_das.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_das.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_das.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_das.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ +** $Id: op_das.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_dec_reg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_dec_reg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_dec_reg.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_dec_reg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_dec_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_dec_reg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_enter.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_enter.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_enter.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_enter.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_enter.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_enter.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc0.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc0.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc0.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc0.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_esc0.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_esc0.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc1.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc1.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc1.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc1.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_esc1.c - * @ingroup handlers_ia32 - * $Id: op_esc1.c,v 1.8 2008/01/07 01:32:56 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_esc1.c + * + * @ingroup IA32_instrs + * $Id: op_esc1.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc2.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc2.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc2.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc2.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_esc2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_esc2.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc3.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc3.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc3.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc3.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_esc3.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_esc3.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc4.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc4.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc4.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc4.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,6 +1,6 @@ /** - * $Id: op_esc4.c,v 1.5 2008/01/07 01:32:56 heroine Exp $ - * @file op_esc4.c + * $Id: op_esc4.c 1397 2009-09-13 02:19:08Z may $ +* @file libasm/src/arch/ia32/handlers/op_esc4.c * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc5.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc5.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc5.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc5.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_esc5.c - * @ingroup handlers_ia32 - * $Id: op_esc5.c,v 1.7 2008/01/07 01:32:56 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_esc5.c + * + * @ingroup IA32_instrs + * $Id: op_esc5.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc6.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc6.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc6.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc6.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_esc6.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_esc6.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc7.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc7.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_esc7.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_esc7.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /** - * $Id: op_esc7.c,v 1.6 2008/01/07 01:32:56 heroine Exp $ + * $Id: op_esc7.c 1311 2009-01-14 20:36:48Z may $ * @param */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_fwait.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_fwait.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_fwait.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_fwait.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,6 +1,6 @@ /** - * $Id: op_fwait.c,v 1.7 2008/01/07 01:32:56 heroine Exp $ - * @file op_fwait.c + * $Id: op_fwait.c 1397 2009-09-13 02:19:08Z may $ +* @file libasm/src/arch/ia32/handlers/op_fwait.c */ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_group6.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_group6.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_group6.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_group6.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_group6.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_group6.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_group7.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_group7.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_group7.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_group7.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_group7.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_group7.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_hlt.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_hlt.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_hlt.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_hlt.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_hlt.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_hlt.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_immed_rmb_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_immed_rmb_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_immed_rmv_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_immed_rmv_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_immed_rmv_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_immed_rmv_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_imul_gv_ev_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_imul_gv_ev_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_imul_rv_rmv_iv.c +* @file libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c * @brief Handler for instruction op_imul_rv_rmv_iv opcode 0x69 - * @ingroup handlers_ia32 -** $Id: op_imul_rv_rmv_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs +** $Id: op_imul_rv_rmv_iv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_al_dx.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_al_dx.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_al_dx.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_al_dx.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_in_al_dx.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_in_al_dx.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @file op_in_al_ref_ib.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c + * + * @ingroup IA32_instrs * @brief Handler for instruction in al,ib opcode 0xe4 - * $Id: op_in_al_ref_ib.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_in_al_ref_ib.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_incdec_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_incdec_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_incdec_rmb.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_incdec_rmb.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_incdec_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_incdec_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_inc_reg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_inc_reg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_inc_reg.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_inc_reg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_inc_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_inc_reg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_indir_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_indir_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_indir_rmv.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_indir_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_indir_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_indir_rmv.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -47,12 +47,12 @@ break; case 4: - new->type = ASM_TYPE_IMPBRANCH; + new->type = ASM_TYPE_BRANCH; new->instr = ASM_BRANCH; new->op[0].type = ASM_OTYPE_MEMORY; break; case 5: - new->type = ASM_TYPE_IMPBRANCH; + new->type = ASM_TYPE_BRANCH; new->instr = ASM_BRANCH; new->op[0].type = ASM_OTYPE_MEMORY; break; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_eax_dx.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_eax_dx.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_eax_dx.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_eax_dx.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_in_eax_dx.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_in_eax_dx.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_in_eax_ref_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_in_eax_ref_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_insb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_insb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_insb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_insb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_insb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_insb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_insw.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_insw.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_insw.c 2008-04-06 23:16:18.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_insw.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_insw.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_insw.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int1.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int1.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int1.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int1.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_int1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_int1.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int_3.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int_3.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int_3.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int_3.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_int_3.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_int_3.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_int_ib.c 2008-04-06 23:16:12.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_int_ib.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_int_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_int_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_into.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_into.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_into.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_into.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_into.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_into.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_iret.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_iret.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_iret.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_iret.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_iret.c - * @ingroup handlers_ia32 - * $Id: op_iret.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_iret.c + * + * @ingroup IA32_instrs + * $Id: op_iret.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ja.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ja.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ja.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ja.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_ja.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_ja.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int op_ja(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_U_GREATER; new->ptr_instr = opcode; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jae.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jae.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jae.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jae.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jae.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jae.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ int op_jae(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_U_GREATER_EQUAL; new->ptr_instr = opcode; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jb.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -14,7 +14,7 @@ asm_processor *proc) { new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_U_LESS; new->ptr_instr = opcode; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jbe.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jbe.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jbe.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jbe.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jbe.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jbe.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_U_LESS_EQUAL; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_je.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_je.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_je.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_je.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_je.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_je.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -14,7 +14,7 @@ { new->len += 1; new->instr = ASM_BRANCH_EQUAL; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->ptr_instr = opcode; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_je_cxz.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_je_cxz.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_je_cxz.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_je_cxz.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_je_cxz.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_je_cxz.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_CXZ; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jg.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jg.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jg.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_GREATER; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jge.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jge.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jge.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jge.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jge.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jge.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -14,7 +14,7 @@ new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_GREATER_EQUAL; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jl.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jl.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_LESS; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jle.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jle.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jle.c 2008-04-06 23:16:13.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jle.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jle.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jle.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_S_LESS_EQUAL; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_ap.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_ap.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_ap.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_ap.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jmp_ap.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jmp_ap.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -15,7 +15,7 @@ new->ptr_instr = opcode; new->instr = ASM_LBRANCH; new->len += 1; - new->type = ASM_TYPE_IMPBRANCH; + new->type = ASM_TYPE_BRANCH; #if WIP new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ADDRESS, new, 0); diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_ib.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jmp_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jmp_ib.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->instr = ASM_BRANCH; - new->type = ASM_TYPE_IMPBRANCH; + new->type = ASM_TYPE_BRANCH; new->ptr_instr = opcode; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jmp_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jmp_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jmp_iv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jmp_iv.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int op_jmp_iv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { new->instr = ASM_BRANCH; - new->type = ASM_TYPE_IMPBRANCH; + new->type = ASM_TYPE_BRANCH; new->ptr_instr = opcode; new->len += 1; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jne.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jne.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jne.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jne.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jne.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jne.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -14,7 +14,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_EQUAL; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jno.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jno.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jno.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jno.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jno.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jno.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ int op_jno(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_OVERFLOW; new->ptr_instr = opcode; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jnp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jnp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jnp.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jnp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jnp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jnp.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_PARITY; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jns.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jns.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jns.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jns.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jns.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jns.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_NOT_SIGNED; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jo.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jo.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jo.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jo.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_jo.c - * @ingroup handlers_ia32 - * $Id: op_jo.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_jo.c + * + * @ingroup IA32_instrs + * $Id: op_jo.c 1413 2010-05-21 03:41:25Z figueredo $ * */ #include @@ -16,7 +17,8 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; + new->instr = ASM_BRANCH_OVERFLOW; #if WIP new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_jp.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_jp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_jp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_jp.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_PARITY; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_js.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_js.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_js.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_js.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_js.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_js.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->ptr_instr = opcode; new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_BRANCH_SIGNED; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lahf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lahf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lahf.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lahf.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_lahf.c - * @ingroup handlers_ia32 - * $Id: op_lahf.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_lahf.c + * + * @ingroup IA32_instrs + * $Id: op_lahf.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_lds_rm_rmp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_lds_rm_rmp.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lea_rv_m.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lea_rv_m.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lea_rv_m.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lea_rv_m.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_lea_rv_m.c - * @ingroup handlers_ia32 - * $Id: op_lea_rv_m.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_lea_rv_m.c + * + * @ingroup IA32_instrs + * $Id: op_lea_rv_m.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_leave.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_leave.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_leave.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_leave.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_leave.c - * @ingroup handlers_ia32 - * $Id: op_leave.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_leave.c + * + * @ingroup IA32_instrs + * $Id: op_leave.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_les_rm_rmp.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_les_rm_rmp.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_les_rm_rmp.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_les_rm_rmp.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_les_rm_rmp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_les_rm_rmp.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lock.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lock.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lock.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lock.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_lock.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_lock.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lodsb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lodsb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lodsb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lodsb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_lodsb.c - * @ingroup handlers_ia32 - * $Id: op_lodsb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_lodsb.c + * + * @ingroup IA32_instrs + * $Id: op_lodsb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lodsd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lodsd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lodsd.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lodsd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_lodsd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_lodsd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loop.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loop.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loop.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loop.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_loop.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_loop.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -13,7 +13,7 @@ { new->len += 1; new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; new->instr = ASM_LOOP; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loope.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loope.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loope.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loope.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_loope.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_loope.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -14,7 +14,7 @@ new->len += 1; new->ptr_instr = opcode; new->instr = ASM_LOOPE; - new->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_READFLAG; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL | ASM_TYPE_READFLAG; new->flagsread = ASM_FLAG_ZF; #if WIP diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loopne.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loopne.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_loopne.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_loopne.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_loopne.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_loopne.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include @@ -12,7 +12,7 @@ int op_loopne(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { new->instr = ASM_LOOPNE; - new->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_READFLAG; + new->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL | ASM_TYPE_READFLAG; new->ptr_instr = opcode; new->len += 1; new->flagsread = ASM_FLAG_ZF; diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_lss_rv_rmv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_lss_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_al_ref_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_al_ref_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_eax_ref_iv.c - * @ingroup handlers_ia32 - * $Id: op_mov_eax_ref_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c + * + * @ingroup IA32_instrs + * $Id: op_mov_eax_ref_iv.c 1397 2009-09-13 02:19:08Z may $ * */ #include @@ -30,6 +31,7 @@ #else new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); #endif + new->op[0].content = ASM_OP_BASE; new->op[0].ptr = opcode; new->op[0].type = ASM_OTYPE_FIXED; new->op[0].regset = asm_proc_opsize(proc) ? diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_rb_rmb.c - * @ingroup handlers_ia32 - * $Id: op_mov_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_mov_rb_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_ref_iv_al.c - * @ingroup handlers_ia32 - * $Id: op_mov_ref_iv_al.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c + * + * @ingroup IA32_instrs + * $Id: op_mov_ref_iv_al.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_ref_iv_eax.c - * @ingroup handlers_ia32 - * $Id: op_mov_ref_iv_eax.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c + * + * @ingroup IA32_instrs + * $Id: op_mov_ref_iv_eax.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_reg_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_reg_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_reg_iv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_reg_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_reg_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_reg_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** * - * @file op_mov_rmb_ib.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmb_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c + * + * @ingroup IA32_instrs + * $Id: op_mov_rmb_ib.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_rmb_rb.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c + * + * @ingroup IA32_instrs + * $Id: op_mov_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rm_segr.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rm_segr.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rm_segr.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rm_segr.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_rm_segr.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_rm_segr.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_rmv_iv.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmv_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c + * + * @ingroup IA32_instrs + * $Id: op_mov_rmv_iv.c 1397 2009-09-13 02:19:08Z may $ * ChangeLog: * */ diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_movsb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_movsb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_movsb.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_movsb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_movsb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_movsb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_movsd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_movsd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_movsd.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_movsd.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_movsd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_movsd.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_segr_rm.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_segr_rm.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_segr_rm.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_segr_rm.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_mov_segr_rm.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_mov_segr_rm.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_mov_subreg_ib.c - * @ingroup handlers_ia32 - * $Id: op_mov_subreg_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c + * + * @ingroup IA32_instrs + * $Id: op_mov_subreg_ib.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_nop.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_nop.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_nop.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_nop.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_nop.c - * @ingroup handlers_ia32 - * $Id: op_nop.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_nop.c + * + * @ingroup IA32_instrs + * $Id: op_nop.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_opsize.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_opsize.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_opsize.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_opsize.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_opsize.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_opsize.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_al_ib.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_al_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_eax_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_eax_iv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rb_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_rb_rmb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rmb_rb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_rmb_rb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rmv_rv.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_rmv_rv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_or_rv_rmv.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_or_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_or_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_or_rv_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_dx_al.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_dx_al.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_dx_al.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_dx_al.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_out_dx_al.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_out_dx_al.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_dx_eax.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_dx_eax.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_dx_eax.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_dx_eax.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_out_dx_eax.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_out_dx_eax.c * - * $Id: op_out_dx_eax.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * @ingroup IA32_instrs + * + * $Id: op_out_dx_eax.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_out_ref_ib_al.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_out_ref_ib_al.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_out_ref_ib_eax.c - * @ingroup handlers_ia32 - * $Id: op_out_ref_ib_eax.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c + * + * @ingroup IA32_instrs + * $Id: op_out_ref_ib_eax.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_outsb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_outsb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_outsb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_outsb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_outsb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_outsb.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_outsw.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_outsw.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_outsw.c 2008-04-06 23:16:19.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_outsw.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_outsw.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_outsw.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_popa.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_popa.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_popa.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_popa.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_popa.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_popa.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_ds.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_ds.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_ds.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_ds.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pop_ds.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pop_ds.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_es.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_es.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_es.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_es.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pop_es.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pop_es.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_popf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_popf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_popf.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_popf.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_popf.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_popf.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_reg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_reg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_reg.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_reg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pop_reg.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pop_reg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_rmv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_rmv.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pop_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pop_rmv.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_ss.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_ss.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pop_ss.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pop_ss.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** * @brief Handler for pop es instruction. Opcode = 0x17 - * @ingroup handlers_ia32 -** $Id: op_pop_ss.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs +** $Id: op_pop_ss.c 1396 2009-09-12 11:25:11Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_cs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_cs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_cs.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_cs.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_prefix_cs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_prefix_cs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_ds.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_ds.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_ds.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_ds.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_prefix_ds.c - * @ingroup handlers_ia32 - * $Id: op_prefix_ds.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_prefix_ds.c + * + * @ingroup IA32_instrs + * $Id: op_prefix_ds.c 1397 2009-09-13 02:19:08Z may $ * * Changelog * 200-07-29 : instruction length was not incremented. fixed. diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_es.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_es.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_es.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_es.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_prefix_es.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_prefix_es.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_fs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_fs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_fs.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_fs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_prefix_fs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_prefix_fs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_gs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_gs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_gs.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_gs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_prefix_gs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_prefix_gs.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_ss.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_ss.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_prefix_ss.c 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_prefix_ss.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_prefix_ss.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_prefix_ss.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pusha.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pusha.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pusha.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pusha.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pusha.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pusha.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_cs.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_cs.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_cs.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_cs.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** * @brief Handler for instruction push cs opcode 0x0e - * @ingroup handlers_ia32 -** $Id: op_push_cs.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs +** $Id: op_push_cs.c 1396 2009-09-12 11:25:11Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ds.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ds.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ds.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ds.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** * @brief Handler for instruction push ds opcode 0x1e - * @ingroup handlers_ia32 -** $Id: op_push_ds.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs +** $Id: op_push_ds.c 1396 2009-09-12 11:25:11Z may $ ** */ #include @@ -14,7 +15,6 @@ int op_push_ds(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->len += 1; new->ptr_instr = opcode; new->instr = ASM_PUSH; new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; @@ -27,7 +27,8 @@ //asm_fixed_pack(content, type, regset, baser) #else - new->op[0].content = ASM_OP_BASE; + new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); + new->op[0].content |= ASM_OP_BASE | ASM_OP_FIXED; new->op[0].regset = ASM_REGSET_SREG; new->op[0].baser = ASM_REG_DS; #endif diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_es.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_es.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_es.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_es.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_push_es.c - * @ingroup handlers_ia32 -** $Id: op_push_es.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_push_es.c + * + * @ingroup IA32_instrs +** $Id: op_push_es.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pushf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pushf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_pushf.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_pushf.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_pushf.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_pushf.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_push_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_push_ib.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_iv.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_iv.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_push_iv.c - * @ingroup handlers_ia32 - * $Id: op_push_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_push_iv.c + * + * @ingroup IA32_instrs + * $Id: op_push_iv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_reg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_reg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_reg.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_reg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_push_reg.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_push_reg.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ss.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ss.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_push_ss.c 2008-04-06 23:16:19.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_push_ss.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,5 +1,5 @@ /* -** $Id: op_push_ss.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_push_ss.c 1311 2009-01-14 20:36:48Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_repnz.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_repnz.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_repnz.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_repnz.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_repnz.c - * @ingroup handlers_ia32 -** $Id: op_repnz.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_repnz.c + * + * @ingroup IA32_instrs +** $Id: op_repnz.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_repz.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_repz.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_repz.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_repz.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_repz.c - * @ingroup handlers_ia32 -** $Id: op_repz.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_repz.c + * + * @ingroup IA32_instrs +** $Id: op_repz.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ret.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ret.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ret.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ret.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_ret.c - * @ingroup handlers_ia32 -** $Id: op_ret.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_ret.c + * + * @ingroup IA32_instrs +** $Id: op_ret.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_retf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_retf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_retf.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_retf.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_retf.c - * @ingroup handlers_ia32 -** $Id: op_retf.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_retf.c + * + * @ingroup IA32_instrs +** $Id: op_retf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_retf_i2.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_retf_i2.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_retf_i2.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_retf_i2.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_retf_i2.c - * @ingroup handlers_ia32 -** $Id: op_retf_i2.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_retf_i2.c + * + * @ingroup IA32_instrs +** $Id: op_retf_i2.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ret_i2.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ret_i2.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ret_i2.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ret_i2.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_ret_i2.c - * @ingroup handlers_ia32 - * $Id: op_ret_i2.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_ret_i2.c + * + * @ingroup IA32_instrs + * $Id: op_ret_i2.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sahf.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sahf.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sahf.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sahf.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sahf.c - * @ingroup handlers_ia32 -** $Id: op_sahf.c,v 1.4 2007/08/15 21:30:20 strauss Exp $ +* @file libasm/src/arch/ia32/handlers/op_sahf.c + * + * @ingroup IA32_instrs +** $Id: op_sahf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_al_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_al_ib.c - * @ingroup handlers_ia32 -** $Id: op_sbb_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_al_ib.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_al_ib.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_eax_iv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_eax_iv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_rb_rmb.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rb_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_rb_rmb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rmb_rb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rmv_rv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_rmv_rv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sbb_rv_rmv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rv_rmv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c + * + * @ingroup IA32_instrs +** $Id: op_sbb_rv_rmv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_scasb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_scasb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_scasb.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_scasb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_scasb.c - * @ingroup handlers_ia32 -** $Id: op_scasb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_scasb.c + * + * @ingroup IA32_instrs +** $Id: op_scasb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_scasd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_scasd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_scasd.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_scasd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_scasd.c - * @ingroup handlers_ia32 -** $Id: op_scasd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_scasd.c + * + * @ingroup IA32_instrs +** $Id: op_scasd.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setae_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setae_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setae_rmb.c 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setae_rmb.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setae_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setae_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setae_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setae_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_seta_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_seta_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_seta_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_seta_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_seta_rmb.c - * @ingroup handlers_ia32 - * $Id: op_seta_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_seta_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_seta_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setbe_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setbe_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setbe_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setbe_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setbe_rmb.c - * @ingroup handlers_ia32 -* $Id: op_setbe_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setbe_rmb.c + * + * @ingroup IA32_instrs +* $Id: op_setbe_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setb_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setb_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setb_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setb_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sete_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sete_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sete_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sete_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sete_rmb.c - * @ingroup handlers_ia32 - * $Id: op_sete_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sete_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_sete_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setge_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setge_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setge_rmb.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setge_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setge_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setge_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setge_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setge_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setg_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setg_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setg_rmb.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setg_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setg_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setg_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setg_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setg_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setle_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setle_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setle_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setle_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setle_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setle_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setle_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setle_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setl_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setl_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setl_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setl_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setl_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setl_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setl_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setl_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setne_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setne_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setne_rmb.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setne_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setne_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setne_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setne_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setne_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setno_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setno_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setno_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setno_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setno_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setno_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setno_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setno_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setnp_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setnp_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setnp_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setnp_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setnp_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setnp_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setnp_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setnp_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setns_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setns_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setns_rmb.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setns_rmb.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setns_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setns_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setns_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setns_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_seto_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_seto_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_seto_rmb.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_seto_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_seto_rmb.c - * @ingroup handlers_ia32 - * $Id: op_seto_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_seto_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_seto_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setp_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setp_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_setp_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_setp_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_setp_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setp_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_setp_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_setp_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sets_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sets_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sets_rmb.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sets_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sets_rmb.c - * @ingroup handlers_ia32 - * $Id: op_sets_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sets_rmb.c + * + * @ingroup IA32_instrs + * $Id: op_sets_rmb.c 1397 2009-09-13 02:19:08Z may $ */ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmb_1.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmb_1.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmb_1.c 2008-04-06 23:16:21.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmb_1.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_shift_rmb_1.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmb_1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_shift_rmb_1.c + * + * @ingroup IA32_instrs +** $Id: op_shift_rmb_1.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_shift_rmb_cl.c - * @ingroup handlers_ia32 - * $Id: op_shift_rmb_cl.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c + * + * @ingroup IA32_instrs + * $Id: op_shift_rmb_cl.c 1397 2009-09-13 02:19:08Z may $ * * Changelog * 2007-05-29 : instruction set was not complete. diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmv_1.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmv_1.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmv_1.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmv_1.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_shift_rmv_1.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmv_1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_shift_rmv_1.c + * + * @ingroup IA32_instrs +** $Id: op_shift_rmv_1.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_shift_rmv_cl.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmv_cl.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c + * + * @ingroup IA32_instrs +** $Id: op_shift_rmv_cl.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @file op_shr_ib.c - * @ingroup handlers_ia32 -** $Id: op_shr_rmb_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ +* @file libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c + * + * @ingroup IA32_instrs + * $Id: op_shr_rmb_ib.c 1397 2009-09-13 02:19:08Z may $ + * + */ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_shr_rmv_ib.c - * @ingroup handlers_ia32 -** $Id: op_shr_rmv_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c + * + * @ingroup IA32_instrs +** $Id: op_shr_rmv_ib.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stc.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stc.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stc.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stc.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_stc.c - * @ingroup handlers_ia32 -** $Id: op_stc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_stc.c + * + * @ingroup IA32_instrs +** $Id: op_stc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_std.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_std.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_std.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_std.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_std.c - * @ingroup handlers_ia32 -** $Id: op_std.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_std.c + * + * @ingroup IA32_instrs +** $Id: op_std.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sti.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sti.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sti.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sti.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_sti.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_sti.c * -** $Id: op_sti.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * @ingroup IA32_instrs + * +** $Id: op_sti.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stosb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stosb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stosb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stosb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_stosb.c - * @ingroup handlers_ia32 -** $Id: op_stosb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_stosb.c + * + * @ingroup IA32_instrs +** $Id: op_stosb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stosd.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stosd.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_stosd.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_stosd.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_stosd.c - * @ingroup handlers_ia32 -** $Id: op_stosd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_stosd.c + * + * @ingroup IA32_instrs +** $Id: op_stosd.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_al_ib.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sub_al_ib.c - * @ingroup handlers_ia32 -** $Id: op_sub_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sub_al_ib.c + * + * @ingroup IA32_instrs +** $Id: op_sub_al_ib.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_eax_iv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,14 +1,16 @@ /** - * @file op_sub_eax_iv.c - * @ingroup handlers_ia32 -** $Id: op_sub_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sub_eax_iv.c + * + * @ingroup IA32_instrs +** $Id: op_sub_eax_iv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include #include /** - * @ingroup handlers_ia32 + * + * @ingroup IA32_instrs * */ diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sub_rb_rmb.c - * @ingroup handlers_ia32 -** $Id: op_sub_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c + * + * @ingroup IA32_instrs +** $Id: op_sub_rb_rmb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sub_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_sub_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c + * + * @ingroup IA32_instrs +** $Id: op_sub_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_sub_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_sub_rmv_rv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c + * + * @ingroup IA32_instrs +** $Id: op_sub_rmv_rv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @file op_sub_rv_rmv.c +* @file libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c * @brief Handler for instruction sub rv,rmv opcode 0x2b - * @ingroup handlers_ia32 + * + * @ingroup IA32_instrs * - * $Id: op_sub_rv_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_sub_rv_rmv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_al_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_al_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_al_rb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_al_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_test_al_rb.c - * @ingroup handlers_ia32 -** $Id: op_test_al_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_test_al_rb.c + * + * @ingroup IA32_instrs +** $Id: op_test_al_rb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_eax_iv.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_eax_iv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_test_eax_iv.c - * @ingroup handlers_ia32 - * $Id: op_test_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_test_eax_iv.c + * + * @ingroup IA32_instrs + * $Id: op_test_eax_iv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_rmb_rb.c 2008-04-06 23:16:14.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_test_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_test_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_test_rmb_rb.c + * + * @ingroup IA32_instrs +** $Id: op_test_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_test_rmv_rv.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_test_rmv_rv.c 2011-05-16 11:34:43.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file op_test_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_test_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/handlers/op_test_rmv_rv.c + * + * @ingroup IA32_instrs +** $Id: op_test_rmv_rv.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ud2a.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ud2a.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_ud2a.c 2008-04-06 23:16:20.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_ud2a.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_ud2a.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_ud2a.c + * + * @ingroup IA32_instrs * @brief Handler for instruction ud2a opcode 0x?? - * $Id: op_ud2a.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_ud2a.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_unary_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_unary_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_unary_rmb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_unary_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_unary_rmb.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_unary_rmb.c + * + * @ingroup IA32_instrs * @brief Handler for instruction unary rmb opcode 0xf6 - * $Id: op_unary_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_unary_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_unary_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_unary_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_unary_rmv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_unary_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_unary_rmv.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_unary_rmv.c + * + * @ingroup IA32_instrs * @brief Handler for instruction unary rmv opcode 0xf7 - * $Id: op_unary_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_unary_rmv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xchg_eax_reg.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xchg eax,reg opcode 0x91 to 0x97 -** $Id: op_xchg_eax_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: op_xchg_eax_reg.c 1397 2009-09-13 02:19:08Z may $ ** */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c 2008-04-06 23:16:17.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xchg_rmb_rb.c +* @file libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c * @brief Handler for instruction xchg rmb,rb opcode 0x86 - * @ingroup handlers_ia32 - * $Id: op_xchg_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs + * $Id: op_xchg_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xchg_rmv_rv.c +* @file libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c * @brief Handler for instruction xchg rmv,rv opcode 0x87 - * @ingroup handlers_ia32 - * $Id: op_xchg_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * + * @ingroup IA32_instrs + * $Id: op_xchg_rmv_rv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xlatb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xlatb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xlatb.c 2008-04-06 23:16:22.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xlatb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xlatb.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xlatb.c + * + * @ingroup IA32_instrs * @brief - * $Id: op_xlatb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xlatb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_al_ib.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_al_ib.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_al_ib.c 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_al_ib.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @file op_xor_al_ib.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_al_ib.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor al,ib opcode 0x34 * - * $Id: op_xor_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_al_ib.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_eax_iv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_eax_iv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_eax_iv.c 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_eax_iv.c 2011-05-16 11:34:41.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xor_eax_iv.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_eax_iv.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor eax,iv opcode 0x35 - * $Id: op_xor_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_eax_iv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xor_rb_rmb.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor rb,rmb opcode 0x32 - * $Id: op_xor_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_rb_rmb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c 2008-04-06 23:16:16.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xor_rmb_rb.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor rmb,rb opcode 0x30 - * $Id: op_xor_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_rmb_rb.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xor_rmv_rv.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor rmv,rv opcode 0x31 - * $Id: op_xor_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_rmv_rv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c --- eresi-0.8a25/libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c 2008-04-06 23:16:15.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c 2011-05-16 11:34:42.000000000 +0000 @@ -1,8 +1,9 @@ /** - * @file op_xor_rv_rmv.c - * @ingroup handlers_ia32 +* @file libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c + * + * @ingroup IA32_instrs * @brief Handler for instruction xor, opcode 0x33 - * $Id: op_xor_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ + * $Id: op_xor_rv_rmv.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/all-wcprops 2008-04-06 23:16:23.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,1805 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers -END -op_clc.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_clc.c -END -op_setae_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setae_rmb.c -END -op_prefix_ss.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_ss.c -END -op_xor_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_eax_iv.c -END -op_int_ib.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_int_ib.c -END -i386_jns.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jns.c -END -op_adc_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c -END -op_jle.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jle.c -END -op_push_iv.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/handlers/op_push_iv.c -END -op_sets_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sets_rmb.c -END -i386_paddusw_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c -END -op_stosd.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_stosd.c -END -i386_movq_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c -END -op_je.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_je.c -END -op_repnz.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_repnz.c -END -i386_cmovle.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovle.c -END -op_lodsd.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lodsd.c -END -op_jge.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jge.c -END -op_jmp_ap.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jmp_ap.c -END -op_cmpsd.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmpsd.c -END -op_loop.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_loop.c -END -op_immed_rmv_iv.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c -END -i386_punpckhbw_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c -END -i386_jl.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jl.c -END -op_adc_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c -END -op_adc_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c -END -op_and_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_rmb_rb.c -END -op_retf_i2.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_retf_i2.c -END -op_lss_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c -END -i386_mov_dr_rm.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c -END -i386_cmovp.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovp.c -END -op_esc5.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc5.c -END -op_jbe.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jbe.c -END -op_retf.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_retf.c -END -op_test_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_test_rmb_rb.c -END -op_cld.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cld.c -END -i386_rdmsr.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_rdmsr.c -END -i386_bts.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_bts.c -END -op_mov_ref_iv_al.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c -END -op_cmp_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c -END -op_sub_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_al_ib.c -END -i386_shrd_rmv_rv_ib.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c -END -op_sahf.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sahf.c -END -op_aaa.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_aaa.c -END -op_mov_subreg_ib.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c -END -op_prefix_ds.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_ds.c -END -op_mov_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c -END -i386_cmovbe.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovbe.c -END -op_lock.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lock.c -END -op_jns.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jns.c -END -op_scasd.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_scasd.c -END -op_les_rm_rmp.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_les_rm_rmp.c -END -op_cmc.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmc.c -END -op_imul_gv_ev_ib.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c -END -op_das.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_das.c -END -i386_je.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_je.c -END -op_opsize.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_opsize.c -END -i386_cmovns.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovns.c -END -i386_cmova.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmova.c -END -op_386sp.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_386sp.c -END -i386_jne.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jne.c -END -op_dec_reg.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_dec_reg.c -END -op_shr_rmv_ib.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c -END -i386_xadd.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_xadd.c -END -op_xor_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c -END -op_seta_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_seta_rmb.c -END -i386_movq_qq_pq.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c -END -op_esc6.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc6.c -END -op_pop_ss.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pop_ss.c -END -op_popf.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_popf.c -END -op_immed_rmb_ib.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c -END -op_in_eax_ref_ib.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c -END -op_adc_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c -END -i386_imul_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c -END -op_in_al_dx.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_in_al_dx.c -END -op_enter.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_enter.c -END -op_add_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_al_ib.c -END -op_mov_segr_rm.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_segr_rm.c -END -op_btr_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c -END -op_mov_rmv_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c -END -i386_shrd_rmv_rv_cl.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c -END -op_sub_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_eax_iv.c -END -i386_bsf.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_bsf.c -END -i386_pand_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c -END -op_out_dx_eax.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_out_dx_eax.c -END -op_sti.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sti.c -END -op_jg.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jg.c -END -op_xor_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c -END -op_xor_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c -END -i386_pxor_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c -END -op_jo.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jo.c -END -i386_cmovnl.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovnl.c -END -op_call_iv.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_call_iv.c -END -op_out_dx_al.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_out_dx_al.c -END -i386_cmovb.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovb.c -END -op_je_cxz.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_je_cxz.c -END -op_group6.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_group6.c -END -op_unary_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_unary_rmv.c -END -op_add_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_eax_iv.c -END -op_xchg_eax_reg.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c -END -op_prefix_es.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_es.c -END -op_jmp_iv.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jmp_iv.c -END -op_xchg_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c -END -i386_pmullw_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c -END -op_sbb_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c -END -op_esc7.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc7.c -END -op_cmp_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c -END -op_setl_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setl_rmb.c -END -i386_group12.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_group12.c -END -op_or_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_eax_iv.c -END -op_jne.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jne.c -END -op_loope.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_loope.c -END -i386_shld_rmv_rv_cl.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c -END -op_addsize.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_addsize.c -END -op_pop_ds.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pop_ds.c -END -op_pushf.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pushf.c -END -op_hlt.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_hlt.c -END -op_sbb_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_al_ib.c -END -op_setbe_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setbe_rmb.c -END -i386_cmovne.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovne.c -END -op_aas.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_aas.c -END -op_jp.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jp.c -END -op_cmp_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c -END -op_cmp_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c -END -op_mov_rmb_ib.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c -END -i386_jg.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jg.c -END -op_bound_gv_ma.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_bound_gv_ma.c -END -op_group7.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_group7.c -END -op_ret_i2.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_ret_i2.c -END -op_setno_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setno_rmb.c -END -op_cmp_xchg.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_xchg.c -END -op_push_ib.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_ib.c -END -op_esc0.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc0.c -END -op_xor_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c -END -i386_paddusb_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c -END -i386_cmovs.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovs.c -END -op_setg_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setg_rmb.c -END -op_iret.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_iret.c -END -op_push_cs.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_cs.c -END -i386_xstorenrg.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_xstorenrg.c -END -op_mov_al_ref_iv.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c -END -op_seto_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_seto_rmb.c -END -op_xchg_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c -END -op_sub_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c -END -i386_por_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_por_pq_qq.c -END -op_insw.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_insw.c -END -op_outsw.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_outsw.c -END -op_push_ss.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_ss.c -END -op_aad.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_aad.c -END -op_prefix_fs.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_fs.c -END -op_stc.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_stc.c -END -op_immed_rmv_ib.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c -END -op_ja.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_ja.c -END -op_pop_reg.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pop_reg.c -END -op_mov_reg_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_reg_iv.c -END -op_lds_rm_rmp.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c -END -i386_wbinvd.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_wbinvd.c -END -op_add_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_rb_rmb.c -END -i386_cpuid.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cpuid.c -END -op_sub_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c -END -op_sub_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c -END -i386_jp.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jp.c -END -op_pop_es.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pop_es.c -END -op_in_al_ref_ib.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c -END -op_sbb_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c -END -op_ret.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_ret.c -END -op_esc1.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc1.c -END -i386_cmovl.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovl.c -END -op_and_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_eax_iv.c -END -op_setb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setb_rmb.c -END -i386_mov_rm_cr.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c -END -op_popa.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_popa.c -END -op_cmp_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c -END -i386_jnp.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jnp.c -END -op_or_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_rb_rmb.c -END -op_cmp_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmp_al_ib.c -END -op_setge_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setge_rmb.c -END -op_test_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_test_eax_iv.c -END -op_out_ref_ib_eax.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c -END -i386_group14.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_group14.c -END -op_int_3.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_int_3.c -END -i386_cmovnle.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovnle.c -END -op_mov_rm_segr.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rm_segr.c -END -i386_push_fs.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_push_fs.c -END -op_add_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_rv_rmv.c -END -op_add_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_rmv_rv.c -END -op_jno.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jno.c -END -i386_bswap.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_bswap.c -END -op_mov_ref_iv_eax.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c -END -op_std.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_std.c -END -op_ud2a.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_ud2a.c -END -op_shift_rmb_cl.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c -END -i386_movzbl_rv_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c -END -op_jb.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jb.c -END -op_aam.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_aam.c -END -op_in_eax_dx.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_in_eax_dx.c -END -i386_pop_fs.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_pop_fs.c -END -op_sbb_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c -END -op_sbb_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c -END -i386_ja.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_ja.c -END -op_push_ds.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_ds.c -END -op_inc_reg.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_inc_reg.c -END -op_cwtl.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cwtl.c -END -op_into.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_into.c -END -op_fwait.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/854/trunk/libasm/src/arch/ia32/handlers/op_fwait.c -END -op_or_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_rmv_rv.c -END -op_or_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_rv_rmv.c -END -i386_cmovno.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovno.c -END -op_setne_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setne_rmb.c -END -i386_cmove.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmove.c -END -op_movsb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_movsb.c -END -op_prefix_gs.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_gs.c -END -op_indir_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_indir_rmv.c -END -i386_packuswb_pq_qq.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c -END -op_esc2.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc2.c -END -op_loopne.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_loopne.c -END -op_shift_rmb_1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_shift_rmb_1.c -END -i386_mov_cr_rm.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c -END -op_imul_rv_rmv_iv.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c -END -i386_movzwl_rv_rm2.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c -END -op_sete_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sete_rmb.c -END -op_cli.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cli.c -END -i386_bsr_rv_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c -END -i386_jae.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jae.c -END -op_sub_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c -END -op_adc_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_al_ib.c -END -i386_group15.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_group15.c -END -i386_btrl.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_btrl.c -END -op_pusha.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pusha.c -END -op_shift_rmv_1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_shift_rmv_1.c -END -op_adc_eax_iv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_adc_eax_iv.c -END -i386_movd_pd_qd.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c -END -op_jnp.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jnp.c -END -op_stosb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_stosb.c -END -op_unary_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/handlers/op_unary_rmb.c -END -op_jmp_ib.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jmp_ib.c -END -op_arpl_ew_rw.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c -END -op_lodsb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lodsb.c -END -op_cmpsb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cmpsb.c -END -i386_jb.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jb.c -END -op_or_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_al_ib.c -END -op_xlatb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xlatb.c -END -op_add_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_add_rmb_rb.c -END -op_int1.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_int1.c -END -op_setle_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setle_rmb.c -END -op_js.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_js.c -END -i386_cmovnp.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovnp.c -END -op_test_al_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_test_al_rb.c -END -i386_movsbl_rv_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c -END -op_and_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_rb_rmb.c -END -i386_jle.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jle.c -END -op_mov_eax_ref_iv.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c -END -op_setnp_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setnp_rmb.c -END -op_sbb_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c -END -op_insb.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_insb.c -END -op_outsb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_outsb.c -END -op_leave.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_leave.c -END -op_esc3.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc3.c -END -i386_bt_rm_r.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_bt_rm_r.c -END -op_or_rmb_rb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_or_rmb_rb.c -END -op_push_es.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_es.c -END -op_setp_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setp_rmb.c -END -op_push_reg.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_push_reg.c -END -i386_emms.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_emms.c -END -i386_group16.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_group16.c -END -op_repz.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_repz.c -END -i386_jge.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jge.c -END -op_mov_rb_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c -END -op_lea_rv_m.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/handlers/op_lea_rv_m.c -END -op_daa.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_daa.c -END -op_cltd.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_cltd.c -END -op_and_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_al_ib.c -END -i386_movswl_rv_rm2.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c -END -op_scasb.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_scasb.c -END -op_and_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_rmv_rv.c -END -op_and_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_and_rv_rmv.c -END -op_xor_al_ib.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_xor_al_ib.c -END -op_jae.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jae.c -END -i386_punpcklbw_pq_qd.c -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c -END -op_jl.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_jl.c -END -i386_shld.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_shld.c -END -op_shr_rmb_ib.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c -END -op_lahf.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_lahf.c -END -op_test_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_test_rmv_rv.c -END -i386_jbe.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_jbe.c -END -op_shift_rmv_cl.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c -END -op_prefix_cs.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_prefix_cs.c -END -op_pop_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_pop_rmv.c -END -op_incdec_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_incdec_rmb.c -END -i386_cmovae.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovae.c -END -i386_js.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_js.c -END -op_movsd.c -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_movsd.c -END -op_out_ref_ib_al.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c -END -i386_rdtsc.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_rdtsc.c -END -op_nop.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_nop.c -END -op_mov_rv_rmv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c -END -op_mov_rmv_rv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c -END -op_setns_rmb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_setns_rmb.c -END -i386_cmovo.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/i386_cmovo.c -END -op_esc4.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/handlers/op_esc4.c -END diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/entries 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,3628 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/ia32/handlers -http://svn.eresi-project.org/svn - - - -2008-03-14T09:48:44.987521Z -909 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -op_clc.c -file - - - - -2008-04-06T23:16:11.246532Z -0ba39edf347b99327943d2817a73e571 -2008-02-19T17:09:59.893936Z -849 -may - -op_setae_rmb.c -file - - - - -2008-04-06T23:16:11.116887Z -c582ac3de5ad3052de79a74696a41e37 -2008-02-19T17:09:59.893936Z -849 -may - -op_prefix_ss.c -file - - - - -2008-04-06T23:16:11.291137Z -c123f2c184fde85ed224cbf4cd015e04 -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_eax_iv.c -file - - - - -2008-04-06T23:16:11.676899Z -dc714707838230dd8e4c86bd99b75a06 -2008-02-19T17:09:59.893936Z -849 -may - -op_int_ib.c -file - - - - -2008-04-06T23:16:12.273879Z -9cb0d779ee6dbbd1e991ca70024ec6a4 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jns.c -file - - - - -2008-04-06T23:16:12.838026Z -abd0b2ade513d222dc9ec8569f66be5e -2008-02-19T17:09:59.893936Z -849 -may - -op_adc_rb_rmb.c -file - - - - -2008-04-06T23:16:14.082876Z -7e6070d3c231e43831121a75df658f78 -2008-02-19T17:09:59.893936Z -849 -may - -op_jle.c -file - - - - -2008-04-06T23:16:13.757885Z -4ab800d23b910a708979b4de93b56dab -2008-02-19T17:09:59.893936Z -849 -may - -op_push_iv.c -file - - - - -2008-04-06T23:16:14.127685Z -bf7b3fea36c0ddad1779a893c6053fc5 -2008-03-07T17:49:34.750118Z -896 -thorkill - -op_sets_rmb.c -file - - - - -2008-04-06T23:16:14.139202Z -6c1939c1ba03874bd265af4e10c0fa36 -2008-02-19T17:09:59.893936Z -849 -may - -i386_paddusw_pq_qq.c -file - - - - -2008-04-06T23:16:14.150718Z -66bdfd9323fd2f8545234eb9350c58e7 -2008-02-19T17:09:59.893936Z -849 -may - -op_stosd.c -file - - - - -2008-04-06T23:16:14.161899Z -0752ce91ee6e1f7089d65a4bf9e49a88 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movq_pq_qq.c -file - - - - -2008-04-06T23:16:14.196876Z -99039b759cd44d000ed0ebc2d7f0cd2c -2008-02-19T17:09:59.893936Z -849 -may - -op_je.c -file - - - - -2008-04-06T23:16:14.185265Z -e46a87ef0c881dc963fc2b074e5a6268 -2008-02-19T17:09:59.893936Z -849 -may - -op_repnz.c -file - - - - -2008-04-06T23:16:14.173876Z -9daf1e85dc7bcd26f34ef9b786aca693 -2008-03-14T09:48:44.987521Z -909 -enioh - -i386_cmovle.c -file - - - - -2008-04-06T23:16:14.208298Z -3cd1a85e8d01971936505726996c0cca -2008-02-19T17:09:59.893936Z -849 -may - -op_lodsd.c -file - - - - -2008-04-06T23:16:14.219876Z -3ddee90e78d35eb4bf2a4f2b2288eeca -2008-02-19T17:09:59.893936Z -849 -may - -op_jge.c -file - - - - -2008-04-06T23:16:14.230905Z -fc16bdd8a4240852b1c6d21729aa5653 -2008-02-19T17:09:59.893936Z -849 -may - -op_jmp_ap.c -file - - - - -2008-04-06T23:16:14.242900Z -2630933795c80d1a41871aee521ef1a4 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmpsd.c -file - - - - -2008-04-06T23:16:14.253900Z -47ccc53211a9ac1379cb88073dcc7d10 -2008-02-19T17:09:59.893936Z -849 -may - -op_loop.c -file - - - - -2008-04-06T23:16:14.265937Z -8fbd0ffcbb3cb325083ab5094fc14fc7 -2008-02-19T17:09:59.893936Z -849 -may - -op_immed_rmv_iv.c -file - - - - -2008-04-06T23:16:14.277511Z -38afcdbe4ca791be84b8a38ad48fa3fe -2008-02-19T17:09:59.893936Z -849 -may - -i386_punpckhbw_pq_qq.c -file - - - - -2008-04-06T23:16:14.289028Z -753338ecad2570639fc28d872222747f -2008-02-19T17:09:59.893936Z -849 -may - -i386_jl.c -file - - - - -2008-04-06T23:16:14.299954Z -641bd38dd18a7e41c8d8458db0c7df55 -2008-02-19T17:09:59.893936Z -849 -may - -op_adc_rmv_rv.c -file - - - - -2008-04-06T23:16:14.313877Z -97a7db5eedaab23241b0adc6cfd2d582 -2008-02-19T17:09:59.893936Z -849 -may - -op_adc_rv_rmv.c -file - - - - -2008-04-06T23:16:14.325197Z -08685e43cc9695d5a3f0e98c83fcd832 -2008-02-19T17:09:59.893936Z -849 -may - -op_and_rmb_rb.c -file - - - - -2008-04-06T23:16:14.336876Z -6e11017aefcffd5eee4ce6e42c72943e -2008-02-19T17:09:59.893936Z -849 -may - -op_retf_i2.c -file - - - - -2008-04-06T23:16:14.348288Z -6ce7576663d2dcc0a99eca3debb2ca4b -2008-03-14T09:48:44.987521Z -909 -enioh - -op_lss_rv_rmv.c -file - - - - -2008-04-06T23:16:14.359880Z -ef019ff103edba5de81b24dfae7c8b87 -2008-02-19T17:09:59.893936Z -849 -may - -op_esc5.c -file - - - - -2008-04-06T23:16:14.394525Z -73c7ce2b4ef5ba93fc3b0688ddbc4725 -2008-02-19T17:09:59.893936Z -849 -may - -i386_mov_dr_rm.c -file - - - - -2008-04-06T23:16:14.370899Z -2d0764bae8d8605b050c6a7c3ec8d77a -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovp.c -file - - - - -2008-04-06T23:16:14.382947Z -5b27b366fac4b9c66ef04c395edf511e -2008-02-19T17:09:59.893936Z -849 -may - -op_jbe.c -file - - - - -2008-04-06T23:16:14.417962Z -df4ee1c8e5d4bec0aabee2fb8d6e33e8 -2008-02-19T17:09:59.893936Z -849 -may - -op_retf.c -file - - - - -2008-04-06T23:16:14.405899Z -f6fb3d7de95fbe9ba7f8da935ee1a651 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_test_rmb_rb.c -file - - - - -2008-04-06T23:16:14.452630Z -220ae2c6e33f1dd710bb221e1bb046a5 -2008-02-19T17:09:59.893936Z -849 -may - -op_cld.c -file - - - - -2008-04-06T23:16:14.440901Z -130f4a149f8f40bce6acc70de572d7ac -2008-02-19T17:09:59.893936Z -849 -may - -i386_rdmsr.c -file - - - - -2008-04-06T23:16:14.428903Z -4c6b5ba5f220db6d97a27ca524d654e9 -2008-02-19T17:09:59.893936Z -849 -may - -i386_bts.c -file - - - - -2008-04-06T23:16:14.463899Z -70a32333512281409586550e6e71636d -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_ref_iv_al.c -file - - - - -2008-04-06T23:16:14.475778Z -dc5cdef05b6203f0dd2e41f889d46f44 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_eax_iv.c -file - - - - -2008-04-06T23:16:14.487351Z -ce7ec4af6e2883e598d9f8fc1e8455e6 -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_al_ib.c -file - - - - -2008-04-06T23:16:14.498887Z -4945e9fc3e71f3cdae12d3a60180300e -2008-02-19T17:09:59.893936Z -849 -may - -i386_shrd_rmv_rv_ib.c -file - - - - -2008-04-06T23:16:14.510500Z -74357794bb79a7f2867534d5e1947f72 -2008-02-19T17:09:59.893936Z -849 -may - -op_sahf.c -file - - - - -2008-04-06T23:16:14.522017Z -835807ca8e010c54e61a243c41da564f -2008-03-14T09:48:44.987521Z -909 -enioh - -op_aaa.c -file - - - - -2008-04-06T23:16:14.545222Z -c8087923c291fa7114008c56135c81a1 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_subreg_ib.c -file - - - - -2008-04-06T23:16:14.532898Z -346b3ee04f951f08f25f8ab701b74482 -2008-03-07T17:49:34.750118Z -896 -thorkill - -op_prefix_ds.c -file - - - - -2008-04-06T23:16:14.556876Z -bd5d895034001c53ffa29dec30da0913 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rmb_rb.c -file - - - - -2008-04-06T23:16:14.923929Z -974f5e3fb2f5230d5d548436b922ec33 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovbe.c -file - - - - -2008-04-06T23:16:14.935505Z -b65fabc215953b2604b76f00cf27081a -2008-02-19T17:09:59.893936Z -849 -may - -op_lock.c -file - - - - -2008-04-06T23:16:14.948642Z -27bc17cf0b44b1b5b5a99d384976bcd3 -2008-02-19T17:09:59.893936Z -849 -may - -op_jns.c -file - - - - -2008-04-06T23:16:14.960275Z -005d7237a78676fd66d9ef3a8f4e3610 -2008-02-19T17:09:59.893936Z -849 -may - -op_scasd.c -file - - - - -2008-04-06T23:16:14.971876Z -317fbbbbfa65690cf715224ceaf44aa4 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_les_rm_rmp.c -file - - - - -2008-04-06T23:16:14.983424Z -a7ba1d311b1adf1fd221d48e1fe548dd -2008-02-19T17:09:59.893936Z -849 -may - -op_cmc.c -file - - - - -2008-04-06T23:16:14.995055Z -cd18b59c05ab46f9d4c5d9793cd086d7 -2008-02-19T17:09:59.893936Z -849 -may - -op_imul_gv_ev_ib.c -file - - - - -2008-04-06T23:16:15.006630Z -d556f71928d7dae3a17414fa9388e885 -2008-02-19T17:09:59.893936Z -849 -may - -op_das.c -file - - - - -2008-04-06T23:16:15.017882Z -56f5a455539c2588047295389e928528 -2008-02-19T17:09:59.893936Z -849 -may - -i386_je.c -file - - - - -2008-04-06T23:16:15.040900Z -e61eab488a5fa92f42e172a0ba536f0c -2008-02-19T17:09:59.893936Z -849 -may - -op_opsize.c -file - - - - -2008-04-06T23:16:15.029879Z -e93f1aa9c833789a7b3c98ba76ea4457 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovns.c -file - - - - -2008-04-06T23:16:15.120233Z -bd0b696c6ab4b5d48a6fd0323d5a8302 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmova.c -file - - - - -2008-04-06T23:16:15.107879Z -976f9da6af33b6b84b2e13660d3ec74d -2008-02-19T17:09:59.893936Z -849 -may - -op_386sp.c -file - - - - -2008-04-06T23:16:15.131158Z -af401027cd8a84e2b55c9ab05948a487 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jne.c -file - - - - -2008-04-06T23:16:15.143439Z -610729bc7ac88b63871df183d3fe960f -2008-02-19T17:09:59.893936Z -849 -may - -op_dec_reg.c -file - - - - -2008-04-06T23:16:15.155012Z -979af39c5a8c6f35b65700c5348ef75c -2008-02-19T17:09:59.893936Z -849 -may - -op_shr_rmv_ib.c -file - - - - -2008-04-06T23:16:15.166881Z -bb4d7448365b82a9092b105e924ffee1 -2008-03-14T09:48:44.987521Z -909 -enioh - -i386_xadd.c -file - - - - -2008-04-06T23:16:15.178192Z -006671b376627b8dbe9704293744d4da -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_rb_rmb.c -file - - - - -2008-04-06T23:16:15.189906Z -dd59b059e46b164a4999f588916252bb -2008-02-19T17:09:59.893936Z -849 -may - -op_seta_rmb.c -file - - - - -2008-04-06T23:16:15.200909Z -e8c323514e44b12a6483b6b340588910 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movq_qq_pq.c -file - - - - -2008-04-06T23:16:15.213114Z -345406ebc6dd0d266427de70923111c2 -2008-02-19T17:09:59.893936Z -849 -may - -op_esc6.c -file - - - - -2008-04-06T23:16:15.224877Z -f90e40d1d216d71d8d4ed9dc981f71b4 -2008-02-19T17:09:59.893936Z -849 -may - -op_pop_ss.c -file - - - - -2008-04-06T23:16:15.236378Z -0f0deef6d573cac5f4b07cdcac3da65c -2008-02-19T17:09:59.893936Z -849 -may - -op_popf.c -file - - - - -2008-04-06T23:16:15.248010Z -4f7d028d747fef79610dc7027da074a7 -2008-02-19T17:09:59.893936Z -849 -may - -op_immed_rmb_ib.c -file - - - - -2008-04-06T23:16:15.260900Z -c903ced868788fe40899b7779a4f8c7b -2008-02-19T17:09:59.893936Z -849 -may - -op_in_eax_ref_ib.c -file - - - - -2008-04-06T23:16:15.272876Z -fe4fd69dc7f050b176a9ef1487f9bb52 -2008-02-19T17:09:59.893936Z -849 -may - -op_adc_rmb_rb.c -file - - - - -2008-04-06T23:16:15.284468Z -7c3f8333715f0eb3c0a2c76813ab5240 -2008-02-19T17:09:59.893936Z -849 -may - -i386_imul_rv_rmv.c -file - - - - -2008-04-06T23:16:15.296101Z -14058ee406cd52c81efcadd4444aff50 -2008-02-19T17:09:59.893936Z -849 -may - -op_in_al_dx.c -file - - - - -2008-04-06T23:16:15.307876Z -cf4f97ae31baa706105295501811c450 -2008-02-19T17:09:59.893936Z -849 -may - -op_enter.c -file - - - - -2008-04-06T23:16:15.319366Z -8a47bcb4281f73e8f50662cabbef275a -2008-02-19T17:09:59.893936Z -849 -may - -op_add_al_ib.c -file - - - - -2008-04-06T23:16:15.330900Z -2bb2f0c323efaeb760caa9523ba2d846 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_segr_rm.c -file - - - - -2008-04-06T23:16:15.342157Z -0466bad4d6c04e80c37f4b1b9c107911 -2008-02-19T17:09:59.893936Z -849 -may - -op_btr_rmv_rv.c -file - - - - -2008-04-06T23:16:15.354320Z -f594eeed0923f0c04b4da2e0021caeb9 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rmv_iv.c -file - - - - -2008-04-06T23:16:15.365953Z -be7b7ebf8f3f329923db8daa7728ab08 -2008-02-19T17:09:59.893936Z -849 -may - -i386_shrd_rmv_rv_cl.c -file - - - - -2008-04-06T23:16:15.377584Z -e9eddbc6f571764b6c6b9c3e2b281374 -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_eax_iv.c -file - - - - -2008-04-06T23:16:15.389274Z -565f8d3cf43920a34369f0fd3c5b7b90 -2008-02-19T17:09:59.893936Z -849 -may - -i386_bsf.c -file - - - - -2008-04-06T23:16:15.400900Z -607d2425b39892397acc8fa4a2f94e1d -2008-02-19T17:09:59.893936Z -849 -may - -i386_pand_pq_qq.c -file - - - - -2008-04-06T23:16:15.411904Z -5b9bb893cb2428ad1e427cc983803b33 -2008-02-19T17:09:59.893936Z -849 -may - -op_out_dx_eax.c -file - - - - -2008-04-06T23:16:15.424228Z -4b6e52cf9dfd37055c6754100e9f11c8 -2008-02-19T17:09:59.893936Z -849 -may - -op_sti.c -file - - - - -2008-04-06T23:16:15.435899Z -1fcee86a47f501d7b08fdcb02470d5f5 -2008-02-19T17:09:59.893936Z -849 -may - -op_jg.c -file - - - - -2008-04-06T23:16:15.447549Z -c3a2d6ba7fb119b568c653051f9f015c -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_rmv_rv.c -file - - - - -2008-04-06T23:16:15.459241Z -d85ee093b2b0ab1f34a29815fda47e09 -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_rv_rmv.c -file - - - - -2008-04-06T23:16:15.470877Z -4c106e42f7ae799da2fa66ebca7c7ee1 -2008-02-19T17:09:59.893936Z -849 -may - -i386_pxor_pq_qq.c -file - - - - -2008-04-06T23:16:15.481904Z -1430d6985e3416472fd41f769112e7cf -2008-02-19T17:09:59.893936Z -849 -may - -op_jo.c -file - - - - -2008-04-06T23:16:15.493900Z -59c31d19b70491d5887f916131c639d8 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovnl.c -file - - - - -2008-04-06T23:16:15.507563Z -74db35bb9c1c5689dafa09229f848875 -2008-02-19T17:09:59.893936Z -849 -may - -op_call_iv.c -file - - - - -2008-04-06T23:16:15.519254Z -7ca9d3a2e0b32d81b66a5c5aa467bc72 -2008-02-19T17:09:59.893936Z -849 -may - -op_out_dx_al.c -file - - - - -2008-04-06T23:16:15.530899Z -7dd7d4007119514891c7311483deed3e -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovb.c -file - - - - -2008-04-06T23:16:15.542632Z -e4ae81cba6455a79d0ec0c8ff98eef28 -2008-02-19T17:09:59.893936Z -849 -may - -op_je_cxz.c -file - - - - -2008-04-06T23:16:15.554323Z -327aafc0e0b7a30c827558b5d6f37874 -2008-02-19T17:09:59.893936Z -849 -may - -op_group6.c -file - - - - -2008-04-06T23:16:15.577471Z -414e8eae3019ca68b63c4ea169e8206b -2008-02-19T17:09:59.893936Z -849 -may - -op_unary_rmv.c -file - - - - -2008-04-06T23:16:15.589011Z -f32468a655328e17c0d7429943ba09c7 -2008-02-19T17:09:59.893936Z -849 -may - -op_add_eax_iv.c -file - - - - -2008-04-06T23:16:15.600876Z -df5baef8e17f17695db3b299d4207e47 -2008-02-19T17:09:59.893936Z -849 -may - -op_xchg_eax_reg.c -file - - - - -2008-04-06T23:16:15.612598Z -01ce415094c006671ffb98b58127a0b7 -2008-02-19T17:09:59.893936Z -849 -may - -op_prefix_es.c -file - - - - -2008-04-06T23:16:15.624310Z -c59d652a7e57c7732dacea1b700851c6 -2008-02-19T17:09:59.893936Z -849 -may - -op_jmp_iv.c -file - - - - -2008-04-06T23:16:15.635979Z -db124a777720150e14d4bb53a4986c0b -2008-02-19T17:09:59.893936Z -849 -may - -op_xchg_rmv_rv.c -file - - - - -2008-04-06T23:16:15.647726Z -f8e2b826bf14ce06c0256110dcb2f84b -2008-02-19T17:09:59.893936Z -849 -may - -i386_pmullw_pq_qq.c -file - - - - -2008-04-06T23:16:15.658882Z -56ab97f652374c0c1a6a160678c7d283 -2008-02-19T17:09:59.893936Z -849 -may - -op_sbb_eax_iv.c -file - - - - -2008-04-06T23:16:15.670899Z -cbe60ac0a4d3389bbe421209452a4646 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_esc7.c -file - - - - -2008-04-06T23:16:15.682896Z -5f870dd6cbd00dbd1aa7417ad2697745 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_rb_rmb.c -file - - - - -2008-04-06T23:16:15.694543Z -43c50104d169999b1905256c83d5ad2d -2008-02-19T17:09:59.893936Z -849 -may - -op_setl_rmb.c -file - - - - -2008-04-06T23:16:15.705903Z -523be991ffb576c036fe0f85fe8fc40f -2008-02-19T17:09:59.893936Z -849 -may - -i386_group12.c -file - - - - -2008-04-06T23:16:15.717924Z -79a18a7273165e924054b58de5f51090 -2008-02-19T17:09:59.893936Z -849 -may - -op_or_eax_iv.c -file - - - - -2008-04-06T23:16:15.730903Z -d66d463d8e3945ebe57c1f7d3fb200c1 -2008-02-19T17:09:59.893936Z -849 -may - -op_jne.c -file - - - - -2008-04-06T23:16:15.742920Z -363633ffb23fb407957614a21f15d4bc -2008-02-19T17:09:59.893936Z -849 -may - -op_loope.c -file - - - - -2008-04-06T23:16:15.753900Z -726f58c158ae3f8af6ea3495c8e54a86 -2008-02-19T17:09:59.893936Z -849 -may - -i386_shld_rmv_rv_cl.c -file - - - - -2008-04-06T23:16:15.766246Z -cdeccc230020beb622185eda9df3960c -2008-02-19T17:09:59.893936Z -849 -may - -op_addsize.c -file - - - - -2008-04-06T23:16:15.777900Z -3ffe75d2a48d73c2d806970a5e6e7b24 -2008-02-19T17:09:59.893936Z -849 -may - -op_pop_ds.c -file - - - - -2008-04-06T23:16:15.789534Z -499fba15d5f5fc4222286d23502fdb52 -2008-02-19T17:09:59.893936Z -849 -may - -op_pushf.c -file - - - - -2008-04-06T23:16:15.800899Z -d5e904b4c83fb086126dd09ec3a97330 -2008-02-19T17:09:59.893936Z -849 -may - -op_hlt.c -file - - - - -2008-04-06T23:16:15.812891Z -60da27ec579ec63346dffcd2d135099e -2008-02-19T17:09:59.893936Z -849 -may - -op_sbb_al_ib.c -file - - - - -2008-04-06T23:16:15.823994Z -5eb4710c9dc0fa1ada360f50a512b7e3 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_setbe_rmb.c -file - - - - -2008-04-06T23:16:15.836214Z -5f06c72a3b910dd79c34616adafe080f -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovne.c -file - - - - -2008-04-06T23:16:15.847876Z -6a40d24e7a75901a8d4cda7498ffda7e -2008-02-19T17:09:59.893936Z -849 -may - -op_aas.c -file - - - - -2008-04-06T23:16:15.859562Z -b8e54877f52ae06d7ef9b967f037218a -2008-02-19T17:09:59.893936Z -849 -may - -op_jp.c -file - - - - -2008-04-06T23:16:15.870899Z -115510c6f8c096aaf8d1539a521de6d4 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_rmv_rv.c -file - - - - -2008-04-06T23:16:15.882876Z -a2c3108665090d89c27e23f2a2fe150c -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_rv_rmv.c -file - - - - -2008-04-06T23:16:15.894489Z -501d3af36e92497760175b8fb4d0c958 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rmb_ib.c -file - - - - -2008-04-06T23:16:15.905900Z -b9d9d25a8b6c7921683de692942200b5 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jg.c -file - - - - -2008-04-06T23:16:15.917877Z -7176b2b8e918e9ae0301804f5ffb257f -2008-02-19T17:09:59.893936Z -849 -may - -op_bound_gv_ma.c -file - - - - -2008-04-06T23:16:15.928900Z -63f324cec08e30feb2325485442c92dd -2008-02-19T17:09:59.893936Z -849 -may - -op_group7.c -file - - - - -2008-04-06T23:16:15.940902Z -7238943f04c66964b9d38ca7cc0e39f2 -2008-02-19T17:09:59.893936Z -849 -may - -op_ret_i2.c -file - - - - -2008-04-06T23:16:15.952882Z -8c859734295b9065c505ed12de124e1d -2008-02-19T17:09:59.893936Z -849 -may - -op_setno_rmb.c -file - - - - -2008-04-06T23:16:15.977800Z -d14996973d05233fc70d7a6cc7d851fa -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_xchg.c -file - - - - -2008-04-06T23:16:15.965909Z -a379f0974ccb03364ec348d0484f93ef -2008-02-19T17:09:59.893936Z -849 -may - -op_push_ib.c -file - - - - -2008-04-06T23:16:15.989398Z -f01ede2b253292ebf2705c2246325107 -2008-02-19T17:09:59.893936Z -849 -may - -op_esc0.c -file - - - - -2008-04-06T23:16:16.000903Z -3703eb5329f0af451e1be0820b1f3df3 -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_rmb_rb.c -file - - - - -2008-04-06T23:16:16.012882Z -23fa190df4475880d13ccac3831657fd -2008-02-19T17:09:59.893936Z -849 -may - -i386_paddusb_pq_qq.c -file - - - - -2008-04-06T23:16:16.024409Z -eeae9b6c3ab1945a9f56be3beafb8419 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovs.c -file - - - - -2008-04-06T23:16:16.170015Z -c32dae59f22b8ee1bc3e94f4859ec216 -2008-02-19T17:09:59.893936Z -849 -may - -op_setg_rmb.c -file - - - - -2008-04-06T23:16:16.036100Z -92be4650e312912a2e3351211705790b -2008-02-19T17:09:59.893936Z -849 -may - -op_iret.c -file - - - - -2008-04-06T23:16:16.181725Z -08e564ed7d28aac9d6c5bb7635f6c80b -2008-02-19T17:09:59.893936Z -849 -may - -op_push_cs.c -file - - - - -2008-04-06T23:16:16.192899Z -6f3bb7abe2cb1ac2d77d442ea033d261 -2008-02-19T17:09:59.893936Z -849 -may - -i386_xstorenrg.c -file - - - - -2008-04-06T23:16:16.205025Z -0ed59e0d4c13f752e2712fe9e7634878 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_al_ref_iv.c -file - - - - -2008-04-06T23:16:16.215925Z -ccdcd47ad04aab346663edc168ceaec3 -2008-02-19T17:09:59.893936Z -849 -may - -op_seto_rmb.c -file - - - - -2008-04-06T23:16:16.228406Z -219eed4635a540e4a93ea80472f0e24f -2008-02-19T17:09:59.893936Z -849 -may - -op_xchg_rmb_rb.c -file - - - - -2008-04-06T23:16:17.295877Z -966972759a733d6d825e40c911cd2619 -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_rb_rmb.c -file - - - - -2008-04-06T23:16:16.498031Z -cc5daad30185d3f05a12dcd01fe99e8f -2008-02-19T17:09:59.893936Z -849 -may - -i386_por_pq_qq.c -file - - - - -2008-04-06T23:16:16.240097Z -d91640f0307d7ad0571aac35ee7c16cb -2008-02-19T17:09:59.893936Z -849 -may - -op_insw.c -file - - - - -2008-04-06T23:16:18.327403Z -0adf72537e25314d0a5cbd0e2d3e350a -2008-02-19T17:09:59.893936Z -849 -may - -op_outsw.c -file - - - - -2008-04-06T23:16:19.057334Z -acfda052423815e98e6d96d17d338288 -2008-02-19T17:09:59.893936Z -849 -may - -op_push_ss.c -file - - - - -2008-04-06T23:16:19.766079Z -758420deaf4813338fac5f2be109f3d7 -2008-02-19T17:09:59.893936Z -849 -may - -op_aad.c -file - - - - -2008-04-06T23:16:20.072529Z -907ae59df76459b515240840e14ab80d -2008-02-19T17:09:59.893936Z -849 -may - -op_prefix_fs.c -file - - - - -2008-04-06T23:16:20.026039Z -a3db6e26347e634023a81fe1923ccf95 -2008-02-19T17:09:59.893936Z -849 -may - -op_stc.c -file - - - - -2008-04-06T23:16:20.395877Z -a029662fbf2050a8a774ce74e4970b54 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_immed_rmv_ib.c -file - - - - -2008-04-06T23:16:20.339876Z -535702a90d86974b0e37e7bf23dd9175 -2008-02-19T17:09:59.893936Z -849 -may - -op_ja.c -file - - - - -2008-04-06T23:16:20.440688Z -fc0c9967f456caa3815271424aa443fd -2008-02-19T17:09:59.893936Z -849 -may - -op_pop_reg.c -file - - - - -2008-04-06T23:16:20.485651Z -f2b8753a8978fcb7718a37636441f4d0 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_reg_iv.c -file - - - - -2008-04-06T23:16:20.519449Z -4ba8a6d79e3c0af664443c7b71653c74 -2008-02-19T17:09:59.893936Z -849 -may - -op_lds_rm_rmp.c -file - - - - -2008-04-06T23:16:20.531081Z -5e45acf72d3e8fb9ee7bd892d055794e -2008-02-19T17:09:59.893936Z -849 -may - -i386_wbinvd.c -file - - - - -2008-04-06T23:16:20.542714Z -57fdc980bcd7e88211f7de163b2cfe99 -2008-02-19T17:09:59.893936Z -849 -may - -op_add_rb_rmb.c -file - - - - -2008-04-06T23:16:20.554345Z -fdd68b2de3b5e730d272f340dfa291d2 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cpuid.c -file - - - - -2008-04-06T23:16:20.565920Z -77ce6b5f45a888efc8e665cc3ae0d764 -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_rv_rmv.c -file - - - - -2008-04-06T23:16:20.612276Z -0f639fa4a607d277e2728db4e6d3a756 -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_rmv_rv.c -file - - - - -2008-04-06T23:16:20.599904Z -ebcb3b0a120ede715c9fffb1ac34222e -2008-02-19T17:09:59.893936Z -849 -may - -i386_jp.c -file - - - - -2008-04-06T23:16:20.577551Z -4d927d1cd2f0bc70d981d4044babb1a2 -2008-02-19T17:09:59.893936Z -849 -may - -op_pop_es.c -file - - - - -2008-04-06T23:16:20.623905Z -0680801a395337fafeb4431deca0e43b -2008-02-19T17:09:59.893936Z -849 -may - -op_in_al_ref_ib.c -file - - - - -2008-04-06T23:16:20.634950Z -7830d80be94c64601a20221d3e516049 -2008-02-19T17:09:59.893936Z -849 -may - -op_sbb_rb_rmb.c -file - - - - -2008-04-06T23:16:20.647169Z -1f37f79d4f0bc8d77058d3c4237d5fc4 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_ret.c -file - - - - -2008-04-06T23:16:20.658876Z -302ea2fb4dba16c67bfd958bab600241 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_esc1.c -file - - - - -2008-04-06T23:16:20.682065Z -caa299d14b114ae2f96f10e816aa28ed -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovl.c -file - - - - -2008-04-06T23:16:20.670434Z -1942a9c1fb82f249fc9c4e5de3243c04 -2008-02-19T17:09:59.893936Z -849 -may - -op_and_eax_iv.c -file - - - - -2008-04-06T23:16:20.705329Z -3acb8c904573786fae6d64b4b5ae79ae -2008-02-19T17:09:59.893936Z -849 -may - -op_setb_rmb.c -file - - - - -2008-04-06T23:16:20.692899Z -67139ca49174ecf067f79713792e5519 -2008-02-19T17:09:59.893936Z -849 -may - -i386_mov_rm_cr.c -file - - - - -2008-04-06T23:16:20.718580Z -05e99ed413d47e73c4b18a0288eef9cd -2008-02-19T17:09:59.893936Z -849 -may - -op_popa.c -file - - - - -2008-04-06T23:16:20.730214Z -cd12908ee156b743e4952b28e60dad97 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_rmb_rb.c -file - - - - -2008-04-06T23:16:20.752899Z -9f4248b8b2905b20daaf7c1a5c1d0026 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jnp.c -file - - - - -2008-04-06T23:16:20.741876Z -dcdb7eef102b4a0a775672fcb3dfaae9 -2008-02-19T17:09:59.893936Z -849 -may - -op_or_rb_rmb.c -file - - - - -2008-04-06T23:16:20.765196Z -042e2fe9fae10411d39d503241fc6aea -2008-02-19T17:09:59.893936Z -849 -may - -op_cmp_al_ib.c -file - - - - -2008-04-06T23:16:20.776876Z -4753ee03f23e78b2dd7dd40d1b5e3489 -2008-02-19T17:09:59.893936Z -849 -may - -op_setge_rmb.c -file - - - - -2008-04-06T23:16:20.788263Z -46d1b7bc02aafb4a57f0e6755886c434 -2008-02-19T17:09:59.893936Z -849 -may - -op_test_eax_iv.c -file - - - - -2008-04-06T23:16:20.811876Z -aa78024bd15683bb798a7a58575c9f2e -2008-02-19T17:09:59.893936Z -849 -may - -op_out_ref_ib_eax.c -file - - - - -2008-04-06T23:16:20.800122Z -28c8c223822f912c944a992c7a821a5e -2008-02-19T17:09:59.893936Z -849 -may - -i386_group14.c -file - - - - -2008-04-06T23:16:20.835134Z -a22f286d7e8d9bd0f7a8121c570ef6d8 -2008-02-19T17:09:59.893936Z -849 -may - -op_int_3.c -file - - - - -2008-04-06T23:16:20.822899Z -e335bd24912b262f203ff2d2b782d442 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovnle.c -file - - - - -2008-04-06T23:16:20.846876Z -3099a0968dca2d432edd0d73b4ea424a -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rm_segr.c -file - - - - -2008-04-06T23:16:20.858513Z -2b931b3955265ae77340c644ffa75187 -2008-02-19T17:09:59.893936Z -849 -may - -i386_push_fs.c -file - - - - -2008-04-06T23:16:20.870147Z -c269b6a14c059244478b00c2b8d0a9b0 -2008-02-19T17:09:59.893936Z -849 -may - -op_add_rv_rmv.c -file - - - - -2008-04-06T23:16:20.892899Z -9d1c186ef93ec16856ca5ffbe59e3f60 -2008-02-19T17:09:59.893936Z -849 -may - -op_add_rmv_rv.c -file - - - - -2008-04-06T23:16:20.881881Z -675a8bb1c94646ecd8a4990faf891dc8 -2008-02-19T17:09:59.893936Z -849 -may - -op_jno.c -file - - - - -2008-04-06T23:16:20.905214Z -5818870f3f3bb4fc88df2806b5e3892c -2008-02-19T17:09:59.893936Z -849 -may - -i386_bswap.c -file - - - - -2008-04-06T23:16:20.916876Z -dc62f6fa5e54f97fdd316e8305d9a79c -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_ref_iv_eax.c -file - - - - -2008-04-06T23:16:20.928537Z -f7413cbe978b210c2e6e93a4cf614aa5 -2008-02-19T17:09:59.893936Z -849 -may - -op_std.c -file - - - - -2008-04-06T23:16:20.940227Z -20a053d2a675c652af11139181e37a41 -2008-02-19T17:09:59.893936Z -849 -may - -op_ud2a.c -file - - - - -2008-04-06T23:16:20.988550Z -7d68780005937299fcec6a81987d4c7f -2008-02-19T17:09:59.893936Z -849 -may - -op_shift_rmb_cl.c -file - - - - -2008-04-06T23:16:20.976877Z -7c42631a68f46a714fc5798821278d1f -2008-02-19T17:09:59.893936Z -849 -may - -i386_movzbl_rv_rmb.c -file - - - - -2008-04-06T23:16:20.965198Z -7c1acd86a108e2982d2e8de52a5da20e -2008-02-19T17:09:59.893936Z -849 -may - -op_jb.c -file - - - - -2008-04-06T23:16:20.952899Z -874e2c89705afbdabe34d63d3af03a2c -2008-02-19T17:09:59.893936Z -849 -may - -op_aam.c -file - - - - -2008-04-06T23:16:21.011987Z -d2703c04ffaf0e315fb93a9b9487752e -2008-02-19T17:09:59.893936Z -849 -may - -op_in_eax_dx.c -file - - - - -2008-04-06T23:16:21.000240Z -cf9c5e41b1cf300124000082c15ef1c1 -2008-02-19T17:09:59.893936Z -849 -may - -i386_pop_fs.c -file - - - - -2008-04-06T23:16:21.047057Z -1dda1f9e192722e275009436ac6a040c -2008-02-19T17:09:59.893936Z -849 -may - -op_sbb_rmv_rv.c -file - - - - -2008-04-06T23:16:21.035369Z -8c2507fc72d35312b9b19bc292934639 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_sbb_rv_rmv.c -file - - - - -2008-04-06T23:16:21.022899Z -6b1bc16978c4d21ceb0f964effc4db16 -2008-03-14T09:48:44.987521Z -909 -enioh - -i386_ja.c -file - - - - -2008-04-06T23:16:21.070498Z -2af78b6bb092456d29820e61d0103661 -2008-02-19T17:09:59.893936Z -849 -may - -op_push_ds.c -file - - - - -2008-04-06T23:16:21.058877Z -de6cc9f1b17fc0db115d8f0263f03432 -2008-02-19T17:09:59.893936Z -849 -may - -op_inc_reg.c -file - - - - -2008-04-06T23:16:21.082188Z -2b91aa188db67d23e1f57fbb0817c61b -2008-02-19T17:09:59.893936Z -849 -may - -op_cwtl.c -file - - - - -2008-04-06T23:16:21.105626Z -a9c4d91f362ca0899ec79d7bcae48321 -2008-02-19T17:09:59.893936Z -849 -may - -op_into.c -file - - - - -2008-04-06T23:16:21.093878Z -a4084762c16e45f4d732d5918b8cb3ba -2008-02-19T17:09:59.893936Z -849 -may - -op_fwait.c -file - - - - -2008-04-06T23:16:21.117315Z -2fc9bb8651bc5b817173ef973126e0e0 -2008-02-19T20:05:38.979160Z -854 -thorkill - -op_or_rmv_rv.c -file - - - - -2008-04-06T23:16:21.140876Z -3a2c5e3ea5fb4b77c8b6fb8864d3c0db -2008-02-19T17:09:59.893936Z -849 -may - -op_or_rv_rmv.c -file - - - - -2008-04-06T23:16:21.129005Z -e622892f1a7adf5b825f5a79da75b63a -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovno.c -file - - - - -2008-04-06T23:16:21.152441Z -cc720e7ede10bebc831266e8e9d03bbf -2008-02-19T17:09:59.893936Z -849 -may - -op_setne_rmb.c -file - - - - -2008-04-06T23:16:21.164189Z -20de11e3c413484be25e0c70de0f10ba -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmove.c -file - - - - -2008-04-06T23:16:21.177500Z -d994079c2731dfad05170d7522e602a8 -2008-02-19T17:09:59.893936Z -849 -may - -op_movsb.c -file - - - - -2008-04-06T23:16:21.200938Z -738ba4ffe752daa550ffc4973578f1cb -2008-02-19T17:09:59.893936Z -849 -may - -op_prefix_gs.c -file - - - - -2008-04-06T23:16:21.189211Z -2dcebc74b5a961dc554117ab8238d9e9 -2008-02-19T17:09:59.893936Z -849 -may - -op_indir_rmv.c -file - - - - -2008-04-06T23:16:21.212684Z -b3e06b620f5063cecac645600ebfff0f -2008-02-19T17:09:59.893936Z -849 -may - -i386_packuswb_pq_qq.c -file - - - - -2008-04-06T23:16:21.224396Z -f0098feb85a25df25cc858c6ed26122f -2008-02-19T17:09:59.893936Z -849 -may - -op_esc2.c -file - - - - -2008-04-06T23:16:21.247890Z -22a54992a8d8e8a5d64208a7f83ba635 -2008-02-19T17:09:59.893936Z -849 -may - -op_loopne.c -file - - - - -2008-04-06T23:16:21.235900Z -c168d8d5b841f7e4205bc99d0ced66c9 -2008-02-19T17:09:59.893936Z -849 -may - -op_shift_rmb_1.c -file - - - - -2008-04-06T23:16:21.382366Z -f2670434cedd0027f31e1ebf02ba80a4 -2008-03-14T09:48:44.987521Z -909 -enioh - -i386_mov_cr_rm.c -file - - - - -2008-04-06T23:16:22.235525Z -551834edb94650f8e805d851a9c8050c -2008-02-19T17:09:59.893936Z -849 -may - -op_imul_rv_rmv_iv.c -file - - - - -2008-04-06T23:16:22.381340Z -e511aff6f00c3add201ad8108527d748 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movzwl_rv_rm2.c -file - - - - -2008-04-06T23:16:22.404877Z -162f5ab10d98de13eea8c834eca5f472 -2008-02-19T17:09:59.893936Z -849 -may - -op_sete_rmb.c -file - - - - -2008-04-06T23:16:22.393088Z -8561f9a58d69aff6895b3377e8377d0c -2008-02-19T17:09:59.893936Z -849 -may - -op_cli.c -file - - - - -2008-04-06T23:16:22.415899Z -0ce85f4086596f226342e39ae8612a64 -2008-02-19T17:09:59.893936Z -849 -may - -i386_bsr_rv_rmb.c -file - - - - -2008-04-06T23:16:22.428213Z -b88789d5020f942bb64643ae684f1943 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jae.c -file - - - - -2008-04-06T23:16:22.439876Z -da4e9bfc2b5495a19ed65daf37a3fddb -2008-02-19T17:09:59.893936Z -849 -may - -op_sub_rmb_rb.c -file - - - - -2008-04-06T23:16:22.463882Z -2ac6af3d68ceedc1958e06ce527e59ce -2008-02-19T17:09:59.893936Z -849 -may - -op_adc_al_ib.c -file - - - - -2008-04-06T23:16:22.485899Z -5fc6aa7a89572eec9449cab51ad7fe8f -2008-02-19T17:09:59.893936Z -849 -may - -i386_group15.c -file - - - - -2008-04-06T23:16:22.474566Z -aea9efca4c28dc03e5edacc03d247d51 -2008-02-19T17:09:59.893936Z -849 -may - -i386_btrl.c -file - - - - -2008-04-06T23:16:22.497876Z -0a0a87ad61f921ac1df64ad3c53a74ae -2008-02-19T17:09:59.893936Z -849 -may - -op_pusha.c -file - - - - -2008-04-06T23:16:22.509463Z -0dab49610a9b712cf82c1443e3e99518 -2008-02-19T17:09:59.893936Z -849 -may - -op_shift_rmv_1.c -file - - - - -2008-04-06T23:16:22.521095Z -fb86f751d27cde37bf961aa8df26d0bd -2008-03-14T09:48:44.987521Z -909 -enioh - -op_adc_eax_iv.c -file - - - - -2008-04-06T23:16:22.532876Z -9b223a754bedcece052c49e3021df267 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movd_pd_qd.c -file - - - - -2008-04-06T23:16:22.555899Z -6a212f7b7faf59df798e0cb96b9316db -2008-02-19T17:09:59.893936Z -849 -may - -op_jnp.c -file - - - - -2008-04-06T23:16:22.544358Z -89559b0872292eec25ab1c6e82e08166 -2008-02-19T17:09:59.893936Z -849 -may - -op_stosb.c -file - - - - -2008-04-06T23:16:22.569244Z -995e4e1a64c166fd2e7c0c6b3038ea84 -2008-02-19T17:09:59.893936Z -849 -may - -op_unary_rmb.c -file - - - - -2008-04-06T23:16:22.580875Z -dfc3af6cc82aa77c9e45050c3c3a678e -2008-03-07T17:49:34.750118Z -896 -thorkill - -op_jmp_ib.c -file - - - - -2008-04-06T23:16:22.592507Z -a1e64183777206bc7dacef73daf4a701 -2008-02-19T17:09:59.893936Z -849 -may - -op_arpl_ew_rw.c -file - - - - -2008-04-06T23:16:22.604202Z -8f1b6a7b20cfa1c74f7a96310ec8b852 -2008-02-19T17:09:59.893936Z -849 -may - -op_lodsb.c -file - - - - -2008-04-06T23:16:22.615876Z -351c33280f2eb1322288d492a8a8ffd4 -2008-02-19T17:09:59.893936Z -849 -may - -op_cmpsb.c -file - - - - -2008-04-06T23:16:22.627461Z -dd640adf63eaad31d4cb759e6b2537a9 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jb.c -file - - - - -2008-04-06T23:16:22.650876Z -341bcd5de0017e41d2f9c4d60b880810 -2008-02-19T17:09:59.893936Z -849 -may - -op_or_al_ib.c -file - - - - -2008-04-06T23:16:22.639152Z -8bdea5a11ce94beded04ae0b99c940e3 -2008-02-19T17:09:59.893936Z -849 -may - -op_xlatb.c -file - - - - -2008-04-06T23:16:22.662475Z -a811be49dc41d82726e65a39babe2736 -2008-02-19T17:09:59.893936Z -849 -may - -op_add_rmb_rb.c -file - - - - -2008-04-06T23:16:22.685876Z -06b127accfd54cb5772da80d0bbb0b84 -2008-02-19T17:09:59.893936Z -849 -may - -op_int1.c -file - - - - -2008-04-06T23:16:22.674108Z -60c080a1c0a3ecb12f3b745d561ba9ee -2008-02-19T17:09:59.893936Z -849 -may - -op_setle_rmb.c -file - - - - -2008-04-06T23:16:22.708884Z -ffc7886f4d017e374d5ed94c2c1a81de -2008-02-19T17:09:59.893936Z -849 -may - -op_js.c -file - - - - -2008-04-06T23:16:22.697488Z -c21697ef4fab3520f967348378dd1117 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovnp.c -file - - - - -2008-04-06T23:16:22.720876Z -e7471baaeeb66d5fd39344a45ffcbca6 -2008-02-19T17:09:59.893936Z -849 -may - -op_test_al_rb.c -file - - - - -2008-04-06T23:16:22.732498Z -95ffcb647272910dfbada4f4394cf592 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movsbl_rv_rmb.c -file - - - - -2008-04-06T23:16:22.743899Z -c3599104b55feee3cc70885aded6c6d6 -2008-02-19T17:09:59.893936Z -849 -may - -op_and_rb_rmb.c -file - - - - -2008-04-06T23:16:22.767512Z -da5adce778af59c16c78f2d40ed224a7 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jle.c -file - - - - -2008-04-06T23:16:22.755876Z -b6daf5c9acfe077bf6c1beecdf6c7908 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_eax_ref_iv.c -file - - - - -2008-04-06T23:16:22.779202Z -1b8b6d5e2c654ef039acf33df8d97ef6 -2008-02-19T17:09:59.893936Z -849 -may - -op_setnp_rmb.c -file - - - - -2008-04-06T23:16:22.803904Z -c20fc7e19257dfb3bb869efdbd8a579a -2008-02-19T17:09:59.893936Z -849 -may - -op_sbb_rmb_rb.c -file - - - - -2008-04-06T23:16:22.790892Z -aca9e908deae1342f142fea44c608a7d -2008-03-14T09:48:44.987521Z -909 -enioh - -op_insb.c -file - - - - -2008-04-06T23:16:22.815876Z -da86be7369cd09d966b391ab3460776e -2008-02-19T17:09:59.893936Z -849 -may - -op_outsb.c -file - - - - -2008-04-06T23:16:22.826909Z -c69e9caf8d5df39bb8879d7bafef8d3a -2008-02-19T17:09:59.893936Z -849 -may - -op_leave.c -file - - - - -2008-04-06T23:16:22.839235Z -4e4207d3100575403771939275b9db17 -2008-02-19T17:09:59.893936Z -849 -may - -op_esc3.c -file - - - - -2008-04-06T23:16:22.850904Z -c1c93e597b6e34ae90498a911f40f12a -2008-02-19T17:09:59.893936Z -849 -may - -i386_bt_rm_r.c -file - - - - -2008-04-06T23:16:22.862595Z -17bfc84449226dc0a5249dc23eaed4a9 -2008-02-19T17:09:59.893936Z -849 -may - -op_or_rmb_rb.c -file - - - - -2008-04-06T23:16:22.874285Z -52bbd6be79a3050bdbbb64f62cf1c9ba -2008-02-19T17:09:59.893936Z -849 -may - -op_push_es.c -file - - - - -2008-04-06T23:16:22.885899Z -b36e38016274445fcff803b9a94fe667 -2008-02-19T17:09:59.893936Z -849 -may - -op_setp_rmb.c -file - - - - -2008-04-06T23:16:22.897724Z -2035e0332787e2f6d8236e8be5569bf2 -2008-02-19T17:09:59.893936Z -849 -may - -op_push_reg.c -file - - - - -2008-04-06T23:16:22.909414Z -d3dd91a7f613351b16d209301453aab6 -2008-02-19T17:09:59.893936Z -849 -may - -i386_emms.c -file - - - - -2008-04-06T23:16:22.921102Z -e16b3be4e288275037e125055db463c5 -2008-02-19T17:09:59.893936Z -849 -may - -i386_group16.c -file - - - - -2008-04-06T23:16:22.932876Z -28b10a8760141aa92a25bd2b5e2d3bed -2008-02-19T17:09:59.893936Z -849 -may - -op_repz.c -file - - - - -2008-04-06T23:16:22.944541Z -681d3d41b01275663fbbdc32206baeac -2008-03-14T09:48:44.987521Z -909 -enioh - -i386_jge.c -file - - - - -2008-04-06T23:16:22.955899Z -1101387e08726f071e3487fe2b612689 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rb_rmb.c -file - - - - -2008-04-06T23:16:22.967922Z -f60554dfa0bc86dd60ef2372c7b54e1f -2008-02-19T17:09:59.893936Z -849 -may - -op_lea_rv_m.c -file - - - - -2008-04-06T23:16:22.979670Z -acdec86475c78276709985780d6014a7 -2008-03-07T17:49:34.750118Z -896 -thorkill - -op_daa.c -file - - - - -2008-04-06T23:16:22.991359Z -232caca7a38c5e1e0b0e79b8c8563d64 -2008-02-19T17:09:59.893936Z -849 -may - -op_cltd.c -file - - - - -2008-04-06T23:16:23.002909Z -458d5e61146372a91b343908dc1a6c93 -2008-02-19T17:09:59.893936Z -849 -may - -op_and_al_ib.c -file - - - - -2008-04-06T23:16:23.014876Z -cb24d116c6328b28e0f1a5ba7ee4eb61 -2008-02-19T17:09:59.893936Z -849 -may - -i386_movswl_rv_rm2.c -file - - - - -2008-04-06T23:16:23.028127Z -880f0964eebc69f488d6f2888907961a -2008-02-19T17:09:59.893936Z -849 -may - -op_scasb.c -file - - - - -2008-04-06T23:16:23.039855Z -bb6154977f0d0b2fbe84bd72fdaf4aea -2008-03-14T09:48:44.987521Z -909 -enioh - -op_and_rmv_rv.c -file - - - - -2008-04-06T23:16:23.051178Z -d6481702483bbbdf58ad5060cc591dd0 -2008-02-19T17:09:59.893936Z -849 -may - -op_and_rv_rmv.c -file - - - - -2008-04-06T23:16:23.062899Z -b412a9bda05b49b4fb3d9aa4b741fbea -2008-02-19T17:09:59.893936Z -849 -may - -op_xor_al_ib.c -file - - - - -2008-04-06T23:16:23.075041Z -63c57aa2665f6458de58cf21e48c431a -2008-02-19T17:09:59.893936Z -849 -may - -op_jae.c -file - - - - -2008-04-06T23:16:23.085899Z -ed0abfd1a9373828a0ccd8ee2a302236 -2008-02-19T17:09:59.893936Z -849 -may - -i386_punpcklbw_pq_qd.c -file - - - - -2008-04-06T23:16:23.098500Z -8abb3bab2bc83b6094485d69a2b2c84f -2008-02-19T17:09:59.893936Z -849 -may - -op_jl.c -file - - - - -2008-04-06T23:16:23.110227Z -edf99ca43683e6145cb0cc8df5cf911f -2008-02-19T17:09:59.893936Z -849 -may - -i386_shld.c -file - - - - -2008-04-06T23:16:23.121973Z -e3b02b76e6fe8cd8c67e2d7af90c2fc2 -2008-02-19T17:09:59.893936Z -849 -may - -op_shr_rmb_ib.c -file - - - - -2008-04-06T23:16:23.133173Z -e5a35fdde4a3d93114a69d36d49ee690 -2008-03-14T09:48:44.987521Z -909 -enioh - -op_lahf.c -file - - - - -2008-04-06T23:16:23.145412Z -39447746b4d5cfe1dfecd7d290ef8fa1 -2008-02-19T17:09:59.893936Z -849 -may - -op_test_rmv_rv.c -file - - - - -2008-04-06T23:16:23.157161Z -0ea1c5bb032c0cf174b3e1adcfa075c7 -2008-02-19T17:09:59.893936Z -849 -may - -i386_jbe.c -file - - - - -2008-04-06T23:16:23.168935Z -ad4f17428faca4282fecac8d71b55e34 -2008-02-19T17:09:59.893936Z -849 -may - -op_shift_rmv_cl.c -file - - - - -2008-04-06T23:16:23.180655Z -87a10d4900d45add6e8472e16a63338e -2008-03-14T09:48:44.987521Z -909 -enioh - -op_prefix_cs.c -file - - - - -2008-04-06T23:16:23.192075Z -9195379ceebf0c9a4cdb28f7dcd4cfc2 -2008-02-19T17:09:59.893936Z -849 -may - -op_pop_rmv.c -file - - - - -2008-04-06T23:16:23.203876Z -154f8f35305cc83942f1d2150f76aae7 -2008-02-19T17:09:59.893936Z -849 -may - -op_incdec_rmb.c -file - - - - -2008-04-06T23:16:23.227359Z -917ca046e3083905a420890af3447596 -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovae.c -file - - - - -2008-04-06T23:16:23.240670Z -c2d3be450445cb906b24eeb6b83f0227 -2008-02-19T17:09:59.893936Z -849 -may - -i386_js.c -file - - - - -2008-04-06T23:16:23.252473Z -004b9298cb23e179f798e12c6b333e94 -2008-02-19T17:09:59.893936Z -849 -may - -op_movsd.c -file - - - - -2008-04-06T23:16:23.264223Z -0dc6c02519b9cbd164a434408300dc93 -2008-02-19T17:09:59.893936Z -849 -may - -op_out_ref_ib_al.c -file - - - - -2008-04-06T23:16:23.275899Z -72035e2b321e73951c7e36d3fea88b6b -2008-02-19T17:09:59.893936Z -849 -may - -i386_rdtsc.c -file - - - - -2008-04-06T23:16:23.287544Z -96545cfee329247103e21e66d57828d6 -2008-02-19T17:09:59.893936Z -849 -may - -op_nop.c -file - - - - -2008-04-06T23:16:23.299233Z -3d6852ce9ae87417ed9ce46ecddd36e2 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rv_rmv.c -file - - - - -2008-04-06T23:16:23.310891Z -56c35d944e38fbdef9e8ccc1139163a4 -2008-02-19T17:09:59.893936Z -849 -may - -op_mov_rmv_rv.c -file - - - - -2008-04-06T23:16:23.322576Z -3e53732d7f5985af8a829d54c8384864 -2008-02-19T17:09:59.893936Z -849 -may - -op_setns_rmb.c -file - - - - -2008-04-06T23:16:23.334244Z -8301d90d1cbed41309ec4bf61d24051a -2008-02-19T17:09:59.893936Z -849 -may - -i386_cmovo.c -file - - - - -2008-04-06T23:16:23.345877Z -48f4ff5a311fca54201eb25d09dc16d5 -2008-02-19T17:09:59.893936Z -849 -may - -op_esc4.c -file - - - - -2008-04-06T23:16:23.357567Z -e5e7628c34a32a76a768ecf6b0edf495 -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/format 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsf.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file i386_bsf.c - * @ingroup handlers_ia32 - * $Id: i386_bsf.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * -*/ -#include -#include - -/** - * Handler for instruction bsf, opcode 0x0f 0xbc - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int i386_bsf(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_BSF; - - new->type = ASM_TYPE_BITTEST | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, - new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, - new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsr_rv_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsr_rv_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsr_rv_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bsr_rv_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: i386_bsr_rv_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for instruction bsr rv, rms, opcode 0x0f 0xbd - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int i386_bsr_rv_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_BSR; - - new->type = ASM_TYPE_BITTEST | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bswap.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bswap.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bswap.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bswap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** $Id: i386_bswap.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - -int i386_bswap(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - - struct s_modrm *modrm; - modrm = (struct s_modrm *) opcode; - - new->len += 1; - - new->ptr_instr = opcode; - new->instr = ASM_BSWAP; - - new->type = ASM_TYPE_OTHER; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_btrl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_btrl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_btrl.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_btrl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file i386_btrl.c - * @ingroup handlers_ia32 - * $Id: i386_btrl.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction btrl, opcode 0x0f 0xba - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int i386_btrl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_BTRL; - - new->type = ASM_TYPE_BITTEST | ASM_TYPE_BITSET | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bt_rm_r.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bt_rm_r.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bt_rm_r.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bt_rm_r.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file i386_bt_rm_r.c - * @ingroup handlers_ia32 - * $Id: i386_bt_rm_r.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction bt rm, r, opcode 0x0f 0xa3 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int i386_bt_rm_r(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->instr = ASM_BT; - new->len += 1; - - new->type = ASM_TYPE_BITTEST | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bts.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bts.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bts.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_bts.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file i386_bts.c - * @ingroup handlers_ia32 - * $Id: i386_bts.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - - */ - -int i386_bts(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->len += 1; - new->instr = ASM_BTS; - - new->type = ASM_TYPE_BITTEST | ASM_TYPE_BITSET | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmova.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmova.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmova.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmova.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** $Id: i386_cmova.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmova(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVA; - - new->type = ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovae.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovae.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovae.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovae.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovae.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovae(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVAE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_cmovb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->len += 1; - new->instr = ASM_CMOVB; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovbe.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovbe.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovbe.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovbe.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: i386_cmovbe.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovbe(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVBE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmove.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmove.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmove.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmove.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file i386_cmove.c - * @ingroup handlers_ia32 - * $Id: i386_cmove.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - -*/ - - -int i386_cmove(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); - #endif - return (new->len); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovl.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_cmovl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVL; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovle.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovle.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovle.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovle.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovle(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVLE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovne.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovne.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovne.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: i386_cmovne.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovne(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnl.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovnl.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovnl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNL; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnle.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnle.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnle.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnle.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovnle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovnle(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNLE; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovno.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovno.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovno.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovno.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: i386_cmovno.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovno(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNO; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnp.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovnp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovnp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovnp(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNP; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovns.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovns.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovns.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovns.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_cmovns.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovns(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVNS; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovo.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovo.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovo.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: i386_cmovo.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_cmovo(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVO; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovp.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_cmovp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovp(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVP; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cmovs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_cmovs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_cmovs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CMOVA; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cpuid.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cpuid.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cpuid.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_cpuid.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** $Id: i386_cpuid.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0f 0xa2 - Instruction : CPUID - */ - -int i386_cpuid(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_CPUID; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_emms.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_emms.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_emms.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_emms.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: i386_emms.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_emms(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_MOVQ; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group12.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group12.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group12.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group12.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* -** $Id: i386_group12.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_group12(asm_instr *new, u_char *opcode, - u_int len, asm_processor *proc) -{ - int olen; - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->ptr_instr = opcode; - new->len += 1; - switch (modrm->r) - { - case 2: - new->instr = ASM_PSRLW; - - break; - - case 4: - new->instr = ASM_PSRAW; - break; - - case 6: - new->instr = ASM_PSLLW; - break; - - default: - new->instr = ASM_BAD; - return (new->len = 0); - break; - } -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_PMMX, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_PMMX, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif -#else - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_IMMEDIATE; - new->op[1].size = ASM_OSIZE_BYTE; - - operand_rmb_ib(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group14.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group14.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group14.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group14.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/* -** $Id: i386_group14.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_group14(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - struct s_modrm *modrm = (struct s_modrm *) opcode + 1; - - new->ptr_instr = opcode; - new->len += 1; - switch (modrm->r) - { - case 2: - new->instr = ASM_PSRLQ; - break; - - case 6: - new->instr = ASM_PSLLQ; - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_IMMEDIATE; - new->op[1].size = ASM_OSIZE_BYTE; - - operand_rmb_ib(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - break; - - default: - new->instr = ASM_BAD; - return (new->len = 0); - break; - } - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_PMMX, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_PMMX, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif -#else - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_IMMEDIATE; - new->op[1].size = ASM_OSIZE_BYTE; - - operand_rmb_ib(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group15.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group15.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group15.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group15.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* -** $Id: i386_group15.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_group15(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - modrm = (struct s_modrm *) opcode + 1; - - new->len += 1; - - switch(modrm->r) - { - case 2: - new->instr = ASM_LDMXCSR; - new->op[0].type = ASM_OTYPE_ENCODED; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - break; - - case 3: - new->instr = ASM_STMXCSR; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - break; - - case 7: - new->instr = ASM_CLFLUSH; - new->op[0].type = ASM_OTYPE_GENERAL; - break; - - default: - new->len = 0; - break; - } - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group16.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group16.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group16.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_group16.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/** - * @file i386_group16.c - * @ingroup handlers_ia32 - * $Id: i386_group16.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - * - * Changelog - * 2007-05-29: operand type fixed. - */ -#include -#include - -/** - * Handler for instruction group 16, opcode 0x0f 0xae - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction -*/ - -int i386_group16(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - if (new->ptr_instr != 0) - new->ptr_instr = opcode - 1; - new->len += 1; - new->instr = ASM_BAD; - - - modrm = (struct s_modrm *) opcode + 1; - switch(modrm->r) - { - case 0: - new->instr = ASM_FXSAVE; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - break; - case 1: - new->instr = ASM_FXRSTORE; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - break; - case 2: - new->instr = ASM_LDMXCSR; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - break; - case 3: - new->instr = ASM_STMXCSR; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - break; - case 4: - new->instr = ASM_BAD; - break; - case 5: - new->instr = ASM_LFENCE; - break; - case 6: - new->instr = ASM_MFENCE; - break; - case 7: - new->instr = ASM_SFENCE; - ///CLFUSH - break; - } - -#if LIBASM_USE_OPERAND_VECTOR -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_imul_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_imul_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_imul_rv_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_imul_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** $Id: i386_imul_rv_rmv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_imul_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_IMUL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[0].size = ASM_OSIZE_VECTOR; - new->op[1].type = ASM_OTYPE_ENCODED; - new->op[1].size = ASM_OSIZE_VECTOR; - operand_rv_rmv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_ja.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_ja.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_ja.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_ja.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file i386_ja.c - * @ingroup handlers_ia32 - * $Id: i386_ja.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for far ja far instruction, opcode 0x0f 0x87 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * - -*/ - - -int i386_ja(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_U_GREATER; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jae.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jae.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jae.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jae.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_jae.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_jae(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_U_GREATER_EQUAL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_jb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_jb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_U_LESS; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jbe.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jbe.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jbe.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jbe.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jbe.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jbe(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_U_LESS_EQUAL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_je.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_je.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_je.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_je.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_je.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_je(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_EQUAL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jg.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: i386_jg.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jg(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_BRANCH_S_GREATER; - new->len += 1; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - #else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jge.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jge.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jge.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jge.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jge.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jge(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_S_GREATER_EQUAL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jl.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jl.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jl(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_S_LESS; - - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jle.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jle.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jle.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jle.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jle.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jle(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_S_LESS_EQUAL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jne.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jne.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jne.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jne.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jne(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_NOT_EQUAL; - new->len += 1; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - #else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jnp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jnp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jnp.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jnp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jnp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jnp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_PARITY; - new->len += 1; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - #else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; - #endif -return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jns.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jns.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jns.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jns.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jns.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jns(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_SIGNED; - new->len += 1; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - #else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jp.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_jp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_jp.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_jp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_PARITY; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_js.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_js.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_js.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_js.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: i386_js.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_js(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - // new->type = IS_COND_BRANCH; - new->instr = ASM_BRANCH_SIGNED; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif -#else - - - new->op[0].type = ASM_OTYPE_JUMP; - new->op[0].content = ASM_OP_VALUE | ASM_OP_ADDRESS; - new->op[0].ptr = opcode + 1; - new->op[0].len = 4; - memcpy(&new->op[0].imm, opcode + 1, 4); - new->len += 4; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_cr_rm.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_cr_rm.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_cr_rm.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_cr_rm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: i386_mov_cr_rm.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int i386_mov_cr_rm(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) (opcode + 1); - new->len += 1; - new->instr = ASM_MOV; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_CONTROL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new); -#endif -#else - new->op[0].type = ASM_OTYPE_CONTROL; - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_CREG; - new->op[0].baser = modrm->r; - - new->op[1].type = ASM_OTYPE_REGISTER; - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].baser = modrm->m; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movd_pd_qd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movd_pd_qd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movd_pd_qd.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movd_pd_qd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** $Id: i386_movd_pd_qd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_movd_pd_qd(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_MOVD; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_DWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_DWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_dr_rm.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_dr_rm.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_dr_rm.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_dr_rm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** $Id: i386_mov_dr_rm.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int i386_mov_dr_rm(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) (opcode + 1); - new->len += 1; - new->instr = ASM_MOV; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_DEBUG, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_DEBUG, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_REGISTER, new); -#endif -#else - new->op[0].type = ASM_OTYPE_DEBUG; - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_DREG; - new->op[0].baser = modrm->r; - new->op[1].type = ASM_OTYPE_REGISTER; - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].baser = modrm->m; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** $Id: i386_movq_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_movq_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_MOVQ; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_PMMX, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_PMMX, new); -#endif - - #else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_qq_pq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_qq_pq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_qq_pq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movq_qq_pq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** $Id: i386_movq_qq_pq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_movq_qq_pq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_MOVQ; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_PMMX, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_PMMX, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_QMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_PMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rmv_rv(new, opcode + 1, len - 1, proc); - new->op[1].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_rm_cr.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_rm_cr.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_rm_cr.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_mov_rm_cr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** $Id: i386_mov_rm_cr.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int i386_mov_rm_cr(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) (opcode + 1); - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_REGISTER, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_REGISTER, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_CONTROL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_CONTROL, new); -#endif -#else - - new->instr = ASM_MOV; - new->op[0].type = ASM_OTYPE_REGISTER; - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R32; - new->op[0].baser = modrm->m; - new->op[1].type = ASM_OTYPE_SEGMENT; - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_CREG; - new->op[1].baser = modrm->r; - new->len += 1; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movsbl_rv_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movsbl_rv_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movsbl_rv_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movsbl_rv_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** $Id: i386_movsbl_rv_rmb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_movsbl_rv_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - if (asm_proc_opsize(proc)) - new->instr = ASM_MOVSBW; - else - new->instr = ASM_MOVSBL; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmb(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movswl_rv_rm2.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movswl_rv_rm2.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movswl_rv_rm2.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movswl_rv_rm2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** $Id: i386_movswl_rv_rm2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int i386_movswl_rv_rm2(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - if (asm_proc_opsize(proc)) - new->instr = ASM_MOVSBW; - else - new->instr = ASM_MOVSWL; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rm2(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzbl_rv_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzbl_rv_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzbl_rv_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzbl_rv_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: i386_movzbl_rv_rmb.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_movzbl_rv_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - if (asm_proc_opsize(proc)) - new->instr = ASM_MOVZBW; - else - new->instr = ASM_MOVZBL; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[0].size = ASM_OSIZE_VECTOR; - new->op[1].type = ASM_OTYPE_ENCODED; - new->op[1].size = ASM_OSIZE_BYTE; - operand_rv_rmb(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzwl_rv_rm2.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzwl_rv_rm2.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzwl_rv_rm2.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_movzwl_rv_rm2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: i386_movzwl_rv_rm2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_movzwl_rv_rm2(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_MOVZWL; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rm2(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_packuswb_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_packuswb_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_packuswb_pq_qq.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_packuswb_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: i386_packuswb_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_packuswb_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PACKUSWB; - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #else - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusb_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusb_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusb_pq_qq.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusb_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/** - * @file i386_paddusb_pq_qq.c - * @ingroup handlers_ia32 -* $Id: i386_paddusb_pq_qq.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -* -*/ -#include -#include - -/** - * - * - - */ - -int i386_paddusb_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PADDUSB; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusw_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusw_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusw_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_paddusw_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * @file i386_paddusw_pq_qq.c - * @ingroup handlers_ia32 - * $Id: i386_paddusw_pq_qq.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * - */ - -int i386_paddusw_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PADDUSW; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pand_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pand_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pand_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pand_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: i386_pand_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_pand_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PAND; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pmullw_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pmullw_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pmullw_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pmullw_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: i386_pmullw_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_pmullw_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PMULLW; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pop_fs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pop_fs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pop_fs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pop_fs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** $Id: i386_pop_fs.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0f 0xa1 - Instruction : POP -*/ - -int i386_pop_fs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_POP; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].len = 0; - new->op[0].ptr = 0; - new->op[0].baser = ASM_REG_FS; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].len = 0; - new->op[0].ptr = 0; - new->op[0].baser = ASM_REG_FS; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_por_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_por_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_por_pq_qq.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_por_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** $Id: i386_por_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_por_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_POR; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpckhbw_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpckhbw_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpckhbw_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpckhbw_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: i386_punpckhbw_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_punpckhbw_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PUNPCKHBW; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpcklbw_pq_qd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpcklbw_pq_qd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpcklbw_pq_qd.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_punpcklbw_pq_qd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: i386_punpcklbw_pq_qd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_punpcklbw_pq_qd(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PUNPCKLBW; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #else - - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_DWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_push_fs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_push_fs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_push_fs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_push_fs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** $Id: i386_push_fs.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0f 0xa0 - Instruction : PUSH - -*/ - -int i386_push_fs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_PUSH; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].len = 0; - new->op[0].ptr = 0; - new->op[0].baser = ASM_REG_FS; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].len = 0; - new->op[0].ptr = 0; - new->op[0].baser = ASM_REG_FS; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pxor_pq_qq.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pxor_pq_qq.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pxor_pq_qq.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_pxor_pq_qq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** $Id: i386_pxor_pq_qq.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_pxor_pq_qq(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_PXOR; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#else - new->op[0].type = ASM_OTYPE_PMMX; - new->op[0].size = ASM_OSIZE_QWORD; - new->op[1].type = ASM_OTYPE_QMMX; - new->op[1].size = ASM_OSIZE_QWORD; - - operand_rv_rmv(new, opcode + 1, len - 1, proc); - new->op[0].regset = ASM_REGSET_MM; - new->op[1].regset = ASM_REGSET_MM; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdmsr.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdmsr.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdmsr.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdmsr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: i386_rdmsr.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - - */ - -int i386_rdmsr(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_RDMSR; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdtsc.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdtsc.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdtsc.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_rdtsc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: i386_rdtsc.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int i386_rdtsc(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_RDTSC; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/** - * @file i386_shld.c - * @ingroup handlers_ia32 - * $Id: i386_shld.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction shld, opcode 0x0f 0xa4 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int i386_shld(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - new->len += 1; - - modrm = (struct s_modrm *) opcode + 1; - new->instr = ASM_SHLD; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_REGISTER, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_REGISTER, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[2], opcode + 2, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[2], opcode + 2, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - new->len += 1; -#else - - new->op[0].type = ASM_OTYPE_REGISTER; - new->op[0].regset = ASM_REGSET_R32; - new->op[0].content = ASM_OP_BASE; - new->op[0].ptr = opcode + 1; - new->op[0].len = 0; - new->op[0].baser = modrm->m; - - new->op[1].type = ASM_OTYPE_GENERAL; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].content = ASM_OP_BASE; - new->op[1].ptr = opcode + 1; - new->op[1].len = 1; - new->op[1].baser = modrm->r; - - new->op[2].type = ASM_OTYPE_IMMEDIATE; - new->op[2].content = ASM_OP_VALUE; - new->op[2].ptr = opcode + 2; - new->op[2].len = 1; - new->op[2].imm = 0; - memcpy(&new->op[2].imm, opcode + 2, 1); - new->len += new->op[0].len + new->op[1].len + new->op[2].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld_rmv_rv_cl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld_rmv_rv_cl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld_rmv_rv_cl.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shld_rmv_rv_cl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* -** $Id: i386_shld_rmv_rv_cl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_shld_rmv_rv_cl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SHRD; - new->len += 1; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[2], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[2], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[2].content = ASM_OP_BASE; - new->op[2].regset = ASM_REGSET_R8; - new->op[2].ptr = opcode; - new->op[2].len = 0; - new->op[2].baser = ASM_REG_CL; - -#else - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - new->op[1].type = ASM_OTYPE_GENERAL; - new->op[1].size = ASM_OSIZE_VECTOR; - operand_rmv_rv(new, opcode + 1, len - 1, proc); - new->op[2].type = ASM_OTYPE_FIXED; - new->op[2].content = ASM_OP_BASE; - new->op[2].regset = ASM_REGSET_R8; - new->op[2].ptr = opcode; - new->op[2].len = 0; - new->op[2].baser = ASM_REG_CL; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_cl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_cl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_cl.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_cl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** $Id: i386_shrd_rmv_rv_cl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_shrd_rmv_rv_cl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SHRD; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[2].content = ASM_OP_BASE; - new->op[2].regset = ASM_REGSET_R8; - new->op[2].ptr = opcode; - new->op[2].len = 0; - new->op[2].baser = ASM_REG_CL; -#else - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - new->op[1].type = ASM_OTYPE_GENERAL; - new->op[1].size = ASM_OSIZE_VECTOR; - operand_rmv_rv(new, opcode + 1, len - 1, proc); - new->op[2].type = ASM_OTYPE_FIXED; - new->op[2].content = ASM_OP_BASE; - new->op[2].regset = ASM_REGSET_R8; - new->op[2].ptr = opcode; - new->op[2].len = 0; - new->op[2].baser = ASM_REG_CL; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_shrd_rmv_rv_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/** - * @file i386_shrd_rmv_rv_ib.c - * @ingroup handlers_ia32 - * $Id: i386_shrd_rmv_rv_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction shrd, opcode 0x0f 0xac - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int i386_shrd_rmv_rv_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - new->instr = ASM_SHRD; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - new->op[1].type = ASM_OTYPE_GENERAL; - new->op[1].size = ASM_OSIZE_VECTOR; - new->op[2].type = ASM_OTYPE_IMMEDIATE; - new->op[2].size = ASM_OSIZE_BYTE; - operand_rmv_rv(new, opcode + 1, len - 1, proc); - new->op[2].type = ASM_OTYPE_IMMEDIATE; - new->op[2].content = ASM_OP_VALUE; - new->op[2].ptr = opcode + 2; - new->op[2].len = 1; - - new->op[2].imm = 0; - memcpy(&new->op[2].imm, opcode + 2, 1); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_wbinvd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_wbinvd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_wbinvd.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_wbinvd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -/* -** $Id: i386_wbinvd.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int i386_wbinvd(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_WBINVD; - return (new->len); - -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xadd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xadd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xadd.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xadd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file i386_xadd.c - * @ingroup handlers_ia32 - * $Id: i386_xadd.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - */ -#include -#include - -/** - * Handler for the opcode FF C1 - -*/ - -int i386_xadd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - modrm = (struct s_modrm *) opcode; - new->instr = ASM_XADD; - new->len += 1; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_GENERAL; - operand_rmv_rv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xstorenrg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xstorenrg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xstorenrg.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/i386_xstorenrg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: i386_xstorenrg.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int i386_xstorenrg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - switch(*(opcode + 1)) - { - case 0xc0: new->instr = ASM_XSTORERNG; break; - case 0xd0: new->instr = ASM_XCRYPTCBC; break; - case 0xe0: new->instr = ASM_XCRYPTCFB; break; - case 0xe8: new->instr = ASM_XCRYPTOFB; break; - default: new->instr = ASM_NONE; - } - new->len += 2; - return (new->len); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_386sp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_386sp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_386sp.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_386sp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/** - * @file op_386sp.c - * @ingroup handlers_ia32 - * $Id: op_386sp.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * ChangeLog: - * 2007-05-30 Fixed a bug in fetching. The vector used was the previously defined. - * strauss set up a new disasm vector and didn't know about it which - * was called here. - * Filled instruction opcode pointer. - * Removed the old unused handler. - * Added minimal error management. - */ -#include -#include - - -/** - * This is the handler for 2 bytes instruction, opcode 0x0f - * The second byte is used to fetch a new handler in the vector - * starting at offset 0x100. - * @param ins Pointer to instruction structure. - * @param buf Pointer to data to disassemble. - * @param len Length of dat to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction or -1 error. - */ - -int op_386sp(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) -{ - int opcode; - int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *); - - // XXX: Use asm_set_error to set error code to LIBASM_ERROR_TOOSHORT - if (len < 2) - return (-1); - - opcode = *(buf + 1); - opcode += 0x100; - fetch = asm_opcode_fetch(LIBASM_VECTOR_OPCODE_IA32, opcode); - if (!fetch) - return (-1); - if (!ins->ptr_instr) - ins->ptr_instr = buf; - ins->len += 1; - return (fetch(ins, buf + 1, len - 1, proc)); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aaa.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aaa.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aaa.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aaa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_aaa.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the aaa instruction, opcode 0x37 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of disassembled instruction. -*/ - -int op_aaa(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_AAA; - new->type = ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG | ASM_TYPE_ARITH; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF; - new->flagsread = ASM_FLAG_AF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aad.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aad.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aad.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aad.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/** - * @file op_aad.c - * @ingroup handlers_ia32 - * $Id: op_aad.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for the aad instruction, opcode 0xd5 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of disassembled instruction. - */ -int op_aad(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AAD; - new->type = ASM_TYPE_WRITEFLAG | ASM_TYPE_ARITH; - new->flagswritten = ASM_FLAG_SF | ASM_FLAG_ZF | ASM_FLAG_PF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aam.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aam.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aam.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aam.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* -** $Id: op_aam.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - * Handler for the aam instruction, opcode 0xd4 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of disassembled instruction. -*/ - -int op_aam(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AAM; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_SF | ASM_FLAG_ZF | ASM_FLAG_PF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aas.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aas.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_aas.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_aas.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_aas.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the aas instruction, opcode 0x3f - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of disassembled instruction. - */ - -int op_aas(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AAS; - new->type = ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG | ASM_TYPE_ARITH; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF; - new->flagsread = ASM_FLAG_AF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_al_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** $Id: op_adc_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_ADC; - new->len += 1; - new->ptr_instr = opcode; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_eax_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** $Id: op_adc_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_ADC; - new->ptr_instr = opcode; - new->len += 1; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].size = new->op[1].size = asm_proc_vector_size(proc); - - new->op[0].content = ASM_OP_FIXED | ASM_OP_BASE; - new->op[0].baser = ASM_REG_EAX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rb_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_adc_rb_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_ADC; - new->ptr_instr = opcode; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmb_rb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_adc_rmb_rb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_ADC; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmv_rv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_adc_rmv_rv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_ADC; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rv_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_adc_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_adc_rv_rmv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_adc_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_ADC; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_al_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: op_add_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x04 - Instruction : ADD -*/ - -int op_add_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - new->instr = ASM_ADD; - new->ptr_instr = opcode; - new->len += 1; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF | - ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** $Id: op_add_eax_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x05 - Instruction : ADD -*/ - -int op_add_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - - new->instr = ASM_ADD; - new->ptr_instr = opcode; - new->len += 1; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_AF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FIXED | ASM_OP_BASE; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_opsize(proc) ? ASM_REGSET_R16 : - ASM_REGSET_R32; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: op_add_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - * Opcode : 0x02 - * Instruction : ADD - * Destination is a byte register - * Source is a byte encoded - */ - -int op_add_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_ADD; - new->ptr_instr = opcode; - new->len++; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_AF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: op_add_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - * Opcode : 0x00 - * ADD - * Destination is an encoded byte. - * Source is a byte register. - */ - -int op_add_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_ADD; - new->ptr_instr = opcode; - new->len++; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_AF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmv_rv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: op_add_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - * Opcode : 0x01 - * Instruction : ADD - * Operands: Destination: encoded vector. - * Source: is a vector register. - */ - -int op_add_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len++; - new->ptr_instr = opcode; - new->instr = ASM_ADD; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_AF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rv_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_add_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: op_add_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the add rv, rmv instruction, opcode 0x03 - * @param new Pointer to the instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of the data to disassemble. - * @param proc Pointer to the processor structure. - * @return Length of the disassembled instruction. - */ - -int op_add_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_ADD; - new->len++; - new->ptr_instr = opcode; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_AF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_addsize.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_addsize.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_addsize.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_addsize.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** $Id: op_addsize.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_addsize(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - asm_i386_processor *i386p; - - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - - i386p = (asm_i386_processor *) proc; - new->prefix |= ASM_PREFIX_ADDSIZE; - - i386p->internals->addsize = !i386p->internals->addsize; - len = proc->fetch(new, opcode + 1, len - 1, proc); - i386p->internals->addsize = !i386p->internals->addsize; - - return (len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_al_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: op_and_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_AND; - new->ptr_instr = opcode; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_AL; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_eax_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** $Id: op_and_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_AND; - new->len += 1; - new->ptr_instr = opcode; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_R32; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_and_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AND; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmb_rb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_and_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AND; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmv_rv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_and_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AND; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rv_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_and_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_and_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_and_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_AND; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_ZF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_arpl_ew_rw.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_arpl_ew_rw.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_arpl_ew_rw.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_arpl_ew_rw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_arpl_ew_rw.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_arpl_ew_rw(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_ARPL; - new->len += 1; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_bound_gv_ma.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_bound_gv_ma.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_bound_gv_ma.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_bound_gv_ma.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/* -** $Id: op_bound_gv_ma.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_bound_gv_ma(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ -#if !LIBASM_USE_OPERAND_VECTOR - struct s_modrm *modrm; -#endif - - new->instr = ASM_BOUND; - new->len += 1; - new->ptr_instr = opcode; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_MEMORY, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_MEMORY, new); -#endif -#else - - modrm = (struct s_modrm *) (opcode + 1); - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_MEMORY; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].baser = modrm->r; - new->len += new->op[0].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_btr_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_btr_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_btr_rmv_rv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_btr_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_btr_rmv_rv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_btr_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_BTR; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rmv_rv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_call_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_call_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_call_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_call_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_call_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_call_iv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_CALL; - new->type = ASM_TYPE_CALLPROC | ASM_TYPE_TOUCHSP; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_clc.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_clc.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_clc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_clc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_clc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_clc(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CLC; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cld.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cld.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cld.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cld.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_cld.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cld(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CLD; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_DF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cli.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cli.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cli.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cli.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -** $Id: op_cli.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cli(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CLI; - new->type = ASM_TYPE_WRITEFLAG; - /* Should be VIF for CPL = 3 and IOPL < CPL */ - new->flagswritten = ASM_FLAG_IF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cltd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cltd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cltd.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cltd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* -** $Id: op_cltd.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cltd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH; - - if (asm_proc_opsize(proc)) - new->instr = ASM_CWTD; - else - new->instr = ASM_CLTD; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmc.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmc.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_cmc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmc(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_CMC; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_al_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** $Id: op_cmp_al_ib.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_CMP; - new->len += 1; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_AF | - ASM_FLAG_SF | ASM_FLAG_OF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_AL; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** $Id: op_cmp_eax_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_CMP; - new->ptr_instr = opcode; - new->len += 1; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FIXED | ASM_OP_BASE; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rb_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_cmp_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CMP; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_cmp_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_CMP; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmv_rv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_cmp_rmv_rv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CMP; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rv_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_cmp_rv_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CMP; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_cmpsb.c - * @brief Handler for instruction cmpsb opcode 0xa6 - * @ingroup handlers_ia32 - * $Id: op_cmpsb.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction cmpsb opcode 0xa6 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction . - */ - -int op_cmpsb(asm_instr *instr, u_char *opcode, u_int len, asm_processor *proc) -{ - instr->instr = ASM_CMPSB; - instr->len += 1; - instr->ptr_instr = opcode; - - instr->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - instr->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_XSRC, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_XSRC, instr); -#endif -#if WIP - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_YDEST, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_YDEST, instr); -#endif - - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsd.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmpsd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: op_cmpsd.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmpsd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_CMPSD; - - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_XSRC, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_YDEST, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_xchg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_xchg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_xchg.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cmp_xchg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** $Id: op_cmp_xchg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cmp_xchg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_CONTROL; - new->instr = ASM_CMPXCHG; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rmv_rv(new, opcode + 1, len - 1, proc); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cwtl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cwtl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_cwtl.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_cwtl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -** $Id: op_cwtl.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_cwtl(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH; - if (asm_proc_opsize(proc)) - new->instr = ASM_CBTW; - else - new->instr = ASM_CWTL; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_daa.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_daa.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_daa.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_daa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -** $Id: op_daa.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_daa(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_DAA; - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_AF | ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_SF | ASM_FLAG_ZF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_das.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_das.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_das.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_das.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -** $Id: op_das.c,v 1.4 2007/08/14 06:52:55 strauss Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_das(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_DAS; - new->type = ASM_TYPE_ARITH | ASM_TYPE_READFLAG | ASM_TYPE_WRITEFLAG; - new->flagsread = ASM_FLAG_AF | ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_SF | ASM_FLAG_ZF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_dec_reg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_dec_reg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_dec_reg.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_dec_reg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: op_dec_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - -int op_dec_reg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - new->ptr_instr = opcode; - new->instr = ASM_DEC; - new->len += 1; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_INCDEC | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_enter.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_enter.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_enter.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_enter.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** $Id: op_enter.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the enter instruction, opcode 0xc8 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. -*/ - -int op_enter(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_ENTER; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEWORD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEWORD, new); -#endif -#else - - new->op[0].type = ASM_OTYPE_IMMEDIATE; - new->op[0].content = ASM_OP_VALUE; - new->op[0].len = 2; - new->op[0].ptr = opcode + 1; - - new->op[0].imm = 0; - memcpy(&new->op[0].imm, opcode + 1, 2); - new->len += 2; -#endif - new->spdiff = -new->op[0].imm; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc0.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc0.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc0.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc0.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* -** $Id: op_esc0.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_esc0(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - switch(modrm->r) { - case 0: - new->instr = ASM_FADD; - - break; - case 1: - new->instr = ASM_FMUL; - break; - case 2: - new->instr = ASM_FCOM; - break; - case 3: - new->instr = ASM_FCOMP; - break; - case 4: - new->instr = ASM_FSUB; - break; - case 5: - new->instr = ASM_FSUBR; - break; - case 6: - new->instr = ASM_FDIV; - break; - case 7: - new->instr = ASM_FDIVR; - break; - } - if (modrm->mod < 3) - { - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - #else - new->op[0].type = ASM_OTYPE_FIXED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; - #endif - } - else - { - new->len += 1; - switch(modrm->r) - { - case 6: - case 0: - case 5: - case 1: - case 4: - case 7: -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[1].scale = modrm->m; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE; - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[1].scale = modrm->m; -#endif - break; - - case 2: - case 3: -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].scale = modrm->m; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].scale = modrm->m; -#endif - break; - } - } - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc1.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -/** - * @file op_esc1.c - * @ingroup handlers_ia32 - * $Id: op_esc1.c,v 1.8 2008/01/07 01:32:56 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for fpu instruction group 1, opcode 0xd9 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_esc1(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->ptr_instr = opcode; - new->len += 1; - if (modrm->mod == 3) - { - switch(modrm->r) - { - case 0: - new->instr = ASM_FLD; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->len += 1; - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; -#endif - break; - case 1: - new->instr = ASM_FXCH; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->len += 1; - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].len = 1; - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].scale = modrm->m; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].len = 1; - new->op[0].content = ASM_OP_FPU | ASM_OP_SCALE | ASM_OP_BASE; - new->op[0].scale = modrm->m; -#endif - break; - case 2: - new->instr = ASM_FNOP; break; - case 4: - new->len += 1; - switch(modrm->m) { - case 0: new->instr = ASM_FCHS; break; - case 1: new->instr = ASM_FABS; break; - case 4: new->instr = ASM_FTST; break; - case 5: new->instr = ASM_FXAM; break; - default: new->instr = ASM_BAD; break; - } - break; - case 5: - new->len += 1; - switch(modrm->m) { - case 0: new->instr = ASM_FLD1; break; - case 1: new->instr = ASM_FLDL2T; break; - case 2: new->instr = ASM_FLDL2E; break; - case 3: new->instr = ASM_FLDPI; break; - case 4: new->instr = ASM_FLDLG2; break; - case 5: new->instr = ASM_FLDLN2; break; - case 6: new->instr = ASM_FLDZ; break; - } - break; - case 6: - new->len += 1; - switch(modrm->m) { - case 0: new->instr = ASM_F2XM1; break; - case 1: new->instr = ASM_FYL2X; break; - case 2: new->instr = ASM_FPTAN; break; - case 3: new->instr = ASM_FPATAN; break; - case 4: new->instr = ASM_FXTRACT; break; - //case 5: new->instr = ASM_FPREM1; break; - case 6: new->instr = ASM_FDECSTP; break; - case 7: new->instr = ASM_FINCSTP; break; - } - break; - case 7: - new->len += 1; - switch(modrm->m) { - case 0: new->instr = ASM_FPREM; break; - case 1: new->instr = ASM_FYL2XP1; break; - case 2: new->instr = ASM_FSQRT; break; - case 3: new->instr = ASM_FSINCOS; break; - case 4: new->instr = ASM_FRNDINT; break; - case 5: new->instr = ASM_FSCALE; break; - //case 6: new->instr = ASM_SIN; break; - //case 7: new->instr = ASM_COS; break; - } - break; - } - } - else /* modrm != 3 */ - { - switch(modrm->r) - { - case 0: - new->instr = ASM_FLD; - break; - case 1: - new->instr = ASM_BAD; - break; - case 2: - new->instr = ASM_FST; - break; - case 3: - new->instr = ASM_FSTP; - break; - case 4: - new->instr = ASM_FLDENV; - break; - case 5: - new->instr = ASM_FLDCW; - break; - case 6: - if (!(new->prefix & ASM_PREFIX_FWAIT)) - new->instr = ASM_FNSTENV; - else - new->instr = ASM_FSTENV; - break; - case 7: - if (!(new->prefix & ASM_PREFIX_FWAIT)) - new->instr = ASM_FNSTCW; - else - new->instr = ASM_FSTCW; - break; - } - } - if (modrm->mod < 3) - { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); -#endif - } - -#if LIBASM_USE_OPERAND_VECTOR -#else - if (new->op[0].type) - new->len += new->op[0].len; - else - new->len += 1; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc2.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* -** $Id: op_esc2.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_esc2(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->ptr_instr = opcode; - new->len += 1; - if (modrm->mod == 3) - switch (modrm->r) { - case 5: new->instr = ASM_FUCOMPP; break; - default: new->instr = ASM_BAD; break; - } - else - switch(modrm->r) { - case 0: - new->instr = ASM_FIADD; - break; - case 1: - new->instr = ASM_FIMUL; - break; - case 2: - new->instr = ASM_FICOM; - break; - case 3: - new->instr = ASM_FICOMP; - break; - case 4: - new->instr = ASM_FISUB; - break; - case 5: - new->instr = ASM_FISUBR; - break; - case 6: - new->instr = ASM_FIDIV; - break; - case 7: - new->instr = ASM_FIDIVR; - break; - } - if (!(*(opcode + 1) == 0xe9)) { - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - #else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; - #endif - } else - new->len += 1; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc3.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc3.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc3.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** $Id: op_esc3.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_esc3(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - switch(modrm->r) - { - case 0: - new->instr = ASM_FILD; - break; - case 1: - new->instr = ASM_BAD; - break; - case 2: - new->instr = ASM_FIST; - break; - case 3: - new->instr = ASM_FISTP; - break; - case 4: - // bad - break; - case 5: - new->instr = ASM_FLD; - break; - case 6: - - case 7: - new->instr = ASM_FSTP; - break; - } -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc4.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc4.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc4.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc4.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/** - * $Id: op_esc4.c,v 1.5 2008/01/07 01:32:56 heroine Exp $ - * @file op_esc4.c - * - */ -#include -#include - -/** - * Handler of FPU instruction group esc4 opcode 0xdc - -*/ - -int op_esc4(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - switch(modrm->r) - { - case 0: - new->instr = ASM_FADD; - break; - case 1: - new->instr = ASM_FMUL; - break; - case 2: - new->instr= ASM_FCOM; - break; - case 3: - new->instr = ASM_FCOMP; - break; - case 4: - new->instr = ASM_FSUB; - break; - case 5: - new->instr = ASM_FSUBR; - break; - case 6: - new->instr = ASM_FDIV; - break; - case 7: - new->instr = ASM_FDIVR; - break; - } - - if (modrm->mod == 3) - { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE, - modrm->m, 0)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, 0, - asm_fixed_pack(0, ASM_OP_FPU | ASM_OP_BASE, 0, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_FPU | ASM_OP_BASE; - new->len += 1; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_FPU | ASM_OP_BASE; -#endif - } - else - { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_FIXED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); -#endif - } -#if LIBASM_USE_OPERAND_VECTOR -#else - if (new->op[0].type) - new->len += new->op[0].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc5.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc5.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc5.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc5.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/** - * @file op_esc5.c - * @ingroup handlers_ia32 - * $Id: op_esc5.c,v 1.7 2008/01/07 01:32:56 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for esc5 instruction group, opcode 0xdd - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_esc5(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - new->ptr_instr = opcode; - - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - if (modrm->mod == 3) - { - new->len += 1; - switch(modrm->r) - { - case 3: - new->instr = ASM_FSTP; - break; - case 4: - new->instr = ASM_FUCOM; - break; - case 5: - new->instr = ASM_FUCOMP; - break; - default: - new->instr = ASM_BAD; - break; - } - } - else - switch (modrm->r) { - case 0: - new->instr = ASM_FLD; - break; - case 1: - new->instr = ASM_BAD; - break; - case 2: - new->instr = ASM_FST; - break; - case 3: - new->instr = ASM_FSTP; - break; - case 4: - new->instr = ASM_BAD; // ASM_FRSTOR; - break; - case 5: - new->instr = ASM_BAD; // ; - break; - case 6: - if (!(new->prefix & ASM_PREFIX_FWAIT)) - new->instr = ASM_FNSAVE; - else - new->instr = ASM_FSAVE; - break; - case 7: - if (!(new->prefix & ASM_PREFIX_FWAIT)) - new->instr = ASM_FNSAVE; - else - new->instr = ASM_FSAVE; - break; - } - - if (modrm->mod == 3) - { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE, - modrm->m, 0)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].ptr = opcode + 1; - new->op[0].scale = modrm->m; -#else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].ptr = opcode + 1; - new->op[0].scale = modrm->m; -#endif - } - else - { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); -#endif - } -#if LIBASM_USE_OPERAND_VECTOR -#else - if (new->op[0].type) - new->len += new->op[0].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc6.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc6.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc6.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc6.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* -** $Id: op_esc6.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_esc6(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - new->ptr_instr = opcode; - - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - if (modrm->mod <= 2) { - switch(modrm->r) { - case 0: - new->instr = ASM_FIADD; - break; - case 1: - new->instr = ASM_FIMUL; - break; - case 2: - new->instr = ASM_FICOM; - break; - case 3: - new->instr = ASM_FICOMP; - break; - case 4: - new->instr = ASM_FISUB; - break; - case 5: - new->instr = ASM_FISUBR; - break; - case 6: - new->instr = ASM_FIDIV; - - break; - case 7: - new->instr = ASM_FIDIVR; - break; - } - } else { - switch(modrm->r) { - case 0: new->instr = ASM_FADDP; break; - case 1: - new->instr = ASM_FMULP; - break; - case 2: - new->instr = ASM_FCOMPS; - break; - case 3: new->instr = ASM_FCOMPP; - break; - case 4: new->instr = ASM_FSUBP; - break; - case 5: new->instr = ASM_FSUBRP; - break; - case 6: - switch(modrm->m) { - case 3: case 5: case 2: case 4: case 6: case 1: - new->instr = ASM_FDIVP; break; - default: case 0: new->instr = ASM_FDIVP; break; - } - break; - case 7: - switch(modrm->m) { - case 3: new->instr = ASM_FDIVR; break; - default: new->instr = ASM_FDIV; break; - } - break; - } - } - - if (!(*(opcode + 1) == 0xd9)) { - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE, - modrm->m, - 0)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_FPU | ASM_OP_BASE; - new->op[1].len = 0; - #else - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE; - new->op[0].len = 1; - new->op[0].scale = modrm->m; - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_FPU | ASM_OP_BASE; - new->op[1].len = 0; -#endif - } else - new->len++; - #if LIBASM_USE_OPERAND - - #else - if (new->op[0].type) - new->len += new->op[0].len; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc7.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc7.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc7.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_esc7.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -/** - * $Id: op_esc7.c,v 1.6 2008/01/07 01:32:56 heroine Exp $ - * @param - */ -#include -#include - -/** - * Handler for fpu instruction for opcode 0xdf - * - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * - -*/ - -int op_esc7(asm_instr *instr, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - instr->ptr_instr = opcode; - instr->len += 1; - if (*(opcode + 1) == 0xe0) - { - if (!(instr->prefix & ASM_PREFIX_FWAIT)) - instr->instr = ASM_FNSTSW; - else - instr->instr = ASM_FSTSW; - instr->op[0].type = ASM_OTYPE_FIXED; - instr->op[0].content = ASM_OP_BASE; - instr->op[0].regset = ASM_REGSET_R16; - instr->op[0].baser = ASM_REG_EAX; - } - else - switch (modrm->r) - { - case 0: - instr->instr = ASM_FILD; - break; - case 1: - // bad instr->instr = ASM_; - break; - case 2: - instr->instr = ASM_FIST; - break; - case 3: - instr->instr = ASM_FISTP; - break; - case 4: - instr->instr = ASM_FBLD; - break; - case 5: - instr->instr = ASM_FILD; - break; - case 6: - instr->instr = ASM_FBSTP; - break; - case 7: - instr->instr = ASM_FISTP; - break; - } - if (*(opcode + 1) != 0xe0) { -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, - instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, - instr); -#endif -#else - instr->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&instr->op[0], opcode + 1, len - 1, proc); - instr->len += instr->op[0].len; -#endif - } else - instr->len++; - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_fwait.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_fwait.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_fwait.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_fwait.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/** - * $Id: op_fwait.c,v 1.7 2008/01/07 01:32:56 heroine Exp $ - * @file op_fwait.c - */ -#include -#include - -/** - * Instruction handler for opcode 0x9b. - * This opcode is the for fwait prefix opcode. - * Disassembling is forwarded on next byte after execution of this - * handler. - * - * @param new Pointer to instruction structure. - * @param opcode Pointer to buffer to disassemble. - * @param len Length of buffer to disassemble. - * @param proc Pointer to processor structure. - * @return Length of disassembled instruction. - */ - -int op_fwait(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - if (!new->ptr_prefix) - new->ptr_instr = opcode; - new->prefix |= ASM_PREFIX_FWAIT; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_group6.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_group6.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_group6.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_group6.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** $Id: op_group6.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int op_group6(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - new->len += 1; - modrm = (struct s_modrm *) opcode + 1; - switch(modrm->r) { - case 0: - new->instr = ASM_SLDT; - break; - case 1: - new->instr = ASM_STR; - break; - case 2: - new->instr = ASM_LLDT; - break; - case 3: - new->instr = ASM_LTR; - break; - case 4: - case 5: - case 6: - case 7: - break; - } - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - new->op[0].regset = ASM_REGSET_R16; - #else - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; - new->op[0].regset = ASM_REGSET_R16; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_group7.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_group7.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_group7.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_group7.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* -** $Id: op_group7.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -int op_group7(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - new->len += 1; - modrm = (struct s_modrm *) opcode + 1; - - switch(modrm->r) - { - case 0: - new->instr = ASM_SGDT; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - break; - case 1: - new->instr = ASM_SIDT; - break; - case 2: - new->instr = ASM_LGDT; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - break; - case 3: - new->instr = ASM_LIDT; -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#else - new->op[0].type = ASM_OTYPE_ENCODED; - operand_rmv(&new->op[0], opcode + 1, len - 1, proc); - new->len += new->op[0].len; -#endif - break; - case 4: - break; - case 5: - new->instr = ASM_BAD; - break; - case 6: - - break; - case 7: - - break; - } - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_hlt.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_hlt.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_hlt.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_hlt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_hlt.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_hlt(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_HLT; - new->type = ASM_TYPE_STOP; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmb_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmb_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmb_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmb_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* -** $Id: op_immed_rmb_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - -*/ - -int op_immed_rmb_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len+= 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_OF | - ASM_FLAG_PF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - switch(modrm->r) - { - case 0: - new->instr = ASM_ADD; - break; - case 1: - new->instr = ASM_ORB; - new->flagswritten ^= ASM_FLAG_AF; - new->op[1].imm &= 0xff; - break; - case 2: - new->instr = ASM_ADC; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 3: - new->instr = ASM_SBB; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 4: - new->instr = ASM_AND; - new->flagswritten ^= ASM_FLAG_AF; - new->op[1].imm &= 0xff; - break; - case 5: - new->instr = ASM_SUB; - if (new->op[0].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_ESP) - new->type |= ASM_TYPE_EPILOG; - break; - case 6: - new->instr = ASM_XOR; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 7: - new->instr = ASM_CMP; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->op[1].imm &= 0xff; - break; - } - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* -** $Id: op_immed_rmv_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_immed_rmv_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - struct s_modrm *modrm; - - modrm = (struct s_modrm *) (opcode + 1); - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_OF | - ASM_FLAG_PF | ASM_FLAG_SF | ASM_FLAG_ZF; - - switch(modrm->r) { - case 0: - new->instr = ASM_ADD; - break; - case 1: - new->instr = ASM_OR; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 2: - new->instr = ASM_ADC; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 3: - new->instr = ASM_SBB; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 4: - new->instr = ASM_AND; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 5: - new->instr = ASM_SUB; - if (new->op[0].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_ESP) - new->type |= ASM_TYPE_EPILOG; - break; - case 6: - new->instr = ASM_XOR; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 7: - new->instr = ASM_CMP; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - break; - } - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_immed_rmv_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* -** $Id: op_immed_rmv_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_immed_rmv_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - struct s_modrm *modrm; - new->ptr_instr = opcode; - - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_OF | - ASM_FLAG_PF | ASM_FLAG_SF | ASM_FLAG_ZF; - - switch(modrm->r) { - case 0: - new->instr = ASM_ADD; - break; - case 1: - new->instr = ASM_OR; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 2: - new->instr = ASM_ADC; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 3: - new->instr = ASM_SBB; - new->type |= ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - break; - case 4: - new->instr = ASM_AND; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 5: - new->instr = ASM_SUB; - if (new->op[0].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_ESP) - new->type |= ASM_TYPE_EPILOG; - break; - case 6: - new->instr = ASM_XOR; - new->flagswritten ^= ASM_FLAG_AF; - break; - case 7: - new->instr = ASM_CMP; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - break; - } - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_gv_ev_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_gv_ev_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_gv_ev_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_gv_ev_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/* -** $Id: op_imul_gv_ev_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_imul_gv_ev_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_IMUL; - - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_rv_rmv_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_rv_rmv_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_rv_rmv_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_imul_rv_rmv_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/** - * @file op_imul_rv_rmv_iv.c - * @brief Handler for instruction op_imul_rv_rmv_iv opcode 0x69 - * @ingroup handlers_ia32 -** $Id: op_imul_rv_rmv_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction op_imul_rv_rmv_iv opcode 0x69 - * - * - */ - -int op_imul_rv_rmv_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - new->instr = ASM_IMUL; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[2], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_dx.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_dx.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_dx.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_dx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** $Id: op_in_al_dx.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_in_al_dx(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - new->len += 1; - new->instr = ASM_IN; - new->type = ASM_TYPE_LOAD | ASM_TYPE_IO; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - - new->ptr_instr = opcode; - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_AL; - -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_DX; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_ref_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_ref_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_ref_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_al_ref_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/** - * @file op_in_al_ref_ib.c - * @ingroup handlers_ia32 - * @brief Handler for instruction in al,ib opcode 0xe4 - - * $Id: op_in_al_ref_ib.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction in al,ib opcode 0xe4 - * - -*/ - -int op_in_al_ref_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_IN; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_LOAD | ASM_TYPE_IO; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_AL; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_AL; - - new->op[1].type = ASM_OTYPE_IMMEDIATE; - new->op[1].content = ASM_OP_VALUE; - - new->len += 1; - new->op[1].imm = 0; - memcpy(&new->op[1].imm, opcode + 1, 1); - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_incdec_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_incdec_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_incdec_rmb.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_incdec_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* -** $Id: op_incdec_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_incdec_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_INCDEC | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - - switch(modrm->r) { - case 0: - new->instr = ASM_INC; - break; - case 1: - new->instr = ASM_DEC; - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - break; - default: - break; - } - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_inc_reg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_inc_reg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_inc_reg.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_inc_reg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** $Id: op_inc_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - - -int op_inc_reg(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - new->len += 1; - new->instr = ASM_INC; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_INCDEC | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_indir_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_indir_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_indir_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_indir_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* -** $Id: op_indir_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_indir_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) (opcode + 1); - new->len += 1; - switch(modrm->r) { - case 0: - new->instr = ASM_INC; - new->type = ASM_TYPE_INCDEC | ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - break; - case 1: - new->instr = ASM_DEC; - new->type = ASM_TYPE_INCDEC | ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - break; - case 2: - new->type = ASM_TYPE_CALLPROC | ASM_TYPE_TOUCHSP; - new->spdiff = -4; - new->instr = ASM_CALL; - new->op[0].type = ASM_OTYPE_MEMORY; - break; - case 3: - new->type = ASM_TYPE_CALLPROC | ASM_TYPE_TOUCHSP; - new->instr = ASM_CALL; - new->op[0].type = ASM_OTYPE_MEMORY; - - break; - case 4: - new->type = ASM_TYPE_IMPBRANCH; - new->instr = ASM_BRANCH; - new->op[0].type = ASM_OTYPE_MEMORY; - break; - case 5: - new->type = ASM_TYPE_IMPBRANCH; - new->instr = ASM_BRANCH; - new->op[0].type = ASM_OTYPE_MEMORY; - break; - case 6: - new->instr = ASM_PUSH; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - break; - case 7: - new->instr = ASM_BAD; - new->op[0].type = ASM_OTYPE_ENCODED; - new->op[0].size = ASM_OSIZE_VECTOR; - break; - default: - break; - } /* switch */ - if ((new->op[0].type == ASM_OTYPE_ENCODED) || - (new->op[0].type == ASM_OTYPE_MEMORY)) { -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - if (new->op[0].type == ASM_OTYPE_MEMORY) - new->op[0].content |= ASM_OP_ADDRESS; - } - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_dx.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_dx.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_dx.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_dx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** $Id: op_in_eax_dx.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for instruction in eax,dx opcode 0xed - * - */ - -int op_in_eax_dx(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_IN; - new->ptr_instr = opcode; - new->type = ASM_TYPE_LOAD | ASM_TYPE_IO; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R32; - new->op[0].baser = ASM_REG_EAX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE | ASM_OP_REFERENCE, ASM_REG_DX, - ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_DX; - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_ref_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_ref_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_ref_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_in_eax_ref_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** $Id: op_in_eax_ref_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_in_eax_ref_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_IN; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_LOAD | ASM_TYPE_IO; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - new->op[1].content = ASM_OP_REFERENCE | ASM_OP_VALUE; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_insb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_insb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_insb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_insb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** $Id: op_insb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_insb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_INSB; - new->ptr_instr = opcode; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE | ASM_OP_REFERENCE, ASM_REG_DX, - ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_EDX; -#else - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_EDX; - - new->op[0].type = ASM_OTYPE_YDEST; - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].prefix = ASM_PREFIX_DS; - new->op[0].baser = ASM_REG_EDI; - new->op[0].regset = asm_proc_addsize(proc) ? ASM_REGSET_R16 : - ASM_REGSET_R32; -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_insw.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_insw.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_insw.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_insw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** $Id: op_insw.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - -*/ - -int op_insw(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - - if (!asm_proc_opsize(proc)) - new->instr = ASM_INSW; - else - new->instr = ASM_INSD; - new->ptr_instr = opcode; - -#if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE | ASM_OP_REFERENCE, ASM_REG_DX, - ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_DX; -#else - new->op[0].type = ASM_OTYPE_YDEST; - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].baser = ASM_REG_EDI; - new->op[0].prefix = ASM_PREFIX_DS; - new->op[0].regset = asm_proc_addsize(proc) ? ASM_REGSET_R16 : - ASM_REGSET_R32; - - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[1].regset = ASM_REGSET_R16; - new->op[1].baser = ASM_REG_DX; - -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int1.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int1.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int1.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_int1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_int1(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_INT1; - new->type = ASM_TYPE_INT | ASM_TYPE_TOUCHSP; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_3.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_3.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_3.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_int_3.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_int_3(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_INT3; - new->type = ASM_TYPE_INT | ASM_TYPE_TOUCHSP; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_int_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_int_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_int_ib(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_INT; - new->type = ASM_TYPE_INT | ASM_TYPE_TOUCHSP; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_into.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_into.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_into.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_into.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_into.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_into(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_INTO; - new->type = ASM_TYPE_INT | ASM_TYPE_TOUCHSP | ASM_TYPE_READFLAG | ASM_TYPE_BITTEST; - new->flagsread = ASM_FLAG_OF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_iret.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_iret.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_iret.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_iret.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/** - * @file op_iret.c - * @ingroup handlers_ia32 - * $Id: op_iret.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * -*/ -#include -#include - -/** - * - * - */ - -int op_iret(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_IRET; - new->type = ASM_TYPE_INT | ASM_TYPE_TOUCHSP | ASM_TYPE_RETPROC | - ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_NT | ASM_FLAG_VM; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ja.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ja.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ja.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ja.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_ja.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_ja(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_U_GREATER; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jae.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jae.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jae.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jae.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jae.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_jae(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_U_GREATER_EQUAL; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** $Id: op_jb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_jb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_U_LESS; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jbe.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jbe.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jbe.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jbe.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jbe.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jbe(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_U_LESS_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_je.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_je.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_je.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_je.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_je.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_je(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_BRANCH_EQUAL; - new->type = ASM_TYPE_CONDBRANCH; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_je_cxz.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_je_cxz.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_je_cxz.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_je_cxz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_je_cxz.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_je_cxz(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_CXZ; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jg.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jg.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jg(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_S_GREATER; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jge.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jge.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jge.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jge.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jge.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jge(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_S_GREATER_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jl.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jl.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jl(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_S_LESS; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jle.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jle.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jle.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jle.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jle.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jle(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_S_LESS_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ap.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ap.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ap.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jmp_ap.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_jmp_ap(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_LBRANCH; - new->len += 1; - new->type = ASM_TYPE_IMPBRANCH; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ADDRESS, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ADDRESS, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jmp_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_jmp_ib(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_BRANCH; - - new->type = ASM_TYPE_IMPBRANCH; - new->ptr_instr = opcode; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jmp_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jmp_iv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_jmp_iv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_BRANCH; - new->type = ASM_TYPE_IMPBRANCH; - new->ptr_instr = opcode; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jne.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jne.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jne.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jne.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_jne(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jno.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jno.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jno.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jno.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_jno.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_jno(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_OVERFLOW; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_JUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jnp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jnp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jnp.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jnp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jnp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jnp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_PARITY; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jns.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jns.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jns.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jns.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jns.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jns(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_NOT_SIGNED; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jo.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jo.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jo.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/** - * @file op_jo.c - * @ingroup handlers_ia32 - * $Id: op_jo.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Instructiono jo handler for opcode 0x70 - * - */ - -int op_jo(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_jp.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_jp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_jp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_jp(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_PARITY; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_js.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_js.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_js.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_js.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_js.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_js(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_BRANCH_SIGNED; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lahf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lahf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lahf.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lahf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/** - * @file op_lahf.c - * @ingroup handlers_ia32 - * $Id: op_lahf.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for lahf instruction opcode 0x9f - * - -*/ - -int op_lahf(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_LAHF; - new->type = ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_SF | ASM_FLAG_ZF | ASM_FLAG_AF | - ASM_FLAG_PF | ASM_FLAG_CF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lds_rm_rmp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lds_rm_rmp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lds_rm_rmp.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lds_rm_rmp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* -** $Id: op_lds_rm_rmp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for instruction lds opcode 0xc5 - * - -*/ - -int op_lds_rm_rmp(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_LDS; - new->len += 1; - new->type = ASM_TYPE_LOAD; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lea_rv_m.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lea_rv_m.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lea_rv_m.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lea_rv_m.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/** - * @file op_lea_rv_m.c - * @ingroup handlers_ia32 - * $Id: op_lea_rv_m.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * - - */ - -int op_lea_rv_m(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_LEA; - new->type = ASM_TYPE_ARITH; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_leave.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_leave.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_leave.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_leave.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/** - * @file op_leave.c - * @ingroup handlers_ia32 - * $Id: op_leave.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for the leave instruction opcode 0xc9 - * @param new Pointer to the instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. -*/ - -int op_leave(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP; - new->spdiff = 4; - new->instr = ASM_LEAVE; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_les_rm_rmp.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_les_rm_rmp.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_les_rm_rmp.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_les_rm_rmp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_les_rm_rmp.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_les_rm_rmp(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_LES; - new->len += 1; - new->type = ASM_TYPE_LOAD; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lock.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lock.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lock.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lock.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_lock.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_lock(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - new->prefix = ASM_PREFIX_LOCK; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_lodsb.c - * @ingroup handlers_ia32 - * $Id: op_lodsb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * - */ - -int op_lodsb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_LODSB; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_LOAD; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[1].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->op[1].baser = ASM_REG_EAX; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsd.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lodsd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** $Id: op_lodsd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_lodsd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_LODSD; - new->ptr_instr = opcode; - new->type = ASM_TYPE_LOAD; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_XSRC, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loop.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loop.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loop.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_loop.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_loop(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_CONDBRANCH; - new->instr = ASM_LOOP; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loope.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loope.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loope.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loope.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_loope.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_loope(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_LOOPE; - new->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loopne.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loopne.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_loopne.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_loopne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_loopne.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_loopne(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_LOOPNE; - new->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_READFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagsread = ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SHORTJUMP, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lss_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lss_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_lss_rv_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_lss_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_lss_rv_rmv.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_lss_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_LSS; - - #if LIBASM_USE_OPERAND_VECTOR -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - #else - new->op[0].type = ASM_OTYPE_GENERAL; - new->op[1].type = ASM_OTYPE_ENCODED; - operand_rv_rmv(new, opcode + 1, len - 1, proc); - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_al_ref_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_al_ref_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_al_ref_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_al_ref_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** $Id: op_mov_al_ref_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_mov_al_ref_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_MOV; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ASSIGN; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_OFFSET, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_OFFSET, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_eax_ref_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_eax_ref_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_eax_ref_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_eax_ref_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file op_mov_eax_ref_iv.c - * @ingroup handlers_ia32 - * $Id: op_mov_eax_ref_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Instruction handler for opcode 0xa1 - * - -*/ - -int op_mov_eax_ref_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_MOV; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ASSIGN; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[0].ptr = opcode; - new->op[0].type = ASM_OTYPE_FIXED; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->op[0].baser = ASM_REG_EAX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_OFFSET, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_OFFSET, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file op_mov_rb_rmb.c - * @ingroup handlers_ia32 - * $Id: op_mov_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for opcode 0x8a : instruction op_mov_rb_rmb - -*/ - -int op_mov_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_ASSIGN; - new->instr = ASM_MOV; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_al.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_al.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_al.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_al.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file op_mov_ref_iv_al.c - * @ingroup handlers_ia32 - * $Id: op_mov_ref_iv_al.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * - */ - -int op_mov_ref_iv_al(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_MOV; - new->type = ASM_TYPE_ASSIGN; - new->ptr_instr = opcode; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_OFFSET, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_OFFSET, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[1].type = ASM_OTYPE_FIXED; - new->op[1].regset = ASM_REGSET_R8; - new->op[1].content = ASM_OP_BASE; - new->op[1].baser = ASM_REG_AL; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_eax.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_eax.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_eax.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_ref_iv_eax.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * @file op_mov_ref_iv_eax.c - * @ingroup handlers_ia32 - * $Id: op_mov_ref_iv_eax.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - -*/ - -int op_mov_ref_iv_eax(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_MOV; - new->type = ASM_TYPE_ASSIGN; - new->len += 1; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_OFFSET, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_OFFSET, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_reg_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_reg_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_reg_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_reg_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** $Id: op_mov_reg_iv.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - -int op_mov_reg_iv(asm_instr *new, u_char *opcode, u_int len, -asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - new->type = ASM_TYPE_ASSIGN; - new->ptr_instr = opcode; - new->instr = ASM_MOV; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 0, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 0, ASM_OTYPE_OPMOD, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * - * @file op_mov_rmb_ib.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmb_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * - -*/ - -int op_mov_rmb_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - new->type = ASM_TYPE_ASSIGN; - new->len += 1; - new->instr = ASM_MOV; - new->ptr_instr = opcode; - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen , ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen , ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_rb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * @file op_mov_rmb_rb.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - -*/ - -int op_mov_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ASSIGN; - new->instr = ASM_MOV; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rm_segr.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rm_segr.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rm_segr.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rm_segr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_mov_rm_segr.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_mov_rm_segr(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->type = ASM_TYPE_ASSIGN; - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_MOV; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_SEGMENT, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_SEGMENT, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/** - * @file op_mov_rmv_iv.c - * @ingroup handlers_ia32 - * $Id: op_mov_rmv_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * ChangeLog: - * - */ -#include -#include - -/** - * Handler for opcode 0xc7 - * @param new - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_mov_rmv_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - int olen; - new->len += 1; - new->type = ASM_TYPE_ASSIGN; - new->ptr_instr = opcode; - new->instr = ASM_MOV; - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0)); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new)); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, ASM_OTYPE_IMMEDIATE, new); -#endif - - if (asm_instruction_is_prefixed(new, ASM_PREFIX_OPSIZE)) - { - if (asm_operand_is_reference(&new->op[0])) - { - new->instr = ASM_MOVW; - } - } - else - new->instr = ASM_MOV; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_rv.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** $Id: op_mov_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_mov_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->type = ASM_TYPE_ASSIGN; - new->len += 1; - new->instr = ASM_MOV; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - if (new->op[0].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_EBP && - new->op[1].baser == ASM_REG_ESP) { - - new->type |= ASM_TYPE_PROLOG; - } - else if (new->op[0].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_ESP && - new->op[1].baser == ASM_REG_EBP) { - - new->type |= ASM_TYPE_EPILOG; - } - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rv_rmv.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** $Id: op_mov_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_mov_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ASSIGN; - new->instr = ASM_MOV; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - if (new->op[1].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_EBP && - new->op[1].baser == ASM_REG_ESP) { - - new->type |= ASM_TYPE_PROLOG; - } - else if (new->op[1].content == ASM_OP_BASE && - new->op[0].baser == ASM_REG_ESP && - new->op[1].baser == ASM_REG_EBP) { - - new->type |= ASM_TYPE_EPILOG; - } - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** $Id: op_movsb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_movsb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_MOVSB; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_LOAD | ASM_TYPE_STORE | ASM_TYPE_ASSIGN; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsd.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_movsd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_movsd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_movsd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - if (asm_proc_opsize(proc)) - new->instr = ASM_MOVSW; - else - new->instr = ASM_MOVSD; - - new->type = ASM_TYPE_LOAD | ASM_TYPE_STORE | ASM_TYPE_ASSIGN; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_segr_rm.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_segr_rm.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_segr_rm.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_segr_rm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_mov_segr_rm.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_mov_segr_rm(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->type = ASM_TYPE_ASSIGN; - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_MOV; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SEGMENT, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_SEGMENT, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_subreg_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_subreg_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_subreg_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_mov_subreg_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file op_mov_subreg_ib.c - * @ingroup handlers_ia32 - * $Id: op_mov_subreg_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - - - - - - - - - -*/ - -int op_mov_subreg_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ASSIGN; - new->instr = ASM_MOV; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_nop.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_nop.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_nop.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_nop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/** - * @file op_nop.c - * @ingroup handlers_ia32 - * $Id: op_nop.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for the nop instruction, opcode 0x90 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of the instruction. - */ - -int op_nop(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_NOP; - new->type = ASM_TYPE_NOP; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_opsize.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_opsize.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_opsize.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_opsize.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_opsize.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_opsize(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - asm_i386_processor *i386p; - - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - i386p = (asm_i386_processor *) proc; - - i386p->internals->opsize = !i386p->internals->opsize; - new->len += 1; - new->prefix |= ASM_PREFIX_OPSIZE; - len = proc->fetch(new, opcode + 1, len - 1, proc); - i386p->internals->opsize = !i386p->internals->opsize; - return (len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_al_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** $Id: op_or_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0c - Instruction : OR -*/ - -int op_or_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** $Id: op_or_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0d - Instruction : OR - */ - -int op_or_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_FIXED | ASM_OP_BASE; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->op[0].baser = ASM_REG_EAX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: op_or_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0a - */ - -int op_or_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_or_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x08 - Instruction : OR -*/ - -int op_or_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmv_rv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_or_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x09 - Instruction : OR -*/ - -int op_or_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->instr = ASM_OR; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rv_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_or_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* -** $Id: op_or_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x0b - Instruction : OR -*/ - -int op_or_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->ptr_instr = opcode; - new->len += 1; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_al.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_al.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_al.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_al.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** $Id: op_out_dx_al.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_out_dx_al(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_OUT; - new->type = ASM_TYPE_IO | ASM_TYPE_STORE; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DX, - ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].regset = ASM_REGSET_R16; - new->op[0].baser = ASM_REG_DX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R8; - new->op[1].baser = ASM_REG_AL; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_eax.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_eax.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_eax.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_dx_eax.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/** - * @file op_out_dx_eax.c - * @ingroup handlers_ia32 - * - * $Id: op_out_dx_eax.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - - */ - -int op_out_dx_eax(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_OUT; - new->type = ASM_TYPE_IO | ASM_TYPE_STORE; - - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DX, - ASM_REGSET_R16)); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].regset = ASM_REGSET_R16; - new->op[0].baser = ASM_REG_DX; -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].baser = ASM_REG_EAX; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_al.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_al.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_al.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_al.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** $Id: op_out_ref_ib_al.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_out_ref_ib_al(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_OUT; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_IO | ASM_TYPE_STORE; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATEBYTE, new); -#endif -#if WIP - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_FIXED, new); -#endif - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R8; - new->op[1].baser = ASM_REG_AL; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_eax.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_eax.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_eax.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_out_ref_ib_eax.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_out_ref_ib_eax.c - * @ingroup handlers_ia32 - * $Id: op_out_ref_ib_eax.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/* - -*/ - -int op_out_ref_ib_eax(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_OUT; - new->len += 1; - new->type = ASM_TYPE_IO | ASM_TYPE_STORE; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode, - ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new); - new->len += asm_operand_fetch(&new->op[1], opcode, - ASM_OTYPE_FIXED, new); - new->op[1].content = ASM_OP_BASE; - new->op[1].regset = ASM_REGSET_R32; - new->op[1].baser = ASM_REG_EAX; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** $Id: op_outsb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_outsb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_OUTSB; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DX, - ASM_REGSET_R16)); - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].regset = ASM_REGSET_R16; - new->op[0].baser = ASM_REG_EDX; - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsw.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsw.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsw.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_outsw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** $Id: op_outsw.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - -*/ - -int op_outsw(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - - if (!asm_proc_opsize(proc)) - new->instr = ASM_OUTSW; - else - new->instr = ASM_OUTSD; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DX, - ASM_REGSET_R16)); - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_REFERENCE; - new->op[0].regset = ASM_REGSET_R16; - new->op[0].baser = ASM_REG_DX; - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_popa.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_popa.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_popa.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_popa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* -** $Id: op_popa.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the popa instruction. Opcode = 0x61 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of buffer to disassemble. - * @param proc Pointer to processor structure. -*/ - -int op_popa(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_POPA; - new->spdiff = 8 * 4; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_LOAD; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ds.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ds.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ds.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ds.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: op_pop_ds.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_pop_ds(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_POP; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - new->spdiff = 4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DS, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_DS; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_es.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_es.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_es.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_es.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** $Id: op_pop_es.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - Opcode : 0x07 - Instruction : POP -*/ - -int op_pop_es(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_POP; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_ASSIGN | ASM_TYPE_LOAD; - new->spdiff = 4; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_ES, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_ES; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_popf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_popf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_popf.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_popf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: op_popf.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_popf(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_POPF; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_LOAD | ASM_TYPE_WRITEFLAG; - new->spdiff = 4; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_AF | - ASM_FLAG_ZF | ASM_FLAG_SF | ASM_FLAG_TF | - ASM_FLAG_IF | ASM_FLAG_DF | ASM_FLAG_OF | - ASM_FLAG_IOPL | ASM_FLAG_NT | ASM_FLAG_RF | - ASM_FLAG_AC | ASM_FLAG_VIF | ASM_FLAG_VIP | - ASM_FLAG_ID; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_reg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_reg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_reg.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_reg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** $Id: op_pop_reg.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - -int op_pop_reg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_POP; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_ASSIGN | ASM_TYPE_LOAD; - new->spdiff = 4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif - if (new->op[0].baser == ASM_REG_EBP) - new->type |= ASM_TYPE_EPILOG; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_rmv.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: op_pop_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for the pop [rmv] instruction opcode = 0x8f - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Lenght of buffer to disassemble. - * @param proc Pointer to processor structure. - * -*/ - -int op_pop_rmv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_POP; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_ASSIGN | ASM_TYPE_LOAD; - new->spdiff = 4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ss.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ss.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ss.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pop_ss.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @brief Handler for pop es instruction. Opcode = 0x17 - * @ingroup handlers_ia32 -** $Id: op_pop_ss.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for pop es instruction. Opcode = 0x17 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - */ - -int op_pop_ss(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_POP; - new->len += 1; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_ASSIGN | ASM_TYPE_LOAD; - new->spdiff = 4; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_ES, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_SS; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_cs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_cs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_cs.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_cs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_prefix_cs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_prefix_cs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->prefix |= ASM_PREFIX_CS; - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ds.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ds.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ds.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ds.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/** - * @file op_prefix_ds.c - * @ingroup handlers_ia32 - * $Id: op_prefix_ds.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - * Changelog - * 200-07-29 : instruction length was not incremented. fixed. - */ -#include -#include - -/* - -*/ - -int op_prefix_ds(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - new->prefix |= ASM_PREFIX_DS; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_es.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_es.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_es.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_es.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_prefix_es.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_prefix_es(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->prefix |= ASM_PREFIX_ES; - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_fs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_fs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_fs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_fs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_prefix_fs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_prefix_fs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->prefix |= ASM_PREFIX_FS; - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_gs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_gs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_gs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_gs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_prefix_gs.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_prefix_gs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->prefix |= ASM_PREFIX_GS; - new->len += 1; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ss.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ss.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ss.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_prefix_ss.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -/* -** $Id: op_prefix_ss.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_prefix_ss(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->prefix |= ASM_PREFIX_SS; - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pusha.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pusha.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pusha.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pusha.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* -** $Id: op_pusha.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_pusha(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSHA; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4 * 8; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_cs.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_cs.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_cs.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_cs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @brief Handler for instruction push cs opcode 0x0e - * @ingroup handlers_ia32 -** $Id: op_push_cs.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - - -/** - * @brief Handler for instruction push cs opcode 0x0e - */ -int op_push_cs(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSH; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_CS, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_CS; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ds.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ds.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ds.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ds.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/** - * @brief Handler for instruction push ds opcode 0x1e - * @ingroup handlers_ia32 -** $Id: op_push_ds.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * Handler for instruction push ds opcode 0x1e - * -*/ - -int op_push_ds(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSH; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_DS, - ASM_REGSET_SREG)); - - //asm_fixed_pack(content, type, regset, baser) -#else - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_DS; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_es.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_es.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_es.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_es.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file op_push_es.c - * @ingroup handlers_ia32 -** $Id: op_push_es.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction push es opcode 0x06 -*/ - -int op_push_es(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSH; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_ES, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content |= ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_ES; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pushf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pushf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_pushf.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_pushf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** $Id: op_pushf.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_pushf(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSHF; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE | ASM_TYPE_READFLAG; - new->spdiff = -4; - new->flagsread = ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_AF | - ASM_FLAG_ZF | ASM_FLAG_SF | ASM_FLAG_TF | - ASM_FLAG_IF | ASM_FLAG_DF | ASM_FLAG_OF | - ASM_FLAG_IOPL | ASM_FLAG_NT | ASM_FLAG_RF | - ASM_FLAG_AC | ASM_FLAG_VIF | ASM_FLAG_VIP | - ASM_FLAG_ID; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* -** $Id: op_push_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_push_ib(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_PUSH; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_push_iv.c - * @ingroup handlers_ia32 - * $Id: op_push_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * - * Handler for opcode 0x68 , instruction push_iv - -*/ - -int op_push_iv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_PUSH; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_IMMEDIATE, - new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_reg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_reg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_reg.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_reg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** $Id: op_push_reg.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - - - - - - - -*/ - -int op_push_reg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_PUSH; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_OPMOD, new); -#endif - - if (new->op[0].baser == ASM_REG_EBP) - new->type |= ASM_TYPE_PROLOG; - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ss.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ss.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ss.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_push_ss.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** $Id: op_push_ss.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_push_ss(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_PUSH; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_TOUCHSP | ASM_TYPE_STORE; - new->spdiff = -4; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_SS, - ASM_REGSET_SREG)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_SREG; - new->op[0].baser = ASM_REG_SS; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_repnz.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_repnz.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_repnz.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_repnz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/** - * @file op_repnz.c - * @ingroup handlers_ia32 -** $Id: op_repnz.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_repnz(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - new->prefix = ASM_PREFIX_REPNE; - - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_repz.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_repz.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_repz.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_repz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/** - * @file op_repz.c - * @ingroup handlers_ia32 -** $Id: op_repz.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_repz(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - if (!new->ptr_prefix) - new->ptr_prefix = opcode; - new->len += 1; - new->prefix = ASM_PREFIX_REP; - return (proc->fetch(new, opcode + 1, len - 1, proc)); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/** - * @file op_ret.c - * @ingroup handlers_ia32 -** $Id: op_ret.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - - -int op_ret(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_RETPROC | ASM_TYPE_TOUCHSP | ASM_TYPE_EPILOG; - new->spdiff = 4; - new->instr = ASM_RET; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/** - * @file op_retf.c - * @ingroup handlers_ia32 -** $Id: op_retf.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_retf(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_RETF; - new->type = ASM_TYPE_RETPROC | ASM_TYPE_TOUCHSP | ASM_TYPE_EPILOG; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf_i2.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf_i2.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf_i2.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_retf_i2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** - * @file op_retf_i2.c - * @ingroup handlers_ia32 -** $Id: op_retf_i2.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_retf_i2(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - instr->instr = ASM_RETF; - instr->ptr_instr = opcode; - instr->len += 1; - instr->type = ASM_TYPE_RETPROC | ASM_TYPE_TOUCHSP | ASM_TYPE_EPILOG; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEWORD, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEWORD, instr); -#endif - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret_i2.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret_i2.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret_i2.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ret_i2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file op_ret_i2.c - * @ingroup handlers_ia32 - * $Id: op_ret_i2.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for ret instruction, opcode 0xc2 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_ret_i2(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->type = ASM_TYPE_RETPROC | ASM_TYPE_TOUCHSP | ASM_TYPE_EPILOG; - new->spdiff = 4; - new->instr = ASM_RET; - new->ptr_instr = opcode; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEWORD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_IMMEDIATEWORD, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sahf.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sahf.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sahf.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sahf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/** - * @file op_sahf.c - * @ingroup handlers_ia32 -** $Id: op_sahf.c,v 1.4 2007/08/15 21:30:20 strauss Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_sahf(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_SAHF; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_PF | ASM_FLAG_AF | - ASM_FLAG_SF | ASM_FLAG_ZF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_al_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file op_sbb_al_ib.c - * @ingroup handlers_ia32 -** $Id: op_sbb_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SBB; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, new); - new->op[0].size = new->op[1].size = ASM_OSIZE_BYTE; - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/** - * @file op_sbb_eax_iv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_SBB; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].size = new->op[1].size = ASM_OSIZE_VECTOR; - new->op[0].content = ASM_OP_FIXED | ASM_OP_BASE; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_opsize(proc) ? ASM_REGSET_R32 : - ASM_REGSET_R16; - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file op_sbb_rb_rmb.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rb_rmb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_SBB; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_GENERALBYTE, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_GENERALBYTE, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file op_sbb_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rmb_rb.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_rmb_rb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SBB; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERALBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmv_rv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_sbb_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rmv_rv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_rmv_rv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_SBB; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rv_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sbb_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_sbb_rv_rmv.c - * @ingroup handlers_ia32 -** $Id: op_sbb_rv_rmv.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sbb_rv_rmv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->len += 1; - new->instr = ASM_SBB; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG | ASM_TYPE_READFLAG; - new->flagsread = ASM_FLAG_CF; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode +1, ASM_OTYPE_GENERAL, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode +1, ASM_OTYPE_ENCODED, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode +1, ASM_OTYPE_GENERAL, new); - new->len += asm_operand_fetch(&new->op[1], opcode +1, ASM_OTYPE_ENCODED, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file op_scasb.c - * @ingroup handlers_ia32 -** $Id: op_scasb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_scasb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) { - new->instr = ASM_SCASB; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - ASM_REGSET_R8)); - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_EAX; - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_YDEST, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasd.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_scasd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_scasd.c - * @ingroup handlers_ia32 -** $Id: op_scasd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_scasd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - if (asm_proc_opsize(proc)) - new->instr = ASM_SCASW; - else - new->instr = ASM_SCASD; - - new->ptr_instr = opcode; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_YDEST, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_EAX; - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_YDEST, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setae_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setae_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setae_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setae_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setae_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setae_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setae, opcode 0x0f 0x93 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setae_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_U_GREATER_EQUAL; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_seta_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_seta_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_seta_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_seta_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_seta_rmb.c - * @ingroup handlers_ia32 - * $Id: op_seta_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -* -*/ -#include -#include - -/** - * Handler for instruction seta, opcode 0x0f 0x97 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_seta_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_U_GREATER; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setbe_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setbe_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setbe_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setbe_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setbe_rmb.c - * @ingroup handlers_ia32 -* $Id: op_setbe_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -* -*/ -#include -#include - -/** - * Handler for instruction op_setbe, opcode 0x0f 0x96 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setbe_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_U_LESS_EQUAL; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setb_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setb, opcode 0x0f 0x92 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SET_U_LESS; - new->len += 1; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sete_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sete_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sete_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sete_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_sete_rmb.c - * @ingroup handlers_ia32 - * $Id: op_sete_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction sete, opcode 0x0f 0x94 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble - * @param proc Pointer to processor structure - * @return Length of instruction -*/ - -int op_sete_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SET_EQUAL; - new->len += 1; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setge_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setge_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setge_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setge_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_setge_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setge_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setge, opcode 0x0f 0x9d - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setge_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_S_GREATER_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setg_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setg_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setg_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setg_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * @file op_setg_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setg_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setg, opcode 0x0f 0x9f - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setg_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SET_S_GREATER; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setle_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setle_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setle_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setle_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_setle_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setle_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setle, opcode 0x0f 0x9e - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setle_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_S_LESS_EQUAL; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setl_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setl_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setl_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setl_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_setl_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setl_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setl, opcode 0x0f 0x9c - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setl_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SET_S_LESS; - new->len += 1; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setne_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setne_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setne_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setne_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setne_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setne_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setne, opcode 0x0f 0x95 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setne_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_NOT_EQUAL; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setno_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setno_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setno_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setno_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_setno_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setno_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setno, opcode 0x0f 0x91 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setno_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_NOT_OVERFLOW; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setnp_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setnp_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setnp_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setnp_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setnp_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setnp_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setnp, opcode 0x0f 0x9b - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setnp_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_NOT_PARITY; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setns_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setns_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setns_rmb.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setns_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_setns_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setns_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setns, opcode 0x0f 0x99 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_setns_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_NOT_SIGNED; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_seto_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_seto_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_seto_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_seto_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_seto_rmb.c - * @ingroup handlers_ia32 - * $Id: op_seto_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction seto, opcode 0x0f 0x90 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction -*/ - -int op_seto_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_OVERFLOW; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setp_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setp_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_setp_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_setp_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * @file op_setp_rmb.c - * @ingroup handlers_ia32 - * $Id: op_setp_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * Handler for instruction setp, opcode 0x0f 0x9a - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_setp_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_PARITY; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sets_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sets_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sets_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sets_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/** - * @file op_sets_rmb.c - * @ingroup handlers_ia32 - * $Id: op_sets_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - */ -#include -#include - -/** - * Handler for instruction sets, opcode 0x0f 0x98 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. -*/ - -int op_sets_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SET_SIGNED; -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_1.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_1.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_1.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/** - * @file op_shift_rmb_1.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmb_1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_shift_rmb_1(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->ptr_instr = opcode; - new->len += 1; - new->instr = ASM_SHR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF | - ASM_FLAG_CF | ASM_FLAG_OF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_cl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_cl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_cl.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmb_cl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/** - * @file op_shift_rmb_cl.c - * @ingroup handlers_ia32 - * $Id: op_shift_rmb_cl.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - * Changelog - * 2007-05-29 : instruction set was not complete. - * operand type for operand 1 was incorrect. -*/ -#include -#include - -/** - * Handler for instruction shit rmb,cl opcode 0xd2 - * - */ - -int op_shift_rmb_cl(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - instr->ptr_instr = opcode; - instr->len += 1; - instr->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - instr->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF; - - switch(modrm->r) - { - case 0: instr->instr = ASM_ROL; break; - case 1: instr->instr = ASM_ROR; break; - case 2: instr->instr = ASM_RCL; break; - case 3: instr->instr = ASM_RCR; break; - case 4: - instr->instr = ASM_SHL; - instr->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - case 5: - instr->instr = ASM_SHR; - instr->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - case 6: - instr->instr = ASM_SAL; - instr->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - case 7: - instr->instr = ASM_SAR; - instr->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - } - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - instr, 0); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_FIXED, instr, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_CL, - ASM_REGSET_R8)); - -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - instr); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_FIXED, instr); - instr->op[1].content = ASM_OP_BASE; - instr->op[1].regset = ASM_REGSET_R8; - instr->op[1].baser = ASM_REG_CL; -#endif - - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_1.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_1.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_1.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -/** - * @file op_shift_rmv_1.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmv_1.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - - */ - -int op_shift_rmv_1(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode + 1; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF | - ASM_FLAG_CF | ASM_FLAG_OF; - - switch(modrm->r) { - case ASM_REG_EDI: - new->instr = ASM_SAR; - break; - case ASM_REG_ESP: - new->instr = ASM_SHL; - break; - default: - new->instr = ASM_SHR; - break; - } - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_cl.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_cl.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_cl.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shift_rmv_cl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/** - * @file op_shift_rmv_cl.c - * @ingroup handlers_ia32 -** $Id: op_shift_rmv_cl.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_shift_rmv_cl(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF; - - switch(modrm->r) { - case 0: - new->instr = ASM_ROL; - break; - case 5: - new->instr = ASM_SHR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - case 4: - new->instr = ASM_SHL; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - case 7: - new->instr = ASM_SAR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - break; - default: - new->instr = ASM_BAD; - } - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_CL, - ASM_REGSET_R8)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); - new->op[1].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[1].regset = ASM_REGSET_R8; - new->op[1].baser = ASM_REG_CL; - new->op[1].len = 0; - new->op[1].ptr = 0; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmb_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmb_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmb_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmb_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/** - * @file op_shr_ib.c - * @ingroup handlers_ia32 -** $Id: op_shr_rmb_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_shr_rmb_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - struct s_modrm *modrm; - int olen; - - modrm = (struct s_modrm *) (opcode + 1); - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF; - - if (modrm->r == ASM_REG_EAX) - new->instr = ASM_ROL; - else if (modrm->r == ASM_REG_EBP) { - new->instr = ASM_SHR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - else if (modrm->r == ASM_REG_EDI) { - new->instr = ASM_SAR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - else if (modrm->r == ASM_REG_ECX) - new->instr = ASM_ROR; - else if (modrm->r == 3) - new->instr = ASM_RCR; - else { - new->instr = ASM_SHL; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmv_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmv_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmv_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_shr_rmv_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/** - * @file op_shr_rmv_ib.c - * @ingroup handlers_ia32 -** $Id: op_shr_rmv_ib.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_shr_rmv_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) { - struct s_modrm *modrm; - int olen; - - modrm = (struct s_modrm *) opcode + 1; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - - if (modrm->r == ASM_REG_EAX) - new->instr = ASM_ROL; - if (modrm->r == ASM_REG_EBP) { - new->instr = ASM_SHR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - else if (modrm->r == ASM_REG_EDI) { - new->instr = ASM_SAR; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - else if (modrm->r == ASM_REG_ECX) - new->instr = ASM_ROR; - else if (modrm->r == ASM_REG_EAX) - new->instr = ASM_ROL; - else { - new->instr = ASM_SHL; - new->flagswritten |= ASM_FLAG_PF | ASM_FLAG_ZF | ASM_FLAG_SF; - } - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new, 0)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stc.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stc.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stc.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/** - * @file op_stc.c - * @ingroup handlers_ia32 -** $Id: op_stc.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief - * -*/ - -int op_stc(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_STC; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_std.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_std.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_std.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_std.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/** - * @file op_std.c - * @ingroup handlers_ia32 -** $Id: op_std.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_std(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_STD; - new->type = ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_DF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sti.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sti.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sti.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sti.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/** - * @file op_sti.c - * @ingroup handlers_ia32 - * -** $Id: op_sti.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @todo: Set flags field. - * - * - -*/ - -int op_sti(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_STI; - new->type = ASM_TYPE_WRITEFLAG; - /* Should be VIF for CPL = 3 and IOPL < CPL */ - new->flagswritten = ASM_FLAG_IF; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** - * @file op_stosb.c - * @ingroup handlers_ia32 -** $Id: op_stosb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_stosb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->ptr_instr = opcode; - new->instr = ASM_STOSB; - new->len += 1; - new->type = ASM_TYPE_STORE; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_XSRC, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosd.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosd.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosd.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_stosd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file op_stosd.c - * @ingroup handlers_ia32 -** $Id: op_stosd.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_stosd(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_STOSD; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_STORE; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_YDEST, new); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_FIXED, new); - new->op[1].content = ASM_OP_BASE; - new->op[1].len = 0; - new->op[1].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->op[1].baser = ASM_REG_EAX; -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_al_ib.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_sub_al_ib.c - * @ingroup handlers_ia32 -** $Id: op_sub_al_ib.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sub_al_ib(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SUB; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].regset = ASM_REGSET_R8; - new->op[0].baser = ASM_REG_AL; - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/** - * @file op_sub_eax_iv.c - * @ingroup handlers_ia32 -** $Id: op_sub_eax_iv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @ingroup handlers_ia32 - * -*/ - -int op_sub_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_SUB; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].regset = ASM_REGSET_R32; - new->op[0].baser = ASM_REG_EAX; - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rb_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file op_sub_rb_rmb.c - * @ingroup handlers_ia32 -** $Id: op_sub_rb_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sub_rb_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SUB; - new->ptr_instr = opcode; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, - new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, - new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/** - * @file op_sub_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_sub_rmb_rb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/* - -*/ - -int op_sub_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_SUB; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmv_rv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_sub_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_sub_rmv_rv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction sub rmv,rv opcode 0x29 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_sub_rmv_rv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_SUB; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODED, - new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERAL, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rv_rmv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_sub_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file op_sub_rv_rmv.c - * @brief Handler for instruction sub rv,rmv opcode 0x2b - * @ingroup handlers_ia32 - * - * $Id: op_sub_rv_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction sub rv,rmv opcode 0x2b - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_sub_rv_rmv(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - instr->len += 1; - instr->instr = ASM_SUB; - instr->ptr_instr = opcode; - instr->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - instr->flagswritten = ASM_FLAG_AF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_OF | ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_GENERAL, instr, 0); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_ENCODED, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_GENERAL, instr); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_ENCODED, instr); -#endif - - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_al_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_al_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_al_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_al_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file op_test_al_rb.c - * @ingroup handlers_ia32 -** $Id: op_test_al_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction test al,rb opcode 0xa8 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_test_al_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_TEST; - new->len += 1; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE; - new->op[0].baser = ASM_REG_AL; - new->op[0].regset = ASM_REGSET_R8; - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_eax_iv.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * @file op_test_eax_iv.c - * @ingroup handlers_ia32 - * $Id: op_test_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction test eax,iv opcode 0xa9 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_test_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_TEST; - new->len += 1; - new->ptr_instr = opcode; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_IMMEDIATE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].content = ASM_OP_BASE; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->op[0].baser = ASM_REG_AX; - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_IMMEDIATE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmb_rb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file op_test_rmb_rb.c - * @ingroup handlers_ia32 -** $Id: op_test_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - - -/** - * @brief Handler for instruction test rmb,rb opcode 0x84 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_test_rmb_rb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_TEST; - new->ptr_instr = opcode; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERALBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERALBYTE, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmv_rv.c.svn-base 2008-04-06 23:16:11.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_test_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file op_test_rmv_rv.c - * @ingroup handlers_ia32 -** $Id: op_test_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction test rmv,rv opcode 0x85 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_test_rmv_rv(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_TEST; - new->ptr_instr = opcode; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERAL, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, - ASM_OTYPE_GENERAL, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ud2a.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ud2a.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_ud2a.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_ud2a.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/** - * @file op_ud2a.c - * @ingroup handlers_ia32 - * @brief Handler for instruction ud2a opcode 0x?? - * $Id: op_ud2a.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction ud2a opcode 0x?? - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_ud2a(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->instr = ASM_UD2A; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/** - * @file op_unary_rmb.c - * @ingroup handlers_ia32 - * @brief Handler for instruction unary rmb opcode 0xf6 - * $Id: op_unary_rmb.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction unary rmb opcode 0xf6 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_unary_rmb(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - int olen; - - new->ptr_instr = opcode; - modrm = (struct s_modrm *) opcode + 1; - new->len += 1; - new->type = ASM_TYPE_ARITH; - - switch(modrm->r) { - case 0: - new->instr = ASM_TEST; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - new->op[0].type = ASM_OTYPE_ENCODED; - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new, 0); -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATEBYTE, new); -#endif - - break; - case 1: - return (0); - break; - case 2: - new->instr = ASM_NOT; - break; - case 3: - new->instr = ASM_NEG; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - break; - case 4: - new->instr = ASM_MUL; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - break; - case 5: - new->instr = ASM_IMUL; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - break; - case 6: - new->instr = ASM_DIV; - break; - case 7: - new->instr = ASM_IDIV; - break; - default: - break; - } - - if (!new->op[0].type) - { -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODEDBYTE, new); -#endif - } - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_unary_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/** - * @file op_unary_rmv.c - * @ingroup handlers_ia32 - * @brief Handler for instruction unary rmv opcode 0xf7 - * $Id: op_unary_rmv.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ - * -*/ -#include -#include - -/** - * @brief Handler for instruction unary rmv opcode 0xf7 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_unary_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - struct s_modrm *modrm; - int olen; - - modrm = (struct s_modrm *) (opcode + 1); - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH; - switch (modrm->r) { - case 0: - new->instr = ASM_TEST; - new->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF | ASM_FLAG_PF | - ASM_FLAG_SF | ASM_FLAG_ZF; - break; - case 1: - return (0); - case 2: - new->instr = ASM_NOT; - break; - case 3: - new->instr = ASM_NEG; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF; - break; - case 4: - new->instr = ASM_MUL; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - break; - case 5: - new->instr = ASM_IMUL; - new->type |= ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_OF | ASM_FLAG_CF; - break; - case 6: - new->instr = ASM_DIV; - break; - case 7: - new->instr = ASM_IDIV; - break; - } /* switch */ - -#if WIP - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new, 0)); - - if (new->instr == ASM_TEST) { - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATE, new, 0); - } -#else - new->len += (olen = asm_operand_fetch(&new->op[0], opcode + 1, - ASM_OTYPE_ENCODED, new)); - - if (new->instr == ASM_TEST) { - new->len += asm_operand_fetch(&new->op[1], opcode + 1 + olen, - ASM_OTYPE_IMMEDIATE, new); - } -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_eax_reg.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_eax_reg.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_eax_reg.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_eax_reg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file op_xchg_eax_reg.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xchg eax,reg opcode 0x91 to 0x97 -** $Id: op_xchg_eax_reg.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include -#include - -/** - * @brief Handler for instruction xchg eax,reg opcode 0x91 to 0x97 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_xchg_eax_reg(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_XCHG; - new->ptr_instr = opcode; - new->len += 1; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, - new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_OPMOD, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_FIXED, - new); - new->op[0].content = ASM_OP_BASE | ASM_OP_FIXED; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - new->len += asm_operand_fetch(&new->op[1], opcode, ASM_OTYPE_OPMOD, new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file op_xchg_rmb_rb.c - * @brief Handler for instruction xchg rmb,rb opcode 0x86 - * @ingroup handlers_ia32 - * $Id: op_xchg_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xchg rmb,rb opcode 0x86 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_xchg_rmb_rb(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - instr->len += 1; - instr->ptr_instr = opcode; - instr->instr = ASM_XCHG; - instr->type = ASM_TYPE_LOAD | ASM_TYPE_STORE; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - instr, 0); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - instr); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - instr); -#endif - - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmv_rv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xchg_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file op_xchg_rmv_rv.c - * @brief Handler for instruction xchg rmv,rv opcode 0x87 - * @ingroup handlers_ia32 - * $Id: op_xchg_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xchg rmv,rv opcode 0x87 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_xchg_rmv_rv(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - instr->len += 1; - instr->ptr_instr = opcode; - instr->instr = ASM_XCHG; - instr->type = ASM_TYPE_LOAD | ASM_TYPE_STORE; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, - instr, 0); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERAL, - instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, - instr); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERAL, - instr); -#endif - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xlatb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xlatb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xlatb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xlatb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/** - * @file op_xlatb.c - * @ingroup handlers_ia32 - * @brief - * $Id: op_xlatb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief - */ - -int op_xlatb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_XLATB; - new->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_al_ib.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_al_ib.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_al_ib.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_al_ib.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * @file op_xor_al_ib.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor al,ib opcode 0x34 - * - * $Id: op_xor_al_ib.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor al,ib opcode 0x34 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Return length of instruction. - */ - -int op_xor_al_ib(asm_instr *instr, u_char *opcode, u_int len, asm_processor *proc) { - instr->instr = ASM_XOR; - instr->len += 1; - instr->ptr_instr = opcode; - instr->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - instr->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode, ASM_OTYPE_FIXED, instr, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_AL, - ASM_REGSET_R8)); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode, ASM_OTYPE_FIXED, instr); - instr->op[0].ptr = opcode; - instr->op[0].len = 0; - instr->op[0].baser = ASM_REG_AL; - instr->op[0].regset = ASM_REGSET_R8; - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, - ASM_OTYPE_IMMEDIATEBYTE, instr); -#endif - - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_eax_iv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_eax_iv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_eax_iv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_eax_iv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/** - * @file op_xor_eax_iv.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor eax,iv opcode 0x35 - * $Id: op_xor_eax_iv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor eax,iv opcode 0x35 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - - -int op_xor_eax_iv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_XOR; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new, - asm_fixed_pack(0, ASM_OP_BASE, ASM_REG_EAX, - asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16)); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, - new, 0); -#else - - new->len += asm_operand_fetch(&new->op[0], opcode, ASM_OTYPE_FIXED, new); - new->op[0].ptr = opcode; - new->op[0].len = 0; - new->op[0].baser = ASM_REG_EAX; - new->op[0].regset = asm_proc_is_protected(proc) ? - ASM_REGSET_R32 : ASM_REGSET_R16; - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_IMMEDIATE, - new); -#endif - - return (new->len); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rb_rmb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rb_rmb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rb_rmb.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rb_rmb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/** - * @file op_xor_rb_rmb.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor rb,rmb opcode 0x32 - * $Id: op_xor_rb_rmb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor rb,rmb opcode 0x32 - * @param instr Pointer to instruction structure - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. -*/ - -int op_xor_rb_rmb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->instr = ASM_XOR; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERALBYTE, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODEDBYTE, new); -#endif - - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmb_rb.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmb_rb.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmb_rb.c.svn-base 2008-04-06 23:16:10.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmb_rb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file op_xor_rmb_rb.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor rmb,rb opcode 0x30 - * $Id: op_xor_rmb_rb.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor rmb,rb opcode 0x30 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction disassembled. -*/ - -int op_xor_rmb_rb(asm_instr *new, u_char *opcode, u_int len, asm_processor *proc) -{ - new->len += 1; - new->ptr_instr = opcode; - new->instr = ASM_XOR; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - new, 0); -#else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_ENCODEDBYTE, - new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_GENERALBYTE, - new); -#endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmv_rv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmv_rv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmv_rv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rmv_rv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file op_xor_rmv_rv.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor rmv,rv opcode 0x31 - * $Id: op_xor_rmv_rv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor rmv,rv opcode 0x31 - * @param instr Pointer to instruction structure. - * @param opcode Pointer to data to disassemble - * @param len Length of data to disassemble - * @param proc Pointer to processor structure - * @return Insruction length - -*/ - -int op_xor_rmv_rv(asm_instr *instr, u_char *opcode, u_int len, - asm_processor *proc) -{ - instr->len += 1; - instr->ptr_instr = opcode; - instr->instr = ASM_XOR; - instr->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - instr->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - -#if WIP - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, instr, 0); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERAL, instr, 0); -#else - instr->len += asm_operand_fetch(&instr->op[0], opcode + 1, ASM_OTYPE_ENCODED, instr); - instr->len += asm_operand_fetch(&instr->op[1], opcode + 1, ASM_OTYPE_GENERAL, instr); -#endif - return (instr->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rv_rmv.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rv_rmv.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rv_rmv.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/handlers/.svn/text-base/op_xor_rv_rmv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * @file op_xor_rv_rmv.c - * @ingroup handlers_ia32 - * @brief Handler for instruction xor, opcode 0x33 - * $Id: op_xor_rv_rmv.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * - */ -#include -#include - -/** - * @brief Handler for instruction xor, opcode 0x33 - * @param new Pointer to instruction structure. - * @param opcode Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction. - */ - -int op_xor_rv_rmv(asm_instr *new, u_char *opcode, u_int len, - asm_processor *proc) -{ - new->instr = ASM_XOR; - new->ptr_instr = opcode; - new->len += 1; - new->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - new->flagswritten = ASM_FLAG_CF | ASM_FLAG_OF | ASM_FLAG_PF | - ASM_FLAG_ZF | ASM_FLAG_SF; - - #if WIP - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new, 0); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new, 0); - #else - new->len += asm_operand_fetch(&new->op[0], opcode + 1, ASM_OTYPE_GENERAL, new); - new->len += asm_operand_fetch(&new->op[1], opcode + 1, ASM_OTYPE_ENCODED, new); - #endif - return (new->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/init_i386.c eresi-0.0.20110516/libasm/src/arch/ia32/init_i386.c --- eresi-0.8a25/libasm/src/arch/ia32/init_i386.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/init_i386.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,7 +1,7 @@ /** - * @file init_i386.c - * @ingroup libasm_ia32 - * $Id: init_i386.c,v 1.13 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/init_i386.c + * @ingroup ia32 + * $Id: init_i386.c 1397 2009-09-13 02:19:08Z may $ * */ #ifndef I386_H_ @@ -26,14 +26,19 @@ */ int fetch_i386(asm_instr *instr, u_char *buf, u_int len, - asm_processor *proc) + asm_processor *proc) { u_char opcode; int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *); + int to_ret; opcode = *buf; fetch = asm_opcode_fetch(LIBASM_VECTOR_OPCODE_IA32, opcode); - return (fetch(instr, buf, len, proc)); + to_ret = fetch(instr, buf, len, proc); + if (to_ret > 0) + instr->name = proc->instr_table[instr->instr]; + return (to_ret); + } int asm_init_i386(asm_processor *proc) @@ -44,36 +49,25 @@ } /** - * Intialize the processor structure to disassemble i386 bytecode. + * Intialize the processor and vector structures to disassemble i386 bytecode. * @param Pointer to a asm_processor structure. * @return Always 1. */ int asm_init_ia32(asm_processor *proc) { - struct s_asm_proc_i386 *inter; init_instr_table(proc); proc->type = ASM_PROC_IA32; - /* Register the ia32 vector */ asm_register_ia32(); - - // XXX: dead code to remove - //asm_init_ia32_vector(); - //asm_init_vectors(proc); - // asm_arch_register(proc, 1); /* dummy parameters for the moment */ - - proc->resolve_immediate = asm_resolve_ia32; proc->resolve_data = 0; - // proc->get_operand = create_i386_operand; proc->fetch = fetch_i386; proc->display_handle = asm_ia32_display_instr_att; inter = proc->internals = malloc(sizeof (struct s_asm_proc_i386)); inter->opsize = inter->addsize = 0; inter->mode = INTEL_PROT; - return (1); } @@ -83,4 +77,56 @@ free(proc->instr_table); } +/* Resolve destinations of control flow instruction depending on real or protected mode */ +eresi_Addr asm_dest_resolve(asm_processor *proc, eresi_Addr addr, u_int shift) +{ + int mode; + u_short off; + + mode = asm_ia32_get_mode(proc); + if (mode == INTEL_REAL) + { + off = (addr & 0xFFFF) + shift; + addr = (addr & 0xFFFF0000) + off; + } + else + addr += shift; + return (addr); +} + + +/** Get mode of IA32 processor */ +int asm_ia32_get_mode(asm_processor *proc) +{ + struct s_asm_proc_i386 *inter; + + inter = proc->internals; + return (inter->mode); +} + + +/** + * Switch + * @param proc Pointer to asm processor structure. + * @param mode INTEL_PROT or INTEL_REAL + */ +int asm_ia32_switch_mode(asm_processor *proc, int mode) +{ + struct s_asm_proc_i386 *inter; + + inter = proc->internals; + inter->mode = mode; + if (mode == INTEL_PROT) + inter->opsize = inter->addsize = 0; + else + { + /** + * inter->opsize and inter->addsize values are perhaps not accurate. + * Must add testcode for this feature. + */ + inter->opsize = inter->addsize = 1; + } + return (1); +} + #endif diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,9 +1,12 @@ /** - * @file asm_operand_fetch_address.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_address.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ + * @defgroup IA32_operands Libasm IA32 operands handlers. + * @ingroup ia32 + */ +/** +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c + * @ingroup IA32_operands + * $Id: asm_operand_fetch_address.c 1397 2009-09-13 02:19:08Z may $ */ - #include #include @@ -13,7 +16,7 @@ * */ /** - * @ingroup operand_handler + * @ingroup IA32_operands * Decode data for operand type ASM_OTYPE_YDEST * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data @@ -30,11 +33,16 @@ asm_instr *ins) #endif { + u_int len; + operand->type = ASM_OTYPE_ADDRESS; operand->content = ASM_OP_VALUE; operand->ptr = opcode; operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); - return (4); + len = asm_proc_opsize(ins->proc) ? 2 : 4; + operand->len = len; + memcpy(&operand->imm, opcode, len); + if (len == 2) + operand->imm = operand->imm & 0xFFFF; + return (len); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,19 +1,18 @@ /** - * @file asm_operand_fetch.c - * @ingroup operand_handler - * $Id: asm_operand_fetch.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c + * + * @ingroup IA32_operands + * @brief Implements top-level fetching handler for IA32 operands. + * + * $Id: asm_operand_fetch.c 1397 2009-09-13 02:19:08Z may $ */ - -/** - * @defgroup operand_handler Operand decoding handlers. - */ - #include #include /** * @brief Main function, dispatch processing to handler. - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param op Pointer to operand to fill * @param opcode Pointer to operand data. * @param otype Type of operand to fetch : ASM_OTYPE_* diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_control.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_control.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_control.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -9,7 +10,8 @@ /** * Decode data for operand type ASM_OTYPE_CONTROL - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_debug.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_debug.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_debug.c 1397 2009-09-13 02:19:08Z may $ */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,14 +1,16 @@ /** - * @file asm_operand_fetch_encodedbyte.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_encodedbyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_encodedbyte.c 1397 2009-09-13 02:19:08Z may $ */ #include #include /** - * @ingroup operand_handler + * + * @ingroup IA32_operands * Decode data for operand type ASM_OTYPE_ENCODEDBYTE * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_encoded.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_encoded.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_encoded.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -9,7 +10,8 @@ /** - * @ingroup operand_handler + * + * @ingroup IA32_operands * Decode data for operand type ASM_OTYPE_ENCODED * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_fixed.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_fixed.c,v 1.3 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_fixed.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -12,7 +13,8 @@ * Implement optional parameter for fixed operand fetching. */ /** - * @ingroup operand_handler + * + * @ingroup IA32_operands * Decode data for operand type ASM_OTYPE_YDEST * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_generalbyte.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_generalbyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_generalbyte.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -9,7 +10,8 @@ /** * Decode data for operand type ASM_OTYPE_GENERALBYTE - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_general.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_general.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_general.c 1397 2009-09-13 02:19:08Z may $ * @brief Operand Handler to decode data for operand type ASM_OTYPE_GENERAL */ @@ -10,7 +11,8 @@ /** * @brief Decode data for operand type ASM_OTYPE_GENERAL - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param type Not used. @@ -30,10 +32,11 @@ operand->type = ASM_OTYPE_GENERAL; operand->content = ASM_OP_BASE; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; + operand->regset = asm_proc_is_protected(ins->proc) ? + ASM_REGSET_R32 : ASM_REGSET_R16; modrm = (struct s_modrm *) opcode; operand->baser = modrm->r; operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (operand->len = 0); + operand->len = 0; + return (0); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_immediatebye.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediatebyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_immediatebyte.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -9,7 +10,8 @@ /** * Handler to fetch ASM_OTYPE_IMMEDIATEBYTE operand. - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure. * @param opcode Pointer to data to disassemble. * @param otype Operand type. @@ -25,13 +27,19 @@ int otype, asm_instr *ins) #endif { + u_int len; + operand->type = ASM_OTYPE_IMMEDIATE; operand->content = ASM_OP_VALUE; operand->ptr = opcode; operand->imm = 0; operand->len = 1; if (*opcode >= 0x80) - memset(&operand->imm, 0xff, 4); + { + len = asm_proc_opsize(ins->proc) ? 2 : 4; + //memset(&operand->imm, 0xff, 4); + memset(&operand->imm, 0xff, len); + } memcpy(&operand->imm, opcode, 1); return (1); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_immediate.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediate.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_immediate.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -13,7 +14,8 @@ */ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype @@ -34,6 +36,6 @@ operand->ptr = opcode; operand->imm = 0; operand->len = asm_proc_opsize(ins->proc) ? 2 : 4; - memcpy(&operand->imm, opcode, asm_proc_opsize(ins->proc) ? 2 : 4); + memcpy(&operand->imm, opcode, operand->len); return (operand->len); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_immediateword.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediateword.c,v 1.3 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_immediateword.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -9,7 +10,8 @@ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_jump.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_jump.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c + * + * @ingroup IA32_operands + * $Id: asm_operand_fetch_jump.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -12,7 +13,8 @@ */ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype @@ -28,12 +30,15 @@ int otype, asm_instr *ins) #endif { + u_int len; + operand->type = ASM_OTYPE_JUMP; operand->content = ASM_OP_VALUE | ASM_OP_ADDRESS; operand->ptr = opcode; operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); + len = asm_proc_opsize(ins->proc) ? 2 : 4; + operand->len = len; + memcpy(&operand->imm, opcode, len); operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (4); + return (len); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file asm_operand_fetch_memory.c - * $Id: asm_operand_fetch_memory.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c + * $Id: asm_operand_fetch_memory.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -11,7 +11,8 @@ */ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file asm_operand_fetch_offset.c - * $Id: asm_operand_fetch_offset.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c + * $Id: asm_operand_fetch_offset.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -11,7 +11,8 @@ */ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype @@ -27,12 +28,16 @@ int otype, asm_instr *ins) #endif { + u_int len; + operand->type = ASM_OTYPE_OFFSET; operand->content = ASM_OP_VALUE | ASM_OP_REFERENCE; operand->ptr = opcode; operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); + operand->regset = asm_proc_is_protected(ins->proc) ? ASM_REGSET_R32 : ASM_REGSET_R16; + len = asm_proc_opsize(ins->proc) ? 2 : 4; + operand->len = len; + memcpy(&operand->imm, opcode, len); operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (4); + return (len); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file asm_operand_fetch_opmod.c - * $Id: asm_operand_fetch_opmod.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c + * $Id: asm_operand_fetch_opmod.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -8,7 +8,8 @@ /** * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file asm_operand_fetch_pmmx.c - * $Id: asm_operand_fetch_pmmx.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c + * $Id: asm_operand_fetch_pmmx.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -13,7 +13,8 @@ */ /** * Decode data for operand type ASM_OTYPE_PMMX - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file asm_operand_fetch_register.c - * $Id: asm_operand_fetch_register.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c + * $Id: asm_operand_fetch_register.c 1397 2009-09-13 02:19:08Z may $ */ #include @@ -8,7 +8,8 @@ /** * @brief Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,7 @@ /** - * @file asm_operand_fetch_segment.c - * @ingroup operand_handler +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c + * + * @ingroup IA32_operands */ #include @@ -8,7 +9,8 @@ /** * @brief Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler + * + * @ingroup IA32_operands * @param operand Pointer to operand structure to fill. * @param opcode Pointer to operand data * @param otype diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,7 @@ /** - * @file asm_operand_fetch_shortjump.c - * @ingroup operand_handler +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c + * + * @ingroup IA32_operands */ #include @@ -22,17 +23,23 @@ int otype, asm_instr *ins) #endif { - + u_int len; + #if WIP - asm_content_pack(operand, ASM_OP_VALUE | ASM_OP_ADDRESS, ASM_OTYPE_JUMP); + asm_content_pack(operand, ASM_OP_VALUE | ASM_OP_ADDRESS, ASM_OTYPE_SHORTJUMP); #else operand->content = ASM_OP_VALUE |ASM_OP_ADDRESS; - operand->type = ASM_OTYPE_JUMP; + operand->type = ASM_OTYPE_SHORTJUMP; #endif operand->len = 1; operand->imm = 0; + + //if (*(opcode) >= 0x80u) + //memcpy((char *) &operand->imm + 1, "\xff\xff\xff", 3); + len = asm_proc_opsize(ins->proc) ? 1 : 3; if (*(opcode) >= 0x80u) - memcpy((char *) &operand->imm + 1, "\xff\xff\xff", 3); + memset((char *) &operand->imm + 1, 0xFF, len); + memcpy(&operand->imm, opcode, 1); return (1); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,6 +1,7 @@ /** - * @file asm_operand_fetch_xsrc.c - * @ingroup operand_handler +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c + * + * @ingroup IA32_operands */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c 2011-05-16 11:34:44.000000000 +0000 @@ -1,7 +1,8 @@ /** - * @file asm_operand_fetch_ydest.c +* @file libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c * @brief Wrapper to call operand handler. - * @ingroup operand_handler + * + * @ingroup IA32_operands */ #include diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers -END -asm_operand_fetch_general.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c -END -asm_operand_fetch_opmod.c -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c -END -asm_operand_fetch_xsrc.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c -END -asm_operand_fetch.c -K 25 -svn:wc:ra_dav:version-url -V 81 -/svn/!svn/ver/849/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c -END -asm_operand_fetch_control.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c -END -asm_operand_fetch_pmmx.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c -END -asm_operand_fetch_immediatebyte.c -K 25 -svn:wc:ra_dav:version-url -V 95 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c -END -asm_operand_fetch_register.c -K 25 -svn:wc:ra_dav:version-url -V 90 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c -END -asm_operand_fetch_address.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c -END -asm_operand_fetch_encodedbyte.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c -END -asm_operand_fetch_debug.c -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c -END -asm_operand_fetch_offset.c -K 25 -svn:wc:ra_dav:version-url -V 88 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c -END -asm_operand_fetch_ydest.c -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c -END -asm_operand_fetch_immediateword.c -K 25 -svn:wc:ra_dav:version-url -V 95 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c -END -asm_operand_fetch_shortjump.c -K 25 -svn:wc:ra_dav:version-url -V 91 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c -END -asm_operand_fetch_immediate.c -K 25 -svn:wc:ra_dav:version-url -V 91 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c -END -asm_operand_fetch_fixed.c -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c -END -asm_operand_fetch_generalbyte.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c -END -asm_operand_fetch_encoded.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c -END -asm_operand_fetch_segment.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c -END -asm_operand_fetch_memory.c -K 25 -svn:wc:ra_dav:version-url -V 88 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c -END -asm_operand_fetch_jump.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/!svn/ver/896/trunk/libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c -END diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/ia32/operand_handlers -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -asm_operand_fetch_general.c -file - - - - -2008-04-06T23:16:24.865127Z -0ab783186f38280afdb240902ee0f0ea -2008-02-19T17:09:59.893936Z -849 -may - -asm_operand_fetch_opmod.c -file - - - - -2008-04-06T23:16:24.913886Z -2dc0d2fa10a0eea9a873cfaae4859769 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_xsrc.c -file - - - - -2008-04-06T23:16:24.924903Z -b83e6de3f717e9ade5f5d09ecadf4074 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch.c -file - - - - -2008-04-06T23:16:24.947903Z -23d308e17b33dba88a715be8efcfc1bb -2008-02-19T17:09:59.893936Z -849 -may - -asm_operand_fetch_control.c -file - - - - -2008-04-06T23:16:24.936877Z -b54d5835c3ad5034399134c14d55ed09 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_pmmx.c -file - - - - -2008-04-06T23:16:24.959641Z -b316103f1eae53a5c722d4df1473b2be -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_immediatebyte.c -file - - - - -2008-04-06T23:16:24.970903Z -1b4fcfef484aedeadb79f092177269f0 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_register.c -file - - - - -2008-04-06T23:16:24.982248Z -7922310b115a860ceeb0c28c78a6f28e -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_address.c -file - - - - -2008-04-06T23:16:25.004934Z -affff426bfa99b49052d9ac67492dc66 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_encodedbyte.c -file - - - - -2008-04-06T23:16:24.993592Z -666ca095f456818adf8f524427358f02 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_debug.c -file - - - - -2008-04-06T23:16:25.027620Z -8508f1d1ab6155952c2360f8f62ba3c0 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_offset.c -file - - - - -2008-04-06T23:16:25.015900Z -6d56e03b5018df861a7830a7659c3f8c -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_ydest.c -file - - - - -2008-04-06T23:16:25.038962Z -71be3f7a17e75ef5bc36cfc185849d0d -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_immediateword.c -file - - - - -2008-04-06T23:16:25.172531Z -8bca1f3dfd226cb9aab83418ac12c01e -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_shortjump.c -file - - - - -2008-04-06T23:16:25.183880Z -1361ef00e4c31b279bb10262a2a89880 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_immediate.c -file - - - - -2008-04-06T23:16:25.195217Z -80e90c410660e26e68d73c4567998c86 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_fixed.c -file - - - - -2008-04-06T23:16:25.205900Z -d96d2498f2dae7814429bfefa710caa0 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_generalbyte.c -file - - - - -2008-04-06T23:16:25.217903Z -9275a601a89ba8d38b2728128a0a39a9 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_encoded.c -file - - - - -2008-04-06T23:16:25.229303Z -0d495c7cc3a5e9e98a105d63c7ca8c71 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_segment.c -file - - - - -2008-04-06T23:16:25.240703Z -5e2a793ed5b9cced41846118bda0dcb3 -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_memory.c -file - - - - -2008-04-06T23:16:25.252044Z -081642f6a84a2830424b0de4599101cd -2008-03-07T17:49:34.750118Z -896 -thorkill - -asm_operand_fetch_jump.c -file - - - - -2008-04-06T23:16:25.263349Z -1e618aba0f5fe2557e117a96bc885c41 -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/format 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_address.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_address.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_address.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_address.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -/** - * @file asm_operand_fetch_address.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_address.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Fetch operands of - * - * - */ -/** - * @ingroup operand_handler - * Decode data for operand type ASM_OTYPE_YDEST - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ -#if WIP -int asm_operand_fetch_address(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_address(asm_operand *operand, u_char *opcode, - int otype, - asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_ADDRESS; - operand->content = ASM_OP_VALUE; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); - return (4); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_control.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_control.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_control.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_control.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file asm_operand_fetch_control.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_control.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Decode data for operand type ASM_OTYPE_CONTROL - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_control(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_control(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - operand->type = ASM_OTYPE_CONTROL; - operand->content = ASM_OP_BASE; - operand->regset = ASM_REGSET_CREG; - operand->baser = modrm->r; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 0; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->sindex = get_reg_intel(operand->indexr, operand->regset); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/** - * @file asm_operand_fetch.c - * @ingroup operand_handler - * $Id: asm_operand_fetch.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - */ - -/** - * @defgroup operand_handler Operand decoding handlers. - */ - -#include -#include - -/** - * @brief Main function, dispatch processing to handler. - * @ingroup operand_handler - * @param op Pointer to operand to fill - * @param opcode Pointer to operand data. - * @param otype Type of operand to fetch : ASM_OTYPE_* - * @param proc Pointer to processor structure. - * @return Operand length or -1 on error (should currently never occur) - */ - -#if WIP -int asm_operand_fetch(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins) -#endif -{ - vector_t *vec; - u_int dim[1]; - int to_ret; -#if WIP - int (*fetch)(asm_operand *, u_char *, int, asm_instr *, int); -#else - int (*fetch)(asm_operand *, u_char *, int, asm_instr *); -#endif - - vec = aspect_vector_get(LIBASM_VECTOR_OPERAND_IA32); - dim[0] = otype; - - fetch = aspect_vectors_select(vec, dim); -#if WIP - to_ret = fetch(operand, opcode, otype, ins, opt); -#else - to_ret = fetch(operand, opcode, otype, ins); -#endif - if (to_ret == -1) - { - printf("%s:%i Unsupported operand type : %i\n", __FILE__, __LINE__, - otype); - } - else - { - operand->sbaser = ((operand->content & ASM_OP_BASE) ? - get_reg_intel(operand->baser, operand->regset) : ""); - operand->sindex = ((operand->content & ASM_OP_BASE) ? - get_reg_intel(operand->indexr, operand->regset) : ""); - } - return (to_ret); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_debug.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_debug.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_debug.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_debug.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file asm_operand_fetch_debug.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_debug.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - - -/** - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_debug(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_debug(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - operand->type = ASM_OTYPE_DEBUG; - operand->content = ASM_OP_BASE; - operand->regset = ASM_REGSET_CREG; - operand->baser = modrm->r; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 0; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->sindex = get_reg_intel(operand->indexr, operand->regset); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encodedbyte.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encodedbyte.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encodedbyte.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encodedbyte.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file asm_operand_fetch_encodedbyte.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_encodedbyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * @ingroup operand_handler - * Decode data for operand type ASM_OTYPE_ENCODEDBYTE - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_encodedbyte(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_encodedbyte(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - int len; - - operand->type = ASM_OTYPE_ENCODED; - len = operand_rmb(operand, opcode, 5, ins->proc); - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->sindex = get_reg_intel(operand->indexr, operand->regset); - return (len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encoded.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encoded.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encoded.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_encoded.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file asm_operand_fetch_encoded.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_encoded.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - - -/** - * @ingroup operand_handler - * Decode data for operand type ASM_OTYPE_ENCODED - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_encoded(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_encoded(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - int len; - operand->type = ASM_OTYPE_ENCODED; - len = operand_rmv(operand, opcode, 4, ins->proc); - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->sindex = get_reg_intel(operand->indexr, operand->regset); - return (len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_fixed.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_fixed.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_fixed.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_fixed.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file asm_operand_fetch_fixed.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_fixed.c,v 1.3 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * @todo - * Implement optional parameter for fixed operand fetching. - */ -/** - * @ingroup operand_handler - * Decode data for operand type ASM_OTYPE_YDEST - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_fixed(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_fixed(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_FIXED; - #if WIP - /** - * @todo extract fields. - operand->content = asm_fixed_unpack_content(); - operand->regset = asm_fixed_unpack_regset(); - operand-> - */ -#endif - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_generalbyte.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_generalbyte.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_generalbyte.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_generalbyte.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * @file asm_operand_fetch_generalbyte.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_generalbyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Decode data for operand type ASM_OTYPE_GENERALBYTE - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_generalbyte(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_generalbyte(asm_operand *operand, u_char *opcode, - int type, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - operand->type = ASM_OTYPE_GENERAL; - operand->content = ASM_OP_BASE; - operand->regset = ASM_REGSET_R8; - modrm = (struct s_modrm *) opcode; - operand->baser = modrm->r; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->sindex = get_reg_intel(operand->indexr, operand->regset); - return (operand->len = 0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_general.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_general.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_general.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_general.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_general.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_general.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - * @brief Operand Handler to decode data for operand type ASM_OTYPE_GENERAL - */ - -#include -#include - -/** - * @brief Decode data for operand type ASM_OTYPE_GENERAL - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param type Not used. - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_general(asm_operand *operand, u_char *opcode, - int type, asm_instr *ins, int opt) -#else -int asm_operand_fetch_general(asm_operand *operand, u_char *opcode, - int type, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - operand->type = ASM_OTYPE_GENERAL; - operand->content = ASM_OP_BASE; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - modrm = (struct s_modrm *) opcode; - operand->baser = modrm->r; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (operand->len = 0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediatebyte.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediatebyte.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediatebyte.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediatebyte.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/** - * @file asm_operand_fetch_immediatebye.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediatebyte.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Handler to fetch ASM_OTYPE_IMMEDIATEBYTE operand. - * @ingroup operand_handler - * @param operand Pointer to operand structure. - * @param opcode Pointer to data to disassemble. - * @param otype Operand type. - * @param proc Pointer to processor structure. - * @return Operand Length - */ - -#if WIP -int asm_operand_fetch_immediatebyte(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_immediatebyte(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_IMMEDIATE; - operand->content = ASM_OP_VALUE; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 1; - if (*opcode >= 0x80) - memset(&operand->imm, 0xff, 4); - memcpy(&operand->imm, opcode, 1); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediate.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediate.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediate.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediate.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_immediate.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediate.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_immediate(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_immediate(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_IMMEDIATE; - operand->content = ASM_OP_VALUE; - operand->ptr = opcode; - operand->imm = 0; - operand->len = asm_proc_opsize(ins->proc) ? 2 : 4; - memcpy(&operand->imm, opcode, asm_proc_opsize(ins->proc) ? 2 : 4); - return (operand->len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediateword.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediateword.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediateword.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_immediateword.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file asm_operand_fetch_immediateword.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_immediateword.c,v 1.3 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_immediateword(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_immediateword(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_IMMEDIATE; - operand->content = ASM_OP_VALUE; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 2; - memcpy(&operand->imm, opcode, 2); - return (2); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_jump.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_jump.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_jump.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_jump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_jump.c - * @ingroup operand_handler - * $Id: asm_operand_fetch_jump.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include -/** - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_jump(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_jump(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_JUMP; - operand->content = ASM_OP_VALUE | ASM_OP_ADDRESS; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (4); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_memory.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_memory.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_memory.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_memory.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/** - * @file asm_operand_fetch_memory.c - * $Id: asm_operand_fetch_memory.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include -/** - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_memory(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_memory(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - operand->type = ASM_OTYPE_MEMORY; - - operand->content = ASM_OP_BASE; - operand->regset = ASM_REGSET_R32; - operand->baser = modrm->r; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - - return (0); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_offset.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_offset.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_offset.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_offset.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * @file asm_operand_fetch_offset.c - * $Id: asm_operand_fetch_offset.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include -/** - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_offset(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_offset(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - operand->type = ASM_OTYPE_OFFSET; - operand->content = ASM_OP_VALUE | ASM_OP_REFERENCE; - operand->ptr = opcode; - operand->imm = 0; - operand->len = 4; - memcpy(&operand->imm, opcode, 4); - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (4); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_opmod.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_opmod.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_opmod.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_opmod.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * @file asm_operand_fetch_opmod.c - * $Id: asm_operand_fetch_opmod.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_opmod(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_opmod(asm_operand *operand, u_char *opcode, - int type, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - operand->type = ASM_OTYPE_OPMOD; - operand->content = ASM_OP_BASE; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - modrm = (struct s_modrm *) opcode; - operand->baser = modrm->m; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_pmmx.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_pmmx.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_pmmx.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_pmmx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_pmmx.c - * $Id: asm_operand_fetch_pmmx.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * Fetch ASM_OTYPE_PMMX operand - * - * - */ -/** - * Decode data for operand type ASM_OTYPE_PMMX - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_pmmx(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_pmmx(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - int len; - operand->type = ASM_OTYPE_PMMX; - len = operand_rmv(operand, opcode, 4, ins->proc); - asm_content_pack(operand, operand->content, operand->type); - operand->regset = ASM_REGSET_MM; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - return (len); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_register.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_register.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_register.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** - * @file asm_operand_fetch_register.c - * $Id: asm_operand_fetch_register.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ - */ - -#include -#include - -/** - * @brief Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_register(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_register(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - asm_content_pack(operand, ASM_OP_BASE, ASM_OTYPE_REGISTER); - //operand->type = ASM_OTYPE_REGISTER; - //operand->content = ASM_OP_BASE; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - operand->baser = modrm->m; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->ptr = opcode; - operand->imm = 0; - operand->len = 0; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_segment.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_segment.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_segment.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_segment.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/** - * @file asm_operand_fetch_segment.c - * @ingroup operand_handler - */ - -#include -#include - -/** - * @brief Decode data for operand type ASM_OTYPE_YDEST - * @ingroup operand_handler - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_segment(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins, int opt) -#else -int asm_operand_fetch_segment(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - -#if WIP - asm_content_pack(operand, ASM_OP_BASE, ASM_OTYPE_SEGMENT); -#else - operand->type = ASM_OTYPE_SEGMENT; - operand->content = ASM_OP_BASE; -#endif - - operand->regset = ASM_REGSET_SREG; - operand->baser = modrm->r; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_shortjump.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_shortjump.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_shortjump.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_shortjump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/** - * @file asm_operand_fetch_shortjump.c - * @ingroup operand_handler - */ - -#include -#include - -/** - * @brief Decode data for operand type ASM_OTYPE_SHORTJUMP - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ -#if WIP -int asm_operand_fetch_shortjump(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins, int opt) -#else -int asm_operand_fetch_shortjump(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ - -#if WIP - asm_content_pack(operand, ASM_OP_VALUE | ASM_OP_ADDRESS, ASM_OTYPE_JUMP); -#else - operand->content = ASM_OP_VALUE |ASM_OP_ADDRESS; - operand->type = ASM_OTYPE_JUMP; -#endif - operand->len = 1; - operand->imm = 0; - if (*(opcode) >= 0x80u) - memcpy((char *) &operand->imm + 1, "\xff\xff\xff", 3); - memcpy(&operand->imm, opcode, 1); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_xsrc.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_xsrc.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_xsrc.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_xsrc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_xsrc.c - * @ingroup operand_handler - */ - -#include -#include - - -/** - * Decode data for operand type ASM_OTYPE_YDEST - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_xsrc(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins, int opt) -#else -int asm_operand_fetch_xsrc(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -#endif -{ -#if WIP - asm_content_pack(operand, ASM_OP_BASE | ASM_OP_REFERENCE, ASM_OTYPE_XSRC); -#else - operand->type = ASM_OTYPE_XSRC; - operand->content = ASM_OP_BASE | ASM_OP_REFERENCE; -#endif - operand->baser = ASM_REG_ESI; - operand->regset = asm_proc_opsize(ins->proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->prefix = ASM_PREFIX_DS; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_ydest.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_ydest.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_ydest.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_handlers/.svn/text-base/asm_operand_fetch_ydest.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file asm_operand_fetch_ydest.c - * @brief Wrapper to call operand handler. - * @ingroup operand_handler - */ - -#include -#include - -/** - * @brief Decode data for operand type ASM_OTYPE_YDEST - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to operand data - * @param otype - * @param ins Pointer to instruction structure. - * @return Operand length - */ - -#if WIP -int asm_operand_fetch_ydest(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins, int opt) -#else -int asm_operand_fetch_ydest(asm_operand *operand, u_char *opcode, int otype, - asm_instr *ins) -#endif -{ -#if WIP - asm_content_pack(operand, ASM_OP_BASE|ASM_OP_REFERENCE,ASM_OTYPE_YDEST); -#else - operand->type = ASM_OTYPE_YDEST; - operand->content = ASM_OP_BASE | ASM_OP_REFERENCE; -#endif - //asm_content_pack() - operand->baser = ASM_REG_EDI; - operand->regset = asm_proc_opsize(ins->proc) ? ASM_REGSET_R16 : ASM_REGSET_R32; - operand->sbaser = get_reg_intel(operand->baser, operand->regset); - operand->prefix = ASM_PREFIX_ES; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/operand_ia32.c eresi-0.0.20110516/libasm/src/arch/ia32/operand_ia32.c --- eresi-0.8a25/libasm/src/arch/ia32/operand_ia32.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/operand_ia32.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,7 +1,7 @@ /** - * @file operand_ia32.c - * @ingroup libasm_ia32 -** $Id: operand_ia32.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/arch/ia32/operand_ia32.c + * @ingroup ia32 +** $Id: operand_ia32.c 1397 2009-09-13 02:19:08Z may $ ** ** Author : ** Started : Tue May 28 13:06:39 2002 @@ -13,18 +13,12 @@ /** - * Extracts operands from memory and stores them in instruction. - * - * @todo - * This function should not be called. - * - * - * - * + * @brief Extracts operands from memory and stores them in instruction. + * @todo This function should not be called. */ - -int operand_rmb_ib(asm_instr *ins, u_char *opcode, int len, - asm_processor *proc) { +int operand_rmb_ib(asm_instr *ins, u_char *opcode, + int len, asm_processor *proc) +{ struct s_modrm *modrm; modrm = (struct s_modrm *) opcode; @@ -42,6 +36,7 @@ return (1); } + /** * @brief Decode a modRM operand of size Byte. * @@ -51,173 +46,163 @@ * @param proc Pointer to processor structure * @return Length of the operand. * -*/ - - -int operand_rmb(asm_operand *op, u_char *opcode, u_int len, - asm_processor *proc) { + */ +int operand_rmb(asm_operand *op, u_char *opcode, u_int len, asm_processor *proc) +{ struct s_modrm *modrm; struct s_sidbyte *sidbyte; + u_char mode; + u_char pmode; modrm = (struct s_modrm *) (opcode); sidbyte = (struct s_sidbyte *) (opcode + 1); - - switch(modrm->mod) { - case 0: - - /** - * mod : 00 - * operand base - * - */ - - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; - op->regset = ASM_REGSET_R32; - op->len = 6; - op->ptr = opcode; - op->scale = asm_int_pow2(sidbyte->sid); - - if (((unsigned char)*(opcode + 2)) >= 0x80) - memcpy((char *) &op->imm + 2, "\xff\xff", 2); - else - op->imm = 0; - memcpy((char *) &op->imm, opcode + 2, 4); - - op->indexr = sidbyte->index; - } else { - - if ((op->indexr = sidbyte->index) != ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE; - op->len = 2; - op->ptr = opcode; - op->regset = ASM_REGSET_R32; - - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - - } - } else { - if (modrm->m == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; - op->ptr = opcode; - op->len = 5; - memcpy(&op->imm, opcode + 1, 4); - } else { - - op->ptr = opcode; - op->len = 1; - op->content = ASM_OP_REFERENCE | ASM_OP_BASE; - - op->baser = modrm->m; - op->regset = ASM_REGSET_R32; - } - } - break; - - /** - * mod : 01 - * operand : base + sbyte - * - */ - - case 1: - if (modrm->m == ASM_REG_ESP) { + + mode = asm_ia32_get_mode(proc); + pmode = (mode == INTEL_PROT); + +#if __DEBUG_MODRM__ + fprintf(stderr, "[DEBUG_MODRM] IA32 processor in %c-mode (RMB) \n", + (pmode ? 'p' : (mode == INTEL_REAL ? 'r' : 'U'))); +#endif + + switch (modrm->mod) + { + + /** mod == 00 : operand base */ + case 0: + + switch (modrm->m) + { + + case ASM_REG_ESP: + if (sidbyte->base == ASM_REG_EBP) + { + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; + op->regset = ASM_REGSET_R32; + op->len = (pmode ? 6 : 4); // + op->ptr = opcode; + op->scale = asm_int_pow2(sidbyte->sid); + + // erased by the following memcpy !? + //if (((unsigned char)*(opcode + 2)) >= 0x80) + //memcpy((char *) &op->imm + 2, "\xff\xff", 2); + //else + //op->imm = 0; + memcpy((char *) &op->imm, opcode + 2, (pmode ? 4 : 2)); // + op->indexr = sidbyte->index; + } + else + { + if ((op->indexr = sidbyte->index) != ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + else + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE; + op->len = 2; + op->ptr = opcode; + op->regset = ASM_REGSET_R32; + op->baser = sidbyte->base; + op->scale = asm_int_pow2(sidbyte->sid); + } + break; + + case ASM_REG_EBP: + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; + op->ptr = opcode; + op->len = (pmode ? 5 : 3); // + memcpy(&op->imm, opcode + 1, (pmode ? 4 : 2)); // + break; + + default: + op->ptr = opcode; + op->len = 1; + op->content = ASM_OP_REFERENCE | ASM_OP_BASE; + op->baser = modrm->m; + op->regset = pmode ? ASM_REGSET_R32 : ASM_REGSET_R16; + break; + } + break; + + /** mod == 01 : operand : base + sbyte */ + case 1: + if (modrm->m == ASM_REG_ESP) + { + if ((op->indexr = sidbyte->index) != ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + else + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; + op->ptr = opcode; + op->len = (pmode ? 3 : 1); // + op->regset = ASM_REGSET_R32; + op->baser = sidbyte->base; + op->indexr = sidbyte->index; + op->scale = asm_int_pow2(sidbyte->sid); + if (*(opcode + 2) >= 0x80u) + memset((char *) &op->imm + 1, '\xff', (pmode ? 3 : 1)); // + else + op->imm = 0; + memcpy(&op->imm, opcode + 2, 1); + } + else + { + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; + op->len = 2; // ????? + op->baser = modrm->m; + op->regset = ASM_REGSET_R32; + if (*(opcode + 1) >= 0x80u) + memset((char *) &op->imm + 1, '\xff', (pmode ? 3 : 1)); // + else + op->imm = 0; + memcpy(&op->imm, opcode + 1, 1); + } + break; - if ((op->indexr = sidbyte->index) != ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; + /** mod == 10 : operand base + sdword */ + case 2: op->ptr = opcode; - op->len = 3; - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - if (*(opcode + 2) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 2, 1); - } else { - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 2; - op->baser = modrm->m; - + if (modrm->m == ASM_REG_ESP) + { + if (sidbyte->base == ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + else + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + + op->regset = ASM_REGSET_R32; + op->baser = sidbyte->base; + op->indexr = sidbyte->index; + op->scale = asm_int_pow2(sidbyte->sid); + op->len = (pmode ? 6 : 4); // + memcpy(&op->imm, opcode + 2, (pmode ? 4 : 2)); // + } + else + { + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; + op->len = (pmode ? 5 : 3); // + op->regset = ASM_REGSET_R32; + op->baser = modrm->m; + op->imm = 0; + memcpy(&op->imm, opcode + 1, (pmode ? 4 : 2)); // + } + break; + + /* + if (modrm->m == ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; + op->len = 5; + op->baser = modrm->m; op->regset = ASM_REGSET_R32; - if (*(opcode + 1) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 1, 1); - } - break; - case 2: + memcpy(&op->imm, opcode + 1, 4); + op->baser; + op->imm; + break; + */ - /** - * mod : value 10 - * base + sdword - * - */ - - op->ptr = opcode; - - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - op->len = 6; - - memcpy(&op->imm, opcode + 2, 4); - - } else { - - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; - - op->regset = ASM_REGSET_R32; - op->baser = modrm->m; - op->imm = 0; - memcpy(&op->imm, opcode + 1, 4); - } - - break; - - /**************/ - if (modrm->m == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; - - op->baser = modrm->m; - op->regset = ASM_REGSET_R32; - memcpy(&op->imm, opcode + 1, 4); - - /* - op->baser; - op->imm; - */ - break; + /* mod == 3 */ case 3: op->content = ASM_OP_BASE; op->regset = ASM_REGSET_R8; op->len = 1; op->ptr = opcode; - op->baser = modrm->m; break; } @@ -232,134 +217,162 @@ * */ -int operand_rmv(asm_operand *op, u_char *opcode, u_int len, - asm_processor *proc) { +int operand_rmv(asm_operand *op, u_char *opcode, u_int len, asm_processor *proc) +{ struct s_modrm *modrm; struct s_sidbyte *sidbyte; - + u_char mode; + u_char pmode; + + mode = asm_ia32_get_mode(proc); + pmode = (mode == INTEL_PROT); + +#if __DEBUG_MODRM__ + fprintf(stderr, "[DEBUG_MODRM] IA32 processor in %c-mode (RMV) \n", + (pmode ? 'p' : (mode == INTEL_REAL ? 'r' : 'U'))); +#endif + modrm = (struct s_modrm *) (opcode); sidbyte = (struct s_sidbyte *) (opcode + 1); - op->regset = ASM_REGSET_R32; - switch(modrm->mod) { - case 0: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_EBP) { - /* pushl 0x8050fe0(,%eax,4) ; opcode = 'ff 34 85 e0 0f 05 08' */ - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; - op->regset = ASM_REGSET_R32; - op->len = 6; - op->ptr = opcode; - op->scale = asm_int_pow2(sidbyte->sid); - - memcpy((char *) &op->imm, opcode + 2, 4); - - op->baser = -1; - op->indexr = sidbyte->index; - } else if (sidbyte->base == ASM_REG_ESP) { - op->content = ASM_OP_REFERENCE | ASM_OP_SCALE | ASM_OP_BASE; - op->len = 2; - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - - } else { - op->content = ASM_OP_REFERENCE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - // op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - op->len = 2; - op->ptr = opcode; - + op->regset = pmode ? ASM_REGSET_R32 : ASM_REGSET_R16; + switch (modrm->mod) + { + + /* modrm->mod = 0 */ + case 0: + + switch (modrm->m) + { + + /* modrm == ESP */ + case ASM_REG_ESP: + switch (sidbyte->base) + { + + case ASM_REG_EBP: + + /* pushl 0x8050fe0(,%eax,4) ; opcode = 'ff 34 85 e0 0f 05 08' */ + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; + op->regset = ASM_REGSET_R32; + op->len = (pmode ? 6 : 4); // + op->ptr = opcode; + op->scale = asm_int_pow2(sidbyte->sid); + memcpy((char *) &op->imm, opcode + 2, (pmode ? 4 : 2)); // + op->baser = -1; + op->indexr = sidbyte->index; + break; + + case ASM_REG_ESP: + op->content = ASM_OP_REFERENCE | ASM_OP_SCALE | ASM_OP_BASE; + op->len = 2; + op->baser = sidbyte->base; + op->scale = asm_int_pow2(sidbyte->sid); + break; + + default: + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + // op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + op->len = 2; + op->ptr = opcode; + op->regset = ASM_REGSET_R32; + op->baser = sidbyte->base; + op->scale = asm_int_pow2(sidbyte->sid); + op->indexr = sidbyte->index; + break; + } + break; + + /* modrm == EBP */ + case ASM_REG_EBP: + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; + op->ptr = opcode; + op->len = (pmode ? 5 : 3); // + memcpy(&op->imm, opcode + 1, (pmode ? 4 : 2)); // + break; + + /* modrm != EBP and modrm != ESP */ + default: + op->ptr = opcode; + op->len = 1; + op->content = ASM_OP_REFERENCE | ASM_OP_BASE; + op->baser = modrm->m; + break; + } + break; + + /* modrm->mod = 1 */ + case 1: + if (modrm->m == ASM_REG_ESP) + { + if (sidbyte->base == ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; + else + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + op->ptr = opcode; + op->len = 3; // ???? + op->regset = ASM_REGSET_R32; + op->baser = sidbyte->base; + op->indexr = sidbyte->index; + op->scale = asm_int_pow2(sidbyte->sid); + if (*(opcode + 2) >= 0x80u) + memset((char *) &op->imm + 1, '\xff', (pmode ? 3 : 1)); // + else + op->imm = 0; + memcpy(&op->imm, opcode + 2, 1); + } + else + { + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; + op->len = 2; // ????? op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - op->indexr = sidbyte->index; - } - } else { - if (modrm->m == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; - op->ptr = opcode; - op->len = 5; - memcpy(&op->imm, opcode + 1, 4); - } else { - - op->ptr = opcode; - op->len = 1; - op->content = ASM_OP_REFERENCE | ASM_OP_BASE; - op->baser = modrm->m; + if (*(opcode + 1) >= 0x80u) + memset((char *) &op->imm + 1, '\xff', (pmode ? 3 : 1)); // + else + op->imm = 0; + memcpy(&op->imm, opcode + 1, 1); } - } - break; - - case 1: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - op->ptr = opcode; - op->len = 3; - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - if (*(opcode + 2) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 2, 1); - } else { - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 2; - op->regset = ASM_REGSET_R32; - op->baser = modrm->m; - - if (*(opcode + 1) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 1, 1); - } - break; - case 2: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - - op->len = 6; - op->ptr = opcode; - - op->baser = sidbyte->base; - op->regset = ASM_REGSET_R32; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - memcpy(&op->imm, opcode + 2, 4); - - } else { - - - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; + break; + + /* modrm->mod = 2 */ + case 2: + if (modrm->m == ASM_REG_ESP) + { + if (sidbyte->base == ASM_REG_ESP) + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; + else + op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; + + op->len = (pmode ? 6 : 4); // + op->ptr = opcode; + op->baser = sidbyte->base; + op->regset = ASM_REGSET_R32; + op->indexr = sidbyte->index; + op->scale = asm_int_pow2(sidbyte->sid); + memcpy(&op->imm, opcode + 2, (pmode ? 4 : 2)); // + } + else + { + op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; + op->len = (pmode ? 5 : 3); // + op->ptr = opcode; + op->regset = ASM_REGSET_R32; + op->baser = modrm->m; + memcpy(&op->imm, opcode + 1, (pmode ? 4 : 2)); // + } + break; + + /* modrm->mod = 3 */ + case 3: + op->content = ASM_OP_BASE; + op->len = 1; op->ptr = opcode; - op->regset = ASM_REGSET_R32; - + op->regset = asm_proc_opsize(proc) ? ASM_REGSET_R16 : ASM_REGSET_R32; op->baser = modrm->m; - memcpy(&op->imm, opcode + 1, 4); + break; } - break; - case 3: - op->content = ASM_OP_BASE; - op->len = 1; - op->ptr = opcode; - op->regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - op->baser = modrm->m; - break; - } + return (op->len); } @@ -380,7 +393,6 @@ */ int asm_content_pack(asm_operand *op, int content, int otype) { - return (0); } diff -Nru eresi-0.8a25/libasm/src/arch/ia32/output_ia32.c eresi-0.0.20110516/libasm/src/arch/ia32/output_ia32.c --- eresi-0.8a25/libasm/src/arch/ia32/output_ia32.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/output_ia32.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,7 +1,7 @@ /** - * @file output_ia32.c - * @ingroup libasm_ia32 -** $Id: output_ia32.c,v 1.13 2008/01/07 01:32:56 heroine Exp $ +* @file libasm/src/arch/ia32/output_ia32.c + * @ingroup ia32 +** $Id: output_ia32.c 1397 2009-09-13 02:19:08Z may $ ** ** Author : ** Started : Xxx Xxx xx xx:xx:xx 2002 @@ -22,9 +22,9 @@ * */ -void asm_resolve_ia32(void *d, u_int val, char *buf, u_int len) +void asm_resolve_ia32(void *d, eresi_Addr val, char *buf, u_int len) { - snprintf(buf, len, "0x%x", val); + snprintf(buf, len, XFMT, val); } /** @@ -34,20 +34,26 @@ * */ -char *asm_get_instr_name(asm_instr *i) { +char *asm_get_instr_name(asm_instr *i) +{ return (i->proc->instr_table[i->instr]); } -void output_instr(asm_instr *instr) { - +void output_instr(asm_instr *instr) +{ printf("%10s ", instr->proc->instr_table[instr->instr]); - if (instr->op[0].type) { - switch(instr->op[0].content) { + if (instr->op[0].type) + { + switch(instr->op[0].content) + { + + } + } /* !instr->op1 */ + else + { } - } /* !instr->op1 */ else { - - } + /* printf("\t;; len: %5u ", instr->len); if (instr->type & IS_MEM_WRITE) @@ -128,23 +134,23 @@ * @bug 2007-06-16 : Raise a segfault when used lonely */ -void att_dump_operand(asm_instr *ins, int num, unsigned int addr, - void *bufptr) +void att_dump_operand(asm_instr *ins, int num, eresi_Addr addr, void *bufptr) { - char resolved[256]; - int baser; - int indexr; - int scale; - int imm; - asm_operand *op; - char *buffer; + char resolved[256]; + eresi_Addr addr_mask; + int baser; + int indexr; + int scale; + int imm; + asm_operand *op; + char *buffer; + /* Fetch some necessary info */ + addr_mask = asm_proc_opsize(ins->proc) ? 0x000fffff : 0xffffffff; op = 0; buffer = bufptr; - baser = indexr = scale = imm = 0; - - switch(num) + switch (num) { case 1: op = &ins->op[0]; @@ -156,150 +162,138 @@ op = &ins->op[2]; break; } + asm_operand_get_immediate(ins, num, addr, &imm); + asm_operand_get_basereg(ins, num, addr, &baser); + asm_operand_get_indexreg(ins, num, addr, &indexr); + asm_operand_get_scale(ins, num, addr, &scale); + + /* Resolve target addresses if any, dealing with real/protected mode addressing */ + if (op->content & ASM_OP_ADDRESS) + { + if (op->content & ASM_OP_REFERENCE) + ins->proc->resolve_immediate(ins->proc->resolve_data, imm & addr_mask, resolved, 256); + else + { + addr = asm_dest_resolve(ins->proc, addr, imm + ins->len); + ins->proc->resolve_immediate(ins->proc->resolve_data, addr, resolved, 256); + } + } + else if (op->len == 1) + snprintf(resolved, sizeof(resolved), "0x%02X", (u_char) imm); + else + ins->proc->resolve_immediate(ins->proc->resolve_data, imm, resolved, 256); - - // if (op->content & ASM_OP_VALUE) - asm_operand_get_immediate(ins, num, addr, &imm); - // if (op->content & ASM_OP_BASE) - asm_operand_get_basereg(ins, num, addr, &baser); - // if (op->content & ASM_OP_INDEX) - asm_operand_get_indexreg(ins, num, addr, &indexr); - // if (op->content & ASM_OP_SCALE) - asm_operand_get_scale(ins, num, addr, &scale); - - if (ASM_OP_ADDRESS & op->content) { - if (ASM_OP_REFERENCE & op->content) - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm, resolved, 256); - else if (ASM_OP_VALUE & op->content) - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm + addr + ins->len, resolved, 256); - else - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm + addr + ins->len, resolved, 256); - } else - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm, resolved, 256); - - switch(op->content & ~ASM_OP_FIXED) { - case ASM_OP_BASE|ASM_OP_ADDRESS: - sprintf(buffer, "*%%%s", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_BASE: - sprintf(buffer, "%%%s", - get_reg_intel(baser, op->regset)); - break; - /* - case OP_SUBREG: - sprintf(buffer, "%%%s", - get_subreg_intel(baser)); - break; - case OP_SEGREG: - break; - */ - case ASM_OP_VALUE: - sprintf(buffer, "$%s", - resolved); - break; - case ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE: - sprintf(buffer, "%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE: - sprintf(buffer, "(%%%s)", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_ADDRESS: - sprintf(buffer, "*(%%%s)", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE: - sprintf(buffer, "%s(%%%s)", - resolved - , get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s(%%%s)", - resolved - , get_reg_intel(baser, op->regset)); - break; - case - ASM_OP_REFERENCE | ASM_OP_ADDRESS | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: + /* Resolve any potential encoded information */ + switch (op->content & ~ASM_OP_FIXED) + { + case ASM_OP_BASE|ASM_OP_ADDRESS: + sprintf(buffer, "*%%%s", + get_reg_intel(baser, op->regset)); + break; + case ASM_OP_BASE: + sprintf(buffer, "%%%s", + get_reg_intel(baser, op->regset)); + break; + case ASM_OP_VALUE: + sprintf(buffer, "$%s", + resolved); + break; + case ASM_OP_VALUE | ASM_OP_ADDRESS: + sprintf(buffer, "%s", + resolved); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE: + sprintf(buffer, "%s", + resolved); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_ADDRESS: + sprintf(buffer, "*%s", + resolved); + break; + case ASM_OP_REFERENCE | ASM_OP_BASE: + sprintf(buffer, "(%%%s)", + get_reg_intel(baser, op->regset)); + break; + case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_ADDRESS: + sprintf(buffer, "*(%%%s)", + get_reg_intel(baser, op->regset)); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE: + sprintf(buffer, "%s(%%%s)", resolved, + get_reg_intel(baser, op->regset)); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_ADDRESS: + sprintf(buffer, "*%s(%%%s)", resolved, + get_reg_intel(baser, op->regset)); + break; + case + ASM_OP_REFERENCE | ASM_OP_ADDRESS | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: sprintf(buffer, "*(%%%s,%%%s,%d)", get_reg_intel(baser, op->regset), get_reg_intel(indexr, op->regset), scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "(%%%s,%d)", - get_reg_intel(baser, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "(%%%s,%%%s,%d)", - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "%s(%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE | ASM_OP_VALUE: - sprintf(buffer, "%s(%%%s,%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), + break; + case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE: + sprintf(buffer, "(%%%s,%d)", + get_reg_intel(baser, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: + sprintf(buffer, "(%%%s,%%%s,%d)", + get_reg_intel(baser, op->regset), get_reg_intel(indexr, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE: + sprintf(buffer, "%s(%%%s,%d)", + resolved, + get_reg_intel(baser, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE | ASM_OP_VALUE: + sprintf(buffer, "%s(%%%s,%%%s,%d)", + resolved, + get_reg_intel(baser, op->regset), + get_reg_intel(indexr, op->regset), scale); - break; + break; case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE | ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s(%%%s,%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_VALUE | ASM_OP_SCALE |ASM_OP_ADDRESS: - sprintf(buffer, "*%s(,%%%s,%d)", - resolved, - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "%s(,%%%s,%d)", - resolved, - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "(,%%%s,%d)", - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_FPU | ASM_OP_BASE: - strcat(buffer, "%st"); - break; - case ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "%%st(%d)", scale); - break; - - case 0: - break; - default: - sprintf(buffer, "(...)"); - } + sprintf(buffer, "*%s(%%%s,%%%s,%d)", + resolved, + get_reg_intel(baser, op->regset), + get_reg_intel(indexr, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_VALUE | ASM_OP_SCALE |ASM_OP_ADDRESS: + sprintf(buffer, "*%s(,%%%s,%d)", + resolved, + get_reg_intel(indexr, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE: + sprintf(buffer, "%s(,%%%s,%d)", + resolved, + get_reg_intel(indexr, op->regset), + scale); + break; + case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_SCALE: + sprintf(buffer, "(,%%%s,%d)", + get_reg_intel(indexr, op->regset), + scale); + break; + case ASM_OP_FPU | ASM_OP_BASE: + strcat(buffer, "%st"); + break; + case ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE: + sprintf(buffer, "%%st(%d)", scale); + break; + + case 0: + break; + default: + sprintf(buffer, "(...)"); + } } /** @@ -325,11 +319,12 @@ */ char *asm_ia32_display_instr_att(asm_instr *instr, - int addr) + eresi_Addr addr) { static char buffer[1024]; int len; - + int margin; + if (!instr) return (0); @@ -355,32 +350,36 @@ return (buffer); } - if (instr->op[0].type) { - /* Add spaces */ - len = strlen(buffer); - while(len++ < (int)config_get_data(CONFIG_ASM_ATT_MARGIN_FLAG)) - strcat(buffer, " "); - - if (instr->op[2].type) { - asm_operand_get_att(instr, 3, addr, buffer + strlen(buffer)); - strcat(buffer, ","); - } + /* Add spaces */ + if (instr->op[0].type) + { + len = strlen(buffer); + margin = (int) config_get_data(CONFIG_ASM_ATT_MARGIN_FLAG); + while (len++ < margin) + strcat(buffer, " "); + + if (instr->op[2].type) + { + asm_operand_get_att(instr, 3, addr, buffer + strlen(buffer)); + strcat(buffer, ","); + } - if (instr->op[1].type) { - switch(instr->op[1].prefix & ASM_PREFIX_SEG) { - case ASM_PREFIX_ES: - strcat(buffer, "%es:"); - break; - case ASM_PREFIX_DS: - strcat(buffer, "%ds:"); - break; - } - - asm_operand_get_att(instr, 2, addr, buffer + strlen(buffer)); - strcat(buffer, ","); + if (instr->op[1].type) + { + switch(instr->op[1].prefix & ASM_PREFIX_SEG) + { + case ASM_PREFIX_ES: + strcat(buffer, "%es:"); + break; + case ASM_PREFIX_DS: + strcat(buffer, "%ds:"); + break; + } + asm_operand_get_att(instr, 2, addr, buffer + strlen(buffer)); + strcat(buffer, ","); } - switch(instr->op[0].prefix & ASM_PREFIX_SEG) + switch (instr->op[0].prefix & ASM_PREFIX_SEG) { case ASM_PREFIX_ES: strcat(buffer, "%es:"); diff -Nru eresi-0.8a25/libasm/src/arch/ia32/register.c eresi-0.0.20110516/libasm/src/arch/ia32/register.c --- eresi-0.8a25/libasm/src/arch/ia32/register.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/register.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file register.c - * @ingroup libasm_ia32 +* @file libasm/src/arch/ia32/register.c + * @ingroup ia32 * @brief Registration of the ia32 disassembling vector. * */ diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/ia32/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/ia32/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32 -END -output_ia32.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/output_ia32.c -END -tables_i386.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/tables_i386.c -END -register.c -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/register.c -END -operand_ia32.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/operand_ia32.c -END -init_i386.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/909/trunk/libasm/src/arch/ia32/init_i386.c -END diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/entries eresi-0.0.20110516/libasm/src/arch/ia32/.svn/entries --- eresi-0.8a25/libasm/src/arch/ia32/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/ia32 -http://svn.eresi-project.org/svn - - - -2008-03-14T09:48:44.987521Z -909 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -output_ia32.c -file - - - - -2008-04-06T23:16:25.334131Z -da5cecb7955de4897a7613f20e1d6137 -2008-03-14T09:48:44.987521Z -909 -enioh - -handlers -dir - -tables_i386.c -file - - - - -2008-04-06T23:16:25.344927Z -85dc489bf75f9a7afda49a5d7c5a099f -2008-03-14T09:48:44.987521Z -909 -enioh - -register.c -file - - - - -2008-04-06T23:16:25.355899Z -bf23b1064032d48f87dc925bc5595e19 -2008-03-14T09:48:44.987521Z -909 -enioh - -operand_ia32.c -file - - - - -2008-04-06T23:16:25.366892Z -e6d7b72d502b9521c81a7a9e68f5f43a -2008-03-14T09:48:44.987521Z -909 -enioh - -operand_handlers -dir - -init_i386.c -file - - - - -2008-04-06T23:16:25.380401Z -e79fae91c6aa62709034601f6a81a96d -2008-03-14T09:48:44.987521Z -909 -enioh - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/format eresi-0.0.20110516/libasm/src/arch/ia32/.svn/format --- eresi-0.8a25/libasm/src/arch/ia32/.svn/format 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/init_i386.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/init_i386.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/init_i386.c.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/init_i386.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/** - * @file init_i386.c - * @ingroup libasm_ia32 - * $Id: init_i386.c,v 1.13 2007/10/14 00:01:41 heroine Exp $ - * - */ -#ifndef I386_H_ -#define I386_h_ - -#include -#include - -void init_instr_table(asm_processor *); - - -/** - * Handler to fetch i386 bytecode. - * This handler is called throught a function pointer stored in - * the asm_processor structure. - * - * @param instr Pointer to instruction structure to fill. - * @param buf Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Length of instruction or -1 on error. - */ - -int fetch_i386(asm_instr *instr, u_char *buf, u_int len, - asm_processor *proc) -{ - u_char opcode; - int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *); - - opcode = *buf; - fetch = asm_opcode_fetch(LIBASM_VECTOR_OPCODE_IA32, opcode); - return (fetch(instr, buf, len, proc)); -} - -int asm_init_i386(asm_processor *proc) -{ - fprintf(stderr, "you should not use asm_init_i386 anymore." - " Use asm_init_ia32 instead\n"); - return (asm_init_ia32(proc)); -} - -/** - * Intialize the processor structure to disassemble i386 bytecode. - * @param Pointer to a asm_processor structure. - * @return Always 1. - */ - -int asm_init_ia32(asm_processor *proc) -{ - - struct s_asm_proc_i386 *inter; - - init_instr_table(proc); - proc->type = ASM_PROC_IA32; - /* Register the ia32 vector */ - asm_register_ia32(); - - // XXX: dead code to remove - //asm_init_ia32_vector(); - //asm_init_vectors(proc); - // asm_arch_register(proc, 1); /* dummy parameters for the moment */ - - - proc->resolve_immediate = asm_resolve_ia32; - proc->resolve_data = 0; - // proc->get_operand = create_i386_operand; - proc->fetch = fetch_i386; - proc->display_handle = asm_ia32_display_instr_att; - inter = proc->internals = malloc(sizeof (struct s_asm_proc_i386)); - inter->opsize = inter->addsize = 0; - inter->mode = INTEL_PROT; - - return (1); -} - -void asm_free_i386(asm_processor *proc) -{ - free(proc->internals); - free(proc->instr_table); -} - -#endif diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/operand_ia32.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/operand_ia32.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/operand_ia32.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/operand_ia32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,418 +0,0 @@ -/** - * @file operand_ia32.c - * @ingroup libasm_ia32 -** $Id: operand_ia32.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -** Author : -** Started : Tue May 28 13:06:39 2002 -** Updated : Sun Mar 21 00:39:09 2004 -*/ - -#include -#include - - -/** - * Extracts operands from memory and stores them in instruction. - * - * @todo - * This function should not be called. - * - * - * - * - */ - -int operand_rmb_ib(asm_instr *ins, u_char *opcode, int len, - asm_processor *proc) { - struct s_modrm *modrm; - - modrm = (struct s_modrm *) opcode; - operand_rmb(&ins->op[0], opcode, len, proc); - ins->op[1].content = ASM_OP_VALUE; - ins->op[1].len = 1; - ins->op[1].ptr = opcode + (ins->op[0].len ? ins->op[0].len : 1); - // if (*(opcode + ins->op1.len) >= 0x80u) - // memcpy((char *) &ins->op2.imm + 1, "\xff\xff\xff", 3); - // else - ins->op[1].imm = 0; - memcpy(&ins->op[1].imm, opcode + (ins->op[0].len ? ins->op[0].len : 1), 1); - - ins->len += (ins->op[0].len ? ins->op[0].len : 1) + ins->op[1].len; - return (1); -} - -/** - * @brief Decode a modRM operand of size Byte. - * - * @param op Pointer to operand to fill. - * @param opcode Pointer to operand bytes. - * @param len Length of data. - * @param proc Pointer to processor structure - * @return Length of the operand. - * -*/ - - -int operand_rmb(asm_operand *op, u_char *opcode, u_int len, - asm_processor *proc) { - struct s_modrm *modrm; - struct s_sidbyte *sidbyte; - - modrm = (struct s_modrm *) (opcode); - sidbyte = (struct s_sidbyte *) (opcode + 1); - - switch(modrm->mod) { - case 0: - - /** - * mod : 00 - * operand base - * - */ - - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; - op->regset = ASM_REGSET_R32; - op->len = 6; - op->ptr = opcode; - op->scale = asm_int_pow2(sidbyte->sid); - - if (((unsigned char)*(opcode + 2)) >= 0x80) - memcpy((char *) &op->imm + 2, "\xff\xff", 2); - else - op->imm = 0; - memcpy((char *) &op->imm, opcode + 2, 4); - - op->indexr = sidbyte->index; - } else { - - if ((op->indexr = sidbyte->index) != ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE; - op->len = 2; - op->ptr = opcode; - op->regset = ASM_REGSET_R32; - - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - - } - } else { - if (modrm->m == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; - op->ptr = opcode; - op->len = 5; - memcpy(&op->imm, opcode + 1, 4); - } else { - - op->ptr = opcode; - op->len = 1; - op->content = ASM_OP_REFERENCE | ASM_OP_BASE; - - op->baser = modrm->m; - op->regset = ASM_REGSET_R32; - } - } - break; - - /** - * mod : 01 - * operand : base + sbyte - * - */ - - case 1: - if (modrm->m == ASM_REG_ESP) { - - if ((op->indexr = sidbyte->index) != ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | - ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; - op->ptr = opcode; - op->len = 3; - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - if (*(opcode + 2) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 2, 1); - } else { - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 2; - op->baser = modrm->m; - - op->regset = ASM_REGSET_R32; - if (*(opcode + 1) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 1, 1); - } - break; - case 2: - - /** - * mod : value 10 - * base + sdword - * - */ - - op->ptr = opcode; - - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - op->len = 6; - - memcpy(&op->imm, opcode + 2, 4); - - } else { - - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; - - op->regset = ASM_REGSET_R32; - op->baser = modrm->m; - op->imm = 0; - memcpy(&op->imm, opcode + 1, 4); - } - - break; - - /**************/ - - if (modrm->m == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; - - op->baser = modrm->m; - op->regset = ASM_REGSET_R32; - memcpy(&op->imm, opcode + 1, 4); - - /* - op->baser; - op->imm; - */ - break; - case 3: - op->content = ASM_OP_BASE; - op->regset = ASM_REGSET_R8; - op->len = 1; - op->ptr = opcode; - - op->baser = modrm->m; - break; - } - - return (op->len); -} - - -/*** - * - * - * - */ - -int operand_rmv(asm_operand *op, u_char *opcode, u_int len, - asm_processor *proc) { - struct s_modrm *modrm; - struct s_sidbyte *sidbyte; - - modrm = (struct s_modrm *) (opcode); - sidbyte = (struct s_sidbyte *) (opcode + 1); - - op->regset = ASM_REGSET_R32; - switch(modrm->mod) { - case 0: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_EBP) { - /* pushl 0x8050fe0(,%eax,4) ; opcode = 'ff 34 85 e0 0f 05 08' */ - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE; - op->regset = ASM_REGSET_R32; - op->len = 6; - op->ptr = opcode; - op->scale = asm_int_pow2(sidbyte->sid); - - memcpy((char *) &op->imm, opcode + 2, 4); - - op->baser = -1; - op->indexr = sidbyte->index; - } else if (sidbyte->base == ASM_REG_ESP) { - op->content = ASM_OP_REFERENCE | ASM_OP_SCALE | ASM_OP_BASE; - op->len = 2; - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - - } else { - op->content = ASM_OP_REFERENCE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - // op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - op->len = 2; - op->ptr = opcode; - - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->scale = asm_int_pow2(sidbyte->sid); - op->indexr = sidbyte->index; - } - } else { - if (modrm->m == ASM_REG_EBP) { - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE; - op->ptr = opcode; - op->len = 5; - memcpy(&op->imm, opcode + 1, 4); - } else { - - op->ptr = opcode; - op->len = 1; - op->content = ASM_OP_REFERENCE | ASM_OP_BASE; - - op->baser = modrm->m; - } - } - break; - - case 1: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - op->ptr = opcode; - op->len = 3; - op->regset = ASM_REGSET_R32; - op->baser = sidbyte->base; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - if (*(opcode + 2) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 2, 1); - } else { - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 2; - op->regset = ASM_REGSET_R32; - op->baser = modrm->m; - - if (*(opcode + 1) >= 0x80u) - memcpy((char *) &op->imm + 1, "\xff\xff\xff", 3); - else - op->imm = 0; - memcpy(&op->imm, opcode + 1, 1); - } - break; - case 2: - if (modrm->m == ASM_REG_ESP) { - if (sidbyte->base == ASM_REG_ESP) - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_SCALE; - else - op->content = ASM_OP_REFERENCE | ASM_OP_VALUE | - ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE; - - op->len = 6; - op->ptr = opcode; - - op->baser = sidbyte->base; - op->regset = ASM_REGSET_R32; - op->indexr = sidbyte->index; - op->scale = asm_int_pow2(sidbyte->sid); - memcpy(&op->imm, opcode + 2, 4); - - } else { - - - op->content = ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_VALUE; - op->len = 5; - op->ptr = opcode; - op->regset = ASM_REGSET_R32; - - op->baser = modrm->m; - memcpy(&op->imm, opcode + 1, 4); - } - break; - case 3: - op->content = ASM_OP_BASE; - op->len = 1; - op->ptr = opcode; - op->regset = asm_proc_opsize(proc) ? - ASM_REGSET_R16 : ASM_REGSET_R32; - op->baser = modrm->m; - break; - } - return (op->len); -} - - -/** - * Note about operand content field. - * This field contain two packed value - * one for the content of the operand, which is a bitfield, - * and an otype value which is the type of the operand. - * This type is related to the sandpile.org reference and - * to the enum ASM_OTYPE_* (!!add link to enum!!) - */ - -/** - * Pack content and otype values of the content field. - * @param content - * @param otype - */ -int asm_content_pack(asm_operand *op, int content, int otype) -{ - - return (0); -} - -/** - * Return content part of the content field - */ -int asm_content_extract_otype(asm_operand *op) -{ - return (0); -} - -/** - * Return otype part of the content field - * param asm_op_content Content field of an operand. - */ -int asm_content_extract_content(asm_operand *op) -{ - return (0); -} - -/** - * Return a packed value for asm_operand_fetch_fixed optional parameters. - * @todo Implement this correctly. - * opt may be a regset or nothing - * value may be a register, or a fixed value - * otype is an - */ -int asm_fixed_pack(int otype, int content, int value, int opt) -{ - return (otype | content | value | opt); -} - - - - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/output_ia32.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/output_ia32.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/output_ia32.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/output_ia32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,419 +0,0 @@ -/** - * @file output_ia32.c - * @ingroup libasm_ia32 -** $Id: output_ia32.c,v 1.13 2008/01/07 01:32:56 heroine Exp $ -** -** Author : -** Started : Xxx Xxx xx xx:xx:xx 2002 -** Updated : Thu Mar 11 00:40:31 2004 -*/ - -/* - Sat Jul 13 00:15:51 2002 - removed a bug in scalar output. - -*/ - -#include -#include - -/** - * Default resolving handler for virtual address - * - */ - -void asm_resolve_ia32(void *d, u_int val, char *buf, u_int len) -{ - snprintf(buf, len, "0x%x", val); -} - -/** - * Instruction label handler. - * Return ia32 instruction label - * - * - */ - -char *asm_get_instr_name(asm_instr *i) { - return (i->proc->instr_table[i->instr]); -} - -void output_instr(asm_instr *instr) { - - printf("%10s ", instr->proc->instr_table[instr->instr]); - if (instr->op[0].type) { - switch(instr->op[0].content) { - - } - } /* !instr->op1 */ else { - - } - /* - printf("\t;; len: %5u ", instr->len); - if (instr->type & IS_MEM_WRITE) - printf("MW : Y "); - else - printf("MW : N "); - - if (instr->type & IS_MEM_READ) - printf("MR : Y "); - else - printf("MR : N "); - if (instr->type & IS_CALL) - printf("CALL : Y "); - else - printf("CALL : N "); - if (instr->type & IS_JMP) - printf("JMP : Y "); - else - printf("JMP : N "); - if (instr->type & IS_COND_BRANCH) - printf("CONDBR : Y "); - else - printf("CONDBR : N "); - */ - puts(""); - -} - -/** - * Return register ascii string - * @param r Register - * @param regset Register Set (32 bits registers, 16 bits, control ...) - */ - -char *get_reg_intel(int r, int regset) -{ - char *rsub[8] ={ "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh" }; - char *r16[8] = { "ax", "cx", "dx", "bx", "sp", "bp", "si", "di" }; - char *r32[8] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" }; - char *rseg[8] = { "es", "cs", "ss", "ds", "fs", "gs", "#@!", "#@!" }; - char *rmm[8] = { "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7"}; - char *rxmm[8] = {"xmm0", "xmm1", "xmm2","xmm3", "xmm4", "xmm5","xmm6", "xmm7"}; - char *rcr[8] = { "cr0", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7"}; - char *rdr[8] = { "db0", "db1", "db2", "db3", "db4", "db5", "db6", "db7"}; - char *rdefault[8] = {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7"}; - - if (r >= 0 && r < 8) - switch(regset) { - case ASM_REGSET_R8: - return (rsub[r]); - case ASM_REGSET_R16: - return (r16[r]); - case ASM_REGSET_R32: - return (r32[r]); - case ASM_REGSET_XMM: - return (rxmm[r]); - case ASM_REGSET_CREG: - return (rcr[r]); - case ASM_REGSET_DREG: - return (rdr[r]); - case ASM_REGSET_MM: - return (rmm[r]); - case ASM_REGSET_SREG: - return (rseg[r]); - default: - return (rdefault[r]); - } - return ("\?\?\?"); -} - - -/** - * Dump an operand output in att syntax to a buffer. - * @param instr Pointer to instruction structure - * @param num Number of operand to dump - * @param addr Virtual address of instruction - * @param bufptr Buffer to dump operand to - * @bug 2007-06-16 : Raise a segfault when used lonely - */ - -void att_dump_operand(asm_instr *ins, int num, unsigned int addr, - void *bufptr) -{ - char resolved[256]; - int baser; - int indexr; - int scale; - int imm; - asm_operand *op; - char *buffer; - - op = 0; - buffer = bufptr; - - baser = indexr = scale = imm = 0; - - switch(num) - { - case 1: - op = &ins->op[0]; - break; - case 2: - op = &ins->op[1]; - break; - case 3: - op = &ins->op[2]; - break; - } - - - // if (op->content & ASM_OP_VALUE) - asm_operand_get_immediate(ins, num, addr, &imm); - // if (op->content & ASM_OP_BASE) - asm_operand_get_basereg(ins, num, addr, &baser); - // if (op->content & ASM_OP_INDEX) - asm_operand_get_indexreg(ins, num, addr, &indexr); - // if (op->content & ASM_OP_SCALE) - asm_operand_get_scale(ins, num, addr, &scale); - - if (ASM_OP_ADDRESS & op->content) { - if (ASM_OP_REFERENCE & op->content) - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm, resolved, 256); - else if (ASM_OP_VALUE & op->content) - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm + addr + ins->len, resolved, 256); - else - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm + addr + ins->len, resolved, 256); - } else - ins->proc->resolve_immediate(ins->proc->resolve_data, - imm, resolved, 256); - - switch(op->content & ~ASM_OP_FIXED) { - case ASM_OP_BASE|ASM_OP_ADDRESS: - sprintf(buffer, "*%%%s", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_BASE: - sprintf(buffer, "%%%s", - get_reg_intel(baser, op->regset)); - break; - /* - case OP_SUBREG: - sprintf(buffer, "%%%s", - get_subreg_intel(baser)); - break; - case OP_SEGREG: - break; - */ - case ASM_OP_VALUE: - sprintf(buffer, "$%s", - resolved); - break; - case ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE: - sprintf(buffer, "%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s", - resolved); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE: - sprintf(buffer, "(%%%s)", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_ADDRESS: - sprintf(buffer, "*(%%%s)", - get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE: - sprintf(buffer, "%s(%%%s)", - resolved - , get_reg_intel(baser, op->regset)); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s(%%%s)", - resolved - , get_reg_intel(baser, op->regset)); - break; - case - ASM_OP_REFERENCE | ASM_OP_ADDRESS | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "*(%%%s,%%%s,%d)", - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "(%%%s,%d)", - get_reg_intel(baser, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "(%%%s,%%%s,%d)", - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "%s(%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE | ASM_OP_VALUE: - sprintf(buffer, "%s(%%%s,%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_BASE | ASM_OP_INDEX | ASM_OP_SCALE | - ASM_OP_VALUE | ASM_OP_ADDRESS: - sprintf(buffer, "*%s(%%%s,%%%s,%d)", - resolved, - get_reg_intel(baser, op->regset), - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_VALUE | ASM_OP_SCALE |ASM_OP_ADDRESS: - sprintf(buffer, "*%s(,%%%s,%d)", - resolved, - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_VALUE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "%s(,%%%s,%d)", - resolved, - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_REFERENCE | ASM_OP_INDEX | ASM_OP_SCALE: - sprintf(buffer, "(,%%%s,%d)", - get_reg_intel(indexr, op->regset), - scale); - break; - case ASM_OP_FPU | ASM_OP_BASE: - strcat(buffer, "%st"); - break; - case ASM_OP_FPU | ASM_OP_BASE | ASM_OP_SCALE: - sprintf(buffer, "%%st(%d)", scale); - break; - - case 0: - break; - default: - sprintf(buffer, "(...)"); - } -} - -/** - * - * - * - */ - -int asm_operand_get_att(asm_instr *ins, int num, int opt, void *valptr) -{ - att_dump_operand(ins, num, opt, valptr); - return (1); -} - - - - -/** - * @brief Return at&t ascii representation of an instruction - * @param instr Pointer to an instruction structure. - * @param addr Address of the instruction. May be used to compute offset of branch. - * @return A Pointer to a static buffer containing ascii instruction - */ - -char *asm_ia32_display_instr_att(asm_instr *instr, - int addr) -{ - static char buffer[1024]; - int len; - - if (!instr) - return (0); - - memset(buffer, 0, 1024); - - if (instr->prefix & ASM_PREFIX_LOCK) - strcat(buffer, "lock "); - if (instr->prefix & ASM_PREFIX_REP) - strcat(buffer, "repz "); - if (instr->prefix & ASM_PREFIX_REPNE) - strcat(buffer, "repnz "); - - if (instr->instr >= 0 && instr->instr <= ASM_BAD) - { - if (instr->proc->instr_table[instr->instr] != NULL) - sprintf(buffer + strlen(buffer), "%s", instr->proc->instr_table[instr->instr]); - else - sprintf(buffer + strlen(buffer), "missing"); - } - else - { - sprintf(buffer + strlen(buffer), "out_of_range"); - return (buffer); - } - - if (instr->op[0].type) { - /* Add spaces */ - len = strlen(buffer); - while(len++ < (int)config_get_data(CONFIG_ASM_ATT_MARGIN_FLAG)) - strcat(buffer, " "); - - if (instr->op[2].type) { - asm_operand_get_att(instr, 3, addr, buffer + strlen(buffer)); - strcat(buffer, ","); - } - - if (instr->op[1].type) { - switch(instr->op[1].prefix & ASM_PREFIX_SEG) { - case ASM_PREFIX_ES: - strcat(buffer, "%es:"); - break; - case ASM_PREFIX_DS: - strcat(buffer, "%ds:"); - break; - } - - asm_operand_get_att(instr, 2, addr, buffer + strlen(buffer)); - strcat(buffer, ","); - } - - switch(instr->op[0].prefix & ASM_PREFIX_SEG) - { - case ASM_PREFIX_ES: - strcat(buffer, "%es:"); - break; - case ASM_PREFIX_DS: - strcat(buffer, "%ds:"); - break; - } - - switch (instr->prefix & ASM_PREFIX_MASK) - { - case ASM_PREFIX_CS: - strcat(buffer, "%cs:"); - break; - case ASM_PREFIX_ES: - strcat(buffer, "%es:"); - break; - case ASM_PREFIX_DS: - strcat(buffer, "%ds:"); - break; - case ASM_PREFIX_GS: - strcat(buffer, "%gs:"); - break; - case ASM_PREFIX_FS: - strcat(buffer, "%fs:"); - break; - case ASM_PREFIX_SS: - strcat(buffer, "%ss:"); - break; - } - asm_operand_get_att(instr, 1, addr, buffer + strlen(buffer)); - } - - return(buffer); -} - diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/register.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/register.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/register.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,479 +0,0 @@ -/** - * @file register.c - * @ingroup libasm_ia32 - * @brief Registration of the ia32 disassembling vector. - * - */ - -#include -#include - -/** - * @brief Initialize the disassembling vector for ia32. - * @return Always returns 1 - * @todo Add return error code. - * prototype should be changed to (asm_processor *proc). - * for error handling. - */ - -int asm_register_ia32() -{ - static int init_ok = 0; - - LIBASM_PROFILE_FIN(); - if (init_ok == 1) - goto out; - asm_register_opcode_create(LIBASM_VECTOR_OPCODE_IA32, 512); - asm_register_ia32_opcodes(); - - asm_register_operand_create(LIBASM_VECTOR_OPERAND_IA32, ASM_OTYPE_NUM); - asm_register_ia32_operands(); - - init_ok = 1; - out: - LIBASM_PROFILE_FOUT(init_ok); -} - -/** - * Register an ia32 disassembly handler for an opcode - * @param opcode opcode to raise new handler - * @param fcn new handler. - */ -int asm_register_ia32_opcode(int opcode, unsigned long fcn) -{ - LIBASM_PROFILE_FIN(); - asm_register_opcode(LIBASM_VECTOR_OPCODE_IA32, opcode, fcn); - LIBASM_PROFILE_FOUT(1); -} - -/** - * Register an handler for a ia32 operand type. - * @param operand_type Type of the operand to register - * @param fcn Function pointer. - * @return 1 on success, 0 on error. - */ - -int asm_register_ia32_operand(int operand_type, unsigned long fcn) -{ - LIBASM_PROFILE_FIN(); - asm_register_operand(LIBASM_VECTOR_OPERAND_IA32, operand_type, fcn); - LIBASM_PROFILE_FOUT(1); -} - -int asm_register_ia32_operands() -{ - asm_register_ia32_operand(ASM_OTYPE_NONE, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_FIXED, (unsigned long) asm_operand_fetch_fixed); - asm_register_ia32_operand(ASM_OTYPE_OPMOD, (unsigned long) asm_operand_fetch_opmod); - asm_register_ia32_operand(ASM_OTYPE_ADDRESS, (unsigned long) asm_operand_fetch_address); - asm_register_ia32_operand(ASM_OTYPE_CONTROL, (unsigned long) asm_operand_fetch_control); - asm_register_ia32_operand(ASM_OTYPE_DEBUG, (unsigned long) asm_operand_fetch_debug); - asm_register_ia32_operand(ASM_OTYPE_ENCODED, (unsigned long) asm_operand_fetch_encoded); - asm_register_ia32_operand(ASM_OTYPE_ENCODEDBYTE, (unsigned long) asm_operand_fetch_encodedbyte); - asm_register_ia32_operand(ASM_OTYPE_FLAGS, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_GENERAL, (unsigned long) asm_operand_fetch_general); - asm_register_ia32_operand(ASM_OTYPE_GENERALBYTE, (unsigned long) asm_operand_fetch_generalbyte); - asm_register_ia32_operand(ASM_OTYPE_IMMEDIATE, (unsigned long) asm_operand_fetch_immediate); - asm_register_ia32_operand(ASM_OTYPE_IMMEDIATEWORD, (unsigned long) asm_operand_fetch_immediateword); - asm_register_ia32_operand(ASM_OTYPE_IMMEDIATEBYTE, (unsigned long) asm_operand_fetch_immediatebyte); - asm_register_ia32_operand(ASM_OTYPE_JUMP, (unsigned long) asm_operand_fetch_jump); - asm_register_ia32_operand(ASM_OTYPE_SHORTJUMP, (unsigned long) asm_operand_fetch_shortjump); - asm_register_ia32_operand(ASM_OTYPE_MEMORY, (unsigned long) asm_operand_fetch_memory); - asm_register_ia32_operand(ASM_OTYPE_OFFSET, (unsigned long) asm_operand_fetch_offset); - asm_register_ia32_operand(ASM_OTYPE_PMMX, (unsigned long) asm_operand_fetch_pmmx); - asm_register_ia32_operand(ASM_OTYPE_QMMX, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REGISTER, (unsigned long) asm_operand_fetch_register); - asm_register_ia32_operand(ASM_OTYPE_SEGMENT, (unsigned long) asm_operand_fetch_segment); - asm_register_ia32_operand(ASM_OTYPE_TEST, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_VSFP, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_WSFP, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_XSRC, (unsigned long) asm_operand_fetch_xsrc); - asm_register_ia32_operand(ASM_OTYPE_YDEST, (unsigned long) asm_operand_fetch_ydest); - asm_register_ia32_operand(ASM_OTYPE_VALUE, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG0, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG1, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG2, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG3, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG4, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG5, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG6, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_REG7, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_0, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_1, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_2, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_3, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_4, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_5, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_6, (unsigned long) asm_operand_fetch_default); - asm_register_ia32_operand(ASM_OTYPE_ST_7, (unsigned long) asm_operand_fetch_default); - return (1); -} - -/** - * @brief Register ia32 opcode handlers. - * @return Always 1. - */ - -int asm_register_ia32_opcodes() -{ - asm_register_ia32_opcode(0x00, (unsigned long) op_add_rmb_rb); - asm_register_ia32_opcode(0x01, (unsigned long) op_add_rmv_rv); - asm_register_ia32_opcode(0x02, (unsigned long) op_add_rb_rmb); - asm_register_ia32_opcode(0x03, (unsigned long) op_add_rv_rmv); - asm_register_ia32_opcode(0x04, (unsigned long) op_add_al_ib); - asm_register_ia32_opcode(0x05, (unsigned long) op_add_eax_iv); - asm_register_ia32_opcode(0x06, (unsigned long) op_push_es); - asm_register_ia32_opcode(0x07, (unsigned long) op_pop_es); - asm_register_ia32_opcode(0x08, (unsigned long) op_or_rmb_rb); - asm_register_ia32_opcode(0x09, (unsigned long) op_or_rmv_rv); - asm_register_ia32_opcode(0x0a, (unsigned long) op_or_rb_rmb); - asm_register_ia32_opcode(0x0b, (unsigned long) op_or_rv_rmv); - asm_register_ia32_opcode(0x0c, (unsigned long) op_or_al_ib); - asm_register_ia32_opcode(0x0d, (unsigned long) op_or_eax_iv); - asm_register_ia32_opcode(0x0e, (unsigned long) op_push_cs); - asm_register_ia32_opcode(0x0f, (unsigned long) op_386sp); - asm_register_ia32_opcode(0x10, (unsigned long) op_adc_rmb_rb); - asm_register_ia32_opcode(0x11, (unsigned long) op_adc_rmv_rv); - asm_register_ia32_opcode(0x12, (unsigned long) op_adc_rb_rmb); - asm_register_ia32_opcode(0x13, (unsigned long) op_adc_rv_rmv); - asm_register_ia32_opcode(0x14, (unsigned long) op_adc_al_ib); - asm_register_ia32_opcode(0x15, (unsigned long) op_adc_eax_iv); - asm_register_ia32_opcode(0x16, (unsigned long) op_push_ss); - asm_register_ia32_opcode(0x17, (unsigned long) op_pop_es); - asm_register_ia32_opcode(0x18, (unsigned long) op_sbb_rmb_rb); - asm_register_ia32_opcode(0x19, (unsigned long) op_sbb_rmv_rv); - asm_register_ia32_opcode(0x1a, (unsigned long) op_sbb_rb_rmb); - asm_register_ia32_opcode(0x1b, (unsigned long) op_sbb_rv_rmv); - asm_register_ia32_opcode(0x1c, (unsigned long) op_sbb_al_ib); - asm_register_ia32_opcode(0x1d, (unsigned long) op_sbb_eax_iv); - asm_register_ia32_opcode(0x1e, (unsigned long) op_push_ds); - asm_register_ia32_opcode(0x1f, (unsigned long) op_pop_ds); - asm_register_ia32_opcode(0x20, (unsigned long) op_and_rmb_rb); - asm_register_ia32_opcode(0x21, (unsigned long) op_and_rmv_rv); - asm_register_ia32_opcode(0x22, (unsigned long) op_and_rb_rmb); - asm_register_ia32_opcode(0x23, (unsigned long) op_and_rv_rmv); - asm_register_ia32_opcode(0x24, (unsigned long) op_and_al_ib); - asm_register_ia32_opcode(0x25, (unsigned long) op_and_eax_iv); - asm_register_ia32_opcode(0x26, (unsigned long) op_prefix_es); - asm_register_ia32_opcode(0x27, (unsigned long) op_daa); - asm_register_ia32_opcode(0x28, (unsigned long) op_sub_rmb_rb); - asm_register_ia32_opcode(0x29, (unsigned long) op_sub_rmv_rv); - asm_register_ia32_opcode(0x2a, (unsigned long) op_sub_rb_rmb); - asm_register_ia32_opcode(0x2b, (unsigned long) op_sub_rv_rmv); - asm_register_ia32_opcode(0x2c, (unsigned long) op_sub_al_ib); - asm_register_ia32_opcode(0x2d, (unsigned long) op_sub_eax_iv); - asm_register_ia32_opcode(0x2e, (unsigned long) op_prefix_cs); - asm_register_ia32_opcode(0x2f, (unsigned long) op_das); - asm_register_ia32_opcode(0x30, (unsigned long) op_xor_rmb_rb); - asm_register_ia32_opcode(0x31, (unsigned long) op_xor_rmv_rv); - asm_register_ia32_opcode(0x32, (unsigned long) op_xor_rb_rmb); - asm_register_ia32_opcode(0x33, (unsigned long) op_xor_rv_rmv); - asm_register_ia32_opcode(0x34, (unsigned long) op_xor_al_ib); - asm_register_ia32_opcode(0x35, (unsigned long) op_xor_eax_iv); - asm_register_ia32_opcode(0x36, (unsigned long) op_prefix_ss); - asm_register_ia32_opcode(0x37, (unsigned long) op_aaa); - asm_register_ia32_opcode(0x38, (unsigned long) op_cmp_rmb_rb); - asm_register_ia32_opcode(0x39, (unsigned long) op_cmp_rmv_rv); - asm_register_ia32_opcode(0x3a, (unsigned long) op_cmp_rb_rmb); - asm_register_ia32_opcode(0x3b, (unsigned long) op_cmp_rv_rmv); - asm_register_ia32_opcode(0x3c, (unsigned long) op_cmp_al_ib); - asm_register_ia32_opcode(0x3d, (unsigned long) op_cmp_eax_iv); - asm_register_ia32_opcode(0x3e, (unsigned long) op_prefix_ds); - asm_register_ia32_opcode(0x3f, (unsigned long) op_aas); - asm_register_ia32_opcode(0x40, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x41, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x42, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x43, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x44, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x45, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x46, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x47, (unsigned long) op_inc_reg); - asm_register_ia32_opcode(0x48, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x49, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4a, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4b, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4c, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4d, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4e, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x4f, (unsigned long) op_dec_reg); - asm_register_ia32_opcode(0x50, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x51, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x52, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x53, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x54, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x55, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x56, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x57, (unsigned long) op_push_reg); - asm_register_ia32_opcode(0x58, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x59, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5a, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5b, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5c, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5d, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5e, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x5f, (unsigned long) op_pop_reg); - asm_register_ia32_opcode(0x60, (unsigned long) op_pusha); - asm_register_ia32_opcode(0x61, (unsigned long) op_popa); - asm_register_ia32_opcode(0x62, (unsigned long) op_bound_gv_ma); - asm_register_ia32_opcode(0x63, (unsigned long) op_arpl_ew_rw); - asm_register_ia32_opcode(0x64, (unsigned long) op_prefix_fs); - asm_register_ia32_opcode(0x65, (unsigned long) op_prefix_gs); - asm_register_ia32_opcode(0x66, (unsigned long) op_opsize); - asm_register_ia32_opcode(0x67, (unsigned long) op_addsize); - asm_register_ia32_opcode(0x68, (unsigned long) op_push_iv); - asm_register_ia32_opcode(0x69, (unsigned long) op_imul_rv_rmv_iv); - asm_register_ia32_opcode(0x6a, (unsigned long) op_push_ib); - asm_register_ia32_opcode(0x6b, (unsigned long) op_imul_gv_ev_ib); - asm_register_ia32_opcode(0x6c, (unsigned long) op_insb); - asm_register_ia32_opcode(0x6d, (unsigned long) op_insw); - asm_register_ia32_opcode(0x6e, (unsigned long) op_outsb); - asm_register_ia32_opcode(0x6f, (unsigned long) op_outsw); - asm_register_ia32_opcode(0x70, (unsigned long) op_jo); - asm_register_ia32_opcode(0x71, (unsigned long) op_jno); - asm_register_ia32_opcode(0x72, (unsigned long) op_jb); - asm_register_ia32_opcode(0x73, (unsigned long) op_jae); - asm_register_ia32_opcode(0x74, (unsigned long) op_je); - asm_register_ia32_opcode(0x75, (unsigned long) op_jne); - asm_register_ia32_opcode(0x76, (unsigned long) op_jbe); - asm_register_ia32_opcode(0x77, (unsigned long) op_ja); - asm_register_ia32_opcode(0x78, (unsigned long) op_js); - asm_register_ia32_opcode(0x79, (unsigned long) op_jns); - asm_register_ia32_opcode(0x7a, (unsigned long) op_jp); - asm_register_ia32_opcode(0x7b, (unsigned long) op_jnp); - asm_register_ia32_opcode(0x7c, (unsigned long) op_jl); - asm_register_ia32_opcode(0x7d, (unsigned long) op_jge); - asm_register_ia32_opcode(0x7e, (unsigned long) op_jle); - asm_register_ia32_opcode(0x7f, (unsigned long) op_jg); - asm_register_ia32_opcode(0x80, (unsigned long) op_immed_rmb_ib); - asm_register_ia32_opcode(0x82, (unsigned long) op_immed_rmb_ib); - asm_register_ia32_opcode(0x81, (unsigned long) op_immed_rmv_iv); - asm_register_ia32_opcode(0x83, (unsigned long) op_immed_rmv_ib); - asm_register_ia32_opcode(0x84, (unsigned long) op_test_rmb_rb); - asm_register_ia32_opcode(0x85, (unsigned long) op_test_rmv_rv); - asm_register_ia32_opcode(0x86, (unsigned long) op_xchg_rmb_rb); - asm_register_ia32_opcode(0x87, (unsigned long) op_xchg_rmv_rv); - asm_register_ia32_opcode(0x88, (unsigned long) op_mov_rmb_rb); - asm_register_ia32_opcode(0x89, (unsigned long) op_mov_rmv_rv); - asm_register_ia32_opcode(0x8a, (unsigned long) op_mov_rb_rmb); - asm_register_ia32_opcode(0x8b, (unsigned long) op_mov_rv_rmv); - asm_register_ia32_opcode(0x8c, (unsigned long) op_mov_rm_segr); - asm_register_ia32_opcode(0x8d, (unsigned long) op_lea_rv_m); - asm_register_ia32_opcode(0x8e, (unsigned long) op_mov_segr_rm); - asm_register_ia32_opcode(0x8f, (unsigned long) op_pop_rmv); - asm_register_ia32_opcode(0x90, (unsigned long) op_nop); - asm_register_ia32_opcode(0x91, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x92, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x93, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x94, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x95, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x96, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x97, (unsigned long) op_xchg_eax_reg); - asm_register_ia32_opcode(0x98, (unsigned long) op_cwtl); - asm_register_ia32_opcode(0x99, (unsigned long) op_cltd); - asm_register_ia32_opcode(0x9b, (unsigned long) op_fwait); - asm_register_ia32_opcode(0x9c, (unsigned long) op_pushf); - asm_register_ia32_opcode(0x9d, (unsigned long) op_popf); - asm_register_ia32_opcode(0x9e, (unsigned long) op_sahf); - asm_register_ia32_opcode(0x9f, (unsigned long) op_lahf); - asm_register_ia32_opcode(0xa0, (unsigned long) op_mov_al_ref_iv); - asm_register_ia32_opcode(0xa1, (unsigned long) op_mov_eax_ref_iv); - asm_register_ia32_opcode(0xa2, (unsigned long) op_mov_ref_iv_al); - asm_register_ia32_opcode(0xa3, (unsigned long) op_mov_ref_iv_eax); - asm_register_ia32_opcode(0xa4, (unsigned long) op_movsb); - asm_register_ia32_opcode(0xa5, (unsigned long) op_movsd); - asm_register_ia32_opcode(0xa6, (unsigned long) op_cmpsb); - asm_register_ia32_opcode(0xa7, (unsigned long) op_cmpsd); - asm_register_ia32_opcode(0xa8, (unsigned long) op_test_al_rb); - asm_register_ia32_opcode(0xa9, (unsigned long) op_test_eax_iv); - asm_register_ia32_opcode(0xaa, (unsigned long) op_stosb); - asm_register_ia32_opcode(0xab, (unsigned long) op_stosd); - asm_register_ia32_opcode(0xac, (unsigned long) op_lodsb); - asm_register_ia32_opcode(0xad, (unsigned long) op_lodsd); - asm_register_ia32_opcode(0xae, (unsigned long) op_scasb); - asm_register_ia32_opcode(0xaf, (unsigned long) op_scasd); - asm_register_ia32_opcode(0xb0, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb1, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb2, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb3, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb4, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb5, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb6, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb7, (unsigned long) op_mov_subreg_ib); - asm_register_ia32_opcode(0xb8, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xb9, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xba, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xbb, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xbc, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xbd, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xbe, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xbf, (unsigned long) op_mov_reg_iv); - asm_register_ia32_opcode(0xc0, (unsigned long) op_shr_rmb_ib); - asm_register_ia32_opcode(0xc1, (unsigned long) op_shr_rmv_ib); - asm_register_ia32_opcode(0xc2, (unsigned long) op_ret_i2); - asm_register_ia32_opcode(0xc3, (unsigned long) op_ret); - asm_register_ia32_opcode(0xc4, (unsigned long) op_les_rm_rmp); - asm_register_ia32_opcode(0xc5, (unsigned long) op_lds_rm_rmp); - asm_register_ia32_opcode(0xc6, (unsigned long) op_mov_rmb_ib); - asm_register_ia32_opcode(0xc7, (unsigned long) op_mov_rmv_iv); - asm_register_ia32_opcode(0xc8, (unsigned long) op_enter); - asm_register_ia32_opcode(0xc9, (unsigned long) op_leave); - asm_register_ia32_opcode(0xca, (unsigned long) op_retf_i2); - asm_register_ia32_opcode(0xcb, (unsigned long) op_retf); - asm_register_ia32_opcode(0xcc, (unsigned long) op_int_3); - asm_register_ia32_opcode(0xcd, (unsigned long) op_int_ib); - asm_register_ia32_opcode(0xce, (unsigned long) op_into); - asm_register_ia32_opcode(0xcf, (unsigned long) op_iret); - asm_register_ia32_opcode(0xd0, (unsigned long) op_shift_rmb_1); - asm_register_ia32_opcode(0xd1, (unsigned long) op_shift_rmv_1); - asm_register_ia32_opcode(0xd2, (unsigned long) op_shift_rmb_cl); - asm_register_ia32_opcode(0xd3, (unsigned long) op_shift_rmv_cl); - asm_register_ia32_opcode(0xd4, (unsigned long) op_aam); - asm_register_ia32_opcode(0xd5, (unsigned long) op_aad); - asm_register_ia32_opcode(0xd7, (unsigned long) op_xlatb); - asm_register_ia32_opcode(0xd8, (unsigned long) op_esc0); - asm_register_ia32_opcode(0xd9, (unsigned long) op_esc1); - asm_register_ia32_opcode(0xda, (unsigned long) op_esc2); - asm_register_ia32_opcode(0xdb, (unsigned long) op_esc3); - asm_register_ia32_opcode(0xdc, (unsigned long) op_esc4); - asm_register_ia32_opcode(0xdd, (unsigned long) op_esc5); - asm_register_ia32_opcode(0xde, (unsigned long) op_esc6); - asm_register_ia32_opcode(0xdf, (unsigned long) op_esc7); - asm_register_ia32_opcode(0xe0, (unsigned long) op_loopne); - asm_register_ia32_opcode(0xe1, (unsigned long) op_loope); - asm_register_ia32_opcode(0xe2, (unsigned long) op_loop); - asm_register_ia32_opcode(0xe3, (unsigned long) op_je_cxz); - asm_register_ia32_opcode(0xe4, (unsigned long) op_in_al_ref_ib); - asm_register_ia32_opcode(0xe5, (unsigned long) op_in_eax_ref_ib); - asm_register_ia32_opcode(0xe6, (unsigned long) op_out_ref_ib_al); - asm_register_ia32_opcode(0xe7, (unsigned long) op_out_ref_ib_eax); - asm_register_ia32_opcode(0xe8, (unsigned long) op_call_iv); - asm_register_ia32_opcode(0xe9, (unsigned long) op_jmp_iv); - asm_register_ia32_opcode(0xea, (unsigned long) op_jmp_ap); - asm_register_ia32_opcode(0xeb, (unsigned long) op_jmp_ib); - asm_register_ia32_opcode(0xec, (unsigned long) op_in_al_dx); - asm_register_ia32_opcode(0xed, (unsigned long) op_in_eax_dx); - asm_register_ia32_opcode(0xee, (unsigned long) op_out_dx_al); - asm_register_ia32_opcode(0xef, (unsigned long) op_out_dx_eax); - asm_register_ia32_opcode(0xf0, (unsigned long) op_lock); - asm_register_ia32_opcode(0xf1, (unsigned long) op_lock); - asm_register_ia32_opcode(0xf2, (unsigned long) op_repnz); - asm_register_ia32_opcode(0xf3, (unsigned long) op_repz); - asm_register_ia32_opcode(0xf4, (unsigned long) op_hlt); - asm_register_ia32_opcode(0xf5, (unsigned long) op_cmc); - asm_register_ia32_opcode(0xf6, (unsigned long) op_unary_rmb); - asm_register_ia32_opcode(0xf7, (unsigned long) op_unary_rmv); - asm_register_ia32_opcode(0xf8, (unsigned long) op_clc); - asm_register_ia32_opcode(0xf9, (unsigned long) op_stc); - asm_register_ia32_opcode(0xfa, (unsigned long) op_cli); - asm_register_ia32_opcode(0xfb, (unsigned long) op_sti); - asm_register_ia32_opcode(0xfc, (unsigned long) op_cld); - asm_register_ia32_opcode(0xfd, (unsigned long) op_std); - asm_register_ia32_opcode(0xfe, (unsigned long) op_incdec_rmb); - asm_register_ia32_opcode(0xff, (unsigned long) op_indir_rmv); - - - asm_register_ia32_opcode(0x100 + 0x00, (unsigned long) op_group6); - asm_register_ia32_opcode(0x100 + 0x01, (unsigned long) op_group7); - asm_register_ia32_opcode(0x100 + 0x09, (unsigned long) i386_wbinvd); - asm_register_ia32_opcode(0x100 + 0x0b, (unsigned long) op_ud2a); - asm_register_ia32_opcode(0x100 + 0x20, (unsigned long) i386_mov_rm_cr); - asm_register_ia32_opcode(0x100 + 0x22, (unsigned long) i386_mov_cr_rm); - asm_register_ia32_opcode(0x100 + 0x23, (unsigned long) i386_mov_dr_rm); - asm_register_ia32_opcode(0x100 + 0x31, (unsigned long) i386_rdtsc); - asm_register_ia32_opcode(0x100 + 0x32, (unsigned long) i386_rdmsr); - asm_register_ia32_opcode(0x100 + 0x40, (unsigned long) i386_cmovo); - asm_register_ia32_opcode(0x100 + 0x41, (unsigned long) i386_cmovno); - asm_register_ia32_opcode(0x100 + 0x42, (unsigned long) i386_cmovb); - asm_register_ia32_opcode(0x100 + 0x43, (unsigned long) i386_cmovae); - asm_register_ia32_opcode(0x100 + 0x44, (unsigned long) i386_cmove); - asm_register_ia32_opcode(0x100 + 0x45, (unsigned long) i386_cmovne); - asm_register_ia32_opcode(0x100 + 0x46, (unsigned long) i386_cmovbe); - asm_register_ia32_opcode(0x100 + 0x47, (unsigned long) i386_cmova); - asm_register_ia32_opcode(0x100 + 0x48, (unsigned long) i386_cmovs); - asm_register_ia32_opcode(0x100 + 0x49, (unsigned long) i386_cmovns); - asm_register_ia32_opcode(0x100 + 0x4a, (unsigned long) i386_cmovp); - asm_register_ia32_opcode(0x100 + 0x4b, (unsigned long) i386_cmovnp); - asm_register_ia32_opcode(0x100 + 0x4c, (unsigned long) i386_cmovl); - asm_register_ia32_opcode(0x100 + 0x4d, (unsigned long) i386_cmovnl); - asm_register_ia32_opcode(0x100 + 0x4e, (unsigned long) i386_cmovle); - asm_register_ia32_opcode(0x100 + 0x4f, (unsigned long) i386_cmovnle); - asm_register_ia32_opcode(0x100 + 0x60, (unsigned long) i386_punpcklbw_pq_qd); - asm_register_ia32_opcode(0x100 + 0x67, (unsigned long) i386_packuswb_pq_qq); - asm_register_ia32_opcode(0x100 + 0x68, (unsigned long) i386_punpckhbw_pq_qq); - asm_register_ia32_opcode(0x100 + 0x6e, (unsigned long) i386_movd_pd_qd); - asm_register_ia32_opcode(0x100 + 0x6f, (unsigned long) i386_movq_pq_qq); - asm_register_ia32_opcode(0x100 + 0x71, (unsigned long) i386_group12); - asm_register_ia32_opcode(0x100 + 0x72, (unsigned long) i386_group14); - asm_register_ia32_opcode(0x100 + 0x73, (unsigned long) i386_group15); - asm_register_ia32_opcode(0x100 + 0x77, (unsigned long) i386_emms); - asm_register_ia32_opcode(0x100 + 0x7f, (unsigned long) i386_movq_qq_pq); - asm_register_ia32_opcode(0x100 + 0x82, (unsigned long) i386_jb); - asm_register_ia32_opcode(0x100 + 0x83, (unsigned long) i386_jae); - asm_register_ia32_opcode(0x100 + 0x84, (unsigned long) i386_je); - asm_register_ia32_opcode(0x100 + 0x85, (unsigned long) i386_jne); - asm_register_ia32_opcode(0x100 + 0x86, (unsigned long) i386_jbe); - asm_register_ia32_opcode(0x100 + 0x87, (unsigned long) i386_ja); - asm_register_ia32_opcode(0x100 + 0x88, (unsigned long) i386_js); - asm_register_ia32_opcode(0x100 + 0x89, (unsigned long) i386_jns); - asm_register_ia32_opcode(0x100 + 0x8a, (unsigned long) i386_jp); - asm_register_ia32_opcode(0x100 + 0x8b, (unsigned long) i386_jnp); - asm_register_ia32_opcode(0x100 + 0x8c, (unsigned long) i386_jl); - asm_register_ia32_opcode(0x100 + 0x8d, (unsigned long) i386_jge); - asm_register_ia32_opcode(0x100 + 0x8e, (unsigned long) i386_jle); - asm_register_ia32_opcode(0x100 + 0x8f, (unsigned long) i386_jg); - asm_register_ia32_opcode(0x100 + 0x90, (unsigned long) i386_jg); - asm_register_ia32_opcode(0x100 + 0x91, (unsigned long) op_setno_rmb); - asm_register_ia32_opcode(0x100 + 0x92, (unsigned long) op_setb_rmb); - asm_register_ia32_opcode(0x100 + 0x93, (unsigned long) op_setae_rmb); - asm_register_ia32_opcode(0x100 + 0x94, (unsigned long) op_sete_rmb); - asm_register_ia32_opcode(0x100 + 0x95, (unsigned long) op_setne_rmb); - asm_register_ia32_opcode(0x100 + 0x96, (unsigned long) op_setbe_rmb); - asm_register_ia32_opcode(0x100 + 0x97, (unsigned long) op_seta_rmb); - asm_register_ia32_opcode(0x100 + 0x98, (unsigned long) op_sets_rmb); - asm_register_ia32_opcode(0x100 + 0x99, (unsigned long) op_setns_rmb); - asm_register_ia32_opcode(0x100 + 0x9a, (unsigned long) op_setp_rmb); - asm_register_ia32_opcode(0x100 + 0x9b, (unsigned long) op_setnp_rmb); - asm_register_ia32_opcode(0x100 + 0x9c, (unsigned long) op_setl_rmb); - asm_register_ia32_opcode(0x100 + 0x9d, (unsigned long) op_setge_rmb); - asm_register_ia32_opcode(0x100 + 0x9e, (unsigned long) op_setle_rmb); - asm_register_ia32_opcode(0x100 + 0x9f, (unsigned long) op_setg_rmb); - asm_register_ia32_opcode(0x100 + 0xa0, (unsigned long) i386_push_fs); - asm_register_ia32_opcode(0x100 + 0xa1, (unsigned long) i386_pop_fs); - asm_register_ia32_opcode(0x100 + 0xa2, (unsigned long) i386_cpuid); - asm_register_ia32_opcode(0x100 + 0xa3, (unsigned long) i386_bt_rm_r); - asm_register_ia32_opcode(0x100 + 0xa4, (unsigned long) i386_shld); - asm_register_ia32_opcode(0x100 + 0xa5, (unsigned long) i386_shld_rmv_rv_cl); - asm_register_ia32_opcode(0x100 + 0xa7, (unsigned long) i386_xstorenrg); - asm_register_ia32_opcode(0x100 + 0xab, (unsigned long) i386_bts); - asm_register_ia32_opcode(0x100 + 0xac, (unsigned long) i386_shrd_rmv_rv_ib); - asm_register_ia32_opcode(0x100 + 0xad, (unsigned long) i386_shrd_rmv_rv_cl); - asm_register_ia32_opcode(0x100 + 0xae, (unsigned long) i386_group16); - asm_register_ia32_opcode(0x100 + 0xaf, (unsigned long) i386_imul_rv_rmv); - asm_register_ia32_opcode(0x100 + 0xb1, (unsigned long) op_cmp_xchg); - asm_register_ia32_opcode(0x100 + 0xb2, (unsigned long) op_lss_rv_rmv); - asm_register_ia32_opcode(0x100 + 0xb3, (unsigned long) op_btr_rmv_rv); - asm_register_ia32_opcode(0x100 + 0xb6, (unsigned long) i386_movzbl_rv_rmb); - asm_register_ia32_opcode(0x100 + 0xb7, (unsigned long) i386_movzwl_rv_rm2); - asm_register_ia32_opcode(0x100 + 0xba, (unsigned long) i386_btrl); - asm_register_ia32_opcode(0x100 + 0xbc, (unsigned long) i386_bsf); - asm_register_ia32_opcode(0x100 + 0xbd, (unsigned long) i386_bsr_rv_rmb); - asm_register_ia32_opcode(0x100 + 0xbe, (unsigned long) i386_movsbl_rv_rmb); - asm_register_ia32_opcode(0x100 + 0xbf, (unsigned long) i386_movswl_rv_rm2); - asm_register_ia32_opcode(0x100 + 0xc1, (unsigned long) i386_xadd); - asm_register_ia32_opcode(0x100 + 0xc8, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xc9, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xca, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xcb, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xcc, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xcd, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xce, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xcf, (unsigned long) i386_bswap); - asm_register_ia32_opcode(0x100 + 0xd5, (unsigned long) i386_pmullw_pq_qq); - asm_register_ia32_opcode(0x100 + 0xdb, (unsigned long) i386_pand_pq_qq); - asm_register_ia32_opcode(0x100 + 0xdc, (unsigned long) i386_paddusb_pq_qq); - asm_register_ia32_opcode(0x100 + 0xdd, (unsigned long) i386_paddusw_pq_qq); - asm_register_ia32_opcode(0x100 + 0xeb, (unsigned long) i386_por_pq_qq); - asm_register_ia32_opcode(0x100 + 0xef, (unsigned long) i386_pxor_pq_qq); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/tables_i386.c.svn-base eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/tables_i386.c.svn-base --- eresi-0.8a25/libasm/src/arch/ia32/.svn/text-base/tables_i386.c.svn-base 2008-04-06 23:16:24.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/.svn/text-base/tables_i386.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,311 +0,0 @@ -/** - * @file tables_i386.c - * @ingroup libasm_ia32 - * @brief Initialization of ia32 processor mnemonic table. - * $Id: tables_i386.c,v 1.15 2008/01/07 01:32:56 heroine Exp $ - * - */ -#include - -/** - * @brief Initialize ia32 mnemonic table. - * @param proc Pointer to processor structure. - * @return Returns 1 - */ -int init_instr_table(asm_processor *proc) -{ - - /** - * XXX: should be replaced by a static array ? - */ - - proc->instr_table = malloc(sizeof(char *) * (ASM_BAD + 1)); - memset(proc->instr_table, 0, sizeof(char *) * (ASM_BAD + 1)); - - proc->instr_table[ASM_ADC] = "adc"; - proc->instr_table[ASM_ADD] = "add"; - proc->instr_table[ASM_AND] = "and"; - proc->instr_table[ASM_AAM] = "aam"; - proc->instr_table[ASM_AAD] = "aad"; - proc->instr_table[ASM_AAA] = "aaa"; - proc->instr_table[ASM_AAS] = "aas"; - proc->instr_table[ASM_ARPL] = "arpl"; - - proc->instr_table[ASM_BOUND] = "bound"; - proc->instr_table[ASM_BSWAP] = "bswap"; - proc->instr_table[ASM_BTRL] = "btrl"; - - proc->instr_table[ASM_CMPSB] = "cmpsb"; - proc->instr_table[ASM_CMPSD] = "cmpsd"; - proc->instr_table[ASM_CALL] = "call"; - proc->instr_table[ASM_CMP] = "cmp"; - proc->instr_table[ASM_CWTL] = "cwtl"; - proc->instr_table[ASM_CWTD] = "cwtd"; - proc->instr_table[ASM_CBTW] = "cbtw"; - proc->instr_table[ASM_CLTD] = "cltd"; - proc->instr_table[ASM_CPUID] = "cpuid"; - proc->instr_table[ASM_CLD] = "cld"; - proc->instr_table[ASM_CLI] = "cli"; - proc->instr_table[ASM_CLC] = "clc"; - - proc->instr_table[ASM_DAA] = "daa"; - proc->instr_table[ASM_DAS] = "das"; - proc->instr_table[ASM_DIV] = "div"; - proc->instr_table[ASM_DEC] = "dec"; - - proc->instr_table[ASM_EMMS] = "emms"; - proc->instr_table[ASM_ENTER] = "enter"; - - proc->instr_table[ASM_FWAIT] = "fwait"; - - proc->instr_table[ASM_HLT] = "hlt"; - - proc->instr_table[ASM_INTO] = "into"; - proc->instr_table[ASM_IRET] = "iret"; - proc->instr_table[ASM_INT] = "int"; - proc->instr_table[ASM_INT3] = "int3"; - proc->instr_table[ASM_INT1] = "int1"; - proc->instr_table[ASM_IN] = "in"; - proc->instr_table[ASM_INSB] = "insb"; - proc->instr_table[ASM_INSW] = "insw"; - proc->instr_table[ASM_INSD] = "insd"; - proc->instr_table[ASM_INC] = "inc"; - proc->instr_table[ASM_IMUL] = "imul"; - proc->instr_table[ASM_IDIV] = "idiv"; - - proc->instr_table[ASM_BRANCH] = "jmp"; - proc->instr_table[ASM_BRANCH_U_LESS] = "jb"; - proc->instr_table[ASM_BRANCH_U_LESS_EQUAL] = "jbe"; - proc->instr_table[ASM_BRANCH_S_LESS] = "jl"; - proc->instr_table[ASM_BRANCH_S_LESS_EQUAL] = "jle"; - proc->instr_table[ASM_BRANCH_U_GREATER] = "ja"; - proc->instr_table[ASM_BRANCH_U_GREATER_EQUAL] = "jae"; - proc->instr_table[ASM_BRANCH_S_GREATER] = "jg"; - proc->instr_table[ASM_BRANCH_S_GREATER_EQUAL] = "jge"; - proc->instr_table[ASM_BRANCH_EQUAL] = "je"; - proc->instr_table[ASM_BRANCH_NOT_EQUAL] = "jne"; - proc->instr_table[ASM_BRANCH_PARITY] = "jp"; - proc->instr_table[ASM_BRANCH_NOT_PARITY] = "jnp"; - proc->instr_table[ASM_BRANCH_OVERFLOW] = "jo"; - proc->instr_table[ASM_BRANCH_NOT_OVERFLOW] = "jno"; - proc->instr_table[ASM_BRANCH_SIGNED] = "js"; - proc->instr_table[ASM_BRANCH_NOT_SIGNED] = "jns"; - proc->instr_table[ASM_BRANCH_CXZ] = "jecxz"; - - proc->instr_table[ASM_LEA] = "lea"; - proc->instr_table[ASM_LOAD] = "ld"; - proc->instr_table[ASM_LOCK] = "lock"; - proc->instr_table[ASM_LOOP] = "loop"; - proc->instr_table[ASM_LOOPE] = "loope"; - proc->instr_table[ASM_LOOPNE] = "loopne"; - proc->instr_table[ASM_LEAVE] = "leave"; - proc->instr_table[ASM_LAHF] = "lahf"; - proc->instr_table[ASM_LODSB] = "lodsb"; - proc->instr_table[ASM_LODSD] = "lodsd"; - proc->instr_table[ASM_LES] = "les"; - proc->instr_table[ASM_LDS] = "lds"; - proc->instr_table[ASM_LBRANCH] = "ljmp"; - - proc->instr_table[ASM_MOVSB] = "movsb"; - proc->instr_table[ASM_MOVSW] = "movsw"; - proc->instr_table[ASM_MOVSD] = "movsl"; - proc->instr_table[ASM_MOVSBL] = "movsbl"; - proc->instr_table[ASM_MOVSBW] = "movsbw"; - proc->instr_table[ASM_MOVSWL] = "movswl"; - proc->instr_table[ASM_MOVZWL] = "movzwl"; - proc->instr_table[ASM_MOVZBW] = "movzbw"; - proc->instr_table[ASM_MOVZBL] = "movzbl"; - proc->instr_table[ASM_MUL] = "mull"; - proc->instr_table[ASM_MOV] = "mov"; - proc->instr_table[ASM_MOVW] = "movw"; - proc->instr_table[ASM_MOVD] = "movd"; - proc->instr_table[ASM_MOVQ] = "movq"; - - proc->instr_table[ASM_NEG] = "neg"; - proc->instr_table[ASM_NOT] = "not"; - proc->instr_table[ASM_NOP] = "nop"; - - proc->instr_table[ASM_OR] = "or"; - proc->instr_table[ASM_ORB] = "orb"; - proc->instr_table[ASM_OUT] = "out"; - proc->instr_table[ASM_OUTSB] = "outsb"; - proc->instr_table[ASM_OUTSW] = "outsw"; - - proc->instr_table[ASM_PUSH] = "push"; - proc->instr_table[ASM_POP] = "pop"; - proc->instr_table[ASM_PUSHF] = "pushf"; - proc->instr_table[ASM_POPF] = "popf"; - proc->instr_table[ASM_PUSHA] = "pusha"; - proc->instr_table[ASM_POPA] = "popa"; - proc->instr_table[ASM_PAND] = "pand"; - proc->instr_table[ASM_POR] = "por"; - proc->instr_table[ASM_PXOR] = "pxor"; - proc->instr_table[ASM_PUNPCKLBW] = "punpcklbw"; - proc->instr_table[ASM_PUNPCKHBW] = "punpckhbw"; - proc->instr_table[ASM_PACKUSWB] = "packuswb"; - proc->instr_table[ASM_PSLLQ] = "psllq"; - proc->instr_table[ASM_PSRLQ] = "psrlq"; - proc->instr_table[ASM_PSRLW] = "psrlw"; - proc->instr_table[ASM_PSRAW] = "psraw"; - proc->instr_table[ASM_PSLLW] = "psllw"; - proc->instr_table[ASM_PMULLW] = "pmullw"; - proc->instr_table[ASM_PADDUSW] = "paddusw"; - proc->instr_table[ASM_PADDUSB] = "paddusb"; - - proc->instr_table[ASM_RET] = "ret"; - proc->instr_table[ASM_REPNZ] = "repnz"; - proc->instr_table[ASM_REPZ] = "repz"; - proc->instr_table[ASM_RCL] = "rcl"; - proc->instr_table[ASM_ROL] = "rol"; - proc->instr_table[ASM_ROR] = "ror"; - proc->instr_table[ASM_RCR] = "rcr"; - proc->instr_table[ASM_RETF] = "retf"; - proc->instr_table[ASM_RDMSR] = "rdmsr"; - - proc->instr_table[ASM_STORE] = "st"; - proc->instr_table[ASM_STI] = "sti"; - proc->instr_table[ASM_SUB] = "sub"; - proc->instr_table[ASM_SBB] = "sbb"; - proc->instr_table[ASM_SCASB] = "scas"; - proc->instr_table[ASM_SCASD] = "scasd"; - proc->instr_table[ASM_STOSB] = "stosb"; - proc->instr_table[ASM_STOSD] = "stos"; - proc->instr_table[ASM_SHR] = "shr"; - proc->instr_table[ASM_SAHF] = "sahf"; - proc->instr_table[ASM_SHIFT] = "shift"; - proc->instr_table[ASM_SAR] = "sar"; - proc->instr_table[ASM_STD] = "std"; - proc->instr_table[ASM_SHL] = "shl"; - proc->instr_table[ASM_SHRD] = "shrd"; - proc->instr_table[ASM_STC] = "stc"; - - proc->instr_table[ASM_TEST] = "test"; - - proc->instr_table[ASM_XADD] = "xadd"; - proc->instr_table[ASM_XOR] = "xor"; - proc->instr_table[ASM_XCHG] = "xchg"; - proc->instr_table[ASM_XLATB] = "xlatb"; - proc->instr_table[ASM_XSTORERNG] = "xstore-rng"; - proc->instr_table[ASM_XCRYPTCBC] = "xcrypt-cbc"; - proc->instr_table[ASM_XCRYPTCFB] = "xcrypt-cfb"; - proc->instr_table[ASM_XCRYPTOFB] = "xcrypt-ofb"; - - proc->instr_table[ASM_WBINVD] = "wbinvd"; - - /* i386 */ - - proc->instr_table[ASM_SET_U_LESS] = "setb"; - proc->instr_table[ASM_CMPXCHG] = "cmpxchg"; - proc->instr_table[ASM_RDTSC] = "rdtsc"; - proc->instr_table[ASM_BTR] = "btr"; - proc->instr_table[ASM_SET_U_LESS_EQUAL] = "setbe"; - proc->instr_table[ASM_SET_S_LESS] = "setl"; - proc->instr_table[ASM_SET_S_LESS_EQUAL] = "setle"; - proc->instr_table[ASM_SET_U_GREATER] = "seta"; - proc->instr_table[ASM_SET_U_GREATER_EQUAL] = "setae"; - proc->instr_table[ASM_SET_S_GREATER] = "setg"; - proc->instr_table[ASM_SET_S_GREATER_EQUAL] = "setge"; - proc->instr_table[ASM_SET_SIGNED] = "sets"; - proc->instr_table[ASM_SET_NOT_SIGNED] = "setns"; - proc->instr_table[ASM_SET_PARITY] = "setp"; - proc->instr_table[ASM_SET_NOT_PARITY] = "setnp"; - proc->instr_table[ASM_SET_OVERFLOW] = "seto"; - proc->instr_table[ASM_SET_NOT_OVERFLOW] = "setno"; - proc->instr_table[ASM_SET_EQUAL] = "sete"; - proc->instr_table[ASM_SET_NOT_EQUAL] = "setne"; - proc->instr_table[ASM_BT] = "bt"; - proc->instr_table[ASM_BTS] = "bts"; - proc->instr_table[ASM_SHLD] = "shld"; - proc->instr_table[ASM_CMC] = "cmc"; - proc->instr_table[ASM_BSR] = "bsr"; - proc->instr_table[ASM_CMOVNE] = "cmovne"; - proc->instr_table[ASM_CMOVA] = "cmova"; - proc->instr_table[ASM_CMOVAE] = "cmovae"; - proc->instr_table[ASM_CMOVE] = "cmove"; - proc->instr_table[ASM_CMOVO] = "cmovo"; - proc->instr_table[ASM_CMOVNO] = "cmovno"; - proc->instr_table[ASM_CMOVB] = "cmovb"; - proc->instr_table[ASM_CMOVBE] = "cmovbe"; - proc->instr_table[ASM_CMOVS] = "cmovs"; - proc->instr_table[ASM_CMOVNS] = "cmovns"; - proc->instr_table[ASM_CMOVP] = "cmovp"; - proc->instr_table[ASM_CMOVNP] = "cmovnp"; - proc->instr_table[ASM_CMOVL] = "cmovl"; - proc->instr_table[ASM_CMOVNL] = "cmovnl"; - proc->instr_table[ASM_CMOVLE] = "cmovle"; - proc->instr_table[ASM_CMOVNLE] = "cmovnle"; - proc->instr_table[ASM_LSS] = "lss"; - proc->instr_table[ASM_UD2A] = "ud2a"; - proc->instr_table[ASM_LGDT] = "lgdt"; - proc->instr_table[ASM_LIDT] = "lidt"; - proc->instr_table[ASM_SGDT] = "sgdtl"; - proc->instr_table[ASM_SIDT] = "sidt"; - proc->instr_table[ASM_STR] = "str"; - proc->instr_table[ASM_LTR] = "ltr"; - proc->instr_table[ASM_LLDT] = "lldt"; - proc->instr_table[ASM_STMXCSR] = "stmxcsr"; - proc->instr_table[ASM_LDMXCSR] = "ldmxcsr"; - proc->instr_table[ASM_BSF] = "bsf"; - - proc->instr_table[ASM_LFENCE] = "lfence"; - proc->instr_table[ASM_MFENCE] = "mfence"; - proc->instr_table[ASM_SFENCE] = "sfence"; - proc->instr_table[ASM_FXSAVE] = "fxsave"; - proc->instr_table[ASM_FXRSTORE] = "fxrstore"; - proc->instr_table[ASM_LDMXCSR] = "ldmxcsr"; - proc->instr_table[ASM_STMXCSR] = "stmxcsr"; - /* FPU */ - proc->instr_table[ASM_FILD] = "fild"; - proc->instr_table[ASM_FIMUL] = "fimul"; - proc->instr_table[ASM_FSTP] = "fstp"; - proc->instr_table[ASM_FSAVE] = "fsave"; - proc->instr_table[ASM_FNSAVE] = "fnsave"; - proc->instr_table[ASM_FCOM] = "fcom"; - proc->instr_table[ASM_FCOMP] = "fcomp"; - proc->instr_table[ASM_FCOMPP] = "fcompp"; - proc->instr_table[ASM_FLD] = "fldt"; - proc->instr_table[ASM_FLDZ] = "fldz"; - proc->instr_table[ASM_FADD] = "fadd"; - proc->instr_table[ASM_FIADD] = "fiadd"; - proc->instr_table[ASM_FABS] = "fabs"; - proc->instr_table[ASM_FADDP] = "faddp"; - proc->instr_table[ASM_FLD] = "fld"; - proc->instr_table[ASM_FCOM] = "fcom"; - proc->instr_table[ASM_FDIV] = "fdiv"; - proc->instr_table[ASM_FDIVR] = "fdivr"; - proc->instr_table[ASM_FDIVP] = "fdivp"; - proc->instr_table[ASM_FDIVRP] = "fdivrp"; - proc->instr_table[ASM_FXCH] = "fxch"; - proc->instr_table[ASM_FINIT] = "finit"; - proc->instr_table[ASM_FICOMP] = "ficomp"; - proc->instr_table[ASM_FIDIV] = "fidiv"; - proc->instr_table[ASM_FIDIVR] = "fidivr"; - proc->instr_table[ASM_FLD1] = "fld1"; - proc->instr_table[ASM_FLDCW] = "fldcw"; - proc->instr_table[ASM_FCHS] = "fchs"; - proc->instr_table[ASM_FST] = "fst"; - proc->instr_table[ASM_FISUB] = "fisub"; - proc->instr_table[ASM_FISUBR] = "fisubr"; - proc->instr_table[ASM_FIST] = "fist"; - proc->instr_table[ASM_FISTP] = "fistp"; - proc->instr_table[ASM_FMUL] = "fmul"; - proc->instr_table[ASM_FMULP] = "fmulp"; - proc->instr_table[ASM_FSUB] = "fsub"; - proc->instr_table[ASM_FSUBR] = "fsubr"; - proc->instr_table[ASM_FSUBP] = "fsubp"; - proc->instr_table[ASM_FSUBRP] = "fsubrp"; - proc->instr_table[ASM_FUCOM] = "fucom"; - proc->instr_table[ASM_FUCOMP] = "fucomp"; - proc->instr_table[ASM_FUCOMPP] = "fucompp"; - proc->instr_table[ASM_FSTSW] = "fstsw"; - proc->instr_table[ASM_FNSTSW] = "fnstsw"; - proc->instr_table[ASM_FPREM] = "fprem"; - proc->instr_table[ASM_FSCALE] = "fscale"; - proc->instr_table[ASM_FSQRT] = "fsqrt"; - proc->instr_table[ASM_FNSTCW] = "fnstcw"; - proc->instr_table[ASM_FSTCW] = "fstcw"; - proc->instr_table[ASM_FRNDINT] = "frndint"; - proc->instr_table[ASM_FPATAN] = "fpatan"; - proc->instr_table[ASM_BAD] = "(bad)"; - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/ia32/tables_i386.c eresi-0.0.20110516/libasm/src/arch/ia32/tables_i386.c --- eresi-0.8a25/libasm/src/arch/ia32/tables_i386.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/ia32/tables_i386.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,8 +1,8 @@ /** - * @file tables_i386.c - * @ingroup libasm_ia32 +* @file libasm/src/arch/ia32/tables_i386.c + * @ingroup ia32 * @brief Initialization of ia32 processor mnemonic table. - * $Id: tables_i386.c,v 1.15 2008/01/07 01:32:56 heroine Exp $ + * $Id: tables_i386.c 1397 2009-09-13 02:19:08Z may $ * */ #include diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_abs_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_abs_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ABS_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_abs_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_abs_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ABS_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_abs_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_abs_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_abs_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_abs_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ABS_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_add.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: Integer overflow */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_add_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_add_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ADD_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addi.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addi.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_addi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: Integer Overflow */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addiu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addiu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addiu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addiu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_addiu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptione: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_add_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_add_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ADD_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_add_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_add_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_add_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_add_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ADD_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_addu.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_addu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_addu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -25,5 +29,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_and.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_and.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_and.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_and.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_and.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_andi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_andi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_andi.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_andi.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_andi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bal.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bal.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bal.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bal.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bal.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BAL; - ins->type = /* ASM_TYPE_IMPBRANCH */ ASM_TYPE_CALLPROC; + ins->type = /* ASM_TYPE_BRANCH */ ASM_TYPE_CALLPROC; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_b.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_b.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_b.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_b.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_b.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_B; - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1f.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1f.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1f.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1f.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,25 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc1f.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_bc1f(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_BC1F; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; + mips_convert_format_i(&temp, buf); + ins->op[0].imm = temp.im; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1fl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1fl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1fl.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1fl.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,25 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc1fl.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_bc1fl(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_BC1FL; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; + mips_convert_format_i(&temp, buf); + ins->op[0].imm = temp.im; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1t.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1t.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1t.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1t.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,25 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc1t.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_bc1t(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_BC1T; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; + mips_convert_format_i(&temp, buf); + ins->op[0].imm = temp.im; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1tl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1tl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc1tl.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc1tl.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,25 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc1tl.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_bc1tl(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_BC1TL; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; + mips_convert_format_i(&temp, buf); + ins->op[0].imm = temp.im; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2f.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2f.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2f.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2f.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc2f.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BC2F; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2fl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2fl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2fl.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2fl.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc2fl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BC2FL; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2t.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2t.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2t.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2t.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc2t.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BC2T; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2tl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2tl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bc2tl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bc2tl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bc2tl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BC2TL; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].imm = temp.im; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_beq.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_beq.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_beq.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_beq.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_beq.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,7 +22,7 @@ break; default: ins->instr = ASM_MIPS_BEQ; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -31,5 +35,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_beql.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_beql.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_beql.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_beql.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_beql.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BEQL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezal.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezal.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezal.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezal.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgezal.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGEZAL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; + ins->type = ASM_TYPE_CONDCONTROL | ASM_TYPE_CALLPROC; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezall.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezall.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezall.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezall.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgezall.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGEZALL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; + ins->type = ASM_TYPE_CONDCONTROL | ASM_TYPE_CALLPROC; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgez.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgez.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgez.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgez.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgez.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGEZ; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgezl.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgezl.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgezl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGEZL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgtz.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgtz.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgtz.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgtz.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgtz.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGTZ; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgtzl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgtzl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bgtzl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bgtzl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bgtzl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BGTZL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_blez.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_blez.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_blez.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_blez.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_blez.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLEZ; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_blezl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_blezl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_blezl.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_blezl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_blezl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLEZL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzal.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzal.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzal.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzal.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bltzal.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLTZAL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; + ins->type = ASM_TYPE_CONDCONTROL | ASM_TYPE_CALLPROC; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzall.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzall.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzall.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzall.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bltzall.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLTZALL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; + ins->type = ASM_TYPE_CONDCONTROL | ASM_TYPE_CALLPROC; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltz.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltz.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltz.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltz.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bltz.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLTZ; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bltzl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bltzl.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bltzl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BLTZL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bne.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bne.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bne.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bne.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bne.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BNE; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bnel.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bnel.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_bnel.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_bnel.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_bnel.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_BNEL; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_break.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_break.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_break.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_break.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_break.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -12,5 +16,5 @@ /* Exceptions: Breakpoint */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ceil_l_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CEIL_L_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ceil_l_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CEIL_L_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ceil_w_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CEIL_W_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ceil_w_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CEIL_W_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_eq_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_EQ_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_eq_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_EQ_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_eq_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_EQ_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cfc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cfc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cfc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cfc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,26 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cfc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cfc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_CFC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cfc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cfc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cfc2.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cfc2.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cfc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_CFC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp,buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_f_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_f_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_F_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_f_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_F_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_f_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_f_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_f_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_f_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_F_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_le_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_le_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LE_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_le_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LE_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_le_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_le_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_le_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_le_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LE_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_clo.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_clo.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_clo.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_clo.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_clo.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exception: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_lt_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LT_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_lt_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LT_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_lt_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_LT_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_clz.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_clz.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_clz.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_clz.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_clz.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_nge_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGE_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_nge_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGE_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_nge_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGE_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngl_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGL_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngle_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGLE_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngle_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGLE_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngle_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGLE_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngl_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGL_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngl_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGL_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngt_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGT_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngt_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGT_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ngt_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_NGT_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ole_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLE_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ole_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLE_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ole_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLE_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_olt_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLT_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_olt_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLT_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_olt_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_OLT_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cop2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cop2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cop2.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cop2.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cop2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,5 +15,5 @@ /* Exceptions: Coprocessor Unusable, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_seq_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SEQ_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_seq_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SEQ_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_seq_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SEQ_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_sf_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SF_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_sf_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SF_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_sf_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_SF_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ctc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ctc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ctc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ctc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ctc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ctc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_CTC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Division-by-zero, Inexact, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ctc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ctc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ctc2.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ctc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ctc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_CTC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp,buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -17,6 +21,7 @@ asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); /* Exceptions: Coprocessor Unusable, Reserved instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Division-by-zero, Inexact, Overflow, Underflow */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ueq_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UEQ_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ueq_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UEQ_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ueq_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UEQ_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ule_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULE_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ule_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULE_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ule_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULE_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ult_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULT_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ult_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULT_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_ult_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_ULT_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_un_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_un_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UN_D; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_un_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UN_PS; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_c_un_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_c_un_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,27 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_c_un_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_c_un_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_C_UN_S; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_d_l(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_D_L; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_d_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_D_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_d_w(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_D_W; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_l_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_L_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_l_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_L_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_ps_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_PS_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_s_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_S_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_s_l(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_S_L; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_s_pl(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_S_PL; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_s_pu(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_S_PU; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_s_w(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_S_W; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_w_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_W_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_cvt_w_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_CVT_W_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dadd.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dadd.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dadd.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dadd.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dadd.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: Integer overflow, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddi.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddi.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_daddi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Integer overflow, Reserved instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddiu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddiu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddiu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddiu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_daddiu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_daddu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_daddu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_daddu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dclo.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dclo.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dclo.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dclo.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dclo.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dclz.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dclz.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dclz.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dclz.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dclz.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ddiv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ddiv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ddiv.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ddiv.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ddiv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ddivu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ddivu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ddivu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ddivu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ddivu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_deret.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_deret.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_deret.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_deret.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_deret.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* DERET */ + +int asm_mips_deret(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_DERET; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_RETPROC; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_div.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_div_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_div_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_DIV_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_div_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_div_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_div_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_div_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_DIV_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_divu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_divu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_divu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_divu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_divu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc0.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc0.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc0.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc0.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,30 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmfc0.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* DMFC0 rt,rd,sl */ + +int asm_mips_dmfc0(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_DMFC0; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].imm = temp.sl; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,26 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmfc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_dmfc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_DMFC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmfc2.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmfc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmfc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_DMFC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp,buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc0.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc0.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc0.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc0.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,30 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmtc0.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* DMTC0 rt,rd,sl */ + +int asm_mips_dmtc0(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_DMTC0; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].imm = temp.sl; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,26 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmtc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_dmtc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_cop2 temp; + + ins->instr = ASM_MIPS_DMTC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_cop2(&temp,buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmtc2.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmtc2.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmtc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_DMTC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp,buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmult.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmult.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmult.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmult.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmult.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmultu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmultu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dmultu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dmultu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dmultu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsll32.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsll32.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsll32.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsll32.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsll32.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsll.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsll.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsll.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsll.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsll.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsllv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsllv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsllv.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsllv.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsllv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsra32.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsra32.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsra32.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsra32.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsra32.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsra.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsra.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsra.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsra.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsra.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrav.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrav.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrav.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrav.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsrav.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrl32.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrl32.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrl32.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrl32.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsrl32.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsrl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrlv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrlv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsrlv.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsrlv.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsrlv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsub.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsub.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsub.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsub.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsub.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Integer Overflow, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsubu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsubu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_dsubu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_dsubu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_dsubu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ehb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ehb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ehb.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ehb.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ehb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_BAD; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_eret.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_eret.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_eret.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_eret.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_eret.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* ERET */ + +int asm_mips_eret(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_ERET; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_RETPROC; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ext.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ext.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ext.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ext.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ext.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_EXT; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_floor_l_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_FLOOR_L_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_floor_l_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_FLOOR_L_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_floor_w_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_FLOOR_W_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_floor_w_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_FLOOR_W_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ins.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ins.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ins.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ins.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ins.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_INS; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jal.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jal.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jal.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jal.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_jal.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -16,5 +20,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jalr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jalr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jalr.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jalr.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_jalr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -16,5 +20,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -10,5 +14,5 @@ // asm_mips_operand_r(&ins->op[0], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); asm_mips_jalr(ins, buf, len, proc); - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_j.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_j.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_j.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_j.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_j.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_jump temp; ins->instr = ASM_MIPS_J; - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; mips_convert_format_j(&temp,buf); ins->op[0].imm = temp.ta; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_JUMP, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jr.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jr.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_jr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,16 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_JR; - ins->type = ASM_TYPE_IMPBRANCH; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + if (temp.rs == ASM_MIPS_REG_RA) + ins->type = ASM_TYPE_RETPROC; + else + ins->type = ASM_TYPE_BRANCH; + /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jr.hb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jr.hb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_jr.hb.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_jr.hb.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_jr.hb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -10,5 +14,5 @@ // asm_mips_operand_r(&ins->op[0], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); asm_mips_jr(ins, buf, len, proc); - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lb.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lb.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lbu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lbu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lbu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lbu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lbu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ld.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ld.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ld.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ld.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ld.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ldc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_ldc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_LDC1; + ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; + mips_convert_format_i(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].imm = temp.im; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + ins->op[2].baser = temp.rs; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, Address Error */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldc2.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ldc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldl.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ldl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldr.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldr.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ldr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ldxc1.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ldxc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ldxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lh.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lh.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lh.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lh.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lh.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lhu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lhu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lhu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lhu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lhu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ll.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ll.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ll.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ll.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ll.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lld.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lld.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lld.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lld.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lld.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lui.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lui.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lui.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lui.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lui.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -18,5 +22,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_luxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_luxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_luxc1.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_luxc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_luxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, TLB Modified, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lw.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lw.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lw.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lw.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lw.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_lwc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_LWC1; + ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; + mips_convert_format_i(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].imm = temp.im; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + ins->op[2].baser = temp.rs; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); + + /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwc2.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwl.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None / TLB Refill, TLB Invalid, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwr.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwr.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_LWR; - ins->type = ASM_TYPE_LOAD; + ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_LWU; - ins->type = ASM_TYPE_LOAD; + ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_lwxc1.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_lwxc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_lwxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_madd.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_d.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_madd_d.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_ps.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_madd_ps.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_madd_s.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_madd_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_madd_s.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_maddu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_maddu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_maddu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_maddu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_maddu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc0.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc0.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc0.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc0.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mfc0.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* MFC0 rt,rd */ + +int asm_mips_mfc0(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_MFC0; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mfc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* MFC1 rt,rd */ + +int asm_mips_mfc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_MFC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfc2.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mfc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_MFC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp, buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Coprocesor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfhi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfhi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mfhi.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mfhi.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mfhi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MFHI; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mflo.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mflo.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mflo.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mflo.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mflo.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MFLO; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,37 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movcf_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movcf_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + u_int converted = 0; + + memcpy((char *)&converted,buf,sizeof(converted)); + + if ((converted >> 16) & 0x1) + ins->instr = ASM_MIPS_MOVT_D; + else + ins->instr = ASM_MIPS_MOVF_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].imm = temp.rt >> 2; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,37 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movcf_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + u_int converted = 0; + + memcpy((char *)&converted,buf,sizeof(converted)); + + if ((converted >> 16) & 0x1) + ins->instr = ASM_MIPS_MOVT_PS; + else + ins->instr = ASM_MIPS_MOVF_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].imm = temp.rt >> 2; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movcf_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movcf_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,37 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movcf_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movcf_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + u_int converted = 0; + + memcpy((char *)&converted,buf,sizeof(converted)); + + if ((converted >> 16) & 0x1) + ins->instr = ASM_MIPS_MOVT_S; + else + ins->instr = ASM_MIPS_MOVF_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].imm = temp.rt >> 2; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mov_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mov_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOV_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movf.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movf.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movf.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movf.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movf.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_mov temp; ins->instr = ASM_MIPS_MOVF; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_mov(&temp,buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movn.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MOVN; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movn_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movn_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVN_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movn_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movn_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVN_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movn_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movn_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movn_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movn_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVN_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mov_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mov_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOV_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mov_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mov_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mov_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mov_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOV_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movt.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movt.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movt.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movt.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movt.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_mov temp; ins->instr = ASM_MIPS_MOVT; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_mov(&temp,buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movz.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MOVZ; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rd; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movz_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movz_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVZ_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movz_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movz_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVZ_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_movz_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_movz_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,31 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_movz_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_movz_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MOVZ_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_msub.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_d.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_msub_d.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_ps.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_msub_ps.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msub_s.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msub_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_msub_s.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msubu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msubu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_msubu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_msubu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_msubu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc0.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc0.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc0.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc0.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mtc0.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* MTC0 rt,rd */ + +int asm_mips_mtc0(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_MTC0; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mtc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* MTC1 rt,rd */ + +int asm_mips_mtc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_priv temp; + + ins->instr = ASM_MIPS_MTC1; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; + mips_convert_format_priv(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtc2.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtc2.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mtc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop2 temp; ins->instr = ASM_MIPS_MTC2; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_cop2(&temp,buf); ins->op[0].baser = temp.rt; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mthi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mthi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mthi.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mthi.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mthi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MTHI; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtlo.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtlo.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mtlo.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mtlo.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mtlo.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,12 +13,12 @@ struct s_mips_decode_reg temp; ins->instr = ASM_MIPS_MTLO; - ins->type = ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_ASSIGN; mips_convert_format_r(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mul.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mul_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mul_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MUL_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mul_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mul_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MUL_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mul_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mul_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mul_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_mul_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_MUL_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mult.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mult.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_mult.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_mult.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_mult.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_multu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_multu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_multu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_multu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_multu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_neg_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_neg_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_NEG_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_neg_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_neg_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_NEG_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_neg_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_neg_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_neg_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_neg_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_NEG_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -26,5 +30,5 @@ /* Exception: Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nop.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nop.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nop.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nop.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nop.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -12,5 +16,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nor.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nor.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_nor.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_nor.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_nor.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_or.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_or.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_or.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_or.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_or.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ori.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ori.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ori.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ori.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ori.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_pref.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_pref.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_pref.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_pref.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_pref.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None :) */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_prefx.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_prefx.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_prefx.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_prefx.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_prefx.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_cop1x temp; ins->instr = ASM_MIPS_PREFX; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; + ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_ARCH; mips_convert_format_cop1x(&temp, buf); ins->op[0].baser = temp.f1; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rdhwr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rdhwr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rdhwr.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rdhwr.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_rdhwr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_RDHWR; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_recip_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_recip_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_recip_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_recip_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_recip_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_recip_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_RECIP_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_recip_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_recip_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_recip_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_recip_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_recip_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_recip_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_RECIP_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rotr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rotr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rotr.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rotr.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_rotr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_ROTR; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rotrv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rotrv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rotrv.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rotrv.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_rotrv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_ROTRV; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_l_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_l_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_l_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_l_d.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_round_l_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_round_l_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ROUND_L_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_l_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_l_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_l_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_l_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_round_l_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_round_l_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ROUND_L_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_w_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_w_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_w_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_w_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_round_w_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_round_w_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ROUND_W_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_w_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_w_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_round_w_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_round_w_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_round_w_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_round_w_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_ROUND_W_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_rsqrt_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_RSQRT_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_rsqrt_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_RSQRT_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Division-by-zero, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sb.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sb.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sc.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sc.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sc.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sc.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sc.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_scd.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_scd.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_scd.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_scd.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_scd.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdbbp.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdbbp.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdbbp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdbbp.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,26 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdbbp.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* SDBBP code */ + +int asm_mips_sdbbp(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_jump temp; + + ins->instr = ASM_MIPS_SDBBP; + ins->type = ASM_TYPE_ARCH; + mips_convert_format_j(&temp,buf); + ins->op[0].imm = (temp.ta >> 6) & 0xFFFFF; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_JUMP, ins); + + /* Exceptions: Debug Breakpoint Exception */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sd.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sd.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sd.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sd.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sd.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sdc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_SDC1; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; + mips_convert_format_i(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].imm = temp.im; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + ins->op[2].baser = temp.rs; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdc2.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdl.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdl.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdr.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdr.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error, Reserved Instruction */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sdxc1.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sdxc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sdxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_seb.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_seb.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_seb.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_seb.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_seb.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_SEB; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_seh.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_seh.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_seh.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_seh.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_seh.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_SEH; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sh.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sh.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sh.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sh.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sh.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sll.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sll.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sll.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sll.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sll.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -34,5 +38,5 @@ break; } - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sllv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sllv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sllv.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sllv.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sllv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_slt.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_slt.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_slt.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_slt.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_slt.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_slti.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_slti.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_slti.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_slti.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_slti.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sltiu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sltiu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sltiu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sltiu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sltiu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sltu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sltu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sltu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sltu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sltu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sqrt_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_SQRT_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sqrt_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_SQRT_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sra.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sra.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sra.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sra.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sra.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srav.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srav.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srav.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srav.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_srav.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_srl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srlv.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srlv.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_srlv.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_srlv.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_srlv.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ssnop.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ssnop.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_ssnop.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_ssnop.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_ssnop.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -12,5 +16,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sub.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: Integer Overflow */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sub_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sub_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_SUB_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_ps.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_ps.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_ps.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_ps.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sub_ps.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sub_ps(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_SUB_PS; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sub_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sub_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,32 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sub_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_sub_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_SUB_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[2].regset = ASM_MIPS_REG_FPU; + ins->op[2].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow, Underflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_subu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_subu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_subu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_subu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_subu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_suxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_suxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_suxc1.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_suxc1.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_suxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, TLB Modified, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sw.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sw.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sw.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sw.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sw.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swc1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_swc1.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_swc1(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_imm temp; + + ins->instr = ASM_MIPS_SWC1; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; + mips_convert_format_i(&temp, buf); + ins->op[0].baser = temp.rt; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].imm = temp.im; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); + ins->op[2].baser = temp.rs; + asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); + + /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swc2.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swc2.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swc2.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swc2.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_swc2.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swl.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swl.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swl.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swl.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_swl.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swr.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swr.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_swr.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swxc1.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swxc1.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_swxc1.c 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_swxc1.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_swxc1.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -21,5 +25,5 @@ /* Exception: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction, Coprocessor Unusable */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sync.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sync.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_sync.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_sync.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_sync.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -12,5 +16,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_synci.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_synci.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_synci.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_synci.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_synci.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_SYNCI; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_syscall.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_syscall.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_syscall.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_syscall.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_syscall.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -12,5 +16,5 @@ /* Exceptions: System Call */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_teq.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_teq.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_teq.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_teq.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_teq.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TEQ; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_teqi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_teqi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_teqi.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_teqi.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_teqi.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TEQI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tge.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tge.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tge.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tge.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tge.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TGE; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgei.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgei.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgei.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgei.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tgei.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TGEI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgeiu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgeiu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgeiu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgeiu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tgeiu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TGEIU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgeu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgeu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tgeu.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tgeu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tgeu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TGEU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbp.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbp.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbp.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlbp.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* TLBP */ + +int asm_mips_tlbp(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_TLBP; + ins->type = ASM_TYPE_ARCH; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbr.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlbr.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* TLBR */ + +int asm_mips_tlbr(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_TLBR; + ins->type = ASM_TYPE_ARCH; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbwi.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbwi.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbwi.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbwi.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlbwi.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* TLBWI */ + +int asm_mips_tlbwi(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_TLBWI; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONTROL; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbwr.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbwr.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlbwr.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlbwr.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlbwr.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* TLBWR */ + +int asm_mips_tlbwr(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_TLBWR; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONTROL; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlt.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlt.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlt.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlt.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlt.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TLT; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlti.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlti.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tlti.c 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tlti.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tlti.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TLTI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tltiu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tltiu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tltiu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tltiu.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tltiu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TLTIU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tltu.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tltu.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tltu.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tltu.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tltu.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TLTU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tne.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tne.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tne.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tne.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tne.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -11,7 +15,7 @@ struct s_mips_decode_trap temp; ins->instr = ASM_MIPS_TNE; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_t(&temp,buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -20,5 +24,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tnei.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tnei.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_tnei.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_tnei.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_tnei.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -9,7 +13,7 @@ struct s_mips_decode_imm temp; ins->instr = ASM_MIPS_TNEI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; + ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON | ASM_TYPE_INT; mips_convert_format_i(&temp, buf); ins->op[0].baser = temp.rs; asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); @@ -18,5 +22,5 @@ /* Exceptions: Trap */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_trunc_l_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_TRUNC_L_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_trunc_l_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_TRUNC_L_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c 2011-05-16 11:34:27.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_trunc_w_d(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_TRUNC_W_D; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,29 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +int asm_mips_trunc_w_s(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + struct s_mips_decode_reg temp; + + ins->instr = ASM_MIPS_TRUNC_W_S; + ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; + mips_convert_format_r(&temp, buf); + ins->op[0].regset = ASM_MIPS_REG_FPU; + ins->op[0].baser = temp.sa; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); + ins->op[1].regset = ASM_MIPS_REG_FPU; + ins->op[1].baser = temp.rd; + asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); + + /* Exception: Reserved Instruction, Coprocessor Unusable */ + /* FPU Exceptions: Inexact, Unimplemented Operation, Invalid Operation, Overflow */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_wait.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_wait.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_wait.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_wait.c 2011-05-16 11:34:28.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_wait.c +** @ingroup MIPS_instrs +*/ +/* Adam 'pi3' Zabrocki */ +/* Manuel Martin - 2007 */ + +#include + +/* WAIT */ + +int asm_mips_wait(asm_instr *ins, u_char *buf, u_int len, + asm_processor *proc) +{ + ins->instr = ASM_MIPS_WAIT; + ins->type = ASM_TYPE_ARCH; + asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); + + /* Exceptions: Coprocessor Unusable */ + + return 4; +} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_wsbh.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_wsbh.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_wsbh.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_wsbh.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_wsbh.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -7,5 +11,5 @@ asm_processor *proc) { ins->instr = ASM_MIPS_WSBH; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_xor.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_xor.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_xor.c 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_xor.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_xor.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -22,5 +26,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_xori.c eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_xori.c --- eresi-0.8a25/libasm/src/arch/mips/handlers/asm_mips_xori.c 2008-04-06 23:15:58.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/asm_mips_xori.c 2011-05-16 11:34:27.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/handlers/asm_mips_xori.c +** @ingroup MIPS_instrs +*/ /* Adam 'pi3' Zabrocki */ /* Manuel Martin - 2007 */ @@ -20,5 +24,5 @@ /* Exceptions: None */ - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/all-wcprops 2008-04-06 23:16:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,1073 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers -END -asm_mips_sd.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sd.c -END -asm_mips_sh.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sh.c -END -asm_mips_syscall.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_syscall.c -END -asm_mips_bltz.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bltz.c -END -asm_mips_andi.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_andi.c -END -asm_mips_swr.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_swr.c -END -asm_mips_tlti.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tlti.c -END -asm_mips_clo.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_clo.c -END -asm_mips_addu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_addu.c -END -asm_mips_or.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_or.c -END -asm_mips_bgezall.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgezall.c -END -asm_mips_sdxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_sdxc1.c -END -asm_mips_mfhi.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mfhi.c -END -asm_mips_dsllv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsllv.c -END -asm_mips_nmsub_ps.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c -END -asm_mips_nmadd_d.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c -END -asm_mips_ddiv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ddiv.c -END -asm_mips_tltu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tltu.c -END -asm_mips_dsrlv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsrlv.c -END -asm_mips_dadd.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dadd.c -END -asm_mips_pref.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_pref.c -END -asm_mips_dsub.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsub.c -END -asm_mips_mflo.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mflo.c -END -asm_mips_mthi.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mthi.c -END -asm_mips_jr.hb.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_jr.hb.c -END -asm_mips_nmsub_s.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c -END -asm_mips_lwc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lwc2.c -END -asm_mips_movf.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_movf.c -END -asm_mips_seb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_seb.c -END -asm_mips_jr.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_jr.c -END -asm_mips_mtlo.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mtlo.c -END -asm_mips_sync.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_sync.c -END -asm_mips_subu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_subu.c -END -asm_mips_movn.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_movn.c -END -asm_mips_tge.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tge.c -END -asm_mips_lw.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lw.c -END -asm_mips_div.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_div.c -END -asm_mips_prefx.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_prefx.c -END -asm_mips_mfc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mfc2.c -END -asm_mips_bltzal.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bltzal.c -END -asm_mips_add.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_add.c -END -asm_mips_sub.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sub.c -END -asm_mips_maddu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_maddu.c -END -asm_mips_movz.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_movz.c -END -asm_mips_dsll.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsll.c -END -asm_mips_dsra32.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsra32.c -END -asm_mips_ehb.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/asm_mips_ehb.c -END -asm_mips_bgezl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgezl.c -END -asm_mips_mtc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mtc2.c -END -asm_mips_lwu.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lwu.c -END -asm_mips_divu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_divu.c -END -asm_mips_jalr.hb.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c -END -asm_mips_ldr.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ldr.c -END -asm_mips_xori.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_xori.c -END -asm_mips_lbu.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lbu.c -END -asm_mips_sdl.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sdl.c -END -asm_mips_dmult.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dmult.c -END -asm_mips_rdhwr.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_rdhwr.c -END -asm_mips_nmsub_d.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c -END -asm_mips_sll.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sll.c -END -asm_mips_msubu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_msubu.c -END -asm_mips_blez.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_blez.c -END -asm_mips_ld.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ld.c -END -asm_mips_tnei.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tnei.c -END -asm_mips_tltiu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tltiu.c -END -asm_mips_teqi.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_teqi.c -END -asm_mips_slt.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_slt.c -END -asm_mips_wsbh.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_wsbh.c -END -asm_mips_cop2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/889/trunk/libasm/src/arch/mips/handlers/asm_mips_cop2.c -END -asm_mips_lh.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lh.c -END -asm_mips_daddi.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_daddi.c -END -asm_mips_beq.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_beq.c -END -asm_mips_ll.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ll.c -END -asm_mips_blezl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_blezl.c -END -asm_mips_slti.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_slti.c -END -asm_mips_bc2f.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bc2f.c -END -asm_mips_rotrv.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_rotrv.c -END -asm_mips_daddu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_daddu.c -END -asm_mips_break.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_break.c -END -asm_mips_synci.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_synci.c -END -asm_mips_sltu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sltu.c -END -asm_mips_madd_s.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_madd_s.c -END -asm_mips_bc2fl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bc2fl.c -END -asm_mips_jalr.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_jalr.c -END -asm_mips_teq.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_teq.c -END -asm_mips_lui.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lui.c -END -asm_mips_luxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_luxc1.c -END -asm_mips_nor.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_nor.c -END -asm_mips_dsrl.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsrl.c -END -asm_mips_lwr.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lwr.c -END -asm_mips_sb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sb.c -END -asm_mips_swl.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_swl.c -END -asm_mips_bgtz.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgtz.c -END -asm_mips_madd_ps.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_madd_ps.c -END -asm_mips_xor.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_xor.c -END -asm_mips_srav.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_srav.c -END -asm_mips_swc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_swc2.c -END -asm_mips_dsubu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsubu.c -END -asm_mips_ldc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ldc2.c -END -asm_mips_rotr.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_rotr.c -END -asm_mips_lhu.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lhu.c -END -asm_mips_dmfc2.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dmfc2.c -END -asm_mips_bal.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bal.c -END -asm_mips_srl.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_srl.c -END -asm_mips_sltiu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sltiu.c -END -asm_mips_jal.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_jal.c -END -asm_mips_madd_d.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_madd_d.c -END -asm_mips_dmtc2.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dmtc2.c -END -asm_mips_ddivu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ddivu.c -END -asm_mips_tgeiu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tgeiu.c -END -asm_mips_seh.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_seh.c -END -asm_mips_sllv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sllv.c -END -asm_mips_movt.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_movt.c -END -asm_mips_nmadd_ps.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c -END -asm_mips_srlv.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_srlv.c -END -asm_mips_msub_s.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_msub_s.c -END -asm_mips_dsra.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsra.c -END -asm_mips_dclz.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dclz.c -END -asm_mips_mul.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mul.c -END -asm_mips_lwxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_lwxc1.c -END -asm_mips_suxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_suxc1.c -END -asm_mips_bltzall.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bltzall.c -END -asm_mips_bne.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bne.c -END -asm_mips_madd.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_madd.c -END -asm_mips_sc.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sc.c -END -asm_mips_bc2tl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bc2tl.c -END -asm_mips_msub.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_msub.c -END -cpuinsns.txt -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/cpuinsns.txt -END -asm_mips_dsrl32.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsrl32.c -END -asm_mips_dmultu.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dmultu.c -END -asm_mips_lld.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lld.c -END -asm_mips_ldxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_ldxc1.c -END -asm_mips_ldl.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ldl.c -END -asm_mips_bnel.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bnel.c -END -template.txt -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/template.txt -END -asm_mips_bgtzl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgtzl.c -END -asm_mips_beql.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_beql.c -END -asm_mips_sra.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sra.c -END -asm_mips_tne.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tne.c -END -asm_mips_bgez.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgez.c -END -asm_mips_clz.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_clz.c -END -asm_mips_sdr.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sdr.c -END -asm_mips_tgei.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tgei.c -END -asm_mips_ori.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ori.c -END -asm_mips_ins.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/asm_mips_ins.c -END -asm_mips_sw.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sw.c -END -asm_mips_daddiu.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_daddiu.c -END -asm_mips_lb.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lb.c -END -asm_mips_ext.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/asm_mips_ext.c -END -asm_mips_tlt.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tlt.c -END -asm_mips_tgeu.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_tgeu.c -END -asm_mips_nmadd_s.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c -END -asm_mips_multu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_multu.c -END -asm_mips_msub_ps.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_msub_ps.c -END -asm_mips_msub_d.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_msub_d.c -END -asm_mips_scd.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_scd.c -END -fpuinsns.txt -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/819/trunk/libasm/src/arch/mips/handlers/fpuinsns.txt -END -asm_mips_cfc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_cfc2.c -END -asm_mips_dsrav.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsrav.c -END -asm_mips_mult.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_mult.c -END -asm_mips_b.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_b.c -END -asm_mips_dclo.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dclo.c -END -asm_mips_addiu.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_addiu.c -END -asm_mips_bltzl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bltzl.c -END -asm_mips_j.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_j.c -END -asm_mips_bc2t.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bc2t.c -END -generate.sh -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/856/trunk/libasm/src/arch/mips/handlers/generate.sh -END -asm_mips_ctc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_ctc2.c -END -asm_mips_sdc2.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_sdc2.c -END -asm_mips_nop.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_nop.c -END -asm_mips_lwl.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_lwl.c -END -asm_mips_addi.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_addi.c -END -asm_mips_alnv_ps.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c -END -asm_mips_and.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_and.c -END -asm_mips_ssnop.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/892/trunk/libasm/src/arch/mips/handlers/asm_mips_ssnop.c -END -asm_mips_dsll32.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_dsll32.c -END -asm_mips_bgezal.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/handlers/asm_mips_bgezal.c -END -asm_mips_swxc1.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/handlers/asm_mips_swxc1.c -END diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/entries 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,2165 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/mips/handlers -http://svn.eresi-project.org/svn - - - -2008-03-26T17:25:46.832365Z -938 -pi3 - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -asm_mips_sd.c -file - - - - -2008-04-06T23:15:57.867887Z -6995cee1bb03101d485ebbe11cb04347 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sh.c -file - - - - -2008-04-06T23:15:57.889136Z -26d16d154ac78c9f5d21a592b6ee0b41 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_syscall.c -file - - - - -2008-04-06T23:15:57.900903Z -f8b9a00261a91b396aec236329ca223b -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bltz.c -file - - - - -2008-04-06T23:15:57.912981Z -b8546cfa551e6c3e843ac96d050acc80 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_andi.c -file - - - - -2008-04-06T23:15:57.924587Z -ebf814f38b63048f78b77399357ec17a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_swr.c -file - - - - -2008-04-06T23:15:57.936319Z -2c4fbd01e1049a036c6010a4007b5043 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tlti.c -file - - - - -2008-04-06T23:15:57.947965Z -dd869a88595fabea363f55b6846677c3 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_clo.c -file - - - - -2008-04-06T23:15:57.961886Z -edbff519083633cf2f2dce44b6b43514 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_addu.c -file - - - - -2008-04-06T23:15:57.971360Z -68c637e80611580ff7fe96b4e01d9277 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_or.c -file - - - - -2008-04-06T23:15:57.984539Z -dd0241c243cbcae389fc6dd9d9c57846 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bgezall.c -file - - - - -2008-04-06T23:15:57.995903Z -f7ca974af813cfa876afd4792e2b7026 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sdxc1.c -file - - - - -2008-04-06T23:15:58.007876Z -c610e57e292224ba53513878bf0f2104 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_mfhi.c -file - - - - -2008-04-06T23:15:58.018882Z -dc04fc554019ddb45ba9a4f3f3e62ff1 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsllv.c -file - - - - -2008-04-06T23:15:58.031126Z -3f1655d498af4089ba5832965e24b547 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nmsub_ps.c -file - - - - -2008-04-06T23:15:58.121698Z -5b30e8a67db05435b5e9b3c1ea05430f -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_ddiv.c -file - - - - -2008-04-06T23:15:58.110008Z -bd233d00e1c81fd6178e040bd5868292 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nmadd_d.c -file - - - - -2008-04-06T23:15:58.042877Z -b24eaefbb25ed084376cf9b2dbb6314a -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_tltu.c -file - - - - -2008-04-06T23:15:58.132903Z -13ea0f5719b1c3d16596ad7e02abe57e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsrlv.c -file - - - - -2008-04-06T23:15:58.145019Z -e767b6e7e828da23d432a85f87cc2050 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dadd.c -file - - - - -2008-04-06T23:15:58.168073Z -5d54cd94dcab2eb6295c1b1ba42bbe00 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_pref.c -file - - - - -2008-04-06T23:15:58.156881Z -be93a616c0efa5c52814ae0498014e7e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsub.c -file - - - - -2008-04-06T23:15:58.191877Z -096c999ee1b6cc63b4ae05257af96ebc -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mflo.c -file - - - - -2008-04-06T23:15:58.180031Z -1f1f7e179fa71607d92ea3fbf624f4d6 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mthi.c -file - - - - -2008-04-06T23:15:58.203410Z -0a5974e29ae3a1502db3398efa6bd596 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_jr.hb.c -file - - - - -2008-04-06T23:15:58.215098Z -3b1c0706885a40582a7d929f65c3bff8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nmsub_s.c -file - - - - -2008-04-06T23:15:58.226877Z -2704fcc2a6168cf731a4df5373e321c8 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_lwc2.c -file - - - - -2008-04-06T23:15:58.261876Z -a90a67d3e677cef5dbe80523e6b6175d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_movf.c -file - - - - -2008-04-06T23:15:58.237899Z -a365cda3e9f299c8f381da9197e9543f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_seb.c -file - - - - -2008-04-06T23:15:58.274997Z -3dad52c7a1ca628ac4cffbf3efefb8cb -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_jr.c -file - - - - -2008-04-06T23:15:58.298378Z -dfaf30898f977c4be1e3e6e8b801615e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mtlo.c -file - - - - -2008-04-06T23:15:58.286687Z -0e728a330606590b1af42c79bfd11f2f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sync.c -file - - - - -2008-04-06T23:15:58.310066Z -62291ba56f6b32aebe2d9fc7b99de231 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_subu.c -file - - - - -2008-04-06T23:15:58.321876Z -c7132eaecb2ea6639854f43a3e8ea30e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_movn.c -file - - - - -2008-04-06T23:15:58.333228Z -71fceb8098601e8e349ef0af3018d3fe -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tge.c -file - - - - -2008-04-06T23:15:58.345195Z -e2bb972e2f863c7d99cd90925de6f299 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lw.c -file - - - - -2008-04-06T23:15:58.356885Z -54e3ce6d27a15903090eab9896f1f660 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_div.c -file - - - - -2008-04-06T23:15:58.368575Z -aadfd4fa66c839c018fef942a07e8433 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_prefx.c -file - - - - -2008-04-06T23:15:58.380264Z -6a1a05ac377fe4a4bd266d57a60746c5 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_mfc2.c -file - - - - -2008-04-06T23:15:58.391903Z -a4ea0bd4008c24e52c61de312e9b893c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bltzal.c -file - - - - -2008-04-06T23:15:58.403500Z -c5ac2e2343d3136849d5facefb0931fd -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_add.c -file - - - - -2008-04-06T23:15:58.415393Z -f72a84b1b17c66eb58169fd4a9b3a266 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sub.c -file - - - - -2008-04-06T23:15:58.427141Z -8b3cc2066a64b1f5a3e38cb183e09b27 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_maddu.c -file - - - - -2008-04-06T23:15:58.438877Z -e0af601de74f7ba808a23d2dc6a02da9 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_movz.c -file - - - - -2008-04-06T23:15:58.450013Z -985687a572187a6f3becd1cb4aa354eb -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsll.c -file - - - - -2008-04-06T23:15:58.461899Z -f1e30e5fc6b134e5a48984849590fb0f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsra32.c -file - - - - -2008-04-06T23:15:58.474033Z -4fc31e857c9bbd7fed9d73497230fc5d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ehb.c -file - - - - -2008-04-06T23:15:58.485876Z -c868eeba532f272806efa2eed89b6f97 -2008-02-20T14:43:56.964401Z -856 -may - -asm_mips_bgezl.c -file - - - - -2008-04-06T23:15:58.499020Z -be6603a176c8c2467ae4b6e4fd3d458c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mtc2.c -file - - - - -2008-04-06T23:15:58.510876Z -6e6f4bfbb488da6d2a1a0739472843f4 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lwu.c -file - - - - -2008-04-06T23:15:58.521900Z -3945c95107ed0cec584c1233df68938b -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_divu.c -file - - - - -2008-04-06T23:15:58.534037Z -7a28c318683f22b0e2fb7cbd2256894a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_jalr.hb.c -file - - - - -2008-04-06T23:15:58.545951Z -d546e0899e26d1d9f5137abb178d4d04 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_ldr.c -file - - - - -2008-04-06T23:15:58.557698Z -1822021cadd86c102941954612bf5d8d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_xori.c -file - - - - -2008-04-06T23:15:58.569446Z -0346bc73d1c92e5b38b5bc86b88236b8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lbu.c -file - - - - -2008-04-06T23:15:58.580932Z -2cb6d2708cabdc2471495e55cc4d2813 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sdl.c -file - - - - -2008-04-06T23:15:58.592909Z -4eb4071520bae60288d6bc8e471556eb -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dmult.c -file - - - - -2008-04-06T23:15:58.604344Z -23e495df3accdc31f1be653b428fe429 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_rdhwr.c -file - - - - -2008-04-06T23:15:58.616438Z -1c1ec8db388a9c01b2ca4cf7a92423e5 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_nmsub_d.c -file - - - - -2008-04-06T23:15:58.628186Z -dcce759bba3c47e15f397e022a07e0c2 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_sll.c -file - - - - -2008-04-06T23:15:58.639934Z -52b9ff774de70c282fe9f46fddc02fb9 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_msubu.c -file - - - - -2008-04-06T23:15:58.650900Z -f021069310df283000abea13a915f944 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_blez.c -file - - - - -2008-04-06T23:15:58.663428Z -e38da2d86a9fb54daef87714ba5fbf42 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tnei.c -file - - - - -2008-04-06T23:15:58.686990Z -4e5b3f8a65f4ad63666003e337c0f87a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ld.c -file - - - - -2008-04-06T23:15:58.675184Z -a46f0149f023b15f634efb516cba08cd -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tltiu.c -file - - - - -2008-04-06T23:15:58.699880Z -5bc9ea58fc88e6e9dc37ef2677b66c22 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_teqi.c -file - - - - -2008-04-06T23:15:58.723876Z -01cef7893586c93406aff30b34e4de40 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_slt.c -file - - - - -2008-04-06T23:15:58.711880Z -2cec47fdf7fe3f7a69e952c1badaaf75 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_wsbh.c -file - - - - -2008-04-06T23:15:58.759149Z -34d55c8c0868c8f9114b7b8152ee54fb -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_cop2.c -file - - - - -2008-04-06T23:15:58.747343Z -8e0531d0d1cbc8cf3465c3157756126b -2008-03-05T11:43:30.675965Z -889 -thorkill - -asm_mips_lh.c -file - - - - -2008-04-06T23:15:58.734878Z -5841493e4bbe10329a3db883647a317a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_daddi.c -file - - - - -2008-04-06T23:15:58.770897Z -f98edff760c28e73853ed7a352bad8d8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_beq.c -file - - - - -2008-04-06T23:15:58.794477Z -c22039de603b6d81785b2f0c4e8d184a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ll.c -file - - - - -2008-04-06T23:15:58.781899Z -5924b7ae5d3ee0209a9ee401bb992420 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_blezl.c -file - - - - -2008-04-06T23:15:58.806256Z -1494318d476b14a89923ae5faec600bb -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_slti.c -file - - - - -2008-04-06T23:15:58.818155Z -3a44982f80522d8d79e0cd81768712d0 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bc2f.c -file - - - - -2008-04-06T23:15:58.841617Z -9ddaf1e0c1a81131febd1559c501b7e5 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_rotrv.c -file - - - - -2008-04-06T23:15:58.829876Z -5edd00369c2d087b91ea6a62db1bfaac -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_daddu.c -file - - - - -2008-04-06T23:15:58.853422Z -1c054a156bb0fe014cefe5881834b4cf -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_break.c -file - - - - -2008-04-06T23:15:58.865169Z -37445fbb99f1dc9d46221428e16e60b6 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_synci.c -file - - - - -2008-04-06T23:15:58.876974Z -46115cdf7b51c812081b3f33d5ce393a -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_sltu.c -file - - - - -2008-04-06T23:15:58.901903Z -8bd88caf7be19727016a8005cc200aa9 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_madd_s.c -file - - - - -2008-04-06T23:15:58.888876Z -15049bfbc2cd15c23b55573bc3dc2b71 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_bc2fl.c -file - - - - -2008-04-06T23:15:58.924909Z -a4b17edbab162c87a0741ee37a8f118d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_jalr.c -file - - - - -2008-04-06T23:15:58.913955Z -c37828a4bb05e331468a0e9f2af2faf1 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_teq.c -file - - - - -2008-04-06T23:15:58.960659Z -65c14c469c246ae0194a1b5c5982ea39 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lui.c -file - - - - -2008-04-06T23:15:58.948853Z -2d94e8c014adf120f7475182ba5b8661 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_luxc1.c -file - - - - -2008-04-06T23:15:58.971899Z -7c654fa96b29144798ecfc00661f673e -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_nor.c -file - - - - -2008-04-06T23:15:58.984328Z -53399e3c42f1f2e1234ffedd5f200541 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsrl.c -file - - - - -2008-04-06T23:15:59.019876Z -189bc52ee85fc10374ad9ccf20088335 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lwr.c -file - - - - -2008-04-06T23:15:59.007996Z -a2a28b110ad94578787dd889e7b69804 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sb.c -file - - - - -2008-04-06T23:15:58.995879Z -5e641b2dfa734c67afca160ef05c0810 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_swl.c -file - - - - -2008-04-06T23:15:59.042899Z -ef816af564500861511f103fecc5fa4b -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bgtz.c -file - - - - -2008-04-06T23:15:59.110661Z -f339751f0fb81942727611297a1affdc -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_madd_ps.c -file - - - - -2008-04-06T23:15:59.121899Z -07c31753b616426f99ecdb6c48b49c8a -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_xor.c -file - - - - -2008-04-06T23:15:59.133903Z -4c6b46458f255ad1617e5bde4a5b4408 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_srav.c -file - - - - -2008-04-06T23:15:59.147876Z -96f78aeec1cb8d7ad7eeb76df330d87f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_swc2.c -file - - - - -2008-04-06T23:15:59.159563Z -5e0db5c0159a2d7c9f9e6b307c5a4b08 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsubu.c -file - - - - -2008-04-06T23:15:59.171184Z -994b883c6684fdef632ebcd7fd1a1100 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ldc2.c -file - - - - -2008-04-06T23:15:59.183311Z -5d2c13e66d8976964b023b51e6222023 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_rotr.c -file - - - - -2008-04-06T23:15:59.195096Z -4ab29c2275ed0f7796f603cacff8cbd0 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_lhu.c -file - - - - -2008-04-06T23:15:59.206917Z -2c1df3b4928bc967bcfd49829cca0577 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dmfc2.c -file - - - - -2008-04-06T23:15:59.218876Z -ee18b648a23028cd9294f9cfeb640ed7 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bal.c -file - - - - -2008-04-06T23:15:59.241899Z -362b84ee8d1241d0cce2fed844d29eb1 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_srl.c -file - - - - -2008-04-06T23:15:59.265203Z -b5017272b063a0eb91ab5541eea24ac0 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sltiu.c -file - - - - -2008-04-06T23:15:59.253681Z -c6442dc857ae9e12e1bc7f0808a1c498 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_jal.c -file - - - - -2008-04-06T23:15:59.277149Z -06d3f4a762e1db3b467d00477762c43f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_madd_d.c -file - - - - -2008-04-06T23:15:59.288931Z -15fecaf21edfa4b031a670aa46587b59 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_dmtc2.c -file - - - - -2008-04-06T23:15:59.300708Z -a1a7851a892efb5a4d3d6143300a3a6c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ddivu.c -file - - - - -2008-04-06T23:15:59.311899Z -ba21522e50c3b21923f60ccf8d1c19f3 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tgeiu.c -file - - - - -2008-04-06T23:15:59.324886Z -dfa21f97db4a64800e663c61b07237bd -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_seh.c -file - - - - -2008-04-06T23:15:59.335897Z -ff9dc8656824a5920c047ef134f37cbe -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_sllv.c -file - - - - -2008-04-06T23:15:59.348882Z -df923bfec04039ec4b13448651023a15 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_movt.c -file - - - - -2008-04-06T23:15:59.372875Z -c9aca06a0e44738d83e1e5e7f28a937e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nmadd_ps.c -file - - - - -2008-04-06T23:15:59.361090Z -c93ec91fc6be2cb4fa52d4fa31595c18 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_srlv.c -file - - - - -2008-04-06T23:15:59.384624Z -3ca7fd2dfc32d43d976cbe8d1c8c2b64 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_msub_s.c -file - - - - -2008-04-06T23:15:59.395899Z -e7a0dddd59fe14d55b2661b7b314f55b -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_dsra.c -file - - - - -2008-04-06T23:15:59.408177Z -c906a64166d840f271d365b6114679cf -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dclz.c -file - - - - -2008-04-06T23:15:59.419925Z -359918e816b37b1f84e58adb6292c309 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mul.c -file - - - - -2008-04-06T23:15:59.431730Z -2bc9c2b270b28942e2524166964a8369 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lwxc1.c -file - - - - -2008-04-06T23:15:59.442899Z -4365d292f0ef79e3ae719057a289d81b -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_suxc1.c -file - - - - -2008-04-06T23:15:59.454899Z -70bb67dc45eedfa73a955fe95316bcdd -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_bltzall.c -file - - - - -2008-04-06T23:15:59.478876Z -0e61c622e27c5780e41d555efa945c2c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bne.c -file - - - - -2008-04-06T23:15:59.467089Z -6d03bc3184506b2afcbad7ce2ee869ed -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_madd.c -file - - - - -2008-04-06T23:15:59.502391Z -b9b48aa7d16d9c8e8988e1cb7dc60af2 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sc.c -file - - - - -2008-04-06T23:15:59.490643Z -cdb42ed261c72ec7f725309f75dd084e -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bc2tl.c -file - - - - -2008-04-06T23:15:59.525889Z -6c727f8762e3c0b7f91ceff45b9dc92c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_msub.c -file - - - - -2008-04-06T23:15:59.514196Z -87938e09aca54fae1ac78dc1942b7cf8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -cpuinsns.txt -file - - - - -2008-04-06T23:15:59.537043Z -dd872553e3c2b1e841a53c04675691e2 -2008-02-20T14:43:56.964401Z -856 -may - -asm_mips_dsrl32.c -file - - - - -2008-04-06T23:15:59.551118Z -69f6a61b22397e291f8db65c99cc82d7 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dmultu.c -file - - - - -2008-04-06T23:15:59.562944Z -066722f149ce5ac739b157a7c6ef524b -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lld.c -file - - - - -2008-04-06T23:15:59.574672Z -1458e1a2c6fef9ae8e24d6ce09e9e838 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ldxc1.c -file - - - - -2008-04-06T23:15:59.586197Z -5965656e65f5f37982d1a37eea4e3f95 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_ldl.c -file - - - - -2008-04-06T23:15:59.598052Z -d92bd5d16a9b812522d659e40caf909a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bnel.c -file - - - - -2008-04-06T23:15:59.609800Z -9df88610472fd27a626f381ac7828599 -2008-03-08T13:33:40.593577Z -899 -pi3 - -template.txt -file - - - - -2008-04-06T23:15:59.621490Z -9ba5056f95d3ae8d785ea354f2b4d5be -2008-02-20T14:43:56.964401Z -856 -may - -asm_mips_bgtzl.c -file - - - - -2008-04-06T23:15:59.633316Z -634c1cb58ade44813e82ab46ab03c2e4 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_beql.c -file - - - - -2008-04-06T23:15:59.644986Z -7f54a838b69852fe889d521c903e56d0 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sra.c -file - - - - -2008-04-06T23:15:59.656485Z -eea3b652cc1680e2e1996985572b08e7 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tne.c -file - - - - -2008-04-06T23:15:59.667931Z -af434ab002e732b5075ff2531866d765 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bgez.c -file - - - - -2008-04-06T23:15:59.680113Z -ecfcea833b00b63f51c5d34fef100604 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_clz.c -file - - - - -2008-04-06T23:15:59.691878Z -fdd203fd6f2ec27887cc3cfdb062a35b -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sdr.c -file - - - - -2008-04-06T23:15:59.703197Z -e99e770d96bcb121f2df6f8c1072b300 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tgei.c -file - - - - -2008-04-06T23:15:59.714905Z -345bb213baea0e5c7da0896dee88a3dc -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ori.c -file - - - - -2008-04-06T23:15:59.727045Z -af855dac23c3dfae8b21122f48dadebe -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ins.c -file - - - - -2008-04-06T23:15:59.738391Z -9ff3df6d59c66ce058db8eba89829bb7 -2008-02-20T14:43:56.964401Z -856 -may - -asm_mips_sw.c -file - - - - -2008-04-06T23:15:59.750541Z -ff7262f38440839092557f6922497068 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_daddiu.c -file - - - - -2008-04-06T23:15:59.763796Z -977caeef53dad1c2e4a2826be66434c8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_lb.c -file - - - - -2008-04-06T23:15:59.774899Z -8102dbe300ee24fdd65735f9f468d7be -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ext.c -file - - - - -2008-04-06T23:15:59.787101Z -047d7b5439428e38ad6dc8a3d020f588 -2008-02-20T14:43:56.964401Z -856 -may - -asm_mips_tlt.c -file - - - - -2008-04-06T23:15:59.799037Z -61d87cba88e562c527712c11f66c84b3 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_tgeu.c -file - - - - -2008-04-06T23:15:59.810788Z -374f1888bb87ee3e77da35329dad1597 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nmadd_s.c -file - - - - -2008-04-06T23:15:59.822536Z -0000f222581493601a8668bbb765d062 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_multu.c -file - - - - -2008-04-06T23:15:59.834284Z -e2cbb6c337e7074c0bbccebea54539d7 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_msub_ps.c -file - - - - -2008-04-06T23:15:59.846030Z -b1b8b63cdca9555cb6d8775124d5c476 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_msub_d.c -file - - - - -2008-04-06T23:15:59.857385Z -c33887c457f5a9556e88eb394e6fb295 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_scd.c -file - - - - -2008-04-06T23:15:59.881158Z -740b931014acbca481d506559bd61fdd -2008-03-08T13:33:40.593577Z -899 -pi3 - -fpuinsns.txt -file - - - - -2008-04-06T23:15:59.892903Z -f73d682c7c0fd8525965aeadac2dbb2a -2007-10-30T17:23:31.000000Z -819 -heroine - -asm_mips_cfc2.c -file - - - - -2008-04-06T23:15:59.904654Z -a90229706840b75df5b8a9c670ae3b25 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dsrav.c -file - - - - -2008-04-06T23:15:59.916402Z -41876a30de4f9e983013c2de4b12a255 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_mult.c -file - - - - -2008-04-06T23:15:59.928208Z -44ea8717c05cd6d43595207a15d5126d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_b.c -file - - - - -2008-04-06T23:15:59.939951Z -1d0dae666af573f07218b95c5fd67078 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_dclo.c -file - - - - -2008-04-06T23:15:59.951704Z -b4314945bc2eb515d488abbdd8c7171f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_addiu.c -file - - - - -2008-04-06T23:15:59.964909Z -1e49b08595a39b37cd8ccb780d1f2784 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bltzl.c -file - - - - -2008-04-06T23:15:59.976883Z -db78621efce8858634def1d9fe26fdc6 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_j.c -file - - - - -2008-04-06T23:15:59.988168Z -39273fcae5ee4122df263d714169723f -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bc2t.c -file - - - - -2008-04-06T23:15:59.999900Z -84f67f208ee52f2715e47e1701957700 -2008-03-08T13:33:40.593577Z -899 -pi3 - -generate.sh -file - - - - -2008-04-06T23:16:00.012179Z -e98cd0ff329d9481a37a736d1fc3a313 -2008-02-20T14:43:56.964401Z -856 -may -has-props - -asm_mips_ctc2.c -file - - - - -2008-04-06T23:16:00.023983Z -d3c60c9223e999030741856edc23a0ac -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_sdc2.c -file - - - - -2008-04-06T23:16:00.034899Z -07e9eb0cd9d673ae23c75a8df9d00d9a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_nop.c -file - - - - -2008-04-06T23:16:00.168900Z -5571d5401c5477146769b9d8671fbf06 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_lwl.c -file - - - - -2008-04-06T23:16:00.181402Z -b107d0a3411cf1615c9eb9e98f6a944a -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_addi.c -file - - - - -2008-04-06T23:16:00.193317Z -b4a8384978db4e58d3c8a3d2b047aa77 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_alnv_ps.c -file - - - - -2008-04-06T23:16:00.204875Z -2eb9b4995fd8deb9a4b1dde44136f7a9 -2008-03-26T17:25:46.832365Z -938 -pi3 - -asm_mips_and.c -file - - - - -2008-04-06T23:16:00.216887Z -417c8d184f8d47aeb8ed82e626b5b8ca -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_ssnop.c -file - - - - -2008-04-06T23:16:00.228676Z -00fe9dbcafd9fa7ce88bc9f7d41a5a29 -2008-03-05T22:21:56.939078Z -892 -pi3 - -asm_mips_dsll32.c -file - - - - -2008-04-06T23:16:00.239900Z -4dcc5f5c2b62824720495f1b0463444c -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_bgezal.c -file - - - - -2008-04-06T23:16:00.251881Z -58bce93fe92e082d043cd9ddad70fec3 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_swxc1.c -file - - - - -2008-04-06T23:16:00.264091Z -faba8611ce51f19c605b4397eeed2843 -2008-03-26T17:25:46.832365Z -938 -pi3 - diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/format 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/prop-base/generate.sh.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/prop-base/generate.sh.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/prop-base/generate.sh.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/prop-base/generate.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_add.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_add.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_add.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_add.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_add(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_ADD; - ins->type = ASM_TYPE_ARITH /* | ASM_TYPE_ */; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Integer overflow */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addi.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_addi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_ADDI; - ins->type = ASM_TYPE_ARITH /* | ASM_TYPE_ */; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exception: Integer Overflow */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addiu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addiu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addiu.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addiu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_addiu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_ADDIU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptione: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addu.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_addu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_addu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_ADDU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_alnv_ps.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_alnv_ps.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_alnv_ps.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_alnv_ps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_alnv_ps(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_ALNV_PS; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.f1; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.in; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_and.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_and.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_and.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_and.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_and(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_AND; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_andi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_andi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_andi.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_andi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_andi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_ANDI; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exception: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bal.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bal.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bal.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bal(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BAL; - ins->type = /* ASM_TYPE_IMPBRANCH */ ASM_TYPE_CALLPROC; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2f.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2f.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2f.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2f.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bc2f(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BC2F; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2fl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2fl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2fl.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2fl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bc2fl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BC2FL; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2t.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2t.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2t.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2t.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bc2t(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BC2T; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2tl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2tl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2tl.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bc2tl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bc2tl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BC2TL; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_b.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_b.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_b.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_b.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_b(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_B; - ins->type = ASM_TYPE_IMPBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].imm = temp.im; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beq.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beq.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beq.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_beq(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - u_int converted = 0; - - memcpy((char *)&converted,buf,sizeof(converted)); - - switch ((converted >> 16) & 0x3FF) { - - case ASM_MIPS_OTYPE_NONE: - asm_mips_b(ins,buf,len,proc); - break; - default: - ins->instr = ASM_MIPS_BEQ; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_BRANCH, ins); - break; - } - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beql.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beql.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beql.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_beql.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_beql(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BEQL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezal.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezal.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezal.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgezal(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGEZAL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezall.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezall.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezall.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezall.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgezall(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGEZALL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgez.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgez.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgez.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgez.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgez(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGEZ; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezl.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgezl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgezl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGEZL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtz.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtz.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtz.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgtz(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGTZ; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtzl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtzl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtzl.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bgtzl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bgtzl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BGTZL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blez.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blez.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blez.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blez.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_blez(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLEZ; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blezl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blezl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blezl.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_blezl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_blezl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLEZL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzal.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzal.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzal.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bltzal(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLTZAL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzall.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzall.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzall.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzall.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bltzall(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLTZALL; - ins->type = ASM_TYPE_CONDBRANCH | ASM_TYPE_CALLPROC; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltz.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltz.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltz.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bltz(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLTZ; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzl.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bltzl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bltzl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BLTZL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bne.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bne.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bne.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bne(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BNE; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bnel.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bnel.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bnel.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_bnel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_bnel(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_BNEL; - ins->type = ASM_TYPE_CONDBRANCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_BRANCH, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_break.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_break.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_break.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_break.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_break(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_BREAK; - ins->type = ASM_TYPE_STOP /* ?????? */; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP /* ASM_MIPS_OTYPE_TRAP */, ins); - - /* Exceptions: Breakpoint */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cfc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cfc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cfc2.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cfc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_cfc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_CFC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp,buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clo.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clo.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clo.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* CLO rd,rs */ - -int asm_mips_clo(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_CLO; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clz.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clz.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clz.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_clz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* CLZ rd,rs */ - -int asm_mips_clz(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_CLZ; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cop2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cop2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cop2.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_cop2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_cop2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_COP2; - ins->type = ASM_TYPE_ARCH; - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ctc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ctc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ctc2.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ctc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ctc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_CTC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp,buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Coprocessor Unusable, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dadd.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dadd.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dadd.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dadd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DADD rd,rs,rt */ - -int asm_mips_dadd(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DADD; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Integer overflow, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddi.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_daddi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_DADDI; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Integer overflow, Reserved instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddiu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddiu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddiu.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddiu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_daddiu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_DADDIU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_daddu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_daddu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DADDU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclo.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclo.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclo.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DCLO rd,rs */ - -int asm_mips_dclo(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DCLO; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclz.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclz.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclz.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dclz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DCLZ rd,rs */ - -int asm_mips_dclz(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DCLZ; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddiv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddiv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddiv.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddiv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ddiv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DDIV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddivu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddivu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddivu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ddivu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ddivu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DDIVU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_div.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_div.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_div.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_div.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_div(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DIV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_divu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_divu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_divu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_divu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_divu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DIVU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmfc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmfc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmfc2.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmfc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dmfc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_DMFC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp,buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sl; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Coprocessor Unusable, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmtc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmtc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmtc2.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmtc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dmtc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_DMTC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp,buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sl; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Coprocessor Unusable, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmult.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmult.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmult.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmult.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dmult(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DMULT; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmultu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmultu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmultu.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dmultu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dmultu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_DMULTU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll32.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll32.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll32.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsll32(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSLL32; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsll.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsll(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSLL; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsllv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsllv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsllv.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsllv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DSLLV rd,rt,rs */ - -int asm_mips_dsllv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSLLV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra32.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra32.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra32.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsra32(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRA32; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsra.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsra(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRA; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrav.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrav.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrav.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrav.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DSRAV rd,rt,rs */ - -int asm_mips_dsrav(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRAV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl32.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl32.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl32.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsrl32(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRL32; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsrl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRL; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrlv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrlv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrlv.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsrlv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* DSRLV rd,rt,rs */ - -int asm_mips_dsrlv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSRLV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsub.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsub.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsub.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsub(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSUB; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Integer Overflow, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsubu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsubu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsubu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_dsubu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_dsubu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_DSUBU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ehb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ehb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ehb.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ehb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include "libasm.h" - -int asm_mips_ehb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_BAD; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ext.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ext.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ext.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ext.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include "libasm.h" - -int asm_mips_ext(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_EXT; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ins.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ins.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ins.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ins.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include "libasm.h" - -int asm_mips_ins(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_INS; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jal.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jal.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jal.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_jal(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_jump temp; - - ins->instr = ASM_MIPS_JAL; - ins->type = ASM_TYPE_CALLPROC; - mips_convert_format_j(&temp,buf); - ins->op[0].imm = temp.ta; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_JUMP, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_jalr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_JALR; - ins->type = ASM_TYPE_CALLPROC; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.hb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.hb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.hb.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jalr.hb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_jalr_hb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ -// ins->instr = ASM_MIPS_JALR; -// asm_mips_operand_r(&ins->op[0], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - asm_mips_jalr(ins, buf, len, proc); - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_j.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_j.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_j.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_j.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_j(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_jump temp; - - ins->instr = ASM_MIPS_J; - ins->type = ASM_TYPE_IMPBRANCH; - mips_convert_format_j(&temp,buf); - ins->op[0].imm = temp.ta; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_JUMP, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_jr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_JR; - ins->type = ASM_TYPE_IMPBRANCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.hb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.hb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.hb.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_jr.hb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_jr_hb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ -// ins->instr = ASM_MIPS_JR; -// asm_mips_operand_r(&ins->op[0], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - asm_mips_jr(ins, buf, len, proc); - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lb.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LB; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lbu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lbu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lbu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lbu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lbu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LBU; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldc2.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ldc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LDC2; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ld.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ld.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ld.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ld.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ld(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LD; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldl.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ldl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LDL; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldr.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ldr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LDR; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldxc1.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ldxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ldxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_LDXC1; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lh.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lh.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lh.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lh(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LH; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lhu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lhu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lhu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lhu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lhu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LHU; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ll.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ll.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ll.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ll.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ll(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LL; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lld.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lld.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lld.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lld.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lld(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LLD; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lui.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lui.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lui.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lui.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lui(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LUI; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_luxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_luxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_luxc1.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_luxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_luxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_LUXC1; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, TLB Modified, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwc2.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lwc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LWC2; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lw.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lw.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lw.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lw(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LW; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwl.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lwl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LWL; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: None / TLB Refill, TLB Invalid, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwr.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lwr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LWR; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lwu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_LWU; - ins->type = ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwxc1.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_lwxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_lwxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_LWXC1; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MADD rs,rt */ - -int asm_mips_madd(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MADD; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_d.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_d.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_d.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_d.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_madd_d(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MADD_D; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_ps.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_ps.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_ps.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_ps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_madd_ps(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MADD_PS; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_s.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_s.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_s.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_madd_s.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_madd_s(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MADD_S; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_maddu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_maddu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_maddu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_maddu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MADDU rs,rt */ - -int asm_mips_maddu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MADDU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfc2.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mfc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_MFC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sl; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Coprocesor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfhi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfhi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfhi.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mfhi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mfhi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MFHI; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mflo.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mflo.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mflo.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mflo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mflo(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MFLO; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movf.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movf.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movf.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_movf(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_mov temp; - - ins->instr = ASM_MIPS_MOVF; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_mov(&temp,buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.cc; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movn.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movn.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movn.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movn.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include "libasm.h" - -/* MOVN rd,rs,rt */ - -int asm_mips_movn(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MOVN; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movt.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movt.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movt.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_movt(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_mov temp; - - ins->instr = ASM_MIPS_MOVT; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_mov(&temp,buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.cc; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movz.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movz.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movz.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_movz.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MOVZ rd,rs,rt */ - -int asm_mips_movz(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MOVZ; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MSUB rs,rt */ - -int asm_mips_msub(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MSUB; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_d.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_d.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_d.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_d.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_msub_d(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MSUB_D; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_ps.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_ps.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_ps.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_ps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_msub_ps(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MSUB_PS; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_s.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_s.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_s.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msub_s.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_msub_s(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_MSUB_S; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msubu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msubu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msubu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_msubu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MSUBU rs,rt */ - -int asm_mips_msubu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MSUBU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtc2.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mtc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop2 temp; - - ins->instr = ASM_MIPS_MTC2; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_cop2(&temp,buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sl; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mthi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mthi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mthi.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mthi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mthi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MTHI; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtlo.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtlo.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtlo.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mtlo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_mtlo(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MTLO; - ins->type = ASM_TYPE_ARCH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mul.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mul.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mul.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mul.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MUL rd,rs,rt */ - -int asm_mips_mul(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_MUL; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mult.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mult.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mult.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_mult.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MULT rs,rt */ - -int asm_mips_mult(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_MULT; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_multu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_multu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_multu.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_multu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* MULTU rs,rt */ - -int asm_mips_multu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_MULTU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_d.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_d.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_d.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_d.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmadd_d(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMADD_D; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_ps.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_ps.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_ps.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_ps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmadd_ps(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMADD_PS; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_s.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_s.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_s.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmadd_s.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmadd_s(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMADD_S; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_d.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_d.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_d.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_d.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmsub_d(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMSUB_D; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_ps.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_ps.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_ps.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_ps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmsub_ps(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMSUB_PS; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_s.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_s.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_s.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nmsub_s.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nmsub_s(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_NMSUB_S; - ins->type = ASM_TYPE_ARITH | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].regset = ASM_MIPS_REG_FPU; - ins->op[1].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].regset = ASM_MIPS_REG_FPU; - ins->op[2].baser = temp.f2; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[3].regset = ASM_MIPS_REG_FPU; - ins->op[3].baser = temp.in; - asm_mips_operand_fetch(&ins->op[3], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exception: Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nop.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nop.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nop.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_nop(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_NOP; - ins->type = ASM_TYPE_NOP; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nor.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nor.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nor.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_nor.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* NOR rd,rs,rt */ - -int asm_mips_nor(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_NOR; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_or.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_or.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_or.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_or.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* OR rd,rs,rt */ - -int asm_mips_or(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_OR; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ori.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ori.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ori.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ori.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ori(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_ORI; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_pref.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_pref.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_pref.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_pref.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_pref(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_PREF; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_LOAD; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: None :) */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_prefx.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_prefx.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_prefx.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_prefx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_prefx(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_PREFX; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].baser = temp.f1; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rdhwr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rdhwr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rdhwr.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rdhwr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_rdhwr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_RDHWR; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotr.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_rotr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_ROTR; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotrv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotrv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotrv.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_rotrv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_rotrv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_ROTRV; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sb.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SB; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sc.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sc.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sc.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sc(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SC; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_scd.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_scd.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_scd.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_scd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_scd(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SCD; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdc2.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sdc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SDC2; - ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sd.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sd.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sd.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sd(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SD; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdl.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sdl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SDL; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdr.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sdr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SDR; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error, Reserved Instruction */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdxc1.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sdxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sdxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_SDXC1; - ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f1; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seb.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seb.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seb.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_seb(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SEB; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seh.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seh.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seh.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_seh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_seh(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SEH; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sh.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sh.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sh.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sh(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SH; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sll.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sll.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sll.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sll.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sll(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - u_int converted = 0; - - memcpy((char *)&converted,buf,sizeof(converted)); - - switch ((converted >> 6) & 0xFFFFF) { - - case MIPS_OPCODE_NOP: - asm_mips_nop(ins,buf,len,proc); - break; - case MIPS_OPCODE_SSNOP: - asm_mips_ssnop(ins,buf,len,proc); - break; - default: - ins->instr = ASM_MIPS_SLL; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - break; - } - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sllv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sllv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sllv.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sllv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SLLV rd,rt,rs */ - -int asm_mips_sllv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SLLV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slt.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slt.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slt.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SLT rd,rs,rt */ - -int asm_mips_slt(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SLT; - ins->type = ASM_TYPE_COMPARISON; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slti.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slti.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slti.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_slti.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_slti(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SLTI; - ins->type = ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltiu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltiu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltiu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltiu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sltiu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SLTIU; - ins->type = ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sltu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SLTU rd,rs,rt */ - -int asm_mips_sltu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SLTU; - ins->type = ASM_TYPE_COMPARISON; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sra.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sra.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sra.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sra.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sra(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SRA; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srav.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srav.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srav.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srav.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SRAV rd,rt,rs */ - -int asm_mips_srav(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SRAV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srl.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_srl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SRL; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.sa; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srlv.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srlv.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srlv.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_srlv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SRLV rd,rt,rs */ - -int asm_mips_srlv(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SRLV; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ssnop.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ssnop.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ssnop.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_ssnop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_ssnop(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SSNOP; - ins->type = ASM_TYPE_NOP; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sub.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sub.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sub.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SUB rd,rs,rt */ - -int asm_mips_sub(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SUB; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Integer Overflow */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_subu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_subu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_subu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_subu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* SUBU rd,rs,rt */ - -int asm_mips_subu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_SUBU; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_suxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_suxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_suxc1.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_suxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_suxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_SUXC1; - ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f1; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, TLB Modified, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swc2.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swc2.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swc2.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swc2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_swc2(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SWC2; - ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: Coprocessor Unusable, Reserved Instruction, TLB Refill, TLB Invalid, TLB Modified, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sw.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sw.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sw.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sw(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SW; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swl.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swl.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swl.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_swl(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SWL; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swr.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swr.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swr.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_swr(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_SWR; - ins->type = ASM_TYPE_STORE; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - ins->op[2].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exceptions: TLB Refill, TLB Invalid, TLB Modified, Bus Error, Address Error */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swxc1.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swxc1.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swxc1.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_swxc1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_swxc1(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_cop1x temp; - - ins->instr = ASM_MIPS_SWXC1; - ins->type = ASM_TYPE_STORE | ASM_TYPE_ARCH; - mips_convert_format_cop1x(&temp, buf); - ins->op[0].regset = ASM_MIPS_REG_FPU; - ins->op[0].baser = temp.f1; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.in; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.bs; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGBASE, ins); - - /* Exception: TLB Refill, TLB Invalid, TLB Modified, Address Error, Reserved Instruction, Coprocessor Unusable */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sync.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sync.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sync.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_sync.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_sync(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SYNC; - ins->type = ASM_TYPE_LOAD | ASM_TYPE_STORE | ASM_TYPE_ARCH; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_synci.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_synci.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_synci.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_synci.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_synci(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SYNCI; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_syscall.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_syscall.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_syscall.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_syscall.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_syscall(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_SYSCALL; - ins->type = ASM_TYPE_ARCH; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_NOOP /* ASM_MIPS_OTYPE_TRAP */ , ins); - - /* Exceptions: System Call */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teq.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teq.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teq.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TEQ rs,rt */ - -int asm_mips_teq(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TEQ; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teqi.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teqi.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teqi.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_teqi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_teqi(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TEQI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tge.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tge.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tge.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tge.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TGE rs,rt */ - -int asm_mips_tge(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TGE; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgei.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgei.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgei.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgei.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_tgei(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TGEI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeiu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeiu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeiu.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeiu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_tgeiu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TGEIU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeu.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tgeu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TGEU rs,rt */ - -int asm_mips_tgeu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TGEU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlt.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlt.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlt.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TLT rs,rt */ - -int asm_mips_tlt(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TLT; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlti.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlti.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlti.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tlti.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_tlti(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TLTI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltiu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltiu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltiu.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltiu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_tltiu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TLTIU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltu.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltu.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltu.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tltu.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TLTU rs,rt */ - -int asm_mips_tltu(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TLTU; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tne.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tne.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tne.c.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tne.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* TNE rs,rt */ - -int asm_mips_tne(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_trap temp; - - ins->instr = ASM_MIPS_TNE; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_t(&temp,buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tnei.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tnei.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tnei.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_tnei.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_tnei(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_TNEI; - ins->type = ASM_TYPE_ARCH | ASM_TYPE_COMPARISON; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].imm = temp.im; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: Trap */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_wsbh.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_wsbh.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_wsbh.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_wsbh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_wsbh(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ASM_MIPS_WSBH; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xor.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xor.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xor.c.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xor.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -/* XOR rd,rs,rt */ - -int asm_mips_xor(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_reg temp; - - ins->instr = ASM_MIPS_XOR; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_r(&temp, buf); - ins->op[0].baser = temp.rd; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_REGISTER, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xori.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xori.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xori.c.svn-base 2008-04-06 23:15:55.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/asm_mips_xori.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include - -int asm_mips_xori(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_mips_decode_imm temp; - - ins->instr = ASM_MIPS_XORI; - ins->type = ASM_TYPE_ARITH; - mips_convert_format_i(&temp, buf); - ins->op[0].baser = temp.rt; - asm_mips_operand_fetch(&ins->op[0], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[1].baser = temp.rs; - asm_mips_operand_fetch(&ins->op[1], buf, ASM_MIPS_OTYPE_REGISTER, ins); - ins->op[2].imm = temp.im; - asm_mips_operand_fetch(&ins->op[2], buf, ASM_MIPS_OTYPE_IMMEDIATE, ins); - - /* Exceptions: None */ - - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/cpuinsns.txt.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/cpuinsns.txt.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/cpuinsns.txt.svn-base 2008-04-06 23:15:56.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/cpuinsns.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -add -addi -addiu -addu -clo -clz -dadd -daddi -daddiu -daddu -dclo -dclz -ddiv -ddivu -div -divu -dmult -dmultu -dsub -dsubu -madd -maddu -msub -msubu -mul -mult -multu -slt -slti -sltiu -sltu -sub -subu -seb -seh -b -bal -beq -bgez -bgezal -bgtz -blez -bltz -bltzal -bne -j -jal -jalr -jr -jalr_hb -jr_hb -nop -ssnop -ehb -lb -lbu -ld -ldl -ldr -lh -lhu -ll -lld -lw -lwl -lwr -lwu -pref -sb -sc -scd -sd -sdl -sdr -sh -sw -swl -swr -sync -synci -and -andi -lui -nor -or -ori -xor -xori -ext -ins -wsbh -mfhi -mflo -movf -movn -movt -movz -mthi -mtlo -dsll -dsll32 -dsllv -dsra -dsra32 -dsrav -dsrl -dsrl32 -dsrlv -sll -sllv -sra -srav -srl -srlv -rdhwr -rotr -rotrv -break -syscall -teq -teqi -tge -tgei -tgeiu -tgeu -tlt -tlti -tltiu -tltu -tne -tnei -beql -bgezall -bgezl -bgtzl -blezl -bltzall -bltzl -bnel diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/fpuinsns.txt.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/fpuinsns.txt.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/fpuinsns.txt.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/fpuinsns.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -bc1f -bc1t -bc1fl -bc1tl -abs.fmt -add.fmt -div.fmt -madd.fmt -msub.fmt -mul.fmt -neg.fmt -nmadd.fmt -nmsub.fmt -recip.fmt -rsqrt.fmt -sqrt.fmt -sub.fmt -c.cond.fmt -alnv.ps -ceil.l.fmt -ceil.w.fmt -cvt.d.fmt -cvt.l.fmt -cvt.ps.s -cvt.s.pl -cvt.s.pu -cvt.s.fmt -cvt.w.fmt -floor.l.fmt -floor.w.fmt -pll.ps -plu.ps -pul.ps -puu.ps -round.l.fmt -round.w.fmt -trunc.l.fmt -trunc.w.fmt -ldc1 -ldxc1 -luxc1 -lwc1 -lwxc1 -prefx -sdc1 -sdxc1 -suxc1 -swc1 -swxc1 -cfc1 -ctc1 -mfc1 -mfhc1 -mov.fmt -movf.fmt -movn.fmt -movt.fmt -movz.fmt -mtc1 -mthc1 - diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/generate.sh.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/generate.sh.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/generate.sh.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/generate.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -#!/bin/sh -cat ./cpuinsns.txt | xargs -t --replace=REEMP awk '{sub(/SUBSTITUTE/,"REEMP");print $0 > "asm_mips_REEMP.c"}' ./template.txt -cat ./cop2insns.txt | xargs -t --replace=REEMP awk '{sub(/SUBSTITUTE/,"REEMP");print $0 > "asm_mips_REEMP.c"}' ./template.txt diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/template.txt.svn-base eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/template.txt.svn-base --- eresi-0.8a25/libasm/src/arch/mips/handlers/.svn/text-base/template.txt.svn-base 2008-04-06 23:15:57.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/.svn/text-base/template.txt.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -/* Adam 'pi3' Zabrocki */ -/* Manuel Martin - 2007 */ - -#include "libasm.h" - -int asm_mips_SUBSTITUTE(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - ins->instr = ; - return 777; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/handlers/template.txt eresi-0.0.20110516/libasm/src/arch/mips/handlers/template.txt --- eresi-0.8a25/libasm/src/arch/mips/handlers/template.txt 2008-04-06 23:15:59.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/handlers/template.txt 2011-05-16 11:34:27.000000000 +0000 @@ -7,5 +7,5 @@ asm_processor *proc) { ins->instr = ; - return 777; + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/init_mips.c eresi-0.0.20110516/libasm/src/arch/mips/init_mips.c --- eresi-0.8a25/libasm/src/arch/mips/init_mips.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/init_mips.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,5 +1,9 @@ /** - * @file init_mips.c +* @file libasm/src/arch/mips/init_mips.c +** @ingroup mips +*/ +/** +* @file libasm/src/arch/mips/init_mips.c * @brief This file have function for initializing and fetch code for MIPS architecture. * * fix and fill @@ -81,10 +85,12 @@ dim[2] = (converted & 0x10000 ) >> 16; break; case MIPS_OPCODE_SRL: - dim[2] = ((converted & 0x200000 ) >> 21) + 2; +// dim[2] = ((converted & 0x200000 ) >> 21) + 2; + dim[2] = ((converted >> 21) & 0x1F); break; case MIPS_OPCODE_SRLV: - dim[2] = ((converted & 0x40) >> 6) + 4; +// dim[2] = ((converted & 0x40) >> 6) + 4; + dim[2] = ((converted >> 6) & 0x1F); break; } break; @@ -110,8 +116,40 @@ break; case MIPS_OPCODE_COP0: + do { + u_int tmp = (converted >> 3) & 0xFF; + + if (!tmp) + dim[1] = tmp; + else + dim[1] = converted & 0x3F; + } while(0); break; + case MIPS_OPCODE_COP1: + do { + + u_int tmp = (converted >> 0) & 0x3F; + u_int fmt = (converted >> 21) & 0x1F; + u_int jajo = (converted >> 4) & 0xF; + u_int kupa = (converted >> 0) & 0xF; + + if (fmt == MIPS_OPCODE_BCC2) { + dim[1] = fmt; + dim[2] = (converted >> 16) & 0x3; + } else if (fmt == MIPS_OPCODE_F_CFC1 || fmt == MIPS_OPCODE_F_CTC1 + || fmt == MIPS_OPCODE_F_MFC1 || fmt == MIPS_OPCODE_F_MTC1 + || fmt == MIPS_OPCODE_DMFC2 || fmt == MIPS_OPCODE_DMTC2) { + dim[1] = fmt; + } else if (jajo == 0x3) { + dim[1] = kupa; + dim[2] = fmt; + } else { + dim[1] = tmp; + dim[2] = fmt; + } + + } while(0); break; case MIPS_OPCODE_COP2: do { @@ -121,7 +159,7 @@ dim[1] = tmp; else { dim[1] = (converted >> 21) & 0x1F; - if (dim[1] == MIPS_OPCODE_BC) + if (dim[1] == MIPS_OPCODE_BCC2) dim[2] = (converted >> 16) & 0x3; } } while(0); @@ -146,7 +184,7 @@ * for register vectors. * * @param proc Pointer to a asm_processor structure. - * @return Always 0 + * @return Always 1 */ int asm_init_mips(asm_processor *proc) { @@ -158,5 +196,5 @@ asm_arch_register(proc, 0); - return (0); + return (1); } diff -Nru eresi-0.8a25/libasm/src/arch/mips/mips_convert.c eresi-0.0.20110516/libasm/src/arch/mips/mips_convert.c --- eresi-0.8a25/libasm/src/arch/mips/mips_convert.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/mips_convert.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,8 +1,12 @@ /** - * @file mips_convert.c +* @file libasm/src/arch/mips/mips_convert.c +** @ingroup mips +*/ +/** +* @file libasm/src/arch/mips/mips_convert.c * @brief Convert MIPS instruction to definied types and fill suitable structures. * - * $Id: mips_convert.c,v 1.4 2008/03/13 15:46:27 heroine && pi3 Exp $ + * $Id: mips_convert.c 1397 2009-09-13 02:19:08Z may $ * * Integrated to vectors * - Adam 'pi3' Zabrocki diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,6 +1,14 @@ +/** + * @defgroup MIPS_operands MIPS operands API. + * @ingroup mips + */ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c +** @ingroup MIPS_operands +*/ /* - * - Adam 'pi3' Zabrocki - * + * Started by Adam 'pi3' Zabrocki + * $Id: asm_mips_operand_fetch.c 1397 2009-09-13 02:19:08Z may $ */ #include diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c +** @ingroup MIPS_operands +*/ /* * - Adam 'pi3' Zabrocki * diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/all-wcprops 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/operand_handlers -END -asm_mips_operand_none.c -K 25 -svn:wc:ra_dav:version-url -V 85 -/svn/!svn/ver/865/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c -END -asm_mips_operand_r.c -K 25 -svn:wc:ra_dav:version-url -V 82 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c -END -asm_mips_operand_i.c -K 25 -svn:wc:ra_dav:version-url -V 82 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c -END -asm_mips_operand_regbase.c -K 25 -svn:wc:ra_dav:version-url -V 88 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c -END -asm_mips_operand_fetch.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c -END -asm_mips_operand_j.c -K 25 -svn:wc:ra_dav:version-url -V 82 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c -END -asm_mips_operand_noop.c -K 25 -svn:wc:ra_dav:version-url -V 85 -/svn/!svn/ver/865/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c -END -asm_mips_operand_branch.c -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/899/trunk/libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c -END diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/entries 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/mips/operand_handlers -http://svn.eresi-project.org/svn - - - -2008-03-26T17:25:46.832365Z -938 -pi3 - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -asm_mips_operand_none.c -file - - - - -2008-04-06T23:16:04.201882Z -36f9cf63d81d03feb5673bb2c7b5f090 -2008-02-26T14:07:36.698064Z -865 -pi3 - -asm_mips_operand_r.c -file - - - - -2008-04-06T23:16:04.233152Z -03b4cdd60d12232f0acb3bf98740aee8 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_operand_i.c -file - - - - -2008-04-06T23:16:04.244892Z -663213675a45e690dfca4ff0204faa5d -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_operand_regbase.c -file - - - - -2008-04-06T23:16:04.255995Z -0770d835fd8e4b1457a32141d2303c66 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_operand_fetch.c -file - - - - -2008-04-06T23:16:04.267453Z -0908600dfe0164d441c8309548da3133 -2008-03-26T17:25:46.832365Z -938 -pi3 -has-props - -asm_mips_operand_j.c -file - - - - -2008-04-06T23:16:04.278913Z -62e26b57acfc7e5e0d7024f7f6219ff1 -2008-03-08T13:33:40.593577Z -899 -pi3 - -asm_mips_operand_noop.c -file - - - - -2008-04-06T23:16:04.290314Z -f92558d2fe88de0befb29326f0250294 -2008-02-26T14:07:36.698064Z -865 -pi3 - -asm_mips_operand_branch.c -file - - - - -2008-04-06T23:16:04.300926Z -5ee28a704ff1008c73e6768a809c8c9e -2008-03-08T13:33:40.593577Z -899 -pi3 - diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/format 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/prop-base/asm_mips_operand_fetch.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/prop-base/asm_mips_operand_fetch.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/prop-base/asm_mips_operand_fetch.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/prop-base/asm_mips_operand_fetch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_branch.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_branch.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_branch.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_branch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_branch(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_BRANCH; -// memcpy(&op->scale,opcode,4); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_fetch.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_fetch.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_fetch.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_fetch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -int asm_mips_operand_fetch(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) - -{ - vector_t *vec; - u_int dim[1]; - int ret; - int (*func_op)(asm_operand *op, u_char *opcode, int otype, asm_instr *ins); - - vec = aspect_vector_get(LIBASM_VECTOR_OPERAND_MIPS); - dim[0] = otype; - - func_op = aspect_vectors_select(vec, dim); - if ( (ret = func_op(op, opcode, otype, ins)) == -1) { - printf("%s:%i Unsupported operand content : %i\n", __FILE__, __LINE__, - otype); - } - - return (ret); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_i.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_i.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_i.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_i.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_i(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_IMMEDIATE; -// memcpy(&op->scale,opcode,4); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_j.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_j.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_j.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_j.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_j(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_JUMP; -// memcpy(&op->scale,opcode,4); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_none.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_none.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_none.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_none.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_none(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_NONE; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_noop.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_noop.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_noop.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_noop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_noop(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_NOOP; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_r.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_r.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_r.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_r.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_r(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_REGISTER; -// memcpy(&op->scale,opcode,4); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_regbase.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_regbase.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_regbase.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/operand_handlers/.svn/text-base/asm_mips_operand_regbase.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* - * - Adam 'pi3' Zabrocki - * - */ - -#include - -void asm_mips_operand_regbase(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - op->type = ASM_MIPS_OTYPE_REGBASE; -// memcpy(&op->scale,opcode,4); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/output_mips.c eresi-0.0.20110516/libasm/src/arch/mips/output_mips.c --- eresi-0.8a25/libasm/src/arch/mips/output_mips.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/output_mips.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,15 +1,17 @@ /** - * @file output_mips.c - * @brief This file respond for MIPS ASCII output engine... - * - * fix and fill - * - Adam 'pi3' Zabrocki +* @file libasm/src/arch/mips/output_mips.c +** @ingroup mips +*/ +/** +* @file libasm/src/arch/mips/output_mips.c + * @brief This file implements the MIPS ASCII output engine * + * Made by Manuel Martin and Adam Zabrocki + * $Id: output_mips.c 1397 2009-09-13 02:19:08Z may $ */ -/* Manuel Martin - 2007 */ - #include + /** * @fn char *asm_mips_display_operand(asm_instr *ins, int num, unsigned int addr) * @brief Return ASCII representation of a mips operand @@ -19,60 +21,62 @@ * @parram addr Virtual Address of instruction. * @return A pointer to a static buffer or NULL on error. */ -char *asm_mips_display_operand(asm_instr *ins, int num, unsigned int addr) +char *asm_mips_display_operand(asm_instr *ins, int num, eresi_Addr addr) { - unsigned int i; - static char bufer[80]; - char temp[4][20]; - - asm_operand *op; - memset(bufer,0x0,sizeof(bufer)); - for (i=0;i<4;i++) { - op = &ins->op[i]; - memset(&temp[i][0],0x0,sizeof(temp[i])); - switch(op->type) { - + unsigned int i; + static char bufer[80]; + char temp[4][20]; + asm_operand *op; + + memset(bufer, 0x0, sizeof(bufer)); + for (i = 0; i < 4; i++) + { + op = &ins->op[i]; + memset(&temp[i][0], 0x0, sizeof(temp[i])); + switch(op->type) + { case ASM_MIPS_OTYPE_REGISTER: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",%s" : "%s",(op->regset) ? e_mips_registers[op->baser].fpu_mnemonic : e_mips_registers[op->baser].ext_mnemonic); - break; - + snprintf(temp[i],sizeof(temp[i]),(i) ? ",%s" : "%s", + (op->regset) ? + e_mips_registers[op->baser].fpu_mnemonic : + e_mips_registers[op->baser].ext_mnemonic); + break; + case ASM_MIPS_OTYPE_IMMEDIATE: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",%d" : "%d",(short)op->imm); - break; - + snprintf(temp[i],sizeof(temp[i]),(i) ? ",%d" : "%d",(short) op->imm); + break; + case ASM_MIPS_OTYPE_JUMP: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",0x%x" : "0x%x",(op->imm << 2) | ((((addr + 8) >> 28) & 0xF) << 28)); - break; - + snprintf(temp[i], sizeof(temp[i]), (i ? ","XFMT : XFMT), + (op->imm << 2) | ((((addr + 8) >> 28) & 0xF) << 28)); + break; + case ASM_MIPS_OTYPE_NONE: case ASM_MIPS_OTYPE_NOOP: - -// snprintf(bufer,sizeof(bufer)," "); - - break; - + // snprintf(bufer,sizeof(bufer)," "); + break; + case ASM_MIPS_OTYPE_BRANCH: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",0x%x" : "0x%x",(addr+(((short)op->imm+1)*4))); - break; - + snprintf(temp[i], sizeof(temp[i]) , (i) ? ","XFMT : XFMT, + (addr + (((short) op->imm + 1) * 4))); + break; + case ASM_MIPS_OTYPE_REGBASE: - - snprintf(temp[i],sizeof(temp[i]),"(%s)",(op->regset) ? e_mips_registers[op->baser].fpu_mnemonic : e_mips_registers[op->baser].ext_mnemonic); - break; - - } - } - - for (i=0;i<4;i++) - if (temp[i][0]) - strcat(bufer,temp[i]); - + snprintf(temp[i], sizeof(temp[i]), "(%s)", + (op->regset) ? + e_mips_registers[op->baser].fpu_mnemonic : + e_mips_registers[op->baser].ext_mnemonic); + break; + + } + } + + for (i = 0; i < 4; i++) + if (temp[i][0]) + strcat(bufer,temp[i]); + return (bufer[0]) ? bufer : NULL; - + } /** @@ -83,17 +87,20 @@ * @param addr Virtual Address of instruction. * @return Pointer to a static buffer or NULL on error. */ -char *asm_mips_display_instr(asm_instr *ins,int addr) +char *asm_mips_display_instr(asm_instr *ins, eresi_Addr addr) { - static char buf[32+80]; - char *tmp = asm_mips_display_operand(ins,0x0,addr); - - bzero(buf,sizeof(buf)); - - if (tmp) - snprintf(buf,sizeof(buf),"%s %s",e_mips_instrs[ins->instr].mnemonic,asm_mips_display_operand(ins,0x0,addr)); - else - snprintf(buf,sizeof(buf),"%s",e_mips_instrs[ins->instr].mnemonic); - - return buf; + static char buf[120]; + char *tmp = NULL; + + tmp = asm_mips_display_operand(ins, 0, addr); + bzero(buf, sizeof(buf)); + + if (tmp) + snprintf(buf, sizeof(buf), "%s %s", + e_mips_instrs[ins->instr].mnemonic, + asm_mips_display_operand(ins, 0, addr)); + else + snprintf(buf, sizeof(buf), "%s", e_mips_instrs[ins->instr].mnemonic); + + return buf; } diff -Nru eresi-0.8a25/libasm/src/arch/mips/register_mips.c eresi-0.0.20110516/libasm/src/arch/mips/register_mips.c --- eresi-0.8a25/libasm/src/arch/mips/register_mips.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/register_mips.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,7 +1,11 @@ /** - * @file register_mips.c +* @file libasm/src/arch/mips/register_mips.c +** @ingroup mips +*/ +/** +* @file libasm/src/arch/mips/register_mips.c * @brief Registration of the MIPS disassembling vectors. - * $Id: register_mips.c,v 1.3 2008/03/13 16:15:37 strauss & pi3 Exp $ + * $Id: register_mips.c 1397 2009-09-13 02:19:08Z may $ * * fix and fill * - Adam 'pi3' Zabrocki diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/mips/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/mips/.svn/all-wcprops 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/942/trunk/libasm/src/arch/mips -END -tables_mips.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/942/trunk/libasm/src/arch/mips/tables_mips.c -END -mips_convert.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/mips_convert.c -END -output_mips.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/942/trunk/libasm/src/arch/mips/output_mips.c -END -init_mips.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/938/trunk/libasm/src/arch/mips/init_mips.c -END -register_mips.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/922/trunk/libasm/src/arch/mips/register_mips.c -END diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/entries eresi-0.0.20110516/libasm/src/arch/mips/.svn/entries --- eresi-0.8a25/libasm/src/arch/mips/.svn/entries 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/mips -http://svn.eresi-project.org/svn - - - -2008-03-27T11:27:27.668410Z -942 -pi3 - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -handlers -dir - -tables_mips.c -file - - - - -2008-04-06T23:16:04.350131Z -09a35b21b8e4b755745736b7b85653b2 -2008-03-27T11:27:27.668410Z -942 -pi3 - -operand_handlers -dir - -mips_convert.c -file - - - - -2008-04-06T23:16:04.370192Z -de3baf07b3cfe6773bf44d29ed02e1c4 -2008-03-26T17:25:46.832365Z -938 -pi3 - -output_mips.c -file - - - - -2008-04-06T23:16:04.381136Z -47eacd9cfdeed2e84af48ab2be5aef23 -2008-03-27T11:27:27.668410Z -942 -pi3 - -init_mips.c -file - - - - -2008-04-06T23:16:04.393143Z -4b4d49a8a3fefca69fc845b5104a5612 -2008-03-26T17:25:46.832365Z -938 -pi3 - -register_mips.c -file - - - - -2008-04-06T23:16:04.404318Z -5ef6dc3c048dcebd7073ee3f4d8bec7b -2008-03-21T13:17:35.285663Z -922 -pi3 - diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/format eresi-0.0.20110516/libasm/src/arch/mips/.svn/format --- eresi-0.8a25/libasm/src/arch/mips/.svn/format 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/init_mips.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/init_mips.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/init_mips.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/init_mips.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,162 +0,0 @@ -/** - * @file init_mips.c - * @brief This file have function for initializing and fetch code for MIPS architecture. - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - * Manuel Martin - 2007 - */ - -#include - - -/** - * @fn int asm_fetch_mips(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) - * @brief MIPS main fetching handler. - * - * This function is called by asm_read_instr. - * Function pointer is stored in asm_processor structure. - * - * @param ins Pointer to instruction structure to fill. - * @param buf Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @return Lengh of instruction or 0 on error. - */ -int asm_fetch_mips(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) -{ - vector_t *vec = 0; - u_int i = 0, converted = 0; - u_int dim[3]; - u_char *for_help; - LIBASM_HANDLER_FETCH(fetch); - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy((char *)&converted,buf,sizeof(converted)); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - for_help = (u_char*)&converted; - for(i=0;i<4;i++) - *(for_help + i) = *(buf + 3 - i); - } else { - printf("[INIT] Where am I ?!?!?!\n"); - exit(-1); - } - - ins->proc = proc; - ins->len = 4; - ins->ptr_instr = buf; - ins->nb_op = 0; - ins->type = ASM_TYPE_NONE; - - vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_MIPS); - -/* - * Instruction hierarchy, lacks COP0 COP1 COP2 and COP1X - * subclasses wich are fpu/privileged/coprocessor 2 stuff - * - * dim[0] = 0-63 = base class : 64 combinations - * dim[1] = 0-63 = SPECIAL subclass : 64 combinations - * dim[2] = 0-1 = MOVCI subclass - * dim[2] = 2-3 = SRL subclass - * dim[2] = 4-5 = SRLV subclass - * dim[1] = 64-95 = REGIMM subclass : 32 combinations - * dim[1] = 96-159 = SPECIAL2 subclass : 64 combinations - * dim[1] = 160-223 = SPECIAL3 subclass : 64 combinations - * dim[2] = 6-37 = BSHFL subclass : 32 combinations - */ - - dim[0] = converted >> 26; - dim[1] = 0; - dim[2] = 0; - - switch(dim[0]) - { - case MIPS_OPCODE_SPECIAL: - { - dim[1] = converted & 0x3f; - switch(dim[1]) - { - case MIPS_OPCODE_MOVCI: - dim[2] = (converted & 0x10000 ) >> 16; - break; - case MIPS_OPCODE_SRL: - dim[2] = ((converted & 0x200000 ) >> 21) + 2; - break; - case MIPS_OPCODE_SRLV: - dim[2] = ((converted & 0x40) >> 6) + 4; - break; - } - break; - } - case MIPS_OPCODE_REGIMM: - - dim[1] = ((converted >> 16) & 0x1F); - break; - - case MIPS_OPCODE_SPECIAL2: - - dim[1] = converted & 0x3F; - break; - - case MIPS_OPCODE_SPECIAL3: - - dim[1] = converted & 0x3F; - switch(dim[1]) - { - case MIPS_OPCODE_BSHFL: - dim[2] = ((converted & 0x7c0) >> 6) + 6; - } - break; - - case MIPS_OPCODE_COP0: - break; - case MIPS_OPCODE_COP1: - break; - case MIPS_OPCODE_COP2: - do { - u_int tmp = (converted >> 25) & 0x1; - - if (tmp) - dim[1] = tmp; - else { - dim[1] = (converted >> 21) & 0x1F; - if (dim[1] == MIPS_OPCODE_BC) - dim[2] = (converted >> 16) & 0x3; - } - } while(0); - break; - - case MIPS_OPCODE_COP1X: - - dim[1] = converted & 0x3F; - break; - - } - - fetch = aspect_vectors_select(vec,dim); - return (fetch(ins,(u_char *)&converted,len,proc)); -} - -/** - * @fn int asm_init_mips(asm_processor *proc) - * @brief MIPS initialization function to disassemble. - * - * This function fill asm_processor structure and call - * for register vectors. - * - * @param proc Pointer to a asm_processor structure. - * @return Always 0 - */ -int asm_init_mips(asm_processor *proc) -{ - proc->fetch = asm_fetch_mips; - proc->display_handle = asm_mips_display_instr; - proc->internals = 0; - proc->type = ASM_PROC_MIPS; - proc->instr_table = (char **)e_mips_instrs; - - asm_arch_register(proc, 0); - - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/mips_convert.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/mips_convert.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/mips_convert.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/mips_convert.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,226 +0,0 @@ -/** - * @file mips_convert.c - * @brief Convert MIPS instruction to definied types and fill suitable structures. - * - * $Id: mips_convert.c,v 1.4 2008/03/13 15:46:27 heroine && pi3 Exp $ - * - * Integrated to vectors - * - Adam 'pi3' Zabrocki - * - */ - -#include - -/** - * @fn void mips_convert_format_r(struct s_mips_decode_reg *opcode, u_char *buf) - * @brief Convert 'type r' instruction. - * - * Fill structure for 'type r' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_r(struct s_mips_decode_reg *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->rs = (converted >> 21) & 0x1F; - opcode->rt = (converted >> 16) & 0x1F; - opcode->rd = (converted >> 11) & 0x1F; - opcode->sa = (converted >> 6) & 0x1F; - opcode->fn = (converted >> 0) & 0x3F; - } else { - printf("[CONV_R] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_i(struct s_mips_decode_imm *opcode, u_char *buf) - * @brief Convert 'type i' instruction. - * - * Fill structure for 'type i' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_i(struct s_mips_decode_imm *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->rs = (converted >> 21) & 0x1F; - opcode->rt = (converted >> 16) & 0x1F; - opcode->im = (converted >> 0) & 0xFFFF; - } else { - printf("[CONV_I] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_j(struct s_mips_decode_jump *opcode, u_char *buf) - * @brief Convert 'type j' instruction. - * - * Fill structure for 'type j' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_j(struct s_mips_decode_jump *opcode, - u_char *buf) -{ - - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->ta = (converted >> 0) & 0x3FFFFFF; - } else { - printf("[CONV_J] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_t(struct s_mips_decode_trap *opcode, u_char *buf) - * @brief Convert 'trap' instruction. - * - * Fill structure for 'trap' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_t(struct s_mips_decode_trap *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->rs = (converted >> 21) & 0x1F; - opcode->rt = (converted >> 16) & 0x1F; - opcode->code = (converted >> 6) & 0x3FF; - opcode->fn = (converted >> 0) & 0x3F; - } else { - printf("[CONV_T] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_cop2(struct s_mips_decode_cop2 *opcode, u_char *buf) - * @brief Convert instrction from second coprocesor - * - * Fill structure for 'second coprocesor' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_cop2(struct s_mips_decode_cop2 *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->rs = (converted >> 21) & 0x1F; - opcode->rt = (converted >> 16) & 0x1F; - opcode->rd = (converted >> 11) & 0x1F; - opcode->fn = (converted >> 3) & 0xFF; - opcode->sl = (converted >> 0) & 0x7; - } else { - printf("[CONV_COP2] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_mov(struct s_mips_decode_mov *opcode, u_char *buf) - * @brief Convert *mov* instruction. - * - * Fill structure for 'mov' MIPS instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_mov(struct s_mips_decode_mov *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->rs = (converted >> 21) & 0x1F; - opcode->cc = (converted >> 18) & 0x7; - opcode->b1 = (converted >> 17) & 0x1; - opcode->tf = (converted >> 16) & 0x1; - opcode->rd = (converted >> 11) & 0x1F; - opcode->b2 = (converted >> 6) & 0x1F; - opcode->fn = (converted >> 0) & 0x3F; - } else { - printf("[CONV_MOV] Where am I ?!?!?!\n"); - exit(-1); - } - -} - -/** - * @fn void mips_convert_format_cop1x(struct s_mips_decode_mov *opcode, u_char *buf) - * @brief Convert COP1X instruction. - * - * Fill structure for MIPS COP1X instruction. - * - * @param opcode Pointer to structure which will be fill. - * @param buf Pointer to data -> instruction. - */ -void mips_convert_format_cop1x(struct s_mips_decode_cop1x *opcode, - u_char *buf) -{ - u_int32_t converted; - - if (asm_config_get_endian() == CONFIG_ASM_BIG_ENDIAN) { - memcpy(opcode, buf, 4); - } else if (asm_config_get_endian() == CONFIG_ASM_LITTLE_ENDIAN) { - memcpy(&converted, buf, 4); - opcode->op = (converted >> 26) & 0x3F; - opcode->bs = (converted >> 21) & 0x1F; - opcode->in = (converted >> 16) & 0x1F; - opcode->f1 = (converted >> 11) & 0x1F; - opcode->f2 = (converted >> 6) & 0x1F; - opcode->fn = (converted >> 3) & 0x3; - opcode->fmt = (converted >> 0) & 0x3; - } else { - printf("[CONV_MOV] Where am I ?!?!?!\n"); - exit(-1); - } - -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/output_mips.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/output_mips.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/output_mips.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/output_mips.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/** - * @file output_mips.c - * @brief This file respond for MIPS ASCII output engine... - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - */ -/* Manuel Martin - 2007 */ - -#include - -/** - * @fn char *asm_mips_display_operand(asm_instr *ins, int num, unsigned int addr) - * @brief Return ASCII representation of a mips operand - * - * @param ins Pointer to asm_instr structure. - * @param num Now it unused. - * @parram addr Virtual Address of instruction. - * @return A pointer to a static buffer or NULL on error. - */ -char *asm_mips_display_operand(asm_instr *ins, int num, unsigned int addr) -{ - unsigned int i; - static char bufer[80]; - char temp[4][20]; - - asm_operand *op; - memset(bufer,0x0,sizeof(bufer)); - for (i=0;i<4;i++) { - op = &ins->op[i]; - memset(&temp[i][0],0x0,sizeof(temp[i])); - switch(op->type) { - - case ASM_MIPS_OTYPE_REGISTER: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",%s" : "%s",(op->regset) ? e_mips_registers[op->baser].fpu_mnemonic : e_mips_registers[op->baser].ext_mnemonic); - break; - - case ASM_MIPS_OTYPE_IMMEDIATE: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",%d" : "%d",(short)op->imm); - break; - - case ASM_MIPS_OTYPE_JUMP: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",0x%x" : "0x%x",(op->imm << 2) | ((((addr + 8) >> 28) & 0xF) << 28)); - break; - - case ASM_MIPS_OTYPE_NONE: - case ASM_MIPS_OTYPE_NOOP: - -// snprintf(bufer,sizeof(bufer)," "); - - break; - - case ASM_MIPS_OTYPE_BRANCH: - - snprintf(temp[i],sizeof(temp[i]),(i) ? ",0x%x" : "0x%x",(addr+(((short)op->imm+1)*4))); - break; - - case ASM_MIPS_OTYPE_REGBASE: - - snprintf(temp[i],sizeof(temp[i]),"(%s)",(op->regset) ? e_mips_registers[op->baser].fpu_mnemonic : e_mips_registers[op->baser].ext_mnemonic); - break; - - } - } - - for (i=0;i<4;i++) - if (temp[i][0]) - strcat(bufer,temp[i]); - - return (bufer[0]) ? bufer : NULL; - -} - -/** - * @fn char *asm_mips_display_instr(asm_instr *ins,int addr) - * @brief Return ASCII representation of a mips instruction with operand. - * - * @param ins Pointer to instruction structure. - * @param addr Virtual Address of instruction. - * @return Pointer to a static buffer or NULL on error. - */ -char *asm_mips_display_instr(asm_instr *ins,int addr) -{ - static char buf[32+80]; - char *tmp = asm_mips_display_operand(ins,0x0,addr); - - bzero(buf,sizeof(buf)); - - if (tmp) - snprintf(buf,sizeof(buf),"%s %s",e_mips_instrs[ins->instr].mnemonic,asm_mips_display_operand(ins,0x0,addr)); - else - snprintf(buf,sizeof(buf),"%s",e_mips_instrs[ins->instr].mnemonic); - - return buf; -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/register_mips.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/register_mips.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/register_mips.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/register_mips.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -/** - * @file register_mips.c - * @brief Registration of the MIPS disassembling vectors. - * $Id: register_mips.c,v 1.3 2008/03/13 16:15:37 strauss & pi3 Exp $ - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - * Manuel Martin - 2007 - * This file contains mips architecture registration code. -*/ - -#include - -/** - * @fn int asm_register_mips_opcode(int op1,int op2,int op3, unsigned long fcn) - * @brief Register MIPS opcode handler. - * - * This function is called by asm_register_mips_opcodes() - * - * @param op1 First argument of instruction type. - * @param op2 Second argument of instruction type. - * @param op3 Third argument of instruction type. - * @param fcn Address for registered function. - * @return Always 1 - */ -int asm_register_mips_opcode(int op1,int op2,int op3, unsigned long fcn) -{ - vector_t *vec; - u_int dim[3]; - - LIBASM_PROFILE_FIN(); - - vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_MIPS); - dim[0] = op1; - dim[1] = op2; - dim[2] = op3; - - aspect_vectors_insert(vec,dim,fcn); - LIBASM_PROFILE_FOUT(1); -} - -/** - * @fn int asm_register_mips_opcodes() - * @brief Register MIPS opcode handlers. - * - * @return 1 on success - */ -int asm_register_mips_opcodes() -{ - int i = 0; - struct e_mips_instr *insns; - - insns = e_mips_instrs; - for(i=0;insns[i].code != ASM_MIPS_TABLE_END;i++) - { - asm_register_mips_opcode(insns[i].index1,insns[i].index2,insns[i].index3, (unsigned long) insns[i].func_op); - } - return (1); -} - -/** - * @fn int asm_register_mips() - * @brief Initialize the disassembling vector for MIPS. - * - * @return Always 1. - */ -int asm_register_mips() -{ - u_int *dims; - char **dimstr; - - dims = malloc(3 * sizeof (u_int)); - if (!dims) - { - goto out; - } - dimstr = malloc(3 * sizeof (char *)); - if (!dimstr) - { - goto out; - } - - /* TODO: These sizes _HAVE_ to be reviewed */ - dims[0] = 64; - dims[1] = 64; - dims[2] = 64; - - dimstr[0] = "OPCODES"; - dimstr[1] = "SECONDARY OPCODES"; /* Should be 0 when unused */ - dimstr[2] = "TERTIARY OPCODES"; /* Should be 0 when unused */ - - aspect_register_vector(LIBASM_VECTOR_OPCODE_MIPS, asm_fetch_default, - dims, dimstr, 3, ASPECT_TYPE_CADDR); - - /* Initializing MIPS operand handler vector */ - /* This section is just a stub for when the operand vector is actually - * implemented. */ - - dims = malloc(1 * sizeof (u_int)); - - if (!dims) - { - goto out; - } - dimstr = malloc(1 * sizeof (char *)); - if (!dimstr) - { - goto out; - } - - dims[0] = ASM_MIPS_OTYPE_LAST; - - dimstr[0] = "OPERAND"; - - aspect_register_vector(LIBASM_VECTOR_OPERAND_MIPS, asm_operand_fetch_default, - dims, dimstr, 1, ASPECT_TYPE_CADDR); - - asm_register_mips_opcodes(); - asm_register_mips_operands(); - - out: - return (1); -} - -/** - * @fn int asm_register_mips() - * @brief Register MIPS operand handlers. - * - * @return Always 1. - */ -int asm_register_mips_operands() -{ - asm_register_mips_operand(ASM_MIPS_OTYPE_NONE, (unsigned long) asm_mips_operand_none); - asm_register_mips_operand(ASM_MIPS_OTYPE_REGISTER, (unsigned long) asm_mips_operand_r); - asm_register_mips_operand(ASM_MIPS_OTYPE_IMMEDIATE, (unsigned long) asm_mips_operand_i); - asm_register_mips_operand(ASM_MIPS_OTYPE_JUMP, (unsigned long) asm_mips_operand_j); - asm_register_mips_operand(ASM_MIPS_OTYPE_NOOP, (unsigned long) asm_mips_operand_noop); - asm_register_mips_operand(ASM_MIPS_OTYPE_BRANCH, (unsigned long) asm_mips_operand_branch); - asm_register_mips_operand(ASM_MIPS_OTYPE_REGBASE, (unsigned long) asm_mips_operand_regbase); - - return 1; -} - - -/** - * @fn int asm_register_mips_operand(unsigned int type, unsigned long func) - * @brief Register MIPS operand handler. - * - * This function is called by asm_register_mips_operands() - * - * @param type Type of the operand to register. - * @param func Function pointer. - * @return 1 on success, 0 on error. - */ -int asm_register_mips_operand(unsigned int type, unsigned long func) -{ - LIBASM_PROFILE_FIN(); - asm_register_operand(LIBASM_VECTOR_OPERAND_MIPS, type, func); - LIBASM_PROFILE_FOUT(1); -} diff -Nru eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/tables_mips.c.svn-base eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/tables_mips.c.svn-base --- eresi-0.8a25/libasm/src/arch/mips/.svn/text-base/tables_mips.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/.svn/text-base/tables_mips.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,358 +0,0 @@ -/** - * @file tables_mips.c - * @brief MIPS processor mnemonic table. - * $Id: tables_i386.c,v 1.15 2008/03/13 16:32:56 pi3 Exp $ - * - * fix and fill - * - Adam 'pi3' Zabrocki - * - * - * Manuel Martin - 2007 - */ - -#include - -/** - * @struct e_mips_instrs - * @brief Fill in "struct e_mips_instr" - * - * This structure have filled "struct e_mips_instr" - * and it is used in register vectors for opcodes. - * - * First field have name for instruction. - * Second field have something like unique ID (ASM_MIPS_xxx) - * Third, Fourth and Fifth field have unequivocal identify instruction (0x0 when unused) - * Sixth field have pointer to handler. - */ -struct e_mips_instr e_mips_instrs [] = { - - -/* CPU: Arithmetic Instructions => ALL from MIPS Vol. 2 + Extra 2 */ - - {"add" ,ASM_MIPS_ADD ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_ADD ,0x0 ,asm_mips_add}, - {"addi" ,ASM_MIPS_ADDI ,MIPS_OPCODE_ADDI ,0x0 ,0x0 ,asm_mips_addi}, - {"addiu" ,ASM_MIPS_ADDIU ,MIPS_OPCODE_ADDIU ,0x0 ,0x0 ,asm_mips_addiu}, - {"addu" ,ASM_MIPS_ADDU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_ADDU ,0x0 ,asm_mips_addu}, - {"clo" ,ASM_MIPS_CLO ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_CLO ,0x0 ,asm_mips_clo}, - {"clz" ,ASM_MIPS_CLZ ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_CLZ ,0x0 ,asm_mips_clz}, -// - {"dadd" ,ASM_MIPS_DADD ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DADD ,0x0 ,asm_mips_dadd}, - {"daddi" ,ASM_MIPS_DADDI ,MIPS_OPCODE_DADDI ,0x0 ,0x0 ,asm_mips_daddi}, - {"daddiu" ,ASM_MIPS_DADDIU ,MIPS_OPCODE_DADDIU ,0x0 ,0x0 ,asm_mips_daddiu}, - {"daddu" ,ASM_MIPS_DADDU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DADDU ,0x0 ,asm_mips_daddu}, - {"dclo" ,ASM_MIPS_DCLO ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_DCLO ,0x0 ,asm_mips_dclo}, - {"dclz" ,ASM_MIPS_DCLZ ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_DCLZ ,0x0 ,asm_mips_dclz}, - {"ddiv" ,ASM_MIPS_DDIV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DDIV ,0x0 ,asm_mips_ddiv}, - {"ddivu" ,ASM_MIPS_DDIVU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DDIVU ,0x0 ,asm_mips_ddivu}, -// - {"div" ,ASM_MIPS_DIV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DIV ,0x0 ,asm_mips_div}, - {"divu" ,ASM_MIPS_DIVU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DIVU ,0x0 ,asm_mips_divu}, -// - {"dmult" ,ASM_MIPS_DMULT ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DMULT ,0x0 ,asm_mips_dmult}, - {"dmultu" ,ASM_MIPS_DMULTU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DMULTU ,0x0 ,asm_mips_dmultu}, - {"dsub" ,ASM_MIPS_DSUB ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSUB ,0x0 ,asm_mips_dsub}, - {"dsubu" ,ASM_MIPS_DSUBU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSUBU ,0x0 ,asm_mips_dsubu}, -// - {"madd" ,ASM_MIPS_MADD ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_MADD ,0x0 ,asm_mips_madd}, - {"maddu" ,ASM_MIPS_MADDU ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_MADDU ,0x0 ,asm_mips_maddu}, - {"msub" ,ASM_MIPS_MSUB ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_MSUB ,0x0 ,asm_mips_msub}, - {"msubu" ,ASM_MIPS_MSUBU ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_MSUBU ,0x0 ,asm_mips_msubu}, - {"mul" ,ASM_MIPS_MUL ,MIPS_OPCODE_SPECIAL2 ,MIPS_OPCODE_MUL ,0x0 ,asm_mips_mul}, - {"mult" ,ASM_MIPS_MULT ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MULT ,0x0 ,asm_mips_mult}, - {"multu" ,ASM_MIPS_MULTU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MULTU ,0x0 ,asm_mips_multu}, - {"slt" ,ASM_MIPS_SLT ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLT ,0x0 ,asm_mips_slt}, - {"slti" ,ASM_MIPS_SLTI ,MIPS_OPCODE_SLTI ,0x0 ,0x0 ,asm_mips_slti}, - {"sltiu" ,ASM_MIPS_SLTIU ,MIPS_OPCODE_SLTIU ,0x0 ,0x0 ,asm_mips_sltiu}, - {"sltu" ,ASM_MIPS_SLTU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLTU ,0x0 ,asm_mips_sltu}, - {"sub" ,ASM_MIPS_SUB ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SUB ,0x0 ,asm_mips_sub}, - {"subu" ,ASM_MIPS_SUBU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SUBU ,0x0 ,asm_mips_subu}, - /* Extra 2: */ - {"seb" ,ASM_MIPS_SEB ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_BSHFL ,MIPS_OPCODE_SEB ,asm_mips_seb}, - {"seh" ,ASM_MIPS_SEH ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_BSHFL ,MIPS_OPCODE_SEH ,asm_mips_seh}, - - -/* CPU: Branch and Jump Instructions => ALL from MIPS Vol. 2 + Extra 2 */ - - {"b" ,ASM_MIPS_B ,MIPS_OPCODE_BEQ ,0x0 ,0x0 ,asm_mips_b}, - {"bal" ,ASM_MIPS_BAL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BGEZAL ,0x0 ,asm_mips_bal}, - {"beq" ,ASM_MIPS_BEQ ,MIPS_OPCODE_BEQ ,0x0 ,0x0 ,asm_mips_beq}, - {"bgez" ,ASM_MIPS_BGEZ ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BGEZ ,0x0 ,asm_mips_bgez}, - {"bgezal" ,ASM_MIPS_BGEZAL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BGEZAL ,0x0 ,asm_mips_bgezal}, - {"bgtz" ,ASM_MIPS_BGTZ ,MIPS_OPCODE_BGTZ ,0x0 ,0x0 ,asm_mips_bgtz}, - {"blez" ,ASM_MIPS_BLEZ ,MIPS_OPCODE_BLEZ ,0x0 ,0x0 ,asm_mips_blez}, - {"bltz" ,ASM_MIPS_BLTZ ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BLTZ ,0x0 ,asm_mips_bltz}, - {"bltzal" ,ASM_MIPS_BLTZAL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BLTZAL ,0x0 ,asm_mips_bltzal}, - {"bne" ,ASM_MIPS_BNE ,MIPS_OPCODE_BNE ,0x0 ,0x0 ,asm_mips_bne}, - {"j" ,ASM_MIPS_J ,MIPS_OPCODE_J ,0x0 ,0x0 ,asm_mips_j}, - {"jal" ,ASM_MIPS_JAL ,MIPS_OPCODE_JAL ,0x0 ,0x0 ,asm_mips_jal}, - {"jalr" ,ASM_MIPS_JALR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_JALR ,0x0 ,asm_mips_jalr}, - {"jr" ,ASM_MIPS_JR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_JR ,0x0 ,asm_mips_jr}, - /* Extra 2: */ - {"jalr.hb" ,ASM_MIPS_JALR_HB ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_JALR ,0x0 ,asm_mips_jalr_hb}, - {"jr.hb" ,ASM_MIPS_JR_HB ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_JR ,0x0 ,asm_mips_jr_hb}, - - -/* CPU: Instruction Control Instructions => ALL from MIPS Vol. 2 + Extra 1 */ - - {"nop" ,ASM_MIPS_NOP ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLL ,MIPS_OPCODE_NOP ,asm_mips_nop}, - {"ssnop" ,ASM_MIPS_SSNOP ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLL ,MIPS_OPCODE_SSNOP ,asm_mips_ssnop}, - /* Extra 1: */ -// {"ehb" ,ASM_MIPS_EHB ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLL ,MIPS_OPCODE_EHB, asm_mips_ehb}, - - -/* CPU: Load, Store, and Memory Control Instructions => ALL from MIPS Vol. 2 + Extra 1 */ - - {"lb" ,ASM_MIPS_LB ,MIPS_OPCODE_LB ,0x0 ,0x0 ,asm_mips_lb}, - {"lbu" ,ASM_MIPS_LBU ,MIPS_OPCODE_LBU ,0x0 ,0x0 ,asm_mips_lbu}, -// - {"ld" ,ASM_MIPS_LD ,MIPS_OPCODE_LD ,0x0 ,0x0 ,asm_mips_ld}, - {"ldl" ,ASM_MIPS_LDL ,MIPS_OPCODE_LDL ,0x0 ,0x0 ,asm_mips_ldl}, - {"ldr" ,ASM_MIPS_LDR ,MIPS_OPCODE_LDR ,0x0 ,0x0 ,asm_mips_ldr}, -// - {"lh" ,ASM_MIPS_LH ,MIPS_OPCODE_LH ,0x0 ,0x0 ,asm_mips_lh}, - {"lhu" ,ASM_MIPS_LHU ,MIPS_OPCODE_LHU ,0x0 ,0x0 ,asm_mips_lhu}, - {"ll" ,ASM_MIPS_LL ,MIPS_OPCODE_LL ,0x0 ,0x0 ,asm_mips_ll}, -// - {"lld" ,ASM_MIPS_LLD ,MIPS_OPCODE_LLD ,0x0 ,0x0 ,asm_mips_lld}, -// - {"lw" ,ASM_MIPS_LW ,MIPS_OPCODE_LW ,0x0 ,0x0 ,asm_mips_lw}, - {"lwl" ,ASM_MIPS_LWL ,MIPS_OPCODE_LWL ,0x0 ,0x0 ,asm_mips_lwl}, - {"lwr" ,ASM_MIPS_LWR ,MIPS_OPCODE_LWR ,0x0 ,0x0 ,asm_mips_lwr}, -// - {"lwu" ,ASM_MIPS_LWU ,MIPS_OPCODE_LWU ,0x0 ,0x0 ,asm_mips_lwu}, -// - {"pref" ,ASM_MIPS_PREF ,MIPS_OPCODE_PREF ,0x0 ,0x0 ,asm_mips_pref}, - {"sb" ,ASM_MIPS_SB ,MIPS_OPCODE_SB ,0x0 ,0x0 ,asm_mips_sb}, - {"sc" ,ASM_MIPS_SC ,MIPS_OPCODE_SC ,0x0 ,0x0 ,asm_mips_sc}, -// - {"scd" ,ASM_MIPS_SCD ,MIPS_OPCODE_SCD ,0x0 ,0x0 ,asm_mips_scd}, - {"sd" ,ASM_MIPS_SD ,MIPS_OPCODE_SD ,0x0 ,0x0 ,asm_mips_sd}, - {"sdl" ,ASM_MIPS_SDL ,MIPS_OPCODE_SDL ,0x0 ,0x0 ,asm_mips_sdl}, - {"sdr" ,ASM_MIPS_SDR ,MIPS_OPCODE_SDR ,0x0 ,0x0 ,asm_mips_sdr}, -// - {"sh" ,ASM_MIPS_SH ,MIPS_OPCODE_SH ,0x0 ,0x0 ,asm_mips_sh}, - {"sw" ,ASM_MIPS_SW ,MIPS_OPCODE_SW ,0x0 ,0x0 ,asm_mips_sw}, - {"swl" ,ASM_MIPS_SWL ,MIPS_OPCODE_SWL ,0x0 ,0x0 ,asm_mips_swl}, - {"swr" ,ASM_MIPS_SWR ,MIPS_OPCODE_SWR ,0x0 ,0x0 ,asm_mips_swr}, - {"sync" ,ASM_MIPS_SYNC ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SYNC ,0x0 ,asm_mips_sync}, - /* Extra: 1 */ - {"synci" ,ASM_MIPS_SYNCI ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_SYNCI ,0x0 ,asm_mips_synci}, - - -/* CPU: Logical Instructions => ALL from MIPS Vol. 2 + Extra 3 */ - - {"and" ,ASM_MIPS_AND ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_AND ,0x0 ,asm_mips_and}, - {"andi" ,ASM_MIPS_ANDI ,MIPS_OPCODE_ANDI ,0x0 ,0x0 ,asm_mips_andi}, - {"lui" ,ASM_MIPS_LUI ,MIPS_OPCODE_LUI ,0x0 ,0x0 ,asm_mips_lui}, - {"nor" ,ASM_MIPS_NOR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_NOR ,0x0 ,asm_mips_nor}, - {"or" ,ASM_MIPS_OR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_OR ,0x0 ,asm_mips_or}, - {"ori" ,ASM_MIPS_ORI ,MIPS_OPCODE_ORI ,0x0 ,0x0 ,asm_mips_ori}, - {"xor" ,ASM_MIPS_XOR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_XOR ,0x0 ,asm_mips_xor}, - {"xori" ,ASM_MIPS_XORI ,MIPS_OPCODE_XORI ,0x0 ,0x0 ,asm_mips_xori}, - /* Extra: 3 */ - {"ext" ,ASM_MIPS_EXT ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_EXT ,0x0 ,asm_mips_ext}, - {"ins" ,ASM_MIPS_INS ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_INS ,0x0 ,asm_mips_ins}, - {"wsbh" ,ASM_MIPS_WSBH ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_BSHFL ,MIPS_OPCODE_WSBH ,asm_mips_wsbh}, - - -/* CPU: Move Instructions => ALL from MIPS Vol. 2 */ - - {"mfhi" ,ASM_MIPS_MFHI ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MFHI ,0x0 ,asm_mips_mfhi}, - {"mflo" ,ASM_MIPS_MFLO ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MFLO ,0x0 ,asm_mips_mflo}, - {"movf" ,ASM_MIPS_MOVF ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MOVCI ,MIPS_OPCODE_MOVF ,asm_mips_movf}, - {"movn" ,ASM_MIPS_MOVN ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MOVN ,0x0 ,asm_mips_movn}, - {"movt" ,ASM_MIPS_MOVT ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MOVCI ,MIPS_OPCODE_MOVT ,asm_mips_movt}, - {"movz" ,ASM_MIPS_MOVZ ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MOVZ ,0x0 ,asm_mips_movz}, - {"mthi" ,ASM_MIPS_MTHI ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MTHI ,0x0 ,asm_mips_mthi}, - {"mtlo" ,ASM_MIPS_MTLO ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_MTLO ,0x0 ,asm_mips_mtlo}, - - -/* CPU: Shift Instructions => ALL from MIPS Vol. 2 + Extra 3 */ - -// - - {"dsll" ,ASM_MIPS_DSLL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSLL ,0x0 ,asm_mips_dsll}, - {"dsll32" ,ASM_MIPS_DSLL32 ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSLL32 ,0x0 ,asm_mips_dsll32}, - {"dsllv" ,ASM_MIPS_DSLLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSLLV ,0x0 ,asm_mips_dsllv}, - {"dsra" ,ASM_MIPS_DSRA ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRA ,0x0 ,asm_mips_dsra}, - {"dsra32" ,ASM_MIPS_DSRA32 ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRA32 ,0x0 ,asm_mips_dsra32}, - {"dsrav" ,ASM_MIPS_DSRAV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRAV ,0x0 ,asm_mips_dsrav}, - {"dsrl" ,ASM_MIPS_DSRL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRL ,0x0 ,asm_mips_dsrl}, - {"dsrl32" ,ASM_MIPS_DSRL32 ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRL32 ,0x0 ,asm_mips_dsrl32}, - {"dsrlv" ,ASM_MIPS_DSRLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_DSRLV ,0x0 ,asm_mips_dsrlv}, -// - {"sll" ,ASM_MIPS_SLL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLL ,0x0 ,asm_mips_sll}, - {"sllv" ,ASM_MIPS_SLLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLLV ,0x0 ,asm_mips_sllv}, - {"sra" ,ASM_MIPS_SRA ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRA ,0x0 ,asm_mips_sra}, - {"srav" ,ASM_MIPS_SRAV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRAV ,0x0 ,asm_mips_srav}, - {"srl" ,ASM_MIPS_SRL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRL ,MIPS_OPCODE_SRL ,asm_mips_srl}, - {"srlv" ,ASM_MIPS_SRLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRLV ,MIPS_OPCODE_SRLV ,asm_mips_srlv}, - /* Extra: 3 */ - {"rdhwr" ,ASM_MIPS_RDHWR ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_RDHWR ,0x0 ,asm_mips_rdhwr}, - {"rotr" ,ASM_MIPS_ROTR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRL ,MIPS_OPCODE_ROTR ,asm_mips_rotr}, - {"rotrv" ,ASM_MIPS_ROTRV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRLV ,MIPS_OPCODE_ROTRV ,asm_mips_rotrv}, - - -/* CPU: Trap Instructions => ALL from MIPS Vol. 2 */ - - {"break" ,ASM_MIPS_BREAK ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_BREAK ,0x0 ,asm_mips_break}, - {"syscall" ,ASM_MIPS_SYSCALL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SYSCALL ,0x0 ,asm_mips_syscall}, - {"teq" ,ASM_MIPS_TEQ ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TEQ ,0x0 ,asm_mips_teq}, - {"teqi" ,ASM_MIPS_TEQI ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TEQI ,0x0 ,asm_mips_teqi}, - {"tge" ,ASM_MIPS_TGE ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TGE ,0x0 ,asm_mips_tge}, - {"tgei" ,ASM_MIPS_TGEI ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TGEI ,0x0 ,asm_mips_tgei}, - {"tgeiu" ,ASM_MIPS_TGEIU ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TGEIU ,0x0 ,asm_mips_tgeiu}, - {"tgeu" ,ASM_MIPS_TGEU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TGEU ,0x0 ,asm_mips_tgeu}, - {"tlt" ,ASM_MIPS_TLT ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TLT ,0x0 ,asm_mips_tlt}, - {"tlti" ,ASM_MIPS_TLTI ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TLTI ,0x0 ,asm_mips_tlti}, - {"tltiu" ,ASM_MIPS_TLTIU ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TLTIU ,0x0 ,asm_mips_tltiu}, - {"tltu" ,ASM_MIPS_TLTU ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TLTU ,0x0 ,asm_mips_tltu}, - {"tne" ,ASM_MIPS_TNE ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_TNE ,0x0 ,asm_mips_tne}, - {"tnei" ,ASM_MIPS_TNEI ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_TNEI ,0x0 ,asm_mips_tnei}, - - -/* CPU: Obsolete CPU Branch Instructions => ALL from MIPS Vol. 2 */ - - {"beql" ,ASM_MIPS_BEQL ,MIPS_OPCODE_BEQL ,0x0 ,0x0 ,asm_mips_beql}, - {"bgezall" ,ASM_MIPS_BGEZALL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BGEZALL ,0x0 ,asm_mips_bgezall}, - {"bgezl" ,ASM_MIPS_BGEZL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BGEZL ,0x0 ,asm_mips_bgezl}, - {"bgtzl" ,ASM_MIPS_BGTZL ,MIPS_OPCODE_BGTZL ,0x0 ,0x0 ,asm_mips_bgtzl}, - {"blezl" ,ASM_MIPS_BLEZL ,MIPS_OPCODE_BLEZL ,0x0 ,0x0 ,asm_mips_blezl}, - {"bltzall" ,ASM_MIPS_BLTZALL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BLTZALL ,0x0 ,asm_mips_bltzall}, - {"bltzl" ,ASM_MIPS_BLTZL ,MIPS_OPCODE_REGIMM ,MIPS_OPCODE_BLTZL ,0x0 ,asm_mips_bltzl}, - {"bnel" ,ASM_MIPS_BNEL ,MIPS_OPCODE_BNEL ,0x0 ,0x0 ,asm_mips_bnel}, - - -/* - -// FPU Arithmetic: - - abs.dmt - add.fmt - div.fmt - madd.fmt - msub.fmt - mul.fmt - ... - ... -*/ - - - -/* Coprocessor Branch Instructions - COP2 */ - - {"bc2f" ,ASM_MIPS_BC2F ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x0 ,asm_mips_bc2f}, - {"bc2t" ,ASM_MIPS_BC2T ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x1 ,asm_mips_bc2t}, - - -/* Coprocessor Execute Instruction - COP2 */ - - {"cop2" ,ASM_MIPS_COP2 ,MIPS_OPCODE_COP2 ,0x1 ,0x0 ,asm_mips_cop2}, - - -/* Coprocessor Load and Store Instructions - COP2 */ - - {"ldc2" ,ASM_MIPS_LDC2 ,MIPS_OPCODE_LDC2 ,0x0 ,0x0 ,asm_mips_ldc2}, - {"lwc2" ,ASM_MIPS_LWC2 ,MIPS_OPCODE_LWC2 ,0x0 ,0x0 ,asm_mips_lwc2}, - {"sdc2" ,ASM_MIPS_SDC2 ,MIPS_OPCODE_SDC2 ,0x0 ,0x0 ,asm_mips_sdc2}, - {"swc2" ,ASM_MIPS_SWC2 ,MIPS_OPCODE_SWC2 ,0x0 ,0x0 ,asm_mips_swc2}, - - -/* Coprocessor Move Instructions - COP2 */ - - {"cfc2" ,ASM_MIPS_CFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CF ,0x0 ,asm_mips_cfc2}, - {"ctc2" ,ASM_MIPS_CTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CT ,0x0 ,asm_mips_ctc2}, - {"dmfc2" ,ASM_MIPS_DMFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMF ,0x0 ,asm_mips_dmfc2}, - {"dmtc2" ,ASM_MIPS_DMTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMT ,0x0 ,asm_mips_dmtc2}, - {"mfc2" ,ASM_MIPS_MFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MF ,0x0 ,asm_mips_mfc2}, - {"mtc2" ,ASM_MIPS_MTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MT ,0x0 ,asm_mips_mtc2}, - - - -/* Obsolute Coprocessor Branch Instructions - COP2 */ - - {"bc2fl" ,ASM_MIPS_BC2FL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x2 ,asm_mips_bc2fl}, - {"bc2tl" ,ASM_MIPS_BC2TL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x3 ,asm_mips_bc2tl}, - - -/* COP1X Instructions */ - - {"lwxc1" ,ASM_MIPS_LWXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_LWXC1 ,0x0 ,asm_mips_lwxc1}, - {"ldxc1" ,ASM_MIPS_LDXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_LDXC1 ,0x0 ,asm_mips_ldxc1}, - {"luxc1" ,ASM_MIPS_LUXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_LUXC1 ,0x0 ,asm_mips_luxc1}, - {"swxc1" ,ASM_MIPS_SWXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_SWXC1 ,0x0 ,asm_mips_swxc1}, - {"sdxc1" ,ASM_MIPS_SDXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_SDXC1 ,0x0 ,asm_mips_sdxc1}, - {"suxc1" ,ASM_MIPS_SUXC1 ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_SUXC1 ,0x0 ,asm_mips_suxc1}, - {"prefx" ,ASM_MIPS_PREFX ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_PREFX ,0x0 ,asm_mips_prefx}, - {"alnv.ps" ,ASM_MIPS_ALNV_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_ALNV_PS ,0x0 ,asm_mips_alnv_ps}, - {"madd.s" ,ASM_MIPS_MADD_S ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MADD_S ,0x0 ,asm_mips_madd_s}, - {"madd.d" ,ASM_MIPS_MADD_D ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MADD_D ,0x0 ,asm_mips_madd_d}, - {"madd.ps" ,ASM_MIPS_MADD_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MADD_PS ,0x0 ,asm_mips_madd_ps}, - {"msub.s" ,ASM_MIPS_MSUB_S ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MSUB_S ,0x0 ,asm_mips_msub_s}, - {"msub.d" ,ASM_MIPS_MSUB_D ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MSUB_D ,0x0 ,asm_mips_msub_d}, - {"msub.ps" ,ASM_MIPS_MSUB_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_MSUB_PS ,0x0 ,asm_mips_msub_ps}, - {"nmadd.s" ,ASM_MIPS_NMADD_S ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMADD_S ,0x0 ,asm_mips_nmadd_s}, - {"nmadd.d" ,ASM_MIPS_NMADD_D ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMADD_D ,0x0 ,asm_mips_nmadd_d}, - {"nmadd.ps" ,ASM_MIPS_NMADD_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMADD_PS ,0x0 ,asm_mips_nmadd_ps}, - {"nmsub.s" ,ASM_MIPS_NMSUB_S ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMSUB_S ,0x0 ,asm_mips_nmsub_s}, - {"nmsub.d" ,ASM_MIPS_NMSUB_D ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMSUB_D ,0x0 ,asm_mips_nmsub_d}, - {"nmsub.ps" ,ASM_MIPS_NMSUB_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMSUB_PS ,0x0 ,asm_mips_nmsub_ps}, - - - /*TODO - * - FPU insns - * - privileged insns - */ - - /* mnemonic code index1 index 2 index 3 func pointer */ - { (const char *) -1, (int) -1, (int) -1, (int) -1, (int) -1, NULL } -}; - -/** - * @struct e_mips_registers - * @brief Fill in "struct e_mips_register" - * - * This structure have filled "struct e_mips_instr" - * - * First field have name for register. - * Second field have alternative name for register. - * Third field have unique ID (ASM_MIPS_REG_xxx) - */ -struct e_mips_register e_mips_registers [] = { - {"zero","r0","f0",ASM_MIPS_REG_ZERO}, - {"at","r1","f1",ASM_MIPS_REG_AT}, - {"v0","r2","f2",ASM_MIPS_REG_V0}, - {"v1","r3","f3",ASM_MIPS_REG_V1}, - {"a0","r4","f4",ASM_MIPS_REG_A0}, - {"a1","r5","f5",ASM_MIPS_REG_A1}, - {"a2","r6","f6",ASM_MIPS_REG_A2}, - {"a3","r7","f7",ASM_MIPS_REG_A3}, - {"t0","r8","f8",ASM_MIPS_REG_T0}, - {"t1","r9","f9",ASM_MIPS_REG_T1}, - {"t2","r10","f10",ASM_MIPS_REG_T2}, - {"t3","r11","f11",ASM_MIPS_REG_T3}, - {"t4","r12","f12",ASM_MIPS_REG_T4}, - {"t5","r13","f13",ASM_MIPS_REG_T5}, - {"t6","r14","f14",ASM_MIPS_REG_T6}, - {"t7","r15","f15",ASM_MIPS_REG_T7}, - {"s0","r16","f16",ASM_MIPS_REG_S0}, - {"s1","r17","f17",ASM_MIPS_REG_S1}, - {"s2","r18","f18",ASM_MIPS_REG_S2}, - {"s3","r19","f19",ASM_MIPS_REG_S3}, - {"s4","r20","f20",ASM_MIPS_REG_S4}, - {"s5","r21","f21",ASM_MIPS_REG_S5}, - {"s6","r22","f22",ASM_MIPS_REG_S6}, - {"s7","r23","f23",ASM_MIPS_REG_S7}, - {"t8","r24","f24",ASM_MIPS_REG_T8}, - {"t9","r25","f25",ASM_MIPS_REG_T9}, - {"k0","r26","f26",ASM_MIPS_REG_K0}, - {"k1","r27","f27",ASM_MIPS_REG_K1}, - {"gp","r28","f28",ASM_MIPS_REG_GP}, - {"sp","r29","f29",ASM_MIPS_REG_SP}, - {"fp","r30","f30",ASM_MIPS_REG_FP}, - {"ra","r31","f31",ASM_MIPS_REG_RA}, -// {-1,-1,-1} - /* ext_mnemonic mnemonic fpu_mnemonic code */ - { (const char *) -1, (const char *) -1, (const char *) -1, (int) -1 } -}; - diff -Nru eresi-0.8a25/libasm/src/arch/mips/tables_mips.c eresi-0.0.20110516/libasm/src/arch/mips/tables_mips.c --- eresi-0.8a25/libasm/src/arch/mips/tables_mips.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/mips/tables_mips.c 2011-05-16 11:34:28.000000000 +0000 @@ -1,7 +1,11 @@ /** - * @file tables_mips.c +* @file libasm/src/arch/mips/tables_mips.c +** @ingroup mips +*/ +/** +* @file libasm/src/arch/mips/tables_mips.c * @brief MIPS processor mnemonic table. - * $Id: tables_i386.c,v 1.15 2008/03/13 16:32:56 pi3 Exp $ + * $Id: tables_mips.c 1397 2009-09-13 02:19:08Z may $ * * fix and fill * - Adam 'pi3' Zabrocki @@ -185,8 +189,8 @@ {"sllv" ,ASM_MIPS_SLLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SLLV ,0x0 ,asm_mips_sllv}, {"sra" ,ASM_MIPS_SRA ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRA ,0x0 ,asm_mips_sra}, {"srav" ,ASM_MIPS_SRAV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRAV ,0x0 ,asm_mips_srav}, - {"srl" ,ASM_MIPS_SRL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRL ,MIPS_OPCODE_SRL ,asm_mips_srl}, - {"srlv" ,ASM_MIPS_SRLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRLV ,MIPS_OPCODE_SRLV ,asm_mips_srlv}, + {"srl" ,ASM_MIPS_SRL ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRL ,0x0 ,asm_mips_srl}, + {"srlv" ,ASM_MIPS_SRLV ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRLV ,0x0 ,asm_mips_srlv}, /* Extra: 3 */ {"rdhwr" ,ASM_MIPS_RDHWR ,MIPS_OPCODE_SPECIAL3 ,MIPS_OPCODE_RDHWR ,0x0 ,asm_mips_rdhwr}, {"rotr" ,ASM_MIPS_ROTR ,MIPS_OPCODE_SPECIAL ,MIPS_OPCODE_SRL ,MIPS_OPCODE_ROTR ,asm_mips_rotr}, @@ -223,26 +227,10 @@ {"bnel" ,ASM_MIPS_BNEL ,MIPS_OPCODE_BNEL ,0x0 ,0x0 ,asm_mips_bnel}, -/* - -// FPU Arithmetic: - - abs.dmt - add.fmt - div.fmt - madd.fmt - msub.fmt - mul.fmt - ... - ... -*/ - - - /* Coprocessor Branch Instructions - COP2 */ - {"bc2f" ,ASM_MIPS_BC2F ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x0 ,asm_mips_bc2f}, - {"bc2t" ,ASM_MIPS_BC2T ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x1 ,asm_mips_bc2t}, + {"bc2f" ,ASM_MIPS_BC2F ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BCC2 ,0x0 ,asm_mips_bc2f}, + {"bc2t" ,ASM_MIPS_BC2T ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BCC2 ,0x1 ,asm_mips_bc2t}, /* Coprocessor Execute Instruction - COP2 */ @@ -260,19 +248,19 @@ /* Coprocessor Move Instructions - COP2 */ - {"cfc2" ,ASM_MIPS_CFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CF ,0x0 ,asm_mips_cfc2}, - {"ctc2" ,ASM_MIPS_CTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CT ,0x0 ,asm_mips_ctc2}, - {"dmfc2" ,ASM_MIPS_DMFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMF ,0x0 ,asm_mips_dmfc2}, - {"dmtc2" ,ASM_MIPS_DMTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMT ,0x0 ,asm_mips_dmtc2}, - {"mfc2" ,ASM_MIPS_MFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MF ,0x0 ,asm_mips_mfc2}, - {"mtc2" ,ASM_MIPS_MTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MT ,0x0 ,asm_mips_mtc2}, + {"cfc2" ,ASM_MIPS_CFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CFC2 ,0x0 ,asm_mips_cfc2}, + {"ctc2" ,ASM_MIPS_CTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_CTC2 ,0x0 ,asm_mips_ctc2}, + {"dmfc2" ,ASM_MIPS_DMFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMFC2 ,0x0 ,asm_mips_dmfc2}, + {"dmtc2" ,ASM_MIPS_DMTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_DMTC2 ,0x0 ,asm_mips_dmtc2}, + {"mfc2" ,ASM_MIPS_MFC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MFC2 ,0x0 ,asm_mips_mfc2}, + {"mtc2" ,ASM_MIPS_MTC2 ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_MTC2 ,0x0 ,asm_mips_mtc2}, /* Obsolute Coprocessor Branch Instructions - COP2 */ - {"bc2fl" ,ASM_MIPS_BC2FL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x2 ,asm_mips_bc2fl}, - {"bc2tl" ,ASM_MIPS_BC2TL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BC ,0x3 ,asm_mips_bc2tl}, + {"bc2fl" ,ASM_MIPS_BC2FL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BCC2 ,0x2 ,asm_mips_bc2fl}, + {"bc2tl" ,ASM_MIPS_BC2TL ,MIPS_OPCODE_COP2 ,MIPS_OPCODE_BCC2 ,0x3 ,asm_mips_bc2tl}, /* COP1X Instructions */ @@ -299,11 +287,190 @@ {"nmsub.ps" ,ASM_MIPS_NMSUB_PS ,MIPS_OPCODE_COP1X ,MIPS_OPCODE_NMSUB_PS ,0x0 ,asm_mips_nmsub_ps}, +/* Privileged Instructions - COP0 */ + + {"mfc0" ,ASM_MIPS_MFC0 ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_MFC0 ,0x0 ,asm_mips_mfc0}, // ! + {"dmfc0" ,ASM_MIPS_DMFC0 ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_DMFC0 ,0x0 ,asm_mips_dmfc0}, // ! + {"tlbwi" ,ASM_MIPS_TLBWI ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_TLBWI ,0x0 ,asm_mips_tlbwi}, + {"mtc0" ,ASM_MIPS_MTC0 ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_MTC0 ,0x0 ,asm_mips_mtc0}, // ! + {"dmtc0" ,ASM_MIPS_DMTC0 ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_DMTC0 ,0x0 ,asm_mips_dmtc0}, // ! + {"tlbwr" ,ASM_MIPS_TLBWR ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_TLBWR ,0x0 ,asm_mips_tlbwr}, + {"eret" ,ASM_MIPS_ERET ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_ERET ,0x0 ,asm_mips_eret}, + {"tlbp" ,ASM_MIPS_TLBP ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_TLBP ,0x0 ,asm_mips_tlbp}, + {"tlbr" ,ASM_MIPS_TLBR ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_TLBR ,0x0 ,asm_mips_tlbr}, + {"wait" ,ASM_MIPS_WAIT ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_WAIT ,0x0 ,asm_mips_wait}, + +/* EJTAG Instruction... */ + + {"deret" ,ASM_MIPS_DERET ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_DERET ,0x0 ,asm_mips_deret}, + {"sdbbp" ,ASM_MIPS_SDBBP ,MIPS_OPCODE_COP0 ,MIPS_OPCODE_SDBBP ,0x0 ,asm_mips_sdbbp}, + + /*TODO * - FPU insns - * - privileged insns */ - + +/* FPU arithmetics */ + + {"abs.s" ,ASM_MIPS_ABS_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_ABS ,MIPS_OPCODE_FMT_S ,asm_mips_abs_s}, // ! + {"abs.d" ,ASM_MIPS_ABS_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_ABS ,MIPS_OPCODE_FMT_D ,asm_mips_abs_d}, // ! + {"abs.ps" ,ASM_MIPS_ABS_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_ABS ,MIPS_OPCODE_FMT_PS ,asm_mips_abs_ps}, + {"add.s" ,ASM_MIPS_ADD_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ADD ,MIPS_OPCODE_FMT_S ,asm_mips_add_s}, // ! + {"add.d" ,ASM_MIPS_ADD_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ADD ,MIPS_OPCODE_FMT_D ,asm_mips_add_d}, // ! + {"add.ps" ,ASM_MIPS_ADD_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ADD ,MIPS_OPCODE_FMT_PS ,asm_mips_add_ps}, +// <--- START ---> + {"div.s" ,ASM_MIPS_DIV_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_DIV ,MIPS_OPCODE_FMT_S ,asm_mips_div_s}, + {"div.d" ,ASM_MIPS_DIV_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_DIV ,MIPS_OPCODE_FMT_D ,asm_mips_div_d}, + {"mul.s" ,ASM_MIPS_MUL_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MUL ,MIPS_OPCODE_FMT_S ,asm_mips_mul_s}, // ! + {"mul.d" ,ASM_MIPS_MUL_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MUL ,MIPS_OPCODE_FMT_D ,asm_mips_mul_d}, // ! + {"mul.ps" ,ASM_MIPS_MUL_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MUL ,MIPS_OPCODE_FMT_PS ,asm_mips_mul_ps}, + {"neg.s" ,ASM_MIPS_NEG_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_NEG ,MIPS_OPCODE_FMT_S ,asm_mips_neg_s}, // ! + {"neg.d" ,ASM_MIPS_NEG_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_NEG ,MIPS_OPCODE_FMT_D ,asm_mips_neg_d}, // ! + {"neg.ps" ,ASM_MIPS_NEG_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_NEG ,MIPS_OPCODE_FMT_PS ,asm_mips_neg_ps}, + {"recip.s" ,ASM_MIPS_RECIP_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_RECIP ,MIPS_OPCODE_FMT_S ,asm_mips_recip_s}, + {"recip.d" ,ASM_MIPS_RECIP_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_RECIP ,MIPS_OPCODE_FMT_D ,asm_mips_recip_d}, + {"rsqrt.s" ,ASM_MIPS_RSQRT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_RSQRT ,MIPS_OPCODE_FMT_S ,asm_mips_rsqrt_s}, + {"rsqrt.d" ,ASM_MIPS_RSQRT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_RSQRT ,MIPS_OPCODE_FMT_D ,asm_mips_rsqrt_d}, + {"sqrt.s" ,ASM_MIPS_SQRT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_SQRT ,MIPS_OPCODE_FMT_S ,asm_mips_sqrt_s}, + {"sqrt.d" ,ASM_MIPS_SQRT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_SQRT ,MIPS_OPCODE_FMT_D ,asm_mips_sqrt_d}, + {"sub.s" ,ASM_MIPS_SUB_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_SUB ,MIPS_OPCODE_FMT_S ,asm_mips_sub_s}, // ! + {"sub.d" ,ASM_MIPS_SUB_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_SUB ,MIPS_OPCODE_FMT_D ,asm_mips_sub_d}, // ! + {"sub.ps" ,ASM_MIPS_SUB_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_SUB ,MIPS_OPCODE_FMT_PS ,asm_mips_sub_ps}, + +/* FPU Branch Instructions */ + + {"bc1f" ,ASM_MIPS_BC1F ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_BCC2 ,0x0 ,asm_mips_bc1f}, + {"bc1t" ,ASM_MIPS_BC1T ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_BCC2 ,0x1 ,asm_mips_bc1t}, + +/* FPU Convert Instructions */ + + {"ceil.l.s" ,ASM_MIPS_CEIL_L_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CEIL_L ,MIPS_OPCODE_FMT_S ,asm_mips_ceil_l_s}, + {"ceil.l.d" ,ASM_MIPS_CEIL_L_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CEIL_L ,MIPS_OPCODE_FMT_D ,asm_mips_ceil_l_d}, + {"ceil.w.s" ,ASM_MIPS_CEIL_W_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CEIL_W ,MIPS_OPCODE_FMT_S ,asm_mips_ceil_w_s}, + {"ceil.w.d" ,ASM_MIPS_CEIL_W_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CEIL_W ,MIPS_OPCODE_FMT_D ,asm_mips_ceil_w_d}, + + {"cvt.d.s" ,ASM_MIPS_CVT_D_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_D ,MIPS_OPCODE_FMT_S ,asm_mips_cvt_d_s}, + {"cvt.d.w" ,ASM_MIPS_CVT_D_W ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_D ,MIPS_OPCODE_FMT_W ,asm_mips_cvt_d_w}, + {"cvt.d.l" ,ASM_MIPS_CVT_D_L ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_D ,MIPS_OPCODE_FMT_L ,asm_mips_cvt_d_l}, + {"cvt.l.s" ,ASM_MIPS_CVT_L_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_L ,MIPS_OPCODE_FMT_S ,asm_mips_cvt_l_s}, + {"cvt.l.d" ,ASM_MIPS_CVT_L_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_L ,MIPS_OPCODE_FMT_D ,asm_mips_cvt_l_d}, + {"cvt.ps.s" ,ASM_MIPS_CVT_PS_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_PS_S ,MIPS_OPCODE_FMT_S ,asm_mips_cvt_ps_s}, + {"cvt.s.d" ,ASM_MIPS_CVT_S_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_S ,MIPS_OPCODE_FMT_D ,asm_mips_cvt_s_d}, + {"cvt.s.w" ,ASM_MIPS_CVT_S_W ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_S ,MIPS_OPCODE_FMT_W ,asm_mips_cvt_s_w}, + {"cvt.s.l" ,ASM_MIPS_CVT_S_L ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_S ,MIPS_OPCODE_FMT_L ,asm_mips_cvt_s_l}, + {"cvt.s.pl" ,ASM_MIPS_CVT_S_PL ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_S_PL ,MIPS_OPCODE_FMT_PS ,asm_mips_cvt_s_pl}, + {"cvt.s.pu" ,ASM_MIPS_CVT_S_PU ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_S ,MIPS_OPCODE_FMT_PS ,asm_mips_cvt_s_pu}, + {"cvt.w.s" ,ASM_MIPS_CVT_W_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_W ,MIPS_OPCODE_FMT_S ,asm_mips_cvt_w_s}, + {"cvt.w.d" ,ASM_MIPS_CVT_W_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CVT_W ,MIPS_OPCODE_FMT_D ,asm_mips_cvt_w_d}, + + {"floor.l.s",ASM_MIPS_FLOOR_L_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_FLOOR_L,MIPS_OPCODE_FMT_S ,asm_mips_floor_l_s}, + {"floor.l.d",ASM_MIPS_FLOOR_L_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_FLOOR_L,MIPS_OPCODE_FMT_D ,asm_mips_floor_l_d}, + {"floor.w.s",ASM_MIPS_FLOOR_W_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_FLOOR_W,MIPS_OPCODE_FMT_S ,asm_mips_floor_w_s}, + {"floor.w.d",ASM_MIPS_FLOOR_W_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_FLOOR_W,MIPS_OPCODE_FMT_D ,asm_mips_floor_w_d}, + + {"round.l.s",ASM_MIPS_ROUND_L_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ROUND_L,MIPS_OPCODE_FMT_S ,asm_mips_round_l_s}, + {"round.l.d",ASM_MIPS_ROUND_L_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ROUND_L,MIPS_OPCODE_FMT_D ,asm_mips_round_l_d}, + {"round.w.s",ASM_MIPS_ROUND_W_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ROUND_W,MIPS_OPCODE_FMT_S ,asm_mips_round_w_s}, + {"round.w.d",ASM_MIPS_ROUND_W_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_ROUND_W,MIPS_OPCODE_FMT_D ,asm_mips_round_w_d}, + + {"trunc.l.s",ASM_MIPS_TRUNC_L_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_TRUNC_L,MIPS_OPCODE_FMT_S ,asm_mips_trunc_l_s}, + {"trunc.l.d",ASM_MIPS_TRUNC_L_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_TRUNC_L,MIPS_OPCODE_FMT_D ,asm_mips_trunc_l_d}, + {"trunc.w.s",ASM_MIPS_TRUNC_W_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_TRUNC_W,MIPS_OPCODE_FMT_S ,asm_mips_trunc_w_s}, + {"trunc.w.d",ASM_MIPS_TRUNC_W_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_TRUNC_W,MIPS_OPCODE_FMT_D ,asm_mips_trunc_w_d}, + + /* FPU Load, Store and Memory Control Instructions */ + + {"ldc1" ,ASM_MIPS_LDC1 ,MIPS_OPCODE_LDC1 ,0x0 ,0x0 ,asm_mips_ldc1}, + {"lwc1" ,ASM_MIPS_LWC1 ,MIPS_OPCODE_LWC1 ,0x0 ,0x0 ,asm_mips_lwc1}, + {"sdc1" ,ASM_MIPS_SDC1 ,MIPS_OPCODE_SDC1 ,0x0 ,0x0 ,asm_mips_sdc1}, + {"swc1" ,ASM_MIPS_SWC1 ,MIPS_OPCODE_SWC1 ,0x0 ,0x0 ,asm_mips_swc1}, + + /* FPU Move Instructions */ + + {"cfc1" ,ASM_MIPS_CFC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CFC1 ,0x0 ,asm_mips_cfc1}, + {"ctc1" ,ASM_MIPS_CTC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_CTC1 ,0x0 ,asm_mips_ctc1}, + {"mfc1" ,ASM_MIPS_MFC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MFC1 ,0x0 ,asm_mips_mfc1}, + {"mtc1" ,ASM_MIPS_MTC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MTC1 ,0x0 ,asm_mips_mtc1}, + + {"mov.s" ,ASM_MIPS_MOV_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOV ,MIPS_OPCODE_FMT_S ,asm_mips_mov_s}, + {"mov.d" ,ASM_MIPS_MOV_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOV ,MIPS_OPCODE_FMT_D ,asm_mips_mov_d}, + {"mov.ps" ,ASM_MIPS_MOV_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOV ,MIPS_OPCODE_FMT_PS ,asm_mips_mov_ps}, + + {"movf.s" ,ASM_MIPS_MOVF_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_S ,asm_mips_movcf_s}, + {"movf.d" ,ASM_MIPS_MOVF_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_D ,asm_mips_movcf_d}, + {"movf.ps" ,ASM_MIPS_MOVF_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_PS ,asm_mips_movcf_ps}, + + {"movt.s" ,ASM_MIPS_MOVT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_S ,asm_mips_movcf_s}, + {"movt.d" ,ASM_MIPS_MOVT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_D ,asm_mips_movcf_d}, + {"movt.ps" ,ASM_MIPS_MOVT_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVCF ,MIPS_OPCODE_FMT_PS ,asm_mips_movcf_ps}, + + {"movn.s" ,ASM_MIPS_MOVN_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVN ,MIPS_OPCODE_FMT_S ,asm_mips_movn_s}, + {"movn.d" ,ASM_MIPS_MOVN_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVN ,MIPS_OPCODE_FMT_D ,asm_mips_movn_d}, + {"movn.ps" ,ASM_MIPS_MOVN_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVN ,MIPS_OPCODE_FMT_PS ,asm_mips_movn_ps}, + + {"movz.s" ,ASM_MIPS_MOVZ_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVZ ,MIPS_OPCODE_FMT_S ,asm_mips_movz_s}, + {"movz.d" ,ASM_MIPS_MOVZ_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVZ ,MIPS_OPCODE_FMT_D ,asm_mips_movz_d}, + {"movz.ps" ,ASM_MIPS_MOVZ_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_F_MOVZ ,MIPS_OPCODE_FMT_PS ,asm_mips_movz_ps}, + + /* FPU Absolute Branch Instructions */ + + {"bc1fl" ,ASM_MIPS_BC1FL ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_BCC2 ,0x2 ,asm_mips_bc1fl}, + {"bc1tl" ,ASM_MIPS_BC1TL ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_BCC2 ,0x3 ,asm_mips_bc1tl}, + + /* BUGFIX */ + {"dmtc1" ,ASM_MIPS_DMTC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_DMTC2 ,0x0 ,asm_mips_dmtc1}, + {"dmfc1" ,ASM_MIPS_DMFC1 ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_DMFC2 ,0x0 ,asm_mips_dmfc1}, + + /* C.cond.fmt glupie instrukcje :) */ + {"c.f.s" ,ASM_MIPS_C_F_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_F ,MIPS_OPCODE_FMT_S ,asm_mips_c_f_s}, + {"c.f.d" ,ASM_MIPS_C_F_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_F ,MIPS_OPCODE_FMT_D ,asm_mips_c_f_d}, + {"c.f.ps" ,ASM_MIPS_C_F_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_F ,MIPS_OPCODE_FMT_PS ,asm_mips_c_f_ps}, + {"c.un.s" ,ASM_MIPS_C_UN_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UN ,MIPS_OPCODE_FMT_S ,asm_mips_c_un_s}, + {"c.un.d" ,ASM_MIPS_C_UN_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UN ,MIPS_OPCODE_FMT_D ,asm_mips_c_un_d}, + {"c.un.ps" ,ASM_MIPS_C_UN_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UN ,MIPS_OPCODE_FMT_PS ,asm_mips_c_un_ps}, + {"c.eq.s" ,ASM_MIPS_C_EQ_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_EQ ,MIPS_OPCODE_FMT_S ,asm_mips_c_eq_s}, + {"c.eq.d" ,ASM_MIPS_C_EQ_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_EQ ,MIPS_OPCODE_FMT_D ,asm_mips_c_eq_d}, + {"c.eq.ps" ,ASM_MIPS_C_EQ_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_EQ ,MIPS_OPCODE_FMT_PS ,asm_mips_c_eq_ps}, + {"c.ueq.s" ,ASM_MIPS_C_UEQ_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UEQ ,MIPS_OPCODE_FMT_S ,asm_mips_c_ueq_s}, + {"c.ueq.d" ,ASM_MIPS_C_UEQ_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UEQ ,MIPS_OPCODE_FMT_D ,asm_mips_c_ueq_d}, + {"c.ueq.ps" ,ASM_MIPS_C_UEQ_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_UEQ ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ueq_ps}, + {"c.olt.s" ,ASM_MIPS_C_OLT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLT ,MIPS_OPCODE_FMT_S ,asm_mips_c_olt_s}, + {"c.olt.d" ,ASM_MIPS_C_OLT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLT ,MIPS_OPCODE_FMT_D ,asm_mips_c_olt_d}, + {"c.olt.ps" ,ASM_MIPS_C_OLT_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLT ,MIPS_OPCODE_FMT_PS ,asm_mips_c_olt_ps}, + {"c.ult.s" ,ASM_MIPS_C_ULT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULT ,MIPS_OPCODE_FMT_S ,asm_mips_c_ult_s}, + {"c.ult.d" ,ASM_MIPS_C_ULT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULT ,MIPS_OPCODE_FMT_D ,asm_mips_c_ult_d}, + {"c.ult.ps" ,ASM_MIPS_C_ULT_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULT ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ult_ps}, + {"c.ole.s" ,ASM_MIPS_C_OLE_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLE ,MIPS_OPCODE_FMT_S ,asm_mips_c_ole_s}, + {"c.ole.d" ,ASM_MIPS_C_OLE_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLE ,MIPS_OPCODE_FMT_D ,asm_mips_c_ole_d}, + {"c.ole.ps" ,ASM_MIPS_C_OLE_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_OLE ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ole_ps}, + {"c.ule.s" ,ASM_MIPS_C_ULE_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULE ,MIPS_OPCODE_FMT_S ,asm_mips_c_ule_s}, + {"c.ule.d" ,ASM_MIPS_C_ULE_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULE ,MIPS_OPCODE_FMT_D ,asm_mips_c_ule_d}, + {"c.ule.ps" ,ASM_MIPS_C_ULE_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_ULE ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ule_ps}, + {"c.sf.s" ,ASM_MIPS_C_SF_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SF ,MIPS_OPCODE_FMT_S ,asm_mips_c_sf_s}, + {"c.sf.d" ,ASM_MIPS_C_SF_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SF ,MIPS_OPCODE_FMT_D ,asm_mips_c_sf_d}, + {"c.sf.ps" ,ASM_MIPS_C_SF_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SF ,MIPS_OPCODE_FMT_PS ,asm_mips_c_sf_ps}, + {"c.ngle.s" ,ASM_MIPS_C_NGLE_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGLE ,MIPS_OPCODE_FMT_S ,asm_mips_c_ngle_s}, + {"c.ngle.d" ,ASM_MIPS_C_NGLE_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGLE ,MIPS_OPCODE_FMT_D ,asm_mips_c_ngle_d}, + {"c.ngle.ps",ASM_MIPS_C_NGLE_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGLE ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ngle_ps}, + {"c.seq.s" ,ASM_MIPS_C_SEQ_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SEQ ,MIPS_OPCODE_FMT_S ,asm_mips_c_seq_s}, + {"c.seq.d" ,ASM_MIPS_C_SEQ_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SEQ ,MIPS_OPCODE_FMT_D ,asm_mips_c_seq_d}, + {"c.seq.ps" ,ASM_MIPS_C_SEQ_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_SEQ ,MIPS_OPCODE_FMT_PS ,asm_mips_c_seq_ps}, + {"c.ngl.s" ,ASM_MIPS_C_NGL_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGL ,MIPS_OPCODE_FMT_S ,asm_mips_c_ngl_s}, + {"c.ngl.d" ,ASM_MIPS_C_NGL_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGL ,MIPS_OPCODE_FMT_D ,asm_mips_c_ngl_d}, + {"c.ngl.ps" ,ASM_MIPS_C_NGL_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGL ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ngl_ps}, + {"c.lt.s" ,ASM_MIPS_C_LT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LT ,MIPS_OPCODE_FMT_S ,asm_mips_c_lt_s}, + {"c.lt.d" ,ASM_MIPS_C_LT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LT ,MIPS_OPCODE_FMT_D ,asm_mips_c_lt_d}, + {"c.lt.ps" ,ASM_MIPS_C_LT_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LT ,MIPS_OPCODE_FMT_PS ,asm_mips_c_lt_ps}, + {"c.nge.s" ,ASM_MIPS_C_NGE_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGE ,MIPS_OPCODE_FMT_S ,asm_mips_c_nge_s}, + {"c.nge.d" ,ASM_MIPS_C_NGE_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGE ,MIPS_OPCODE_FMT_D ,asm_mips_c_nge_d}, + {"c.nge.ps" ,ASM_MIPS_C_NGE_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGE ,MIPS_OPCODE_FMT_PS ,asm_mips_c_nge_ps}, + {"c.le.s" ,ASM_MIPS_C_LE_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LE ,MIPS_OPCODE_FMT_S ,asm_mips_c_le_s}, + {"c.le.d" ,ASM_MIPS_C_LE_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LE ,MIPS_OPCODE_FMT_D ,asm_mips_c_le_d}, + {"c.le.ps" ,ASM_MIPS_C_LE_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_LE ,MIPS_OPCODE_FMT_PS ,asm_mips_c_le_ps}, + {"c.ngt.s" ,ASM_MIPS_C_NGT_S ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGT ,MIPS_OPCODE_FMT_S ,asm_mips_c_ngt_s}, + {"c.ngt.d" ,ASM_MIPS_C_NGT_D ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGT ,MIPS_OPCODE_FMT_D ,asm_mips_c_ngt_d}, + {"c.ngt.ps" ,ASM_MIPS_C_NGT_PS ,MIPS_OPCODE_COP1 ,MIPS_OPCODE_COND_NGT ,MIPS_OPCODE_FMT_PS ,asm_mips_c_ngt_ps}, + /* mnemonic code index1 index 2 index 3 func pointer */ { (const char *) -1, (int) -1, (int) -1, (int) -1, (int) -1, NULL } }; @@ -351,7 +518,7 @@ {"sp","r29","f29",ASM_MIPS_REG_SP}, {"fp","r30","f30",ASM_MIPS_REG_FP}, {"ra","r31","f31",ASM_MIPS_REG_RA}, -// {-1,-1,-1} + /* ext_mnemonic mnemonic fpu_mnemonic code */ { (const char *) -1, (const char *) -1, (const char *) -1, (int) -1 } }; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_add.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_add.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_add.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_add.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_add.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_add.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_add.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; @@ -33,16 +38,19 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_INC; - - if (ins->op[1].imm == 1) + if (asm_config_get_synthinstr()) + { + if ((ins->op[0].baser == ins->op[2].baser) && + ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { + + ins->instr = ASM_SP_INC; + + if (ins->op[1].imm == 1) ins->nb_op = 1; - else + else ins->nb_op = 2; - } + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_addc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_addc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_addc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_addcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_addcc.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_addcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; @@ -34,17 +39,20 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_INCCC; - - if (ins->op[1].imm == 1) + if (asm_config_get_synthinstr()) + { + if ((ins->op[0].baser == ins->op[2].baser) && + ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { + + ins->instr = ASM_SP_INCCC; + + if (ins->op[1].imm == 1) ins->nb_op = 1; - else + else ins->nb_op = 2; - } - + } + } + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addccc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addccc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_addccc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_addccc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_addccc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_addccc.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_addccc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_and.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_and.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_and.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_and.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_and.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_and.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_and.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -16,6 +20,7 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; + ins->arith = ASM_ARITH_AND; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andcc.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_andcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_andcc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_andcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_AND; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; ins->nb_op = 3; @@ -33,12 +38,14 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if (ins->op[0].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_BTST; - ins->nb_op = 2; - ins->op[0] = ins->op[2]; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[0].baser == ASM_REG_G0) { + ins->instr = ASM_SP_BTST; + ins->nb_op = 2; + ins->op[0] = ins->op[2]; + } + } return 4; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andn.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andn.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andn.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andn.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_andn.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_andn.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_andn.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_AND; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; @@ -33,10 +38,13 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BCLR; - ins->nb_op = 2; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[0].baser == ins->op[2].baser) { + ins->instr = ASM_SP_BCLR; + ins->nb_op = 2; + } + } return 4; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andncc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andncc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_andncc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_andncc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_andncc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_andncc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_andncc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_AND | ASM_ARITH_NOT; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bicc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bicc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bicc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bicc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_bicc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_bicc.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_bicc.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -18,11 +22,11 @@ ins->instr = inter->bcc_table[opcode.cond]; if (ins->instr == ASM_SP_BA) - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; else if (ins->instr == ASM_SP_BN) ins->type = ASM_TYPE_NOP; else - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; ins->nb_op = 1; ins->op[0].imm = opcode.imm; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_bpcc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_bpcc.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -18,11 +22,11 @@ ins->instr = inter->bcc_table[opcodep.cond]; if (ins->instr == ASM_SP_BA) - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; else if (ins->instr == ASM_SP_BN) ins->type = ASM_TYPE_NOP; else - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; ins->nb_op = 2; ins->op[0].imm = opcodep.imm; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bpr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bpr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_bpr.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_bpr.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_bpr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_bpr.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_bpr.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -16,7 +20,7 @@ inter = proc->internals; ins->instr = inter->brcc_table[opcoder.rcond]; - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; ins->nb_op = 2; ins->op[0].imm = opcoder.d16; ins->op[1].baser = opcoder.rs1; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_call.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_call.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_call.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_call.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_call.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_call.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_call.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_casa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_casa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_casa.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_casa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_casa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_casa.c,v 1.9 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_casa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_casxa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_casxa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_casxa.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_casxa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_casxa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_casxa.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_casxa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_done.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_done.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_done.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_done.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_done.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_done.c,v 1.6 2007/07/18 15:47:10 strauss Exp $ +** $Id: asm_sparc_done.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fbfcc.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fbfcc.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -18,11 +22,11 @@ ins->instr = inter->fbcc_table[opcode.cond]; if (ins->instr == ASM_SP_FBA) - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; else if (ins->instr == ASM_SP_FBN) ins->type = ASM_TYPE_NOP; else - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; ins->nb_op = 1; ins->op[0].imm = opcode.imm; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fbpfcc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fbpfcc.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -18,13 +22,14 @@ ins->instr = inter->fbcc_table[opcodep.cond]; if (ins->instr == ASM_SP_FBA) - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; else if (ins->instr == ASM_SP_FBN) ins->type = ASM_TYPE_NOP; else - ins->type = ASM_TYPE_CONDBRANCH; + ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; - ins->type = ASM_TYPE_CONDBRANCH; + /* Removed during flags cleanup. */ + /* ins->type = ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL; */ ins->nb_op = 2; ins->op[0].imm = opcodep.imm; ins->op[1].baser = opcodep.cc; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmpd.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmpd.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmped.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmped.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmpeq.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmpeq.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmpes.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmpes.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmpq.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmpq.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fcmps.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fcmps.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_flush.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_flush.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_flush.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_flush.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_flush.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_flush.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_flush.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_flushw.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_flushw.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_flushw.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_flushw.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_flushw.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_flushw.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ +** $Id: asm_sparc_flushw.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovdcc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fmovdcc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovdr.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: asm_sparc_fmovdr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovqcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_fmovqcc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovqr.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_fmovqr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovscc.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_fmovscc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fmovsr.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_fmovsr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_fpop1.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_fpop1.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -11,17 +15,37 @@ { struct s_decode_format3 opcode; struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - + sparc_convert_format3(&opcode, buf); + inter = proc->internals; ins->instr = inter->fpop1_table[opcode.opf]; - ins->type = ASM_TYPE_ARITH; + if (opcode.opf < 0x40 || opcode.opf >= 0x70) { ins->type = ASM_TYPE_ASSIGN; ins->nb_op = 2; } else { /* 0x40 < opf < 0x69 - add, sub, mul, div */ + ins->type = ASM_TYPE_ARITH; + + /* FIXME: what is the value to switch on here ? */ + /* + switch () + { + case: + ins->arith = ASM_ARITH_ADD; + break; + case: + ins->arith = ASM_ARITH_SUB; + break; + case: + ins->arith = ASM_ARITH_MUL; + break; + case: + ins->arith = ASM_ARITH_DIV; + break; + } + */ + ins->nb_op = 3; ins->op[2].baser = opcode.rs1; asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_FREGISTER, ins); diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_illegal.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_illegal.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_illegal.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_illegal.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_illegal.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_illegal.c,v 1.3 2007/08/07 07:13:27 may Exp $ +** $Id: asm_sparc_illegal.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_illtrap.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_illtrap.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_impdep1.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ +** $Id: asm_sparc_impdep1.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_impdep2.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ +** $Id: asm_sparc_impdep2.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_jmpl.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_jmpl.c 1413 2010-05-21 03:41:25Z figueredo $ ** */ #include "libasm.h" @@ -16,7 +20,7 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - ins->type = ASM_TYPE_IMPBRANCH; + ins->type = ASM_TYPE_BRANCH; ins->nb_op = 2; ins->op[0].baser = opcode.rd; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldda.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldda.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldda.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldda.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldda.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldda.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldda.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldd.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldd.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldd.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldd.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldd.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldd.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldd.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lddfa.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lddfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lddf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lddf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lddf.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lddf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lddf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lddf.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lddf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldf.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldfsr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldfsr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldqfa.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldqfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldqf.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldqf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldsba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldsba.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldsb.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldsb.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldsha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldsha.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldsh.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldsh.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldstuba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldstuba.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldstub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldstub.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldswa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldswa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldsw.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldsw.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduba.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduba.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduba.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduba.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lduba.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lduba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lduba.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldub.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldub.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldub.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldub.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldub.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldub.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduha.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduha.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduha.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduha.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lduha.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lduha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lduha.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduh.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduh.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduh.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduh.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lduh.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lduh.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lduh.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lduwa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lduwa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduw.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduw.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_lduw.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_lduw.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_lduw.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_lduw.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_lduw.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldxa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldxa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldx.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldx.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_ldx.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_ldx.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_ldx.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_ldx.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_ldx.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_movcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_movcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_movcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_movcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_movcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_movcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_movcc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_movr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_movr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_movr.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_movr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_movr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_movr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_movr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_mulscc.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_mulscc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_mulx.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_mulx.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_mulx.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_mulx.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_mulx.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_mulx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_mulx.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_or.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_or.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_or.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_or.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_or.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_or.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_or.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,8 +19,9 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD; + + ins->arith = ASM_ARITH_OR; + ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; ins->op[0].baser = opcode.rd; @@ -24,31 +29,41 @@ ins->op[2].baser = opcode.rs1; asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BSET; - ins->nb_op = 2; - } - else if (ins->op[2].baser == ASM_REG_G0) { - if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[1].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; + if (opcode.i == 0) + { + ins->op[1].baser = opcode.rs2; + asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); } - else { - ins->instr = ASM_SP_MOV; - ins->nb_op = 2; + else + { + ins->op[1].imm = opcode.imm; + asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - } + if (asm_config_get_synthinstr()) + { + if (ins->op[0].baser == ins->op[2].baser) + { + ins->instr = ASM_SP_BSET; + ins->nb_op = 2; + ins->type = ASM_TYPE_BITSET; + } + else if (ins->op[2].baser == ASM_REG_G0) + { + if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && + ins->op[1].baser == ASM_REG_G0) + { + ins->instr = ASM_SP_CLR; + ins->nb_op = 1; + } + else + { + ins->instr = ASM_SP_MOV; + ins->nb_op = 2; + ins->type = ASM_TYPE_ASSIGN; + } + } + } + return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orcc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_orcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_orcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_orcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_OR; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orn.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orn.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orn.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orn.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_orn.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_orn.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_orn.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orncc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orncc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_orncc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_orncc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_orncc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_orncc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_orncc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_OR | ASM_ARITH_NOT; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_popc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_popc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_popc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_popc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_popc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_popc.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_popc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_prefetcha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_prefetcha.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_prefetch.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_prefetch.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_rd.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_rd.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_rd.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_rd.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_rd.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_rd.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_rd.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_rdpr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_rdpr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_restore.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_restore.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_restore.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_restore.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_restore.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_restore.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_restore.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_return.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_return.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_return.c 2008-04-06 23:16:06.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_return.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_return.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_return.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_return.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_save.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_save.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_save.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_save.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_save.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_save.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_save.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_saved.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_saved.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_saved.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_saved.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_saved.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_saved.c,v 1.6 2007/08/07 07:13:27 may Exp $ +** $Id: asm_sparc_saved.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sdiv.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sdiv.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sdivcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sdivcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sdivx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sdivx.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sethi.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sethi.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sethi.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sethi.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sethi.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sethi.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sethi.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sll.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sll.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sll.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sll.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sll.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sll.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sll.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -14,6 +18,7 @@ sparc_convert_format3(&opcode, buf); inter = proc->internals; + ins->arith = ASM_ARITH_SL; ins->type = ASM_TYPE_ARITH; ins->instr = inter->shift_table[opcode.op3 - 0x25 + diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_smul.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_smul.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_smul.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_smul.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_smul.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_smul.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_smul.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_smulcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_smulcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sra.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sra.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sra.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sra.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sra.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sra.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sra.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -14,6 +18,8 @@ sparc_convert_format3(&opcode, buf); inter = proc->internals; + + ins->arith = ASM_ARITH_SR; ins->type = ASM_TYPE_ARITH; ins->instr = inter->shift_table[opcode.op3 - 0x25 + diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_srl.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_srl.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_srl.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_srl.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_srl.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_srl.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_srl.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,6 +19,7 @@ inter = proc->internals; ins->type = ASM_TYPE_ARITH; + ins->arith = ASM_ARITH_SL; ins->instr = inter->shift_table[opcode.op3 - 0x25 + ((opcode.imm & 0x1000) ? 1 : 0)]; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stba.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stba.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stba.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stba.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stba.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stba.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stba.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stb.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stb.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stb.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stb.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stb.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stb.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stb.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { @@ -32,10 +36,13 @@ ins->op[1].baser = opcode.rd; asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRB; - ins->nb_op = 1; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRB; + ins->nb_op = 1; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stda.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stda.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stda.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stda.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stda.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stda.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stda.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_std.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_std.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_std.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_std.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_std.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_std.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_std.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { @@ -32,22 +36,25 @@ ins->op[1].baser = opcode.rd; asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - if (ins->instr == ASM_SP_STB && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRB; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STH && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRH; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STW && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STX && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRX; - ins->nb_op = 1; - } + if (asm_config_get_synthinstr()) + { + if (ins->instr == ASM_SP_STB && ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRB; + ins->nb_op = 1; + } + else if (ins->instr == ASM_SP_STH && ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRH; + ins->nb_op = 1; + } + else if (ins->instr == ASM_SP_STW && ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLR; + ins->nb_op = 1; + } + else if (ins->instr == ASM_SP_STX && ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRX; + ins->nb_op = 1; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stdfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stdfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stdf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stdf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stdf.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stdf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stdf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stdf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stdf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stfa.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stfa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stf.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stf.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stfsr.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stfsr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; if (opcode.rd == 0) ins->instr = ASM_SP_LDFSR; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stha.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stha.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stha.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stha.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stha.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stha.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stha.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sth.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sth.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sth.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sth.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sth.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sth.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sth.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { @@ -32,10 +36,13 @@ ins->op[1].baser = opcode.rd; asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRH; - ins->nb_op = 1; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRH; + ins->nb_op = 1; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stqfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stqfa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stqf.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stqf.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stqf.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stqf.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stqf.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stqf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stqf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stwa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stwa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stwa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stwa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stwa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stwa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stwa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stw.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stw.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stw.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stw.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stw.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stw.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stw.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { @@ -32,10 +36,13 @@ ins->op[1].baser = opcode.rd; asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLR; + ins->nb_op = 1; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stxa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stxa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stxa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stxa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stxa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stxa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stxa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stx.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stx.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_stx.c 2008-04-06 23:16:06.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_stx.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_stx.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_stx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_stx.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libasm.h" @@ -15,7 +19,7 @@ inter = proc->internals; ins->instr = inter->op3_table[opcode.op3]; - ins->type = ASM_TYPE_STORE; + ins->type = ASM_TYPE_STORE | ASM_TYPE_ASSIGN; ins->nb_op = 2; if (opcode.i) { @@ -32,10 +36,13 @@ ins->op[1].baser = opcode.rd; asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRX; - ins->nb_op = 1; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[1].baser == ASM_REG_G0) { + ins->instr = ASM_SP_CLRX; + ins->nb_op = 1; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sub.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sub.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_sub.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_sub.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_sub.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_sub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_sub.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; @@ -33,25 +38,28 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_DEC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - else if (ins->op[2].baser == ASM_REG_G0 && - ins->op[1].content == ASM_SP_OTYPE_REGISTER) { - - ins->instr = ASM_SP_NEG; - if (ins->op[1].baser == ins->op[0].baser) - ins->nb_op = 1; - else - ins->nb_op = 2; - } + if (asm_config_get_synthinstr()) + { + if ((ins->op[0].baser == ins->op[2].baser) && + ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { + + ins->instr = ASM_SP_DEC; + + if (ins->op[1].imm == 1) + ins->nb_op = 1; + else + ins->nb_op = 2; + } + else if (ins->op[2].baser == ASM_REG_G0 && + ins->op[1].content == ASM_SP_OTYPE_REGISTER) { + + ins->instr = ASM_SP_NEG; + if (ins->op[1].baser == ins->op[0].baser) + ins->nb_op = 1; + else + ins->nb_op = 2; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_subc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_subc.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_subc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subcc.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_subcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_subcc.c,v 1.11 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_subcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; @@ -34,23 +39,26 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if (ins->op[0].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CMP; - ins->type |= ASM_TYPE_COMPARISON; - ins->nb_op = 2; - ins->op[0] = ins->op[1]; - ins->op[1] = ins->op[2]; - } - else if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_DECCC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[0].baser == ASM_REG_G0) + { + ins->instr = ASM_SP_CMP; + ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; + ins->nb_op = 2; + ins->op[0] = ins->op[1]; + ins->op[1] = ins->op[2]; + } + else if ((ins->op[0].baser == ins->op[2].baser) && + ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) + { + ins->instr = ASM_SP_DECCC; + if (ins->op[1].imm == 1) + ins->nb_op = 1; + else + ins->nb_op = 2; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subccc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subccc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_subccc.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_subccc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_subccc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_subccc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_subccc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_swapa.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_swapa.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_swapa.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_swapa.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_swapa.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_swapa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_swapa.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_swap.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_swap.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_swap.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_swap.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_swap.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_swap.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_swap.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_taddcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_taddcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_taddcctv.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_taddcctv.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_ADD; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_tcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_tcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_tcc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_tsubcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_tsubcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_tsubcctv.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_tsubcctv.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_SUB; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udiv.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udiv.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udiv.c 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udiv.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_udiv.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_udiv.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_udiv.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_udivcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_udivcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udivx.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udivx.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_udivx.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_udivx.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_udivx.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_udivx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_udivx.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_DIV; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_umul.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_umul.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_umul.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_umul.c 2011-05-16 11:34:31.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_umul.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_umul.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_umul.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_umulcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_umulcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_MUL; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_wr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_wr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_wr.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_wr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_wr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_wr.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_wr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_wrpr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_wrpr.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libasm.h" diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xnor.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xnor.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xnor.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xnor.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_xnor.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_xnor.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_xnor.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_XOR | ASM_ARITH_NOT; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c 2008-04-06 23:16:05.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_xnorcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_xnorcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_XOR | ASM_ARITH_NOT; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xor.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xor.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xor.c 2008-04-06 23:16:07.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xor.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_xor.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_xor.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_xor.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_XOR; ins->type = ASM_TYPE_ARITH; ins->nb_op = 3; @@ -33,10 +38,13 @@ asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); } - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BTOG; - ins->nb_op = 2; - } + if (asm_config_get_synthinstr()) + { + if (ins->op[0].baser == ins->op[2].baser) { + ins->instr = ASM_SP_BTOG; + ins->nb_op = 2; + } + } return 4; } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c --- eresi-0.8a25/libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c 2008-04-06 23:16:06.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c 2011-05-16 11:34:32.000000000 +0000 @@ -1,6 +1,10 @@ +/** +* @file libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c +** @ingroup SPARC_instrs +*/ /* ** -** $Id: asm_sparc_xorcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ +** $Id: asm_sparc_xorcc.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libasm.h" @@ -15,7 +19,8 @@ inter = proc->internals; ins->instr = inter->op2_table[opcode.op3]; - + + ins->arith = ASM_ARITH_XOR; ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/all-wcprops 2008-04-06 23:16:08.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,767 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers -END -asm_sparc_bpcc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c -END -asm_sparc_udiv.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_udiv.c -END -asm_sparc_fcmps.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c -END -asm_sparc_sethi.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sethi.c -END -asm_sparc_fcmpes.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c -END -asm_sparc_flush.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_flush.c -END -asm_sparc_bpr.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_bpr.c -END -asm_sparc_ldsb.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c -END -asm_sparc_sra.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sra.c -END -asm_sparc_ldx.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldx.c -END -asm_sparc_stb.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stb.c -END -asm_sparc_stf.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stf.c -END -asm_sparc_stha.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stha.c -END -asm_sparc_saved.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_saved.c -END -asm_sparc_ldda.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldda.c -END -asm_sparc_fmovqr.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c -END -asm_sparc_lduw.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lduw.c -END -asm_sparc_stqfa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c -END -asm_sparc_stxa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stxa.c -END -asm_sparc_mulx.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_mulx.c -END -asm_sparc_orcc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_orcc.c -END -asm_sparc_smulcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c -END -asm_sparc_xnor.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_xnor.c -END -asm_sparc_fcmpd.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c -END -asm_sparc_fmovdr.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c -END -asm_sparc_fcmped.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c -END -asm_sparc_popc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_popc.c -END -asm_sparc_and.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_and.c -END -asm_sparc_lddfa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c -END -asm_sparc_ldswa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c -END -asm_sparc_lduwa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c -END -asm_sparc_smul.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_smul.c -END -asm_sparc_or.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_or.c -END -asm_sparc_taddcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c -END -asm_sparc_fbpfcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c -END -asm_sparc_ldsba.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c -END -asm_sparc_ldqf.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c -END -asm_sparc_lduba.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lduba.c -END -asm_sparc_wr.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_wr.c -END -asm_sparc_lduh.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lduh.c -END -asm_sparc_stfa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stfa.c -END -asm_sparc_orn.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_orn.c -END -asm_sparc_addcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_addcc.c -END -asm_sparc_addccc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_addccc.c -END -asm_sparc_movcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_movcc.c -END -asm_sparc_tcc.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_tcc.c -END -asm_sparc_lddf.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lddf.c -END -asm_sparc_ldsw.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c -END -asm_sparc_stw.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stw.c -END -asm_sparc_fmovdcc.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c -END -asm_sparc_movr.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_movr.c -END -asm_sparc_fpop1.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c -END -asm_sparc_done.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_done.c -END -asm_sparc_andncc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_andncc.c -END -asm_sparc_add.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_add.c -END -asm_sparc_sub.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sub.c -END -asm_sparc_tsubcctv.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c -END -asm_sparc_udivx.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_udivx.c -END -asm_sparc_bicc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_bicc.c -END -asm_sparc_prefetcha.c -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c -END -asm_sparc_ldf.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldf.c -END -asm_sparc_fcmpq.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c -END -asm_sparc_flushw.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_flushw.c -END -asm_sparc_ldfsr.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c -END -asm_sparc_fcmpeq.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c -END -asm_sparc_andn.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_andn.c -END -asm_sparc_umul.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_umul.c -END -asm_sparc_tsubcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c -END -asm_sparc_std.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_std.c -END -asm_sparc_sll.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sll.c -END -asm_sparc_ldsh.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c -END -asm_sparc_stda.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stda.c -END -asm_sparc_ldsha.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c -END -asm_sparc_xnorcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c -END -asm_sparc_ldstub.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c -END -asm_sparc_lduha.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_lduha.c -END -asm_sparc_sth.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sth.c -END -asm_sparc_subcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_subcc.c -END -asm_sparc_impdep1.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c -END -asm_sparc_stdfa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c -END -asm_sparc_illtrap.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c -END -asm_sparc_casa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_casa.c -END -asm_sparc_andcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_andcc.c -END -asm_sparc_illegal.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_illegal.c -END -asm_sparc_udivcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c -END -asm_sparc_stx.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stx.c -END -asm_sparc_xorcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c -END -asm_sparc_return.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_return.c -END -asm_sparc_ldxa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c -END -asm_sparc_addc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_addc.c -END -asm_sparc_prefetch.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c -END -asm_sparc_jmpl.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c -END -asm_sparc_subccc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_subccc.c -END -asm_sparc_orncc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_orncc.c -END -asm_sparc_sdiv.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c -END -asm_sparc_rdpr.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c -END -asm_sparc_xor.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_xor.c -END -asm_sparc_swap.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_swap.c -END -asm_sparc_swapa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_swapa.c -END -asm_sparc_call.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_call.c -END -asm_sparc_stqf.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stqf.c -END -asm_sparc_stwa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stwa.c -END -asm_sparc_mulscc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c -END -asm_sparc_ldub.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldub.c -END -asm_sparc_ldqfa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c -END -asm_sparc_stba.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stba.c -END -asm_sparc_subc.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_subc.c -END -asm_sparc_save.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_save.c -END -asm_sparc_stdf.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stdf.c -END -asm_sparc_srl.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_srl.c -END -asm_sparc_impdep2.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c -END -asm_sparc_stfsr.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c -END -asm_sparc_fbfcc.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c -END -asm_sparc_rd.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_rd.c -END -asm_sparc_ldfa.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c -END -asm_sparc_sdivcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c -END -asm_sparc_fmovsr.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c -END -asm_sparc_restore.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_restore.c -END -asm_sparc_umulcc.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c -END -asm_sparc_wrpr.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c -END -asm_sparc_taddcctv.c -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c -END -asm_sparc_sdivx.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c -END -asm_sparc_fmovqcc.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c -END -asm_sparc_ldstuba.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c -END -asm_sparc_casxa.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_casxa.c -END -asm_sparc_fmovscc.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c -END -asm_sparc_ldd.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/handlers/asm_sparc_ldd.c -END diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/entries 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,1552 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/sparc/handlers -http://svn.eresi-project.org/svn - - - -2008-02-19T17:09:59.893936Z -849 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -asm_sparc_bpcc.c -file - - - - -2008-04-06T23:16:04.983876Z -b11784b1c6c6bc8ed32c3cf2887309ab -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_udiv.c -file - - - - -2008-04-06T23:16:04.995899Z -6d1cffc0215db89465364411ea4c62db -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmps.c -file - - - - -2008-04-06T23:16:05.007339Z -cda39885277fc062eda11a7b3a7db536 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sethi.c -file - - - - -2008-04-06T23:16:05.086449Z -10d33d9b221178351599bdfec2ab48a1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmpes.c -file - - - - -2008-04-06T23:16:05.097899Z -5a38ee58699392248f2492b19c3fde05 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_flush.c -file - - - - -2008-04-06T23:16:05.120876Z -78ade010a5eb44f2509e5b7c94506df1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_bpr.c -file - - - - -2008-04-06T23:16:05.142899Z -749d7b8504fdddf9c133f8be496a3f56 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldsb.c -file - - - - -2008-04-06T23:16:05.166600Z -8b658d7a58927915faa2e9ad38ba36bc -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sra.c -file - - - - -2008-04-06T23:16:05.177905Z -b0ab7d4add0392043f522462176d1cbf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldx.c -file - - - - -2008-04-06T23:16:05.189243Z -14717a3758ba6148e57a40079b83df49 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stb.c -file - - - - -2008-04-06T23:16:05.200974Z -c9338c327e38496f740cf6c6cb22a10f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stf.c -file - - - - -2008-04-06T23:16:05.271289Z -3663f216a19f601b9f8ccb5c7ac165b5 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stha.c -file - - - - -2008-04-06T23:16:05.340014Z -a2ed6c5a55f711d2b480faaf3f700e5c -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_saved.c -file - - - - -2008-04-06T23:16:05.373912Z -a05d167509f5a7823a4c0ac6648898b1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldda.c -file - - - - -2008-04-06T23:16:05.385914Z -0426ebd616ebb8a7d97739fe77a5588b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovqr.c -file - - - - -2008-04-06T23:16:05.443359Z -4de58b2dd957a8b3181bf5788d18c23f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lduw.c -file - - - - -2008-04-06T23:16:05.455090Z -2a992a160527739a20cef8369b030082 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stqfa.c -file - - - - -2008-04-06T23:16:05.478121Z -3187dda1e1c6be0c30f6c7ac5769e933 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stxa.c -file - - - - -2008-04-06T23:16:07.586379Z -aaebd8a137d1cc7538e678ee588aa4e0 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_mulx.c -file - - - - -2008-04-06T23:16:07.670286Z -f527b61231f47f1d2f3bfcd565cdfcf5 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_orcc.c -file - - - - -2008-04-06T23:16:07.699345Z -2ac066748e8960e4e02e97c4cf1012e4 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_smulcc.c -file - - - - -2008-04-06T23:16:07.710879Z -71655ccd6bf3482846f7c32b49ed4c0a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_xnor.c -file - - - - -2008-04-06T23:16:07.721899Z -e42fb204a5e82de16ed7fb1ebba4362b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmpd.c -file - - - - -2008-04-06T23:16:07.745149Z -8a3b193b39dfc4a11e54821df633fc73 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovdr.c -file - - - - -2008-04-06T23:16:07.768259Z -d784e9f3fda119c8842dad17ebc80a10 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmped.c -file - - - - -2008-04-06T23:16:07.779899Z -adb044c055d20cdb2a811744bf5b5c77 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_popc.c -file - - - - -2008-04-06T23:16:07.803103Z -8414b326b90842d88e95353054aefee9 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_and.c -file - - - - -2008-04-06T23:16:07.826196Z -32ad5910edf2482544b41f9ea93983d6 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lddfa.c -file - - - - -2008-04-06T23:16:07.908604Z -2756b057f8f1bc00b6b4eeef772acf1f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldswa.c -file - - - - -2008-04-06T23:16:07.897086Z -850bf2aaa131c4c02447f9e3d69f470a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lduwa.c -file - - - - -2008-04-06T23:16:07.954901Z -6aee5ca18de471233cdde0ab853bf5ec -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_smul.c -file - - - - -2008-04-06T23:16:08.000903Z -3143b55273079dfdc894bd5f6658ba6c -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_or.c -file - - - - -2008-04-06T23:16:07.989624Z -fef1e46190e7a2ace0874fac457b7b40 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_taddcc.c -file - - - - -2008-04-06T23:16:08.012876Z -28049b77be9756ccf422392e9d17e475 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fbpfcc.c -file - - - - -2008-04-06T23:16:08.024202Z -bb325161d4b3802482da8c899b0ec2e7 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldsba.c -file - - - - -2008-04-06T23:16:08.035916Z -8c11f2b957c4eab6fe949caffc7b13cf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldqf.c -file - - - - -2008-04-06T23:16:08.188042Z -2286c78fe744d1e0ab95e7ae3d5449cb -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lduba.c -file - - - - -2008-04-06T23:16:08.271231Z -790a7bffe2b0f8b8e01c72990f8b0956 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_wr.c -file - - - - -2008-04-06T23:16:08.294435Z -e69e3082634e8e4d00a0a5e2ea814bd8 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lduh.c -file - - - - -2008-04-06T23:16:08.317876Z -e61305b2baa3fdca8c639ebf1206f065 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stfa.c -file - - - - -2008-04-06T23:16:08.341899Z -27131fc8b5f425ca9d28a8a3ad726040 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_orn.c -file - - - - -2008-04-06T23:16:08.365876Z -8c9abf5169663f164e97fab03d73ca32 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_addcc.c -file - - - - -2008-04-06T23:16:08.353904Z -601b282285bc7b7803b734f92d585f28 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_addccc.c -file - - - - -2008-04-06T23:16:08.424061Z -77e18aa075a09ba891d8899f8cd099b8 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_movcc.c -file - - - - -2008-04-06T23:16:08.481900Z -4ceebab520fbcb9b18d5e2870e6d9ca0 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_tcc.c -file - - - - -2008-04-06T23:16:08.517148Z -6eea6cab2d26b4f24cb6369f1a3642c9 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lddf.c -file - - - - -2008-04-06T23:16:08.504899Z -99305b278d9454011b37465f77869be3 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldsw.c -file - - - - -2008-04-06T23:16:08.494029Z -12077a5431dba4bd95d3dffbaff9cdfc -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stw.c -file - - - - -2008-04-06T23:16:08.551899Z -76a3696d42248f319c810b0d4d5972d1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovdcc.c -file - - - - -2008-04-06T23:16:08.562887Z -7a60d3cde07d5788965e2a5f80617f27 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_movr.c -file - - - - -2008-04-06T23:16:08.575049Z -565580222adc7c3515324618239cffbb -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fpop1.c -file - - - - -2008-04-06T23:16:08.611238Z -a770ceb7a81fe29e61f7809cdef2b413 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_done.c -file - - - - -2008-04-06T23:16:08.599643Z -317a62dde55b3d3503aef4e36d961762 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_andncc.c -file - - - - -2008-04-06T23:16:08.635395Z -0befe9807198739fb6d92c6145884570 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_add.c -file - - - - -2008-04-06T23:16:08.667031Z -91265393a8214172f7146febc58043a7 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sub.c -file - - - - -2008-04-06T23:16:08.690678Z -86c69e87199e7051d55a5b6d398e863a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_tsubcctv.c -file - - - - -2008-04-06T23:16:08.736876Z -098f589e5659a0aeac030c1f6663255d -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_udivx.c -file - - - - -2008-04-06T23:16:08.782979Z -7acb0903cc94fc0ce88eb98382705d26 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_bicc.c -file - - - - -2008-04-06T23:16:08.793909Z -581adff0625f90ebe21a74e598061ed4 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_prefetcha.c -file - - - - -2008-04-06T23:16:08.817647Z -6515a796fe08187272e915de8f35b408 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldf.c -file - - - - -2008-04-06T23:16:08.840876Z -8cc710b18287d00d1de9492933696c9e -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmpq.c -file - - - - -2008-04-06T23:16:04.972903Z -eb53879b7a5da0b091016d9a7faec7cf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_flushw.c -file - - - - -2008-04-06T23:16:05.018876Z -44f796fbd79ba440e679192beb708af3 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldfsr.c -file - - - - -2008-04-06T23:16:05.030198Z -66b033b8280392ee7d54f0d5681b149e -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fcmpeq.c -file - - - - -2008-04-06T23:16:05.041877Z -d95ffd58e0646d1ff431ab957f11fb96 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_andn.c -file - - - - -2008-04-06T23:16:05.109330Z -ae0ac8870c81365b137317c047edcf0b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_umul.c -file - - - - -2008-04-06T23:16:05.131903Z -4af66f431c62307a44b78be75463515c -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_tsubcc.c -file - - - - -2008-04-06T23:16:05.155142Z -48c5387e3dc9fe8813ef27032ce05347 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_std.c -file - - - - -2008-04-06T23:16:05.236912Z -18606ecf8b18f623d0ede3604086fa6b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sll.c -file - - - - -2008-04-06T23:16:05.225452Z -4cfd61bcda24f52094f4128d901ea6b9 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldsh.c -file - - - - -2008-04-06T23:16:05.213899Z -33da3cfa394461b82113e6de32c2cde3 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stda.c -file - - - - -2008-04-06T23:16:05.259876Z -0fee2e122ff7e48ec49f94618e6233ac -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldsha.c -file - - - - -2008-04-06T23:16:05.247900Z -73ff3cd02217e60bf8ac9aff5da3567c -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_xnorcc.c -file - - - - -2008-04-06T23:16:05.282877Z -7e3ebb2f3a4d4c004e604ce944138e2a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldstub.c -file - - - - -2008-04-06T23:16:05.305877Z -71a76af2edd7c90c649644459cf2ac84 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_lduha.c -file - - - - -2008-04-06T23:16:05.294206Z -27186862c8ef816a627f10720fc59835 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sth.c -file - - - - -2008-04-06T23:16:05.317182Z -98b98dd3612b4f3976064678338745cf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_subcc.c -file - - - - -2008-04-06T23:16:05.350903Z -e0871b65fe246a17e156efb05ece20f5 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_impdep1.c -file - - - - -2008-04-06T23:16:05.327899Z -90758a7616587867eb86bd0c57b6a918 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stdfa.c -file - - - - -2008-04-06T23:16:05.362904Z -86c3f28718583710fb28e32c5addbf67 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_illtrap.c -file - - - - -2008-04-06T23:16:05.396903Z -0b61046eeb01024bf3acb212235a2a3f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_casa.c -file - - - - -2008-04-06T23:16:05.408941Z -43e6c559bc713d912e6f79d9c4cbfaa2 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_andcc.c -file - - - - -2008-04-06T23:16:05.420600Z -493fad0bf8f856133be92156ba6fe914 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_illegal.c -file - - - - -2008-04-06T23:16:05.431899Z -e74d034794f313679f39e9cd21f91f87 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_udivcc.c -file - - - - -2008-04-06T23:16:05.465903Z -cf4494c47de199abd1e64d1042f0c08f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stx.c -file - - - - -2008-04-06T23:16:06.175881Z -f17ba410d605744acfab5d4629cf9743 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_xorcc.c -file - - - - -2008-04-06T23:16:06.324166Z -5d19017e894d66afd0898ea10254753a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_return.c -file - - - - -2008-04-06T23:16:06.933123Z -edb53b8beb4fe7a63d352a1f61b58b3d -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldxa.c -file - - - - -2008-04-06T23:16:07.733892Z -3104abd68fbf224989205b969301502f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_addc.c -file - - - - -2008-04-06T23:16:07.756981Z -ffa7f1c4b87b3176ffcad3499ba3bc3b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_prefetch.c -file - - - - -2008-04-06T23:16:07.791529Z -98da7de90f7d91e77016aa285e3b2966 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_jmpl.c -file - - - - -2008-04-06T23:16:07.813954Z -37a6f5c51314b037486a064dc464c43b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_subccc.c -file - - - - -2008-04-06T23:16:07.837711Z -f57b5f053a720eb33150e3e5a4905f97 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_orncc.c -file - - - - -2008-04-06T23:16:07.849286Z -d3050e8fdad37ddc16778a4c3e831ed0 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sdiv.c -file - - - - -2008-04-06T23:16:07.860876Z -1a384c5662a8457270faa78ba12c1c4d -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_rdpr.c -file - - - - -2008-04-06T23:16:07.871899Z -a67d547a9c1f3d52f3c8c71e096d36fb -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_xor.c -file - - - - -2008-04-06T23:16:07.884975Z -b8e2b57233c7b96607c401cb77beda27 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_swap.c -file - - - - -2008-04-06T23:16:07.920178Z -7f1c8fc792d4ec796b453e80d244b6aa -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_swapa.c -file - - - - -2008-04-06T23:16:07.943327Z -71328b08f2926477feb40dd81436968a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_call.c -file - - - - -2008-04-06T23:16:07.931876Z -d0a9db82fb47aa5184c22ac08a211c3d -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stqf.c -file - - - - -2008-04-06T23:16:07.966149Z -4f367d4ab281b3b23a14fdc500915f86 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stwa.c -file - - - - -2008-04-06T23:16:07.978049Z -cfee2caa2f016b50aea74e8c65a211cf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_mulscc.c -file - - - - -2008-04-06T23:16:08.235976Z -de5660d591f494706f42b2c5a9e5ed84 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldub.c -file - - - - -2008-04-06T23:16:08.158611Z -0e19f7148e30c8ed344058b2f64cce14 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldqfa.c -file - - - - -2008-04-06T23:16:08.282876Z -2f7223e3cc16ac2f7773a6f750683819 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stba.c -file - - - - -2008-04-06T23:16:08.306066Z -1927b389d75dd0eee6f1b0eb5c4d8f76 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_subc.c -file - - - - -2008-04-06T23:16:08.329329Z -683391d5f465adb5dc68216e4d93cd3a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_save.c -file - - - - -2008-04-06T23:16:08.377477Z -a30ecbbd8fd12da460631c984c9e8e8b -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stdf.c -file - - - - -2008-04-06T23:16:08.411900Z -d433aa8182df8ef92a7660a6d326bed2 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_srl.c -file - - - - -2008-04-06T23:16:08.400876Z -db18af3be2fc0ca16e60268339a980cf -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_impdep2.c -file - - - - -2008-04-06T23:16:08.388900Z -910a3c8457784017333c91e03a77fca8 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_stfsr.c -file - - - - -2008-04-06T23:16:08.435876Z -ee9b5c0bc42041990261ba27a9771b8a -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fbfcc.c -file - - - - -2008-04-06T23:16:08.446903Z -2bd8156490457015fe066c06a3f3b5e8 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_rd.c -file - - - - -2008-04-06T23:16:08.458972Z -eb31dc7baeed015a65d2110cc3772810 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldfa.c -file - - - - -2008-04-06T23:16:08.470877Z -1c7c523ded6712b02cafde3735e3578e -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sdivcc.c -file - - - - -2008-04-06T23:16:08.528983Z -1fb60d3417692871789547744ae75a1f -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovsr.c -file - - - - -2008-04-06T23:16:08.539880Z -37ecf4b95defb3a76347e66896a252b4 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_restore.c -file - - - - -2008-04-06T23:16:08.586565Z -749bbdcc2503017891d26df0240795c1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_umulcc.c -file - - - - -2008-04-06T23:16:08.678899Z -aa280749b05aa033d5a85ed2ead90e53 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_wrpr.c -file - - - - -2008-04-06T23:16:08.701900Z -79170c9f41cc7ae252d45cf8a5f37857 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_taddcctv.c -file - - - - -2008-04-06T23:16:08.712909Z -3c47646ca5cd41cf5c2582b9cb7da831 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_sdivx.c -file - - - - -2008-04-06T23:16:08.725282Z -0b846cec929aa0de9ee9de6f24c8fd2d -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovqcc.c -file - - - - -2008-04-06T23:16:08.759889Z -0a189b8519f49989d8fbd5a4054a15a7 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldstuba.c -file - - - - -2008-04-06T23:16:08.748373Z -10863ee8da2e8c0712c1844f574377b1 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_casxa.c -file - - - - -2008-04-06T23:16:08.771394Z -bfe161b414ef0dda3e12d3e6bce9ca74 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_fmovscc.c -file - - - - -2008-04-06T23:16:08.806072Z -588a8cb58d5e0c4c49576ff3b135f314 -2008-02-19T17:09:59.893936Z -849 -may - -asm_sparc_ldd.c -file - - - - -2008-04-06T23:16:08.828899Z -229464d9c3c9acda02d447cc6189cb77 -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/format 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addccc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addccc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addccc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addccc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_addccc.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_addccc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** -** $Id: asm_sparc_addcc.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_addcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_INCCC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_addc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_addc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_addc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_add.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_add.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_add.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_add.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* -** -** $Id: asm_sparc_add.c,v 1.8 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_add(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_INC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_andcc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_andcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_BTST; - ins->nb_op = 2; - ins->op[0] = ins->op[2]; - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_and.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_and.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_and.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_and.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_and.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_and(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andncc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andncc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andncc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andncc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_andncc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_andncc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andn.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andn.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andn.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_andn.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: asm_sparc_andn.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_andn(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BCLR; - ins->nb_op = 2; - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bicc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bicc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bicc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bicc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** -** $Id: asm_sparc_bicc.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_bicc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_branch opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_branch(&opcode, buf); - - inter = proc->internals; - - ins->instr = inter->bcc_table[opcode.cond]; - - if (ins->instr == ASM_SP_BA) - ins->type = ASM_TYPE_IMPBRANCH; - else if (ins->instr == ASM_SP_BN) - ins->type = ASM_TYPE_NOP; - else - ins->type = ASM_TYPE_CONDBRANCH; - - ins->nb_op = 1; - ins->op[0].imm = opcode.imm; - ins->annul = opcode.a; - ins->prediction = 1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISPLACEMENT, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** -** $Id: asm_sparc_bpcc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_bpcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_pbranch opcodep; - struct s_asm_proc_sparc *inter; - sparc_convert_pbranch(&opcodep, buf); - - inter = proc->internals; - - ins->instr = inter->bcc_table[opcodep.cond]; - - if (ins->instr == ASM_SP_BA) - ins->type = ASM_TYPE_IMPBRANCH; - else if (ins->instr == ASM_SP_BN) - ins->type = ASM_TYPE_NOP; - else - ins->type = ASM_TYPE_CONDBRANCH; - - ins->nb_op = 2; - ins->op[0].imm = opcodep.imm; - ins->op[1].baser = opcodep.cc + 4; - ins->annul = opcodep.a; - ins->prediction = opcodep.p; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISPLACEMENT, ins); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_CC, ins); - - if (ins->instr == ASM_SP_BN && - ins->annul && ins->prediction && ins->op[1].baser == ASM_SP_XCC) { - - ins->instr = ASM_SP_IPREFETCH; - ins->nb_op = 1; - ins->type = ASM_TYPE_NONE; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_bpr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* -** -** $Id: asm_sparc_bpr.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_bpr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_rbranch opcoder; - struct s_asm_proc_sparc *inter; - sparc_convert_rbranch(&opcoder, buf); - - inter = proc->internals; - - ins->instr = inter->brcc_table[opcoder.rcond]; - ins->type = ASM_TYPE_CONDBRANCH; - ins->nb_op = 2; - ins->op[0].imm = opcoder.d16; - ins->op[1].baser = opcoder.rs1; - ins->annul = opcoder.a; - ins->prediction = opcoder.p; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISPLACEMENT, ins); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_call.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_call.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_call.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_call.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* -** -** $Id: asm_sparc_call.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_call(asm_instr *ins, u_char *buf, u_int len, - asm_processor *proc) -{ - struct s_decode_call opcode; - sparc_convert_call(&opcode, buf); - - ins->ptr_instr = buf; - ins->instr = ASM_SP_CALL; - ins->type = ASM_TYPE_CALLPROC; - ins->nb_op = 1; - ins->op[0].imm = opcode.displacement; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISP30, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** -** $Id: asm_sparc_casa.c,v 1.9 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_casa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON | ASM_TYPE_STORE; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[2].baser = opcode.rs1; - ins->op[2].imm = 0; - ins->op[2].address_space = -1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[2].baser = opcode.rs1; - ins->op[2].indexr = -1; - ins->op[2].address_space = opcode.none; - - /* Synthethics */ - if (ins->op[2].address_space == ASM_SP_ASI_P) - ins->instr = ASM_SP_CAS; - else if (ins->op[2].address_space == ASM_SP_ASI_P_L) { - ins->instr = ASM_SP_CASL; - ins->op[2].address_space = ASM_SP_ASI_P; - } - - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casxa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casxa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casxa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_casxa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** -** $Id: asm_sparc_casxa.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_casxa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON | ASM_TYPE_STORE; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[2].baser = opcode.rs1; - ins->op[2].imm = 0; - ins->op[2].address_space = -1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[2].baser = opcode.rs1; - ins->op[2].indexr = -1; - ins->op[2].address_space = opcode.none; - - /* Synthethics */ - if (ins->op[2].address_space == ASM_SP_ASI_P) - ins->instr = ASM_SP_CASX; - else if (ins->op[2].address_space == ASM_SP_ASI_P_L) { - ins->instr = ASM_SP_CASXL; - ins->op[2].address_space = ASM_SP_ASI_P; - } - - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_done.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_done.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_done.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_done.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** -** $Id: asm_sparc_done.c,v 1.6 2007/07/18 15:47:10 strauss Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_done(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_RETPROC | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - if (opcode.rd == 0) /* DONE */ - ins->instr = ASM_SP_DONE; - else if (opcode.rd == 1) - ins->instr = ASM_SP_RETRY; /* RETRY */ - else - ins->instr = ASM_SP_BAD; - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbfcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbfcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbfcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbfcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** -** $Id: asm_sparc_fbfcc.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fbfcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_branch opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_branch(&opcode, buf); - - inter = proc->internals; - - ins->instr = inter->fbcc_table[opcode.cond]; - - if (ins->instr == ASM_SP_FBA) - ins->type = ASM_TYPE_IMPBRANCH; - else if (ins->instr == ASM_SP_FBN) - ins->type = ASM_TYPE_NOP; - else - ins->type = ASM_TYPE_CONDBRANCH; - - ins->nb_op = 1; - ins->op[0].imm = opcode.imm; - ins->annul = opcode.a; - ins->prediction = 1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISPLACEMENT, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbpfcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbpfcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbpfcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fbpfcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_fbpfcc.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fbpfcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_pbranch opcodep; - struct s_asm_proc_sparc *inter; - sparc_convert_pbranch(&opcodep, buf); - - inter = proc->internals; - - ins->instr = inter->fbcc_table[opcodep.cond]; - - if (ins->instr == ASM_SP_FBA) - ins->type = ASM_TYPE_IMPBRANCH; - else if (ins->instr == ASM_SP_FBN) - ins->type = ASM_TYPE_NOP; - else - ins->type = ASM_TYPE_CONDBRANCH; - - ins->type = ASM_TYPE_CONDBRANCH; - ins->nb_op = 2; - ins->op[0].imm = opcodep.imm; - ins->op[1].baser = opcodep.cc; - ins->annul = opcodep.a; - ins->prediction = opcodep.p; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_DISPLACEMENT, ins); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpd.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpd.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpd.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmpd.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmpd(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs1 & 1) << 5) | (opcode.rs1 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmped.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmped.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmped.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmped.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmped.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmped(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs1 & 1) << 5) | (opcode.rs1 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpeq.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpeq.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpeq.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpeq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmpeq.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmpeq(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs1 & 1) << 5) | (opcode.rs1 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpes.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpes.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpes.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmpes.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmpes(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpq.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpq.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpq.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmpq.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmpq.c,v 1.11 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmpq(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs1 & 1) << 5) | (opcode.rs1 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmps.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmps.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmps.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fcmps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fcmps.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fcmps(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_FCC0 << opcode.cc; - - ins->instr = inter->fcmp_table[(opcode.opf & 0x1f) - 16]; - ins->nb_op = 3; - ins->op[0].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flush.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flush.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flush.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flush.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/* -** -** $Id: asm_sparc_flush.c,v 1.7 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_flush(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_OTHER; - - ins->nb_op = 1; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flushw.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flushw.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flushw.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_flushw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* -** -** $Id: asm_sparc_flushw.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_flushw(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - ins->type = ASM_TYPE_OTHER; - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovdcc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovdcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_READFLAG; - - if (opcode.opf_cc < 4) { - ins->instr = inter->fmovfcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_FCC0 << opcode.opf_cc; - } - else if (opcode.opf_cc == 4 || opcode.opf_cc == 6) { - ins->instr = inter->fmovcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_N | ASM_SP_FLAG_Z; - } - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.opf_cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovdr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovdr.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovdr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; - - inter = proc->internals; - - ins->instr = inter->fmovr_table[(((opcode.opf & 0x1f) - 6) * 8) - + opcode.rcond]; - - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovqcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovqcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_READFLAG; - - if (opcode.opf_cc < 4) { - ins->instr = inter->fmovfcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_FCC0 << opcode.opf_cc; - } - else if (opcode.opf_cc == 4 || opcode.opf_cc == 6) { - ins->instr = inter->fmovcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_N | ASM_SP_FLAG_Z; - } - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.opf_cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovqr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovqr.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovqr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; - - ins->instr = inter->fmovr_table[(((opcode.opf & 0x1f) - 6) * 8) - + opcode.rcond]; - - ins->nb_op = 3; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = ((opcode.rs2 & 1) << 5) | (opcode.rs2 & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovscc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovscc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovscc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovscc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovscc.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovscc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_READFLAG; - - if (opcode.opf_cc < 4) { - ins->instr = inter->fmovfcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_FCC0 << opcode.opf_cc; - } - else if (opcode.opf_cc == 4 || opcode.opf_cc == 6) { - ins->instr = inter->fmovcc_table[(((opcode.opf & 0x1f) - 1) * 8) - + opcode.cond]; - - ins->flagsread = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_N | ASM_SP_FLAG_Z; - } - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.opf_cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovsr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovsr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovsr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fmovsr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** -** $Id: asm_sparc_fmovsr.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fmovsr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_COMPARISON; - - ins->instr = inter->fmovr_table[(((opcode.opf & 0x1f) - 6) * 8) - + opcode.rcond]; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fpop1.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fpop1.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fpop1.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_fpop1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_fpop1.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_fpop1(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - - ins->instr = inter->fpop1_table[opcode.opf]; - ins->type = ASM_TYPE_ARITH; - if (opcode.opf < 0x40 || opcode.opf >= 0x70) { - ins->type = ASM_TYPE_ASSIGN; - ins->nb_op = 2; - } - else { /* 0x40 < opf < 0x69 - add, sub, mul, div */ - ins->nb_op = 3; - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_FREGISTER, ins); - } - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illegal.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illegal.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illegal.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illegal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -/* -** -** $Id: asm_sparc_illegal.c,v 1.3 2007/08/07 07:13:27 may Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_illegal(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - ins->instr = ASM_SP_BAD; - ins->type = ASM_TYPE_STOP; - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illtrap.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illtrap.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illtrap.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_illtrap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -/* -** -** $Id: asm_sparc_illtrap.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_illtrap(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_branch opcode; - sparc_convert_branch(&opcode, buf); - - ins->type = ASM_TYPE_INT | ASM_TYPE_STOP; - - ins->instr = ASM_SP_ILLTRAP; - ins->nb_op = 1; - ins->op[0].imm = opcode.immediate; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep1.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep1.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep1.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* -** -** $Id: asm_sparc_impdep1.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_impdep1(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - ins->type = ASM_TYPE_ARCH; - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep2.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep2.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep2.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_impdep2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/* -** -** $Id: asm_sparc_impdep2.c,v 1.4 2007/06/16 20:24:25 strauss Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_impdep2(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - ins->type = ASM_TYPE_ARCH; - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_jmpl.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_jmpl.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_jmpl.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_jmpl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -/* -** -** $Id: asm_sparc_jmpl.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_jmpl(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_IMPBRANCH; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - if (ins->op[0].baser == ASM_REG_O7) { - ins->nb_op = 1; - ins->instr = ASM_SP_CALL; - ins->type = ASM_TYPE_CALLPROC; - ins->op[0] = ins->op[1]; - } - else if (ins->op[0].baser == ASM_REG_G0) { - if (ins->op[1].content == ASM_SP_OTYPE_IMM_ADDRESS && - ins->op[1].baser == ASM_REG_I7 && ins->op[1].imm == 8) { - - ins->instr = ASM_SP_RET; - ins->type = ASM_TYPE_RETPROC; - ins->nb_op = 0; - } - else if (ins->op[1].content == ASM_SP_OTYPE_IMM_ADDRESS && - ins->op[1].baser == ASM_REG_O7 && ins->op[1].imm == 8) { - - ins->instr = ASM_SP_RETL; - ins->type = ASM_TYPE_RETPROC; - ins->nb_op = 0; - } - else { - ins->instr = ASM_SP_JMP; - ins->nb_op = 1; - ins->op[0] = ins->op[1]; - } - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldda.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldda.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldda.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldda.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldda.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldda(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldd.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldd.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldd.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldd.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldd(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_lddfa.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lddfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lddf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_lddf.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lddf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfsr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfsr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfsr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldfsr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_ldfsr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldfsr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - if (opcode.rd == 0) - ins->instr = ASM_SP_LDFSR; - else if (opcode.rd == 1) - ins->instr = ASM_SP_LDXFSR; - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 2; - ins->op[0].baser = ASM_FREG_FSR; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldqfa.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldqfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldqf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldqf.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldqf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_FREGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsba.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsba.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsba.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsba.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldsba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldsba(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsb.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsb.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsb.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldsb.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldsb(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsha.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsha.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsha.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsha.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldsha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldsha(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsh.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsh.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsh.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldsh.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldsh(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstuba.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstuba.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstuba.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstuba.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldstuba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldstuba(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN | ASM_TYPE_STORE; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstub.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstub.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstub.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldstub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldstub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldstub(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN | ASM_TYPE_STORE; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldswa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldswa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldswa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldswa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldswa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldswa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsw.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsw.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsw.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldsw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldsw.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldsw(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduba.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduba.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduba.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduba.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_lduba.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lduba(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldub.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldub.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldub.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_ldub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldub(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduha.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduha.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduha.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduha.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_lduha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lduha(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduh.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduh.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduh.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_lduh.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lduh(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduwa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduwa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduwa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduwa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_lduwa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lduwa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduw.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduw.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduw.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_lduw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_lduw.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_lduw(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldxa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldxa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldxa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldxa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_ldxa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldxa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; - -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldx.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldx.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldx.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_ldx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_ldx.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_ldx(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,50 +0,0 @@ -/* -** -** $Id: asm_sparc_movcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_movcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_decode_format4 opcode4; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - sparc_convert_format4(&opcode4, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN | ASM_TYPE_READFLAG; - - if (opcode4.cc2 == 0) { /* fcc{0,1,2,3,4} */ - ins->instr = inter->movcc_table[opcode4.cond]; - ins->flagsread = ASM_SP_FLAG_FCC0 << opcode4.cc; - } - else if (opcode4.cc0 == 0) { /* icc or xcc */ - ins->instr = inter->movfcc_table[opcode4.cond]; - ins->flagsread = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_N | ASM_SP_FLAG_Z; - } - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 3; - ins->op[0].baser = opcode4.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode4.cc; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_CC, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_movr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_movr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_movr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ASSIGN; - - ins->instr = inter->movr_table[opcode.rcond]; - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm10; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulscc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulscc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulscc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulscc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_mulscc.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_mulscc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulx.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulx.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulx.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_mulx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_mulx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_mulx(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/* -** -** $Id: asm_sparc_orcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_orcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ASM_REG_G0 && - ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[2].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_TST; - ins->type = ASM_TYPE_COMPARISON | ASM_TYPE_WRITEFLAG; - ins->nb_op = 1; - ins->op[0] = ins->op[1]; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_or.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_or.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_or.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_or.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/* -** -** $Id: asm_sparc_or.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_or(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BSET; - ins->nb_op = 2; - } - else if (ins->op[2].baser == ASM_REG_G0) { - if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[1].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; - } - else { - ins->instr = ASM_SP_MOV; - ins->nb_op = 2; - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orncc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orncc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orncc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orncc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_orncc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_orncc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orn.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orn.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orn.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_orn.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_orn.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_orn(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_popc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_popc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_popc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_popc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_popc.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_popc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ASSIGN; - - if (opcode.rs1 == 0) { - ins->instr = ASM_SP_POPC; - ins->nb_op = 2; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - } - else - ins->instr = ASM_SP_BAD; - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetcha.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetcha.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetcha.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetcha.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_prefetcha.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_prefetcha(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD; - - ins->nb_op = 2; - ins->op[0].imm = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetch.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetch.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetch.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_prefetch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_prefetch.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_prefetch(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD; - - ins->nb_op = 2; - ins->op[0].imm = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rd.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rd.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rd.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/* -** -** $Id: asm_sparc_rd.c,v 1.9 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_rd(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ASSIGN; - - if (opcode.rs1 != 15) { /* RD*(-PR) */ - ins->nb_op = 2; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[1].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_SREGISTER, ins); - - if (ins->op[0].baser == ASM_SREG_Y) { - ins->instr = ASM_SP_MOV; - } - } - else { - if (opcode.rd != 0) - ins->instr = ASM_SP_BAD; - else if (opcode.i == 0) { /* STBAR */ - ins->type = ASM_TYPE_OTHER; - ins->instr = ASM_SP_STBAR; - } - else if (opcode.i == 1) { /* MEMBAR */ - ins->instr = ASM_SP_MEMBAR; - ins->type = ASM_TYPE_OTHER; - ins->nb_op = 1; - - /* operand = cmask OR mmask */ - ins->op[0].imm = ((opcode.imm & 0x70) >> 4) | (opcode.imm & 0xf); - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rdpr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rdpr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rdpr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_rdpr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_rdpr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_rdpr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ASSIGN; - - if (opcode.rs1 < ASM_PREG_BAD16 || opcode.rs1 > ASM_PREG_BAD30) { - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[1].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_PREGISTER, ins); - } - else - ins->instr = ASM_SP_BAD; - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_restore.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_restore.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_restore.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_restore.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_restore.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_restore(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_EPILOG; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_return.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_return.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_return.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_return.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** -** $Id: asm_sparc_return.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -/** - * Sparc handler for the return instruction. - * @param ins Pointer to instruction structure. - * @param buf Pointer to data to disassemble. - * @param len Length of data to disassemble. - * @param proc Pointer to processor structure. - * @param Return instruction length. - */ - -int -asm_sparc_return(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_RETPROC; - - ins->nb_op = 1; - - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_save.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_save.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_save.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_save.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_save.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_save(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_PROLOG; - - ins->nb_op = 3; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_saved.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_saved.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_saved.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_saved.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* -** -** $Id: asm_sparc_saved.c,v 1.6 2007/08/07 07:13:27 may Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_saved(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_PROLOG; - - if (opcode.rd == 0) - ins->instr = ASM_SP_SAVED; - else if (opcode.rd == 1) - ins->instr = ASM_SP_RESTORED; - else - ins->instr = ASM_SP_BAD; - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_sdivcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sdivcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdiv.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdiv.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdiv.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdiv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_sdiv.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sdiv(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivx.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivx.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivx.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sdivx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_sdivx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sdivx(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sethi.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sethi.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sethi.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sethi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: asm_sparc_sethi.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sethi(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_branch opcode; - sparc_convert_branch(&opcode, buf); - - ins->type = ASM_TYPE_ASSIGN; - - if (!opcode.rd && !opcode.imm) { - ins->instr = ASM_SP_NOP; - ins->type = ASM_TYPE_NOP; - ins->nb_op = 0; - } - else { - ins->instr = ASM_SP_SETHI; - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_SETHI, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sll.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sll.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sll.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sll.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_sll.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sll(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ARITH; - - ins->instr = inter->shift_table[opcode.op3 - 0x25 + - ((opcode.imm & 0x1000) ? 1 : 0)]; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.shcnt; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smulcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smulcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smulcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smulcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_smulcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_smulcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smul.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smul.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smul.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_smul.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_smul.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_smul(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sra.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sra.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sra.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sra.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* -** -** $Id: asm_sparc_sra.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sra(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ARITH; - - ins->instr = inter->shift_table[opcode.op3 - 0x25 + - ((opcode.imm & 0x1000) ? 1 : 0)]; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.shcnt; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - /* Synthetics */ - if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[1].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_SIGNX; - if (ins->op[2].baser == ins->op[0].baser) - ins->nb_op = 1; - else { - ins->nb_op = 2; - ins->op[1] = ins->op[2]; - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_srl.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_srl.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_srl.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_srl.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/* -** -** $Id: asm_sparc_srl.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_srl(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_ARITH; - - ins->instr = inter->shift_table[opcode.op3 - 0x25 + - ((opcode.imm & 0x1000) ? 1 : 0)]; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.shcnt; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - /* Synthetics */ - if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[1].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_CLRUW; - if (ins->op[2].baser == ins->op[0].baser) - ins->nb_op = 1; - else { - ins->nb_op = 2; - ins->op[1] = ins->op[2]; - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stba.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stba.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stba.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stba.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stba.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stba(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stb.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stb.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stb.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stb.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_stb.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stb(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRB; - ins->nb_op = 1; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stda.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stda.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stda.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stda.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stda.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stda(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_std.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_std.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_std.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_std.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** -** $Id: asm_sparc_std.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_std(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (ins->instr == ASM_SP_STB && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRB; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STH && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRH; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STW && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; - } - else if (ins->instr == ASM_SP_STX && ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRX; - ins->nb_op = 1; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stdfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stdfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stdf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_stdf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stdf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stfa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_stf.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfsr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfsr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfsr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stfsr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: asm_sparc_stfsr.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stfsr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - if (opcode.rd == 0) - ins->instr = ASM_SP_LDFSR; - else if (opcode.rd == 1) - ins->instr = ASM_SP_LDXFSR; - else { - ins->instr = ASM_SP_BAD; - return 4; - } - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = ASM_FREG_FSR; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stha.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stha.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stha.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stha.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stha.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stha(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sth.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sth.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sth.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sth.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_sth.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sth(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRH; - ins->nb_op = 1; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqfa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqfa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqfa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stqfa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stqfa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqf.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqf.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqf.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stqf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_stqf.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stqf(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = ((opcode.rd & 1) << 5) | (opcode.rd & 0x1E); - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_FREGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stwa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stwa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stwa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stwa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stwa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stwa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stw.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stw.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stw.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_stw.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stw(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLR; - ins->nb_op = 1; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stxa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stxa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stxa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stxa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_stxa.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stxa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - ins->op[0].address_space = -1; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - ins->op[0].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stx.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stx.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stx.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_stx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_stx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_stx(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_STORE; - - ins->nb_op = 2; - if (opcode.i) { - ins->op[0].baser = opcode.rs1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode.rs1; - ins->op[0].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (ins->op[1].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CLRX; - ins->nb_op = 1; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subccc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subccc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subccc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subccc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_subccc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_subccc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** -** $Id: asm_sparc_subcc.c,v 1.11 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_subcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ASM_REG_G0) { - ins->instr = ASM_SP_CMP; - ins->type |= ASM_TYPE_COMPARISON; - ins->nb_op = 2; - ins->op[0] = ins->op[1]; - ins->op[1] = ins->op[2]; - } - else if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_DECCC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_subc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_subc.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_subc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sub.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sub.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sub.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_sub.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** -** $Id: asm_sparc_sub.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_sub(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if ((ins->op[0].baser == ins->op[2].baser) && - ins->op[1].content == ASM_SP_OTYPE_IMMEDIATE) { - - ins->instr = ASM_SP_DEC; - - if (ins->op[1].imm == 1) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - else if (ins->op[2].baser == ASM_REG_G0 && - ins->op[1].content == ASM_SP_OTYPE_REGISTER) { - - ins->instr = ASM_SP_NEG; - if (ins->op[1].baser == ins->op[0].baser) - ins->nb_op = 1; - else - ins->nb_op = 2; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swapa.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swapa.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swapa.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swapa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_swapa.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_swapa(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_STORE | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - ins->op[1].address_space = -1; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - ins->op[1].address_space = opcode.none; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swap.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swap.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swap.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_swap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: asm_sparc_swap.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_swap(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op3_table[opcode.op3]; - - ins->type = ASM_TYPE_LOAD | ASM_TYPE_STORE | ASM_TYPE_ASSIGN; - - ins->nb_op = 2; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i) { - ins->op[1].baser = opcode.rs1; - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[1].baser = opcode.rs1; - ins->op[1].indexr = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_taddcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_taddcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcctv.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcctv.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcctv.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_taddcctv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_taddcctv.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_taddcctv(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/* -** -** $Id: asm_sparc_tcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_tcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_decode_format4 opcode4; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - sparc_convert_format4(&opcode4, buf); - - inter = proc->internals; - ins->type = ASM_TYPE_INT | ASM_TYPE_READFLAG; - ins->flagsread = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_N | ASM_SP_FLAG_Z; - - ins->instr = inter->tcc_table[opcode4.cond]; - ins->nb_op = 2; - if (opcode4.i) { - ins->op[0].baser = opcode4.rs1; - ins->op[0].imm = opcode4.sw_trap; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMM_ADDRESS, ins); - } - else { - ins->op[0].baser = opcode4.rs1; - ins->op[0].indexr = opcode4.rs2; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REG_ADDRESS, ins); - } - - ins->op[1].baser = (opcode4.cc & 0x3) + 4; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_CC, ins); - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_tsubcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_tsubcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcctv.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcctv.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcctv.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_tsubcctv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_tsubcctv.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_tsubcctv(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_udivcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_udivcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udiv.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udiv.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udiv.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udiv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_udiv.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_udiv(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivx.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivx.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivx.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_udivx.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_udivx.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_udivx(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umulcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umulcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umulcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umulcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_umulcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_umulcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umul.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umul.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umul.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_umul.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -/* -** -** $Id: asm_sparc_umul.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_umul(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* -** -** $Id: asm_sparc_wr.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_wr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ASSIGN; - - if (opcode.rd == 1) - ins->instr = ASM_SP_BAD; - else if (opcode.rd == 15) { /* SIR */ - ins->instr = ASM_SP_SIR; - ins->type = ASM_TYPE_INT; - ins->nb_op = 1; - ins->op[0].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - else { /* WR */ - ins->nb_op = 3; - - if (opcode.rd == 2) { /* WRCCR overwrites the condition codes */ - ins->type |= ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - } - - if (opcode.rd == 4 || opcode.rd == 5) /* can't write PC or TICK */ - ins->op[0].baser = ASM_SREG_BAD; - else - ins->op[0].baser = opcode.rd; - - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_SREGISTER, ins); - - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ASM_SREG_Y && ins->op[2].baser == ASM_REG_G0) { - ins->instr = ASM_SP_MOV; - ins->nb_op = 2; - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wrpr.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wrpr.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wrpr.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_wrpr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/* -** -** $Id: asm_sparc_wrpr.c,v 1.8 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_wrpr(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ASSIGN; - - ins->nb_op = 3; - if (opcode.rd == 31) /* can't write VER */ - ins->op[0].baser = ASM_PREG_BAD16; - else - ins->op[0].baser = opcode.rd; - - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_PREGISTER, ins); - - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnorcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnorcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnorcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnorcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_xnorcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_xnorcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnor.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnor.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnor.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xnor.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* -** -** $Id: asm_sparc_xnor.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_xnor(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[1].content == ASM_SP_OTYPE_REGISTER && - ins->op[1].baser == ASM_REG_G0) { - - ins->instr = ASM_SP_NOT; - if (ins->op[2].baser == ins->op[0].baser) - ins->nb_op = 1; - else { - ins->nb_op = 2; - ins->op[1] = ins->op[2]; - } - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xorcc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xorcc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xorcc.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xorcc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* -** -** $Id: asm_sparc_xorcc.c,v 1.10 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_xorcc(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH | ASM_TYPE_WRITEFLAG; - ins->flagswritten = ASM_SP_FLAG_C | ASM_SP_FLAG_V | ASM_SP_FLAG_Z | ASM_SP_FLAG_N; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xor.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xor.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xor.c.svn-base 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/handlers/.svn/text-base/asm_sparc_xor.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** -** $Id: asm_sparc_xor.c,v 1.7 2007/10/14 00:01:42 heroine Exp $ -** -*/ -#include "libasm.h" - -int -asm_sparc_xor(asm_instr * ins, u_char * buf, u_int len, - asm_processor * proc) -{ - struct s_decode_format3 opcode; - struct s_asm_proc_sparc *inter; - sparc_convert_format3(&opcode, buf); - - inter = proc->internals; - ins->instr = inter->op2_table[opcode.op3]; - - ins->type = ASM_TYPE_ARITH; - - ins->nb_op = 3; - ins->op[0].baser = opcode.rd; - asm_sparc_op_fetch(&ins->op[0], buf, ASM_SP_OTYPE_REGISTER, ins); - ins->op[2].baser = opcode.rs1; - asm_sparc_op_fetch(&ins->op[2], buf, ASM_SP_OTYPE_REGISTER, ins); - - if (opcode.i == 0) { - ins->op[1].baser = opcode.rs2; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_REGISTER, ins); - } - else { - ins->op[1].imm = opcode.imm; - asm_sparc_op_fetch(&ins->op[1], buf, ASM_SP_OTYPE_IMMEDIATE, ins); - } - - if (ins->op[0].baser == ins->op[2].baser) { - ins->instr = ASM_SP_BTOG; - ins->nb_op = 2; - } - - return 4; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/init_sparc.c eresi-0.0.20110516/libasm/src/arch/sparc/init_sparc.c --- eresi-0.8a25/libasm/src/arch/sparc/init_sparc.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/init_sparc.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/init_sparc.c +** @ingroup sparc +*/ /* ** ** init_sparc.c in @@ -6,7 +10,7 @@ ** Started : Sun Nov 30 20:13:12 2003 ** Updated : Thu Dec 4 03:01:07 2003 ** -** $Id: init_sparc.c,v 1.10 2007/11/28 00:21:37 strauss Exp $ +** $Id: init_sparc.c 1397 2009-09-13 02:19:08Z may $ ** */ diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c +** @ingroup SPARC_operands +*/ #include #include @@ -12,7 +16,7 @@ */ int asm_sparc_op_fetch_reg_address(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) + int otype, asm_instr *ins) { operand->content = ASM_SP_OTYPE_REG_ADDRESS; operand->type = ASM_OPTYPE_MEM; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c +** @ingroup SPARC_operands +*/ #include #include diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,11 @@ +/** + * @defgroup SPARC_operands SPARC operands API. + * @ingroup sparc + */ +/** +* @file libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c +** @ingroup SPARC_operands +*/ #include #include @@ -15,9 +23,8 @@ free(asm_name_pool[index]); ret = asm_name_pool[index] = (char *) malloc(ASM_OP_NAME_LEN); - - index = (index+1)%ASM_POOL_SIZE; - + if (ret != NULL) + index = (index + 1) % ASM_POOL_SIZE; return ret; } @@ -39,7 +46,8 @@ case ASM_SP_OTYPE_IMM_ADDRESS: buf = asm_name_pool_alloc(); - sprintf(buf, "[ %s", get_sparc_register(op->baser)); + op->sbaser = get_sparc_register(op->baser); + sprintf(buf, "[ %s", op->sbaser); if (op->imm) sprintf(buf+strlen(buf), " + 0x%x", op->imm); @@ -51,13 +59,16 @@ return buf; case ASM_SP_OTYPE_REG_ADDRESS: buf = asm_name_pool_alloc(); + op->sbaser = get_sparc_register(op->baser); + if (op->indexr > 0) - sprintf(buf, "[ %s + %s ]", get_sparc_register(op->baser), - get_sparc_register(op->indexr)); - - else - sprintf(buf, "[ %s ]", get_sparc_register(op->baser)); - + { + op->sindex = get_sparc_register(op->indexr); + sprintf(buf, "[ %s + %s ]", op->sbaser, op->sindex); + } + else + sprintf(buf, "[ %s ]", op->sbaser); + if (op->address_space != ASM_SP_ASI_P) sprintf(buf+strlen(buf), " 0x%x", op->address_space); diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/all-wcprops 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/911/trunk/libasm/src/arch/sparc/operand_handlers -END -asm_sparc_op_fetch.c -K 25 -svn:wc:ra_dav:version-url -V 83 -/svn/!svn/ver/911/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c -END -asm_sparc_op_fetch_disp30.c -K 25 -svn:wc:ra_dav:version-url -V 90 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c -END -asm_sparc_op_fetch_reg_address.c -K 25 -svn:wc:ra_dav:version-url -V 95 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c -END -asm_sparc_op_fetch_pregister.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c -END -asm_sparc_op_fetch_register.c -K 25 -svn:wc:ra_dav:version-url -V 92 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c -END -asm_sparc_op_fetch_cc.c -K 25 -svn:wc:ra_dav:version-url -V 86 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c -END -asm_sparc_op_fetch_imm_address.c -K 25 -svn:wc:ra_dav:version-url -V 95 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c -END -asm_sparc_op_fetch_sregister.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c -END -asm_sparc_op_name.c -K 25 -svn:wc:ra_dav:version-url -V 82 -/svn/!svn/ver/735/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c -END -asm_sparc_op_fetch_displacement.c -K 25 -svn:wc:ra_dav:version-url -V 96 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c -END -asm_sparc_op_fetch_fregister.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c -END -asm_sparc_op_fetch_sethi.c -K 25 -svn:wc:ra_dav:version-url -V 89 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c -END -asm_sparc_op_fetch_immediate.c -K 25 -svn:wc:ra_dav:version-url -V 93 -/svn/!svn/ver/765/trunk/libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c -END diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/entries eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/entries --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/entries 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/sparc/operand_handlers -http://svn.eresi-project.org/svn - - - -2008-03-14T10:03:51.600980Z -911 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -asm_sparc_op_fetch.c -file - - - - -2008-04-06T23:16:09.243877Z -d3b2d3abdb531acd7e514d6349d70cbf -2008-03-14T10:03:51.600980Z -911 -may - -asm_sparc_op_fetch_disp30.c -file - - - - -2008-04-06T23:16:09.279889Z -c51b382a4a223d0f90f265efe2c7cbe3 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_reg_address.c -file - - - - -2008-04-06T23:16:09.290888Z -9a05a2b21441c4f472d856b931b45f82 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_pregister.c -file - - - - -2008-04-06T23:16:09.302665Z -f9cdd6aa1d34dfa1932b2495f4145396 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_register.c -file - - - - -2008-04-06T23:16:09.315877Z -730553d098a0b161f1b6729ad862ad49 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_cc.c -file - - - - -2008-04-06T23:16:09.327088Z -fb6e2e7470f533b2f337c1c43d643ff1 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_imm_address.c -file - - - - -2008-04-06T23:16:09.338213Z -4d3ff05195f8645e54c8683fe0a4a0c4 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_sregister.c -file - - - - -2008-04-06T23:16:09.349899Z -30b7cf2ec037cf142ef9c8952969a13d -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_name.c -file - - - - -2008-04-06T23:16:09.360986Z -f84162ac72fb815bc96ef26dfffb6026 -2007-07-19T07:20:55.000000Z -735 -strauss - -asm_sparc_op_fetch_displacement.c -file - - - - -2008-04-06T23:16:09.372876Z -e7452082f2ed2a282f021f3712708df2 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_fregister.c -file - - - - -2008-04-06T23:16:09.384265Z -6cac5a3ceaac0c649591b54eb65b4644 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_sethi.c -file - - - - -2008-04-06T23:16:09.395877Z -acc607b342aa254288e89c80fb7a0f42 -2007-08-07T07:13:27.000000Z -765 -may - -asm_sparc_op_fetch_immediate.c -file - - - - -2008-04-06T23:16:09.407124Z -8ae6e58aa245b35cf28e9e499fa57176 -2007-08-07T07:13:27.000000Z -765 -may - diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/format eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/format --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/format 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_cc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_cc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_cc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_cc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_CC - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_cc(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_CC; - operand->type = ASM_OPTYPE_REG; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -#include -#include - - -/** - * Main function, dispatch processing to handler. - * @param op Pointer to operand to fill - * @param opcode Pointer to operand data. - * @param otype Content of operand to fetch : ASM_OTYPE_* - * @param proc Pointer to processor structure. - * @return Operand length or -1 on error (should currently never occur) - */ -int asm_sparc_op_fetch(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - vector_t *vec; - u_int dim[1]; - int to_ret; - int (*fetch)(asm_operand *, u_char *, int, asm_instr *); - - vec = aspect_vector_get("operand-sparc"); - dim[0] = otype; - - fetch = aspect_vectors_select(vec, dim); - to_ret = fetch(op, opcode, otype, ins); - - if (to_ret == -1) - { - printf("%s:%i Unsupported operand content : %i\n", __FILE__, __LINE__, - otype); - } - - op->name = asm_sparc_get_op_name(op); - - return (to_ret); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_disp30.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_disp30.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_disp30.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_disp30.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_DISP30 - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_disp30(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_DISP30; - operand->type = ASM_OPTYPE_IMM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_displacement.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_displacement.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_displacement.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_displacement.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_DISPLACEMENT - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_displacement(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_DISPLACEMENT; - operand->type = ASM_OPTYPE_IMM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_fregister.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_fregister.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_fregister.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_fregister.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_FREGISTER - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_fregister(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_FREGISTER; - operand->type = ASM_OPTYPE_REG; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_imm_address.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_imm_address.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_imm_address.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_imm_address.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_IMM_ADDRESS - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_imm_address(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_IMM_ADDRESS; - operand->type = ASM_OPTYPE_MEM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_immediate.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_immediate.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_immediate.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_immediate.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_IMMEDIATE - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_immediate(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_IMMEDIATE; - operand->type = ASM_OPTYPE_IMM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_pregister.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_pregister.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_pregister.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_pregister.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_PREGISTER - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_pregister(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_PREGISTER; - operand->type = ASM_OPTYPE_REG; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_reg_address.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_reg_address.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_reg_address.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_reg_address.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_REG_ADDRESS - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_reg_address(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_REG_ADDRESS; - operand->type = ASM_OPTYPE_MEM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_register.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_register.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_register.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_REGISTER - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_register(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_REGISTER; - operand->type = ASM_OPTYPE_REG; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sethi.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sethi.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sethi.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sethi.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_SETHI - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_sethi(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_SETHI; - operand->type = ASM_OPTYPE_IMM; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sregister.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sregister.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sregister.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_fetch_sregister.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#include -#include - -/** - * Decode data for operand content ASM_SP_OTYPE_SREGISTER - * @param operand Pointer to operand structure to fill. - * @param opcode Pointer to opcode data. - * @param otype Operand content. - * @param ins Pointer to instruction structure. - * - * @return Operand length (currently unused in libasm-sparc) - */ - -int asm_sparc_op_fetch_sregister(asm_operand *operand, u_char *opcode, - int otype, asm_instr *ins) -{ - operand->content = ASM_SP_OTYPE_SREGISTER; - operand->type = ASM_OPTYPE_REG; - return (0); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_name.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_name.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_name.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/operand_handlers/.svn/text-base/asm_sparc_op_name.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -#include -#include - -#define ASM_POOL_SIZE 100 -#define ASM_OP_NAME_LEN 64 - -/* FIFO sort-of memory manager */ -char *asm_name_pool_alloc() { - static char* asm_name_pool[ASM_POOL_SIZE] = {}; - static int index = 0; - - char *ret; - - if (asm_name_pool[index] != NULL) - free(asm_name_pool[index]); - - ret = asm_name_pool[index] = (char *) malloc(ASM_OP_NAME_LEN); - - index = (index+1)%ASM_POOL_SIZE; - - return ret; -} - -char *asm_sparc_get_op_name(asm_operand *op) { - char *buf; - - switch (op->content) { - - case ASM_SP_OTYPE_REGISTER: - return get_sparc_register(op->baser); - case ASM_SP_OTYPE_SREGISTER: - return get_sparc_sregister(op->baser); - case ASM_SP_OTYPE_PREGISTER: - return get_sparc_pregister(op->baser); - case ASM_SP_OTYPE_FREGISTER: - return get_sparc_fregister(op->baser); - case ASM_SP_OTYPE_CC: - return get_sparc_cc(op->baser); - - case ASM_SP_OTYPE_IMM_ADDRESS: - buf = asm_name_pool_alloc(); - sprintf(buf, "[ %s", get_sparc_register(op->baser)); - if (op->imm) - sprintf(buf+strlen(buf), " + 0x%x", op->imm); - - sprintf(buf+strlen(buf), " ]"); - - if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " %%asi"); - - return buf; - case ASM_SP_OTYPE_REG_ADDRESS: - buf = asm_name_pool_alloc(); - if (op->indexr > 0) - sprintf(buf, "[ %s + %s ]", get_sparc_register(op->baser), - get_sparc_register(op->indexr)); - - else - sprintf(buf, "[ %s ]", get_sparc_register(op->baser)); - - if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " 0x%x", op->address_space); - - return buf; - - default: - return NULL; - - } -} - diff -Nru eresi-0.8a25/libasm/src/arch/sparc/output_sparc.c eresi-0.0.20110516/libasm/src/arch/sparc/output_sparc.c --- eresi-0.8a25/libasm/src/arch/sparc/output_sparc.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/output_sparc.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/output_sparc.c +** @ingroup sparc +*/ /* ** output_sparc.c for in /hate/home/hate/code/libasm_current ** @@ -7,16 +11,20 @@ ** Started on Fri Jun 10 14:06:47 2005 #!HATE#@! ** Last update Thu Jun 16 05:41:18 2005 #!HATE#@! ** -** $Id: output_sparc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ +** $Id: output_sparc.c 1439 2010-12-13 10:27:16Z may $ ** */ #include #include -void asm_resolve_sparc(void *d, u_int val, char *buf, u_int len) +void asm_resolve_sparc(void *d, eresi_Addr val, char *buf, u_int len) { - sprintf(buf, "0x%x", val); + uint32_t addr; + + /* Address are always 32bits long on sparc, even for the ultra-64 architecture */ + addr = (uint32_t) val; + sprintf(buf, "0x%X", addr); } char *get_sparc_register(int reg) @@ -177,21 +185,21 @@ */ void asm_sparc_dump_operand(asm_instr *ins, int num, - unsigned int addr, char *buf) + eresi_Addr addr, char *buf) { asm_operand *op; - int address; - /** - * - */ - switch(num) { + eresi_Addr address; + + switch (num) + { case 1: op = &ins->op[0]; break; case 2: op = &ins->op[1]; break; case 3: op = &ins->op[2]; break; default: return; - } + } - switch(op->content) { + switch (op->content) + { case ASM_SP_OTYPE_REGISTER: sprintf(buf, "%s", get_sparc_register(op->baser)); break; @@ -209,15 +217,15 @@ break; case ASM_SP_OTYPE_IMMEDIATE: if (op->imm < 10) - sprintf(buf, "%i", op->imm); + sprintf(buf, "%i", op->imm); else - sprintf(buf, "0x%x", op->imm); + sprintf(buf, "0x%x", op->imm); break; case ASM_SP_OTYPE_SETHI: if (op->imm) - sprintf(buf, "%%hi(0x%x)", op->imm << 10); + sprintf(buf, "%%hi(0x%x)", op->imm << 10); else - sprintf(buf, "%%hi(%x)", op->imm << 10); + sprintf(buf, "%%hi(%x)", op->imm << 10); break; case ASM_SP_OTYPE_DISPLACEMENT: address = addr + (op->imm << 2); @@ -228,26 +236,26 @@ ins->proc->resolve_immediate(ins->proc->resolve_data, address, buf, 42); break; case ASM_SP_OTYPE_IMM_ADDRESS: - sprintf(buf, "[ %s", get_sparc_register(op->baser)); + sprintf(buf, "[%s", get_sparc_register(op->baser)); if (op->imm) - sprintf(buf+strlen(buf), " + 0x%x", op->imm); + sprintf(buf + strlen(buf), " + 0x%x", op->imm); - sprintf(buf+strlen(buf), " ]"); + sprintf(buf + strlen(buf), "]"); if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " %%asi"); + sprintf(buf + strlen(buf), " %%asi"); break; case ASM_SP_OTYPE_REG_ADDRESS: if (op->indexr > 0) - sprintf(buf, "[ %s + %s ]", get_sparc_register(op->baser), - get_sparc_register(op->indexr)); - - else - sprintf(buf, "[ %s ]", get_sparc_register(op->baser)); - + sprintf(buf, "[%s + %s]", + get_sparc_register(op->baser), + get_sparc_register(op->indexr)); + else + sprintf(buf, "[%s]", get_sparc_register(op->baser)); + if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " 0x%x", op->address_space); + sprintf(buf + strlen(buf), " 0x%x", op->address_space); break; default: @@ -260,34 +268,43 @@ * * */ -char *asm_sparc_display_instr(asm_instr *instr, int addr) +char *asm_sparc_display_instr(asm_instr *instr, eresi_Addr addr) { - static char buffer[1024]; + static char buffer[1024]; + memset(buffer, 0, 1024); sprintf(buffer, "%s", instr->proc->instr_table[instr->instr]); - - switch (instr->type) { - case ASM_TYPE_CONDBRANCH: - if (instr->annul) - strcat(buffer, ",a"); - if (!instr->prediction) - strcat(buffer, ",pn"); - - default: - if (instr->nb_op > 0) { - strcat(buffer, " "); - - if (instr->nb_op == 3) { - asm_sparc_dump_operand(instr, 3, addr, buffer + strlen(buffer)); - strcat(buffer, ", "); - } - if (instr->nb_op >= 2) { - asm_sparc_dump_operand(instr, 2, addr, buffer + strlen(buffer)); - strcat(buffer, ", "); - } - asm_sparc_dump_operand(instr, 1, addr, buffer + strlen(buffer)); - } - } + + // just debugging to be able to break + if (!strcmp(instr->proc->instr_table[instr->instr], "btog")) + { + *buffer = *buffer; + } + + if ((instr->type & ASM_TYPE_BRANCH) && (instr->type & ASM_TYPE_CONDCONTROL)) + { + if (instr->annul) + strcat(buffer, ",a"); + if (!instr->prediction) + strcat(buffer, ",pn"); + } + + if (instr->nb_op > 0) + { + strcat(buffer, " "); + + if (instr->nb_op == 3) + { + asm_sparc_dump_operand(instr, 3, addr, buffer + strlen(buffer)); + strcat(buffer, ", "); + } + if (instr->nb_op >= 2) + { + asm_sparc_dump_operand(instr, 2, addr, buffer + strlen(buffer)); + strcat(buffer, ", "); + } + asm_sparc_dump_operand(instr, 1, addr, buffer + strlen(buffer)); + } return (buffer); } diff -Nru eresi-0.8a25/libasm/src/arch/sparc/register.c eresi-0.0.20110516/libasm/src/arch/sparc/register.c --- eresi-0.8a25/libasm/src/arch/sparc/register.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/register.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,5 +1,9 @@ /** - * @file register.c +* @file libasm/src/arch/sparc/register.c +** @ingroup sparc +*/ +/** +* @file libasm/src/arch/sparc/register.c * @brief * */ diff -Nru eresi-0.8a25/libasm/src/arch/sparc/sparc_convert.c eresi-0.0.20110516/libasm/src/arch/sparc/sparc_convert.c --- eresi-0.8a25/libasm/src/arch/sparc/sparc_convert.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/sparc_convert.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/sparc_convert.c +** @ingroup sparc +*/ /* ** sparc_convert.c for in /hate/home/hate/code/libasm ** @@ -7,7 +11,7 @@ ** Started on Mon Apr 25 01:01:26 2005 #!HATE#@! ** Last update Tue Jun 14 09:18:36 2005 #!HATE#@! ** -** $Id: sparc_convert.c,v 1.6 2007/06/16 20:24:25 strauss Exp $ +** $Id: sparc_convert.c 1397 2009-09-13 02:19:08Z may $ ** */ diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/sparc/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/sparc/.svn/all-wcprops 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/911/trunk/libasm/src/arch/sparc -END -tables_sparc.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/tables_sparc.c -END -register.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/896/trunk/libasm/src/arch/sparc/register.c -END -output_sparc.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/output_sparc.c -END -sparc_convert.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/sparc_convert.c -END -init_sparc.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/849/trunk/libasm/src/arch/sparc/init_sparc.c -END diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/entries eresi-0.0.20110516/libasm/src/arch/sparc/.svn/entries --- eresi-0.8a25/libasm/src/arch/sparc/.svn/entries 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch/sparc -http://svn.eresi-project.org/svn - - - -2008-03-14T10:03:51.600980Z -911 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -handlers -dir - -tables_sparc.c -file - - - - -2008-04-06T23:16:09.455887Z -7bca9a0eab8cad66123cf8e18d5f0fcc -2008-02-19T17:09:59.893936Z -849 -may - -register.c -file - - - - -2008-04-06T23:16:09.464904Z -716c56bd3848a363c4136792dca2d9ba -2008-03-07T17:49:34.750118Z -896 -thorkill - -operand_handlers -dir - -output_sparc.c -file - - - - -2008-04-06T23:16:09.475894Z -fd12feaaf97811635323159e88066dae -2008-02-19T17:09:59.893936Z -849 -may - -sparc_convert.c -file - - - - -2008-04-06T23:16:09.487902Z -bcfd4e0975e870f65f109f875deb897c -2008-02-19T17:09:59.893936Z -849 -may - -init_sparc.c -file - - - - -2008-04-06T23:16:09.498877Z -96ce50132afa2652b2dd5a85648b601b -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/format eresi-0.0.20110516/libasm/src/arch/sparc/.svn/format --- eresi-0.8a25/libasm/src/arch/sparc/.svn/format 2008-04-06 23:16:04.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/init_sparc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/init_sparc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/init_sparc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/init_sparc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -/* -** -** init_sparc.c in -** -** Author : -** Started : Sun Nov 30 20:13:12 2003 -** Updated : Thu Dec 4 03:01:07 2003 -** -** $Id: init_sparc.c,v 1.10 2007/11/28 00:21:37 strauss Exp $ -** -*/ - -#include -#include - -/** - * Fetching handler of the sparc architecture. - * @param ins - * @param buf - * @param len - * @param proc - */ -int fetch_sparc(asm_instr *ins, u_char *buf, u_int len, asm_processor *proc) -{ - vector_t *vec; - u_int dim[3]; - int (*fetch)(asm_instr *, u_char *, u_int, asm_processor *); - - int converted; - -#if __BYTE_ORDER == __LITTLE_ENDIAN - u_char *ptr; - int i; - ptr = (u_char*) &converted; - - for (i = 0; i < 4; i++) - *(ptr + i) = *(buf + 3 - i); - - #if DEBUG_SPARC - printf("[DIS_SPARC] big endian -> little endian : 0x%08x - ", converted); - - for (i = 31; i >= 0; i--){ - printf("%i", MGETBIT(converted, i)); - if (!(i % 8)) - printf(" "); - } - - puts(""); - #endif -#else - - memcpy(&converted, buf, 4); - -#endif - - ins->proc = proc; - ins->len = 4; - ins->ptr_instr = buf; - ins->nb_op = 0; - ins->type = ASM_TYPE_NONE; - /* Primary (implicit) address space */ - ins->op[0].address_space = 0x80; - ins->op[1].address_space = 0x80; - ins->op[2].address_space = 0x80; - - vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_SPARC); - dim[0] = (converted & 0xC0000000) >> 30; - dim[1] = 0; - dim[2] = 0; - - if (MGETBIT(converted, 31)) { - if (MGETBIT(converted, 30)) { - dim[1] = (converted >> 19) & 0x3f; - dim[2] = 0; - } - else { - dim[1] = (converted >> 19) & 0x3f; - - if (dim[1] == 0x35) /* FPop2 */ - dim[2] = (converted & 0x3E0) >> 5; - else - dim[2] = 0; - } - } - else { - if (MGETBIT(converted, 30)) { - dim[1] = 0; - dim[2] = 0; - } - else { - dim[1] = (converted >> 22) & 0x7; - dim[2] = 0; - } - } - - fetch = aspect_vectors_select(vec, dim); - return (fetch(ins, (u_char*) &converted, len, proc)); - - printf("[DEBUG_SPARC] fetch_sparc:impossible execution path\n"); - return (-1); -} - -/** - * Initialize the sparc processor. - * - */ - -int asm_init_sparc(asm_processor *proc) -{ - struct s_asm_proc_sparc *inter; - - proc->instr_table = sparc_instr_list; - proc->resolve_immediate = asm_resolve_sparc; - proc->resolve_data = 0; - proc->fetch = fetch_sparc; - proc->display_handle = asm_sparc_display_instr; - proc->type = ASM_PROC_SPARC; - - proc->internals = inter = malloc(sizeof (struct s_asm_proc_sparc)); - - inter->bcc_table = sparc_bcc_list; - inter->brcc_table = sparc_brcc_list; - inter->fbcc_table = sparc_fbcc_list; - inter->shift_table = sparc_shift_list; - inter->movcc_table = sparc_movcc_list; - inter->movfcc_table = sparc_movfcc_list; - inter->movr_table = sparc_movr_list; - inter->fpop1_table = sparc_fpop1_list; - inter->fmovcc_table = sparc_fmovcc_list; - inter->fmovfcc_table = sparc_fmovfcc_list; - inter->fmovr_table = sparc_fmovr_list; - inter->fcmp_table = sparc_fcmp_list; - inter->tcc_table = sparc_tcc_list; - inter->op2_table = sparc_op2_table; - inter->op3_table = sparc_op3_table; - - - /** - * XXX: Check this code and update if necessary to follow line developpement. - */ - - asm_arch_register(proc, 0); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/output_sparc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/output_sparc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/output_sparc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/output_sparc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,293 +0,0 @@ -/* -** output_sparc.c for in /hate/home/hate/code/libasm_current -** -** Made by #!HATE#@! -** Login -** -** Started on Fri Jun 10 14:06:47 2005 #!HATE#@! -** Last update Thu Jun 16 05:41:18 2005 #!HATE#@! -** -** $Id: output_sparc.c,v 1.10 2007/10/14 00:01:41 heroine Exp $ -** -*/ - -#include -#include - -void asm_resolve_sparc(void *d, u_int val, char *buf, u_int len) -{ - sprintf(buf, "0x%x", val); -} - -char *get_sparc_register(int reg) -{ - switch(reg) { - case ASM_REG_G0: return "%g0"; - case ASM_REG_G1: return "%g1"; - case ASM_REG_G2: return "%g2"; - case ASM_REG_G3: return "%g3"; - case ASM_REG_G4: return "%g4"; - case ASM_REG_G5: return "%g5"; - case ASM_REG_G6: return "%g6"; - case ASM_REG_G7: return "%g7"; - case ASM_REG_O0: return "%o0"; - case ASM_REG_O1: return "%o1"; - case ASM_REG_O2: return "%o2"; - case ASM_REG_O3: return "%o3"; - case ASM_REG_O4: return "%o4"; - case ASM_REG_O5: return "%o5"; - case ASM_REG_O6: return "%sp"; - case ASM_REG_O7: return "%o7"; - case ASM_REG_L0: return "%l0"; - case ASM_REG_L1: return "%l1"; - case ASM_REG_L2: return "%l2"; - case ASM_REG_L3: return "%l3"; - case ASM_REG_L4: return "%l4"; - case ASM_REG_L5: return "%l5"; - case ASM_REG_L6: return "%l6"; - case ASM_REG_L7: return "%l7"; - case ASM_REG_I0: return "%i0"; - case ASM_REG_I1: return "%i1"; - case ASM_REG_I2: return "%i2"; - case ASM_REG_I3: return "%i3"; - case ASM_REG_I4: return "%i4"; - case ASM_REG_I5: return "%i5"; - case ASM_REG_I6: return "%fp"; - case ASM_REG_I7: return "%i7"; - default: return "bad"; - } -} - -/* Get SPARC state register */ -char *get_sparc_sregister(int reg) -{ - switch(reg) { - case ASM_SREG_Y: return "%y"; - case ASM_SREG_CCR: return "%ccr"; - case ASM_SREG_ASI: return "%asi"; - case ASM_SREG_TICK: return "%tick"; - case ASM_SREG_PC: return "%pc"; - case ASM_SREG_FPRS: return "%fprs"; - default: return "bad"; - } -} - -/* Get SPARC privileged register */ -char *get_sparc_pregister(int reg) -{ - switch(reg) { - case ASM_PREG_TPC: return "%tpc"; - case ASM_PREG_TNPC: return "%tnpc"; - case ASM_PREG_TSTATE: return "%tstate"; - case ASM_PREG_TT: return "%tt"; - case ASM_PREG_TICK: return "%tick"; - case ASM_PREG_TBA: return "%tba"; - case ASM_PREG_PSTATE: return "%pstate"; - case ASM_PREG_TL: return "%tl"; - case ASM_PREG_PIL: return "%pil"; - case ASM_PREG_CWP: return "%cwp"; - case ASM_PREG_CANSAVE: return "%cansave"; - case ASM_PREG_CANRESTORE: return "%canrestore"; - case ASM_PREG_CLEANWIN: return "%cleanwin"; - case ASM_PREG_OTHERWIN: return "%otherwin"; - case ASM_PREG_WSTATE: return "%wstate"; - case ASM_PREG_FQ: return "%fq"; - case ASM_PREG_VER: return "%ver"; - default: return "bad"; - } -} - -/* Get SPARC floating-point register */ -char *get_sparc_fregister(int reg) -{ - switch(reg) { - case ASM_FREG_FSR: return "%fsr"; - case 0: return "%f0"; - case 1: return "%f1"; - case 2: return "%f2"; - case 3: return "%f3"; - case 4: return "%f4"; - case 5: return "%f5"; - case 6: return "%f6"; - case 7: return "%f7"; - case 8: return "%f8"; - case 9: return "%f9"; - case 10: return "%f10"; - case 11: return "%f11"; - case 12: return "%f12"; - case 13: return "%f13"; - case 14: return "%f14"; - case 15: return "%f15"; - case 16: return "%f16"; - case 17: return "%f17"; - case 18: return "%f18"; - case 19: return "%f19"; - case 20: return "%f20"; - case 21: return "%f21"; - case 22: return "%f22"; - case 23: return "%f23"; - case 24: return "%f24"; - case 25: return "%f25"; - case 26: return "%f26"; - case 27: return "%f27"; - case 28: return "%f28"; - case 29: return "%f29"; - case 30: return "%f30"; - case 31: return "%f31"; - case 32: return "%f32"; - case 34: return "%f34"; - case 36: return "%f36"; - case 38: return "%f38"; - case 40: return "%f40"; - case 42: return "%f42"; - case 44: return "%f44"; - case 46: return "%f46"; - case 48: return "%f48"; - case 50: return "%f50"; - case 52: return "%f52"; - case 54: return "%f54"; - case 56: return "%f56"; - case 58: return "%f58"; - case 60: return "%f60"; - case 62: return "%f62"; - default: return "bad"; - } -} - -/* Get SPARC condition code */ -char *get_sparc_cc(int cc) -{ - switch(cc) { - case ASM_SP_FCC0: return "%fcc0"; - case ASM_SP_FCC1: return "%fcc1"; - case ASM_SP_FCC2: return "%fcc2"; - case ASM_SP_FCC3: return "%fcc3"; - case ASM_SP_ICC: return "%icc"; - case ASM_SP_XCC: return "%xcc"; - default: return "bad"; - } -} - -/** - * Dump a sparc operand to a buffer. - * @param ins Pointer to instruction structure. - * @param num Number of the operand to dump - * @param addr Address of the instruction - * @param buf Buffer to store operand ascii representation. - */ - -void asm_sparc_dump_operand(asm_instr *ins, int num, - unsigned int addr, char *buf) -{ - asm_operand *op; - int address; - /** - * - */ - switch(num) { - case 1: op = &ins->op[0]; break; - case 2: op = &ins->op[1]; break; - case 3: op = &ins->op[2]; break; - default: return; - } - - switch(op->content) { - case ASM_SP_OTYPE_REGISTER: - sprintf(buf, "%s", get_sparc_register(op->baser)); - break; - case ASM_SP_OTYPE_SREGISTER: - sprintf(buf, "%s", get_sparc_sregister(op->baser)); - break; - case ASM_SP_OTYPE_PREGISTER: - sprintf(buf, "%s", get_sparc_pregister(op->baser)); - break; - case ASM_SP_OTYPE_FREGISTER: - sprintf(buf, "%s", get_sparc_fregister(op->baser)); - break; - case ASM_SP_OTYPE_CC: - sprintf(buf, "%s", get_sparc_cc(op->baser)); - break; - case ASM_SP_OTYPE_IMMEDIATE: - if (op->imm < 10) - sprintf(buf, "%i", op->imm); - else - sprintf(buf, "0x%x", op->imm); - break; - case ASM_SP_OTYPE_SETHI: - if (op->imm) - sprintf(buf, "%%hi(0x%x)", op->imm << 10); - else - sprintf(buf, "%%hi(%x)", op->imm << 10); - break; - case ASM_SP_OTYPE_DISPLACEMENT: - address = addr + (op->imm << 2); - ins->proc->resolve_immediate(ins->proc->resolve_data, address, buf, 42); - break; - case ASM_SP_OTYPE_DISP30: - address = addr + (op->imm << 2); - ins->proc->resolve_immediate(ins->proc->resolve_data, address, buf, 42); - break; - case ASM_SP_OTYPE_IMM_ADDRESS: - sprintf(buf, "[ %s", get_sparc_register(op->baser)); - if (op->imm) - sprintf(buf+strlen(buf), " + 0x%x", op->imm); - - sprintf(buf+strlen(buf), " ]"); - - if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " %%asi"); - - break; - case ASM_SP_OTYPE_REG_ADDRESS: - if (op->indexr > 0) - sprintf(buf, "[ %s + %s ]", get_sparc_register(op->baser), - get_sparc_register(op->indexr)); - - else - sprintf(buf, "[ %s ]", get_sparc_register(op->baser)); - - if (op->address_space != ASM_SP_ASI_P) - sprintf(buf+strlen(buf), " 0x%x", op->address_space); - break; - - default: - sprintf(buf, "err"); - } -} - -/** - * Return a pointer to a static buffer containing - * - * - */ -char *asm_sparc_display_instr(asm_instr *instr, int addr) -{ - static char buffer[1024]; - memset(buffer, 0, 1024); - sprintf(buffer, "%s", instr->proc->instr_table[instr->instr]); - - switch (instr->type) { - case ASM_TYPE_CONDBRANCH: - if (instr->annul) - strcat(buffer, ",a"); - if (!instr->prediction) - strcat(buffer, ",pn"); - - default: - if (instr->nb_op > 0) { - strcat(buffer, " "); - - if (instr->nb_op == 3) { - asm_sparc_dump_operand(instr, 3, addr, buffer + strlen(buffer)); - strcat(buffer, ", "); - } - if (instr->nb_op >= 2) { - asm_sparc_dump_operand(instr, 2, addr, buffer + strlen(buffer)); - strcat(buffer, ", "); - } - asm_sparc_dump_operand(instr, 1, addr, buffer + strlen(buffer)); - } - } - - return (buffer); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/register.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/register.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/register.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,269 +0,0 @@ -/** - * @file register.c - * @brief - * - */ - -#include -#include - -int asm_register_sparc_instructions(); -int asm_register_sparc_operands(); - -/** - * Initialize sparc vector. - * @return Always 1. - */ -int asm_register_sparc() -{ - u_int *dims; - char **dimstr; - int to_ret; - - dims = malloc(3 * sizeof (u_int)); - if (!dims) - { - to_ret = 0; - goto out; - } - dimstr = malloc(3 * sizeof (char *)); - if (!dimstr) - { - to_ret = 0; - goto out; - } - - dims[0] = 4; - dims[1] = 64; - dims[2] = 32; - - dimstr[0] = "OPCODES"; - dimstr[1] = "SECONDARY OPCODES"; /* Should be 0 when unused */ - dimstr[2] = "FPOP2 OPCODE (OPF_LOW)"; /* Should be 0 when unused */ - - aspect_register_vector(LIBASM_VECTOR_OPCODE_SPARC, asm_fetch_default, - dims, dimstr, 3, ASPECT_TYPE_CADDR); - - /* Initializing SPARC operand handler vector */ - dims = malloc(1 * sizeof (u_int)); - - if (!dims) - { - to_ret = 0; - goto out; - } - dimstr = malloc(1 * sizeof (char *)); - if (!dimstr) - { - to_ret = 0; - goto out; - } - - dims[0] = ASM_SP_OTYPE_NUM; - - dimstr[0] = "OPERAND"; - - aspect_register_vector(LIBASM_VECTOR_OPERAND_SPARC, asm_operand_fetch_default, - dims, dimstr, 1, ASPECT_TYPE_CADDR); - - asm_register_sparc_instructions(); - asm_register_sparc_operands(); - - out: - return (1); -} - -/** - * @brief Create the instruction vector - * @param opcode First opcode - * @param opcode2 Second opcode - * @param fpop - * @param fcn Default handler of the instruction vector. - * @return - */ -int asm_register_sparc_opcode(int opcode, int opcode2, int fpop, - unsigned long fcn) -{ - vector_t *vec; - u_int dim[3]; - - LIBASM_PROFILE_FIN(); - vec = aspect_vector_get(LIBASM_VECTOR_OPCODE_SPARC); - dim[0] = opcode; - dim[1] = opcode2; - dim[2] = fpop; - - aspect_vectors_insert(vec, dim, fcn); - LIBASM_PROFILE_FOUT(1); -} - -/** - * @brief Register each instruction handler for the sparc architecture. - * @return 1 on success, or -1 on error - */ - -int asm_register_sparc_instructions() -{ - asm_register_sparc_opcode( 0x02, 0x00, 0x00, (unsigned long) asm_sparc_add); - asm_register_sparc_opcode( 0x02, 0x08, 0x00, (unsigned long) asm_sparc_addc); - asm_register_sparc_opcode( 0x02, 0x10, 0x00, (unsigned long) asm_sparc_addcc); - asm_register_sparc_opcode( 0x02, 0x18, 0x00, (unsigned long) asm_sparc_addccc); - asm_register_sparc_opcode( 0x02, 0x01, 0x00, (unsigned long) asm_sparc_and); - asm_register_sparc_opcode( 0x02, 0x11, 0x00, (unsigned long) asm_sparc_andcc); - asm_register_sparc_opcode( 0x02, 0x05, 0x00, (unsigned long) asm_sparc_andn); - asm_register_sparc_opcode( 0x02, 0x15, 0x00, (unsigned long) asm_sparc_andncc); - asm_register_sparc_opcode( 0x00, 0x02, 0x00, (unsigned long) asm_sparc_bicc); - asm_register_sparc_opcode( 0x00, 0x01, 0x00, (unsigned long) asm_sparc_bpcc); - asm_register_sparc_opcode( 0x00, 0x03, 0x00, (unsigned long) asm_sparc_bpr); - asm_register_sparc_opcode( 0x01, 0x00, 0x00, (unsigned long) asm_sparc_call); - asm_register_sparc_opcode( 0x03, 0x3c, 0x00, (unsigned long) asm_sparc_casa); - asm_register_sparc_opcode( 0x03, 0x3e, 0x00, (unsigned long) asm_sparc_casxa); - asm_register_sparc_opcode( 0x02, 0x3e, 0x00, (unsigned long) asm_sparc_done); - asm_register_sparc_opcode( 0x00, 0x06, 0x00, (unsigned long) asm_sparc_fbfcc); - asm_register_sparc_opcode( 0x00, 0x05, 0x00, (unsigned long) asm_sparc_fbpfcc); - asm_register_sparc_opcode( 0x02, 0x35, 0x12, (unsigned long) asm_sparc_fcmpd); - asm_register_sparc_opcode( 0x02, 0x35, 0x16, (unsigned long) asm_sparc_fcmped); - asm_register_sparc_opcode( 0x02, 0x35, 0x17, (unsigned long) asm_sparc_fcmpeq); - asm_register_sparc_opcode( 0x02, 0x35, 0x15, (unsigned long) asm_sparc_fcmpes); - asm_register_sparc_opcode( 0x02, 0x35, 0x13, (unsigned long) asm_sparc_fcmpq); - asm_register_sparc_opcode( 0x02, 0x35, 0x11, (unsigned long) asm_sparc_fcmps); - asm_register_sparc_opcode( 0x02, 0x3b, 0x00, (unsigned long) asm_sparc_flush); - asm_register_sparc_opcode( 0x02, 0x2b, 0x00, (unsigned long) asm_sparc_flushw); - asm_register_sparc_opcode( 0x02, 0x35, 0x02, (unsigned long) asm_sparc_fmovdcc); - asm_register_sparc_opcode( 0x02, 0x35, 0x06, (unsigned long) asm_sparc_fmovdr); - asm_register_sparc_opcode( 0x02, 0x35, 0x03, (unsigned long) asm_sparc_fmovqcc); - asm_register_sparc_opcode( 0x02, 0x35, 0x07, (unsigned long) asm_sparc_fmovqr); - asm_register_sparc_opcode( 0x02, 0x35, 0x01, (unsigned long) asm_sparc_fmovscc); - asm_register_sparc_opcode( 0x02, 0x35, 0x05, (unsigned long) asm_sparc_fmovsr); - asm_register_sparc_opcode( 0x02, 0x34, 0x00, (unsigned long) asm_sparc_fpop1); - asm_register_sparc_opcode( 0x00, 0x00, 0x00, (unsigned long) asm_sparc_illtrap); - asm_register_sparc_opcode( 0x02, 0x36, 0x00, (unsigned long) asm_sparc_impdep1); - asm_register_sparc_opcode( 0x02, 0x37, 0x00, (unsigned long) asm_sparc_impdep2); - asm_register_sparc_opcode( 0x02, 0x38, 0x00, (unsigned long) asm_sparc_jmpl); - asm_register_sparc_opcode( 0x03, 0x03, 0x00, (unsigned long) asm_sparc_ldd); - asm_register_sparc_opcode( 0x03, 0x13, 0x00, (unsigned long) asm_sparc_ldda); - asm_register_sparc_opcode( 0x03, 0x23, 0x00, (unsigned long) asm_sparc_lddf); - asm_register_sparc_opcode( 0x03, 0x33, 0x00, (unsigned long) asm_sparc_lddfa); - asm_register_sparc_opcode( 0x03, 0x20, 0x00, (unsigned long) asm_sparc_ldf); - asm_register_sparc_opcode( 0x03, 0x30, 0x00, (unsigned long) asm_sparc_ldfa); - asm_register_sparc_opcode( 0x03, 0x21, 0x00, (unsigned long) asm_sparc_ldfsr); - asm_register_sparc_opcode( 0x03, 0x22, 0x00, (unsigned long) asm_sparc_ldqf); - asm_register_sparc_opcode( 0x03, 0x32, 0x00, (unsigned long) asm_sparc_ldqfa); - asm_register_sparc_opcode( 0x03, 0x09, 0x00, (unsigned long) asm_sparc_ldsb); - asm_register_sparc_opcode( 0x03, 0x19, 0x00, (unsigned long) asm_sparc_ldsba); - asm_register_sparc_opcode( 0x03, 0x0a, 0x00, (unsigned long) asm_sparc_ldsh); - asm_register_sparc_opcode( 0x03, 0x1a, 0x00, (unsigned long) asm_sparc_ldsha); - asm_register_sparc_opcode( 0x03, 0x0d, 0x00, (unsigned long) asm_sparc_ldstub); - asm_register_sparc_opcode( 0x03, 0x1d, 0x00, (unsigned long) asm_sparc_ldstuba); - asm_register_sparc_opcode( 0x03, 0x08, 0x00, (unsigned long) asm_sparc_ldsw); - asm_register_sparc_opcode( 0x03, 0x18, 0x00, (unsigned long) asm_sparc_ldswa); - asm_register_sparc_opcode( 0x03, 0x01, 0x00, (unsigned long) asm_sparc_ldub); - asm_register_sparc_opcode( 0x03, 0x11, 0x00, (unsigned long) asm_sparc_lduba); - asm_register_sparc_opcode( 0x03, 0x02, 0x00, (unsigned long) asm_sparc_lduh); - asm_register_sparc_opcode( 0x03, 0x12, 0x00, (unsigned long) asm_sparc_lduha); - asm_register_sparc_opcode( 0x03, 0x00, 0x00, (unsigned long) asm_sparc_lduw); - asm_register_sparc_opcode( 0x03, 0x10, 0x00, (unsigned long) asm_sparc_lduwa); - asm_register_sparc_opcode( 0x03, 0x0b, 0x00, (unsigned long) asm_sparc_ldx); - asm_register_sparc_opcode( 0x03, 0x1b, 0x00, (unsigned long) asm_sparc_ldxa); - asm_register_sparc_opcode( 0x02, 0x2c, 0x00, (unsigned long) asm_sparc_movcc); - asm_register_sparc_opcode( 0x02, 0x2f, 0x00, (unsigned long) asm_sparc_movr); - asm_register_sparc_opcode( 0x02, 0x24, 0x00, (unsigned long) asm_sparc_mulscc); - asm_register_sparc_opcode( 0x02, 0x09, 0x00, (unsigned long) asm_sparc_mulx); - asm_register_sparc_opcode( 0x02, 0x02, 0x00, (unsigned long) asm_sparc_or); - asm_register_sparc_opcode( 0x02, 0x12, 0x00, (unsigned long) asm_sparc_orcc); - asm_register_sparc_opcode( 0x02, 0x06, 0x00, (unsigned long) asm_sparc_orn); - asm_register_sparc_opcode( 0x02, 0x16, 0x00, (unsigned long) asm_sparc_orncc); - asm_register_sparc_opcode( 0x02, 0x2e, 0x00, (unsigned long) asm_sparc_popc); - asm_register_sparc_opcode( 0x03, 0x2d, 0x00, (unsigned long) asm_sparc_prefetch); - asm_register_sparc_opcode( 0x03, 0x3d, 0x00, (unsigned long) asm_sparc_prefetcha); - asm_register_sparc_opcode( 0x02, 0x28, 0x00, (unsigned long) asm_sparc_rd); - asm_register_sparc_opcode( 0x02, 0x2a, 0x00, (unsigned long) asm_sparc_rdpr); - asm_register_sparc_opcode( 0x02, 0x3d, 0x00, (unsigned long) asm_sparc_restore); - asm_register_sparc_opcode( 0x02, 0x39, 0x00, (unsigned long) asm_sparc_return); - asm_register_sparc_opcode( 0x02, 0x3c, 0x00, (unsigned long) asm_sparc_save); - asm_register_sparc_opcode( 0x02, 0x31, 0x00, (unsigned long) asm_sparc_saved); - asm_register_sparc_opcode( 0x02, 0x0f, 0x00, (unsigned long) asm_sparc_sdiv); - asm_register_sparc_opcode( 0x02, 0x1f, 0x00, (unsigned long) asm_sparc_sdivcc); - asm_register_sparc_opcode( 0x02, 0x2d, 0x00, (unsigned long) asm_sparc_sdivx); - asm_register_sparc_opcode( 0x00, 0x04, 0x00, (unsigned long) asm_sparc_sethi); - asm_register_sparc_opcode( 0x02, 0x25, 0x00, (unsigned long) asm_sparc_sll); - asm_register_sparc_opcode( 0x02, 0x0b, 0x00, (unsigned long) asm_sparc_smul); - asm_register_sparc_opcode( 0x02, 0x1b, 0x00, (unsigned long) asm_sparc_smulcc); - asm_register_sparc_opcode( 0x02, 0x27, 0x00, (unsigned long) asm_sparc_sra); - asm_register_sparc_opcode( 0x02, 0x26, 0x00, (unsigned long) asm_sparc_srl); - asm_register_sparc_opcode( 0x03, 0x05, 0x00, (unsigned long) asm_sparc_stb); - asm_register_sparc_opcode( 0x03, 0x15, 0x00, (unsigned long) asm_sparc_stba); - asm_register_sparc_opcode( 0x03, 0x07, 0x00, (unsigned long) asm_sparc_std); - asm_register_sparc_opcode( 0x03, 0x17, 0x00, (unsigned long) asm_sparc_stda); - asm_register_sparc_opcode( 0x03, 0x27, 0x00, (unsigned long) asm_sparc_stdf); - asm_register_sparc_opcode( 0x03, 0x37, 0x00, (unsigned long) asm_sparc_stdfa); - asm_register_sparc_opcode( 0x03, 0x24, 0x00, (unsigned long) asm_sparc_stf); - asm_register_sparc_opcode( 0x03, 0x34, 0x00, (unsigned long) asm_sparc_stfa); - asm_register_sparc_opcode( 0x03, 0x25, 0x00, (unsigned long) asm_sparc_stfsr); - asm_register_sparc_opcode( 0x03, 0x06, 0x00, (unsigned long) asm_sparc_sth); - asm_register_sparc_opcode( 0x03, 0x16, 0x00, (unsigned long) asm_sparc_stha); - asm_register_sparc_opcode( 0x03, 0x26, 0x00, (unsigned long) asm_sparc_stqf); - asm_register_sparc_opcode( 0x03, 0x36, 0x00, (unsigned long) asm_sparc_stqfa); - asm_register_sparc_opcode( 0x03, 0x04, 0x00, (unsigned long) asm_sparc_stw); - asm_register_sparc_opcode( 0x03, 0x14, 0x00, (unsigned long) asm_sparc_stwa); - asm_register_sparc_opcode( 0x03, 0x0e, 0x00, (unsigned long) asm_sparc_stx); - asm_register_sparc_opcode( 0x03, 0x1e, 0x00, (unsigned long) asm_sparc_stxa); - asm_register_sparc_opcode( 0x02, 0x04, 0x00, (unsigned long) asm_sparc_sub); - asm_register_sparc_opcode( 0x02, 0x0c, 0x00, (unsigned long) asm_sparc_subc); - asm_register_sparc_opcode( 0x02, 0x14, 0x00, (unsigned long) asm_sparc_subcc); - asm_register_sparc_opcode( 0x02, 0x1c, 0x00, (unsigned long) asm_sparc_subccc); - asm_register_sparc_opcode( 0x03, 0x0f, 0x00, (unsigned long) asm_sparc_swap); - asm_register_sparc_opcode( 0x03, 0x1f, 0x00, (unsigned long) asm_sparc_swapa); - asm_register_sparc_opcode( 0x02, 0x20, 0x00, (unsigned long) asm_sparc_taddcc); - asm_register_sparc_opcode( 0x02, 0x22, 0x00, (unsigned long) asm_sparc_taddcctv); - asm_register_sparc_opcode( 0x02, 0x3a, 0x00, (unsigned long) asm_sparc_tcc); - asm_register_sparc_opcode( 0x02, 0x21, 0x00, (unsigned long) asm_sparc_tsubcc); - asm_register_sparc_opcode( 0x02, 0x23, 0x00, (unsigned long) asm_sparc_tsubcctv); - asm_register_sparc_opcode( 0x02, 0x0e, 0x00, (unsigned long) asm_sparc_udiv); - asm_register_sparc_opcode( 0x02, 0x1e, 0x00, (unsigned long) asm_sparc_udivcc); - asm_register_sparc_opcode( 0x02, 0x0d, 0x00, (unsigned long) asm_sparc_udivx); - asm_register_sparc_opcode( 0x02, 0x0a, 0x00, (unsigned long) asm_sparc_umul); - asm_register_sparc_opcode( 0x02, 0x1a, 0x00, (unsigned long) asm_sparc_umulcc); - asm_register_sparc_opcode( 0x02, 0x30, 0x00, (unsigned long) asm_sparc_wr); - asm_register_sparc_opcode( 0x02, 0x32, 0x00, (unsigned long) asm_sparc_wrpr); - asm_register_sparc_opcode( 0x02, 0x07, 0x00, (unsigned long) asm_sparc_xnor); - asm_register_sparc_opcode( 0x02, 0x17, 0x00, (unsigned long) asm_sparc_xnorcc); - asm_register_sparc_opcode( 0x02, 0x03, 0x00, (unsigned long) asm_sparc_xor); - asm_register_sparc_opcode( 0x02, 0x13, 0x00, (unsigned long) asm_sparc_xorcc); - return (1); -} - -/** - * Register an handler for a sparc operand content. - * @param operand_type Content of the operand to register - * @param fcn Function pointer. - * @return 1 on success, 0 on error. - */ - -int asm_register_sparc_operand(int operand_type, unsigned long fcn) -{ - LIBASM_PROFILE_FIN(); - asm_register_operand(LIBASM_VECTOR_OPERAND_SPARC, operand_type, fcn); - LIBASM_PROFILE_FOUT(1); -} - -/** - * Register operands. - * - */ - -int asm_register_sparc_operands() -{ - asm_register_sparc_operand(ASM_SP_OTYPE_REGISTER, (unsigned long) asm_sparc_op_fetch_register); - asm_register_sparc_operand(ASM_SP_OTYPE_IMMEDIATE, (unsigned long) asm_sparc_op_fetch_immediate); - asm_register_sparc_operand(ASM_SP_OTYPE_DISPLACEMENT, (unsigned long) asm_sparc_op_fetch_displacement); - asm_register_sparc_operand(ASM_SP_OTYPE_DISP30, (unsigned long) asm_sparc_op_fetch_disp30); - asm_register_sparc_operand(ASM_SP_OTYPE_SETHI, (unsigned long) asm_sparc_op_fetch_sethi); - asm_register_sparc_operand(ASM_SP_OTYPE_FREGISTER, (unsigned long) asm_sparc_op_fetch_fregister); - asm_register_sparc_operand(ASM_SP_OTYPE_SREGISTER, (unsigned long) asm_sparc_op_fetch_sregister); - asm_register_sparc_operand(ASM_SP_OTYPE_PREGISTER, (unsigned long) asm_sparc_op_fetch_pregister); - asm_register_sparc_operand(ASM_SP_OTYPE_CC, (unsigned long) asm_sparc_op_fetch_cc); - asm_register_sparc_operand(ASM_SP_OTYPE_IMM_ADDRESS, (unsigned long) asm_sparc_op_fetch_imm_address); - asm_register_sparc_operand(ASM_SP_OTYPE_REG_ADDRESS, (unsigned long) asm_sparc_op_fetch_reg_address); - return (1); -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/sparc_convert.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/sparc_convert.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/sparc_convert.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/sparc_convert.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -/* -** sparc_convert.c for in /hate/home/hate/code/libasm -** -** Made by #!HATE#@! -** Login -** -** Started on Mon Apr 25 01:01:26 2005 #!HATE#@! -** Last update Tue Jun 14 09:18:36 2005 #!HATE#@! -** -** $Id: sparc_convert.c,v 1.6 2007/06/16 20:24:25 strauss Exp $ -** -*/ - -/* - * Note: during the development on this code, I got kinda - * confused about the efficiency of this endian-specific-code - * approach. I'm not sure if this is doing what it's supposed - * to, but I'm too stupid to draw a conclusion. So, please, - * someone take a look at the code, fix whatever needs to - * be fixed and remove this note. kthx. - * - * Strauss - */ - -#include - -void sparc_convert_pbranch(struct s_decode_pbranch *opcode, u_char *buf) -{ - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->a = (converted >> 29) & 0x1; - opcode->cond = (converted >> 25) & 0xf; - opcode->op2 = (converted >> 22) & 0x7; - opcode->cc1 = (converted >> 21) & 0x1; - opcode->cc0 = (converted >> 20) & 0x1; - opcode->p = (converted >> 19) & 0x1; - opcode->immediate = converted & 0x7FFFF; - #else - memcpy(opcode, buf, 4); - #endif - - opcode->cc = (opcode->cc1 << 1) | opcode->cc0; - - if (opcode->immediate & 0x40000) - opcode->imm = opcode->immediate | 0xFFFC0000; - else - opcode->imm = opcode->immediate; -} - -void sparc_convert_rbranch(struct s_decode_rbranch *opcode, u_char *buf) -{ - int d16; - - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->a = (converted >> 29) & 0x1; - opcode->zero = (converted >> 28) & 0x1; - opcode->rcond = (converted >> 25) & 0x7; - opcode->op2 = (converted >> 22) & 0x7; - opcode->d16hi = (converted >> 20) & 0x3; - opcode->p = (converted >> 19) & 0x1; - opcode->rs1 = (converted >> 14) & 0x1f; - opcode->d16lo = converted & 0x3FFF; - #else - memcpy(opcode, buf, 4); - #endif - - d16 = (opcode->d16hi << 14) | (opcode->d16lo); - if (d16 & 0x8000) - opcode->d16 = d16 | 0xFFFF0000; - else - opcode->d16 = d16; -} - -void sparc_convert_branch(struct s_decode_branch *opcode, u_char *buf) -{ - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->a = (converted >> 29) & 0x1; - opcode->cond = (converted >> 25) & 0xf; - opcode->op2 = (converted >> 22) & 0x7; - opcode->immediate = converted & 0x3FFFFF; - #else - memcpy(opcode, buf, 4); - #endif - - opcode->rd = (opcode->a << 4) | opcode->cond; - - if (opcode->immediate & 0x200000) - opcode->imm = opcode->immediate | 0xFFE00000; - else - opcode->imm = opcode->immediate; -} - -void sparc_convert_call(struct s_decode_call *opcode, u_char *buf) -{ - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->disp30 = (converted & 0x3FFFFFFF); - #else - memcpy(opcode, buf, 4); - #endif - - if (opcode->disp30 & 0x20000000) - opcode->displacement = opcode->disp30 | 0xC0000000; - else - opcode->displacement = opcode->disp30; -} - -void sparc_convert_format3(struct s_decode_format3 *opcode, u_char *buf) -{ - int shcnt, immediate10; - int immediate; - - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->rd = (converted >> 25) & 0x1f; - opcode->op3 = (converted >> 19) & 0x3f; - opcode->rs1 = (converted >> 14) & 0x1f; - opcode->i = (converted >> 13) & 0x1; - opcode->none = (converted >> 5) & 0xff; - opcode->rs2 = converted & 0x1f; - #else - memcpy(opcode, buf, 4); - #endif - - /* The following code sets the immediate and the shcnt values - * (abstracting whether the shcnt value is for 32 or 64 bits) - */ - immediate = (opcode->none << 5) | (opcode->rs2); - - if (immediate & 0x1000) - opcode->imm = 0xFFFFF000 | immediate; - else - opcode->imm = immediate; - - immediate10 = immediate & 0x3ff; - if (immediate10 & 0x200) - opcode->imm10 = 0xFFFFFC00 | immediate10; - else - opcode->imm10 = immediate10; - - shcnt = immediate & 0x3f; - /* (immediate & 0x1fff == the 'x' bit */ - if ((immediate & 0x1fff) == 0) - shcnt &= 0x1f; - - opcode->shcnt = shcnt; - - opcode->rcond = (opcode->imm & 0x1c00) >> 10; - opcode->opf = (opcode->i << 8) | opcode->none; - opcode->opf_cc = (opcode->opf & 0x1c0) >> 6; - opcode->cc = opcode->rd & 0x3; - opcode->cond = opcode->rs1 & 0xf; -} - -void sparc_convert_format4(struct s_decode_format4 *opcode, u_char *buf) -{ - int immediate; - - #if __BYTE_ORDER == __LITTLE_ENDIAN - int converted; - - memcpy(&converted, buf, 4); - opcode->op = (converted >> 30) & 0x3; - opcode->rd = (converted >> 25) & 0x1f; - opcode->op3 = (converted >> 19) & 0x3f; - opcode->rs1 = (converted >> 14) & 0x1f; - opcode->i = (converted >> 13) & 0x1; - opcode->cc1 = (converted >> 12) & 0x1; - opcode->cc0 = (converted >>11) & 0x1; - opcode->none = (converted >> 5) & 0x3f; - opcode->rs2 = converted & 0x1f; - #else - memcpy(opcode, buf, 4); - #endif - - opcode->cond = opcode->rs1 & 0xf; - opcode->cc2 = opcode->rs1 & 0x10; - opcode->cc = (opcode->cc2 << 2) | (opcode->cc1 << 1) | opcode->cc0; - - opcode->sw_trap = ((opcode->none & 0x3) << 5) | opcode->rs2; - - immediate = (opcode->none << 5) | (opcode->rs2); - - if (immediate & 0x400) - opcode->imm = 0xFFFFF800 | immediate; - else - opcode->imm = immediate; -} diff -Nru eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/tables_sparc.c.svn-base eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/tables_sparc.c.svn-base --- eresi-0.8a25/libasm/src/arch/sparc/.svn/text-base/tables_sparc.c.svn-base 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/.svn/text-base/tables_sparc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1072 +0,0 @@ -/* -** tables_sparc.c for in /hate/home/hate/code/libasm_current -** -** Made by #!HATE#@! -** Login -** -** Started on Tue Jun 14 05:23:16 2005 #!HATE#@! -** Last update Thu Jun 16 05:39:25 2005 #!HATE#@! -** -** $Id: tables_sparc.c,v 1.5 2007/03/07 16:45:34 thor Exp $ -** -*/ - -#include - -int sparc_op2_table[64] = { - ASM_SP_ADD, - ASM_SP_AND, - ASM_SP_OR, - ASM_SP_XOR, - ASM_SP_SUB, - ASM_SP_ANDN, - ASM_SP_ORN, - ASM_SP_XNOR, - - ASM_SP_ADDC, - ASM_SP_MULX, - ASM_SP_UMUL, - ASM_SP_SMUL, - ASM_SP_SUBC, - ASM_SP_UDIVX, - ASM_SP_UDIV, - ASM_SP_SDIV, - - ASM_SP_ADDCC, - ASM_SP_ANDCC, - ASM_SP_ORCC, - ASM_SP_XORCC, - ASM_SP_SUBCC, - ASM_SP_ANDNCC, - ASM_SP_ORNCC, - ASM_SP_XNORCC, - - ASM_SP_ADDCCC, - ASM_SP_, - ASM_SP_UMULCC, - ASM_SP_SMULCC, - ASM_SP_SUBCCC, - ASM_SP_, - ASM_SP_UDIVCC, - ASM_SP_SDIVCC, - - - ASM_SP_TADDCC, - ASM_SP_TSUBCC, - ASM_SP_TADDCCTV, - ASM_SP_TSUBCCTV, - ASM_SP_MULSCC, - ASM_SP_SLL, /* SLL, SLLX */ - ASM_SP_SRL, /* SRL, SRLX */ - ASM_SP_SRA, /* SRA, SRAX */ - - ASM_SP_RD, /* RD*(-PR), MEMBAR, STBAR */ - ASM_SP_, - ASM_SP_RDPR, - ASM_SP_FLUSHW, - ASM_SP_MOVA, /* MOVcc */ - ASM_SP_SDIVX, - ASM_SP_POPC, - ASM_SP_MOVRZ, /* MOVr */ - - ASM_SP_WR, /* WR*(-PR), SIR */ - ASM_SP_SAVED, /* SAVED, RESTORED */ - ASM_SP_WRPR, - ASM_SP_, - ASM_SP_FMOVS, /* FPop1 */ - ASM_SP_FMOVS, /* FPop2 */ - ASM_SP_IMPDEP1, - ASM_SP_IMPDEP2, - - ASM_SP_JMPL, - ASM_SP_RETURN, - ASM_SP_TA, - ASM_SP_FLUSH, - ASM_SP_SAVE, - ASM_SP_RESTORE, - ASM_SP_DONE, /* DONE, RETRY */ - ASM_SP_ -}; - -int sparc_op3_table[64] = { - ASM_SP_LDUW, - ASM_SP_LDUB, - ASM_SP_LDUH, - ASM_SP_LDD, - ASM_SP_STW, - ASM_SP_STB, - ASM_SP_STH, - ASM_SP_STD, - - ASM_SP_LDSW, - ASM_SP_LDSB, - ASM_SP_LDSH, - ASM_SP_LDX, - ASM_SP_, - ASM_SP_LDSTUB, - ASM_SP_STX, - ASM_SP_SWAP, - - ASM_SP_LDUWA, - ASM_SP_LDUBA, - ASM_SP_LDUHA, - ASM_SP_LDDA, - ASM_SP_STWA, - ASM_SP_STBA, - ASM_SP_STHA, - ASM_SP_STDA, - - ASM_SP_LDSWA, - ASM_SP_LDSBA, - ASM_SP_LDSHA, - ASM_SP_LDXA, - ASM_SP_, - ASM_SP_LDSTUBA, - ASM_SP_STXA, - ASM_SP_SWAPA, - - - - ASM_SP_LDF, - ASM_SP_LDFSR, /* LDFSR, LDXFSR */ - ASM_SP_LDQF, - ASM_SP_LDDF, - ASM_SP_STF, - ASM_SP_STFSR, /* STFSR, STXFSR */ - ASM_SP_STQF, - ASM_SP_STDF, - - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_PREFETCH, - ASM_SP_, - ASM_SP_, - - ASM_SP_LDFA, - ASM_SP_, - ASM_SP_LDQFA, - ASM_SP_LDDFA, - ASM_SP_STFA, - ASM_SP_, - ASM_SP_, - ASM_SP_, - - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_CASA, - ASM_SP_PREFETCHA, - ASM_SP_CASXA, - ASM_SP_ -}; - -int sparc_bcc_list[16] = { - ASM_SP_BN, - ASM_SP_BE, - ASM_SP_BLE, - ASM_SP_BL, - ASM_SP_BLEU, - ASM_SP_BCS, - ASM_SP_BNEG, - ASM_SP_BVS, - ASM_SP_BA, - ASM_SP_BNE, - ASM_SP_BG, - ASM_SP_BGE, - ASM_SP_BGU, - ASM_SP_BCC, - ASM_SP_BPOS, - ASM_SP_BVC -}; - -int sparc_tcc_list[16] = { - ASM_SP_TN, - ASM_SP_TE, - ASM_SP_TLE, - ASM_SP_TL, - ASM_SP_TLEU, - ASM_SP_TCS, - ASM_SP_TNEG, - ASM_SP_TVS, - ASM_SP_TA, - ASM_SP_TNE, - ASM_SP_TG, - ASM_SP_TGE, - ASM_SP_TGU, - ASM_SP_TCC, - ASM_SP_TPOS, - ASM_SP_TVC -}; - -int sparc_brcc_list[8] = { - ASM_SP_, - ASM_SP_BRZ, - ASM_SP_BRLEZ, - ASM_SP_BRLZ, - ASM_SP_, - ASM_SP_BRNZ, - ASM_SP_BRGZ, - ASM_SP_BRGEZ -}; - -int sparc_fbcc_list[16] = { - ASM_SP_FBN, - ASM_SP_FBNE, - ASM_SP_FBLG, - ASM_SP_FBUL, - ASM_SP_FBL, - ASM_SP_FBUG, - ASM_SP_FBG, - ASM_SP_FBU, - ASM_SP_FBA, - ASM_SP_FBE, - ASM_SP_FBUE, - ASM_SP_FBGE, - ASM_SP_FBUGE, - ASM_SP_FBLE, - ASM_SP_FBULE, - ASM_SP_FBO -}; - -int sparc_shift_list[6] = { - ASM_SP_SLL, - ASM_SP_SLLX, - ASM_SP_SRL, - ASM_SP_SRLX, - ASM_SP_SRA, - ASM_SP_SRAX, -}; - -int sparc_movcc_list[16] = { - ASM_SP_MOVN, - ASM_SP_MOVE, - ASM_SP_MOVLE, - ASM_SP_MOVL, - ASM_SP_MOVLEU, - ASM_SP_MOVCS, - ASM_SP_MOVNEG, - ASM_SP_MOVVS, - ASM_SP_MOVA, - ASM_SP_MOVNE, - ASM_SP_MOVG, - ASM_SP_MOVGE, - ASM_SP_MOVGU, - ASM_SP_MOVCC, - ASM_SP_MOVPOS, - ASM_SP_MOVVC -}; - -int sparc_movfcc_list[16] = { - ASM_SP_MOVN, - ASM_SP_MOVNE, - ASM_SP_MOVLG, - ASM_SP_MOVUL, - ASM_SP_MOVL, - ASM_SP_MOVUG, - ASM_SP_MOVG, - ASM_SP_MOVU, - ASM_SP_MOVA, - ASM_SP_MOVE, - ASM_SP_MOVUE, - ASM_SP_MOVGE, - ASM_SP_MOVUGE, - ASM_SP_MOVLE, - ASM_SP_MOVULE, - ASM_SP_MOVO -}; - -int sparc_movr_list[8] = { - ASM_SP_, - ASM_SP_MOVRZ, - ASM_SP_MOVRLEZ, - ASM_SP_MOVRLZ, - ASM_SP_, - ASM_SP_MOVRNZ, - ASM_SP_MOVRGZ, - ASM_SP_MOVRGEZ -}; - -int sparc_fpop1_list[256] = { - ASM_SP_, /* 0x00 */ - ASM_SP_FMOVS, - ASM_SP_FMOVD, - ASM_SP_FMOVQ, - ASM_SP_, - ASM_SP_FNEGS, - ASM_SP_FNEGD, - ASM_SP_FNEGQ, - ASM_SP_, - ASM_SP_FABSS, - ASM_SP_FABSD, - ASM_SP_FABSQ, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x10 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x20 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_SQRTS, - ASM_SP_SQRTD, - ASM_SP_SQRTQ, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x30 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x40 */ - ASM_SP_FADDS, - ASM_SP_FADDD, - ASM_SP_FADDQ, - ASM_SP_, - ASM_SP_FSUBS, - ASM_SP_FSUBD, - ASM_SP_FSUBQ, - ASM_SP_, - ASM_SP_FMULS, - ASM_SP_FMULD, - ASM_SP_FMULQ, - ASM_SP_, - ASM_SP_FDIVS, - ASM_SP_FDIVD, - ASM_SP_FDIVQ, - ASM_SP_, /* 0x50 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x60 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_FSMULD, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_FDMULQ, - ASM_SP_, - ASM_SP_, /* 0x70 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x80 */ - ASM_SP_FSTOX, - ASM_SP_FDTOX, - ASM_SP_FQTOX, - ASM_SP_FXTOS, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_FXTOD, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_FXTOQ, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0x90 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0xA0 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0xB0 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0xC0 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_FITOS, - ASM_SP_, - ASM_SP_FDTOS, - ASM_SP_FQTOS, - ASM_SP_FITOD, - ASM_SP_FSTOD, - ASM_SP_, - ASM_SP_FQTOD, - ASM_SP_FITOQ, - ASM_SP_FSTOQ, - ASM_SP_FDTOQ, - ASM_SP_, - ASM_SP_, /* 0xD0 */ - ASM_SP_FSTOI, - ASM_SP_FDTOI, - ASM_SP_FQTOI, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0xE0 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, /* 0xF0 */ - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_, - ASM_SP_ -}; - -int sparc_fmovcc_list[48] = { - ASM_SP_FMOVSN, - ASM_SP_FMOVSE, - ASM_SP_FMOVSLE, - ASM_SP_FMOVSL, - ASM_SP_FMOVSLEU, - ASM_SP_FMOVSCS, - ASM_SP_FMOVSNEG, - ASM_SP_FMOVSVS, - ASM_SP_FMOVSA, - ASM_SP_FMOVSNE, - ASM_SP_FMOVSG, - ASM_SP_FMOVSGE, - ASM_SP_FMOVSGU, - ASM_SP_FMOVSCC, - ASM_SP_FMOVSPOS, - ASM_SP_FMOVSVC, - ASM_SP_FMOVDN, - ASM_SP_FMOVDE, - ASM_SP_FMOVDLE, - ASM_SP_FMOVDL, - ASM_SP_FMOVDLEU, - ASM_SP_FMOVDCS, - ASM_SP_FMOVDNEG, - ASM_SP_FMOVDVS, - ASM_SP_FMOVDA, - ASM_SP_FMOVDNE, - ASM_SP_FMOVDG, - ASM_SP_FMOVDGE, - ASM_SP_FMOVDGU, - ASM_SP_FMOVDCC, - ASM_SP_FMOVDPOS, - ASM_SP_FMOVDVC, - ASM_SP_FMOVQN, - ASM_SP_FMOVQE, - ASM_SP_FMOVQLE, - ASM_SP_FMOVQL, - ASM_SP_FMOVQLEU, - ASM_SP_FMOVQCS, - ASM_SP_FMOVQNEG, - ASM_SP_FMOVQVS, - ASM_SP_FMOVQA, - ASM_SP_FMOVQNE, - ASM_SP_FMOVQG, - ASM_SP_FMOVQGE, - ASM_SP_FMOVQGU, - ASM_SP_FMOVQCC, - ASM_SP_FMOVQPOS, - ASM_SP_FMOVQVC -}; - -int sparc_fmovfcc_list[48] = { - ASM_SP_FMOVSN, - ASM_SP_FMOVSNE, - ASM_SP_FMOVSLG, - ASM_SP_FMOVSUL, - ASM_SP_FMOVSL, - ASM_SP_FMOVSUG, - ASM_SP_FMOVSG, - ASM_SP_FMOVSU, - ASM_SP_FMOVSA, - ASM_SP_FMOVSE, - ASM_SP_FMOVSUE, - ASM_SP_FMOVSGE, - ASM_SP_FMOVSUGE, - ASM_SP_FMOVSLE, - ASM_SP_FMOVSULE, - ASM_SP_FMOVSO, - ASM_SP_FMOVDN, - ASM_SP_FMOVDNE, - ASM_SP_FMOVDLG, - ASM_SP_FMOVDUL, - ASM_SP_FMOVDL, - ASM_SP_FMOVDUG, - ASM_SP_FMOVDG, - ASM_SP_FMOVDU, - ASM_SP_FMOVDA, - ASM_SP_FMOVDE, - ASM_SP_FMOVDUE, - ASM_SP_FMOVDGE, - ASM_SP_FMOVDUGE, - ASM_SP_FMOVDLE, - ASM_SP_FMOVDULE, - ASM_SP_FMOVDO, - ASM_SP_FMOVQN, - ASM_SP_FMOVQNE, - ASM_SP_FMOVQLG, - ASM_SP_FMOVQUL, - ASM_SP_FMOVQL, - ASM_SP_FMOVQUG, - ASM_SP_FMOVQG, - ASM_SP_FMOVQU, - ASM_SP_FMOVQA, - ASM_SP_FMOVQE, - ASM_SP_FMOVQUE, - ASM_SP_FMOVQGE, - ASM_SP_FMOVQUGE, - ASM_SP_FMOVQLE, - ASM_SP_FMOVQULE, - ASM_SP_FMOVQO -}; - -int sparc_fmovr_list[24] = { - ASM_SP_, - ASM_SP_FMOVRSZ, - ASM_SP_FMOVRSLEZ, - ASM_SP_FMOVRSLZ, - ASM_SP_, - ASM_SP_FMOVRSNZ, - ASM_SP_FMOVRSGZ, - ASM_SP_FMOVRSGEZ, - ASM_SP_, - ASM_SP_FMOVRDZ, - ASM_SP_FMOVRDLEZ, - ASM_SP_FMOVRDLZ, - ASM_SP_, - ASM_SP_FMOVRDNZ, - ASM_SP_FMOVRDGZ, - ASM_SP_FMOVRDGEZ, - ASM_SP_, - ASM_SP_FMOVRQZ, - ASM_SP_FMOVRQLEZ, - ASM_SP_FMOVRQLZ, - ASM_SP_, - ASM_SP_FMOVRQNZ, - ASM_SP_FMOVRQGZ, - ASM_SP_FMOVRQGEZ -}; - -int sparc_fcmp_list[8] = { - ASM_SP_, - ASM_SP_FCMPS, - ASM_SP_FCMPD, - ASM_SP_FCMPQ, - ASM_SP_, - ASM_SP_FCMPES, - ASM_SP_FCMPED, - ASM_SP_FCMPEQ -}; - -char *sparc_instr_list[ASM_SP_BAD + 1] = { - "(unimpl)", - "add", /* ADD */ - "addcc", /* ADDcc */ - "addc", /* ADDC */ - "addccc", /* ADDCcc */ - "and", /* AND */ - "andcc", /* ANDcc */ - "andn", /* ANDN */ - "andncc", /* ANDNcc */ - "ba", /* BPcc, Bicc */ - "bn", - "bne", - "be", - "bg", - "ble", - "bge", - "bl", - "bgu", - "bleu", - "bcc", - "bcs", - "bpos", - "bneg", - "bvc", - "bvs", - "brz", /* BPr */ - "brlez", - "brlz", - "brnz", - "brgz", - "brgez", - "call", /* CALL */ - "casa", /* CASA */ - "casxa", /* CASXA */ - "done", /* DONE */ - "fabss", /* FABS(s,d,q) */ - "fabsd", - "fabsq", - "fadds", /* FADD(s,d,q) */ - "faddd", - "faddq", - "fba", /* FBfcc, FBPfcc */ - "fbn", - "fbu", - "fbg", - "fbug", - "fbl", - "fbul", - "fblg", - "fbne", - "fbe", - "fbue", - "fbge", - "fbuge", - "fble", - "fbule", - "fbo", - "fcmps", /* FCMP(s,d,q) */ - "fcmpd", - "fcmpq", - "fcmpes", /* FCMPE(s,d,q) */ - "fcmped", - "fcmpeq", - "fdivs", /* FDIV(s,d,q) */ - "fdivd", - "fdivq", - "fdmulq", /* FdMULq */ - "fitos", /* FiTO(s,d,q) */ - "fitod", - "fitoq", - "flush", /* FLUSH */ - "flushw", /* FLUSHW */ - "fmovs", /* FMOV(s,d,q) */ - "fmovd", - "fmovq", - "fmovsa", /* FMOV(s,d,q)cc */ - "fmovsn", - "fmovsne", - "fmovse", - "fmovsg", - "fmovsle", - "fmovsge", - "fmovsl", - "fmovsgu", - "fmovsleu", - "fmovscc", - "fmovscs", - "fmovspos", - "fmovsneg", - "fmovsvc", - "fmovsvs", - "fmovsu", - "fmovsug", - "fmovsul", - "fmovslg", - "fmovsue", - "fmovsuge", - "fmovsule", - "fmovso", - "fmovda", - "fmovdn", - "fmovdne", - "fmovde", - "fmovdg", - "fmovdle", - "fmovdge", - "fmovdl", - "fmovdgu", - "fmovdleu", - "fmovdcc", - "fmovdcs", - "fmovdpos", - "fmovdneg", - "fmovdvc", - "fmovdvs", - "fmovdu", - "fmovdug", - "fmovdul", - "fmovdlg", - "fmovdue", - "fmovduge", - "fmovdule", - "fmovdo", - "fmovqa", - "fmovqn", - "fmovqne", - "fmovqe", - "fmovqg", - "fmovqle", - "fmovqge", - "fmovql", - "fmovqgu", - "fmovqleu", - "fmovqcc", - "fmovqcs", - "fmovqpos", - "fmovqneg", - "fmovqvc", - "fmovqvs", - "fmovqu", - "fmovqug", - "fmovqul", - "fmovqlg", - "fmovque", - "fmovquge", - "fmovqule", - "fmovo", - "fmovrsz", /* FMOV(s,d,q)r */ - "fmovrslez", - "fmovrslz", - "fmovrsnz", - "fmovrsgz", - "fmovrsgez", - "fmovrdz", - "fmovrdlez", - "fmovrdlz", - "fmovrdnz", - "fmovrdgz", - "fmovrdgez", - "fmovrqz", - "fmovrqlez", - "fmovrqlz", - "fmovrqnz", - "fmovrqgz", - "fmovrqgez", - "fmuls", /* FMUL(s,d,q) */ - "fmuld", - "fmulq", - "fnegs", /* FNEG(s,d,q) */ - "fnegd", - "fnegq", - "fsmuld", /* FsMULd */ - "fsqrts", /* FSQRT(s,d,q) */ - "fsqrtd", - "fsqrtq", - "fstoi", /* F(s,d,q)TOi */ - "fdtoi", - "fqtoi", - "fstod", /* F(s,d,q)TO(s,d,q) */ - "fstoq", - "fdtos", - "fdtoq", - "fqtos", - "fqtod", - "fstox", /* F(s,d,q)TOx */ - "fdtox", - "fqtox", - "fsubs", /* FSUB(s,d,q) */ - "fsubd", - "fsubq", - "fxtos", /* FxTO(s,d,q) */ - "fxtod", - "fxtoq", - "illtrap", /* ILLTRAP */ - "impdep1", /* IMPDEP1 and IMPDEP2 are not real names, these are - * implementation-specific instruction. Maybe we should let - * the user specify a name for these instructions? - */ - "impdep2", - "jmpl", /* JMPL, RET, RETL */ - "ldd", /* LDD */ - "ldda", /* LDDA */ - "ldd", /* LDFF */ - "ldda", /* LDDFA */ - "ld", /* LDF */ - "lda", /* LDFA */ - "ld", /* LDFSR */ - "ldq", /* LDQF */ - "ldqa", /* LDQFA */ - "ldsb", /* LDSB */ - "ldsba", /* LDSBA */ - "ldsh", /* LDSH */ - "ldsha", /* LDSHA */ - "ldstub", /* LDSTUB */ - "ldstuba", /* LDSTUBA */ - "ldsw", /* LDSW */ - "ldswa", /* LDSWA */ - "ldub", /* LDUB */ - "lduba", /*LDUBA */ - "lduh", /* LDUH */ - "lduha", /* LDUHA */ - "ld", /* LDUW */ - "lduwa", /* LDUWA */ - "ldx", /* LDX */ - "ldxa", /* LDXA */ - "ldx", /* LDXFSR */ - "membar", /* MEMBAR */ - "mova", /* MOVcc */ - "movn", - "movne", - "move", - "movg", - "movle", - "movge", - "movl", - "movgu", - "movleu", - "movcc", - "movcs", - "movpos", - "movneg", - "movvc", - "movvs", - "movu", - "movug", - "movul", - "movlg", - "movue", - "movuge", - "movule", - "movo", - "movrz", /* MOVr */ - "movrlez", - "movrlz", - "movrnz", - "movrgz", - "movrgez", - "mulscc", /* MULScc */ - "mulx", /* MULX */ - "nop", /* NOP */ - "or", /* OR */ - "orcc", /* ORcc */ - "orn", /* ORC */ - "orncc", /* ORNcc */ - "popc", /* POPC */ - "prefetch", /* PREFETCH */ - "prefetcha", /* PREFETCHA */ - "rd", /* RDASI, RDASR, RDCCR, RDFPRS, RDPC, RDTICK, RDY */ - "rdpr", /* RDPR */ - "restore", /* RESTORE */ - "restored", /* RESTORED */ - "retry", /* RETRY */ - "return", /* RETURN */ - "save", /* SAVE */ - "saved", /* SAVED */ - "sdiv", /* SDIV */ - "sdivcc", /* SDIVcc */ - "sdivx", /* SDIVX */ - "sethi", /* SETHI */ - "sir", /* SIR */ - "sll", /* SLL */ - "sllx", /* SLLX */ - "smul", /* SMUL */ - "smulcc", /* SMULcc */ - "sqrts", /* SQRT(s,d,q) */ - "sqrtd", - "sqrtq", - "sra", /* SRA */ - "srax", /* SRAX */ - "srl", /* SRL */ - "srlx", /* SRLX */ - "stb", /* STB */ - "stba", /* STBA */ - "stbar", /* STBAR */ - "std", /* STD */ - "stda", /* STDA */ - "std", /* STDF */ - "stda", /* STDFA */ - "st", /* STF */ - "sta", /* STFA */ - "st", /* STFSR */ - "sth", /* STH */ - "stha", /* STHA */ - "stq", /* STQF */ - "stqa", /* STQFA */ - "st", /* STW */ - "stwa", /* STWA */ - "stx", /* STX */ - "stxa", /* STXA */ - "stx", /* STXFSR */ - "sub", /* SUB */ - "subcc", /* SUBcc */ - "subc", /* SUBC */ - "subccc", /* SUBCcc */ - "swap", /* SWAP */ - "swapa", /* SWAPA */ - "taddcc", /* TADDcc */ - "taddcctv", /* TADDccTV */ - "ta", /* Tcc */ - "tn", - "tne", - "te", - "tg", - "tle", - "tge", - "tl", - "tgu", - "tleu", - "tcc", - "tcs", - "tpos", - "tneg", - "tvc", - "tvs", - "tsubcc", /* TSUBcc */ - "tsubcctv", /* TSUBccTV */ - "udiv", /* UDIV */ - "udivcc", /* UDIVcc */ - "udivx", /* UDIVX */ - "umul", /* UMUL */ - "umulcc", /* UMULcc */ - "wr", /* WRASI, WRASR, WRCCR, WRFPRS, WRY */ - "wrpr", /* WRPR */ - "xnor", /* XNOR */ - "xnorcc", /* XNORcc */ - "xor", /* XOR */ - "xorcc", /* XORcc */ - "cmp", /* Synthetics */ - "jmp", - "iprefetch", - "tst", - "ret", - "retl", - "setuw", - "set", - "setsw", - "setx", - "signx", - "not", - "neg", - "cas", - "casl", - "casx", - "casxl", - "inc", - "inccc", - "dec", - "deccc", - "btst", - "bset", - "bclr", - "btog", - "clr", - "clrb", - "clrh", - "clrx", - "clruw", - "mov", - "(bad)" -}; diff -Nru eresi-0.8a25/libasm/src/arch/sparc/tables_sparc.c eresi-0.0.20110516/libasm/src/arch/sparc/tables_sparc.c --- eresi-0.8a25/libasm/src/arch/sparc/tables_sparc.c 2008-04-06 23:16:09.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/sparc/tables_sparc.c 2011-05-16 11:34:33.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libasm/src/arch/sparc/tables_sparc.c +** @ingroup sparc +*/ /* ** tables_sparc.c for in /hate/home/hate/code/libasm_current ** @@ -7,7 +11,7 @@ ** Started on Tue Jun 14 05:23:16 2005 #!HATE#@! ** Last update Thu Jun 16 05:39:25 2005 #!HATE#@! ** -** $Id: tables_sparc.c,v 1.5 2007/03/07 16:45:34 thor Exp $ +** $Id: tables_sparc.c 1439 2010-12-13 10:27:16Z may $ ** */ @@ -1054,14 +1058,14 @@ "casl", "casx", "casxl", - "inc", - "inccc", - "dec", - "deccc", + "inc", // inc is a add + "inccc", //inccc = addcc + "dec", // dec is a sub + "deccc", // deccc is a subcc "btst", "bset", "bclr", - "btog", + "btog", // btog is a xor "clr", "clrb", "clrh", diff -Nru eresi-0.8a25/libasm/src/arch/.svn/all-wcprops eresi-0.0.20110516/libasm/src/arch/.svn/all-wcprops --- eresi-0.8a25/libasm/src/arch/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/942/trunk/libasm/src/arch -END diff -Nru eresi-0.8a25/libasm/src/arch/.svn/entries eresi-0.0.20110516/libasm/src/arch/.svn/entries --- eresi-0.8a25/libasm/src/arch/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src/arch -http://svn.eresi-project.org/svn - - - -2008-03-27T11:27:27.668410Z -942 -pi3 - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -mips -dir - -sparc -dir - -ia32 -dir - diff -Nru eresi-0.8a25/libasm/src/arch/.svn/format eresi-0.0.20110516/libasm/src/arch/.svn/format --- eresi-0.8a25/libasm/src/arch/.svn/format 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/arch/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/build.c eresi-0.0.20110516/libasm/src/build.c --- eresi-0.8a25/libasm/src/build.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/build.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,8 +1,8 @@ /** - * @file build.c - * @ingroup libasm_engine +* @file libasm/src/build.c + * @ingroup libasm * @brief Contains latest build date. - * $Id: build.c,v 1.3 2008/01/01 14:55:00 heroine Exp $ + * $Id: build.c 1397 2009-09-13 02:19:08Z may $ */ /** diff -Nru eresi-0.8a25/libasm/src/error.c eresi-0.0.20110516/libasm/src/error.c --- eresi-0.8a25/libasm/src/error.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/error.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,8 +1,8 @@ /** - * @file error.c - * @ingroup libasm_engine +* @file libasm/src/error.c + * @ingroup libasm ** -** $Id: error.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ +** $Id: error.c 1397 2009-09-13 02:19:08Z may $ ** ** Author : ** Started : Sun Nov 30 19:58:38 2003 diff -Nru eresi-0.8a25/libasm/src/generic.c eresi-0.0.20110516/libasm/src/generic.c --- eresi-0.8a25/libasm/src/generic.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/generic.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,8 +1,8 @@ /** - * @file generic.c - * @ingroup libasm_engine +* @file libasm/src/generic.c + * @ingroup libasm * Latest edition Author : $Author: may $ - * $Id: generic.c,v 1.15 2007/12/26 14:21:06 may Exp $ + * $Id: generic.c 1439 2010-12-13 10:27:16Z may $ * Started : Wed Jul 24 18:45:15 2002 * Updated : Sat Mar 20 05:26:26 2004 */ @@ -87,7 +87,8 @@ */ void asm_set_resolve_handler(asm_processor *proc, - void (*fcn)(void *, u_int, char *, u_int), void *d) { + void (*fcn)(void *, eresi_Addr, char *, u_int), void *d) +{ proc->resolve_immediate = fcn; proc->resolve_data = d; } @@ -361,9 +362,9 @@ fprintf(out, "ins=[%s] len=[%i] types=[%c|%c%c%c]\n", asm_instr_get_memonic(ins, ins->proc), asm_instr_len(ins), - ins->type & ASM_TYPE_IMPBRANCH ? 'I' : + (ins->type & ASM_TYPE_BRANCH) && !(ins->type & ASM_TYPE_CONDCONTROL) ? 'I' : ins->type & ASM_TYPE_CALLPROC ? 'C' : - ins->type & ASM_TYPE_CONDBRANCH ? 'J' : + (ins->type & ASM_TYPE_BRANCH) && (ins->type & ASM_TYPE_CONDCONTROL) ? 'J' : ins->type & ASM_TYPE_RETPROC ? 'R' : ' ', ins->type & ASM_TYPE_ARITH ? 'c' : ' ', ins->type & ASM_TYPE_CONTROL ? 'f' : ' ', @@ -393,6 +394,14 @@ } /** + * get the synthetic instruction enabled flag + */ +int asm_config_get_synthinstr() +{ + return (int) config_get_data(CONFIG_ASM_SYNTHINSTRS); +} + +/** * * */ diff -Nru eresi-0.8a25/libasm/src/instruction.c eresi-0.0.20110516/libasm/src/instruction.c --- eresi-0.8a25/libasm/src/instruction.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/instruction.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,12 +1,12 @@ /** * - * @file instruction.c - * @ingroup libasm_engine +* @file libasm/src/instruction.c + * @ingroup libasm * Author : * Started : Mon Mar 15 13:58:52 2004 * Updated : Mon Mar 22 01:35:03 2004 * - * $Id: instruction.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ + * $Id: instruction.c 1397 2009-09-13 02:19:08Z may $ * */ diff -Nru eresi-0.8a25/libasm/src/operand.c eresi-0.0.20110516/libasm/src/operand.c --- eresi-0.8a25/libasm/src/operand.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/operand.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,13 +1,10 @@ /** - * @file operand.c - * @ingroup operands - * $Id: operand.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * operand.c in +* @file libasm/src/operand.c + * @ingroup libasm + * @brief Contains arch-independent generic operand manipulation functions. * * Author : - * Started : Sat Mar 6 06:28:22 2004 - * Updated : Wed Apr 7 19:54:38 2004 - * @brief Contains operand manipulation functions. + * $Id: operand.c 1397 2009-09-13 02:19:08Z may $ */ #include diff -Nru eresi-0.8a25/libasm/src/output.c eresi-0.0.20110516/libasm/src/output.c --- eresi-0.8a25/libasm/src/output.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/output.c 2011-05-16 11:34:45.000000000 +0000 @@ -1,7 +1,7 @@ /** - * @file output.c - * @ingroup libasm_engine - * $Id: output.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ +* @file libasm/src/output.c + * @ingroup libasm + * $Id: output.c 1397 2009-09-13 02:19:08Z may $ * * Author : * Started : Xxx Xxx xx xx:xx:xx 2002 @@ -17,7 +17,7 @@ * @param buf Pointer to store string * @param len Length of string */ -void asm_resolve_immediate(asm_processor *proc, u_int val, +void asm_resolve_immediate(asm_processor *proc, eresi_Addr val, char *buf, u_int len) { LIBASM_PROFILE_FIN(); @@ -32,10 +32,10 @@ * @param addr Virtual address of instruction * @return Pointer to a static buffer containing current instruction string */ -char *asm_display_instr_att(asm_instr *instr, - int addr) +char *asm_display_instr_att(asm_instr *instr, eresi_Addr addr) { char *to_ret; + LIBASM_PROFILE_FIN(); to_ret = instr->proc->display_handle(instr, addr); LIBASM_PROFILE_ROUT(to_ret); diff -Nru eresi-0.8a25/libasm/src/register.c eresi-0.0.20110516/libasm/src/register.c --- eresi-0.8a25/libasm/src/register.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/register.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,7 +1,7 @@ /** - * $Id: register.c,v 1.10 2007/11/28 00:21:37 strauss Exp $ - * @file register.c - * @ingroup libasm_engine + * $Id: register.c 1397 2009-09-13 02:19:08Z may $ +* @file libasm/src/register.c + * @ingroup libasm * @brief Registration of instruction and operand handlers. */ @@ -10,7 +10,50 @@ /** - * Initialize instruction level vector + * Wrapper for Architecture initialization. + * + * This function create an abstraction to enable partial building + * of libasm depending on needs. + * @param proc Pointer to asm_processor structure. + * @param arch Architecture: ASM_PROC_IA32 + */ + +int asm_init_arch(asm_processor *proc, int arch) +{ + switch(arch) + { +#if LIBASM_ENABLE_IA32 + //#warning Enabling IA32 support + case ASM_PROC_IA32: + return asm_init_ia32(proc); + break; +#endif +#if LIBASM_ENABLE_SPARC + //#warning Enabling SPARC support + case ASM_PROC_SPARC: + return asm_init_sparc(proc); + break; +#endif +#if LIBASM_ENABLE_MIPS + //#warning Enabling MIPS support + case ASM_PROC_MIPS: + return asm_init_mips(proc); + break; +#endif +#if LIBASM_ENABLE_ARM + //#warning Enabling ARM support + case ASM_PROC_ARM: + return asm_init_arm(proc); + break; +#endif + default: + return (0); + } + return (0); +} + +/** + * Initialize instruction level vector. * @param proc Pointer to processor structure * @param machine Currently not used. * @return 1 on success, 0 on error @@ -20,28 +63,39 @@ int to_ret; LIBASM_PROFILE_FIN(); + + to_ret = 0; +#if LIBASM_ENABLE_IA32 if (proc->type == ASM_PROC_IA32) { asm_register_ia32(proc); + to_ret = 1; } - else if (proc->type == ASM_PROC_SPARC) +#endif +#if LIBASM_ENABLE_SPARC + if (proc->type == ASM_PROC_SPARC) { asm_register_sparc(); + to_ret = 1; } - else if (proc->type == ASM_PROC_MIPS) +#endif +#if LIBASM_ENABLE_MIPS + if (proc->type == ASM_PROC_MIPS) { asm_register_mips(); + to_ret = 1; } +#endif +#if LIBASM_ENABLE_ARM + if (proc->type == ASM_PROC_ARM) + { + asm_register_arm(); + to_ret = 1; + } +#endif // // Add your architecture handler here. // - else - { - to_ret = 0; - goto out; - } - to_ret = 1; - out: LIBASM_PROFILE_FOUT(to_ret); } diff -Nru eresi-0.8a25/libasm/src/.svn/all-wcprops eresi-0.0.20110516/libasm/src/.svn/all-wcprops --- eresi-0.8a25/libasm/src/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/945/trunk/libasm/src -END -build.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/909/trunk/libasm/src/build.c -END -output.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/909/trunk/libasm/src/output.c -END -instruction.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/909/trunk/libasm/src/instruction.c -END -register.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/909/trunk/libasm/src/register.c -END -vectors.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/909/trunk/libasm/src/vectors.c -END -operand.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/849/trunk/libasm/src/operand.c -END -error.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/909/trunk/libasm/src/error.c -END -generic.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/945/trunk/libasm/src/generic.c -END diff -Nru eresi-0.8a25/libasm/src/.svn/entries eresi-0.0.20110516/libasm/src/.svn/entries --- eresi-0.8a25/libasm/src/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/src -http://svn.eresi-project.org/svn - - - -2008-03-27T22:24:43.639027Z -945 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -build.c -file - - - - -2008-04-06T23:16:25.437901Z -22e5dfc153fb557ce3a8ad0cb5f85872 -2008-03-14T09:48:44.987521Z -909 -enioh - -output.c -file - - - - -2008-04-06T23:16:25.448888Z -0c0a1daf562320378b0ba25552fde608 -2008-03-14T09:48:44.987521Z -909 -enioh - -instruction.c -file - - - - -2008-04-06T23:16:25.460092Z -a00809332dab19fddc247f6fa9766027 -2008-03-14T09:48:44.987521Z -909 -enioh - -register.c -file - - - - -2008-04-06T23:16:25.471152Z -cb5dffddacae14cd10b4582db5531d58 -2008-03-14T09:48:44.987521Z -909 -enioh - -vectors.c -file - - - - -2008-04-06T23:16:25.482153Z -d44569c50e9ca4ebc7acb5753ab8c924 -2008-03-14T09:48:44.987521Z -909 -enioh - -operand.c -file - - - - -2008-04-06T23:16:25.494005Z -cdbc95ad33acb74f27eaedd1feb7be86 -2008-02-19T17:09:59.893936Z -849 -may - -error.c -file - - - - -2008-04-06T23:16:25.505348Z -d286c2e04387739a04bd3395eb430603 -2008-03-14T09:48:44.987521Z -909 -enioh - -arch -dir - -generic.c -file - - - - -2008-04-06T23:16:25.516631Z -b75110411dac444f767962f80356aeec -2008-03-27T22:24:43.639027Z -945 -may - diff -Nru eresi-0.8a25/libasm/src/.svn/format eresi-0.0.20110516/libasm/src/.svn/format --- eresi-0.8a25/libasm/src/.svn/format 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/build.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/build.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/build.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/build.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/** - * @file build.c - * @ingroup libasm_engine - * @brief Contains latest build date. - * $Id: build.c,v 1.3 2008/01/01 14:55:00 heroine Exp $ - */ - -/** - * State of the project. - * - * Libasm developpement is not regular. Some time is spent on documenting it. - * Some time to fix bugs. Some time to implement. - * - * Currently, there are two architectures supported : - * - - * - * - * - */ - -#include - -/** - * @brief Return build date. - * @return build date. - */ - -char *asm_get_build(void) -{ - return (__DATE__); -} - -/** - * - */ - -char *g_asm_features [] = - { - - - 0 - }; - -/** - * - */ - -char **asm_get_features() -{ - return g_asm_features; -} diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/error.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/error.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/error.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/error.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/** - * @file error.c - * @ingroup libasm_engine -** -** $Id: error.c,v 1.4 2007/10/14 00:01:41 heroine Exp $ -** -** Author : -** Started : Sun Nov 30 19:58:38 2003 -** Updated : Thu Dec 4 01:18:48 2003 -*/ - -#include - - -/** - * Set error - * @param ins Pointer to instruction structure. - * @param err Error number - * @param msg Error message - */ -void asm_set_error(asm_instr *ins, int err, char *msg) -{ - if (ins && ins->proc) - ins->proc->error_code = err; -} - - -/** - * Set error message. - * This is currently not implemented. - * @param ins Pointer to instruction structure - * @param msg Error message - */ - -void asm_set_errormsg(asm_instr *ins, char *msg) -{ -} - - -/** - * Return error code. - * @param ins Pointer to instruction structure. - * @return Return error code. - */ - -int asm_get_error(asm_instr *ins) -{ - return (0); -} - -/** - * Return error message. - * @param ins Pointer to instruction structure. - * @return Return a pointer to a static string containing error message. - */ - -const char *asm_get_errormsg(asm_processor *proc) -{ - if (proc) - { - switch(proc->error_code) - { - case LIBASM_ERROR_SUCCESS: return (LIBASM_MSG_SUCCESS); - case LIBASM_ERROR_NSUCH_CONTENT: return (LIBASM_MSG_SUCCESS); - case LIBASM_ERROR_ILLEGAL: return (LIBASM_MSG_SUCCESS); - case LIBASM_ERROR_TOOSHORT: return (LIBASM_MSG_TOOSHORT); - } - return (LIBASM_MSG_ERRORNOTIMPLEMENTED); - } - else - return ("asm_get_errormsg: proc is NULL"); -} diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/generic.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/generic.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/generic.c.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/generic.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,403 +0,0 @@ -/** - * @file generic.c - * @ingroup libasm_engine - * Latest edition Author : $Author: may $ - * $Id: generic.c,v 1.15 2007/12/26 14:21:06 may Exp $ - * Started : Wed Jul 24 18:45:15 2002 - * Updated : Sat Mar 20 05:26:26 2004 - */ -#include -#include - -/** - * Fetch instruction using asm_processor handler - * func asm_read_instr - * fetch instruction stored in buffer of max length len - * according to specified processor. - * @param instr instruction to fill. - * @param buf pointer to opcode to disassemble - * @param len maximum length of opcode to disassemble - * @return -1 on error or instruction fetched length - */ - -int asm_read_instr(asm_instr *instr, u_char *buf, - u_int len, asm_processor *proc) -{ - int to_ret; - - LIBASM_PROFILE_FIN(); - memset(instr, 0, sizeof (asm_instr)); - instr->proc = proc; - to_ret = proc->fetch(instr, buf, len, proc); - instr->name = instr->proc->instr_table[instr->instr]; - - /* Print debug information if requested */ - if ((int) config_get_data(CONFIG_USE_ASMDEBUG)) - asm_instruction_debug(instr, stdout); - - LIBASM_PROFILE_FOUT(to_ret); -} - -/** - * @brief Reassemble instruction operands. WORK IN PROGRESS - * - * @param instr Pointer to instruction structure. - * @param buf Pointer to instruction buffer - * @param len Length of buffer. - * @return Length of written instruction or -1 on error. - */ - -int asm_write_instr(asm_instr *instr, u_char *buf, u_int len) { - /* - if (instr->op1) - asm_write_operand(instr->op1); - if (instr->op2) - asm_write_operand(instr->op1); - if (instr->op3) - asm_write_operand(instr->op1) - fprintf(stderr, "asm_write unimplemented\n"); - */ - return (-1); -} - -/** - * @brief Return instruction length - * @param ins Pointer to instruction structure. - * @return - */ - -int asm_instr_len(asm_instr *ins) -{ - return (asm_instruction_get_len(ins, 0, 0)); -} - -/** - * Return 2 power val - * @param val The level of power to raise 2. - * @return Return the computed value. - */ -int asm_int_pow2(int val) { - return (val ? (2 * asm_int_pow2(val - 1)) : 1); -} - -/** - * @brief Set the resolving handler to display addresses. - * @param proc Pointer to processor structure. - * @param fcn The resolving handler to use - */ - -void asm_set_resolve_handler(asm_processor *proc, - void (*fcn)(void *, u_int, char *, u_int), void *d) { - proc->resolve_immediate = fcn; - proc->resolve_data = d; -} - -/** - * @brief returns 1 if OPLEN is not activated - * This is related only to ia32 architecture. - * @param proc The pointer to the processor structure. - * @return 1 if OPLEN is activated, 0 if not. - */ - -int asm_proc_is_protected(asm_processor *proc) { - asm_i386_processor *i386p; - - i386p = (asm_i386_processor *) proc; - if (i386p->internals->mode == INTEL_PROT) - return (1); - return (0); -} - - -/** - * @brief returns the value of the processor's current operand length - * This is related only to ia32 architecture. - * @param proc Pointer to the processor structure. - * @return 1 if opsize is set, 0 if not. - */ - -int asm_proc_opsize(asm_processor *proc) { - asm_i386_processor *i386p; - - i386p = (asm_i386_processor *) proc; - if (i386p->internals->opsize) - return (1); - return (0); -} - -/** - * @brief Returns the value of the processor's current address size - * @param proc Pointer to the processor structure - * @return 1 if addsize is set, 0 if not - */ - -int asm_proc_addsize(asm_processor *proc) -{ - asm_i386_processor *i386p; - - i386p = (asm_i386_processor *) proc; - if (i386p->internals->addsize) - return (1); - return (0); -} - -/** - * @brief Returns vector current size depending on oplen prefix - * This is related to ia32 architecture only - * @param proc Pointer to the processor structure. - * @return 4 or 2 depending on - */ - -int asm_proc_vector_len(asm_processor *proc) -{ - if (asm_proc_opsize(proc)) - return (2); - else - return (4); -} - -/** - * @brief Return vector size depending on prefix - * This is ia32 related. - * @param proc Pointer to the processor structure - * @return Return vector size. - */ - -int asm_proc_vector_size(asm_processor *proc) -{ - if (asm_proc_opsize(proc)) - return (2); - else - return (4); -} - -/** - * Set the immediate part of the operand if present - * @param ins Pointer to instruction - * @param num Number of the operand to set. - * @param opt Optionnal. may be used to specify current virtual address. - * @param valptr Pointer to the new value - * @return number of bytes written - */ - -int asm_operand_set_immediate(asm_instr *ins, int num, - int opt, void *valptr) -{ - int *value; - int off; - int len; - asm_operand *op; - - op = 0; - off = len = 0; - value = (int *) valptr; - - switch(num) - { - case 1: - op = &ins->op[0]; - break; - case 2: - op = &ins->op[1]; - break; - case 3: - op = &ins->op[2]; - break; - default: - op = 0; - return (-1); - break; - } - - if (op->ptr && (op->content & ASM_OP_VALUE)) { - switch (op->len) { - case 0: - break; - case 1: - if ((op->type & ASM_OP_BASE) || (op->type & ASM_OP_INDEX)) { - if ((op->type & ASM_OP_SCALE) || (op->type & ASM_OP_INDEX)) { - off = 2; - len = 1; - } else { - off = 1; - len = 1; - } } else { - off = 0; - len = 1; - } - break; - case 2: - if ((op->type & ASM_OP_BASE) || (op->type & ASM_OP_INDEX)) { - off = 1; - len = 1; - } else { - off = 0; - len = 2; - } - break; - case 3: - off = 2; - len = 1; - break; - case 4: - off = 0; - len = 4; - break; - case 5: - off = 1; - len = 4; - break; - case 6: - off = 2; - len = 4; - break; - } /* !switch */ } /* !if */ - else { - off = 0; - len = 0; - } - memcpy(op->ptr + off, value, len); - memset(&op->imm, 0, 4); - memcpy(&op->imm, value, len); - return (len); -} - - -/** - * returns a pointer to a static buffer containing instruction memonic - */ -/** - * returns a pointer to a static buffer containing instruction memonic - * @param ins Pointer to the instruction structure - * @param proc Pointer to the processor structure - * return Return the mnemonic. -*/ - -char *asm_instr_get_memonic(asm_instr *ins, asm_processor *proc) { - return (proc->instr_table[ins->instr]); -} - -/** - * @brief Return content field of an operand. - * @param ins Pointer to an instruction structure. - * @param num Number of the operand to get content from. - * @param opt Currently not used. - * @param valptr Currently not used. - * @return Return operand content field. - */ - -int asm_operand_get_content(asm_instr *ins, int num, int opt, void *valptr) -{ - switch(num) - { - case 1: - return (ins->op[0].content); - case 2: - return (ins->op[1].content); - case 3: - return (ins->op[2].content); - default: - return (0); - } -} - -/** - * @brief Dump debug output of operand to a file stream. - * @param ins Pointer to the instruction structure - * @param num Number of the operand to dump - * @param opt optional parameter. Currently not used. - * @param valptr is a filestream : FILE * - * @return 1 on success, 0 on error. - */ -int asm_operand_debug(asm_instr *ins, int num, int opt, void *valptr) -{ - asm_operand *op; - FILE *fp; - - switch(num) - { - case 1: op = &ins->op[0]; break; - case 2: op = &ins->op[1]; break; - case 3: op = &ins->op[2]; break; - default: return (-1); - } - if (op->type) - { - fp = (FILE *) valptr; - - fprintf(fp, "o%i type=[%s] content=[%c%c%c%c]\n", - num, - asm_operand_type_string(op->type), - op->content & ASM_OP_BASE ? 'B' : ' ', - op->content & ASM_OP_INDEX ? 'I' : ' ', - op->content & ASM_OP_SCALE ? 'S' : ' ', - op->content & ASM_OP_VALUE ? 'V' : ' '); - /* - fprintf(fp, "o%i len = %i\n", num, op->len); - fprintf(fp, "o%i ptr = %8p\n", num, op->ptr); - fprintf(fp, "o%i type = %08x\n", num, op->type); - fprintf(fp, "o%i size = %i\n", num, op->size); - fprintf(fp, "o%i content = [%i]\n", num, op->content); - - fprintf(fp, "o%i immediate = %08X\n", num, op->imm); - fprintf(fp, "o%i basereg = %i\n", num, op->baser); - fprintf(fp, "o%i indexreg = %i\n", num, op->indexr); - fprintf(fp, "o%i scale = %i\n", num, op->scale); - */ - } - return (1); -} - -/** - * Dump debugging information for an instruction. - * @param ins Pointer to instruction to debug. - * @param out Output FILE* stream. - */ - -void asm_instruction_debug(asm_instr *ins, FILE *out) -{ - int i; - - fprintf(out, "ins=[%s] len=[%i] types=[%c|%c%c%c]\n", - asm_instr_get_memonic(ins, ins->proc), - asm_instr_len(ins), - ins->type & ASM_TYPE_IMPBRANCH ? 'I' : - ins->type & ASM_TYPE_CALLPROC ? 'C' : - ins->type & ASM_TYPE_CONDBRANCH ? 'J' : - ins->type & ASM_TYPE_RETPROC ? 'R' : ' ', - ins->type & ASM_TYPE_ARITH ? 'c' : ' ', - ins->type & ASM_TYPE_CONTROL ? 'f' : ' ', - ins->type & ASM_TYPE_ASSIGN ? 'a' : ' '); - for (i = 0; i < 3; i++) - { - asm_operand_debug(ins, i, 0, out); - } -} - - -/** - * set config flag to specified endian - * @param mode endian (big/little) - */ -void asm_config_set_endian(int mode) -{ - config_update_key(CONFIG_ASM_ENDIAN_FLAG,(void *) mode); -} - -/** - * get the endian flag - */ -int asm_config_get_endian() -{ - return (int) config_get_data(CONFIG_ASM_ENDIAN_FLAG); -} - -/** - * - * - */ - -int asm_instruction_is_prefixed(asm_instr *ins, int prefix) -{ - return (ins->prefix & prefix); -} diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/instruction.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/instruction.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/instruction.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/instruction.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/** - * - * @file instruction.c - * @ingroup libasm_engine - * Author : - * Started : Mon Mar 15 13:58:52 2004 - * Updated : Mon Mar 22 01:35:03 2004 - * - * $Id: instruction.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - */ - -#include - -/** - * Return instruction length. - * @param ins Pointer to instruction structure. - * @param opt Optional parameter, not used. - * @param valptr Optional parameter, not used. - * @return Instruction length - */ - -int asm_instruction_get_len(asm_instr *ins, int opt, void *valptr) { - int *val; - - val = (int *) valptr; - if (ins && val) - *val = ins->len; - return (ins->len); -} - -/** - * @param - * @param opt Optional parameter. Not used. - * @param valptr - * @return Returns 0. - */ - -int asm_instruction_get_mnemonic(asm_instr *ins, int opt, void *valptr) -{ - char **ptr; - - if (valptr) - { - ptr = valptr; - *ptr = ins->proc->instr_table[ins->instr]; - } - return (0); -} - -/** - * @brief Get instruction type. - * @return Returns 1 on success, 0 on error. - */ - -int asm_instruction_get_type(asm_instr *ins, int opt, void *valptr) -{ - int *val; - - if (valptr) - { - val = valptr; - *val = ins->type; - } - return (1); -} - -/** - * @brief Get instruction prefixes - * @param ins Pointer to instruction. - * @param opt Optional parameter. - * @param valptr Pointer to store prefix (bitflag stored on an integer) - * @return Returns 1. - */ - -int asm_instruction_get_prefix(asm_instr *ins, int opt, void *valptr) -{ - int *val; - - if (valptr) - { - val = valptr; - *val = ins->prefix; - } - return (1); -} - -/** - * get number of operand of instruction - * - */ - -int asm_instruction_get_nbop(asm_instr *ins, int opt, void *valptr) -{ - int *val; - - if (valptr) - { - val = valptr; - *val = 0; - if (ins->op[0].type) - (*val)++; - if (ins->op[1].type) - (*val)++; - if (ins->op[2].type) - (*val)++; - } - return (1); -} - -/** - * @brief Return instruction length - * @param instr Pointer to instruction. - */ -int asm_instruction_get_length(asm_instr *instr) -{ - if (instr) - return (instr->len); - else - return (-1); -} diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/operand.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/operand.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/operand.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/operand.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,417 +0,0 @@ -/** - * @file operand.c - * @ingroup operands - * $Id: operand.c,v 1.6 2007/10/14 00:01:41 heroine Exp $ - * operand.c in - * - * Author : - * Started : Sat Mar 6 06:28:22 2004 - * Updated : Wed Apr 7 19:54:38 2004 - * @brief Contains operand manipulation functions. -*/ - -#include -#include - -/** - * Return immediate part of the operand - * @param ins Pointer to instruction - * @param num Number of the operand. (SOURCE/DEST/OPT) - * @param opt Optionnal. May be the virtual address of instruction - * @param valptr Reference to store immediate content - */ -int asm_operand_get_immediate(asm_instr *ins, int num, - int opt, void *valptr) -{ - - asm_operand *op; - /* - char *c; - short *s; - int *i; - */ - - switch(num) - { - case 1: op = &ins->op[0]; break; - case 2: op = &ins->op[1]; break; - case 3: op = &ins->op[2]; break; - default: - return (-1); - } - - memset(valptr, 0, 4); - memcpy(valptr, &op->imm, 4); - - /** - * This is pseudo dead code - * it was about - * - */ - /* - switch(op->type) - { - case ASM_OTYPE_VALUE: - switch(op->size) - { - case ASM_OSIZE_BYTE: memcpy(valptr, &op->imm, 1); break; - case ASM_OSIZE_WORD: memcpy(valptr, &op->imm, 2); break; - case ASM_OSIZE_DWORD: memcpy(valptr, &op->imm, 4); break; - case ASM_OSIZE_VECTOR: memcpy(valptr, &op->imm, 4); break; - default: return (-1); - } - break; - case ASM_OTYPE_JUMP: - switch(op->size) - { - case ASM_OSIZE_BYTE: c = op->ptr; opt = opt + *c; break; - case ASM_OSIZE_WORD: s = (short *)op->ptr; opt += *s; break; - case ASM_OSIZE_DWORD: i = (int *) op->ptr; opt += *i; break; - case ASM_OSIZE_VECTOR: i = (int *) op->ptr; opt += *i; break; - } - memcpy(valptr, &opt, 4); - break; - } - */ - return (1); -} - - -/** - * Get base register of operand - * asm_operand must have ASM_OP_BASE defined - * @param ins Pointer to instruction - * @param num Number of the operand - * @param opt Optionnal parameter, may be virtual address - * @param valptr Reference to store the content of the register - * @return -1 on error, - */ - -int asm_operand_get_basereg(asm_instr *ins, int num, - int opt, void *valptr) -{ - int *val; - - val = (int *) valptr; - switch(num) - { - case 1: - if (ins->op[0].type && (ins->op[0].content & ASM_OP_BASE)) - *val = ins->op[0].baser; - else - return (-1); - break; - case 2: - if (ins->op[1].type && (ins->op[1].content & ASM_OP_BASE)) - *val = ins->op[1].baser; - else - return (-1); - break; - case 3: - if (ins->op[2].type && (ins->op[2].content & ASM_OP_BASE)) - *val = ins->op[2].baser; - else - return (-1); - break; - default: - return (-1); - } - return (1); -} - -/** - * Get index register field of operand - * asm_operand must have ASM_OP_INDEX - * @return -1 on errorreturn -1 on error - */ - -int asm_operand_get_indexreg(asm_instr *ins, int num, - int opt, void *valptr) -{ - int *val; - - val = (int *) valptr; - switch(num) - { - case 1: - if (ins->op[0].type && (ins->op[0].content & ASM_OP_INDEX)) - *val = ins->op[0].indexr; - else - return (-1); - break; - case 2: - if (ins->op[1].type && (ins->op[1].content & ASM_OP_INDEX)) - *val = ins->op[1].indexr; - else - return (-1); - break; - case 3: - if (ins->op[2].type && (ins->op[2].content & ASM_OP_INDEX)) - *val = ins->op[2].indexr; - else - return (-1); - break; - default: - return (-1); - } - return (1); -} - -/** - * Get scale field of operand - * asn_operand must have ASM_OP_SCALE type set - * @return -1 on error, 1 on success - */ - -int asm_operand_get_scale(asm_instr *ins, int num, - int opt, void *valptr) { - int *val; - - val = (int *) valptr; - switch(num) - { - case 1: - if (ins->op[0].type && (ins->op[0].content & ASM_OP_SCALE)) - *val = ins->op[0].scale; - else - return (-1); - break; - case 2: - if (ins->op[1].type && (ins->op[1].content & ASM_OP_SCALE)) - *val = ins->op[1].scale; - else - return (-1); - break; - case 3: - if (ins->op[2].type && (ins->op[2].content & ASM_OP_SCALE)) - *val = ins->op[2].scale; - else - return (-1); - break; - default: - return (-1); - } - return (1); -} - -/** - * Set base register of operand - * @param ins - * @param num - * @param opt - * @param valptr - * @return -1 on error, 1 on success - */ - -int asm_operand_set_basereg(asm_instr *ins, int num, - int opt, void *valptr) -{ - asm_modrm *modrm; - asm_operand *op; - int *val; - - return (-1); - if (!op->ptr) { - fprintf(stderr, "no pointer available"); - } - else - { - val = (int *) valptr; - modrm = (asm_modrm *) op->ptr; - switch(op->type) - { - case ASM_OTYPE_OPMOD: - modrm->m = *val; - break; - case ASM_OTYPE_CONTROL: - modrm->m = *val; - break; - case ASM_OTYPE_DEBUG: - modrm->m = *val; - break; - case ASM_OTYPE_ENCODED: - modrm->r = *val; - break; - case ASM_OTYPE_GENERAL: - modrm->r = *val; - break; - case ASM_OTYPE_REGISTER: - modrm->m = *val; - break; - default: - return (0); - } - /* - if ((op->type & ASM_OP_BASE) && - ((ASM_OP_INDEX & op->type) || (ASM_OP_SCALE))) { - - */ - } - - return (1); -} - - -/** - * Set index register of operand - * @param ins - * @param num - * @param opt - * @param valptr - * @return -1 on error, 1 on success - */ - -int asm_operand_set_indexreg(asm_instr *ins, int num, - int opt, void *valptr) { - int *val; - struct s_sidbyte *sidbyte; - asm_operand *op; - - return (-1); - if (op->content & ASM_OP_INDEX) { - sidbyte = (struct s_sidbyte *) (op->ptr + 1); - val = (int *) valptr; - switch(op->type) { - case ASM_OTYPE_ENCODED: - case ASM_OTYPE_MEMORY: - if (!op->ptr) - fprintf(stderr, "ptr field NULL, cannot set index reg\n"); - else - sidbyte->index = *val; - break; - default: - fprintf(stderr, "unsupported operand type to set index register\n"); - } - } - - return (-1); -} - -/** - * Set scale field of operand - * @param ins - * @param num - * @param opt - * @param valptr - * @return -1 on error, 1 on success - */ -int asm_operand_set_scale(asm_instr *ins, int num, - int opt, void *valptr) { - int *val; - struct s_sidbyte *sidbyte; - asm_operand *op; - - return (-1); - op = &ins->op[0]; - val = (int *) valptr; - if (op && op->type & ASM_OP_SCALE) { - - if (op->type & ASM_OP_FPU) - sidbyte->sid = *val; - else - switch(*val) { - case 1: - sidbyte->sid = 0; break; - case 2: - sidbyte->sid = 1; break; - case 4: - sidbyte->sid = 2; break; - case 8: - sidbyte->sid = 3; break; - default: - return (0); - } - } - return (1); -} - -/** - * - * - * - */ - -int asm_operand_get_type(asm_instr *ins, int num, int opt, void *valptr) { - int *val; - - if ((val = valptr)) - switch(num) - { - case 1: - return (*val = ins->op[0].type); - case 2: - return (*val = ins->op[1].type); - case 3: - return (*val = ins->op[2].type); - } - return (-1); -} - - -int asm_operand_get_size(asm_instr *ins, int num, int opt, void *valptr) { - int *val, to_ret; - - val = (int *) valptr; - switch(num) - { - case 1: - *val = ins->op[0].size; - to_ret = 1; - break; - case 2: - *val = ins->op[1].size; - to_ret = 1; - break; - case 3: - *val = ins->op[2].size; - to_ret = 1; - break; - default: - to_ret = -1; - } - return (to_ret); -} - -int asm_operand_get_len(asm_instr *ins, int num, int opt, void *valptr) { - switch(num) - { - case 1: - return (ins->op[0].len); - case 2: - return (ins->op[1].len); - case 3: - return (ins->op[2].len); - default: - return (0); - } -} - -/** - * Return number of operands - * @param ins Pointer to instruction * - */ -int asm_operand_get_count(asm_instr *ins, int num, int opt, void *valptr) -{ - if (!ins) - return (-1); - num = 0; - if (ins->op[0].content) - num++; - if (ins->op[1].content) - num++; - if (ins->op[2].content) - num++; - return (num); -} - - -/** - * Return wether operand if a reference or not. - * @param op Pointer to operand structure. - * @return True if operand is a reference, or False. - */ -int asm_operand_is_reference(asm_operand *op) -{ - return(op->content & ASM_OP_REFERENCE); -} - diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/output.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/output.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/output.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/output.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -/** - * @file output.c - * @ingroup libasm_engine - * $Id: output.c,v 1.5 2007/10/14 00:01:41 heroine Exp $ - * - * Author : - * Started : Xxx Xxx xx xx:xx:xx 2002 - * Updated : Thu Mar 11 00:40:31 2004 - * @brief ASCII Output wrappers. - */ -#include -#include -/** - * @brief Wrapper to internal resolving handler for immediate values. - * @param proc Pointer to processor structure - * @param val Value to resolve - * @param buf Pointer to store string - * @param len Length of string - */ -void asm_resolve_immediate(asm_processor *proc, u_int val, - char *buf, u_int len) -{ - LIBASM_PROFILE_FIN(); - proc->resolve_immediate(proc->resolve_data, val, buf, len); - LIBASM_PROFILE_VOUT(); -} - - -/** - * @brief Wrapper to internal Ascii output handler. - * @param instr Pointer to instruction structure - * @param addr Virtual address of instruction - * @return Pointer to a static buffer containing current instruction string - */ -char *asm_display_instr_att(asm_instr *instr, - int addr) -{ - char *to_ret; - LIBASM_PROFILE_FIN(); - to_ret = instr->proc->display_handle(instr, addr); - LIBASM_PROFILE_ROUT(to_ret); -} - - -/** - * merged from mjollnir - * @brief Debug dump to stderr of an operand - * @param op Pointer to operand structure. - * @return Always returns 0. - */ -int asm_debug_operand(asm_operand * op) -{ - fprintf(stderr, "[*] Operand Dump\n[*] len: %d type: %d size: %d content: %d\n", - op->len, op->type, op->size, op->content); - - fprintf(stderr, "[*] Content: %s %s %s %s %s %s %s\n", - (op->content & ASM_OP_VALUE) ? "ASM_OP_VALUE" : ".", - (op->content & ASM_OP_BASE) ? "ASM_OP_BASE" : ".", - (op->content & ASM_OP_INDEX) ? "ASM_OP_INDEX" : ".", - (op->content & ASM_OP_SCALE) ? "ASM_OP_SCALE" : ".", - (op->content & ASM_OP_FIXED) ? "ASM_OP_FIXED" : ".", - (op->content & ASM_OP_REFERENCE) ? "ASM_OP_REFERENCE" : ".", - (op->content & ASM_OP_ADDRESS) ? "ASM_OP_ADDRESS" : "."); - - return 0; -} - -/** - * @brief Return a string describing otype - * @param type Instruction type - * @return A pointer to a static string - */ - -char *asm_operand_type_string(int type) -{ - switch (type) - { - case ASM_OTYPE_FIXED: return ("fixed"); - case ASM_OTYPE_OPMOD: return ("opmod"); - case ASM_OTYPE_ADDRESS: return ("address"); - case ASM_OTYPE_CONTROL: return ("control"); - case ASM_OTYPE_DEBUG: return ("debug"); - case ASM_OTYPE_ENCODED: return ("encoded"); - case ASM_OTYPE_ENCODEDBYTE: return ("encodedbyte"); - case ASM_OTYPE_FLAGS: return ("flags"); - case ASM_OTYPE_GENERAL: return ("general"); - case ASM_OTYPE_GENERALBYTE: return ("generalbyte"); - case ASM_OTYPE_IMMEDIATE: return ("immediate"); - case ASM_OTYPE_IMMEDIATEWORD: return ("immediateword"); - case ASM_OTYPE_IMMEDIATEBYTE: return ("immediatebyte"); - case ASM_OTYPE_SHORTJUMP: return ("shortjump"); - case ASM_OTYPE_JUMP: return ("jump"); - case ASM_OTYPE_MEMORY: return ("memory"); - case ASM_OTYPE_OFFSET: return ("offset"); - case ASM_OTYPE_PMMX: return ("pmmx"); - case ASM_OTYPE_QMMX: return ("qmmx"); - case ASM_OTYPE_REGISTER: return ("register"); - case ASM_OTYPE_SEGMENT: return ("segment"); - case ASM_OTYPE_TEST: return ("test"); - case ASM_OTYPE_VSFP: return ("vsfp"); - case ASM_OTYPE_WSFP: return ("wsfp"); - case ASM_OTYPE_XSRC: return ("xsrc"); - case ASM_OTYPE_YDEST: return ("ydest"); - } - return ("undocumented type"); -} - - - - - - - diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/register.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/register.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/register.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -/** - * $Id: register.c,v 1.10 2007/11/28 00:21:37 strauss Exp $ - * @file register.c - * @ingroup libasm_engine - * @brief Registration of instruction and operand handlers. - */ - -#include -#include - - -/** - * Initialize instruction level vector - * @param proc Pointer to processor structure - * @param machine Currently not used. - * @return 1 on success, 0 on error - */ -int asm_arch_register(asm_processor *proc, int machine) -{ - int to_ret; - - LIBASM_PROFILE_FIN(); - if (proc->type == ASM_PROC_IA32) - { - asm_register_ia32(proc); - } - else if (proc->type == ASM_PROC_SPARC) - { - asm_register_sparc(); - } - else if (proc->type == ASM_PROC_MIPS) - { - asm_register_mips(); - } - // - // Add your architecture handler here. - // - else - { - to_ret = 0; - goto out; - } - to_ret = 1; - out: - LIBASM_PROFILE_FOUT(to_ret); -} - -/** - * @brief Create a new operand vector of dimension 1 and size - * @param vector_name Name of the vector - * @param size Size of the vector - * @return 1 on success, or 0 on error. - */ -int asm_register_operand_create(const char *vector_name, int size) -{ - u_int *dims; - char **dimstr; - - dims = malloc(1 * sizeof (u_int)); - if (!dims) - { - return 0; - } - dimstr = malloc(1 * sizeof (char *)); - if (!dimstr) - { - return 0; - } - dims[0] = size; - dimstr[0] = "OPERAND"; - aspect_register_vector((char *)vector_name, asm_operand_fetch_default, - dims, dimstr, 1, ASPECT_TYPE_CADDR); - return (1); -} - - -/** - * Generic function to register operand handlers. - * @param vector_name name of the vector to store the handlers (arch specific) - * @param operand_type Type of the operand to register - * @param fcn Function pointer. - * @return 1 on success, 0 on error. - */ - -int asm_register_operand(const char *vector_name, int operand_type, - unsigned long fcn) -{ - vector_t *vec; - u_int dim[1]; - - LIBASM_PROFILE_FIN(); - vec = aspect_vector_get((char *)vector_name); - dim[0] = operand_type; - aspect_vectors_insert(vec, dim, fcn); - LIBASM_PROFILE_FOUT(1); -} - - -/** - * - * - * - */ - -int asm_register_opcode_create(const char *vector_name, int size) -{ - u_int *dims; - char **dimstr; - - dims = malloc(1 * sizeof (u_int)); - if (!dims) - { - return 0; - } - dimstr = malloc(1 * sizeof (char *)); - if (!dimstr) - { - return 0; - } - dims[0] = size; - dimstr[0] = "opcode"; - aspect_register_vector((char *) vector_name, asm_operand_fetch_default, - dims, dimstr, 1, ASPECT_TYPE_CADDR); - return (1); -} - -/** - * - * - * - * - * - */ - -int asm_register_opcode(const char *vector_name, int opcode, - unsigned long fcn) -{ - vector_t *vec; - u_int dim[1]; - int to_ret; - - LIBASM_PROFILE_FIN(); - to_ret = 0; - if ((vec = aspect_vector_get((char *)vector_name)) != NULL) - { - dim[0] = opcode; - aspect_vectors_insert(vec, dim, fcn); - to_ret = 1; - } - LIBASM_PROFILE_FOUT(to_ret); -} diff -Nru eresi-0.8a25/libasm/src/.svn/text-base/vectors.c.svn-base eresi-0.0.20110516/libasm/src/.svn/text-base/vectors.c.svn-base --- eresi-0.8a25/libasm/src/.svn/text-base/vectors.c.svn-base 2008-04-06 23:15:54.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/.svn/text-base/vectors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/** - * @defgroup libasm_engine libasm Engine. - */ -/** - * $Id: vectors.c,v 1.13 2007/10/14 00:01:41 heroine Exp $ - * @file vectors.c - * @ingroup libasm_engine - * @brief Initialization the instruction and opcode vectors. - */ - -#include - -/** - * @brief Default handler for the disasm vector. - * This handler does nothing, simply returning -1. - * @param ins Pointer to instruction structure to fill - * @param opcode Pointer to buffer to disassemble - * @param len Length of the buffer to disassemble - * @param proc Pointer to the processor structure - * @return -1 - */ -#if 0 && WIP -int asm_fetch_default(asm_instr *ins, u_char *opcode, u_int len, - asm_processor *proc, int opt) -{ - int to_ret; - LIBASM_PROFILE_FIN(); - if (proc->type == ASM_PROC_SPARC) - to_ret = asm_sparc_illegal(ins, opcode, len, proc); - else - to_ret = -1; - LIBASM_PROFILE_FOUT(to_ret); -} -#else -int asm_fetch_default(asm_instr *ins, u_char *opcode, u_int len, - asm_processor *proc) -{ - int to_ret; - LIBASM_PROFILE_FIN(); - if (proc->type == ASM_PROC_SPARC) - to_ret = asm_sparc_illegal(ins, opcode, len, proc); - else - to_ret = -1; - LIBASM_PROFILE_FOUT(to_ret); -} -#endif - -/** - * @brief Default handler for the operand vector - * This handler does nothing, simply returning -1 - * @param ins Pointer to instruction structure to fill - * @param opcode Pointer to buffer to disassemble - * @param len Length of the buffer to disassemble - * @param proc Pointer to the processor structure - * @return -1 - * - */ -#if WIP -int asm_operand_fetch_default(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins, int opt) -{ - LIBASM_PROFILE_FIN(); - LIBASM_PROFILE_FOUT(-1); -} -#else -int asm_operand_fetch_default(asm_operand *op, u_char *opcode, int otype, - asm_instr *ins) -{ - LIBASM_PROFILE_FIN(); - LIBASM_PROFILE_FOUT(-1); -} -#endif - -/** - * @brief Return handler associated with an opcode - * @param vector_name Name of the vector. - * @param opcode - * - */ -void *asm_opcode_fetch(const char *vector_name, int opcode) -{ - vector_t *vec; - u_int dim[1]; - void *fcn_ptr; - - vec = aspect_vector_get((char *) vector_name); - dim[0] = opcode; - fcn_ptr = aspect_vectors_select(vec, dim); - return (fcn_ptr); -} diff -Nru eresi-0.8a25/libasm/src/vectors.c eresi-0.0.20110516/libasm/src/vectors.c --- eresi-0.8a25/libasm/src/vectors.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/src/vectors.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,17 +1,15 @@ /** - * @defgroup libasm_engine libasm Engine. - */ -/** - * $Id: vectors.c,v 1.13 2007/10/14 00:01:41 heroine Exp $ - * @file vectors.c - * @ingroup libasm_engine + * $Id: vectors.c 1409 2010-05-11 14:03:41Z figueredo $ +* @file libasm/src/vectors.c + * @ingroup libasm * @brief Initialization the instruction and opcode vectors. */ - #include /** * @brief Default handler for the disasm vector. + * @ingroup libasm + * * This handler does nothing, simply returning -1. * @param ins Pointer to instruction structure to fill * @param opcode Pointer to buffer to disassemble @@ -25,9 +23,11 @@ { int to_ret; LIBASM_PROFILE_FIN(); +#if LIBASM_ENABLE_SPARC if (proc->type == ASM_PROC_SPARC) to_ret = asm_sparc_illegal(ins, opcode, len, proc); else +#endif to_ret = -1; LIBASM_PROFILE_FOUT(to_ret); } @@ -36,11 +36,25 @@ asm_processor *proc) { int to_ret; + LIBASM_PROFILE_FIN(); - if (proc->type == ASM_PROC_SPARC) - to_ret = asm_sparc_illegal(ins, opcode, len, proc); - else - to_ret = -1; + + switch (proc->type) + { +#if LIBASM_ENABLE_SPARC + case ASM_PROC_SPARC: + to_ret = asm_sparc_illegal(ins, opcode, len, proc); + break; +#endif +#if LIBASM_ENABLE_ARM + case ASM_PROC_ARM: + to_ret = asm_arm_illegal(ins, opcode, len, proc); + break; +#endif + default: + to_ret = -1; + } + LIBASM_PROFILE_FOUT(to_ret); } #endif diff -Nru eresi-0.8a25/libasm/.svn/all-wcprops eresi-0.0.20110516/libasm/.svn/all-wcprops --- eresi-0.8a25/libasm/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 30 -/svn/!svn/ver/950/trunk/libasm -END -configure -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/863/trunk/libasm/configure -END -README.FIRST -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/21/trunk/libasm/README.FIRST -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/libasm/Makefile -END diff -Nru eresi-0.8a25/libasm/.svn/entries eresi-0.0.20110516/libasm/.svn/entries --- eresi-0.8a25/libasm/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -tools -dir - -configure -file - - - - -2008-04-06T23:16:25.918131Z -884cd860375b503cfb2493f0fce9d92f -2008-02-26T13:38:31.975429Z -863 -pi3 -has-props - -include -dir - -README.FIRST -file - - - - -2008-04-06T23:16:25.928903Z -3c59dbc7a304397504db96895e84be99 -2005-10-02T22:30:24.000000Z -21 -thor - -doc -dir - -src -dir - -testsuite -dir - -Makefile -file - - - - -2008-04-06T23:16:25.940597Z -fbf138bbbea882d07bf27368c5e693a8 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/libasm/.svn/format eresi-0.0.20110516/libasm/.svn/format --- eresi-0.8a25/libasm/.svn/format 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/.svn/prop-base/configure.svn-base eresi-0.0.20110516/libasm/.svn/prop-base/configure.svn-base --- eresi-0.8a25/libasm/.svn/prop-base/configure.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/prop-base/configure.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libasm/.svn/text-base/configure.svn-base eresi-0.0.20110516/libasm/.svn/text-base/configure.svn-base --- eresi-0.8a25/libasm/.svn/text-base/configure.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/text-base/configure.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -#!/bin/sh -SRCS=$(ls src/arch/mips/handlers/*.c; ls src/arch/mips/operand_handlers/*.c; ls src/arch/ia32/handlers/*.c; ls src/arch/sparc/handlers/*.c; ls src/arch/sparc/operand_handlers/*.c; ls src/arch/ia32/operand_handlers/*.c) -echo -n "SRCS_hdl = " > Makefile.inc -FIRST="1" -for i in ${SRCS} ; do - if [ "$FIRST" = "1" ] ; then - FIRST="0" - echo -n " $i " >> Makefile.inc - else - echo -n "\\ - $i " >> Makefile.inc - fi -done diff -Nru eresi-0.8a25/libasm/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libasm/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libasm/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,115 +0,0 @@ -## -## $Id: Makefile,v 1.31 2008/01/01 17:07:26 heroine Exp $ -## Author : -## Started : Xxx Xxx xx xx:xx:xx 2002 -## Updated : Sun Mar 21 00:03:07 2004 -## - -#DBGFLAGS = -ggdb -DDEBUG_SPARC -include Makefile.inc -include ../config.h -# -# Architecture source files -# -SRCS_libasm = \ - src/generic.c \ - src/output.c \ - src/error.c \ - src/operand.c \ - src/instruction.c \ - src/register.c \ - src/build.c \ - src/vectors.c \ - src/arch/ia32/init_i386.c \ - src/arch/ia32/register.c \ - src/arch/ia32/tables_i386.c \ - src/arch/ia32/output_ia32.c \ - src/arch/ia32/operand_ia32.c \ - src/arch/sparc/init_sparc.c \ - src/arch/sparc/register.c \ - src/arch/sparc/tables_sparc.c \ - src/arch/sparc/output_sparc.c \ - src/arch/sparc/sparc_convert.c \ - src/arch/mips/init_mips.c \ - src/arch/mips/output_mips.c \ - src/arch/mips/tables_mips.c \ - src/arch/mips/mips_convert.c \ - src/arch/mips/register_mips.c - - - -OBJS_libasm = ${SRCS_libasm:.c=.o} -OBJS_libasm += ${SRCS_hdl:.c=.o} -NAME_libasm = libasm.a -NAME_libasm_o = libasm.o - -SRCS_sparc = tools/sparc_mydisasm.c -OBJS_sparc = ${SRCS_sparc:.c=.o} -NAME_sparc = test_sparc - -CFLAGS = -Iinclude -Isrc/include -Wall -g3 -fPIC -DERESI32 \ - -I../libaspect/include -#CFLAGS += -O2 -RM = rm -f -ETAGS = etags -CC ?= gcc -E -LD ?= ld -CP = cp - -all: libasm.so - - -install: - ${CP} ${NAME_libasm} /usr/lib - ${CP} include/libasm.h /usr/include - ${CP} include/libasm-i386.h /usr/include - ${CP} include/libasm-sparc.h /usr/include - -dep: - @sh configure - @rm -f src/build.o - -libasm.so: $(OBJS_libasm) - @ar rc ${NAME_libasm} ${OBJS_libasm} - @echo "[AR] ${NAME_libasm}" - @${RANLIB} ${NAME_libasm} - @echo "[RANLIB] ${NAME_libasm}" - @$(LD) -r $(OBJS_libasm) -o ${NAME_libasm_o} - @echo "[CC -shared] libasm.so" -ifeq ($(IRIX),1) - @$(LD) ${OBJS_libasm} -o libasm.so -shared -else - @$(CC) ${OBJS_libasm} -o libasm.so -shared -endif - -clean: - @$(RM) ${OBJS_libasm} ${OBJS_mydisasm} ${OBJS_cmpdump} Makefile.inc - @find . -name '*~' -exec rm -f {} \; - @find src -name '*.o' -exec rm -rf {} \; - -fclean: clean - @$(RM) ${NAME_libasm} ${NAME_libasm_o} ${NAME_mydisasm} ${NAME_cmpdump} - @$(RM) *.so *.o *.a - @$(RM) mydisasm - -tags: - @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c - @echo TAGS generated succesfully - -.c.o: - @$(CC) $(CFLAGS) ${DBGFLAGS} -c $*.c -o $*.o - @echo "[CC] $*.o" - -docs: - doxygen doc/doxygen.conf - -mydisasm: - $(CC) -g3 -I../libelfsh/include/ -I../libaspect/include/ -I./include/ \ - tools/mydisasm.c -DERESI32 -o ./mydisasm -L ../libelfsh/ -lelfsh32 \ - -L../libaspect/ -laspect32 -L./ -lasm -L../libetrace/ -letrace32 - -test: - (cd testsuite/ia32 && ${SHELL} launch_test.sh) - -Makefile.inc: - $(SHELL) configure diff -Nru eresi-0.8a25/libasm/.svn/text-base/README.FIRST.svn-base eresi-0.0.20110516/libasm/.svn/text-base/README.FIRST.svn-base --- eresi-0.8a25/libasm/.svn/text-base/README.FIRST.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/.svn/text-base/README.FIRST.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ - -The release is WORK IN PROGRESS - -This is the version first public release of -libasm in source code. The source is not -perfect and we know about it. However it is -better than a closed source library. - --- The ELF shell crew - diff -Nru eresi-0.8a25/libasm/testsuite/api/Makefile eresi-0.0.20110516/libasm/testsuite/api/Makefile --- eresi-0.8a25/libasm/testsuite/api/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/api/Makefile 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,11 @@ +SRCS = test_instr_name.c + +CONFIG_SCRIPT=$(HOME)/devhell/eresi.trunk/eresi-config + +CFLAGS = $(shell $(CONFIG_SCRIPT) libasm --defines --cflags) +LDFLAGS = $(shell $(CONFIG_SCRIPT) libasm --libs) + +OBJS = $(SRCS:.c=.o) + +all: $(OBJS) + $(foreach obj, $(OBJS), cc -o $(obj:.o=.out) $(obj) $(LDFLAGS)) \ No newline at end of file diff -Nru eresi-0.8a25/libasm/testsuite/api/test_instr_name.c eresi-0.0.20110516/libasm/testsuite/api/test_instr_name.c --- eresi-0.8a25/libasm/testsuite/api/test_instr_name.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/api/test_instr_name.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,45 @@ + + +#include +#include + +void test_sparc(); +void test_ia32(); +void test_mips(); +void test_arm(); + +int main() +{ + test_sparc(); + test_mips(); + test_ia32(); + test_arm(); +} + +void test_sparc() +{ + asm_processor proc; + + asm_init_arch(&proc, ASM_PROC_SPARC); +} + +void test_mips() +{ + asm_processor proc; + + asm_init_arch(&proc, ASM_PROC_MIPS); +} + +void test_ia32() +{ + asm_processor proc; + + asm_init_arch(&proc, ASM_PROC_IA32); +} + +void test_arm() +{ + asm_processor proc; + + asm_init_arch(&proc, ASM_PROC_ARM); +} diff -Nru eresi-0.8a25/libasm/testsuite/arm/build.sh eresi-0.0.20110516/libasm/testsuite/arm/build.sh --- eresi-0.8a25/libasm/testsuite/arm/build.sh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/arm/build.sh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,3 @@ +for i in *.s; do + arm-elf-as $i -o ${i/.s/.obj} +done diff -Nru eresi-0.8a25/libasm/testsuite/arm/disasm.esh eresi-0.0.20110516/libasm/testsuite/arm/disasm.esh --- eresi-0.8a25/libasm/testsuite/arm/disasm.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/arm/disasm.esh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,5 @@ +#!../../../elfsh/elfsh32 +nocolor +load $1 +disasm test + diff -Nru eresi-0.8a25/libasm/testsuite/arm/sanity_big.s eresi-0.0.20110516/libasm/testsuite/arm/sanity_big.s --- eresi-0.8a25/libasm/testsuite/arm/sanity_big.s 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/arm/sanity_big.s 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,2615 @@ + .text + .arm + + .section test, "ax" + /* Data processing */ + /* AND */ + /* .. condition codes */ + andeq r0, r1, r2 + andne r0, r1, r2 + andcs r0, r1, r2 + andcc r0, r1, r2 + andmi r0, r1, r2 + andpl r0, r1, r2 + andvs r0, r1, r2 + andvc r0, r1, r2 + andhi r0, r1, r2 + andls r0, r1, r2 + andge r0, r1, r2 + andlt r0, r1, r2 + andgt r0, r1, r2 + andle r0, r1, r2 + and r0, r1, r2 + nop + /* .. write flags */ + andeqs r0, r1, r2 + andnes r0, r1, r2 + andcss r0, r1, r2 + andccs r0, r1, r2 + andmis r0, r1, r2 + andpls r0, r1, r2 + andvss r0, r1, r2 + andvcs r0, r1, r2 + andhis r0, r1, r2 + andlss r0, r1, r2 + andges r0, r1, r2 + andlts r0, r1, r2 + andgts r0, r1, r2 + andles r0, r1, r2 + ands r0, r1, r2 + nop + /* .. addressing modes */ + and r0, r1, #1 + and r0, r1, r2 + and r0, r1, r2, lsl #1 + and r0, r1, r2, lsl r3 + and r0, r1, r2, lsr #1 + and r0, r1, r2, lsr r3 + and r0, r1, r2, asr #1 + and r0, r1, r2, asr r3 + and r0, r1, r2, ror #1 + and r0, r1, r2, ror r3 + and r0, r1, r2, rrx + nop + /* .. write pc */ + and pc, r1, #1 + and pc, r1, r2 + and pc, r1, r2, lsl #1 + and pc, r1, r2, lsl r3 + and pc, r1, r2, lsr #1 + and pc, r1, r2, lsr r3 + and pc, r1, r2, asr #1 + and pc, r1, r2, asr r3 + and pc, r1, r2, ror #1 + and pc, r1, r2, ror r3 + and pc, r1, r2, rrx + + /* EOR */ + /* .. condition codes */ + eoreq r0, r1, r2 + eorne r0, r1, r2 + eorcs r0, r1, r2 + eorcc r0, r1, r2 + eormi r0, r1, r2 + eorpl r0, r1, r2 + eorvs r0, r1, r2 + eorvc r0, r1, r2 + eorhi r0, r1, r2 + eorls r0, r1, r2 + eorge r0, r1, r2 + eorlt r0, r1, r2 + eorgt r0, r1, r2 + eorle r0, r1, r2 + eor r0, r1, r2 + nop + /* .. write flags */ + eoreqs r0, r1, r2 + eornes r0, r1, r2 + eorcss r0, r1, r2 + eorccs r0, r1, r2 + eormis r0, r1, r2 + eorpls r0, r1, r2 + eorvss r0, r1, r2 + eorvcs r0, r1, r2 + eorhis r0, r1, r2 + eorlss r0, r1, r2 + eorges r0, r1, r2 + eorlts r0, r1, r2 + eorgts r0, r1, r2 + eorles r0, r1, r2 + eors r0, r1, r2 + nop + /* .. addressing modes */ + eor r0, r1, #1 + eor r0, r1, r2 + eor r0, r1, r2, lsl #1 + eor r0, r1, r2, lsl r3 + eor r0, r1, r2, lsr #1 + eor r0, r1, r2, lsr r3 + eor r0, r1, r2, asr #1 + eor r0, r1, r2, asr r3 + eor r0, r1, r2, ror #1 + eor r0, r1, r2, ror r3 + eor r0, r1, r2, rrx + nop + /* .. write pc */ + eor pc, r1, #1 + eor pc, r1, r2 + eor pc, r1, r2, lsl #1 + eor pc, r1, r2, lsl r3 + eor pc, r1, r2, lsr #1 + eor pc, r1, r2, lsr r3 + eor pc, r1, r2, asr #1 + eor pc, r1, r2, asr r3 + eor pc, r1, r2, ror #1 + eor pc, r1, r2, ror r3 + eor pc, r1, r2, rrx + + /* SUB */ + /* .. condition codes */ + subeq r0, r1, r2 + subne r0, r1, r2 + subcs r0, r1, r2 + subcc r0, r1, r2 + submi r0, r1, r2 + subpl r0, r1, r2 + subvs r0, r1, r2 + subvc r0, r1, r2 + subhi r0, r1, r2 + subls r0, r1, r2 + subge r0, r1, r2 + sublt r0, r1, r2 + subgt r0, r1, r2 + suble r0, r1, r2 + sub r0, r1, r2 + nop + /* .. write flags */ + subeqs r0, r1, r2 + subnes r0, r1, r2 + subcss r0, r1, r2 + subccs r0, r1, r2 + submis r0, r1, r2 + subpls r0, r1, r2 + subvss r0, r1, r2 + subvcs r0, r1, r2 + subhis r0, r1, r2 + sublss r0, r1, r2 + subges r0, r1, r2 + sublts r0, r1, r2 + subgts r0, r1, r2 + subles r0, r1, r2 + subs r0, r1, r2 + nop + /* .. addressing modes */ + sub r0, r1, #1 + sub r0, r1, r2 + sub r0, r1, r2, lsl #1 + sub r0, r1, r2, lsl r3 + sub r0, r1, r2, lsr #1 + sub r0, r1, r2, lsr r3 + sub r0, r1, r2, asr #1 + sub r0, r1, r2, asr r3 + sub r0, r1, r2, ror #1 + sub r0, r1, r2, ror r3 + sub r0, r1, r2, rrx + nop + /* .. write pc */ + sub pc, r1, #1 + sub pc, r1, r2 + sub pc, r1, r2, lsl #1 + sub pc, r1, r2, lsl r3 + sub pc, r1, r2, lsr #1 + sub pc, r1, r2, lsr r3 + sub pc, r1, r2, asr #1 + sub pc, r1, r2, asr r3 + sub pc, r1, r2, ror #1 + sub pc, r1, r2, ror r3 + sub pc, r1, r2, rrx + + /* RSB */ + /* .. condition codes */ + rsbeq r0, r1, r2 + rsbne r0, r1, r2 + rsbcs r0, r1, r2 + rsbcc r0, r1, r2 + rsbmi r0, r1, r2 + rsbpl r0, r1, r2 + rsbvs r0, r1, r2 + rsbvc r0, r1, r2 + rsbhi r0, r1, r2 + rsbls r0, r1, r2 + rsbge r0, r1, r2 + rsblt r0, r1, r2 + rsbgt r0, r1, r2 + rsble r0, r1, r2 + rsb r0, r1, r2 + nop + /* .. write flags */ + rsbeqs r0, r1, r2 + rsbnes r0, r1, r2 + rsbcss r0, r1, r2 + rsbccs r0, r1, r2 + rsbmis r0, r1, r2 + rsbpls r0, r1, r2 + rsbvss r0, r1, r2 + rsbvcs r0, r1, r2 + rsbhis r0, r1, r2 + rsblss r0, r1, r2 + rsbges r0, r1, r2 + rsblts r0, r1, r2 + rsbgts r0, r1, r2 + rsbles r0, r1, r2 + rsbs r0, r1, r2 + nop + /* .. addressing modes */ + rsb r0, r1, #1 + rsb r0, r1, r2 + rsb r0, r1, r2, lsl #1 + rsb r0, r1, r2, lsl r3 + rsb r0, r1, r2, lsr #1 + rsb r0, r1, r2, lsr r3 + rsb r0, r1, r2, asr #1 + rsb r0, r1, r2, asr r3 + rsb r0, r1, r2, ror #1 + rsb r0, r1, r2, ror r3 + rsb r0, r1, r2, rrx + nop + /* .. write pc */ + rsb pc, r1, #1 + rsb pc, r1, r2 + rsb pc, r1, r2, lsl #1 + rsb pc, r1, r2, lsl r3 + rsb pc, r1, r2, lsr #1 + rsb pc, r1, r2, lsr r3 + rsb pc, r1, r2, asr #1 + rsb pc, r1, r2, asr r3 + rsb pc, r1, r2, ror #1 + rsb pc, r1, r2, ror r3 + rsb pc, r1, r2, rrx + + /* ADD */ + /* .. condition codes */ + addeq r0, r1, r2 + addne r0, r1, r2 + addcs r0, r1, r2 + addcc r0, r1, r2 + addmi r0, r1, r2 + addpl r0, r1, r2 + addvs r0, r1, r2 + addvc r0, r1, r2 + addhi r0, r1, r2 + addls r0, r1, r2 + addge r0, r1, r2 + addlt r0, r1, r2 + addgt r0, r1, r2 + addle r0, r1, r2 + add r0, r1, r2 + nop + /* .. write flags */ + addeqs r0, r1, r2 + addnes r0, r1, r2 + addcss r0, r1, r2 + addccs r0, r1, r2 + addmis r0, r1, r2 + addpls r0, r1, r2 + addvss r0, r1, r2 + addvcs r0, r1, r2 + addhis r0, r1, r2 + addlss r0, r1, r2 + addges r0, r1, r2 + addlts r0, r1, r2 + addgts r0, r1, r2 + addles r0, r1, r2 + adds r0, r1, r2 + nop + /* .. addressing modes */ + add r0, r1, #1 + add r0, r1, r2 + add r0, r1, r2, lsl #1 + add r0, r1, r2, lsl r3 + add r0, r1, r2, lsr #1 + add r0, r1, r2, lsr r3 + add r0, r1, r2, asr #1 + add r0, r1, r2, asr r3 + add r0, r1, r2, ror #1 + add r0, r1, r2, ror r3 + add r0, r1, r2, rrx + nop + /* .. write pc */ + add pc, r1, #1 + add pc, r1, r2 + add pc, r1, r2, lsl #1 + add pc, r1, r2, lsl r3 + add pc, r1, r2, lsr #1 + add pc, r1, r2, lsr r3 + add pc, r1, r2, asr #1 + add pc, r1, r2, asr r3 + add pc, r1, r2, ror #1 + add pc, r1, r2, ror r3 + add pc, r1, r2, rrx + + /* ADC */ + /* .. condition codes */ + adceq r0, r1, r2 + adcne r0, r1, r2 + adccs r0, r1, r2 + adccc r0, r1, r2 + adcmi r0, r1, r2 + adcpl r0, r1, r2 + adcvs r0, r1, r2 + adcvc r0, r1, r2 + adchi r0, r1, r2 + adcls r0, r1, r2 + adcge r0, r1, r2 + adclt r0, r1, r2 + adcgt r0, r1, r2 + adcle r0, r1, r2 + adc r0, r1, r2 + nop + /* .. write flags */ + adceqs r0, r1, r2 + adcnes r0, r1, r2 + adccss r0, r1, r2 + adcccs r0, r1, r2 + adcmis r0, r1, r2 + adcpls r0, r1, r2 + adcvss r0, r1, r2 + adcvcs r0, r1, r2 + adchis r0, r1, r2 + adclss r0, r1, r2 + adcges r0, r1, r2 + adclts r0, r1, r2 + adcgts r0, r1, r2 + adcles r0, r1, r2 + adcs r0, r1, r2 + nop + /* .. addressing modes */ + adc r0, r1, #1 + adc r0, r1, r2 + adc r0, r1, r2, lsl #1 + adc r0, r1, r2, lsl r3 + adc r0, r1, r2, lsr #1 + adc r0, r1, r2, lsr r3 + adc r0, r1, r2, asr #1 + adc r0, r1, r2, asr r3 + adc r0, r1, r2, ror #1 + adc r0, r1, r2, ror r3 + adc r0, r1, r2, rrx + nop + /* .. write pc */ + adc pc, r1, #1 + adc pc, r1, r2 + adc pc, r1, r2, lsl #1 + adc pc, r1, r2, lsl r3 + adc pc, r1, r2, lsr #1 + adc pc, r1, r2, lsr r3 + adc pc, r1, r2, asr #1 + adc pc, r1, r2, asr r3 + adc pc, r1, r2, ror #1 + adc pc, r1, r2, ror r3 + adc pc, r1, r2, rrx + + /* SBC */ + /* .. condition codes */ + sbceq r0, r1, r2 + sbcne r0, r1, r2 + sbccs r0, r1, r2 + sbccc r0, r1, r2 + sbcmi r0, r1, r2 + sbcpl r0, r1, r2 + sbcvs r0, r1, r2 + sbcvc r0, r1, r2 + sbchi r0, r1, r2 + sbcls r0, r1, r2 + sbcge r0, r1, r2 + sbclt r0, r1, r2 + sbcgt r0, r1, r2 + sbcle r0, r1, r2 + sbc r0, r1, r2 + nop + /* .. write flags */ + sbceqs r0, r1, r2 + sbcnes r0, r1, r2 + sbccss r0, r1, r2 + sbcccs r0, r1, r2 + sbcmis r0, r1, r2 + sbcpls r0, r1, r2 + sbcvss r0, r1, r2 + sbcvcs r0, r1, r2 + sbchis r0, r1, r2 + sbclss r0, r1, r2 + sbcges r0, r1, r2 + sbclts r0, r1, r2 + sbcgts r0, r1, r2 + sbcles r0, r1, r2 + sbcs r0, r1, r2 + nop + /* .. addressing modes */ + sbc r0, r1, #1 + sbc r0, r1, r2 + sbc r0, r1, r2, lsl #1 + sbc r0, r1, r2, lsl r3 + sbc r0, r1, r2, lsr #1 + sbc r0, r1, r2, lsr r3 + sbc r0, r1, r2, asr #1 + sbc r0, r1, r2, asr r3 + sbc r0, r1, r2, ror #1 + sbc r0, r1, r2, ror r3 + sbc r0, r1, r2, rrx + nop + /* .. write pc */ + sbc pc, r1, #1 + sbc pc, r1, r2 + sbc pc, r1, r2, lsl #1 + sbc pc, r1, r2, lsl r3 + sbc pc, r1, r2, lsr #1 + sbc pc, r1, r2, lsr r3 + sbc pc, r1, r2, asr #1 + sbc pc, r1, r2, asr r3 + sbc pc, r1, r2, ror #1 + sbc pc, r1, r2, ror r3 + sbc pc, r1, r2, rrx + + /* RSC */ + /* .. condition codes */ + rsceq r0, r1, r2 + rscne r0, r1, r2 + rsccs r0, r1, r2 + rsccc r0, r1, r2 + rscmi r0, r1, r2 + rscpl r0, r1, r2 + rscvs r0, r1, r2 + rscvc r0, r1, r2 + rschi r0, r1, r2 + rscls r0, r1, r2 + rscge r0, r1, r2 + rsclt r0, r1, r2 + rscgt r0, r1, r2 + rscle r0, r1, r2 + rsc r0, r1, r2 + nop + /* .. write flags */ + rsceqs r0, r1, r2 + rscnes r0, r1, r2 + rsccss r0, r1, r2 + rscccs r0, r1, r2 + rscmis r0, r1, r2 + rscpls r0, r1, r2 + rscvss r0, r1, r2 + rscvcs r0, r1, r2 + rschis r0, r1, r2 + rsclss r0, r1, r2 + rscges r0, r1, r2 + rsclts r0, r1, r2 + rscgts r0, r1, r2 + rscles r0, r1, r2 + rscs r0, r1, r2 + nop + /* .. addressing modes */ + rsc r0, r1, #1 + rsc r0, r1, r2 + rsc r0, r1, r2, lsl #1 + rsc r0, r1, r2, lsl r3 + rsc r0, r1, r2, lsr #1 + rsc r0, r1, r2, lsr r3 + rsc r0, r1, r2, asr #1 + rsc r0, r1, r2, asr r3 + rsc r0, r1, r2, ror #1 + rsc r0, r1, r2, ror r3 + rsc r0, r1, r2, rrx + nop + /* .. write pc */ + rsc pc, r1, #1 + rsc pc, r1, r2 + rsc pc, r1, r2, lsl #1 + rsc pc, r1, r2, lsl r3 + rsc pc, r1, r2, lsr #1 + rsc pc, r1, r2, lsr r3 + rsc pc, r1, r2, asr #1 + rsc pc, r1, r2, asr r3 + rsc pc, r1, r2, ror #1 + rsc pc, r1, r2, ror r3 + rsc pc, r1, r2, rrx + + /* TST */ + /* .. condition codes */ + tsteq r0, r1 + tstne r0, r1 + tstcs r0, r1 + tstcc r0, r1 + tstmi r0, r1 + tstpl r0, r1 + tstvs r0, r1 + tstvc r0, r1 + tsthi r0, r1 + tstls r0, r1 + tstge r0, r1 + tstlt r0, r1 + tstgt r0, r1 + tstle r0, r1 + tst r0, r1 + nop + /* .. addressing modes */ + tst r0, #1 + tst r0, r1 + tst r0, r1, lsl #1 + tst r0, r1, lsl r2 + tst r0, r1, lsr #1 + tst r0, r1, lsr r2 + tst r0, r1, asr #1 + tst r0, r1, asr r2 + tst r0, r1, ror #1 + tst r0, r1, ror r2 + tst r0, r1, rrx + + /* TEQ */ + /* .. condition codes */ + teqeq r0, r1 + teqne r0, r1 + teqcs r0, r1 + teqcc r0, r1 + teqmi r0, r1 + teqpl r0, r1 + teqvs r0, r1 + teqvc r0, r1 + teqhi r0, r1 + teqls r0, r1 + teqge r0, r1 + teqlt r0, r1 + teqgt r0, r1 + teqle r0, r1 + teq r0, r1 + nop + /* .. addressing modes */ + teq r0, #1 + teq r0, r1 + teq r0, r1, lsl #1 + teq r0, r1, lsl r2 + teq r0, r1, lsr #1 + teq r0, r1, lsr r2 + teq r0, r1, asr #1 + teq r0, r1, asr r2 + teq r0, r1, ror #1 + teq r0, r1, ror r2 + teq r0, r1, rrx + + /* CMP */ + /* .. condition codes */ + cmpeq r0, r1 + cmpne r0, r1 + cmpcs r0, r1 + cmpcc r0, r1 + cmpmi r0, r1 + cmppl r0, r1 + cmpvs r0, r1 + cmpvc r0, r1 + cmphi r0, r1 + cmpls r0, r1 + cmpge r0, r1 + cmplt r0, r1 + cmpgt r0, r1 + cmple r0, r1 + cmp r0, r1 + nop + /* .. addressing modes */ + cmp r0, #1 + cmp r0, r1 + cmp r0, r1, lsl #1 + cmp r0, r1, lsl r2 + cmp r0, r1, lsr #1 + cmp r0, r1, lsr r2 + cmp r0, r1, asr #1 + cmp r0, r1, asr r2 + cmp r0, r1, ror #1 + cmp r0, r1, ror r2 + cmp r0, r1, rrx + + /* CMN */ + /* .. condition codes */ + cmneq r0, r1 + cmnne r0, r1 + cmncs r0, r1 + cmncc r0, r1 + cmnmi r0, r1 + cmnpl r0, r1 + cmnvs r0, r1 + cmnvc r0, r1 + cmnhi r0, r1 + cmnls r0, r1 + cmnge r0, r1 + cmnlt r0, r1 + cmngt r0, r1 + cmnle r0, r1 + cmn r0, r1 + nop + /* .. addressing modes */ + cmn r0, #1 + cmn r0, r1 + cmn r0, r1, lsl #1 + cmn r0, r1, lsl r2 + cmn r0, r1, lsr #1 + cmn r0, r1, lsr r2 + cmn r0, r1, asr #1 + cmn r0, r1, asr r2 + cmn r0, r1, ror #1 + cmn r0, r1, ror r2 + cmn r0, r1, rrx + + /* ORR */ + /* .. condition codes */ + orreq r0, r1, r2 + orrne r0, r1, r2 + orrcs r0, r1, r2 + orrcc r0, r1, r2 + orrmi r0, r1, r2 + orrpl r0, r1, r2 + orrvs r0, r1, r2 + orrvc r0, r1, r2 + orrhi r0, r1, r2 + orrls r0, r1, r2 + orrge r0, r1, r2 + orrlt r0, r1, r2 + orrgt r0, r1, r2 + orrle r0, r1, r2 + orr r0, r1, r2 + nop + /* .. write flags */ + orreqs r0, r1, r2 + orrnes r0, r1, r2 + orrcss r0, r1, r2 + orrccs r0, r1, r2 + orrmis r0, r1, r2 + orrpls r0, r1, r2 + orrvss r0, r1, r2 + orrvcs r0, r1, r2 + orrhis r0, r1, r2 + orrlss r0, r1, r2 + orrges r0, r1, r2 + orrlts r0, r1, r2 + orrgts r0, r1, r2 + orrles r0, r1, r2 + orrs r0, r1, r2 + nop + /* .. addressing modes */ + orr r0, r1, #1 + orr r0, r1, r2 + orr r0, r1, r2, lsl #1 + orr r0, r1, r2, lsl r3 + orr r0, r1, r2, lsr #1 + orr r0, r1, r2, lsr r3 + orr r0, r1, r2, asr #1 + orr r0, r1, r2, asr r3 + orr r0, r1, r2, ror #1 + orr r0, r1, r2, ror r3 + orr r0, r1, r2, rrx + nop + /* .. write pc */ + orr pc, r1, #1 + orr pc, r1, r2 + orr pc, r1, r2, lsl #1 + orr pc, r1, r2, lsl r3 + orr pc, r1, r2, lsr #1 + orr pc, r1, r2, lsr r3 + orr pc, r1, r2, asr #1 + orr pc, r1, r2, asr r3 + orr pc, r1, r2, ror #1 + orr pc, r1, r2, ror r3 + orr pc, r1, r2, rrx + + /* MOV */ + /* .. condition codes */ + moveq r0, r1 + movne r0, r1 + movcs r0, r1 + movcc r0, r1 + movmi r0, r1 + movpl r0, r1 + movvs r0, r1 + movvc r0, r1 + movhi r0, r1 + movls r0, r1 + movge r0, r1 + movlt r0, r1 + movgt r0, r1 + movle r0, r1 + mov r0, r1 + nop + /* .. write flags */ + moveqs r0, r1 + movnes r0, r1 + movcss r0, r1 + movccs r0, r1 + movmis r0, r1 + movpls r0, r1 + movvss r0, r1 + movvcs r0, r1 + movhis r0, r1 + movlss r0, r1 + movges r0, r1 + movlts r0, r1 + movgts r0, r1 + movles r0, r1 + movs r0, r1 + nop + /* .. addressing modes */ + mov r0, #1 + mov r0, r1 + mov r0, r1, lsl #1 + mov r0, r1, lsl r2 + mov r0, r1, lsr #1 + mov r0, r1, lsr r2 + mov r0, r1, asr #1 + mov r0, r1, asr r2 + mov r0, r1, ror #1 + mov r0, r1, ror r2 + mov r0, r1, rrx + nop + /* .. write pc */ + mov pc, #1 + mov pc, r1 + mov pc, r1, lsl #1 + mov pc, r1, lsl r2 + mov pc, r1, lsr #1 + mov pc, r1, lsr r2 + mov pc, r1, asr #1 + mov pc, r1, asr r2 + mov pc, r1, ror #1 + mov pc, r1, ror r2 + mov pc, r1, rrx + + /* BIC */ + /* .. condition codes */ + biceq r0, r1, r2 + bicne r0, r1, r2 + biccs r0, r1, r2 + biccc r0, r1, r2 + bicmi r0, r1, r2 + bicpl r0, r1, r2 + bicvs r0, r1, r2 + bicvc r0, r1, r2 + bichi r0, r1, r2 + bicls r0, r1, r2 + bicge r0, r1, r2 + biclt r0, r1, r2 + bicgt r0, r1, r2 + bicle r0, r1, r2 + bic r0, r1, r2 + nop + /* .. write flags */ + biceqs r0, r1, r2 + bicnes r0, r1, r2 + biccss r0, r1, r2 + bicccs r0, r1, r2 + bicmis r0, r1, r2 + bicpls r0, r1, r2 + bicvss r0, r1, r2 + bicvcs r0, r1, r2 + bichis r0, r1, r2 + biclss r0, r1, r2 + bicges r0, r1, r2 + biclts r0, r1, r2 + bicgts r0, r1, r2 + bicles r0, r1, r2 + bics r0, r1, r2 + nop + /* .. addressing modes */ + bic r0, r1, #1 + bic r0, r1, r2 + bic r0, r1, r2, lsl #1 + bic r0, r1, r2, lsl r3 + bic r0, r1, r2, lsr #1 + bic r0, r1, r2, lsr r3 + bic r0, r1, r2, asr #1 + bic r0, r1, r2, asr r3 + bic r0, r1, r2, ror #1 + bic r0, r1, r2, ror r3 + bic r0, r1, r2, rrx + nop + /* .. write pc */ + bic pc, r1, #1 + bic pc, r1, r2 + bic pc, r1, r2, lsl #1 + bic pc, r1, r2, lsl r3 + bic pc, r1, r2, lsr #1 + bic pc, r1, r2, lsr r3 + bic pc, r1, r2, asr #1 + bic pc, r1, r2, asr r3 + bic pc, r1, r2, ror #1 + bic pc, r1, r2, ror r3 + bic pc, r1, r2, rrx + + /* MVN */ + /* .. condition codes */ + mvneq r0, r1 + mvnne r0, r1 + mvncs r0, r1 + mvncc r0, r1 + mvnmi r0, r1 + mvnpl r0, r1 + mvnvs r0, r1 + mvnvc r0, r1 + mvnhi r0, r1 + mvnls r0, r1 + mvnge r0, r1 + mvnlt r0, r1 + mvngt r0, r1 + mvnle r0, r1 + mvn r0, r1 + nop + /* .. write flags */ + mvneqs r0, r1 + mvnnes r0, r1 + mvncss r0, r1 + mvnccs r0, r1 + mvnmis r0, r1 + mvnpls r0, r1 + mvnvss r0, r1 + mvnvcs r0, r1 + mvnhis r0, r1 + mvnlss r0, r1 + mvnges r0, r1 + mvnlts r0, r1 + mvngts r0, r1 + mvnles r0, r1 + mvns r0, r1 + nop + /* .. addressing modes */ + mvn r0, #1 + mvn r0, r1 + mvn r0, r1, lsl #1 + mvn r0, r1, lsl r2 + mvn r0, r1, lsr #1 + mvn r0, r1, lsr r2 + mvn r0, r1, asr #1 + mvn r0, r1, asr r2 + mvn r0, r1, ror #1 + mvn r0, r1, ror r2 + mvn r0, r1, rrx + nop + /* .. write pc */ + mvn pc, #1 + mvn pc, r1 + mvn pc, r1, lsl #1 + mvn pc, r1, lsl r2 + mvn pc, r1, lsr #1 + mvn pc, r1, lsr r2 + mvn pc, r1, asr #1 + mvn pc, r1, asr r2 + mvn pc, r1, ror #1 + mvn pc, r1, ror r2 + mvn pc, r1, rrx + + /* Branch */ + /* B */ + /* .. condition codes */ + beq . + bne . + bcs . + bcc . + bmi . + bpl . + bvs . + bvc . + bhi . + bls . + bge . + blt . + bgt . + ble . + b . + + /* BL */ + /* .. condition codes */ + bleq . + blne . + blcs . + blcc . + blmi . + blpl . + blvs . + blvc . + blhi . + blls . + blge . + bllt . + blgt . + blle . + bl . + + /* BLX(1) */ + blx . + + /* BLX(2) */ + /* .. condition codes */ + blxeq r0 + blxne r0 + blxcs r0 + blxcc r0 + blxmi r0 + blxpl r0 + blxvs r0 + blxvc r0 + blxhi r0 + blxls r0 + blxge r0 + blxlt r0 + blxgt r0 + blxle r0 + blx r0 + + /* BX */ + /* .. condition codes */ + bxeq r0 + bxne r0 + bxcs r0 + bxcc r0 + bxmi r0 + bxpl r0 + bxvs r0 + bxvc r0 + bxhi r0 + bxls r0 + bxge r0 + bxlt r0 + bxgt r0 + bxle r0 + bx r0 + nop + /* .. use LR */ + bxeq lr + bxne lr + bxcs lr + bxcc lr + bxmi lr + bxpl lr + bxvs lr + bxvc lr + bxhi lr + bxls lr + bxge lr + bxlt lr + bxgt lr + bxle lr + bx lr + + /* Interrupt */ + /* BKPT */ + bkpt 0 + + /* SWI */ + /* .. condition codes */ + swieq 0 + swine 0 + swics 0 + swicc 0 + swimi 0 + swipl 0 + swivs 0 + swivc 0 + swihi 0 + swils 0 + swige 0 + swilt 0 + swigt 0 + swile 0 + swi 0 + + /* Load/Store */ + /* LDM(1) */ + /* .. condition codes */ + ldmeqia r0, {r1, r2, r3} + ldmneia r0, {r1, r2, r3} + ldmcsia r0, {r1, r2, r3} + ldmccia r0, {r1, r2, r3} + ldmmiia r0, {r1, r2, r3} + ldmplia r0, {r1, r2, r3} + ldmvsia r0, {r1, r2, r3} + ldmvcia r0, {r1, r2, r3} + ldmhiia r0, {r1, r2, r3} + ldmlsia r0, {r1, r2, r3} + ldmgeia r0, {r1, r2, r3} + ldmltia r0, {r1, r2, r3} + ldmgtia r0, {r1, r2, r3} + ldmleia r0, {r1, r2, r3} + ldmia r0, {r1, r2, r3} + nop + /* .. addressing modes */ + ldmeqib r0, {r1, r2, r3} + ldmneib r0, {r1, r2, r3} + ldmcsib r0, {r1, r2, r3} + ldmccib r0, {r1, r2, r3} + ldmmiib r0, {r1, r2, r3} + ldmplib r0, {r1, r2, r3} + ldmvsib r0, {r1, r2, r3} + ldmvcib r0, {r1, r2, r3} + ldmhiib r0, {r1, r2, r3} + ldmlsib r0, {r1, r2, r3} + ldmgeib r0, {r1, r2, r3} + ldmltib r0, {r1, r2, r3} + ldmgtib r0, {r1, r2, r3} + ldmleib r0, {r1, r2, r3} + ldmib r0, {r1, r2, r3} + ldmeqda r0, {r1, r2, r3} + ldmneda r0, {r1, r2, r3} + ldmcsda r0, {r1, r2, r3} + ldmccda r0, {r1, r2, r3} + ldmmida r0, {r1, r2, r3} + ldmplda r0, {r1, r2, r3} + ldmvsda r0, {r1, r2, r3} + ldmvcda r0, {r1, r2, r3} + ldmhida r0, {r1, r2, r3} + ldmlsda r0, {r1, r2, r3} + ldmgeda r0, {r1, r2, r3} + ldmltda r0, {r1, r2, r3} + ldmgtda r0, {r1, r2, r3} + ldmleda r0, {r1, r2, r3} + ldmda r0, {r1, r2, r3} + ldmeqdb r0, {r1, r2, r3} + ldmnedb r0, {r1, r2, r3} + ldmcsdb r0, {r1, r2, r3} + ldmccdb r0, {r1, r2, r3} + ldmmidb r0, {r1, r2, r3} + ldmpldb r0, {r1, r2, r3} + ldmvsdb r0, {r1, r2, r3} + ldmvcdb r0, {r1, r2, r3} + ldmhidb r0, {r1, r2, r3} + ldmlsdb r0, {r1, r2, r3} + ldmgedb r0, {r1, r2, r3} + ldmltdb r0, {r1, r2, r3} + ldmgtdb r0, {r1, r2, r3} + ldmledb r0, {r1, r2, r3} + ldmdb r0, {r1, r2, r3} + nop + /* .. writeback */ + ldmia r0!, {r1, r2, r3} + nop + /* .. touch sp */ + ldmia sp!, {r1, r2, r3} + pop {r1, r2, r3} + nop + /* .. touch pc */ + ldmia sp!, {r1, r2, pc} + nop + /* LDM(2) */ + ldmia r0, {r1, r2, r3}^ + nop + /* LDM(3) */ + ldmia r0, {r1, r2, pc}^ + + /* LDR */ + /* .. condition codes */ + ldreq r0, [r1] + ldrne r0, [r1] + ldrcs r0, [r1] + ldrcc r0, [r1] + ldrmi r0, [r1] + ldrpl r0, [r1] + ldrvs r0, [r1] + ldrvc r0, [r1] + ldrhi r0, [r1] + ldrls r0, [r1] + ldrge r0, [r1] + ldrlt r0, [r1] + ldrgt r0, [r1] + ldrle r0, [r1] + ldr r0, [r1] + nop + /* .. addressing modes */ + ldr r0, [r1] + ldr r0, [r1, #4] + ldr r0, [r1, #-4] + ldr r0, [r1, r2] + ldr r0, [r1, -r2] + ldr r0, [r1, r2, lsl #2] + ldr r0, [r1, -r2, lsl #2] + ldr r0, [r1, r2, lsr #2] + ldr r0, [r1, -r2, lsr #2] + ldr r0, [r1, r2, asr #2] + ldr r0, [r1, -r2, asr #2] + ldr r0, [r1, r2, ror #2] + ldr r0, [r1, -r2, ror #2] + ldr r0, [r1, r2, rrx] + ldr r0, [r1, -r2, rrx] + ldr r0, [r1]! + ldr r0, [r1, #4]! + ldr r0, [r1, #-4]! + ldr r0, [r1, r2]! + ldr r0, [r1, -r2]! + ldr r0, [r1, r2, lsl #2]! + ldr r0, [r1, -r2, lsl #2]! + ldr r0, [r1, r2, lsr #2]! + ldr r0, [r1, -r2, lsr #2]! + ldr r0, [r1, r2, asr #2]! + ldr r0, [r1, -r2, asr #2]! + ldr r0, [r1, r2, ror #2]! + ldr r0, [r1, -r2, ror #2]! + ldr r0, [r1, r2, rrx]! + ldr r0, [r1, -r2, rrx]! + ldr r0, [r1], #4 + ldr r0, [r1], #-4 + ldr r0, [r1], r2 + ldr r0, [r1], -r2 + ldr r0, [r1], r2, lsl #2 + ldr r0, [r1], -r2, lsl #2 + ldr r0, [r1], r2, lsr #2 + ldr r0, [r1], -r2, lsr #2 + ldr r0, [r1], r2, asr #2 + ldr r0, [r1], -r2, asr #2 + ldr r0, [r1], r2, ror #2 + ldr r0, [r1], -r2, ror #2 + ldr r0, [r1], r2, rrx + ldr r0, [r1], -r2, rrx + nop + /* .. write PC */ + ldr pc, [r1] + ldr pc, [r1, #4] + ldr pc, [r1, #-4] + ldr pc, [r1, r2] + ldr pc, [r1, -r2] + ldr pc, [r1, r2, lsl #2] + ldr pc, [r1, -r2, lsl #2] + ldr pc, [r1, r2, lsr #2] + ldr pc, [r1, -r2, lsr #2] + ldr pc, [r1, r2, asr #2] + ldr pc, [r1, -r2, asr #2] + ldr pc, [r1, r2, ror #2] + ldr pc, [r1, -r2, ror #2] + ldr pc, [r1, r2, rrx] + ldr pc, [r1, -r2, rrx] + ldr pc, [r1]! + ldr pc, [r1, #4]! + ldr pc, [r1, #-4]! + ldr pc, [r1, r2]! + ldr pc, [r1, -r2]! + ldr pc, [r1, r2, lsl #2]! + ldr pc, [r1, -r2, lsl #2]! + ldr pc, [r1, r2, lsr #2]! + ldr pc, [r1, -r2, lsr #2]! + ldr pc, [r1, r2, asr #2]! + ldr pc, [r1, -r2, asr #2]! + ldr pc, [r1, r2, ror #2]! + ldr pc, [r1, -r2, ror #2]! + ldr pc, [r1, r2, rrx]! + ldr pc, [r1, -r2, rrx]! + ldr pc, [r1], #4 + ldr pc, [r1], #-4 + ldr pc, [r1], r2 + ldr pc, [r1], -r2 + ldr pc, [r1], r2, lsl #2 + ldr pc, [r1], -r2, lsl #2 + ldr pc, [r1], r2, lsr #2 + ldr pc, [r1], -r2, lsr #2 + ldr pc, [r1], r2, asr #2 + ldr pc, [r1], -r2, asr #2 + ldr pc, [r1], r2, ror #2 + ldr pc, [r1], -r2, ror #2 + ldr pc, [r1], r2, rrx + ldr pc, [r1], -r2, rrx + + /* LDRB */ + /* .. condition codes */ + ldreqb r0, [r1] + ldrneb r0, [r1] + ldrcsb r0, [r1] + ldrccb r0, [r1] + ldrmib r0, [r1] + ldrplb r0, [r1] + ldrvsb r0, [r1] + ldrvcb r0, [r1] + ldrhib r0, [r1] + ldrlsb r0, [r1] + ldrgeb r0, [r1] + ldrltb r0, [r1] + ldrgtb r0, [r1] + ldrleb r0, [r1] + ldrb r0, [r1] + nop + /* .. addressing modes */ + ldrb r0, [r1] + ldrb r0, [r1, #4] + ldrb r0, [r1, #-4] + ldrb r0, [r1, r2] + ldrb r0, [r1, -r2] + ldrb r0, [r1, r2, lsl #2] + ldrb r0, [r1, -r2, lsl #2] + ldrb r0, [r1, r2, lsr #2] + ldrb r0, [r1, -r2, lsr #2] + ldrb r0, [r1, r2, asr #2] + ldrb r0, [r1, -r2, asr #2] + ldrb r0, [r1, r2, ror #2] + ldrb r0, [r1, -r2, ror #2] + ldrb r0, [r1, r2, rrx] + ldrb r0, [r1, -r2, rrx] + ldrb r0, [r1]! + ldrb r0, [r1, #4]! + ldrb r0, [r1, #-4]! + ldrb r0, [r1, r2]! + ldrb r0, [r1, -r2]! + ldrb r0, [r1, r2, lsl #2]! + ldrb r0, [r1, -r2, lsl #2]! + ldrb r0, [r1, r2, lsr #2]! + ldrb r0, [r1, -r2, lsr #2]! + ldrb r0, [r1, r2, asr #2]! + ldrb r0, [r1, -r2, asr #2]! + ldrb r0, [r1, r2, ror #2]! + ldrb r0, [r1, -r2, ror #2]! + ldrb r0, [r1, r2, rrx]! + ldrb r0, [r1, -r2, rrx]! + ldrb r0, [r1], #4 + ldrb r0, [r1], #-4 + ldrb r0, [r1], r2 + ldrb r0, [r1], -r2 + ldrb r0, [r1], r2, lsl #2 + ldrb r0, [r1], -r2, lsl #2 + ldrb r0, [r1], r2, lsr #2 + ldrb r0, [r1], -r2, lsr #2 + ldrb r0, [r1], r2, asr #2 + ldrb r0, [r1], -r2, asr #2 + ldrb r0, [r1], r2, ror #2 + ldrb r0, [r1], -r2, ror #2 + ldrb r0, [r1], r2, rrx + ldrb r0, [r1], -r2, rrx + + /* LDRBT */ + /* .. condition codes */ + ldreqbt r0, [r1] + ldrnebt r0, [r1] + ldrcsbt r0, [r1] + ldrccbt r0, [r1] + ldrmibt r0, [r1] + ldrplbt r0, [r1] + ldrvsbt r0, [r1] + ldrvcbt r0, [r1] + ldrhibt r0, [r1] + ldrlsbt r0, [r1] + ldrgebt r0, [r1] + ldrltbt r0, [r1] + ldrgtbt r0, [r1] + ldrlebt r0, [r1] + ldrbt r0, [r1] + nop + /* .. addressing modes */ + ldrbt r0, [r1] + ldrbt r0, [r1], #4 + ldrbt r0, [r1], #-4 + ldrbt r0, [r1], r2 + ldrbt r0, [r1], -r2 + ldrbt r0, [r1], r2, lsl #2 + ldrbt r0, [r1], -r2, lsl #2 + ldrbt r0, [r1], r2, lsr #2 + ldrbt r0, [r1], -r2, lsr #2 + ldrbt r0, [r1], r2, asr #2 + ldrbt r0, [r1], -r2, asr #2 + ldrbt r0, [r1], r2, ror #2 + ldrbt r0, [r1], -r2, ror #2 + ldrbt r0, [r1], r2, rrx + ldrbt r0, [r1], -r2, rrx + + /* LDRH */ + /* .. condition codes */ + ldreqh r0, [r1] + ldrneh r0, [r1] + ldrcsh r0, [r1] + ldrcch r0, [r1] + ldrmih r0, [r1] + ldrplh r0, [r1] + ldrvsh r0, [r1] + ldrvch r0, [r1] + ldrhih r0, [r1] + ldrlsh r0, [r1] + ldrgeh r0, [r1] + ldrlth r0, [r1] + ldrgth r0, [r1] + ldrleh r0, [r1] + ldrh r0, [r1] + nop + /* .. addressing modes */ + ldrh r0, [r1] + ldrh r0, [r1, #4] + ldrh r0, [r1, #-4] + ldrh r0, [r1, r2] + ldrh r0, [r1, -r2] + ldrh r0, [r1]! + ldrh r0, [r1, #4]! + ldrh r0, [r1, #-4]! + ldrh r0, [r1, r2]! + ldrh r0, [r1, -r2]! + ldrh r0, [r1], #4 + ldrh r0, [r1], #-4 + ldrh r0, [r1], r2 + ldrh r0, [r1], -r2 + + /* LDRSB */ + /* .. condition codes */ + ldreqsb r0, [r1] + ldrnesb r0, [r1] + ldrcssb r0, [r1] + ldrccsb r0, [r1] + ldrmisb r0, [r1] + ldrplsb r0, [r1] + ldrvssb r0, [r1] + ldrvcsb r0, [r1] + ldrhisb r0, [r1] + ldrlssb r0, [r1] + ldrgesb r0, [r1] + ldrltsb r0, [r1] + ldrgtsb r0, [r1] + ldrlesb r0, [r1] + ldrsb r0, [r1] + nop + /* .. addressing modes */ + ldrsb r0, [r1] + ldrsb r0, [r1, #4] + ldrsb r0, [r1, #-4] + ldrsb r0, [r1, r2] + ldrsb r0, [r1, -r2] + ldrsb r0, [r1]! + ldrsb r0, [r1, #4]! + ldrsb r0, [r1, #-4]! + ldrsb r0, [r1, r2]! + ldrsb r0, [r1, -r2]! + ldrsb r0, [r1], #4 + ldrsb r0, [r1], #-4 + ldrsb r0, [r1], r2 + ldrsb r0, [r1], -r2 + + /* LDRSH */ + /* .. condition codes */ + ldreqsh r0, [r1] + ldrnesh r0, [r1] + ldrcssh r0, [r1] + ldrccsh r0, [r1] + ldrmish r0, [r1] + ldrplsh r0, [r1] + ldrvssh r0, [r1] + ldrvcsh r0, [r1] + ldrhish r0, [r1] + ldrlssh r0, [r1] + ldrgesh r0, [r1] + ldrltsh r0, [r1] + ldrgtsh r0, [r1] + ldrlesh r0, [r1] + ldrsh r0, [r1] + nop + /* .. addressing modes */ + ldrsh r0, [r1] + ldrsh r0, [r1, #4] + ldrsh r0, [r1, #-4] + ldrsh r0, [r1, r2] + ldrsh r0, [r1, -r2] + ldrsh r0, [r1]! + ldrsh r0, [r1, #4]! + ldrsh r0, [r1, #-4]! + ldrsh r0, [r1, r2]! + ldrsh r0, [r1, -r2]! + ldrsh r0, [r1], #4 + ldrsh r0, [r1], #-4 + ldrsh r0, [r1], r2 + ldrsh r0, [r1], -r2 + + /* LDRT */ + /* .. condition codes */ + ldreqt r0, [r1] + ldrnet r0, [r1] + ldrcst r0, [r1] + ldrcct r0, [r1] + ldrmit r0, [r1] + ldrplt r0, [r1] + ldrvst r0, [r1] + ldrvct r0, [r1] + ldrhit r0, [r1] + ldrlst r0, [r1] + ldrget r0, [r1] + ldrltt r0, [r1] + ldrgtt r0, [r1] + ldrlet r0, [r1] + ldrt r0, [r1] + nop + /* .. addressing modes */ + ldrt r0, [r1] + ldrt r0, [r1], #4 + ldrt r0, [r1], #-4 + ldrt r0, [r1], r2 + ldrt r0, [r1], -r2 + ldrt r0, [r1], r2, lsl #2 + ldrt r0, [r1], -r2, lsl #2 + ldrt r0, [r1], r2, lsr #2 + ldrt r0, [r1], -r2, lsr #2 + ldrt r0, [r1], r2, asr #2 + ldrt r0, [r1], -r2, asr #2 + ldrt r0, [r1], r2, ror #2 + ldrt r0, [r1], -r2, ror #2 + ldrt r0, [r1], r2, rrx + ldrt r0, [r1], -r2, rrx + + /* STM(1) */ + /* .. condition codes */ + stmeqia r0, {r1, r2, r3} + stmneia r0, {r1, r2, r3} + stmcsia r0, {r1, r2, r3} + stmccia r0, {r1, r2, r3} + stmmiia r0, {r1, r2, r3} + stmplia r0, {r1, r2, r3} + stmvsia r0, {r1, r2, r3} + stmvcia r0, {r1, r2, r3} + stmhiia r0, {r1, r2, r3} + stmlsia r0, {r1, r2, r3} + stmgeia r0, {r1, r2, r3} + stmltia r0, {r1, r2, r3} + stmgtia r0, {r1, r2, r3} + stmleia r0, {r1, r2, r3} + stmia r0, {r1, r2, r3} + nop + /* .. addressing modes */ + stmeqib r0, {r1, r2, r3} + stmneib r0, {r1, r2, r3} + stmcsib r0, {r1, r2, r3} + stmccib r0, {r1, r2, r3} + stmmiib r0, {r1, r2, r3} + stmplib r0, {r1, r2, r3} + stmvsib r0, {r1, r2, r3} + stmvcib r0, {r1, r2, r3} + stmhiib r0, {r1, r2, r3} + stmlsib r0, {r1, r2, r3} + stmgeib r0, {r1, r2, r3} + stmltib r0, {r1, r2, r3} + stmgtib r0, {r1, r2, r3} + stmleib r0, {r1, r2, r3} + stmib r0, {r1, r2, r3} + stmeqda r0, {r1, r2, r3} + stmneda r0, {r1, r2, r3} + stmcsda r0, {r1, r2, r3} + stmccda r0, {r1, r2, r3} + stmmida r0, {r1, r2, r3} + stmplda r0, {r1, r2, r3} + stmvsda r0, {r1, r2, r3} + stmvcda r0, {r1, r2, r3} + stmhida r0, {r1, r2, r3} + stmlsda r0, {r1, r2, r3} + stmgeda r0, {r1, r2, r3} + stmltda r0, {r1, r2, r3} + stmgtda r0, {r1, r2, r3} + stmleda r0, {r1, r2, r3} + stmda r0, {r1, r2, r3} + stmeqdb r0, {r1, r2, r3} + stmnedb r0, {r1, r2, r3} + stmcsdb r0, {r1, r2, r3} + stmccdb r0, {r1, r2, r3} + stmmidb r0, {r1, r2, r3} + stmpldb r0, {r1, r2, r3} + stmvsdb r0, {r1, r2, r3} + stmvcdb r0, {r1, r2, r3} + stmhidb r0, {r1, r2, r3} + stmlsdb r0, {r1, r2, r3} + stmgedb r0, {r1, r2, r3} + stmltdb r0, {r1, r2, r3} + stmgtdb r0, {r1, r2, r3} + stmledb r0, {r1, r2, r3} + stmdb r0, {r1, r2, r3} + nop + /* .. writeback */ + stmia r0!, {r1, r2, r3} + nop + /* .. touch sp */ + stmdb sp!, {r1, r2, r3} + push {r1, r2, r3} + nop + /* STM(2) */ + stmdb r0, {r1, r2, r3}^ + + /* STR */ + /* .. condition codes */ + streq r0, [r1] + strne r0, [r1] + strcs r0, [r1] + strcc r0, [r1] + strmi r0, [r1] + strpl r0, [r1] + strvs r0, [r1] + strvc r0, [r1] + strhi r0, [r1] + strls r0, [r1] + strge r0, [r1] + strlt r0, [r1] + strgt r0, [r1] + strle r0, [r1] + str r0, [r1] + nop + /* .. addressing modes */ + str r0, [r1] + str r0, [r1, #4] + str r0, [r1, #-4] + str r0, [r1, r2] + str r0, [r1, -r2] + str r0, [r1, r2, lsl #2] + str r0, [r1, -r2, lsl #2] + str r0, [r1, r2, lsr #2] + str r0, [r1, -r2, lsr #2] + str r0, [r1, r2, asr #2] + str r0, [r1, -r2, asr #2] + str r0, [r1, r2, ror #2] + str r0, [r1, -r2, ror #2] + str r0, [r1, r2, rrx] + str r0, [r1, -r2, rrx] + str r0, [r1]! + str r0, [r1, #4]! + str r0, [r1, #-4]! + str r0, [r1, r2]! + str r0, [r1, -r2]! + str r0, [r1, r2, lsl #2]! + str r0, [r1, -r2, lsl #2]! + str r0, [r1, r2, lsr #2]! + str r0, [r1, -r2, lsr #2]! + str r0, [r1, r2, asr #2]! + str r0, [r1, -r2, asr #2]! + str r0, [r1, r2, ror #2]! + str r0, [r1, -r2, ror #2]! + str r0, [r1, r2, rrx]! + str r0, [r1, -r2, rrx]! + str r0, [r1], #4 + str r0, [r1], #-4 + str r0, [r1], r2 + str r0, [r1], -r2 + str r0, [r1], r2, lsl #2 + str r0, [r1], -r2, lsl #2 + str r0, [r1], r2, lsr #2 + str r0, [r1], -r2, lsr #2 + str r0, [r1], r2, asr #2 + str r0, [r1], -r2, asr #2 + str r0, [r1], r2, ror #2 + str r0, [r1], -r2, ror #2 + str r0, [r1], r2, rrx + str r0, [r1], -r2, rrx + + /* STRB */ + /* .. condition codes */ + streqb r0, [r1] + strneb r0, [r1] + strcsb r0, [r1] + strccb r0, [r1] + strmib r0, [r1] + strplb r0, [r1] + strvsb r0, [r1] + strvcb r0, [r1] + strhib r0, [r1] + strlsb r0, [r1] + strgeb r0, [r1] + strltb r0, [r1] + strgtb r0, [r1] + strleb r0, [r1] + strb r0, [r1] + nop + /* .. addressing modes */ + strb r0, [r1] + strb r0, [r1, #4] + strb r0, [r1, #-4] + strb r0, [r1, r2] + strb r0, [r1, -r2] + strb r0, [r1, r2, lsl #2] + strb r0, [r1, -r2, lsl #2] + strb r0, [r1, r2, lsr #2] + strb r0, [r1, -r2, lsr #2] + strb r0, [r1, r2, asr #2] + strb r0, [r1, -r2, asr #2] + strb r0, [r1, r2, ror #2] + strb r0, [r1, -r2, ror #2] + strb r0, [r1, r2, rrx] + strb r0, [r1, -r2, rrx] + strb r0, [r1]! + strb r0, [r1, #4]! + strb r0, [r1, #-4]! + strb r0, [r1, r2]! + strb r0, [r1, -r2]! + strb r0, [r1, r2, lsl #2]! + strb r0, [r1, -r2, lsl #2]! + strb r0, [r1, r2, lsr #2]! + strb r0, [r1, -r2, lsr #2]! + strb r0, [r1, r2, asr #2]! + strb r0, [r1, -r2, asr #2]! + strb r0, [r1, r2, ror #2]! + strb r0, [r1, -r2, ror #2]! + strb r0, [r1, r2, rrx]! + strb r0, [r1, -r2, rrx]! + strb r0, [r1], #4 + strb r0, [r1], #-4 + strb r0, [r1], r2 + strb r0, [r1], -r2 + strb r0, [r1], r2, lsl #2 + strb r0, [r1], -r2, lsl #2 + strb r0, [r1], r2, lsr #2 + strb r0, [r1], -r2, lsr #2 + strb r0, [r1], r2, asr #2 + strb r0, [r1], -r2, asr #2 + strb r0, [r1], r2, ror #2 + strb r0, [r1], -r2, ror #2 + strb r0, [r1], r2, rrx + strb r0, [r1], -r2, rrx + + /* STRBT */ + /* .. condition codes */ + streqbt r0, [r1] + strnebt r0, [r1] + strcsbt r0, [r1] + strccbt r0, [r1] + strmibt r0, [r1] + strplbt r0, [r1] + strvsbt r0, [r1] + strvcbt r0, [r1] + strhibt r0, [r1] + strlsbt r0, [r1] + strgebt r0, [r1] + strltbt r0, [r1] + strgtbt r0, [r1] + strlebt r0, [r1] + strbt r0, [r1] + nop + /* .. addressing modes */ + strbt r0, [r1] + strbt r0, [r1], #4 + strbt r0, [r1], #-4 + strbt r0, [r1], r2 + strbt r0, [r1], -r2 + strbt r0, [r1], r2, lsl #2 + strbt r0, [r1], -r2, lsl #2 + strbt r0, [r1], r2, lsr #2 + strbt r0, [r1], -r2, lsr #2 + strbt r0, [r1], r2, asr #2 + strbt r0, [r1], -r2, asr #2 + strbt r0, [r1], r2, ror #2 + strbt r0, [r1], -r2, ror #2 + strbt r0, [r1], r2, rrx + strbt r0, [r1], -r2, rrx + + /* STRH */ + /* .. condition codes */ + streqh r0, [r1] + strneh r0, [r1] + strcsh r0, [r1] + strcch r0, [r1] + strmih r0, [r1] + strplh r0, [r1] + strvsh r0, [r1] + strvch r0, [r1] + strhih r0, [r1] + strlsh r0, [r1] + strgeh r0, [r1] + strlth r0, [r1] + strgth r0, [r1] + strleh r0, [r1] + strh r0, [r1] + nop + /* .. addressing modes */ + strh r0, [r1] + strh r0, [r1, #4] + strh r0, [r1, #-4] + strh r0, [r1, r2] + strh r0, [r1, -r2] + strh r0, [r1]! + strh r0, [r1, #4]! + strh r0, [r1, #-4]! + strh r0, [r1, r2]! + strh r0, [r1, -r2]! + strh r0, [r1], #4 + strh r0, [r1], #-4 + strh r0, [r1], r2 + strh r0, [r1], -r2 + + /* STRT */ + /* .. condition codes */ + streqt r0, [r1] + strnet r0, [r1] + strcst r0, [r1] + strcct r0, [r1] + strmit r0, [r1] + strplt r0, [r1] + strvst r0, [r1] + strvct r0, [r1] + strhit r0, [r1] + strlst r0, [r1] + strget r0, [r1] + strltt r0, [r1] + strgtt r0, [r1] + strlet r0, [r1] + strt r0, [r1] + nop + /* .. addressing modes */ + strt r0, [r1] + strt r0, [r1], #4 + strt r0, [r1], #-4 + strt r0, [r1], r2 + strt r0, [r1], -r2 + strt r0, [r1], r2, lsl #2 + strt r0, [r1], -r2, lsl #2 + strt r0, [r1], r2, lsr #2 + strt r0, [r1], -r2, lsr #2 + strt r0, [r1], r2, asr #2 + strt r0, [r1], -r2, asr #2 + strt r0, [r1], r2, ror #2 + strt r0, [r1], -r2, ror #2 + strt r0, [r1], r2, rrx + strt r0, [r1], -r2, rrx + + /* Multiply */ + /* MLA */ + /* .. condition codes */ + mlaeq r0, r1, r2, r3 + mlane r0, r1, r2, r3 + mlacs r0, r1, r2, r3 + mlacc r0, r1, r2, r3 + mlami r0, r1, r2, r3 + mlapl r0, r1, r2, r3 + mlavs r0, r1, r2, r3 + mlavc r0, r1, r2, r3 + mlahi r0, r1, r2, r3 + mlals r0, r1, r2, r3 + mlage r0, r1, r2, r3 + mlalt r0, r1, r2, r3 + mlagt r0, r1, r2, r3 + mlale r0, r1, r2, r3 + mla r0, r1, r2, r3 + nop + /* .. write flags */ + mlaeqs r0, r1, r2, r3 + mlanes r0, r1, r2, r3 + mlacss r0, r1, r2, r3 + mlaccs r0, r1, r2, r3 + mlamis r0, r1, r2, r3 + mlapls r0, r1, r2, r3 + mlavss r0, r1, r2, r3 + mlavcs r0, r1, r2, r3 + mlahis r0, r1, r2, r3 + mlalss r0, r1, r2, r3 + mlages r0, r1, r2, r3 + mlalts r0, r1, r2, r3 + mlagts r0, r1, r2, r3 + mlales r0, r1, r2, r3 + mlas r0, r1, r2, r3 + + /* MUL */ + /* .. condition codes */ + muleq r0, r1, r2 + mulne r0, r1, r2 + mulcs r0, r1, r2 + mulcc r0, r1, r2 + mulmi r0, r1, r2 + mulpl r0, r1, r2 + mulvs r0, r1, r2 + mulvc r0, r1, r2 + mulhi r0, r1, r2 + mulls r0, r1, r2 + mulge r0, r1, r2 + mullt r0, r1, r2 + mulgt r0, r1, r2 + mulle r0, r1, r2 + mul r0, r1, r2 + nop + /* .. write flags */ + muleqs r0, r1, r2 + mulnes r0, r1, r2 + mulcss r0, r1, r2 + mulccs r0, r1, r2 + mulmis r0, r1, r2 + mulpls r0, r1, r2 + mulvss r0, r1, r2 + mulvcs r0, r1, r2 + mulhis r0, r1, r2 + mullss r0, r1, r2 + mulges r0, r1, r2 + mullts r0, r1, r2 + mulgts r0, r1, r2 + mulles r0, r1, r2 + muls r0, r1, r2 + + /* SMLAL */ + /* .. condition codes */ + smlaleq r0, r1, r2, r3 + smlalne r0, r1, r2, r3 + smlalcs r0, r1, r2, r3 + smlalcc r0, r1, r2, r3 + smlalmi r0, r1, r2, r3 + smlalpl r0, r1, r2, r3 + smlalvs r0, r1, r2, r3 + smlalvc r0, r1, r2, r3 + smlalhi r0, r1, r2, r3 + smlalls r0, r1, r2, r3 + smlalge r0, r1, r2, r3 + smlallt r0, r1, r2, r3 + smlalgt r0, r1, r2, r3 + smlalle r0, r1, r2, r3 + smlal r0, r1, r2, r3 + nop + /* .. write flags */ + smlaleqs r0, r1, r2, r3 + smlalnes r0, r1, r2, r3 + smlalcss r0, r1, r2, r3 + smlalccs r0, r1, r2, r3 + smlalmis r0, r1, r2, r3 + smlalpls r0, r1, r2, r3 + smlalvss r0, r1, r2, r3 + smlalvcs r0, r1, r2, r3 + smlalhis r0, r1, r2, r3 + smlallss r0, r1, r2, r3 + smlalges r0, r1, r2, r3 + smlallts r0, r1, r2, r3 + smlalgts r0, r1, r2, r3 + smlalles r0, r1, r2, r3 + smlals r0, r1, r2, r3 + + /* SMULL */ + /* .. condition codes */ + smulleq r0, r1, r2, r3 + smullne r0, r1, r2, r3 + smullcs r0, r1, r2, r3 + smullcc r0, r1, r2, r3 + smullmi r0, r1, r2, r3 + smullpl r0, r1, r2, r3 + smullvs r0, r1, r2, r3 + smullvc r0, r1, r2, r3 + smullhi r0, r1, r2, r3 + smullls r0, r1, r2, r3 + smullge r0, r1, r2, r3 + smulllt r0, r1, r2, r3 + smullgt r0, r1, r2, r3 + smullle r0, r1, r2, r3 + smull r0, r1, r2, r3 + nop + /* .. write flags */ + smulleqs r0, r1, r2, r3 + smullnes r0, r1, r2, r3 + smullcss r0, r1, r2, r3 + smullccs r0, r1, r2, r3 + smullmis r0, r1, r2, r3 + smullpls r0, r1, r2, r3 + smullvss r0, r1, r2, r3 + smullvcs r0, r1, r2, r3 + smullhis r0, r1, r2, r3 + smulllss r0, r1, r2, r3 + smullges r0, r1, r2, r3 + smulllts r0, r1, r2, r3 + smullgts r0, r1, r2, r3 + smullles r0, r1, r2, r3 + smulls r0, r1, r2, r3 + + /* UMLAL */ + /* .. condition codes */ + umlaleq r0, r1, r2, r3 + umlalne r0, r1, r2, r3 + umlalcs r0, r1, r2, r3 + umlalcc r0, r1, r2, r3 + umlalmi r0, r1, r2, r3 + umlalpl r0, r1, r2, r3 + umlalvs r0, r1, r2, r3 + umlalvc r0, r1, r2, r3 + umlalhi r0, r1, r2, r3 + umlalls r0, r1, r2, r3 + umlalge r0, r1, r2, r3 + umlallt r0, r1, r2, r3 + umlalgt r0, r1, r2, r3 + umlalle r0, r1, r2, r3 + umlal r0, r1, r2, r3 + nop + /* .. write flags */ + umlaleqs r0, r1, r2, r3 + umlalnes r0, r1, r2, r3 + umlalcss r0, r1, r2, r3 + umlalccs r0, r1, r2, r3 + umlalmis r0, r1, r2, r3 + umlalpls r0, r1, r2, r3 + umlalvss r0, r1, r2, r3 + umlalvcs r0, r1, r2, r3 + umlalhis r0, r1, r2, r3 + umlallss r0, r1, r2, r3 + umlalges r0, r1, r2, r3 + umlallts r0, r1, r2, r3 + umlalgts r0, r1, r2, r3 + umlalles r0, r1, r2, r3 + umlals r0, r1, r2, r3 + + /* UMULL */ + /* .. condition codes */ + umulleq r0, r1, r2, r3 + umullne r0, r1, r2, r3 + umullcs r0, r1, r2, r3 + umullcc r0, r1, r2, r3 + umullmi r0, r1, r2, r3 + umullpl r0, r1, r2, r3 + umullvs r0, r1, r2, r3 + umullvc r0, r1, r2, r3 + umullhi r0, r1, r2, r3 + umullls r0, r1, r2, r3 + umullge r0, r1, r2, r3 + umulllt r0, r1, r2, r3 + umullgt r0, r1, r2, r3 + umullle r0, r1, r2, r3 + umull r0, r1, r2, r3 + nop + /* .. write flags */ + umulleqs r0, r1, r2, r3 + umullnes r0, r1, r2, r3 + umullcss r0, r1, r2, r3 + umullccs r0, r1, r2, r3 + umullmis r0, r1, r2, r3 + umullpls r0, r1, r2, r3 + umullvss r0, r1, r2, r3 + umullvcs r0, r1, r2, r3 + umullhis r0, r1, r2, r3 + umulllss r0, r1, r2, r3 + umullges r0, r1, r2, r3 + umulllts r0, r1, r2, r3 + umullgts r0, r1, r2, r3 + umullles r0, r1, r2, r3 + umulls r0, r1, r2, r3 + + /* Coprocessor */ + /* CDP */ + /* .. condition codes */ + cdpeq p0, 0, cr0, cr1, cr2, 0 + cdpne p0, 0, cr0, cr1, cr2, 0 + cdpcs p0, 0, cr0, cr1, cr2, 0 + cdpcc p0, 0, cr0, cr1, cr2, 0 + cdpmi p0, 0, cr0, cr1, cr2, 0 + cdppl p0, 0, cr0, cr1, cr2, 0 + cdpvs p0, 0, cr0, cr1, cr2, 0 + cdpvc p0, 0, cr0, cr1, cr2, 0 + cdphi p0, 0, cr0, cr1, cr2, 0 + cdpls p0, 0, cr0, cr1, cr2, 0 + cdpge p0, 0, cr0, cr1, cr2, 0 + cdplt p0, 0, cr0, cr1, cr2, 0 + cdpgt p0, 0, cr0, cr1, cr2, 0 + cdple p0, 0, cr0, cr1, cr2, 0 + cdp p0, 0, cr0, cr1, cr2, 0 + cdp2 p0, 0, cr0, cr1, cr2, 0 + + /* MCR */ + /* .. condition codes */ + mcreq p0, 0, r0, cr0, cr1, 1 + mcrne p0, 0, r0, cr0, cr1, 1 + mcrcs p0, 0, r0, cr0, cr1, 1 + mcrcc p0, 0, r0, cr0, cr1, 1 + mcrmi p0, 0, r0, cr0, cr1, 1 + mcrpl p0, 0, r0, cr0, cr1, 1 + mcrvs p0, 0, r0, cr0, cr1, 1 + mcrvc p0, 0, r0, cr0, cr1, 1 + mcrhi p0, 0, r0, cr0, cr1, 1 + mcrls p0, 0, r0, cr0, cr1, 1 + mcrge p0, 0, r0, cr0, cr1, 1 + mcrlt p0, 0, r0, cr0, cr1, 1 + mcrgt p0, 0, r0, cr0, cr1, 1 + mcrle p0, 0, r0, cr0, cr1, 1 + mcr p0, 0, r0, cr0, cr1, 1 + mcr2 p0, 0, r0, cr0, cr1, 1 + + /* MRC */ + /* .. condition codes */ + mrceq p0, 0, r0, cr0, cr1, 1 + mrcne p0, 0, r0, cr0, cr1, 1 + mrccs p0, 0, r0, cr0, cr1, 1 + mrccc p0, 0, r0, cr0, cr1, 1 + mrcmi p0, 0, r0, cr0, cr1, 1 + mrcpl p0, 0, r0, cr0, cr1, 1 + mrcvs p0, 0, r0, cr0, cr1, 1 + mrcvc p0, 0, r0, cr0, cr1, 1 + mrchi p0, 0, r0, cr0, cr1, 1 + mrcls p0, 0, r0, cr0, cr1, 1 + mrcge p0, 0, r0, cr0, cr1, 1 + mrclt p0, 0, r0, cr0, cr1, 1 + mrcgt p0, 0, r0, cr0, cr1, 1 + mrcle p0, 0, r0, cr0, cr1, 1 + mrc p0, 0, r0, cr0, cr1, 1 + mrc2 p0, 0, r0, cr0, cr1, 1 + + /* LDC */ + /* .. condition codes */ + ldceq p0, cr0, [r0] + ldcne p0, cr0, [r0] + ldccs p0, cr0, [r0] + ldccc p0, cr0, [r0] + ldcmi p0, cr0, [r0] + ldcpl p0, cr0, [r0] + ldcvs p0, cr0, [r0] + ldcvc p0, cr0, [r0] + ldchi p0, cr0, [r0] + ldcls p0, cr0, [r0] + ldcge p0, cr0, [r0] + ldclt p0, cr0, [r0] + ldcgt p0, cr0, [r0] + ldcle p0, cr0, [r0] + ldc p0, cr0, [r0] + ldc2 p0, cr0, [r0] + + /* STC */ + /* .. condition codes */ + stceq p0, cr0, [r0] + stcne p0, cr0, [r0] + stccs p0, cr0, [r0] + stccc p0, cr0, [r0] + stcmi p0, cr0, [r0] + stcpl p0, cr0, [r0] + stcvs p0, cr0, [r0] + stcvc p0, cr0, [r0] + stchi p0, cr0, [r0] + stcls p0, cr0, [r0] + stcge p0, cr0, [r0] + stclt p0, cr0, [r0] + stcgt p0, cr0, [r0] + stcle p0, cr0, [r0] + stc p0, cr0, [r0] + stc2 p0, cr0, [r0] + + /* Misc */ + /* SWP */ + /* .. condition codes */ + swpeq r0, r1, [r2] + swpne r0, r1, [r2] + swpcs r0, r1, [r2] + swpcc r0, r1, [r2] + swpmi r0, r1, [r2] + swppl r0, r1, [r2] + swpvs r0, r1, [r2] + swpvc r0, r1, [r2] + swphi r0, r1, [r2] + swpls r0, r1, [r2] + swpge r0, r1, [r2] + swplt r0, r1, [r2] + swpgt r0, r1, [r2] + swple r0, r1, [r2] + swp r0, r1, [r2] + + /* SWPB */ + /* .. condition codes */ + swpeqb r0, r1, [r2] + swpneb r0, r1, [r2] + swpcsb r0, r1, [r2] + swpccb r0, r1, [r2] + swpmib r0, r1, [r2] + swpplb r0, r1, [r2] + swpvsb r0, r1, [r2] + swpvcb r0, r1, [r2] + swphib r0, r1, [r2] + swplsb r0, r1, [r2] + swpgeb r0, r1, [r2] + swpltb r0, r1, [r2] + swpgtb r0, r1, [r2] + swpleb r0, r1, [r2] + swpb r0, r1, [r2] + + /* MRS */ + /* .. condition codes */ + mrseq r0, cpsr + mrsne r0, spsr + mrscs r0, cpsr + mrscc r0, spsr + mrsmi r0, cpsr + mrspl r0, spsr + mrsvs r0, cpsr + mrsvc r0, spsr + mrshi r0, cpsr + mrsls r0, spsr + mrsge r0, cpsr + mrslt r0, spsr + mrsgt r0, cpsr + mrsle r0, spsr + mrs r0, cpsr + + /* MSR */ + /* .. condition codes */ + msreq cpsr_fsxc, r0 + msrne spsr_fsxc, r0 + msrcs cpsr_fsxc, r0 + msrcc spsr_fsxc, r0 + msrmi cpsr_fsxc, r0 + msrpl spsr_fsxc, r0 + msrvs cpsr_fsxc, r0 + msrvc spsr_fsxc, r0 + msrhi cpsr_fsxc, r0 + msrls spsr_fsxc, r0 + msrge cpsr_fsxc, r0 + msrlt spsr_fsxc, r0 + msrgt cpsr_fsxc, r0 + msrle spsr_fsxc, r0 + msr cpsr_fsxc, r0 + nop + /* .. addressing modes */ + msreq cpsr_fsxc, r0 + msrne spsr_fsxc, r0 + msrcs cpsr_fsxc, r0 + msrcc spsr_fsxc, r0 + msrmi cpsr_fsxc, r0 + msrpl spsr_fsxc, r0 + msrvs cpsr_fsxc, r0 + msrvc spsr_fsxc, r0 + msrhi cpsr_fsxc, r0 + msrls spsr_fsxc, r0 + msrge cpsr_fsxc, r0 + msrlt spsr_fsxc, r0 + msrgt cpsr_fsxc, r0 + msrle spsr_fsxc, r0 + msr cpsr_fsxc, r0 + msreq cpsr_fsxc, #4 + msrne spsr_fsxc, #4 + msrcs cpsr_fsxc, #4 + msrcc spsr_fsxc, #4 + msrmi cpsr_fsxc, #4 + msrpl spsr_fsxc, #4 + msrvs cpsr_fsxc, #4 + msrvc spsr_fsxc, #4 + msrhi cpsr_fsxc, #4 + msrls spsr_fsxc, #4 + msrge cpsr_fsxc, #4 + msrlt spsr_fsxc, #4 + msrgt cpsr_fsxc, #4 + msrle spsr_fsxc, #4 + msr cpsr_fsxc, #4 + nop + /* .. region selection */ + msr cpsr_f, #4 + msr spsr_s, #4 + msr cpsr_x, #4 + msr spsr_c, #4 + msr cpsr_fs, #4 + msr spsr_fx, #4 + msr cpsr_fc, #4 + msr spsr_sx, #4 + msr cpsr_sc, #4 + msr spsr_xc, #4 + msr cpsr_fsx, #4 + msr spsr_fsc, #4 + msr cpsr_fxc, #4 + msr spsr_sxc, #4 + msr cpsr_fsxc, #4 + + /* CLZ */ + /* .. condition codes */ + clzeq r0, r1 + clzne r0, r1 + clzcs r0, r1 + clzcc r0, r1 + clzmi r0, r1 + clzpl r0, r1 + clzvs r0, r1 + clzvc r0, r1 + clzhi r0, r1 + clzls r0, r1 + clzge r0, r1 + clzlt r0, r1 + clzgt r0, r1 + clzle r0, r1 + clz r0, r1 + + /* DSP extension */ + /* LDRD */ + /* .. condition codes */ + ldreqd r0, [r1] + ldrned r0, [r1] + ldrcsd r0, [r1] + ldrccd r0, [r1] + ldrmid r0, [r1] + ldrpld r0, [r1] + ldrvsd r0, [r1] + ldrvcd r0, [r1] + ldrhid r0, [r1] + ldrlsd r0, [r1] + ldrged r0, [r1] + ldrltd r0, [r1] + ldrgtd r0, [r1] + ldrled r0, [r1] + ldrd r0, [r1] + nop + /* .. addressing modes */ + ldrd r0, [r1] + ldrd r0, [r1, #4] + ldrd r0, [r1, #-4] + ldrd r0, [r1, r2] + ldrd r0, [r1, -r2] + ldrd r0, [r1]! + ldrd r0, [r1, #4]! + ldrd r0, [r1, #-4]! + ldrd r0, [r1, r2]! + ldrd r0, [r1, -r2]! + ldrd r0, [r1], #4 + ldrd r0, [r1], #-4 + ldrd r0, [r1], r2 + ldrd r0, [r1], -r2 + + /* STRD */ + /* .. condition codes */ + streqd r0, [r1] + strned r0, [r1] + strcsd r0, [r1] + strccd r0, [r1] + strmid r0, [r1] + strpld r0, [r1] + strvsd r0, [r1] + strvcd r0, [r1] + strhid r0, [r1] + strlsd r0, [r1] + strged r0, [r1] + strltd r0, [r1] + strgtd r0, [r1] + strled r0, [r1] + strd r0, [r1] + nop + /* .. addressing modes */ + strd r0, [r1] + strd r0, [r1, #4] + strd r0, [r1, #-4] + strd r0, [r1, r2] + strd r0, [r1, -r2] + strd r0, [r1]! + strd r0, [r1, #4]! + strd r0, [r1, #-4]! + strd r0, [r1, r2]! + strd r0, [r1, -r2]! + strd r0, [r1], #4 + strd r0, [r1], #-4 + strd r0, [r1], r2 + strd r0, [r1], -r2 + + /* MCRR */ + /* .. condition codes */ + mcrreq p0, 0, r0, r1, cr0 + mcrrne p0, 0, r0, r1, cr0 + mcrrcs p0, 0, r0, r1, cr0 + mcrrcc p0, 0, r0, r1, cr0 + mcrrmi p0, 0, r0, r1, cr0 + mcrrpl p0, 0, r0, r1, cr0 + mcrrvs p0, 0, r0, r1, cr0 + mcrrvc p0, 0, r0, r1, cr0 + mcrrhi p0, 0, r0, r1, cr0 + mcrrls p0, 0, r0, r1, cr0 + mcrrge p0, 0, r0, r1, cr0 + mcrrlt p0, 0, r0, r1, cr0 + mcrrgt p0, 0, r0, r1, cr0 + mcrrle p0, 0, r0, r1, cr0 + mcrr p0, 0, r0, r1, cr0 + + /* MRRC */ + /* .. condition codes */ + mrrceq p0, 0, r0, r1, cr0 + mrrcne p0, 0, r0, r1, cr0 + mrrccs p0, 0, r0, r1, cr0 + mrrccc p0, 0, r0, r1, cr0 + mrrcmi p0, 0, r0, r1, cr0 + mrrcpl p0, 0, r0, r1, cr0 + mrrcvs p0, 0, r0, r1, cr0 + mrrcvc p0, 0, r0, r1, cr0 + mrrchi p0, 0, r0, r1, cr0 + mrrcls p0, 0, r0, r1, cr0 + mrrcge p0, 0, r0, r1, cr0 + mrrclt p0, 0, r0, r1, cr0 + mrrcgt p0, 0, r0, r1, cr0 + mrrcle p0, 0, r0, r1, cr0 + mrrc p0, 0, r0, r1, cr0 + + /* PLD */ + /* .. addressing modes */ + pld [r0] + pld [r0, #4] + pld [r0, #-4] + pld [r0, r1] + pld [r0, -r1] + pld [r0, r1, lsl #2] + pld [r0, -r1, lsl #2] + pld [r0, r1, lsr #2] + pld [r0, -r1, lsr #2] + pld [r0, r1, asr #2] + pld [r0, -r1, asr #2] + pld [r0, r1, ror #2] + pld [r0, -r1, ror #2] + pld [r0, r1, rrx] + pld [r0, -r1, rrx] + + /* QADD */ + /* .. condition codes */ + qaddeq r0, r1, r2 + qaddne r0, r1, r2 + qaddcs r0, r1, r2 + qaddcc r0, r1, r2 + qaddmi r0, r1, r2 + qaddpl r0, r1, r2 + qaddvs r0, r1, r2 + qaddvc r0, r1, r2 + qaddhi r0, r1, r2 + qaddls r0, r1, r2 + qaddge r0, r1, r2 + qaddlt r0, r1, r2 + qaddgt r0, r1, r2 + qaddle r0, r1, r2 + qadd r0, r1, r2 + + /* QSUB */ + /* .. condition codes */ + qsubeq r0, r1, r2 + qsubne r0, r1, r2 + qsubcs r0, r1, r2 + qsubcc r0, r1, r2 + qsubmi r0, r1, r2 + qsubpl r0, r1, r2 + qsubvs r0, r1, r2 + qsubvc r0, r1, r2 + qsubhi r0, r1, r2 + qsubls r0, r1, r2 + qsubge r0, r1, r2 + qsublt r0, r1, r2 + qsubgt r0, r1, r2 + qsuble r0, r1, r2 + qsub r0, r1, r2 + + /* QDADD */ + /* .. condition codes */ + qdaddeq r0, r1, r2 + qdaddne r0, r1, r2 + qdaddcs r0, r1, r2 + qdaddcc r0, r1, r2 + qdaddmi r0, r1, r2 + qdaddpl r0, r1, r2 + qdaddvs r0, r1, r2 + qdaddvc r0, r1, r2 + qdaddhi r0, r1, r2 + qdaddls r0, r1, r2 + qdaddge r0, r1, r2 + qdaddlt r0, r1, r2 + qdaddgt r0, r1, r2 + qdaddle r0, r1, r2 + qdadd r0, r1, r2 + + /* QDSUB */ + /* .. condition codes */ + qdsubeq r0, r1, r2 + qdsubne r0, r1, r2 + qdsubcs r0, r1, r2 + qdsubcc r0, r1, r2 + qdsubmi r0, r1, r2 + qdsubpl r0, r1, r2 + qdsubvs r0, r1, r2 + qdsubvc r0, r1, r2 + qdsubhi r0, r1, r2 + qdsubls r0, r1, r2 + qdsubge r0, r1, r2 + qdsublt r0, r1, r2 + qdsubgt r0, r1, r2 + qdsuble r0, r1, r2 + qdsub r0, r1, r2 + + /* SMLAXY */ + /* .. condition codes */ + smlabbeq r0, r1, r2, r3 + smlabbne r0, r1, r2, r3 + smlabbcs r0, r1, r2, r3 + smlabbcc r0, r1, r2, r3 + smlabbmi r0, r1, r2, r3 + smlabbpl r0, r1, r2, r3 + smlabbvs r0, r1, r2, r3 + smlabbvc r0, r1, r2, r3 + smlabbhi r0, r1, r2, r3 + smlabbls r0, r1, r2, r3 + smlabbge r0, r1, r2, r3 + smlabblt r0, r1, r2, r3 + smlabbgt r0, r1, r2, r3 + smlabble r0, r1, r2, r3 + smlabb r0, r1, r2, r3 + smlabteq r0, r1, r2, r3 + smlabtne r0, r1, r2, r3 + smlabtcs r0, r1, r2, r3 + smlabtcc r0, r1, r2, r3 + smlabtmi r0, r1, r2, r3 + smlabtpl r0, r1, r2, r3 + smlabtvs r0, r1, r2, r3 + smlabtvc r0, r1, r2, r3 + smlabthi r0, r1, r2, r3 + smlabtls r0, r1, r2, r3 + smlabtge r0, r1, r2, r3 + smlabtlt r0, r1, r2, r3 + smlabtgt r0, r1, r2, r3 + smlabtle r0, r1, r2, r3 + smlabt r0, r1, r2, r3 + smlatbeq r0, r1, r2, r3 + smlatbne r0, r1, r2, r3 + smlatbcs r0, r1, r2, r3 + smlatbcc r0, r1, r2, r3 + smlatbmi r0, r1, r2, r3 + smlatbpl r0, r1, r2, r3 + smlatbvs r0, r1, r2, r3 + smlatbvc r0, r1, r2, r3 + smlatbhi r0, r1, r2, r3 + smlatbls r0, r1, r2, r3 + smlatbge r0, r1, r2, r3 + smlatblt r0, r1, r2, r3 + smlatbgt r0, r1, r2, r3 + smlatble r0, r1, r2, r3 + smlatb r0, r1, r2, r3 + smlatteq r0, r1, r2, r3 + smlattne r0, r1, r2, r3 + smlattcs r0, r1, r2, r3 + smlattcc r0, r1, r2, r3 + smlattmi r0, r1, r2, r3 + smlattpl r0, r1, r2, r3 + smlattvs r0, r1, r2, r3 + smlattvc r0, r1, r2, r3 + smlatthi r0, r1, r2, r3 + smlattls r0, r1, r2, r3 + smlattge r0, r1, r2, r3 + smlattlt r0, r1, r2, r3 + smlattgt r0, r1, r2, r3 + smlattle r0, r1, r2, r3 + smlatt r0, r1, r2, r3 + + /* SMLALXY */ + /* .. condition codes */ + smlalbbeq r0, r1, r2, r3 + smlalbbne r0, r1, r2, r3 + smlalbbcs r0, r1, r2, r3 + smlalbbcc r0, r1, r2, r3 + smlalbbmi r0, r1, r2, r3 + smlalbbpl r0, r1, r2, r3 + smlalbbvs r0, r1, r2, r3 + smlalbbvc r0, r1, r2, r3 + smlalbbhi r0, r1, r2, r3 + smlalbbls r0, r1, r2, r3 + smlalbbge r0, r1, r2, r3 + smlalbblt r0, r1, r2, r3 + smlalbbgt r0, r1, r2, r3 + smlalbble r0, r1, r2, r3 + smlalbb r0, r1, r2, r3 + smlalbteq r0, r1, r2, r3 + smlalbtne r0, r1, r2, r3 + smlalbtcs r0, r1, r2, r3 + smlalbtcc r0, r1, r2, r3 + smlalbtmi r0, r1, r2, r3 + smlalbtpl r0, r1, r2, r3 + smlalbtvs r0, r1, r2, r3 + smlalbtvc r0, r1, r2, r3 + smlalbthi r0, r1, r2, r3 + smlalbtls r0, r1, r2, r3 + smlalbtge r0, r1, r2, r3 + smlalbtlt r0, r1, r2, r3 + smlalbtgt r0, r1, r2, r3 + smlalbtle r0, r1, r2, r3 + smlalbt r0, r1, r2, r3 + smlaltbeq r0, r1, r2, r3 + smlaltbne r0, r1, r2, r3 + smlaltbcs r0, r1, r2, r3 + smlaltbcc r0, r1, r2, r3 + smlaltbmi r0, r1, r2, r3 + smlaltbpl r0, r1, r2, r3 + smlaltbvs r0, r1, r2, r3 + smlaltbvc r0, r1, r2, r3 + smlaltbhi r0, r1, r2, r3 + smlaltbls r0, r1, r2, r3 + smlaltbge r0, r1, r2, r3 + smlaltblt r0, r1, r2, r3 + smlaltbgt r0, r1, r2, r3 + smlaltble r0, r1, r2, r3 + smlaltb r0, r1, r2, r3 + smlaltteq r0, r1, r2, r3 + smlalttne r0, r1, r2, r3 + smlalttcs r0, r1, r2, r3 + smlalttcc r0, r1, r2, r3 + smlalttmi r0, r1, r2, r3 + smlalttpl r0, r1, r2, r3 + smlalttvs r0, r1, r2, r3 + smlalttvc r0, r1, r2, r3 + smlaltthi r0, r1, r2, r3 + smlalttls r0, r1, r2, r3 + smlalttge r0, r1, r2, r3 + smlalttlt r0, r1, r2, r3 + smlalttgt r0, r1, r2, r3 + smlalttle r0, r1, r2, r3 + smlaltt r0, r1, r2, r3 + + /* SMLAWY */ + /* .. condition codes */ + smlawbeq r0, r1, r2, r3 + smlawbne r0, r1, r2, r3 + smlawbcs r0, r1, r2, r3 + smlawbcc r0, r1, r2, r3 + smlawbmi r0, r1, r2, r3 + smlawbpl r0, r1, r2, r3 + smlawbvs r0, r1, r2, r3 + smlawbvc r0, r1, r2, r3 + smlawbhi r0, r1, r2, r3 + smlawbls r0, r1, r2, r3 + smlawbge r0, r1, r2, r3 + smlawblt r0, r1, r2, r3 + smlawbgt r0, r1, r2, r3 + smlawble r0, r1, r2, r3 + smlawb r0, r1, r2, r3 + smlawteq r0, r1, r2, r3 + smlawtne r0, r1, r2, r3 + smlawtcs r0, r1, r2, r3 + smlawtcc r0, r1, r2, r3 + smlawtmi r0, r1, r2, r3 + smlawtpl r0, r1, r2, r3 + smlawtvs r0, r1, r2, r3 + smlawtvc r0, r1, r2, r3 + smlawthi r0, r1, r2, r3 + smlawtls r0, r1, r2, r3 + smlawtge r0, r1, r2, r3 + smlawtlt r0, r1, r2, r3 + smlawtgt r0, r1, r2, r3 + smlawtle r0, r1, r2, r3 + smlawt r0, r1, r2, r3 + + /* SMULXY */ + /* .. condition codes */ + smulbbeq r0, r1, r2 + smulbbne r0, r1, r2 + smulbbcs r0, r1, r2 + smulbbcc r0, r1, r2 + smulbbmi r0, r1, r2 + smulbbpl r0, r1, r2 + smulbbvs r0, r1, r2 + smulbbvc r0, r1, r2 + smulbbhi r0, r1, r2 + smulbbls r0, r1, r2 + smulbbge r0, r1, r2 + smulbblt r0, r1, r2 + smulbbgt r0, r1, r2 + smulbble r0, r1, r2 + smulbb r0, r1, r2 + smulbteq r0, r1, r2 + smulbtne r0, r1, r2 + smulbtcs r0, r1, r2 + smulbtcc r0, r1, r2 + smulbtmi r0, r1, r2 + smulbtpl r0, r1, r2 + smulbtvs r0, r1, r2 + smulbtvc r0, r1, r2 + smulbthi r0, r1, r2 + smulbtls r0, r1, r2 + smulbtge r0, r1, r2 + smulbtlt r0, r1, r2 + smulbtgt r0, r1, r2 + smulbtle r0, r1, r2 + smulbt r0, r1, r2 + smultbeq r0, r1, r2 + smultbne r0, r1, r2 + smultbcs r0, r1, r2 + smultbcc r0, r1, r2 + smultbmi r0, r1, r2 + smultbpl r0, r1, r2 + smultbvs r0, r1, r2 + smultbvc r0, r1, r2 + smultbhi r0, r1, r2 + smultbls r0, r1, r2 + smultbge r0, r1, r2 + smultblt r0, r1, r2 + smultbgt r0, r1, r2 + smultble r0, r1, r2 + smultb r0, r1, r2 + smultteq r0, r1, r2 + smulttne r0, r1, r2 + smulttcs r0, r1, r2 + smulttcc r0, r1, r2 + smulttmi r0, r1, r2 + smulttpl r0, r1, r2 + smulttvs r0, r1, r2 + smulttvc r0, r1, r2 + smultthi r0, r1, r2 + smulttls r0, r1, r2 + smulttge r0, r1, r2 + smulttlt r0, r1, r2 + smulttgt r0, r1, r2 + smulttle r0, r1, r2 + smultt r0, r1, r2 + + /* SMULWY */ + /* .. condition codes */ + smulwbeq r0, r1, r2 + smulwbne r0, r1, r2 + smulwbcs r0, r1, r2 + smulwbcc r0, r1, r2 + smulwbmi r0, r1, r2 + smulwbpl r0, r1, r2 + smulwbvs r0, r1, r2 + smulwbvc r0, r1, r2 + smulwbhi r0, r1, r2 + smulwbls r0, r1, r2 + smulwbge r0, r1, r2 + smulwblt r0, r1, r2 + smulwbgt r0, r1, r2 + smulwble r0, r1, r2 + smulwb r0, r1, r2 + smulwteq r0, r1, r2 + smulwtne r0, r1, r2 + smulwtcs r0, r1, r2 + smulwtcc r0, r1, r2 + smulwtmi r0, r1, r2 + smulwtpl r0, r1, r2 + smulwtvs r0, r1, r2 + smulwtvc r0, r1, r2 + smulwthi r0, r1, r2 + smulwtls r0, r1, r2 + smulwtge r0, r1, r2 + smulwtlt r0, r1, r2 + smulwtgt r0, r1, r2 + smulwtle r0, r1, r2 + smulwt r0, r1, r2 + + nop + nop + nop + nop + nop + .end + \ No newline at end of file diff -Nru eresi-0.8a25/libasm/testsuite/arm/sanity_small.s eresi-0.0.20110516/libasm/testsuite/arm/sanity_small.s --- eresi-0.8a25/libasm/testsuite/arm/sanity_small.s 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/arm/sanity_small.s 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,115 @@ + .text + .arm + + .section test, "ax" + /* Data processing */ + and r0, r1, r2 + eor r0, r1, r2 + sub r0, r1, r2 + rsb r0, r1, r2 + add r0, r1, r2 + adc r0, r1, r2 + sbc r0, r1, r2 + rsc r0, r1, r2 + tst r0, r1 + teq r0, r1 + cmp r0, r1 + cmn r0, r1 + orr r0, r1, r2 + mov r0, r1 + bic r0, r1, r2 + mvn r0, r1 + /* Branch */ + b . + bl . + blx . + blx r0 + bx lr + /* Interrupt */ + bkpt 0 + swi 0 + /* Load/Store */ + /* LDM(1) */ + ldmia r0, {r1, r2, r3} + ldmia sp!, {r1, r2, r3} + pop {r1, r2, r3} + /* LDM(2) */ + ldmia r0, {r1, r2, r3}^ + /* LDM(3) */ + ldmia r0, {r1, r2, pc}^ + ldr r0, [r1] + ldrb r0, [r1] + ldrbt r0, [r1] + ldrh r0, [r1] + ldrsb r0, [r1] + ldrsh r0, [r1] + ldrt r0, [r1] + /* STM(1) */ + stmdb r0, {r1, r2, r3} + stmdb sp!, {r1, r2, r3} + push {r1, r2, r3} + /* STM(2) */ + stmdb r0, {r1, r2, r3}^ + str r0, [r1] + strb r0, [r1] + strbt r0, [r1] + strh r0, [r1] + strt r0, [r1] + /* Multiply */ + mla r0, r1, r2, r3 + mul r0, r1, r2 + smlal r0, r1, r2, r3 + smull r0, r1, r2, r3 + umlal r0, r1, r2, r3 + umull r0, r1, r2, r3 + /* Coprocessor */ + cdp p0, 0, cr0, cr1, cr2, 0 + cdp2 p0, 0, cr0, cr1, cr2, 0 + mcr p0, 0, r0, cr0, cr1, 1 + mcr2 p0, 0, r0, cr0, cr1, 1 + mrc p0, 0, r0, cr0, cr1, 1 + mrc2 p0, 0, r0, cr0, cr1, 1 + ldc p0, cr0, [r0] + ldc2 p0, cr0, [r0] + stc p0, cr0, [r0] + stc2 p0, cr0, [r0] + /* Misc */ + swp r0, r1, [r2] + swpb r0, r1, [r2] + mrs r0, cpsr + msr cpsr_fsxc, r0 + clz r0, r1 + /* DSP extension */ + ldrd r0, [r1] + strd r0, [r1] + mcrr p0, 0, r0, r1, cr0 + mrrc p0, 0, r0, r1, cr0 + pld [r0] + qadd r0, r1, r2 + qsub r0, r1, r2 + qdadd r0, r1, r2 + qdsub r0, r1, r2 + smlabb r0, r1, r2, r3 + smlabt r0, r1, r2, r3 + smlatb r0, r1, r2, r3 + smlatt r0, r1, r2, r3 + smlalbb r0, r1, r2, r3 + smlalbt r0, r1, r2, r3 + smlaltb r0, r1, r2, r3 + smlaltt r0, r1, r2, r3 + smlawb r0, r1, r2, r3 + smlawt r0, r1, r2, r3 + smulbb r0, r1, r2 + smulbt r0, r1, r2 + smultb r0, r1, r2 + smultt r0, r1, r2 + smulwb r0, r1, r2 + smulwt r0, r1, r2 + + add r0, r1, r2 + add r0, r1, r2 + add r0, r1, r2 + add r0, r1, r2 + add r0, r1, r2 + .end + \ No newline at end of file diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/all-wcprops eresi-0.0.20110516/libasm/testsuite/ia32/.svn/all-wcprops --- eresi-0.8a25/libasm/testsuite/ia32/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/929/trunk/libasm/testsuite/ia32 -END -bugs.asm -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/bugs.asm -END -mov.asm -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/mov.asm -END -launch_test.sh -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/929/trunk/libasm/testsuite/ia32/launch_test.sh -END -ae.asm -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/ae.asm -END -shl.asm -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/shl.asm -END -memory.asm -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/memory.asm -END -fwait.asm -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/843/trunk/libasm/testsuite/ia32/fwait.asm -END -ja.asm -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/ja.asm -END -seta.asm -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/849/trunk/libasm/testsuite/ia32/seta.asm -END diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/entries eresi-0.0.20110516/libasm/testsuite/ia32/.svn/entries --- eresi-0.8a25/libasm/testsuite/ia32/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/testsuite/ia32 -http://svn.eresi-project.org/svn - - - -2008-03-25T02:54:59.614936Z -929 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -bugs.asm -file - - - - -2008-04-06T23:16:25.700877Z -92263624b8b32b43857a04995761dd86 -2008-02-19T17:09:59.893936Z -849 -may - -mov.asm -file - - - - -2008-04-06T23:16:25.755150Z -08e352250eff8b3fd72c9a906813e8f7 -2008-02-19T17:09:59.893936Z -849 -may - -launch_test.sh -file - - - - -2008-04-06T23:16:25.767160Z -29ff5d6a6578f0a311578df4d0e12d42 -2008-03-25T02:54:59.614936Z -929 -enioh -has-props - -ae.asm -file - - - - -2008-04-06T23:16:25.778676Z -35375f642cbf9f06f27afc93c89e766b -2008-02-19T17:09:59.893936Z -849 -may - -shl.asm -file - - - - -2008-04-06T23:16:25.790075Z -4bda1283d5fb7db9610e6107acf283a4 -2008-02-19T17:09:59.893936Z -849 -may - -memory.asm -file - - - - -2008-04-06T23:16:25.800883Z -4bf18533a6a9ecf98cd8604934ad28e7 -2008-02-19T17:09:59.893936Z -849 -may - -fwait.asm -file - - - - -2008-04-06T23:16:25.812931Z -4621a69d93cdc2f31013a4e485a45ab9 -2008-02-16T12:32:28.000000Z -843 -thor - -ja.asm -file - - - - -2008-04-06T23:16:25.824333Z -f94d23b200160951611ae2e181a32fcd -2008-02-19T17:09:59.893936Z -849 -may - -seta.asm -file - - - - -2008-04-06T23:16:25.835793Z -61962a572c88745041aede2ccbfc61c3 -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/format eresi-0.0.20110516/libasm/testsuite/ia32/.svn/format --- eresi-0.8a25/libasm/testsuite/ia32/.svn/format 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/prop-base/launch_test.sh.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/prop-base/launch_test.sh.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/prop-base/launch_test.sh.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/prop-base/launch_test.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/ae.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/ae.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/ae.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/ae.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -// $Id: ae.asm,v 1.1 2007/05/29 00:36:12 heroine Exp $ -fxsave 0xfffffde8(%ebp) diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/bugs.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/bugs.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/bugs.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/bugs.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -// $Id: bugs.asm,v 1.2 2007/10/14 00:01:42 heroine Exp $ -movw $0x2,0xffffffbc(%ebp) -mov $0x10,%di -andw $0xfff,0xffffff90(%ebp) -movw $0x0,0xfffffeda(%ebp) -jb 0x80499c0 -jb 0x8048c88 -setge %al -setge %al -jb 0x8049035 -;seta %dl -jb 0x8049644 -movw $0x1ff,0xffffff7e(%ebp) -andw $0xf3ff,0x8(%eax) -movw $0x3,0xfffffff0(%ebp) -fldz -shld $0x2,%eax,%edx -movw $0xe180,0xffffff90(%ebp) -movw $0xe180,0xffffff90(%ebp) -mov $0x2000,%ax -jb 0x8048753 -;seta %dl -movw $0x0,(%eax) -setle %al -setle %al -;seta %dl -;seta %dl -shld $0x10,%ecx,%ebx -movw $0x20,0x8050a7f(%ecx) -;seta %dl -movw $0x6d,0xffffffa0(%ebp) -shrd $0x3,%edx,%eax -movw $0x0,0x804f128 -movw $0x0,0x804f128 -mov $0x1388,%ax -;seta %dl -shld $0x9,%ebx,%esi -;seta %dl -ret $0x4 -movw $0x0,0xfffffffa(%ebp) -movw $0x0,0x48(%eax) -bsf %edx,%ecx -bsf %edx,%ecx -jb 0x8049885 -jb 0x8048844 -shrd $0x14,%ecx,%edx -jb 0x804b8f4 -jb 0x8048fe9 -jb 0x8049330 -jb 0x8049330 -jb 0x8049330 -jb 0x8049fac -jb 0x80499c1 -jb 0x804960c -jb 0x804966f -shrd $0x18,%edi,%ecx -shrd $0x18,%ebx,%ecx -movw $0x6ecf,0xffffffdc(%ebp) -shld $0x9,%eax,%edx -shld $0x2,%eax,%edx -jb 0x804ac0c -movw $0x3d,0xffffffac(%ebp) -cmp $0x1002,%ax -testw $0xff00,0x70(%eax) -jb 0x8049f44 -jb 0x8049884 -cmpw $0xff,0x2c(%ecx) -movw $0x0,0xe0(%eax) -mov $0xc8,%si -movw $0x8,0xc(%ebx) -jb 0x8049df0 -jb 0x80489e8 -jb 0x8049328 -jb 0x8048c98 -jb 0x8048ed0 -jb 0x8048ed0 -movw $0x61b6,0xffffffea(%ebp) -;seta %dl -movw $0x32,0x8(%eax) -movw $0x32,0x8(%ebx) -jb 0x8049574 -movw $0x0,0x88(%edx) -jb 0x8048d1a -mov $0x1,%si -jb 0x804a340 -movw $0x2,0xffffffdc(%ebp) -movw $0x0,0x2(%edi) -movw $0x0,0x8050be2 -jb 0x8049494 -;seta %dl -movw $0x2f2e,(%ecx) -movw $0x2f2e,(%ecx) -jb 0x80493a6 -mov $0xff00,%ax -movw $0x802,0xffffffda(%ebp) -setle %al -shrd $0x18,%ebx,%ecx -movw $0x46,0x804d8a4(%ecx) -;seta %dl -mov $0x1,%di -movw $0x2f,0x804b904 -movw $0xc023,0xffffff64(%ebp) -jb 0x8048ff1 -jb 0x80490bb -jb 0x80490bb -jb 0x80490bb -;seta %dl -;seta %dl -;seta %al diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/fwait.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/fwait.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/fwait.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/fwait.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ - // - // - // fstcw 0xfffffffa(%ebp) - .byte 0x9b, 0xd9, 0x7d, 0x0a - // - .byte 0xd9, 0x7d, 0x0a \ No newline at end of file diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/ja.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/ja.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/ja.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/ja.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -// $Id: ja.asm,v 1.1 2007/05/29 09:58:40 heroine Exp $ - // ja 0x8048cd4 - .byte 0x0f, 0x85, 0x84, 0x00, 0x00, 0x00 - .byte 0x0f, 0x87, 0x84, 0x00, 0x00, 0x00 - .byte 0x0f, 0x88, 0x84, 0x00, 0x00, 0x00 diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/launch_test.sh.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/launch_test.sh.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/launch_test.sh.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/launch_test.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -#!/usr/bin/env bash -# -# $Id: launch_test.sh,v 1.6 2007/10/29 11:26:44 heroine Exp $ -# -# This script launch lbmjollnir script to make diffs -# between an objdump dump and a mydisasm dump of each -# .asm file in the current directory. -# -MYDISASM=./mydisasm - -function debugPrint -{ - echo "$1" -} - -function init_test -{ - debugPrint "### Build testsuite" - for i in *.asm; do - debugPrint "as $i -o ${i/asm/o}" - as $i -o ${i/asm/o} #2> /dev/null - if ! ld ${i/asm/o} -o ${i/.asm/} 2> /dev/null ; then - echo "[ER] Failed compiling $i" - fi - done - ln -sf ../../mydisasm mydisasm -} - -function diff_test -{ - for i in *.asm ; do - echo -n "[Testing] $i:" - if python ../parse.py ${i/.asm/} - #if perl ../../../libmjollnir/tools/desDiff.pl ${i/.asm/} 2> /dev/null - then - echo "[OK] Test ok" - else - echo Error detected. Check output bellow and press enter when you are ready to launch gdb on mydisasm - echo While in gdb, type run_it to launch gdb tracing until asm_read_instr - read - cat >> tmp.gdb <>> You can now type continue to reach next asm_read_instr\n -end -EOF - gdb -x tmp.gdb mydisasm - rm tmp.gdb - fi - done -} - - -function purge_test -{ - debugPrint "### Cleaning up test directory" - for i in *.asm; do - rm ${i/asm/o} ${i/.asm/} - done - rm -f *.mydisasm - rm -f *.objdump - rm -f ./mydisasm -} - -if [ ! -z "$1" ] ; then - ARG=$1 -else - ARG="*.asm" -fi - -init_test $ARG -diff_test $ARG -echo -n "Purge testsuite directory ? [y/N]" -read val -if [ "$val" == "y" ] ; then - purge_test $ARG -fi diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/memory.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/memory.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/memory.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/memory.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -// $Id: memory.asm,v 1.1 2007/05/29 00:36:12 heroine Exp $ -lea (%ecx,%eax,1),%eax -lea (%edx,%eax,1),%eax -lea (%ebx,%eax,1),%eax -lea (%esi,%eax,1),%eax -lea (%edi,%eax,1),%eax -lea (%ebx,%ecx,1),%eax -lea (%ebx,%edx,1),%eax -lea (%edi,%edx,1),%eax -lea (%ebx,%esi,1),%eax -lea (%eax,%eax,2),%eax -lea (%edx,%edx,2),%eax -lea (%ebx,%ebx,2),%eax -lea (%edi,%edi,2),%eax -lea (%eax,%eax,4),%eax -lea (%edx,%eax,4),%eax -lea (%edx,%edx,4),%eax -lea (%ebx,%ebx,4),%eax -lea (%esi,%esi,4),%eax -lea (%ebx,%eax,8),%eax -lea 0x0(,%ecx,8),%eax -lea 0x0(,%edx,8),%eax -lea 0x805b880(,%ebx,8),%eax -lea 0x0(,%esi,8),%eax -lea (%eax,%edx,1),%ecx -lea (%edx,%ebx,1),%ecx -lea (%edx,%esi,1),%ecx -lea (%edi,%esi,1),%ecx -lea (%ebx,%eax,4),%ecx -lea (%eax,%edx,4),%ecx -lea 0x0(,%ebx,4),%ecx -lea 0x0(,%edi,4),%ecx -lea (%eax,%ecx,1),%edx -lea (%eax,%eax,2),%edx -lea (%edx,%edx,2),%edx -lea 0x0(,%ecx,4),%edx -lea (%edx,%edx,4),%edx -lea (%edi,%edx,4),%edx -lea (%ebx,%ebx,4),%edx -lea (%esi,%eax,8),%edx -lea (%eax,%edx,8),%edx -lea (%edx,%eax,1),%ebx -lea (%edi,%edx,1),%ebx -lea (%edx,%eax,2),%ebx -lea (%eax,%edx,2),%ebx -lea (%edi,%ecx,4),%ebx -lea (%edx,%ebx,4),%ebx -lea (%ebx,%eax,8),%ebx -lea 0x0(,%ecx,8),%ebx -lea (%ecx,%eax,1),%esi -lea (%ebx,%ecx,1),%esi -lea (%ecx,%edx,1),%esi -lea (%edx,%edi,1),%esi -lea (%edx,%eax,4),%esi -lea 0x0(,%ebx,8),%esi -lea (%ebx,%eax,1),%edi -lea (%esi,%eax,1),%edi -lea (%eax,%edx,8),%edi -lea 0xffffffff(%eax),%eax -lea 0xffffffff(%edx),%eax -lea 0x8(%ebx),%eax -lea 0x14(%ebx),%eax -lea 0x15(%ebx),%eax -lea 0x1(%ecx,%eax,1),%eax -lea 0x2(%ecx,%eax,1),%eax -lea 0x1(%edx,%eax,1),%eax -lea 0xc(%edi,%eax,1),%eax -lea 0x1(%eax,%ebx,1),%eax -lea 0x20(%eax,%ebx,1),%eax -lea 0x23(%esp),%eax -lea 0x2f(%esp),%eax -lea 0x2(%eax,%edi,1),%eax -lea 0xffffffd0(%eax,%edx,2),%eax -lea 0x18(%ebp),%eax -lea 0xffffff90(%ebp),%eax -lea 0xffffff9c(%ebp),%eax -lea 0xffffffa2(%ebp),%eax -lea 0xffffffb7(%ebp),%eax -lea 0xffffffbf(%ebp),%eax -lea 0xffffffca(%ebp),%eax -lea 0xffffffcc(%ebp),%eax -lea 0xffffffd8(%ebp),%eax -lea 0xffffffe0(%ebp),%eax -lea 0xffffffe3(%ebp),%eax -lea 0xffffffe8(%ebp),%eax -lea 0xffffffec(%ebp),%eax -lea 0xfffffff0(%ebp),%eax -lea 0xfffffff4(%ebp),%eax -lea 0x7c(%esi),%eax -lea 0xffffffff(%edi),%eax -lea 0x1(%eax),%ecx -lea 0x64(%eax),%ecx -lea 0x1(%edx),%ecx -lea 0x64(%edx),%ecx -lea 0x1(%ebx),%ecx -lea 0x4(%ecx,%edx,1),%ecx -lea 0x4(%esp),%ecx -lea 0x1(%eax,%esi,1),%ecx -lea 0xffffffa2(%ebp),%ecx -lea 0xffffffb7(%ebp),%ecx -lea 0xffffffbf(%ebp),%ecx -lea 0xffffffcc(%ebp),%ecx -lea 0xffffffe5(%ebp),%ecx -lea 0xffffffe6(%ebp),%ecx -lea 0xffffffe8(%ebp),%ecx -lea 0xffffffec(%ebp),%ecx -lea 0xfffffff0(%ebp),%ecx -lea 0xfffffff4(%ebp),%ecx -lea 0x1(%edi),%ecx -lea 0x1(%eax),%edx -lea 0xffffffe8(%eax),%edx -lea 0xfffffffe(%eax),%edx -lea 0xffffffcc(%ebp),%edx -lea 0xffffffd8(%ebp),%edx -lea 0xffffffdf(%ebp),%edx -lea 0xffffffe4(%ebp),%edx -lea 0xffffffe6(%ebp),%edx -lea 0xffffffe7(%ebp),%edx -lea 0xffffffec(%ebp),%edx -lea 0xfffffff0(%ebp),%edx -lea 0x1(%eax),%ebx -lea 0x7(%eax),%ebx -lea 0x13(%edx),%ebx -lea 0xffffffff(%edx,%eax,1),%ebx -lea 0xffffffff(%ecx,%ebx,1),%ebx -lea 0xffffffc8(%ebp),%ebx -lea 0xffffffca(%ebp),%ebx -lea 0xffffffcc(%ebp),%ebx -lea 0xffffffd0(%ebp),%ebx -lea 0xffffffd8(%ebp),%ebx -lea 0xfffffff0(%ebp),%ebx -lea 0x1(%esi),%ebx -lea 0x1(%edi),%ebx -lea 0xfffffff4(%ebp),%esp -lea 0x1(%eax),%esi -lea 0x7(%eax),%esi -lea 0x13(%eax),%esi -lea 0xffffff80(%eax),%esi -lea 0xfffffff2(%eax),%esi -lea 0xffffffff(%eax),%esi -lea 0x1(%ebx),%esi -lea 0xffffffff(%ebx,%eax,1),%esi -lea 0x0(%esi),%esi -lea 0xffffff9c(%eax,%edi,1),%esi -lea 0xffffffd0(%ebp),%esi -lea 0xffffffed(%ebp),%esi -lea 0x0(%esi),%esi -lea 0x1(%eax),%edi -lea 0x8(%eax),%edi -lea 0x14(%eax),%edi -lea 0xffffffff(%eax),%edi -lea 0xffffff9c(%ebp),%edi -lea 0xffffffd0(%ebp),%edi -lea 0xffffffd4(%ebp),%edi -lea 0xffffffd8(%ebp),%edi -lea 0xffffffdb(%ebp),%edi -lea 0x4(%esi),%edi -lea 0xff0f3d54(%edx),%eax -lea 0xffffff04(%ebx),%eax -lea 0x805b880(%ebx),%eax -lea 0xfffffd04(%ebp),%eax -lea 0xffffd911(%ebp),%eax -lea 0xfffffd16(%ebp),%eax -lea 0xffffff3c(%ebp),%eax -lea 0xffffff40(%ebp),%eax -lea 0xfffffd68(%ebp),%eax -lea 0xfffffd6c(%ebp),%eax -lea 0xffffff78(%ebp),%eax -lea 0xfffffb9c(%ebp),%eax -lea 0xfffffb9d(%ebp),%eax -lea 0xfffffcec(%ebp),%eax -lea 0xffffeaf2(%ebp),%eax -lea 0x76c(%eax),%ecx -lea 0x76c(%edi,%ecx,1),%ecx -lea 0xffffd911(%ebp),%ecx -lea 0xffffeaf2(%ebp),%ecx -lea 0xfefefeff(%eax),%edx -lea 0x80000000(%ebx),%edx -lea 0xffffff04(%ebx),%edx -lea 0xffffd911(%ebp),%edx -lea 0xffffff3c(%ebp),%edx -lea 0xfffffb9d(%ebp),%edx -lea 0xfffffcec(%ebp),%edx -lea 0x8058972(%edx),%ebx -lea 0x16d(%ebx,%ecx,1),%ebx -lea 0xffffd911(%ebp),%ebx -lea 0xffffdfe8(%ebp),%ebx -lea 0xffffeaf2(%ebp),%ebx -lea 0x0(%esi),%esi -lea 0xfffff92d(%ebp),%esi -lea 0xffffff74(%ebp),%esi -lea 0x0(%esi),%esi -lea 0xffffff04(%ebx),%edi -lea 0x0(%edi),%edi -lea 0xffffeaf2(%ebp),%edi -lea 0x0(%edi),%edi diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/mov.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/mov.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/mov.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/mov.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -// $Id: mov.asm,v 1.1 2007/05/29 00:36:12 heroine Exp $ -mov %eax,0x804e5c0 diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/seta.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/seta.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/seta.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/seta.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -// $Id: seta.asm,v 1.2 2007/10/28 14:35:03 heroine Exp $ -seta %dl - diff -Nru eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/shl.asm.svn-base eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/shl.asm.svn-base --- eresi-0.8a25/libasm/testsuite/ia32/.svn/text-base/shl.asm.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/ia32/.svn/text-base/shl.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// $Id: shl.asm,v 1.1 2007/05/29 00:36:12 heroine Exp $ -rol %cl,%dl -ror %cl,%dl -rcl %cl,%dl -rcr %cl,%dl -shl %cl,%dl -shr %cl,%dl -sal %cl,%dl -sar %cl,%dl diff -Nru eresi-0.8a25/libasm/testsuite/sparc/build.sh eresi-0.0.20110516/libasm/testsuite/sparc/build.sh --- eresi-0.8a25/libasm/testsuite/sparc/build.sh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/sparc/build.sh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,4 @@ +PATH=$PATH:~/cross-compiler/bin +for i in *.as ; do + sparc-as $i -o ${i/as/obj} +done \ No newline at end of file diff -Nru eresi-0.8a25/libasm/testsuite/sparc/test.as eresi-0.0.20110516/libasm/testsuite/sparc/test.as --- eresi-0.8a25/libasm/testsuite/sparc/test.as 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/sparc/test.as 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,8 @@ +nop +call %g1 +nop +nop +ret +restore +save %sp, -104, %sp +sethi %hi(0x33000), %l1 diff -Nru eresi-0.8a25/libasm/testsuite/.svn/all-wcprops eresi-0.0.20110516/libasm/testsuite/.svn/all-wcprops --- eresi-0.8a25/libasm/testsuite/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/929/trunk/libasm/testsuite -END -parse.py -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/929/trunk/libasm/testsuite/parse.py -END diff -Nru eresi-0.8a25/libasm/testsuite/.svn/entries eresi-0.0.20110516/libasm/testsuite/.svn/entries --- eresi-0.8a25/libasm/testsuite/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/testsuite -http://svn.eresi-project.org/svn - - - -2008-03-25T02:54:59.614936Z -929 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -tools -dir - -parse.py -file - - - - -2008-04-06T23:16:25.884131Z -fca58249b99d0715503eff0f05b5fe4a -2008-03-25T02:54:59.614936Z -929 -enioh - -ia32 -dir - diff -Nru eresi-0.8a25/libasm/testsuite/.svn/format eresi-0.0.20110516/libasm/testsuite/.svn/format --- eresi-0.8a25/libasm/testsuite/.svn/format 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/testsuite/.svn/text-base/parse.py.svn-base eresi-0.0.20110516/libasm/testsuite/.svn/text-base/parse.py.svn-base --- eresi-0.8a25/libasm/testsuite/.svn/text-base/parse.py.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/.svn/text-base/parse.py.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,281 +0,0 @@ -#!/usr/bin/python -# $Id$ -# -# This script compare mydisasm and objdump outputs to -# find bugs in libasm. -# - -import os -import re -import sys -PATH_ELFSH32 = '../../../elfsh/elfsh32' -path_mydisasm = '../../mydisasm' -path_objdump = 'objdump' -dump_mydisasm = "dump.mydisasm" -dump_objdump = "dump.objdump" - -line_mydisasm = '' -line_objdump = '' -nline = '' -nline = '' - - -def extract_textinfo(binary): - fd = os.popen("%s -f %s -quiet -sym | egrep .text" % (PATH_ELFSH32, binary)) - line = fd.readline() - #line = " [012] 0x08049AE0 SECTION .text sz:052692 foff:006880 scop:Local" - regexp = re.compile(".*(?P
0x[0-9,A-F]{8}).*sz:(?P[^ ]+)") - m = regexp.match(line) - if m != None: - print m.groups() - return m.groups() - else: - return None - - -def next_line_mydisasm(hdl_mydisasm): - """Get next valid line from mydisasm output - return an array - - @param hdl_mydisasm Handle to mydisasm output - """ - rejected = 1 - while rejected: - nline_mydisasm = hdl_mydisasm.next() - if nline_mydisasm == '': - return None - - nline_mydisasm = nline_mydisasm.rstrip() #([a-z,\%,\,]*) - regexp = re.compile("0x(?P
[0-9,a-z]{8}):\s+(?P[a-z]*)\s+(?P\S+).*") - m = regexp.match(nline_mydisasm) - if m: - #print 'mydisasm -> ' + str(m.groups()) - to_ret = m.groups() - to_ret = { - "address": m.group('address'), - "instr": m.group('instr'), - "operands": m.group('operands') - } - return to_ret - else: - pass - #print "mydisasm '%s' rejected"%(nline_mydisasm) - - - -def next_line_objdump(hdl_objdump): - """Get next valid line from objdump output - - @param hdl_objdump file handle to objdump output. - """ - rejected = 1 - while rejected: - nline_objdump = hdl_objdump.next() - if nline_objdump == '': - return None - nline_objdump = nline_objdump.rstrip() - regexp = re.compile(".*(?P
[0-9,a-f]{7}):\s+(?P[a-f,0-9, ]*)\s+" + - "(?P[a-z]+)\s+(?P.*)") - m = regexp.match(nline_objdump) - if m: - to_ret = m.groups() - #print 'objdump -> ' + str(to_ret) - if len(to_ret) < 2: - print 'fuck this : ' + nline_objdump - to_ret = { - "address": m.group('address'), - "instr": m.group("instr"), - "operands": m.group('operands'), - "opcodes": m.group('opcodes') - } - return to_ret - else: - #print "objdump '%s' rejected"%(nline_objdump) - pass - - -def compare_instruction(mydisasm, objdump): - """Compare two instruction - @param mydisasm - @param objdump - @return True if both instruction are the sames. - """ - vaddr = int(objdump['address'], 16) - imydisasm = mydisasm['instr'] - omydisasm = mydisasm['operands'] - iobjdump = objdump['instr'] - oobjdump = objdump['operands'] - if ((imydisasm[0:len(iobjdump)] == iobjdump) and - (omydisasm and oobjdump)): - return True - else: - return False - -def check_outputs(hdl_mydisasm, hdl_objdump): - nline_mydisasm = next_line_mydisasm(hdl_mydisasm) - nline_objdump = next_line_objdump(hdl_objdump) - skip_mydisasm = 0 - skip_objdump = 0 - line_match = 0 - line_unmatch = 0 - alined = 1 - try: - while 1: - # - # We have finished of readling lines from a file. - # - if (nline_mydisasm == None or nline_mydisasm == None): - print "End" - break - vaddr_myd = int(nline_mydisasm['address'],16) - vaddr_obj = int(nline_objdump['address'],16) - # mydisasm address is below objdump one - # Previous instruction was shorter than in objdump - # Raise alert - if vaddr_myd < vaddr_obj: - alined = 0 - print 'skipping mydisasm ' + str(nline_mydisasm) - skip_mydisasm += 1 - nline_mydisasm = next_line_mydisasm(hdl_mydisasm) - continue - # - # - # - if vaddr_myd > vaddr_obj: - alined = 0 - print 'skipping objdump ' + str(nline_objdump) - nline_objdump = next_line_objdump(hdl_objdump) - skip_objdump += 1 - continue - vaddr = nline_mydisasm['address'] - if alined == 0: - print "Disassembly realined." - alined = 1 - - if (nline_mydisasm == None or nline_mydisasm == None): - print "End" - break - if compare_instruction(nline_mydisasm, nline_objdump) == False: - try: - print ("%s objdump('%s' '%s') "%(vaddr, - nline_objdump['instr'], - nline_objdump['operands']) + - "!= mydisasm('%s' '%s') %s"%(nline_mydisasm['instr'], - nline_mydisasm['operands'], - nline_objdump['opcodes'])) - except TypeError: - print "Objdump parsed line" - print nline_objdump - print "mydisasm parsed line" - print nline_mydisasm - return - line_unmatch += 1 - else: - line_match += 1 - nline_mydisasm = next_line_mydisasm(hdl_mydisasm) - nline_objdump = next_line_objdump(hdl_objdump) - except: - print "Matching lines: %d"%(line_match) - print "Unmatching lines: %d"%(line_unmatch) - print "mydisasm skipped lines: %d"%(skip_mydisasm) - print "objdump skipped lines: %d"%(skip_objdump) - - -def main(): - i = 1 - if len(sys.argv) < 2: - print "Usage: %s "%(sys.argv[0]) - return -1 - else: - binary = sys.argv[1] - - # - # Extract binary information with elfsh - # - # - infos = extract_textinfo(binary) - if infos == None: - print "Error while parsing elfsh32 output" - # cmd_elfsh = ("../../elfsh/elfsh32 -f %s "%(binary) + - # "-pht | egrep 'r-x.*Loadable' | cut -d\" \" -f3,5") - #print cmd_elfsh - #elfsh = os.popen(cmd_elfsh) - #output = elfsh.readline().strip() - - - #arr = output.split(" ") - exe_start = int(infos[0], 16) - exe_size = int(infos[1]) - exe_end = exe_start + exe_size - - print "Size of .text = %i" % (exe_size) - # - # Intialization. - # - cmd_my = ("%s "%(path_mydisasm) + - " %s "%(binary) + - "%s %i > %s "%(hex(exe_start), exe_size, dump_mydisasm)) - cmd_obj = ("%s -d "%(path_objdump) + - " -z --start-address=%s --stop-address=%s"%(hex(exe_start), hex(exe_end)) + - " %s > %s "%(binary, dump_objdump)) - print cmd_my - print cmd_obj - import time - time.sleep(3) - os.system(cmd_my) - os.system(cmd_obj) - hdl_mydisasm = open(dump_mydisasm) - hdl_objdump = open(dump_objdump) - check_outputs(hdl_mydisasm, hdl_objdump) - -##################################### - -import StringIO - -def test_objdump(): - print "### Running testsuite for objdump parser" - testbuf = StringIO.StringIO(""" -/bin/ls: file format elf32-i386 - -Disassembly of section .init: - -080494b4 <_init>: - 80494b4: 55 push %ebp - 80494b5: 89 e5 mov %esp,%ebp - 80494b7: 83 ec 08 sub $0x8,%esp - 80494ba: e8 45 06 00 00 call 8049b04 -""") - try: - while True: - objdump = next_line_objdump(testbuf) - print objdump - except: - pass - - -def test_mydisasm(): - print "### Running testsuite for mydisasm parser" - testbuf = StringIO.StringIO(""" -0x08049b8f: nop 90 -0x08049b90: push %ebp 55 -0x08049b91: mov %esp,%ebp 89 e5 -0x08049b93: sub $0x18,%esp 83 ec 18 -0x08049b96: mov 0x8(%ebp),%eax 8b 45 08 -0x08049b99: mov 0xc(%ebp),%ecx 8b 4d 0c -0x08049b9c: mov 0x4(%eax),%edx 8b 50 04 -0x08049b9f: mov (%eax),%eax 8b 00 -0x08049ba1: mov %ecx,0x8(%esp,1) 89 4c 24 08 - """) - try: - while True: - mydisasm = next_line_mydisasm(testbuf) - print mydisasm - except: - pass - -if (len(sys.argv) > 1) and (sys.argv[1] == "--test"): - test_objdump() - test_mydisasm() - print extract_textinfo("/bin/ls") -else: - main() diff -Nru eresi-0.8a25/libasm/testsuite/tools/.svn/all-wcprops eresi-0.0.20110516/libasm/testsuite/tools/.svn/all-wcprops --- eresi-0.8a25/libasm/testsuite/tools/.svn/all-wcprops 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/tools/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/849/trunk/libasm/testsuite/tools -END -get_assembly.sh -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/849/trunk/libasm/testsuite/tools/get_assembly.sh -END diff -Nru eresi-0.8a25/libasm/testsuite/tools/.svn/entries eresi-0.0.20110516/libasm/testsuite/tools/.svn/entries --- eresi-0.8a25/libasm/testsuite/tools/.svn/entries 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/tools/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/testsuite/tools -http://svn.eresi-project.org/svn - - - -2008-02-19T17:09:59.893936Z -849 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -get_assembly.sh -file - - - - -2008-04-06T23:16:25.618876Z -6ee28afd7fb3d3cba298ee16c90074eb -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/testsuite/tools/.svn/format eresi-0.0.20110516/libasm/testsuite/tools/.svn/format --- eresi-0.8a25/libasm/testsuite/tools/.svn/format 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/tools/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/testsuite/tools/.svn/text-base/get_assembly.sh.svn-base eresi-0.0.20110516/libasm/testsuite/tools/.svn/text-base/get_assembly.sh.svn-base --- eresi-0.8a25/libasm/testsuite/tools/.svn/text-base/get_assembly.sh.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/tools/.svn/text-base/get_assembly.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -#!/bin/sh -# -# $Id: get_assembly.sh,v 1.2 2007/10/02 20:55:22 heroine Exp $ -# -if [ ! -z "$1" ]; then -objdump -d $1 -w | grep -v Disassembly | grep -v '>:' | grep -v elf32 | cut -f3 | cut -f1 -d'<' | egrep -v '^call' | egrep -v '^j' | grep -v 'repz ret' |sort -u -else -cat < binary.asm - -EOF -fi diff -Nru eresi-0.8a25/libasm/testsuite/unittest/build.sh eresi-0.0.20110516/libasm/testsuite/unittest/build.sh --- eresi-0.8a25/libasm/testsuite/unittest/build.sh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/unittest/build.sh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,7 @@ +#!/bin/sh + + +cc $(eresi-config libasm --cflags) test_libasm_support.c -o test_libasm_support $(eresi-config libasm --libs) -ggdb +cc $(eresi-config libasm --cflags) test_op_mov_reg_iv.c -o test_op_mov_reg_iv $(eresi-config libasm --libs) -ggdb +cc $(eresi-config libasm --cflags) test_call16.c -o test_call16 $(eresi-config libasm --libs) -ggdb +cc $(eresi-config libasm --cflags) test_groups.c -o test_groups $(eresi-config libasm --libs) -ggdb diff -Nru eresi-0.8a25/libasm/testsuite/unittest/test_call16.c eresi-0.0.20110516/libasm/testsuite/unittest/test_call16.c --- eresi-0.8a25/libasm/testsuite/unittest/test_call16.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/unittest/test_call16.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,80 @@ +#include +#include +#include + + +#define OPCODE_TO_TEST "\xE8\x00\x00\x5b" +#define OPCODE_VADDR 0x0000EDA7 + + + +/** + * @return 1 on success, 0 on failure + */ +int test32(void) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + printf("Initialization ret = %i\n", ret); + ret = asm_read_instr(&ins, OPCODE_TO_TEST, 5, &proc); + printf("asm_read_instr returned %i\n", ret); + vaddr = OPCODE_VADDR; + dump = asm_display_instr_att(&ins, vaddr); + printf("Disasm -> %s\n", dump); + return (0); +} + +/** + * @return 1 on success, 0 on failure + */ +int test16(void) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + printf("Initialization ret = %i\n", ret); + asm_ia32_switch_mode(&proc, INTEL_REAL); + ret = asm_read_instr(&ins, OPCODE_TO_TEST, 5, &proc); + printf("asm_read_instr returned %i\n", ret); + vaddr = OPCODE_VADDR; + dump = asm_display_instr_att(&ins, vaddr); + printf("Disasm -> %s\n", dump); + return (0); +} + +/** + * Call both test for protected and real mode + */ + + + +int main(int ac, char **av) +{ + int ret; + int failed; + + failed = 0; + + if ((test32()) != 1) + { + printf("test32 failed\n"); + failed = 1; + } + + if ((test16()) != 1) + { + printf("test16 failed\n"); + failed = 1; + } + + return (failed); +} diff -Nru eresi-0.8a25/libasm/testsuite/unittest/test_groups.c eresi-0.0.20110516/libasm/testsuite/unittest/test_groups.c --- eresi-0.8a25/libasm/testsuite/unittest/test_groups.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/unittest/test_groups.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,164 @@ +#include +#include +#include + + +#define OPCODE_TO_TEST "\xE8\x00\x00\x5b" +#define OPCODE_VADDR 0x0000EDA7 + +typedef struct s_instr2test +{ + char *opcodes; + int len; + int vaddr; + char *disasm32; + char *disasm16; +} instr2test_t; + + + +instr2test_t g_instr2test_array[] = + { + { "\xA1\x10\x00\x00\x00", 2, 0x000FF5CC, "mov 0x00000010,%eax", "mov 0x00000010,%ax"}, + { "\xFE\x06", 2, 0x000FF316, "inc (%esi)", "inc (%si)"}, + { "\x66\x2E\x8B\x0B\x66", 5, 0x000FF5D1, "mov (%ebx),%cs:%ecx", "mov (%bx),%cs:%cx"}, + { "\xEB\x00", 2, 0x000FF2E4, "jmp 0x000FF2E6", ""}, + + { "\xE8\x09\x47\x00\x00", 5, 0x000FF2E6, "", ""}, + + // { "\x70\x00", 0x000FF318 , 2, "", ""}, + // { "\x70\x00", 0x000FF318 , 2, "", ""}, + //{ "\x70\x00", 0x000FF318 , 2, "", ""}, + { NULL, 0, 0, "", ""}, + }; + +/** + * + */ + +char *dump_bytes(unsigned char *ptr, int len) +{ + int i; + static char buffer[513]; + + for(i = 0; i < len; i++) + sprintf(buffer + (i * 2), "%02X", *(ptr + i)); + return (buffer); +} + +int compare_disassembly(char *orig, char *dumped) +{ + return (strcmp(orig, dumped)); +} + +/** + * @return 1 on success, 0 on failure + */ +int test32(instr2test_t *instr2test) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + if (!ret) + { + printf("Initialization ret = %i\n", ret); + return (0); + } + ret = asm_read_instr(&ins, instr2test->opcodes, 12, &proc); + + vaddr = instr2test->vaddr; + dump = asm_display_instr_att(&ins, vaddr); + ret = compare_disassembly(instr2test->disasm32, dump); + if (ret != 0) + { + printf("test32 failed | bytes : %s | waited : '%s' | got '%s'\n", + dump_bytes(instr2test->opcodes, instr2test->len), + instr2test->disasm32, dump); + return (0); + } +} + +/** + * @return 1 on success, 0 on failure + */ +int test16(instr2test_t *instr2test) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + if (!ret) + { + printf("Initialization ret = %i\n", ret); + return (0); + } + asm_ia32_switch_mode(&proc, INTEL_REAL); + ret = asm_read_instr(&ins, instr2test->opcodes, 12, &proc); + + vaddr = instr2test->vaddr; + dump = asm_display_instr_att(&ins, vaddr); + ret = compare_disassembly(instr2test->disasm16, dump); + if (ret != 0) + { + printf("test16 failed | bytes : %s | waited : '%s' | got '%s'\n", + dump_bytes(instr2test->opcodes, instr2test->len), + instr2test->disasm16, dump); + return (0); + } + + return (1); +} + +int run_test(instr2test_t *instr2test) +{ + int failed = 0; + + if ((test32(instr2test)) != 1) + { + failed = 1; + } + + if ((test16(instr2test)) != 1) + { + failed = 1; + } + if (failed == 1) + return (0); + return (1); +} +/** + * Call both test for protected and real mode + */ + +int main(int ac, char **av) +{ + int ret; + int failed; + int global_failed; + instr2test_t *instr2test; + int number; + + + if (ac < 2) + { + for (instr2test = g_instr2test_array; instr2test->opcodes != NULL; instr2test++) + { + run_test(instr2test); + } + } + else + { + number = atoi(av[1]); + if ((number >= 0) && (number < 6)) + run_test(&g_instr2test_array[number]); + else + printf("test %i out of range\n", number); + } +} diff -Nru eresi-0.8a25/libasm/testsuite/unittest/test_libasm_support.c eresi-0.0.20110516/libasm/testsuite/unittest/test_libasm_support.c --- eresi-0.8a25/libasm/testsuite/unittest/test_libasm_support.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/unittest/test_libasm_support.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,25 @@ +#include +#include "libasm.h" + +int main() +{ + asm_processor proc; + + if (asm_init_arch(&proc, ASM_PROC_IA32)) + printf("[x] IA32 supported\n"); + else + printf("[ ] IA32 unsupported\n"); + if (asm_init_arch(&proc, ASM_PROC_SPARC)) + printf("[x] SPARC supported\n"); + else + printf("[ ] SPARC unsupported\n"); + if (asm_init_arch(&proc, ASM_PROC_MIPS)) + printf("[x] MIPS supported\n"); + else + printf("[ ] MIPS unsupported\n"); + if (asm_init_arch(&proc, ASM_PROC_ARM)) + printf("[x] ARM supported\n"); + else + printf("[ ] ARM unsupported\n"); + return (0); +} diff -Nru eresi-0.8a25/libasm/testsuite/unittest/test_op_mov_reg_iv.c eresi-0.0.20110516/libasm/testsuite/unittest/test_op_mov_reg_iv.c --- eresi-0.8a25/libasm/testsuite/unittest/test_op_mov_reg_iv.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libasm/testsuite/unittest/test_op_mov_reg_iv.c 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,79 @@ +#include +#include +#include + +#define OPCODE_TO_TEST "\xBE\x7F\x7D\xE8\x34" +#define OPCODE_VADDR 0x0804000 + + + +/** + * @return 1 on success, 0 on failure + */ +int test32(void) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + printf("Initialization ret = %i\n", ret); + ret = asm_read_instr(&ins, OPCODE_TO_TEST, 5, &proc); + printf("asm_read_instr returned %i\n", ret); + vaddr = OPCODE_VADDR; + dump = asm_display_instr_att(&ins, vaddr); + printf("Disasm -> %s\n", dump); + return (0); +} + +/** + * @return 1 on success, 0 on failure + */ +int test16(void) +{ + asm_processor proc; + asm_instr ins; + int ret; + char *dump; + int vaddr; + + ret = asm_init_arch(&proc, ASM_PROC_IA32); + printf("Initialization ret = %i\n", ret); + asm_ia32_switch_mode(&proc, INTEL_REAL); + ret = asm_read_instr(&ins, OPCODE_TO_TEST, 5, &proc); + printf("asm_read_instr returned %i\n", ret); + vaddr = OPCODE_VADDR; + dump = asm_display_instr_att(&ins, vaddr); + printf("Disasm -> %s\n", dump); + return (0); +} + +/** + * Call both test for protected and real mode + */ + + + +int main(int ac, char **av) +{ + int ret; + int failed; + + failed = 0; + + if ((test32()) != 1) + { + printf("test32 failed\n"); + failed = 1; + } + + if ((test16()) != 1) + { + printf("test16 failed\n"); + failed = 1; + } + + return (failed); +} diff -Nru eresi-0.8a25/libasm/tools/modrm.c eresi-0.0.20110516/libasm/tools/modrm.c --- eresi-0.8a25/libasm/tools/modrm.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/modrm.c 2011-05-16 11:34:15.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file modrm.c - * $Id: modrm.c,v 1.2 2007/10/14 00:01:42 heroine Exp $ +* @file libasm/tools/modrm.c + * $Id: modrm.c 1397 2009-09-13 02:19:08Z may $ * @brief Little utility to display modrm byte to debug ia32. */ #include diff -Nru eresi-0.8a25/libasm/tools/mydisasm.c eresi-0.0.20110516/libasm/tools/mydisasm.c --- eresi-0.8a25/libasm/tools/mydisasm.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/mydisasm.c 2011-05-16 11:34:15.000000000 +0000 @@ -3,7 +3,7 @@ ** Started : Mon Jun 10 01:49:20 2002 ** Updated : Thu Dec 4 02:46:23 2003 ** -** $Id: mydisasm.c,v 1.11 2007/10/14 00:01:42 heroine Exp $ +** $Id: mydisasm.c 1311 2009-01-14 20:36:48Z may $ ** */ @@ -137,7 +137,7 @@ printf("Converted vaddr %08x to file offset : %i\n", vaddr, start); - curr = elfsh_raw_read(obj, start, ptr, len); + curr = elfsh_readmemf(obj, start, ptr, len); if (curr != len) { printf("error reading %li bytes at %li -> read %i bytes\n", len, start, curr); diff -Nru eresi-0.8a25/libasm/tools/.svn/all-wcprops eresi-0.0.20110516/libasm/tools/.svn/all-wcprops --- eresi-0.8a25/libasm/tools/.svn/all-wcprops 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/849/trunk/libasm/tools -END -modrm.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/849/trunk/libasm/tools/modrm.c -END -libasm-config.template -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/849/trunk/libasm/tools/libasm-config.template -END -mydisasm.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/849/trunk/libasm/tools/mydisasm.c -END diff -Nru eresi-0.8a25/libasm/tools/.svn/entries eresi-0.0.20110516/libasm/tools/.svn/entries --- eresi-0.8a25/libasm/tools/.svn/entries 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libasm/tools -http://svn.eresi-project.org/svn - - - -2008-02-19T17:09:59.893936Z -849 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -modrm.c -file - - - - -2008-04-06T23:15:53.538132Z -36fc5a3bd709c669a2468e0060965150 -2008-02-19T17:09:59.893936Z -849 -may - -libasm-config.template -file - - - - -2008-04-06T23:15:53.580876Z -22640ca50a181f17880517042dcc32fb -2008-02-19T17:09:59.893936Z -849 -may -has-props - -mydisasm.c -file - - - - -2008-04-06T23:15:53.592052Z -f7c956ed2beb186f000886a31cd6e3b5 -2008-02-19T17:09:59.893936Z -849 -may - diff -Nru eresi-0.8a25/libasm/tools/.svn/format eresi-0.0.20110516/libasm/tools/.svn/format --- eresi-0.8a25/libasm/tools/.svn/format 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libasm/tools/.svn/prop-base/libasm-config.template.svn-base eresi-0.0.20110516/libasm/tools/.svn/prop-base/libasm-config.template.svn-base --- eresi-0.8a25/libasm/tools/.svn/prop-base/libasm-config.template.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/prop-base/libasm-config.template.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libasm/tools/.svn/text-base/libasm-config.template.svn-base eresi-0.0.20110516/libasm/tools/.svn/text-base/libasm-config.template.svn-base --- eresi-0.8a25/libasm/tools/.svn/text-base/libasm-config.template.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/text-base/libasm-config.template.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -# -# $Id: libasm-config.template,v 1.1 2007/08/17 01:27:22 heroine Exp $ -# -# Template of configuration script for building project with libasm -# Copy this script to libasm-config and set your own values -# -# Note: libasm depends on libaspect. -#!/bin/sh - -if echo "$0" | grep "libasm-config.template" > /dev/null ; then -echo Copy this script to libasm-config and set your own values -exit 0 -fi - -# Paths -ROOT_PATH=/usr/local/ -LIBASM_PATH=${ROOT_PATH}/libasm -LIBASPECT_PATH=${ROOT_PATH}/libaspect - -case "$1" in ---cflags) -echo -I${LIBASM_PATH}/include -I${LIBASPECT_PATH}/include -;; ---libraries32) -echo -L${LIBASM_PATH} -lasm -L${LIBASPECT_PATH} -laspect32 -;; -*) -echo "Argument: [--clags|--libraires32|--all]" -;; -esac diff -Nru eresi-0.8a25/libasm/tools/.svn/text-base/modrm.c.svn-base eresi-0.0.20110516/libasm/tools/.svn/text-base/modrm.c.svn-base --- eresi-0.8a25/libasm/tools/.svn/text-base/modrm.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/text-base/modrm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file modrm.c - * $Id: modrm.c,v 1.2 2007/10/14 00:01:42 heroine Exp $ - * @brief Little utility to display modrm byte to debug ia32. - */ -#include -#include - -typedef struct s_modrm -{ - u_char m:3; - u_char r:3; - u_char mod:2; -} asm_modrm; - -/** - * Will display content of 0xe0 for the modrm byte: - * Main usage : modrm 0xe2 - * $ ./modrm e2 - * op = 3 r = 4, m = 2 - * - */ -int main(int ac, char **av) -{ - struct s_modrm val; - char hex; - if (ac < 2) - { - printf("Usage: %s [hex modrmbyte]\n", av[0]); - exit(-1); - } - hex = strtoul(av[1], 0, 16); - memcpy(&val, &hex, 1); - printf("op = %i r = %i, m = %i\n", - val.mod, - val.r, - val.m); - return (0); -} diff -Nru eresi-0.8a25/libasm/tools/.svn/text-base/mydisasm.c.svn-base eresi-0.0.20110516/libasm/tools/.svn/text-base/mydisasm.c.svn-base --- eresi-0.8a25/libasm/tools/.svn/text-base/mydisasm.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libasm/tools/.svn/text-base/mydisasm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -/* -** Author : -** Started : Mon Jun 10 01:49:20 2002 -** Updated : Thu Dec 4 02:46:23 2003 -** -** $Id: mydisasm.c,v 1.11 2007/10/14 00:01:42 heroine Exp $ -** -*/ - -/* - * this tool is designed to disassemble binary with the same output as - * objdump (except symbols.) - * - * - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -int usage(char *p) -{ - printf("Usage: %s <[len]>\n", - p); - return (-1); -} - -void dump_opcodes(char *why, u_char *ptr, u_int curr, u_int vaddr) -{ - printf("0x%08x (%s): .byte 0x%02x\n", (int) vaddr + curr, why, *(ptr + curr)); - printf(";; error reading instruction at %p\n", ptr + curr); - printf(";; dumping opcodes: %02x %02x %02x %02x\n", - *(ptr + curr), *(ptr + curr + 1), - *(ptr + curr + 2), *(ptr + curr + 3)); -} - -int main(int ac, char **av) { - u_char *ptr; - unsigned long start; - unsigned long end; - unsigned long len; - u_int curr; - unsigned long vaddr; - char *att_dump; - int i; - Elf32_Sym *sym; - elfshobj_t *obj; - asm_instr instr; - asm_processor proc; - u_int arch; - - if (ac < 3) - return (usage(av[0])); - - obj = elfsh_load_obj(av[1]); - if (!obj) - { - printf("failed opening %s\n", av[1]); - return (-1); - } - - - /* fetching 2nd argument : symbol or vaddr */ - - arch = elfsh_get_arch(obj->hdr); - - vaddr = 0; - if (!(sym = elfsh_get_metasym_by_name(obj, av[2]))) - vaddr = strtoul(av[2], 0, 16); - else - vaddr = sym->st_value; - - /* - if (!vaddr) - { - printf("invalid start %s: null or cannot find symbol\n", av[2]); - elfsh_unload_obj(obj); - return (-1); - } - */ - /* fetching third argument if present L: */ - - if (av[3]) - len = atol(av[3]); - else - { - if (!sym) - { - printf("len required with no symbol information\n"); - elfsh_unload_obj(obj); - return (-1); - } - else - len = sym->st_size; - } - - - end = vaddr + len; - - /* select arch */ - - switch(arch) - { - case EM_SPARC32PLUS: - case EM_SPARC: - case EM_SPARCV9: - asm_init_sparc(&proc); - break; - case EM_386: - asm_init_ia32(&proc); - break; - case EM_MIPS: - asm_init_mips(&proc); - break; - default: - printf("unsupported architecture : %i\n", arch); - elfsh_unload_obj(obj); - return (-1); - } - - /* - filling buffer - */ - - ptr = malloc(len + 1); - memset(ptr, 0, len + 1); - start = elfsh_get_foffset_from_vaddr(obj, vaddr); - if (!start) - printf("Converted vaddr %08x to file offset : %i\n", vaddr, start); - - - curr = elfsh_raw_read(obj, start, ptr, len); - if (curr != len) - { - printf("error reading %li bytes at %li -> read %i bytes\n", len, start, curr); - elfsh_error(); - elfsh_unload_obj(obj); - return (-1); - } - - /* disassembling loop */ - - curr = 0; - - while(curr < len) { - if (asm_read_instr(&instr, ptr + curr, len - curr, &proc) > 0) { - att_dump = asm_display_instr_att(&instr, (int) vaddr + curr); - if (att_dump && (strcmp(att_dump,"int_err"))) - { - printf("0x%08x:\t", (int) vaddr + curr); - printf("%30s\t", att_dump); - for (i = 0; i < instr.len; i++) - printf("%02x ", *(ptr + curr + i)); - puts(""); - - //asm_instruction_debug(&instr, stdout); - curr += asm_instr_len(&instr); - } - else - { - dump_opcodes("int_err", ptr, curr, vaddr); - curr++; - } - } else { - dump_opcodes("asm_read_instr",ptr,curr,vaddr); - curr++; - } - } - if (arch == EM_386) - asm_free_i386(&proc); - - free(ptr); - elfsh_unload_obj(obj); - return (0); -} - - - - - diff -Nru eresi-0.8a25/libaspect/config.c eresi-0.0.20110516/libaspect/config.c --- eresi-0.8a25/libaspect/config.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/config.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,8 +1,9 @@ /* -** @file state.c +* @file libaspect/config.c +** @ingroup libaspect ** ** Started on Sat Jun 2 15:20:18 2005 jfv -** $Id: config.c,v 1.12 2008-02-16 12:32:27 thor Exp $ +** $Id: config.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libaspect.h" @@ -317,8 +318,8 @@ */ void profiler_setmorecolor(char *(*coloradv)(char *ty, char *p, char *te), char *(*colorinstr_fmt)(char* p, char *t), - char *(*coloraddress)(char *p, u_long a), - char *(*colornumber)(char *p, u_int n), + char *(*coloraddress)(char *p, eresi_Addr a), + char *(*colornumber)(char *p, eresi_Off n), char *(*colorstr_fmt)(char *p, char *t), char *(*colorfieldstr_fmt)(char *p, char *t), char *(*colortypestr_fmt)(char *p, char *t), diff -Nru eresi-0.8a25/libaspect/containers.c eresi-0.0.20110516/libaspect/containers.c --- eresi-0.8a25/libaspect/containers.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/containers.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,10 +1,11 @@ /* -** @file containers.c +* @file libaspect/containers.c +** @ingroup libaspect ** -** @brief Implement generic routines for containers +** @brief Implement generic routines for containers. ** ** Started on Sat Jun 2 15:20:18 2005 jfv -** $Id: containers.c,v 1.3 2008-02-16 12:32:27 thor Exp $ +** $Id: containers.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libaspect.h" @@ -14,10 +15,12 @@ * @brief Create container lists * @param container Container holding the lists * @param linktype CONTAINER_LINK_IN or CONTAINER_LINK_OUT for input or output links list + * @param uniqid Unique ID to be put into name * @return -1 on error and 0 on success */ int container_linklists_create(container_t *container, - u_int linktype) + u_int linktype, + u_int uniqid) { aspectype_t *type; char bufname[BUFSIZ]; @@ -47,26 +50,28 @@ switch (linktype) { case CONTAINER_LINK_IN: - snprintf(bufname, BUFSIZ, "%s_%08X_%s", prefix, *(u_long *) container->data, "inputs"); + snprintf(bufname, BUFSIZ, "%d_%s_"AFMT"_%s", + uniqid, prefix, *(eresi_Addr *) container->data, "inputs"); newlist = elist_find(bufname); if (newlist) container->inlinks = newlist; else { XALLOC(__FILE__, __FUNCTION__, __LINE__, container->inlinks, sizeof(list_t), -1); - elist_init(container->inlinks, strdup(bufname), container->type); + elist_init(container->inlinks, strdup(bufname), ASPECT_TYPE_LINK); } break; case CONTAINER_LINK_OUT: - snprintf(bufname, BUFSIZ, "%s_%08X_%s", prefix, *(u_long *) container->data, "outputs"); + snprintf(bufname, BUFSIZ, "%d_%s_"AFMT"_%s", + uniqid, prefix, *(eresi_Addr *) container->data, "outputs"); newlist = elist_find(bufname); if (newlist) container->outlinks = newlist; else { XALLOC(__FILE__, __FUNCTION__, __LINE__, container->outlinks, sizeof(list_t), -1); - elist_init(container->outlinks, strdup(bufname), container->type); + elist_init(container->outlinks, strdup(bufname), ASPECT_TYPE_LINK); } break; default: @@ -83,10 +88,11 @@ * @param type Type of element inside container * @param data Data pointer for contained element * @param inlist Input links list if any (else it will be created empty) - * @Param outlist Output links list if any (else it will be created empty) + * @param outlist Output links list if any (else it will be created empty) + * @param uniqid Unique ID to be put into name * @return Container newly created */ -container_t *container_create(u_int type, void *data, list_t *inlist, list_t *outlist) +container_t *container_create(u_int type, void *data, list_t *inlist, list_t *outlist, u_int uniqid) { container_t *newcntnr; aspectype_t *rtype; @@ -98,9 +104,10 @@ "Unknown container element type", NULL); /* Make sure meta-data is initialized and contiguous with pointed data */ +#if defined(DEBUG_LIBASPECT) fprintf(stderr, "Allocating sizeof(container) + (%s type->size = %u) \n", rtype->name, rtype->size); - +#endif XALLOC(__FILE__, __FUNCTION__, __LINE__, newcntnr, sizeof(container_t) + rtype->size, NULL); newcntnr->data = (char *) newcntnr + sizeof(container_t); newcntnr->type = type; @@ -110,12 +117,12 @@ if (inlist) newcntnr->inlinks = elist_copy(inlist); else - container_linklists_create(newcntnr, CONTAINER_LINK_IN); + container_linklists_create(newcntnr, CONTAINER_LINK_IN, uniqid); if (outlist) newcntnr->outlinks = elist_copy(outlist); else - container_linklists_create(newcntnr, CONTAINER_LINK_OUT); - + container_linklists_create(newcntnr, CONTAINER_LINK_OUT, uniqid); + /* Make sure the container and contained data are contiguous */ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); } diff -Nru eresi-0.8a25/libaspect/doc/.svn/all-wcprops eresi-0.0.20110516/libaspect/doc/.svn/all-wcprops --- eresi-0.8a25/libaspect/doc/.svn/all-wcprops 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/760/trunk/libaspect/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/760/trunk/libaspect/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libaspect/doc/.svn/entries eresi-0.0.20110516/libaspect/doc/.svn/entries --- eresi-0.8a25/libaspect/doc/.svn/entries 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libaspect/doc -http://svn.eresi-project.org/svn - - - -2007-08-03T14:26:18.000000Z -760 -heroine - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:52.849887Z -fe1ead8edca0b83a64671081081f20e0 -2007-08-03T14:26:18.000000Z -760 -heroine - diff -Nru eresi-0.8a25/libaspect/doc/.svn/format eresi-0.0.20110516/libaspect/doc/.svn/format --- eresi-0.8a25/libaspect/doc/.svn/format 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libaspect/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libaspect/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libaspect/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libaspect - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = include ./ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.h *.c - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libaspect - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/libaspect/include/aproxy.h eresi-0.0.20110516/libaspect/include/aproxy.h --- eresi-0.8a25/libaspect/include/aproxy.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/aproxy.h 2011-05-16 11:34:14.000000000 +0000 @@ -25,8 +25,8 @@ #endif /* - @file aproxy.h - $Id: aproxy.h,v 1.2 2007-08-03 11:50:59 heroine Exp $ +* @file libaspect/include/aproxy.h + $Id: aproxy.h 1397 2009-09-13 02:19:08Z may $ @brief `ptmalloc2', a malloc implementation for multiple threads without lock contention, by Wolfram Gloger . diff -Nru eresi-0.8a25/libaspect/include/libaspect-btree.h eresi-0.0.20110516/libaspect/include/libaspect-btree.h --- eresi-0.8a25/libaspect/include/libaspect-btree.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/libaspect-btree.h 2011-05-16 11:34:14.000000000 +0000 @@ -1,12 +1,12 @@ /* ** -** @file libbtree.h +* @file libaspect/include/libaspect-btree.h ** ** Author : ** Started : Fri Oct 17 14:30:27 2003 ** Updated : Thu Nov 27 23:27:49 2003 ** -** $Id: libaspect-btree.h,v 1.4 2008-02-16 12:32:27 thor Exp $ +** $Id: libaspect-btree.h 1397 2009-09-13 02:19:08Z may $ ** */ diff -Nru eresi-0.8a25/libaspect/include/libaspect.h eresi-0.0.20110516/libaspect/include/libaspect.h --- eresi-0.8a25/libaspect/include/libaspect.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/libaspect.h 2011-05-16 11:34:14.000000000 +0000 @@ -1,12 +1,12 @@ /** - ** @file libaspect.h +* @file libaspect/include/libaspect.h ** ** @brief The header file for modular objects in the framework ** ** Started Dec 22 2006 02:57:03 jfv ** ** - ** $Id: libaspect.h,v 1.40 2008-02-16 12:32:27 thor Exp $ + ** $Id: libaspect.h 1443 2011-01-14 06:37:39Z may $ ** */ #if !defined(__ASPECT_H__) @@ -20,6 +20,8 @@ #include #include #include +#include +#include /* Debug flags */ #define __DEBUG_LIST__ 1 @@ -52,10 +54,16 @@ #include #define __LITTLE_ENDIAN _LITTLE_ENDIAN #define __BIG_ENDIAN _BIG_ENDIAN + +#if defined(__FreeBSD__) + #include + #include + #define __WORDSIZE __ELF_WORD_SIZE +#endif #if __FreeBSD__ < 5 - #define __BYTE_ORDER __LITTLE_ENDIAN + #define __BYTE_ORDER __LITTLE_ENDIAN #else - #define __BYTE_ORDER BYTE_ORDER + #define __BYTE_ORDER BYTE_ORDER #endif #elif defined(sun) @@ -87,6 +95,15 @@ #endif +#ifndef __RELEASE__ +#define ASSERT(_x) assert(_x) +#define NOT_REACHED() ASSERT(FALSE) +#else +#define ASSERT(_x) +#define NOT_REACHED() +#endif +#define NOT_USED(_x) _x = _x + #ifndef swap32 #define swap32(x) \ ((uint32_t)( \ @@ -116,6 +133,60 @@ ((uint64_t)(((uint64_t)x) & (uint64_t) 0xff00000000000000ULL) >> 56))) #endif +/* The size of an address depends on if we analyse 32bits or 64bits objects */ +#if defined(ERESI32) + typedef uint32_t eresi_Addr; + typedef uint32_t eresi_Off; + +#define XFMT "0x%08X" +#define AFMT "%08X" +#define UFMT "%08u" +#define DFMT "%08d" +#define RDFMT "%d" +#define RXFMT "0x%X" + +#elif defined(ERESI64) + typedef uint64_t eresi_Addr; + typedef uint64_t eresi_Off; +#if __WORDSIZE == 32 + #define XFMT "0x%016llX" + #define AFMT "%016llX" + #define UFMT "%016llu" + #define DFMT "%016lld" + #define RDFMT "%lld" + #define RXFMT "0x%llX" +#elif __WORDSIZE == 64 + #define XFMT "0x%016lX" + #define AFMT "%016lX" + #define UFMT "%016lu" + #define DFMT "%016ld" + #define RDFMT "%ld" + #define RXFMT "0x%lX" +#else + #error "__WORDSIZE not defined" +#endif + +#else + #error "You must define either ERESI32 or ERESI64 built" +#endif + +/* Define Boolean types */ +typedef uint8_t Bool; +#define TRUE 1 +#define FALSE 0 + +/* Typedef the registers, linear addresses, virtual, etc for better + understanding. */ +typedef uint32_t ureg32; +typedef uint64_t ureg64; + +typedef uint32_t la32; +typedef uint64_t la64; + +typedef uint32_t va32; +typedef uint64_t va64; + + /* Include this here since it contains an allocation too */ #ifndef __KERNEL__ #include "aproxy.h" @@ -125,7 +196,7 @@ #include "libaspect-btree.h" #include "libaspect-profiler.h" -/* Those types are only the builtin types */ +/* Those types are built-in */ #define ASPECT_TYPE_UNKNOW 0 /*!< Unknown */ #define ASPECT_TYPE_RAW 1 /*!< Raw */ #define ASPECT_TYPE_BYTE 2 /*!< Byte */ @@ -136,20 +207,22 @@ #define ASPECT_TYPE_DADDR 7 /*!< 4 or 8 bytes */ #define ASPECT_TYPE_CADDR 8 /*!< 4 or 8 bytes */ #define ASPECT_TYPE_BIT 9 /*!< just 1 bit */ -#define ASPECT_TYPE_CORENUM 10 /*!< Core types number */ +#define ASPECT_TYPE_OID 10 /*!< object identifier */ +#define ASPECT_TYPE_CORENUM 11 /*!< Core types number */ -/* Vectors, tables and hash are considered simple types : - you cannot copy them or look inside them without foreach */ -#define ASPECT_TYPE_VECT 10 /*!< Vector type */ -#define ASPECT_TYPE_HASH 11 /*!< Hash table type */ -#define ASPECT_TYPE_LIST 12 /*!< List type */ -#define ASPECT_TYPE_SIMPLENUM 13 /*!< SIMPLE TYPES NUMBER */ +/* Vectors, tables and hash are parts of "simple types" + Note: you cannot copy them or look inside them without foreach */ +#define ASPECT_TYPE_VECT ASPECT_TYPE_CORENUM /*!< Vector type */ +#define ASPECT_TYPE_HASH (ASPECT_TYPE_CORENUM + 1) /*!< Hash table type */ +#define ASPECT_TYPE_LIST (ASPECT_TYPE_CORENUM + 2) /*!< List type */ +#define ASPECT_TYPE_SIMPLENUM (ASPECT_TYPE_CORENUM + 3) /*!< SIMPLE TYPES NUMBER */ /* Now come complex types which are part of the base types */ -#define ASPECT_TYPE_EXPR 13 /*!< Expression type */ -#define ASPECT_TYPE_BLOC 14 /*!< Block type */ -#define ASPECT_TYPE_FUNC 15 /*!< Function type */ -#define ASPECT_TYPE_BASENUM 16 /*!< BASE TYPES NUMBER */ +#define ASPECT_TYPE_EXPR ASPECT_TYPE_SIMPLENUM /*!< Expression type */ +#define ASPECT_TYPE_BLOC (ASPECT_TYPE_SIMPLENUM + 1) /*!< Block type */ +#define ASPECT_TYPE_FUNC (ASPECT_TYPE_SIMPLENUM + 2) /*!< Function type */ +#define ASPECT_TYPE_LINK (ASPECT_TYPE_SIMPLENUM + 3) +#define ASPECT_TYPE_BASENUM (ASPECT_TYPE_SIMPLENUM + 4) /*!< BASE TYPES NUMBER */ /* Type names */ #define ASPECT_TYPENAME_UNKNOW "unknown" @@ -162,6 +235,7 @@ #define ASPECT_TYPENAME_LONG "long" #define ASPECT_TYPENAME_DADDR "daddr" #define ASPECT_TYPENAME_CADDR "caddr" +#define ASPECT_TYPENAME_OID "oid" #define ASPECT_TYPENAME_VECT "vector" #define ASPECT_TYPENAME_HASH "hash" @@ -169,10 +243,36 @@ #define ASPECT_TYPENAME_EXPR "expr" #define ASPECT_TYPENAME_BLOC "bloc" #define ASPECT_TYPENAME_FUNC "func" +#define ASPECT_TYPENAME_LINK "link" + /* Max pointer depth for a compound type */ #define ASPECT_TYPE_MAXPTRDEPTH 1 +/* Some general purpose macros */ +#define IS_VADDR(s) (s[0] == '0' && (s[1] == 'X' || s[1] == 'x')) +#define PRINTABLE(c) (c >= 32 && c <= 126) + +#define LOWORD(_dw) ((_dw) & 0xffff) +#define HIWORD(_dw) (((_dw) >> 16) & 0xffff) +#define LOBYTE(_w) ((_w) & 0xff) +#define HIBYTE(_w) (((_w) >> 8) & 0xff) + +#define HIDWORD(_qw) ((uint32)((_qw) >> 32)) +#define LODWORD(_qw) ((uint32)(_qw)) +#define QWORD(_hi, _lo) ((((uint64)(_hi)) << 32) | ((uint32)(_lo))) + +#define BYTE_IN_CHAR 2 +#define WORD_IN_BYTE 2 +#define DWORD_IN_BYTE 4 +#define QWORD_IN_BYTE 8 +#define BYTE_IN_BIT 8 +#define WORD_IN_BIT 16 +#define DWORD_IN_BIT 32 +#define QWORD_IN_BIT 64 + +#define NEXT_CHAR(_x) _x + 1 + /* A structure for the type information */ typedef struct s_info { @@ -234,7 +334,6 @@ void *data; /* !< @brief Pointer to the contained object */ } container_t; - /** * @brief Input and Output links for containers */ @@ -258,17 +357,20 @@ */ #define CONFIG_SAFEMODE_OFF 0 #define CONFIG_SAFEMODE_ON 1 -#define CONFIG_CFGDEPTH_DEFAULT 30 +#define CONFIG_CFGDEPTH_DEFAULT 1 /** * @brief libasm related config */ -#define CONFIG_ASM_ENDIAN_FLAG "libasm.endian.flag" -#define CONFIG_ASM_LITTLE_ENDIAN 0 -#define CONFIG_ASM_BIG_ENDIAN 1 +#define CONFIG_ASM_ENDIAN_FLAG "libasm.endian.flag" +#define CONFIG_ASM_LITTLE_ENDIAN 0 +#define CONFIG_ASM_BIG_ENDIAN 1 #define CONFIG_ASM_ATT_MARGIN_DEFAULT 14 -#define CONFIG_ASM_ATT_MARGIN_FLAG "libasm.output.att.margin" +#define CONFIG_ASM_ATT_MARGIN_FLAG "libasm.output.att.margin" + +#define CONFIG_ASM_SYNTHINSTRS_DEFAULT 1 +#define CONFIG_ASM_SYNTHINSTRS "libasm.output.synth.instrs" /* A configuration item */ typedef struct s_config_item @@ -325,8 +427,8 @@ /* Advanced */ char *(*coloradv)(char *ty, char *p, char *te); char *(*colorinstr_fmt)(char* p, char *t); - char *(*coloraddress)(char *p, u_long a); - char *(*colornumber)(char *p, u_int n); + char *(*coloraddress)(char *p, eresi_Addr a); + char *(*colornumber)(char *p, eresi_Off n); char *(*colorstr_fmt)(char *p, char *t); char *(*colorfieldstr_fmt)(char *p, char *t); char *(*colortypestr_fmt)(char *p, char *t); @@ -340,12 +442,17 @@ int aspect_init(); void aspect_called_ctors_inc(); int aspect_called_ctors_finished(); +int kernsh_is_present(); +void kernsh_present_set(); +void kedbg_present_set(); +int kedbg_is_present(); void e2dbg_presence_set(); void e2dbg_presence_reset(); u_char e2dbg_presence_get(); u_char e2dbg_kpresence_get(); void e2dbg_kpresence_set(u_char pres); + /* Retreive pointer on the vector hash table */ hash_t* aspect_vecthash_get(); @@ -372,9 +479,14 @@ unsigned int); /* Container related functions */ -container_t *container_create(u_int type, void *data, list_t *in, list_t *out); +container_t *container_create(u_int type, + void *data, + list_t *in, + list_t *out, + u_int uniqid); int container_linklists_create(container_t *container, - u_int linktype); + u_int linktype, + u_int uniqid); /* Type related functions */ int aspect_type_simple(int typeid); @@ -463,9 +575,9 @@ char *(*colorinstr_fmt)(char* p, char *t), char *(*coloraddress)(char *p, - u_long a), + eresi_Addr a), char *(*colornumber)(char *p, - u_int n), + eresi_Off n), char *(*colorstr_fmt)(char *p, char *t), char *(*colorfieldstr_fmt)(char *p, diff -Nru eresi-0.8a25/libaspect/include/libaspect-hash.h eresi-0.0.20110516/libaspect/include/libaspect-hash.h --- eresi-0.8a25/libaspect/include/libaspect-hash.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/libaspect-hash.h 2011-05-16 11:34:14.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file libhash.h +* @file libaspect/include/libaspect-hash.h ** ** Started on Fri Jan 24 20:25:42 2003 jfv ** Last update Fri Dec 22 00:14:56 2006 jfv ** -** $Id: libaspect-hash.h,v 1.10 2007-11-28 07:56:08 may Exp $ +** $Id: libaspect-hash.h 1440 2010-12-29 02:22:03Z may $ ** */ #ifndef _LIBHASH_H_ @@ -57,6 +57,7 @@ int hash_apply(hash_t *h, void *ptr, int (*f)(listent_t *e, void *p)); /* Apply function */ int hash_merge(hash_t *dst, hash_t *src); /* Fuse hashes */ +int hash_inter(hash_t *dst, hash_t *src); /* intersect hashes */ int hash_unmerge(hash_t *dst, hash_t *src); /* Quotient hashes */ int hash_size(hash_t *hash); /* Return the elm nbr */ void* hash_get_one(hash_t *hash); /* Get any object */ diff -Nru eresi-0.8a25/libaspect/include/libaspect-list.h eresi-0.0.20110516/libaspect/include/libaspect-list.h --- eresi-0.8a25/libaspect/include/libaspect-list.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/libaspect-list.h 2011-05-16 11:34:14.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file libaspect-list.h +* @file libaspect/include/libaspect-list.h ** ** @brief Prototypes of API for ERESI lists ** ** Started on Fri Jul 13 20:25:42 2007 jfv -** $Id: libaspect-list.h,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: libaspect-list.h 1444 2011-01-31 07:41:29Z may $ */ #ifndef _LIBLIST_H_ @@ -41,6 +41,7 @@ void elist_destroy(list_t *h); /* Free the list */ list_t *elist_copy(list_t *h); /* Copy a list */ int elist_add(list_t *h, char *k, void *d); /* Add an entry */ +int elist_append(list_t *h, char *key, void *data); /* Append element to list */ int elist_del(list_t *h, char *key); /* Delete an entry */ void *elist_get(list_t *h, char *key); /* Get data from key */ void *elist_select(list_t *h, char *key); /* Get an entry pointer */ @@ -59,5 +60,8 @@ int elist_compare(list_t *first, list_t *two); /* Compare the content of 2 lists */ u_char elist_linearity_get(list_t *l); /* Get linearity of a list */ void elist_linearity_set(list_t *l, u_char val); /* Set linearity of a list */ +void *elist_pop(list_t *h); /* Remove the head of the list */ +int elist_push(list_t *h, void *data); /* Add an element in first of the list */ +void *elist_get_headptr(list_t *h); /* Get list head data without popping */ #endif /* _LIBLIST_H_ */ diff -Nru eresi-0.8a25/libaspect/include/libaspect-profiler.h eresi-0.0.20110516/libaspect/include/libaspect-profiler.h --- eresi-0.8a25/libaspect/include/libaspect-profiler.h 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/libaspect-profiler.h 2011-05-16 11:34:14.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file libelfsh-internal.h +* @file libaspect/include/libaspect-profiler.h ** ** Started on Wed Jan 1 07:51:24 2003 jfv ** Last update Thu Mar 20 06:19:53 2003 jfv ** -** $Id: libaspect-profiler.h,v 1.9 2007-08-03 11:50:59 heroine Exp $ +** $Id: libaspect-profiler.h 1440 2010-12-29 02:22:03Z may $ ** */ @@ -68,8 +68,8 @@ { \ if ((a = (void *) calloc(b, 1)) == NULL) \ { \ - write(1, "Out of memory\n", 14); \ - exit(1); \ + int wret = write(1, "Out of memory\n", 14); \ + exit(wret); \ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ (char *)"Out of memory .", c); \ } \ @@ -88,8 +88,8 @@ { \ if ((a = (void *) realloc(b, c)) == NULL) \ { \ - write(1, "Out of memory\n", 14); \ - exit(1); \ + int wret = write(1, "Out of memory\n", 14); \ + exit(wret); \ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ "Out of memory .", d); \ } \ @@ -268,6 +268,9 @@ } \ while (0) +#define PROFILER_INQ() \ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__) + #define PROFILER_IN(file, fun, lin) \ int profileme = profiler_depth; \ do { \ @@ -277,6 +280,9 @@ profiler_incdepth(); } \ } while (0) +#define PROFILER_OUTQ() \ + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__) + #define PROFILER_OUT(file, func, line) \ do { \ if (profiler_started()) { \ @@ -295,6 +301,9 @@ return; \ } while (0) +#define PROFILER_ROUTQ(ret) \ + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret) + #define PROFILER_ROUT(file, f, l, ret) \ do { \ if (profiler_started()) { \ @@ -313,6 +322,9 @@ return ret; \ } while (0) +#define PROFILER_ERRQ(msg, ret) \ + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, msg, ret); + #define PROFILER_ERR(file, f, l, m, r) \ do { \ if (profiler_started()) { \ diff -Nru eresi-0.8a25/libaspect/include/.svn/all-wcprops eresi-0.0.20110516/libaspect/include/.svn/all-wcprops --- eresi-0.8a25/libaspect/include/.svn/all-wcprops 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/945/trunk/libaspect/include -END -libaspect-list.h -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/843/trunk/libaspect/include/libaspect-list.h -END -aproxy.h -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/758/trunk/libaspect/include/aproxy.h -END -libaspect-btree.h -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/843/trunk/libaspect/include/libaspect-btree.h -END -libaspect-profiler.h -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/758/trunk/libaspect/include/libaspect-profiler.h -END -libaspect.h -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/945/trunk/libaspect/include/libaspect.h -END -libaspect-hash.h -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/823/trunk/libaspect/include/libaspect-hash.h -END diff -Nru eresi-0.8a25/libaspect/include/.svn/entries eresi-0.0.20110516/libaspect/include/.svn/entries --- eresi-0.8a25/libaspect/include/.svn/entries 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libaspect/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:24:43.639027Z -945 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libaspect-list.h -file - - - - -2008-04-06T23:15:52.570126Z -c82e37fe472cc9a316eeb9f80a329e12 -2008-02-16T12:32:28.000000Z -843 -thor - -aproxy.h -file - - - - -2008-04-06T23:15:52.596982Z -bab683a4f41b3023a321e403d202d194 -2007-08-03T11:51:01.000000Z -758 -heroine - -libaspect-btree.h -file - - - - -2008-04-06T23:15:52.615886Z -cd67949bce5080df71c039bb07f3b5da -2008-02-16T12:32:28.000000Z -843 -thor - -libaspect-profiler.h -file - - - - -2008-04-06T23:15:52.619908Z -4c4ea67ac0667a6923ebe6cf917eae52 -2007-08-03T11:51:01.000000Z -758 -heroine - -libaspect.h -file - - - - -2008-04-06T23:15:52.631558Z -d30f08d908ea719353fcadb567893d9e -2008-03-27T22:24:43.639027Z -945 -may - -libaspect-hash.h -file - - - - -2008-04-06T23:15:52.642954Z -40f2561758fe266aa7f827c8ab6a05bd -2007-11-28T07:56:09.000000Z -823 -may - diff -Nru eresi-0.8a25/libaspect/include/.svn/format eresi-0.0.20110516/libaspect/include/.svn/format --- eresi-0.8a25/libaspect/include/.svn/format 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/aproxy.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/aproxy.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/aproxy.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/aproxy.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,257 +0,0 @@ -/* Prototypes and definition for malloc implementation. - Copyright (C) 1996,97,99,2000,2002,2003,2004 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _MALLOC_H -#define _MALLOC_H 1 - -#ifdef _LIBC -#include -#endif - -/* - @file aproxy.h - $Id: aproxy.h,v 1.2 2007-08-03 11:50:59 heroine Exp $ - @brief `ptmalloc2', a malloc implementation for multiple threads without - lock contention, by Wolfram Gloger . - - VERSION 2.7.0 - - This work is mainly derived from malloc-2.7.0 by Doug Lea - , which is available from: - - ftp://gee.cs.oswego.edu/pub/misc/malloc.c - - This trimmed-down header file only provides function prototypes and - the exported data structures. For more detailed function - descriptions and compile-time options, see the source file - `malloc.c'. -*/ - -//#include "malloc-machine.h" - -/* Forward declarations. */ - -struct malloc_chunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_state * mstate; -//typedef unsigned short pid_t; - - -#if defined(__STDC__) || defined (__cplusplus) -# include -# define __malloc_ptr_t void * -#else -# undef size_t -# define size_t unsigned int -# undef ptrdiff_t -# define ptrdiff_t int -# define __malloc_ptr_t char * -#endif - -#ifdef _LIBC - -/* Used by GNU libc internals. */ -# define __malloc_size_t size_t -# define __malloc_ptrdiff_t ptrdiff_t -#elif !defined __attribute_malloc__ -# define __attribute_malloc__ -#endif - -#ifdef __GNUC__ - -/* GCC can always grok prototypes. For C++ programs we add throw() - to help it optimize the function calls. But this works only with - gcc 2.8.x and egcs. */ -# ifndef __THROW -# if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8) -# define __THROW throw () -# else -# define __THROW -# endif -# endif -# define __MALLOC_P(args) args __THROW -/* This macro will be used for functions which might take C++ callback - functions. */ -# define __MALLOC_PMT(args) args - -#else /* Not GCC. */ - -# define __THROW - -# if (defined __STDC__ && __STDC__) || defined __cplusplus - -# define __MALLOC_P(args) args -# define __MALLOC_PMT(args) args - -# ifndef __const -# define __const const -# endif - -# else /* Not ANSI C or C++. */ - -# define __MALLOC_P(args) () /* No prototypes. */ -# define __MALLOC_PMT(args) () - -# ifndef __const -# define __const -# endif - -# endif /* ANSI C or C++. */ - -#endif /* GCC. */ - -#ifndef NULL -# ifdef __cplusplus -# define NULL 0 -# else -# define NULL ((__malloc_ptr_t) 0) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* Allocate SIZE bytes of memory. */ -extern __malloc_ptr_t aproxy_malloc __MALLOC_P ((size_t __size)) __attribute_malloc__; - -/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */ -extern __malloc_ptr_t aproxy_calloc __MALLOC_P ((size_t __nmemb, size_t __size)) - __attribute_malloc__; - -/* Re-allocate the previously allocated block in __ptr, making the new - block SIZE bytes long. */ -extern __malloc_ptr_t aproxy_realloc __MALLOC_P ((__malloc_ptr_t __ptr, - size_t __size)) - __attribute_malloc__; - -/* Free a block allocated by `malloc', `realloc' or `calloc'. */ -extern void aproxy_free __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Free a block allocated by `calloc'. */ -extern void aproxy_cfree __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */ -extern __malloc_ptr_t aproxy_memalign __MALLOC_P ((size_t __alignment, size_t __size)); - -/* Allocate SIZE bytes on a page boundary. */ -extern __malloc_ptr_t aproxy_valloc __MALLOC_P ((size_t __size)) __attribute_malloc__; - -/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up - __size to nearest pagesize. */ -extern __malloc_ptr_t aproxy_pvalloc __MALLOC_P ((size_t __size)) - __attribute_malloc__; - -/* Underlying allocation function; successive calls should return - contiguous pieces of memory. */ -extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size)); - -/* Default value of `__morecore'. */ -extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size)) - __attribute_malloc__; - -/* SVID2/XPG mallinfo structure */ - -struct mallinfo { - int arena; /* non-mmapped space allocated from system */ - int ordblks; /* number of free chunks */ - int smblks; /* number of fastbin blocks */ - int hblks; /* number of mmapped regions */ - int hblkhd; /* space in mmapped regions */ - int usmblks; /* maximum total allocated space */ - int fsmblks; /* space available in freed fastbin blocks */ - int uordblks; /* total allocated space */ - int fordblks; /* total free space */ - int keepcost; /* top-most, releasable (via malloc_trim) space */ -}; - -/* Returns a copy of the updated current mallinfo. */ -extern struct mallinfo mallinfo __MALLOC_P ((void)); - -/* SVID2/XPG mallopt options */ -#ifndef M_MXFAST -# define M_MXFAST 1 /* maximum request size for "fastbins" */ -#endif -#ifndef M_NLBLKS -# define M_NLBLKS 2 /* UNUSED in this malloc */ -#endif -#ifndef M_GRAIN -# define M_GRAIN 3 /* UNUSED in this malloc */ -#endif -#ifndef M_KEEP -# define M_KEEP 4 /* UNUSED in this malloc */ -#endif - -/* mallopt options that actually do something */ -#define M_TRIM_THRESHOLD -1 -#define M_TOP_PAD -2 -#define M_MMAP_THRESHOLD -3 -#define M_MMAP_MAX -4 -#define M_CHECK_ACTION -5 - -/* General SVID/XPG interface to tunable parameters. */ -extern int mallopt __MALLOC_P ((int __param, int __val)); - -/* Release all but __pad bytes of freed top-most memory back to the - system. Return 1 if successful, else 0. */ -extern int malloc_trim __MALLOC_P ((size_t __pad)); - -/* Report the number of usable allocated bytes associated with allocated - chunk __ptr. */ -extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Prints brief summary statistics on stderr. */ -extern void malloc_stats __MALLOC_P ((void)); - -/* Record the state of all malloc variables in an opaque data structure. */ -extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void)); - -/* Restore the state of all malloc variables from data obtained with - malloc_get_state(). */ -extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr)); - -/* Called once when malloc is initialized; redefining this variable in - the application provides the preferred way to set up the hook - pointers. */ -extern void (*__aproxy_initialize_hook) __MALLOC_PMT ((void)); -/* Hooks for debugging and user-defined versions. */ -extern void (*__aproxy_free_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_hook) __MALLOC_PMT ((size_t __size, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_realloc_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr, - size_t __size, - __const __malloc_ptr_t)); -extern __malloc_ptr_t (*__aproxy_memalign_hook) __MALLOC_PMT ((size_t __alignment, - size_t __size, - __const __malloc_ptr_t)); -extern void (*__aproxy_after_morecore_hook) __MALLOC_PMT ((void)); - -/* Activate a standard set of debugging hooks. */ -extern void __aproxy_check_init __MALLOC_P ((void)); - - -#ifdef __cplusplus -} /* end of extern "C" */ -#endif - -/* Missing prototype */ -char *aproxy_strdup(const char *s); - -#endif /* malloc.h */ diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-btree.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-btree.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-btree.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-btree.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/* -** -** @file libbtree.h -** -** Author : -** Started : Fri Oct 17 14:30:27 2003 -** Updated : Thu Nov 27 23:27:49 2003 -** -** $Id: libaspect-btree.h,v 1.4 2008-02-16 12:32:27 thor Exp $ -** -*/ - -#ifndef __KERNEL__ - #include - #include - #include -#endif - -/** - * @brief Graphviz node pattern for debugging purpose - */ -#define BTREE_DEBUG_NODE "\"btree_%08x\" [\n"\ -"label = \" %8x| %8x| %8x\n"\ -"shape = \"record\"\n"\ -"];\n" - -/** - * @brief Graphviz link pattern for debugging purpose - */ -#define BTREE_DEBUG_LINK "\"btree_%08x\":%s -> \"btree_%08x\":ptr [\n"\ -"id = %i\n"\ -"];\n" - -#ifndef __KERNEL__ -/** - * - */ -struct s_debug -{ - FILE *fp; - int link; -}; -#endif - -/** - * @brief Binary tree structure. - */ -typedef struct s_btree -{ - unsigned int id; /*!< Id of the node */ - void *elem; /*!< Pointer to element of the node */ - struct s_btree *left; /*!< Left link of the tree */ - struct s_btree *right; /*!< Right link of the tree */ -} btree_t; - -#define BTREE_FREE_ELEM 1 -#define BTREE_FREE_TREE 0 - -void btree_insert(btree_t **, u_int, void *); -void btree_insert_sort(btree_t **, int (*)(void *, void *), void *); -void *btree_get_elem(btree_t *, u_int); -void *btree_find_elem(btree_t *, int (*)(void *, void *), void *); -void btree_browse_prefix(btree_t *, int (*)(void *, void *), void *); -void btree_browse_infix(btree_t *, int (*)(void *, void *), void *); -void btree_browse_suffix(btree_t *, int (*)(void *, void *), void *); -void btree_free(btree_t *, int); - -void btree_browse_prefix_debug(btree_t *, int (*)(void *, void *, btree_t *), void *); -void btree_debug(btree_t *, char *, void (*)(void *, void *)); diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-hash.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-hash.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-hash.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-hash.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* -** @file libhash.h -** -** Started on Fri Jan 24 20:25:42 2003 jfv -** Last update Fri Dec 22 00:14:56 2006 jfv -** -** $Id: libaspect-hash.h,v 1.10 2007-11-28 07:56:08 may Exp $ -** -*/ -#ifndef _LIBHASH_H_ - #define _LIBHASH_H_ 1 - -#ifdef __BEOS__ - #include -#endif - -#include "libaspect-list.h" - -/** - * @brief Hash table - */ -typedef struct s_hash -{ - listent_t *ent; - int size; - int elmnbr; - u_int type; - u_char linearity; - char *name; -} hash_t; - -/** - * @brief The hash table of hash tables is accessible to the public - */ -extern hash_t *hash_hash; - -/** - * @brief The hash table of list is accessible to the public - */ -extern hash_t *hash_lists; - -/* hash.c */ -int hash_init(hash_t*, char*, int, u_int); /* Allocate the table */ -hash_t *hash_find(char *name); /* Find a hash table */ -int hash_register(hash_t *h, char *name); /* Register a hash table */ -hash_t *hash_empty(char *name); /* Empty the hash table */ -void hash_destroy(hash_t *h); /* Free the table */ -int hash_add(hash_t*, char*, void *); /* Add an entry */ -int hash_del(hash_t *h, char *key); /* Delete an entry */ -void *hash_get(hash_t *h, char *key); /* Get data from key */ -void *hash_select(hash_t *h, char *key); /* Get an entry pointer */ -listent_t *hash_get_head(hash_t *h, char *b); /* Get a list head */ -listent_t *hash_get_ent(hash_t *h, char *key); /* Get an entry metadata */ -void hash_print(hash_t *h); /* Print the hash table */ -char** hash_get_keys(hash_t *h, int* n); /* Create array of keys */ -void hash_free_keys(char **keys); /* Free keys */ -int hash_apply(hash_t *h, void *ptr, - int (*f)(listent_t *e, void *p)); /* Apply function */ -int hash_merge(hash_t *dst, hash_t *src); /* Fuse hashes */ -int hash_unmerge(hash_t *dst, hash_t *src); /* Quotient hashes */ -int hash_size(hash_t *hash); /* Return the elm nbr */ -void* hash_get_one(hash_t *hash); /* Get any object */ -void* hash_get_single(hash_t *hash); /* Get _the_ only object */ -int hash_set(hash_t *h, char *key, void *data); /* Change meta data for a key */ -u_char hash_linearity_get(hash_t *h); /* Get hash table linearity */ -void hash_linearity_set(hash_t *h, u_char v); /* Set hash table linearity */ - -#endif /* _LIBHASH_H_ */ diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/libaspect.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/libaspect.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,488 +0,0 @@ -/** - ** @file libaspect.h - ** - ** @brief The header file for modular objects in the framework - ** - ** Started Dec 22 2006 02:57:03 jfv - ** - ** - ** $Id: libaspect.h,v 1.40 2008-02-16 12:32:27 thor Exp $ - ** - */ -#if !defined(__ASPECT_H__) - #define __ASPECT_H__ 1 - -#ifndef __KERNEL__ - -#include -#include -#include -#include -#include -#include - -/* Debug flags */ -#define __DEBUG_LIST__ 1 - -#ifdef __BEOS__ - #include - #include -#else -#if !defined(__USE_GNU) - #define __USE_GNU -#endif - #include -#endif - -#endif /* __KERNEL__ */ - -/* Endianess definitions */ -#if defined(__linux__) || defined (__BEOS__) - -#ifndef __KERNEL__ - #include -#else - #define __LITTLE_ENDIAN 1234 - #define __BIG_ENDIAN 4321 - #define __PDP_ENDIAN 3412 -#endif - -#elif defined(__FreeBSD__) || defined (__OpenBSD__) || defined(__NetBSD__) - -#include - #define __LITTLE_ENDIAN _LITTLE_ENDIAN - #define __BIG_ENDIAN _BIG_ENDIAN - #if __FreeBSD__ < 5 - #define __BYTE_ORDER __LITTLE_ENDIAN - #else - #define __BYTE_ORDER BYTE_ORDER - #endif - -#elif defined(sun) - - #define __LITTLE_ENDIAN 1234 - #define __BIG_ENDIAN 4321 - -#if !defined(__i386) - #define __BYTE_ORDER __BIG_ENDIAN -#else - #define __BYTE_ORDER __LITTLE_ENDIAN -#endif - -#elif defined(HPUX) - - #include - #undef ADD - #define __LITTLE_ENDIAN LITTLE_ENDIAN - #define __BIG_ENDIAN BIG_ENDIAN - #define __BYTE_ORDER BYTE_ORDER - -#elif defined(IRIX) - - #include - #include - #define __LITTLE_ENDIAN LITTLE_ENDIAN - #define __BIG_ENDIAN BIG_ENDIAN - #define __BYTE_ORDER BIG_ENDIAN - -#endif - -#ifndef swap32 -#define swap32(x) \ - ((uint32_t)( \ - (((uint32_t)(x) & (uint32_t) 0x000000ffU) << 24) | \ - (((uint32_t)(x) & (uint32_t) 0x0000ff00U) << 8) | \ - (((uint32_t)(x) & (uint32_t) 0x00ff0000U) >> 8) | \ - (((uint32_t)(x) & (uint32_t) 0xff000000U) >> 24) )) -#endif - -#ifndef swap16 -#define swap16(x) \ - ((unsigned short)( \ - (((unsigned short)(x) & (unsigned short) 0x00ffU) << 8) | \ - (((unsigned short)(x) & (unsigned short) 0xff00U) >> 8) )) -#endif - -#ifndef swap64 -#define swap64(x) \ - ((uint64_t)( \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x00000000000000ffULL) << 56) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x000000000000ff00ULL) << 40) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x0000000000ff0000ULL) << 24) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x00000000ff000000ULL) << 8) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x000000ff00000000ULL) >> 8) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x0000ff0000000000ULL) >> 24) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0x00ff000000000000ULL) >> 40) | \ - ((uint64_t)(((uint64_t)x) & (uint64_t) 0xff00000000000000ULL) >> 56))) -#endif - -/* Include this here since it contains an allocation too */ -#ifndef __KERNEL__ - #include "aproxy.h" -#endif -#include "libaspect-hash.h" -#include "libaspect-list.h" -#include "libaspect-btree.h" -#include "libaspect-profiler.h" - -/* Those types are only the builtin types */ -#define ASPECT_TYPE_UNKNOW 0 /*!< Unknown */ -#define ASPECT_TYPE_RAW 1 /*!< Raw */ -#define ASPECT_TYPE_BYTE 2 /*!< Byte */ -#define ASPECT_TYPE_STR 3 /*!< String */ -#define ASPECT_TYPE_SHORT 4 /*!< 2 bytes */ -#define ASPECT_TYPE_INT 5 /*!< 4 bytes */ -#define ASPECT_TYPE_LONG 6 /*!< 4 or 8 bytes */ -#define ASPECT_TYPE_DADDR 7 /*!< 4 or 8 bytes */ -#define ASPECT_TYPE_CADDR 8 /*!< 4 or 8 bytes */ -#define ASPECT_TYPE_BIT 9 /*!< just 1 bit */ -#define ASPECT_TYPE_CORENUM 10 /*!< Core types number */ - -/* Vectors, tables and hash are considered simple types : - you cannot copy them or look inside them without foreach */ -#define ASPECT_TYPE_VECT 10 /*!< Vector type */ -#define ASPECT_TYPE_HASH 11 /*!< Hash table type */ -#define ASPECT_TYPE_LIST 12 /*!< List type */ -#define ASPECT_TYPE_SIMPLENUM 13 /*!< SIMPLE TYPES NUMBER */ - -/* Now come complex types which are part of the base types */ -#define ASPECT_TYPE_EXPR 13 /*!< Expression type */ -#define ASPECT_TYPE_BLOC 14 /*!< Block type */ -#define ASPECT_TYPE_FUNC 15 /*!< Function type */ -#define ASPECT_TYPE_BASENUM 16 /*!< BASE TYPES NUMBER */ - -/* Type names */ -#define ASPECT_TYPENAME_UNKNOW "unknown" -#define ASPECT_TYPENAME_RAW "raw" -#define ASPECT_TYPENAME_BYTE "byte" -#define ASPECT_TYPENAME_BIT "bit" -#define ASPECT_TYPENAME_STR "string" -#define ASPECT_TYPENAME_SHORT "short" -#define ASPECT_TYPENAME_INT "int" -#define ASPECT_TYPENAME_LONG "long" -#define ASPECT_TYPENAME_DADDR "daddr" -#define ASPECT_TYPENAME_CADDR "caddr" - -#define ASPECT_TYPENAME_VECT "vector" -#define ASPECT_TYPENAME_HASH "hash" -#define ASPECT_TYPENAME_LIST "list" -#define ASPECT_TYPENAME_EXPR "expr" -#define ASPECT_TYPENAME_BLOC "bloc" -#define ASPECT_TYPENAME_FUNC "func" - -/* Max pointer depth for a compound type */ -#define ASPECT_TYPE_MAXPTRDEPTH 1 - -/* A structure for the type information */ -typedef struct s_info -{ - char *name; - u_int size; -} typeinfo_t; - - -/** - * @brief Structure for type - */ -typedef struct s_type -{ - u_int type; /*!< @brief Plain or pointed type */ - - u_char isptr; /*!< @brief the type is a pointer */ - u_int size; /*!< @brief Type full memsize */ - u_int off; /*!< @brief Offset inside parent */ - - u_int dimnbr; /*!< @brief Nbr of array dimensions */ - u_int *elemnbr; /*!< @brief Nbr of elements per dim */ - char *name; /*!< @brief Type name */ - char *fieldname; /*!< @brief Field name */ - - /* We have a list of child, and a list - ** of nexts in case we are ourselves - ** a child of a structure object */ - struct s_type *childs; /*!< @brief Curobj fields if any */ - struct s_type *next; /*!< @brief Next parent field */ -} aspectype_t; - - -/** - * @brief The structure of multidimensional vectors - */ -typedef struct s_vector -{ - void *hook; /*!< @brief The vector data */ - void *register_func; /*!< @brief Registration function */ - void *default_func; /*!< @brief Default registered function */ - u_int *arraydims; /*!< @brief Size of each dimension */ - char **strdims; /*!< @brief Label for each dimension */ - u_int arraysz; /*!< @brief Number of dimensions */ - u_int type; /*!< @brief Elements type in this vector */ -} vector_t; - - -/** - * @brief Structure to define a generic container - */ -typedef struct s_container -{ - unsigned int id; /* !< @brief unique id of this container */ - u_int type; /* !< @brief Contained object type */ - u_int nbrinlinks; /* !< @brief Number of -ondisk- input links */ - u_int nbroutlinks; /* !< @brief Number of -ondisk- output links */ - list_t *inlinks; /* !< @brief Input links for this container */ - list_t *outlinks; /* !< @brief Output links for this container */ - void *data; /* !< @brief Pointer to the contained object */ -} container_t; - - -/** - * @brief Input and Output links for containers - */ -#define CONTAINER_LINK_IN 0 -#define CONTAINER_LINK_OUT 1 - -/** - * @brief Config related data types - */ -#define CONFIG_HASH_SIZE 256 - -/** - * @brief Default names for config names - */ -#define CONFIG_NAME_SAFEMODE "safemode" -#define CONFIG_USE_ASMDEBUG "asm.debug" -#define CONFIG_CFGDEPTH "mjr.cfg_depth" - -/** - * @brief Config flags - */ -#define CONFIG_SAFEMODE_OFF 0 -#define CONFIG_SAFEMODE_ON 1 -#define CONFIG_CFGDEPTH_DEFAULT 30 - -/** - * @brief libasm related config - */ -#define CONFIG_ASM_ENDIAN_FLAG "libasm.endian.flag" -#define CONFIG_ASM_LITTLE_ENDIAN 0 -#define CONFIG_ASM_BIG_ENDIAN 1 - -#define CONFIG_ASM_ATT_MARGIN_DEFAULT 14 -#define CONFIG_ASM_ATT_MARGIN_FLAG "libasm.output.att.margin" - -/* A configuration item */ -typedef struct s_config_item -{ - char *name; -#define CONFIG_TYPE_INT 0 -#define CONFIG_TYPE_STR 1 - u_int type; /*!< int will use val, str *data */ - - /* RO/RW - it's relevant to higher api - like revm_ allows direct updates to those values - when RW is set and enforces usage of revm_api - when RO is set (see profile) */ - u_int val; /*!< For int values 0-off/1-on ... */ -#define CONFIG_MODE_RW 0 -#define CONFIG_MODE_RO 1 - u_int mode; - void *data; -} configitem_t; - - - -/** - * The library has its world itself - * There stands all the flags that are used by libelfsh - */ -typedef struct s_aspectworld -{ - hash_t config_hash; /*!< Configuration */ - u_char kernel_mode; /*!< Kernel residence */ - -#define PROFILE_NONE 0 -#define PROFILE_WARN (1 << 0) -#define PROFILE_FUNCS (1 << 1) -#define PROFILE_ALLOC (1 << 2) -#define PROFILE_DEBUG (1 << 3) - u_char proflevel; /*!< Profiling switch */ - u_char profstarted; /*!< Profiling started ? */ - int (*profile)(char *); /*!< Profiling output func */ - int (*profile_err)(char *); /*!< Profiling error func */ - - /* Libui pointers */ - void (*endline)(); - - /* Simple */ - char *(*colorinstr)(char *text); - char *(*colorstr)(char *t); - char *(*colorfieldstr)(char *t); - char *(*colortypestr)(char *t); - char *(*colorend)(char *text); - char *(*colorwarn)(char *text); - char *(*colorfunction)(char *text); - char *(*colorfilename)(char *text); - /* Advanced */ - char *(*coloradv)(char *ty, char *p, char *te); - char *(*colorinstr_fmt)(char* p, char *t); - char *(*coloraddress)(char *p, u_long a); - char *(*colornumber)(char *p, u_int n); - char *(*colorstr_fmt)(char *p, char *t); - char *(*colorfieldstr_fmt)(char *p, char *t); - char *(*colortypestr_fmt)(char *p, char *t); - char *(*colorwarn_fmt)(char *pattern, char *text); -} aspectworld_t; - -/* Make it accessible from all files */ -extern aspectworld_t aspectworld; - -/* Low-level constructor-time related functions */ -int aspect_init(); -void aspect_called_ctors_inc(); -int aspect_called_ctors_finished(); -void e2dbg_presence_set(); -void e2dbg_presence_reset(); -u_char e2dbg_presence_get(); -u_char e2dbg_kpresence_get(); -void e2dbg_kpresence_set(u_char pres); - -/* Retreive pointer on the vector hash table */ -hash_t* aspect_vecthash_get(); - -/* Retreive a vector from the vectors hash table */ -vector_t* aspect_vector_get(char *name); - -/* Add the function pointer to the hook at requested coordonates */ -void aspect_vectors_insert(vector_t *vect, - unsigned int *dim, - unsigned long fct); - -/* Get the hook from the dimension array */ -void* aspect_vectors_select(vector_t *vect, - unsigned int *dim); - -/* Project each dimension and get the requested data pointer */ -void *aspect_vectors_selectptr(vector_t *vect, - unsigned int *dim); - -/* Add a new vector */ -int aspect_register_vector(char *, void*, - unsigned int*, - char **, unsigned int, - unsigned int); - -/* Container related functions */ -container_t *container_create(u_int type, void *data, list_t *in, list_t *out); -int container_linklists_create(container_t *container, - u_int linktype); - -/* Type related functions */ -int aspect_type_simple(int typeid); -char *aspect_type_get(u_int type); -u_int aspect_typesize_get(u_int type); -int aspect_basetypes_create(); -int aspect_type_find_union_size(aspectype_t *type); -int aspect_type_register_real(char *label, - aspectype_t *ntype); -aspectype_t *aspect_type_create(u_char isunion, - char *label, - char **fields, - u_int fieldnbr); -int aspect_type_register(u_char isunion, - char *label, - char **fields, - u_int fieldnbr); -aspectype_t *aspect_type_copy(aspectype_t *type, - unsigned int off, - u_char isptr, - u_int elemnbr, - char *fieldname, - u_int *dims); -aspectype_t *aspect_type_copy_by_name(aspectype_t *type, char *name, hash_t *fields, u_int, u_int); -int aspect_basetype_register(char *name, u_int size); -typeinfo_t *aspect_basetype_get(unsigned int *nbr); -aspectype_t *aspect_type_get_by_name(char *name); -aspectype_t *aspect_type_get_by_id(unsigned int id); -aspectype_t *aspect_type_get_child(aspectype_t *parent, char *name); -char *aspect_typename_get(u_int typeid); - -/* profile.c : Profiler related functions */ -void profiler_reset(u_int sel); -int profiler_print(char *file, char *func, - u_int line, char *msg); -void profiler_err(char *file, char *func, - u_int line, char *msg); -void profiler_out(char *file, char *func, u_int line); - -void profiler_error(); -void profiler_incdepth(); -void profiler_decdepth(); -void profiler_updir(); -int profiler_enabled(); -int profiler_is_enabled(u_char mask); -u_char profiler_started(); -void profiler_error_reset(); -int profiler_enable_err(); -int profiler_enable_out(); -int profiler_enable_alloc(); -int profiler_enable_debug(); -int profiler_disable_err(); -int profiler_disable_out(); -int profiler_disable_alloc(); -int profiler_disable_debug(); -int profiler_disable_all(); -int profiler_enable_all(); - -void profiler_install(int (*profile)(char *), - int (*profile_err)(char *)); - -/* The allocation profiler */ -void profiler_alloc_warnprint(char *s, int fat, int i); -void profiler_alloc_warning(u_char warntype); -void profile_alloc_shift(); -int profiler_alloc_update(char *file, char *func, - u_int line, u_long addr, - u_char atype, u_char otype); -profallocentry_t *profiler_alloc_find(u_char direction, - u_long addr, - u_char optype); - -/* Color related handlers for the profiler */ -void profiler_setcolor(void (*endline)(), - char *(*colorinstr)(char *text), - char *(*colorstr)(char *t), - char *(*colorfieldstr)(char *t), - char *(*colortypestr)(char *t), - char *(*colorend)(char *text), - char *(*colorwarn)(char *text), - char *(*colorfunction)(char *text), - char *(*colorfilename)(char *text)); -void profiler_setmorecolor(char *(*coloradv)(char *ty, - char *p, - char *te), - char *(*colorinstr_fmt)(char* p, - char *t), - char *(*coloraddress)(char *p, - u_long a), - char *(*colornumber)(char *p, - u_int n), - char *(*colorstr_fmt)(char *p, - char *t), - char *(*colorfieldstr_fmt)(char *p, - char *t), - char *(*colortypestr_fmt)(char *p, - char *t), - char *(*colorwarn_fmt)(char *pat, - char *text)); - -/* config.c : Configuration related fonctions */ -void config_init(); -void config_add_item(char *name, u_int type, - u_int mode, void *dat); -void config_update_key(char *name, void *data); -void *config_get_data(char *name); -void config_safemode_set(); -void config_safemode_reset(); -int config_safemode(); - -#endif diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-list.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-list.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-list.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-list.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/* -** @file libaspect-list.h -** -** @brief Prototypes of API for ERESI lists -** -** Started on Fri Jul 13 20:25:42 2007 jfv -** $Id: libaspect-list.h,v 1.8 2008-02-16 12:32:27 thor Exp $ -*/ - -#ifndef _LIBLIST_H_ - #define _LIBLIST_H_ 1 - -/** - * @brief List entry data structure - */ -typedef struct s_listent -{ - char *key; - void *data; - struct s_listent *next; -} listent_t; - -/** - * @brief List data structure - */ -typedef struct s_aspect_list -{ - listent_t *head; - int elmnbr; - u_int type; - u_char linearity; - char *name; -} list_t; - -/* list.c */ -int elist_init(list_t *, char*, u_int); /* Allocate the list */ -list_t *elist_find(char *name); /* Find a list */ -int elist_register(list_t *h, char *name); /* Register a list */ -list_t *elist_empty(char *name); /* Empty the list */ -list_t *elist_reverse(list_t *l); /* Reverse the list */ -void elist_destroy(list_t *h); /* Free the list */ -list_t *elist_copy(list_t *h); /* Copy a list */ -int elist_add(list_t *h, char *k, void *d); /* Add an entry */ -int elist_del(list_t *h, char *key); /* Delete an entry */ -void *elist_get(list_t *h, char *key); /* Get data from key */ -void *elist_select(list_t *h, char *key); /* Get an entry pointer */ -listent_t *elist_get_head(list_t *h); /* Get a list head */ -listent_t *elist_get_ent(list_t *h, char *key); /* Get an entry metadata */ -void elist_print(list_t *h); /* Print the list */ -char** elist_get_keys(list_t *h, int* n); /* Create array of keys */ -void elist_free_keys(char **keys); /* Free keys */ -int elist_apply(list_t *h, void *ptr, - int (*f)(listent_t *e, void *p)); /* Apply function */ -int elist_merge(list_t *dst, list_t *src); /* Fuse lists */ -int elist_unmerge(list_t *dst, list_t *src); /* Quotient lists */ -int elist_size(list_t *hash); /* Return the elm nbr */ -int elist_set(list_t *h, char *key, void *data); /* Change meta data for a key */ -int elist_replace(list_t *h, char *k, list_t *nl); /* Replace one elem by a list */ -int elist_compare(list_t *first, list_t *two); /* Compare the content of 2 lists */ -u_char elist_linearity_get(list_t *l); /* Get linearity of a list */ -void elist_linearity_set(list_t *l, u_char val); /* Set linearity of a list */ - -#endif /* _LIBLIST_H_ */ diff -Nru eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-profiler.h.svn-base eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-profiler.h.svn-base --- eresi-0.8a25/libaspect/include/.svn/text-base/libaspect-profiler.h.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/include/.svn/text-base/libaspect-profiler.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -/* -** @file libelfsh-internal.h -** -** Started on Wed Jan 1 07:51:24 2003 jfv -** Last update Thu Mar 20 06:19:53 2003 jfv -** -** $Id: libaspect-profiler.h,v 1.9 2007-08-03 11:50:59 heroine Exp $ -** -*/ - -#ifndef __LIBASPECT_INTERN_ - #define __LIBASPECT_INTERN_ - -#if defined(sun) || defined(__linux__) || defined(__BEOS__) || defined(HPUX) || defined(__FreeBSD__) - #define PROFILER_ERRORS_ARRAY strerror(errno) -#else - #define PROFILER_ERRORS_ARRAY sys_errlist[sys_nerr] -#endif - -/* Extern variables */ -extern int profiler_depth; -extern char* profiler_error_str; -extern int aspect_type_nbr; -extern hash_t *vector_hash; -extern hash_t types_hash; - - -/** - * Type of warnings that emit the allocation profiler - */ -#define PROFILER_WARNING_UNKNOW 0 -#define PROFILER_WARNING_LAST 1 -#define PROFILER_WARNING_FIRST 2 - -/** - * The structure for an allocation entry - */ -typedef struct s_allocentry -{ -#define PROFILER_ALLOC_UNKNOW 0 -#define PROFILER_ALLOC_LEGIT 1 -#define PROFILER_ALLOC_PROXY 2 - u_char alloctype; /*!< Inform about the allocator */ - -#define PROFILER_OP_UNKNOW 0 -#define PROFILER_OP_ALLOC 1 -#define PROFILER_OP_REALLOC 2 -#define PROFILER_OP_FREE 3 - u_char optype; /*!< Inform about alloc/free/etc */ - char *filename; /*!< Inform about file location */ - char *funcname; /*!< Inform about func location */ - u_int linenbr; /*!< Inform about line number */ - u_long addr; /*!< Address of allocation */ -} profallocentry_t; - -/** - * Maximum function calls patterns depth - */ -#define PROFILER_MAX_PATTERN 10 -#define PROFILER_MAX_ALLOC 2000 - - -/** - * Safe calloc() - */ -#define XALLOC(f, fc, l, a, b, c) \ -do \ -{ \ - if ((a = (void *) calloc(b, 1)) == NULL) \ - { \ - write(1, "Out of memory\n", 14); \ - exit(1); \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)"Out of memory .", c); \ - } \ - if (profiler_started()) \ - profiler_alloc_update(f, (char *) fc, l, (u_long) a, \ - PROFILER_ALLOC_PROXY, \ - PROFILER_OP_ALLOC); \ -} \ -while (0) - -/** - * Safe realloc() - */ -#define XREALLOC(f, fc, l, a, b, c, d) \ -do \ -{ \ - if ((a = (void *) realloc(b, c)) == NULL) \ - { \ - write(1, "Out of memory\n", 14); \ - exit(1); \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Out of memory .", d); \ - } \ - if (profiler_started()) \ - profiler_alloc_update(f, (char *) fc, l, (u_long) a, \ - PROFILER_ALLOC_PROXY, \ - PROFILER_OP_REALLOC); \ -} \ -while (0) - -/** - * Our free() - */ -#define XFREE(f, fc, l, a) \ -do \ -{ \ - if (profiler_started()) \ - profiler_alloc_update(f, (char *) fc, l, (u_long) a, \ - PROFILER_ALLOC_PROXY, \ - PROFILER_OP_FREE); \ - free(a); \ - a = 0; \ -} \ -while (0) - -/** - * Our strdup() - */ -#define XSTRDUP(f, fc, l, a, b) \ -do \ -{ \ - if (profiler_started()) \ - profiler_alloc_update(f, (char *) fc, l, (u_long) a, \ - PROFILER_ALLOC_PROXY, \ - PROFILER_OP_ALLOC); \ - a = strdup(b); \ -} \ -while (0) - -/** - * Safe open() - */ -#define XOPEN(a, b, c, d, e) \ -do \ -{ \ - if ((a = open(b, c, d)) < 0) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Cannot open file", e); \ -} \ -while (0) - -/** - * Safe read() - */ -#define XREAD(a, b, c, d) \ -do \ -{ \ - if (read(a, b, c) != c) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *) PROFILER_ERRORS_ARRAY, d); \ -} \ -while (0) - -/** - * Safe lseek() - */ -#define XSEEK(a, b, c, d) \ -do \ -{ \ - if (lseek(a, b, c) == (off_t) -1) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *) PROFILER_ERRORS_ARRAY, d); \ -} \ -while (0) - -/** - * Safe write - */ -#define XWRITE(a, b, c, d) \ -do \ -{ \ - if (write(a, b, c) != c) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *) PROFILER_ERRORS_ARRAY, d); \ - if (fsync(a)) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *) PROFILER_ERRORS_ARRAY, d); \ -} \ -while (0) - -/** - * Safe close - */ -#define XCLOSE(a, b) \ -do \ -{ \ - if (close(a)) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)PROFILER_ERRORS_ARRAY, b); \ -} \ -while (0) - -/** - * @brief Safe mmap - */ -#define XMMAP(a, b, c, d, e, f, g, h) \ -do \ -{ \ - if ((a = mmap(b, c, d, e, f, g)) == MAP_FAILED) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)PROFILER_ERRORS_ARRAY, h); \ -} \ -while (0) - - -/** - * @brief Safe munmap - */ -#define XMUNMAP(a, b, c) \ -do \ -{ \ - if (munmap(a, b) == -1) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)PROFILER_ERRORS_ARRAY, c); \ -} \ -while(0) - -/** - * @brief Safe msync - */ -#define XMSYNC(a, b, c, d) \ -do \ -{ \ - if (msync(a, b, c) == -1) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)PROFILER_ERRORS_ARRAY, d); \ -} \ -while(0) - -/** - * @brief Safe lseek64 - */ -#define XLSEEK64(a, b, c, d) \ -do \ -{ \ - if (lseek64(a, (off64_t)b, c) == -1) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - (char *)PROFILER_ERRORS_ARRAY, d); \ -} \ -while(0) - - -/** - * Simple useful macro - */ -#define INTERVAL(a, b, c) (a <= b && b < c) - -/** - * Profiling macros - */ -#define NOPROFILER_IN() int profileme = 0 - -#define NOPROFILER_OUT() \ -do \ -{ \ - profileme = 0; \ - return; \ -} \ -while (0) - -#define NOPROFILER_ROUT(r) \ -do \ -{ \ - profileme = 0; \ - return (r); \ -} \ -while (0) - -#define PROFILER_IN(file, fun, lin) \ -int profileme = profiler_depth; \ -do { \ - if (profiler_started()) { \ - profiler_updir(); \ - profiler_out(file, (char*) fun, lin); \ - profiler_incdepth(); } \ -} while (0) - -#define PROFILER_OUT(file, func, line) \ -do { \ - if (profiler_started()) { \ - profiler_decdepth(); \ - if (profileme != profiler_depth) \ - { \ - printf(" [!] A function called by current" \ - "forgot to decrement profiler_depth" \ - "(%d %d)\n", \ - profileme, profiler_depth); \ - printf(" Current FUNCTION %s@%s:%d\n", \ - func, file, line); \ - profiler_depth = profileme; \ - } \ - profiler_out(file, (char*) func, line); } \ - return; \ -} while (0) - -#define PROFILER_ROUT(file, f, l, ret) \ -do { \ - if (profiler_started()) { \ - profiler_decdepth(); \ - if (profileme != profiler_depth) \ - { \ - printf(" [!] A function called by current " \ - "forgot to decrement profiler_depth" \ - "(%d %d)\n", profileme, \ - profiler_depth); \ - printf(" Current FUNCTION %s@%s:%d\n", \ - f, file, l); \ - profiler_depth = profileme; \ - } \ - profiler_out(file, (char*) f, l); } \ - return ret; \ -} while (0) - -#define PROFILER_ERR(file, f, l, m, r) \ -do { \ - if (profiler_started()) { \ - profiler_decdepth(); \ - if (profileme != profiler_depth) \ - { \ - printf(" [!] A function called by current " \ - "one forgot to decrement " \ - "profiler_depth\n"); \ - printf(" Current FUNCTION %s@%s:%d\n", \ - f, file, l); \ - profiler_depth = profileme; \ - } \ - profiler_error_str = m; \ - profiler_err(file, (char*) f, l, m); } \ - return r; \ -} while (0) - -#define PROFILER_RERR(file, f, l, m) \ -do { \ - if (profiler_started()) { \ - profiler_decdepth(); \ - if (profileme != profiler_depth) \ - { \ - printf("a function called by the current " \ - "one forgot to decrement " \ - "profiler_depth\n"); \ - printf("current FUNCTION %s@%s:%d\n", \ - f, file, l); \ - profiler_depth = profileme; \ - } \ - profiler_error_str = m; \ - profiler_err(file, (char*) f, l, m); } \ -} while (0) - - - -/** - * Debugging macro - */ -#ifdef ELFSH_DEBUG -#define PROFILER_DEBUG(fi, f, l, fm, a...) do \ - { \ - if (profiler_started() && dbgworld.proflevel >= PROFILE_DEBUG) \ - { \ - char dbg[BUFSIZ]; \ - snprintf(dbg, BUFSIZ, " [D]<%s@%s:%d> ", f, fi, l); \ - dbgworld.profile(dbg); \ - snprintf(dbg, BUFSIZ, fm, ##a); \ - dbgworld.profile(dbg); \ - dbgworld.profile("\n"); \ - } \ - while (0) -#endif - - -#endif diff -Nru eresi-0.8a25/libaspect/init.c eresi-0.0.20110516/libaspect/init.c --- eresi-0.8a25/libaspect/init.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/init.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,12 +1,13 @@ /** -** @file vectors.c +* @file libaspect/init.c +** @ingroup libaspect ** -** @brief Implement the modularity for the framework +** @brief Implement the modularity for the framework. ** ** Started Dec 22 2006 02:57:03 jfv ** ** -** $Id: init.c,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: init.c 1439 2010-12-13 10:27:16Z may $ ** */ #include "libaspect.h" @@ -19,6 +20,8 @@ static u_char called_ctors = 0; static u_char dbgpresent = 0; +static u_char kshpresent = 0; +static u_char kdbgpresent = 0; /** * @brief Count the number of constructors already called in the framework (update internal variable) @@ -77,6 +80,46 @@ } +/** + * @brief Set kernsh presence flag + */ +void kernsh_present_set() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + kshpresent = 1; + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/** + * @brief Get presence of kernsh + * @return 1 on success, 0 on error + */ +int kernsh_is_present() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, kshpresent); +} + +/** + * @brief Set presence of kedbg + */ +void kedbg_present_set() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + kdbgpresent = 1; + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/** + * @brief Get presence of kedbg + * @return 1 on success, 0 on error + */ +int kedbg_is_present() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, kdbgpresent); +} + /** Are we in kernel mode */ u_char e2dbg_kpresence_get() { @@ -120,10 +163,13 @@ aspectworld.proflevel = PROFILE_NONE; + + /* XXX: should go in their respective library */ + config_add_item(CONFIG_CFGDEPTH, CONFIG_TYPE_INT, CONFIG_MODE_RW, - CONFIG_CFGDEPTH_DEFAULT); + (void *) CONFIG_CFGDEPTH_DEFAULT); config_add_item(CONFIG_NAME_SAFEMODE, CONFIG_TYPE_INT, @@ -133,12 +179,17 @@ config_add_item(CONFIG_ASM_ENDIAN_FLAG, CONFIG_TYPE_INT, CONFIG_MODE_RW, - (void *)CONFIG_ASM_LITTLE_ENDIAN); - - config_add_item(CONFIG_ASM_ATT_MARGIN_FLAG, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *)CONFIG_ASM_ATT_MARGIN_DEFAULT); + (void *) CONFIG_ASM_LITTLE_ENDIAN); + + config_add_item(CONFIG_ASM_ATT_MARGIN_FLAG, + CONFIG_TYPE_INT, + CONFIG_MODE_RW, + (void *) CONFIG_ASM_ATT_MARGIN_DEFAULT); + + config_add_item(CONFIG_ASM_SYNTHINSTRS, + CONFIG_TYPE_INT, + CONFIG_MODE_RW, + (void *) CONFIG_ASM_SYNTHINSTRS_DEFAULT); } diff -Nru eresi-0.8a25/libaspect/libbtree.c eresi-0.0.20110516/libaspect/libbtree.c --- eresi-0.8a25/libaspect/libbtree.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/libbtree.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,12 +1,13 @@ /** ** -** @file libbtree.c +* @file libaspect/libbtree.c +** @ingroup libaspect ** ** Author : <087432084750432042> ** Started : Fri Oct 17 14:29:24 2003 ** Updated : Thu Nov 27 23:29:29 2003 ** -** $Id: libbtree.c,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: libbtree.c 1397 2009-09-13 02:19:08Z may $ ** */ diff -Nru eresi-0.8a25/libaspect/libhash.c eresi-0.0.20110516/libaspect/libhash.c --- eresi-0.8a25/libaspect/libhash.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/libhash.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,11 +1,12 @@ -/* -** @file libhash.c -** -** @brief Contain ELFsh internal hashtables library calls -** -** Started on Fri Jan 24 20:26:18 2003 jfv -** $Id: libhash.c,v 1.41 2007-11-28 08:18:17 may Exp $ -*/ +/** +* @file libaspect/libhash.c + * @ingroup libaspect + * + * @brief Contain ELFsh internal hashtables library calls. + * + * Started on Fri Jan 24 20:26:18 2003 jfv + * $Id: libhash.c 1443 2011-01-14 06:37:39Z may $ + */ #include "libaspect.h" @@ -14,6 +15,11 @@ /** * @brief Initialize the hash table + * @param h Pointer to the hash to initialize + * @param name Name of the hash. + * @param size Size to document + * @param type Type to document + * @param Returns 0 on success, -1 on error or 1 if hash already exists. */ int hash_init(hash_t *h, char *name, int size, u_int type) { @@ -40,6 +46,8 @@ #endif NOPROFILER_ROUT(1); } + + //printf("INIT HASH %s \n", name); /* Add a new element */ XALLOC(__FILE__, __FUNCTION__, __LINE__, @@ -61,6 +69,8 @@ /** * @brief Return a hash table by its name + * @param name Name of the hash to retrieve. + * @return A pointer to a hash_t structure or NULL on error. */ hash_t *hash_find(char *name) { @@ -69,9 +79,14 @@ return ((hash_t *) hash_get(hash_hash, name)); } -/* Return a hash table pointer by its name */ -/* Overwrite existing table if there was one sharing that name, only - if both tables have the same elements type */ +/** + * Return a hash table pointer by its name. + * Overwrite existing table if there was one sharing that name, only + * if both tables have the same elements type + * @param table + * @param name + * @return + */ int hash_register(hash_t *table, char *name) { hash_t *h; @@ -100,6 +115,8 @@ /** * @brief Empty a hash table + * @param name Name of the ash table to empty. + * @param returrn a pointer to the hash table or NULL on error. */ hash_t *hash_empty(char *name) { @@ -110,25 +127,29 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); hash = hash_find(name); - if (!hash) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); + //printf("EMPTY HASH %s \n", name); + size = hash->size; type = hash->type; hash_del(hash_hash, name); hash_destroy(hash); XALLOC(__FILE__, __FUNCTION__, __LINE__, newname, strlen(name) + 1, NULL); - strcpy(newname, name); + strncpy(newname, name, strlen(name)); hash_init(hash, newname, size, type); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, hash); } -/* Destroy a hash table */ -void hash_destroy(hash_t *h) +/** + * Destroy a hash table. + * @param hash Pointer to the hash to destroy + */ +void hash_destroy(hash_t *hash) { char **keys; int idx; @@ -136,21 +157,27 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + //printf("DESTROY HASH %s \n", hash->name); + /* We should not destroy the elements as they might be in other hashes */ - keys = hash_get_keys(h, &keynbr); + keys = hash_get_keys(hash, &keynbr); for (idx = 0; idx < keynbr; idx++) if (keys[idx]) XFREE(__FILE__, __FUNCTION__, __LINE__, keys[idx]); if (keys) hash_free_keys(keys); - hash_del(hash_hash, h->name); - XFREE(__FILE__, __FUNCTION__, __LINE__, h->ent); + hash_del(hash_hash, hash->name); + XFREE(__FILE__, __FUNCTION__, __LINE__, hash->ent); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } /** - * @brief Add an entry to the hash table + * @brief Add an entry to the hash table. + * @param h Hash table. + * @param key Key of the new entry. + * @param data Value associated with the key. + * @return Returns an index (to document) */ int hash_add(hash_t *h, char *key, void *data) { @@ -166,6 +193,8 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameters", -1); + //printf("ADD %s in HASH %s \n", key, h->name); + /* If the element already exist, make sure we erase the existing one */ actual = hash_get(h, key); if (actual) @@ -197,11 +226,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, index); } - - - -/** - * @brief Delete an entry from the hash table +/** + * @brief Delete an entry from the hash table. + * @param */ int hash_del(hash_t *h, char *key) { @@ -229,7 +256,8 @@ /* Looking for the good entry in the list for this hash value */ while (actual->next != NULL && actual->next->key != NULL && - strcmp(actual->next->key, key)) + strcmp(actual->next->key, + key)) actual = actual->next; /* Not found */ @@ -244,10 +272,11 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - -/** +/** * @brief Retrieve the metadata for a given key + * + * @param h + * @param key */ void *hash_get(hash_t *h, char *key) { @@ -256,12 +285,18 @@ actual = hash_get_head(h, key); while (actual != NULL && actual->key != NULL && - strcmp(actual->key, key)) + strcmp(actual->key, + key)) actual = actual->next; return (actual != NULL ? actual->data : NULL); } -/* Retrieve the data pointer for a given key */ +/** + * Retrieve the data pointer for a given key + * + * @param h + * @param key + */ void *hash_select(hash_t *h, char *key) { listent_t *actual; @@ -276,7 +311,13 @@ -/* Change the metadata for an existing entry, giving its key */ +/** + * Change the metadata for an existing entry, giving its key + * @param h + * @param key + * @param data + * @return + */ int hash_set(hash_t *h, char *key, void *data) { listent_t *ent; @@ -291,6 +332,9 @@ /** * @brief Retrieve the -entry- for a given key + * @param h + * @param key + * @return */ listent_t *hash_get_ent(hash_t *h, char *key) { @@ -304,9 +348,12 @@ return (actual); } - - -/* Retreive a Hash entry head giving the key */ +/** + * Retreive a Hash entry head giving the key * + * @param h + * @param backup + * @return + */ listent_t *hash_get_head(hash_t *h, char *backup) { u_int index; @@ -320,6 +367,9 @@ /** * @brief Used to create arrays of keys for completion + * @param h + * @param n + * @return */ char **hash_get_keys(hash_t *h, int *n) { @@ -367,7 +417,10 @@ PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } -/* Print the hash table (DEBUG PURPOSE) */ +/** + * Print the hash table (DEBUG PURPOSE) + * @param h Hash table. + */ void hash_print(hash_t *h) { listent_t *actual; @@ -387,7 +440,11 @@ } /** - * @brief Apply func all entries + * @brief Apply func all entries . + * @param h + * @param ptr + * @param func + * @return */ int hash_apply(hash_t *h, void *ptr, @@ -456,10 +513,33 @@ return (0); for (ret = index = 0; index < src->size; index++) for (actual = &src->ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) + actual != NULL && actual->key != NULL; + actual = actual->next) if (!hash_get(dst, actual->key)) - ret += hash_add(dst, actual->key, actual->data); + ret += hash_add(dst, actual->key, actual->data); + return ret; +} + + + +/* Intersect hash tables in the first one */ +int hash_inter(hash_t *dst, hash_t *src) +{ + char **keys; + int keynbr; + int idx; + char *curkey; + int ret; + + if (!src || !dst || src->elmnbr == 0 || dst->elmnbr == 0) + return (0); + keys = hash_get_keys(dst, &keynbr); + for (ret = idx = 0; idx < keynbr; idx++) + { + curkey = keys[idx]; + if (!hash_get(src, curkey)) + ret += hash_del(dst, curkey); + } return ret; } @@ -491,7 +571,11 @@ return (hash ? hash->elmnbr : 0); } -/* Return the only element of this hash */ +/** + * @brief Return the only element of this hash . + * @param hash Hash table. + * @return NULL on error. + */ void *hash_get_single(hash_t *hash) { char **keys; @@ -503,8 +587,13 @@ return (hash_get(hash, keys[0])); } -/* Return an element of this hash */ -/* The choice is non-deterministic */ +/** + * Return an element of this hash + * The choice is non-deterministic. + * + * @param hash + * @return + */ void* hash_get_one(hash_t *hash) { char **keys; @@ -517,7 +606,10 @@ } -/* Linear typing of list API */ +/** + * Linear typing of list API. + * @param h Hash table. + */ u_char hash_linearity_get(hash_t *h) { if (!h) @@ -525,7 +617,11 @@ return (h->linearity); } -/* Linear typing of list API */ +/** + * Linear typing of list API . + * @param h + * @param val + */ void hash_linearity_set(hash_t *h, u_char val) { if (!h) diff -Nru eresi-0.8a25/libaspect/liblist.c eresi-0.0.20110516/libaspect/liblist.c --- eresi-0.8a25/libaspect/liblist.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/liblist.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,18 +1,20 @@ /** -** @file liblist.c -** -** Contain ELFsh internal lists related API -** -** Started on Fri Jul 13 20:26:18 2007 jfv -** $Id: liblist.c,v 1.9 2008-02-16 12:32:27 thor Exp $ -*/ + * @file libaspect/liblist.c + * @ingroup libaspect + * + * @brief Contain ELFsh internal lists related API. + * + * Started on Fri Jul 13 20:26:18 2007 jfv + * $Id: liblist.c 1444 2011-01-31 07:41:29Z may $ + */ + #include "libaspect.h" /* Hash tables of hash tables */ hash_t *hash_lists = NULL; /** - * @brief Initialize the hash table + * @brief Initialize the hash table */ int elist_init(list_t *h, char *name, u_int type) { @@ -34,7 +36,7 @@ #endif NOPROFILER_ROUT(1); } -#if 1 //__LIST_DEBUG__ +#if __LIST_DEBUG__ else fprintf(stderr, "DEBUG: List %s allocated at %p does not exists in hash : CREATING \n", name, h); #endif @@ -74,7 +76,7 @@ h = elist_empty(name); elist_merge(h, list); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } + } XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); elist_init(h, name, h->type); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -98,7 +100,7 @@ elist_destroy(list); XALLOC(__FILE__, __FUNCTION__, __LINE__, newname, strlen(name) + 1, NULL); - strcpy(newname, name); + strncpy(newname, name, strlen(name)); XALLOC(__FILE__, __FUNCTION__, __LINE__, list, sizeof(list_t), NULL); elist_init(list, newname, type); @@ -140,7 +142,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - fprintf(stderr, "DEBUG: Destroying list %s at addr %p \n", h->name, h); + //fprintf(stderr, "DEBUG: Destroying list %s at addr %p \n", h->name, h); /* We should not destroy the elements as they might be in other hashes */ keys = elist_get_keys(h, &keynbr); @@ -177,6 +179,7 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, newelem, size, NULL); memcpy(newelem, curent->data, size); newent->data = newelem; + newent->key = strdup(curent->key); newent->next = NULL; if (prevent) prevent->next = newent; @@ -202,8 +205,7 @@ if (!h || !key || !data) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameters", -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - cur, sizeof(listent_t), -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, cur, sizeof(listent_t), -1); next = h->head; cur->key = key; cur->data = data; @@ -213,6 +215,76 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +/** + * @brief Add an element at the head of the list + */ +int elist_append(list_t *h, char *key, void *data) +{ + listent_t *cur; + listent_t *next; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!h || !key || !data) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameters", -1); + if (!h->head) + { + ret = elist_add(h, key, data); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to append list element", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + XALLOC(__FILE__, __FUNCTION__, __LINE__, cur, sizeof(listent_t), -1); + cur->key = key; + cur->data = data; + cur->next = NULL; + next = h->head; + while (next->next) + next = next->next; + next->next = cur; + h->elmnbr++; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/* + * @brief Push an element on the list (used as a stack) + */ +int elist_push(list_t *h, void *data) +{ + char key[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!h || !data) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameters", -1); + + snprintf(key, sizeof(key), "%s_%u", h->name, h->elmnbr); + elist_add(h, strdup(key), data); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/* + * @brief Pop an element off the list (used as a stack) + */ +void *elist_pop(list_t *h) +{ + listent_t *next; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!h || !h->head) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid input list", NULL); + next = h->head; + h->head = h->head->next; + h->elmnbr--; + XFREE(__FILE__, __FUNCTION__, __LINE__, next); + if (!h->head) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, h->head); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, h->head->data); +} + /** * @brief Delete an element from a list @@ -221,6 +293,7 @@ { listent_t *curelem; listent_t *prevelem; + listent_t *todel; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!h || !key) @@ -234,12 +307,19 @@ if (!curelem) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); if (!prevelem) - h->head = h->head->next; + { + todel = h->head; + h->head = h->head->next; + } else - prevelem->next = prevelem->next->next; + { + todel = prevelem->next; + prevelem->next = prevelem->next->next; + } h->elmnbr--; if (!h->elmnbr) h->head = NULL; + XFREE(__FILE__, __FUNCTION__, __LINE__, todel); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -281,6 +361,14 @@ return (h->head); } +/* Get the list head data */ +void *elist_get_headptr(list_t *h) +{ + if (!h || !h->head) + return (NULL); + return (h->head->data); +} + /* Change the metadata for an existing entry, giving its key */ int elist_set(list_t *h, char *key, void *data) { @@ -305,8 +393,6 @@ listent_t *cur; listent_t *lastent; listent_t *prev; - int idx; - char namebuf[BUFSIZ]; /* Preliminary checks */ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -317,7 +403,7 @@ /* Just find the latest entry */ for (lastent = newlist->head; lastent && lastent->next; lastent = lastent->next); - /* Now find the original element to swap with the new list */ + /* Now find the original element to replace by the new list */ for (prev = NULL, cur = h->head; cur; prev = cur, cur = cur->next) if (!strcmp(cur->key, key)) { @@ -326,8 +412,8 @@ else prev->next = newlist->head; lastent->next = cur->next; - h->elmnbr += newlist->elmnbr; - XFREE(__FILE__, __FUNCTION__, __LINE__, cur->data); + h->elmnbr += newlist->elmnbr - 1; + //XFREE(__FILE__, __FUNCTION__, __LINE__, cur->data); XFREE(__FILE__, __FUNCTION__, __LINE__, cur); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libaspect/Makefile eresi-0.0.20110516/libaspect/Makefile --- eresi-0.8a25/libaspect/Makefile 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/Makefile 2011-05-16 11:34:14.000000000 +0000 @@ -9,8 +9,9 @@ LD = ld RM = rm -f AR = ar rc -CFLAGS32 += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI32 -CFLAGS64 += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI64 +RANLIB = ranlib +CFLAGS32 += -Iinclude -fPIC -g3 -O2 -DERESI32 $(EXTRACFLAGS) +CFLAGS64 += -Iinclude -fPIC -g3 -O2 -DERESI64 $(EXTRACFLAGS) SRC = vectors.c libhash.c libbtree.c types.c init.c \ config.c profiler.c liblist.c containers.c @@ -22,18 +23,16 @@ all : all32 all64 -libaspect32.so : $(OBJ32) - @$(CC) -L../liballocproxy/ -lallocproxy \ - $(DLOPT) -shared $(OBJ32) -o $(NAME32).so +libaspect32.so : $(OBJ32) + @$(CC) -L../liballocproxy/ -lallocproxy $(DLOPT) -shared $(OBJ32) -o $(NAME32).so @$(AR) $(NAME32).a $(OBJ32) @$(RANLIB) $(NAME32).a $(LD) -r $(OBJ32) -o $(NAME32).o all32: libaspect32.so -libaspect64.so : $(OBJ64) - @$(LD) -L../liballocproxy/ -lallocproxy \ - $(DLOPT) -shared $(OBJ64) -o $(NAME64).so +libaspect64.so : $(OBJ64) + @$(LD) -L../liballocproxy/ -lallocproxy $(DLOPT) -shared $(OBJ64) -o $(NAME64).so @$(AR) $(NAME64).a $(OBJ64) @$(RANLIB) $(NAME64).a $(LD) -r $(OBJ64) -o $(NAME64).o @@ -43,7 +42,7 @@ clean : @$(RM) \#* *\# *~ $(OBJ) $(OBJ32) $(OBJ64) .\#* include/\#* \ - include/*\# include/*~ include/.\#* + include/*\# include/*~ include/.\#* $(NAME32).o $(NAME64).o fclean : clean @$(RM) *.so *.a diff -Nru eresi-0.8a25/libaspect/profiler.c eresi-0.0.20110516/libaspect/profiler.c --- eresi-0.8a25/libaspect/profiler.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/profiler.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,11 +1,9 @@ /** -** @file error.c +* @file libaspect/profiler.c +** @ingroup libaspect ** ** Started on Thu Nov 08 02:08:28 2001 mm -** Last update Wed Jun 08 10:01:42 2005 mm -** -** $Id: profiler.c,v 1.10 2008-02-16 12:32:27 thor Exp $ -** +** $Id: profiler.c 1397 2009-09-13 02:19:08Z may $ */ #include "libaspect.h" @@ -109,7 +107,7 @@ /** - * @brief Warn if anything bad is happening + * @brief Warn if anything bad is happening. Good when we cannot use valgrind. * @param warntype Either PROFILER_WARNING_LAST, PROFILER_WARNING_FIRST or PROFILER_WARNING_UNKNOW */ void profiler_alloc_warning(u_char warntype) @@ -140,7 +138,7 @@ /* We do emit a warning if we encountered a double free */ if (allocentries[profiler_adepth].optype == PROFILER_OP_FREE && ent2 && ent2 > ent) - profiler_alloc_warnprint(" [E] A pointer was freed" + profiler_alloc_warnprint(" [A] A pointer was freed" " but it is already free ", 1, profiler_adepth); @@ -149,7 +147,7 @@ allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC) && ent && ent->alloctype != allocentries[profiler_adepth].alloctype) - profiler_alloc_warnprint(" [E] A pointer was freed" + profiler_alloc_warnprint(" [A] A pointer was freed" " but it is was belonging " " to another allocator ", 1, profiler_adepth); @@ -157,21 +155,21 @@ /* We emit a warning when we free without remembering the alloc */ if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC && !ent) - profiler_alloc_warnprint(" [!] A pointer was reallocated but its" + profiler_alloc_warnprint(" [A] A pointer was reallocated but its" " allocation was not found in history", 0, profiler_adepth); /* We emit a warning when we realloc without remembering alloc */ if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC && !ent && !ent2) - profiler_alloc_warnprint(" [!] A pointer was reallocated but its" + profiler_alloc_warnprint(" [A] A pointer was reallocated but its" " allocation was not found in history", 0, profiler_adepth); /* We emit a warning when we realloc something freed */ if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC && ent2 && (ent2 > ent)) - profiler_alloc_warnprint(" [E] A pointer was reallocated but it" + profiler_alloc_warnprint(" [A] A pointer was reallocated but it" " was in a freed state", 1, profiler_adepth); @@ -179,7 +177,7 @@ and this pointer was already allocated after beeing freed */ if (allocentries[profiler_adepth].optype == PROFILER_OP_ALLOC && ent && ((ent > ent2) || (ent > ent3))) - profiler_alloc_warnprint(" [E] A pointer was reallocated" + profiler_alloc_warnprint(" [A] A pointer was reallocated" " without beeing freed ", 1, profiler_adepth); @@ -195,7 +193,7 @@ allocentries[0].addr, PROFILER_OP_FREE); if (!ent) - profiler_alloc_warnprint(" [!] An allocation was removed" + profiler_alloc_warnprint(" [A] An allocation was removed" " from the history without beeing free", 0, 0); break; @@ -204,7 +202,7 @@ default: case PROFILER_WARNING_UNKNOW: if (aspectworld.profile) - aspectworld.profile(" [E] Unknown warning type requested to the " + aspectworld.profile(" [A] Unknown warning type requested to the " "allocator profiler\n"); exit(-1); break; @@ -264,17 +262,15 @@ u_int line, u_long addr, u_char atype, u_char otype) { - //void *profunc; - // XXX: remove this ? - //profunc = aspectworld.profile; - //aspectworld.profile = (void *) printf; + if (aspectworld.proflevel & PROFILE_ALLOC) + printf(" [A] %s@%s:%u %s ADDR %lX \n", func, file, line, + (atype == PROFILER_OP_FREE ? "FREE" : "(RE)ALLOC"), addr); /* Just happens an entry at the end. Check the last entry. */ if (profiler_adepth + 1 != PROFILER_MAX_ALLOC) { profiler_alloc_add(file, func, line, addr, atype, otype); profiler_alloc_warning(PROFILER_WARNING_LAST); - //aspectworld.profile = profunc; return (0); } @@ -284,7 +280,6 @@ profiler_alloc_add(file, func, line, addr, atype, otype); profiler_alloc_warning(PROFILER_WARNING_LAST); - //aspectworld.profile = profunc; return (1); } diff -Nru eresi-0.8a25/libaspect/.svn/all-wcprops eresi-0.0.20110516/libaspect/.svn/all-wcprops --- eresi-0.8a25/libaspect/.svn/all-wcprops 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 33 -/svn/!svn/ver/950/trunk/libaspect -END -liblist.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/945/trunk/libaspect/liblist.c -END -profiler.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/843/trunk/libaspect/profiler.c -END -init.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/937/trunk/libaspect/init.c -END -types.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/945/trunk/libaspect/types.c -END -config.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/843/trunk/libaspect/config.c -END -containers.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/945/trunk/libaspect/containers.c -END -vectors.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/843/trunk/libaspect/vectors.c -END -libbtree.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/843/trunk/libaspect/libbtree.c -END -libhash.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/945/trunk/libaspect/libhash.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/950/trunk/libaspect/Makefile -END diff -Nru eresi-0.8a25/libaspect/.svn/entries eresi-0.0.20110516/libaspect/.svn/entries --- eresi-0.8a25/libaspect/.svn/entries 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libaspect -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -liblist.c -file - - - - -2008-04-06T23:15:53.259877Z -5a1fa2a6533d1ad67b4a2e3602785c29 -2008-03-27T22:24:43.639027Z -945 -may - -profiler.c -file - - - - -2008-04-06T23:15:53.273004Z -c98d3aff841fc5ff96837d92264f8604 -2008-02-16T12:32:28.000000Z -843 -thor - -init.c -file - - - - -2008-04-06T23:15:53.296880Z -2fd949eaf43bca4fe48da0c3219f134d -2008-03-26T15:02:37.962585Z -937 -pouik - -doc -dir - -types.c -file - - - - -2008-04-06T23:15:53.306880Z -5bbe3317c65a3047fdabe433589bda1f -2008-03-27T22:24:43.639027Z -945 -may - -config.c -file - - - - -2008-04-06T23:15:53.317883Z -ed625164042ca07bf12fd82b81b9d47e -2008-02-16T12:32:28.000000Z -843 -thor - -containers.c -file - - - - -2008-04-06T23:15:53.329135Z -d6ab70425b9db9594ecb997f901bb29f -2008-03-27T22:24:43.639027Z -945 -may - -vectors.c -file - - - - -2008-04-06T23:15:53.340944Z -44943f497aac8502de0195c9ab44b461 -2008-02-16T12:32:28.000000Z -843 -thor - -libbtree.c -file - - - - -2008-04-06T23:15:53.352402Z -1643e37ccaa48fa751019cf48d407d2b -2008-02-16T12:32:28.000000Z -843 -thor - -libhash.c -file - - - - -2008-04-06T23:15:53.363876Z -730bd078201b04d6e638f2ec612aeea1 -2008-03-27T22:24:43.639027Z -945 -may - -Makefile -file - - - - -2008-04-06T23:15:53.375147Z -4133e0eb998f50112f7275b14535011c -2008-03-29T07:54:04.209482Z -950 -enioh -has-props - diff -Nru eresi-0.8a25/libaspect/.svn/format eresi-0.0.20110516/libaspect/.svn/format --- eresi-0.8a25/libaspect/.svn/format 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libaspect/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/libaspect/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/libaspect/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libaspect/.svn/text-base/config.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/config.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/config.c.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/config.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,335 +0,0 @@ -/* -** @file state.c -** -** Started on Sat Jun 2 15:20:18 2005 jfv -** $Id: config.c,v 1.12 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - - -aspectworld_t aspectworld; - - - -/** - * @brief Wrapper for updating value depending on data type - * @param item Configuration item structure - * @param data Configuration item value - */ -static void __config_update_item(configitem_t *item, void *data) -{ - - switch(item->type) - { - case CONFIG_TYPE_INT: - item->val = (int)data; - break; - - case CONFIG_TYPE_STR: - item->data = strdup(data); - break; - - default: - break; - } -} - -/** - * @brief Add a configure item to the configuration items hash table - * @param name Configuration item string name - * @param type Configuration item type identifier - * @param mode Configuration mode (RW or RO) - * @param data Configuration item value - */ -void config_add_item(char *name, - u_int type, /* int, string ... */ - u_int mode, /* RW, RO */ - void *data) -{ - configitem_t *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, tmp, sizeof(configitem_t), ); - tmp->name = strdup(name); - tmp->type = type; - tmp->mode = mode; - tmp->val = -1; - tmp->data = NULL; - - __config_update_item(tmp,data); - - if (hash_get(&aspectworld.config_hash,tmp->name) == NULL) - hash_add(&aspectworld.config_hash,tmp->name,tmp); - - PROFILER_OUT(__FILE__,__FUNCTION__,__LINE__); -} - -/** - * @brief Update value of an existing configuration item - * @param name Configuration item string name - * @param data Configuration item value - */ -void config_update_key(char *name,void *data) -{ - configitem_t *tmp; - - tmp = (configitem_t *) hash_get(&aspectworld.config_hash,name); - if (tmp == NULL) - return; - - __config_update_item(tmp,data); - hash_del(&aspectworld.config_hash, name); - hash_add(&aspectworld.config_hash, tmp->name, tmp); -} - - -/** - * @brief Retreive the value of a configuration item - * @param name Requested configuration item name - * @return A pointer on the configuration item value - */ -void *config_get_data(char *name) -{ - configitem_t *item; - - item = (configitem_t *) hash_get(&aspectworld.config_hash,name); - - if (item == NULL) - return NULL; - - switch (item->type) - { - case CONFIG_TYPE_INT: - return (int *)item->val; - case CONFIG_TYPE_STR: - return (char *)item->data; - default: - return NULL; - } -} - -/** - * @brief Function to turn on safemode - */ -void config_safemode_set() -{ - config_update_key(CONFIG_NAME_SAFEMODE, - (void *) CONFIG_SAFEMODE_ON); -} - -/** - * @brief Functions to turn off safemode - */ -void config_safemode_reset() -{ - config_update_key(CONFIG_NAME_SAFEMODE, - (void *) CONFIG_SAFEMODE_OFF); -} - -/** - * @brief Indicate safemode state - * @return Current safemode state - */ -int config_safemode() -{ - return (int) config_get_data(CONFIG_NAME_SAFEMODE); -} - -/** - * @brief Enable profile verbose printing for internal ERESI warnings - * @return Always 0 - */ -int profiler_enable_err() -{ - aspectworld.proflevel |= PROFILE_WARN; - return (0); -} - -/** - * @brief Enable profile verbose printing for internal ERESI functions tracing - * @return Always 0 - */ -int profiler_enable_out() -{ - aspectworld.proflevel |= PROFILE_FUNCS; - return (0); -} - -/** - * @brief Enable profile verbose printing for internal memory allocations - * @return Always 0 - */ -int profiler_enable_alloc() -{ - aspectworld.proflevel |= PROFILE_ALLOC; - return (0); -} - -/** - * @brief Enable profile verbose printing for internal debugging informations - * @return Always 0 - */ -int profiler_enable_debug() -{ - aspectworld.proflevel |= PROFILE_DEBUG; - return (0); -} - -/** - * @brief Disable profile verbose printing for internal warnings - * @return Always 0 - */ -int profiler_disable_err() -{ - aspectworld.proflevel &= (~PROFILE_WARN); - return (0); -} - -/** - * @brief Disable profile verbose printing for internal ERESI functions tracing - * @return Always 0 - */ -int profiler_disable_out() -{ - aspectworld.proflevel &= (~PROFILE_FUNCS); - return (0); -} - -/** - * @brief Disable profile verbose printing for internal memory allocations - * @return Always 0 - */ -int profiler_disable_alloc() -{ - aspectworld.proflevel &= (~PROFILE_ALLOC); - return (0); -} - -/** - * @brief Disable profile verbose printing for internal debugging informations - * @return Always 0 - */ -int profiler_disable_debug() -{ - aspectworld.proflevel &= (~PROFILE_DEBUG); - return (0); -} - -/** - * @brief Disable all profiling printing - * @return Always 0 - */ -int profiler_disable_all() -{ - aspectworld.proflevel = PROFILE_NONE; - return 0; -} - -/** - * @brief Enable all profiling printing - * @return Always 0 - */ -int profiler_enable_all() -{ - profiler_enable_err(); - profiler_enable_out(); - profiler_enable_alloc(); - return 0; -} - -/** - * @brief Test if profiling is enabled - * @return Integer value of the profiling level - */ -int profiler_enabled() -{ - return (aspectworld.proflevel); -} - -/** - * @brief Test if profiler is enabled under certain flags - * @param mask Bitmask of bits to be tested - * @return A Bitmask of enabled profiling flags - */ -int profiler_is_enabled(u_char mask) -{ - return (aspectworld.proflevel & mask); -} - -/** - * @brief Change the profiling output function (default: revm_output in librevm) - * @param profile Function pointer of type int fct(char*) to be registered for standard profiling - * @param profile_err Function pointer of type int fct(char*) to be registered for error profiling - */ -void profiler_install(int (*profile)(char *), - int (*profile_err)(char *)) -{ - aspectworld.profile = profile; - aspectworld.profile_err = profile_err; -} - -/* We setup two functions for colors because we have too many functions */ - -/** - * @brief Change simple color functions handlers - * @param endline Function pointer of type void fct() handling ends of line (default: revm_endline) - * @param colorinstr Function pointer of type char *fct(char *str) handling instruction printing - * @param colorstr Function pointer of type char *fct(char *str) handling string printing - * @param colorfieldstr Function pointer of type char *fct(char *str) handling field printing - * @param colortypestr Function pointer of type char *fct(char *str) handling type printing - * @param colorend Function pointer of type char *fct(char *str) handling ending lines printing - * @param colorwarn Function pointer of type char *fct(char *str) handling priting of warnings - * @param colorfunction Function pointer of type char *fct(char *str) handling function name printing - * @param colorfilename Function pointer of type char *fct(char *str) handling file name printing - */ -void profiler_setcolor(void (*endline)(), - char *(*colorinstr)(char *text), - char *(*colorstr)(char *t), - char *(*colorfieldstr)(char *t), - char *(*colortypestr)(char *t), - char *(*colorend)(char *text), - char *(*colorwarn)(char *text), - char *(*colorfunction)(char *text), - char *(*colorfilename)(char *text)) -{ - aspectworld.endline = endline; - aspectworld.colorinstr = colorinstr; - aspectworld.colorstr = colorstr; - aspectworld.colorfieldstr = colorfieldstr; - aspectworld.colortypestr = colortypestr; - aspectworld.colorend = colorend; - aspectworld.colorwarn = colorwarn; - aspectworld.colorfunction = colorfunction; - aspectworld.colorfilename = colorfilename; -} - -/** - * @brief Change advanced color functions - * @param coloradv Function pointer of type char *fct(char*, char*, char*) formatting end lines - * @param colorinstr_fmt Function pointer of type char *fct(char *, char *) formatting instructions - * @param coloraddress Function pointer of type char *fct(char *, u_long) formatting addresses - * @param colornumber Function pointer of type char *fct(char *, u_int) formatting decimal numbers - * @param colorstr_fmt Function pointer of type char *fct(char *, char *) formatting strings - * @param colorfieldstr_fmt Function pointer of type char *fct(char *, char *) formatting field strings - * @param colortypestr_fmt Function pointer of type char *fct(char *, char *) formatting type names - * @param colorwarn_fmt Function pointer of type char *fct(char *, char *) formatting warnings - */ -void profiler_setmorecolor(char *(*coloradv)(char *ty, char *p, char *te), - char *(*colorinstr_fmt)(char* p, char *t), - char *(*coloraddress)(char *p, u_long a), - char *(*colornumber)(char *p, u_int n), - char *(*colorstr_fmt)(char *p, char *t), - char *(*colorfieldstr_fmt)(char *p, char *t), - char *(*colortypestr_fmt)(char *p, char *t), - char *(*colorwarn_fmt)(char *pattern, char *text)) -{ - aspectworld.coloradv = coloradv; - aspectworld.colorinstr_fmt = colorinstr_fmt; - aspectworld.coloraddress = coloraddress; - aspectworld.colornumber = colornumber; - aspectworld.colorstr_fmt = colorstr_fmt; - aspectworld.colorfieldstr_fmt = colorfieldstr_fmt; - aspectworld.colortypestr_fmt = colortypestr_fmt; - aspectworld.colorwarn_fmt = colorwarn_fmt; -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/containers.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/containers.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/containers.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/containers.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* -** @file containers.c -** -** @brief Implement generic routines for containers -** -** Started on Sat Jun 2 15:20:18 2005 jfv -** $Id: containers.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - - -/** - * @brief Create container lists - * @param container Container holding the lists - * @param linktype CONTAINER_LINK_IN or CONTAINER_LINK_OUT for input or output links list - * @return -1 on error and 0 on success - */ -int container_linklists_create(container_t *container, - u_int linktype) -{ - aspectype_t *type; - char bufname[BUFSIZ]; - char *prefix; - list_t *newlist; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check for prefix (XXX: change to lookup user-configured prefixes ?) */ - switch (container->type) - { - case ASPECT_TYPE_BLOC: - prefix = "bloc"; - break; - case ASPECT_TYPE_FUNC: - prefix = "func"; - break; - default: - type = aspect_type_get_by_id(container->type); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find type of container", -1); - prefix = type->name; - } - - /* Now really allocate the list */ - switch (linktype) - { - case CONTAINER_LINK_IN: - snprintf(bufname, BUFSIZ, "%s_%08X_%s", prefix, *(u_long *) container->data, "inputs"); - newlist = elist_find(bufname); - if (newlist) - container->inlinks = newlist; - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, container->inlinks, sizeof(list_t), -1); - elist_init(container->inlinks, strdup(bufname), container->type); - } - - break; - case CONTAINER_LINK_OUT: - snprintf(bufname, BUFSIZ, "%s_%08X_%s", prefix, *(u_long *) container->data, "outputs"); - newlist = elist_find(bufname); - if (newlist) - container->outlinks = newlist; - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, container->outlinks, sizeof(list_t), -1); - elist_init(container->outlinks, strdup(bufname), container->type); - } - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown link type", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Create a new container - * @param type Type of element inside container - * @param data Data pointer for contained element - * @param inlist Input links list if any (else it will be created empty) - * @Param outlist Output links list if any (else it will be created empty) - * @return Container newly created - */ -container_t *container_create(u_int type, void *data, list_t *inlist, list_t *outlist) -{ - container_t *newcntnr; - aspectype_t *rtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - rtype = aspect_type_get_by_id(type); - if (!rtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown container element type", NULL); - - /* Make sure meta-data is initialized and contiguous with pointed data */ - fprintf(stderr, "Allocating sizeof(container) + (%s type->size = %u) \n", - rtype->name, rtype->size); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, newcntnr, sizeof(container_t) + rtype->size, NULL); - newcntnr->data = (char *) newcntnr + sizeof(container_t); - newcntnr->type = type; - memcpy((char *) newcntnr->data, (char *) data, rtype->size); - - /* Create lists if not specified */ - if (inlist) - newcntnr->inlinks = elist_copy(inlist); - else - container_linklists_create(newcntnr, CONTAINER_LINK_IN); - if (outlist) - newcntnr->outlinks = elist_copy(outlist); - else - container_linklists_create(newcntnr, CONTAINER_LINK_OUT); - - /* Make sure the container and contained data are contiguous */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/init.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/init.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/init.c.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/init.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,157 +0,0 @@ -/** -** @file vectors.c -** -** @brief Implement the modularity for the framework -** -** Started Dec 22 2006 02:57:03 jfv -** -** -** $Id: init.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - - -static u_char aspect_initialized = 0; - - -/***************** ERESI Constructors help functions **********************/ - -static u_char called_ctors = 0; -static u_char dbgpresent = 0; - -/** - * @brief Count the number of constructors already called in the framework (update internal variable) - */ -void aspect_called_ctors_inc() -{ - if (!called_ctors) - e2dbg_presence_set(); - called_ctors++; -} - -/** - * @brief Test if we called all constructors or not (currently we have 3) - */ -int aspect_called_ctors_finished() -{ - return (called_ctors == 3); -} - - -/*************** E2DBG presence help functions *******************/ - - -/** - * @brief Set debugger presence - */ -void e2dbg_presence_set() -{ - dbgpresent = 1; - -#if 1 //__DEBUG_E2DBG__ - //write(2, " [*] Enabled debugger presence\n", 31); -#endif - -} - -/** @brief Reset debugger presence */ -void e2dbg_presence_reset() -{ - dbgpresent = 0; - -#if 1 //__DEBUG_E2DBG__ - //write(2, " [*] Disabled debugger presence\n", 32); -#endif - -} - -/* Get the Debugger presence information */ -u_char e2dbg_presence_get() -{ -#if 1 //__DEBUG_E2DBG__ - //write(2, " [*] Probbing debugger presence\n", 32); -#endif - - return (dbgpresent); -} - - -/** Are we in kernel mode */ -u_char e2dbg_kpresence_get() -{ - return (aspectworld.kernel_mode); -} - -/** Enable or disable kernel mode */ -void e2dbg_kpresence_set(u_char pres) -{ - aspectworld.kernel_mode = pres; -} - -/**************** LIBASPECT initiazation ******************/ - - -/** @brief Initialize the vector hash table */ -static void aspect_vectors_init() -{ - vector_hash = (hash_t *) hash_find("type_vector"); -} - - -/** @brief Initialize base types : each type has a hash table of typed objects */ -static void aspect_types_init() -{ - hash_init(&types_hash, "types", 11, ASPECT_TYPE_UNKNOW); - aspect_basetypes_create(); -} - - -/** @brief Configuration initialization in libaspect */ -static void aspect_config_init() -{ - memset(&aspectworld, 0x00, sizeof(aspectworld_t)); - - // Just for debugging - //aspectworld.profile = (void *) puts; - - hash_init(&aspectworld.config_hash, "configuration", - CONFIG_HASH_SIZE, ASPECT_TYPE_UNKNOW); - - aspectworld.proflevel = PROFILE_NONE; - - config_add_item(CONFIG_CFGDEPTH, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - CONFIG_CFGDEPTH_DEFAULT); - - config_add_item(CONFIG_NAME_SAFEMODE, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - CONFIG_SAFEMODE_OFF); - - config_add_item(CONFIG_ASM_ENDIAN_FLAG, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *)CONFIG_ASM_LITTLE_ENDIAN); - - config_add_item(CONFIG_ASM_ATT_MARGIN_FLAG, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *)CONFIG_ASM_ATT_MARGIN_DEFAULT); - -} - -/** @brief Initialize everything Libaspect */ -int aspect_init() -{ - if (!aspect_initialized) - { - aspect_initialized = 1; - aspect_config_init(); - aspect_types_init(); - aspect_vectors_init(); - aspectworld.profstarted = 1; - } - return (0); -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/libbtree.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/libbtree.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/libbtree.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/libbtree.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,274 +0,0 @@ -/** -** -** @file libbtree.c -** -** Author : <087432084750432042> -** Started : Fri Oct 17 14:29:24 2003 -** Updated : Thu Nov 27 23:29:29 2003 -** -** $Id: libbtree.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ - -//#include - -#include "libaspect.h" - -/** - * @brief insert element in tree using id to sort it - * - * - * - * - */ - -void btree_insert(btree_t **proot, /*!< ptr to btree root */ - u_int id, /*!< element id */ - void *elem) /*!< ptr to element */ -{ - btree_t *root; - void *ptr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - root = *proot; - if (!root) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, ptr, sizeof (btree_t), ); - root = (btree_t *) ptr; - root->id = id; - root->elem = elem; - *proot = root; - } - else - { - if (id < root->id) - btree_insert(&root->left, id, elem); - else - btree_insert(&root->right, id, elem); - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Insert element in tree using a function to sort it. - * - * depending on function return value, element is insert - * in left or right path: - * if return value is null, element is already present in - * tree and is discarded. - * - * if apply function return a positive value, - * element is inserted on right path - * if apply function return a negative value, - * element is inserted on left path - * - */ - -void btree_insert_sort(btree_t **proot, /*!< ptr to root */ - int (*apply)(void *, void *), /*!< cmp handler */ - void *elem) /*!< element */ -{ - btree_t *root; - int ret; - root = *proot; - - if (!root) - btree_insert(proot, (u_int) elem, elem); - else - { - if ((ret = apply(root->elem, elem))) - { - if (ret > 0) - btree_insert_sort(&root->right, apply, elem); - else - btree_insert_sort(&root->left, apply, elem); - } - } -} - -/** - * @brief return an element by providing its id. - * id is id provided to insert element - * with btree_insert(); - * do not use on trees built with btree_insert_sort - */ - -void *btree_get_elem(btree_t *root, /* !< ptr to root */ - u_int id) /* !< element id to fetch */ -{ - if (!root) - return (NULL); - /* elem found, return it */ - if (root->id == id) - return (root->elem); - /* switch on path */ - if (id < root->id) - return (btree_get_elem(root->left, id)); - else if (root->id < id) - return (btree_get_elem(root->right, id)); - return (NULL); -} - -/** - * return an element by providing a matching function - * this matching function is used to follow path - * until it find element depending on its return value: - * if match function is null, element is current element - * and is returned. - * else - * if return value is negative, element is searched in right path - * if return value is positive, element is searched in left path - * - */ - -void *btree_find_elem(btree_t *root, - int (*match)(void *, void *), - void *ptr) -{ - int ret; - void *to_ret; - - if (root) - { - ret = match(root->elem, ptr); - if (!ret) - to_ret = root->elem; - else - { - if (ret > 0) - to_ret = btree_find_elem(root->right, match, ptr); - else - to_ret = btree_find_elem(root->left, match, ptr); - } - } - else - to_ret = NULL; - return (to_ret); -} - -/** - * @brief browse tree and call function apply on each element. - * - * @param ptr ptr is a pointer passed as second argument of apply - * - */ - -void btree_browse_prefix(btree_t *root, int (*apply)(void *, void *), void *ptr) -{ - if (root) - { - apply(root->elem, ptr); - if (root->left) - btree_browse_prefix(root->left, apply, ptr); - if (root->right) - btree_browse_prefix(root->right, apply, ptr); - } -} - - -void btree_browse_infix(btree_t *root, int (*apply)(void *, void *), void *ptr) -{ - if (root) - { - if (root->left) - btree_browse_infix(root->left, apply, ptr); - apply(root->elem, ptr); - if (root->right) - btree_browse_infix(root->right, apply, ptr); - } -} - -void btree_browse_suffix(btree_t *root, int (*apply)(void *, void *), void *ptr) -{ - if (root) - { - if (root->left) - btree_browse_suffix(root->left, apply, ptr); - if (root->right) - btree_browse_suffix(root->right, apply, ptr); - apply(root->elem, ptr); - } -} - -/** - * @brief free full tree. - * @param mode if mode is not null, tree elements are also freed - */ - -void btree_free(btree_t *root, int mode) -{ - if (root) - { - if (mode) - XFREE(__FILE__, __FUNCTION__, __LINE__, root->elem); - btree_free(root->left, mode); - btree_free(root->right, mode); - XFREE(__FILE__, __FUNCTION__, __LINE__, root); - } -} - - -#ifndef __KERNEL__ - -/** - * - * - */ - -int btree_debug_node(void *elem, void *ptr, btree_t *root) -{ - struct s_debug *opt; - - opt = (struct s_debug *) ptr; - - fprintf(opt->fp, BTREE_DEBUG_NODE, (int) root, (int) root, - (int) root->left, (int) root->right); - return (0); -} - -int btree_debug_link(void *elem, void *ptr, btree_t *root) -{ - struct s_debug *opt; - - opt = (struct s_debug *) ptr; - - if (root->left) - fprintf(opt->fp, BTREE_DEBUG_LINK, (int) root, - "L", (int) root->left, opt->link++); - if (root->right) - fprintf(opt->fp, BTREE_DEBUG_LINK, (int) root, "R", - (int) root->right, opt->link++); - return (0); -} - -void btree_browse_prefix_debug(btree_t *root, int (*apply)(void *, void *, btree_t *), - void *ptr) -{ - if (root) - { - apply(root->elem, ptr, root); - if (root->left) - btree_browse_prefix_debug(root->left, apply, ptr); - if (root->right) - btree_browse_prefix_debug(root->right, apply, ptr); - } -} - - -void btree_debug(btree_t *root, char *filename, - void (*apply)(void *, void *)) { - struct s_debug opt; - opt.fp = fopen(filename, "w"); - if (opt.fp) - { - fprintf(opt.fp, "digraph g {\n" - "size=\"6,4\"; ratio = fill; graph [ rankdir = \"LR\" ] ;\n"); - btree_browse_prefix_debug(root, btree_debug_node, &opt); - opt.link = 0; - btree_browse_prefix_debug(root, btree_debug_link, &opt); - fprintf(opt.fp, "};\n"); - fclose(opt.fp); - } -} - -#endif diff -Nru eresi-0.8a25/libaspect/.svn/text-base/libhash.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/libhash.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/libhash.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/libhash.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,534 +0,0 @@ -/* -** @file libhash.c -** -** @brief Contain ELFsh internal hashtables library calls -** -** Started on Fri Jan 24 20:26:18 2003 jfv -** $Id: libhash.c,v 1.41 2007-11-28 08:18:17 may Exp $ -*/ -#include "libaspect.h" - - -/* Hash tables of hash tables */ -hash_t *hash_hash = NULL; - -/** - * @brief Initialize the hash table - */ -int hash_init(hash_t *h, char *name, int size, u_int type) -{ - NOPROFILER_IN(); - - /* First checks */ - /* Initialize the global hash table of lists and - the global hash table of hash tables */ - if (!hash_hash) - { - hash_hash = (hash_t *) calloc(sizeof(hash_t), 1); - hash_init(hash_hash, "hashes", 51, ASPECT_TYPE_UNKNOW); - } - if (type >= aspect_type_nbr) - { - fprintf(stderr, "Unable to initialize hash table %s \n", name); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to initialize hash table", -1); - } - if (h != hash_hash && hash_find(name) && h->ent) - { -#if __DEBUG__ - fprint(stderr, "Hash table already exists and initialized\n"); -#endif - NOPROFILER_ROUT(1); - } - - /* Add a new element */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - h->ent, size * sizeof(listent_t), -1); - h->size = size; - h->type = type; - h->elmnbr = 0; - h->linearity = 0; - h->name = name; - hash_add(hash_hash, name, h); - - if (!hash_lists) - { - hash_lists = (hash_t *) calloc(sizeof(hash_t), 1); - hash_init(hash_lists, "lists", 51, ASPECT_TYPE_UNKNOW); - } - NOPROFILER_ROUT(0); -} - -/** - * @brief Return a hash table by its name - */ -hash_t *hash_find(char *name) -{ - if (!name) - return (NULL); - return ((hash_t *) hash_get(hash_hash, name)); -} - -/* Return a hash table pointer by its name */ -/* Overwrite existing table if there was one sharing that name, only - if both tables have the same elements type */ -int hash_register(hash_t *table, char *name) -{ - hash_t *h; - int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_hash, name); - if (h) - { - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = table->type; - if (h->type != table->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incompatible hash tables", -1); - if (h->elmnbr) - h = hash_empty(name); - hash_merge(h, table); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(hash_t), -1); - sz = (table->size > table->elmnbr ? table->size : table->elmnbr); - hash_init(h, name, sz, table->type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Empty a hash table - */ -hash_t *hash_empty(char *name) -{ - hash_t *hash; - char *newname; - int size; - char type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash = hash_find(name); - - if (!hash) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - size = hash->size; - type = hash->type; - hash_del(hash_hash, name); - hash_destroy(hash); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newname, strlen(name) + 1, NULL); - strcpy(newname, name); - hash_init(hash, newname, size, type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, hash); -} - - - -/* Destroy a hash table */ -void hash_destroy(hash_t *h) -{ - char **keys; - int idx; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We should not destroy the elements as they might be in other hashes */ - keys = hash_get_keys(h, &keynbr); - for (idx = 0; idx < keynbr; idx++) - if (keys[idx]) - XFREE(__FILE__, __FUNCTION__, __LINE__, keys[idx]); - if (keys) - hash_free_keys(keys); - hash_del(hash_hash, h->name); - XFREE(__FILE__, __FUNCTION__, __LINE__, h->ent); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * @brief Add an entry to the hash table - */ -int hash_add(hash_t *h, char *key, void *data) -{ - listent_t *actual; - listent_t *newent; - char *backup; - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //Weaken the check : do not hash_get(h, key) check and do not check !data - if (!h || !key) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - - /* If the element already exist, make sure we erase the existing one */ - actual = hash_get(h, key); - if (actual) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - hash_set(h, key, data)); - - newent = NULL; - for (index = 0, backup = key; *backup; backup++) - index += *backup; - index %= h->size; - - if (h->ent[index].key == NULL) - { - h->ent[index].key = key; - h->ent[index].data = data; - } - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newent, sizeof(listent_t), -1); - newent->key = key; - newent->data = data; - actual = h->ent + index; - while (actual->next) - actual = actual->next; - actual->next = newent; - } - h->elmnbr++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, index); -} - - - - -/** - * @brief Delete an entry from the hash table - */ -int hash_del(hash_t *h, char *key) -{ - listent_t *actual; - listent_t *todel; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check the first entry for this hash */ - actual = hash_get_head(h, key); - if (actual->key != NULL && !strcmp(actual->key, key)) - { - if (actual->next) - { - todel = actual->next; - *actual = *actual->next; - XFREE(__FILE__, __FUNCTION__, __LINE__, todel); - } - else - bzero(actual, sizeof (listent_t)); - h->elmnbr--; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Looking for the good entry in the list for this hash value */ - while (actual->next != NULL && - actual->next->key != NULL && - strcmp(actual->next->key, key)) - actual = actual->next; - - /* Not found */ - if (!actual->next) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - /* Found */ - todel = actual->next; - actual->next = actual->next->next; - XFREE(__FILE__, __FUNCTION__, __LINE__, todel); - h->elmnbr--; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Retrieve the metadata for a given key - */ -void *hash_get(hash_t *h, char *key) -{ - listent_t *actual; - - actual = hash_get_head(h, key); - while (actual != NULL && - actual->key != NULL && - strcmp(actual->key, key)) - actual = actual->next; - return (actual != NULL ? actual->data : NULL); -} - -/* Retrieve the data pointer for a given key */ -void *hash_select(hash_t *h, char *key) -{ - listent_t *actual; - - actual = hash_get_head(h, key); - while (actual != NULL && - actual->key != NULL && - strcmp(actual->key, key)) - actual = actual->next; - return (actual != NULL ? &actual->data : NULL); -} - - - -/* Change the metadata for an existing entry, giving its key */ -int hash_set(hash_t *h, char *key, void *data) -{ - listent_t *ent; - - ent = hash_get_ent(h, key); - if (!ent || (!ent->key && !ent->data)) - return (hash_add(h, key, data)); - ent->data = data; - return (0); -} - - -/** - * @brief Retrieve the -entry- for a given key - */ -listent_t *hash_get_ent(hash_t *h, char *key) -{ - listent_t *actual; - - actual = hash_get_head(h, key); - while (actual != NULL && - actual->key != NULL && - strcmp(actual->key, key)) - actual = actual->next; - return (actual); -} - - - -/* Retreive a Hash entry head giving the key */ -listent_t *hash_get_head(hash_t *h, char *backup) -{ - u_int index; - - for (index = 0; *backup; backup++) - index += *backup; - return (&h->ent[index % h->size]); -} - - - -/** - * @brief Used to create arrays of keys for completion - */ -char **hash_get_keys(hash_t *h, int *n) -{ - char **keys; - listent_t *curelem; - int idx; - int last; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !h->elmnbr) - { - if (n) - *n = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", NULL); - } - XALLOC(__FILE__, __FUNCTION__, __LINE__, keys, - sizeof(char *) * (h->elmnbr + 1), NULL); - - for (last = idx = 0; idx < h->size; idx++) - { - curelem = h->ent + idx; - while (curelem && curelem->key) - { - keys[last] = curelem->key; - curelem = curelem->next; - last++; - } - } - if (n) - *n = h->elmnbr; - keys[last] = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, keys); -} - - -/** - * @brief Free the keys returned by hash_get_keys() - */ -void hash_free_keys(char **keys) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (keys) - XFREE(__FILE__, __FUNCTION__, __LINE__, keys); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Print the hash table (DEBUG PURPOSE) */ -void hash_print(hash_t *h) -{ - listent_t *actual; - int index; - - if (!h) - return; - puts(".::. Printing hash .::. "); - for (index = 0; index < h->size; index++) - { - for (actual = &h->ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - printf(" ENT [%u] key = %s ; data = %p ; next = %p\n", - index, actual->key, actual->data, actual->next); - } -} - -/** - * @brief Apply func all entries -*/ -int hash_apply(hash_t *h, - void *ptr, - int (*func)(listent_t *ph, void *pptr)) -{ - listent_t *actual; - int index; - int ret = 0; - - for (index = 0; index < h->size; index++) - { - for (actual = &h->ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - ret |= func (actual, ptr); - } - return ret; -} - - -/* Compare 2 hash tables */ -/* Contributed by zorgon */ -/* Can be used to compare ELF in memory and ELF in file */ -int hash_compare(hash_t *first, hash_t *two) -{ - int index; - int m; - listent_t *actual; - listent_t *bis; - - if (first->size != two->size) - return (-1); - for (m = index = 0; index < first->size; index++) - { - for (actual = first->ent + index; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - bis = hash_get_ent(two, actual->key); - if (actual->data != bis->data) - { - printf("FIRST key = %s ; data = %p", - actual->key, actual->data); - printf("SECOND key = %s ; data = %p", - bis->key, bis->data); - m++; - } - } - } - if (m) - return (-1); - return (0); -} - - -/* Merge hash tables in the first one */ -/* We cannot use hash_get_keys() because we dont know the type of hashed objects */ -int hash_merge(hash_t *dst, hash_t *src) -{ - listent_t *actual; - int index; - int ret; - - /* Make sure we dont inject element already presents */ - if (!src || !dst || src->elmnbr == 0) - return (0); - for (ret = index = 0; index < src->size; index++) - for (actual = &src->ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - if (!hash_get(dst, actual->key)) - ret += hash_add(dst, actual->key, actual->data); - return ret; -} - - -/* Delete all elements of source hash in destination hash */ -/* We cannot use hash_get_keys() because we dont know the type of hashed objects */ -int hash_unmerge(hash_t *dst, hash_t *src) -{ - listent_t *actual; - int index; - int ret; - - /* Make sure we dont inject element already presents */ - if (!src || !dst || src->elmnbr == 0) - return (0); - for (ret = index = 0; index < src->size; index++) - for (actual = &src->ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - if (hash_get(dst, actual->key)) - ret += hash_del(dst, actual->key); - return ret; -} - - -/* Return the hash size */ -int hash_size(hash_t *hash) -{ - return (hash ? hash->elmnbr : 0); -} - -/* Return the only element of this hash */ -void *hash_get_single(hash_t *hash) -{ - char **keys; - int idx; - - if (!hash || hash_size(hash) != 1) - return (NULL); - keys = hash_get_keys(hash, &idx); - return (hash_get(hash, keys[0])); -} - -/* Return an element of this hash */ -/* The choice is non-deterministic */ -void* hash_get_one(hash_t *hash) -{ - char **keys; - int index; - - if (!hash || !hash_size(hash)) - return (NULL); - keys = hash_get_keys(hash, &index); - return (hash_get(hash, keys[0])); -} - - -/* Linear typing of list API */ -u_char hash_linearity_get(hash_t *h) -{ - if (!h) - return (0); - return (h->linearity); -} - -/* Linear typing of list API */ -void hash_linearity_set(hash_t *h, u_char val) -{ - if (!h) - return; - h->linearity = val; -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/liblist.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/liblist.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/liblist.c.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/liblist.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,470 +0,0 @@ -/** -** @file liblist.c -** -** Contain ELFsh internal lists related API -** -** Started on Fri Jul 13 20:26:18 2007 jfv -** $Id: liblist.c,v 1.9 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libaspect.h" - -/* Hash tables of hash tables */ -hash_t *hash_lists = NULL; - -/** - * @brief Initialize the hash table - */ -int elist_init(list_t *h, char *name, u_int type) -{ - list_t *exist; - - NOPROFILER_IN(); - if (type >= aspect_type_nbr) - { - fprintf(stderr, "Unable to initialize list %s \n", name); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to initialize list", -1); - } - exist = elist_find(name); - if (exist) - { -#if 1 //__LIST_DEBUG__ - fprintf(stderr, "DEBUG: List %s (%p) already exists in hash with addr %p : NOT CREATING \n", - name, h, exist); -#endif - NOPROFILER_ROUT(1); - } -#if 1 //__LIST_DEBUG__ - else - fprintf(stderr, "DEBUG: List %s allocated at %p does not exists in hash : CREATING \n", name, h); -#endif - - bzero(h, sizeof(list_t)); - h->type = type; - h->name = name; - hash_add(hash_lists, name, h); - NOPROFILER_ROUT(0); -} - -/** - * @brief Return a list by its name - */ -list_t *elist_find(char *name) -{ - return ((list_t *) hash_get(hash_lists, name)); -} - -/** - * @brief Set a list by its name (overwrite if existing ) - */ -int elist_register(list_t *list, char *name) -{ - list_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_lists, name); - if (h) - { - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = list->type; - if (h->type != list->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incompatible lists", -1); - if (h->elmnbr) - h = elist_empty(name); - elist_merge(h, list); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(list_t), -1); - elist_init(h, name, h->type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Empty a list - */ -list_t *elist_empty(char *name) -{ - list_t *list; - char *newname; - char type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - list = elist_find(name); - if (!list) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - type = list->type; - hash_del(hash_lists, name); - elist_destroy(list); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newname, strlen(name) + 1, NULL); - strcpy(newname, name); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - list, sizeof(list_t), NULL); - elist_init(list, newname, type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, list); -} - - -/* Reverse a list */ -list_t *elist_reverse(list_t *l) -{ - list_t *newlist; - listent_t *nextent; - listent_t *curent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash_del(hash_lists, l->name); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newlist, sizeof(list_t), NULL); - elist_init(newlist, l->name, l->type); - - /* Copy the list inserting at the beginning all the time */ - for (curent = l->head; curent; curent = nextent) - { - elist_add(newlist, curent->key, curent->data); - nextent = curent->next; - XFREE(__FILE__, __FUNCTION__, __LINE__, curent); - } - - XFREE(__FILE__, __FUNCTION__, __LINE__, l); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newlist); -} - - -/* Destroy a list */ -void elist_destroy(list_t *h) -{ - char **keys; - int idx; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - fprintf(stderr, "DEBUG: Destroying list %s at addr %p \n", h->name, h); - - /* We should not destroy the elements as they might be in other hashes */ - keys = elist_get_keys(h, &keynbr); - for (idx = 0; idx < keynbr; idx++) - XFREE(__FILE__, __FUNCTION__, __LINE__, keys[idx]); - if (keys) - elist_free_keys(keys); - hash_del(hash_lists, h->name); - XFREE(__FILE__, __FUNCTION__, __LINE__, h); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Copy a list */ -list_t *elist_copy(list_t *h) -{ - list_t *newlist; - listent_t *newent; - listent_t *prevent; - listent_t *curent; - void *newelem; - int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newlist, sizeof(list_t), NULL); - *newlist = *h; - prevent = NULL; - size = aspect_typesize_get(h->type); - - /* Copy the list */ - for (curent = h->head; curent; curent = curent->next) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, newent, sizeof(listent_t), NULL); - *newent = *curent; - XALLOC(__FILE__, __FUNCTION__, __LINE__, newelem, size, NULL); - memcpy(newelem, curent->data, size); - newent->data = newelem; - newent->next = NULL; - if (prevent) - prevent->next = newent; - else - newlist->head = newent; - prevent = newent; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newlist); -} - - - -/** - * @brief Add an element at the head of the list - */ -int elist_add(list_t *h, char *key, void *data) -{ - listent_t *cur; - listent_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !key || !data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - cur, sizeof(listent_t), -1); - next = h->head; - cur->key = key; - cur->data = data; - cur->next = next; - h->head = cur; - h->elmnbr++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Delete an element from a list - */ -int elist_del(list_t *h, char *key) -{ - listent_t *curelem; - listent_t *prevelem; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !key) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - curelem = h->head; - prevelem = NULL; - for (curelem = h->head; curelem && strcmp(curelem->key, key); - curelem = curelem->next) - prevelem = curelem; - if (!curelem) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!prevelem) - h->head = h->head->next; - else - prevelem->next = prevelem->next->next; - h->elmnbr--; - if (!h->elmnbr) - h->head = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the list element giving the key - */ -void *elist_get(list_t *h, char *key) -{ - listent_t *cur; - - if (!h || !key) - return (NULL); - for (cur = h->head; cur; cur = cur->next) - if (!strcmp(cur->key, key)) - return (cur->data); - return (NULL); -} - -/** - * @brief Get the list data giving the key - */ -void *elist_select(list_t *h, char *key) -{ - listent_t *cur; - - if (!h || !key) - return (NULL); - for (cur = h->head; cur; cur = cur->next) - if (!strcmp(cur->key, key)) - return (cur->data); - return (NULL); -} - -/* Get the list head */ -listent_t *elist_get_head(list_t *h) -{ - if (!h) - return (NULL); - return (h->head); -} - -/* Change the metadata for an existing entry, giving its key */ -int elist_set(list_t *h, char *key, void *data) -{ - listent_t *cur; - - if (!h || !key) - return (-1); - for (cur = h->head; cur; cur = cur->next) - if (!strcmp(cur->key, key)) - { - cur->data = data; - return (0); - } - return (-1); -} - -/** - * @brief Replace a single element by a list of elements - */ -int elist_replace(list_t *h, char *key, list_t *newlist) -{ - listent_t *cur; - listent_t *lastent; - listent_t *prev; - int idx; - char namebuf[BUFSIZ]; - - /* Preliminary checks */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !key || !newlist || !newlist->head) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", 0); - - /* Just find the latest entry */ - for (lastent = newlist->head; lastent && lastent->next; lastent = lastent->next); - - /* Now find the original element to swap with the new list */ - for (prev = NULL, cur = h->head; cur; prev = cur, cur = cur->next) - if (!strcmp(cur->key, key)) - { - if (!prev) - h->head = newlist->head; - else - prev->next = newlist->head; - lastent->next = cur->next; - h->elmnbr += newlist->elmnbr; - XFREE(__FILE__, __FUNCTION__, __LINE__, cur->data); - XFREE(__FILE__, __FUNCTION__, __LINE__, cur); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Could not find the element to swap */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find element to be swapped", -1); -} - - -/* Return the array of keys */ -char** elist_get_keys(list_t *h, int* n) -{ - char **keys; - listent_t *curelem; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !h->elmnbr) - { - if (n) - *n = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", NULL); - } - XALLOC(__FILE__, __FUNCTION__, __LINE__, keys, - sizeof(char *) * (h->elmnbr + 1), NULL); - for (idx = 0, curelem = h->head; curelem; curelem = curelem->next, idx++) - keys[idx] = curelem->key; - if (n) - *n = h->elmnbr; - keys[idx] = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, keys); -} - -/* Free the keys array */ -void elist_free_keys(char **keys) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XFREE(__FILE__, __FUNCTION__, __LINE__, keys); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Get -the list entry- for a given key */ -listent_t *elist_get_ent(list_t *h, char *key) -{ - listent_t *cur; - - if (!h || !key) - return (NULL); - for (cur = h->head; cur; cur = cur->next) - if (!strcmp(cur->key, key)) - return (cur); - return (NULL); -} - -/* Print list content */ -void elist_print(list_t *h) -{ - listent_t *actual; - int index; - - if (!h) - return; - puts(".::. Printing list .::. "); - for (index = 0, actual = h->head; index < h->elmnbr; index++, actual = actual->next) - printf(" ENT [%u] key = %s ; data = %p ; next = %p\n", - index, actual->key, actual->data, actual->next); -} - -/* Apply a function on all elements of the list */ -int elist_apply(list_t *h, void *ptr, - int (*func)(listent_t *e, void *p)) -{ - int index; - int ret = 0; - listent_t *cur; - - if (!h || !func) - return (-1); - for (cur = h->head, index = 0; index < h->elmnbr; index++, cur = cur->next) - ret |= func (cur, ptr); - return ret; -} - -/* Merge two list */ -int elist_merge(list_t *dst, list_t *src) -{ - int index; - listent_t *cur; - - if (!dst || !src) - return (-1); - for (cur = src->head, index = 0; index < src->elmnbr; index++, cur = cur->next) - elist_add(dst, cur->key, cur->data); - return 0; -} - -/* Unmerge two lists */ -int elist_unmerge(list_t *dst, list_t *src) -{ - listent_t *cur; - - if (!dst || !src) - return (-1); - for (cur = src->head; cur; cur = cur->next) - elist_del(dst, cur->key); - return 0; -} - -/* Return the size of a list */ -int elist_size(list_t *h) -{ - if (!h) - return (0); - return (h->elmnbr); -} - -/* Compare two lists */ -/* Unimplemented */ -int elist_compare(list_t *first, list_t *two) -{ - return (-1); -} - -/* Linear typing of list API */ -u_char elist_linearity_get(list_t *l) -{ - if (!l) - return (0); - return (l->linearity); -} - -/* Linear typing of list API */ -void elist_linearity_set(list_t *l, u_char val) -{ - if (!l) - return; - l->linearity = val; -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -## -## Makefile.am for libaspect in elfsh -## -## Started on Fri Dec 22 16:32:29 2006 jfv -## -include ../config.h - -CC ?= gcc -LD = ld -RM = rm -f -AR = ar rc -CFLAGS32 += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI32 -CFLAGS64 += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI64 -SRC = vectors.c libhash.c libbtree.c types.c init.c \ - config.c profiler.c liblist.c containers.c - -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -NAME = libaspect -NAME32 = libaspect32 -NAME64 = libaspect64 - -all : all32 all64 - -libaspect32.so : $(OBJ32) - @$(CC) -L../liballocproxy/ -lallocproxy \ - $(DLOPT) -shared $(OBJ32) -o $(NAME32).so - @$(AR) $(NAME32).a $(OBJ32) - @$(RANLIB) $(NAME32).a - $(LD) -r $(OBJ32) -o $(NAME32).o - -all32: libaspect32.so - -libaspect64.so : $(OBJ64) - @$(LD) -L../liballocproxy/ -lallocproxy \ - $(DLOPT) -shared $(OBJ64) -o $(NAME64).so - @$(AR) $(NAME64).a $(OBJ64) - @$(RANLIB) $(NAME64).a - $(LD) -r $(OBJ64) -o $(NAME64).o - -all64: libaspect64.so - - -clean : - @$(RM) \#* *\# *~ $(OBJ) $(OBJ32) $(OBJ64) .\#* include/\#* \ - include/*\# include/*~ include/.\#* - -fclean : clean - @$(RM) *.so *.a - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< - -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - -docs: - doxygen doc/doxygen.conf diff -Nru eresi-0.8a25/libaspect/.svn/text-base/profiler.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/profiler.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/profiler.c.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/profiler.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,564 +0,0 @@ -/** -** @file error.c -** -** Started on Thu Nov 08 02:08:28 2001 mm -** Last update Wed Jun 08 10:01:42 2005 mm -** -** $Id: profiler.c,v 1.10 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - -/* Patterns memory */ -static char mem[2][PROFILER_MAX_PATTERN][80] = {{{0,0,0}}}; - -/* Patterns hit counters */ -static u_int hit[2][PROFILER_MAX_PATTERN] = {{0,0}}; - -/* Selection of memory */ -static u_int sel; - -/* The last error message */ -char *profiler_error_str = NULL; - -/* Last function depth */ -int profiler_depth = 0; - -/* Last function direction */ -static char profiler_direction = '+'; - -/* Allocation cache */ -static profallocentry_t allocentries[PROFILER_MAX_ALLOC]; - -/* Current allocation depth */ -static u_int profiler_adepth = 0; - - - -/***************** Now the allocator profiler *********************/ - - - -/** - * @brief Find an entry in the allocation profiler cache - * @param direction Either PROFILER_WARNING_LAST, PROFILER_WARNING_FIRST, or PROFILER_WARNING_UNKNOW - * @param addr Allocated address to be found in profiling cache - * @param optype Type of operation to be found - * @return Allocation profiler entry corresponding to input criterions - */ -profallocentry_t *profiler_alloc_find(u_char direction, - u_long addr, - u_char optype) -{ - u_int index; - - switch (direction) - { - case PROFILER_WARNING_LAST: - for (index = profiler_adepth - 1; index; index--) - if (allocentries[index].addr == addr && - allocentries[index].optype == optype) - return (allocentries + index); - return (NULL); - case PROFILER_WARNING_FIRST: - for (index = 1; index < profiler_adepth; index++) - if (allocentries[index].addr == addr && - allocentries[index].optype == optype) - return (allocentries + index); - return (NULL); - case PROFILER_WARNING_UNKNOW: - default: - if (aspectworld.profile) - aspectworld.profile(" [E] Unknown alloc optype requested to the " - "allocator profiler\n"); - return (NULL); - } -} - - -/** - * @brief Print the warning string - * @param str Header string to be printed - * @param fatal 1 if error is fatal (exit afterwards) - * @param idx Index corresponding to allocation entry to print - */ -void profiler_alloc_warnprint(char *str, int fatal, int idx) -{ - char buf[BUFSIZ]; - - snprintf(buf, sizeof(buf), - "%s\n (%s-[%s of addr: 0x%08lX at %s@%s:%u) \n\n", str, - (allocentries[idx].alloctype == - PROFILER_ALLOC_LEGIT ? "LEGIT " : - PROFILER_ALLOC_PROXY ? "PROXY " : "UNKNOW "), - (allocentries[idx].optype == - PROFILER_OP_ALLOC ? "ALLOC " : - PROFILER_OP_REALLOC ? "REALLOC" : - PROFILER_OP_FREE ? "FREE " : "UNKNOW "), - allocentries[idx].addr, - allocentries[idx].filename, - allocentries[idx].funcname, - allocentries[idx].linenbr); - if (aspectworld.profile) - aspectworld.profile(buf); - if (fatal) - exit(-1); -} - - - - -/** - * @brief Warn if anything bad is happening - * @param warntype Either PROFILER_WARNING_LAST, PROFILER_WARNING_FIRST or PROFILER_WARNING_UNKNOW - */ -void profiler_alloc_warning(u_char warntype) -{ - profallocentry_t *ent; - profallocentry_t *ent2; - profallocentry_t *ent3; - - /* Do not emit warning if not asked to */ - if (!(aspectworld.proflevel & PROFILE_ALLOC)) - return; - - switch (warntype) - { - - /* There are many checks for the last entry */ - case PROFILER_WARNING_LAST: - ent2 = profiler_alloc_find(PROFILER_WARNING_LAST, - allocentries[profiler_adepth].addr, - PROFILER_OP_FREE); - ent = profiler_alloc_find(PROFILER_WARNING_LAST, - allocentries[profiler_adepth].addr, - PROFILER_OP_ALLOC); - ent3 = profiler_alloc_find(PROFILER_WARNING_LAST, - allocentries[profiler_adepth].addr, - PROFILER_OP_REALLOC); - - /* We do emit a warning if we encountered a double free */ - if (allocentries[profiler_adepth].optype == PROFILER_OP_FREE && - ent2 && ent2 > ent) - profiler_alloc_warnprint(" [E] A pointer was freed" - " but it is already free ", - 1, profiler_adepth); - - /* We emit a warning when a free happens in the wrong allocator */ - if ((allocentries[profiler_adepth].optype == PROFILER_OP_FREE || - allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC) - && ent - && ent->alloctype != allocentries[profiler_adepth].alloctype) - profiler_alloc_warnprint(" [E] A pointer was freed" - " but it is was belonging " - " to another allocator ", - 1, profiler_adepth); - - /* We emit a warning when we free without remembering the alloc */ - if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC - && !ent) - profiler_alloc_warnprint(" [!] A pointer was reallocated but its" - " allocation was not found in history", - 0, profiler_adepth); - - /* We emit a warning when we realloc without remembering alloc */ - if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC - && !ent && !ent2) - profiler_alloc_warnprint(" [!] A pointer was reallocated but its" - " allocation was not found in history", - 0, profiler_adepth); - - /* We emit a warning when we realloc something freed */ - if (allocentries[profiler_adepth].optype == PROFILER_OP_REALLOC - && ent2 && (ent2 > ent)) - profiler_alloc_warnprint(" [E] A pointer was reallocated but it" - " was in a freed state", - 1, profiler_adepth); - - /* We do emit a warning if the last entry is an allocation - and this pointer was already allocated after beeing freed */ - if (allocentries[profiler_adepth].optype == PROFILER_OP_ALLOC && - ent && ((ent > ent2) || (ent > ent3))) - profiler_alloc_warnprint(" [E] A pointer was reallocated" - " without beeing freed ", - 1, profiler_adepth); - - break; - - /* We do emit a warning if the first entry is a malloc - and it has not been freed before it was removed from - the cache, which mean its a potential memory leak */ - case PROFILER_WARNING_FIRST: - if (allocentries[0].optype == PROFILER_OP_FREE) - return; - ent = profiler_alloc_find(PROFILER_WARNING_FIRST, - allocentries[0].addr, - PROFILER_OP_FREE); - if (!ent) - profiler_alloc_warnprint(" [!] An allocation was removed" - " from the history without beeing free", - 0, 0); - break; - - /* Just an error detection message */ - default: - case PROFILER_WARNING_UNKNOW: - if (aspectworld.profile) - aspectworld.profile(" [E] Unknown warning type requested to the " - "allocator profiler\n"); - exit(-1); - break; - } -} - - - -/** - * @brief Shift the allocation history - */ -void profiler_alloc_shift() -{ - int index; - - for (index = 1; index < PROFILER_MAX_ALLOC; index++) - allocentries[index - 1] = allocentries[index]; - profiler_adepth--; -} - - - -/** - * @brief Add an entry in the allocation cache - * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done - * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done - * @param line Generally called with __LINE__ (gcc), contains the line number in related file - * @param addr Newly allocated address - * @param atype Type of allocation - * @param otype Type of allocation operation - */ -static void profiler_alloc_add(char *file, char *func, - u_int line, u_long addr, - u_char atype, u_char otype) -{ - allocentries[profiler_adepth].alloctype = atype; - allocentries[profiler_adepth].optype = otype; - allocentries[profiler_adepth].filename = file; - allocentries[profiler_adepth].funcname = func; - allocentries[profiler_adepth].linenbr = line; - allocentries[profiler_adepth].addr = addr; - profiler_adepth++; -} - - -/** - * @brief Update allocation cache with a new entry - * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done - * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done - * @param line Generally called with __LINE__ (gcc), contains the line number in related file - * @param addr Newly allocated address - * @param atype Type of allocation - * @param otype Type of allocation operation - * @return 0 if we are filling the last cache entry, 0 if not - */ -int profiler_alloc_update(char *file, char *func, - u_int line, u_long addr, - u_char atype, u_char otype) -{ - //void *profunc; - // XXX: remove this ? - //profunc = aspectworld.profile; - //aspectworld.profile = (void *) printf; - - /* Just happens an entry at the end. Check the last entry. */ - if (profiler_adepth + 1 != PROFILER_MAX_ALLOC) - { - profiler_alloc_add(file, func, line, addr, atype, otype); - profiler_alloc_warning(PROFILER_WARNING_LAST); - //aspectworld.profile = profunc; - return (0); - } - - /* In that case we have to shift all entries. Check the removed entry */ - profiler_alloc_warning(PROFILER_WARNING_FIRST); - profiler_alloc_shift(); - profiler_alloc_add(file, func, line, addr, atype, otype); - profiler_alloc_warning(PROFILER_WARNING_LAST); - - //aspectworld.profile = profunc; - return (1); -} - - - - -/***************** Now the profiler for function calls ***************/ - - - - - - -/** - * @brief Reset profiler memory - * @param lsel Identifiant for profiler cache bank to be used - */ -void profiler_reset(u_int lsel) -{ - u_int idx; - - for (idx = 0; idx < PROFILER_MAX_PATTERN; idx++) - { - mem[lsel][idx][0] = 0x00; - hit[lsel][idx] = 0; - } -} - - -/** - * @brief Generic routine for profiler output - * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done - * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done - * @param line Generally called with __LINE__ (gcc), contains the line number in related file - * @param msg Profiling message suffix to be printed - * @return 1 if message is already present in bank, 0 if not - */ -int profiler_print(char *file, char *func, - u_int line, char *msg) -{ - char buff[80]; - char buf[BUFSIZ]; - // char mesg[100]; - volatile int idx; - // volatile int idx2; - char flag; - char *fill; - - sel = (msg ? 0 : 1); - - /* Compute location string */ - snprintf(buf, sizeof(buf), "<%s@%s:%u>", func, file, line); - snprintf(buff, sizeof(buff), "%-50s %s", buf, (msg ? msg : "")); - flag = 0; - - for (idx = 0; idx < PROFILER_MAX_PATTERN; idx++) - if (!strcmp(buff, mem[sel][idx])) - { - hit[sel][idx]++; - flag = 1; - } - if (flag) - return (1); - - fill = alloca(profiler_depth + 1); - memset(fill, ' ', profiler_depth); - fill[profiler_depth] = 0x00; - - /* Print memory when pattern matched */ - for (idx = PROFILER_MAX_PATTERN - 1; idx >= 0; idx--) - if (hit[sel][idx]) - { - aspectworld.profile("\n"); - - /* - for (idx2 = idx; idx2 >= 0; idx2--) - { - snprintf(buf, BUFSIZ, " %s [%c] --[ (%u hit%s) %-50s \n", - fill, - (sel ? 'P' : 'W'), - hit[sel][idx], - (hit[sel][idx] > 1 ? "s" : ""), - mem[sel][idx2]); - aspectworld.profile(buf); - } - - snprintf(mesg, sizeof(mesg), " %s [%c] --- Last %u %s %u time(s) ---\n\n", - fill, - (sel ? 'P' : 'W'), idx + 1, - (sel ? "function(s) called/returned again" : "warning(s) repeated"), - hit[sel][idx]); - - aspectworld.profile(mesg); - */ - - for (idx = 0; idx < PROFILER_MAX_PATTERN; idx++) - hit[sel][idx] = 0; - break; - } - - /* shifting of memories */ - for (idx = PROFILER_MAX_PATTERN - 1; idx > 0; idx--) - strncpy(mem[sel][idx], mem[sel][idx - 1], 80); - strncpy(mem[sel][0], buff, 80); - - return (0); -} - - -/** - * @brief Generic routine for profiler error output - * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done - * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done - * @param line Generally called with __LINE__ (gcc), contains the line number in related file - * @param msg Profiling message suffix to be printed - */ -void profiler_err(char *file, char *func, - u_int line, char *msg) -{ - char buff[80]; - char buf[BUFSIZ]; - char *fill; - - if (!(aspectworld.proflevel & PROFILE_WARN)) - return; - - /* Stock a pattern without printing */ - if (profiler_print(file, func, line, msg)) - return; - - fill = (profiler_depth - 6 > 0 ? alloca(profiler_depth + 1) : ""); - if (profiler_depth - 6 > 0) - { - memset(fill, ' ', profiler_depth); - fill[profiler_depth] = 0x00; - } - - if (aspectworld.endline != NULL) - { - snprintf(buff, sizeof(buff), " <%s@%s:%s>", - aspectworld.colorfunction(func), - aspectworld.colorfilename(file), - aspectworld.colornumber("%u", line)); - snprintf(buf, BUFSIZ, " %s %s %-70s %s \n", - aspectworld.colorwarn("[W]"), - fill, buff, aspectworld.colorwarn(msg)); - } - else - { - snprintf(buff, sizeof(buff), " <%s@%s:%u>", - func, file, line); - snprintf(buf, BUFSIZ, " [W] %s %-70s %s \n", - fill, buff, msg); - } - - if (aspectworld.profile_err != NULL) - aspectworld.profile_err(buf); - else - fprintf(stderr, "No profiling function specified.\n"); - if (aspectworld.endline != NULL) - aspectworld.endline(); - profiler_reset(0); -} - - -/** - * @brief Write the last profiling information - * @param file Generally called with __FILE__ (gcc), contains the file name where allocation is done - * @param func Generally called with __FUNCTION__ (gcc), contains the function name where allocation is done - * @param line Generally called with __LINE__ (gcc), contains the line number in related file - */ -void profiler_out(char *file, char *func, u_int line) -{ - char buff[160]; - char *space; - char b_dir[2]; - - if (!(aspectworld.proflevel & PROFILE_FUNCS)) - return; - - /* Stock a pattern, without printing */ - if (profiler_print(file, func, line, NULL)) - return; - - if (profiler_depth > 80) - profiler_depth = 1; - space = alloca(profiler_depth + 1); - memset(space, 0x00, profiler_depth); - memset(space, ' ', profiler_depth); - space[profiler_depth] = 0x00; - - if (aspectworld.endline != NULL) - { - b_dir[0] = profiler_direction; - b_dir[1] = '\0'; - snprintf(buff, sizeof(buff), "%s %s %s <%s@%s:%s>\n", - space, - aspectworld.colornumber("%u", profiler_depth), - aspectworld.colorfieldstr(b_dir), - aspectworld.colorfunction(func), - aspectworld.colorfilename(file), - aspectworld.colornumber("%u", line)); - } - else - { - snprintf(buff, sizeof(buff), "%s %u %c <%s@%s:%u>\n", - space, profiler_depth, profiler_direction, - func, file,line); - } - if (aspectworld.profile) - aspectworld.profile(buff); - - if (aspectworld.endline != NULL) - aspectworld.endline(); -} - -/** - * @brief Profiler is started ? - */ -u_char profiler_started() -{ - return (aspectworld.profstarted); -} - - -/** - * @brief Set the current function depth and direction - */ -void profiler_incdepth() -{ - profiler_depth++; -} - -/** - * @brief Set current function direction to be UP (function entering) - */ -void profiler_updir() -{ - profiler_direction = '+'; -} - -/** - * @brief Set current function direction to be DOWN (function exiting) - */ -void profiler_decdepth() -{ - if (profiler_depth > 0) - profiler_depth--; - profiler_direction = '-'; -} - -/** - * @brief Remove lastly generated error (nulify error string) - */ -void profiler_error_reset() -{ - profiler_error_str = NULL; -} - -/** - * @brief Display last error message - */ -void profiler_error() -{ - char buf[BUFSIZ]; - - if (profiler_error_str) - { - snprintf(buf, BUFSIZ, " [E] %s\n\n", profiler_error_str); - if (aspectworld.profile_err) - aspectworld.profile_err(buf); - else - printf("[WARNING] : profile_err() is NULL . Reverting to prinf.\n%s\n", buf); - } - - profiler_error_reset(); -} diff -Nru eresi-0.8a25/libaspect/.svn/text-base/types.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/types.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/types.c.svn-base 2008-04-06 23:15:52.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/types.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,743 +0,0 @@ -/** -** @file types.c -** -** @brief The base of the unified type system -** -** Started on Sun Jan 9 07:23:58 2007 jfv -** -** $Id: types.c,v 1.24 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - - -/** - * @brief Available types hash - */ -hash_t types_hash; - -/* Base types numbers, strings, and infos */ -/* Type Unknown is always at index 0 */ -int aspect_type_nbr = ASPECT_TYPE_BASENUM; -typeinfo_t *aspect_typeinfo = NULL; -typeinfo_t aspect_typeinfo_base[ASPECT_TYPE_BASENUM] = - { - {ASPECT_TYPENAME_UNKNOW , 0 }, - {ASPECT_TYPENAME_RAW , 0 }, - {ASPECT_TYPENAME_BYTE , sizeof(u_char) }, - {ASPECT_TYPENAME_STR , sizeof(u_long) }, - {ASPECT_TYPENAME_SHORT , sizeof(u_short) }, - {ASPECT_TYPENAME_INT , sizeof(u_int) }, - {ASPECT_TYPENAME_LONG , sizeof(u_long) }, - {ASPECT_TYPENAME_DADDR , sizeof(u_long) }, - {ASPECT_TYPENAME_CADDR , sizeof(u_long) }, - {ASPECT_TYPENAME_BIT , sizeof(u_char) }, - {ASPECT_TYPENAME_VECT , sizeof(vector_t) }, - {ASPECT_TYPENAME_HASH , sizeof(hash_t) }, - {ASPECT_TYPENAME_LIST , sizeof(list_t) }, - {ASPECT_TYPENAME_EXPR , 24 }, /* XXX: should be sizeof(revmexpr_t) */ - {ASPECT_TYPENAME_BLOC , 16 }, /* XXX: should be sizeof(mjrblock_t) */ - {ASPECT_TYPENAME_FUNC , 111 }, /* XXX: should be sizeof(mjrfunc_t) */ - }; - -/** - * @brief Indicate if a type is simple (1) or not (0) - * @param typeid Type identifier to be checked - * @return 1 if type is simple, 0 if not - */ -int aspect_type_simple(int typeid) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (typeid != ASPECT_TYPE_UNKNOW && typeid < ASPECT_TYPE_SIMPLENUM) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Copy the structure representing a field data type for creating a new meta-type instance - * @param type Type structure for the field data type - * @param off Offset in parent data type - * @param isptr Indicate if field data type is a pointer - * @param elemnbr Element numbers (if typing an array) - * @param fieldname Name for typed field - * @param dims Dimension array for type - * @return Type structure derived from input information - */ -aspectype_t *aspect_type_copy(aspectype_t *type, - unsigned int off, - u_char isptr, - u_int elemnbr, - char *fieldname, - u_int *dims) -{ - aspectype_t *newtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), NULL); - memcpy(newtype, type, sizeof(aspectype_t)); - newtype->off = off; - newtype->isptr = isptr; - newtype->dimnbr = elemnbr; - newtype->fieldname = fieldname; - newtype->elemnbr = dims; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtype); -} - - -/** - * @brief Copy the structure representing a data type and change its name to create a new meta-type - * @param type Type structure to be copied - * @param name Type name to be copied - * @param fieldshash Hash table of fields for this type (if structure type) - * @param curdepth Number of pointer indirections since start of copy - * @param maxdepth Maximum number of pointer indirections for whole copy - * @return Copied meta-type structure - */ -aspectype_t *aspect_type_copy_by_name(aspectype_t *type, - char *name, - hash_t *fieldshash, - u_int curdepth, - u_int maxdepth) -{ - aspectype_t *newtype; - aspectype_t *result; - aspectype_t *next; - aspectype_t *prev; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (curdepth > maxdepth) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid depth parameters", NULL); - - /* Allocate and name the new type */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), NULL); - memcpy(newtype, type, sizeof(aspectype_t)); - if (name) - newtype->name = strdup(name); - if (fieldshash && newtype->fieldname) - hash_add(fieldshash, strdup(newtype->fieldname), (void *) 1); - prev = result = newtype; - - /* Here check if newtype->childs is a pointer */ - if (newtype->childs) - { - if (!newtype->isptr || curdepth != maxdepth || !maxdepth) - { - if (newtype->isptr) - curdepth++; - newtype->childs = aspect_type_copy_by_name(newtype->childs, NULL, - (!newtype->fieldname ? fieldshash : NULL), - curdepth, maxdepth); - if (newtype->isptr) - curdepth--; - } - else - newtype->childs = NULL; - } - - /* Copy all the field types, if we are dealing with a record type */ - for (next = newtype->next; next; next = next->next) - { - - /* Copy the type structure */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), NULL); - memcpy(newtype, next, sizeof(aspectype_t)); - - /* Set this field name as used to avoid doubles */ - if (fieldshash) - hash_add(fieldshash, strdup(newtype->fieldname), (void *) 1); - - /* Here check if next->childs is a pointer */ - if (next->childs) - { - if (!next->childs->isptr || curdepth != maxdepth || !maxdepth) - { - if (next->childs->isptr) - curdepth++; - newtype->childs = aspect_type_copy_by_name(next->childs, - NULL, NULL, - curdepth, maxdepth); - if (next->childs->isptr) - curdepth--; - } - else - next->childs = NULL; - } - - /* Now next type in structure */ - prev->next = newtype; - prev = newtype; - } - - /* Return copied root type as a result */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, result); -} - - -/** - * @brief Add a field to a meta-type - * @param parent Parent data type - * @param field Field data type to add to parent - * @return 0 on succes and -1 on error - */ -int aspect_type_addfield(aspectype_t *parent, - aspectype_t *field) -{ - volatile aspectype_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!parent || !field) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (!parent->childs) - parent->childs = field; - else - { - for (next = parent->childs; next->next; next = next->next); - next->next = field; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Find the number of dimensions for a field - * @param typename Complete type name string (can be array) - * @param dimnbr Pointer on dimension number integer to be filled - * @return NULL on error or dimension array on succesfull allocation -*/ -static u_int *aspect_type_getdims(char *typename, int *dimnbr) -{ - char *idxname; - char *idxend; - u_int *dims; - char *realtypename; - int idx; - int curidx; - u_int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First count the number of dimensions */ - for (idx = 0, realtypename = typename; *typename; - typename = idxend + 1) - { - idxname = strchr(typename, '['); - if (idxname) - { - idxend = strchr(idxname + 1, ']'); - if (!idxend) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array dimensions", NULL); - idx++; - } - else - break; - } - - *dimnbr = idx; - - /* Then allocate the array */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - dims, idx * sizeof(int), NULL); - - /* Fill array with fetched indexes */ - for (curidx = 0, typename = realtypename; - curidx < idx; - typename = idxend + 1, curidx++) - { - idxname = strchr(typename, '['); - *idxname = 0x00; - idxend = strchr(idxname + 1, ']'); - sz = atoi(idxname + 1); - if (!sz) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array element number", NULL); - dims[curidx] = sz; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dims); -} - - -/** - * @brief Find the size of an union type - * @param utype Union type whose size is to be infered - * @return Total size for union type - */ -int aspect_type_find_union_size(aspectype_t *utype) -{ - int biggest = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!utype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input type", 0); - if (!utype->next && utype->childs) - utype = utype->childs; - while (utype) - { - if (utype->size > biggest) - biggest = utype->size; - utype = utype->next; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, biggest); -} - - - -/** - * @brief Create a new (meta description) type - * @param isunion 1 if type to be created is a union - * @param label String name for new type - * @param fields List of fields for type - * @param fieldnbr Number of fields for type - * @return Created type structure - */ -aspectype_t *aspect_type_create(u_char isunion, - char *label, - char **fields, - u_int fieldnbr) -{ - aspectype_t *newtype; - aspectype_t *childtype; - aspectype_t *copy; - aspectype_t *supertype; - int index; - char *fieldname; - char *typename; - char *fieldsz; - u_int curoff, off; - char isptr; - int dimnbr; - u_int *dims; - u_int idx; - u_int size; - hash_t fields_hash; - u_char updatetype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (!label || !fields || !fieldnbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Subtyping was specified */ - updatetype = 0; - supertype = NULL; - typename = strstr(label, "::"); - if (typename) - { - *typename = 0x00; - typename += 2; - supertype = aspect_type_get_by_name(typename); - if (!supertype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid record derivation", NULL); - } - - /* Check that the created type name is not existing already */ - /* It is authorized to update/change some specific types: bloc, func, vector, hash, list .. */ - newtype = hash_get(&types_hash, label); - if (newtype && (newtype->type < ASPECT_TYPE_CORENUM || newtype->type >= ASPECT_TYPE_BASENUM)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create type : name already exists", NULL); - - /* Just remember the name of fields we have already created */ - bzero(&fields_hash, sizeof(hash_t)); - hash_init(&fields_hash, "localfields", 10, ASPECT_TYPE_UNKNOW); - - /* Allocate the new type structure */ - if (!supertype) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), NULL); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype->childs, sizeof(hash_t), NULL); - newtype->childs = NULL; - newtype->name = strdup(label); - curoff = 0; - } - else - { - newtype = aspect_type_copy_by_name(supertype, label, &fields_hash, 0, ASPECT_TYPE_MAXPTRDEPTH); - curoff = newtype->size; - } - - /* Add fields to types */ - for (dims = NULL, off = dimnbr = isptr = index = 0; - index < fieldnbr; - index++, off = dimnbr = isptr = 0, dims = NULL) - { - /* Field name */ - fieldname = fields[index]; - - /* Typename */ - typename = strchr(fields[index], ':'); - if (typename) - *typename++ = 0x00; - - /* Size field */ - fieldsz = strchr(fields[index], '%'); - if (fieldsz) - *fieldsz++ = 0x00; - - /* Either you provide the size or the typename */ - if (!*fieldname || hash_get(&fields_hash, fieldname) || - (!typename && !fieldsz) || (typename && fieldsz) || - (typename && !*typename) || (fieldsz && (!*fieldsz || !atoi(fieldsz)))) - - { - hash_destroy(&fields_hash); - XFREE(__FILE__, __FUNCTION__, __LINE__, newtype->name); - XFREE(__FILE__, __FUNCTION__, __LINE__, newtype); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid use of fieldname or typename", NULL); - } - hash_add(&fields_hash, strdup(fieldname), (void *) 1); - - /* Support raw types determined by their size */ - if (!typename) - { - off = atoi(fieldsz); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - childtype, sizeof(aspectype_t), NULL); - childtype->type = ASPECT_TYPE_RAW; - childtype->size = off; - childtype->name = aspect_typeinfo[childtype->type].name; - } - - /* Deals with incomplete types */ - else - { - /* Pointer types */ - isptr = 0; - while (typename[0] == '*') - { - isptr += 1; - typename++; - } - - /* Array type */ - dims = aspect_type_getdims(typename, &dimnbr); - if (dimnbr < 0) - { - hash_destroy(&fields_hash); - XFREE(__FILE__, __FUNCTION__, __LINE__,newtype->name); - XFREE(__FILE__, __FUNCTION__, __LINE__,newtype); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array dimensions", NULL); - } - - /* Lookup field type */ - childtype = hash_get(&types_hash, typename); - if (!childtype) - { - /* If we have a non-pointer recursive type, - make it a pointer */ - if (!strcmp(label, typename)) - { - isptr = 1; - childtype = newtype; - off = sizeof(u_long); - } - - /* If we point on a unknown type, mark is as unknown */ - else if (isptr) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - childtype, sizeof(aspectype_t), NULL); - childtype->type = ASPECT_TYPE_UNKNOW; - childtype->name = strdup(typename); - - } - else - { - hash_destroy(&fields_hash); - XFREE(__FILE__, __FUNCTION__, __LINE__, newtype->name); - XFREE(__FILE__, __FUNCTION__, __LINE__, newtype); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type structure", NULL); - } - } - else - off = (isptr ? sizeof(u_long) : childtype->size); - } - - /* Copy an existing base type for this child and change type offset */ - copy = aspect_type_copy(childtype, (isunion ? 0 : curoff), isptr, - dimnbr, fieldname, dims); - for (size = off, idx = 0; dims != NULL && idx < dimnbr; idx++) - size *= dims[idx]; - - /* Compute the correct size for bitfields */ - if (childtype->type == ASPECT_TYPE_BIT) - { - size /= 8; - size++; - } - - curoff += size; - aspect_type_addfield(newtype, copy); - } - - /* Add type to global type hash table and return success */ - newtype->size = (isunion ? aspect_type_find_union_size(newtype) : curoff); - hash_destroy(&fields_hash); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtype); -} - - -/** - * @brief The real type registering code - * @param label Name for type to be registered - * @param ntype Type structure to be registered - * @return 0 on success and -1 on error - */ -int aspect_type_register_real(char *label, - aspectype_t *ntype) -{ - aspectype_t *update; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We do a type update of one of the base type */ - update = hash_get(&types_hash, label); - if (update) - { - ntype->type = update->type; - hash_set(&types_hash, label, ntype); - aspect_typeinfo[ntype->type].size = ntype->size; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* A real new type incrementing the last type id */ - hash_add(&types_hash, label, ntype); - aspect_type_nbr++; - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - aspect_typeinfo, aspect_typeinfo, - sizeof(typeinfo_t) * aspect_type_nbr, -1); - aspect_typeinfo[aspect_type_nbr - 1].name = label; - aspect_typeinfo[aspect_type_nbr - 1].size = ntype->size; - ntype->type = aspect_type_nbr - 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Wrapper for easy type creation and registration - * @param isunion 1 if registered type is a union - * @param label Name of registered type - * @param fields Array of field names for registered type - * @param fieldnbr Number of fields for registered type - * @return 0 on success and -1 on error - */ -int aspect_type_register(u_char isunion, - char *label, - char **fields, - u_int fieldnbr) -{ - aspectype_t *ret; - int iret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = aspect_type_create(isunion, label, fields, fieldnbr); - - if (!ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type declaration", -1); - - iret = aspect_type_register_real(label, ret); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, iret); -} - - -/** - * @brief Create a new type with a single field (internal function) - * @param type Type identifier to be created - * @param info Internal typeinfo structure related to newly created type - * @return 0 on success and -1 on error - */ -static int aspect_basetype_create(u_int type, typeinfo_t *info) -{ - aspectype_t *newtype; - char hashname[BUFSIZ]; - hash_t *newhash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), -1); - newtype->type = type; - newtype->size = info->size; - newtype->name = info->name; - hash_add(&types_hash, info->name, newtype); - - /* Create the hash table for objects of that type */ - snprintf(hashname, sizeof(hashname), "type_%s", info->name); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newhash, sizeof(hash_t), -1); - hash_init(newhash, strdup(hashname), 11, ASPECT_TYPE_UNKNOW); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Create all simple types - * @return 0 on success and -1 on error - */ -int aspect_basetypes_create() -{ - int index; - u_int basesize; - static u_int done = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (done) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - done = 1; - basesize = ASPECT_TYPE_BASENUM * sizeof(typeinfo_t); - XALLOC(__FILE__, __FUNCTION__, __LINE__, aspect_typeinfo, basesize, -1); - memcpy(aspect_typeinfo, aspect_typeinfo_base, basesize); - for (index = 1; index < ASPECT_TYPE_BASENUM; index++) - aspect_basetype_create(index, aspect_typeinfo + index); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get field type from field name and parent type - * @param parent Parent type structure - * @param name Field name to lookup - * @return Type for looked-up field - */ -aspectype_t *aspect_type_get_child(aspectype_t *parent, char *name) -{ - aspectype_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (cur = parent->childs; cur; cur = cur->next) - if (!strcmp(cur->fieldname, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cur); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown child name", NULL); -} - -/** - * @brief Get a type by its type id - * @param id Type identifier to be found - * @return Structure for matching type - */ -aspectype_t *aspect_type_get_by_id(unsigned int id) -{ - aspectype_t *type; - typeinfo_t info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (id >= aspect_type_nbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type ID", NULL); - info = aspect_typeinfo[id]; - type = hash_get(&types_hash, info.name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/** - * @brief Get a type by its type id - * @param name Type name to be found - * @return Structure for matching type - */ -aspectype_t *aspect_type_get_by_name(char *name) -{ - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - type = hash_get(&types_hash, name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - - - -/** - * @brief Return the list of base types - * @param nbr Integer pointer that will be filled with the number of base types - * @return Pointer on array of internal Typeinfo structures - */ -typeinfo_t *aspect_basetype_get(unsigned int *nbr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (nbr) - *nbr = ASPECT_TYPE_BASENUM; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, aspect_typeinfo_base); -} - - -/** - * @brief Create and register a new simple type - * @param name Name for new base type - * @param size Total size for new base type - * @return -1 on error and 0 on success - */ -int aspect_basetype_register(char *name, u_int size) -{ - typeinfo_t info; - aspectype_t *exist; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - exist = (aspectype_t *) hash_get(&types_hash, name); - - if (exist) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Type destination already exist", -1); - - info.name = name; - info.size = size; - - aspect_basetype_create(aspect_type_nbr, &info); - - /* The type ID is incremented here */ - aspect_type_nbr++; - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - aspect_typeinfo, aspect_typeinfo, - sizeof(typeinfo_t) * aspect_type_nbr, -1); - aspect_typeinfo[aspect_type_nbr - 1].name = name; - aspect_typeinfo[aspect_type_nbr - 1].size = size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Retreive the ascii name of a type - * @param type Requested type identifier - * @return Name associated to type identifier - */ -char *aspect_typename_get(u_int type) -{ - if (type >= aspect_type_nbr) - return (NULL); - return (aspect_typeinfo[type].name); -} - -/** - * @brief Retreive the size (in bytes) of a type - * @param type Requested type identifier - * @return Size of requested type - */ -u_int aspect_typesize_get(u_int type) -{ - if (type >= aspect_type_nbr) - return (0); - return (aspect_typeinfo[type].size); -} - diff -Nru eresi-0.8a25/libaspect/.svn/text-base/vectors.c.svn-base eresi-0.0.20110516/libaspect/.svn/text-base/vectors.c.svn-base --- eresi-0.8a25/libaspect/.svn/text-base/vectors.c.svn-base 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/.svn/text-base/vectors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,262 +0,0 @@ -/* -** @file vectors.c -** -** @brief Implement the modularity for the framework -** -** Started Dec 22 2006 02:57:03 jfv -** -** -** $Id: vectors.c,v 1.25 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libaspect.h" - -hash_t *vector_hash = NULL; - - -/** - * @brief Retreive a vector from the hash table giving its name - * @param name Vector name - * @return Found vector, or NULL if unfound - */ -vector_t* aspect_vector_get(char *name) -{ - vector_t *vect; - - if (!vector_hash) - { - printf("Tried to get a vector when hash table = NULL \n"); - sleep(30); - return (NULL); - } - - vect = (vector_t *) hash_get(vector_hash, name); - return (vect); -} - -/** - * @brief Retreive the hash table : useful when iterating over it - * @return Return a pointer to the global hash table - */ -hash_t* aspect_vecthash_get() -{ - return (vector_hash); -} - - -/** - * @brief Project each dimension and write the desired function pointer - * @param vect Vector in which handlers are to be inserted - * @param dim Dimension arrays where handler is to be inserted - * @param fct Handler to be inserted (casted to unsigned long) - */ -void aspect_vectors_insert(vector_t *vect, - unsigned int *dim, - unsigned long fct) -{ - unsigned long *tmp; - unsigned int idx; - unsigned int dimsz; - - dimsz = vect->arraysz; - tmp = (unsigned long *) vect->hook; - for (idx = 0; idx < dimsz; idx++) - { - tmp += dim[idx]; - if (idx + 1 < dimsz) - tmp = (unsigned long *) *tmp; - } - *tmp = (unsigned long) fct; -} - - -/** - * @brief Project each dimension and get the requested function pointer - * @param vect Vector to be looked up - * @param dim DImension arrays where handler is to be selected - * @return Return Function pointer for selected handler - */ -void* aspect_vectors_select(vector_t *vect, unsigned int *dim) -{ - unsigned long *tmp; - unsigned int idx; - unsigned int dimsz; - - tmp = (unsigned long *) vect->hook; - dimsz = vect->arraysz; - for (idx = 0; idx < dimsz; idx++) - { - tmp += dim[idx]; - tmp = (unsigned long *) *tmp; - } - return (tmp); -} - - -/** - * @brief Project each dimension and get the requested vector element pointer - * @param vect Vector to be looked up - * @param dim Dimension arrays for vector element - * @return The element of the vector containing the requested handler - */ -void *aspect_vectors_selectptr(vector_t * vect, - unsigned int *dim) -{ - unsigned long *tmp; - unsigned int idx; - unsigned int dimsz; - - tmp = (unsigned long *) vect->hook; - dimsz = vect->arraysz; - for (idx = 0; idx < dimsz; idx++) - { - tmp += dim[idx]; - if (idx + 1 < dimsz) - tmp = (unsigned long *) *tmp; - } - return (tmp); -} - - - - -/** - * @brief Allocate recursively the hook array for a vector (internal function) - * @param tab Vector hook array to be allocated - * @param dims Vector dimensions array - * @param depth Vector depth remaining to be allocated - * @param dimsz Number of dimensions in vector - * return 0 in success or -1 if error - */ -static int aspect_vectors_recalloc(unsigned long *tab, - unsigned int *dims, - unsigned int depth, - unsigned int dimsz) -{ - unsigned int idx; - void *ptr; - - //PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("Calling recalloc with depth = %u and dimsz = %u\n", - //depth, dimsz); - - if (depth == dimsz) - return (0); - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - for (idx = 0; idx < dims[depth - 1]; idx++) - { - - //XALLOC(__FILE__, __FUNCTION__, __LINE__, - //ptr, dims[depth] * sizeof(unsigned long), -1); - - ptr = calloc(dims[depth] * sizeof(unsigned long), 1); - if (!ptr) - return (-1); - - tab[idx] = (unsigned long) ptr; - aspect_vectors_recalloc((unsigned long *) tab[idx], - dims, depth + 1, dimsz); - } - - - //printf("GETTING OUT OF recalloc with depth = %u and dimentnbr = %u\n", - // depth, dimsz); - - return (0); - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Initialize recursively the hook array in a vector (internal function) - * @param tab Vector hopl array to be initialized - * @param dims Dimension array for vector - * @param depth Vector depth remaining to be initialized - * @param dimsz Number of dimensions for vector - * @param defaultelem Default element for vector - * @return Always 0 - */ -static int aspect_vectors_recinit(unsigned long *tab, - unsigned int *dims, - unsigned int depth, - unsigned int dimsz, - void *defaultelem) -{ - unsigned int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if we reached a leaf, otherwise recurse more */ - if (depth == dimsz) - { - for (idx = 0; idx < dims[depth - 1]; idx++) - tab[idx] = (unsigned long) defaultelem; - } - else - for (idx = 0; idx < dims[depth - 1]; idx++) - aspect_vectors_recinit((unsigned long *) tab[idx], dims, - depth + 1, dimsz, defaultelem); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Register a new vector. A vector is an multidimentional array of hooks - * @param name Vector name to be registered - * @param defaultfunc Default handler for initializing all vector elements - * @param dimensions Dimension arrays for the vector - * @param strdims Dimension arrays for dimension description (to be printed) - * @param dimsz Number of dimensions - * @param vectype Type of elements inside this new vector - * @return 0 on success and -1 on error - */ -int aspect_register_vector(char *name, - void *defaultfunc, - unsigned int *dimensions, - char **strdims, - unsigned int dimsz, - unsigned int vectype) -{ - vector_t *vector; - unsigned long *ptr; - void *mem; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!defaultfunc || !dimsz || !dimensions) - { - write(1, "Invalid NULL parameters\n", 24); - return (-1); - } - if (vectype >= aspect_type_nbr) - { - write(1, "Invalid vector element type\n", 28); - return (-1); - } - - XALLOC(__FILE__, __FUNCTION__, __LINE__, mem, sizeof(vector_t), -1); - vector = (vector_t *) mem; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, mem, - dimensions[0] * sizeof(unsigned long), -1); - ptr = (unsigned long *) mem; - - vector->hook = ptr; - if (dimsz > 1) - aspect_vectors_recalloc((unsigned long *) vector->hook, - dimensions, 1, dimsz); - - vector->arraysz = dimsz; - vector->arraydims = dimensions; - vector->strdims = strdims; - vector->default_func = defaultfunc; - hash_add(vector_hash, name, vector); - - /* Initialize vectored elements */ - aspect_vectors_recinit((unsigned long *) vector->hook, - dimensions, 1, dimsz, defaultfunc); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} diff -Nru eresi-0.8a25/libaspect/types.c eresi-0.0.20110516/libaspect/types.c --- eresi-0.8a25/libaspect/types.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/types.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,12 +1,10 @@ /** -** @file types.c -** -** @brief The base of the unified type system +* @file libaspect/types.c +** @ingroup libaspect +** @brief The base of the unified type system. ** ** Started on Sun Jan 9 07:23:58 2007 jfv -** -** $Id: types.c,v 1.24 2008-02-16 12:32:27 thor Exp $ -** +** $Id: types.c 1397 2009-09-13 02:19:08Z may $ */ #include "libaspect.h" @@ -25,19 +23,21 @@ {ASPECT_TYPENAME_UNKNOW , 0 }, {ASPECT_TYPENAME_RAW , 0 }, {ASPECT_TYPENAME_BYTE , sizeof(u_char) }, - {ASPECT_TYPENAME_STR , sizeof(u_long) }, + {ASPECT_TYPENAME_STR , sizeof(u_long) }, {ASPECT_TYPENAME_SHORT , sizeof(u_short) }, {ASPECT_TYPENAME_INT , sizeof(u_int) }, {ASPECT_TYPENAME_LONG , sizeof(u_long) }, - {ASPECT_TYPENAME_DADDR , sizeof(u_long) }, - {ASPECT_TYPENAME_CADDR , sizeof(u_long) }, + {ASPECT_TYPENAME_DADDR , sizeof(eresi_Addr) }, + {ASPECT_TYPENAME_CADDR , sizeof(eresi_Addr) }, {ASPECT_TYPENAME_BIT , sizeof(u_char) }, + {ASPECT_TYPENAME_OID , sizeof(u_int) }, {ASPECT_TYPENAME_VECT , sizeof(vector_t) }, {ASPECT_TYPENAME_HASH , sizeof(hash_t) }, {ASPECT_TYPENAME_LIST , sizeof(list_t) }, - {ASPECT_TYPENAME_EXPR , 24 }, /* XXX: should be sizeof(revmexpr_t) */ - {ASPECT_TYPENAME_BLOC , 16 }, /* XXX: should be sizeof(mjrblock_t) */ - {ASPECT_TYPENAME_FUNC , 111 }, /* XXX: should be sizeof(mjrfunc_t) */ + {ASPECT_TYPENAME_EXPR , 28 }, /* XXX: should be sizeof(revmexpr_t) */ + {ASPECT_TYPENAME_BLOC , 13 }, /* XXX: should be sizeof(mjrblock_t) */ + {ASPECT_TYPENAME_FUNC , 110 }, /* XXX: should be sizeof(mjrfunc_t) */ + {ASPECT_TYPENAME_LINK , 6 }, /* XXX: should be sizeof(mjrlink_t) */ }; /** @@ -79,7 +79,7 @@ newtype->off = off; newtype->isptr = isptr; newtype->dimnbr = elemnbr; - newtype->fieldname = fieldname; + newtype->fieldname = strdup(fieldname); newtype->elemnbr = dims; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtype); } @@ -461,7 +461,7 @@ XFREE(__FILE__, __FUNCTION__, __LINE__, newtype->name); XFREE(__FILE__, __FUNCTION__, __LINE__, newtype); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type structure", NULL); + "Invalid type structure", NULL); } } else diff -Nru eresi-0.8a25/libaspect/vectors.c eresi-0.0.20110516/libaspect/vectors.c --- eresi-0.8a25/libaspect/vectors.c 2008-04-06 23:15:53.000000000 +0000 +++ eresi-0.0.20110516/libaspect/vectors.c 2011-05-16 11:34:14.000000000 +0000 @@ -1,13 +1,14 @@ -/* -** @file vectors.c -** -** @brief Implement the modularity for the framework +/** + * @defgroup libaspect libaspect: The ERESI aspect library. + * @ingroup ERESI + */ +/** +* @file libaspect/vectors.c +** @ingroup libaspect +** @brief Implement the modularity for the framework. ** ** Started Dec 22 2006 02:57:03 jfv -** -** -** $Id: vectors.c,v 1.25 2008-02-16 12:32:27 thor Exp $ -** +** $Id: vectors.c 1440 2010-12-29 02:22:03Z may $ */ #include "libaspect.h" @@ -228,12 +229,12 @@ if (!defaultfunc || !dimsz || !dimensions) { - write(1, "Invalid NULL parameters\n", 24); + (void) write(1, "Invalid NULL parameters\n", 24); return (-1); } if (vectype >= aspect_type_nbr) { - write(1, "Invalid vector element type\n", 28); + (void) write(1, "Invalid vector element type\n", 28); return (-1); } diff -Nru eresi-0.8a25/libdump/doc/.svn/all-wcprops eresi-0.0.20110516/libdump/doc/.svn/all-wcprops --- eresi-0.8a25/libdump/doc/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/12/trunk/libdump/doc -END -DUMP-draft -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/12/trunk/libdump/doc/DUMP-draft -END -TODO -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/12/trunk/libdump/doc/TODO -END diff -Nru eresi-0.8a25/libdump/doc/.svn/entries eresi-0.0.20110516/libdump/doc/.svn/entries --- eresi-0.8a25/libdump/doc/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libdump/doc -http://svn.eresi-project.org/svn - - - -2005-08-02T06:43:53.000000Z -12 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -DUMP-draft -file - - - - -2008-04-06T23:15:44.746902Z -4ebb1a2f6aa305f6a8b83a1ccd61b59c -2005-08-02T06:43:53.000000Z -12 -thor - -TODO -file - - - - -2008-04-06T23:15:44.757136Z -36414766ce183ffd7476fe2ff6a99ff9 -2005-08-02T06:43:53.000000Z -12 -thor - diff -Nru eresi-0.8a25/libdump/doc/.svn/format eresi-0.0.20110516/libdump/doc/.svn/format --- eresi-0.8a25/libdump/doc/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libdump/doc/.svn/text-base/DUMP-draft.svn-base eresi-0.0.20110516/libdump/doc/.svn/text-base/DUMP-draft.svn-base --- eresi-0.8a25/libdump/doc/.svn/text-base/DUMP-draft.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/doc/.svn/text-base/DUMP-draft.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,125 +0,0 @@ - - .:| DUMP v0a3 |:. - - Created on Mon Feb 7 16:38:21 2005 ym - Updated on Wed Mar 16 20:38:38 2005 ym - -:\ New direction ;/ -Instead of building a tree on top of existing connections we will use an -ad-hoc like routing protocol (very similar to Direct Source Routing) - -:\ Node knowledge :/ -Type socket -Type id -Type pkt_id -Type port = (socket, id) -Var myids = list of id -Var ports = list of port -Enum MsgType = ... -Var RRrecentlyUsed = list of (pkt_id) -Var RrrecentlyUsed = list of (pkt_id) - -:\ Types of Messages /: -- : Route Request -- : Route reply -- : Legacy Message - - -:\ States /: -- M : main state (listening state) -- R : handle RR messages -> receive_RR(src, path, dest) -- r : handle Rr messages -> receive_Rr(src, path, dest) - - -:\ Automaton /: - - |-[Rr received]--> r - M |-[RR received]--> R - |-[...]----------> ?? - - -:\ Functions /: -(for process i) - -== receive_RR : == -if ( "in" RRrecentlyUsed) -{ - // nothing -} -else -{ - RRrecentlyUsed = RRrecentlyUsed + - /* we are the destination */ - if (dest == i) - { - /* get the previous node in the path */ - prev = last (path) - /* send route reply */ - send (, prev) - } - /* we are only a node */ - else - { - /* don't forward to sender */ - forall (j "in" Ports\{last(path)}) - { - send (, j) - } - } -} - -== receive_Rr: == -if ( "in" RrrecentlyUsed) -{ - // nothing -} -else -{ - RrrecentlyUsed = RrrecentlyUsed + - /* we are the destination */ - if (dest == i) - { - // we received a path to the requested destination - } - /* we are only a node */ - else - { - next = next (path, i); - send (, next) - } -} - -== get_route (dest) == -/* create the first RR message and send it */ -recentlySeen = recentlySeen + -forall (j "in" Ports) -{ - send (, j) -} -// wait for an Rr, the first for exemple or the shorter or whatever - -== clean_recentlyUsed (date) == -/* clean the recentlyUsed table */ -forall (j "in" recentlyUsed) -{ - if (j.timestamp < date) - remove(j); -} - -== last (path) == -/* return the last element (id) of the given path */ - -== next (path, i) == -/* return the next node to i in the path */ - - -:\ Questions/Notes /: -- what else ? - -> how to ensure communication reliability ? - - - - - - - diff -Nru eresi-0.8a25/libdump/doc/.svn/text-base/TODO.svn-base eresi-0.0.20110516/libdump/doc/.svn/text-base/TODO.svn-base --- eresi-0.8a25/libdump/doc/.svn/text-base/TODO.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/doc/.svn/text-base/TODO.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ - .:/ DUMP To DO list \:. - -:: Created on Wed Mar 16 20:21:43 2005 ym :: - - -A. Known issues : - - - DUMP does not support NAT routers : - The Id that the other know as being mine is not the Id that I think i - have. - => In order to solve this issue, we should exchange Id at the begining - of the communication. - -B. Code modifications : - - - add negociation on connection. - - add authentication on connection. - - extend protocol to allow set of Id direct send (multicast) - and all directed send (broadcast). - - allow easy definition of new message type, and corresponding handling - function. - - allow to use other than TCP sockets (SSL, UDP, ...) -> add packet checksum - - struct dump_op_s, dump_register(dump_type_t, function) ... ? diff -Nru eresi-0.8a25/libdump/dump.c eresi-0.0.20110516/libdump/dump.c --- eresi-0.8a25/libdump/dump.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/dump.c 2011-05-16 11:35:01.000000000 +0000 @@ -5,10 +5,9 @@ ** Updated on Wed Mar 9 22:02:29 CET 2005 ym ** ** -** $Id: dump.c,v 1.5 2007-08-03 18:05:03 may Exp $ +** $Id: dump.c 1311 2009-01-14 20:36:48Z may $ ** */ - #include "libdump.h" /**************************/ @@ -45,11 +44,8 @@ int dump_add_neighbor(int s, dump_id_t peer_addr) { char *tmp; - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_neighbor : [%d,%s]\n", s, inet_ntoa(peer_addr)); -#endif - + DEBUGPRINT(printf("[DUMP] dump_add_neighbor : [%d,%s]\n", s, + inet_ntoa(peer_addr))); tmp = inet_ntoa(peer_addr); hash_add(&dump_world.ports, strdup(tmp), (void *) (int) s); @@ -129,9 +125,7 @@ if (hash_get(&dump_world.RRrecently_seen, str) != NULL) { -#if __DEBUG_DUMP__ - printf("[DUMP] DUP(RR)!!\n"); -#endif + DEBUGPRINT(printf("[DUMP] DUP(RR)!!\n")); return 1; } else @@ -147,9 +141,7 @@ if (hash_get(&dump_world.RRrecently_seen, str) != NULL) { -#if __DEBUG_DUMP__ - printf("[DUMP] DUP(Rr)!!\n"); -#endif + DEBUGPRINT(printf("[DUMP] DUP(Rr)!!\n")); return 1; } else @@ -202,38 +194,26 @@ pkt_wq_t *new; NOPROFILER_IN(); - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_send_queue \n"); -#endif + DEBUGPRINT(printf("[DUMP] dump_add_send_queue \n")); XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (pkt_wq_t), -1); new->next = NULL; new->pkt = pkt; -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_send_queue : "); -#endif - + DEBUGPRINT(printf("[DUMP] dump_add_send_queue : ")); if (tmp != NULL) { while (tmp->next != NULL) { -#if __DEBUG_DUMP__ - printf("."); -#endif + DEBUGPRINT(printf(".")); tmp = tmp->next; } tmp->next = new; } else dump_world.send_wq = new; - -#if __DEBUG_DUMP__ - printf("\n"); -#endif - + DEBUGPRINT(printf("\n")); return 0; } @@ -242,34 +222,24 @@ { pkt_wq_t *tmp = dump_world.send_wq; -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue\n"); -#endif - + DEBUGPRINT(printf("[DUMP] dump_lookup_send_queue\n")); if (tmp == NULL) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue -> nothing to send\n"); -#endif + DEBUGPRINT(printf("[DUMP] dump_lookup_send_queue -> nothing to send\n")); return NULL; } for (; tmp != NULL; tmp = tmp->next) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue " - "-> proposed dst %s :\n", inet_ntoa(dst)); - printf("[DUMP] dump_lookup_send_queue " - "-> packet dst %s :\n", inet_ntoa(tmp->pkt->dst)); -#endif - + DEBUGPRINT(printf("[DUMP] dump_lookup_send_queue " + "-> proposed dst %s :\n", inet_ntoa(dst))); + DEBUGPRINT(printf("[DUMP] dump_lookup_send_queue " + "-> packet dst %s :\n", inet_ntoa(tmp->pkt->dst))); if (memcmp(&(tmp->pkt->dst), &dst, sizeof (dump_id_t))==0) return tmp->pkt; } -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue " - "-> nothing matching this destination \n"); -#endif + DEBUGPRINT(printf("[DUMP] dump_lookup_send_queue " + "-> nothing matching this destination \n")); return NULL; } @@ -281,10 +251,7 @@ /* * DO NOT free pkt->path ... */ -#if __DEBUG_DUMP__ - printf("[DUMP] dump_del_send_queue\n"); -#endif - + DEBUGPRINT(printf("[DUMP] dump_del_send_queue\n")); for (; tmp != NULL; prev = tmp, tmp = tmp->next) { if (tmp->pkt == pkt) @@ -380,9 +347,7 @@ { if (!strcmp(actual->data, inet_ntoa(id))) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_is_myid : IT'S ME\n"); -#endif + DEBUGPRINT(printf("[DUMP] dump_is_myid : IT'S ME\n")); return 1; } } @@ -408,9 +373,8 @@ actual != NULL && actual->key != NULL; actual = actual->next) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : default id : %s \n", (char *) actual->data); -#endif + DEBUGPRINT(printf("[DUMP] dump_get_myid : default id : %s \n", + (char *) actual->data)); inet_aton((char *)actual->data, &ret); return ret; } @@ -423,22 +387,17 @@ if (tmp2 == NULL) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : id not found\n"); -#endif + DEBUGPRINT(printf("[DUMP] dump_get_myid : id not found\n")); ret.s_addr = htonl(INADDR_ANY); return ret; } inet_aton(tmp2, &ret); - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : using id -> %s\n", tmp2); -#endif - + DEBUGPRINT(printf("[DUMP] dump_get_myid : using id -> %s\n", tmp2)); return ret; } + /* add an id to myids hash table */ int dump_add_myid(dump_id_t id, int s) { @@ -450,6 +409,7 @@ return 0; } + /* del an id from myids hash table */ int dump_del_myid(int s) { @@ -480,9 +440,7 @@ { if ((long) actual->data == s) { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_disconnect from : %s", actual->key); -#endif + DEBUGPRINT(printf("[DUMP] dump_disconnect from : %s", actual->key)); dump_del_myid(s); hash_del(&dump_world.ports, actual->key); @@ -492,9 +450,8 @@ return 0; } } -#if __DEBUG_DUMP__ - printf("[DUMP] dump_disconnect : not connected on socket %d\n", s); -#endif + DEBUGPRINT(printf("[DUMP] dump_disconnect : " + "not connected on socket %d\n", s)); return (-1); } @@ -508,7 +465,7 @@ if (h == NULL) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Unknown host '%s'\n", host); #endif return (-1); @@ -529,7 +486,8 @@ { int sd, rc; struct hostent *h; - struct sockaddr_in local_addr, serv_addr; + struct sockaddr_in local_addr; + struct sockaddr_in serv_addr; struct sockaddr_in loc; socklen_t lloc = sizeof (struct sockaddr_in); @@ -537,21 +495,22 @@ if (h == NULL) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Unknown host '%s'\n", host); #endif return 0; } - + serv_addr.sin_family = h->h_addrtype; memcpy((char *) &serv_addr.sin_addr.s_addr, h->h_addr_list[0], h->h_length); + serv_addr.sin_port = htons(port); if (dump_lookup_neighbor(serv_addr.sin_addr) != 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Already connected to %s\n", host); #endif return (-1); @@ -559,7 +518,7 @@ if (dump_is_myid(serv_addr.sin_addr) == 1 ) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Attempt to connect to local node\n"); #endif return (-1); @@ -569,7 +528,7 @@ sd = socket(AF_INET, SOCK_STREAM, 0); if (sd < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) perror("cannot open socket "); #endif return (-1); @@ -583,7 +542,7 @@ rc = bind(sd, (struct sockaddr *) &local_addr, sizeof (local_addr)); if (rc < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Cannot bind port TCP %u\n", port); perror("error "); #endif @@ -594,7 +553,7 @@ rc = connect(sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)); if (rc < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) perror("[EE] Cannot connect "); return (-1); #endif @@ -606,15 +565,11 @@ /* add a new id (if not already registred) */ /* get local id */ getsockname(sd, (struct sockaddr *) &loc, &lloc); -#if __DEBUG_DUMP__ - printf("[+] local id : %s \n", - inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr)); - - printf("[+] add new id : %s\n", - inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr)); -#endif + DEBUGPRINT(printf("[+] local id : %s \n", + inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr))); + DEBUGPRINT(printf("[+] add new id : %s\n", + inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr))); dump_add_myid(((struct sockaddr_in *) &loc)->sin_addr, sd); - return sd; } diff -Nru eresi-0.8a25/libdump/dump_main.c eresi-0.0.20110516/libdump/dump_main.c --- eresi-0.8a25/libdump/dump_main.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/dump_main.c 2011-05-16 11:35:01.000000000 +0000 @@ -5,7 +5,7 @@ ** Updated on Wed Mar 9 22:02:29 CET 2005 ym ** ** -** $Id: dump_main.c,v 1.2 2007-03-07 16:45:35 thor Exp $ +** $Id: dump_main.c 1309 2009-01-14 18:41:02Z may $: dump_main.c,v 1.2 2007-03-07 16:45:35 thor Exp $ ** */ diff -Nru eresi-0.8a25/libdump/include/libdump.h eresi-0.0.20110516/libdump/include/libdump.h --- eresi-0.8a25/libdump/include/libdump.h 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/include/libdump.h 2011-05-16 11:35:01.000000000 +0000 @@ -5,14 +5,14 @@ ** Updated on Wed Mar 9 22:02:29 CET 2005 ym ** ** -** $Id: libdump.h,v 1.3 2007-03-07 16:45:35 thor Exp $ +** $Id: libdump.h 1311 2009-01-14 20:36:48Z may $ ** */ #ifndef _LIBDUMP_H_ #define _LIBDUMP_H_ 1 -#include "libelfsh.h" +#include "libaspect.h" #include #include @@ -42,8 +42,18 @@ #define DUMP_MAXTRY 5 /* Debug flags */ -#define __DEBUG_DUMP__ 0 +#define __DEBUG_DUMP__ FALSE +#ifdef __DEBUG_DUMP__ +#define DEBUGPRINT(_command) \ + do \ + { \ + _command; \ + } while(0); +#else +#define DEBUGPRINT(_command) +#endif + /* DUMP error msg */ char *dump_error_msg; diff -Nru eresi-0.8a25/libdump/include/.svn/all-wcprops eresi-0.0.20110516/libdump/include/.svn/all-wcprops --- eresi-0.8a25/libdump/include/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/502/trunk/libdump/include -END -libdump.h -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/502/trunk/libdump/include/libdump.h -END diff -Nru eresi-0.8a25/libdump/include/.svn/entries eresi-0.0.20110516/libdump/include/.svn/entries --- eresi-0.8a25/libdump/include/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libdump/include -http://svn.eresi-project.org/svn - - - -2007-03-07T16:45:36.000000Z -502 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libdump.h -file - - - - -2008-04-06T23:15:44.688892Z -1edb774704a162b92c1a714270d89472 -2007-03-07T16:45:36.000000Z -502 -thor - diff -Nru eresi-0.8a25/libdump/include/.svn/format eresi-0.0.20110516/libdump/include/.svn/format --- eresi-0.8a25/libdump/include/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libdump/include/.svn/text-base/libdump.h.svn-base eresi-0.0.20110516/libdump/include/.svn/text-base/libdump.h.svn-base --- eresi-0.8a25/libdump/include/.svn/text-base/libdump.h.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/include/.svn/text-base/libdump.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -/* -** libdump.h for elfsh -** -** Started on Tue Feb 15 12:53:05 CET 2005 ym -** Updated on Wed Mar 9 22:02:29 CET 2005 ym -** -** -** $Id: libdump.h,v 1.3 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#ifndef _LIBDUMP_H_ -#define _LIBDUMP_H_ 1 - -#include "libelfsh.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - - -#ifndef __socklen_t_defined -typedef uint32_t socklen_t; -# define __socklen_t_defined -#endif - - -/* DUMP Recently Seen limit (s) */ -#define DUMP_RS_LIMIT 60 - -/* DUMP max read try */ -#define DUMP_MAXTRY 5 - -/* Debug flags */ -#define __DEBUG_DUMP__ 0 - -/* DUMP error msg */ -char *dump_error_msg; - -typedef struct in_addr dump_id_t; - -typedef uint16_t pkt_type_t; - -typedef uint32_t pkt_id_t; -typedef uint32_t dump_len_t; - -/* A packet */ -typedef struct s_pkt -{ - dump_id_t src; - dump_id_t dst; -#define RR 1 -#define Rr 2 -#define DATA 3 - pkt_id_t id; - pkt_type_t type; - dump_len_t size; - dump_len_t path_len; - dump_id_t *path; - void *data; -} pkt_t; - - -/* Packet send queue */ -typedef struct s_pkt_wq -{ - pkt_t *pkt; - struct s_pkt_wq *next; -} pkt_wq_t; - - -#define HDR_SIZE (sizeof (pkt_t) - sizeof (void *) - sizeof (dump_id_t *)) -#define HASHTABLE_SIZE 10 - -/* Dump world */ -typedef struct s_dump_world -{ - hash_t RRrecently_seen; /* RR recently seen's id */ - hash_t Rrrecently_seen; /* Rr recently seen's id */ - hash_t ports; /* Neighbors */ - hash_t myids; /* Local ids */ - pkt_wq_t *send_wq; /* Send wait queue */ - int sock; /* Main socket */ -} dump_world_t; - -/* DUMP world */ -dump_world_t dump_world; - - - -/* DUMP functions */ -/* dump.c */ -int dump_init(); -pkt_id_t dump_mk_pkt_id(); -int dump_free(pkt_t *pkt); -int dump_lookup_RR_recently_seen(pkt_id_t id); -int dump_lookup_Rr_recently_seen(pkt_id_t id); -int dump_add_RR_recently_seen(pkt_id_t id); -int dump_add_Rr_recently_seen(pkt_id_t id); -int dump_clean_recently_seen(); -int dump_add_neighbor(int s, dump_id_t peer_addr); -int dump_lookup_neighbor(dump_id_t peer_addr); -int dump_del_neighbor(dump_id_t peer_addr); -pkt_t *dump_lookup_send_queue(dump_id_t dst); -int dump_add_send_queue(pkt_t *pkt); -int dump_del_send_queue(pkt_t *pkt); -int dump_print_pkt(pkt_t *pkt); -dump_id_t dump_get_myid(int s); -int dump_is_myid(dump_id_t id); -int dump_add_myid(dump_id_t id, int s); -int dump_del_myid(int s); -int dump_disconnect(int s); -int dump_disconnect_host(char *host); -int dump_connect_to(char *host, u_int port); -/* recv.c */ -void *dump_receive_cb(int s); -/* send.c */ -int dump_send_DATA(void); -int dump_send_real(int s, pkt_t *data); -int dump_forward_RR(void); -int dump_forward_Rr(void); -int dump_send_RR(dump_id_t src, - dump_id_t dst, - dump_len_t path_len, - dump_id_t *path, - int next_hop_socket, - pkt_id_t id); -int dump_send_Rr(dump_id_t src, - dump_id_t dst, - dump_len_t path_len, - dump_id_t *path, - int next_hop_scoket, - pkt_id_t id); -int dump_send(dump_id_t dst, void *data, dump_len_t len); - -#endif /* _LIBDUMP_H_ */ diff -Nru eresi-0.8a25/libdump/Makefile eresi-0.0.20110516/libdump/Makefile --- eresi-0.8a25/libdump/Makefile 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -1,38 +1,47 @@ ## -## Makefile for libdump in elfsh +## Makefile for libdump in ERESI ## ## Started on Sat Jan 25 05:41:19 2003 jfv -## Last update Tue Feb 15 12:58:45 2005 ym +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ ## include ../config.h -SRC = dump.c recv.c send.c -OBJ = dump.o recv.o send.o -CFLAGS = -Wall $(BITS) -g3 -Iinclude -I../libc/include/ -I../libelfsh/include/ \ - -I../libaspect/include/ -I../elibc/include -DELFSH_INTERN -fPIC -LDFLAGS = -L./ -L../libelfsh/ -lelfsh -ldump -L/usr/pkg/lib/ -ltermcap \ - -lreadline -laspect $(BITS) $(EXTRAOPT) +SRC = dump.c recv.c send.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 = -Wall -g3 -Iinclude -I../libaspect/include/ -fPIC -DERESI32 +CFLAGS64 = -Wall -g3 -Iinclude -I../libaspect/include/ -fPIC -DERESI64 +LDFLAGS32 = $(EXTRAOPT) +LDFLAGS64 = $(EXTRAOPT) +NAME32 = libdump32 +NAME64 = libdump64 + CC ?= gcc LD ?= ld AR = ar rc -NAME = libdump -all : $(OBJ) - $(AR) $(NAME).a $(OBJ) - $(RANLIB) $(NAME).a - $(LD) -r $(OBJ) -o $(NAME).o - -test: all dump_main.o -# $(CC) $(CFLAGS) $(LDFLAGS) dump_main.o -o dump_main - gcc -Wall -DERESI32 -g3 -Iinclude -I../libhash/include/ \ - -DELFSH_INTERN -L./ -L../libelfsh/ -llibelfsh -L/usr/pkg/lib/ \ - -ltermcap -lreadline -DERESI32 ../libhash/hash.o dump.o recv.o\ - send.o dump_main.c -o dump_main +all : all32 all64 + +all32: $(OBJ32) + $(AR) $(NAME32).a $(OBJ32) + $(RANLIB) $(NAME32).a + $(LD) -r $(OBJ32) -o $(NAME32).o $(LDFLAGS32) + +all64: $(OBJ64) + $(AR) $(NAME64).a $(OBJ64) + $(RANLIB) $(NAME64).a + $(LD) -r $(OBJ64) -o $(NAME64).o $(LDFLAGS64) clean : - @rm -f $(OBJ) *~ *\# \#* .\#* dump_main.o + @rm -f $(OBJ32) $(OBJ64) *~ *\# \#* .\#* dump_main.o @rm -f include/*~ include/*\# include/\#* include/.\#* fclean : clean - @rm -f $(NAME).a $(NAME).o dump_main + @rm -f $(NAME32).a $(NAME32).o dump_main* $(NAME64).a $(NAME64).o + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< + +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libdump/recv.c eresi-0.0.20110516/libdump/recv.c --- eresi-0.8a25/libdump/recv.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/recv.c 2011-05-16 11:35:01.000000000 +0000 @@ -5,7 +5,7 @@ ** Updated on Wed Mar 9 22:02:29 CET 2005 ym ** ** -** $Id: recv.c,v 1.4 2007-08-03 18:05:03 may Exp $ +** $Id: recv.c 1311 2009-01-14 20:36:48Z may $ ** */ @@ -35,7 +35,7 @@ /* connection closed */ if (tmp2 == 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[WW] Connection closed by remote host (1)\n"); #endif XFREE(__FILE__, __FUNCTION__, __LINE__,msg); @@ -56,7 +56,7 @@ } continue; } -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Error while reading on socket (1)\n"); perror("recv"); #endif @@ -88,7 +88,7 @@ /* connection closed */ if (tmp2 == 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[WW] Connection closed by remote host (2)\n"); #endif XFREE(__FILE__, __FUNCTION__, __LINE__,msg); @@ -110,7 +110,7 @@ } continue; } -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Error while reading on socket (2)\n"); perror("recv"); #endif @@ -143,7 +143,7 @@ /* connection closed */ if (tmp2 == 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[WW] Connection closed by remote host (3)\n"); #endif XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); @@ -168,7 +168,7 @@ } continue; } -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] Error while reading on socket (3)\n"); perror("recv"); #endif @@ -239,7 +239,7 @@ dump_lookup_neighbor(prev), 0) < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) fprintf(stderr, "dump_send_Rr error (1)\n"); #endif XFREE(__FILE__, __FUNCTION__, __LINE__,npath); @@ -277,7 +277,7 @@ (long) actual->data, pkt->id) < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] dump_send_RR error (2)\n"); #endif XFREE(__FILE__, __FUNCTION__, __LINE__,npath); @@ -285,7 +285,7 @@ } } -#if __DEBUG_DUMP__ && !defined(ELFSH_INTERN) +#if __DEBUG_DUMP__ && !defined(ERESI_INTERNAL) else { printf("[DUMP] dump_receive_RR :" @@ -342,7 +342,7 @@ if (next_hop_socket == 0) { /* ERROR improve that */ -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) fprintf(stderr, "[EE] error while sending packet\n"); #endif exit(-1); @@ -386,7 +386,7 @@ dump_lookup_neighbor(pkt->path[i - 1]), pkt->id) < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] error occurs while forwarding Rr packet\n"); #endif return (-1); @@ -439,7 +439,7 @@ if (next_hop_socket == 0) { /* ERROR improve that */ -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] error while forwarding packet\n"); #endif return (pkt_t *) (-1); @@ -448,7 +448,7 @@ if (dump_send_real(next_hop_socket, pkt) < 0) { -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] error occurs while forwarding DATA packet\n"); #endif return (pkt_t *) (-1); @@ -507,7 +507,7 @@ case DATA: pkt = dump_receive_DATA(pkt); /* need some mem free */ -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) if (pkt < 0) { printf("[EE] error while forwaring data\n"); @@ -516,7 +516,7 @@ return pkt; break; default: -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) fprintf(stderr, "[EE] Unknown packet type %u \n", ntohs(pkt->type)); #endif /* XXX anything to add ? */ diff -Nru eresi-0.8a25/libdump/send.c eresi-0.0.20110516/libdump/send.c --- eresi-0.8a25/libdump/send.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/send.c 2011-05-16 11:35:01.000000000 +0000 @@ -5,7 +5,7 @@ ** Updated on Wed Mar 9 22:02:29 CET 2005 ym ** ** -** $Id: send.c,v 1.4 2007-08-03 18:05:03 may Exp $ +** $Id: send.c 1311 2009-01-14 20:36:48Z may $ ** */ @@ -23,7 +23,7 @@ if (pkt == NULL) { /* ERROR error handling */ -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] dump_send_real illegal argument"); #endif return (-1); @@ -53,7 +53,7 @@ if (ret < 0) { /* ERROR error handling */ -#if !defined(ELFSH_INTERN) +#if !defined(ERESI_INTERNAL) printf("[EE] send failed"); #endif exit(-1); diff -Nru eresi-0.8a25/libdump/.svn/all-wcprops eresi-0.0.20110516/libdump/.svn/all-wcprops --- eresi-0.8a25/libdump/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 31 -/svn/!svn/ver/762/trunk/libdump -END -recv.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/762/trunk/libdump/recv.c -END -dump.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/762/trunk/libdump/dump.c -END -dump_main.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/502/trunk/libdump/dump_main.c -END -send.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/762/trunk/libdump/send.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/753/trunk/libdump/Makefile -END diff -Nru eresi-0.8a25/libdump/.svn/entries eresi-0.0.20110516/libdump/.svn/entries --- eresi-0.8a25/libdump/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libdump -http://svn.eresi-project.org/svn - - - -2007-08-03T18:05:03.000000Z -762 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -recv.c -file - - - - -2008-04-06T23:15:44.793902Z -49ad1adbc8722198b017978d1e9fab48 -2007-08-03T18:05:03.000000Z -762 -may - -include -dir - -doc -dir - -dump.c -file - - - - -2008-04-06T23:15:44.814480Z -5308b0cf70fa4312a1da970477007d08 -2007-08-03T18:05:03.000000Z -762 -may - -dump_main.c -file - - - - -2008-04-06T23:15:44.825877Z -90dd8b34420f96bbec23fdb3938a77d4 -2007-03-07T16:45:36.000000Z -502 -thor - -send.c -file - - - - -2008-04-06T23:15:44.836900Z -650e411d49f83f07c17283d6785cd9c4 -2007-08-03T18:05:03.000000Z -762 -may - -Makefile -file - - - - -2008-04-06T23:15:44.847899Z -af47997d89e5dfa565f102650eee112b -2007-07-31T23:30:35.000000Z -753 -may - diff -Nru eresi-0.8a25/libdump/.svn/format eresi-0.0.20110516/libdump/.svn/format --- eresi-0.8a25/libdump/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libdump/.svn/text-base/dump.c.svn-base eresi-0.0.20110516/libdump/.svn/text-base/dump.c.svn-base --- eresi-0.8a25/libdump/.svn/text-base/dump.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/text-base/dump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,620 +0,0 @@ -/* -** dump.c for elfsh -** -** Started on Tue Feb 15 12:51:34 CET 2005 ym -** Updated on Wed Mar 9 22:02:29 CET 2005 ym -** -** -** $Id: dump.c,v 1.5 2007-08-03 18:05:03 may Exp $ -** -*/ - -#include "libdump.h" - -/**************************/ -/* libdump init functions */ -/**************************/ - -/* dump initialization */ -int dump_init() -{ - /* hash tables initializations */ - hash_init(&dump_world.ports, "dump_ports", - HASHTABLE_SIZE, ASPECT_TYPE_UNKNOW); - hash_init(&dump_world.RRrecently_seen, "dump_RRseen", - HASHTABLE_SIZE, ASPECT_TYPE_UNKNOW); - hash_init(&dump_world.Rrrecently_seen, "dump_Rrseen", - HASHTABLE_SIZE, ASPECT_TYPE_UNKNOW); - hash_init(&dump_world.myids, "dump_myids", - HASHTABLE_SIZE, ASPECT_TYPE_UNKNOW); - - /* initialize send wait queue */ - dump_world.send_wq = (pkt_wq_t *) NULL; - - /* initialize PRNG */ - srand(time(NULL)); - - return 0; -} - -/***********************/ -/* neighbors managment */ -/***********************/ - -/* add a neighbor */ -int dump_add_neighbor(int s, dump_id_t peer_addr) -{ - char *tmp; - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_neighbor : [%d,%s]\n", s, inet_ntoa(peer_addr)); -#endif - - tmp = inet_ntoa(peer_addr); - - hash_add(&dump_world.ports, strdup(tmp), (void *) (int) s); - return 0; -} - -/* remove a neighbor */ -int dump_del_neighbor(dump_id_t peer_addr) -{ - hash_del(&dump_world.ports, inet_ntoa(peer_addr)); - return 0; -} - -/* return the socket matching the peer_addr */ -int dump_lookup_neighbor(dump_id_t peer_addr) -{ - return (long) hash_get(&dump_world.ports, inet_ntoa(peer_addr)); -} - -/*********************************/ -/* recently seen table managment */ -/*********************************/ - -/* add RR to RR's recently seen table */ -int dump_add_RR_recently_seen(pkt_id_t id) -{ - char *str; - time_t *date; - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,str, sizeof (char)*20, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,date, sizeof (time_t), -1); - - /* convert id to string */ - snprintf(str, 20-1, "%u", ntohl(id)); - - /* get date */ - time(date); - - /* add it to hash table */ - hash_add(&dump_world.RRrecently_seen, str, (void *) date); - - return 0; -} - -/* add Rr to Rr's recently seen table */ -int dump_add_Rr_recently_seen(pkt_id_t id) -{ - char *str; - time_t *date; - - NOPROFILER_IN(); - - - XALLOC(__FILE__, __FUNCTION__, __LINE__,str, sizeof (char)*20, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,date, sizeof (time_t), -1); - - /* convert id to string */ - snprintf(str, 20-1, "%u", ntohl(id)); - - /* get date */ - time(date); - - /* add it to hash table */ - hash_add(&dump_world.Rrrecently_seen, str, (void *) date); - - return 0; -} - -/* recently seen lookup (in RR table) */ -int dump_lookup_RR_recently_seen(pkt_id_t id) -{ - char str[20]; - - snprintf(str, 20-1, "%u", ntohl(id)); - - if (hash_get(&dump_world.RRrecently_seen, str) != NULL) - { -#if __DEBUG_DUMP__ - printf("[DUMP] DUP(RR)!!\n"); -#endif - return 1; - } - else - return 0; -} - -/* recently seen lookup (in Rr table) */ -int dump_lookup_Rr_recently_seen(pkt_id_t id) -{ - char str[20]; - - snprintf(str, 20-1, "%u", ntohl(id)); - - if (hash_get(&dump_world.RRrecently_seen, str) != NULL) - { -#if __DEBUG_DUMP__ - printf("[DUMP] DUP(Rr)!!\n"); -#endif - return 1; - } - else - return 0; -} - -/* clean recently seen table */ -int dump_clean_recently_seen() -{ - listent_t *actual; - time_t current; - int index; - - /* get current date */ - time(¤t); - - for (index = 0; index < dump_world.RRrecently_seen.size; index++) - for (actual = &dump_world.RRrecently_seen.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (difftime(current, *(((time_t *) actual->data))) > DUMP_RS_LIMIT) - { - hash_del(&dump_world.RRrecently_seen, actual->key); - } - } - - for (index = 0; index < dump_world.Rrrecently_seen.size; index++) - for (actual = &dump_world.Rrrecently_seen.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (difftime(current, *(((time_t *) actual->data))) > DUMP_RS_LIMIT) - { - hash_del(&dump_world.Rrrecently_seen, actual->key); - } - } - - return 0; -} - -/*****************************/ -/* send wait queue managment */ -/*****************************/ - -/* add a packet ready to be send */ -int dump_add_send_queue(pkt_t *pkt) -{ - pkt_wq_t *tmp = dump_world.send_wq; - pkt_wq_t *new; - - NOPROFILER_IN(); - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_send_queue \n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (pkt_wq_t), -1); - - new->next = NULL; - new->pkt = pkt; - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_add_send_queue : "); -#endif - - if (tmp != NULL) - { - while (tmp->next != NULL) - { -#if __DEBUG_DUMP__ - printf("."); -#endif - tmp = tmp->next; - } - tmp->next = new; - } - else - dump_world.send_wq = new; - -#if __DEBUG_DUMP__ - printf("\n"); -#endif - - return 0; -} - -/* search for a packet waiting for given route */ -pkt_t *dump_lookup_send_queue(dump_id_t dst) -{ - pkt_wq_t *tmp = dump_world.send_wq; - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue\n"); -#endif - - if (tmp == NULL) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue -> nothing to send\n"); -#endif - return NULL; - } - - for (; tmp != NULL; tmp = tmp->next) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue " - "-> proposed dst %s :\n", inet_ntoa(dst)); - printf("[DUMP] dump_lookup_send_queue " - "-> packet dst %s :\n", inet_ntoa(tmp->pkt->dst)); -#endif - - if (memcmp(&(tmp->pkt->dst), &dst, sizeof (dump_id_t))==0) - return tmp->pkt; - } -#if __DEBUG_DUMP__ - printf("[DUMP] dump_lookup_send_queue " - "-> nothing matching this destination \n"); -#endif - return NULL; -} - -/* remove a packet waiting for given route */ -int dump_del_send_queue(pkt_t *pkt) -{ - pkt_wq_t *tmp = dump_world.send_wq; - pkt_wq_t *prev = dump_world.send_wq; - /* - * DO NOT free pkt->path ... - */ -#if __DEBUG_DUMP__ - printf("[DUMP] dump_del_send_queue\n"); -#endif - - for (; tmp != NULL; prev = tmp, tmp = tmp->next) - { - if (tmp->pkt == pkt) - { - if (prev == dump_world.send_wq) - dump_world.send_wq = tmp->next; - else - prev->next = tmp->next; - - XFREE(__FILE__, __FUNCTION__, __LINE__,tmp); - /* XXX to improve : pkt never freed */ - return 0; - } - } - - return 0; -} - -/************/ -/* Various */ -/************/ - -/* return a timestamp */ -time_t dump_mk_timestamp() -{ - return time(NULL); -} - -/* return a random pkt id */ -pkt_id_t dump_mk_pkt_id() -{ - /* XXX to improve */ - return htonl(rand()); -} - -/* free a pkt */ -int dump_free(pkt_t *pkt) -{ - if (pkt != NULL) - { - if (pkt->path != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,pkt->path); - if (pkt->data != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,pkt->data); - XFREE(__FILE__, __FUNCTION__, __LINE__,pkt); - } - return 0; -} - -/* print the given packet */ -int dump_print_pkt(pkt_t *pkt) -{ - int i; - - if (pkt == NULL && pkt != (pkt_t *) (-1)) - { - printf("| null packet\n"); - return 0; - } - - printf("| src : %s\n", inet_ntoa(pkt->src)); - printf("| dst : %s\n", inet_ntoa(pkt->dst)); - printf("| id : %u\n", ntohl(pkt->id)); - printf("| type : %s\n", - pkt->type ==htons(RR)? - "RR":(pkt->type == htons(Rr)? - "Rr":(pkt->type == htons(DATA)? - "DATA":"unknown"))); - printf ("| size : %u \n", ntohl(pkt->size)); - printf ("| path_len : %u \n", ntohl(pkt->path_len)); - printf ("| path : \n"); - for (i = 0; i < ntohl(pkt->path_len); i++) - { - printf("| -> %s\n", inet_ntoa(pkt->path[i])); - } - return 0; -} - -/************/ -/* myid mgt */ -/************/ - -/* is my id ? */ -int dump_is_myid(dump_id_t id) -{ - listent_t *actual; - int index; - - for (index = 0; index < dump_world.myids.size; index++) - for (actual = &dump_world.myids.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (!strcmp(actual->data, inet_ntoa(id))) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_is_myid : IT'S ME\n"); -#endif - return 1; - } - } - return 0; -} - -/* return a node id */ -dump_id_t dump_get_myid(int s) -{ - dump_id_t ret; - char tmp[5]; - char *tmp2; - - listent_t *actual; - int index; - - /* special case ... */ - if (s == 0) - { - - for (index = 0; index < dump_world.myids.size; index++) - for (actual = &dump_world.myids.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : default id : %s \n", (char *) actual->data); -#endif - inet_aton((char *)actual->data, &ret); - return ret; - } - } - - - snprintf(tmp, 5-1, "%d", s); - - tmp2 = (char *) hash_get(&dump_world.myids, tmp); - - if (tmp2 == NULL) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : id not found\n"); -#endif - ret.s_addr = htonl(INADDR_ANY); - return ret; - } - - inet_aton(tmp2, &ret); - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_get_myid : using id -> %s\n", tmp2); -#endif - - return ret; -} - -/* add an id to myids hash table */ -int dump_add_myid(dump_id_t id, int s) -{ - char tmp[5]; - - snprintf(tmp, 5-1, "%d", s); - - hash_add(&dump_world.myids, strdup(tmp), (void *) strdup(inet_ntoa(id))); - return 0; -} - -/* del an id from myids hash table */ -int dump_del_myid(int s) -{ - char tmp[5]; - - snprintf(tmp, 5-1, "%d", s); - - hash_del(&dump_world.myids, tmp); - - return 0; -} - -/******************/ -/* connection mgt */ -/******************/ - -/* disconnect from given peer */ -int dump_disconnect(int s) -{ - listent_t *actual; - int index; - - /* special case ... */ - for (index = 0; index < dump_world.ports.size; index++) - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if ((long) actual->data == s) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_disconnect from : %s", actual->key); -#endif - dump_del_myid(s); - - hash_del(&dump_world.ports, actual->key); - - close(s); - - return 0; - } - } -#if __DEBUG_DUMP__ - printf("[DUMP] dump_disconnect : not connected on socket %d\n", s); -#endif - return (-1); -} - -/* disconnect from given peer */ -int dump_disconnect_host(char *host) -{ - struct hostent *h; - struct sockaddr_in serv_addr; - - h = gethostbyname(host); - - if (h == NULL) - { -#if !defined(ELFSH_INTERN) - printf("[EE] Unknown host '%s'\n", host); -#endif - return (-1); - } - - memcpy((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - - return dump_disconnect(dump_lookup_neighbor(serv_addr.sin_addr)); -} - -/* connect to given host - returns socket's fd in case of success, - 0 otherwise. -*/ -int dump_connect_to(char *host, u_int port) -{ - int sd, rc; - struct hostent *h; - struct sockaddr_in local_addr, serv_addr; - struct sockaddr_in loc; - socklen_t lloc = sizeof (struct sockaddr_in); - - h = gethostbyname(host); - - if (h == NULL) - { -#if !defined(ELFSH_INTERN) - printf("[EE] Unknown host '%s'\n", host); -#endif - return 0; - } - - serv_addr.sin_family = h->h_addrtype; - memcpy((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - serv_addr.sin_port = htons(port); - - if (dump_lookup_neighbor(serv_addr.sin_addr) != 0) - { -#if !defined(ELFSH_INTERN) - printf("[EE] Already connected to %s\n", host); -#endif - return (-1); - } - - if (dump_is_myid(serv_addr.sin_addr) == 1 ) - { -#if !defined(ELFSH_INTERN) - printf("[EE] Attempt to connect to local node\n"); -#endif - return (-1); - } - - /* create socket */ - sd = socket(AF_INET, SOCK_STREAM, 0); - if (sd < 0) - { -#if !defined(ELFSH_INTERN) - perror("cannot open socket "); -#endif - return (-1); - } - - /* bind */ - local_addr.sin_family = AF_INET; - local_addr.sin_addr.s_addr = htonl(INADDR_ANY); - local_addr.sin_port = htons(0); - - rc = bind(sd, (struct sockaddr *) &local_addr, sizeof (local_addr)); - if (rc < 0) - { -#if !defined(ELFSH_INTERN) - printf("[EE] Cannot bind port TCP %u\n", port); - perror("error "); -#endif - return (-1); - } - - /* connect to server */ - rc = connect(sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)); - if (rc < 0) - { -#if !defined(ELFSH_INTERN) - perror("[EE] Cannot connect "); - return (-1); -#endif - } - - /* add a neighbor */ - dump_add_neighbor(sd, serv_addr.sin_addr); - - /* add a new id (if not already registred) */ - /* get local id */ - getsockname(sd, (struct sockaddr *) &loc, &lloc); -#if __DEBUG_DUMP__ - printf("[+] local id : %s \n", - inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr)); - - printf("[+] add new id : %s\n", - inet_ntoa(((struct sockaddr_in *) &loc)->sin_addr)); -#endif - - dump_add_myid(((struct sockaddr_in *) &loc)->sin_addr, sd); - - return sd; -} diff -Nru eresi-0.8a25/libdump/.svn/text-base/dump_main.c.svn-base eresi-0.0.20110516/libdump/.svn/text-base/dump_main.c.svn-base --- eresi-0.8a25/libdump/.svn/text-base/dump_main.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/text-base/dump_main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,470 +0,0 @@ -/* -** dump_main.c for elfsh -** -** Started on Tue Feb 20 14:40:34 CET 2005 ym -** Updated on Wed Mar 9 22:02:29 CET 2005 ym -** -** -** $Id: dump_main.c,v 1.2 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#include -#include -#include -#include -#include -#include -#include -#include "libdump.h" - -#define SERVER_PORT 4445 - -/* XXX some commands may have to add sockets to this list !!! */ -int sd_list[24]; -int sd_num = 0; - -/* disconnect from given host */ -int disconnect_from (char *host) -{ - struct hostent *h; - struct sockaddr_in serv_addr; - int socket; - int i; - - h = gethostbyname (host); - - if (h == NULL) - { - printf ("[EE] Unknown host '%s'\n", host); - return 0; - } - - memcpy ((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - - socket = dump_lookup_neighbor (serv_addr.sin_addr); - - if (socket == 0) - { - printf ("[EE] No connection to host '%s'\n", host); - return 0; - } - /* - printf ("[+] disconnecting : del_neighbor \n"); - dump_del_neighbor (serv_addr.sin_addr); - printf ("[+] disconnecting : del_myid \n"); - dump_del_myid (socket); - printf ("[+] disconnecting : close \n"); - close (socket); - */ - - dump_disconnect (socket); - - - for (i = 2; i < sd_num; i++) - { - if (sd_list[i] == socket) - sd_list[i] = 0; - /* XXX dirty */ - } - return 0; -} - -/* send data to host */ -int send_to (char *host, char *data) -{ - struct hostent *h; - struct sockaddr_in serv_addr; - - h = gethostbyname (host); - - if (h == NULL) - { - printf ("[EE] Unknown host '%s'\n", host); - return 0; - } - - printf ("[+] sending data\n"); - - memcpy ((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - - return dump_send (serv_addr.sin_addr, data, strlen (data)); -} - - -/* connect to given host */ -int connect_to (char *host) -{ - int sd, rc; - struct hostent *h; - struct sockaddr_in local_addr, serv_addr; - struct sockaddr_in loc; - socklen_t lloc = sizeof (struct sockaddr_in); - - h = gethostbyname (host); - - if (h == NULL) - { - printf ("[EE] Unknown host '%s'\n", host); - return 0; - } - - serv_addr.sin_family = h->h_addrtype; - memcpy ((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - serv_addr.sin_port = htons (SERVER_PORT); - - /* create socket */ - sd = socket (AF_INET, SOCK_STREAM, 0); - if (sd < 0) - { - perror ("cannot open socket "); - exit (1); - } - - /* bind any port number */ - local_addr.sin_family = AF_INET; - local_addr.sin_addr.s_addr = htonl (INADDR_ANY); - local_addr.sin_port = htons (0); - - rc = bind (sd, (struct sockaddr *) &local_addr, sizeof (local_addr)); - if (rc < 0) - { - printf ("[EE] Cannot bind port TCP %u\n", SERVER_PORT); - perror ("error "); - exit (1); - } - - /* connect to server */ - rc = connect (sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)); - if (rc < 0) - { - perror ("[EE] Cannot connect "); - exit (1); - } - - - sd_list[sd_num] = sd; - sd_num ++; - - /* adding a neighbor */ - dump_add_neighbor (sd, serv_addr.sin_addr); - - /* adding a new id (if not already registred) */ - - /* get local id */ - getsockname (sd, (struct sockaddr *) &loc, &lloc); - - printf ("[+] local id : %s \n", - inet_ntoa (((struct sockaddr_in *) &loc)->sin_addr)); - - printf ("[+] add new id : %s\n", - inet_ntoa (((struct sockaddr_in *) &loc)->sin_addr)); - - dump_add_myid (((struct sockaddr_in *) &loc)->sin_addr, sd); - - printf ("[+] added\n"); - - return 0; -} - -/* parse command */ -void lhandler (char *c) -{ - char *w; - - if (c != NULL) - { - add_history (c); - //printf ("[+] -> readline : %s\n", c); - - w = strtok (c, " "); - if (w == NULL) - return; - - if (!strcmp ("connect", w)) - { - printf ("[+] connect\n"); - w = strtok (NULL, " "); - if (w == NULL) - return ; - connect_to (w); - return ; - } - else if (!strcmp ("exit", w)) - { - printf ("\n[+] leaving\n"); - exit (0); - } - else if (!strcmp ("quit", w)) - { - printf ("\n[+] leaving\n"); - exit (0); - } - else if (!strcmp ("send", w)) - { - w = strtok (NULL, " "); - if (w == NULL) - return ; - send_to (w, strtok (NULL, " ")); - return ; - } - else if (!strcmp ("disconnect", w)) - { - w = strtok (NULL, " "); - if (w == NULL) - return ; - disconnect_from (w); - return ; - } - } - else - { - printf ("\n[+] leaving\n"); - exit (0); - } -} - -/* create main socket */ -int main_socket () -{ - int main_socket; - int one = 1; - struct sockaddr_in serv_addr; - - main_socket = socket (PF_INET, SOCK_STREAM, 0); - - if (main_socket < 0) - { - perror ("[EE] Cannot open socket "); - return (-1); - } - - /* bind server port */ - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = htonl (INADDR_ANY); - serv_addr.sin_port = htons (SERVER_PORT); - - /* REUSEADDR */ - setsockopt (main_socket, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one)); - - /* bind socket */ - if (bind (main_socket, - (struct sockaddr *) &serv_addr, - sizeof (serv_addr)) < 0) - { - perror ("[EE] Cannot bind port "); - return (-1); - } - - /* listen */ - listen (main_socket, 5); - - printf ("[+] Ready to accept connection on TCP port %u\n", SERVER_PORT); - - return main_socket; -} - -/* Dump test main loop */ -int main_loop (int main_sd, int input_fd) -{ - int sd_max = 0; - int new_sd; - int i; - - struct sockaddr_in cli_addr; - int cli_len; - - int readsocks; - struct timeval timeout; - - void *data; - - struct sockaddr loc; - socklen_t lloc = sizeof (struct sockaddr); - - - fd_set socks; - - /* add input fd to socket list */ - sd_list[0] = input_fd; - sd_num ++; - - /* add main socket to socket list */ - sd_list[1] = main_sd; - sd_num ++; - - - /* loops */ - while (1) - { - - FD_ZERO (&socks); - - /* add sockets to fd_set */ - for (i = 0; i < sd_num; i++) - { - if (i >= 2 && sd_list[i] == 0) - continue; // skip closed connections - sd_max = (sd_maxtype == htons(RR))? - "RR":((((pkt_t *) data)->type ==htons(Rr))? - "Rr":((((pkt_t *) data)->type ==htons(DATA))? - "DATA":"Unknown"))); - dump_free (data); - } - else - printf ("[+] null (non-data packet)\n"); - - } - } - - /* ... main socket */ - if (FD_ISSET (sd_list[1], &socks)) - { - /* try to accept connection */ - cli_len = sizeof (cli_addr); - new_sd = accept (sd_list[1], - (struct sockaddr *) &cli_addr, - &cli_len); - if (new_sd > 0) - { - printf ("[+] Connection from : %s\n", - inet_ntoa (cli_addr.sin_addr)); - sd_list[sd_num] = new_sd; - sd_num++; - - /* getsockname ()*/ - getsockname (new_sd, &loc, &lloc); - - printf ("[+] add new id \n"); - dump_add_myid (((struct sockaddr_in *) &loc)->sin_addr, new_sd); - - printf ("[+] added\n"); - printf ("[+] my new id : %s \n", - inet_ntoa (dump_get_myid (new_sd))); - - printf ("[+] Adding a DUMP neighbor : [%d,%s]\n", - new_sd, inet_ntoa (cli_addr.sin_addr)); - dump_add_neighbor (new_sd, cli_addr.sin_addr); - } - } - - - } - - return 0; -} - - - -int main () -{ - - int main_sd; - int input_fd = 0; // =stdin - - /* create the main socket */ - main_sd = main_socket (); - - if (main_sd == (-1)) - { - printf ("[EE] error on main socket\n"); - exit (-1); - } - - // XXX how to get local id ? - - /* get local id */ - - /* initialize dump */ - dump_init ("NULL"); - printf ("[+] Dump initialized\n"); - - /* install readline handler */ - rl_callback_handler_install ("dump ->", lhandler); - - atexit (rl_callback_handler_remove); - - /* loops for ever */ - main_loop (main_sd, input_fd); - - /* remove readline callback handler */ - rl_callback_handler_remove(); - - printf ("[EE] DUMP end ???? \n"); - - return 0; -} diff -Nru eresi-0.8a25/libdump/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libdump/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libdump/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -## -## Makefile for libdump in elfsh -## -## Started on Sat Jan 25 05:41:19 2003 jfv -## Last update Tue Feb 15 12:58:45 2005 ym -## - -include ../config.h - -SRC = dump.c recv.c send.c -OBJ = dump.o recv.o send.o -CFLAGS = -Wall $(BITS) -g3 -Iinclude -I../libc/include/ -I../libelfsh/include/ \ - -I../libaspect/include/ -I../elibc/include -DELFSH_INTERN -fPIC -LDFLAGS = -L./ -L../libelfsh/ -lelfsh -ldump -L/usr/pkg/lib/ -ltermcap \ - -lreadline -laspect $(BITS) $(EXTRAOPT) -CC ?= gcc -LD ?= ld -AR = ar rc -NAME = libdump - -all : $(OBJ) - $(AR) $(NAME).a $(OBJ) - $(RANLIB) $(NAME).a - $(LD) -r $(OBJ) -o $(NAME).o - -test: all dump_main.o -# $(CC) $(CFLAGS) $(LDFLAGS) dump_main.o -o dump_main - gcc -Wall -DERESI32 -g3 -Iinclude -I../libhash/include/ \ - -DELFSH_INTERN -L./ -L../libelfsh/ -llibelfsh -L/usr/pkg/lib/ \ - -ltermcap -lreadline -DERESI32 ../libhash/hash.o dump.o recv.o\ - send.o dump_main.c -o dump_main - -clean : - @rm -f $(OBJ) *~ *\# \#* .\#* dump_main.o - @rm -f include/*~ include/*\# include/\#* include/.\#* - -fclean : clean - @rm -f $(NAME).a $(NAME).o dump_main diff -Nru eresi-0.8a25/libdump/.svn/text-base/recv.c.svn-base eresi-0.0.20110516/libdump/.svn/text-base/recv.c.svn-base --- eresi-0.8a25/libdump/.svn/text-base/recv.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/text-base/recv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,530 +0,0 @@ -/* -** recv.c for elfsh -** -** Started on Tue Feb 15 12:51:34 CET 2005 ym -** Updated on Wed Mar 9 22:02:29 CET 2005 ym -** -** -** $Id: recv.c,v 1.4 2007-08-03 18:05:03 may Exp $ -** -*/ - -#include "libdump.h" - - -/* read a complete packet from given socket */ -pkt_t *dump_recv_pkt(int s) -{ - int tmp = 0; - int tmp2 = 0; - int len = 0; - pkt_t *msg; - int try = 0; - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,msg, sizeof (pkt_t), NULL); - - /* read fixed size header part */ - do - { - tmp2 = recv(s, (void *) msg + tmp, - (size_t) (HDR_SIZE - tmp), - MSG_DONTWAIT); - - /* connection closed */ - if (tmp2 == 0) - { -#if !defined(ELFSH_INTERN) - printf("[WW] Connection closed by remote host (1)\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - - /* error */ - if (tmp2 == (-1)) - { - /* EAGAIN */ - if (tmp2 == EAGAIN) - { - try++; - if (try > DUMP_MAXTRY) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, msg); - return (pkt_t *)(-1); - } - continue; - } -#if !defined(ELFSH_INTERN) - printf("[EE] Error while reading on socket (1)\n"); - perror("recv"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__, msg); - return (pkt_t *)(-1); - } - - len += tmp2; - tmp += tmp2; - - } while (tmp != (size_t)(HDR_SIZE)); - - if (ntohl(msg->path_len) != 0) - { - /* read pkt path from header */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - msg->path, - ntohl(msg->path_len) * sizeof (dump_id_t), - (pkt_t *) -1); - - tmp = 0; - do - { - tmp2 = recv(s, - (void *) msg->path + tmp, - (size_t) ntohl(msg->path_len)*sizeof (dump_id_t) - tmp, - MSG_DONTWAIT); - - /* connection closed */ - if (tmp2 == 0) - { -#if !defined(ELFSH_INTERN) - printf("[WW] Connection closed by remote host (2)\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - - /* error */ - if (tmp2 == (-1)) - { - /* EAGAIN */ - if (tmp2 == EAGAIN) - { - try++; - if (try > DUMP_MAXTRY) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - continue; - } -#if !defined(ELFSH_INTERN) - printf("[EE] Error while reading on socket (2)\n"); - perror("recv"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - - len += tmp2; - tmp += tmp2; - - } while (tmp != ntohl(msg->path_len)*sizeof (dump_id_t)); - } - else - msg->path=NULL; - - /* read payload */ - if (ntohl(msg->size) != 0) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,msg->data, (size_t) sizeof (char)*ntohl(msg->size), (pkt_t *) -1); - - tmp = 0; - do - { - tmp2 = recv(s, - (void *) msg->data + tmp, - (size_t) ntohl(msg->size)*sizeof (char) - tmp, - MSG_DONTWAIT); - - /* connection closed */ - if (tmp2 == 0) - { -#if !defined(ELFSH_INTERN) - printf("[WW] Connection closed by remote host (3)\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->data); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - - /* error */ - if (tmp2 == (-1)) - { - /* EAGAIN */ - if (errno == EAGAIN) - { - try++; - if (try > DUMP_MAXTRY) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->data); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - continue; - } -#if !defined(ELFSH_INTERN) - printf("[EE] Error while reading on socket (3)\n"); - perror("recv"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg->data); - XFREE(__FILE__, __FUNCTION__, __LINE__,msg); - return (pkt_t *)(-1); - } - - len += tmp2; - tmp += tmp2; - - } while (tmp != ntohl(msg->size)*sizeof (char)); - } - else - msg->data = NULL; - - return msg; -} - - -/* handle RR packet */ -int dump_receive_RR(pkt_t *pkt) -{ - dump_id_t prev; - dump_id_t *npath; - listent_t *actual; - int index; - - NOPROFILER_IN(); - - if (dump_lookup_RR_recently_seen(pkt->id)) - { - return (-1); - } - - /* add packet's id to RR table */ - dump_add_RR_recently_seen(pkt->id); - - /* sanity check */ - if (ntohl(pkt->path_len) == 0) - return (-1); - - /* add myid to path's tail */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,npath, sizeof (dump_id_t)*(ntohl(pkt->path_len)+1), -1); - - /* back the previous hop up */ - prev = pkt->path[ntohl(pkt->path_len)-1]; - - /* copy previous path's nodes */ - memcpy (npath, pkt->path, ntohl(pkt->path_len)*sizeof (dump_id_t)); - - /* is my id ? */ - if (dump_is_myid(pkt->dst)) - { - /* add myid to path */ - npath[ntohl(pkt->path_len) + 1 - 1] = - dump_get_myid(dump_lookup_neighbor (prev)); - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_RR : it's me !! \n"); -#endif - /* send Rr packet with new id */ - if (dump_send_Rr(pkt->dst, - pkt->src, - (ntohl(pkt->path_len)+1), - npath, - dump_lookup_neighbor(prev), - 0) < 0) - { -#if !defined(ELFSH_INTERN) - fprintf(stderr, "dump_send_Rr error (1)\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,npath); - return (-1); - } - } - else - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_RR : it's NOT me !! \n"); -#endif - /* send it to all neighbors ... */ - for (index = 0; index < dump_world.ports.size; index++) - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - /* ... but the sender */ - if (strcmp(actual->key, inet_ntoa(prev))) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_RR :" - " send to %s, it's NOT the Request sender\n", - actual->key); -#endif - /* add myid to path */ - npath[ntohl(pkt->path_len) + 1 - 1] = - dump_get_myid((long) actual->data); - - /* send RR packet with same id */ - if (dump_send_RR(pkt->src, - pkt->dst, - (ntohl(pkt->path_len)+1), - npath, - (long) actual->data, - pkt->id) < 0) - { -#if !defined(ELFSH_INTERN) - printf("[EE] dump_send_RR error (2)\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,npath); - return (-1); - } - } - -#if __DEBUG_DUMP__ && !defined(ELFSH_INTERN) - else - { - printf("[DUMP] dump_receive_RR :" - " don't send to %s, it's the Request sender\n", - actual->key); - } -#endif - } - - } - - XFREE(__FILE__, __FUNCTION__, __LINE__,npath); - return 0; -} - -/* handle Rr packet */ -int dump_receive_Rr(pkt_t *pkt) -{ - int i; - int next_hop_socket; - pkt_t *spkt; - - - if (dump_lookup_Rr_recently_seen(pkt->id)) - { - return (-1); - } - - /* add packet's id to Rr table */ - dump_add_Rr_recently_seen(pkt->id); - - /* sanity check */ - if (ntohl(pkt->path_len) == 0) - return (-1); - - /* is my id ? */ - if (dump_is_myid(pkt->dst)) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_Rr : it's me !! \n"); -#endif - /* if data are waiting for this route to be sent, send it */ - while ((spkt = dump_lookup_send_queue(pkt->src)) != NULL) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_Rr : a packet to send \n"); -#endif - spkt->path = pkt->path; - spkt->path_len = pkt->path_len; // pkt->path_len is in NBO - - /* XXX ensure that it is correct */ - next_hop_socket = dump_lookup_neighbor(pkt->path[1]); - - if (next_hop_socket == 0) - { - /* ERROR improve that */ -#if !defined(ELFSH_INTERN) - fprintf(stderr, "[EE] error while sending packet\n"); -#endif - exit(-1); - } - - // XXX - // spkt->src = dump_get_myid (next_hop_socket); - - /* send the packet */ - dump_send_real(next_hop_socket, spkt); - - /* free pkt */ - XFREE(__FILE__, __FUNCTION__, __LINE__,spkt->data); - XFREE(__FILE__, __FUNCTION__, __LINE__,spkt); - - /* remove it from wait queue */ - dump_del_send_queue(spkt); - } - return 0; - } - else - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_Rr : it's NOT me !! \n"); -#endif - /* send it to next path's hop with same id*/ - for (i = 0; i < ntohl(pkt->path_len); i++) - { - if (dump_is_myid(pkt->path[i])) - { - if (i > 0) - { - /* update my id in path according to outgoing socket */ - pkt->path[i] = - dump_get_myid(dump_lookup_neighbor(pkt->path[i - 1])); - - if (dump_send_Rr(pkt->src, - pkt->dst, - ntohl(pkt->path_len), - pkt->path, - dump_lookup_neighbor(pkt->path[i - 1]), - pkt->id) < 0) - { -#if !defined(ELFSH_INTERN) - printf("[EE] error occurs while forwarding Rr packet\n"); -#endif - return (-1); - } - } - else - { - printf("[EE] error in path\n"); - return (-1); - } - return 0; - } - } - } - return 0; -} - -/* handle DATA packet */ -pkt_t *dump_receive_DATA(pkt_t *pkt) -{ - int i; - int next_hop_socket; - - /* sanity check */ - if (ntohl(pkt->path_len) == 0) - return (pkt_t *) (-1); - - /* is my id ? */ - if (dump_is_myid(pkt->dst)) - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_DATA : it's me !! \n"); -#endif - return pkt; - } - else - { -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_DATA : it's NOT me !! \n"); -#endif - /* send it to next path's hop */ - for (i = ntohl(pkt->path_len) ; i >= 0; i--) - { - if (dump_is_myid(pkt->path[i])) - { - - /* XXX ensure that it is correct */ - next_hop_socket = dump_lookup_neighbor(pkt->path[i + 1]); - - if (next_hop_socket == 0) - { - /* ERROR improve that */ -#if !defined(ELFSH_INTERN) - printf("[EE] error while forwarding packet\n"); -#endif - return (pkt_t *) (-1); - } - - - if (dump_send_real(next_hop_socket, pkt) < 0) - { -#if !defined(ELFSH_INTERN) - printf("[EE] error occurs while forwarding DATA packet\n"); -#endif - return (pkt_t *) (-1); - } - return NULL; - } - } - } - return NULL; -} - - -/* receive callback */ -void *dump_receive_cb(int s) -{ - pkt_t *pkt; - -#if __DEBUG_DUMP__ - printf("[DUMP] dump_receive_cb [%d]\n", s); -#endif - - /* clean recently seen tables */ - dump_clean_recently_seen(); - - /* read an entire packet */ - pkt = dump_recv_pkt(s); - - if (pkt == (pkt_t *) (-1)) - { -#if __DEBUG_DUMP__ - printf("[DUMP] error -> disconnecting\n"); -#endif - dump_disconnect(s); - return (void *) (-1); - } -#if __DEBUG_DUMP__ - printf("[DUMP] ----recv-----\n"); - dump_print_pkt(pkt); - printf("[DUMP] -------------\n"); -#endif - - /* if packet readed */ - if (pkt != NULL) - { - /* determine packet type */ - switch (ntohs(pkt->type)) - { - case RR: - dump_receive_RR(pkt); - dump_free(pkt); - break; - case Rr: - dump_receive_Rr(pkt); - dump_free(pkt); - break; - case DATA: - pkt = dump_receive_DATA(pkt); - /* need some mem free */ -#if !defined(ELFSH_INTERN) - if (pkt < 0) - { - printf("[EE] error while forwaring data\n"); - } -#endif - return pkt; - break; - default: -#if !defined(ELFSH_INTERN) - fprintf(stderr, "[EE] Unknown packet type %u \n", ntohs(pkt->type)); -#endif - /* XXX anything to add ? */ - exit(-1); - } - } - - return NULL; -} - - diff -Nru eresi-0.8a25/libdump/.svn/text-base/send.c.svn-base eresi-0.0.20110516/libdump/.svn/text-base/send.c.svn-base --- eresi-0.8a25/libdump/.svn/text-base/send.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libdump/.svn/text-base/send.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,197 +0,0 @@ -/* -** send.c for elfsh -** -** Started on Tue Feb 15 12:51:34 CET 2005 ym -** Updated on Wed Mar 9 22:02:29 CET 2005 ym -** -** -** $Id: send.c,v 1.4 2007-08-03 18:05:03 may Exp $ -** -*/ - -#include "libdump.h" - -/* really do send */ -int dump_send_real(int s, pkt_t *pkt) -{ - int ret; - void *data; - int len = HDR_SIZE + ntohl(pkt->path_len)*sizeof (dump_id_t) + ntohl(pkt->size); - - NOPROFILER_IN(); - - if (pkt == NULL) - { - /* ERROR error handling */ -#if !defined(ELFSH_INTERN) - printf("[EE] dump_send_real illegal argument"); -#endif - return (-1); - } - - - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, sizeof (char)*len, -1); - - /* copy the header part */ - memcpy(data, pkt, HDR_SIZE); - - /* copy the path part */ - memcpy(data + HDR_SIZE, pkt->path, ntohl(pkt->path_len)*sizeof (dump_id_t)); - - /* copy the data part */ - memcpy(data + HDR_SIZE + ntohl(pkt->path_len)*sizeof (dump_id_t), - pkt->data, - ntohl(pkt->size)); - -#if __DEBUG_DUMP__ - printf("[DUMP] ----send - len = %d----\n", len); - dump_print_pkt(pkt); - printf("[DUMP] ----------\n"); -#endif - - ret = send(s, data, len, 0); - if (ret < 0) - { - /* ERROR error handling */ -#if !defined(ELFSH_INTERN) - printf("[EE] send failed"); -#endif - exit(-1); - } - - XFREE(__FILE__, __FUNCTION__, __LINE__,data); - - return ret; -} - -/* send a RR packet */ -int dump_send_RR(dump_id_t src, - dump_id_t dst, - dump_len_t path_len, - dump_id_t *path, - int next_hop_socket, - pkt_id_t id - ) -{ - int ret; - pkt_t *pkt; - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,pkt, sizeof (pkt_t), -1); - - pkt->src = src; - pkt->dst = dst; - if (id == 0) - pkt->id = dump_mk_pkt_id(); - else - pkt->id = id; - pkt->type = htons(RR); - pkt->size = htonl(0); - pkt->path_len = htonl(path_len); - pkt->path = path; - pkt->data = NULL; - - /* send it now */ - ret = dump_send_real(next_hop_socket, pkt); - - XFREE(__FILE__, __FUNCTION__, __LINE__,pkt); - return ret; -} - -/* send a Rr packet */ -int dump_send_Rr(dump_id_t src, - dump_id_t dst, - dump_len_t path_len, - dump_id_t *path, - int next_hop_socket, - pkt_id_t id - ) -{ - int ret; - pkt_t *pkt; - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,pkt, sizeof (pkt_t), -1); - - pkt->src = src; - pkt->dst = dst; - if (id == 0) - pkt->id = dump_mk_pkt_id(); - else - pkt->id = id; - pkt->type = htons(Rr); - pkt->size = htonl(0); - pkt->path_len = htonl(path_len); - pkt->path = path; - pkt->data = NULL; - - if (next_hop_socket == 0) - return (-1); - - /* send it now */ - ret = dump_send_real(next_hop_socket, pkt); - - XFREE(__FILE__, __FUNCTION__, __LINE__,pkt); - return ret; -} - -/* send a DATA packet */ -int dump_send(dump_id_t dst, void *data, dump_len_t len) -{ - /* do not actually send data, but send RR - and data will be sent when Rr arrive - */ - dump_id_t *path; - int next_hop_socket; - int index; - listent_t *actual; - pkt_t *pkt; - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,pkt, sizeof (pkt_t), -1); - - pkt->src = dump_get_myid(0); - pkt->dst = dst; - pkt->id = dump_mk_pkt_id(); - pkt->type = htons(DATA); - pkt->size = htonl(len); - pkt->path_len = htonl(0); - pkt->path = NULL; - pkt->data = data; - - /* add pkt to send wait queue */ - dump_add_send_queue(pkt); - - /* prepare RR */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,path, sizeof (dump_id_t), -1); - - /* search all neighbors ...*/ - for (index = 0; index < dump_world.ports.size; index++) - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - next_hop_socket = (long) actual->data; - - /* fill the first path node */ - *path = dump_get_myid(next_hop_socket); - - /* ... and send RR to them */ -#if __DEBUG_DUMP__ - printf ("[DUMP] send RR\n"); -#endif - dump_send_RR(dump_get_myid(next_hop_socket), - dst, - 1, - path, - next_hop_socket, - 0); - } - - XFREE(__FILE__, __FUNCTION__, __LINE__,path); - return 0; -} - diff -Nru eresi-0.8a25/libe2dbg/common/backtrace.c eresi-0.0.20110516/libe2dbg/common/backtrace.c --- eresi-0.8a25/libe2dbg/common/backtrace.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/backtrace.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,10 +1,10 @@ -/* -** backtrace.c for e2dbg +/** +* @file libe2dbg/common/backtrace.c +** @brief Implement the backtrace functionality. +** @ingroup common ** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: backtrace.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** +** Started on Tue Aug 16 09:38:03 2005 jfv +** $Id: backtrace.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" @@ -25,13 +25,13 @@ /* Preliminary checks */ if (!world.curjob) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current workspace", -1); + "No current workspace", -1); if (!world.curjob->curfile) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current file", -1); + "No current file", -1); /* Get the current frame by calling the hook */ - frame = (eresi_Addr) e2dbg_getfp(); + frame = (eresi_Addr)(uintptr_t)e2dbg_getfp(); if (!frame) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No context", (-1)); @@ -52,33 +52,38 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - /* Call the getret hook */ + /* Call the getret hook and check its result. */ ret = (eresi_Addr) e2dbg_getret(world.curjob->curfile, (eresi_Addr) frame); + if (!ret || ret == 0xffffffff) + break; /* Resolve and print current trace frame */ if (i == 0) ret = *(e2dbg_getpc()); + name = revm_resolve(world.curjob->curfile, (eresi_Addr) ret, &off); if (!name) name = "?"; - /* Just insert the real entry point where we reach the thread entry point of e2dbg */ + /* Just insert the real entry point where we reach the thread + entry point of e2dbg */ if (strstr(name, "e2dbg_thread_start")) { snprintf(logbuf, BUFSIZ - 1, "%u", (unsigned int) e2dbgworld.stoppedthread->tid); t = hash_get(&e2dbgworld.threads, logbuf); - name2 = revm_resolve(world.curjob->curfile, (eresi_Addr) t->entry, &off2); + name2 = revm_resolve(world.curjob->curfile, + (eresi_Addr)(uintptr_t) t->entry, &off2); if (name2) { if (off2) snprintf(logbuf, BUFSIZ - 1, " [%02d] "XFMT" in "XFMT" <%s + " UFMT "> -ENTRY-\n", i, - ret, (eresi_Addr) t->entry, name2, off2); + ret, (eresi_Addr)(uintptr_t) t->entry, name2, off2); else snprintf(logbuf, BUFSIZ - 1, " [%02d] "XFMT" in "XFMT " <%s> -ENTRY-\n", i, - ret, (eresi_Addr) t->entry, name2); + ret, (eresi_Addr)(uintptr_t) t->entry, name2); e2dbg_output(logbuf); i++; } @@ -118,10 +123,10 @@ int ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!elfsh_is_debug_mode()) + if (!elfsh_is_runtime_mode()) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Not in dynamic or debugger mode", -1); - if (e2dbgworld.curthread == NULL || e2dbgworld.curthread->context == 0) + if (e2dbgworld.curthread == NULL || e2dbgworld.curthread->context == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No current thread context available", -1); e2dbg_output(" .:: Backtrace ::. \n"); diff -Nru eresi-0.8a25/libe2dbg/common/breakpoints.c eresi-0.0.20110516/libe2dbg/common/breakpoints.c --- eresi-0.8a25/libe2dbg/common/breakpoints.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/breakpoints.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,27 +1,20 @@ -/* -** breakpoints.c for e2dbg -** +/** +* @file libe2dbg/common/breakpoints.c +** @ingroup common +** ** Started on Tue Aug 16 09:38:03 2005 mayhem -** -** $Id: breakpoints.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Simple shared flags for watch/breakpoints */ -static u_char watchflag; - - - -/** - * Add a breakpoint - */ +** $Id: breakpoints.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + +/* + * @brief Add a breakpoint +*/ int elfsh_bp_add(hash_t *bps, elfshobj_t *file, char *resolv, - eresi_Addr addr, - u_char flags) + eresi_Addr addr) + { static int lastbpid = 1; elfshbp_t *bp; @@ -36,418 +29,435 @@ /* Breakpoints handlers must be initialized */ elfsh_setup_hooks(); - XALLOC(__FILE__, __FUNCTION__, __LINE__,bp , sizeof(elfshbp_t), (-1)); - bp->obj = file; - bp->type = INSTR; - bp->addr = addr; - bp->symname = strdup(resolv); - - bp->flags = flags; - snprintf(tmp, 32, XFMT, addr); - if (hash_get(bps, tmp)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint already exist", -1); - - /* Call the architecture dependent hook for breakpoints */ - ret = e2dbg_setbreak(file, bp); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint insertion failed", (-1)); - - /* Add new breakpoint to hash table */ - bp->id = lastbpid++; - hash_add(bps, strdup(tmp), bp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Add a breakpoint without using a script command */ -int e2dbg_breakpoint_add(eresi_Addr addr, u_char flags) -{ - int err; - char buf[BUFSIZ]; - char *name; - elfsh_SAddr off; - elfshobj_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Resolve source file */ - file = e2dbg_get_parent_object(addr); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot resolve parent file for bp", -1); - - /* Resolve breakpoint address */ - name = revm_resolve(file, addr, &off); - if (off) - snprintf(buf, BUFSIZ, "<%s + " DFMT ">", name, off); - else - snprintf(buf, BUFSIZ, "<%s>", name); - - /* Really put the breakpoint */ - err = elfsh_bp_add(&e2dbgworld.bp, file, buf, addr, flags); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add breakpoint", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Return 1 if the breakpoint is a watchpoint */ -int e2dbg_is_watchpoint(elfshbp_t *b) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - b && b->flags & ELFSH_BP_WATCH); -} - - - - - -/* Find breakpoint by ID */ -elfshbp_t *e2dbg_breakpoint_from_id(uint32_t bpid) -{ - elfshbp_t *cur; - int index; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - keys = hash_get_keys(&e2dbgworld.bp, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.bp, keys[index]); - if (cur->id == bpid) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - cur); - } - hash_free_keys(keys); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find breakpoing by ID", NULL); -} - - - -/* Find a breakpoint by various ways */ -elfshbp_t *e2dbg_breakpoint_lookup(char *name) -{ - eresi_Addr addr; - elfsh_Sym *sym; - elfshbp_t *bp; - uint16_t bpid; - char straddr[32]; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bp = NULL; - - /* Lookup by vaddr */ - if (IS_VADDR(name)) - { - - if (sscanf(name + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", - NULL); - } - - /* Try to lookup by ID */ - else if (revm_isnbr(name)) - { - bpid = atoi(name); - bp = e2dbg_breakpoint_from_id(bpid); - if (!bp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid breakpoint ID", NULL); - } - - /* Resolve symbol */ - /* Sometimes we fix symbols on the disk only */ - /* This avoid a mprotect */ - else - { - sym = elfsh_get_metasym_by_name(world.curjob->curfile, - name); - if (!sym || !sym->st_value) - { - elfsh_toggle_mode(); - sym = elfsh_get_metasym_by_name(world.curjob->curfile, - name); - elfsh_toggle_mode(); - } - if (!sym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No symbol by that name in the current file", - NULL); - - if (!sym->st_value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested symbol address unknown", - NULL); - addr = sym->st_value; - } - - /* Get the breakpoint */ - if (!bp) - { - snprintf(straddr, sizeof(straddr), XFMT, addr); - bp = hash_get(&e2dbgworld.bp, straddr); - if (!bp) - { - snprintf(logbuf, BUFSIZ, - "\n [!] No breakpoint set at addr " AFMT " \n\n", addr); - e2dbg_output(logbuf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No breakpoint at this address", NULL); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, bp); -} - - - - - -/* Find the correct location for a breakpoint. Avoid putting breakpoints - on plt entries when possible */ -eresi_Addr e2dbg_breakpoint_find_addr(char *str) -{ - elfsh_Sym *sym; - elfsh_Sym *bsym; - elfshsect_t *sect; - elfshobj_t *parent; - char **keys; - int keynbr; - int index; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - sym = bsym = NULL; - - /* Sometimes we fix symbols on the disk : we avoid mprotect */ - /* Only return success early if not a plt symbol */ - keys = NULL; - parent = world.curjob->curfile; - sym = elfsh_get_metasym_by_name(parent, str); - if (!sym || !sym->st_value) - { - elfsh_toggle_mode(); - sym = elfsh_get_metasym_by_name(parent, str); - elfsh_toggle_mode(); - } - - if (sym && parent->hdr->e_type == ET_DYN) - sym->st_value += parent->rhdr.base; - - if (sym && sym->st_value) - { - sect = elfsh_get_parent_section(parent, sym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - goto end; - } - - /* Try to look in other objects */ - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - - for (index = 0; index < keynbr; index++) - { - if (strstr(keys[index], E2DBG_ARGV0)) - continue; - - parent = hash_get(&world.curjob->loaded, keys[index]); - bsym = elfsh_get_metasym_by_name(parent, str); - if (!bsym || !bsym->st_value) - { - elfsh_toggle_mode(); - bsym = elfsh_get_metasym_by_name(parent, str); - elfsh_toggle_mode(); - if (bsym && bsym->st_value) - { - sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - { - sym = bsym; - if (strstr(parent->name, "libc.so")) - goto end; - } - if (!sym) - sym = bsym; - } - } - else - { - sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - { - sym = bsym; - if (strstr(parent->name, "libc.so")) - goto end; - } - if (!sym) - sym = bsym; - } - -#if __DEBUG_BP__ - printf("BPSym after %-30s = %08X \n", parent->name, (eresi_Addr) sym); -#endif - - } - - /* Return error or success, dont forget to free the keys */ - end: - if (keys) - hash_free_keys(keys); - - if (!sym || !sym->st_value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No symbol by that name in the current file", 0); - addr = sym->st_value; - if (elfsh_get_objtype(parent->hdr) == ET_DYN) - { -#if __DEBUG_BP__ - printf(" [*] Adding base addr %08X \n", parent->rhdr.base); -#endif - addr += parent->rhdr.base; - } - -#if __DEBUG_BP__ - printf(" [*] Will set breakpoint on %08X (parent = %s) \n", - addr, parent->name); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addr); -} - - - - -/* Breakpoint command */ -int cmd_bp() -{ - char *str; - int ret; - eresi_Addr addr; - char logbuf[BUFSIZ]; - int idx; - int index; - elfsh_SAddr off = 0; - char *name; - elfshbp_t *cur; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* build argc */ - for (idx = 0; world.curjob->curcmd->param[idx] != NULL; idx++); - str = revm_lookup_string(world.curjob->curcmd->param[0]); - - fprintf(stderr, "Putting breakpoint on %s \n", str); - - /* Select subcommand */ - switch (idx) - { - - /* List breakpoints */ - case 0: - e2dbg_output(" .:: Breakpoints & Watchpoints ::.\n\n"); - keys = hash_get_keys(&e2dbgworld.bp, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.bp, keys[index]); - name = revm_resolve(world.curjob->curfile, - (eresi_Addr) cur->addr, &off); - if (off) - snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s + " UFMT ">\n", - (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), - cur->id, cur->addr, name, off); - else - snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s>\n", - (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), - cur->id, cur->addr, name); - e2dbg_output(logbuf); - } - hash_free_keys(keys); - if (!index) - e2dbg_output(" [*] No breakpoints\n"); - e2dbg_output("\n"); - break; - - /* Supply a new breakpoint */ - case 1: - if (!elfsh_is_debug_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not in dynamic or debugger mode", -1); - if (!str || !(*str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Break on a supplied virtual address */ - if (IS_VADDR(str)) - { - if (sscanf(str + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", (-1)); - } - - /* Resolve first a function name */ - else - { - addr = e2dbg_breakpoint_find_addr(str); - if (addr == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested symbol address unknown", -1); - } - - /* Add the breakpoint */ - ret = e2dbg_breakpoint_add(addr, watchflag); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint insertion failed\n", (-1)); - if (ret >= 0) - { - name = revm_resolve(world.curjob->curfile, addr, &off); - if (!off) - snprintf(logbuf, BUFSIZ - 1, - " [*] %spoint added at <%s> (" XFMT ")\n\n", - (watchflag ? "Watch" : "Break"), name, addr); - else - snprintf(logbuf, BUFSIZ - 1, - " [*] %spoint added at <%s + " UFMT "> (" XFMT ")\n\n", - (watchflag ? "Watch" : "Break"), name, off, addr); - e2dbg_output(logbuf); - } - break; - - /* Wrong command syntax */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong arg number", (-1)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/* Watchpoint command */ -int cmd_watch() -{ - int err; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - watchflag = 1; - err = cmd_bp(); - watchflag = 0; - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to install watchpoint", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (err)); -} + XALLOC(__FILE__, __FUNCTION__, __LINE__,bp , sizeof(elfshbp_t), (-1)); + bp->obj = file; + bp->type = INSTR; + bp->addr = addr; + bp->symname = strdup(resolv); + snprintf(tmp, 32, XFMT, addr); + if (hash_get(bps, tmp)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Breakpoint already exist", -1); + + /* Call the architecture dependent hook for breakpoints */ + ret = e2dbg_setbreak(file, bp); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Breakpoint insertion failed", (-1)); + + /* Add new breakpoint to hash table */ + bp->id = lastbpid++; + hash_add(bps, strdup(tmp), bp); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/* Add a breakpoint without using a script command */ +int e2dbg_breakpoint_add(eresi_Addr addr) +{ + int err; + char buf[BUFSIZ]; + char *name; + elfsh_SAddr off; + elfshobj_t *file; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Resolve source file */ + file = e2dbg_get_parent_object(addr); + if (file == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot resolve parent file for bp", -1); + + /* Resolve breakpoint address */ + name = revm_resolve(file, addr, &off); + if (off) + snprintf(buf, BUFSIZ, "<%s + " DFMT ">", name, off); + else + snprintf(buf, BUFSIZ, "<%s>", name); + + /* Really put the breakpoint */ + err = elfsh_bp_add(&e2dbgworld.bp, file, buf, addr); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot add breakpoint", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/* Return 1 if the breakpoint is a watchpoint */ +int e2dbg_is_watchpoint(elfshbp_t *b) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + b && b->flags & ELFSH_BP_WATCH); +} + + + + + +/* Find breakpoint by ID */ +elfshbp_t *e2dbg_breakpoint_from_id(uint32_t bpid) +{ + elfshbp_t *cur; + int index; + char **keys; + int keynbr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + keys = hash_get_keys(&e2dbgworld.bp, &keynbr); + for (index = 0; index < keynbr; index++) + { + cur = hash_get(&e2dbgworld.bp, keys[index]); + if (cur->id == bpid) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + cur); + } + hash_free_keys(keys); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find breakpoing by ID", NULL); +} + + + +/* Find a breakpoint by various ways */ +elfshbp_t *e2dbg_breakpoint_lookup(char *name) +{ + eresi_Addr addr; + elfshbp_t *bp; + uint16_t bpid; + char straddr[32]; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + bp = NULL; + + /* Lookup by vaddr */ + if (IS_VADDR(name)) + { + + if (sscanf(name + 2, AFMT, &addr) != 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid virtual address requested", + NULL); + } + + /* Try to lookup by ID */ + else if (revm_isnbr(name)) + { + bpid = atoi(name); + bp = e2dbg_breakpoint_from_id(bpid); + if (!bp) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid breakpoint ID", NULL); + } + + /* Resolve symbol */ + /* Here we fix symbols on the disk only ! This avoid a mprotect */ + else + { + addr = e2dbg_breakpoint_find_addr(name); + if (!addr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Requested symbol address unknown", + NULL); + } + + /* Get the breakpoint */ + if (!bp) + { + snprintf(straddr, sizeof(straddr), XFMT, addr); + bp = hash_get(&e2dbgworld.bp, straddr); + if (!bp) + { + snprintf(logbuf, BUFSIZ, + "\n [!] No breakpoint set at addr " AFMT " \n\n", addr); + e2dbg_output(logbuf); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No breakpoint at this address", NULL); + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, bp); +} + + + + + +/* Find the correct location for a breakpoint. Avoid putting breakpoints + on plt entries when possible */ +eresi_Addr e2dbg_breakpoint_find_addr(char *str) +{ + elfsh_Sym *sym; + elfsh_Sym *bsym; + elfshsect_t *sect; + elfshobj_t *parent; + char **keys; + int keynbr; + int index; + eresi_Addr addr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + sym = bsym = NULL; + + /* Sometimes we fix symbols on the disk : we avoid mprotect */ + /* Only return success early if not a plt symbol */ + keys = NULL; + parent = world.curjob->curfile; + sym = elfsh_get_metasym_by_name(parent, str); + if (!sym || !sym->st_value) + { + elfsh_toggle_mode(); + sym = elfsh_get_metasym_by_name(parent, str); + elfsh_toggle_mode(); + } + + if (sym && parent->hdr->e_type == ET_DYN) + sym->st_value += parent->rhdr.base; + + if (sym && sym->st_value) + { + sect = elfsh_get_parent_section(parent, sym->st_value, NULL); + if (!elfsh_is_plt(parent, sect)) + goto end; + } + + /* Try to look in other objects */ + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + + for (index = 0; index < keynbr; index++) + { + if (strstr(keys[index], E2DBG_ARGV0)) + continue; + + parent = hash_get(&world.curjob->loaded, keys[index]); + bsym = elfsh_get_metasym_by_name(parent, str); + if (!bsym || !bsym->st_value) + { + elfsh_toggle_mode(); + bsym = elfsh_get_metasym_by_name(parent, str); + elfsh_toggle_mode(); + if (bsym && bsym->st_value) + { + sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); + if (!elfsh_is_plt(parent, sect)) + { + sym = bsym; + if (strstr(parent->name, "libc.so")) + goto end; + } + if (!sym) + sym = bsym; + } + } + else + { + sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); + if (!elfsh_is_plt(parent, sect)) + { + sym = bsym; + if (strstr(parent->name, "libc.so")) + goto end; + } + if (!sym) + sym = bsym; + } + +#if __DEBUG_BP__ + printf("BPSym after %-30s = " XFMT "\n", parent->name, (eresi_Addr) sym); +#endif + + } + + /* Return error or success, dont forget to free the keys */ + end: + if (keys) + hash_free_keys(keys); + + if (!sym || !sym->st_value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No symbol by that name in the current file", 0); + addr = sym->st_value; + if (elfsh_get_objtype(parent->hdr) == ET_DYN) + { +#if __DEBUG_BP__ + printf(" [*] Adding base addr " XFMT " of ET_DYN %s\n", + parent->rhdr.base, parent->name); +#endif + addr += parent->rhdr.base; + } + +#if __DEBUG_BP__ + printf(" [*] Will set breakpoint on " XFMT " (parent = %s) \n", + addr, parent->name); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addr); +} + + + + +/* Breakpoint command */ +int cmd_bp() +{ + char *str; + int ret; + eresi_Addr addr; + char logbuf[BUFSIZ]; + int idx; + int index; + elfsh_SAddr off = 0; + char *name; + elfshbp_t *cur; + char **keys; + int keynbr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* build argc */ + for (idx = 0; world.curjob->curcmd->param[idx] != NULL; idx++); + str = revm_lookup_string(world.curjob->curcmd->param[0]); + + /* Select subcommand */ + switch (idx) + { + + /* List breakpoints */ + case 0: + e2dbg_output(" .:: Breakpoints ::.\n\n"); + keys = hash_get_keys(&e2dbgworld.bp, &keynbr); + for (index = 0; index < keynbr; index++) + { + cur = hash_get(&e2dbgworld.bp, keys[index]); + name = revm_resolve(world.curjob->curfile, + (eresi_Addr) cur->addr, &off); + if (off) + snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s + " UFMT ">\n", + (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), + cur->id, cur->addr, name, off); + else + snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s>\n", + (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), + cur->id, cur->addr, name); + e2dbg_output(logbuf); + } + hash_free_keys(keys); + if (!index) + e2dbg_output(" [*] No breakpoints\n"); + e2dbg_output("\n"); + break; + + /* Supply a new breakpoint */ + case 1: + if (!elfsh_is_runtime_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Not in dynamic or debugger mode", -1); + if (!str || !(*str)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); + + /* Break on a supplied virtual address */ + if (IS_VADDR(str)) + { + if (sscanf(str + 2, AFMT, &addr) != 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid virtual address requested", (-1)); + } + + /* Resolve first a function name */ + else + { + addr = e2dbg_breakpoint_find_addr(str); + if (addr == 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Requested symbol address unknown", -1); + } + + /* Add the breakpoint */ + ret = e2dbg_breakpoint_add(addr); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Breakpoint insertion failed\n", (-1)); + if (ret >= 0) + { + name = revm_resolve(world.curjob->curfile, addr, &off); + if (!off) + snprintf(logbuf, BUFSIZ - 1, + " [*] Breakpoint added at <%s> (" XFMT ")\n\n", name, addr); + else + snprintf(logbuf, BUFSIZ - 1, + " [*] Breakpoint added at <%s + " UFMT "> (" XFMT ")\n\n", + name, off, addr); + e2dbg_output(logbuf); + } + break; + + /* Wrong command syntax */ + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Wrong arg number", (-1)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); +} + + + +/* Watchpoint */ +int cmd_watch() +{ + int idx; + revmexpr_t *addr; + eresi_Addr val; + char buff[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* List watchpoints */ + if (!world.curjob->curcmd->param[0]) + { + e2dbg_output(" .:: Watchpoints ::.\n\n"); + for (idx = 0; e2dbgworld.tracedata[idx]; idx++) + { + snprintf(buff, BUFSIZ, " [%u] %-40s ("XFMT")\n", + idx, e2dbgworld.tracedstr[idx], e2dbgworld.tracedata[idx]); + e2dbg_output(buff); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Put a new watchpoint */ + for (idx = 0; world.curjob->curcmd->param[idx]; idx++) + { + addr = revm_compute(world.curjob->curcmd->param[idx]); + if (!addr || !addr->type || !addr->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameter", -1); + if (addr->type->type != ASPECT_TYPE_LONG && + addr->type->type != ASPECT_TYPE_CADDR && + addr->type->type != ASPECT_TYPE_DADDR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can watch only an address", -1); + if (e2dbgworld.tdatanbr >= E2DBG_STEPCMD_MAX) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Too many watch: cannot trace more", -1); + val = (addr->value->immed ? addr->value->immed_val.ent : + addr->value->get_obj(addr->value->parent)); + e2dbgworld.tracedata[e2dbgworld.tdatanbr] = val; + e2dbgworld.tracedstr[e2dbgworld.tdatanbr] = strdup(world.curjob->curcmd->param[idx]); + snprintf(buff, BUFSIZ, " [%u] Added watchpoint on address "XFMT" - (from %s)\n", + e2dbgworld.tdatanbr, e2dbgworld.tracedata[e2dbgworld.tdatanbr], + e2dbgworld.tracedstr[e2dbgworld.tdatanbr]); + e2dbg_output(buff); + e2dbgworld.tdatanbr++; + } + + e2dbg_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libe2dbg/common/common.c eresi-0.0.20110516/libe2dbg/common/common.c --- eresi-0.8a25/libe2dbg/common/common.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/common.c 2011-05-16 11:35:06.000000000 +0000 @@ -0,0 +1,64 @@ +/** + * @defgroup common + * @ingroup libe2dbg + */ +/* +* @file libe2dbg/common/common.c +** @brief Common generic API for libe2dbg +** @ingroup common +** +** $Id: common.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + +/* The debugger world */ +e2dbgworld_t e2dbgworld; + +/** + * Realize the output. + ** @todo: XXX: Need a vector + * @param str + * @return + */ +int e2dbg_output(char *str) +{ + //revm_output(str); + fprintf(stderr, str); + return (0); +} + + +/** + * Get the parent object of a breakpoint. + * Thats needed for the mprotect stuff inside the breakpoint handler + * @param addr + * @return + */ +elfshobj_t *e2dbg_get_parent_object(eresi_Addr addr) +{ + elfsh_Phdr *cur; + elfshobj_t *curfile; + elfshsect_t *cursect; + char **keys; + int index; + int keynbr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + for (index = 0; index < keynbr; index++) + { + curfile = hash_get(&world.curjob->loaded, keys[index]); + cursect = elfsh_get_parent_section(curfile, addr, NULL); + if (cursect) + { + cur = elfsh_get_parent_segment(curfile, cursect); + if (cur) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, curfile); + } + } + + /* Parent object not found */ + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get parent object addr", (NULL)); +} diff -Nru eresi-0.8a25/libe2dbg/common/dbghooks.c eresi-0.0.20110516/libe2dbg/common/dbghooks.c --- eresi-0.8a25/libe2dbg/common/dbghooks.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/dbghooks.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,17 +1,15 @@ -/* -** vmhooks.c for e2dbg in the ELF shell framework -** -** The interface hooking system -** -** Those hooks stay in the debugger and not in libelfsh. +/** +* @file libe2dbg/common/dbghooks.c +** @brief Vectors for debugging features +** @ingroup common ** ** Started Sat Sep 24 07:17:33 2005 jfv -** $Id: dbghooks.c,v 1.1 2008-02-16 12:32:27 thor Exp $ +** $Id: dbghooks.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" -/* Void handlers for the 2 hooks */ +/* Void handlers for the 3 register-related vectors */ void e2dbg_default_getregs() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -24,6 +22,13 @@ PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } +void e2dbg_default_printregs() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + /* Error handler by default for them */ eresi_Addr* e2dbg_default_getpc() { @@ -75,11 +80,19 @@ "Unsupported Arch, ELF type, or OS", -1); } +int e2dbg_default_deletebreak_handler(elfshbp_t *bp) + +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + /* Register a next frame-pointer handler */ int e2dbg_register_nextfphook(u_char archtype, u_char hosttype, - u_char ostype, void *fct) + u_char ostype, void *(*fct)(void *frame)) { vector_t *nextfp; u_int *dim; @@ -87,17 +100,16 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); nextfp = aspect_vector_get(E2DBG_HOOK_NEXTFP); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); - //hook_nextfp[archtype][hosttype][ostype] = fct; dim = alloca(sizeof(u_int) * 4); dim[0] = archtype; dim[1] = hosttype; @@ -118,13 +130,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); getret = aspect_vector_get(E2DBG_HOOK_GETRET); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -146,13 +158,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); setregs = aspect_vector_get(E2DBG_HOOK_SETREGS); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + "Invalid Host type", -1); + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -166,7 +178,7 @@ /* Register an SETREGS injection handler */ int e2dbg_register_gregshook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) + void *fct) { vector_t *getregs; u_int *dim; @@ -174,13 +186,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); getregs = aspect_vector_get(E2DBG_HOOK_GETREGS); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + "Invalid Host type", -1); + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -192,6 +204,33 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +/* Register an PRINTREGS handler */ +int e2dbg_register_pregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct) +{ + vector_t *printregs; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + printregs = aspect_vector_get(E2DBG_HOOK_PRINTREGS); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (hosttype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = hosttype; + dim[2] = ostype; + aspect_vectors_insert(printregs, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + /* Register an GETPC injection handler */ int e2dbg_register_getpchook(u_char archtype, u_char hosttype, u_char ostype, void *fct) @@ -202,13 +241,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); getpc = aspect_vector_get(E2DBG_HOOK_GETPC); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -222,7 +261,7 @@ /* Register an GETPC injection handler */ int e2dbg_register_getfphook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) + eresi_Addr *(*fct)(void)) { vector_t *getfp; u_int *dim; @@ -230,13 +269,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); getfp = aspect_vector_get(E2DBG_HOOK_GETFP); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -258,13 +297,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); setstep = aspect_vector_get(E2DBG_HOOK_SETSTEP); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -286,13 +325,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); resetstep = aspect_vector_get(E2DBG_HOOK_RESETSTEP); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); @@ -312,26 +351,44 @@ u_char ostype, void *fct) { vector_t *breakp; - u_int *dim; + u_int dim[4]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); breakp = aspect_vector_get(E2DBG_HOOK_BREAK); - if (archtype >= ELFSH_ARCHNUM) + if (archtype >= ELFSH_ARCH_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) + if (hosttype >= ELFSH_HOST_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Host type", -1); - if (ostype >= ELFSH_OSNUM) + if (ostype >= ELFSH_OS_NUM) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); dim[0] = archtype; dim[1] = hosttype; dim[2] = ostype; - aspect_vectors_insert(breakp, dim, (unsigned long) fct); + aspect_vectors_insert(breakp, dim, (u_long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Register a breakpoint deletion handler + */ +int e2dbg_register_delbreakhook(u_char hosttype, void *fct) +{ + vector_t *breakp; + u_int dim[2]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + breakp = aspect_vector_get(E2DBG_HOOK_DELBREAK); + + if (hosttype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + dim[0] = hosttype; + aspect_vectors_insert(breakp, dim, (u_long) fct); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -343,18 +400,26 @@ { u_int *dims; char **strdims; + u_int *adims; + char **astrdims; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* All hooks have the same dimensions here */ XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 4 * sizeof(u_int) , -1); XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 4 * sizeof(char *), -1); - dims[0] = ELFSH_ARCHNUM; - dims[1] = E2DBG_HOSTNUM; - dims[2] = ELFSH_OSNUM; + dims[0] = ELFSH_ARCH_NUM; + dims[1] = ELFSH_HOST_NUM; + dims[2] = ELFSH_OS_NUM; strdims[0] = "ARCHTYPE"; strdims[1] = "HOSTYPE"; strdims[2] = "OSTYPE"; + + /* Except the breakpoint deletion hook */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, adims , 2 * sizeof(u_int) , -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, astrdims, 2 * sizeof(char *), -1); + adims[0] = ELFSH_HOST_NUM; + astrdims[0] = "HOSTYPE"; /* Initialize debugger vectors */ aspect_register_vector(E2DBG_HOOK_GETREGS, @@ -363,6 +428,9 @@ aspect_register_vector(E2DBG_HOOK_SETREGS, e2dbg_default_setregs, dims, strdims, 3, ASPECT_TYPE_CADDR); + aspect_register_vector(E2DBG_HOOK_PRINTREGS, + e2dbg_default_printregs, + dims, strdims, 3, ASPECT_TYPE_CADDR); aspect_register_vector(E2DBG_HOOK_GETPC, e2dbg_default_getpc, dims, strdims, 3, ASPECT_TYPE_CADDR); @@ -384,6 +452,9 @@ aspect_register_vector(E2DBG_HOOK_BREAK, e2dbg_default_breakhandler, dims, strdims, 3, ASPECT_TYPE_CADDR); + aspect_register_vector(E2DBG_HOOK_DELBREAK, + e2dbg_default_deletebreak_handler, + adims, astrdims, 1, ASPECT_TYPE_CADDR); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -392,7 +463,7 @@ /* Setup internal VM hooks */ void e2dbg_setup_hooks() { - static int done = 0; + static Bool done = FALSE; /* Check if already initialized */ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -400,319 +471,7 @@ PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); aspect_init(); e2dbg_register_vectors(); - - /* Initialize vectors */ - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_get_regvars_ia32_sysv); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_get_regvars_ia32_sysv); - - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_set_regvars_ia32_sysv); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_set_regvars_ia32_sysv); - - - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_getpc_sysv_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_ia32); - - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_setstep_sysv_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_ia32); - - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_resetstep_sysv_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_ia32); - - - /* For sparc32 */ - - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_get_regvars_sparc32_sysv); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_get_regvars_sparc32_sysv); - - - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_set_regvars_sparc32_sysv); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_set_regvars_sparc32_sysv); - - - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_getpc_sysv_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_sparc32); - - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_setstep_sysv_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_sparc32); - - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_resetstep_sysv_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_sparc32); - - - /***********************************/ - /* Now nextfp hooks */ - /***********************************/ - - /* Usual nextfp targets for ET_EXEC/ET_DYN on IA32 */ - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_bt_ia32); - - /* Now for sparc */ - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); - - - - /************************************/ - /* Now getfp hooks */ - /***********************************/ - - /* Usual getfp targets for ET_EXEC/ET_DYN on IA32 */ - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); - - /* Now for sparc */ - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); - - - /***********************************/ - /* Now register getret hooks */ - /***********************************/ - - /* Usual getret targets for ET_EXEC/IA32 */ - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getret_ia32); - - /* Now for sparc32 */ - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); - - /***********************************/ - /* Now register breakpoint hooks */ - /***********************************/ - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_break_ia32); - - /* Now for sparc */ - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_break_sparc32); - - done = 1; + done = TRUE; PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } @@ -736,7 +495,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GETREGS handler unexistant for this ARCH/OS", -1); @@ -752,6 +511,8 @@ } + + /* Call the setregs hook */ int e2dbg_setregs() { @@ -770,7 +531,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "SETREGS handler unexistant for this ARCH/OS", -1); @@ -785,6 +546,42 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + +/* Call the setregs hook */ +int e2dbg_printregs() +{ + u_char archtype; + u_char hosttype; + u_char ostype; + u_int dim[3]; + vector_t *printregs; + void (*fct)(); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + printregs = aspect_vector_get(E2DBG_HOOK_PRINTREGS); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(world.curjob->curfile); + hosttype = elfsh_get_hosttype(world.curjob->curfile); + ostype = elfsh_get_ostype(world.curjob->curfile); + if (archtype == ELFSH_ARCH_ERROR || + hosttype == ELFSH_HOST_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PRINTREGS handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = hosttype; + dim[2] = ostype; + fct = aspect_vectors_select(printregs, dim); + + /* This hook is non-fatal, we just wont have printed registers if it fails. */ + fct(); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + /* Call the getpc hook */ eresi_Addr* e2dbg_getpc() { @@ -804,7 +601,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GETPC handler unexistant for this ARCH/OS", NULL); @@ -840,7 +637,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GETPC handler unexistant for this ARCH/OS", NULL); @@ -875,7 +672,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "SETSTEP handler unexistant for this ARCH/OS", -1); @@ -906,7 +703,7 @@ hosttype = elfsh_get_hosttype(world.curjob->curfile); ostype = elfsh_get_ostype(world.curjob->curfile); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GETPC handler unexistant for this ARCH/OS", -1); @@ -940,7 +737,7 @@ hosttype = elfsh_get_hosttype(file); ostype = elfsh_get_ostype(file); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "BACKTRACE (nextfp) handler unexistant for this ARCH/OS", @@ -977,7 +774,7 @@ hosttype = elfsh_get_hosttype(file); ostype = elfsh_get_ostype(file); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GETRET handler unexistant for this ARCH/OS", -1); @@ -994,9 +791,6 @@ } - - - /** * Call the breakpoint hook */ @@ -1018,7 +812,7 @@ hosttype = elfsh_get_hosttype(file); ostype = elfsh_get_ostype(file); if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || + hosttype == ELFSH_HOST_ERROR || ostype == ELFSH_OS_ERROR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "SETBREAK handler unexistant for this ARCH/OS", -1); @@ -1033,3 +827,34 @@ "Breakpoint handler failed", (-1)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + +/** + * Call the breakpoint deletion hook + */ +int e2dbg_deletebreak(elfshbp_t *bp) +{ + vector_t *breakh; + u_char hosttype; + int ret; + int (*fct)(elfshbp_t *bp); + u_int dim[1]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + breakh = aspect_vector_get(E2DBG_HOOK_DELBREAK); + + /* Fingerprint binary */ + hosttype = elfsh_get_hosttype(bp->obj); + if (hosttype == ELFSH_HOST_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "DELBREAK handler unexistant for this ARCH/OS", -1); + + dim[0] = hosttype; + fct = aspect_vectors_select(breakh, dim); + ret = fct(bp); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Breakpoint deletion handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libe2dbg/common/dbg-ia32.c eresi-0.0.20110516/libe2dbg/common/dbg-ia32.c --- eresi-0.8a25/libe2dbg/common/dbg-ia32.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/dbg-ia32.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -/* -** dbg-ia32.c for e2dbg in the ERESI framework -** -** Debugger backend for the IA32 architecture -** -** Those hooks stay in the debugger and not in libelfsh. -** -** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter -** -** Started Sat Sep 24 07:17:33 2005 jfv -** $Id: dbg-ia32.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libe2dbg.h" - - - - - - -/* Regvars handler for the IA32 architecture on BSD */ -void e2dbg_get_regvars_ia32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); - //E2DBG_GETREG(E2DBG_SSPVAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - //E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_get_regvars_ia32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Regvars handler for the IA32 architecture */ -void e2dbg_set_regvars_ia32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); - //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_set_regvars_ia32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getpc_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getpc_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getfp_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.mc_ebp); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getfp_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Enable stepping on BSD */ -void e2dbg_setstep_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; -#elif defined(__NetBSD__) - e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Enable stepping on Sys V */ -void e2dbg_setstep_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on Sys V */ -void e2dbg_resetstep_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on BSD */ -void e2dbg_resetstep_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; -#elif defined(__NetBSD__) - e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Get the next frame pointer given the current one - */ -void *e2dbg_bt_ia32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((void *) *(long*) frame)); -} - -/** - * Get the return address giving the current frame pointer - */ -void *e2dbg_getret_ia32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (void *) (*((long *) frame + 1))); -} - - -/** - * Write a breakpoint 0xCC in memory - * One of the 2 breakpoint technique of e2dbg - */ -int e2dbg_break_ia32(elfshobj_t *f, - elfshbp_t *bp) -{ - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] bp->addr %08X \n", bp->addr); -#endif - - bp->savedinstr[0] = *(u_long *) bp->addr; - prot = elfsh_munprotect(f, bp->addr, 4); - if (prot == (-1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after munprotect\n"); -#endif - *(u_char *) bp->addr = 0xCC; -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after write\n"); -#endif - elfsh_mprotect(bp->addr, 4, prot); -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after mprotect\n"); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} diff -Nru eresi-0.8a25/libe2dbg/common/dbg-sparc32.c eresi-0.0.20110516/libe2dbg/common/dbg-sparc32.c --- eresi-0.8a25/libe2dbg/common/dbg-sparc32.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/dbg-sparc32.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ -/* -** dbg-sparc32.c for e2dbg in the ERESI framework -** -** Debugger backend for the SPARC32 architecture -** -** Those hooks stay in the debugger and not in libelfsh. -** -** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter -** -** Started Thu Jun 07 07:17:33 2007 mayhem -** $Id: dbg-sparc32.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libe2dbg.h" - - - - - - -/* Regvars handler for the IA32 architecture on BSD */ -void e2dbg_get_regvars_sparc32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); -#elif defined(SPARC) && defined(__NetBSD__) - //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_get_regvars_sparc32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); - E2DBG_GETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); - E2DBG_GETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); - E2DBG_GETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); - E2DBG_GETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); - E2DBG_GETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); - E2DBG_GETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); - E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); - E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); - E2DBG_GETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); - E2DBG_GETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); - E2DBG_GETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); - E2DBG_GETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); - E2DBG_GETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); - E2DBG_GETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); - E2DBG_GETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); - E2DBG_GETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); - E2DBG_GETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Regvars handler for the IA32 architecture */ -void e2dbg_set_regvars_sparc32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); -#elif defined(SPARC) && defined(__NetBSD__) - //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_set_regvars_sparc32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); - E2DBG_SETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); - E2DBG_SETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); - E2DBG_SETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); - E2DBG_SETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); - E2DBG_SETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); - E2DBG_SETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); - E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); - E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); - E2DBG_SETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); - E2DBG_SETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); - E2DBG_SETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); - E2DBG_SETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); - E2DBG_SETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); - E2DBG_SETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); - E2DBG_SETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); - E2DBG_SETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); - E2DBG_SETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getpc_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(SPARC) && defined(__NetBSD__) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getpc_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *) &e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getfp_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.mc_ebp); -#elif defined(__NetBSD__) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Get Program Stack Pointer register on Sys V */ -/* On SPARC, we use SP and not FP in that handler */ -eresi_Addr* e2dbg_getfp_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Enable stepping on BSD */ -void e2dbg_setstep_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; -#elif defined(SPARC) && defined(__NetBSD__) - //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Enable stepping on Sys V */ -void e2dbg_setstep_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on Sys V */ -void e2dbg_resetstep_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Disable stepping on BSD */ -void e2dbg_resetstep_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; -#elif defined(SPARC) && defined(__NetBSD__) - //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Get the next frame pointer given the current one - */ -void *e2dbg_bt_sparc32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((void *) *(long*) frame + 14)); -} - - -/** - * Get the return address giving the current frame pointer - */ -void *e2dbg_getret_sparc32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (void *) (*((long *) frame + 15))); -} - - -/** - * Write a sparc breakpoint in memory - * One of the 2 breakpoint technique of e2dbg - */ -#if !defined(SPARC) -int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) -{ - return (0); -} -#else -int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) -{ - int prot; - unsigned long addr; - unsigned long long addr64; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] bp->addr %016x \n", bp->addr); -#endif - - memcpy(bp->savedinstr, (u_char *) bp->addr, 8); - - prot = elfsh_munprotect(f, bp->addr, 8); - if (prot == (-1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after munprotect\n"); -#endif - - //*(u_long *) bp->addr = 0x91d02001; /* opcode for ta 1 */ - - *((u_long *) bp->addr) = 0x01000000; /* put nop here */ - *((u_long *) bp->addr + 1) = 0x01000000; /* put nop here */ - - addr = (bp->addr & (~7)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address to be flushed: %016lx \n", addr); -#endif - - /* Testing .... */ - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (0)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (8)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (16)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (0)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (8)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (16)); - - addr64 = 0xffffffff00000000 + addr; - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address64 to be flushed: %016llx \n", addr64); -#endif - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (0)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (8)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (16)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (0)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (8)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (16)); - - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after sleep & write\n"); -#endif - - elfsh_mprotect(bp->addr, 8, prot); - - sleep(2); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after mprotect\n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} -#endif /* defined(SPARC) */ - - diff -Nru eresi-0.8a25/libe2dbg/common/delete.c eresi-0.0.20110516/libe2dbg/common/delete.c --- eresi-0.8a25/libe2dbg/common/delete.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/delete.c 2011-05-16 11:35:06.000000000 +0000 @@ -0,0 +1,83 @@ +/** +* @file libe2dbg/common/delete.c + * @brief Command and API for breakpoint deletion + * @ingroup common + * + * Started on Tue Aug 16 09:38:03 2005 jfv + * $Id: delete.c 1397 2009-09-13 02:19:08Z may $ + */ +#include "libe2dbg.h" + + +/** + * Delete a breakpoint for real. + * @param Breakpoint structure to delete + * @return Nothing. + */ +int e2dbg_breakpoint_delete(elfshbp_t *bp) +{ + eresi_Addr addr; + char *name; + int prot; + elfsh_SAddr off; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + addr = bp->addr; + + /* Delete the breakpoint */ + prot = elfsh_munprotect(bp->obj, addr, 1); + e2dbg_deletebreak(bp); + elfsh_mprotect(bp->obj, addr, 1, prot); + name = revm_resolve(bp->obj, addr, &off); + snprintf(logbuf, BUFSIZ, XFMT, addr); + hash_del(&e2dbgworld.bp, logbuf); + + if (off) + snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT + " <%s + " UFMT "> removed\n", addr, name, off); + else + snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT " <%s> removed\n", + addr, name); + e2dbg_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Delete breakpoints + * @return Success (0) or error (-1). + */ +int cmd_delete() +{ + elfshbp_t *bp; + char **keys; + int keynbr; + int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Lookup breakpoint */ + for (index = 0; world.curjob->curcmd->param[index]; index++) + { + bp = e2dbg_breakpoint_lookup(revm_lookup_string(world.curjob->curcmd->param[index])); + if (!bp) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown breakpoint", -1); + e2dbg_breakpoint_delete(bp); + } + + /* Delete all breakpoints if no argument was given */ + if (!index) + { + keys = hash_get_keys(&e2dbgworld.bp, &keynbr); + for (index = 0; index < keynbr; index++) + { + bp = hash_get(&e2dbgworld.bp, keys[index]); + e2dbg_breakpoint_delete(bp); + } + hash_free_keys(keys); + } + + e2dbg_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libe2dbg/common/display.c eresi-0.0.20110516/libe2dbg/common/display.c --- eresi-0.8a25/libe2dbg/common/display.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/display.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,13 +1,13 @@ -/* -** display.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: display.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" +/** + * @file libe2dbg/common/display.c + * @ingroup common + * @brief Command and API for the display-on-breakpoint feature. + * + * Started on Tue Aug 16 09:38:03 2005 jfv + * $Id: display.c 1410 2010-05-14 13:45:20Z thorkill $ + */ +#include "libe2dbg.h" /* Print all display commands */ void e2dbg_display_print() @@ -15,7 +15,6 @@ char buff[BUFSIZ]; int idx; int printed; - listent_t *actual; elfshbp_t *curbp; int idx2; @@ -78,20 +77,14 @@ int idx; revmargv_t *cur; char *str; - char buf[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + for (idx = 0; idx < nbr; idx++) { - fprintf(stderr, "executing display entry %u \n", idx); if (cmd[idx]) { - snprintf(buf, BUFSIZ, - "\t .:: Display %u [%s] result ::. \n", - idx, cmd[idx]); - e2dbg_output(buf); - /* Register displayed command in the script control flow */ str = strdup(cmd[idx]); @@ -102,7 +95,7 @@ /* Execute displayed command */ cur = world.curjob->curcmd; - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; + world.curjob->curcmd = world.curjob->recur[world.curjob->curscope].script; if (revm_execmd() < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Display execution failed", -1); @@ -128,7 +121,7 @@ { e2dbg_display_print(); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } + } /* Add a global display */ if (!revm_isnbr(world.curjob->curcmd->param[0])) @@ -163,14 +156,11 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - /* Delete displays */ +// FIXME: empty function? int cmd_undisplay() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libe2dbg/common/dumpregs.c eresi-0.0.20110516/libe2dbg/common/dumpregs.c --- eresi-0.8a25/libe2dbg/common/dumpregs.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/dumpregs.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,18 +1,17 @@ -/* -** dumpregs.c for elfsh +/** +* @file libe2dbg/common/dumpregs.c +** @ingroup common +** @brief Command and API for register printing. ** ** Started on Wed Jul 27 04:08:52 2005 ym -** -** -** $Id: dumpregs.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** +** $Id: dumpregs.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" /* Resolve a register */ -void e2dbg_register_dump(char *name, uint32_t reg) +void e2dbg_register_dump(char *name, ureg32 reg) { elfsh_SAddr off; char *str; @@ -30,92 +29,18 @@ /* The register dumping function */ /* Print the registers state just before entering the breakpoint */ -/* Small BSD patch submitted by Rod */ int cmd_dumpregs() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e2dbgworld.curthread) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No current thread available", (-1)); if (!e2dbgworld.curthread->context) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No context available", (-1)); - e2dbg_output(" .:: Registers ::. \n\n"); - -#if defined(__amd64__) && defined(__FreeBSD__) - #error "Register context not filled on FreeBSD / AMD64" -#elif defined(__FreeBSD__) //|| defined(__OpenBSD__) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.mc_edx); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.mc_esi); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.mc_edi); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.mc_esp); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#elif defined(IRIX) - e2dbg_register_dump("R0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_R0]); - e2dbg_register_dump("AT", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_AT]); - e2dbg_register_dump("V0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V0]); - e2dbg_register_dump("V1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V1]); - e2dbg_register_dump("A0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A0]); - e2dbg_register_dump("A1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A1]); - e2dbg_register_dump("A2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A2]); - e2dbg_register_dump("A3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A3]); - e2dbg_register_dump("A4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A4]); - e2dbg_register_dump("A5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A5]); - e2dbg_register_dump("A6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A6]); - e2dbg_register_dump("A7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A7]); - e2dbg_register_dump("T0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T0]); - e2dbg_register_dump("T1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T1]); - e2dbg_register_dump("T2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T2]); - e2dbg_register_dump("T3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T3]); - e2dbg_register_dump("S0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S0]); - e2dbg_register_dump("S1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S1]); - e2dbg_register_dump("S2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S2]); - e2dbg_register_dump("S3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S3]); - e2dbg_register_dump("S4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S4]); - e2dbg_register_dump("S5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S5]); - e2dbg_register_dump("S6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S6]); - e2dbg_register_dump("S7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S7]); - e2dbg_register_dump("T8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T8]); - e2dbg_register_dump("T9", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T9]); - e2dbg_register_dump("K0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K0]); - e2dbg_register_dump("K1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K1]); - e2dbg_register_dump("GP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_GP]); - e2dbg_register_dump("SP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SP]); - e2dbg_register_dump("S8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S8]); - e2dbg_register_dump("RA", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_RA]); - e2dbg_register_dump("MDLO", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDLO]); - e2dbg_register_dump("MDHI", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDHI]); - e2dbg_register_dump("EPC", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_EPC]); - e2dbg_register_dump("SR", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SR]); -#elif defined(__i386__) && !(defined(__OpenBSD__)) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - - printf("\n"); - + e2dbg_setregs(); + e2dbg_printregs(); + e2dbg_output("\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); } diff -Nru eresi-0.8a25/libe2dbg/common/linkmap.c eresi-0.0.20110516/libe2dbg/common/linkmap.c --- eresi-0.8a25/libe2dbg/common/linkmap.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/linkmap.c 2011-05-16 11:35:06.000000000 +0000 @@ -0,0 +1,98 @@ +/** +* @file libe2dbg/common/linkmap.c +** @ingroup common +** @brief Command and API for accessing the LINKMAP linked list. +** +** $Id: linkmap.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + + +/** + * Dump the linkmap + * @param file + * @return + */ +int e2dbg_linkmap_print(elfshobj_t *file) +{ + char logbuf[BUFSIZ]; +#if defined(sun) + Link_map *actual; +#else + elfshlinkmap_t *actual; +#endif + int i = 1; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!file) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); + if (!file->linkmap || file->linkmap == E2DBG_ABSENT_LINKMAP) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No linkmap", -1); + + e2dbg_output(" .::. Linkmap entries .::. \n"); + + for (actual = elfsh_linkmap_get_lprev(file->linkmap); actual != NULL; + actual = elfsh_linkmap_get_lprev(actual), i++) + { + snprintf(logbuf, BUFSIZ - 1, + " [%02u] addr : " XFMT " dyn : " XFMT " - %s\n", i, + (eresi_Addr) elfsh_linkmap_get_laddr(actual), + (eresi_Addr) elfsh_linkmap_get_lld(actual), + elfsh_linkmap_get_lname(actual)); + e2dbg_output(logbuf); + } + + for (actual = file->linkmap; actual != NULL; + actual = elfsh_linkmap_get_lnext(actual), i++) + { + snprintf(logbuf, BUFSIZ - 1, + " [%02u] addr : "XFMT" dyn : "XFMT" - %s\n", i, + (eresi_Addr) elfsh_linkmap_get_laddr(actual), + (eresi_Addr) elfsh_linkmap_get_lld(actual), + elfsh_linkmap_get_lname(actual)); + e2dbg_output(logbuf); + } + + e2dbg_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Linkmap dump command + * @return +*/ +int cmd_linkmap() +{ + int old; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (elfsh_is_runtime_mode()) + { + if (!world.curjob) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No current workspace", -1); + + if (!world.curjob->curfile) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No current file", -1); + + old = world.curjob->curfile->id; + + /* switch to the main program file */ + revm_doswitch(1); + ret = e2dbg_linkmap_print(world.curjob->curfile); + revm_doswitch(old); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Debug mode only command", (-1)); +} + + diff -Nru eresi-0.8a25/libe2dbg/common/Makefile eresi-0.0.20110516/libe2dbg/common/Makefile --- eresi-0.8a25/libe2dbg/common/Makefile 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/Makefile 2011-05-16 11:35:06.000000000 +0000 @@ -2,46 +2,56 @@ ## Makefile for common (user/kernel code) parts of libe2dbg in the ERESI framework ## ## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id +## $Id: Makefile 1313 2009-01-15 03:03:47Z may $ ## include ../../config.h +LD ?= ld +CC ?= gcc +RM = rm -f SRC = backtrace.c breakpoints.c display.c mode.c stack.c \ - step.c dumpregs.c dbghooks.c mutex.c dbg-ia32.c dbg-sparc32.c + dumpregs.c dbghooks.c mutex.c common.c delete.c linkmap.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f +OBJNAME32 = libe2dbg-common32 +OBJNAME64 = libe2dbg-common64 CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ + -I ../../libgdbwrap/include/ \ -I../../libelfsh/include/ -I../../libdump/include/ \ -I../../libasm/include/ -I../../libstderesi/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ -I../../libaspect/include -I../../librevm/include/ \ -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINCINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI32 + -I../../libetrace/include/ \ + -DE2DBG_PRESENT -DE2DBG_INTERN $(ASMOPT) $(EXTRACFLAGS) \ + -DERESI32 CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ + -I ../../libgdbwrap/include/ \ -I../../libelfsh/include/ -I../../libdump/include/ \ -I../../libasm/include/ -I../../libstderesi/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ -I../../libaspect/include -I../../librevm/include/ \ -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI64 + -I../../libetrace/include \ + -DE2DBG_PRESENT -DE2DBG_INTERN $(ASMOPT) $(EXTRACFLAGS) \ + -DERESI64 all : all32 all64 all32 : ${OBJ32} + $(LD) -r ${OBJ32} -o $(OBJNAME32).o all64 : ${OBJ64} + $(LD) -r ${OBJ64} -o $(OBJNAME64).o clean : @$(RM) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* fclean : clean + @$(RM) *.o %.32.o : %.c $(CC) $(CFLAGS32) -c -o $@ $< diff -Nru eresi-0.8a25/libe2dbg/common/mode.c eresi-0.0.20110516/libe2dbg/common/mode.c --- eresi-0.8a25/libe2dbg/common/mode.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/mode.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,10 +1,10 @@ -/* -** mode.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: mode.c,v 1.1 2008-02-16 12:32:27 thor Exp $ +/** +* @file libe2dbg/common/mode.c +** @brief Implement command for switching between static and dynamic mode. +** @ingroup common ** +** Started on Tue Aug 16 09:38:03 2005 jfv +** $Id: mode.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" @@ -22,7 +22,7 @@ { if (elfsh_is_static_mode()) param = "STATIC"; - else if (elfsh_is_debug_mode()) + else if (elfsh_is_runtime_mode()) param = "DYNAMIC"; else PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -42,12 +42,14 @@ if (world.curjob) { if (world.curjob->curfile) - if (!world.curjob->curfile->linkmap && !world.curjob->curfile->rhdr.base) + if (!world.curjob->curfile->linkmap && + !world.curjob->curfile->rhdr.base && + world.curjob->curfile->hostype != ELFSH_HOST_GDB) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Can't switch to dynamic" " mode on not mapped file.", -1); } - elfsh_set_debug_mode(); + elfsh_set_runtime_mode(); e2dbg_output(" [*] e2dbg is now in DYNAMIC mode\n\n"); } else diff -Nru eresi-0.8a25/libe2dbg/common/mutex.c eresi-0.0.20110516/libe2dbg/common/mutex.c --- eresi-0.8a25/libe2dbg/common/mutex.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/mutex.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,12 +1,9 @@ -/* -** mutex.c for e2dbg -** -** The debugger needs mutexes inside signal handlers so we do not use pthread mutexes -** -** Last update Wed Oct 11 18:22:59 2005 jfv -** -** $Id: mutex.c,v 1.1 2008-02-16 12:32:27 thor Exp $ +/** +* @file libe2dbg/common/mutex.c +** @brief Implement debugger mutexes inside signal handlers (no pthread mutexes) +** @ingroup common ** +** $Id: mutex.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/common/stack.c eresi-0.0.20110516/libe2dbg/common/stack.c --- eresi-0.8a25/libe2dbg/common/stack.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/stack.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,10 +1,10 @@ -/* -** stack.c for e2dbg +/** +* @file libe2dbg/common/stack.c +** @ingroup common +** @brief Implement commands and API for reading the stack. ** ** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: stack.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** +** $Id: stack.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" @@ -57,7 +57,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Preliminary checks */ - if (!elfsh_is_debug_mode()) + if (!elfsh_is_runtime_mode()) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Command only available in e2dbg", (-1)); param = world.curjob->curcmd->param[0]; @@ -96,7 +96,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Preliminary checks */ - if (!elfsh_is_debug_mode()) + if (!elfsh_is_runtime_mode()) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Command only available in e2dbg", (-1)); param = world.curjob->curcmd->param[0]; diff -Nru eresi-0.8a25/libe2dbg/common/step.c eresi-0.0.20110516/libe2dbg/common/step.c --- eresi-0.8a25/libe2dbg/common/step.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/step.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* -** delete.c for e2dbg -** -** Delete breakpoints -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: step.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Perform stepping */ -int e2dbg_step() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Checking stepping flag in the thread structure */ - if (e2dbgworld.curthread->step) - { - if (e2dbg_resetstep() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to disable stepping", -1); - e2dbg_output("\n [*] Disabled stepping\n\n"); - e2dbgworld.curthread->step = 0; - e2dbgworld.curthread->count = E2DBG_BREAK_NONE; - e2dbgworld.curthread->was_step = 1; - } - - /* Disable stepping and continue */ - else - { - if (e2dbg_setstep() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to enable stepping", -1); - e2dbg_output("\n [*] Enabled stepping \n\n"); - e2dbgworld.curthread->step = 1; - e2dbg_setregs(); - if (e2dbgworld.stoppedthread->tid != e2dbgworld.curthread->tid) - e2dbgworld.curthread = e2dbgworld.stoppedthread; - e2dbg_thread_contall(); - world.curjob->curfile->running = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Step command */ -int cmd_step() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retry: - if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) - { - if (e2dbgworld.sourcing) - goto retry; - else - printf("wasnt sourcing ... existing \n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You must be in a SIGTRAP handler to step", -1); - } - - ret = e2dbg_step(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/* Step-trace command */ -int cmd_itrace() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retry: - if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) - { - if (e2dbgworld.sourcing) - goto retry; - else - printf("wasnt sourcing ... existing \n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You must be in a SIGTRAP handler to step", -1); - } - - /* Enable or disable trace flag */ - if (e2dbgworld.curthread->trace) - e2dbgworld.curthread->trace = 0; - else - e2dbgworld.curthread->trace = 1; - ret = e2dbg_step(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/common/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/common/.svn/all-wcprops 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libe2dbg/common -END -backtrace.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libe2dbg/common/backtrace.c -END -dbghooks.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libe2dbg/common/dbghooks.c -END -breakpoints.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/946/trunk/libe2dbg/common/breakpoints.c -END -mutex.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libe2dbg/common/mutex.c -END -mode.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libe2dbg/common/mode.c -END -display.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libe2dbg/common/display.c -END -stack.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libe2dbg/common/stack.c -END -dumpregs.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/925/trunk/libe2dbg/common/dumpregs.c -END -dbg-sparc32.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/946/trunk/libe2dbg/common/dbg-sparc32.c -END -dbg-ia32.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libe2dbg/common/dbg-ia32.c -END -step.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libe2dbg/common/step.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/843/trunk/libe2dbg/common/Makefile -END diff -Nru eresi-0.8a25/libe2dbg/common/.svn/entries eresi-0.0.20110516/libe2dbg/common/.svn/entries --- eresi-0.8a25/libe2dbg/common/.svn/entries 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg/common -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -backtrace.c -file - - - - -2008-04-06T23:16:29.614152Z -cab3a8d8761d4faa131ba3d46e69c429 -2008-03-27T22:53:48.747992Z -946 -may - -dbghooks.c -file - - - - -2008-04-06T23:16:29.688151Z -207ed294282054abf4684b1b8df1302b -2008-03-27T22:53:48.747992Z -946 -may - -breakpoints.c -file - - - - -2008-04-06T23:16:29.697153Z -3a3740d220ef80af3faabe8a01275afe -2008-03-27T22:53:48.747992Z -946 -may - -mutex.c -file - - - - -2008-04-06T23:16:29.707879Z -ab7cd894fa632d9271a63725db49a223 -2008-02-16T12:32:28.000000Z -843 -thor - -mode.c -file - - - - -2008-04-06T23:16:29.719536Z -61a98d971a4a05c1e7b7df9b4946d78b -2008-02-16T12:32:28.000000Z -843 -thor - -display.c -file - - - - -2008-04-06T23:16:29.730879Z -6d3463f7a1b58789455496a96ede02c6 -2008-02-16T12:32:28.000000Z -843 -thor - -stack.c -file - - - - -2008-04-06T23:16:29.742282Z -7c4b998058d359828e459244aeee2fba -2008-03-27T22:53:48.747992Z -946 -may - -dumpregs.c -file - - - - -2008-04-06T23:16:29.753129Z -4008d14d40d1aef9ff66487acdb34e5f -2008-03-24T18:25:11.790287Z -925 -enioh - -dbg-sparc32.c -file - - - - -2008-04-06T23:16:29.764908Z -079acd415373bdefdb3defae91b685a2 -2008-03-27T22:53:48.747992Z -946 -may - -dbg-ia32.c -file - - - - -2008-04-06T23:16:29.775899Z -28343c3c451913784c55ec8d689ec243 -2008-03-27T22:53:48.747992Z -946 -may - -step.c -file - - - - -2008-04-06T23:16:29.787593Z -84ac131a1cddac65f9c654be35727381 -2008-02-16T12:32:28.000000Z -843 -thor - -Makefile -file - - - - -2008-04-06T23:16:29.799154Z -fe7b58bf4db5e55371847a7164cfe42a -2008-02-16T12:32:28.000000Z -843 -thor - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/format eresi-0.0.20110516/libe2dbg/common/.svn/format --- eresi-0.8a25/libe2dbg/common/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/backtrace.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/backtrace.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/backtrace.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/backtrace.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -/* -** backtrace.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: backtrace.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Display backtrace with sym resolution */ -int e2dbg_bt() -{ - e2dbgthread_t *t; - eresi_Addr frame; - eresi_Addr ret; - char *name, *name2; - elfsh_SAddr off, off2; - char logbuf[BUFSIZ]; - int i = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (!world.curjob) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current workspace", -1); - if (!world.curjob->curfile) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current file", -1); - - /* Get the current frame by calling the hook */ - frame = (eresi_Addr) e2dbg_getfp(); - if (!frame) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No context", (-1)); - - /* Backtrace frames */ - while (frame && frame != 0xFFFFFFFF) - { - /* Check if the next frame is pointing on our stack */ - if (e2dbgworld.curthread->stackaddr > frame || - e2dbgworld.curthread->stackaddr + e2dbgworld.curthread->stacksize < frame) - { - snprintf(logbuf, BUFSIZ, - " [*] Invalid next frame address " AFMT - " (stackaddr = " AFMT ", size = %u, max = " AFMT " )\n\n", - frame, e2dbgworld.curthread->stackaddr, - e2dbgworld.curthread->stacksize, - e2dbgworld.curthread->stackaddr + e2dbgworld.curthread->stacksize); - e2dbg_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Call the getret hook */ - ret = (eresi_Addr) e2dbg_getret(world.curjob->curfile, (eresi_Addr) frame); - - /* Resolve and print current trace frame */ - if (i == 0) - ret = *(e2dbg_getpc()); - name = revm_resolve(world.curjob->curfile, (eresi_Addr) ret, &off); - if (!name) - name = "?"; - - /* Just insert the real entry point where we reach the thread entry point of e2dbg */ - if (strstr(name, "e2dbg_thread_start")) - { - snprintf(logbuf, BUFSIZ - 1, "%u", - (unsigned int) e2dbgworld.stoppedthread->tid); - t = hash_get(&e2dbgworld.threads, logbuf); - name2 = revm_resolve(world.curjob->curfile, (eresi_Addr) t->entry, &off2); - if (name2) - { - if (off2) - snprintf(logbuf, BUFSIZ - 1, - " [%02d] "XFMT" in "XFMT" <%s + " UFMT "> -ENTRY-\n", i, - ret, (eresi_Addr) t->entry, name2, off2); - else - snprintf(logbuf, BUFSIZ - 1, - " [%02d] "XFMT" in "XFMT " <%s> -ENTRY-\n", i, - ret, (eresi_Addr) t->entry, name2); - e2dbg_output(logbuf); - i++; - } - } - - /* Filter the name in case we have a known-pattern address */ - if (ret == E2DBG_VSYSCALL_RETADDR) - name = "KERNEL VSYSCALL PAGE : one function missing"; - else if (ret == E2DBG_SIGTRAMP_RETADDR) - name = "KERNEL SIGNAL TRAMPOLINE"; - - /* Print the current level frame */ - if (off) - snprintf(logbuf, BUFSIZ - 1, " [%02d] " XFMT " in " XFMT - " <%s + " UFMT ">\n", i, (eresi_Addr) ret, ret - off, name, off); - - else - snprintf(logbuf, BUFSIZ - 1, " [%02d] "XFMT" in "XFMT" <%s>\n", i, - (eresi_Addr) ret, ret, name); - e2dbg_output(logbuf); - - /* Call the nextfp hook */ - frame = e2dbg_nextfp(world.curjob->curfile, (eresi_Addr) frame); - i++; - } - - e2dbg_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* Backtrace command */ -int cmd_bt() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!elfsh_is_debug_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not in dynamic or debugger mode", -1); - if (e2dbgworld.curthread == NULL || e2dbgworld.curthread->context == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current thread context available", -1); - e2dbg_output(" .:: Backtrace ::. \n"); - ret = e2dbg_bt(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/breakpoints.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/breakpoints.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/breakpoints.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/breakpoints.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,453 +0,0 @@ -/* -** breakpoints.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 mayhem -** -** $Id: breakpoints.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Simple shared flags for watch/breakpoints */ -static u_char watchflag; - - - -/** - * Add a breakpoint - */ -int elfsh_bp_add(hash_t *bps, - elfshobj_t *file, - char *resolv, - eresi_Addr addr, - u_char flags) -{ - static int lastbpid = 1; - elfshbp_t *bp; - char tmp[32]; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || addr == 0 || bps == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Breakpoints handlers must be initialized */ - elfsh_setup_hooks(); - XALLOC(__FILE__, __FUNCTION__, __LINE__,bp , sizeof(elfshbp_t), (-1)); - bp->obj = file; - bp->type = INSTR; - bp->addr = addr; - bp->symname = strdup(resolv); - - bp->flags = flags; - snprintf(tmp, 32, XFMT, addr); - if (hash_get(bps, tmp)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint already exist", -1); - - /* Call the architecture dependent hook for breakpoints */ - ret = e2dbg_setbreak(file, bp); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint insertion failed", (-1)); - - /* Add new breakpoint to hash table */ - bp->id = lastbpid++; - hash_add(bps, strdup(tmp), bp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Add a breakpoint without using a script command */ -int e2dbg_breakpoint_add(eresi_Addr addr, u_char flags) -{ - int err; - char buf[BUFSIZ]; - char *name; - elfsh_SAddr off; - elfshobj_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Resolve source file */ - file = e2dbg_get_parent_object(addr); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot resolve parent file for bp", -1); - - /* Resolve breakpoint address */ - name = revm_resolve(file, addr, &off); - if (off) - snprintf(buf, BUFSIZ, "<%s + " DFMT ">", name, off); - else - snprintf(buf, BUFSIZ, "<%s>", name); - - /* Really put the breakpoint */ - err = elfsh_bp_add(&e2dbgworld.bp, file, buf, addr, flags); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add breakpoint", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Return 1 if the breakpoint is a watchpoint */ -int e2dbg_is_watchpoint(elfshbp_t *b) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - b && b->flags & ELFSH_BP_WATCH); -} - - - - - -/* Find breakpoint by ID */ -elfshbp_t *e2dbg_breakpoint_from_id(uint32_t bpid) -{ - elfshbp_t *cur; - int index; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - keys = hash_get_keys(&e2dbgworld.bp, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.bp, keys[index]); - if (cur->id == bpid) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - cur); - } - hash_free_keys(keys); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find breakpoing by ID", NULL); -} - - - -/* Find a breakpoint by various ways */ -elfshbp_t *e2dbg_breakpoint_lookup(char *name) -{ - eresi_Addr addr; - elfsh_Sym *sym; - elfshbp_t *bp; - uint16_t bpid; - char straddr[32]; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bp = NULL; - - /* Lookup by vaddr */ - if (IS_VADDR(name)) - { - - if (sscanf(name + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", - NULL); - } - - /* Try to lookup by ID */ - else if (revm_isnbr(name)) - { - bpid = atoi(name); - bp = e2dbg_breakpoint_from_id(bpid); - if (!bp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid breakpoint ID", NULL); - } - - /* Resolve symbol */ - /* Sometimes we fix symbols on the disk only */ - /* This avoid a mprotect */ - else - { - sym = elfsh_get_metasym_by_name(world.curjob->curfile, - name); - if (!sym || !sym->st_value) - { - elfsh_toggle_mode(); - sym = elfsh_get_metasym_by_name(world.curjob->curfile, - name); - elfsh_toggle_mode(); - } - if (!sym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No symbol by that name in the current file", - NULL); - - if (!sym->st_value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested symbol address unknown", - NULL); - addr = sym->st_value; - } - - /* Get the breakpoint */ - if (!bp) - { - snprintf(straddr, sizeof(straddr), XFMT, addr); - bp = hash_get(&e2dbgworld.bp, straddr); - if (!bp) - { - snprintf(logbuf, BUFSIZ, - "\n [!] No breakpoint set at addr " AFMT " \n\n", addr); - e2dbg_output(logbuf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No breakpoint at this address", NULL); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, bp); -} - - - - - -/* Find the correct location for a breakpoint. Avoid putting breakpoints - on plt entries when possible */ -eresi_Addr e2dbg_breakpoint_find_addr(char *str) -{ - elfsh_Sym *sym; - elfsh_Sym *bsym; - elfshsect_t *sect; - elfshobj_t *parent; - char **keys; - int keynbr; - int index; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - sym = bsym = NULL; - - /* Sometimes we fix symbols on the disk : we avoid mprotect */ - /* Only return success early if not a plt symbol */ - keys = NULL; - parent = world.curjob->curfile; - sym = elfsh_get_metasym_by_name(parent, str); - if (!sym || !sym->st_value) - { - elfsh_toggle_mode(); - sym = elfsh_get_metasym_by_name(parent, str); - elfsh_toggle_mode(); - } - - if (sym && parent->hdr->e_type == ET_DYN) - sym->st_value += parent->rhdr.base; - - if (sym && sym->st_value) - { - sect = elfsh_get_parent_section(parent, sym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - goto end; - } - - /* Try to look in other objects */ - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - - for (index = 0; index < keynbr; index++) - { - if (strstr(keys[index], E2DBG_ARGV0)) - continue; - - parent = hash_get(&world.curjob->loaded, keys[index]); - bsym = elfsh_get_metasym_by_name(parent, str); - if (!bsym || !bsym->st_value) - { - elfsh_toggle_mode(); - bsym = elfsh_get_metasym_by_name(parent, str); - elfsh_toggle_mode(); - if (bsym && bsym->st_value) - { - sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - { - sym = bsym; - if (strstr(parent->name, "libc.so")) - goto end; - } - if (!sym) - sym = bsym; - } - } - else - { - sect = elfsh_get_parent_section(parent, bsym->st_value, NULL); - if (!elfsh_is_plt(parent, sect)) - { - sym = bsym; - if (strstr(parent->name, "libc.so")) - goto end; - } - if (!sym) - sym = bsym; - } - -#if __DEBUG_BP__ - printf("BPSym after %-30s = %08X \n", parent->name, (eresi_Addr) sym); -#endif - - } - - /* Return error or success, dont forget to free the keys */ - end: - if (keys) - hash_free_keys(keys); - - if (!sym || !sym->st_value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No symbol by that name in the current file", 0); - addr = sym->st_value; - if (elfsh_get_objtype(parent->hdr) == ET_DYN) - { -#if __DEBUG_BP__ - printf(" [*] Adding base addr %08X \n", parent->rhdr.base); -#endif - addr += parent->rhdr.base; - } - -#if __DEBUG_BP__ - printf(" [*] Will set breakpoint on %08X (parent = %s) \n", - addr, parent->name); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addr); -} - - - - -/* Breakpoint command */ -int cmd_bp() -{ - char *str; - int ret; - eresi_Addr addr; - char logbuf[BUFSIZ]; - int idx; - int index; - elfsh_SAddr off = 0; - char *name; - elfshbp_t *cur; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* build argc */ - for (idx = 0; world.curjob->curcmd->param[idx] != NULL; idx++); - str = revm_lookup_string(world.curjob->curcmd->param[0]); - - fprintf(stderr, "Putting breakpoint on %s \n", str); - - /* Select subcommand */ - switch (idx) - { - - /* List breakpoints */ - case 0: - e2dbg_output(" .:: Breakpoints & Watchpoints ::.\n\n"); - keys = hash_get_keys(&e2dbgworld.bp, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.bp, keys[index]); - name = revm_resolve(world.curjob->curfile, - (eresi_Addr) cur->addr, &off); - if (off) - snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s + " UFMT ">\n", - (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), - cur->id, cur->addr, name, off); - else - snprintf(logbuf, BUFSIZ, " %c [%02u] " XFMT " <%s>\n", - (e2dbg_is_watchpoint(cur) ? 'W' : 'B'), - cur->id, cur->addr, name); - e2dbg_output(logbuf); - } - hash_free_keys(keys); - if (!index) - e2dbg_output(" [*] No breakpoints\n"); - e2dbg_output("\n"); - break; - - /* Supply a new breakpoint */ - case 1: - if (!elfsh_is_debug_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not in dynamic or debugger mode", -1); - if (!str || !(*str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Break on a supplied virtual address */ - if (IS_VADDR(str)) - { - if (sscanf(str + 2, AFMT, &addr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", (-1)); - } - - /* Resolve first a function name */ - else - { - addr = e2dbg_breakpoint_find_addr(str); - if (addr == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested symbol address unknown", -1); - } - - /* Add the breakpoint */ - ret = e2dbg_breakpoint_add(addr, watchflag); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint insertion failed\n", (-1)); - if (ret >= 0) - { - name = revm_resolve(world.curjob->curfile, addr, &off); - if (!off) - snprintf(logbuf, BUFSIZ - 1, - " [*] %spoint added at <%s> (" XFMT ")\n\n", - (watchflag ? "Watch" : "Break"), name, addr); - else - snprintf(logbuf, BUFSIZ - 1, - " [*] %spoint added at <%s + " UFMT "> (" XFMT ")\n\n", - (watchflag ? "Watch" : "Break"), name, off, addr); - e2dbg_output(logbuf); - } - break; - - /* Wrong command syntax */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong arg number", (-1)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/* Watchpoint command */ -int cmd_watch() -{ - int err; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - watchflag = 1; - err = cmd_bp(); - watchflag = 0; - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to install watchpoint", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (err)); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/dbghooks.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbghooks.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/dbghooks.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbghooks.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1035 +0,0 @@ -/* -** vmhooks.c for e2dbg in the ELF shell framework -** -** The interface hooking system -** -** Those hooks stay in the debugger and not in libelfsh. -** -** Started Sat Sep 24 07:17:33 2005 jfv -** $Id: dbghooks.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libe2dbg.h" - - -/* Void handlers for the 2 hooks */ -void e2dbg_default_getregs() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -void e2dbg_default_setregs() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Error handler by default for them */ -eresi_Addr* e2dbg_default_getpc() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETPC unimplemented on this architecture", NULL); -} - -eresi_Addr* e2dbg_default_getfp() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETFP unimplemented on this architecture", NULL); -} - -void e2dbg_default_setstep() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_RERR(__FILE__, __FUNCTION__, __LINE__, - "SETSTEP unimplemented on this architecture"); -} - -void e2dbg_default_resetstep() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_RERR(__FILE__, __FUNCTION__, __LINE__, - "RESETSTEP unimplemented on this architecture"); -} - -eresi_Addr e2dbg_default_nextfphandler(eresi_Addr a) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -eresi_Addr e2dbg_default_getrethandler(eresi_Addr a) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -int e2dbg_default_breakhandler(elfshobj_t *null, - elfshbp_t *null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - - -/* Register a next frame-pointer handler */ -int e2dbg_register_nextfphook(u_char archtype, u_char hosttype, - u_char ostype, void *fct) -{ - vector_t *nextfp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - nextfp = aspect_vector_get(E2DBG_HOOK_NEXTFP); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - //hook_nextfp[archtype][hosttype][ostype] = fct; - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(nextfp, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Register a next return-addr handler */ -int e2dbg_register_getrethook(u_char archtype, u_char hosttype, - u_char ostype, void *fct) -{ - vector_t *getret; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getret = aspect_vector_get(E2DBG_HOOK_GETRET); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(getret, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an SETREGS injection handler */ -int e2dbg_register_sregshook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *setregs; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - setregs = aspect_vector_get(E2DBG_HOOK_SETREGS); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(setregs, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an SETREGS injection handler */ -int e2dbg_register_gregshook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *getregs; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getregs = aspect_vector_get(E2DBG_HOOK_GETREGS); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(getregs, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an GETPC injection handler */ -int e2dbg_register_getpchook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *getpc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getpc = aspect_vector_get(E2DBG_HOOK_GETPC); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(getpc, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an GETPC injection handler */ -int e2dbg_register_getfphook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *getfp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getfp = aspect_vector_get(E2DBG_HOOK_GETFP); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(getfp, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an SETSTEP injection handler */ -int e2dbg_register_setstephook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *setstep; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - setstep = aspect_vector_get(E2DBG_HOOK_SETSTEP); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(setstep, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Register an RESETSTEP injection handler */ -int e2dbg_register_resetstephook(u_char archtype, u_char hosttype, u_char ostype, - void *fct) -{ - vector_t *resetstep; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - resetstep = aspect_vector_get(E2DBG_HOOK_RESETSTEP); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(resetstep, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register a breakpoint redirection handler - */ -int e2dbg_register_breakhook(u_char archtype, u_char hosttype, - u_char ostype, void *fct) -{ - vector_t *breakp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - breakp = aspect_vector_get(E2DBG_HOOK_BREAK); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (hosttype >= E2DBG_HOSTNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Host type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - aspect_vectors_insert(breakp, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* Initialize libe2dbg.hook vectors */ -static int e2dbg_register_vectors() -{ - u_int *dims; - char **strdims; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* All hooks have the same dimensions here */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 4 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 4 * sizeof(char *), -1); - dims[0] = ELFSH_ARCHNUM; - dims[1] = E2DBG_HOSTNUM; - dims[2] = ELFSH_OSNUM; - strdims[0] = "ARCHTYPE"; - strdims[1] = "HOSTYPE"; - strdims[2] = "OSTYPE"; - - /* Initialize debugger vectors */ - aspect_register_vector(E2DBG_HOOK_GETREGS, - e2dbg_default_getregs, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_SETREGS, - e2dbg_default_setregs, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_GETPC, - e2dbg_default_getpc, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_SETSTEP, - e2dbg_default_setstep, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_RESETSTEP, - e2dbg_default_resetstep, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_GETFP, - e2dbg_default_getfp, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_NEXTFP, - e2dbg_default_nextfphandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_GETRET, - e2dbg_default_getrethandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(E2DBG_HOOK_BREAK, - e2dbg_default_breakhandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Setup internal VM hooks */ -void e2dbg_setup_hooks() -{ - static int done = 0; - - /* Check if already initialized */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (done) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - aspect_init(); - e2dbg_register_vectors(); - - /* Initialize vectors */ - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_get_regvars_ia32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_get_regvars_ia32_sysv); - e2dbg_register_gregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_get_regvars_ia32_sysv); - - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_set_regvars_ia32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_set_regvars_ia32_sysv); - e2dbg_register_sregshook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_set_regvars_ia32_sysv); - - - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_getpc_sysv_ia32); - e2dbg_register_getpchook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_ia32); - - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_setstep_sysv_ia32); - e2dbg_register_setstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_ia32); - - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_resetstep_sysv_ia32); - e2dbg_register_resetstephook(ELFSH_ARCH_IA32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_ia32); - - - /* For sparc32 */ - - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_get_regvars_sparc32_bsd); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_get_regvars_sparc32_sysv); - e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_get_regvars_sparc32_sysv); - - - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_set_regvars_sparc32_bsd); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_set_regvars_sparc32_sysv); - e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_set_regvars_sparc32_sysv); - - - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_getpc_sysv_sparc32); - e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_sparc32); - - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_setstep_sysv_sparc32); - e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_sparc32); - - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_LINUX, e2dbg_resetstep_sysv_sparc32); - e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, E2DBG_HOST_PROC, - ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_sparc32); - - - /***********************************/ - /* Now nextfp hooks */ - /***********************************/ - - /* Usual nextfp targets for ET_EXEC/ET_DYN on IA32 */ - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_bt_ia32); - e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_bt_ia32); - - /* Now for sparc */ - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); - e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); - - - - /************************************/ - /* Now getfp hooks */ - /***********************************/ - - /* Usual getfp targets for ET_EXEC/ET_DYN on IA32 */ - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); - e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); - - /* Now for sparc */ - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); - e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); - - - /***********************************/ - /* Now register getret hooks */ - /***********************************/ - - /* Usual getret targets for ET_EXEC/IA32 */ - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getret_ia32); - e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getret_ia32); - - /* Now for sparc32 */ - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); - e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); - - /***********************************/ - /* Now register breakpoint hooks */ - /***********************************/ - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_break_ia32); - e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_break_ia32); - - /* Now for sparc */ - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, e2dbg_break_sparc32); - e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, e2dbg_break_sparc32); - - done = 1; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Call the getregs hook */ -int e2dbg_getregs() -{ - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *getregs; - void (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getregs = aspect_vector_get(E2DBG_HOOK_GETREGS); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETREGS handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(getregs, dim); - - /* This hook is non-fatal, we just wont have regs as variables if it fails */ - fct(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Call the setregs hook */ -int e2dbg_setregs() -{ - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *setregs; - void (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - setregs = aspect_vector_get(E2DBG_HOOK_SETREGS); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SETREGS handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(setregs, dim); - - /* This hook is non-fatal, we just wont have modified registers if it fails. */ - fct(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Call the getpc hook */ -eresi_Addr* e2dbg_getpc() -{ - eresi_Addr *pc; - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *getpc; - eresi_Addr *(*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getpc = aspect_vector_get(E2DBG_HOOK_GETPC); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETPC handler unexistant for this ARCH/OS", NULL); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(getpc, dim); - pc = fct(); - if (pc == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get program counter register", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pc); -} - - -/* Call the getfp hook */ -eresi_Addr* e2dbg_getfp() -{ - eresi_Addr *fp; - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *getfp; - eresi_Addr *(*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getfp = aspect_vector_get(E2DBG_HOOK_GETFP); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETPC handler unexistant for this ARCH/OS", NULL); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(getfp, dim); - fp = fct(); - if (fp == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get program counter register", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, fp); -} - - -/* Call the getregs hook */ -int e2dbg_setstep() -{ - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *setstep; - void (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - setstep = aspect_vector_get(E2DBG_HOOK_SETSTEP); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SETSTEP handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(setstep, dim); - fct(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Call the getregs hook */ -int e2dbg_resetstep() -{ - u_char archtype; - u_char hosttype; - u_char ostype; - u_int dim[3]; - vector_t *resetstep; - void (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - resetstep = aspect_vector_get(E2DBG_HOOK_RESETSTEP); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(world.curjob->curfile); - hosttype = elfsh_get_hosttype(world.curjob->curfile); - ostype = elfsh_get_ostype(world.curjob->curfile); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETPC handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(resetstep, dim); - fct(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Call the getregs hook */ -eresi_Addr e2dbg_nextfp(elfshobj_t *file, eresi_Addr addr) -{ - u_char archtype; - u_char hosttype; - u_char ostype; - int ret; - u_int dim[3]; - vector_t *nextfp; - int (*fct)(eresi_Addr addr); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - nextfp = aspect_vector_get(E2DBG_HOOK_NEXTFP); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - hosttype = elfsh_get_hosttype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "BACKTRACE (nextfp) handler unexistant for this ARCH/OS", - -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(nextfp, dim); - ret = fct(addr); - if (ret == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Backtrace handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/* Call the getregs hook */ -eresi_Addr e2dbg_getret(elfshobj_t *file, eresi_Addr addr) -{ - u_char archtype; - u_char hosttype; - u_char ostype; - int ret; - u_int dim[3]; - vector_t *getret; - int (*fct)(eresi_Addr addr); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - getret = aspect_vector_get(E2DBG_HOOK_GETRET); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - hosttype = elfsh_get_hosttype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GETRET handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(getret, dim); - ret = fct(addr); - if (ret == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GetRet handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - - -/** - * Call the breakpoint hook - */ -int e2dbg_setbreak(elfshobj_t *file, elfshbp_t *bp) -{ - vector_t *breakh; - u_char archtype; - u_char hosttype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *file, elfshbp_t *bp); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - breakh = aspect_vector_get(E2DBG_HOOK_BREAK); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - hosttype = elfsh_get_hosttype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - hosttype == E2DBG_HOST_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SETBREAK handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = hosttype; - dim[2] = ostype; - fct = aspect_vectors_select(breakh, dim); - ret = fct(file, bp); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Breakpoint handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/dbg-ia32.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbg-ia32.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/dbg-ia32.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbg-ia32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -/* -** dbg-ia32.c for e2dbg in the ERESI framework -** -** Debugger backend for the IA32 architecture -** -** Those hooks stay in the debugger and not in libelfsh. -** -** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter -** -** Started Sat Sep 24 07:17:33 2005 jfv -** $Id: dbg-ia32.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libe2dbg.h" - - - - - - -/* Regvars handler for the IA32 architecture on BSD */ -void e2dbg_get_regvars_ia32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); - //E2DBG_GETREG(E2DBG_SSPVAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - //E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_get_regvars_ia32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); - E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Regvars handler for the IA32 architecture */ -void e2dbg_set_regvars_ia32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); - //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_set_regvars_ia32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); - E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getpc_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getpc_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getfp_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.mc_ebp); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getfp_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Enable stepping on BSD */ -void e2dbg_setstep_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; -#elif defined(__NetBSD__) - e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Enable stepping on Sys V */ -void e2dbg_setstep_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on Sys V */ -void e2dbg_resetstep_sysv_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(__i386__) && (defined(__linux__) || defined(sun)) - e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on BSD */ -void e2dbg_resetstep_bsd_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) - e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; -#elif defined(__NetBSD__) - e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Get the next frame pointer given the current one - */ -void *e2dbg_bt_ia32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((void *) *(long*) frame)); -} - -/** - * Get the return address giving the current frame pointer - */ -void *e2dbg_getret_ia32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (void *) (*((long *) frame + 1))); -} - - -/** - * Write a breakpoint 0xCC in memory - * One of the 2 breakpoint technique of e2dbg - */ -int e2dbg_break_ia32(elfshobj_t *f, - elfshbp_t *bp) -{ - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] bp->addr %08X \n", bp->addr); -#endif - - bp->savedinstr[0] = *(u_long *) bp->addr; - prot = elfsh_munprotect(f, bp->addr, 4); - if (prot == (-1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after munprotect\n"); -#endif - *(u_char *) bp->addr = 0xCC; -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after write\n"); -#endif - elfsh_mprotect(bp->addr, 4, prot); -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after mprotect\n"); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/dbg-sparc32.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbg-sparc32.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/dbg-sparc32.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dbg-sparc32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ -/* -** dbg-sparc32.c for e2dbg in the ERESI framework -** -** Debugger backend for the SPARC32 architecture -** -** Those hooks stay in the debugger and not in libelfsh. -** -** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter -** -** Started Thu Jun 07 07:17:33 2007 mayhem -** $Id: dbg-sparc32.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libe2dbg.h" - - - - - - -/* Regvars handler for the IA32 architecture on BSD */ -void e2dbg_get_regvars_sparc32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); -#elif defined(SPARC) && defined(__NetBSD__) - //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_get_regvars_sparc32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); - E2DBG_GETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); - E2DBG_GETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); - E2DBG_GETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); - E2DBG_GETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); - E2DBG_GETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); - E2DBG_GETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); - E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); - E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); - E2DBG_GETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); - E2DBG_GETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); - E2DBG_GETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); - E2DBG_GETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); - E2DBG_GETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); - E2DBG_GETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); - E2DBG_GETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); - E2DBG_GETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); - E2DBG_GETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Regvars handler for the IA32 architecture */ -void e2dbg_set_regvars_sparc32_bsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); -#elif defined(SPARC) && defined(__NetBSD__) - //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Regvars handler for the IA32 architecture on SYSV */ -void e2dbg_set_regvars_sparc32_sysv() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); - E2DBG_SETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); - E2DBG_SETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); - E2DBG_SETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); - E2DBG_SETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); - E2DBG_SETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); - E2DBG_SETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); - E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); - E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); - E2DBG_SETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); - E2DBG_SETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); - E2DBG_SETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); - E2DBG_SETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); - E2DBG_SETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); - E2DBG_SETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); - E2DBG_SETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); - E2DBG_SETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); - E2DBG_SETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getpc_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(SPARC) && defined(__NetBSD__) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Get Program Counter register on Sys V */ -eresi_Addr* e2dbg_getpc_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *) &e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - - -/* Get Program Counter register */ -eresi_Addr* e2dbg_getfp_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.mc_ebp); -#elif defined(__NetBSD__) - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Get Program Stack Pointer register on Sys V */ -/* On SPARC, we use SP and not FP in that handler */ -eresi_Addr* e2dbg_getfp_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Enable stepping on BSD */ -void e2dbg_setstep_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; -#elif defined(SPARC) && defined(__NetBSD__) - //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Enable stepping on Sys V */ -void e2dbg_setstep_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Disable stepping on Sys V */ -void e2dbg_resetstep_sysv_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__linux__) || defined(sun)) - //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Disable stepping on BSD */ -void e2dbg_resetstep_bsd_sparc32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) - //e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; -#elif defined(SPARC) && defined(__NetBSD__) - //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; -#endif - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Get the next frame pointer given the current one - */ -void *e2dbg_bt_sparc32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((void *) *(long*) frame + 14)); -} - - -/** - * Get the return address giving the current frame pointer - */ -void *e2dbg_getret_sparc32(void *frame) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!frame) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (void *) (*((long *) frame + 15))); -} - - -/** - * Write a sparc breakpoint in memory - * One of the 2 breakpoint technique of e2dbg - */ -#if !defined(SPARC) -int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) -{ - return (0); -} -#else -int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) -{ - int prot; - unsigned long addr; - unsigned long long addr64; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] bp->addr %016x \n", bp->addr); -#endif - - memcpy(bp->savedinstr, (u_char *) bp->addr, 8); - - prot = elfsh_munprotect(f, bp->addr, 8); - if (prot == (-1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after munprotect\n"); -#endif - - //*(u_long *) bp->addr = 0x91d02001; /* opcode for ta 1 */ - - *((u_long *) bp->addr) = 0x01000000; /* put nop here */ - *((u_long *) bp->addr + 1) = 0x01000000; /* put nop here */ - - addr = (bp->addr & (~7)); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address to be flushed: %016lx \n", addr); -#endif - - /* Testing .... */ - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (0)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (8)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (16)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (0)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (8)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr), - "r" (16)); - - addr64 = 0xffffffff00000000 + addr; - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address64 to be flushed: %016llx \n", addr64); -#endif - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (0)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (8)); - - __asm__ __volatile__("iflush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (16)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (0)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (8)); - - __asm__ __volatile__("flush %0 + %1 \n\t" :: - "r" ((unsigned long) addr64), - "r" (16)); - - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after sleep & write\n"); -#endif - - elfsh_mprotect(bp->addr, 8, prot); - - sleep(2); - -#if __DEBUG_BREAKPOINTS__ - fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after mprotect\n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} -#endif /* defined(SPARC) */ - - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/display.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/display.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/display.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/display.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -/* -** display.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: display.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Print all display commands */ -void e2dbg_display_print() -{ - char buff[BUFSIZ]; - int idx; - int printed; - - listent_t *actual; - elfshbp_t *curbp; - int idx2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Global displays */ - printed = 0; - for (idx = 0; idx < E2DBG_STEPCMD_MAX; idx++) - { - if (!e2dbgworld.displaycmd[idx]) - continue; - if (!printed) - { - e2dbg_output("\n\t .:: e2dbg global displayed commands \n"); - printed = 1; - } - snprintf(buff, BUFSIZ, "\t %u: %s \n", - idx, e2dbgworld.displaycmd[idx]); - e2dbg_output(buff); - } - if (!printed) - e2dbg_output("\n\t .:: e2dbg currently has no global displays \n\n"); - - /* Display breakpoint commands */ - printed = 0; - for (idx = 0; idx < e2dbgworld.bp.size; idx++) - for (actual = e2dbgworld.bp.ent + idx; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - curbp = (elfshbp_t *) actual->data; - for (idx2 = 0; idx2 < 10; idx2++) - if (curbp->cmd[idx2]) - { - if (!printed) - { - snprintf(buff, BUFSIZ, - "\n\t .:: e2dbg display for breakpoint %u [" XFMT "] %s \n", - curbp->id, curbp->addr, curbp->symname); - e2dbg_output(buff); - printed = 1; - } - snprintf(buff, BUFSIZ, "\t %u: %s \n", - idx2, curbp->cmd[idx2]); - e2dbg_output(buff); - } - printed = 0; - } - - e2dbg_output("\n"); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/* Execute all displayed commands for a breakpoint or a step */ -int e2dbg_display(char **cmd, u_int nbr) -{ - int idx; - revmargv_t *cur; - char *str; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (idx = 0; idx < nbr; idx++) - { - fprintf(stderr, "executing display entry %u \n", idx); - if (cmd[idx]) - { - - snprintf(buf, BUFSIZ, - "\t .:: Display %u [%s] result ::. \n", - idx, cmd[idx]); - e2dbg_output(buf); - - /* Register displayed command in the script control flow */ - str = strdup(cmd[idx]); - - if (revm_exec_str(cmd[idx]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Display execrequest failed", -1); - cmd[idx] = str; - - /* Execute displayed command */ - cur = world.curjob->curcmd; - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - if (revm_execmd() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Display execution failed", -1); - world.curjob->curcmd = cur; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Display on breakpoint or step */ -int cmd_display() -{ - elfshbp_t *bp; - char buf[BUFSIZ]; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* No parameter, list displays */ - if (!world.curjob->curcmd->param[0]) - { - e2dbg_display_print(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Add a global display */ - if (!revm_isnbr(world.curjob->curcmd->param[0])) - { - if (e2dbgworld.displaynbr >= E2DBG_STEPCMD_MAX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many global displays", 0); - str = revm_string_get(world.curjob->curcmd->param); - snprintf(buf, BUFSIZ, "\n [*] Adding global display %u [%s] \n\n", - e2dbgworld.displaynbr, str); - e2dbg_output(buf); - e2dbgworld.displaycmd[e2dbgworld.displaynbr++] = str; - } - - /* Add a local display on breakpoint */ - else - { - bp = e2dbg_breakpoint_lookup(world.curjob->curcmd->param[0]); - if (!bp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find specified breakpoint", 0); - if (bp->cmdnbr >= 10) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many local displays", 0); - str = revm_string_get(&world.curjob->curcmd->param[1]); - snprintf(buf, BUFSIZ, "\n [*] Adding display %u [%s] for breakpoint %u " - "[" XFMT "] %s \n\n", bp->cmdnbr, str, - bp->id, bp->addr, bp->symname); - e2dbg_output(buf); - bp->cmd[(int) bp->cmdnbr++] = str; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Delete displays */ -int cmd_undisplay() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/dumpregs.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dumpregs.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/dumpregs.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/dumpregs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* -** dumpregs.c for elfsh -** -** Started on Wed Jul 27 04:08:52 2005 ym -** -** -** $Id: dumpregs.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - - -/* Resolve a register */ -void e2dbg_register_dump(char *name, uint32_t reg) -{ - elfsh_SAddr off; - char *str; - - str = revm_resolve(world.curjob->curfile, reg, &off); - - if (!off) - printf("\t [%s] %08X (%010u) <%s> \n", - name, reg, reg, (str ? str : "unknown")); - else - printf("\t [%s] %08X (%010u) <%s + " UFMT "> \n", - name, reg, reg, str, off); -} - - -/* The register dumping function */ -/* Print the registers state just before entering the breakpoint */ -/* Small BSD patch submitted by Rod */ -int cmd_dumpregs() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e2dbgworld.curthread) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current thread available", (-1)); - if (!e2dbgworld.curthread->context) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No context available", (-1)); - - e2dbg_output(" .:: Registers ::. \n\n"); - -#if defined(__amd64__) && defined(__FreeBSD__) - #error "Register context not filled on FreeBSD / AMD64" -#elif defined(__FreeBSD__) //|| defined(__OpenBSD__) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.mc_ecx); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.mc_edx); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.mc_esi); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.mc_edi); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.mc_esp); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.mc_ebp); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.mc_eip); -#elif defined(__NetBSD__) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); -#elif defined(IRIX) - e2dbg_register_dump("R0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_R0]); - e2dbg_register_dump("AT", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_AT]); - e2dbg_register_dump("V0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V0]); - e2dbg_register_dump("V1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V1]); - e2dbg_register_dump("A0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A0]); - e2dbg_register_dump("A1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A1]); - e2dbg_register_dump("A2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A2]); - e2dbg_register_dump("A3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A3]); - e2dbg_register_dump("A4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A4]); - e2dbg_register_dump("A5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A5]); - e2dbg_register_dump("A6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A6]); - e2dbg_register_dump("A7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A7]); - e2dbg_register_dump("T0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T0]); - e2dbg_register_dump("T1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T1]); - e2dbg_register_dump("T2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T2]); - e2dbg_register_dump("T3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T3]); - e2dbg_register_dump("S0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S0]); - e2dbg_register_dump("S1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S1]); - e2dbg_register_dump("S2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S2]); - e2dbg_register_dump("S3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S3]); - e2dbg_register_dump("S4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S4]); - e2dbg_register_dump("S5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S5]); - e2dbg_register_dump("S6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S6]); - e2dbg_register_dump("S7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S7]); - e2dbg_register_dump("T8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T8]); - e2dbg_register_dump("T9", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T9]); - e2dbg_register_dump("K0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K0]); - e2dbg_register_dump("K1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K1]); - e2dbg_register_dump("GP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_GP]); - e2dbg_register_dump("SP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SP]); - e2dbg_register_dump("S8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S8]); - e2dbg_register_dump("RA", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_RA]); - e2dbg_register_dump("MDLO", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDLO]); - e2dbg_register_dump("MDHI", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDHI]); - e2dbg_register_dump("EPC", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_EPC]); - e2dbg_register_dump("SR", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SR]); -#elif defined(__i386__) && !(defined(__OpenBSD__)) - e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); - e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); - e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); - e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); - e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); - e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); - e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); - e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); - e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); -#endif - - printf("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -## -## Makefile for common (user/kernel code) parts of libe2dbg in the ERESI framework -## -## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id -## - -include ../../config.h - -SRC = backtrace.c breakpoints.c display.c mode.c stack.c \ - step.c dumpregs.c dbghooks.c mutex.c dbg-ia32.c dbg-sparc32.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ - -I../../libelfsh/include/ -I../../libdump/include/ \ - -I../../libasm/include/ -I../../libstderesi/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libaspect/include -I../../librevm/include/ \ - -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINCINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI32 - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ - -I../../libelfsh/include/ -I../../libdump/include/ \ - -I../../libasm/include/ -I../../libstderesi/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libaspect/include -I../../librevm/include/ \ - -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI64 - -all : all32 all64 - -all32 : ${OBJ32} - -all64 : ${OBJ64} - -clean : - @$(RM) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -fclean : clean - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/mode.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/mode.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/mode.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/mode.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** mode.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: mode.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Change between static (ondisk) and dynamic (memory) mode */ -int cmd_mode() -{ - char *param; - char buf[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - param = world.curjob->curcmd->param[0]; - if (!param) - { - if (elfsh_is_static_mode()) - param = "STATIC"; - else if (elfsh_is_debug_mode()) - param = "DYNAMIC"; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown e2dbg mode", -1); - snprintf(buf, sizeof(buf), " [*] e2dbg is in %s MODE \n\n", param); - e2dbg_output(buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (*param == 's' || *param == 'S') - { - elfsh_set_static_mode(); - e2dbg_output(" [*] e2dbg is now in STATIC mode\n\n"); - } - else if (*param == 'd' || *param == 'D') - { - if (world.curjob) - { - if (world.curjob->curfile) - if (!world.curjob->curfile->linkmap && !world.curjob->curfile->rhdr.base) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't switch to dynamic" - " mode on not mapped file.", -1); - } - elfsh_set_debug_mode(); - e2dbg_output(" [*] e2dbg is now in DYNAMIC mode\n\n"); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown mode for E2DBG", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/mutex.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/mutex.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/mutex.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/mutex.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** mutex.c for e2dbg -** -** The debugger needs mutexes inside signal handlers so we do not use pthread mutexes -** -** Last update Wed Oct 11 18:22:59 2005 jfv -** -** $Id: mutex.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - - -/* Mutex internal API */ -int e2dbg_mutex_init(elfshmutex_t *m) -{ - *m = E2DBG_MUTEX_UNLOCKED; - return (0); -} - -/* This is not really real-time for now */ -int e2dbg_mutex_lock(elfshmutex_t *m) -{ - while (*m == E2DBG_MUTEX_LOCKED) - { - if (e2dbgworld.exited) - _exit(0); - usleep(200); - } - *m = E2DBG_MUTEX_LOCKED; - return (0); -} - -/* Return an error if already unlocked */ -int e2dbg_mutex_unlock(elfshmutex_t *m) -{ - if (e2dbgworld.exited) - _exit(0); - if (*m == E2DBG_MUTEX_UNLOCKED) - return (-1); - *m = E2DBG_MUTEX_UNLOCKED; - return (0); -} diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/stack.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/stack.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/stack.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/stack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/* -** stack.c for e2dbg -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: stack.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - - -/* Symbol matching on the stack content. Always useful */ -int e2dbg_stack_dump(uint32_t size, eresi_Addr start) -{ - long *i; - char logbuf[BUFSIZ]; - char *name; - elfsh_SAddr off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - e2dbg_output(" .:: Stack ::.\n"); - - /* Just a simple loop that dump resolved stack content */ - for (i = (long *) start; i < (long *) start + size; i++) - { - if ((eresi_Addr) i >= E2DBG_KERNELBASE) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot dump anymore : end of stack", -1); - - name = revm_resolve(world.curjob->curfile, *i, &off); - if (!name) - name = "?"; - if (off) - snprintf(logbuf, BUFSIZ - 1, " " XFMT " " XFMT " <%s + " DFMT "> \n", - (eresi_Addr) i, (eresi_Addr) *i, name, off); - else - snprintf(logbuf, BUFSIZ - 1, " " XFMT " " XFMT " <%s> \n", - (eresi_Addr) i, (eresi_Addr) *i, name); - e2dbg_output(logbuf); - } - e2dbg_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Stack display with symbols */ -int cmd_stack() -{ - char *param; - eresi_Addr size; - revmobj_t *ssp; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (!elfsh_is_debug_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command only available in e2dbg", (-1)); - param = world.curjob->curcmd->param[0]; - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - - param = revm_lookup_string(param); - expr = revm_expr_get(E2DBG_SSP_VAR); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No saved SP", -1); - ssp = expr->value; - - /* Dump debuggee stack */ - if (revm_isnbr(param)) - { - if (sscanf(param, UFMT, &size) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - e2dbg_stack_dump(size, ssp->immed_val.ent)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); -} - - - - -/* Debugger stack display with symbols */ -int cmd_dbgstack() -{ - char *param; - eresi_Addr size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (!elfsh_is_debug_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command only available in e2dbg", (-1)); - param = world.curjob->curcmd->param[0]; - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - - param = revm_lookup_string(param); - - /* Dump debugger stack */ - if (revm_isnbr(param)) - { - if (sscanf(param, UFMT, &size) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - e2dbg_stack_dump(size, (eresi_Addr) ¶m)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); -} - diff -Nru eresi-0.8a25/libe2dbg/common/.svn/text-base/step.c.svn-base eresi-0.0.20110516/libe2dbg/common/.svn/text-base/step.c.svn-base --- eresi-0.8a25/libe2dbg/common/.svn/text-base/step.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/common/.svn/text-base/step.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* -** delete.c for e2dbg -** -** Delete breakpoints -** -** Started on Tue Aug 16 09:38:03 2005 jfv -** -** $Id: step.c,v 1.1 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libe2dbg.h" - - -/* Perform stepping */ -int e2dbg_step() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Checking stepping flag in the thread structure */ - if (e2dbgworld.curthread->step) - { - if (e2dbg_resetstep() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to disable stepping", -1); - e2dbg_output("\n [*] Disabled stepping\n\n"); - e2dbgworld.curthread->step = 0; - e2dbgworld.curthread->count = E2DBG_BREAK_NONE; - e2dbgworld.curthread->was_step = 1; - } - - /* Disable stepping and continue */ - else - { - if (e2dbg_setstep() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to enable stepping", -1); - e2dbg_output("\n [*] Enabled stepping \n\n"); - e2dbgworld.curthread->step = 1; - e2dbg_setregs(); - if (e2dbgworld.stoppedthread->tid != e2dbgworld.curthread->tid) - e2dbgworld.curthread = e2dbgworld.stoppedthread; - e2dbg_thread_contall(); - world.curjob->curfile->running = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Step command */ -int cmd_step() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retry: - if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) - { - if (e2dbgworld.sourcing) - goto retry; - else - printf("wasnt sourcing ... existing \n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You must be in a SIGTRAP handler to step", -1); - } - - ret = e2dbg_step(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/* Step-trace command */ -int cmd_itrace() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retry: - if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) - { - if (e2dbgworld.sourcing) - goto retry; - else - printf("wasnt sourcing ... existing \n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You must be in a SIGTRAP handler to step", -1); - } - - /* Enable or disable trace flag */ - if (e2dbgworld.curthread->trace) - e2dbgworld.curthread->trace = 0; - else - e2dbgworld.curthread->trace = 1; - ret = e2dbg_step(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libe2dbg/include/libe2dbg.h eresi-0.0.20110516/libe2dbg/include/libe2dbg.h --- eresi-0.8a25/libe2dbg/include/libe2dbg.h 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/include/libe2dbg.h 2011-05-16 11:35:06.000000000 +0000 @@ -1,25 +1,36 @@ -/* -** -** libe2dbg.h for The Embedded ELF debugger -** -** Started on Sun 05 Jun 2005 17:54:01 jfv -** -** -** $Id: libe2dbg.h,v 1.32 2007-12-06 05:11:58 may Exp $ -** -*/ +/** + * @defgroup libe2dbg libe2dbg: The Embedded ERESI debugger library. + * @ingroup e2dbg + */ + +/** + * @file libe2dbg/include/libe2dbg.h + * @brief The Embedded ERESI debugger header file. + * @ingroup libe2dbg + * + * Started on Sun 05 Jun 2005 17:54:01 jfv + * $Id: libe2dbg.h 1440 2010-12-29 02:22:03Z may $ + */ #ifndef __E2DBG_H__ #define __E2DBG_H__ +#define _GNU_SOURCE + #if defined(__OpenBSD__) #include -/** - * environ is not defined in unistd.h - */ + +/* Environ is not defined in unistd.h */ extern char **environ; #endif + #include + +#if defined(__linux__) +#include +#endif + #include + #include "revm.h" #include "aproxy.h" #include "libstderesi.h" @@ -32,18 +43,23 @@ #include #endif -#define __DEBUG_E2DBG__ 0 -#define __DEBUG_BP__ 0 -#define __DEBUG_EMALLOC__ 0 -#define __DEBUG_LINKMAP__ 0 -#define __DEBUG_THREADS__ 0 +#define _GNU_SOURCE +#include + +#define __DEBUG_E2DBG__ FALSE +#define __DEBUG_BP__ FALSE +#define __DEBUG_EMALLOC__ FALSE +#define __DEBUG_LINKMAP__ FALSE +#define __DEBUG_THREADS__ FALSE #define E2DBG_DYNAMIC_LINKMAP ((elfshlinkmap_t *) 1) +#define E2DBG_ABSENT_LINKMAP ((elfshlinkmap_t *) 2) #define E2DBG_PROFILER_BUFLEN 256 #define E2DBG_CONFIG ".e2dbgrc" #define E2DBG_HOOK_GETREGS "hook_getregs" #define E2DBG_HOOK_SETREGS "hook_setregs" +#define E2DBG_HOOK_PRINTREGS "hook_printregs" #define E2DBG_HOOK_GETPC "hook_getpc" #define E2DBG_HOOK_SETSTEP "hook_setstep" #define E2DBG_HOOK_RESETSTEP "hook_resetstep" @@ -51,6 +67,7 @@ #define E2DBG_HOOK_NEXTFP "hook_nextfp" #define E2DBG_HOOK_GETRET "hook_getret" #define E2DBG_HOOK_BREAK "hook_setbreak" +#define E2DBG_HOOK_DELBREAK "hook_delbreak" /* Kernel related defines */ #define E2DBG_VSYSCALL_RETADDR (0xFFFFE420) @@ -58,20 +75,20 @@ #define E2DBG_KERNELBASE ((eresi_Addr) 0xC0000000) /* Generic register names */ -#define E2DBG_SSP_VAR "ssp" /* Saved stack ptr */ -#define E2DBG_SP_VAR "sp" -#define E2DBG_FP_VAR "fp" -#define E2DBG_PC_VAR "pc" +#define E2DBG_SSP_VAR "$ssp" /* Saved stack ptr */ +#define E2DBG_SP_VAR "$sp" +#define E2DBG_FP_VAR "$fp" +#define E2DBG_PC_VAR "$pc" /* IA32 registers names */ -#define E2DBG_EAX_VAR "eax" -#define E2DBG_EBX_VAR "ebx" -#define E2DBG_ECX_VAR "ecx" -#define E2DBG_EDX_VAR "edx" -#define E2DBG_ESI_VAR "esi" -#define E2DBG_EDI_VAR "edi" +#define E2DBG_EAX_VAR "$eax" +#define E2DBG_EBX_VAR "$ebx" +#define E2DBG_ECX_VAR "$ecx" +#define E2DBG_EDX_VAR "$edx" +#define E2DBG_ESI_VAR "$esi" +#define E2DBG_EDI_VAR "$edi" -/* ia32 under solaris */ +/* IA32 under solaris */ #if (defined(__i386) && defined(sun)) #define REG_UESP UESP #define REG_EIP EIP @@ -87,24 +104,48 @@ #endif /* SPARC registers name */ -#define E2DBG_TSTATE_VAR "tstate" -#define E2DBG_NPC_VAR "npc" -#define E2DBG_Y_VAR "y" -#define E2DBG_G1_VAR "g1" -#define E2DBG_G2_VAR "g2" -#define E2DBG_G3_VAR "g3" -#define E2DBG_G4_VAR "g4" -#define E2DBG_G5_VAR "g5" -#define E2DBG_G6_VAR "g6" -#define E2DBG_G7_VAR "g7" -#define E2DBG_O0_VAR "o0" -#define E2DBG_O1_VAR "o1" -#define E2DBG_O2_VAR "o2" -#define E2DBG_O3_VAR "o3" -#define E2DBG_O4_VAR "o4" -#define E2DBG_O5_VAR "o5" -#define E2DBG_O6_VAR "o6" -#define E2DBG_O7_VAR "o7" +#define E2DBG_TSTATE_VAR "$tstate" +#define E2DBG_NPC_VAR "$npc" +#define E2DBG_Y_VAR "$y" +#define E2DBG_G1_VAR "$g1" +#define E2DBG_G2_VAR "$g2" +#define E2DBG_G3_VAR "$g3" +#define E2DBG_G4_VAR "$g4" +#define E2DBG_G5_VAR "$g5" +#define E2DBG_G6_VAR "$g6" +#define E2DBG_G7_VAR "$g7" +#define E2DBG_O0_VAR "$o0" +#define E2DBG_O1_VAR "$o1" +#define E2DBG_O2_VAR "$o2" +#define E2DBG_O3_VAR "$o3" +#define E2DBG_O4_VAR "$o4" +#define E2DBG_O5_VAR "$o5" +#define E2DBG_O6_VAR "$o6" +#define E2DBG_O7_VAR "$o7" + +/* AMD64 registers name */ +#define E2DBG_R8_VAR "$r8" +#define E2DBG_R9_VAR "$r9" +#define E2DBG_R10_VAR "$r10" +#define E2DBG_R11_VAR "$r11" +#define E2DBG_R12_VAR "$r12" +#define E2DBG_R13_VAR "$r13" +#define E2DBG_R14_VAR "$r14" +#define E2DBG_R15_VAR "$r15" +#define E2DBG_RDI_VAR "$rdi" +#define E2DBG_RSI_VAR "$rsi" +#define E2DBG_RBP_VAR "$rbp" +#define E2DBG_RBX_VAR "$rbx" +#define E2DBG_RAX_VAR "$rax" +#define E2DBG_RDX_VAR "$rdx" +#define E2DBG_RCX_VAR "$rcx" +#define E2DBG_RSP_VAR "$rsp" +#define E2DBG_RIP_VAR "$rip" +#define E2DBG_EFLAGS_VAR "$eflags" +#define E2DBG_CS_VAR "$cs" +#define E2DBG_GS_VAR "$gs" +#define E2DBG_FS_VAR "$fs" +#define E2DBG_CR2_VAR "$cr2" /* Debugger commands */ @@ -139,6 +180,9 @@ signal(SIGTRAP, SIG_IGN); \ signal(SIGUSR2, SIG_IGN); \ } while (0); + //signal(SIGSEGV, SIG_IGN); + //signal(SIGBUS, SIG_IGN); + #define SETSIG \ do \ @@ -154,7 +198,10 @@ ac.sa_sigaction = e2dbg_thread_sigusr2; \ sigaction(SIGUSR2, &ac, NULL); \ } while (0) - + //ac.sa_sigaction = e2dbg_sigsegv_handler; + //sigaction(SIGSEGV, &ac, NULL); + //ac.sa_sigaction = e2dbg_sigsegv_handler; + //sigaction(SIGBUS, &ac, NULL); // was in SETSIG -> commenting it make the core available // ac.sa_sigaction = e2dbg_sigsegv_handler; @@ -171,7 +218,7 @@ if (!e || !e->value) \ { \ r = revm_create_LONG(1, val); \ - e = revm_expr_create_from_object(r, name); \ + e = revm_expr_create_from_object(r, name, 1); \ } \ else \ e->value->immed_val.ent = val; \ @@ -188,7 +235,7 @@ if (!e || !e->value) \ { \ r = revm_create_LONG(1, val); \ - e = revm_expr_create_from_object(r, name); \ + e = revm_expr_create_from_object(r, name, 1); \ } \ else \ val = e->value->immed_val.ent; \ @@ -207,10 +254,10 @@ { int fd; elfsh_Ehdr e; - elfsh_Off dynoff; - elfsh_Off symoff; - elfsh_Off stroff; - elfsh_Off strsz; + eresi_Off dynoff; + eresi_Off symoff; + eresi_Off stroff; + eresi_Off strsz; } e2dbgobj_t; /* The parameter structure for e2dbg_entry in a dedicated thread */ @@ -301,6 +348,11 @@ char *displaycmd[E2DBG_STEPCMD_MAX]; /* Commands to be executed on step */ u_short displaynbr; /* Number of global display cmd */ + /* Data currently being traced */ + eresi_Addr tracedata[E2DBG_STEPCMD_MAX]; /* Address of traced variables */ + char *tracedstr[E2DBG_STEPCMD_MAX]; /* Strings for traced variables */ + u_short tdatanbr; /* Number of traced variables */ + /* Current debuggee threads information */ elfshbp_t *curbp; /* Current breakpoint if any */ e2dbgthread_t *curthread; /* Currently working thread */ @@ -334,16 +386,22 @@ #endif /* Default hook handler */ +void e2dbg_default_printregs(); void e2dbg_default_getregs(); void e2dbg_default_setregs(); eresi_Addr* e2dbg_default_getpc(); void e2dbg_default_setstep(); void e2dbg_default_resetstep(); +int e2dbg_default_deletebreak_handler(elfshbp_t *bp); void e2dbg_setup_hooks(); +/* User hook handlers */ +int e2dbg_user_hooks_install(void); + /* libe2dbg.hooks */ int e2dbg_getregs(); int e2dbg_setregs(); +int e2dbg_printregs(); eresi_Addr* e2dbg_getpc(); int e2dbg_setstep(); int e2dbg_resetstep(); @@ -351,6 +409,7 @@ eresi_Addr e2dbg_nextfp(elfshobj_t *file, eresi_Addr addr); eresi_Addr* e2dbg_getfp(); int e2dbg_setbreak(elfshobj_t *file, elfshbp_t *bp); +int e2dbg_deletebreak(elfshbp_t *bp); /* Backend for ia32 */ void e2dbg_get_regvars_ia32_bsd(); @@ -368,6 +427,28 @@ void *e2dbg_bt_ia32(void *frame); void *e2dbg_getret_ia32(void *frame); int e2dbg_break_ia32(elfshobj_t *f, elfshbp_t *bp); +int e2dbg_delbreak_user(elfshbp_t *bp); +void e2dbg_print_regvars_ia32_freebsd(); +void e2dbg_print_regvars_ia32_netbsd(); +void e2dbg_print_regvars_ia32_sysv(); +void e2dbg_print_regvars_mips_irix(); + +/* Backend for AMD64 */ +void e2dbg_get_regvars_amd64_bsd(); +void e2dbg_get_regvars_amd64_sysv(); +void e2dbg_set_regvars_amd64_bsd(); +void e2dbg_set_regvars_amd64_sysv(); +eresi_Addr* e2dbg_getpc_bsd_amd64(); +eresi_Addr* e2dbg_getpc_sysv_amd64(); +void e2dbg_setstep_bsd_amd64(); +void e2dbg_setstep_sysv_amd64(); +void e2dbg_resetstep_sysv_amd64(); +void e2dbg_resetstep_bsd_amd64(); +eresi_Addr* e2dbg_getfp_sysv_amd64(); +eresi_Addr* e2dbg_getfp_bsd_amd64(); +void *e2dbg_bt_amd64(void *frame); +void *e2dbg_getret_amd64(void *frame); +int e2dbg_break_amd64(elfshobj_t *f, elfshbp_t *bp); /* Backend for sparc32 */ @@ -390,13 +471,16 @@ /* e2dbg vector API for registration */ int e2dbg_register_sregshook(u_char at, u_char ht, u_char ost, void *f); int e2dbg_register_gregshook(u_char at, u_char ht, u_char ost, void *f); +int e2dbg_register_pregshook(u_char archtype, u_char hosttype, u_char ostype, void *fct); int e2dbg_register_getpchook(u_char at, u_char ht, u_char ost, void *f); int e2dbg_register_setstephook(u_char at, u_char ht, u_char ost, void *f); int e2dbg_register_resetstephook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_nextfphook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_nextfphook(u_char at, u_char ht, u_char ost, void *f); +int e2dbg_register_nextfphook(u_char at, u_char ht, u_char ost, void *(*fct)(void *frame)); int e2dbg_register_getrethook(u_char at, u_char ht, u_char ost, void *f); int e2dbg_register_breakhook(u_char a, u_char o, u_char os, void *fct); +int e2dbg_register_delbreakhook(u_char hosttype, void *fct); +int e2dbg_register_getfphook(u_char archtype, u_char hosttype, + u_char ostype, eresi_Addr *(*fct)(void)); /* More e2dbg API */ char *e2dbg_get_string(char **params); @@ -405,6 +489,7 @@ char *revm_modename_get(); int e2dbg_self(); int e2dbg_kill(int pid, int sig); +int e2dbg_step(); /* Linkmap related API */ int e2dbg_linkmap_load(char *name); @@ -413,11 +498,13 @@ /* breakpoint API */ void e2dbg_generic_breakpoint(int signum, siginfo_t *info, void *context); elfshbp_t *e2dbg_breakpoint_from_id(uint32_t bpid); -int e2dbg_breakpoint_add(eresi_Addr addr, u_char flags); +int e2dbg_breakpoint_add(eresi_Addr addr); int e2dbg_display(char **cmd, u_int nbr); int e2dbg_is_watchpoint(elfshbp_t *b); elfshbp_t *e2dbg_breakpoint_lookup(char *name); eresi_Addr e2dbg_breakpoint_find_addr(char *str); +int elfsh_bp_add(hash_t *bps, elfshobj_t *file, + char *resolv, eresi_Addr addr); /* Stack API */ int e2dbg_bt(); @@ -434,6 +521,8 @@ int e2dbg_setup(char *name); int e2dbg_entry(e2dbgparams_t *); +void e2dbg_register_command(void); +void e2dbg_register_dump(char *name, ureg32 reg); void e2dbg_start_proc(); int e2dbg_output(); @@ -455,7 +544,7 @@ void e2dbg_threads_print(); int e2dbg_thread_stopall(int signum); void e2dbg_thread_contall(); -int e2dbg_curthread_init(); +int e2dbg_curthread_init(void); #if !defined(sun) int pthread_attr_getstack(__const pthread_attr_t *__restrict __attr, diff -Nru eresi-0.8a25/libe2dbg/include/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/include/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/include/.svn/all-wcprops 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libe2dbg/include -END -libe2dbg.h -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libe2dbg/include/libe2dbg.h -END diff -Nru eresi-0.8a25/libe2dbg/include/.svn/entries eresi-0.0.20110516/libe2dbg/include/.svn/entries --- eresi-0.8a25/libe2dbg/include/.svn/entries 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libe2dbg.h -file - - - - -2008-04-06T23:16:29.528126Z -57b2b9dc8502b62f96efba07774a9eb7 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libe2dbg/include/.svn/format eresi-0.0.20110516/libe2dbg/include/.svn/format --- eresi-0.8a25/libe2dbg/include/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/include/.svn/text-base/libe2dbg.h.svn-base eresi-0.0.20110516/libe2dbg/include/.svn/text-base/libe2dbg.h.svn-base --- eresi-0.8a25/libe2dbg/include/.svn/text-base/libe2dbg.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/include/.svn/text-base/libe2dbg.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,491 +0,0 @@ -/* -** -** libe2dbg.h for The Embedded ELF debugger -** -** Started on Sun 05 Jun 2005 17:54:01 jfv -** -** -** $Id: libe2dbg.h,v 1.32 2007-12-06 05:11:58 may Exp $ -** -*/ -#ifndef __E2DBG_H__ - #define __E2DBG_H__ - -#if defined(__OpenBSD__) -#include -/** - * environ is not defined in unistd.h - */ -extern char **environ; -#endif -#include -#include -#include "revm.h" -#include "aproxy.h" -#include "libstderesi.h" - -#if defined(__FreeBSD__) - #include -#endif - -#if defined(sun) - #include -#endif - -#define __DEBUG_E2DBG__ 0 -#define __DEBUG_BP__ 0 -#define __DEBUG_EMALLOC__ 0 -#define __DEBUG_LINKMAP__ 0 -#define __DEBUG_THREADS__ 0 - -#define E2DBG_DYNAMIC_LINKMAP ((elfshlinkmap_t *) 1) -#define E2DBG_PROFILER_BUFLEN 256 - -#define E2DBG_CONFIG ".e2dbgrc" -#define E2DBG_HOOK_GETREGS "hook_getregs" -#define E2DBG_HOOK_SETREGS "hook_setregs" -#define E2DBG_HOOK_GETPC "hook_getpc" -#define E2DBG_HOOK_SETSTEP "hook_setstep" -#define E2DBG_HOOK_RESETSTEP "hook_resetstep" -#define E2DBG_HOOK_GETFP "hook_getfp" -#define E2DBG_HOOK_NEXTFP "hook_nextfp" -#define E2DBG_HOOK_GETRET "hook_getret" -#define E2DBG_HOOK_BREAK "hook_setbreak" - -/* Kernel related defines */ -#define E2DBG_VSYSCALL_RETADDR (0xFFFFE420) -#define E2DBG_SIGTRAMP_RETADDR (0xFFFFE440) -#define E2DBG_KERNELBASE ((eresi_Addr) 0xC0000000) - -/* Generic register names */ -#define E2DBG_SSP_VAR "ssp" /* Saved stack ptr */ -#define E2DBG_SP_VAR "sp" -#define E2DBG_FP_VAR "fp" -#define E2DBG_PC_VAR "pc" - -/* IA32 registers names */ -#define E2DBG_EAX_VAR "eax" -#define E2DBG_EBX_VAR "ebx" -#define E2DBG_ECX_VAR "ecx" -#define E2DBG_EDX_VAR "edx" -#define E2DBG_ESI_VAR "esi" -#define E2DBG_EDI_VAR "edi" - -/* ia32 under solaris */ -#if (defined(__i386) && defined(sun)) -#define REG_UESP UESP -#define REG_EIP EIP -#define REG_EAX EAX -#define REG_EFL EFL -#define REG_ECX ECX -#define REG_EDX EDX -#define REG_EBX EBX -#define REG_ESP ESP -#define REG_EBP EBP -#define REG_ESI ESI -#define REG_EDI EDI -#endif - -/* SPARC registers name */ -#define E2DBG_TSTATE_VAR "tstate" -#define E2DBG_NPC_VAR "npc" -#define E2DBG_Y_VAR "y" -#define E2DBG_G1_VAR "g1" -#define E2DBG_G2_VAR "g2" -#define E2DBG_G3_VAR "g3" -#define E2DBG_G4_VAR "g4" -#define E2DBG_G5_VAR "g5" -#define E2DBG_G6_VAR "g6" -#define E2DBG_G7_VAR "g7" -#define E2DBG_O0_VAR "o0" -#define E2DBG_O1_VAR "o1" -#define E2DBG_O2_VAR "o2" -#define E2DBG_O3_VAR "o3" -#define E2DBG_O4_VAR "o4" -#define E2DBG_O5_VAR "o5" -#define E2DBG_O6_VAR "o6" -#define E2DBG_O7_VAR "o7" - - -/* Debugger commands */ -#define CMD_MODE "mode" -#define CMD_LINKMAP "linkmap" -#define CMD_BT "bt" -#define CMD_BT2 "backtrace" -#define CMD_BP "b" -#define CMD_WATCH "watch" -#define CMD_BP2 "break" -#define CMD_STACK "stack" -#define CMD_DBGSTACK "dbgstack" -#define CMD_DUMPREGS "dumpregs" -#define CMD_STEP "step" -#define CMD_ITRACE "itrace" -#define CMD_START "start" -#define CMD_DELETE "delete" -#define CMD_RUN "run" -#define CMD_DISPLAY "display" -#define CMD_UNDISPLAY "undisplay" -#define CMD_THREADS "threads" - - -/* Signal handling for debugger */ -#define CLRSIG do { \ - struct sigaction ac; \ - \ - memset(&ac, 0x00, sizeof(ac)); \ - ac.sa_flags = SA_SIGINFO; \ - ac.sa_sigaction = e2dbg_internal_sigsegv_handler; \ - signal(SIGINT, SIG_IGN); \ - signal(SIGTRAP, SIG_IGN); \ - signal(SIGUSR2, SIG_IGN); \ -} while (0); - -#define SETSIG \ -do \ -{ \ - struct sigaction ac; \ - \ - memset(&ac, 0x00, sizeof(ac)); \ - ac.sa_flags = SA_SIGINFO | SA_ONSTACK; \ - ac.sa_sigaction = e2dbg_generic_breakpoint; \ - sigaction(SIGTRAP, &ac, NULL); \ - ac.sa_sigaction = e2dbg_sigint_handler; \ - sigaction(SIGINT, &ac, NULL); \ - ac.sa_sigaction = e2dbg_thread_sigusr2; \ - sigaction(SIGUSR2, &ac, NULL); \ -} while (0) - - -// was in SETSIG -> commenting it make the core available -// ac.sa_sigaction = e2dbg_sigsegv_handler; -//sigaction(SIGSEGV, &ac, NULL); - - -/* Create variable from register value */ -#define E2DBG_GETREG(name, val) \ -do \ -{ \ - revmobj_t *r; \ - revmexpr_t *e; \ - e = revm_expr_get(name); \ - if (!e || !e->value) \ - { \ - r = revm_create_LONG(1, val); \ - e = revm_expr_create_from_object(r, name); \ - } \ - else \ - e->value->immed_val.ent = val; \ -} \ -while (0) - -/* Set the register value */ -#define E2DBG_SETREG(name, val) \ -do \ -{ \ - revmobj_t *r; \ - revmexpr_t *e; \ - e = revm_expr_get(name); \ - if (!e || !e->value) \ - { \ - r = revm_create_LONG(1, val); \ - e = revm_expr_create_from_object(r, name); \ - } \ - else \ - val = e->value->immed_val.ent; \ -} \ -while (0) - - - -/* A mutex is just an unsigned char */ -typedef u_char elfshmutex_t; - - -/* The internal object descriptor for e2dbg when resolving - symbols before malloc is available */ -typedef struct s_eobj -{ - int fd; - elfsh_Ehdr e; - elfsh_Off dynoff; - elfsh_Off symoff; - elfsh_Off stroff; - elfsh_Off strsz; -} e2dbgobj_t; - -/* The parameter structure for e2dbg_entry in a dedicated thread */ -typedef struct s_e2dbgparams -{ - char **av; - u_int ac; -} e2dbgparams_t; - - -/* The structure representing a thread */ -typedef struct s_thread -{ - pthread_t tid; /* Key identification of that thread */ - char initial; /* Is this thread the initial one ? */ - -#define E2DBG_THREAD_INIT 0 -#define E2DBG_THREAD_STARTED 1 -#define E2DBG_THREAD_BREAKING 2 -#define E2DBG_THREAD_SIGUSR2 3 -#define E2DBG_THREAD_BREAKUSR2 4 -#define E2DBG_THREAD_STOPPING 5 -#define E2DBG_THREAD_RUNNING 6 -#define E2DBG_THREAD_FINISHED 7 - char state; /* Initiliazing, Running, Finished */ - -#define E2DBG_BREAK_NONE 0 -#define E2DBG_BREAK_HIT 1 -#define E2DBG_BREAK_EXEC 2 -#define E2DBG_BREAK_FINISHED 3 -#define E2DBG_BREAK_MAX 3 - int count; /* State when breakpointing */ - - eresi_Addr past; /* Previous opcode instead of break */ - u_char step; /* Is this thread beeing stepped ? */ - u_char was_step; /* Is this thread was just beeing stepped ? */ - u_char trace; /* Is the thread beeing itraced ? */ - void *(*entry)(void *); /* Entry point */ - pthread_attr_t *attr; /* Thread attributes */ - ucontext_t *context; /* Thread context on signal */ - - time_t stime; /* Creation time */ - time_t etime; /* Ending time */ - - eresi_Addr tlsaddr; /* Address of TLS data */ - unsigned int tlsize; /* Size of TLS data */ - eresi_Addr stackaddr; /* Address of stack */ - unsigned int stacksize; /* Size of stack */ - -} e2dbgthread_t; - - -/* Hold all resolved symbols that we need in pre-malloc stage */ -typedef struct s_e2dbgsyms -{ - eresi_Addr piebase; /* Computed base address for PIE */ - eresi_Addr mallocsym; /* Resolved libc malloc */ - eresi_Addr vallocsym; /* Resolved libc valloc */ - eresi_Addr callocsym; /* Resolved libc calloc */ - eresi_Addr reallocsym; /* Resolved libc realloc */ - eresi_Addr memalignsym; /* Resolved libc memalign*/ - eresi_Addr freesym; /* Resolved libc free */ - eresi_Addr mallochooksym; /* Resolved libc malloc hook */ - eresi_Addr memalignhooksym; /* Resolved libc memalign hook */ - eresi_Addr pthstartupsym; /* Resolved __libc_malloc_pthread_startup */ - eresi_Addr pthreadcreate; /* Resolved pthread_create */ - eresi_Addr pthreadexit; /* Resolved pthread_exit */ - eresi_Addr signal; /* Resolved signal function */ -#if defined(sun) - Link_map *map; /* Linkmap has a different format on solaris */ -#else - elfshlinkmap_t *map; /* Early resolved linkmap */ -#endif -} e2dbgsyms_t; - - -/* This structure contains the internal data of the debugger placed in the VM */ -typedef struct s_e2dbgworld -{ - char preloaded; /* Say if we were preloaded */ - hash_t bp; /* Breakpoints hash table */ - hash_t threads; /* Threads hash table */ - u_char sourcing; /* We are executing a debugger script */ - e2dbgsyms_t syms; /* Resolved symbol informations */ - - /* Display commands memory */ -#define E2DBG_STEPCMD_MAX 50 - char *displaycmd[E2DBG_STEPCMD_MAX]; /* Commands to be executed on step */ - u_short displaynbr; /* Number of global display cmd */ - - /* Current debuggee threads information */ - elfshbp_t *curbp; /* Current breakpoint if any */ - e2dbgthread_t *curthread; /* Currently working thread */ - e2dbgthread_t *stoppedthread; /* Latest stopped thread */ - u_int threadnbr; /* Number of existing threads */ - u_int threadsyncnbr; /* Number of threads with contexts */ - u_int threadgotnbr; /* Number of threads with retreived contexts */ - - /* Synchronization values */ -#define E2DBG_MUTEX_UNLOCKED 0 -#define E2DBG_MUTEX_LOCKED 1 - elfshmutex_t dbgbp; /* The breakpoint handler mutex */ - - /* Exit status */ - int exited; /* Debugger exited */ - int debuggee_exited; /* Debuggee exited */ - int (*real_main)(int argc, char **argv, char **aux); -} e2dbgworld_t; - -/* The Debugger world in the VM */ -extern e2dbgworld_t e2dbgworld; - -/* Some libc extern */ -#if defined(__FreeBSD__) || defined(__NetBSD__) - extern char *__progname; - extern char **environ; -#elif defined(sun) - extern char **environ; -#else - extern char *__progname_full; -#endif - -/* Default hook handler */ -void e2dbg_default_getregs(); -void e2dbg_default_setregs(); -eresi_Addr* e2dbg_default_getpc(); -void e2dbg_default_setstep(); -void e2dbg_default_resetstep(); -void e2dbg_setup_hooks(); - -/* libe2dbg.hooks */ -int e2dbg_getregs(); -int e2dbg_setregs(); -eresi_Addr* e2dbg_getpc(); -int e2dbg_setstep(); -int e2dbg_resetstep(); -eresi_Addr e2dbg_getret(elfshobj_t *file, eresi_Addr addr); -eresi_Addr e2dbg_nextfp(elfshobj_t *file, eresi_Addr addr); -eresi_Addr* e2dbg_getfp(); -int e2dbg_setbreak(elfshobj_t *file, elfshbp_t *bp); - -/* Backend for ia32 */ -void e2dbg_get_regvars_ia32_bsd(); -void e2dbg_get_regvars_ia32_sysv(); -void e2dbg_set_regvars_ia32_bsd(); -void e2dbg_set_regvars_ia32_sysv(); -eresi_Addr* e2dbg_getpc_bsd_ia32(); -eresi_Addr* e2dbg_getpc_sysv_ia32(); -void e2dbg_setstep_bsd_ia32(); -void e2dbg_setstep_sysv_ia32(); -void e2dbg_resetstep_sysv_ia32(); -void e2dbg_resetstep_bsd_ia32(); -eresi_Addr* e2dbg_getfp_sysv_ia32(); -eresi_Addr* e2dbg_getfp_bsd_ia32(); -void *e2dbg_bt_ia32(void *frame); -void *e2dbg_getret_ia32(void *frame); -int e2dbg_break_ia32(elfshobj_t *f, elfshbp_t *bp); - - -/* Backend for sparc32 */ -void e2dbg_get_regvars_sparc32_bsd(); -void e2dbg_get_regvars_sparc32_sysv(); -void e2dbg_set_regvars_sparc32_bsd(); -void e2dbg_set_regvars_sparc32_sysv(); -eresi_Addr* e2dbg_getpc_bsd_sparc32(); -eresi_Addr* e2dbg_getpc_sysv_sparc32(); -eresi_Addr* e2dbg_getfp_bsd_sparc32(); -eresi_Addr* e2dbg_getfp_sysv_sparc32(); -void e2dbg_setstep_bsd_sparc32(); -void e2dbg_setstep_sysv_sparc32(); -void e2dbg_resetstep_sysv_sparc32(); -void e2dbg_resetstep_bsd_sparc32(); -void *e2dbg_bt_sparc32(void *frame); -void *e2dbg_getret_sparc32(void *frame); -int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp); - -/* e2dbg vector API for registration */ -int e2dbg_register_sregshook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_gregshook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_getpchook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_setstephook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_resetstephook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_nextfphook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_nextfphook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_getrethook(u_char at, u_char ht, u_char ost, void *f); -int e2dbg_register_breakhook(u_char a, u_char o, u_char os, void *fct); - -/* More e2dbg API */ -char *e2dbg_get_string(char **params); -int e2dbg_linkmap(elfshobj_t *file); -char *revm_get_prompt(); -char *revm_modename_get(); -int e2dbg_self(); -int e2dbg_kill(int pid, int sig); - -/* Linkmap related API */ -int e2dbg_linkmap_load(char *name); -elfshlinkmap_t* e2dbg_linkmap_getaddr(); - -/* breakpoint API */ -void e2dbg_generic_breakpoint(int signum, siginfo_t *info, void *context); -elfshbp_t *e2dbg_breakpoint_from_id(uint32_t bpid); -int e2dbg_breakpoint_add(eresi_Addr addr, u_char flags); -int e2dbg_display(char **cmd, u_int nbr); -int e2dbg_is_watchpoint(elfshbp_t *b); -elfshbp_t *e2dbg_breakpoint_lookup(char *name); -eresi_Addr e2dbg_breakpoint_find_addr(char *str); - -/* Stack API */ -int e2dbg_bt(); -int e2dbg_stack_dump(uint32_t size, eresi_Addr start); - -/* Mutex API */ -int e2dbg_mutex_init(elfshmutex_t *m); -int e2dbg_mutex_lock(elfshmutex_t *m); -int e2dbg_mutex_unlock(elfshmutex_t *m); - -/* e2dbg main API */ -void e2dbg_init(void) __attribute__ ((constructor)); -void e2dbg_last_init(void) __attribute__ ((constructor)); - -int e2dbg_setup(char *name); -int e2dbg_entry(e2dbgparams_t *); -void e2dbg_start_proc(); -int e2dbg_output(); - -/* Early symbol / parent object resolving API */ -int e2dbg_dlsym_init(); -eresi_Addr e2dbg_dlsym(char *sym2resolve); -elfshobj_t *e2dbg_get_parent_object(eresi_Addr addr); - -/* Signal handling */ -void e2dbg_sigsegv_handler(int signum, siginfo_t *info, void *context); -void e2dbg_internal_sigsegv_handler(int signum, siginfo_t *info, void *pcontext); -void e2dbg_sigint_handler(int signum, siginfo_t *info, void *context); -void e2dbg_sigstop_handler(int signum, siginfo_t *info, void *pcontext); -void e2dbg_sigtrap_handler(int signum, siginfo_t *info, void *context); -void e2dbg_sigusr1_handler(int signum, siginfo_t *info, void *pcontext); -void e2dbg_thread_sigusr2(int signum, siginfo_t *info, void *pcontext); - -/* Thread API */ -void e2dbg_threads_print(); -int e2dbg_thread_stopall(int signum); -void e2dbg_thread_contall(); -int e2dbg_curthread_init(); - -#if !defined(sun) -int pthread_attr_getstack(__const pthread_attr_t *__restrict __attr, - void **__restrict __stackaddr, - size_t *__restrict __stacksize); -#endif - -/* e2dbg commands */ -int cmd_mode(); -int cmd_linkmap(); -int cmd_bt(); -int cmd_stack(); -int cmd_dbgstack(); -int cmd_run(); -int cmd_bp(); -int cmd_watch(); -int cmd_display(); -int cmd_undisplay(); -int cmd_delete(); -int cmd_step(); -int cmd_itrace(); -int cmd_start(); -int cmd_dumpregs(); -int cmd_cont(); -int cmd_threads(); - -/* Undefined on FreeBSD */ -#if defined(__FreeBSD__) -void on_exit(void *exitptr, int param); -#endif - -#endif - diff -Nru eresi-0.8a25/libe2dbg/kernel/buffering.c eresi-0.0.20110516/libe2dbg/kernel/buffering.c --- eresi-0.8a25/libe2dbg/kernel/buffering.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/buffering.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/buffering.c +* @file libe2dbg/kernel/buffering.c * * */ diff -Nru eresi-0.8a25/libe2dbg/kernel/commands.c eresi-0.0.20110516/libe2dbg/kernel/commands.c --- eresi-0.8a25/libe2dbg/kernel/commands.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/commands.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/commands.c +* @file libe2dbg/kernel/commands.c * * */ diff -Nru eresi-0.8a25/libe2dbg/kernel/idt.c eresi-0.0.20110516/libe2dbg/kernel/idt.c --- eresi-0.8a25/libe2dbg/kernel/idt.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/idt.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/buffering.c +* @file libe2dbg/kernel/idt.c * * */ diff -Nru eresi-0.8a25/libe2dbg/kernel/include/ke2dbg-vars.h eresi-0.0.20110516/libe2dbg/kernel/include/ke2dbg-vars.h --- eresi-0.8a25/libe2dbg/kernel/include/ke2dbg-vars.h 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/ke2dbg-vars.h 2011-05-16 11:35:06.000000000 +0000 @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Droids Corporation. * - * $Id: ke2dbg-vars.h,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: ke2dbg-vars.h 1311 2009-01-14 20:36:48Z may $ * */ diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/kernel/include/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/kernel/include/.svn/all-wcprops 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/947/trunk/libe2dbg/kernel/include -END -ke2dbg-syscalls.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/947/trunk/libe2dbg/kernel/include/ke2dbg-syscalls.h -END -ke2dbg.h -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/946/trunk/libe2dbg/kernel/include/ke2dbg.h -END -ke2dbg-font256.h -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/include/ke2dbg-font256.h -END -ke2dbg-config.h -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/include/ke2dbg-config.h -END -ke2dbg-pcidata.h -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/include/ke2dbg-pcidata.h -END -ke2dbg-keyb.h -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/include/ke2dbg-keyb.h -END -ke2dbg-pci.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/include/ke2dbg-pci.h -END -ke2dbg-vars.h -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/924/trunk/libe2dbg/kernel/include/ke2dbg-vars.h -END diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/entries eresi-0.0.20110516/libe2dbg/kernel/include/.svn/entries --- eresi-0.8a25/libe2dbg/kernel/include/.svn/entries 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg/kernel/include -http://svn.eresi-project.org/svn - - - -2008-03-28T09:54:54.348685Z -947 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -ke2dbg-syscalls.h -file - - - - -2008-04-06T23:16:29.114876Z -cfa5dc2efa0ddb3e86dd8a87481719ee -2008-03-28T09:54:54.348685Z -947 -pouik - -ke2dbg.h -file - - - - -2008-04-06T23:16:29.134052Z -501c527a4a0ff563ff948551fa73b551 -2008-03-27T22:53:48.747992Z -946 -may - -ke2dbg-font256.h -file - - - - -2008-04-06T23:16:29.144899Z -b368fff562f7e77410ca8782a35a18f7 -2008-02-16T12:32:28.000000Z -843 -thor - -ke2dbg-config.h -file - - - - -2008-04-06T23:16:29.156680Z -9915178e3cf3f2671b9bb2374c115976 -2008-02-16T12:32:28.000000Z -843 -thor - -ke2dbg-pcidata.h -file - - - - -2008-04-06T23:16:29.168021Z -05c4a7f69abfeaa8384116034a169e8f -2008-02-16T12:32:28.000000Z -843 -thor - -ke2dbg-keyb.h -file - - - - -2008-04-06T23:16:29.178899Z -6e20ad23221880e7b99eea1aae93f123 -2008-02-16T12:32:28.000000Z -843 -thor - -ke2dbg-pci.h -file - - - - -2008-04-06T23:16:29.190650Z -fce10fd7bfd8b84e7727917e646f0d0e -2008-02-16T12:32:28.000000Z -843 -thor - -ke2dbg-vars.h -file - - - - -2008-04-06T23:16:29.202051Z -00d76143d25eb32fa887241f329e4e37 -2008-03-24T13:43:31.172355Z -924 -pouik - diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/format eresi-0.0.20110516/libe2dbg/kernel/include/.svn/format --- eresi-0.8a25/libe2dbg/kernel/include/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-config.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-config.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-config.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-config.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ - -#ifndef CONFIG_H -#define CONFIG_H - -/* _________________________ OS definitions ____________________ */ - -/* FOR WINDOWS */ -/* #define WIN32 */ -/* #define KEYB_INTER 0x51 */ - -/* OR LINUX */ -#ifndef LINUX -#define LINUX -#endif -#define KEYB_INTER 0x21 - -/* OR FREEBSD */ -/* #define FREEBSD */ -/* le reste viendra plus tard... */ - - -/* ________________________ video definitions __________________ */ - -/* CONSOLE MODE */ -#define VIDEO_AA - -/* OR GRAPHIC MODE */ -/* we want a graphic mode */ -/*#define VIDEO_FB */ -/* we want direct hardware writtng */ -/* #define HW_FB */ -/* we want ke2dbg to find automatically the address of the video hardware */ -/* #define AUTO_HW_FB */ - -/* we set a default value... */ -#define SCREEN_ADRESSE 0xF0000000 - - -/* screen dimension (internal hardware dimensions) */ -#define SCREEN_MAX_X 2048 -#define SCREEN_MAX_Y 768 - -/* screen bytes per pixel (internal hardware dimensions) */ -/* #define BYTE_PER_PIXEL_HALF */ -/* #define BYTE_PER_PIXEL_ONE */ -/* #define BYTE_PER_PIXEL_TWO */ -/* #define BYTE_PER_PIXEL_THREE */ -#define BYTE_PER_PIXEL_FOUR - - -/* ____________________________ custom _________________________ */ - -#define DONT_HOOK_KBD - -#endif /* CONFIG_H */ diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-font256.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-font256.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-font256.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-font256.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1537 +0,0 @@ -unsigned char font_data[]={ -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, -0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, -0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, -0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, -0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, -0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, -0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, -0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, -0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, -0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, -0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0xA3, 0x00, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, 0x00, 0xA3, -0x00, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, 0xA3, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0xA3, 0xA3, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, -0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0xA3, 0xA3, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0xA3, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA3, 0xA3, 0xA3, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,490 +0,0 @@ -/* - * - * - * - * - * - */ - -#ifndef KE2DBG_H - #define KE2DBG_H - -#include -#include -#include - -#ifdef FREEBSD - #include - #include -#endif - - -typedef struct _bp_struct -{ - unsigned long address; - unsigned long paddress; - unsigned char hw; - unsigned char value; - unsigned int attrib; -} Bp_struct; - -typedef struct reg_struct -{ - eresi_Addr reg_EDI; - eresi_Addr reg_ESI; - eresi_Addr reg_EBP; - eresi_Addr reg_ESP_; - eresi_Addr reg_EBX; - eresi_Addr reg_EDX; - eresi_Addr reg_ECX; - eresi_Addr reg_EAX; - eresi_Addr reg_ES; - eresi_Addr reg_FS; - eresi_Addr reg_GS; - eresi_Addr reg_DS; - eresi_Addr reg_dummy_ret; - eresi_Addr reg_ERROR; - eresi_Addr reg_EIP; - eresi_Addr reg_CS; - eresi_Addr reg_EFLAG; - eresi_Addr reg_ESP; - eresi_Addr reg_SS; -} Reg_struct; - - -typedef struct tagBITMAPFILEHEADER -{ /* bmfh */ - unsigned int bfSize; - short bfReserved1; - short bfReserved2; - unsigned int bfOffBits; -} BITMAPFILEHEADER; - - -typedef struct tagBITMAPINFOHEADER -{ /* bmih */ - unsigned int biSize; - unsigned int biWidth; - unsigned int biHeight; - short int biPlanes; - short int biBitCount ; - int biCompression; - int biSizeImage; - unsigned int biXPelsPerMeter; - unsigned int biYPelsPerMeter; - int biClrUsed; - int biClrImportant; -} BITMAPINFOHEADER; - - -#define NUM_BREAKPOINTS 20 -#define NUM_HW_BREAKPOINTS 4 -#define HW_MAGIC_VALUE 0x100 - -#define BP_CLASSIC 0x1 -#define BP_ONE_SHOT 0x2 -#define BUFFERMAXCMD 40 - -#define KEYBOARD_PORT_60 0x60 -#define KEYBOARD_PORT_64 0x64 - -#define KBENTER -1 -#define KBF11 -2 -#define KBF12 -3 -#define KBDEL -4 -#define KBCURSORUP -5 -#define KBCURSORDOWN -6 -#define KBLEFTALT -7 -#define KBRIGHTSHIFT -8 -#define KBPAGEUP -9 -#define KBPAGEDOWN -10 -#define KBLEFTSHIFT -11 -#define KBCURSORLEFT -12 -#define KBCURSORRIGHT -13 -#define KBESC -14 -#define KBUP -128 - -#define ke2dbg_toupper(c) ((c) - 0x20 * (((c) >= 'a') && ((c) <= 'z'))) -#define ke2dbg_tolower(c) ((c) + 0x20 * (((c) >= 'A') && ((c) <= 'Z'))) - -#define ke2dbg_screen_dump_size (80 * 25 * 2) -#define SCREEN_LINE 40 -#define BITMAP_ID 0x4d42 -#define BUFFERMAXLINES 80 - -#define PAG4M 2 -#define EXISTE 1 -#define NOEXISTE 0 - -#ifndef NULL -#define NULL 0 -#endif - -/* Keyboard defines */ -#define CTRL_KEY 0x1d -#define F_KEY 0x21 - -// commands -#define READ_CONTROLLER 0x20 -#define WRITE_CONTROLLER 0x60 - -// command bytes -#define SET_LEDS 0xED -#define KEY_RESET 0xFF - -// responses from keyboard -#define KEY_ACK 0xFA // ack -#define KEY_AGAIN 0xFE // send again - -// status register bits -#define IBUFFER_FULL 0x02 -#define OBUFFER_FULL 0x01 - -// flags for keyboard LEDS -#define SCROLL_LOCK_BIT (0x01 << 0) -#define NUMLOCK_BIT (0x01 << 1) -#define CAPS_LOCK_BIT (0x01 << 2) - - -int ke2dbg_insert_bp(unsigned int, unsigned int, unsigned int ); -int ke2dbg_is_breakpoint(unsigned char *); -int ke2dbg_is_hw_breakpoint(unsigned char* ); -int ke2dbg_erase_breakpoint(unsigned int ); -int ke2dbg_pass_breakpoint(unsigned int ); -int ke2dbg_spawn_breakpoint(unsigned int ); -void ke2dbg_display_breakpoints(void); -unsigned char ke2dbg_true_byte_bp(unsigned char *); - -//int parse_inst(unsigned int , unsigned int , insn*); - -void ke2dbg_printf_disasm(eresi_Addr, eresi_Addr); - -unsigned int ke2dbg_dr0_get(void); -unsigned int ke2dbg_dr1_get(void); -unsigned int ke2dbg_dr2_get(void); -unsigned int ke2dbg_dr3_get(void); -unsigned int ke2dbg_dr4_get(void); -unsigned int ke2dbg_dr5_get(void); -unsigned int ke2dbg_dr6_get(void); -unsigned int ke2dbg_dr7_get(void); - -void ke2dbg_dr0_set(unsigned int value); -void ke2dbg_dr1_set(unsigned int value); -void ke2dbg_dr2_set(unsigned int value); -void ke2dbg_dr3_set(unsigned int value); -void ke2dbg_dr4_set(unsigned int value); -void ke2dbg_dr5_set(unsigned int value); -void ke2dbg_dr6_set(unsigned int value); -void ke2dbg_dr7_set(unsigned int value); - -unsigned int ke2dbg_cr4_get(void); -void ke2dbg_cr4_set(unsigned int value); -void ke2dbg_hwbp_reset(void); -void ke2dbg_hwbp_set(unsigned int ad); -unsigned int ke2dbg_pageinfo_print_i(unsigned int adresse); -void ke2dbg_pageinfo_print(void); -int ke2dbg_hwbp_check(void); -void ke2dbg_hwbp_enable(int i); -void ke2dbg_hwbp_disable(int i); -void ke2dbg_idhwbp_enable(int id_hw_bp); -void ke2dbg_idhwbp_disable(int id_hw_bp); -void ke2dbg_wpbit_reset(void); -void ke2dbg_wpbit_set(void); - -void ke2dbg_logbuf_clean(void); -void ke2dbg_command_insert(char *); -void ke2dbg_command_recall(int ); -void ke2dbg_logbuf_insert(char *); -void ke2dbg_logbuf_print(void); -void ke2dbg_logbuf_downline(void); -void ke2dbg_logbuf_upline(void); -void ke2dbg_logbuf_downlines(void); -void ke2dbg_logbuf_uplines(void); -void ke2dbg_logbuf_start(void); -void ke2dbg_logbuf_end(void); -void ke2dbg_logbuf_restore(void); -void ke2dbg_output(char *ptr); - -void _ke2dbg_kbdhandle (void); -void _ke2dbg_int0_handle (void); -void _ke2dbg_int1_handle (void); -void _ke2dbg_int3_handle (void); -void _ke2dbg_int6_handle (void); -void _ke2dbg_int13_handle (void); -void _ke2dbg_int14_handle (void); -void _ke2dbg_int128_handle (void); -void ke2dbg_kbdhandle(void); -void ke2dbg_int0_handle (void); -void ke2dbg_int1_handle (void); -void ke2dbg_int3_handle (void); -void ke2dbg_int6_handle (void); -void ke2dbg_int13_handle (void); -void ke2dbg_int14_handle (void); -void ke2dbg_int128_handle (void); -int ke2dbg_init(void); -void ke2dbg_cleanup(void); - -unsigned int* ke2dbg_idt_getbase(void); -unsigned int* ke2dbg_gdt_getbase(void); -unsigned int ke2dbg_ldt_getbase(void); -unsigned int ke2dbg_virt2lin_convert(unsigned int , unsigned int ); -void ke2dbg_idt_print(unsigned long *); -unsigned long ke2dbg_idt_modify(unsigned int ,unsigned int *); -unsigned long ke2dbg_idt_readent(unsigned int *); - -void ke2dbg_kbdreset(void); -void dummy_asm(void); -unsigned int ke2dbg_scancode_read(void); -void ke2dbg_handle_scancode(unsigned char ); -char ke2dbg_scan_to_ascii(int ); -unsigned int ke2dbg_keyboard_wait(void); -void ke2dbg_keyboard_read(void); -unsigned int ke2dbg_keyboard_write(unsigned char); -unsigned char ke2dbg_keystroke_print(void); -unsigned int myke2dbg_keyboard_wait(unsigned char*); -unsigned int _ke2dbg_scancode_read(void); - -unsigned int* ke2dbg_basetp(void); -unsigned int ke2dbg_pageinfo_get(unsigned int addr, unsigned int *tab_page, unsigned int *tab_page_ent, unsigned int *level); -int ke2dbg_page_exist(unsigned int ); -unsigned int ke2dbg_pageinfo_set(unsigned int adresse, unsigned int data, unsigned int level); -int write_save_dirty(unsigned char* ptr, unsigned char o); -void ke2dbg_page_display(unsigned int page_ad); -unsigned int kedbg_physpage_get(unsigned int ad); -unsigned int ke2dbg_linear2physical(unsigned int ptr); -void poked(unsigned int ptr, unsigned int v); -void poked1(unsigned int ptr, unsigned int v); -void poked_cache(unsigned int ptr, unsigned int v); - - -unsigned char ke2dbg_inb (unsigned int Port); -unsigned short ke2dbg_inw (unsigned int Port); -unsigned int ke2dbg_inl (unsigned int Port); -void ke2dbg_outb (unsigned char Value , unsigned int Port); -void ke2dbg_outw (unsigned short Value, unsigned int Port); -void ke2dbg_outl (unsigned int Value , unsigned int Port); - -int ke2dbg_sprintf (char *outbuf, char *fmt, ...); -int ke2dbg_isalpha(register int ); -int ke2dbg_isupper(register int ); -int ke2dbg_islower(register int ); -int ke2dbg_isdigit(register int ); -int ke2dbg_isxdigit(register int ); -int ke2dbg_isspace(register int ); -int ke2dbg_ispunct(register int ); -int ke2dbg_isalnum(register int ); -int ke2dbg_isprint(register int ); -int ke2dbg_isgraph(register int ); -int ke2dbg_iscntrl(register int ); -int ke2dbg_isascii(register int ); -int ke2dbg_toascii(register int ); - -int ke2dbg_atoi( char *); -char * ke2dbg_strchr( char *, int ); -int ke2dbg_strcmp( char *, char *); -size_t ke2dbg_strlen( char *); -int ke2dbg_strnicmp ( char *, char *,size_t ); -int ke2dbg_stricmp (char *, char *); -char * ke2dbg_strcpy(char *, char *); -unsigned ke2dbg_strcspn( char *, char *); -char *ke2dbg_strcat(char *, char *); -char *ke2dbg_strncat(char *, char *, unsigned int ); -int ke2dbg_strncmp( char *, char *, unsigned int ); -char * ke2dbg_strncpy(char *, char *, unsigned int ); -char * ke2dbg_strpbrk( char *, char *); -char * ke2dbg_strrchr( char *, int ); -unsigned int ke2dbg_strspn( char *, char *); -char * ke2dbg_strstr( char *, char *); -char * ke2dbg_strtok_r(char *, char *, char **); -void* ke2dbg_memset(void* , int , unsigned int ); -void* ke2dbg_memcpy(void* , void* , unsigned int ); - - -int test(void); -void ke2dbg_screen_prepare(void); -int LoadBMP(char* , unsigned int* , unsigned int* , unsigned int *, unsigned char *); -void my_outb(unsigned short port, unsigned char value); -void ke2dbg_membase_read(void); -void ke2dbg_membase_restore(void) ; -void ke2dbg_memreset(void); -void put_XY_char(int x, int y, unsigned char a); -void print_char(unsigned char , unsigned int , unsigned int ); -void Put_String(char* , unsigned int , unsigned int ); -void PutString(unsigned long ,unsigned long ,char *,char ); -void ke2dbg_screen_dump(void); -void ke2dbg_data_dump(eresi_Addr selector, eresi_Addr ptr); -void ke2dbg_screen_restore(int); -void ke2dbg_message_display(char *); -void WriteVCon(unsigned int ,unsigned ,char *); -void ke2dbg_line_delete(int ); -void ke2dbg_ClearAW(void); -void ke2dbg_ClearDW(void); -void ke2dbg_ClearCW(void); -void cls(void); -void ke2dbg_text_display(int ,int ,char *); -void ke2dbg_Refresh_AW(void); -void ke2dbg_Refresh_DW(void); -void ke2dbg_codewin_refresh(void); -void ke2dbg_allwin_refresh(void); -void ke2dbg_cursor_top_right(void); -void ke2dbg_display_refresh(void); - -#ifdef VIDEO_AA -void ke2dbg_display_start(void); -void kedbg_display_end(void); -#endif /* VIDEO_AA */ - -void ke2dbg_cmdkey_insert(char ); -void ke2dbg_command_clear(void); -void ke2dbg_cmdkey_delete(void); - -void ke2dbg_change_color(char *,char *); -void ke2dbg_console_off(void); -void ke2dbg_console_on(void); -void ke2dbg_screen_test(void); -void ke2dbg_print_AW(char* ptr, int ligne); -void ke2dbg_print_DW(char* ptr, int ligne); -void ke2dbg_print_CW(char* ptr, int ligne); -void ke2dbg_cursor_update(unsigned int x, unsigned int y); -void ke2dbg_cursor_erase(void); - -/* PCI API that must be exported */ -void pci_list_controller(void); -unsigned int pci_detect_display(void); - - -/* ke2dbg.c */ -void ke2dbg_register_print(Reg_struct *regstack); -void ke2dbg_keystate_print (unsigned int o ); -void ke2dbg_step (void); - -/* rr0d commands */ -void ke2dbg_commands_install(); -int cmd_rr0d_rasta(); -int cmd_rr0d_rasta_off(); -int cmd_rr0d_set(); -int cmd_rr0d_help(); -int cmd_rr0d_insertbp(); -int cmd_rr0d_removebp(); -int cmd_rr0d_idt(); -int cmd_rr0d_bpm(); -int cmd_rr0d_loadsyms(); -int cmd_rr0d_info(); -int cmd_rr0d_listsyms(); -int cmd_rr0d_editmem(); -int cmd_rr0d_inthook(); -int cmd_rr0d_rdtschook(); -int cmd_rr0d_foolmode(); -int cmd_rr0d_unfoolmode(); -int cmd_rr0d_print(); - -/* Extern variables */ - -extern eresi_Addr adresse_ret_1; -extern eresi_Addr adresse_ret_2; -extern int hook_rdtsc; -extern unsigned int edit_mode; - -extern int accessline[SCREEN_LINE]; -extern char screen_lines[39][80]; -extern char screen_colors[39][80]; - -extern unsigned int data_win_y; -extern unsigned int data_win_dim; -extern unsigned int code_win_y; -extern unsigned int code_win_dim; -extern unsigned int buff_win_y; -extern unsigned int buff_win_dim; -extern unsigned int cmd_win_y; -extern unsigned int cmd_win_dim; -extern unsigned int screen_offset_x; -extern unsigned int screen_offset_y; -extern unsigned int screen_bpp; -extern unsigned int code_dim_line[10]; - -extern int fired; -extern unsigned int gdt_limit; -extern unsigned long idt_[2]; -extern unsigned long gdt_[2]; -extern unsigned long ldt_[1]; -extern unsigned int data_ptr; -extern unsigned int old_data_ptr; -extern unsigned int code_ptr; -extern unsigned int old_code_ptr; -extern char debug__[80]; - -extern int unmapped_bp_to_shoot; -extern int bufferindex; -extern int insertbufferindex; -extern char buff_cmd[BUFFERMAXCMD][80]; -extern int insertcmdindex; -extern int cmdindex; -extern Bp_struct list_breakpoints[NUM_BREAKPOINTS]; - -extern unsigned char fb_hw_padding_var1[0x1000]; -extern unsigned char fb_hw_flying_page1[1024*0x1000]; -extern unsigned char fb_hw_padding_var2[0x1000]; -extern unsigned int fb_hw_flying_page1_sav; -extern unsigned int fb_hw_flying_page1_level; - -extern unsigned int cursor_X; -extern unsigned int cursor_Y; -extern unsigned int cursor_old_color; -extern unsigned int cursor_color; - -extern unsigned int font_width; -extern unsigned int font_height; -extern unsigned int font_x; -extern unsigned int font_y; -extern unsigned int font_bpp; -extern unsigned int screen_adresse ; -extern unsigned char font_data[]; - -extern unsigned int pagedir; -extern unsigned int saved_wp_bit; - -extern Reg_struct *reg_stack; -extern Reg_struct current_reg_stack; -/* BUG /!\ pour nux, 0x18 */ - -/* keyboard.c */ -extern int CommandLength; -extern char Command[256]; -extern unsigned int rasta_mode; -extern unsigned int fOOl_mode; -extern unsigned int fOOl_mode_color_shift; -extern unsigned int first_asm_line; -extern unsigned int update_disasm; -extern unsigned int force_disasm; -extern char *table_command[]; -extern long back_disasm (unsigned int , int ); -extern void *old_int[MAX_INT]; -extern void *tmp_int[MAX_INT]; -extern unsigned long addrnewint[MAX_INT]; -extern int is_int_hooked[MAX_INT]; -extern Reg_struct *reg_stack; -extern unsigned int ctrl_key; -extern unsigned int shift_key; -extern unsigned int alt_key; - -/* strings.c */ -int strcmp(const char *p1, const char *p2); -char *strncat(char *s1, const char *s2, size_t n); -char *strncpy(char *s1, const char *s2, size_t n); -int strncmp(const char *s1, const char *s2, size_t n); -char *strcat(char *dest, const char *src); -char strtok_r(char *s, const char *delim, char **save_ptr); -void bzero(void *s, size_t len); - -#define CMD_RASTA "rr0d-rasta" -#define CMD_RASTA_OFF "rr0d-norasta" -#define CMD_FOOL "rr0d-f00l" -#define CMD_FOOL_OFF "rr0d-nof00l" -#define CMD_IDT "rr0d-idt" -#define CMD_BPM "rr0d-bpm" -#define CMD_RINFO "rr0d-rinfo" -#define CMD_EDITMEM "rr0d-editmem" -#define CMD_INTHOOK "rr0d-inthook" -#define CMD_RDTSCHOOK "rr0d-rdtschook" - -#endif /* KE2DBG_H */ diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-keyb.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-keyb.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-keyb.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-keyb.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -/* - * - * - * - * - * - */ -#ifndef _KE2DBG_KEYB_H_ - #define _KE2DBG_KEYB_H_ - -/* AZERTY TAB */ -#define AZERTY -#ifdef AZERTY -static u_char scantable_MAJ[] = { - 0, 0, '1','2','3','4','5','6','7','8','9','0','?','-', 0, - 0, 'A','Z','E','R','T','Y','U','I','O','P', 0, 0, 0, - 0, 'Q','S','D','F','G','H','J','K','L','M','%', 0, 0, - 0, 'W','X','C','V','B','N','?','.','/', 0, 0, 0, - 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, '7','8','9', 0, '4','5','6','+','1','2','3', - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static u_char scantable_N_MAJ[] = { - 0, 0, '&','e','"','\'','(','-','e','_','c','a',')','=', 0, - 0, 'a','z','e','r','t','y','u','i','o','p','^','$', 0, - 0, 'q','s','d','f','g','h','j','k','l','m','u','*', 0, - 0, 'w','x','c','v','b','n',',',';',':','!', 0, 0, - 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - '7','8','9', 0, '4','5','6','+','1','2','3', - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -#else -/* ====== quertzy ======*/ -static u_char scantable_MAJ[] = { - 0, 0, '!','"','§','$','%','&','/','(',')','=','?','`', 0, - 0, 'Q','W','E','R','T','Y','U','I','O','P','Ãœ','*', 0, - 0, 'A','S','D','F','G','H','J','K','L','Ö','Ä','\'', 0, - '>', 'Y','X','C','V','B','N','M',';',':','_', 0, 0, - 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static u_char scantable_N_MAJ[] = { - 0, 0, '1','2','3','4','5','6','7','8','9','0','?','­', 0, - 0, 'q','w','e','r','t','y','u','i','o','p','ü','+', 0, - 0, 'a','s','d','f','g','h','j','k','l','ö','ä','#', 0, - '<','y','x','c','v','b','n','m',',','.','-', 0, 0, - 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; -#endif - -#endif diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pcidata.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pcidata.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pcidata.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pcidata.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9322 +0,0 @@ -pci_desc tab_vendor_0095[] = { - {0x0680, "Ultra ATA/133 IDE RAID CONTROLLER CARD", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_018A[] = { - {0x0106, "FPC-0106TX misprogrammed [RTL81xx]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_021B[] = { - {0x8139, "HNE-300 (RealTek RTL8139c) [iPaq Networking]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0291[] = { - {0x8212, "DM9102A(DM9102AE, SM9102AF) Ethernet 100/10 MBit(Rev 40)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_02AC[] = { - {0x1012, "1012 PCMCIA 10/100 Ethernet Card [RTL81xx]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0357[] = { - {0x000A, "TTP-Monitoring Card V2.0", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0432[] = { - {0x0001, "Pluto2 DVB-T Receiver for PCMCIA [EasyWatch MobilSet]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_045E[] = { - {0x006E, "MN-510 802.11b wireless USB paddle", NULL}, - {0x00C2, "MN-710 wireless USB paddle", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_04CF[] = { - {0x8818, "CS8818 USB2.0-to-ATAPI Bridge Controller with Embedded PHY", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_050D[] = { - {0x7050, "F5D7050 802.11g Wireless USB Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_05E3[] = { - {0x0701, "CBD516", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0675[] = { - {0x1700, "IS64PH ISDN Adapter", NULL}, - {0x1702, "IS64PH ISDN Adapter", NULL}, - {0x1703, "ISDN Adapter (PCI Bus, DV, W)", NULL}, - {0x1704, "ISDN Adapter (PCI Bus, D, C)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_067B[] = { - {0x3507, "PL-3507 Hi-Speed USB & IEEE 1394 Combo to IDE Bridge Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_09C1[] = { - {0x0704, "CM 200E Cable Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0B49[] = { - {0x064F, "Trance Vibrator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_0E11[] = { - {0x0001, "PCI to EISA Bridge", NULL}, - {0x0002, "PCI to ISA Bridge", NULL}, - {0x0046, "Smart Array 64xx", NULL}, - {0x0049, "NC7132 Gigabit Upgrade Module", NULL}, - {0x004A, "NC6136 Gigabit Server Adapter", NULL}, - {0x005A, "Remote Insight II board - Lights-Out", NULL}, - {0x007C, "NC7770 1000BaseTX", NULL}, - {0x007D, "NC6770 1000BaseTX", NULL}, - {0x0085, "NC7780 1000BaseTX", NULL}, - {0x00B1, "Remote Insight II board - PCI device", NULL}, - {0x00BB, "NC7760", NULL}, - {0x00CA, "NC7771", NULL}, - {0x00CB, "NC7781", NULL}, - {0x00CF, "NC7772", NULL}, - {0x00D0, "NC7782", NULL}, - {0x00D1, "NC7783", NULL}, - {0x00E3, "NC7761", NULL}, - {0x0508, "Netelligent 4/16 Token Ring", NULL}, - {0x1000, "Triflex/Pentium Bridge, Model 1000", NULL}, - {0x2000, "Triflex/Pentium Bridge, Model 2000", NULL}, - {0x3032, "QVision 1280/p", NULL}, - {0x3033, "QVision 1280/p", NULL}, - {0x3034, "QVision 1280/p", NULL}, - {0x4000, "4000 [Triflex]", NULL}, - {0x4030, "SMART-2/P", NULL}, - {0x4031, "SMART-2SL", NULL}, - {0x4032, "Smart Array 3200", NULL}, - {0x4033, "Smart Array 3100ES", NULL}, - {0x4034, "Smart Array 221", NULL}, - {0x4040, "Integrated Array", NULL}, - {0x4048, "Compaq Raid LC2", NULL}, - {0x4050, "Smart Array 4200", NULL}, - {0x4051, "Smart Array 4250ES", NULL}, - {0x4058, "Smart Array 431", NULL}, - {0x4070, "Smart Array 5300", NULL}, - {0x4080, "Smart Array 5i", NULL}, - {0x4082, "Smart Array 532", NULL}, - {0x4083, "Smart Array 5312", NULL}, - {0x4091, "Smart Array 6i", NULL}, - {0x409A, "Smart Array 641", NULL}, - {0x409B, "Smart Array 642", NULL}, - {0x409C, "Smart Array 6400", NULL}, - {0x409D, "Smart Array 6400 EM", NULL}, - {0x6010, "HotPlug PCI Bridge 6010", NULL}, - {0x7020, "USB Controller", NULL}, - {0xA0EC, "Fibre Channel Host Controller", NULL}, - {0xA0F0, "Advanced System Management Controller", NULL}, - {0xA0F3, "Triflex PCI to ISA Bridge", NULL}, - {0xA0F7, "PCI Hotplug Controller", NULL}, - {0xA0F8, "ZFMicro Chipset USB", NULL}, - {0xA0FC, "FibreChannel HBA Tachyon", NULL}, - {0xAE10, "Smart-2/P RAID Controller", NULL}, - {0xAE29, "MIS-L", NULL}, - {0xAE2A, "MPC", NULL}, - {0xAE2B, "MIS-E", NULL}, - {0xAE31, "System Management Controller", NULL}, - {0xAE32, "Netelligent 10/100 TX PCI UTP", NULL}, - {0xAE33, "Triflex Dual EIDE Controller", NULL}, - {0xAE34, "Netelligent 10 T PCI UTP", NULL}, - {0xAE35, "Integrated NetFlex-3/P", NULL}, - {0xAE40, "Netelligent Dual 10/100 TX PCI UTP", NULL}, - {0xAE43, "Netelligent Integrated 10/100 TX UTP", NULL}, - {0xAE69, "CETUS-L", NULL}, - {0xAE6C, "Northstar", NULL}, - {0xAE6D, "NorthStar CPU to PCI Bridge", NULL}, - {0xB011, "Netelligent 10/100 TX Embedded UTP", NULL}, - {0xB012, "Netelligent 10 T/2 PCI UTP/Coax", NULL}, - {0xB01E, "NC3120 Fast Ethernet NIC", NULL}, - {0xB01F, "NC3122 Fast Ethernet NIC", NULL}, - {0xB02F, "NC1120 Ethernet NIC", NULL}, - {0xB030, "Netelligent 10/100 TX UTP", NULL}, - {0xB04A, "10/100 TX PCI Intel WOL UTP Controller", NULL}, - {0xB060, "Smart Array 5300 Controller", NULL}, - {0xB0C6, "NC3161 Fast Ethernet NIC", NULL}, - {0xB0C7, "NC3160 Fast Ethernet NIC", NULL}, - {0xB0D7, "NC3121 Fast Ethernet NIC", NULL}, - {0xB0DD, "NC3131 Fast Ethernet NIC", NULL}, - {0xB0DE, "NC3132 Fast Ethernet Module", NULL}, - {0xB0DF, "NC6132 Gigabit Module", NULL}, - {0xB0E0, "NC6133 Gigabit Module", NULL}, - {0xB0E1, "NC3133 Fast Ethernet Module", NULL}, - {0xB123, "NC6134 Gigabit NIC", NULL}, - {0xB134, "NC3163 Fast Ethernet NIC", NULL}, - {0xB13C, "NC3162 Fast Ethernet NIC", NULL}, - {0xB144, "NC3123 Fast Ethernet NIC", NULL}, - {0xB163, "NC3134 Fast Ethernet NIC", NULL}, - {0xB164, "NC3165 Fast Ethernet Upgrade Module", NULL}, - {0xB178, "Smart Array 5i/532", NULL}, - {0xB1A4, "NC7131 Gigabit Server Adapter", NULL}, - {0xB200, "Memory Hot-Plug Controller", NULL}, - {0xB203, "Integrated Lights Out Controller", NULL}, - {0xB204, "Integrated Lights Out Processor", NULL}, - {0xF130, "NetFlex-3/P ThunderLAN 1.0", NULL}, - {0xF150, "NetFlex-3/P ThunderLAN 2.3", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1000[] = { - {0x0001, "53c810", NULL}, - {0x0002, "53c820", NULL}, - {0x0003, "53c825", NULL}, - {0x0004, "53c815", NULL}, - {0x0005, "53c810AP", NULL}, - {0x0006, "53c860", NULL}, - {0x000A, "53c1510", NULL}, - {0x000B, "53C896/897", NULL}, - {0x000C, "53c895", NULL}, - {0x000D, "53c885", NULL}, - {0x000F, "53c875", NULL}, - {0x0010, "53C1510", NULL}, - {0x0012, "53c895a", NULL}, - {0x0013, "53c875a", NULL}, - {0x0020, "53c1010 Ultra3 SCSI Adapter", NULL}, - {0x0021, "53c1010 66MHz Ultra3 SCSI Adapter", NULL}, - {0x0030, "53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0031, "53c1030ZC PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0032, "53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0033, "1030ZC_53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0040, "53c1035 PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0041, "53C1035ZC PCI-X Fusion-MPT Dual Ultra320 SCSI", NULL}, - {0x0050, "SAS1064 PCI-X Fusion-MPT SAS", NULL}, - {0x0054, "SAS1068 PCI-X Fusion-MPT SAS", NULL}, - {0x0056, "SAS1064E PCI-Express Fusion-MPT SAS", NULL}, - {0x0058, "SAS1068E PCI-Express Fusion-MPT SAS", NULL}, - {0x005A, "SAS1066E PCI-Express Fusion-MPT SAS", NULL}, - {0x005C, "SAS1064A PCI-X Fusion-MPT SAS", NULL}, - {0x005E, "SAS1066 PCI-X Fusion-MPT SAS", NULL}, - {0x0060, "SAS1078 PCI-X Fusion-MPT SAS", NULL}, - {0x0062, "SAS1078 PCI-Express Fusion-MPT SAS", NULL}, - {0x008F, "53c875J", NULL}, - {0x0407, "MegaRAID", NULL}, - {0x0408, "MegaRAID", NULL}, - {0x0409, "MegaRAID", NULL}, - {0x0621, "FC909 Fibre Channel Adapter", NULL}, - {0x0622, "FC929 Fibre Channel Adapter", NULL}, - {0x0623, "FC929 LAN", NULL}, - {0x0624, "FC919 Fibre Channel Adapter", NULL}, - {0x0625, "FC919 LAN", NULL}, - {0x0626, "FC929X Fibre Channel Adapter", NULL}, - {0x0627, "FC929X LAN", NULL}, - {0x0628, "FC919X Fibre Channel Adapter", NULL}, - {0x0629, "FC919X LAN", NULL}, - {0x0640, "FC949X Fibre Channel Adapter", NULL}, - {0x0642, "FC939X Fibre Channel Adapter", NULL}, - {0x0646, "FC949ES Fibre Channel Adapter", NULL}, - {0x0701, "83C885 NT50 DigitalScape Fast Ethernet", NULL}, - {0x0702, "Yellowfin G-NIC gigabit ethernet", NULL}, - {0x0804, "SA2010", NULL}, - {0x0805, "SA2010ZC", NULL}, - {0x0806, "SA2020", NULL}, - {0x0807, "SA2020ZC", NULL}, - {0x0901, "61C102", NULL}, - {0x1000, "63C815", NULL}, - {0x1960, "MegaRAID", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1001[] = { - {0x0010, "PCI 1616 Measurement card with 32 digital I/O lines", NULL}, - {0x0011, "OPTO-PCI Opto-Isolated digital I/O board", NULL}, - {0x0012, "PCI-AD/DA Analogue I/O board", NULL}, - {0x0013, "PCI-OPTO-RELAIS Digital I/O board with relay outputs", NULL}, - {0x0014, "PCI-Counter/Timer Counter Timer board", NULL}, - {0x0015, "PCI-DAC416 Analogue output board", NULL}, - {0x0016, "PCI-MFB Analogue I/O board", NULL}, - {0x0017, "PROTO-3 PCI Prototyping board", NULL}, - {0x9100, "INI-9100/9100W SCSI Host", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1002[] = { - {0x3150, "M24 1P [Radeon Mobility X600]", NULL}, - {0x3152, "M22 [Radeon Mobility X300]", NULL}, - {0x3154, "M24 1T [FireGL M24 GL]", NULL}, - {0x3E50, "RV380 0x3e50 [Radeon X600]", NULL}, - {0x3E54, "RV380 0x3e54 [FireGL V3200]", NULL}, - {0x3E70, "RV380 [Radeon X600] Secondary", NULL}, - {0x4136, "Radeon IGP 320 M", NULL}, - {0x4137, "Radeon IGP330/340/350", NULL}, - {0x4144, "R300 AD [Radeon 9500 Pro]", NULL}, - {0x4145, "R300 AE [Radeon 9700 Pro]", NULL}, - {0x4146, "R300 AF [Radeon 9700 Pro]", NULL}, - {0x4147, "R300 AG [FireGL Z1/X1]", NULL}, - {0x4148, "R350 AH [Radeon 9800]", NULL}, - {0x4149, "R350 AI [Radeon 9800]", NULL}, - {0x414A, "R350 AJ [Radeon 9800]", NULL}, - {0x414B, "R350 AK [Fire GL X2]", NULL}, - {0x4150, "RV350 AP [Radeon 9600]", NULL}, - {0x4151, "RV350 AQ [Radeon 9600]", NULL}, - {0x4152, "RV350 AR [Radeon 9600]", NULL}, - {0x4153, "RV350 AS [Radeon 9550]", NULL}, - {0x4154, "RV350 AT [Fire GL T2]", NULL}, - {0x4155, "RV350 AU [Fire GL T2]", NULL}, - {0x4156, "RV350 AV [Fire GL T2]", NULL}, - {0x4157, "RV350 AW [Fire GL T2]", NULL}, - {0x4158, "68800AX [Mach32]", NULL}, - {0x4164, "R300 AD [Radeon 9500 Pro] (Secondary)", NULL}, - {0x4165, "R300 AE [Radeon 9700 Pro] (Secondary)", NULL}, - {0x4166, "R300 AF [Radeon 9700 Pro] (Secondary)", NULL}, - {0x4168, "Radeon R350 [Radeon 9800] (Secondary)", NULL}, - {0x4170, "RV350 AP [Radeon 9600] (Secondary)", NULL}, - {0x4171, "RV350 AQ [Radeon 9600] (Secondary)", NULL}, - {0x4172, "RV350 AR [Radeon 9600] (Secondary)", NULL}, - {0x4173, "RV350 ? [Radeon 9550] (Secondary)", NULL}, - {0x4237, "Radeon 7000 IGP", NULL}, - {0x4242, "R200 BB [Radeon All in Wonder 8500DV]", NULL}, - {0x4243, "R200 BC [Radeon All in Wonder 8500]", NULL}, - {0x4336, "Radeon Mobility U1", NULL}, - {0x4337, "Radeon IGP 330M/340M/350M", NULL}, - {0x4341, "IXP150 AC'97 Audio Controller", NULL}, - {0x4345, "EHCI USB Controller", NULL}, - {0x4347, "OHCI USB Controller #1", NULL}, - {0x4348, "OHCI USB Controller #2", NULL}, - {0x4349, "ATI Dual Channel Bus Master PCI IDE Controller", NULL}, - {0x434D, "IXP AC'97 Modem", NULL}, - {0x4353, "ATI SMBus", NULL}, - {0x4354, "215CT [Mach64 CT]", NULL}, - {0x4358, "210888CX [Mach64 CX]", NULL}, - {0x4363, "ATI SMBus", NULL}, - {0x436E, "ATI 436E Serial ATA Controller", NULL}, - {0x4370, "IXP SB400 AC'97 Audio Controller", NULL}, - {0x4371, "IXP SB400 PCI-PCI Bridge", NULL}, - {0x4372, "IXP SB400 SMBus Controller", NULL}, - {0x4373, "IXP SB400 USB2 Host Controller", NULL}, - {0x4374, "IXP SB400 USB Host Controller", NULL}, - {0x4375, "IXP SB400 USB Host Controller", NULL}, - {0x4376, "Standard Dual Channel PCI IDE Controller ATI", NULL}, - {0x4377, "IXP SB400 PCI-ISA Bridge", NULL}, - {0x4378, "ATI SB400 - AC'97 Modem Controller", NULL}, - {0x4379, "ATI 4379 Serial ATA Controller", NULL}, - {0x437A, "ATI 437A Serial ATA Controller", NULL}, - {0x4437, "Radeon Mobility 7000 IGP", NULL}, - {0x4554, "210888ET [Mach64 ET]", NULL}, - {0x4654, "Mach64 VT", NULL}, - {0x4742, "3D Rage Pro AGP 1X/2X", NULL}, - {0x4744, "3D Rage Pro AGP 1X", NULL}, - {0x4747, "3D Rage Pro", NULL}, - {0x4749, "3D Rage Pro", NULL}, - {0x474C, "Rage XC", NULL}, - {0x474D, "Rage XL AGP 2X", NULL}, - {0x474E, "Rage XC AGP", NULL}, - {0x474F, "Rage XL", NULL}, - {0x4750, "3D Rage Pro 215GP", NULL}, - {0x4751, "3D Rage Pro 215GQ", NULL}, - {0x4752, "Rage XL", NULL}, - {0x4753, "Rage XC", NULL}, - {0x4754, "3D Rage I/II 215GT [Mach64 GT]", NULL}, - {0x4755, "3D Rage II+ 215GTB [Mach64 GTB]", NULL}, - {0x4756, "3D Rage IIC 215IIC [Mach64 GT IIC]", NULL}, - {0x4757, "3D Rage IIC AGP", NULL}, - {0x4758, "210888GX [Mach64 GX]", NULL}, - {0x4759, "3D Rage IIC", NULL}, - {0x475A, "3D Rage IIC AGP", NULL}, - {0x4964, "Radeon RV250 Id [Radeon 9000]", NULL}, - {0x4965, "Radeon RV250 Ie [Radeon 9000]", NULL}, - {0x4966, "Radeon RV250 If [Radeon 9000]", NULL}, - {0x4967, "Radeon RV250 Ig [Radeon 9000]", NULL}, - {0x496E, "Radeon RV250 [Radeon 9000] (Secondary)", NULL}, - {0x4A48, "R420 JH [Radeon X800]", NULL}, - {0x4A49, "R420 JI [Radeon X800PRO]", NULL}, - {0x4A4A, "R420 JJ [Radeon X800SE]", NULL}, - {0x4A4B, "R420 JK [Radeon X800]", NULL}, - {0x4A4C, "R420 JL [Radeon X800]", NULL}, - {0x4A4D, "R420 JM [FireGL X3]", NULL}, - {0x4A4E, "M18 JN [Radeon Mobility 9800]", NULL}, - {0x4A50, "R420 JP [Radeon X800XT]", NULL}, - {0x4A70, "R420 [X800XT-PE] (Secondary)", NULL}, - {0x4B49, "R480 [Radeon X850XT]", NULL}, - {0x4B4B, "R480 [Radeon X850Pro]", NULL}, - {0x4B4C, "R481 [Radeon X850XT-PE]", NULL}, - {0x4B69, "R480 [Radeon X850XT secondary]", NULL}, - {0x4B6B, "R480 [Radeon X850Pro] (Secondary)", NULL}, - {0x4B6C, "R481 [Radeon X850XT-PE] Secondary", NULL}, - {0x4C42, "3D Rage LT Pro AGP-133", NULL}, - {0x4C44, "3D Rage LT Pro AGP-66", NULL}, - {0x4C45, "Rage Mobility M3 AGP", NULL}, - {0x4C46, "Rage Mobility M3 AGP 2x", NULL}, - {0x4C47, "3D Rage LT-G 215LG", NULL}, - {0x4C49, "3D Rage LT Pro", NULL}, - {0x4C4D, "Rage Mobility P/M AGP 2x", NULL}, - {0x4C4E, "Rage Mobility L AGP 2x", NULL}, - {0x4C50, "3D Rage LT Pro", NULL}, - {0x4C51, "3D Rage LT Pro", NULL}, - {0x4C52, "Rage Mobility P/M", NULL}, - {0x4C53, "Rage Mobility L", NULL}, - {0x4C54, "264LT [Mach64 LT]", NULL}, - {0x4C57, "Radeon Mobility M7 LW [Radeon Mobility 7500]", NULL}, - {0x4C58, "Radeon RV200 LX [Mobility FireGL 7800 M7]", NULL}, - {0x4C59, "Radeon Mobility M6 LY", NULL}, - {0x4C5A, "Radeon Mobility M6 LZ", NULL}, - {0x4C64, "Radeon R250 Ld [Radeon Mobility 9000 M9]", NULL}, - {0x4C65, "Radeon R250 Le [Radeon Mobility 9000 M9]", NULL}, - {0x4C66, "Radeon R250 Lf [FireGL 9000]", NULL}, - {0x4C67, "Radeon R250 Lg [Radeon Mobility 9000 M9]", NULL}, - {0x4C6E, "Radeon R250 Ln [Radeon Mobility 9000 M9] [Secondary]", NULL}, - {0x4D46, "Rage Mobility M4 AGP", NULL}, - {0x4D4C, "Rage Mobility M4 AGP", NULL}, - {0x4E44, "Radeon R300 ND [Radeon 9700 Pro]", NULL}, - {0x4E45, "Radeon R300 NE [Radeon 9500 Pro]", NULL}, - {0x4E46, "RV350 NF [Radeon 9600]", NULL}, - {0x4E47, "Radeon R300 NG [FireGL X1]", NULL}, - {0x4E48, "Radeon R350 [Radeon 9800 Pro]", NULL}, - {0x4E49, "Radeon R350 [Radeon 9800]", NULL}, - {0x4E4A, "RV350 NJ [Radeon 9800 XT]", NULL}, - {0x4E4B, "R350 NK [Fire GL X2]", NULL}, - {0x4E50, "RV350 [Mobility Radeon 9600 M10]", NULL}, - {0x4E51, "M10 NQ [Radeon Mobility 9600]", NULL}, - {0x4E52, "RV350 [Mobility Radeon 9600 M10]", NULL}, - {0x4E53, "M10 NS [Radeon Mobility 9600]", NULL}, - {0x4E54, "M10 NT [FireGL Mobility T2]", NULL}, - {0x4E56, "M11 NV [FireGL Mobility T2e]", NULL}, - {0x4E64, "Radeon R300 [Radeon 9700 Pro] (Secondary)", NULL}, - {0x4E65, "Radeon R300 [Radeon 9500 Pro] (Secondary)", NULL}, - {0x4E66, "RV350 NF [Radeon 9600] (Secondary)", NULL}, - {0x4E67, "Radeon R300 [FireGL X1] (Secondary)", NULL}, - {0x4E68, "Radeon R350 [Radeon 9800 Pro] (Secondary)", NULL}, - {0x4E69, "Radeon R350 [Radeon 9800] (Secondary)", NULL}, - {0x4E6A, "RV350 NJ [Radeon 9800 XT] (Secondary)", NULL}, - {0x4E71, "M10 NQ [Radeon Mobility 9600] (secondary)", NULL}, - {0x5041, "Rage 128 PA/PRO", NULL}, - {0x5042, "Rage 128 PB/PRO AGP 2x", NULL}, - {0x5043, "Rage 128 PC/PRO AGP 4x", NULL}, - {0x5044, "Rage 128 PD/PRO TMDS", NULL}, - {0x5045, "Rage 128 PE/PRO AGP 2x TMDS", NULL}, - {0x5046, "Rage 128 PF/PRO AGP 4x TMDS", NULL}, - {0x5047, "Rage 128 PG/PRO", NULL}, - {0x5048, "Rage 128 PH/PRO AGP 2x", NULL}, - {0x5049, "Rage 128 PI/PRO AGP 4x", NULL}, - {0x504A, "Rage 128 PJ/PRO TMDS", NULL}, - {0x504B, "Rage 128 PK/PRO AGP 2x TMDS", NULL}, - {0x504C, "Rage 128 PL/PRO AGP 4x TMDS", NULL}, - {0x504D, "Rage 128 PM/PRO", NULL}, - {0x504E, "Rage 128 PN/PRO AGP 2x", NULL}, - {0x504F, "Rage 128 PO/PRO AGP 4x", NULL}, - {0x5050, "Rage 128 PP/PRO TMDS [Xpert 128]", NULL}, - {0x5051, "Rage 128 PQ/PRO AGP 2x TMDS", NULL}, - {0x5052, "Rage 128 PR/PRO AGP 4x TMDS", NULL}, - {0x5053, "Rage 128 PS/PRO", NULL}, - {0x5054, "Rage 128 PT/PRO AGP 2x", NULL}, - {0x5055, "Rage 128 PU/PRO AGP 4x", NULL}, - {0x5056, "Rage 128 PV/PRO TMDS", NULL}, - {0x5057, "Rage 128 PW/PRO AGP 2x TMDS", NULL}, - {0x5058, "Rage 128 PX/PRO AGP 4x TMDS", NULL}, - {0x5144, "Radeon R100 QD [Radeon 7200]", NULL}, - {0x5145, "Radeon R100 QE", NULL}, - {0x5146, "Radeon R100 QF", NULL}, - {0x5147, "Radeon R100 QG", NULL}, - {0x5148, "Radeon R200 QH [Radeon 8500]", NULL}, - {0x5149, "Radeon R200 QI", NULL}, - {0x514A, "Radeon R200 QJ", NULL}, - {0x514B, "Radeon R200 QK", NULL}, - {0x514C, "Radeon R200 QL [Radeon 8500 LE]", NULL}, - {0x514D, "Radeon R200 QM [Radeon 9100]", NULL}, - {0x514E, "Radeon R200 QN [Radeon 8500LE]", NULL}, - {0x514F, "Radeon R200 QO [Radeon 8500LE]", NULL}, - {0x5154, "R200 QT [Radeon 8500]", NULL}, - {0x5155, "R200 QU [Radeon 9100]", NULL}, - {0x5157, "Radeon RV200 QW [Radeon 7500]", NULL}, - {0x5158, "Radeon RV200 QX [Radeon 7500]", NULL}, - {0x5159, "Radeon RV100 QY [Radeon 7000/VE]", NULL}, - {0x515A, "Radeon RV100 QZ [Radeon 7000/VE]", NULL}, - {0x515E, "ES1000", NULL}, - {0x5168, "Radeon R200 Qh", NULL}, - {0x5169, "Radeon R200 Qi", NULL}, - {0x516A, "Radeon R200 Qj", NULL}, - {0x516B, "Radeon R200 Qk", NULL}, - {0x516C, "Radeon R200 Ql", NULL}, - {0x5245, "Rage 128 RE/SG", NULL}, - {0x5246, "Rage 128 RF/SG AGP", NULL}, - {0x5247, "Rage 128 RG", NULL}, - {0x524B, "Rage 128 RK/VR", NULL}, - {0x524C, "Rage 128 RL/VR AGP", NULL}, - {0x5345, "Rage 128 SE/4x", NULL}, - {0x5346, "Rage 128 SF/4x AGP 2x", NULL}, - {0x5347, "Rage 128 SG/4x AGP 4x", NULL}, - {0x5348, "Rage 128 SH", NULL}, - {0x534B, "Rage 128 SK/4x", NULL}, - {0x534C, "Rage 128 SL/4x AGP 2x", NULL}, - {0x534D, "Rage 128 SM/4x AGP 4x", NULL}, - {0x534E, "Rage 128 4x", NULL}, - {0x5354, "Mach 64 VT", NULL}, - {0x5446, "Rage 128 Pro Ultra TF", NULL}, - {0x544C, "Rage 128 Pro Ultra TL", NULL}, - {0x5452, "Rage 128 Pro Ultra TR", NULL}, - {0x5453, "Rage 128 Pro Ultra TS", NULL}, - {0x5454, "Rage 128 Pro Ultra TT", NULL}, - {0x5455, "Rage 128 Pro Ultra TU", NULL}, - {0x5460, "M22 [Radeon Mobility M300]", NULL}, - {0x5462, "M24 [Radeon Mobility X600]", NULL}, - {0x5464, "M22 [FireGL GL]", NULL}, - {0x5548, "R423 UH [Radeon X800 (PCIE)]", NULL}, - {0x5549, "R423 UI [Radeon X800PRO (PCIE)]", NULL}, - {0x554A, "R423 UJ [Radeon X800LE (PCIE)]", NULL}, - {0x554B, "R423 UK [Radeon X800SE (PCIE)]", NULL}, - {0x554D, "R430 [Radeon X800 XL] (PCIe)", NULL}, - {0x554F, "R430 [Radeon X800 (PCIE)]", NULL}, - {0x5550, "R423 [Fire GL V7100]", NULL}, - {0x5551, "R423 UQ [FireGL V7200 (PCIE)]", NULL}, - {0x5552, "R423 UR [FireGL V5100 (PCIE)]", NULL}, - {0x5554, "R423 UT [FireGL V7100 (PCIE)]", NULL}, - {0x556B, "Radeon R423 UK (PCIE) [X800 SE] (Secondary)", NULL}, - {0x556D, "R430 [Radeon X800 XL] (PCIe) Secondary", NULL}, - {0x556F, "R430 [Radeon X800 (PCIE) Secondary]", NULL}, - {0x564A, "M26 [Mobility FireGL V5000]", NULL}, - {0x564B, "M26 [Mobility FireGL V5000]", NULL}, - {0x5652, "M26 [Radeon Mobility X700]", NULL}, - {0x5653, "Radeon Mobility X700 (PCIE)", NULL}, - {0x5654, "264VT [Mach64 VT]", NULL}, - {0x5655, "264VT3 [Mach64 VT3]", NULL}, - {0x5656, "264VT4 [Mach64 VT4]", NULL}, - {0x5830, "RS300 Host Bridge", NULL}, - {0x5831, "RS300 Host Bridge", NULL}, - {0x5832, "RS300 Host Bridge", NULL}, - {0x5833, "Radeon 9100 IGP Host Bridge", NULL}, - {0x5834, "Radeon 9100 IGP", NULL}, - {0x5835, "RS300M AGP [Radeon Mobility 9100IGP]", NULL}, - {0x5838, "Radeon 9100 IGP AGP Bridge", NULL}, - {0x5940, "RV280 [Radeon 9200 PRO] (Secondary)", NULL}, - {0x5941, "RV280 [Radeon 9200] (Secondary)", NULL}, - {0x5944, "RV280 [Radeon 9200 SE (PCI)]", NULL}, - {0x5950, "RS480 Host Bridge", NULL}, - {0x5951, "ATI Radeon Xpress 200 (RS480/RS482/RX480/RX482) Chipset - Host bridge", NULL}, - {0x5954, "RS480 [Radeon Xpress 200G Series]", NULL}, - {0x5955, "ATI Radeon XPRESS 200M 5955 (PCIE)", NULL}, - {0x5960, "RV280 [Radeon 9200 PRO]", NULL}, - {0x5961, "RV280 [Radeon 9200]", NULL}, - {0x5962, "RV280 [Radeon 9200]", NULL}, - {0x5964, "RV280 [Radeon 9200 SE]", NULL}, - {0x5969, "ES1000", NULL}, - {0x5974, "RS482 [Radeon Xpress 200]", NULL}, - {0x5975, "RS482 [Radeon Xpress 200M]", NULL}, - {0x5A34, "RS480 PCI-X Root Port", NULL}, - {0x5A38, "RS480 PCI Bridge", NULL}, - {0x5A3F, "RS480 PCI Bridge", NULL}, - {0x5A41, "RS400 [Radeon Xpress 200]", NULL}, - {0x5A42, "RS400 [Radeon Xpress 200M]", NULL}, - {0x5A61, "RC410 [Radeon Xpress 200]", NULL}, - {0x5A62, "RC410 [Radeon Xpress 200M]", NULL}, - {0x5B60, "RV370 5B60 [Radeon X300 (PCIE)]", NULL}, - {0x5B62, "RV370 5B62 [Radeon X600 (PCIE)]", NULL}, - {0x5B63, "RV370 [ATI Sapphire X550 Silent]", NULL}, - {0x5B64, "RV370 5B64 [FireGL V3100 (PCIE)]", NULL}, - {0x5B65, "RV370 5B65 [FireGL D1100 (PCIE)]", NULL}, - {0x5B70, "RV370 [Radeon X300SE]", NULL}, - {0x5B72, "Radeon X600(RV380)", NULL}, - {0x5B73, "RV370 secondary [ATI Sapphire X550 Silent]", NULL}, - {0x5B74, "RV370 5B64 [FireGL V3100 (PCIE)] (Secondary)", NULL}, - {0x5C61, "M9+ 5C61 [Radeon Mobility 9200 (AGP)]", NULL}, - {0x5C63, "M9+ 5C63 [Radeon Mobility 9200 (AGP)]", NULL}, - {0x5D44, "RV280 [Radeon 9200 SE] (Secondary)", NULL}, - {0x5D48, "M28 [Radeon Mobility X800XT]", NULL}, - {0x5D49, "M28 [Mobility FireGL V5100]", NULL}, - {0x5D4A, "Mobility Radeon X800", NULL}, - {0x5D4D, "R480 [Radeon X850XT Platinum (PCIE)]", NULL}, - {0x5D4F, "R480 [Radeon X800 GTO (PCIE)]", NULL}, - {0x5D52, "R480 [Radeon X850XT (PCIE)] (Primary)", NULL}, - {0x5D57, "R423 5F57 [Radeon X800XT (PCIE)]", NULL}, - {0x5D6D, "R480 [Radeon X850XT Platinum (PCIE)] (Secondary)", NULL}, - {0x5D6F, "R480 [Radeon X800 GTO (PCIE)] (Secondary)", NULL}, - {0x5D72, "R480 [Radeon X850XT (PCIE)] (Secondary)", NULL}, - {0x5D77, "R423 5F57 [Radeon X800XT (PCIE)] (Secondary)", NULL}, - {0x5E48, "RV410 [FireGL V5000]", NULL}, - {0x5E49, "RV410 [FireGL V3300]", NULL}, - {0x5E4A, "RV410 [Radeon X700XT]", NULL}, - {0x5E4B, "RV410 [Radeon X700 Pro (PCIE)]", NULL}, - {0x5E4C, "RV410 [Radeon X700SE]", NULL}, - {0x5E4D, "RV410 [Radeon X700 (PCIE)]", NULL}, - {0x5E4F, "RV410 [Radeon X700]", NULL}, - {0x5E6B, "RV410 [Radeon X700 Pro (PCIE)] Secondary", NULL}, - {0x5E6D, "RV410 [Radeon X700 (PCIE)] (Secondary)", NULL}, - {0x700F, "PCI Bridge [IGP 320M]", NULL}, - {0x7010, "PCI Bridge [IGP 340M]", NULL}, - {0x7100, "R520 [Radeon X1800]", NULL}, - {0x7105, "R520 [FireGL]", NULL}, - {0x7109, "R520 [Radeon X1800]", NULL}, - {0x7120, "R520 [Radeon X1800] (Secondary)", NULL}, - {0x7129, "R520 [Radeon X1800] (Secondary)", NULL}, - {0x7142, "RV515 [Radeon X1300]", NULL}, - {0x7146, "RV515 [Radeon X1300]", NULL}, - {0x7162, "RV515 [Radeon X1300] (Secondary)", NULL}, - {0x7166, "RV515 [Radeon X1300] (Secondary)", NULL}, - {0x71C0, "RV530 [Radeon X1600]", NULL}, - {0x71C2, "RV530 [Radeon X1600]", NULL}, - {0x71E0, "RV530 [Radeon X1600] (Secondary)", NULL}, - {0x71E2, "RV530 [Radeon X1600] (Secondary)", NULL}, - {0x7833, "Radeon 9100 IGP Host Bridge", NULL}, - {0x7834, "Radeon 9100 PRO IGP", NULL}, - {0x7835, "Radeon Mobility 9200 IGP", NULL}, - {0x7838, "Radeon 9100 IGP PCI/AGP Bridge", NULL}, - {0x7C37, "RV350 AQ [Radeon 9600 SE]", NULL}, - {0xCAB0, "AGP Bridge [IGP 320M]", NULL}, - {0xCAB2, "RS200/RS200M AGP Bridge [IGP 340M]", NULL}, - {0xCAB3, "R200 AGP Bridge [Mobility Radeon 7000 IGP]", NULL}, - {0xCBB2, "RS200/RS200M AGP Bridge [IGP 340M]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1003[] = { - {0x0201, "US201", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1004[] = { - {0x0005, "82C592-FC1", NULL}, - {0x0006, "82C593-FC1", NULL}, - {0x0007, "82C594-AFC2", NULL}, - {0x0008, "82C596/7 [Wildcat]", NULL}, - {0x0009, "82C597-AFC2", NULL}, - {0x000C, "82C541 [Lynx]", NULL}, - {0x000D, "82C543 [Lynx]", NULL}, - {0x0101, "82C532", NULL}, - {0x0102, "82C534 [Eagle]", NULL}, - {0x0103, "82C538", NULL}, - {0x0104, "82C535", NULL}, - {0x0105, "82C147", NULL}, - {0x0200, "82C975", NULL}, - {0x0280, "82C925", NULL}, - {0x0304, "QSound ThunderBird PCI Audio", NULL}, - {0x0305, "QSound ThunderBird PCI Audio Gameport", NULL}, - {0x0306, "QSound ThunderBird PCI Audio Support Registers", NULL}, - {0x0307, "Thunderbird", NULL}, - {0x0308, "Thunderbird", NULL}, - {0x0702, "VAS96011 [Golden Gate II]", NULL}, - {0x0703, "Tollgate", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1005[] = { - {0x2064, "ALG2032/2064", NULL}, - {0x2128, "ALG2364A", NULL}, - {0x2301, "ALG2301", NULL}, - {0x2302, "ALG2302", NULL}, - {0x2364, "ALG2364", NULL}, - {0x2464, "ALG2364A", NULL}, - {0x2501, "ALG2564A/25128A", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_100B[] = { - {0x0001, "DP83810", NULL}, - {0x0002, "87415/87560 IDE", NULL}, - {0x000E, "87560 Legacy I/O", NULL}, - {0x000F, "FireWire Controller", NULL}, - {0x0011, "NS87560 National PCI System I/O", NULL}, - {0x0012, "USB Controller", NULL}, - {0x0020, "DP83815 (MacPhyter) Ethernet Controller", NULL}, - {0x0021, "PC87200 PCI to ISA Bridge", NULL}, - {0x0022, "DP83820 10/100/1000 Ethernet Controller", NULL}, - {0x0028, "Geode GX2 Host Bridge", NULL}, - {0x002A, "CS5535 South Bridge", NULL}, - {0x002B, "CS5535 ISA bridge", NULL}, - {0x002D, "CS5535 IDE", NULL}, - {0x002E, "CS5535 Audio", NULL}, - {0x002F, "CS5535 USB", NULL}, - {0x0030, "Geode GX2 Graphics Processor", NULL}, - {0x0035, "DP83065 [Saturn] 10/100/1000 Ethernet Controller", NULL}, - {0x0500, "SCx200 Bridge", NULL}, - {0x0501, "SCx200 SMI", NULL}, - {0x0502, "SCx200 IDE", NULL}, - {0x0503, "SCx200 Audio", NULL}, - {0x0504, "SCx200 Video", NULL}, - {0x0505, "SCx200 XBus", NULL}, - {0x0510, "SC1100 Bridge", NULL}, - {0x0511, "SC1100 SMI", NULL}, - {0x0515, "SC1100 XBus", NULL}, - {0xD001, "87410 IDE", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_100C[] = { - {0x3202, "ET4000/W32p rev A", NULL}, - {0x3205, "ET4000/W32p rev B", NULL}, - {0x3206, "ET4000/W32p rev C", NULL}, - {0x3207, "ET4000/W32p rev D", NULL}, - {0x3208, "ET6000", NULL}, - {0x4702, "ET6300", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_100E[] = { - {0x9000, "P9000 Viper", NULL}, - {0x9001, "P9000 Viper", NULL}, - {0x9002, "P9000 Viper", NULL}, - {0x9100, "P9100 Viper Pro/SE", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1011[] = { - {0x0001, "DECchip 21050", NULL}, - {0x0002, "DECchip 21040 [Tulip]", NULL}, - {0x0004, "DECchip 21030 [TGA]", NULL}, - {0x0007, "NVRAM [Zephyr NVRAM]", NULL}, - {0x0008, "KZPSA [KZPSA]", NULL}, - {0x0009, "DECchip 21140 [FasterNet]", NULL}, - {0x000A, "21230 Video Codec", NULL}, - {0x000D, "PBXGB [TGA2]", NULL}, - {0x000F, "DEFPA", NULL}, - {0x0014, "DECchip 21041 [Tulip Pass 3]", NULL}, - {0x0016, "DGLPB [OPPO]", NULL}, - {0x0017, "PV-PCI Graphics Controller (ZLXp-L)", NULL}, - {0x0019, "DECchip 21142/43", NULL}, - {0x001A, "Farallon PN9000SX Gigabit Ethernet", NULL}, - {0x0021, "DECchip 21052", NULL}, - {0x0022, "DECchip 21150", NULL}, - {0x0023, "DECchip 21150", NULL}, - {0x0024, "DECchip 21152", NULL}, - {0x0025, "DECchip 21153", NULL}, - {0x0026, "DECchip 21154", NULL}, - {0x0034, "56k Modem Cardbus", NULL}, - {0x0045, "DECchip 21553", NULL}, - {0x0046, "DECchip 21554", NULL}, - {0x1065, "StrongARM DC21285", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1013[] = { - {0x0038, "GD 7548", NULL}, - {0x0040, "GD 7555 Flat Panel GUI Accelerator", NULL}, - {0x004C, "GD 7556 Video/Graphics LCD/CRT Ctrlr", NULL}, - {0x00A0, "GD 5430/40 [Alpine]", NULL}, - {0x00A2, "GD 5432 [Alpine]", NULL}, - {0x00A4, "GD 5434-4 [Alpine]", NULL}, - {0x00A8, "GD 5434-8 [Alpine]", NULL}, - {0x00AC, "GD 5436 [Alpine]", NULL}, - {0x00B0, "GD 5440", NULL}, - {0x00B8, "GD 5446", NULL}, - {0x00BC, "GD 5480", NULL}, - {0x00D0, "GD 5462", NULL}, - {0x00D2, "GD 5462 [Laguna I]", NULL}, - {0x00D4, "GD 5464 [Laguna]", NULL}, - {0x00D5, "GD 5464 BD [Laguna]", NULL}, - {0x00D6, "GD 5465 [Laguna]", NULL}, - {0x00E8, "GD 5436U", NULL}, - {0x1100, "CL 6729", NULL}, - {0x1110, "PD 6832 PCMCIA/CardBus Ctrlr", NULL}, - {0x1112, "PD 6834 PCMCIA/CardBus Ctrlr", NULL}, - {0x1113, "PD 6833 PCMCIA/CardBus Ctrlr", NULL}, - {0x1200, "GD 7542 [Nordic]", NULL}, - {0x1202, "GD 7543 [Viking]", NULL}, - {0x1204, "GD 7541 [Nordic Light]", NULL}, - {0x4000, "MD 5620 [CLM Data Fax Voice]", NULL}, - {0x4400, "CD 4400", NULL}, - {0x6001, "CS 4610/11 [CrystalClear SoundFusion Audio Accelerator]", NULL}, - {0x6003, "CS 4614/22/24 [CrystalClear SoundFusion Audio Accelerator]", NULL}, - {0x6004, "CS 4614/22/24 [CrystalClear SoundFusion Audio Accelerator]", NULL}, - {0x6005, "Crystal CS4281 PCI Audio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1014[] = { - {0x0002, "PCI to MCA Bridge", NULL}, - {0x0005, "Alta Lite", NULL}, - {0x0007, "Alta MP", NULL}, - {0x000A, "Fire Coral", NULL}, - {0x0017, "CPU to PCI Bridge", NULL}, - {0x0018, "TR Auto LANstreamer", NULL}, - {0x001B, "GXT-150P", NULL}, - {0x001C, "Carrera", NULL}, - {0x001D, "82G2675", NULL}, - {0x0020, "GXT1000 Graphics Adapter", NULL}, - {0x0022, "IBM27-82351", NULL}, - {0x002D, "Python", NULL}, - {0x002E, "SCSI RAID Adapter [ServeRAID]", NULL}, - {0x0031, "2 Port Serial Adapter", NULL}, - {0x0036, "Miami", NULL}, - {0x0037, "82660 CPU to PCI Bridge", NULL}, - {0x003A, "CPU to PCI Bridge", NULL}, - {0x003C, "GXT250P/GXT255P Graphics Adapter", NULL}, - {0x003E, "16/4 Token ring UTP/STP controller", NULL}, - {0x0045, "SSA Adapter", NULL}, - {0x0046, "MPIC interrupt controller", NULL}, - {0x0047, "PCI to PCI Bridge", NULL}, - {0x0048, "PCI to PCI Bridge", NULL}, - {0x0049, "Warhead SCSI Controller", NULL}, - {0x004E, "ATM Controller (14104e00)", NULL}, - {0x004F, "ATM Controller (14104f00)", NULL}, - {0x0050, "ATM Controller (14105000)", NULL}, - {0x0053, "25 MBit ATM Controller", NULL}, - {0x0054, "GXT500P/GXT550P Graphics Adapter", NULL}, - {0x0057, "MPEG PCI Bridge", NULL}, - {0x005C, "i82557B 10/100", NULL}, - {0x005E, "GXT800P Graphics Adapter", NULL}, - {0x007C, "ATM Controller (14107c00)", NULL}, - {0x007D, "3780IDSP [MWave]", NULL}, - {0x008B, "EADS PCI to PCI Bridge", NULL}, - {0x008E, "GXT3000P Graphics Adapter", NULL}, - {0x0090, "GXT 3000P", NULL}, - {0x0091, "SSA Adapter", NULL}, - {0x0095, "20H2999 PCI Docking Bridge", NULL}, - {0x0096, "Chukar chipset SCSI controller", NULL}, - {0x009F, "PCI 4758 Cryptographic Accelerator", NULL}, - {0x00A5, "ATM Controller (1410a500)", NULL}, - {0x00A6, "ATM 155MBPS MM Controller (1410a600)", NULL}, - {0x00B7, "256-bit Graphics Rasterizer [Fire GL1]", NULL}, - {0x00B8, "GXT2000P Graphics Adapter", NULL}, - {0x00BE, "ATM 622MBPS Controller (1410be00)", NULL}, - {0x00DC, "Advanced Systems Management Adapter (ASMA)", NULL}, - {0x00FC, "CPC710 Dual Bridge and Memory Controller (PCI-64)", NULL}, - {0x0104, "Gigabit Ethernet-SX Adapter", NULL}, - {0x0105, "CPC710 Dual Bridge and Memory Controller (PCI-32)", NULL}, - {0x010F, "Remote Supervisor Adapter (RSA)", NULL}, - {0x0142, "Yotta Video Compositor Input", NULL}, - {0x0144, "Yotta Video Compositor Output", NULL}, - {0x0156, "405GP PLB to PCI Bridge", NULL}, - {0x015E, "622Mbps ATM PCI Adapter", NULL}, - {0x0160, "64bit/66MHz PCI ATM 155 MMF", NULL}, - {0x016E, "GXT4000P Graphics Adapter", NULL}, - {0x0170, "GXT6000P Graphics Adapter", NULL}, - {0x017D, "GXT300P Graphics Adapter", NULL}, - {0x0180, "Snipe chipset SCSI controller", NULL}, - {0x0188, "EADS-X PCI-X to PCI-X Bridge", NULL}, - {0x01A7, "PCI-X to PCI-X Bridge", NULL}, - {0x01BD, "ServeRAID Controller", NULL}, - {0x01C1, "64bit/66MHz PCI ATM 155 UTP", NULL}, - {0x01E6, "Cryptographic Accelerator", NULL}, - {0x01FF, "10/100 Mbps Ethernet", NULL}, - {0x0219, "Multiport Serial Adapter", NULL}, - {0x021B, "GXT6500P Graphics Adapter", NULL}, - {0x021C, "GXT4500P Graphics Adapter", NULL}, - {0x0233, "GXT135P Graphics Adapter", NULL}, - {0x0266, "PCI-X Dual Channel SCSI", NULL}, - {0x0268, "Gigabit Ethernet-SX Adapter (PCI-X)", NULL}, - {0x0269, "10/100/1000 Base-TX Ethernet Adapter (PCI-X)", NULL}, - {0x028C, "Citrine chipset SCSI controller", NULL}, - {0x02A1, "Calgary PCI-X Host Bridge", NULL}, - {0x02BD, "Obsidian chipset SCSI controller", NULL}, - {0x0302, "Winnipeg PCI-X Host Bridge", NULL}, - {0x0314, "ZISC 036 Neural accelerator card", NULL}, - {0x3022, "QLA3022 Network Adapter", NULL}, - {0x4022, "QLA3022 Network Adapter", NULL}, - {0xFFFF, "MPIC-2 interrupt controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1017[] = { - {0x5343, "SPEA 3D Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_101A[] = { - {0x0005, "100VG ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_101C[] = { - {0x0193, "33C193A", NULL}, - {0x0196, "33C196A", NULL}, - {0x0197, "33C197A", NULL}, - {0x0296, "33C296A", NULL}, - {0x3193, "7193", NULL}, - {0x3197, "7197", NULL}, - {0x3296, "33C296A", NULL}, - {0x4296, "34C296", NULL}, - {0x9710, "Pipeline 9710", NULL}, - {0x9712, "Pipeline 9712", NULL}, - {0xC24A, "90C", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_101E[] = { - {0x0009, "MegaRAID 428 Ultra RAID Controller (rev 03)", NULL}, - {0x1960, "MegaRAID", NULL}, - {0x9010, "MegaRAID 428 Ultra RAID Controller", NULL}, - {0x9030, "EIDE Controller", NULL}, - {0x9031, "EIDE Controller", NULL}, - {0x9032, "EIDE & SCSI Controller", NULL}, - {0x9033, "SCSI Controller", NULL}, - {0x9040, "Multimedia card", NULL}, - {0x9060, "MegaRAID 434 Ultra GT RAID Controller", NULL}, - {0x9063, "MegaRAC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1022[] = { - {0x1100, "K8 [Athlon64/Opteron] HyperTransport Technology Configuration", NULL}, - {0x1101, "K8 [Athlon64/Opteron] Address Map", NULL}, - {0x1102, "K8 [Athlon64/Opteron] DRAM Controller", NULL}, - {0x1103, "K8 [Athlon64/Opteron] Miscellaneous Control", NULL}, - {0x2000, "79c970 [PCnet32 LANCE]", NULL}, - {0x2001, "79c978 [HomePNA]", NULL}, - {0x2003, "Am 1771 MBW [Alchemy]", NULL}, - {0x2020, "53c974 [PCscsi]", NULL}, - {0x2040, "79c974", NULL}, - {0x2081, "Geode LX Video", NULL}, - {0x2082, "Geode LX AES Security Block", NULL}, - {0x208F, "CS5536 GeodeLink PCI South Bridge", NULL}, - {0x2090, "CS5536 [Geode companion] ISA", NULL}, - {0x2091, "CS5536 [Geode companion] FLASH", NULL}, - {0x2093, "CS5536 [Geode companion] Audio", NULL}, - {0x2094, "CS5536 [Geode companion] OHC", NULL}, - {0x2095, "CS5536 [Geode companion] EHC", NULL}, - {0x2096, "CS5536 [Geode companion] UDC", NULL}, - {0x2097, "CS5536 [Geode companion] UOC", NULL}, - {0x209A, "CS5536 [Geode companion] IDE", NULL}, - {0x3000, "ELanSC520 Microcontroller", NULL}, - {0x7006, "AMD-751 [Irongate] System Controller", NULL}, - {0x7007, "AMD-751 [Irongate] AGP Bridge", NULL}, - {0x700A, "AMD-IGR4 AGP Host to PCI Bridge", NULL}, - {0x700B, "AMD-IGR4 PCI to PCI Bridge", NULL}, - {0x700C, "AMD-760 MP [IGD4-2P] System Controller", NULL}, - {0x700D, "AMD-760 MP [IGD4-2P] AGP Bridge", NULL}, - {0x700E, "AMD-760 [IGD4-1P] System Controller", NULL}, - {0x700F, "AMD-760 [IGD4-1P] AGP Bridge", NULL}, - {0x7400, "AMD-755 [Cobra] ISA", NULL}, - {0x7401, "AMD-755 [Cobra] IDE", NULL}, - {0x7403, "AMD-755 [Cobra] ACPI", NULL}, - {0x7404, "AMD-755 [Cobra] USB", NULL}, - {0x7408, "AMD-756 [Viper] ISA", NULL}, - {0x7409, "AMD-756 [Viper] IDE", NULL}, - {0x740B, "AMD-756 [Viper] ACPI", NULL}, - {0x740C, "AMD-756 [Viper] USB", NULL}, - {0x7410, "AMD-766 [ViperPlus] ISA", NULL}, - {0x7411, "AMD-766 [ViperPlus] IDE", NULL}, - {0x7413, "AMD-766 [ViperPlus] ACPI", NULL}, - {0x7414, "AMD-766 [ViperPlus] USB", NULL}, - {0x7440, "AMD-768 [Opus] ISA", NULL}, - {0x7441, "AMD-768 [Opus] IDE", NULL}, - {0x7443, "AMD-768 [Opus] ACPI", NULL}, - {0x7445, "AMD-768 [Opus] Audio", NULL}, - {0x7446, "AMD-768 [Opus] MC97 Modem (Smart Link HAMR5600 compatible)", NULL}, - {0x7448, "AMD-768 [Opus] PCI", NULL}, - {0x7449, "AMD-768 [Opus] USB", NULL}, - {0x7450, "AMD-8131 PCI-X Bridge", NULL}, - {0x7451, "AMD-8131 PCI-X IOAPIC", NULL}, - {0x7454, "AMD-8151 System Controller", NULL}, - {0x7455, "AMD-8151 AGP Bridge", NULL}, - {0x7458, "AMD-8132 PCI-X Bridge", NULL}, - {0x7459, "AMD-8132 PCI-X IOAPIC", NULL}, - {0x7460, "AMD-8111 PCI", NULL}, - {0x7461, "AMD-8111 USB", NULL}, - {0x7462, "AMD-8111 Ethernet", NULL}, - {0x7464, "AMD-8111 USB", NULL}, - {0x7468, "AMD-8111 LPC", NULL}, - {0x7469, "AMD-8111 IDE", NULL}, - {0x746A, "AMD-8111 SMBus 2.0", NULL}, - {0x746B, "AMD-8111 ACPI", NULL}, - {0x746D, "AMD-8111 AC97 Audio", NULL}, - {0x746E, "AMD-8111 MC97 Modem", NULL}, - {0x756B, "AMD-8111 ACPI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1023[] = { - {0x0194, "82C194", NULL}, - {0x2000, "4DWave DX", NULL}, - {0x2001, "4DWave NX", NULL}, - {0x2100, "CyberBlade XP4m32", NULL}, - {0x2200, "XGI Volari XP5", NULL}, - {0x8400, "CyberBlade/i7", NULL}, - {0x8420, "CyberBlade/i7d", NULL}, - {0x8500, "CyberBlade/i1", NULL}, - {0x8520, "CyberBlade i1", NULL}, - {0x8620, "CyberBlade/i1", NULL}, - {0x8820, "CyberBlade XPAi1", NULL}, - {0x9320, "TGUI 9320", NULL}, - {0x9350, "GUI Accelerator", NULL}, - {0x9360, "Flat panel GUI Accelerator", NULL}, - {0x9382, "Cyber 9382 [Reference design]", NULL}, - {0x9383, "Cyber 9383 [Reference design]", NULL}, - {0x9385, "Cyber 9385 [Reference design]", NULL}, - {0x9386, "Cyber 9386", NULL}, - {0x9388, "Cyber 9388", NULL}, - {0x9397, "Cyber 9397", NULL}, - {0x939A, "Cyber 9397DVD", NULL}, - {0x9420, "TGUI 9420", NULL}, - {0x9430, "TGUI 9430", NULL}, - {0x9440, "TGUI 9440", NULL}, - {0x9460, "TGUI 9460", NULL}, - {0x9470, "TGUI 9470", NULL}, - {0x9520, "Cyber 9520", NULL}, - {0x9525, "Cyber 9525", NULL}, - {0x9540, "Cyber 9540", NULL}, - {0x9660, "TGUI 9660/938x/968x", NULL}, - {0x9680, "TGUI 9680", NULL}, - {0x9682, "TGUI 9682", NULL}, - {0x9683, "TGUI 9683", NULL}, - {0x9685, "ProVIDIA 9685", NULL}, - {0x9750, "3DImage 9750", NULL}, - {0x9753, "TGUI 9753", NULL}, - {0x9754, "TGUI 9754", NULL}, - {0x9759, "TGUI 975", NULL}, - {0x9783, "TGUI 9783", NULL}, - {0x9785, "TGUI 9785", NULL}, - {0x9850, "3DImage 9850", NULL}, - {0x9880, "Blade 3D PCI/AGP", NULL}, - {0x9910, "CyberBlade/XP", NULL}, - {0x9930, "CyberBlade/XPm", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1025[] = { - {0x1435, "M1435", NULL}, - {0x1445, "M1445", NULL}, - {0x1449, "M1449", NULL}, - {0x1451, "M1451", NULL}, - {0x1461, "M1461", NULL}, - {0x1489, "M1489", NULL}, - {0x1511, "M1511", NULL}, - {0x1512, "ALI M1512 Aladdin", NULL}, - {0x1513, "M1513", NULL}, - {0x1521, "ALI M1521 Aladdin III CPU Bridge", NULL}, - {0x1523, "ALI M1523 ISA Bridge", NULL}, - {0x1531, "M1531 Northbridge [Aladdin IV/IV+]", NULL}, - {0x1533, "M1533 PCI-to-ISA Bridge", NULL}, - {0x1535, "M1535 PCI Bridge + Super I/O + FIR", NULL}, - {0x1541, "M1541 Northbridge [Aladdin V]", NULL}, - {0x1542, "M1542 Northbridge [Aladdin V]", NULL}, - {0x1543, "M1543 PCI-to-ISA Bridge + Super I/O + FIR", NULL}, - {0x1561, "M1561 Northbridge [Aladdin 7]", NULL}, - {0x1621, "M1621 Northbridge [Aladdin-Pro II]", NULL}, - {0x1631, "M1631 Northbridge+3D Graphics [Aladdin TNT2]", NULL}, - {0x1641, "M1641 Northbridge [Aladdin-Pro IV]", NULL}, - {0x1647, "M1647 [MaGiK1] PCI North Bridge", NULL}, - {0x1671, "M1671 Northbridge [ALADDiN-P4]", NULL}, - {0x1672, "Northbridge [CyberALADDiN-P4]", NULL}, - {0x3141, "M3141", NULL}, - {0x3143, "M3143", NULL}, - {0x3145, "M3145", NULL}, - {0x3147, "M3147", NULL}, - {0x3149, "M3149", NULL}, - {0x3151, "M3151", NULL}, - {0x3307, "M3307 MPEG-I Video Controller", NULL}, - {0x3309, "M3309 MPEG-II Video w/ Software Audio Decoder", NULL}, - {0x3321, "M3321 MPEG-II Audio/Video Decoder", NULL}, - {0x5212, "M4803", NULL}, - {0x5215, "ALI PCI EIDE Controller", NULL}, - {0x5217, "M5217H", NULL}, - {0x5219, "M5219", NULL}, - {0x5225, "M5225", NULL}, - {0x5229, "M5229", NULL}, - {0x5235, "M5235", NULL}, - {0x5237, "M5237 PCI USB Host Controller", NULL}, - {0x5240, "EIDE Controller", NULL}, - {0x5241, "PCMCIA Bridge", NULL}, - {0x5242, "General Purpose Controller", NULL}, - {0x5243, "PCI to PCI Bridge Controller", NULL}, - {0x5244, "Floppy Disk Controller", NULL}, - {0x5247, "M1541 PCI to PCI Bridge", NULL}, - {0x5251, "M5251 P1394 Controller", NULL}, - {0x5427, "PCI to AGP Bridge", NULL}, - {0x5451, "M5451 PCI AC-Link Controller Audio Device", NULL}, - {0x5453, "M5453 PCI AC-Link Controller Modem Device", NULL}, - {0x7101, "M7101 PCI PMU Power Management Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1028[] = { - {0x0001, "PowerEdge Expandable RAID Controller 2/Si", NULL}, - {0x0002, "PowerEdge Expandable RAID Controller 3/Di", NULL}, - {0x0003, "PowerEdge Expandable RAID Controller 3/Si", NULL}, - {0x0006, "PowerEdge Expandable RAID Controller 3/Di", NULL}, - {0x0007, "Remote Access Card III", NULL}, - {0x0008, "Remote Access Card III", NULL}, - {0x0009, "Remote Access Card III: BMC/SMIC device not present", NULL}, - {0x000A, "PowerEdge Expandable RAID Controller 3/Di", NULL}, - {0x000C, "Embedded Remote Access or ERA/O", NULL}, - {0x000D, "Embedded Remote Access: BMC/SMIC device", NULL}, - {0x000E, "PowerEdge Expandable RAID controller 4/Di", NULL}, - {0x000F, "PowerEdge Expandable RAID controller 4/Di", NULL}, - {0x0010, "Remote Access Card 4", NULL}, - {0x0011, "Remote Access Card 4 Daughter Card", NULL}, - {0x0012, "Remote Access Card 4 Daughter Card Virtual UART", NULL}, - {0x0013, "PowerEdge Expandable RAID controller 4", NULL}, - {0x0014, "Remote Access Card 4 Daughter Card SMIC interface", NULL}, - {0x0015, "PowerEdge Expandable RAID controller 5", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_102A[] = { - {0x0000, "HYDRA", NULL}, - {0x0010, "ASPEN", NULL}, - {0x001F, "AHA-2940U2/U2W /7890/7891 SCSI Controllers", NULL}, - {0x00C5, "AIC-7899 U160/m SCSI Controller", NULL}, - {0x00CF, "AIC-7899P U160/m", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_102B[] = { - {0x0010, "MGA-I [Impression?]", NULL}, - {0x0100, "MGA 1064SG [Mystique]", NULL}, - {0x0518, "MGA-II [Athena]", NULL}, - {0x0519, "MGA 2064W [Millennium]", NULL}, - {0x051A, "MGA 1064SG [Mystique]", NULL}, - {0x051B, "MGA 2164W [Millennium II]", NULL}, - {0x051E, "MGA 1064SG [Mystique] AGP", NULL}, - {0x051F, "MGA 2164W [Millennium II] AGP", NULL}, - {0x0520, "MGA G200", NULL}, - {0x0521, "MGA G200 AGP", NULL}, - {0x0525, "G400/G450", NULL}, - {0x0527, "MGA Parhelia AGP", NULL}, - {0x0528, "Parhelia 8X", NULL}, - {0x0D10, "MGA Ultima/Impression", NULL}, - {0x1000, "MGA G100 [Productiva]", NULL}, - {0x1001, "MGA G100 [Productiva] AGP", NULL}, - {0x2007, "MGA Mistral", NULL}, - {0x2527, "MGA G550 AGP", NULL}, - {0x2537, "Millenium P650/P750", NULL}, - {0x2538, "Millenium P650 PCIe", NULL}, - {0x4536, "VIA Framegrabber", NULL}, - {0x6573, "Shark 10/100 Multiport SwitchNIC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_102C[] = { - {0x00B8, "F64310", NULL}, - {0x00C0, "F69000 HiQVideo", NULL}, - {0x00D0, "F65545", NULL}, - {0x00D8, "F65545", NULL}, - {0x00DC, "F65548", NULL}, - {0x00E0, "F65550", NULL}, - {0x00E4, "F65554", NULL}, - {0x00E5, "F65555 HiQVPro", NULL}, - {0x00F0, "F68554", NULL}, - {0x00F4, "F68554 HiQVision", NULL}, - {0x00F5, "F68555", NULL}, - {0x0C30, "F69030", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_102D[] = { - {0x50DC, "3328 Audio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_102F[] = { - {0x0009, "r4x00", NULL}, - {0x000A, "TX3927 MIPS RISC PCI Controller", NULL}, - {0x0020, "ATM Meteor 155", NULL}, - {0x0030, "TC35815CF PCI 10/100 Mbit Ethernet Controller", NULL}, - {0x0031, "TC35815CF PCI 10/100 Mbit Ethernet Controller with WOL", NULL}, - {0x0105, "TC86C001 [goku-s] IDE", NULL}, - {0x0106, "TC86C001 [goku-s] USB 1.1 Host", NULL}, - {0x0107, "TC86C001 [goku-s] USB Device Controller", NULL}, - {0x0108, "TC86C001 [goku-s] I2C/SIO/GPIO Controller", NULL}, - {0x0180, "TX4927/38 MIPS RISC PCI Controller", NULL}, - {0x0181, "TX4925 MIPS RISC PCI Controller", NULL}, - {0x0182, "TX4937 MIPS RISC PCI Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1031[] = { - {0x5601, "DC20 ASIC", NULL}, - {0x5607, "Video I/O & motion JPEG compressor", NULL}, - {0x5631, "Media 3D", NULL}, - {0x6057, "MiroVideo DC10/DC30+", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1033[] = { - {0x0000, "Vr4181A USB Host or Function Control Unit", NULL}, - {0x0001, "PCI to 486-like bus Bridge", NULL}, - {0x0002, "PCI to VL98 Bridge", NULL}, - {0x0003, "ATM Controller", NULL}, - {0x0004, "R4000 PCI Bridge", NULL}, - {0x0005, "PCI to 486-like bus Bridge", NULL}, - {0x0006, "PC-9800 Graphic Accelerator", NULL}, - {0x0007, "PCI to UX-Bus Bridge", NULL}, - {0x0008, "PC-9800 Graphic Accelerator", NULL}, - {0x0009, "PCI to PC9800 Core-Graph Bridge", NULL}, - {0x0016, "PCI to VL Bridge", NULL}, - {0x001A, "[Nile II]", NULL}, - {0x0021, "Vrc4373 [Nile I]", NULL}, - {0x0029, "PowerVR PCX1", NULL}, - {0x002A, "PowerVR 3D", NULL}, - {0x002C, "Star Alpha 2", NULL}, - {0x002D, "PCI to C-bus Bridge", NULL}, - {0x0035, "USB", NULL}, - {0x003B, "PCI to C-bus Bridge", NULL}, - {0x003E, "NAPCCARD Cardbus Controller", NULL}, - {0x0046, "PowerVR PCX2 [midas]", NULL}, - {0x005A, "Vrc5074 [Nile 4]", NULL}, - {0x0063, "Firewarden", NULL}, - {0x0067, "PowerVR Neon 250 Chipset", NULL}, - {0x0072, "uPD72874 IEEE1394 OHCI 1.1 3-port PHY-Link Ctrlr", NULL}, - {0x0074, "56k Voice Modem", NULL}, - {0x009B, "Vrc5476", NULL}, - {0x00A5, "VRC4173", NULL}, - {0x00A6, "VRC5477 AC97", NULL}, - {0x00CD, "IEEE 1394 [OrangeLink] Host Controller", NULL}, - {0x00CE, "IEEE 1394 Host Controller", NULL}, - {0x00DF, "Vr4131", NULL}, - {0x00E0, "USB 2.0", NULL}, - {0x00E7, "IEEE 1394 Host Controller", NULL}, - {0x00F2, "uPD72874 IEEE1394 OHCI 1.1 3-port PHY-Link Ctrlr", NULL}, - {0x00F3, "uPD6113x Multimedia Decoder/Processor [EMMA2]", NULL}, - {0x010C, "VR7701", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1036[] = { - {0x0000, "TMC-18C30 [36C70]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1039[] = { - {0x0001, "Virtual PCI-to-PCI bridge (AGP)", NULL}, - {0x0002, "SG86C202", NULL}, - {0x0003, "SiS AGP Port (virtual PCI-to-PCI bridge)", NULL}, - {0x0004, "PCI-to-PCI bridge", NULL}, - {0x0006, "85C501/2/3", NULL}, - {0x0008, "SiS85C503/5513 (LPC Bridge)", NULL}, - {0x0009, "ACPI", NULL}, - {0x000A, "PCI-to-PCI bridge", NULL}, - {0x0016, "SiS961/2 SMBus Controller", NULL}, - {0x0018, "SiS85C503/5513 (LPC Bridge)", NULL}, - {0x0180, "RAID bus controller 180 SATA/PATA [SiS]", NULL}, - {0x0181, "SATA", NULL}, - {0x0182, "182 SATA/RAID Controller", NULL}, - {0x0190, "190 Gigabit Ethernet Adapter", NULL}, - {0x0191, "191 Gigabit Ethernet Adapter", NULL}, - {0x0200, "5597/5598/6326 VGA", NULL}, - {0x0204, "82C204", NULL}, - {0x0205, "SG86C205", NULL}, - {0x0300, "300/305 PCI/AGP VGA Display Adapter", NULL}, - {0x0310, "315H PCI/AGP VGA Display Adapter", NULL}, - {0x0315, "315 PCI/AGP VGA Display Adapter", NULL}, - {0x0325, "315PRO PCI/AGP VGA Display Adapter", NULL}, - {0x0330, "330 [Xabre] PCI/AGP VGA Display Adapter", NULL}, - {0x0406, "85C501/2", NULL}, - {0x0496, "85C496", NULL}, - {0x0530, "530 Host", NULL}, - {0x0540, "540 Host", NULL}, - {0x0550, "550 Host", NULL}, - {0x0597, "5513C", NULL}, - {0x0601, "85C601", NULL}, - {0x0620, "620 Host", NULL}, - {0x0630, "630 Host", NULL}, - {0x0633, "633 Host", NULL}, - {0x0635, "635 Host", NULL}, - {0x0645, "SiS645 Host & Memory & AGP Controller", NULL}, - {0x0646, "SiS645DX Host & Memory & AGP Controller", NULL}, - {0x0648, "645xx", NULL}, - {0x0650, "650/M650 Host", NULL}, - {0x0651, "651 Host", NULL}, - {0x0655, "655 Host", NULL}, - {0x0660, "660 Host", NULL}, - {0x0661, "661FX/M661FX/M661MX Host", NULL}, - {0x0730, "730 Host", NULL}, - {0x0733, "733 Host", NULL}, - {0x0735, "735 Host", NULL}, - {0x0740, "740 Host", NULL}, - {0x0741, "741/741GX/M741 Host", NULL}, - {0x0745, "745 Host", NULL}, - {0x0746, "746 Host", NULL}, - {0x0755, "755 Host", NULL}, - {0x0760, "760/M760 Host", NULL}, - {0x0761, "761/M761 Host", NULL}, - {0x0900, "SiS900 PCI Fast Ethernet", NULL}, - {0x0961, "SiS961 [MuTIOL Media IO]", NULL}, - {0x0962, "SiS962 [MuTIOL Media IO]", NULL}, - {0x0963, "SiS963 [MuTIOL Media IO]", NULL}, - {0x0964, "SiS964 [MuTIOL Media IO]", NULL}, - {0x0965, "SiS965 [MuTIOL Media IO]", NULL}, - {0x3602, "83C602", NULL}, - {0x5107, "5107", NULL}, - {0x5300, "SiS540 PCI Display Adapter", NULL}, - {0x5315, "550 PCI/AGP VGA Display Adapter", NULL}, - {0x5401, "486 PCI Chipset", NULL}, - {0x5511, "5511/5512", NULL}, - {0x5513, "5513 [IDE]", NULL}, - {0x5517, "5517", NULL}, - {0x5571, "5571", NULL}, - {0x5581, "5581 Pentium Chipset", NULL}, - {0x5582, "5582", NULL}, - {0x5591, "5591/5592 Host", NULL}, - {0x5596, "5596 Pentium Chipset", NULL}, - {0x5597, "5597 [SiS5582]", NULL}, - {0x5600, "5600 Host", NULL}, - {0x6204, "Video decoder & MPEG interface", NULL}, - {0x6205, "VGA Controller", NULL}, - {0x6236, "6236 3D-AGP", NULL}, - {0x6300, "630/730 PCI/AGP VGA Display Adapter", NULL}, - {0x6306, "530/620 PCI/AGP VGA Display Adapter", NULL}, - {0x6325, "65x/M650/740 PCI/AGP VGA Display Adapter", NULL}, - {0x6326, "86C326 5598/6326", NULL}, - {0x6330, "661/741/760/761 PCI/AGP VGA Display Adapter", NULL}, - {0x7001, "USB 1.0 Controller", NULL}, - {0x7002, "USB 2.0 Controller", NULL}, - {0x7007, "FireWire Controller", NULL}, - {0x7012, "AC'97 Sound Controller", NULL}, - {0x7013, "AC'97 Modem Controller", NULL}, - {0x7016, "SiS7016 PCI Fast Ethernet Adapter", NULL}, - {0x7018, "SiS PCI Audio Accelerator", NULL}, - {0x7019, "SiS7019 Audio Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_103C[] = { - {0x1005, "A4977A Visualize EG", NULL}, - {0x1006, "Visualize FX6", NULL}, - {0x1008, "Visualize FX4", NULL}, - {0x100A, "Visualize FX2", NULL}, - {0x1028, "Tach TL Fibre Channel Host Adapter", NULL}, - {0x1029, "Tach XL2 Fibre Channel Host Adapter", NULL}, - {0x102A, "Tach TS Fibre Channel Host Adapter", NULL}, - {0x1030, "J2585A DeskDirect 10/100VG NIC", NULL}, - {0x1031, "J2585B HP 10/100VG PCI LAN Adapter", NULL}, - {0x1040, "J2973A DeskDirect 10BaseT NIC", NULL}, - {0x1041, "J2585B DeskDirect 10/100 NIC", NULL}, - {0x1042, "J2970A DeskDirect 10BaseT/2 NIC", NULL}, - {0x1048, "Diva Serial [GSP] Multiport UART", NULL}, - {0x1054, "PCI Local Bus Adapter", NULL}, - {0x1064, "79C970 PCnet Ethernet Controller", NULL}, - {0x108B, "Visualize FXe", NULL}, - {0x10C1, "NetServer Smart IRQ Router", NULL}, - {0x10ED, "TopTools Remote Control", NULL}, - {0x10F0, "rio System Bus Adapter", NULL}, - {0x10F1, "rio I/O Controller", NULL}, - {0x1200, "82557B 10/100 NIC", NULL}, - {0x1219, "NetServer PCI Hot-Plug Controller", NULL}, - {0x121A, "NetServer SMIC Controller", NULL}, - {0x121B, "NetServer Legacy COM Port Decoder", NULL}, - {0x121C, "NetServer PCI COM Port Decoder", NULL}, - {0x1229, "zx1 System Bus Adapter", NULL}, - {0x122A, "zx1 I/O Controller", NULL}, - {0x122E, "zx1 Local Bus Adapter", NULL}, - {0x127C, "sx1000 I/O Controller", NULL}, - {0x1290, "Auxiliary Diva Serial Port", NULL}, - {0x1291, "Auxiliary Diva Serial Port", NULL}, - {0x12B4, "zx1 QuickSilver AGP8x Local Bus Adapter", NULL}, - {0x12FA, "BCM4306 802.11b/g Wireless LAN Controller", NULL}, - {0x2910, "E2910A PCIBus Exerciser", NULL}, - {0x2925, "E2925A 32 Bit, 33 MHzPCI Exerciser & Analyzer", NULL}, - {0x3080, "Pavilion ze2028ea", NULL}, - {0x3220, "Hewlett-Packard Smart Array P600", NULL}, - {0x3230, "Hewlett-Packard Smart Array Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1042[] = { - {0x1000, "PC Tech RZ1000", NULL}, - {0x1001, "PC Tech RZ1001", NULL}, - {0x3000, "Samurai_0", NULL}, - {0x3010, "Samurai_1", NULL}, - {0x3020, "Samurai_IDE", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1043[] = { - {0x0675, "ISDNLink P-IN100-ST-D", NULL}, - {0x4015, "v7100 SDRAM [GeForce2 MX]", NULL}, - {0x4021, "v7100 Combo Deluxe [GeForce2 MX + TV tuner]", NULL}, - {0x4057, "v8200 GeForce 3", NULL}, - {0x8043, "v8240 PAL 128M [P4T] Motherboard", NULL}, - {0x807B, "v9280/TD [Geforce4 TI4200 8X With TV-Out and DVI]", NULL}, - {0x80BB, "v9180 Magic/T [GeForce4 MX440 AGP 8x 64MB TV-out]", NULL}, - {0x80C5, "nForce3 chipset motherboard [SK8N]", NULL}, - {0x80DF, "v9520 Magic/T", NULL}, - {0x8187, "802.11a/b/g Wireless LAN Card", NULL}, - {0x8188, "Tiger Hybrid TV Capture Device", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1044[] = { - {0x1012, "Domino RAID Engine", NULL}, - {0xA400, "SmartCache/Raid I-IV Controller", NULL}, - {0xA500, "PCI Bridge", NULL}, - {0xA501, "SmartRAID V Controller", NULL}, - {0xA511, "SmartRAID V Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1045[] = { - {0xA0F8, "82C750 [Vendetta] USB Controller", NULL}, - {0xC101, "92C264", NULL}, - {0xC178, "92C178", NULL}, - {0xC556, "82X556 [Viper]", NULL}, - {0xC557, "82C557 [Viper-M]", NULL}, - {0xC558, "82C558 [Viper-M ISA+IDE]", NULL}, - {0xC567, "82C750 [Vendetta], device 0", NULL}, - {0xC568, "82C750 [Vendetta], device 1", NULL}, - {0xC569, "82C579 [Viper XPress+ Chipset]", NULL}, - {0xC621, "82C621 [Viper-M/N+]", NULL}, - {0xC700, "82C700 [FireStar]", NULL}, - {0xC701, "82C701 [FireStar Plus]", NULL}, - {0xC814, "82C814 [Firebridge 1]", NULL}, - {0xC822, "82C822", NULL}, - {0xC824, "82C824", NULL}, - {0xC825, "82C825 [Firebridge 2]", NULL}, - {0xC832, "82C832", NULL}, - {0xC861, "82C861", NULL}, - {0xC895, "82C895", NULL}, - {0xC935, "EV1935 ECTIVA MachOne PCIAudio", NULL}, - {0xD568, "82C825 [Firebridge 2]", NULL}, - {0xD721, "IDE [FireStar]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1048[] = { - {0x0C60, "Gladiac MX", NULL}, - {0x0D22, "Quadro4 900XGL [ELSA GLoria4 900XGL]", NULL}, - {0x1000, "QuickStep 1000", NULL}, - {0x3000, "QuickStep 3000", NULL}, - {0x8901, "Gloria XL", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_104A[] = { - {0x0008, "STG 2000X", NULL}, - {0x0009, "STG 1764X", NULL}, - {0x0010, "STG4000 [3D Prophet Kyro Series]", NULL}, - {0x0209, "STPC Consumer/Industrial North- and Southbridge", NULL}, - {0x020A, "STPC Atlas/ConsumerS/Consumer IIA Northbridge", NULL}, - {0x0210, "STPC Atlas ISA Bridge", NULL}, - {0x021A, "STPC Consumer S Southbridge", NULL}, - {0x021B, "STPC Consumer IIA Southbridge", NULL}, - {0x0500, "ST70137 [Unicorn] ADSL DMT Transceiver", NULL}, - {0x0564, "STPC Client Northbridge", NULL}, - {0x0981, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x1746, "STG 1764X", NULL}, - {0x2774, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x3520, "MPEG-II decoder card", NULL}, - {0x55CC, "STPC Client Southbridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_104B[] = { - {0x0140, "BT-946C (old) [multimaster 01]", NULL}, - {0x1040, "BT-946C (BA80C30) [MultiMaster 10]", NULL}, - {0x8130, "Flashpoint LT", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_104C[] = { - {0x0500, "100 MBit LAN Controller", NULL}, - {0x0508, "TMS380C2X Compressor Interface", NULL}, - {0x1000, "Eagle i/f AS", NULL}, - {0x104C, "PCI1510 PC card Cardbus Controller", NULL}, - {0x3D04, "TVP4010 [Permedia]", NULL}, - {0x3D07, "TVP4020 [Permedia 2]", NULL}, - {0x8000, "PCILynx/PCILynx2 IEEE 1394 Link Layer Controller", NULL}, - {0x8009, "FireWire Controller", NULL}, - {0x8017, "PCI4410 FireWire Controller", NULL}, - {0x8019, "TSB12LV23 IEEE-1394 Controller", NULL}, - {0x8020, "TSB12LV26 IEEE-1394 Controller (Link)", NULL}, - {0x8021, "TSB43AA22 IEEE-1394 Controller (PHY/Link Integrated)", NULL}, - {0x8022, "TSB43AB22 IEEE-1394a-2000 Controller (PHY/Link)", NULL}, - {0x8023, "TSB43AB22/A IEEE-1394a-2000 Controller (PHY/Link)", NULL}, - {0x8024, "TSB43AB23 IEEE-1394a-2000 Controller (PHY/Link)", NULL}, - {0x8025, "TSB82AA2 IEEE-1394b Link Layer Controller", NULL}, - {0x8026, "TSB43AB21 IEEE-1394a-2000 Controller (PHY/Link)", NULL}, - {0x8027, "PCI4451 IEEE-1394 Controller", NULL}, - {0x8029, "PCI4510 IEEE-1394 Controller", NULL}, - {0x802B, "PCI7410,7510,7610 OHCI-Lynx Controller", NULL}, - {0x802E, "PCI7x20 1394a-2000 OHCI Two-Port PHY/Link-Layer Controller", NULL}, - {0x8031, "PCIxx21/x515 Cardbus Controller", NULL}, - {0x8032, "OHCI Compliant IEEE 1394 Host Controller", NULL}, - {0x8033, "PCIxx21 Integrated FlashMedia Controller", NULL}, - {0x8034, "PCI6411, PCI6421, PCI6611, PCI6621, PCI7411, PCI7421, PCI7611, PCI7621 Secure Digital (SD) Controller", NULL}, - {0x8035, "PCI6411, PCI6421, PCI6611, PCI6621, PCI7411, PCI7421, PCI7611, PCI7621 Smart Card Controller (SMC)", NULL}, - {0x8036, "PCI6515 Cardbus Controller", NULL}, - {0x8038, "PCI6515 SmartCard Controller", NULL}, - {0x8201, "PCI1620 Firmware Loading Function", NULL}, - {0x8204, "PCI7410,7510,7610 PCI Firmware Loading Function", NULL}, - {0x8400, "ACX 100 22Mbps Wireless Interface", NULL}, - {0x8401, "ACX 100 22Mbps Wireless Interface", NULL}, - {0x9000, "Wireless Interface (of unknown type)", NULL}, - {0x9065, "TMS320DM642", NULL}, - {0x9066, "ACX 111 54Mbps Wireless Interface", NULL}, - {0xA001, "TDC1570", NULL}, - {0xA100, "TDC1561", NULL}, - {0xA102, "TNETA1575 HyperSAR Plus w/PCI Host i/f & UTOPIA i/f", NULL}, - {0xA106, "TMS320C6414 TMS320C6415 TMS320C6416", NULL}, - {0xAC10, "PCI1050", NULL}, - {0xAC11, "PCI1053", NULL}, - {0xAC12, "PCI1130", NULL}, - {0xAC13, "PCI1031", NULL}, - {0xAC15, "PCI1131", NULL}, - {0xAC16, "PCI1250", NULL}, - {0xAC17, "PCI1220", NULL}, - {0xAC18, "PCI1260", NULL}, - {0xAC19, "PCI1221", NULL}, - {0xAC1A, "PCI1210", NULL}, - {0xAC1B, "PCI1450", NULL}, - {0xAC1C, "PCI1225", NULL}, - {0xAC1D, "PCI1251A", NULL}, - {0xAC1E, "PCI1211", NULL}, - {0xAC1F, "PCI1251B", NULL}, - {0xAC20, "TI 2030", NULL}, - {0xAC21, "PCI2031", NULL}, - {0xAC22, "PCI2032 PCI Docking Bridge", NULL}, - {0xAC23, "PCI2250 PCI-to-PCI Bridge", NULL}, - {0xAC28, "PCI2050 PCI-to-PCI Bridge", NULL}, - {0xAC30, "PCI1260 PC card Cardbus Controller", NULL}, - {0xAC40, "PCI4450 PC card Cardbus Controller", NULL}, - {0xAC41, "PCI4410 PC card Cardbus Controller", NULL}, - {0xAC42, "PCI4451 PC card Cardbus Controller", NULL}, - {0xAC44, "PCI4510 PC card Cardbus Controller", NULL}, - {0xAC46, "PCI4520 PC card Cardbus Controller", NULL}, - {0xAC47, "PCI7510 PC card Cardbus Controller", NULL}, - {0xAC4A, "PCI7510,7610 PC card Cardbus Controller", NULL}, - {0xAC50, "PCI1410 PC card Cardbus Controller", NULL}, - {0xAC51, "PCI1420", NULL}, - {0xAC52, "PCI1451 PC card Cardbus Controller", NULL}, - {0xAC53, "PCI1421 PC card Cardbus Controller", NULL}, - {0xAC54, "PCI1620 PC Card Controller", NULL}, - {0xAC55, "PCI1520 PC card Cardbus Controller", NULL}, - {0xAC56, "PCI1510 PC card Cardbus Controller", NULL}, - {0xAC60, "PCI2040 PCI to DSP Bridge Controller", NULL}, - {0xAC8D, "PCI 7620", NULL}, - {0xAC8E, "PCI7420 CardBus Controller", NULL}, - {0xAC8F, "PCI7420/PCI7620 Dual Socket CardBus and Smart Card Cont. w/ 1394a-2000 OHCI Two-Port PHY/Link-Layer Cont. and SD/MS-Pro Sockets", NULL}, - {0xFE00, "FireWire Host Controller", NULL}, - {0xFE03, "12C01A FireWire Host Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_104D[] = { - {0x8004, "DTL-H2500 [Playstation development board]", NULL}, - {0x8009, "CXD1947Q i.LINK Controller", NULL}, - {0x8039, "CXD3222 i.LINK Controller", NULL}, - {0x8056, "Rockwell HCF 56K modem", NULL}, - {0x808A, "Memory Stick Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_104E[] = { - {0x0017, "OTI-64017", NULL}, - {0x0107, "OTI-107 [Spitfire]", NULL}, - {0x0109, "Video Adapter", NULL}, - {0x0111, "OTI-64111 [Spitfire]", NULL}, - {0x0217, "OTI-64217", NULL}, - {0x0317, "OTI-64317", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1050[] = { - {0x0000, "NE2000", NULL}, - {0x0001, "W83769F", NULL}, - {0x0105, "W82C105", NULL}, - {0x0840, "W89C840", NULL}, - {0x0940, "W89C940", NULL}, - {0x5A5A, "W89C940F", NULL}, - {0x6692, "W6692", NULL}, - {0x9921, "W99200F MPEG-1 Video Encoder", NULL}, - {0x9922, "W99200F/W9922PF MPEG-1/2 Video Encoder", NULL}, - {0x9970, "W9970CF", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1055[] = { - {0x9130, "SLC90E66 [Victory66] IDE", NULL}, - {0x9460, "SLC90E66 [Victory66] ISA", NULL}, - {0x9462, "SLC90E66 [Victory66] USB", NULL}, - {0x9463, "SLC90E66 [Victory66] ACPI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1057[] = { - {0x0001, "MPC105 [Eagle]", NULL}, - {0x0002, "MPC106 [Grackle]", NULL}, - {0x0003, "MPC8240 [Kahlua]", NULL}, - {0x0004, "MPC107", NULL}, - {0x0006, "MPC8245 [Unity]", NULL}, - {0x0008, "MPC8540", NULL}, - {0x0009, "MPC8560", NULL}, - {0x0100, "MC145575 [HFC-PCI]", NULL}, - {0x0431, "KTI829c 100VG", NULL}, - {0x1801, "DSP56301 Digital Signal Processor", NULL}, - {0x18C0, "MPC8265A/8266/8272", NULL}, - {0x18C1, "MPC8271/MPC8272", NULL}, - {0x3410, "DSP56361 Digital Signal Processor", NULL}, - {0x4801, "Raven", NULL}, - {0x4802, "Falcon", NULL}, - {0x4803, "Hawk", NULL}, - {0x4806, "CPX8216", NULL}, - {0x4D68, "20268", NULL}, - {0x5600, "SM56 PCI Modem", NULL}, - {0x5608, "Wildcard X100P", NULL}, - {0x5803, "MPC5200", NULL}, - {0x5806, "MCF54 Coldfire", NULL}, - {0x5808, "MPC8220", NULL}, - {0x6400, "MPC190 Security Processor (S1 family, encryption)", NULL}, - {0x6405, "MPC184 Security Processor (S1 family)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_105A[] = { - {0x0D30, "PDC20265 (FastTrak100 Lite/Ultra100)", NULL}, - {0x0D38, "20263", NULL}, - {0x1275, "20275", NULL}, - {0x3318, "PDC20318 (SATA150 TX4)", NULL}, - {0x3319, "PDC20319 (FastTrak S150 TX4)", NULL}, - {0x3371, "PDC20371 (FastTrak S150 TX2plus)", NULL}, - {0x3373, "PDC20378 (FastTrak 378/SATA 378)", NULL}, - {0x3375, "PDC20375 (SATA150 TX2plus)", NULL}, - {0x3376, "PDC20376 (FastTrak 376)", NULL}, - {0x3515, "PDC40719", NULL}, - {0x3519, "PDC40519 (FastTrak TX4200)", NULL}, - {0x3570, "20771 (FastTrak TX2300)", NULL}, - {0x3571, "PDC20571 (FastTrak TX2200)", NULL}, - {0x3574, "PDC20579 SATAII 150 IDE Controller", NULL}, - {0x3577, "PDC40779 (SATA 300 779)", NULL}, - {0x3D17, "PDC20718 (SATA 300 TX4)", NULL}, - {0x3D18, "PDC20518/PDC40518 (SATAII 150 TX4)", NULL}, - {0x3D73, "PDC40775 (SATA 300 TX2plus)", NULL}, - {0x3D75, "PDC20575 (SATAII150 TX2plus)", NULL}, - {0x4D30, "PDC20267 (FastTrak100/Ultra100)", NULL}, - {0x4D33, "20246", NULL}, - {0x4D38, "PDC20262 (FastTrak66/Ultra66)", NULL}, - {0x4D68, "PDC20268 (Ultra100 TX2)", NULL}, - {0x4D69, "20269", NULL}, - {0x5275, "PDC20276 (MBFastTrak133 Lite)", NULL}, - {0x5300, "DC5300", NULL}, - {0x6268, "PDC20270 (FastTrak100 LP/TX2/TX4)", NULL}, - {0x6269, "PDC20271 (FastTrak TX2000)", NULL}, - {0x6621, "PDC20621 (FastTrak S150 SX4/FastTrak SX4000 lite)", NULL}, - {0x6622, "PDC20621 [SATA150 SX4] 4 Channel IDE RAID Controller", NULL}, - {0x6624, "PDC20621 [FastTrak SX4100]", NULL}, - {0x6626, "PDC20618 (Ultra 618)", NULL}, - {0x6629, "PDC20619 (FastTrak TX4000)", NULL}, - {0x7275, "PDC20277 (SBFastTrak133 Lite)", NULL}, - {0x8002, "SATAII150 SX8", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_105D[] = { - {0x2309, "Imagine 128", NULL}, - {0x2339, "Imagine 128-II", NULL}, - {0x493D, "Imagine 128 T2R [Ticket to Ride]", NULL}, - {0x5348, "Revolution 4", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1060[] = { - {0x0001, "UM82C881", NULL}, - {0x0002, "UM82C886", NULL}, - {0x0101, "UM8673F", NULL}, - {0x0881, "UM8881", NULL}, - {0x0886, "UM8886F", NULL}, - {0x0891, "UM8891A", NULL}, - {0x1001, "UM886A", NULL}, - {0x673A, "UM8886BF", NULL}, - {0x673B, "EIDE Master/DMA", NULL}, - {0x8710, "UM8710", NULL}, - {0x886A, "UM8886A", NULL}, - {0x8881, "UM8881F", NULL}, - {0x8886, "UM8886F", NULL}, - {0x888A, "UM8886A", NULL}, - {0x8891, "UM8891A", NULL}, - {0x9017, "UM9017F", NULL}, - {0x9018, "UM9018", NULL}, - {0x9026, "UM9026", NULL}, - {0xE881, "UM8881N", NULL}, - {0xE886, "UM8886N", NULL}, - {0xE88A, "UM8886N", NULL}, - {0xE891, "UM8891N", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1061[] = { - {0x0001, "AGX016", NULL}, - {0x0002, "IIT3204/3501", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1066[] = { - {0x0000, "PT80C826", NULL}, - {0x0001, "PT86C521 [Vesuvius v1] Host Bridge", NULL}, - {0x0002, "PT86C523 [Vesuvius v3] PCI-ISA Bridge Master", NULL}, - {0x0003, "PT86C524 [Nile] PCI-to-PCI Bridge", NULL}, - {0x0004, "PT86C525 [Nile-II] PCI-to-PCI Bridge", NULL}, - {0x0005, "National PC87550 System Controller", NULL}, - {0x8002, "PT86C523 [Vesuvius v3] PCI-ISA Bridge Slave", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1067[] = { - {0x0301, "AccelGraphics AccelECLIPSE", NULL}, - {0x0304, "AccelGALAXY A2100 [OEM Evans & Sutherland]", NULL}, - {0x0308, "Tornado 3000 [OEM Evans & Sutherland]", NULL}, - {0x1002, "VG500 [VolumePro Volume Rendering Accelerator]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1069[] = { - {0x0001, "DAC960P", NULL}, - {0x0002, "DAC960PD", NULL}, - {0x0010, "DAC960PG", NULL}, - {0x0020, "DAC960LA", NULL}, - {0x0050, "AcceleRAID 352/170/160 support Device", NULL}, - {0xB166, "AcceleRAID 600/500/400/Sapphire support Device", NULL}, - {0xBA55, "eXtremeRAID 1100 support Device", NULL}, - {0xBA56, "eXtremeRAID 2000/3000 support Device", NULL}, - {0xBA57, "eXtremeRAID 4000/5000 support Device", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_106B[] = { - {0x0001, "Bandit PowerPC host bridge", NULL}, - {0x0002, "Grand Central I/O", NULL}, - {0x0003, "Control Video", NULL}, - {0x0004, "PlanB Video-In", NULL}, - {0x0007, "O'Hare I/O", NULL}, - {0x000C, "DOS on Mac", NULL}, - {0x000E, "Hydra Mac I/O", NULL}, - {0x0010, "Heathrow Mac I/O", NULL}, - {0x0017, "Paddington Mac I/O", NULL}, - {0x0018, "UniNorth FireWire", NULL}, - {0x0019, "KeyLargo USB", NULL}, - {0x001E, "UniNorth Internal PCI", NULL}, - {0x001F, "UniNorth PCI", NULL}, - {0x0020, "UniNorth AGP", NULL}, - {0x0021, "UniNorth GMAC (Sun GEM)", NULL}, - {0x0022, "KeyLargo Mac I/O", NULL}, - {0x0024, "UniNorth/Pangea GMAC (Sun GEM)", NULL}, - {0x0025, "KeyLargo/Pangea Mac I/O", NULL}, - {0x0026, "KeyLargo/Pangea USB", NULL}, - {0x0027, "UniNorth/Pangea AGP", NULL}, - {0x0028, "UniNorth/Pangea PCI", NULL}, - {0x0029, "UniNorth/Pangea Internal PCI", NULL}, - {0x002D, "UniNorth 1.5 AGP", NULL}, - {0x002E, "UniNorth 1.5 PCI", NULL}, - {0x002F, "UniNorth 1.5 Internal PCI", NULL}, - {0x0030, "UniNorth/Pangea FireWire", NULL}, - {0x0031, "UniNorth 2 FireWire", NULL}, - {0x0032, "UniNorth 2 GMAC (Sun GEM)", NULL}, - {0x0033, "UniNorth 2 ATA/100", NULL}, - {0x0034, "UniNorth 2 AGP", NULL}, - {0x0035, "UniNorth 2 PCI", NULL}, - {0x0036, "UniNorth 2 Internal PCI", NULL}, - {0x003B, "UniNorth/Intrepid ATA/100", NULL}, - {0x003E, "KeyLargo/Intrepid Mac I/O", NULL}, - {0x003F, "KeyLargo/Intrepid USB", NULL}, - {0x0040, "K2 KeyLargo USB", NULL}, - {0x0041, "K2 KeyLargo Mac/IO", NULL}, - {0x0042, "K2 FireWire", NULL}, - {0x0043, "K2 ATA/100", NULL}, - {0x0045, "K2 HT-PCI Bridge", NULL}, - {0x0046, "K2 HT-PCI Bridge", NULL}, - {0x0047, "K2 HT-PCI Bridge", NULL}, - {0x0048, "K2 HT-PCI Bridge", NULL}, - {0x0049, "K2 HT-PCI Bridge", NULL}, - {0x004B, "U3 AGP", NULL}, - {0x004C, "K2 GMAC (Sun GEM)", NULL}, - {0x004F, "Shasta Mac I/O", NULL}, - {0x0050, "Shasta IDE", NULL}, - {0x0051, "Shasta (Sun GEM)", NULL}, - {0x0052, "Shasta Firewire", NULL}, - {0x0053, "Shasta PCI Bridge", NULL}, - {0x0054, "Shasta PCI Bridge", NULL}, - {0x0055, "Shasta PCI Bridge", NULL}, - {0x0058, "U3L AGP Bridge", NULL}, - {0x0059, "U3H AGP Bridge", NULL}, - {0x0066, "Intrepid2 AGP Bridge", NULL}, - {0x0067, "Intrepid2 PCI Bridge", NULL}, - {0x0068, "Intrepid2 PCI Bridge", NULL}, - {0x0069, "Intrepid2 ATA/100", NULL}, - {0x006A, "Intrepid2 Firewire", NULL}, - {0x006B, "Intrepid2 GMAC (Sun GEM)", NULL}, - {0x1645, "Tigon3 Gigabit Ethernet NIC (BCM5701)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_106C[] = { - {0x8801, "Dual Pentium ISA/PCI Motherboard", NULL}, - {0x8802, "PowerPC ISA/PCI Motherboard", NULL}, - {0x8803, "Dual Window Graphics Accelerator", NULL}, - {0x8804, "LAN Controller", NULL}, - {0x8805, "100-BaseT LAN", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1071[] = { - {0x8160, "Mitac 8060B Mobile Platform", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1073[] = { - {0x0001, "3D GUI Accelerator", NULL}, - {0x0002, "YGV615 [RPA3 3D-Graphics Controller]", NULL}, - {0x0003, "YMF-740", NULL}, - {0x0004, "YMF-724", NULL}, - {0x0005, "DS1 Audio", NULL}, - {0x0006, "DS1 Audio", NULL}, - {0x0008, "DS1 Audio", NULL}, - {0x000A, "DS1L Audio", NULL}, - {0x000C, "YMF-740C [DS-1L Audio Controller]", NULL}, - {0x000D, "YMF-724F [DS-1 Audio Controller]", NULL}, - {0x0010, "YMF-744B [DS-1S Audio Controller]", NULL}, - {0x0012, "YMF-754 [DS-1E Audio Controller]", NULL}, - {0x0020, "DS-1 Audio", NULL}, - {0x2000, "DS2416 Digital Mixing Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1074[] = { - {0x4E78, "82c500/1", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1077[] = { - {0x1016, "ISP10160 Single Channel Ultra3 SCSI Processor", NULL}, - {0x1020, "ISP1020 Fast-wide SCSI", NULL}, - {0x1022, "ISP1022 Fast-wide SCSI", NULL}, - {0x1080, "ISP1080 SCSI Host Adapter", NULL}, - {0x1216, "ISP12160 Dual Channel Ultra3 SCSI Processor", NULL}, - {0x1240, "ISP1240 SCSI Host Adapter", NULL}, - {0x1280, "ISP1280 SCSI Host Adapter", NULL}, - {0x2020, "ISP2020A Fast!SCSI Basic Adapter", NULL}, - {0x2100, "QLA2100 64-bit Fibre Channel Adapter", NULL}, - {0x2200, "QLA2200 64-bit Fibre Channel Adapter", NULL}, - {0x2300, "QLA2300 64-bit Fibre Channel Adapter", NULL}, - {0x2312, "QLA2312 Fibre Channel Adapter", NULL}, - {0x2322, "QLA2322 Fibre Channel Adapter", NULL}, - {0x2422, "QLA2422 Fibre Channel Adapter", NULL}, - {0x2432, "QLA2432 Fibre Channel Adapter", NULL}, - {0x3010, "QLA3010 Network Adapter", NULL}, - {0x3022, "QLA3022 Network Adapter", NULL}, - {0x4010, "QLA4010 iSCSI TOE Adapter", NULL}, - {0x4022, "QLA4022 iSCSI TOE Adapter", NULL}, - {0x6312, "QLA6312 Fibre Channel Adapter", NULL}, - {0x6322, "QLA6322 Fibre Channel Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1078[] = { - {0x0000, "5510 [Grappa]", NULL}, - {0x0001, "PCI Master", NULL}, - {0x0002, "5520 [Cognac]", NULL}, - {0x0100, "5530 Legacy [Kahlua]", NULL}, - {0x0101, "5530 SMI [Kahlua]", NULL}, - {0x0102, "5530 IDE [Kahlua]", NULL}, - {0x0103, "5530 Audio [Kahlua]", NULL}, - {0x0104, "5530 Video [Kahlua]", NULL}, - {0x0400, "ZFMicro PCI Bridge", NULL}, - {0x0401, "ZFMicro Chipset SMI", NULL}, - {0x0402, "ZFMicro Chipset IDE", NULL}, - {0x0403, "ZFMicro Expansion Bus", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_107D[] = { - {0x0000, "P86C850", NULL}, - {0x2134, "WinFast 3D S320 II", NULL}, - {0x2971, "[GeForce FX 5900] WinFast A350 TDH MyViVo", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_107E[] = { - {0x0001, "5515 ATM Adapter [Flipper]", NULL}, - {0x0002, "100 VG AnyLan Controller", NULL}, - {0x0004, "5526 Fibre Channel Host Adapter", NULL}, - {0x0005, "x526 Fibre Channel Host Adapter", NULL}, - {0x0008, "5525/5575 ATM Adapter (155 Mbit) [Atlantic]", NULL}, - {0x9003, "5535-4P-BRI-ST", NULL}, - {0x9007, "5535-4P-BRI-U", NULL}, - {0x9008, "5535-1P-SR", NULL}, - {0x900C, "5535-1P-SR-ST", NULL}, - {0x900E, "5535-1P-SR-U", NULL}, - {0x9011, "5535-1P-PRI", NULL}, - {0x9013, "5535-2P-PRI", NULL}, - {0x9023, "5536-4P-BRI-ST", NULL}, - {0x9027, "5536-4P-BRI-U", NULL}, - {0x9031, "5536-1P-PRI", NULL}, - {0x9033, "5536-2P-PRI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_107F[] = { - {0x0802, "SL82C105", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1080[] = { - {0x0600, "82C599", NULL}, - {0xC691, "Cypress CY82C691", NULL}, - {0xC693, "82c693", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1081[] = { - {0x0D47, "Radius PCI to NuBUS Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1083[] = { - {0x0001, "FR710", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_108A[] = { - {0x0001, "VME Bridge Model 617", NULL}, - {0x0010, "VME Bridge Model 618", NULL}, - {0x0040, "dataBLIZZARD", NULL}, - {0x3000, "VME Bridge Model 2706", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_108D[] = { - {0x0001, "Token-Ring 16/4 PCI Adapter (3136/3137)", NULL}, - {0x0002, "16/4 Token Ring", NULL}, - {0x0004, "RapidFire 3139 Token-Ring 16/4 PCI Adapter", NULL}, - {0x0005, "GoCard 3250 Token-Ring 16/4 CardBus PC Card", NULL}, - {0x0006, "OC-3530 RapidFire Token-Ring 100", NULL}, - {0x0007, "RapidFire 3141 Token-Ring 16/4 PCI Fiber Adapter", NULL}, - {0x0008, "RapidFire 3540 HSTR 100/16/4 PCI Adapter", NULL}, - {0x0011, "OC-2315", NULL}, - {0x0012, "OC-2325", NULL}, - {0x0013, "OC-2183/2185", NULL}, - {0x0014, "OC-2326", NULL}, - {0x0019, "OC-2327/2250 10/100 Ethernet Adapter", NULL}, - {0x0021, "OC-6151/6152 [RapidFire ATM 155]", NULL}, - {0x0022, "ATM Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_108E[] = { - {0x0001, "EBUS", NULL}, - {0x1000, "EBUS", NULL}, - {0x1001, "Happy Meal", NULL}, - {0x1100, "RIO EBUS", NULL}, - {0x1101, "RIO GEM", NULL}, - {0x1102, "RIO 1394", NULL}, - {0x1103, "RIO USB", NULL}, - {0x1648, "[bge] Gigabit Ethernet", NULL}, - {0x2BAD, "GEM", NULL}, - {0x5000, "Simba Advanced PCI Bridge", NULL}, - {0x5043, "SunPCI Co-processor", NULL}, - {0x8000, "Psycho PCI Bus Module", NULL}, - {0x8001, "Schizo PCI Bus Module", NULL}, - {0x8002, "Schizo+ PCI Bus Module", NULL}, - {0xA000, "Ultra IIi", NULL}, - {0xA001, "Ultra IIe", NULL}, - {0xA801, "Tomatillo PCI Bus Module", NULL}, - {0xABBA, "Cassini 10/100/1000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1091[] = { - {0x0020, "3D graphics processor", NULL}, - {0x0021, "3D graphics processor w/Texturing", NULL}, - {0x0040, "3D graphics frame buffer", NULL}, - {0x0041, "3D graphics frame buffer", NULL}, - {0x0060, "Proprietary bus bridge", NULL}, - {0x00E4, "Powerstorm 4D50T", NULL}, - {0x0720, "Motion JPEG codec", NULL}, - {0x07A0, "Sun Expert3D-Lite Graphics Accelerator", NULL}, - {0x1091, "Sun Expert3D Graphics Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1092[] = { - {0x00A0, "Speedstar Pro SE", NULL}, - {0x00A8, "Speedstar 64", NULL}, - {0x0550, "Viper V550", NULL}, - {0x08D4, "Supra 2260 Modem", NULL}, - {0x094C, "SupraExpress 56i Pro", NULL}, - {0x1092, "Viper V330", NULL}, - {0x6120, "Maximum DVD", NULL}, - {0x8810, "Stealth SE", NULL}, - {0x8811, "Stealth 64/SE", NULL}, - {0x8880, "Stealth", NULL}, - {0x8881, "Stealth", NULL}, - {0x88B0, "Stealth 64", NULL}, - {0x88B1, "Stealth 64", NULL}, - {0x88C0, "Stealth 64", NULL}, - {0x88C1, "Stealth 64", NULL}, - {0x88D0, "Stealth 64", NULL}, - {0x88D1, "Stealth 64", NULL}, - {0x88F0, "Stealth 64", NULL}, - {0x88F1, "Stealth 64", NULL}, - {0x9999, "DMD-I0928-1 \"Monster sound\" sound chip", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1093[] = { - {0x0160, "PCI-DIO-96", NULL}, - {0x0162, "PCI-MIO-16XE-50", NULL}, - {0x1170, "PCI-MIO-16XE-10", NULL}, - {0x1180, "PCI-MIO-16E-1", NULL}, - {0x1190, "PCI-MIO-16E-4", NULL}, - {0x1310, "PCI-6602", NULL}, - {0x1330, "PCI-6031E", NULL}, - {0x1350, "PCI-6071E", NULL}, - {0x14E0, "PCI-6110", NULL}, - {0x14F0, "PCI-6111", NULL}, - {0x17D0, "PCI-6503", NULL}, - {0x1870, "PCI-6713", NULL}, - {0x1880, "PCI-6711", NULL}, - {0x18B0, "PCI-6052E", NULL}, - {0x2410, "PCI-6733", NULL}, - {0x2890, "PCI-6036E", NULL}, - {0x2A60, "PCI-6023E", NULL}, - {0x2A70, "PCI-6024E", NULL}, - {0x2A80, "PCI-6025E", NULL}, - {0x2C80, "PCI-6035E", NULL}, - {0x2CA0, "PCI-6034E", NULL}, - {0x70A9, "PCI-6528", NULL}, - {0x70B8, "PCI-6251 [M Series - High Speed Multifunction DAQ]", NULL}, - {0xB001, "IMAQ-PCI-1408", NULL}, - {0xB011, "IMAQ-PXI-1408", NULL}, - {0xB021, "IMAQ-PCI-1424", NULL}, - {0xB031, "IMAQ-PCI-1413", NULL}, - {0xB041, "IMAQ-PCI-1407", NULL}, - {0xB051, "IMAQ-PXI-1407", NULL}, - {0xB061, "IMAQ-PCI-1411", NULL}, - {0xB071, "IMAQ-PCI-1422", NULL}, - {0xB081, "IMAQ-PXI-1422", NULL}, - {0xB091, "IMAQ-PXI-1411", NULL}, - {0xC801, "PCI-GPIB", NULL}, - {0xC831, "PCI-GPIB bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1095[] = { - {0x0240, "Adaptec AAR-1210SA SATA HostRAID Controller", NULL}, - {0x0640, "PCI0640", NULL}, - {0x0643, "PCI0643", NULL}, - {0x0646, "PCI0646", NULL}, - {0x0647, "PCI0647", NULL}, - {0x0648, "PCI0648", NULL}, - {0x0649, "SiI 0649 Ultra ATA/100 PCI to ATA Host Controller", NULL}, - {0x0650, "PBC0650A", NULL}, - {0x0670, "USB0670", NULL}, - {0x0673, "USB0673", NULL}, - {0x0680, "PCI0680 Ultra ATA-133 Host Controller", NULL}, - {0x3112, "SiI 3112 [SATALink/SATARaid] Serial ATA Controller", NULL}, - {0x3114, "SiI 3114 [SATALink/SATARaid] Serial ATA Controller", NULL}, - {0x3124, "SiI 3124 PCI-X Serial ATA Controller", NULL}, - {0x3132, "SiI 3132 Serial ATA Raid II Controller", NULL}, - {0x3512, "SiI 3512 [SATALink/SATARaid] Serial ATA Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1098[] = { - {0x0001, "QD-8500", NULL}, - {0x0002, "QD-8580", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_109E[] = { - {0x032E, "Bt878 Video Capture", NULL}, - {0x0350, "Bt848 Video Capture", NULL}, - {0x0351, "Bt849A Video capture", NULL}, - {0x0369, "Bt878 Video Capture", NULL}, - {0x036C, "Bt879(?) Video Capture", NULL}, - {0x036E, "Bt878 Video Capture", NULL}, - {0x036F, "Bt879 Video Capture", NULL}, - {0x0370, "Bt880 Video Capture", NULL}, - {0x0878, "Bt878 Audio Capture", NULL}, - {0x0879, "Bt879 Audio Capture", NULL}, - {0x0880, "Bt880 Audio Capture", NULL}, - {0x2115, "BtV 2115 Mediastream controller", NULL}, - {0x2125, "BtV 2125 Mediastream controller", NULL}, - {0x2164, "BtV 2164", NULL}, - {0x2165, "BtV 2165", NULL}, - {0x8230, "Bt8230 ATM Segment/Reassembly Ctrlr (SRC)", NULL}, - {0x8472, "Bt8472", NULL}, - {0x8474, "Bt8474", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10A5[] = { - {0x3052, "SmartPCI562 56K Modem", NULL}, - {0x5449, "SmartPCI561 modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10A8[] = { - {0x0000, "STB Horizon 64", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10A9[] = { - {0x0001, "Crosstalk to PCI Bridge", NULL}, - {0x0002, "Linc I/O controller", NULL}, - {0x0003, "IOC3 I/O controller", NULL}, - {0x0004, "O2 MACE", NULL}, - {0x0005, "RAD Audio", NULL}, - {0x0006, "HPCEX", NULL}, - {0x0007, "RPCEX", NULL}, - {0x0008, "DiVO VIP", NULL}, - {0x0009, "AceNIC Gigabit Ethernet", NULL}, - {0x0010, "AMP Video I/O", NULL}, - {0x0011, "GRIP", NULL}, - {0x0012, "SGH PSHAC GSN", NULL}, - {0x1001, "Magic Carpet", NULL}, - {0x1002, "Lithium", NULL}, - {0x1003, "Dual JPEG 1", NULL}, - {0x1004, "Dual JPEG 2", NULL}, - {0x1005, "Dual JPEG 3", NULL}, - {0x1006, "Dual JPEG 4", NULL}, - {0x1007, "Dual JPEG 5", NULL}, - {0x1008, "Cesium", NULL}, - {0x100A, "IOC4 I/O controller", NULL}, - {0x2001, "Fibre Channel", NULL}, - {0x2002, "ASDE", NULL}, - {0x4001, "TIO-CE PCI Express Bridge", NULL}, - {0x4002, "TIO-CE PCI Express Port", NULL}, - {0x8001, "O2 1394", NULL}, - {0x8002, "G-net NT", NULL}, - {0x8010, "Broadcom e-net [SGI IO9/IO10 BaseIO]", NULL}, - {0x8018, "Broadcom e-net [SGI A330 Server BaseIO]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10AA[] = { - {0x0000, "ACCM 2188", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10AD[] = { - {0x0001, "W83769F", NULL}, - {0x0003, "SL82C103", NULL}, - {0x0005, "SL82C105", NULL}, - {0x0103, "SL82c103", NULL}, - {0x0105, "SL82c105", NULL}, - {0x0565, "W83C553", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B3[] = { - {0x3106, "DB87144", NULL}, - {0xB106, "DB87144", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B4[] = { - {0x1B1D, "Velocity 128 3D", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B5[] = { - {0x0001, "i960 PCI bus interface", NULL}, - {0x1042, "Brandywine / jxi2, Inc. - PMC-SyncClock32, IRIG A & B, Nasa 36", NULL}, - {0x1076, "VScom 800 8 port serial adaptor", NULL}, - {0x1077, "VScom 400 4 port serial adaptor", NULL}, - {0x1078, "VScom 210 2 port serial and 1 port parallel adaptor", NULL}, - {0x1103, "VScom 200 2 port serial adaptor", NULL}, - {0x1146, "VScom 010 1 port parallel adaptor", NULL}, - {0x1147, "VScom 020 2 port parallel adaptor", NULL}, - {0x2540, "IXXAT CAN-Interface PC-I 04/PCI", NULL}, - {0x2724, "Thales PCSM Security Card", NULL}, - {0x6540, "PCI6540/6466 PCI-PCI bridge (transparent mode)", NULL}, - {0x6541, "PCI6540/6466 PCI-PCI bridge (non-transparent mode, primary side)", NULL}, - {0x6542, "PCI6540/6466 PCI-PCI bridge (non-transparent mode, secondary side)", NULL}, - {0x8111, "PEX 8111 PCI Express-to-PCI Bridge", NULL}, - {0x8114, "PEX 8114 PCI Express-to-PCI/PCI-X Bridge", NULL}, - {0x8516, "PEX 8516 Versatile PCI Express Switch", NULL}, - {0x8532, "PEX 8532 Versatile PCI Express Switch", NULL}, - {0x9030, "PCI <-> IOBus Bridge Hot Swap", NULL}, - {0x9036, "9036", NULL}, - {0x9050, "PCI <-> IOBus Bridge", NULL}, - {0x9054, "PCI <-> IOBus Bridge", NULL}, - {0x9056, "Francois", NULL}, - {0x9060, "9060", NULL}, - {0x906D, "9060SD", NULL}, - {0x906E, "9060ES", NULL}, - {0x9080, "9080", NULL}, - {0xBB04, "B&B 3PCIOSD1A Isolated PCI Serial", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B6[] = { - {0x0001, "Smart 16/4 PCI Ringnode", NULL}, - {0x0002, "Smart 16/4 PCI Ringnode Mk2", NULL}, - {0x0003, "Smart 16/4 PCI Ringnode Mk3", NULL}, - {0x0004, "Smart 16/4 PCI Ringnode Mk1", NULL}, - {0x0006, "16/4 Cardbus Adapter", NULL}, - {0x0007, "Presto PCI Adapter", NULL}, - {0x0009, "Smart 100/16/4 PCI-HS Ringnode", NULL}, - {0x000A, "Smart 100/16/4 PCI Ringnode", NULL}, - {0x000B, "16/4 CardBus Adapter Mk2", NULL}, - {0x000C, "RapidFire 3140V2 16/4 TR Adapter", NULL}, - {0x1000, "Collage 25/155 ATM Client Adapter", NULL}, - {0x1001, "Collage 155 ATM Server Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B7[] = { - {0x0001, "3c985 1000BaseSX (SX/TX)", NULL}, - {0x0013, "AR5212 802.11abg NIC (3CRDAG675)", NULL}, - {0x0910, "3C910-A01", NULL}, - {0x1006, "MINI PCI type 3B Data Fax Modem", NULL}, - {0x1007, "Mini PCI 56k Winmodem", NULL}, - {0x1201, "3c982-TXM 10/100baseTX Dual Port A [Hydra]", NULL}, - {0x1202, "3c982-TXM 10/100baseTX Dual Port B [Hydra]", NULL}, - {0x1700, "3c940 10/100/1000Base-T [Marvell]", NULL}, - {0x3390, "3c339 TokenLink Velocity", NULL}, - {0x3590, "3c359 TokenLink Velocity XL", NULL}, - {0x4500, "3c450 HomePNA [Tornado]", NULL}, - {0x5055, "3c555 Laptop Hurricane", NULL}, - {0x5057, "3c575 Megahertz 10/100 LAN CardBus [Boomerang]", NULL}, - {0x5157, "3cCFE575BT Megahertz 10/100 LAN CardBus [Cyclone]", NULL}, - {0x5257, "3cCFE575CT CardBus [Cyclone]", NULL}, - {0x5900, "3c590 10BaseT [Vortex]", NULL}, - {0x5920, "3c592 EISA 10mbps Demon/Vortex", NULL}, - {0x5950, "3c595 100BaseTX [Vortex]", NULL}, - {0x5951, "3c595 100BaseT4 [Vortex]", NULL}, - {0x5952, "3c595 100Base-MII [Vortex]", NULL}, - {0x5970, "3c597 EISA Fast Demon/Vortex", NULL}, - {0x5B57, "3c595 Megahertz 10/100 LAN CardBus [Boomerang]", NULL}, - {0x6000, "3CRSHPW796 [OfficeConnect Wireless CardBus]", NULL}, - {0x6001, "3com 3CRWE154G72 [Office Connect Wireless LAN Adapter]", NULL}, - {0x6055, "3c556 Hurricane CardBus [Cyclone]", NULL}, - {0x6056, "3c556B CardBus [Tornado]", NULL}, - {0x6560, "3cCFE656 CardBus [Cyclone]", NULL}, - {0x6561, "3cCFEM656 10/100 LAN+56K Modem CardBus", NULL}, - {0x6562, "3cCFEM656B 10/100 LAN+Winmodem CardBus [Cyclone]", NULL}, - {0x6563, "3cCFEM656B 10/100 LAN+56K Modem CardBus", NULL}, - {0x6564, "3cXFEM656C 10/100 LAN+Winmodem CardBus [Tornado]", NULL}, - {0x7646, "3cSOHO100-TX Hurricane", NULL}, - {0x7770, "3CRWE777 PCI(PLX) Wireless Adaptor [Airconnect]", NULL}, - {0x7940, "3c803 FDDILink UTP Controller", NULL}, - {0x7980, "3c804 FDDILink SAS Controller", NULL}, - {0x7990, "3c805 FDDILink DAS Controller", NULL}, - {0x80EB, "3c940B 10/100/1000Base-T", NULL}, - {0x8811, "Token ring", NULL}, - {0x9000, "3c900 10BaseT [Boomerang]", NULL}, - {0x9001, "3c900 10Mbps Combo [Boomerang]", NULL}, - {0x9004, "3c900B-TPO Etherlink XL [Cyclone]", NULL}, - {0x9005, "3c900B-Combo Etherlink XL [Cyclone]", NULL}, - {0x9006, "3c900B-TPC Etherlink XL [Cyclone]", NULL}, - {0x900A, "3c900B-FL 10base-FL [Cyclone]", NULL}, - {0x9050, "3c905 100BaseTX [Boomerang]", NULL}, - {0x9051, "3c905 100BaseT4 [Boomerang]", NULL}, - {0x9055, "3c905B 100BaseTX [Cyclone]", NULL}, - {0x9056, "3c905B-T4 Fast EtherLink XL [Cyclone]", NULL}, - {0x9058, "3c905B Deluxe Etherlink 10/100/BNC [Cyclone]", NULL}, - {0x905A, "3c905B-FX Fast Etherlink XL FX 100baseFx [Cyclone]", NULL}, - {0x9200, "3c905C-TX/TX-M [Tornado]", NULL}, - {0x9201, "3C920B-EMB Integrated Fast Ethernet Controller [Tornado]", NULL}, - {0x9202, "3Com 3C920B-EMB-WNM Integrated Fast Ethernet Controller", NULL}, - {0x9210, "3C920B-EMB-WNM Integrated Fast Ethernet Controller", NULL}, - {0x9300, "3CSOHO100B-TX 910-A01 [tulip]", NULL}, - {0x9800, "3c980-TX Fast Etherlink XL Server Adapter [Cyclone]", NULL}, - {0x9805, "3c980-C 10/100baseTX NIC [Python-T]", NULL}, - {0x9900, "3C990-TX [Typhoon]", NULL}, - {0x9902, "3CR990-TX-95 [Typhoon 56-bit]", NULL}, - {0x9903, "3CR990-TX-97 [Typhoon 168-bit]", NULL}, - {0x9904, "3C990B-TX-M/3C990BSVR [Typhoon2]", NULL}, - {0x9905, "3CR990-FX-95/97/95 [Typhon Fiber]", NULL}, - {0x9908, "3CR990SVR95 [Typhoon Server 56-bit]", NULL}, - {0x9909, "3CR990SVR97 [Typhoon Server 168-bit]", NULL}, - {0x990A, "3C990SVR [Typhoon Server]", NULL}, - {0x990B, "3C990SVR [Typhoon Server]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B8[] = { - {0x0005, "83c170 EPIC/100 Fast Ethernet Adapter", NULL}, - {0x0006, "83c175 EPIC/100 Fast Ethernet Adapter", NULL}, - {0x1000, "FDC 37c665", NULL}, - {0x1001, "FDC 37C922", NULL}, - {0x2802, "SMC2802W [EZ Connect g]", NULL}, - {0xA011, "83C170QF", NULL}, - {0xB106, "SMC34C90", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10B9[] = { - {0x0101, "CMI8338/C3DX PCI Audio Device", NULL}, - {0x0111, "C-Media CMI8738/C3DX Audio Device (OEM)", NULL}, - {0x0780, "Multi-IO Card", NULL}, - {0x0782, "Multi-IO Card", NULL}, - {0x1435, "M1435", NULL}, - {0x1445, "M1445", NULL}, - {0x1449, "M1449", NULL}, - {0x1451, "M1451", NULL}, - {0x1461, "M1461", NULL}, - {0x1489, "M1489", NULL}, - {0x1511, "M1511 [Aladdin]", NULL}, - {0x1512, "M1512 [Aladdin]", NULL}, - {0x1513, "M1513 [Aladdin]", NULL}, - {0x1521, "M1521 [Aladdin III]", NULL}, - {0x1523, "M1523", NULL}, - {0x1531, "M1531 [Aladdin IV]", NULL}, - {0x1533, "M1533/M1535 PCI to ISA Bridge [Aladdin IV/V/V+]", NULL}, - {0x1541, "M1541", NULL}, - {0x1543, "M1543", NULL}, - {0x1563, "M1563 HyperTransport South Bridge", NULL}, - {0x1573, "PCI to LPC Controller", NULL}, - {0x1621, "M1621", NULL}, - {0x1631, "ALI M1631 PCI North Bridge Aladdin Pro III", NULL}, - {0x1632, "M1632M Northbridge+Trident", NULL}, - {0x1641, "ALI M1641 PCI North Bridge Aladdin Pro IV", NULL}, - {0x1644, "M1644/M1644T Northbridge+Trident", NULL}, - {0x1646, "M1646 Northbridge+Trident", NULL}, - {0x1647, "M1647 Northbridge [MAGiK 1 / MobileMAGiK 1]", NULL}, - {0x1651, "M1651/M1651T Northbridge [Aladdin-Pro 5/5M,Aladdin-Pro 5T/5TM]", NULL}, - {0x1671, "M1671 Super P4 Northbridge [AGP4X,PCI and SDR/DDR]", NULL}, - {0x1672, "M1672 Northbridge [CyberALADDiN-P4]", NULL}, - {0x1681, "M1681 P4 Northbridge [AGP8X,HyperTransport and SDR/DDR]", NULL}, - {0x1687, "M1687 K8 Northbridge [AGP8X and HyperTransport]", NULL}, - {0x1689, "M1689 K8 Northbridge [Super K8 Single Chip]", NULL}, - {0x1695, "M1695 K8 Northbridge [PCI Express and HyperTransport]", NULL}, - {0x1697, "M1697 HTT Host Bridge", NULL}, - {0x3141, "M3141", NULL}, - {0x3143, "M3143", NULL}, - {0x3145, "M3145", NULL}, - {0x3147, "M3147", NULL}, - {0x3149, "M3149", NULL}, - {0x3151, "M3151", NULL}, - {0x3307, "M3307", NULL}, - {0x3309, "M3309", NULL}, - {0x3323, "M3325 Video/Audio Decoder", NULL}, - {0x5212, "M4803", NULL}, - {0x5215, "MS4803", NULL}, - {0x5217, "M5217H", NULL}, - {0x5219, "M5219", NULL}, - {0x5225, "M5225", NULL}, - {0x5228, "M5228 ALi ATA/RAID Controller", NULL}, - {0x5229, "M5229 IDE", NULL}, - {0x5235, "M5225", NULL}, - {0x5237, "USB 1.1 Controller", NULL}, - {0x5239, "USB 2.0 Controller", NULL}, - {0x5243, "M1541 PCI to AGP Controller", NULL}, - {0x5246, "AGP8X Controller", NULL}, - {0x5247, "PCI to AGP Controller", NULL}, - {0x5249, "M5249 HTT to PCI Bridge", NULL}, - {0x524B, "PCI Express Root Port", NULL}, - {0x524C, "PCI Express Root Port", NULL}, - {0x524D, "PCI Express Root Port", NULL}, - {0x524E, "PCI Express Root Port", NULL}, - {0x5251, "M5251 P1394 OHCI 1.0 Controller", NULL}, - {0x5253, "M5253 P1394 OHCI 1.1 Controller", NULL}, - {0x5261, "M5261 Ethernet Controller", NULL}, - {0x5263, "M5263 Ethernet Controller", NULL}, - {0x5281, "ALi M5281 Serial ATA / RAID Host Controller", NULL}, - {0x5287, "ULi 5287 SATA", NULL}, - {0x5288, "ULi M5288 SATA", NULL}, - {0x5289, "ULi 5289 SATA", NULL}, - {0x5450, "Lucent Technologies Soft Modem AMR", NULL}, - {0x5451, "M5451 PCI AC-Link Controller Audio Device", NULL}, - {0x5453, "M5453 PCI AC-Link Controller Modem Device", NULL}, - {0x5455, "M5455 PCI AC-Link Controller Audio Device", NULL}, - {0x5457, "M5457 AC'97 Modem Controller", NULL}, - {0x5459, "SmartLink SmartPCI561 56K Modem", NULL}, - {0x545A, "SmartLink SmartPCI563 56K Modem", NULL}, - {0x5461, "High Definition Audio/AC'97 Host Controller", NULL}, - {0x5471, "M5471 Memory Stick Controller", NULL}, - {0x5473, "M5473 SD-MMC Controller", NULL}, - {0x7101, "M7101 Power Management Controller [PMU]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10BA[] = { - {0x0301, "AccelGraphics AccelECLIPSE", NULL}, - {0x0304, "AccelGALAXY A2100 [OEM Evans & Sutherland]", NULL}, - {0x0308, "Tornado 3000 [OEM Evans & Sutherland]", NULL}, - {0x1002, "VG500 [VolumePro Volume Rendering Accelerator]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10BD[] = { - {0x0E34, "NE-34", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10C3[] = { - {0x1100, "Smartether100 SC1100 LAN Adapter (i82557B)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10C8[] = { - {0x0001, "NM2070 [MagicGraph 128]", NULL}, - {0x0002, "NM2090 [MagicGraph 128V]", NULL}, - {0x0003, "NM2093 [MagicGraph 128ZV]", NULL}, - {0x0004, "NM2160 [MagicGraph 128XD]", NULL}, - {0x0005, "NM2200 [MagicGraph 256AV]", NULL}, - {0x0006, "NM2360 [MagicMedia 256ZX]", NULL}, - {0x0016, "NM2380 [MagicMedia 256XL+]", NULL}, - {0x0025, "NM2230 [MagicGraph 256AV+]", NULL}, - {0x0083, "NM2093 [MagicGraph 128ZV+]", NULL}, - {0x8005, "NM2200 [MagicMedia 256AV Audio]", NULL}, - {0x8006, "NM2360 [MagicMedia 256ZX Audio]", NULL}, - {0x8016, "NM2380 [MagicMedia 256XL+ Audio]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10CC[] = { - {0x0660, "Articia S Host Bridge", NULL}, - {0x0661, "Articia S PCI Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10CD[] = { - {0x1100, "ASC1100", NULL}, - {0x1200, "ASC1200 [(abp940) Fast SCSI-II]", NULL}, - {0x1300, "ABP940-U / ABP960-U", NULL}, - {0x2300, "ABP940-UW", NULL}, - {0x2500, "ABP940-U2W", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10CF[] = { - {0x2001, "mb86605", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10D9[] = { - {0x0431, "MX98715", NULL}, - {0x0512, "MX98713", NULL}, - {0x0531, "MX987x5", NULL}, - {0x8625, "MX86250", NULL}, - {0x8626, "Macronix MX86251 + 3Dfx Voodoo Rush", NULL}, - {0x8888, "MX86200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10DA[] = { - {0x0508, "TC4048 Token Ring 4/16", NULL}, - {0x3390, "Tl3c3x9", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10DC[] = { - {0x0001, "STAR/RD24 SCI-PCI (PMC)", NULL}, - {0x0002, "TAR/RD24 SCI-PCI (PMC)", NULL}, - {0x0021, "HIPPI destination", NULL}, - {0x0022, "HIPPI source", NULL}, - {0x10DC, "ATT2C15-3 FPGA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10DD[] = { - {0x0100, "Lightning 1200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10DE[] = { - {0x0008, "NV1 [EDGE 3D]", NULL}, - {0x0009, "NV1 [EDGE 3D]", NULL}, - {0x0010, "NV2 [Mutara V08]", NULL}, - {0x0020, "NV4 [RIVA TNT]", NULL}, - {0x0028, "NV5 [RIVA TNT2/TNT2 Pro]", NULL}, - {0x0029, "NV5 [RIVA TNT2 Ultra]", NULL}, - {0x002A, "NV5 [Riva TnT2]", NULL}, - {0x002B, "NV5 [Riva TnT2]", NULL}, - {0x002C, "NV6 [Vanta/Vanta LT]", NULL}, - {0x002D, "NV5M64 [RIVA TNT2 Model 64/Model 64 Pro]", NULL}, - {0x002E, "NV6 [Vanta]", NULL}, - {0x002F, "NV6 [Vanta]", NULL}, - {0x0034, "MCP04 SMBus", NULL}, - {0x0035, "MCP04 IDE", NULL}, - {0x0036, "MCP04 Serial ATA Controller", NULL}, - {0x0037, "MCP04 Ethernet Controller", NULL}, - {0x0038, "MCP04 Ethernet Controller", NULL}, - {0x003A, "MCP04 AC'97 Audio Controller", NULL}, - {0x003B, "MCP04 USB Controller", NULL}, - {0x003C, "MCP04 USB Controller", NULL}, - {0x003D, "MCP04 PCI Bridge", NULL}, - {0x003E, "MCP04 Serial ATA Controller", NULL}, - {0x0040, "NV40 [GeForce 6800 Ultra]", NULL}, - {0x0041, "NV40 [GeForce 6800]", NULL}, - {0x0042, "NV40.2 [GeForce 6800 LE]", NULL}, - {0x0043, "NV40.3", NULL}, - {0x0045, "NV40 [GeForce 6800 GT]", NULL}, - {0x0047, "NV40 [GeForce 6800 GS]", NULL}, - {0x0049, "NV40GL", NULL}, - {0x004E, "NV40GL [Quadro FX 4000]", NULL}, - {0x0050, "CK804 ISA Bridge", NULL}, - {0x0051, "CK804 ISA Bridge", NULL}, - {0x0052, "CK804 SMBus", NULL}, - {0x0053, "CK804 IDE", NULL}, - {0x0054, "CK804 Serial ATA Controller", NULL}, - {0x0055, "CK804 Serial ATA Controller", NULL}, - {0x0056, "CK804 Ethernet Controller", NULL}, - {0x0057, "CK804 Ethernet Controller", NULL}, - {0x0058, "CK804 AC'97 Modem", NULL}, - {0x0059, "CK804 AC'97 Audio Controller", NULL}, - {0x005A, "CK804 USB Controller", NULL}, - {0x005B, "CK804 USB Controller", NULL}, - {0x005C, "CK804 PCI Bridge", NULL}, - {0x005D, "CK804 PCIE Bridge", NULL}, - {0x005E, "CK804 Memory Controller", NULL}, - {0x005F, "CK804 Memory Controller", NULL}, - {0x0060, "nForce2 ISA Bridge", NULL}, - {0x0064, "nForce2 SMBus (MCP)", NULL}, - {0x0065, "nForce2 IDE", NULL}, - {0x0066, "nForce2 Ethernet Controller", NULL}, - {0x0067, "nForce2 USB Controller", NULL}, - {0x0068, "nForce2 USB Controller", NULL}, - {0x006A, "nForce2 AC97 Audio Controler (MCP)", NULL}, - {0x006B, "nForce Audio Processing Unit", NULL}, - {0x006C, "nForce2 External PCI Bridge", NULL}, - {0x006D, "nForce2 PCI Bridge", NULL}, - {0x006E, "nForce2 FireWire (IEEE 1394) Controller", NULL}, - {0x0080, "MCP2A ISA bridge", NULL}, - {0x0084, "MCP2A SMBus", NULL}, - {0x0085, "MCP2A IDE", NULL}, - {0x0086, "MCP2A Ethernet Controller", NULL}, - {0x0087, "MCP2A USB Controller", NULL}, - {0x0088, "MCP2A USB Controller", NULL}, - {0x008A, "MCP2S AC'97 Audio Controller", NULL}, - {0x008B, "MCP2A PCI Bridge", NULL}, - {0x008C, "MCP2A Ethernet Controller", NULL}, - {0x008E, "nForce2 Serial ATA Controller", NULL}, - {0x0091, "GeForce 7800 GTX", NULL}, - {0x0092, "GeForce 7800 GT", NULL}, - {0x0099, "GE Force Go 7800 GTX", NULL}, - {0x00A0, "NV5 [Aladdin TNT2]", NULL}, - {0x00C0, "NV41.0", NULL}, - {0x00C1, "NV41.1 [GeForce 6800]", NULL}, - {0x00C2, "NV41.2 [GeForce 6800 LE]", NULL}, - {0x00C8, "NV41.8 [GeForce Go 6800]", NULL}, - {0x00C9, "NV41.9 [GeForce Go 6800 Ultra]", NULL}, - {0x00CC, "NV41 [Quadro FX Go1400]", NULL}, - {0x00CD, "NV41 [Quadro FX 3450/4000 SDI]", NULL}, - {0x00CE, "NV41GL [Quadro FX 1400]", NULL}, - {0x00D0, "nForce3 LPC Bridge", NULL}, - {0x00D1, "nForce3 Host Bridge", NULL}, - {0x00D2, "nForce3 AGP Bridge", NULL}, - {0x00D3, "CK804 Memory Controller", NULL}, - {0x00D4, "nForce3 SMBus", NULL}, - {0x00D5, "nForce3 IDE", NULL}, - {0x00D6, "nForce3 Ethernet", NULL}, - {0x00D7, "nForce3 USB 1.1", NULL}, - {0x00D8, "nForce3 USB 2.0", NULL}, - {0x00D9, "nForce3 Audio", NULL}, - {0x00DA, "nForce3 Audio", NULL}, - {0x00DD, "nForce3 PCI Bridge", NULL}, - {0x00DF, "CK8S Ethernet Controller", NULL}, - {0x00E0, "nForce3 250Gb LPC Bridge", NULL}, - {0x00E1, "nForce3 250Gb Host Bridge", NULL}, - {0x00E2, "nForce3 250Gb AGP Host to PCI Bridge", NULL}, - {0x00E3, "CK8S Serial ATA Controller (v2.5)", NULL}, - {0x00E4, "nForce 250Gb PCI System Management", NULL}, - {0x00E5, "CK8S Parallel ATA Controller (v2.5)", NULL}, - {0x00E6, "CK8S Ethernet Controller", NULL}, - {0x00E7, "CK8S USB Controller", NULL}, - {0x00E8, "nForce3 EHCI USB 2.0 Controller", NULL}, - {0x00EA, "nForce3 250Gb AC'97 Audio Controller", NULL}, - {0x00ED, "nForce3 250Gb PCI-to-PCI Bridge", NULL}, - {0x00EE, "CK8S Serial ATA Controller (v2.5)", NULL}, - {0x00F0, "NV40 [GeForce 6800/GeForce 6800 Ultra]", NULL}, - {0x00F1, "NV43 [GeForce 6600/GeForce 6600 GT]", NULL}, - {0x00F2, "NV43 [GeForce 6600/GeForce 6600 GT]", NULL}, - {0x00F3, "NV43 [GeForce 6200]", NULL}, - {0x00F8, "NV45GL [Quadro FX 3400/4400]", NULL}, - {0x00F9, "NV40 [GeForce 6800 Ultra/GeForce 6800 GT]", NULL}, - {0x00FA, "NV36 [GeForce PCX 5750]", NULL}, - {0x00FB, "NV35 [GeForce PCX 5900]", NULL}, - {0x00FC, "NV37GL [Quadro FX 330/GeForce PCX 5300]", NULL}, - {0x00FD, "NV37GL [Quadro FX 330/Quadro NVS280]", NULL}, - {0x00FE, "NV38GL [Quadro FX 1300]", NULL}, - {0x00FF, "NV18 [GeForce PCX 4300]", NULL}, - {0x0100, "NV10 [GeForce 256 SDR]", NULL}, - {0x0101, "NV10DDR [GeForce 256 DDR]", NULL}, - {0x0103, "NV10GL [Quadro]", NULL}, - {0x0110, "NV11 [GeForce2 MX/MX 400]", NULL}, - {0x0111, "NV11DDR [GeForce2 MX 100 DDR/200 DDR]", NULL}, - {0x0112, "NV11 [GeForce2 Go]", NULL}, - {0x0113, "NV11GL [Quadro2 MXR/EX/Go]", NULL}, - {0x0140, "NV43 [GeForce 6600 GT]", NULL}, - {0x0141, "NV43 [GeForce 6600]", NULL}, - {0x0142, "NV43 [GeForce 6600 PCIe]", NULL}, - {0x0144, "NV43 [GeForce Go 6600]", NULL}, - {0x0145, "NV43 [GeForce 6610 XL]", NULL}, - {0x0146, "NV43 [Geforce Go 6600TE/6200TE]", NULL}, - {0x0148, "NV43 [GeForce Go 6600]", NULL}, - {0x014E, "NV43GL [Quadro FX 540]", NULL}, - {0x014F, "NV43 [GeForce 6200]", NULL}, - {0x0150, "NV15 [GeForce2 GTS/Pro]", NULL}, - {0x0151, "NV15DDR [GeForce2 Ti]", NULL}, - {0x0152, "NV15BR [GeForce2 Ultra, Bladerunner]", NULL}, - {0x0153, "NV15GL [Quadro2 Pro]", NULL}, - {0x0161, "GeForce 6200 TurboCache(TM)", NULL}, - {0x0164, "NV44 [GeForce Go 6200]", NULL}, - {0x0165, "NV44 [Quadro NVS 285]", NULL}, - {0x0167, "GeForce Go 6200 TurboCache", NULL}, - {0x0170, "NV17 [GeForce4 MX 460]", NULL}, - {0x0171, "NV17 [GeForce4 MX 440]", NULL}, - {0x0172, "NV17 [GeForce4 MX 420]", NULL}, - {0x0173, "NV17 [GeForce4 MX 440-SE]", NULL}, - {0x0174, "NV17 [GeForce4 440 Go]", NULL}, - {0x0175, "NV17 [GeForce4 420 Go]", NULL}, - {0x0176, "NV17 [GeForce4 420 Go 32M]", NULL}, - {0x0177, "NV17 [GeForce4 460 Go]", NULL}, - {0x0178, "NV17GL [Quadro4 550 XGL]", NULL}, - {0x0179, "NV17 [GeForce4 420 Go 32M]", NULL}, - {0x017A, "NV17GL [Quadro4 200/400 NVS]", NULL}, - {0x017B, "NV17GL [Quadro4 550 XGL]", NULL}, - {0x017C, "NV17GL [Quadro4 500 GoGL]", NULL}, - {0x017D, "NV17 [GeForce4 410 Go 16M]", NULL}, - {0x0181, "NV18 [GeForce4 MX 440 AGP 8x]", NULL}, - {0x0182, "NV18 [GeForce4 MX 440SE AGP 8x]", NULL}, - {0x0183, "NV18 [GeForce4 MX 420 AGP 8x]", NULL}, - {0x0185, "NV18 [GeForce4 MX 4000 AGP 8x]", NULL}, - {0x0186, "NV18M [GeForce4 448 Go]", NULL}, - {0x0187, "NV18M [GeForce4 488 Go]", NULL}, - {0x0188, "NV18GL [Quadro4 580 XGL]", NULL}, - {0x018A, "NV18GL [Quadro4 NVS AGP 8x]", NULL}, - {0x018B, "NV18GL [Quadro4 380 XGL]", NULL}, - {0x018D, "NV18M [GeForce4 448 Go]", NULL}, - {0x01A0, "NVCrush11 [GeForce2 MX Integrated Graphics]", NULL}, - {0x01A4, "nForce CPU bridge", NULL}, - {0x01AB, "nForce 420 Memory Controller (DDR)", NULL}, - {0x01AC, "nForce 220/420 Memory Controller", NULL}, - {0x01AD, "nForce 220/420 Memory Controller", NULL}, - {0x01B0, "nForce Audio", NULL}, - {0x01B1, "nForce Audio", NULL}, - {0x01B2, "nForce ISA Bridge", NULL}, - {0x01B4, "nForce PCI System Management", NULL}, - {0x01B7, "nForce AGP to PCI Bridge", NULL}, - {0x01B8, "nForce PCI-to-PCI bridge", NULL}, - {0x01BC, "nForce IDE", NULL}, - {0x01C1, "nForce AC'97 Modem Controller", NULL}, - {0x01C2, "nForce USB Controller", NULL}, - {0x01C3, "nForce Ethernet Controller", NULL}, - {0x01E0, "nForce2 AGP (different version?)", NULL}, - {0x01E8, "nForce2 AGP", NULL}, - {0x01EA, "nForce2 Memory Controller 0", NULL}, - {0x01EB, "nForce2 Memory Controller 1", NULL}, - {0x01EC, "nForce2 Memory Controller 2", NULL}, - {0x01ED, "nForce2 Memory Controller 3", NULL}, - {0x01EE, "nForce2 Memory Controller 4", NULL}, - {0x01EF, "nForce2 Memory Controller 5", NULL}, - {0x01F0, "NV18 [GeForce4 MX - nForce GPU]", NULL}, - {0x0200, "NV20 [GeForce3]", NULL}, - {0x0201, "NV20 [GeForce3 Ti 200]", NULL}, - {0x0202, "NV20 [GeForce3 Ti 500]", NULL}, - {0x0203, "NV20DCC [Quadro DCC]", NULL}, - {0x0221, "GeForce 6200", NULL}, - {0x0240, "C51PV [GeForce 6150]", NULL}, - {0x0241, "C51 PCI Express Bridge", NULL}, - {0x0242, "C51G [GeForce 6100]", NULL}, - {0x0243, "C51 PCI Express Bridge", NULL}, - {0x0244, "C51 PCI Express Bridge", NULL}, - {0x0245, "C51 PCI Express Bridge", NULL}, - {0x0246, "C51 PCI Express Bridge", NULL}, - {0x0247, "C51 PCI Express Bridge", NULL}, - {0x0248, "C51 PCI Express Bridge", NULL}, - {0x0249, "C51 PCI Express Bridge", NULL}, - {0x024A, "C51 PCI Express Bridge", NULL}, - {0x024B, "C51 PCI Express Bridge", NULL}, - {0x024C, "C51 PCI Express Bridge", NULL}, - {0x024D, "C51 PCI Express Bridge", NULL}, - {0x024E, "C51 PCI Express Bridge", NULL}, - {0x024F, "C51 PCI Express Bridge", NULL}, - {0x0250, "NV25 [GeForce4 Ti 4600]", NULL}, - {0x0251, "NV25 [GeForce4 Ti 4400]", NULL}, - {0x0252, "NV25 [GeForce4 Ti]", NULL}, - {0x0253, "NV25 [GeForce4 Ti 4200]", NULL}, - {0x0258, "NV25GL [Quadro4 900 XGL]", NULL}, - {0x0259, "NV25GL [Quadro4 750 XGL]", NULL}, - {0x025B, "NV25GL [Quadro4 700 XGL]", NULL}, - {0x0260, "MCP51 LPC Bridge", NULL}, - {0x0261, "MCP51 LPC Bridge", NULL}, - {0x0262, "MCP51 LPC Bridge", NULL}, - {0x0263, "MCP51 LPC Bridge", NULL}, - {0x0264, "MCP51 SMBus", NULL}, - {0x0265, "MCP51 IDE", NULL}, - {0x0266, "MCP51 Serial ATA Controller", NULL}, - {0x0267, "MCP51 Serial ATA Controller", NULL}, - {0x0268, "MCP51 Ethernet Controller", NULL}, - {0x0269, "MCP51 Ethernet Controller", NULL}, - {0x026A, "MCP51 MCI", NULL}, - {0x026B, "MCP51 AC97 Audio Controller", NULL}, - {0x026C, "MCP51 High Definition Audio", NULL}, - {0x026D, "MCP51 USB Controller", NULL}, - {0x026E, "MCP51 USB Controller", NULL}, - {0x026F, "MCP51 PCI Bridge", NULL}, - {0x0270, "MCP51 Host Bridge", NULL}, - {0x0271, "MCP51 PMU", NULL}, - {0x0272, "MCP51 Memory Controller 0", NULL}, - {0x027E, "C51 Memory Controller 2", NULL}, - {0x027F, "C51 Memory Controller 3", NULL}, - {0x0280, "NV28 [GeForce4 Ti 4800]", NULL}, - {0x0281, "NV28 [GeForce4 Ti 4200 AGP 8x]", NULL}, - {0x0282, "NV28 [GeForce4 Ti 4800 SE]", NULL}, - {0x0286, "NV28 [GeForce4 Ti 4200 Go AGP 8x]", NULL}, - {0x0288, "NV28GL [Quadro4 980 XGL]", NULL}, - {0x0289, "NV28GL [Quadro4 780 XGL]", NULL}, - {0x028C, "NV28GLM [Quadro4 700 GoGL]", NULL}, - {0x02A0, "NV2A [XGPU]", NULL}, - {0x02F0, "C51 Host Bridge", NULL}, - {0x02F1, "C51 Host Bridge", NULL}, - {0x02F2, "C51 Host Bridge", NULL}, - {0x02F3, "C51 Host Bridge", NULL}, - {0x02F4, "C51 Host Bridge", NULL}, - {0x02F5, "C51 Host Bridge", NULL}, - {0x02F6, "C51 Host Bridge", NULL}, - {0x02F7, "C51 Host Bridge", NULL}, - {0x02F8, "C51 Memory Controller 5", NULL}, - {0x02F9, "C51 Memory Controller 4", NULL}, - {0x02FA, "C51 Memory Controller 0", NULL}, - {0x02FB, "C51 PCI Express Bridge", NULL}, - {0x02FC, "C51 PCI Express Bridge", NULL}, - {0x02FD, "C51 PCI Express Bridge", NULL}, - {0x02FE, "C51 Memory Controller 1", NULL}, - {0x02FF, "C51 Host Bridge", NULL}, - {0x0300, "NV30 [GeForce FX]", NULL}, - {0x0301, "NV30 [GeForce FX 5800 Ultra]", NULL}, - {0x0302, "NV30 [GeForce FX 5800]", NULL}, - {0x0308, "NV30GL [Quadro FX 2000]", NULL}, - {0x0309, "NV30GL [Quadro FX 1000]", NULL}, - {0x0311, "NV31 [GeForce FX 5600 Ultra]", NULL}, - {0x0312, "NV31 [GeForce FX 5600]", NULL}, - {0x0313, "NV31", NULL}, - {0x0314, "NV31 [GeForce FX 5600XT]", NULL}, - {0x0316, "NV31M", NULL}, - {0x0317, "NV31M Pro", NULL}, - {0x031A, "NV31M [GeForce FX Go5600]", NULL}, - {0x031B, "NV31M [GeForce FX Go5650]", NULL}, - {0x031C, "NVIDIA Quadro FX Go700", NULL}, - {0x031D, "NV31GLM", NULL}, - {0x031E, "NV31GLM Pro", NULL}, - {0x031F, "NV31GLM Pro", NULL}, - {0x0320, "NV34 [GeForce FX 5200]", NULL}, - {0x0321, "NV34 [GeForce FX 5200 Ultra]", NULL}, - {0x0322, "NV34 [GeForce FX 5200]", NULL}, - {0x0323, "NV34 [GeForce FX 5200LE]", NULL}, - {0x0324, "NV34M [GeForce FX Go5200]", NULL}, - {0x0325, "NV34M [GeForce FX Go5250]", NULL}, - {0x0326, "NV34 [GeForce FX 5500]", NULL}, - {0x0327, "NV34 [GeForce FX 5100]", NULL}, - {0x0328, "NV34M [GeForce FX Go5200 32M/64M]", NULL}, - {0x0329, "NV34M [GeForce FX Go5200]", NULL}, - {0x032A, "NV34GL [Quadro NVS 280 PCI]", NULL}, - {0x032B, "NV34GL [Quadro FX 500/600 PCI]", NULL}, - {0x032C, "NV34GLM [GeForce FX Go 5300]", NULL}, - {0x032D, "NV34 [GeForce FX Go5100]", NULL}, - {0x032F, "NV34GL", NULL}, - {0x0330, "NV35 [GeForce FX 5900 Ultra]", NULL}, - {0x0331, "NV35 [GeForce FX 5900]", NULL}, - {0x0332, "NV35 [GeForce FX 5900XT]", NULL}, - {0x0333, "NV38 [GeForce FX 5950 Ultra]", NULL}, - {0x0334, "NV35 [GeForce FX 5900ZT]", NULL}, - {0x0338, "NV35GL [Quadro FX 3000]", NULL}, - {0x033F, "NV35GL [Quadro FX 700]", NULL}, - {0x0341, "NV36.1 [GeForce FX 5700 Ultra]", NULL}, - {0x0342, "NV36.2 [GeForce FX 5700]", NULL}, - {0x0343, "NV36 [GeForce FX 5700LE]", NULL}, - {0x0344, "NV36.4 [GeForce FX 5700VE]", NULL}, - {0x0345, "NV36.5", NULL}, - {0x0347, "NV36 [GeForce FX Go5700]", NULL}, - {0x0348, "NV36 [GeForce FX Go5700]", NULL}, - {0x0349, "NV36M Pro", NULL}, - {0x034B, "NV36MAP", NULL}, - {0x034C, "NV36 [Quadro FX Go1000]", NULL}, - {0x034E, "NV36GL [Quadro FX 1100]", NULL}, - {0x034F, "NV36GL", NULL}, - {0x0360, "MCP55 LPC Bridge", NULL}, - {0x0361, "MCP55 LPC Bridge", NULL}, - {0x0362, "MCP55 LPC Bridge", NULL}, - {0x0363, "MCP55 LPC Bridge", NULL}, - {0x0364, "MCP55 LPC Bridge", NULL}, - {0x0365, "MCP55 LPC Bridge", NULL}, - {0x0366, "MCP55 LPC Bridge", NULL}, - {0x0367, "MCP55 LPC Bridge", NULL}, - {0x0368, "MCP55 SMBus", NULL}, - {0x0369, "MCP55 Memory Controller", NULL}, - {0x036A, "MCP55 Memory Controller", NULL}, - {0x036C, "MCP55 USB Controller", NULL}, - {0x036D, "MCP55 USB Controller", NULL}, - {0x036E, "MCP55 IDE", NULL}, - {0x0371, "MCP55 High Definition Audio", NULL}, - {0x0372, "MCP55 Ethernet", NULL}, - {0x0373, "MCP55 Ethernet", NULL}, - {0x037A, "MCP55 Memory Controller", NULL}, - {0x037E, "MCP55 SATA Controller", NULL}, - {0x037F, "MCP55 SATA Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10DF[] = { - {0x1AE5, "LP6000 Fibre Channel Host Adapter", NULL}, - {0xF085, "LP850 Fibre Channel Host Adapter", NULL}, - {0xF095, "LP952 Fibre Channel Host Adapter", NULL}, - {0xF098, "LP982 Fibre Channel Host Adapter", NULL}, - {0xF0A1, "Thor LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0A5, "Thor LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0B5, "Viper LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0D1, "Helios LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0D5, "Helios LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0E1, "Zephyr LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0E5, "Zephyr LightPulse Fibre Channel Host Adapter", NULL}, - {0xF0F5, "Neptune LightPulse Fibre Channel Host Adapter", NULL}, - {0xF700, "LP7000 Fibre Channel Host Adapter", NULL}, - {0xF701, "LP7000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2)", NULL}, - {0xF800, "LP8000 Fibre Channel Host Adapter", NULL}, - {0xF801, "LP8000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2)", NULL}, - {0xF900, "LP9000 Fibre Channel Host Adapter", NULL}, - {0xF901, "LP9000 Fibre Channel Host Adapter Alternate ID (JX1:2-3, JX2:1-2)", NULL}, - {0xF980, "LP9802 Fibre Channel Host Adapter", NULL}, - {0xF981, "LP9802 Fibre Channel Host Adapter Alternate ID", NULL}, - {0xF982, "LP9802 Fibre Channel Host Adapter Alternate ID", NULL}, - {0xFA00, "Thor-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFB00, "Viper LightPulse Fibre Channel Host Adapter", NULL}, - {0xFC00, "Thor-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFC10, "Helios-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFC20, "Zephyr-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFD00, "Helios-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFE00, "Zephyr-X LightPulse Fibre Channel Host Adapter", NULL}, - {0xFF00, "Neptune LightPulse Fibre Channel Host Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10E0[] = { - {0x5026, "IMS5026/27/28", NULL}, - {0x5027, "IMS5027", NULL}, - {0x5028, "IMS5028", NULL}, - {0x8849, "IMS8849", NULL}, - {0x8853, "IMS8853", NULL}, - {0x9128, "IMS9128 [Twin turbo 128]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10E1[] = { - {0x0391, "TRM-S1040", NULL}, - {0x690C, "DC-690c", NULL}, - {0xDC29, "DC-290", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10E3[] = { - {0x0000, "CA91C042 [Universe]", NULL}, - {0x0148, "Tsi148 [Tempe]", NULL}, - {0x0860, "CA91C860 [QSpan]", NULL}, - {0x0862, "CA91C862A [QSpan-II]", NULL}, - {0x8260, "CA91L8200B [Dual PCI PowerSpan II]", NULL}, - {0x8261, "CA91L8260B [Single PCI PowerSpan II]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10E4[] = { - {0x8029, "Realtek 8029 Network Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10E8[] = { - {0x1072, "INES GPIB-PCI (AMCC5920 based)", NULL}, - {0x2011, "Q-Motion Video Capture/Edit board", NULL}, - {0x4750, "S5930 [Matchmaker]", NULL}, - {0x5920, "S5920", NULL}, - {0x8043, "LANai4.x [Myrinet LANai interface chip]", NULL}, - {0x8062, "S5933_PARASTATION", NULL}, - {0x807D, "S5933 [Matchmaker]", NULL}, - {0x8088, "Kongsberg Spacetec Format Synchronizer", NULL}, - {0x8089, "Kongsberg Spacetec Serial Output Board", NULL}, - {0x809C, "S5933_HEPC3", NULL}, - {0x80D7, "PCI-9112", NULL}, - {0x80D9, "PCI-9118", NULL}, - {0x80DA, "PCI-9812", NULL}, - {0x811A, "PCI-IEEE1355-DS-DE Interface", NULL}, - {0x814C, "Fastcom ESCC-PCI (Commtech, Inc.)", NULL}, - {0x8170, "S5933 [Matchmaker] (Chipset Development Tool)", NULL}, - {0x81E6, "Multimedia video controller", NULL}, - {0x8291, "Fastcom 232/8-PCI (Commtech, Inc.)", NULL}, - {0x82C4, "Fastcom 422/4-PCI (Commtech, Inc.)", NULL}, - {0x82C5, "Fastcom 422/2-PCI (Commtech, Inc.)", NULL}, - {0x82C6, "Fastcom IG422/1-PCI (Commtech, Inc.)", NULL}, - {0x82C7, "Fastcom IG232/2-PCI (Commtech, Inc.)", NULL}, - {0x82CA, "Fastcom 232/4-PCI (Commtech, Inc.)", NULL}, - {0x82DB, "AJA HDNTV HD SDI Framestore", NULL}, - {0x82E2, "Fastcom DIO24H-PCI (Commtech, Inc.)", NULL}, - {0x8851, "S5933 on Innes Corp FM Radio Capture card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10EA[] = { - {0x1680, "IGA-1680", NULL}, - {0x1682, "IGA-1682", NULL}, - {0x1683, "IGA-1683", NULL}, - {0x2000, "CyberPro 2000", NULL}, - {0x2010, "CyberPro 2000A", NULL}, - {0x5000, "CyberPro 5000", NULL}, - {0x5050, "CyberPro 5050", NULL}, - {0x5202, "CyberPro 5202", NULL}, - {0x5252, "CyberPro5252", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10EB[] = { - {0x0101, "3GA", NULL}, - {0x8111, "Twist3 Frame Grabber", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10EC[] = { - {0x0139, "Zonet Zen3200", NULL}, - {0x8029, "RTL-8029(AS)", NULL}, - {0x8129, "RTL-8129", NULL}, - {0x8138, "RT8139 (B/C) Cardbus Fast Ethernet Adapter", NULL}, - {0x8139, "RTL-8139/8139C/8139C+", NULL}, - {0x8169, "RTL-8169 Gigabit Ethernet", NULL}, - {0x8180, "RTL8180L 802.11b MAC", NULL}, - {0x8197, "SmartLAN56 56K Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10ED[] = { - {0x7310, "V7310", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10EE[] = { - {0x0205, "Wildcard TE205P", NULL}, - {0x0210, "Wildcard TE210P", NULL}, - {0x0314, "Wildcard TE405P/TE410P (1st Gen)", NULL}, - {0x0405, "Wildcard TE405P (2nd Gen)", NULL}, - {0x0410, "Wildcard TE410P (2nd Gen)", NULL}, - {0x3FC0, "RME Digi96", NULL}, - {0x3FC1, "RME Digi96/8", NULL}, - {0x3FC2, "RME Digi96/8 Pro", NULL}, - {0x3FC3, "RME Digi96/8 Pad", NULL}, - {0x3FC4, "RME Digi9652 (Hammerfall)", NULL}, - {0x3FC5, "RME Hammerfall DSP", NULL}, - {0x3FC6, "RME Hammerfall DSP MADI", NULL}, - {0x8381, "Ellips Santos Frame Grabber", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10EF[] = { - {0x8154, "M815x Token Ring Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10F5[] = { - {0xA001, "NDR4000 [NR4600 Bridge]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10FA[] = { - {0x000C, "TARGA 1000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10FB[] = { - {0x186F, "TH 6255", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_10FC[] = { - {0x0003, "Cardbus IDE Controller", NULL}, - {0x0005, "Cardbus SCSI CBSC II", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1101[] = { - {0x1060, "INI-A100U2W", NULL}, - {0x9100, "INI-9100/9100W", NULL}, - {0x9400, "INI-940", NULL}, - {0x9401, "INI-950", NULL}, - {0x9500, "360P", NULL}, - {0x9502, "Initio INI-9100UW Ultra Wide SCSI Controller INIC-950P chip", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1102[] = { - {0x0002, "SB Live! EMU10k1", NULL}, - {0x0004, "SB Audigy", NULL}, - {0x0006, "[SB Live! Value] EMU10k1X", NULL}, - {0x0007, "SB Audigy LS", NULL}, - {0x0008, "SB0400 Audigy2 Value", NULL}, - {0x4001, "SB Audigy FireWire Port", NULL}, - {0x7002, "SB Live! MIDI/Game Port", NULL}, - {0x7003, "SB Audigy MIDI/Game port", NULL}, - {0x7004, "[SB Live! Value] Input device controller", NULL}, - {0x7005, "SB Audigy LS MIDI/Game port", NULL}, - {0x8064, "SB0100 [SBLive! 5.1 OEM]", NULL}, - {0x8938, "Ectiva EV1938", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1103[] = { - {0x0003, "HPT343", NULL}, - {0x0004, "HPT366/368/370/370A/372/372N", NULL}, - {0x0005, "HPT372A/372N", NULL}, - {0x0006, "HPT302", NULL}, - {0x0007, "HPT371/371N", NULL}, - {0x0008, "HPT374", NULL}, - {0x0009, "HPT372N", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1105[] = { - {0x1105, "REALmagic Xcard MPEG 1/2/3/4 DVD Decoder", NULL}, - {0x8300, "REALmagic Hollywood Plus DVD Decoder", NULL}, - {0x8400, "EM840x REALmagic DVD/MPEG-2 Audio/Video Decoder", NULL}, - {0x8401, "EM8401 REALmagic DVD/MPEG-2 A/V Decoder", NULL}, - {0x8470, "EM8470 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x8471, "EM8471 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x8475, "EM8475 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x8476, "EM8476 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x8485, "EM8485 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x8486, "EM8486 REALmagic DVD/MPEG-4 A/V Decoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1106[] = { - {0x0102, "Embedded VIA Ethernet Controller", NULL}, - {0x0130, "VT6305 1394.A Controller", NULL}, - {0x0204, "K8M800 Host Bridge", NULL}, - {0x0238, "K8T890 Host Bridge", NULL}, - {0x0258, "PT880 Host Bridge", NULL}, - {0x0259, "CN400/PM880 Host Bridge", NULL}, - {0x0269, "KT880 Host Bridge", NULL}, - {0x0282, "K8T800Pro Host Bridge", NULL}, - {0x0290, "K8M890 Host Bridge", NULL}, - {0x0296, "P4M800 Host Bridge", NULL}, - {0x0305, "VT8363/8365 [KT133/KM133]", NULL}, - {0x0308, "PT894 Host Bridge", NULL}, - {0x0314, "P4M800CE Host Bridge", NULL}, - {0x0391, "VT8371 [KX133]", NULL}, - {0x0501, "VT8501 [Apollo MVP4]", NULL}, - {0x0505, "VT82C505", NULL}, - {0x0561, "VT82C576MV", NULL}, - {0x0571, "VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE", NULL}, - {0x0576, "VT82C576 3V [Apollo Master]", NULL}, - {0x0585, "VT82C585VP [Apollo VP1/VPX]", NULL}, - {0x0586, "VT82C586/A/B PCI-to-ISA [Apollo VP]", NULL}, - {0x0591, "VT8237A SATA 2-Port Controller", NULL}, - {0x0595, "VT82C595 [Apollo VP2]", NULL}, - {0x0596, "VT82C596 ISA [Mobile South]", NULL}, - {0x0597, "VT82C597 [Apollo VP3]", NULL}, - {0x0598, "VT82C598 [Apollo MVP3]", NULL}, - {0x0601, "VT8601 [Apollo ProMedia]", NULL}, - {0x0605, "VT8605 [ProSavage PM133]", NULL}, - {0x0680, "VT82C680 [Apollo P6]", NULL}, - {0x0686, "VT82C686 [Apollo Super South]", NULL}, - {0x0691, "VT82C693A/694x [Apollo PRO133x]", NULL}, - {0x0693, "VT82C693 [Apollo Pro Plus]", NULL}, - {0x0698, "VT82C693A [Apollo Pro133 AGP]", NULL}, - {0x0926, "VT82C926 [Amazon]", NULL}, - {0x1000, "VT82C570MV", NULL}, - {0x1106, "VT82C570MV", NULL}, - {0x1204, "K8M800 Host Bridge", NULL}, - {0x1208, "PT890 Host Bridge", NULL}, - {0x1238, "K8T890 Host Bridge", NULL}, - {0x1258, "PT880 Host Bridge", NULL}, - {0x1259, "CN400/PM880 Host Bridge", NULL}, - {0x1269, "KT880 Host Bridge", NULL}, - {0x1282, "K8T800Pro Host Bridge", NULL}, - {0x1290, "K8M890 Host Bridge", NULL}, - {0x1296, "P4M800 Host Bridge", NULL}, - {0x1308, "PT894 Host Bridge", NULL}, - {0x1314, "P4M800CE Host Bridge", NULL}, - {0x1571, "VT82C576M/VT82C586", NULL}, - {0x1595, "VT82C595/97 [Apollo VP2/97]", NULL}, - {0x2204, "K8M800 Host Bridge", NULL}, - {0x2208, "PT890 Host Bridge", NULL}, - {0x2238, "K8T890 Host Bridge", NULL}, - {0x2258, "PT880 Host Bridge", NULL}, - {0x2259, "CN400/PM880 Host Bridge", NULL}, - {0x2269, "KT880 Host Bridge", NULL}, - {0x2282, "K8T800Pro Host Bridge", NULL}, - {0x2290, "K8M890 Host Bridge", NULL}, - {0x2296, "P4M800 Host Bridge", NULL}, - {0x2308, "PT894 Host Bridge", NULL}, - {0x2314, "P4M800CE Host Bridge", NULL}, - {0x287A, "VT8251 PCI to PCI Bridge", NULL}, - {0x287B, "VT8251 PCI to PCIE Bridge", NULL}, - {0x287C, "VT8251 PCIE Root Port", NULL}, - {0x287D, "VT8251 PCIE Root Port", NULL}, - {0x287E, "VT8251 Ultra VLINK Controller", NULL}, - {0x3022, "CLE266", NULL}, - {0x3038, "VT82xxxxx UHCI USB 1.1 Controller", NULL}, - {0x3040, "VT82C586B ACPI", NULL}, - {0x3043, "VT86C100A [Rhine]", NULL}, - {0x3044, "IEEE 1394 Host Controller", NULL}, - {0x3050, "VT82C596 Power Management", NULL}, - {0x3051, "VT82C596 Power Management", NULL}, - {0x3053, "VT6105M [Rhine-III]", NULL}, - {0x3057, "VT82C686 [Apollo Super ACPI]", NULL}, - {0x3058, "VT82C686 AC97 Audio Controller", NULL}, - {0x3059, "VT8233/A/8235/8237 AC97 Audio Controller", NULL}, - {0x3065, "VT6102 [Rhine-II]", NULL}, - {0x3068, "AC'97 Modem Controller", NULL}, - {0x3074, "VT8233 PCI to ISA Bridge", NULL}, - {0x3091, "VT8633 [Apollo Pro266]", NULL}, - {0x3099, "VT8366/A/7 [Apollo KT266/A/333]", NULL}, - {0x3101, "VT8653 Host Bridge", NULL}, - {0x3102, "VT8662 Host Bridge", NULL}, - {0x3103, "VT8615 Host Bridge", NULL}, - {0x3104, "USB 2.0", NULL}, - {0x3106, "VT6105 [Rhine-III]", NULL}, - {0x3108, "S3 Unichrome Pro VGA Adapter", NULL}, - {0x3109, "VT8233C PCI to ISA Bridge", NULL}, - {0x3112, "VT8361 [KLE133] Host Bridge", NULL}, - {0x3113, "VPX/VPX2 PCI to PCI Bridge Controller", NULL}, - {0x3116, "VT8375 [KM266/KL266] Host Bridge", NULL}, - {0x3118, "S3 Unichrome Pro VGA Adapter", NULL}, - {0x3119, "VT6120/VT6121/VT6122 Gigabit Ethernet Adapter", NULL}, - {0x3122, "VT8623 [Apollo CLE266] integrated CastleRock graphics", NULL}, - {0x3123, "VT8623 [Apollo CLE266]", NULL}, - {0x3128, "VT8753 [P4X266 AGP]", NULL}, - {0x3133, "VT3133 Host Bridge", NULL}, - {0x3147, "VT8233A ISA Bridge", NULL}, - {0x3148, "P4M266 Host Bridge", NULL}, - {0x3149, "VIA VT6420 SATA RAID Controller", NULL}, - {0x3156, "P/KN266 Host Bridge", NULL}, - {0x3164, "VT6410 ATA133 RAID controller", NULL}, - {0x3168, "VT8374 P4X400 Host Controller/AGP Bridge", NULL}, - {0x3177, "VT8235 ISA Bridge", NULL}, - {0x3178, "ProSavageDDR P4N333 Host Bridge", NULL}, - {0x3188, "VT8385 [K8T800 AGP] Host Bridge", NULL}, - {0x3189, "VT8377 [KT400/KT600 AGP] Host Bridge", NULL}, - {0x3204, "K8M800 Host Bridge", NULL}, - {0x3205, "VT8378 [KM400/A] Chipset Host Bridge", NULL}, - {0x3208, "PT890 Host Bridge", NULL}, - {0x3213, "VPX/VPX2 PCI to PCI Bridge Controller", NULL}, - {0x3218, "K8T800M Host Bridge", NULL}, - {0x3227, "VT8237 ISA bridge [KT600/K8T800/K8T890 South]", NULL}, - {0x3238, "K8T890 Host Bridge", NULL}, - {0x3249, "VT6421 IDE RAID Controller", NULL}, - {0x3258, "PT880 Host Bridge", NULL}, - {0x3259, "CN400/PM880 Host Bridge", NULL}, - {0x3269, "KT880 Host Bridge", NULL}, - {0x3282, "K8T800Pro Host Bridge", NULL}, - {0x3287, "VT8251 PCI to ISA Bridge", NULL}, - {0x3288, "VIA High Definition Audio Controller", NULL}, - {0x3290, "K8M890 Host Bridge", NULL}, - {0x3296, "P4M800 Host Bridge", NULL}, - {0x3337, "VT8237A PCI to ISA Bridge", NULL}, - {0x3344, "UniChrome Pro IGP", NULL}, - {0x3349, "VT8251 AHCI/SATA 4-Port Controller", NULL}, - {0x337A, "VT8237A PCI to PCI Bridge", NULL}, - {0x337B, "VT8237A PCI to PCIE Bridge", NULL}, - {0x4149, "VIA VT6420 (ATA133) Controller", NULL}, - {0x4204, "K8M800 Host Bridge", NULL}, - {0x4208, "PT890 Host Bridge", NULL}, - {0x4238, "K8T890 Host Bridge", NULL}, - {0x4258, "PT880 Host Bridge", NULL}, - {0x4259, "CN400/PM880 Host Bridge", NULL}, - {0x4269, "KT880 Host Bridge", NULL}, - {0x4282, "K8T800Pro Host Bridge", NULL}, - {0x4290, "K8M890 Host Bridge", NULL}, - {0x4296, "P4M800 Host Bridge", NULL}, - {0x4308, "PT894 Host Bridge", NULL}, - {0x4314, "P4M800CE Host Bridge", NULL}, - {0x5030, "VT82C596 ACPI [Apollo PRO]", NULL}, - {0x5208, "PT890 I/O APIC Interrupt Controller", NULL}, - {0x5238, "K8T890 I/O APIC Interrupt Controller", NULL}, - {0x5290, "K8M890 I/O APIC Interrupt Controller", NULL}, - {0x5308, "PT894 I/O APIC Interrupt Controller", NULL}, - {0x6100, "VT85C100A [Rhine II]", NULL}, - {0x7204, "K8M800 Host Bridge", NULL}, - {0x7205, "VT8378 [S3 UniChrome] Integrated Video", NULL}, - {0x7208, "PT890 Host Bridge", NULL}, - {0x7238, "K8T890 Host Bridge", NULL}, - {0x7258, "PT880 Host Bridge", NULL}, - {0x7259, "CN400/PM880 Host Bridge", NULL}, - {0x7269, "KT880 Host Bridge", NULL}, - {0x7282, "K8T800Pro Host Bridge", NULL}, - {0x7290, "K8M890 Host Bridge", NULL}, - {0x7296, "P4M800 Host Bridge", NULL}, - {0x7308, "PT894 Host Bridge", NULL}, - {0x7314, "P4M800CE Host Bridge", NULL}, - {0x8231, "VT8231 [PCI-to-ISA Bridge]", NULL}, - {0x8235, "VT8235 ACPI", NULL}, - {0x8305, "VT8363/8365 [KT133/KM133 AGP]", NULL}, - {0x8391, "VT8371 [KX133 AGP]", NULL}, - {0x8501, "VT8501 [Apollo MVP4 AGP]", NULL}, - {0x8596, "VT82C596 [Apollo PRO AGP]", NULL}, - {0x8597, "VT82C597 [Apollo VP3 AGP]", NULL}, - {0x8598, "VT82C598/694x [Apollo MVP3/Pro133x AGP]", NULL}, - {0x8601, "VT8601 [Apollo ProMedia AGP]", NULL}, - {0x8605, "VT8605 [PM133 AGP]", NULL}, - {0x8691, "VT82C691 [Apollo Pro]", NULL}, - {0x8693, "VT82C693 [Apollo Pro Plus] PCI Bridge", NULL}, - {0xA208, "PT890 PCI to PCI Bridge Controller", NULL}, - {0xA238, "K8T890 PCI to PCI Bridge Controller", NULL}, - {0xB091, "VT8633 [Apollo Pro266 AGP]", NULL}, - {0xB099, "VT8366/A/7 [Apollo KT266/A/333 AGP]", NULL}, - {0xB101, "VT8653 AGP Bridge", NULL}, - {0xB102, "VT8362 AGP Bridge", NULL}, - {0xB103, "VT8615 AGP Bridge", NULL}, - {0xB112, "VT8361 [KLE133] AGP Bridge", NULL}, - {0xB113, "VPX/VPX2 I/O APIC Interrupt Controller", NULL}, - {0xB115, "VT8363/8365 [KT133/KM133] PCI Bridge", NULL}, - {0xB168, "VT8235 PCI Bridge", NULL}, - {0xB188, "VT8237 PCI bridge [K8T800/K8T890 South]", NULL}, - {0xB198, "VT8237 PCI Bridge", NULL}, - {0xB213, "VPX/VPX2 I/O APIC Interrupt Controller", NULL}, - {0xC208, "PT890 PCI to PCI Bridge Controller", NULL}, - {0xC238, "K8T890 PCI to PCI Bridge Controller", NULL}, - {0xD104, "VT8237 Integrated Fast Ethernet Controller", NULL}, - {0xD208, "PT890 PCI to PCI Bridge Controller", NULL}, - {0xD213, "VPX/VPX2 PCI to PCI Bridge Controller", NULL}, - {0xD238, "K8T890 PCI to PCI Bridge Controller", NULL}, - {0xE208, "PT890 PCI to PCI Bridge Controller", NULL}, - {0xE238, "K8T890 PCI to PCI Bridge Controller", NULL}, - {0xF208, "PT890 PCI to PCI Bridge Controller", NULL}, - {0xF238, "K8T890 PCI to PCI Bridge Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1107[] = { - {0x0576, "VIA VT82C570MV [Apollo] (Wrong vendor ID!)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1108[] = { - {0x0100, "p1690plus_AA", NULL}, - {0x0101, "p1690plus_AB", NULL}, - {0x0105, "P1690Plus", NULL}, - {0x0108, "P1690Plus", NULL}, - {0x0138, "P1690Plus", NULL}, - {0x0139, "P1690Plus", NULL}, - {0x013C, "P1690Plus", NULL}, - {0x013D, "P1690Plus", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1109[] = { - {0x1400, "EM110TX [EX110TX]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_110A[] = { - {0x0002, "Pirahna 2-port", NULL}, - {0x0005, "Tulip controller, power management, switch extender", NULL}, - {0x0006, "FSC PINC (I/O-APIC)", NULL}, - {0x0015, "FSC Multiprocessor Interrupt Controller", NULL}, - {0x001D, "FSC Copernicus Management Controller", NULL}, - {0x007B, "FSC Remote Service Controller, mailbox device", NULL}, - {0x007C, "FSC Remote Service Controller, shared memory device", NULL}, - {0x007D, "FSC Remote Service Controller, SMIC device", NULL}, - {0x2101, "HST SAPHIR V Primary PCI (ISDN/PMx)", NULL}, - {0x2102, "DSCC4 PEB/PEF 20534 DMA Supported Serial Communication Controller with 4 Channels", NULL}, - {0x2104, "Eicon Diva 2.02 compatible passive ISDN card", NULL}, - {0x3142, "SIMATIC NET CP 5613A1 (Profibus Adapter)", NULL}, - {0x4021, "SIMATIC NET CP 5512 (Profibus and MPI Cardbus Adapter)", NULL}, - {0x4029, "SIMATIC NET CP 5613A2 (Profibus Adapter)", NULL}, - {0x4942, "FPGA I-Bus Tracer for MBD", NULL}, - {0x6120, "SZB6120", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_110B[] = { - {0x0001, "Mpact Media Processor", NULL}, - {0x0004, "Mpact 2", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1110[] = { - {0x6037, "Firepower Powerized SMP I/O ASIC", NULL}, - {0x6073, "Firepower Powerized SMP I/O ASIC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1112[] = { - {0x2200, "FDDI Adapter", NULL}, - {0x2300, "Fast Ethernet Adapter", NULL}, - {0x2340, "4 Port Fast Ethernet Adapter", NULL}, - {0x2400, "ATM Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1113[] = { - {0x1211, "SMC2-1211TX", NULL}, - {0x1216, "EN-1216 Ethernet Adapter", NULL}, - {0x1217, "EN-1217 Ethernet Adapter", NULL}, - {0x5105, "10Mbps Network card", NULL}, - {0x9211, "EN-1207D Fast Ethernet Adapter", NULL}, - {0x9511, "21x4x DEC-Tulip compatible Fast Ethernet", NULL}, - {0xD301, "CPWNA100 (Philips wireless PCMCIA)", NULL}, - {0xEC02, "SMC 1244TX v3", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1114[] = { - {0x0506, "at76c506 802.11b Wireless Network Adaptor", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1116[] = { - {0x0022, "DT3001", NULL}, - {0x0023, "DT3002", NULL}, - {0x0024, "DT3003", NULL}, - {0x0025, "DT3004", NULL}, - {0x0026, "DT3005", NULL}, - {0x0027, "DT3001-PGL", NULL}, - {0x0028, "DT3003-PGL", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1117[] = { - {0x9500, "Max-1C SVGA card", NULL}, - {0x9501, "Max-1C image processing", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1119[] = { - {0x0000, "GDT 6000/6020/6050", NULL}, - {0x0001, "GDT 6000B/6010", NULL}, - {0x0002, "GDT 6110/6510", NULL}, - {0x0003, "GDT 6120/6520", NULL}, - {0x0004, "GDT 6530", NULL}, - {0x0005, "GDT 6550", NULL}, - {0x0006, "GDT 6117/6517", NULL}, - {0x0007, "GDT 6127/6527", NULL}, - {0x0008, "GDT 6537", NULL}, - {0x0009, "GDT 6557/6557-ECC", NULL}, - {0x000A, "GDT 6115/6515", NULL}, - {0x000B, "GDT 6125/6525", NULL}, - {0x000C, "GDT 6535", NULL}, - {0x000D, "GDT 6555", NULL}, - {0x0010, "GDT 6115/6515", NULL}, - {0x0011, "GDT 6125/6525", NULL}, - {0x0012, "GDT 6535", NULL}, - {0x0013, "GDT 6555/6555-ECC", NULL}, - {0x0100, "GDT 6117RP/6517RP", NULL}, - {0x0101, "GDT 6127RP/6527RP", NULL}, - {0x0102, "GDT 6537RP", NULL}, - {0x0103, "GDT 6557RP", NULL}, - {0x0104, "GDT 6111RP/6511RP", NULL}, - {0x0105, "GDT 6121RP/6521RP", NULL}, - {0x0110, "GDT 6117RD/6517RD", NULL}, - {0x0111, "GDT 6127RD/6527RD", NULL}, - {0x0112, "GDT 6537RD", NULL}, - {0x0113, "GDT 6557RD", NULL}, - {0x0114, "GDT 6111RD/6511RD", NULL}, - {0x0115, "GDT 6121RD/6521RD", NULL}, - {0x0118, "GDT 6118RD/6518RD/6618RD", NULL}, - {0x0119, "GDT 6128RD/6528RD/6628RD", NULL}, - {0x011A, "GDT 6538RD/6638RD", NULL}, - {0x011B, "GDT 6558RD/6658RD", NULL}, - {0x0120, "GDT 6117RP2/6517RP2", NULL}, - {0x0121, "GDT 6127RP2/6527RP2", NULL}, - {0x0122, "GDT 6537RP2", NULL}, - {0x0123, "GDT 6557RP2", NULL}, - {0x0124, "GDT 6111RP2/6511RP2", NULL}, - {0x0125, "GDT 6121RP2/6521RP2", NULL}, - {0x0136, "GDT 6113RS/6513RS", NULL}, - {0x0137, "GDT 6123RS/6523RS", NULL}, - {0x0138, "GDT 6118RS/6518RS/6618RS", NULL}, - {0x0139, "GDT 6128RS/6528RS/6628RS", NULL}, - {0x013A, "GDT 6538RS/6638RS", NULL}, - {0x013B, "GDT 6558RS/6658RS", NULL}, - {0x013C, "GDT 6533RS/6633RS", NULL}, - {0x013D, "GDT 6543RS/6643RS", NULL}, - {0x013E, "GDT 6553RS/6653RS", NULL}, - {0x013F, "GDT 6563RS/6663RS", NULL}, - {0x0166, "GDT 7113RN/7513RN/7613RN", NULL}, - {0x0167, "GDT 7123RN/7523RN/7623RN", NULL}, - {0x0168, "GDT 7118RN/7518RN/7518RN", NULL}, - {0x0169, "GDT 7128RN/7528RN/7628RN", NULL}, - {0x016A, "GDT 7538RN/7638RN", NULL}, - {0x016B, "GDT 7558RN/7658RN", NULL}, - {0x016C, "GDT 7533RN/7633RN", NULL}, - {0x016D, "GDT 7543RN/7643RN", NULL}, - {0x016E, "GDT 7553RN/7653RN", NULL}, - {0x016F, "GDT 7563RN/7663RN", NULL}, - {0x01D6, "GDT 4x13RZ", NULL}, - {0x01D7, "GDT 4x23RZ", NULL}, - {0x01F6, "GDT 8x13RZ", NULL}, - {0x01F7, "GDT 8x23RZ", NULL}, - {0x01FC, "GDT 8x33RZ", NULL}, - {0x01FD, "GDT 8x43RZ", NULL}, - {0x01FE, "GDT 8x53RZ", NULL}, - {0x01FF, "GDT 8x63RZ", NULL}, - {0x0210, "GDT 6519RD/6619RD", NULL}, - {0x0211, "GDT 6529RD/6629RD", NULL}, - {0x0260, "GDT 7519RN/7619RN", NULL}, - {0x0261, "GDT 7529RN/7629RN", NULL}, - {0x02FF, "GDT MAXRP", NULL}, - {0x0300, "GDT NEWRX", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_111A[] = { - {0x0000, "155P-MF1 (FPGA)", NULL}, - {0x0002, "155P-MF1 (ASIC)", NULL}, - {0x0003, "ENI-25P ATM", NULL}, - {0x0005, "SpeedStream (LANAI)", NULL}, - {0x0007, "SpeedStream ADSL", NULL}, - {0x1203, "SpeedStream 1023 Wireless PCI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_111C[] = { - {0x0001, "Powerbis Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_111D[] = { - {0x0001, "IDT77201/77211 155Mbps ATM SAR Controller [NICStAR]", NULL}, - {0x0003, "IDT77222/77252 155Mbps ATM MICRO ABR SAR Controller", NULL}, - {0x0004, "IDT77V252 155Mbps ATM MICRO ABR SAR Controller", NULL}, - {0x0005, "IDT77V222 155Mbps ATM MICRO ABR SAR Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_111F[] = { - {0x4A47, "Precision MX Video engine interface", NULL}, - {0x5243, "Frame capture bus interface", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1127[] = { - {0x0200, "ForeRunner PCA-200 ATM", NULL}, - {0x0210, "PCA-200PC", NULL}, - {0x0250, "ATM", NULL}, - {0x0300, "ForeRunner PCA-200EPC ATM", NULL}, - {0x0310, "ATM", NULL}, - {0x0400, "ForeRunnerHE ATM Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_112F[] = { - {0x0000, "MVC IC-PCI", NULL}, - {0x0001, "MVC IM-PCI Video frame grabber/processor", NULL}, - {0x0008, "PC-CamLink PCI framegrabber", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1131[] = { - {0x1561, "USB 1.1 Host Controller", NULL}, - {0x1562, "USB 2.0 Host Controller", NULL}, - {0x3400, "SmartPCI56(UCB1500) 56K Modem", NULL}, - {0x5400, "TriMedia TM1000/1100", NULL}, - {0x5402, "TriMedia TM-1300", NULL}, - {0x5405, "TriMedia TM1500", NULL}, - {0x5406, "TriMedia TM1700", NULL}, - {0x7130, "SAA7130 Video Broadcast Decoder", NULL}, - {0x7133, "SAA7133/SAA7135 Video Broadcast Decoder", NULL}, - {0x7134, "SAA7134 Video Broadcast Decoder", NULL}, - {0x7145, "SAA7145", NULL}, - {0x7146, "SAA7146", NULL}, - {0x9730, "SAA9730 Integrated Multimedia and Peripheral Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1133[] = { - {0x7901, "EiconCard S90", NULL}, - {0x7902, "EiconCard S90", NULL}, - {0x7911, "EiconCard S91", NULL}, - {0x7912, "EiconCard S91", NULL}, - {0x7941, "EiconCard S94", NULL}, - {0x7942, "EiconCard S94", NULL}, - {0x7943, "EiconCard S94", NULL}, - {0x7944, "EiconCard S94", NULL}, - {0xB921, "EiconCard P92", NULL}, - {0xB922, "EiconCard P92", NULL}, - {0xB923, "EiconCard P92", NULL}, - {0xE001, "Diva Pro 2.0 S/T", NULL}, - {0xE002, "Diva 2.0 S/T PCI", NULL}, - {0xE003, "Diva Pro 2.0 U", NULL}, - {0xE004, "Diva 2.0 U PCI", NULL}, - {0xE005, "Diva 2.01 S/T PCI", NULL}, - {0xE006, "Diva CT S/T PCI", NULL}, - {0xE007, "Diva CT U PCI", NULL}, - {0xE008, "Diva CT Lite S/T PCI", NULL}, - {0xE009, "Diva CT Lite U PCI", NULL}, - {0xE00A, "Diva ISDN+V.90 PCI", NULL}, - {0xE00B, "Diva 2.02 PCI S/T", NULL}, - {0xE00C, "Diva 2.02 PCI U", NULL}, - {0xE00D, "Diva ISDN Pro 3.0 PCI", NULL}, - {0xE00E, "Diva ISDN+CT S/T PCI Rev 2", NULL}, - {0xE010, "Diva Server BRI-2M PCI", NULL}, - {0xE011, "Diva Server BRI S/T Rev 2", NULL}, - {0xE012, "Diva Server 4BRI-8M PCI", NULL}, - {0xE013, "Diva Server 4BRI Rev 2", NULL}, - {0xE014, "Diva Server PRI-30M PCI", NULL}, - {0xE015, "DIVA Server PRI Rev 2", NULL}, - {0xE016, "Diva Server Voice 4BRI PCI", NULL}, - {0xE017, "Diva Server Voice 4BRI Rev 2", NULL}, - {0xE018, "Diva Server BRI-2M 2.0 PCI", NULL}, - {0xE019, "Diva Server Voice PRI Rev 2", NULL}, - {0xE01A, "Diva Server 2FX", NULL}, - {0xE01B, "Diva Server Voice BRI-2M 2.0 PCI", NULL}, - {0xE01C, "Diva Server PRI Rev 3", NULL}, - {0xE01E, "Diva Server 2PRI", NULL}, - {0xE020, "Diva Server 4PRI", NULL}, - {0xE024, "Diva Server Analog-4P", NULL}, - {0xE028, "Diva Server Analog-8P", NULL}, - {0xE02A, "Diva Server IPM-300", NULL}, - {0xE02C, "Diva Server IPM-600", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1134[] = { - {0x0001, "Raceway Bridge", NULL}, - {0x0002, "Dual PCI to RapidIO Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1135[] = { - {0x0001, "Printer controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1138[] = { - {0x8905, "8905 [STD 32 Bridge]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1139[] = { - {0x0001, "VGA Compatable 3D Graphics", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_113C[] = { - {0x0000, "PCI-9060 i960 Bridge", NULL}, - {0x0001, "PCI-SDK [PCI i960 Evaluation Platform]", NULL}, - {0x0911, "PCI-911 [i960Jx-based Intelligent I/O Controller]", NULL}, - {0x0912, "PCI-912 [i960CF-based Intelligent I/O Controller]", NULL}, - {0x0913, "PCI-913", NULL}, - {0x0914, "PCI-914 [I/O Controller w/ secondary PCI bus]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_113F[] = { - {0x0808, "SST-64P Adapter", NULL}, - {0x1010, "SST-128P Adapter", NULL}, - {0x80C0, "SST-16P DB Adapter", NULL}, - {0x80C4, "SST-16P RJ Adapter", NULL}, - {0x80C8, "SST-16P Adapter", NULL}, - {0x8888, "SST-4P Adapter", NULL}, - {0x9090, "SST-8P Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1142[] = { - {0x3210, "AP6410", NULL}, - {0x6422, "ProVideo 6422", NULL}, - {0x6424, "ProVideo 6424", NULL}, - {0x6425, "ProMotion AT25", NULL}, - {0x643D, "ProMotion AT3D", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1144[] = { - {0x0001, "Noservo controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1145[] = { - {0x8007, "NinjaSCSI-32 Workbit", NULL}, - {0xF007, "NinjaSCSI-32 KME", NULL}, - {0xF010, "NinjaSCSI-32 Workbit", NULL}, - {0xF012, "NinjaSCSI-32 Logitec", NULL}, - {0xF013, "NinjaSCSI-32 Logitec", NULL}, - {0xF015, "NinjaSCSI-32 Melco", NULL}, - {0xF020, "NinjaSCSI-32 Sony PCGA-DVD51", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1148[] = { - {0x4000, "FDDI Adapter", NULL}, - {0x4200, "Token Ring adapter", NULL}, - {0x4300, "SK-9872 Gigabit Ethernet Server Adapter (SK-NET GE-ZX dual link)", NULL}, - {0x4320, "SysKonnect SK-9871 V2.0 Gigabit Ethernet 1000Base-ZX Adapter, PCI64, Fiber ZX/SC", NULL}, - {0x4400, "SK-9Dxx Gigabit Ethernet Adapter", NULL}, - {0x4500, "SK-9Mxx Gigabit Ethernet Adapter", NULL}, - {0x9000, "SK-9S21 10/100/1000Base-T Server Adapter, PCI-X, Copper RJ-45", NULL}, - {0x9843, "[Fujitsu] Gigabit Ethernet", NULL}, - {0x9E00, "SK-9E21D 10/100/1000Base-T Adapter, Copper RJ-45", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_114A[] = { - {0x5579, "VMIPCI-5579 (Reflective Memory Card)", NULL}, - {0x5587, "VMIPCI-5587 (Reflective Memory Card)", NULL}, - {0x6504, "VMIC PCI 7755 FPGA", NULL}, - {0x7587, "VMIVME-7587", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_114F[] = { - {0x0002, "AccelePort EPC", NULL}, - {0x0003, "RightSwitch SE-6", NULL}, - {0x0004, "AccelePort Xem", NULL}, - {0x0005, "AccelePort Xr", NULL}, - {0x0006, "AccelePort Xr,C/X", NULL}, - {0x0009, "AccelePort Xr/J", NULL}, - {0x000A, "AccelePort EPC/J", NULL}, - {0x000C, "DataFirePRIme T1 (1-port)", NULL}, - {0x000D, "SyncPort 2-Port (x.25/FR)", NULL}, - {0x0011, "AccelePort 8r EIA-232 (IBM)", NULL}, - {0x0012, "AccelePort 8r EIA-422", NULL}, - {0x0014, "AccelePort 8r EIA-422", NULL}, - {0x0015, "AccelePort Xem", NULL}, - {0x0016, "AccelePort EPC/X", NULL}, - {0x0017, "AccelePort C/X", NULL}, - {0x001A, "DataFirePRIme E1 (1-port)", NULL}, - {0x001B, "AccelePort C/X (IBM)", NULL}, - {0x001D, "DataFire RAS T1/E1/PRI", NULL}, - {0x0023, "AccelePort RAS", NULL}, - {0x0024, "DataFire RAS B4 ST/U", NULL}, - {0x0026, "AccelePort 4r 920", NULL}, - {0x0027, "AccelePort Xr 920", NULL}, - {0x0028, "ClassicBoard 4", NULL}, - {0x0029, "ClassicBoard 8", NULL}, - {0x0034, "AccelePort 2r 920", NULL}, - {0x0035, "DataFire DSP T1/E1/PRI cPCI", NULL}, - {0x0040, "AccelePort Xp", NULL}, - {0x0042, "AccelePort 2p", NULL}, - {0x0043, "AccelePort 4p", NULL}, - {0x0044, "AccelePort 8p", NULL}, - {0x0045, "AccelePort 16p", NULL}, - {0x004E, "AccelePort 32p", NULL}, - {0x0070, "Datafire Micro V IOM2 (Europe)", NULL}, - {0x0071, "Datafire Micro V (Europe)", NULL}, - {0x0072, "Datafire Micro V IOM2 (North America)", NULL}, - {0x0073, "Datafire Micro V (North America)", NULL}, - {0x00B0, "Digi Neo 4", NULL}, - {0x00B1, "Digi Neo 8", NULL}, - {0x00C8, "Digi Neo 2 DB9", NULL}, - {0x00C9, "Digi Neo 2 DB9 PRI", NULL}, - {0x00CA, "Digi Neo 2 RJ45", NULL}, - {0x00CB, "Digi Neo 2 RJ45 PRI", NULL}, - {0x00D0, "ClassicBoard 4 422", NULL}, - {0x00D1, "ClassicBoard 8 422", NULL}, - {0x6001, "Avanstar", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1158[] = { - {0x3011, "Tokenet/vg 1001/10m anylan", NULL}, - {0x9050, "Lanfleet/Truevalue", NULL}, - {0x9051, "Lanfleet/Truevalue", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1159[] = { - {0x0001, "MV-1000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_115D[] = { - {0x0003, "Cardbus Ethernet 10/100", NULL}, - {0x0005, "Cardbus Ethernet 10/100", NULL}, - {0x0007, "Cardbus Ethernet 10/100", NULL}, - {0x000B, "Cardbus Ethernet 10/100", NULL}, - {0x000C, "Mini-PCI V.90 56k Modem", NULL}, - {0x000F, "Cardbus Ethernet 10/100", NULL}, - {0x00D4, "Mini-PCI K56Flex Modem", NULL}, - {0x0101, "Cardbus 56k modem", NULL}, - {0x0103, "Cardbus Ethernet + 56k Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1163[] = { - {0x0001, "Verite 1000", NULL}, - {0x2000, "Verite V2000/V2100/V2200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1165[] = { - {0x0001, "Motion TPEG Recorder/Player with audio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1166[] = { - {0x0000, "CMIC-LE", NULL}, - {0x0005, "CNB20-LE Host Bridge", NULL}, - {0x0006, "CNB20HE Host Bridge", NULL}, - {0x0007, "CNB20-LE Host Bridge", NULL}, - {0x0008, "CNB20HE Host Bridge", NULL}, - {0x0009, "CNB20LE Host Bridge", NULL}, - {0x0010, "CIOB30", NULL}, - {0x0011, "CMIC-HE", NULL}, - {0x0012, "CMIC-WS Host Bridge (GC-LE chipset)", NULL}, - {0x0013, "CNB20-HE Host Bridge", NULL}, - {0x0014, "CMIC-LE Host Bridge (GC-LE chipset)", NULL}, - {0x0015, "CMIC-GC Host Bridge", NULL}, - {0x0016, "CMIC-GC Host Bridge", NULL}, - {0x0017, "GCNB-LE Host Bridge", NULL}, - {0x0036, "HT1000 PCI/PCI-X bridge", NULL}, - {0x0101, "CIOB-X2 PCI-X I/O Bridge", NULL}, - {0x0104, "HT1000 PCI/PCI-X bridge", NULL}, - {0x0110, "CIOB-E I/O Bridge with Gigabit Ethernet", NULL}, - {0x0130, "HT1000 PCI-X bridge", NULL}, - {0x0132, "HT1000 PCI-Express bridge", NULL}, - {0x0200, "OSB4 South Bridge", NULL}, - {0x0201, "CSB5 South Bridge", NULL}, - {0x0203, "CSB6 South Bridge", NULL}, - {0x0205, "HT1000 Legacy South Bridge", NULL}, - {0x0211, "OSB4 IDE Controller", NULL}, - {0x0212, "CSB5 IDE Controller", NULL}, - {0x0213, "CSB6 RAID/IDE Controller", NULL}, - {0x0214, "HT1000 Legacy IDE controller", NULL}, - {0x0217, "CSB6 IDE Controller", NULL}, - {0x0220, "OSB4/CSB5 OHCI USB Controller", NULL}, - {0x0221, "CSB6 OHCI USB Controller", NULL}, - {0x0223, "HT1000 USB Controller", NULL}, - {0x0225, "CSB5 LPC bridge", NULL}, - {0x0227, "GCLE-2 Host Bridge", NULL}, - {0x0230, "CSB5 LPC bridge", NULL}, - {0x0234, "HT1000 LPC Bridge", NULL}, - {0x0240, "K2 SATA", NULL}, - {0x0241, "RAIDCore RC4000", NULL}, - {0x0242, "RAIDCore BC4000", NULL}, - {0x024A, "BCM5785 (HT1000) SATA Native SATA Mode", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_116A[] = { - {0x6100, "Bus/Tag Channel", NULL}, - {0x6800, "Escon Channel", NULL}, - {0x7100, "Bus/Tag Channel", NULL}, - {0x7800, "Escon Channel", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1178[] = { - {0xAFA1, "Fast Ethernet Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1179[] = { - {0x0102, "Extended IDE Controller", NULL}, - {0x0103, "EX-IDE Type-B", NULL}, - {0x0404, "DVD Decoder card", NULL}, - {0x0406, "Tecra Video Capture device", NULL}, - {0x0407, "DVD Decoder card (Version 2)", NULL}, - {0x0601, "CPU to PCI bridge", NULL}, - {0x0603, "ToPIC95 PCI to CardBus Bridge for Notebooks", NULL}, - {0x060A, "ToPIC95", NULL}, - {0x060F, "ToPIC97", NULL}, - {0x0617, "ToPIC100 PCI to Cardbus Bridge with ZV Support", NULL}, - {0x0618, "CPU to PCI and PCI to ISA bridge", NULL}, - {0x0701, "FIR Port", NULL}, - {0x0804, "TC6371AF SmartMedia Controller", NULL}, - {0x0805, "SD TypA Controller", NULL}, - {0x0D01, "FIR Port Type-DO", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_117C[] = { - {0x0030, "Ultra320 SCSI Host Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1180[] = { - {0x0465, "RL5c465", NULL}, - {0x0466, "RL5c466", NULL}, - {0x0475, "RL5c475", NULL}, - {0x0476, "RL5c476 II", NULL}, - {0x0477, "RL5c477", NULL}, - {0x0478, "RL5c478", NULL}, - {0x0511, "R5C511", NULL}, - {0x0522, "R5C522 IEEE 1394 Controller", NULL}, - {0x0551, "R5C551 IEEE 1394 Controller", NULL}, - {0x0552, "R5C552 IEEE 1394 Controller", NULL}, - {0x0554, "R5C554", NULL}, - {0x0575, "R5C575 SD Bus Host Adapter", NULL}, - {0x0576, "R5C576 SD Bus Host Adapter", NULL}, - {0x0592, "R5C592 Memory Stick Bus Host Adapter", NULL}, - {0x0811, "R5C811", NULL}, - {0x0822, "R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter", NULL}, - {0x0841, "R5C841 CardBus/SD/SDIO/MMC/MS/MSPro/xD/IEEE1394", NULL}, - {0x0852, "xD-Picture Card Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1186[] = { - {0x0100, "DC21041", NULL}, - {0x1002, "DL10050 Sundance Ethernet", NULL}, - {0x1025, "AirPlus Xtreme G DWL-G650 Adapter", NULL}, - {0x1026, "AirXpert DWL-AG650 Wireless Cardbus Adapter", NULL}, - {0x1043, "AirXpert DWL-AG650 Wireless Cardbus Adapter", NULL}, - {0x1300, "RTL8139 Ethernet", NULL}, - {0x1340, "DFE-690TXD CardBus PC Card", NULL}, - {0x1541, "DFE-680TXD CardBus PC Card", NULL}, - {0x1561, "DRP-32TXD Cardbus PC Card", NULL}, - {0x2027, "AirPlus Xtreme G DWL-G520 Adapter", NULL}, - {0x3203, "AirPlus Xtreme G DWL-G520 Adapter", NULL}, - {0x3300, "DWL-510 2.4GHz Wireless PCI Adapter", NULL}, - {0x3A03, "AirPro DWL-A650 Wireless Cardbus Adapter(rev.B)", NULL}, - {0x3A04, "AirPro DWL-AB650 Multimode Wireless Cardbus Adapter", NULL}, - {0x3A05, "AirPro DWL-AB520 Multimode Wireless PCI Adapter", NULL}, - {0x3A07, "AirXpert DWL-AG650 Wireless Cardbus Adapter", NULL}, - {0x3A08, "AirXpert DWL-AG520 Wireless PCI Adapter", NULL}, - {0x3A10, "AirXpert DWL-AG650 Wireless Cardbus Adapter(rev.B)", NULL}, - {0x3A11, "AirXpert DWL-AG520 Wireless PCI Adapter(rev.B)", NULL}, - {0x3A12, "AirPlus DWL-G650 Wireless Cardbus Adapter(rev.C)", NULL}, - {0x3A13, "AirPlus DWL-G520 Wireless PCI Adapter(rev.B)", NULL}, - {0x3A14, "AirPremier DWL-AG530 Wireless PCI Adapter", NULL}, - {0x3A63, "AirXpert DWL-AG660 Wireless Cardbus Adapter", NULL}, - {0x4000, "DL2000-based Gigabit Ethernet", NULL}, - {0x4300, "DGE-528T Gigabit Ethernet Adapter", NULL}, - {0x4C00, "Gigabit Ethernet Adapter", NULL}, - {0x8400, "D-Link DWL-650+ CardBus PC Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_118C[] = { - {0x0014, "PCIB [C-bus II to PCI bus host bridge chip]", NULL}, - {0x1117, "Intel 8-way XEON Profusion Chipset [Cache Coherency Filter]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_118D[] = { - {0x0001, "Raptor-PCI framegrabber", NULL}, - {0x0012, "Model 12 Road Runner Frame Grabber", NULL}, - {0x0014, "Model 14 Road Runner Frame Grabber", NULL}, - {0x0024, "Model 24 Road Runner Frame Grabber", NULL}, - {0x0044, "Model 44 Road Runner Frame Grabber", NULL}, - {0x0112, "Model 12 Road Runner Frame Grabber", NULL}, - {0x0114, "Model 14 Road Runner Frame Grabber", NULL}, - {0x0124, "Model 24 Road Runner Frame Grabber", NULL}, - {0x0144, "Model 44 Road Runner Frame Grabber", NULL}, - {0x0212, "Model 12 Road Runner Frame Grabber", NULL}, - {0x0214, "Model 14 Road Runner Frame Grabber", NULL}, - {0x0224, "Model 24 Road Runner Frame Grabber", NULL}, - {0x0244, "Model 44 Road Runner Frame Grabber", NULL}, - {0x0312, "Model 12 Road Runner Frame Grabber", NULL}, - {0x0314, "Model 14 Road Runner Frame Grabber", NULL}, - {0x0324, "Model 24 Road Runner Frame Grabber", NULL}, - {0x0344, "Model 44 Road Runner Frame Grabber", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1190[] = { - {0xC731, "TP-910/920/940 PCI Ultra(Wide) SCSI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1191[] = { - {0x0003, "SCSI Cache Host Adapter", NULL}, - {0x0004, "ATP8400", NULL}, - {0x0005, "ATP850UF", NULL}, - {0x0006, "ATP860 NO-BIOS", NULL}, - {0x0007, "ATP860", NULL}, - {0x0008, "ATP865 NO-ROM", NULL}, - {0x0009, "ATP865", NULL}, - {0x8002, "AEC6710 SCSI-2 Host Adapter", NULL}, - {0x8010, "AEC6712UW SCSI", NULL}, - {0x8020, "AEC6712U SCSI", NULL}, - {0x8030, "AEC6712S SCSI", NULL}, - {0x8040, "AEC6712D SCSI", NULL}, - {0x8050, "AEC6712SUW SCSI", NULL}, - {0x8060, "AEC6712 SCSI", NULL}, - {0x8080, "AEC67160 SCSI", NULL}, - {0x8081, "AEC67160S SCSI", NULL}, - {0x808A, "AEC67162 2-ch. LVD SCSI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1193[] = { - {0x0001, "1221", NULL}, - {0x0002, "1225", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1197[] = { - {0x010C, "CompuScope 82G 8bit 2GS/s Analog Input Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_119B[] = { - {0x1221, "82C092G", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_119E[] = { - {0x0001, "FireStream 155", NULL}, - {0x0003, "FireStream 50", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11A9[] = { - {0x4240, "AMCC S933Q Intelligent Serial Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11AB[] = { - {0x0146, "GT-64010/64010A System Controller", NULL}, - {0x138F, "W8300 802.11 Adapter (rev 07)", NULL}, - {0x1FA6, "Marvell W8300 802.11 Adapter", NULL}, - {0x1FA7, "88W8310 and 88W8000G [Libertas] 802.11g client chipset", NULL}, - {0x1FAA, "88w8335 [Libertas] 802.11b/g Wireless", NULL}, - {0x4320, "88E8001 Gigabit Ethernet Controller", NULL}, - {0x4340, "88E8021 PCI-X IPMI Gigabit Ethernet Controller", NULL}, - {0x4341, "88E8022 PCI-X IPMI Gigabit Ethernet Controller", NULL}, - {0x4342, "88E8061 PCI-E IPMI Gigabit Ethernet Controller", NULL}, - {0x4343, "88E8062 PCI-E IPMI Gigabit Ethernet Controller", NULL}, - {0x4344, "88E8021 PCI-X IPMI Gigabit Ethernet Controller", NULL}, - {0x4345, "88E8022 PCI-X IPMI Gigabit Ethernet Controller", NULL}, - {0x4346, "88E8061 PCI-E IPMI Gigabit Ethernet Controller", NULL}, - {0x4347, "88E8062 PCI-E IPMI Gigabit Ethernet Controller", NULL}, - {0x4350, "88E8035 PCI-E Fast Ethernet Controller", NULL}, - {0x4351, "88E8036 PCI-E Fast Ethernet Controller", NULL}, - {0x4352, "88E8038 PCI-E Fast Ethernet Controller", NULL}, - {0x4360, "88E8052 PCI-E ASF Gigabit Ethernet Controller", NULL}, - {0x4361, "88E8050 PCI-E ASF Gigabit Ethernet Controller", NULL}, - {0x4362, "88E8053 PCI-E Gigabit Ethernet Controller", NULL}, - {0x4363, "88E8055 PCI-E Gigabit Ethernet Controller", NULL}, - {0x4611, "GT-64115 System Controller", NULL}, - {0x4620, "GT-64120/64120A/64121A System Controller", NULL}, - {0x4801, "GT-48001", NULL}, - {0x5005, "Belkin F5D5005 Gigabit Desktop Network PCI Card", NULL}, - {0x5040, "MV88SX5040 4-port SATA I PCI-X Controller", NULL}, - {0x5041, "MV88SX5041 4-port SATA I PCI-X Controller", NULL}, - {0x5080, "MV88SX5080 8-port SATA I PCI-X Controller", NULL}, - {0x5081, "MV88SX5081 8-port SATA I PCI-X Controller", NULL}, - {0x6041, "MV88SX6041 4-port SATA II PCI-X Controller", NULL}, - {0x6081, "MV88SX6081 8-port SATA II PCI-X Controller", NULL}, - {0x6460, "MV64360/64361/64362 System Controller", NULL}, - {0x6480, "MV64460/64461/64462 System Controller", NULL}, - {0xF003, "GT-64010 Primary Image Piranha Image Generator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11AD[] = { - {0x0002, "LNE100TX", NULL}, - {0xC115, "LNE100TX [Linksys EtherFast 10/100]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11AF[] = { - {0x0001, "Cinema", NULL}, - {0xEE40, "Digidesign Audiomedia III", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11B0[] = { - {0x0002, "V300PSC", NULL}, - {0x0292, "V292PBC [Am29030/40 Bridge]", NULL}, - {0x0960, "V96xPBC", NULL}, - {0xC960, "V96DPC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11B8[] = { - {0x0001, "Quad PeerMaster", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11B9[] = { - {0xC0ED, "SSA Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11BC[] = { - {0x0001, "NP-PCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11BD[] = { - {0x002E, "PCTV 40i", NULL}, - {0xBEDE, "Pinnacle AV/DV Studio Capture Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11C1[] = { - {0x0440, "56k WinModem", NULL}, - {0x0441, "56k WinModem", NULL}, - {0x0442, "56k WinModem", NULL}, - {0x0443, "LT WinModem", NULL}, - {0x0444, "LT WinModem", NULL}, - {0x0445, "LT WinModem", NULL}, - {0x0446, "LT WinModem", NULL}, - {0x0447, "LT WinModem", NULL}, - {0x0448, "WinModem 56k", NULL}, - {0x0449, "WinModem 56k", NULL}, - {0x044A, "F-1156IV WinModem (V90, 56KFlex)", NULL}, - {0x044B, "LT WinModem", NULL}, - {0x044C, "LT WinModem", NULL}, - {0x044D, "LT WinModem", NULL}, - {0x044E, "LT WinModem", NULL}, - {0x044F, "V90 WildWire Modem", NULL}, - {0x0450, "LT WinModem", NULL}, - {0x0451, "LT WinModem", NULL}, - {0x0452, "LT WinModem", NULL}, - {0x0453, "LT WinModem", NULL}, - {0x0454, "LT WinModem", NULL}, - {0x0455, "LT WinModem", NULL}, - {0x0456, "LT WinModem", NULL}, - {0x0457, "LT WinModem", NULL}, - {0x0458, "LT WinModem", NULL}, - {0x0459, "LT WinModem", NULL}, - {0x045A, "LT WinModem", NULL}, - {0x045C, "LT WinModem", NULL}, - {0x0461, "V90 WildWire Modem", NULL}, - {0x0462, "V90 WildWire Modem", NULL}, - {0x0480, "Venus Modem (V90, 56KFlex)", NULL}, - {0x048C, "V.92 56K WinModem", NULL}, - {0x048F, "V.92 56k WinModem", NULL}, - {0x5801, "USB", NULL}, - {0x5802, "USS-312 USB Controller", NULL}, - {0x5803, "USS-344S USB Controller", NULL}, - {0x5811, "FW323", NULL}, - {0x8110, "T8110 H.100/H.110 TDM switch", NULL}, - {0xAB10, "WL60010 Wireless LAN MAC", NULL}, - {0xAB11, "WL60040 Multimode Wireles LAN MAC", NULL}, - {0xAB20, "ORiNOCO PCI Adapter", NULL}, - {0xAB21, "Agere Wireless PCI Adapter", NULL}, - {0xAB30, "Hermes2 Mini-PCI WaveLAN a/b/g", NULL}, - {0xED00, "ET-131x PCI-E Ethernet Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11C8[] = { - {0x0658, "PSB32 SCI-Adapter D31x", NULL}, - {0xD665, "PSB64 SCI-Adapter D32x", NULL}, - {0xD667, "PSB66 SCI-Adapter D33x", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11C9[] = { - {0x0010, "16-line serial port w/- DMA", NULL}, - {0x0011, "4-line serial port w/- DMA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11CB[] = { - {0x2000, "PCI_9050", NULL}, - {0x4000, "SUPI_1", NULL}, - {0x8000, "T225", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11D1[] = { - {0x01F7, "VxP524", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11D4[] = { - {0x1535, "Blackfin BF535 processor", NULL}, - {0x1805, "SM56 PCI modem", NULL}, - {0x1889, "AD1889 sound chip", NULL}, - {0x5340, "AD1881 sound chip", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11D5[] = { - {0x0115, "10115", NULL}, - {0x0117, "10117", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11DE[] = { - {0x6057, "ZR36057PQC Video cutting chipset", NULL}, - {0x6120, "ZR36120", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11E3[] = { - {0x0001, "COM-ON-AIR Dosch&Amand DECT", NULL}, - {0x5030, "PC Watchdog", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11F0[] = { - {0x4231, "FDDI", NULL}, - {0x4232, "FASTline UTP Quattro", NULL}, - {0x4233, "FASTline FO", NULL}, - {0x4234, "FASTline UTP", NULL}, - {0x4235, "FASTline-II UTP", NULL}, - {0x4236, "FASTline-II FO", NULL}, - {0x4731, "GIGAline", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11F4[] = { - {0x2915, "CAMAC controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11F6[] = { - {0x0112, "ENet100VG4", NULL}, - {0x0113, "FreedomLine 100", NULL}, - {0x1401, "ReadyLink 2000", NULL}, - {0x2011, "RL100-ATX 10/100", NULL}, - {0x2201, "ReadyLink 100TX (Winbond W89C840)", NULL}, - {0x9881, "RL100TX Fast Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11F8[] = { - {0x7375, "PM7375 [LASAR-155 ATM SAR]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11FE[] = { - {0x0001, "RocketPort 32 port w/external I/F", NULL}, - {0x0002, "RocketPort 8 port w/external I/F", NULL}, - {0x0003, "RocketPort 16 port w/external I/F", NULL}, - {0x0004, "RocketPort 4 port w/quad cable", NULL}, - {0x0005, "RocketPort 8 port w/octa cable", NULL}, - {0x0006, "RocketPort 8 port w/RJ11 connectors", NULL}, - {0x0007, "RocketPort 4 port w/RJ11 connectors", NULL}, - {0x0008, "RocketPort 8 port w/ DB78 SNI (Siemens) connector", NULL}, - {0x0009, "RocketPort 16 port w/ DB78 SNI (Siemens) connector", NULL}, - {0x000A, "RocketPort Plus 4 port", NULL}, - {0x000B, "RocketPort Plus 8 port", NULL}, - {0x000C, "RocketModem 6 port", NULL}, - {0x000D, "RocketModem 4-port", NULL}, - {0x000E, "RocketPort Plus 2 port RS232", NULL}, - {0x000F, "RocketPort Plus 2 port RS422", NULL}, - {0x0801, "RocketPort UPCI 32 port w/external I/F", NULL}, - {0x0802, "RocketPort UPCI 8 port w/external I/F", NULL}, - {0x0803, "RocketPort UPCI 16 port w/external I/F", NULL}, - {0x0805, "RocketPort UPCI 8 port w/octa cable", NULL}, - {0x080C, "RocketModem III 8 port", NULL}, - {0x080D, "RocketModem III 4 port", NULL}, - {0x0812, "RocketPort UPCI Plus 8 port RS422", NULL}, - {0x0903, "RocketPort Compact PCI 16 port w/external I/F", NULL}, - {0x8015, "RocketPort 4-port UART 16954", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_11FF[] = { - {0x0003, "AG-5", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1202[] = { - {0x4300, "Gigabit Ethernet Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1208[] = { - {0x4853, "HS-Link Device", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_120E[] = { - {0x0100, "Cyclom-Y below first megabyte", NULL}, - {0x0101, "Cyclom-Y above first megabyte", NULL}, - {0x0102, "Cyclom-4Y below first megabyte", NULL}, - {0x0103, "Cyclom-4Y above first megabyte", NULL}, - {0x0104, "Cyclom-8Y below first megabyte", NULL}, - {0x0105, "Cyclom-8Y above first megabyte", NULL}, - {0x0200, "Cyclades-Z below first megabyte", NULL}, - {0x0201, "Cyclades-Z above first megabyte", NULL}, - {0x0300, "PC300/RSV or /X21 (2 ports)", NULL}, - {0x0301, "PC300/RSV or /X21 (1 port)", NULL}, - {0x0310, "PC300/TE (2 ports)", NULL}, - {0x0311, "PC300/TE (1 port)", NULL}, - {0x0320, "PC300/TE-M (2 ports)", NULL}, - {0x0321, "PC300/TE-M (1 port)", NULL}, - {0x0400, "PC400", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_120F[] = { - {0x0001, "Roadrunner serial HIPPI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1217[] = { - {0x6729, "OZ6729", NULL}, - {0x673A, "OZ6730", NULL}, - {0x6832, "OZ6832/6833 CardBus Controller", NULL}, - {0x6836, "OZ6836/6860 CardBus Controller", NULL}, - {0x6872, "OZ6812 CardBus Controller", NULL}, - {0x6925, "OZ6922 CardBus Controller", NULL}, - {0x6933, "OZ6933/711E1 CardBus/SmartCardBus Controller", NULL}, - {0x6972, "OZ601/6912/711E0 CardBus/SmartCardBus Controller", NULL}, - {0x7110, "OZ711Mx 4-in-1 MemoryCardBus Accelerator", NULL}, - {0x7112, "OZ711EC1/M1 SmartCardBus/MemoryCardBus Controller", NULL}, - {0x7113, "OZ711EC1 SmartCardBus Controller", NULL}, - {0x7114, "OZ711M1/MC1 4-in-1 MemoryCardBus Controller", NULL}, - {0x7134, "OZ711MP1/MS1 MemoryCardBus Controller", NULL}, - {0x71E2, "OZ711E2 SmartCardBus Controller", NULL}, - {0x7212, "OZ711M2 4-in-1 MemoryCardBus Controller", NULL}, - {0x7213, "OZ6933E CardBus Controller", NULL}, - {0x7223, "OZ711M3/MC3 4-in-1 MemoryCardBus Controller", NULL}, - {0x7233, "OZ711MP3/MS3 4-in-1 MemoryCardBus Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_121A[] = { - {0x0001, "Voodoo", NULL}, - {0x0002, "Voodoo 2", NULL}, - {0x0003, "Voodoo Banshee", NULL}, - {0x0004, "Voodoo Banshee [Velocity 100]", NULL}, - {0x0005, "Voodoo 3", NULL}, - {0x0009, "Voodoo 4 / Voodoo 5", NULL}, - {0x0057, "Voodoo 3/3000 [Avenger]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1220[] = { - {0x1220, "AMCC 5933 TMS320C80 DSP/Imaging board", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1223[] = { - {0x0003, "PM/Link", NULL}, - {0x0004, "PM/T1", NULL}, - {0x0005, "PM/E1", NULL}, - {0x0008, "PM/SLS", NULL}, - {0x0009, "BajaSpan Resource Target", NULL}, - {0x000A, "BajaSpan Section 0", NULL}, - {0x000B, "BajaSpan Section 1", NULL}, - {0x000C, "BajaSpan Section 2", NULL}, - {0x000D, "BajaSpan Section 3", NULL}, - {0x000E, "PM/PPC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1227[] = { - {0x0006, "Raptor GFX 8P", NULL}, - {0x0023, "Raptor GFX [1100T]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_122D[] = { - {0x1206, "368DSP", NULL}, - {0x1400, "Trident PCI288-Q3DII (NX)", NULL}, - {0x50DC, "3328 Audio", NULL}, - {0x80DA, "3328 Audio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1236[] = { - {0x0000, "RealMagic64/GX", NULL}, - {0x6401, "REALmagic 64/GX (SD 6425)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_123D[] = { - {0x0000, "EasyConnect 8/32", NULL}, - {0x0002, "EasyConnect 8/64", NULL}, - {0x0003, "EasyIO", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_123F[] = { - {0x00E4, "MPEG", NULL}, - {0x8120, "E4?", NULL}, - {0x8888, "Cinemaster C 3.0 DVD Decoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1242[] = { - {0x1560, "JNIC-1560 PCI-X Fibre Channel Controller", NULL}, - {0x4643, "FCI-1063 Fibre Channel Adapter", NULL}, - {0x6562, "FCX2-6562 Dual Channel PCI-X Fibre Channel Adapter", NULL}, - {0x656A, "FCX-6562 PCI-X Fibre Channel Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1244[] = { - {0x0700, "B1 ISDN", NULL}, - {0x0800, "C4 ISDN", NULL}, - {0x0A00, "A1 ISDN [Fritz]", NULL}, - {0x0E00, "Fritz!PCI v2.0 ISDN", NULL}, - {0x1100, "C2 ISDN", NULL}, - {0x1200, "T1 ISDN", NULL}, - {0x2700, "Fritz!Card DSL SL", NULL}, - {0x2900, "Fritz!Card DSL v2.0", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_124B[] = { - {0x0040, "PCI-40A or cPCI-200 Quad IndustryPack carrier", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_124D[] = { - {0x0000, "EasyConnection 8/32", NULL}, - {0x0002, "EasyConnection 8/64", NULL}, - {0x0003, "EasyIO", NULL}, - {0x0004, "EasyConnection/RA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_124F[] = { - {0x0041, "IFT-2000 Series RAID Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1255[] = { - {0x1110, "MPEG Forge", NULL}, - {0x1210, "MPEG Fusion", NULL}, - {0x2110, "VideoPlex", NULL}, - {0x2120, "VideoPlex CC", NULL}, - {0x2130, "VideoQuest", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1256[] = { - {0x4201, "PCI-2220I", NULL}, - {0x4401, "PCI-2240I", NULL}, - {0x5201, "PCI-2000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1259[] = { - {0x2560, "AT-2560 Fast Ethernet Adapter (i82557B)", NULL}, - {0xA117, "RTL81xx Fast Ethernet", NULL}, - {0xA120, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_125B[] = { - {0x1400, "ALFA GFC2204 Fast Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_125C[] = { - {0x0101, "Saturn 4520P", NULL}, - {0x0640, "Aries 16000P", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_125D[] = { - {0x0000, "ES336H Fax Modem (Early Model)", NULL}, - {0x1948, "Solo?", NULL}, - {0x1968, "ES1968 Maestro 2", NULL}, - {0x1969, "ES1969 Solo-1 Audiodrive", NULL}, - {0x1978, "ES1978 Maestro 2E", NULL}, - {0x1988, "ES1988 Allegro-1", NULL}, - {0x1989, "ESS Modem", NULL}, - {0x1998, "ES1983S Maestro-3i PCI Audio Accelerator", NULL}, - {0x1999, "ES1983S Maestro-3i PCI Modem Accelerator", NULL}, - {0x199A, "ES1983S Maestro-3i PCI Audio Accelerator", NULL}, - {0x199B, "ES1983S Maestro-3i PCI Modem Accelerator", NULL}, - {0x2808, "ES336H Fax Modem (Later Model)", NULL}, - {0x2838, "ES2838/2839 SuperLink Modem", NULL}, - {0x2898, "ES2898 Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1260[] = { - {0x3872, "Prism 2.5 Wavelan chipset", NULL}, - {0x3873, "Prism 2.5 Wavelan chipset", NULL}, - {0x3886, "ISL3886 [Prism Javelin/Prism Xbow]", NULL}, - {0x3890, "ISL3890 [Prism GT/Prism Duette]/ISL3886 [Prism Javelin/Prism Xbow]", NULL}, - {0x8130, "HMP8130 NTSC/PAL Video Decoder", NULL}, - {0x8131, "HMP8131 NTSC/PAL Video Decoder", NULL}, - {0xFFFF, "ISL3886IK", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1266[] = { - {0x0001, "NE10/100 Adapter (i82557B)", NULL}, - {0x1910, "NE2000Plus (RT8029) Ethernet Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1267[] = { - {0x5352, "PCR2101", NULL}, - {0x5A4B, "Telsat Turbo", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_126C[] = { - {0x1211, "10/100BaseTX [RTL81xx]", NULL}, - {0x126C, "802.11b Wireless Ethernet Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_126F[] = { - {0x0501, "SM501 VoyagerGX Rev. AA", NULL}, - {0x0510, "SM501 VoyagerGX Rev. B", NULL}, - {0x0710, "SM710 LynxEM", NULL}, - {0x0712, "SM712 LynxEM+", NULL}, - {0x0720, "SM720 Lynx3DM", NULL}, - {0x0730, "SM731 Cougar3DR", NULL}, - {0x0810, "SM810 LynxE", NULL}, - {0x0811, "SM811 LynxE", NULL}, - {0x0820, "SM820 Lynx3D", NULL}, - {0x0910, "SM910", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1273[] = { - {0x0002, "DirecPC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1274[] = { - {0x1171, "ES1373 [AudioPCI] (also Creative Labs CT5803)", NULL}, - {0x1371, "ES1371 [AudioPCI-97]", NULL}, - {0x5000, "ES1370 [AudioPCI]", NULL}, - {0x5880, "5880 AudioPCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1278[] = { - {0x0701, "TPE3/TM3 PowerPC Node", NULL}, - {0x0710, "TPE5 PowerPC PCI board", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1279[] = { - {0x0060, "TM8000 Northbridge", NULL}, - {0x0061, "TM8000 AGP bridge", NULL}, - {0x0295, "Northbridge", NULL}, - {0x0395, "LongRun Northbridge", NULL}, - {0x0396, "SDRAM controller", NULL}, - {0x0397, "BIOS scratchpad", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_127A[] = { - {0x1002, "HCF 56k Data/Fax Modem", NULL}, - {0x1003, "HCF 56k Data/Fax Modem", NULL}, - {0x1004, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1005, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1022, "HCF 56k Modem", NULL}, - {0x1023, "HCF 56k Data/Fax Modem", NULL}, - {0x1024, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1025, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1026, "HCF 56k PCI Speakerphone Modem", NULL}, - {0x1032, "HCF 56k Modem", NULL}, - {0x1033, "HCF 56k Modem", NULL}, - {0x1034, "HCF 56k Modem", NULL}, - {0x1035, "HCF 56k PCI Speakerphone Modem", NULL}, - {0x1036, "HCF 56k Modem", NULL}, - {0x1085, "HCF 56k Volcano PCI Modem", NULL}, - {0x2005, "HCF 56k Data/Fax Modem", NULL}, - {0x2013, "HSF 56k Data/Fax Modem", NULL}, - {0x2014, "HSF 56k Data/Fax/Voice Modem", NULL}, - {0x2015, "HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x2016, "HSF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x4311, "Riptide HSF 56k PCI Modem", NULL}, - {0x4320, "Riptide PCI Audio Controller", NULL}, - {0x4321, "Riptide HCF 56k PCI Modem", NULL}, - {0x4322, "Riptide PCI Game Controller", NULL}, - {0x8234, "RapidFire 616X ATM155 Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1282[] = { - {0x9009, "Ethernet 100/10 MBit", NULL}, - {0x9100, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x9102, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x9132, "Ethernet 100/10 MBit", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1283[] = { - {0x673A, "IT8330G", NULL}, - {0x8211, "ITE 8211F Single Channel UDMA 133 (ASUS 8211 (ITE IT8212 ATA RAID Controller))", NULL}, - {0x8212, "IT/ITE8212 Dual channel ATA RAID controller (PCI version seems to be IT8212, embedded seems to be ITE8212)", NULL}, - {0x8330, "IT8330G", NULL}, - {0x8872, "IT8874F PCI Dual Serial Port Controller", NULL}, - {0x8888, "IT8888F PCI to ISA Bridge with SMB", NULL}, - {0x8889, "IT8889F PCI to ISA Bridge", NULL}, - {0xE886, "IT8330G", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1285[] = { - {0x0100, "AGOGO sound chip (aka ESS Maestro 1)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1287[] = { - {0x001E, "LS220D DVD Decoder", NULL}, - {0x001F, "LS220C DVD Decoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_128D[] = { - {0x0021, "ATM155 Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_128E[] = { - {0x0008, "ST128 WSS/SB", NULL}, - {0x0009, "ST128 SAM9407", NULL}, - {0x000A, "ST128 Game Port", NULL}, - {0x000B, "ST128 MPU Port", NULL}, - {0x000C, "ST128 Ctrl Port", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_129A[] = { - {0x0615, "PBT-615 PCI-X Bus Analyzer", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12A3[] = { - {0x8105, "T8105 H100 Digital Switch", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12AB[] = { - {0x0002, "AU8830 [Vortex2] Based Sound Card With A3D Support", NULL}, - {0x3000, "MPG-200C PCI DVD Decoder Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12AE[] = { - {0x0001, "AceNIC Gigabit Ethernet", NULL}, - {0x0002, "AceNIC Gigabit Ethernet (Copper)", NULL}, - {0x00FA, "Farallon PN9100-T Gigabit Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12B9[] = { - {0x1006, "WinModem", NULL}, - {0x1007, "USR 56k Internal WinModem", NULL}, - {0x1008, "56K FaxModem Model 5610", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12BE[] = { - {0x3041, "AN3041Q CO-MEM", NULL}, - {0x3042, "AN3042Q CO-MEM Lite", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12C3[] = { - {0x0058, "PCI NE2K Ethernet", NULL}, - {0x5598, "PCI NE2K Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12C4[] = { - {0x0001, "Blue HEAT/PCI 8 (RS232/CL/RJ11)", NULL}, - {0x0002, "Blue HEAT/PCI 4 (RS232)", NULL}, - {0x0003, "Blue HEAT/PCI 2 (RS232)", NULL}, - {0x0004, "Blue HEAT/PCI 8 (UNIV, RS485)", NULL}, - {0x0005, "Blue HEAT/PCI 4+4/6+2 (UNIV, RS232/485)", NULL}, - {0x0006, "Blue HEAT/PCI 4 (OPTO, RS485)", NULL}, - {0x0007, "Blue HEAT/PCI 2+2 (RS232/485)", NULL}, - {0x0008, "Blue HEAT/PCI 2 (OPTO, Tx, RS485)", NULL}, - {0x0009, "Blue HEAT/PCI 2+6 (RS232/485)", NULL}, - {0x000A, "Blue HEAT/PCI 8 (Tx, RS485)", NULL}, - {0x000B, "Blue HEAT/PCI 4 (Tx, RS485)", NULL}, - {0x000C, "Blue HEAT/PCI 2 (20 MHz, RS485)", NULL}, - {0x000D, "Blue HEAT/PCI 2 PTM", NULL}, - {0x0100, "NT960/PCI", NULL}, - {0x0201, "cPCI Titan - 2 Port", NULL}, - {0x0202, "cPCI Titan - 4 Port", NULL}, - {0x0300, "CTI PCI UART 2 (RS232)", NULL}, - {0x0301, "CTI PCI UART 4 (RS232)", NULL}, - {0x0302, "CTI PCI UART 8 (RS232)", NULL}, - {0x0310, "CTI PCI UART 1+1 (RS232/485)", NULL}, - {0x0311, "CTI PCI UART 2+2 (RS232/485)", NULL}, - {0x0312, "CTI PCI UART 4+4 (RS232/485)", NULL}, - {0x0320, "CTI PCI UART 2", NULL}, - {0x0321, "CTI PCI UART 4", NULL}, - {0x0322, "CTI PCI UART 8", NULL}, - {0x0330, "CTI PCI UART 2 (RS485)", NULL}, - {0x0331, "CTI PCI UART 4 (RS485)", NULL}, - {0x0332, "CTI PCI UART 8 (RS485)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12C5[] = { - {0x007E, "Imaging/Scanning Subsystem Engine", NULL}, - {0x007F, "Imaging/Scanning Subsystem Engine", NULL}, - {0x0081, "PCIVST [Grayscale Thresholding Engine]", NULL}, - {0x0085, "Video Simulator/Sender", NULL}, - {0x0086, "THR2 Multi-scale Thresholder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12D2[] = { - {0x0008, "NV1", NULL}, - {0x0009, "DAC64", NULL}, - {0x0018, "Riva128", NULL}, - {0x0019, "Riva128ZX", NULL}, - {0x0020, "TNT", NULL}, - {0x0028, "TNT2", NULL}, - {0x0029, "UTNT2", NULL}, - {0x002C, "VTNT2", NULL}, - {0x00A0, "ITNT2", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12D4[] = { - {0x0200, "T1 Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12D5[] = { - {0x0003, "BSP16", NULL}, - {0x1000, "BSP15", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12D8[] = { - {0x8150, "PCI to PCI Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12D9[] = { - {0x0002, "PCI Prosody", NULL}, - {0x0004, "cPCI Prosody", NULL}, - {0x0005, "Aculab E1/T1 PCI card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12DE[] = { - {0x0200, "CryptoSwift CS200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12E0[] = { - {0x0010, "ST16C654 Quad UART", NULL}, - {0x0020, "ST16C654 Quad UART", NULL}, - {0x0030, "ST16C654 Quad UART", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12EB[] = { - {0x0001, "Vortex 1", NULL}, - {0x0002, "Vortex 2", NULL}, - {0x0003, "AU8810 Vortex Digital Audio Processor", NULL}, - {0x8803, "Vortex 56k Software Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12F8[] = { - {0x0002, "VideoMaker", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_12FB[] = { - {0x0001, "PMC-MAI", NULL}, - {0x00F5, "F5 Dakar", NULL}, - {0x02AD, "PMC-2MAI", NULL}, - {0x2ADC, "ePMC-2ADC", NULL}, - {0x3100, "PRO-3100", NULL}, - {0x3500, "PRO-3500", NULL}, - {0x4D4F, "Modena", NULL}, - {0x8120, "ePMC-8120", NULL}, - {0xDA62, "Daytona C6201 PCI (Hurricane)", NULL}, - {0xDB62, "Ingliston XBIF", NULL}, - {0xDC62, "Ingliston PLX9054", NULL}, - {0xDD62, "Ingliston JTAG/ISP", NULL}, - {0xEDDC, "ePMC-MSDDC", NULL}, - {0xFA01, "ePMC-FPGA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1307[] = { - {0x0001, "PCI-DAS1602/16", NULL}, - {0x000B, "PCI-DIO48H", NULL}, - {0x000C, "PCI-PDISO8", NULL}, - {0x000D, "PCI-PDISO16", NULL}, - {0x000F, "PCI-DAS1200", NULL}, - {0x0010, "PCI-DAS1602/12", NULL}, - {0x0014, "PCI-DIO24H", NULL}, - {0x0015, "PCI-DIO24H/CTR3", NULL}, - {0x0016, "PCI-DIO48H/CTR15", NULL}, - {0x0017, "PCI-DIO96H", NULL}, - {0x0018, "PCI-CTR05", NULL}, - {0x0019, "PCI-DAS1200/JR", NULL}, - {0x001A, "PCI-DAS1001", NULL}, - {0x001B, "PCI-DAS1002", NULL}, - {0x001C, "PCI-DAS1602JR/16", NULL}, - {0x001D, "PCI-DAS6402/16", NULL}, - {0x001E, "PCI-DAS6402/12", NULL}, - {0x001F, "PCI-DAS16/M1", NULL}, - {0x0020, "PCI-DDA02/12", NULL}, - {0x0021, "PCI-DDA04/12", NULL}, - {0x0022, "PCI-DDA08/12", NULL}, - {0x0023, "PCI-DDA02/16", NULL}, - {0x0024, "PCI-DDA04/16", NULL}, - {0x0025, "PCI-DDA08/16", NULL}, - {0x0026, "PCI-DAC04/12-HS", NULL}, - {0x0027, "PCI-DAC04/16-HS", NULL}, - {0x0028, "PCI-DIO24", NULL}, - {0x0029, "PCI-DAS08", NULL}, - {0x002C, "PCI-INT32", NULL}, - {0x0033, "PCI-DUAL-AC5", NULL}, - {0x0034, "PCI-DAS-TC", NULL}, - {0x0035, "PCI-DAS64/M1/16", NULL}, - {0x0036, "PCI-DAS64/M2/16", NULL}, - {0x0037, "PCI-DAS64/M3/16", NULL}, - {0x004C, "PCI-DAS1000", NULL}, - {0x004D, "PCI-QUAD04", NULL}, - {0x0052, "PCI-DAS4020/12", NULL}, - {0x0054, "PCI-DIO96", NULL}, - {0x005E, "PCI-DAS6025", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1308[] = { - {0x0001, "NetCelerator Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1317[] = { - {0x0981, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x0985, "NC100 Network Everywhere Fast Ethernet 10/100", NULL}, - {0x1985, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x2850, "HSP MicroModem 56", NULL}, - {0x5120, "ADMtek ADM5120 OpenGate System-on-Chip", NULL}, - {0x8201, "ADMtek ADM8211 802.11b Wireless Interface", NULL}, - {0x8211, "ADMtek ADM8211 802.11b Wireless Interface", NULL}, - {0x9511, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1318[] = { - {0x0911, "GNIC-II PCI Gigabit Ethernet [Hamachi]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1319[] = { - {0x0801, "Xwave QS3000A [FM801]", NULL}, - {0x0802, "Xwave QS3000A [FM801 game port]", NULL}, - {0x1000, "FM801 PCI Audio", NULL}, - {0x1001, "FM801 PCI Joystick", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_131F[] = { - {0x1000, "CyberSerial (1-port) 16550", NULL}, - {0x1001, "CyberSerial (1-port) 16650", NULL}, - {0x1002, "CyberSerial (1-port) 16850", NULL}, - {0x1010, "Duet 1S(16550)+1P", NULL}, - {0x1011, "Duet 1S(16650)+1P", NULL}, - {0x1012, "Duet 1S(16850)+1P", NULL}, - {0x1020, "CyberParallel (1-port)", NULL}, - {0x1021, "CyberParallel (2-port)", NULL}, - {0x1030, "CyberSerial (2-port) 16550", NULL}, - {0x1031, "CyberSerial (2-port) 16650", NULL}, - {0x1032, "CyberSerial (2-port) 16850", NULL}, - {0x1034, "Trio 2S(16550)+1P", NULL}, - {0x1035, "Trio 2S(16650)+1P", NULL}, - {0x1036, "Trio 2S(16850)+1P", NULL}, - {0x1050, "CyberSerial (4-port) 16550", NULL}, - {0x1051, "CyberSerial (4-port) 16650", NULL}, - {0x1052, "CyberSerial (4-port) 16850", NULL}, - {0x2000, "CyberSerial (1-port) 16550", NULL}, - {0x2001, "CyberSerial (1-port) 16650", NULL}, - {0x2002, "CyberSerial (1-port) 16850", NULL}, - {0x2010, "Duet 1S(16550)+1P", NULL}, - {0x2011, "Duet 1S(16650)+1P", NULL}, - {0x2012, "Duet 1S(16850)+1P", NULL}, - {0x2020, "CyberParallel (1-port)", NULL}, - {0x2021, "CyberParallel (2-port)", NULL}, - {0x2030, "CyberSerial (2-port) 16550", NULL}, - {0x2031, "CyberSerial (2-port) 16650", NULL}, - {0x2032, "CyberSerial (2-port) 16850", NULL}, - {0x2040, "Trio 1S(16550)+2P", NULL}, - {0x2041, "Trio 1S(16650)+2P", NULL}, - {0x2042, "Trio 1S(16850)+2P", NULL}, - {0x2050, "CyberSerial (4-port) 16550", NULL}, - {0x2051, "CyberSerial (4-port) 16650", NULL}, - {0x2052, "CyberSerial (4-port) 16850", NULL}, - {0x2060, "Trio 2S(16550)+1P", NULL}, - {0x2061, "Trio 2S(16650)+1P", NULL}, - {0x2062, "Trio 2S(16850)+1P", NULL}, - {0x2081, "CyberSerial (8-port) ST16654", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1331[] = { - {0x0030, "ENP-2611", NULL}, - {0x8200, "82600 Host Bridge", NULL}, - {0x8201, "82600 IDE", NULL}, - {0x8202, "82600 USB", NULL}, - {0x8210, "82600 PCI Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1332[] = { - {0x5415, "MM-5415CN PCI Memory Module with Battery Backup", NULL}, - {0x5425, "MM-5425CN PCI 64/66 Memory Module with Battery Backup", NULL}, - {0x6140, "MM-6140D", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_134A[] = { - {0x0001, "Domex 536", NULL}, - {0x0002, "Domex DMX3194UP SCSI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_134D[] = { - {0x2189, "HSP56 MicroModem", NULL}, - {0x2486, "2304WT V.92 MDC Modem", NULL}, - {0x7890, "HSP MicroModem 56", NULL}, - {0x7891, "HSP MicroModem 56", NULL}, - {0x7892, "HSP MicroModem 56", NULL}, - {0x7893, "HSP MicroModem 56", NULL}, - {0x7894, "HSP MicroModem 56", NULL}, - {0x7895, "HSP MicroModem 56", NULL}, - {0x7896, "HSP MicroModem 56", NULL}, - {0x7897, "HSP MicroModem 56", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1353[] = { - {0x0002, "Proserver", NULL}, - {0x0003, "PCI-FUT", NULL}, - {0x0004, "PCI-S0", NULL}, - {0x0005, "PCI-FUT-S0", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_135C[] = { - {0x0010, "QSC-100", NULL}, - {0x0020, "DSC-100", NULL}, - {0x0030, "DSC-200/300", NULL}, - {0x0040, "QSC-200/300", NULL}, - {0x0050, "ESC-100D", NULL}, - {0x0060, "ESC-100M", NULL}, - {0x00F0, "MPAC-100 Syncronous Serial Card (Zilog 85230)", NULL}, - {0x0170, "QSCLP-100", NULL}, - {0x0180, "DSCLP-100", NULL}, - {0x0190, "SSCLP-100", NULL}, - {0x01A0, "QSCLP-200/300", NULL}, - {0x01B0, "DSCLP-200/300", NULL}, - {0x01C0, "SSCLP-200/300", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_135E[] = { - {0x5101, "Route 56.PCI - Multi-Protocol Serial Interface (Zilog Z16C32)", NULL}, - {0x7101, "Single Port RS-232/422/485/530", NULL}, - {0x7201, "Dual Port RS-232/422/485 Interface", NULL}, - {0x7202, "Dual Port RS-232 Interface", NULL}, - {0x7401, "Four Port RS-232 Interface", NULL}, - {0x7402, "Four Port RS-422/485 Interface", NULL}, - {0x7801, "Eight Port RS-232 Interface", NULL}, - {0x8001, "8001 Digital I/O Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1360[] = { - {0x0101, "PCI32 DCF77 Radio Clock", NULL}, - {0x0102, "PCI509 DCF77 Radio Clock", NULL}, - {0x0103, "PCI510 DCF77 Radio Clock", NULL}, - {0x0201, "GPS167PCI GPS Receiver", NULL}, - {0x0202, "GPS168PCI GPS Receiver", NULL}, - {0x0203, "GPS169PCI GPS Receiver", NULL}, - {0x0301, "TCR510PCI IRIG Timecode Reader", NULL}, - {0x0302, "TCR167PCI IRIG Timecode Reader", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_136B[] = { - {0xFF01, "KL5A72002 Motion JPEG", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1371[] = { - {0x434E, "GigaCard Network Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1374[] = { - {0x0024, "Silicom Dual port Giga Ethernet BGE Bypass Server Adapter", NULL}, - {0x0025, "Silicom Quad port Giga Ethernet BGE Bypass Server Adapter", NULL}, - {0x0026, "Silicom Dual port Fiber Giga Ethernet 546 Bypass Server Adapter", NULL}, - {0x0027, "Silicom Dual port Fiber LX Giga Ethernet 546 Bypass Server Adapter", NULL}, - {0x0029, "Silicom Dual port Copper Giga Ethernet 546GB Bypass Server Adapter", NULL}, - {0x002A, "Silicom Dual port Fiber Giga Ethernet 546 TAP/Bypass Server Adapter", NULL}, - {0x002B, "Silicom Dual port Copper Fast Ethernet 546 TAP/Bypass Server Adapter", NULL}, - {0x002C, "Silicom Quad port Copper Giga Ethernet 546GB Bypass Server Adapter", NULL}, - {0x002D, "Silicom Quad port Fiber-SX Giga Ethernet 546GB Bypass Server Adapter", NULL}, - {0x002E, "Silicom Quad port Fiber-LX Giga Ethernet 546GB Bypass Server Adapter", NULL}, - {0x002F, "Silicom Dual port Fiber-SX Giga Ethernet 546GB Low profile Bypass Server Adapter", NULL}, - {0x0030, "Silicom Dual port Fiber-LX Giga Ethernet 546GB Low profile Bypass Server Adapter", NULL}, - {0x0031, "Silicom Quad port Copper Giga Ethernet PCI-E Bypass Server Adapter", NULL}, - {0x0032, "Silicom Dual port Copper Fast Ethernet 546 TAP/Bypass Server Adapter", NULL}, - {0x0034, "Silicom Dual port Copper Giga Ethernet PCI-E BGE Bypass Server Adapter", NULL}, - {0x0035, "Silicom Quad port Copper Giga Ethernet PCI-E BGE Bypass Server Adapter", NULL}, - {0x0036, "Silicom Dual port Fiber Giga Ethernet PCI-E BGE Bypass Server Adapter", NULL}, - {0x0037, "Silicom Quad port Copper Ethernet PCI-E Intel based Bypass Server Adapter", NULL}, - {0x0038, "Silicom Quad port Copper Ethernet PCI-E Intel based Bypass Server Adapter", NULL}, - {0x0039, "Silicom Dual port Fiber-SX Ethernet PCI-E Intel based Bypass Server Adapter", NULL}, - {0x003A, "Silicom Dual port Fiber-LX Ethernet PCI-E Intel based Bypass Server Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_137A[] = { - {0x0001, "PCI-324 Audiowire Interface", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1382[] = { - {0x0001, "ARC88 audio recording card", NULL}, - {0x2008, "Prodif 96 Pro sound system", NULL}, - {0x2088, "Marc 8 Midi sound system", NULL}, - {0x20C8, "Marc A sound system", NULL}, - {0x4008, "Marc 2 sound system", NULL}, - {0x4010, "Marc 2 Pro sound system", NULL}, - {0x4048, "Marc 4 MIDI sound system", NULL}, - {0x4088, "Marc 4 Digi sound system", NULL}, - {0x4248, "Marc X sound system", NULL}, - {0x4424, "TRACE D4 Sound System", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1385[] = { - {0x0013, "WG311T 108 Mbps Wireless PCI Adapter", NULL}, - {0x311A, "GA511 Gigabit Ethernet", NULL}, - {0x4100, "802.11b Wireless Adapter (MA301)", NULL}, - {0x4105, "MA311 802.11b wireless adapter", NULL}, - {0x4400, "WAG511 802.11a/b/g Dual Band Wireless PC Card", NULL}, - {0x4600, "WAG511 802.11a/b/g Dual Band Wireless PC Card", NULL}, - {0x4601, "WAG511 802.11a/b/g Dual Band Wireless PC Card", NULL}, - {0x4610, "WAG511 802.11a/b/g Dual Band Wireless PC Card", NULL}, - {0x4800, "WG511(v1) 54 Mbps Wireless PC Card", NULL}, - {0x4900, "WG311v1 54 Mbps Wireless PCI Adapter", NULL}, - {0x4A00, "WAG311 802.11a/g Wireless PCI Adapter", NULL}, - {0x4B00, "WG511T 108 Mbps Wireless PC Card", NULL}, - {0x4C00, "WG311v2 54 Mbps Wireless PCI Adapter", NULL}, - {0x4D00, "WG311T 108 Mbps Wireless PCI Adapter", NULL}, - {0x4E00, "WG511v2 54 Mbps Wireless PC Card", NULL}, - {0x4F00, "WG511U Double 108 Mbps Wireless PC Card", NULL}, - {0x5200, "GA511 Gigabit PC Card", NULL}, - {0x620A, "GA620 Gigabit Ethernet", NULL}, - {0x622A, "GA622", NULL}, - {0x630A, "GA630 Gigabit Ethernet", NULL}, - {0x6B00, "WG311v3 54 Mbps Wireless PCI Adapter", NULL}, - {0x6D00, "WPNT511 RangeMax™ 240 Mbps Wireless PC Card", NULL}, - {0xF004, "FA310TX", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1389[] = { - {0x0001, "PCI1500PFB [Intelligent fieldbus adaptor]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1393[] = { - {0x1040, "Smartio C104H/PCI", NULL}, - {0x1141, "Industrio CP-114", NULL}, - {0x1680, "Smartio C168H/PCI", NULL}, - {0x2040, "Intellio CP-204J", NULL}, - {0x2180, "Intellio C218 Turbo PCI", NULL}, - {0x3200, "Intellio C320 Turbo PCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1394[] = { - {0x0001, "LXT1001 Gigabit Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1397[] = { - {0x08B4, "ISDN network Controller [HFC-4S]", NULL}, - {0x16B8, "ISDN network Controller [HFC-8S]", NULL}, - {0x2BD0, "ISDN network controller [HFC-PCI]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_139A[] = { - {0x0001, "Quad Port 10/100 Server Accelerator", NULL}, - {0x0003, "Single Port 10/100 Server Accelerator", NULL}, - {0x0005, "Single Port Gigabit Server Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13A3[] = { - {0x0005, "7751 Security Processor", NULL}, - {0x0006, "6500 Public Key Processor", NULL}, - {0x0007, "7811 Security Processor", NULL}, - {0x0012, "7951 Security Processor", NULL}, - {0x0014, "78XX Security Processor", NULL}, - {0x0016, "8065 Security Processor", NULL}, - {0x0017, "8165 Security Processor", NULL}, - {0x0018, "8154 Security Processor", NULL}, - {0x001D, "7956 Security Processor", NULL}, - {0x0020, "7955 Security Processor", NULL}, - {0x0026, "8155 Security Processor", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13A8[] = { - {0x0152, "XR17C/D152 Dual PCI UART", NULL}, - {0x0154, "XR17C154 Quad UART", NULL}, - {0x0158, "XR17C158 Octal UART", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13C0[] = { - {0x0010, "SyncLink Adapter v1", NULL}, - {0x0020, "SyncLink SCC Adapter", NULL}, - {0x0030, "SyncLink Multiport Adapter", NULL}, - {0x0210, "SyncLink Adapter v2", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13C1[] = { - {0x1000, "5xxx/6xxx-series PATA-RAID", NULL}, - {0x1001, "7xxx/8xxx-series PATA/SATA-RAID", NULL}, - {0x1002, "9xxx-series SATA-RAID", NULL}, - {0x1003, "9550SX SATA-RAID", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13C6[] = { - {0x0520, "CEI-520 A429 Card", NULL}, - {0x0620, "CEI-620 A429 Card", NULL}, - {0x0820, "CEI-820 A429 Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13D0[] = { - {0x2103, "B2C2 FlexCopII DVB chip / Technisat SkyStar2 DVB card", NULL}, - {0x2200, "B2C2 FlexCopIII DVB chip / Technisat SkyStar2 DVB card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13D1[] = { - {0xAB02, "ADMtek Centaur-C rev 17 [D-Link DFE-680TX] CardBus Fast Ethernet Adapter", NULL}, - {0xAB03, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0xAB06, "RTL8139 [FE2000VX] CardBus Fast Ethernet Attached Port Adapter", NULL}, - {0xAB08, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13DF[] = { - {0x0001, "PCI56RVP Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13F0[] = { - {0x0200, "IC Plus IP100A Integrated 10/100 Ethernet MAC + PHY", NULL}, - {0x0201, "ST201 Sundance Ethernet", NULL}, - {0x1023, "IC Plus IP1000 Family Gigabit Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13F4[] = { - {0x1401, "Zentai Fibre Channel Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13F6[] = { - {0x0011, "CMI8738", NULL}, - {0x0100, "CM8338A", NULL}, - {0x0101, "CM8338B", NULL}, - {0x0111, "CM8738", NULL}, - {0x0211, "CM8738", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_13FE[] = { - {0x1240, "PCI-1240 4-channel stepper motor controller card", NULL}, - {0x1600, "PCI-1612 4-port RS-232/422/485 PCI communication card", NULL}, - {0x1733, "PCI-1733 32-channel isolated digital input card", NULL}, - {0x1752, "PCI-1752", NULL}, - {0x1754, "PCI-1754", NULL}, - {0x1756, "PCI-1756", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1400[] = { - {0x1401, "9432 TX", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1407[] = { - {0x0100, "Lava Dual Serial", NULL}, - {0x0101, "Lava Quatro A", NULL}, - {0x0102, "Lava Quatro B", NULL}, - {0x0110, "Lava DSerial-PCI Port A", NULL}, - {0x0111, "Lava DSerial-PCI Port B", NULL}, - {0x0120, "Quattro-PCI A", NULL}, - {0x0121, "Quattro-PCI B", NULL}, - {0x0180, "Lava Octo A", NULL}, - {0x0181, "Lava Octo B", NULL}, - {0x0200, "Lava Port Plus", NULL}, - {0x0201, "Lava Quad A", NULL}, - {0x0202, "Lava Quad B", NULL}, - {0x0220, "Lava Quattro PCI Ports A/B", NULL}, - {0x0221, "Lava Quattro PCI Ports C/D", NULL}, - {0x0500, "Lava Single Serial", NULL}, - {0x0600, "Lava Port 650", NULL}, - {0x8000, "Lava Parallel", NULL}, - {0x8001, "Dual parallel port controller A", NULL}, - {0x8002, "Lava Dual Parallel port A", NULL}, - {0x8003, "Lava Dual Parallel port B", NULL}, - {0x8800, "BOCA Research IOPPAR", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1409[] = { - {0x7168, "PCI2S550 (Dual 16550 UART)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1412[] = { - {0x1712, "ICE1712 [Envy24] PCI Multi-Channel I/O Controller", NULL}, - {0x1724, "VT1720/24 [Envy24PT/HT] PCI Multi-Channel Audio Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1415[] = { - {0x8403, "VScom 011H-EP1 1 port parallel adaptor", NULL}, - {0x9501, "OX16PCI954 (Quad 16950 UART) function 0", NULL}, - {0x950A, "EXSYS EX-41092 Dual 16950 Serial adapter", NULL}, - {0x950B, "OXCB950 Cardbus 16950 UART", NULL}, - {0x9510, "OX16PCI954 (Quad 16950 UART) function 1 (Disabled)", NULL}, - {0x9511, "OX16PCI954 (Quad 16950 UART) function 1", NULL}, - {0x9521, "OX16PCI952 (Dual 16950 UART)", NULL}, - {0x9523, "OX16PCI952 Integrated Parallel Port", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1420[] = { - {0x8002, "Gold Card NetGlobal 56k+10/100Mb CardBus (Ethernet part)", NULL}, - {0x8003, "Gold Card NetGlobal 56k+10/100Mb CardBus (Modem part)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1425[] = { - {0x000B, "T210 Protocol Engine", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_142E[] = { - {0x4020, "VM2-2 [Video Maker 2] MPEG1/2 Encoder", NULL}, - {0x4337, "VM2-2-C7 [Video Maker 2 rev. C7] MPEG1/2 Encoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1432[] = { - {0x9130, "RTL81xx Fast Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_144A[] = { - {0x7296, "PCI-7296", NULL}, - {0x7432, "PCI-7432", NULL}, - {0x7433, "PCI-7433", NULL}, - {0x7434, "PCI-7434", NULL}, - {0x7841, "PCI-7841", NULL}, - {0x8133, "PCI-8133", NULL}, - {0x8164, "PCI-8164", NULL}, - {0x8554, "PCI-8554", NULL}, - {0x9111, "PCI-9111", NULL}, - {0x9113, "PCI-9113", NULL}, - {0x9114, "PCI-9114", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1458[] = { - {0x0C11, "K8NS Pro Mainboard", NULL}, - {0xE911, "GN-WIAG02", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_145F[] = { - {0x0001, "NextMove PCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1461[] = { - {0xF436, "AVerTV Hybrid+FM", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1462[] = { - {0x5501, "nVidia NV15DDR [GeForce2 Ti]", NULL}, - {0x6819, "Broadcom Corporation BCM4306 802.11b/g Wireless LAN Controller [MSI CB54G]", NULL}, - {0x6825, "PCI Card wireless 11g [PC54G]", NULL}, - {0x6834, "RaLink RT2500 802.11g [PC54G2]", NULL}, - {0x8725, "NVIDIA NV25 [GeForce4 Ti 4600] VGA Adapter", NULL}, - {0x9000, "NVIDIA NV28 [GeForce4 Ti 4800] VGA Adapter", NULL}, - {0x9110, "GeFORCE FX5200", NULL}, - {0x9119, "NVIDIA NV31 [GeForce FX 5600XT] VGA Adapter", NULL}, - {0x9591, "nVidia Corporation NV36 [GeForce FX 5700LE]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_146C[] = { - {0x1430, "FE-1430TX Fast Ethernet PCI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_148D[] = { - {0x1003, "HCF 56k Data/Fax Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1497[] = { - {0x1497, "SMA Technologie AG", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1498[] = { - {0x0330, "TPMC816 2 Channel CAN bus controller.", NULL}, - {0x0385, "TPMC901 Extended CAN bus with 2/4/6 CAN controller", NULL}, - {0x21CD, "TCP461 CompactPCI 8 Channel Serial Interface RS232/RS422", NULL}, - {0x30C8, "TPCI200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_149D[] = { - {0x0001, "Video Toaster for PC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14AF[] = { - {0x7102, "3D Prophet II MX", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14B3[] = { - {0x0000, "DSL NIC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14B5[] = { - {0x0200, "Scope", NULL}, - {0x0300, "Pulsar", NULL}, - {0x0400, "PulsarSRB", NULL}, - {0x0600, "Pulsar2", NULL}, - {0x0800, "DSP-Board", NULL}, - {0x0900, "DSP-Board", NULL}, - {0x0A00, "DSP-Board", NULL}, - {0x0B00, "DSP-Board", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14B7[] = { - {0x0001, "Symphony 4110", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14B9[] = { - {0x0001, "PC4800", NULL}, - {0x0340, "PC4800", NULL}, - {0x0350, "PC4800", NULL}, - {0x4500, "PC4500", NULL}, - {0x4800, "Cisco Aironet 340 802.11b Wireless LAN Adapter/Aironet PC4800", NULL}, - {0xA504, "Cisco Aironet Wireless 802.11b", NULL}, - {0xA505, "Cisco Aironet CB20a 802.11a Wireless LAN Adapter", NULL}, - {0xA506, "Cisco Aironet Mini PCI b/g", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14C1[] = { - {0x8043, "Myrinet 2000 Scalable Cluster Interconnect", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14D2[] = { - {0x8001, "VScom 010L 1 port parallel adaptor", NULL}, - {0x8002, "VScom 020L 2 port parallel adaptor", NULL}, - {0x8010, "VScom 100L 1 port serial adaptor", NULL}, - {0x8011, "VScom 110L 1 port serial and 1 port parallel adaptor", NULL}, - {0x8020, "VScom 200L 1 port serial adaptor", NULL}, - {0x8021, "VScom 210L 2 port serial and 1 port parallel adaptor", NULL}, - {0x8040, "VScom 400L 4 port serial adaptor", NULL}, - {0x8080, "VScom 800L 8 port serial adaptor", NULL}, - {0xA000, "VScom 010H 1 port parallel adaptor", NULL}, - {0xA001, "VScom 100H 1 port serial adaptor", NULL}, - {0xA003, "VScom 400H 4 port serial adaptor", NULL}, - {0xA004, "VScom 400HF1 4 port serial adaptor", NULL}, - {0xA005, "VScom 200H 2 port serial adaptor", NULL}, - {0xE001, "VScom 010HV2 1 port parallel adaptor", NULL}, - {0xE010, "VScom 100HV2 1 port serial adaptor", NULL}, - {0xE020, "VScom 200HV2 2 port serial adaptor", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14D9[] = { - {0x0010, "AP1011/SP1011 HyperTransport-PCI Bridge [Sturgeon]", NULL}, - {0x9000, "AS90L10204/10208 HyperTransport to PCI-X Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14DB[] = { - {0x2120, "TK9902", NULL}, - {0x2182, "AFAVLAB Technology Inc. 8-port serial card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14DC[] = { - {0x0000, "PCI230", NULL}, - {0x0001, "PCI242", NULL}, - {0x0002, "PCI244", NULL}, - {0x0003, "PCI247", NULL}, - {0x0004, "PCI248", NULL}, - {0x0005, "PCI249", NULL}, - {0x0006, "PCI260", NULL}, - {0x0007, "PCI224", NULL}, - {0x0008, "PCI234", NULL}, - {0x0009, "PCI236", NULL}, - {0x000A, "PCI272", NULL}, - {0x000B, "PCI215", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14E4[] = { - {0x0800, "Sentry5 Chipcommon I/O Controller", NULL}, - {0x0804, "Sentry5 PCI Bridge", NULL}, - {0x0805, "Sentry5 MIPS32 CPU", NULL}, - {0x0806, "Sentry5 Ethernet Controller", NULL}, - {0x080B, "Sentry5 Crypto Accelerator", NULL}, - {0x080F, "Sentry5 DDR/SDR RAM Controller", NULL}, - {0x0811, "Sentry5 External Interface Core", NULL}, - {0x0816, "BCM3302 Sentry5 MIPS32 CPU", NULL}, - {0x1600, "NetXtreme BCM5752 Gigabit Ethernet PCI Express", NULL}, - {0x1601, "NetXtreme BCM5752M Gigabit Ethernet PCI Express", NULL}, - {0x1644, "NetXtreme BCM5700 Gigabit Ethernet", NULL}, - {0x1645, "NetXtreme BCM5701 Gigabit Ethernet", NULL}, - {0x1646, "NetXtreme BCM5702 Gigabit Ethernet", NULL}, - {0x1647, "NetXtreme BCM5703 Gigabit Ethernet", NULL}, - {0x1648, "NetXtreme BCM5704 Gigabit Ethernet", NULL}, - {0x164A, "NetXtreme II BCM5706 Gigabit Ethernet", NULL}, - {0x164C, "NetXtreme II BCM5708 Gigabit Ethernet", NULL}, - {0x164D, "NetXtreme BCM5702FE Gigabit Ethernet", NULL}, - {0x1653, "NetXtreme BCM5705 Gigabit Ethernet", NULL}, - {0x1654, "NetXtreme BCM5705_2 Gigabit Ethernet", NULL}, - {0x1659, "NetXtreme BCM5721 Gigabit Ethernet PCI Express", NULL}, - {0x165D, "NetXtreme BCM5705M Gigabit Ethernet", NULL}, - {0x165E, "NetXtreme BCM5705M_2 Gigabit Ethernet", NULL}, - {0x1668, "NetXtreme BCM5714 Gigabit Ethernet", NULL}, - {0x166A, "NetXtreme BCM5780 Gigabit Ethernet", NULL}, - {0x166B, "NetXtreme BCM5780S Gigabit Ethernet", NULL}, - {0x166E, "570x 10/100 Integrated Controller", NULL}, - {0x1677, "NetXtreme BCM5751 Gigabit Ethernet PCI Express", NULL}, - {0x1678, "NetXtreme BCM5715 Gigabit Ethernet", NULL}, - {0x167D, "NetXtreme BCM5751M Gigabit Ethernet PCI Express", NULL}, - {0x167E, "NetXtreme BCM5751F Fast Ethernet PCI Express", NULL}, - {0x1696, "NetXtreme BCM5782 Gigabit Ethernet", NULL}, - {0x169C, "NetXtreme BCM5788 Gigabit Ethernet", NULL}, - {0x169D, "NetLink BCM5789 Gigabit Ethernet PCI Express", NULL}, - {0x16A6, "NetXtreme BCM5702X Gigabit Ethernet", NULL}, - {0x16A7, "NetXtreme BCM5703X Gigabit Ethernet", NULL}, - {0x16A8, "NetXtreme BCM5704S Gigabit Ethernet", NULL}, - {0x16AA, "NetXtreme II BCM5706S Gigabit Ethernet", NULL}, - {0x16AC, "NetXtreme II BCM5708S Gigabit Ethernet", NULL}, - {0x16C6, "NetXtreme BCM5702A3 Gigabit Ethernet", NULL}, - {0x16C7, "NetXtreme BCM5703 Gigabit Ethernet", NULL}, - {0x16DD, "NetLink BCM5781 Gigabit Ethernet PCI Express", NULL}, - {0x16F7, "NetXtreme BCM5753 Gigabit Ethernet PCI Express", NULL}, - {0x16FD, "NetXtreme BCM5753M Gigabit Ethernet PCI Express", NULL}, - {0x16FE, "NetXtreme BCM5753F Fast Ethernet PCI Express", NULL}, - {0x170C, "BCM4401-B0 100Base-TX", NULL}, - {0x170D, "NetXtreme BCM5901 100Base-TX", NULL}, - {0x170E, "NetXtreme BCM5901 100Base-TX", NULL}, - {0x3352, "BCM3352", NULL}, - {0x3360, "BCM3360", NULL}, - {0x4210, "BCM4210 iLine10 HomePNA 2.0", NULL}, - {0x4211, "BCM4211 iLine10 HomePNA 2.0 + V.90 56k modem", NULL}, - {0x4212, "BCM4212 v.90 56k modem", NULL}, - {0x4301, "BCM4303 802.11b Wireless LAN Controller", NULL}, - {0x4305, "BCM4307 V.90 56k Modem", NULL}, - {0x4306, "BCM4307 Ethernet Controller", NULL}, - {0x4307, "BCM4307 802.11b Wireless LAN Controller", NULL}, - {0x4310, "BCM4310 Chipcommon I/OController", NULL}, - {0x4312, "BCM4310 UART", NULL}, - {0x4313, "BCM4310 Ethernet Controller", NULL}, - {0x4315, "BCM4310 USB Controller", NULL}, - {0x4318, "BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller", NULL}, - {0x4319, "Dell Wireless 1470 DualBand WLAN", NULL}, - {0x4320, "BCM4306 802.11b/g Wireless LAN Controller", NULL}, - {0x4321, "BCM4306 802.11a Wireless LAN Controller", NULL}, - {0x4322, "BCM4306 UART", NULL}, - {0x4324, "BCM4309 802.11a/b/g", NULL}, - {0x4325, "BCM43xG 802.11b/g", NULL}, - {0x4326, "BCM4307 Chipcommon I/O Controller?", NULL}, - {0x4401, "BCM4401 100Base-T", NULL}, - {0x4402, "BCM4402 Integrated 10/100BaseT", NULL}, - {0x4403, "BCM4402 V.90 56k Modem", NULL}, - {0x4410, "BCM4413 iLine32 HomePNA 2.0", NULL}, - {0x4411, "BCM4413 V.90 56k modem", NULL}, - {0x4412, "BCM4412 10/100BaseT", NULL}, - {0x4430, "BCM44xx CardBus iLine32 HomePNA 2.0", NULL}, - {0x4432, "BCM4432 CardBus 10/100BaseT", NULL}, - {0x4610, "BCM4610 Sentry5 PCI to SB Bridge", NULL}, - {0x4611, "BCM4610 Sentry5 iLine32 HomePNA 1.0", NULL}, - {0x4612, "BCM4610 Sentry5 V.90 56k Modem", NULL}, - {0x4613, "BCM4610 Sentry5 Ethernet Controller", NULL}, - {0x4614, "BCM4610 Sentry5 External Interface", NULL}, - {0x4615, "BCM4610 Sentry5 USB Controller", NULL}, - {0x4704, "BCM4704 PCI to SB Bridge", NULL}, - {0x4705, "BCM4704 Sentry5 802.11b Wireless LAN Controller", NULL}, - {0x4706, "BCM4704 Sentry5 Ethernet Controller", NULL}, - {0x4707, "BCM4704 Sentry5 USB Controller", NULL}, - {0x4708, "BCM4704 Crypto Accelerator", NULL}, - {0x4710, "BCM4710 Sentry5 PCI to SB Bridge", NULL}, - {0x4711, "BCM47xx Sentry5 iLine32 HomePNA 2.0", NULL}, - {0x4712, "BCM47xx V.92 56k modem", NULL}, - {0x4713, "Sentry5 Ethernet Controller", NULL}, - {0x4714, "BCM47xx Sentry5 External Interface", NULL}, - {0x4715, "Sentry5 USB Controller", NULL}, - {0x4716, "BCM47xx Sentry5 USB Host Controller", NULL}, - {0x4717, "BCM47xx Sentry5 USB Device Controller", NULL}, - {0x4718, "Sentry5 Crypto Accelerator", NULL}, - {0x4719, "BCM47xx/53xx RoboSwitch Core", NULL}, - {0x4720, "BCM4712 MIPS CPU", NULL}, - {0x5365, "BCM5365P Sentry5 Host Bridge", NULL}, - {0x5600, "BCM5600 StrataSwitch 24+2 Ethernet Switch Controller", NULL}, - {0x5605, "BCM5605 StrataSwitch 24+2 Ethernet Switch Controller", NULL}, - {0x5615, "BCM5615 StrataSwitch 24+2 Ethernet Switch Controller", NULL}, - {0x5625, "BCM5625 StrataSwitch 24+2 Ethernet Switch Controller", NULL}, - {0x5645, "BCM5645 StrataSwitch 24+2 Ethernet Switch Controller", NULL}, - {0x5670, "BCM5670 8-Port 10GE Ethernet Switch Fabric", NULL}, - {0x5680, "BCM5680 G-Switch 8 Port Gigabit Ethernet Switch Controller", NULL}, - {0x5690, "BCM5690 12-port Multi-Layer Gigabit Ethernet Switch", NULL}, - {0x5691, "BCM5691 GE/10GE 8+2 Gigabit Ethernet Switch Controller", NULL}, - {0x5692, "BCM5692 12-port Multi-Layer Gigabit Ethernet Switch", NULL}, - {0x5820, "BCM5820 Crypto Accelerator", NULL}, - {0x5821, "BCM5821 Crypto Accelerator", NULL}, - {0x5822, "BCM5822 Crypto Accelerator", NULL}, - {0x5823, "BCM5823 Crypto Accelerator", NULL}, - {0x5824, "BCM5824 Crypto Accelerator", NULL}, - {0x5840, "BCM5840 Crypto Accelerator", NULL}, - {0x5841, "BCM5841 Crypto Accelerator", NULL}, - {0x5850, "BCM5850 Crypto Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14EA[] = { - {0xAB06, "FNW-3603-TX CardBus Fast Ethernet", NULL}, - {0xAB07, "RTL81xx RealTek Ethernet", NULL}, - {0xAB08, "FNW-3602-TX CardBus Fast Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14F1[] = { - {0x1002, "HCF 56k Modem", NULL}, - {0x1003, "HCF 56k Modem", NULL}, - {0x1004, "HCF 56k Modem", NULL}, - {0x1005, "HCF 56k Modem", NULL}, - {0x1006, "HCF 56k Modem", NULL}, - {0x1022, "HCF 56k Modem", NULL}, - {0x1023, "HCF 56k Modem", NULL}, - {0x1024, "HCF 56k Modem", NULL}, - {0x1025, "HCF 56k Modem", NULL}, - {0x1026, "HCF 56k Modem", NULL}, - {0x1032, "HCF 56k Modem", NULL}, - {0x1033, "HCF 56k Data/Fax Modem", NULL}, - {0x1034, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1035, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1036, "HCF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x1052, "HCF 56k Data/Fax Modem (Worldwide)", NULL}, - {0x1053, "HCF 56k Data/Fax Modem (Worldwide)", NULL}, - {0x1054, "HCF 56k Data/Fax/Voice Modem (Worldwide)", NULL}, - {0x1055, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (Worldwide)", NULL}, - {0x1056, "HCF 56k Data/Fax/Voice/Spkp Modem (Worldwide)", NULL}, - {0x1057, "HCF 56k Data/Fax/Voice/Spkp Modem (Worldwide)", NULL}, - {0x1059, "HCF 56k Data/Fax/Voice Modem (Worldwide)", NULL}, - {0x1063, "HCF 56k Data/Fax Modem", NULL}, - {0x1064, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1065, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1066, "HCF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x1085, "HCF V90 56k Data/Fax/Voice/Spkp PCI Modem", NULL}, - {0x1433, "HCF 56k Data/Fax Modem", NULL}, - {0x1434, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1435, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1436, "HCF 56k Data/Fax Modem", NULL}, - {0x1453, "HCF 56k Data/Fax Modem", NULL}, - {0x1454, "HCF 56k Data/Fax/Voice Modem", NULL}, - {0x1455, "HCF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x1456, "HCF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x1610, "ADSL AccessRunner PCI Arbitration Device", NULL}, - {0x1611, "AccessRunner PCI ADSL Interface Device", NULL}, - {0x1620, "AccessRunner V2 PCI ADSL Arbitration Device", NULL}, - {0x1621, "AccessRunner V2 PCI ADSL Interface Device", NULL}, - {0x1622, "AccessRunner V2 PCI ADSL Yukon WAN Adapter", NULL}, - {0x1803, "HCF 56k Modem", NULL}, - {0x1811, "Conextant MiniPCI Network Adapter", NULL}, - {0x1815, "HCF 56k Modem", NULL}, - {0x2003, "HSF 56k Data/Fax Modem", NULL}, - {0x2004, "HSF 56k Data/Fax/Voice Modem", NULL}, - {0x2005, "HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x2006, "HSF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x2013, "HSF 56k Data/Fax Modem", NULL}, - {0x2014, "HSF 56k Data/Fax/Voice Modem", NULL}, - {0x2015, "HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem", NULL}, - {0x2016, "HSF 56k Data/Fax/Voice/Spkp Modem", NULL}, - {0x2043, "HSF 56k Data/Fax Modem (WorldW SmartDAA)", NULL}, - {0x2044, "HSF 56k Data/Fax/Voice Modem (WorldW SmartDAA)", NULL}, - {0x2045, "HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (WorldW SmartDAA)", NULL}, - {0x2046, "HSF 56k Data/Fax/Voice/Spkp Modem (WorldW SmartDAA)", NULL}, - {0x2063, "HSF 56k Data/Fax Modem (SmartDAA)", NULL}, - {0x2064, "HSF 56k Data/Fax/Voice Modem (SmartDAA)", NULL}, - {0x2065, "HSF 56k Data/Fax/Voice/Spkp (w/Handset) Modem (SmartDAA)", NULL}, - {0x2066, "HSF 56k Data/Fax/Voice/Spkp Modem (SmartDAA)", NULL}, - {0x2093, "HSF 56k Modem", NULL}, - {0x2143, "HSF 56k Data/Fax/Cell Modem (Mob WorldW SmartDAA)", NULL}, - {0x2144, "HSF 56k Data/Fax/Voice/Cell Modem (Mob WorldW SmartDAA)", NULL}, - {0x2145, "HSF 56k Data/Fax/Voice/Spkp (w/HS)/Cell Modem (Mob WorldW SmartDAA)", NULL}, - {0x2146, "HSF 56k Data/Fax/Voice/Spkp/Cell Modem (Mob WorldW SmartDAA)", NULL}, - {0x2163, "HSF 56k Data/Fax/Cell Modem (Mob SmartDAA)", NULL}, - {0x2164, "HSF 56k Data/Fax/Voice/Cell Modem (Mob SmartDAA)", NULL}, - {0x2165, "HSF 56k Data/Fax/Voice/Spkp (w/HS)/Cell Modem (Mob SmartDAA)", NULL}, - {0x2166, "HSF 56k Data/Fax/Voice/Spkp/Cell Modem (Mob SmartDAA)", NULL}, - {0x2343, "HSF 56k Data/Fax CardBus Modem (Mob WorldW SmartDAA)", NULL}, - {0x2344, "HSF 56k Data/Fax/Voice CardBus Modem (Mob WorldW SmartDAA)", NULL}, - {0x2345, "HSF 56k Data/Fax/Voice/Spkp (w/HS) CardBus Modem (Mob WorldW SmartDAA)", NULL}, - {0x2346, "HSF 56k Data/Fax/Voice/Spkp CardBus Modem (Mob WorldW SmartDAA)", NULL}, - {0x2363, "HSF 56k Data/Fax CardBus Modem (Mob SmartDAA)", NULL}, - {0x2364, "HSF 56k Data/Fax/Voice CardBus Modem (Mob SmartDAA)", NULL}, - {0x2365, "HSF 56k Data/Fax/Voice/Spkp (w/HS) CardBus Modem (Mob SmartDAA)", NULL}, - {0x2366, "HSF 56k Data/Fax/Voice/Spkp CardBus Modem (Mob SmartDAA)", NULL}, - {0x2443, "HSF 56k Data/Fax Modem (Mob WorldW SmartDAA)", NULL}, - {0x2444, "HSF 56k Data/Fax/Voice Modem (Mob WorldW SmartDAA)", NULL}, - {0x2445, "HSF 56k Data/Fax/Voice/Spkp (w/HS) Modem (Mob WorldW SmartDAA)", NULL}, - {0x2446, "HSF 56k Data/Fax/Voice/Spkp Modem (Mob WorldW SmartDAA)", NULL}, - {0x2463, "HSF 56k Data/Fax Modem (Mob SmartDAA)", NULL}, - {0x2464, "HSF 56k Data/Fax/Voice Modem (Mob SmartDAA)", NULL}, - {0x2465, "HSF 56k Data/Fax/Voice/Spkp (w/HS) Modem (Mob SmartDAA)", NULL}, - {0x2466, "HSF 56k Data/Fax/Voice/Spkp Modem (Mob SmartDAA)", NULL}, - {0x2F00, "HSF 56k HSFi Modem", NULL}, - {0x2F02, "HSF 56k HSFi Data/Fax", NULL}, - {0x2F11, "HSF 56k HSFi Modem", NULL}, - {0x2F20, "HSF 56k Data/Fax Modem", NULL}, - {0x8234, "RS8234 ATM SAR Controller [ServiceSAR Plus]", NULL}, - {0x8800, "CX23880/1/2/3 PCI Video and Audio Decoder", NULL}, - {0x8801, "CX23880/1/2/3 PCI Video and Audio Decoder [Audio Port]", NULL}, - {0x8802, "CX23880/1/2/3 PCI Video and Audio Decoder [MPEG Port]", NULL}, - {0x8804, "CX23880/1/2/3 PCI Video and Audio Decoder [IR Port]", NULL}, - {0x8811, "CX23880/1/2/3 PCI Video and Audio Decoder [Audio Port]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14F2[] = { - {0x0120, "EV1000 bridge", NULL}, - {0x0121, "EV1000 Parallel port", NULL}, - {0x0122, "EV1000 Serial port", NULL}, - {0x0123, "EV1000 Keyboard controller", NULL}, - {0x0124, "EV1000 Mouse controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14F3[] = { - {0x2030, "2030 DVB-S Satellite Reciever", NULL}, - {0x2050, "2050 DVB-T Terrestrial (Cable) Reciever", NULL}, - {0x2060, "2060 ATSC Terrestrial (Cable) Reciever", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14F8[] = { - {0x2077, "TP-240 dual span E1 VoIP PCI card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_14FC[] = { - {0x0000, "QsNet Elan3 Network Adapter", NULL}, - {0x0001, "QsNetII Elan4 Network Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1500[] = { - {0x1360, "RTL81xx RealTek Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1507[] = { - {0x0001, "MPC105 [Eagle]", NULL}, - {0x0002, "MPC106 [Grackle]", NULL}, - {0x0003, "MPC8240 [Kahlua]", NULL}, - {0x0100, "MC145575 [HFC-PCI]", NULL}, - {0x0431, "KTI829c 100VG", NULL}, - {0x4801, "Raven", NULL}, - {0x4802, "Falcon", NULL}, - {0x4803, "Hawk", NULL}, - {0x4806, "CPX8216", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1516[] = { - {0x0800, "MTD-8xx 100/10M Ethernet PCI Adapter", NULL}, - {0x0803, "SURECOM EP-320X-S 100/10M Ethernet PCI Adapter", NULL}, - {0x0891, "MTD-8xx 100/10M Ethernet PCI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_151A[] = { - {0x1002, "PCI-1002", NULL}, - {0x1004, "PCI-1004", NULL}, - {0x1008, "PCI-1008", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_151C[] = { - {0x0003, "Prodif T 2496", NULL}, - {0x4000, "Prodif 88", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_151F[] = { - {0x0000, "TP560 Data/Fax/Voice 56k modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1522[] = { - {0x0100, "PCI <-> IOBus Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1524[] = { - {0x0510, "CB710 Memory Card Reader Controller", NULL}, - {0x0520, "FLASH memory: ENE Technology Inc:", NULL}, - {0x0530, "ENE PCI Memory Stick Card Reader Controller", NULL}, - {0x0550, "ENE PCI Secure Digital Card Reader Controller", NULL}, - {0x0610, "PCI Smart Card Reader Controller", NULL}, - {0x1211, "CB1211 Cardbus Controller", NULL}, - {0x1225, "CB1225 Cardbus Controller", NULL}, - {0x1410, "CB1410 Cardbus Controller", NULL}, - {0x1411, "CB-710/2/4 Cardbus Controller", NULL}, - {0x1412, "CB-712/4 Cardbus Controller", NULL}, - {0x1420, "CB1420 Cardbus Controller", NULL}, - {0x1421, "CB-720/2/4 Cardbus Controller", NULL}, - {0x1422, "CB-722/4 Cardbus Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1532[] = { - {0x0020, "LonWorks PCLTA-20 PCI LonTalk Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1538[] = { - {0x0303, "ARS106S Ultra ATA 133/100/66 Host Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_153B[] = { - {0x1144, "Aureon 5.1", NULL}, - {0x1147, "Aureon 5.1 Sky", NULL}, - {0x1158, "Philips Semiconductors SAA7134 (rev 01) [Terratec Cinergy 600 TV]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_153F[] = { - {0x0001, "SOC-it 101 System Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1543[] = { - {0x3052, "Intel 537 [Winmodem]", NULL}, - {0x4C22, "Si3036 MC'97 DAA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1571[] = { - {0xA001, "CCSI PCI20-485 ARCnet", NULL}, - {0xA002, "CCSI PCI20-485D ARCnet", NULL}, - {0xA003, "CCSI PCI20-485X ARCnet", NULL}, - {0xA004, "CCSI PCI20-CXB ARCnet", NULL}, - {0xA005, "CCSI PCI20-CXS ARCnet", NULL}, - {0xA006, "CCSI PCI20-FOG-SMA ARCnet", NULL}, - {0xA007, "CCSI PCI20-FOG-ST ARCnet", NULL}, - {0xA008, "CCSI PCI20-TB5 ARCnet", NULL}, - {0xA009, "CCSI PCI20-5-485 5Mbit ARCnet", NULL}, - {0xA00A, "CCSI PCI20-5-485D 5Mbit ARCnet", NULL}, - {0xA00B, "CCSI PCI20-5-485X 5Mbit ARCnet", NULL}, - {0xA00C, "CCSI PCI20-5-FOG-ST 5Mbit ARCnet", NULL}, - {0xA00D, "CCSI PCI20-5-FOG-SMA 5Mbit ARCnet", NULL}, - {0xA201, "CCSI PCI22-485 10Mbit ARCnet", NULL}, - {0xA202, "CCSI PCI22-485D 10Mbit ARCnet", NULL}, - {0xA203, "CCSI PCI22-485X 10Mbit ARCnet", NULL}, - {0xA204, "CCSI PCI22-CHB 10Mbit ARCnet", NULL}, - {0xA205, "CCSI PCI22-FOG_ST 10Mbit ARCnet", NULL}, - {0xA206, "CCSI PCI22-THB 10Mbit ARCnet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1578[] = { - {0x5615, "VPMK3 [Video Processor Mk III]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_157C[] = { - {0x8001, "Fix2000 PCI Y2K Compliance Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1592[] = { - {0x0781, "Multi-IO Card", NULL}, - {0x0782, "Parallel Port Card 2xEPP", NULL}, - {0x0783, "Multi-IO Card", NULL}, - {0x0785, "Multi-IO Card", NULL}, - {0x0786, "Multi-IO Card", NULL}, - {0x0787, "Multi-IO Card", NULL}, - {0x0788, "Multi-IO Card", NULL}, - {0x078A, "Multi-IO Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15A2[] = { - {0x0001, "TA700 PCI Bus Analyzer/Exerciser", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15AD[] = { - {0x0405, "[VMware SVGA II] PCI Display Adapter", NULL}, - {0x0710, "Virtual SVGA", NULL}, - {0x0720, "VMware High-Speed Virtual NIC [vmxnet]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15B3[] = { - {0x5274, "MT21108 InfiniBridge", NULL}, - {0x5A44, "MT23108 InfiniHost", NULL}, - {0x5A45, "MT23108 [Infinihost HCA Flash Recovery]", NULL}, - {0x5A46, "MT23108 PCI Bridge", NULL}, - {0x5E8D, "MT25204 [InfiniHost III Lx HCA Flash Recovery]", NULL}, - {0x6274, "MT25204 [InfiniHost III Lx HCA]", NULL}, - {0x6278, "MT25208 InfiniHost III Ex (Tavor compatibility mode)", NULL}, - {0x6279, "MT25208 [InfiniHost III Ex HCA Flash Recovery]", NULL}, - {0x6282, "MT25208 InfiniHost III Ex", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15BC[] = { - {0x1100, "E8001-66442 PCI Express CIC", NULL}, - {0x2922, "64 Bit, 133MHz PCI-X Exerciser & Protocol Checker", NULL}, - {0x2928, "64 Bit, 66MHz PCI Exerciser & Analyzer", NULL}, - {0x2929, "64 Bit, 133MHz PCI-X Analyzer & Exerciser", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15C5[] = { - {0x8010, "1394b - 1394 Firewire 3-Port Host Adapter Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15C7[] = { - {0x0349, "Tateyama C-PCI PLC/NC card Rev.01A", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15DC[] = { - {0x0001, "Argus 300 PCI Cryptography Module", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15E8[] = { - {0x0130, "Wireless PCI Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15E9[] = { - {0x1841, "ADMA-100 DiscStaQ ATA Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_15EC[] = { - {0x3101, "FC3101 Profibus DP 1 Channel PCI", NULL}, - {0x5102, "FC5102", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1619[] = { - {0x0400, "FarSync T2P (2 port X.21/V.35/V.24)", NULL}, - {0x0440, "FarSync T4P (4 port X.21/V.35/V.24)", NULL}, - {0x0610, "FarSync T1U (1 port X.21/V.35/V.24)", NULL}, - {0x0620, "FarSync T2U (1 port X.21/V.35/V.24)", NULL}, - {0x0640, "FarSync T4U (4 port X.21/V.35/V.24)", NULL}, - {0x1610, "FarSync TE1 (T1,E1)", NULL}, - {0x2610, "FarSync DSL-S1 (SHDSL)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1626[] = { - {0x8410, "RTL81xx Fast Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1629[] = { - {0x1003, "Format synchronizer v3.0", NULL}, - {0x2002, "Fast Universal Data Output", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1637[] = { - {0x3874, "Linksys 802.11b WMP11 PCI Wireless card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1638[] = { - {0x1100, "SMC2602W EZConnect / Addtron AWA-100 / Eumitcom PCI WL11000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_163C[] = { - {0x3052, "SmartLink SmartPCI562 56K Modem", NULL}, - {0x5449, "SmartPCI561 Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_165A[] = { - {0xC100, "PIXCI(R) CL1 Camera Link Video Capture Board [custom QL5232]", NULL}, - {0xD200, "PIXCI(R) D2X Digital Video Capture Board [custom QL5232]", NULL}, - {0xD300, "PIXCI(R) D3X Digital Video Capture Board [custom QL5232]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_165F[] = { - {0x1020, "LMLM4 MPEG-4 encoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1668[] = { - {0x0100, "Mini-PCI bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_166D[] = { - {0x0001, "SiByte BCM1125/1125H/1250 System-on-a-Chip PCI", NULL}, - {0x0002, "SiByte BCM1125H/1250 System-on-a-Chip HyperTransport", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1677[] = { - {0x104E, "5LS172.6 B&R Dual CAN Interface Card", NULL}, - {0x12D7, "5LS172.61 B&R Dual CAN Interface Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_167B[] = { - {0x2102, "ZyDAS ZD1202", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1681[] = { - {0x0010, "Hercules 3d Prophet II Ultra 64MB (350 MHz NV15BR core)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1688[] = { - {0x1170, "WLAN 802.11b card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_168C[] = { - {0x0007, "AR5000 802.11a Wireless Adapter", NULL}, - {0x0011, "AR5210 802.11a NIC", NULL}, - {0x0012, "AR5211 802.11ab NIC", NULL}, - {0x0013, "AR5212 802.11abg NIC", NULL}, - {0x001A, "AR5005G 802.11abg NIC", NULL}, - {0x001B, "AR5006X 802.11abg NIC", NULL}, - {0x0020, "AR5005VL 802.11bg Wireless NIC", NULL}, - {0x1014, "AR5212 802.11abg NIC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_169C[] = { - {0x0044, "Revolution Storage Processing Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16AB[] = { - {0x1100, "GL24110P", NULL}, - {0x1101, "PLX9052 PCMCIA-to-PCI Wireless LAN", NULL}, - {0x1102, "PCMCIA-to-PCI Wireless Network Bridge", NULL}, - {0x8501, "WL-8305 Wireless LAN PCI Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16AE[] = { - {0x1141, "SafeXcel-1141", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16CA[] = { - {0x0001, "Rocket Drive DL", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16E3[] = { - {0x1E0F, "LEON2FT Processor", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16EC[] = { - {0x00FF, "USR997900 10/100 Mbps PCI Network Card", NULL}, - {0x0116, "USR997902 10/100/1000 Mbps PCI Network Card", NULL}, - {0x3685, "Wireless Access PCI Adapter Model 022415", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16ED[] = { - {0x1001, "UMIO communication card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_16F4[] = { - {0x8000, "VW2010", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_170B[] = { - {0x0100, "NSP2000-SSL crypto accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1725[] = { - {0x7174, "VSC7174 PCI/PCI-X Serial ATA Host Bus Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_172A[] = { - {0x13C8, "AEP SureWare Runner 1000V3", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1737[] = { - {0x0013, "WMP54G Wireless Pci Card", NULL}, - {0x0015, "WMP54GS Wireless Pci Card", NULL}, - {0x1032, "Gigabit Network Adapter", NULL}, - {0x1064, "Gigabit Network Adapter", NULL}, - {0xAB08, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0xAB09, "21x4x DEC-Tulip compatible 10/100 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_173B[] = { - {0x03E8, "AC1000 Gigabit Ethernet", NULL}, - {0x03E9, "AC1001 Gigabit Ethernet", NULL}, - {0x03EA, "AC9100 Gigabit Ethernet", NULL}, - {0x03EB, "AC1003 Gigabit Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1743[] = { - {0x8139, "ROL/F-100 Fast Ethernet Adapter with ROL", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1796[] = { - {0x0001, "SIS1100 [Gigabit link]", NULL}, - {0x0002, "HOTlink", NULL}, - {0x0003, "Counter Timer", NULL}, - {0x0004, "CAMAC Controller", NULL}, - {0x0005, "PROFIBUS", NULL}, - {0x0006, "AMCC HOTlink", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1799[] = { - {0x6001, "Wireless PCI Card - F5D6001", NULL}, - {0x6020, "Wireless PCMCIA Card - F5D6020", NULL}, - {0x6060, "Wireless PDA Card - F5D6060", NULL}, - {0x7000, "Wireless PCI Card - F5D7000", NULL}, - {0x7010, "BCM4306 802.11b/g Wireless Lan Controller F5D7010", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_179C[] = { - {0x0557, "DP-PCI-557 [PCI 1553B]", NULL}, - {0x0566, "DP-PCI-566 [Intelligent PCI 1553B]", NULL}, - {0x5031, "DP-CPCI-5031-Synchro Module", NULL}, - {0x5121, "DP-CPCI-5121-IP Carrier", NULL}, - {0x5211, "DP-CPCI-5211-IP Carrier", NULL}, - {0x5679, "AGE Display Module", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17A0[] = { - {0x8033, "GL880S USB 1.1 controller", NULL}, - {0x8034, "GL880S USB 2.0 controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17B3[] = { - {0xAB08, "PN672TX 10/100 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17B4[] = { - {0x0011, "WebEnhance 100 GZIP Compression Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17CC[] = { - {0x2280, "USB 2.0", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17D3[] = { - {0x1110, "ARC-1110 4-Port PCI-X to SATA RAID Controller", NULL}, - {0x1120, "ARC-1120 8-Port PCI-X to SATA RAID Controller", NULL}, - {0x1130, "ARC-1130 12-Port PCI-X to SATA RAID Controller", NULL}, - {0x1160, "ARC-1160 16-Port PCI-X to SATA RAID Controller", NULL}, - {0x1210, "ARC-1210 4-Port PCI-Express to SATA RAID Controller", NULL}, - {0x1220, "ARC-1220 8-Port PCI-Express to SATA RAID Controller", NULL}, - {0x1230, "ARC-1230 12-Port PCI-Express to SATA RAID Controller", NULL}, - {0x1260, "ARC-1260 16-Port PCI-Express to SATA RAID Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17D5[] = { - {0x5831, "Xframe 10 Gigabit Ethernet PCI-X", NULL}, - {0x5832, "Xframe II 10 Gigabit Ethernet PCI-X", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_17FE[] = { - {0x2120, "WMP11v4 802.11b PCI card", NULL}, - {0x2220, "[AirConn] INPROCOMM IPN 2220 Wireless LAN Adapter (rev 01)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1813[] = { - {0x4000, "HaM controllerless modem", NULL}, - {0x4100, "HaM plus Data Fax Modem", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1814[] = { - {0x0101, "Wireless PCI Adapter RT2400 / RT2460", NULL}, - {0x0200, "RT2500 802.11g PCI [PC54G2]", NULL}, - {0x0201, "RT2500 802.11g Cardbus/mini-PCI", NULL}, - {0x0301, "RT2561/RT61 802.11g PCI", NULL}, - {0x0401, "Ralink RT2600 802.11 MIMO", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1822[] = { - {0x4E35, "Mantis DTV PCI Bridge Controller [Ver 1.0]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_182D[] = { - {0x3069, "ISDN PCI DC-105V2", NULL}, - {0x9790, "WL-121 Wireless Network Adapter 100g+ [Ver.3]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_183B[] = { - {0x08A7, "MVC100 DVI", NULL}, - {0x08A8, "MVC101 SDI", NULL}, - {0x08A9, "MVC102 DVI+Audio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1864[] = { - {0x2110, "ISNAP 2110", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1867[] = { - {0x5A44, "MT23108 InfiniHost HCA", NULL}, - {0x5A45, "MT23108 InfiniHost HCA flash recovery", NULL}, - {0x5A46, "MT23108 InfiniHost HCA bridge", NULL}, - {0x6278, "MT25208 InfiniHost III Ex (Tavor compatibility mode)", NULL}, - {0x6282, "MT25208 InfiniHost III Ex", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1888[] = { - {0x0301, "VMFX1 FPGA PMC module", NULL}, - {0x0601, "VSM2 dual PMC carrier", NULL}, - {0x0710, "VS14x series PowerPC PCI board", NULL}, - {0x0720, "VS24x series PowerPC PCI board", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18AC[] = { - {0xD500, "FusionHDTV 5", NULL}, - {0xD810, "FusionHDTV 3 Gold", NULL}, - {0xD820, "FusionHDTV 3 Gold-T", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18B8[] = { - {0xB001, "AMSO 1100 iWARP/RDMA Gigabit Ethernet Coprocessor", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18CA[] = { - {0x0020, "Volari Z7", NULL}, - {0x0040, "Volari V3XT/V5/V8", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18D2[] = { - {0x3069, "DC-105v2 ISDN controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18DD[] = { - {0x4C6F, "Artimi RTMI-100 UWB adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18E6[] = { - {0x0001, "OSCI [Octal Serial Communication Interface]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18EC[] = { - {0xC006, "COMBO6", NULL}, - {0xC045, "COMBO6E", NULL}, - {0xC050, "COMBO-PTM", NULL}, - {0xC058, "COMBO6X", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_18F7[] = { - {0x0001, "Fastcom ESCC-PCI-335", NULL}, - {0x0002, "Fastcom 422/4-PCI-335", NULL}, - {0x0004, "Fastcom 422/2-PCI-335", NULL}, - {0x0005, "Fastcom IGESCC-PCI-ISO/1", NULL}, - {0x000A, "Fastcom 232/4-PCI-335", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1923[] = { - {0x0100, "A104d QUAD T1/E1 AFT card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1942[] = { - {0xE511, "CSX600 Advance Accelerator Board", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1957[] = { - {0x0080, "MPC8349E", NULL}, - {0x0081, "MPC8349", NULL}, - {0x0082, "MPC8347E TBGA", NULL}, - {0x0083, "MPC8347 TBGA", NULL}, - {0x0084, "MPC8347E PBGA", NULL}, - {0x0085, "MPC8347 PBGA", NULL}, - {0x0086, "MPC8343E", NULL}, - {0x0087, "MPC8343", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1966[] = { - {0x1975, "DVG64 family", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_196A[] = { - {0x0101, "NodalCore C-1000 Content Classification Accelerator", NULL}, - {0x0102, "NodalCore C-2000 Content Classification Accelerator", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_197B[] = { - {0x2360, "JMicron 20360/20363 AHCI Controller", NULL}, - {0x2363, "JMicron 20360/20363 AHCI Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1989[] = { - {0x0001, "RapidFile Bridge", NULL}, - {0x8001, "RapidFile", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_19AE[] = { - {0x0520, "4135 HFT Interface Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1A08[] = { - {0x0000, "SC15064", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1C1C[] = { - {0x0001, "82C101", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1D44[] = { - {0xA400, "PM2x24/PM3224", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1DE1[] = { - {0x0391, "TRM-S1040", NULL}, - {0x2020, "DC-390", NULL}, - {0x690C, "690c", NULL}, - {0xDC29, "DC290", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1FC0[] = { - {0x0300, "E2200 Dual E1/Rawpipe Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1FC1[] = { - {0x000D, "InfiniPath HT-400", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_1FCE[] = { - {0x0001, "Spectrum Analyzer PC Card (SAgE)", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_2348[] = { - {0x2010, "8142 100VG/AnyLAN", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_3388[] = { - {0x0013, "HiNT HC4 PCI to ISDN bridge, Multimedia audio controller", NULL}, - {0x0014, "HiNT HC4 PCI to ISDN bridge, Network controller", NULL}, - {0x0020, "HB6 Universal PCI-PCI bridge (transparent mode)", NULL}, - {0x0021, "HB6 Universal PCI-PCI bridge (non-transparent mode)", NULL}, - {0x0022, "HiNT HB4 PCI-PCI Bridge (PCI6150)", NULL}, - {0x0026, "HB2 PCI-PCI Bridge", NULL}, - {0x101A, "E.Band [AudioTrak Inca88]", NULL}, - {0x101B, "E.Band [AudioTrak Inca88]", NULL}, - {0x8011, "VXPro II Chipset", NULL}, - {0x8012, "VXPro II Chipset", NULL}, - {0x8013, "VXPro II IDE", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_3842[] = { - {0xC370, "e-GeFORCE 6600 256 DDR PCI-e", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_3D3D[] = { - {0x0001, "GLINT 300SX", NULL}, - {0x0002, "GLINT 500TX", NULL}, - {0x0003, "GLINT Delta", NULL}, - {0x0004, "Permedia", NULL}, - {0x0005, "Permedia", NULL}, - {0x0006, "GLINT MX", NULL}, - {0x0007, "3D Extreme", NULL}, - {0x0008, "GLINT Gamma G1", NULL}, - {0x0009, "Permedia II 2D+3D", NULL}, - {0x000A, "GLINT R3", NULL}, - {0x000C, "GLINT R3 [Oxygen VX1]", NULL}, - {0x000D, "GLint R4 rev A", NULL}, - {0x0011, "GLint R4 rev B", NULL}, - {0x0012, "GLint R5 rev A", NULL}, - {0x0013, "GLint R5 rev B", NULL}, - {0x0020, "VP10 visual processor", NULL}, - {0x0022, "VP10 visual processor", NULL}, - {0x0024, "VP9 visual processor", NULL}, - {0x0100, "Permedia II 2D+3D", NULL}, - {0x07A1, "Wildcat III 6210", NULL}, - {0x07A2, "Sun XVR-500 Graphics Accelerator", NULL}, - {0x07A3, "Wildcat IV 7210", NULL}, - {0x1004, "Permedia", NULL}, - {0x3D04, "Permedia", NULL}, - {0xFFFF, "Glint VGA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4005[] = { - {0x0300, "ALS300 PCI Audio Device", NULL}, - {0x0308, "ALS300+ PCI Audio Device", NULL}, - {0x0309, "PCI Input Controller", NULL}, - {0x1064, "ALG-2064", NULL}, - {0x2064, "ALG-2064i", NULL}, - {0x2128, "ALG-2364A GUI Accelerator", NULL}, - {0x2301, "ALG-2301", NULL}, - {0x2302, "ALG-2302", NULL}, - {0x2303, "AVG-2302 GUI Accelerator", NULL}, - {0x2364, "ALG-2364A", NULL}, - {0x2464, "ALG-2464", NULL}, - {0x2501, "ALG-2564A/25128A", NULL}, - {0x4000, "ALS4000 Audio Chipset", NULL}, - {0x4710, "ALC200/200P", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4033[] = { - {0x1360, "RTL8139 Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4144[] = { - {0x0044, "ADM-XRCIIPro", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_416C[] = { - {0x0100, "AladdinCARD", NULL}, - {0x0200, "CPC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4444[] = { - {0x0016, "iTVC16 (CX23416) MPEG-2 Encoder", NULL}, - {0x0803, "iTVC15 MPEG-2 Encoder", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4916[] = { - {0x1960, "RedCreek PCI adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_494F[] = { - {0x10E8, "LPCI-COM-8SM", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4A14[] = { - {0x5000, "NV5000SC", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4C53[] = { - {0x0000, "PLUSTEST device", NULL}, - {0x0001, "PLUSTEST-MM device", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4D51[] = { - {0x0200, "MQ-200", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_4DDC[] = { - {0x0100, "DD-42924I5-300 (ARINC 429 Data Bus)", NULL}, - {0x0801, "BU-65570I1 MIL-STD-1553 Test and Simulation", NULL}, - {0x0802, "BU-65570I2 MIL-STD-1553 Test and Simulation", NULL}, - {0x0811, "BU-65572I1 MIL-STD-1553 Test and Simulation", NULL}, - {0x0812, "BU-65572I2 MIL-STD-1553 Test and Simulation", NULL}, - {0x0881, "BU-65570T1 MIL-STD-1553 Test and Simulation", NULL}, - {0x0882, "BU-65570T2 MIL-STD-1553 Test and Simulation", NULL}, - {0x0891, "BU-65572T1 MIL-STD-1553 Test and Simulation", NULL}, - {0x0892, "BU-65572T2 MIL-STD-1553 Test and Simulation", NULL}, - {0x0901, "BU-65565C1 MIL-STD-1553 Data Bus", NULL}, - {0x0902, "BU-65565C2 MIL-STD-1553 Data Bus", NULL}, - {0x0903, "BU-65565C3 MIL-STD-1553 Data Bus", NULL}, - {0x0904, "BU-65565C4 MIL-STD-1553 Data Bus", NULL}, - {0x0B01, "BU-65569I1 MIL-STD-1553 Data Bus", NULL}, - {0x0B02, "BU-65569I2 MIL-STD-1553 Data Bus", NULL}, - {0x0B03, "BU-65569I3 MIL-STD-1553 Data Bus", NULL}, - {0x0B04, "BU-65569I4 MIL-STD-1553 Data Bus", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5046[] = { - {0x1001, "PCI Radio", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5053[] = { - {0x2010, "Daytona Audio Adapter", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5145[] = { - {0x3031, "Concert AudioPCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5168[] = { - {0x0301, "FlyDVB-T", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5301[] = { - {0x0001, "ProMotion aT3D", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5333[] = { - {0x0551, "Plato/PX (system)", NULL}, - {0x5631, "86c325 [ViRGE]", NULL}, - {0x8800, "86c866 [Vision 866]", NULL}, - {0x8801, "86c964 [Vision 964]", NULL}, - {0x8810, "86c764_0 [Trio 32 vers 0]", NULL}, - {0x8811, "86c764/765 [Trio32/64/64V+]", NULL}, - {0x8812, "86cM65 [Aurora64V+]", NULL}, - {0x8813, "86c764_3 [Trio 32/64 vers 3]", NULL}, - {0x8814, "86c767 [Trio 64UV+]", NULL}, - {0x8815, "86cM65 [Aurora 128]", NULL}, - {0x883D, "86c988 [ViRGE/VX]", NULL}, - {0x8870, "FireGL", NULL}, - {0x8880, "86c868 [Vision 868 VRAM] vers 0", NULL}, - {0x8881, "86c868 [Vision 868 VRAM] vers 1", NULL}, - {0x8882, "86c868 [Vision 868 VRAM] vers 2", NULL}, - {0x8883, "86c868 [Vision 868 VRAM] vers 3", NULL}, - {0x88B0, "86c928 [Vision 928 VRAM] vers 0", NULL}, - {0x88B1, "86c928 [Vision 928 VRAM] vers 1", NULL}, - {0x88B2, "86c928 [Vision 928 VRAM] vers 2", NULL}, - {0x88B3, "86c928 [Vision 928 VRAM] vers 3", NULL}, - {0x88C0, "86c864 [Vision 864 DRAM] vers 0", NULL}, - {0x88C1, "86c864 [Vision 864 DRAM] vers 1", NULL}, - {0x88C2, "86c864 [Vision 864-P DRAM] vers 2", NULL}, - {0x88C3, "86c864 [Vision 864-P DRAM] vers 3", NULL}, - {0x88D0, "86c964 [Vision 964 VRAM] vers 0", NULL}, - {0x88D1, "86c964 [Vision 964 VRAM] vers 1", NULL}, - {0x88D2, "86c964 [Vision 964-P VRAM] vers 2", NULL}, - {0x88D3, "86c964 [Vision 964-P VRAM] vers 3", NULL}, - {0x88F0, "86c968 [Vision 968 VRAM] rev 0", NULL}, - {0x88F1, "86c968 [Vision 968 VRAM] rev 1", NULL}, - {0x88F2, "86c968 [Vision 968 VRAM] rev 2", NULL}, - {0x88F3, "86c968 [Vision 968 VRAM] rev 3", NULL}, - {0x8900, "86c755 [Trio 64V2/DX]", NULL}, - {0x8901, "86c775/86c785 [Trio 64V2/DX or /GX]", NULL}, - {0x8902, "Plato/PX", NULL}, - {0x8903, "Trio 3D business multimedia", NULL}, - {0x8904, "Trio 64 3D", NULL}, - {0x8905, "Trio 64V+ family", NULL}, - {0x8906, "Trio 64V+ family", NULL}, - {0x8907, "Trio 64V+ family", NULL}, - {0x8908, "Trio 64V+ family", NULL}, - {0x8909, "Trio 64V+ family", NULL}, - {0x890A, "Trio 64V+ family", NULL}, - {0x890B, "Trio 64V+ family", NULL}, - {0x890C, "Trio 64V+ family", NULL}, - {0x890D, "Trio 64V+ family", NULL}, - {0x890E, "Trio 64V+ family", NULL}, - {0x890F, "Trio 64V+ family", NULL}, - {0x8A01, "ViRGE/DX or /GX", NULL}, - {0x8A10, "ViRGE/GX2", NULL}, - {0x8A13, "86c368 [Trio 3D/2X]", NULL}, - {0x8A20, "86c794 [Savage 3D]", NULL}, - {0x8A21, "86c390 [Savage 3D/MV]", NULL}, - {0x8A22, "Savage 4", NULL}, - {0x8A23, "Savage 4", NULL}, - {0x8A25, "ProSavage PM133", NULL}, - {0x8A26, "ProSavage KM133", NULL}, - {0x8C00, "ViRGE/M3", NULL}, - {0x8C01, "ViRGE/MX", NULL}, - {0x8C02, "ViRGE/MX+", NULL}, - {0x8C03, "ViRGE/MX+MV", NULL}, - {0x8C10, "86C270-294 Savage/MX-MV", NULL}, - {0x8C11, "82C270-294 Savage/MX", NULL}, - {0x8C12, "86C270-294 Savage/IX-MV", NULL}, - {0x8C13, "86C270-294 Savage/IX", NULL}, - {0x8C22, "SuperSavage MX/128", NULL}, - {0x8C24, "SuperSavage MX/64", NULL}, - {0x8C26, "SuperSavage MX/64C", NULL}, - {0x8C2A, "SuperSavage IX/128 SDR", NULL}, - {0x8C2B, "SuperSavage IX/128 DDR", NULL}, - {0x8C2C, "SuperSavage IX/64 SDR", NULL}, - {0x8C2D, "SuperSavage IX/64 DDR", NULL}, - {0x8C2E, "SuperSavage IX/C SDR", NULL}, - {0x8C2F, "SuperSavage IX/C DDR", NULL}, - {0x8D01, "86C380 [ProSavageDDR K4M266]", NULL}, - {0x8D02, "VT8636A [ProSavage KN133] AGP4X VGA Controller (TwisterK)", NULL}, - {0x8D03, "VT8751 [ProSavageDDR P4M266]", NULL}, - {0x8D04, "VT8375 [ProSavage8 KM266/KL266]", NULL}, - {0x9102, "86C410 Savage 2000", NULL}, - {0xCA00, "SonicVibes", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_544C[] = { - {0x0350, "TL880-based HDTV/ATSC tuner", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5455[] = { - {0x4458, "S5933", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5544[] = { - {0x0001, "I-30xx Scanner Interface", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5555[] = { - {0x0003, "TURBOstor HFP-832 [HiPPI NIC]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_5654[] = { - {0x3132, "OpenSwitch12", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_6374[] = { - {0x6773, "GPPCI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_6666[] = { - {0x0001, "PCCOM4", NULL}, - {0x0002, "PCCOM8", NULL}, - {0x0004, "PCCOM2", NULL}, - {0x0101, "PCI 8255/8254 I/O Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_7063[] = { - {0x2000, "HD-2000", NULL}, - {0x3000, "HD-3000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_8008[] = { - {0x0010, "WDOG1 [PCI-Watchdog 1]", NULL}, - {0x0011, "PWDOG2 [PCI-Watchdog 2]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_8086[] = { - {0x0007, "82379AB", NULL}, - {0x0008, "Extended Express System Support Controller", NULL}, - {0x0039, "21145 Fast Ethernet", NULL}, - {0x0122, "82437FX", NULL}, - {0x0309, "80303 I/O Processor PCI-to-PCI Bridge", NULL}, - {0x030D, "80312 I/O Companion Chip PCI-to-PCI Bridge", NULL}, - {0x0326, "6700/6702PXH I/OxAPIC Interrupt Controller A", NULL}, - {0x0327, "6700PXH I/OxAPIC Interrupt Controller B", NULL}, - {0x0329, "6700PXH PCI Express-to-PCI Bridge A", NULL}, - {0x032A, "6700PXH PCI Express-to-PCI Bridge B", NULL}, - {0x032C, "6702PXH PCI Express-to-PCI Bridge A", NULL}, - {0x0330, "80332 [Dobson] I/O processor (A-Segment Bridge)", NULL}, - {0x0331, "80332 [Dobson] I/O processor (A-Segment IOAPIC)", NULL}, - {0x0332, "80332 [Dobson] I/O processor (B-Segment Bridge)", NULL}, - {0x0333, "80332 [Dobson] I/O processor (B-Segment IOAPIC)", NULL}, - {0x0334, "80332 [Dobson] I/O processor (ATU)", NULL}, - {0x0335, "80331 [Lindsay] I/O processor (PCI-X Bridge)", NULL}, - {0x0336, "80331 [Lindsay] I/O processor (ATU)", NULL}, - {0x0340, "41210 [Lanai] Serial to Parallel PCI Bridge (A-Segment Bridge)", NULL}, - {0x0341, "41210 [Lanai] Serial to Parallel PCI Bridge (B-Segment Bridge)", NULL}, - {0x0370, "80333 Segment-A PCI Express-to-PCI Express Bridge", NULL}, - {0x0371, "80333 A-Bus IOAPIC", NULL}, - {0x0372, "80333 Segment-B PCI Express-to-PCI Express Bridge", NULL}, - {0x0373, "80333 B-Bus IOAPIC", NULL}, - {0x0374, "80333 Address Translation Unit", NULL}, - {0x0482, "82375EB/SB PCI to EISA Bridge", NULL}, - {0x0483, "82424TX/ZX [Saturn] CPU to PCI bridge", NULL}, - {0x0484, "82378ZB/IB, 82379AB (SIO, SIO.A) PCI to ISA Bridge", NULL}, - {0x0486, "82425EX/ZX [Aries] PCIset with ISA bridge", NULL}, - {0x04A3, "82434LX/NX [Mercury/Neptune] Processor to PCI bridge", NULL}, - {0x04D0, "82437FX [Triton FX]", NULL}, - {0x0500, "E8870 Processor bus control", NULL}, - {0x0501, "E8870 Memory controller", NULL}, - {0x0502, "E8870 Scalability Port 0", NULL}, - {0x0503, "E8870 Scalability Port 1", NULL}, - {0x0510, "E8870IO Hub Interface Port 0 registers (8-bit compatibility port)", NULL}, - {0x0511, "E8870IO Hub Interface Port 1 registers", NULL}, - {0x0512, "E8870IO Hub Interface Port 2 registers", NULL}, - {0x0513, "E8870IO Hub Interface Port 3 registers", NULL}, - {0x0514, "E8870IO Hub Interface Port 4 registers", NULL}, - {0x0515, "E8870IO General SIOH registers", NULL}, - {0x0516, "E8870IO RAS registers", NULL}, - {0x0530, "E8870SP Scalability Port 0 registers", NULL}, - {0x0531, "E8870SP Scalability Port 1 registers", NULL}, - {0x0532, "E8870SP Scalability Port 2 registers", NULL}, - {0x0533, "E8870SP Scalability Port 3 registers", NULL}, - {0x0534, "E8870SP Scalability Port 4 registers", NULL}, - {0x0535, "E8870SP Scalability Port 5 registers", NULL}, - {0x0536, "E8870SP Interleave registers 0 and 1", NULL}, - {0x0537, "E8870SP Interleave registers 2 and 3", NULL}, - {0x0600, "RAID Controller", NULL}, - {0x061F, "80303 I/O Processor", NULL}, - {0x0960, "80960RP [i960 RP Microprocessor/Bridge]", NULL}, - {0x0962, "80960RM [i960RM Bridge]", NULL}, - {0x0964, "80960RP [i960 RP Microprocessor/Bridge]", NULL}, - {0x1000, "82542 Gigabit Ethernet Controller", NULL}, - {0x1001, "82543GC Gigabit Ethernet Controller (Fiber)", NULL}, - {0x1002, "Pro 100 LAN+Modem 56 Cardbus II", NULL}, - {0x1004, "82543GC Gigabit Ethernet Controller (Copper)", NULL}, - {0x1008, "82544EI Gigabit Ethernet Controller (Copper)", NULL}, - {0x1009, "82544EI Gigabit Ethernet Controller (Fiber)", NULL}, - {0x100A, "82540EM Gigabit Ethernet Controller", NULL}, - {0x100C, "82544GC Gigabit Ethernet Controller (Copper)", NULL}, - {0x100D, "82544GC Gigabit Ethernet Controller (LOM)", NULL}, - {0x100E, "82540EM Gigabit Ethernet Controller", NULL}, - {0x100F, "82545EM Gigabit Ethernet Controller (Copper)", NULL}, - {0x1010, "82546EB Gigabit Ethernet Controller (Copper)", NULL}, - {0x1011, "82545EM Gigabit Ethernet Controller (Fiber)", NULL}, - {0x1012, "82546EB Gigabit Ethernet Controller (Fiber)", NULL}, - {0x1013, "82541EI Gigabit Ethernet Controller (Copper)", NULL}, - {0x1014, "82541ER Gigabit Ethernet Controller", NULL}, - {0x1015, "82540EM Gigabit Ethernet Controller (LOM)", NULL}, - {0x1016, "82540EP Gigabit Ethernet Controller (LOM)", NULL}, - {0x1017, "82540EP Gigabit Ethernet Controller (LOM)", NULL}, - {0x1018, "82541EI Gigabit Ethernet Controller", NULL}, - {0x1019, "82547EI Gigabit Ethernet Controller (LOM)", NULL}, - {0x101A, "82547EI Gigabit Ethernet Controller (Mobile)", NULL}, - {0x101D, "82546EB Gigabit Ethernet Controller", NULL}, - {0x101E, "82540EP Gigabit Ethernet Controller (Mobile)", NULL}, - {0x1026, "82545GM Gigabit Ethernet Controller", NULL}, - {0x1027, "82545GM Gigabit Ethernet Controller", NULL}, - {0x1028, "82545GM Gigabit Ethernet Controller", NULL}, - {0x1029, "82559 Ethernet Controller", NULL}, - {0x1030, "82559 InBusiness 10/100", NULL}, - {0x1031, "82801CAM (ICH3) PRO/100 VE (LOM) Ethernet Controller", NULL}, - {0x1032, "82801CAM (ICH3) PRO/100 VE Ethernet Controller", NULL}, - {0x1033, "82801CAM (ICH3) PRO/100 VM (LOM) Ethernet Controller", NULL}, - {0x1034, "82801CAM (ICH3) PRO/100 VM Ethernet Controller", NULL}, - {0x1035, "82801CAM (ICH3)/82562EH (LOM) Ethernet Controller", NULL}, - {0x1036, "82801CAM (ICH3) 82562EH Ethernet Controller", NULL}, - {0x1037, "82801CAM (ICH3) Chipset Ethernet Controller", NULL}, - {0x1038, "82801CAM (ICH3) PRO/100 VM (KM) Ethernet Controller", NULL}, - {0x1039, "82801DB PRO/100 VE (LOM) Ethernet Controller", NULL}, - {0x103A, "82801DB PRO/100 VE (CNR) Ethernet Controller", NULL}, - {0x103B, "82801DB PRO/100 VM (LOM) Ethernet Controller", NULL}, - {0x103C, "82801DB PRO/100 VM (CNR) Ethernet Controller", NULL}, - {0x103D, "82801DB PRO/100 VE (MOB) Ethernet Controller", NULL}, - {0x103E, "82801DB PRO/100 VM (MOB) Ethernet Controller", NULL}, - {0x1040, "536EP Data Fax Modem", NULL}, - {0x1043, "PRO/Wireless LAN 2100 3B Mini PCI Adapter", NULL}, - {0x1048, "PRO/10GbE LR Server Adapter", NULL}, - {0x104B, "Ethernet Controller", NULL}, - {0x1050, "82562EZ 10/100 Ethernet Controller", NULL}, - {0x1051, "82801EB/ER (ICH5/ICH5R) integrated LAN Controller", NULL}, - {0x1052, "PRO/100 VM Network Connection", NULL}, - {0x1053, "PRO/100 VM Network Connection", NULL}, - {0x1059, "82551QM Ethernet Controller", NULL}, - {0x105E, "82571EB Gigabit Ethernet Controller", NULL}, - {0x105F, "82571EB Gigabit Ethernet Controller", NULL}, - {0x1060, "82571EB Gigabit Ethernet Controller", NULL}, - {0x1064, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller", NULL}, - {0x1065, "82562ET/EZ/GT/GZ - PRO/100 VE Ethernet Controller", NULL}, - {0x1066, "82562 EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller", NULL}, - {0x1067, "82562 EM/EX/GX - PRO/100 VM Ethernet Controller", NULL}, - {0x1068, "82562ET/EZ/GT/GZ - PRO/100 VE (LOM) Ethernet Controller Mobile", NULL}, - {0x1069, "82562EM/EX/GX - PRO/100 VM (LOM) Ethernet Controller Mobile", NULL}, - {0x106A, "82562G - PRO/100 VE (LOM) Ethernet Controller", NULL}, - {0x106B, "82562G - PRO/100 VE Ethernet Controller Mobile", NULL}, - {0x1075, "82547GI Gigabit Ethernet Controller", NULL}, - {0x1076, "82541GI/PI Gigabit Ethernet Controller", NULL}, - {0x1077, "82541GI Gigabit Ethernet Controller", NULL}, - {0x1078, "82541EI Gigabit Ethernet Controller", NULL}, - {0x1079, "82546GB Gigabit Ethernet Controller", NULL}, - {0x107A, "82546GB Gigabit Ethernet Controller", NULL}, - {0x107B, "82546GB Gigabit Ethernet Controller", NULL}, - {0x107C, "82541PI Gigabit Ethernet Controller", NULL}, - {0x107D, "82572EI Gigabit Ethernet Controller", NULL}, - {0x107E, "82572EI Gigabit Ethernet Controller", NULL}, - {0x107F, "82572EI Gigabit Ethernet Controller", NULL}, - {0x1080, "FA82537EP 56K V.92 Data/Fax Modem PCI", NULL}, - {0x1081, "Enterprise Southbridge LAN Copper", NULL}, - {0x1082, "Enterprise Southbridge LAN fiber", NULL}, - {0x1083, "Enterprise Southbridge LAN SERDES", NULL}, - {0x1084, "Enterprise Southbridge IDE Redirection", NULL}, - {0x1085, "Enterprise Southbridge Serial Port Redirection", NULL}, - {0x1086, "Enterprise Southbridge IPMI/KCS0", NULL}, - {0x1087, "Enterprise Southbridge UHCI Redirection", NULL}, - {0x1089, "Enterprise Southbridge BT", NULL}, - {0x108A, "82546EB Gigabit Ethernet Controller", NULL}, - {0x108B, "82573V Gigabit Ethernet Controller (Copper)", NULL}, - {0x108C, "82573E Gigabit Ethernet Controller (Copper)", NULL}, - {0x108E, "82573E KCS", NULL}, - {0x108F, "Intel(R) Active Management Technology - SOL", NULL}, - {0x1092, "Intel(R) PRO/100 VE Network Connection", NULL}, - {0x1096, "PRO/1000 EB Network Connection with I/O Acceleration", NULL}, - {0x1097, "Enterprise Southbridge DPT LAN fiber", NULL}, - {0x1098, "PRO/1000 EB Backplane Connection with I/O Acceleration", NULL}, - {0x1099, "82546GB Quad Port Server Adapter", NULL}, - {0x109A, "82573L Gigabit Ethernet Controller", NULL}, - {0x109B, "82546GB PRO/1000 GF Quad Port Server Adapter", NULL}, - {0x10A0, "82571EB PRO/1000 AT Quad Port Bypass Adapter", NULL}, - {0x10A1, "82571EB PRO/1000 AF Quad Port Bypass Adapter", NULL}, - {0x10B0, "82573L PRO/1000 PL Network Connection", NULL}, - {0x10B2, "82573V PRO/1000 PM Network Connection", NULL}, - {0x10B3, "82573E PRO/1000 PM Network Connection", NULL}, - {0x10B4, "82573L PRO/1000 PL Network Connection", NULL}, - {0x10B5, "82546GB PRO/1000 GT Quad Port Server Adapter", NULL}, - {0x1107, "PRO/1000 MF Server Adapter (LX)", NULL}, - {0x1130, "82815 815 Chipset Host Bridge and Memory Controller Hub", NULL}, - {0x1131, "82815 815 Chipset AGP Bridge", NULL}, - {0x1132, "82815 CGC [Chipset Graphics Controller]", NULL}, - {0x1161, "82806AA PCI64 Hub Advanced Programmable Interrupt Controller", NULL}, - {0x1162, "Xscale 80200 Big Endian Companion Chip", NULL}, - {0x1200, "Intel IXP1200 Network Processor", NULL}, - {0x1209, "8255xER/82551IT Fast Ethernet Controller", NULL}, - {0x1221, "82092AA PCI to PCMCIA Bridge", NULL}, - {0x1222, "82092AA IDE Controller", NULL}, - {0x1223, "SAA7116", NULL}, - {0x1225, "82452KX/GX [Orion]", NULL}, - {0x1226, "82596 PRO/10 PCI", NULL}, - {0x1227, "82865 EtherExpress PRO/100A", NULL}, - {0x1228, "82556 EtherExpress PRO/100 Smart", NULL}, - {0x1229, "82557/8/9 [Ethernet Pro 100]", NULL}, - {0x122D, "430FX - 82437FX TSC [Triton I]", NULL}, - {0x122E, "82371FB PIIX ISA [Triton I]", NULL}, - {0x1230, "82371FB PIIX IDE [Triton I]", NULL}, - {0x1231, "DSVD Modem", NULL}, - {0x1234, "430MX - 82371MX Mobile PCI I/O IDE Xcelerator (MPIIX)", NULL}, - {0x1235, "430MX - 82437MX Mob. System Ctrlr (MTSC) & 82438MX Data Path (MTDP)", NULL}, - {0x1237, "440FX - 82441FX PMC [Natoma]", NULL}, - {0x1239, "82371FB PIIX IDE Interface", NULL}, - {0x123B, "82380PB PCI to PCI Docking Bridge", NULL}, - {0x123C, "82380AB (MISA) Mobile PCI-to-ISA Bridge", NULL}, - {0x123D, "683053 Programmable Interrupt Device", NULL}, - {0x123E, "82466GX (IHPC) Integrated Hot-Plug Controller", NULL}, - {0x123F, "82466GX Integrated Hot-Plug Controller (IHPC)", NULL}, - {0x1240, "82752 (752) AGP Graphics Accelerator", NULL}, - {0x124B, "82380FB (MPCI2) Mobile Docking Controller", NULL}, - {0x1250, "430HX - 82439HX TXC [Triton II]", NULL}, - {0x1360, "82806AA PCI64 Hub PCI Bridge", NULL}, - {0x1361, "82806AA PCI64 Hub Controller (HRes)", NULL}, - {0x1460, "82870P2 P64H2 Hub PCI Bridge", NULL}, - {0x1461, "82870P2 P64H2 I/OxAPIC", NULL}, - {0x1462, "82870P2 P64H2 Hot Plug Controller", NULL}, - {0x1960, "80960RP [i960RP Microprocessor]", NULL}, - {0x1962, "80960RM [i960RM Microprocessor]", NULL}, - {0x1A21, "82840 840 (Carmel) Chipset Host Bridge (Hub A)", NULL}, - {0x1A23, "82840 840 (Carmel) Chipset AGP Bridge", NULL}, - {0x1A24, "82840 840 (Carmel) Chipset PCI Bridge (Hub B)", NULL}, - {0x1A30, "82845 845 (Brookdale) Chipset Host Bridge", NULL}, - {0x1A31, "82845 845 (Brookdale) Chipset AGP Bridge", NULL}, - {0x1A38, "Server DMA Controller", NULL}, - {0x1A48, "PRO/10GbE SR Server Adapter", NULL}, - {0x2410, "82801AA ISA Bridge (LPC)", NULL}, - {0x2411, "82801AA IDE", NULL}, - {0x2412, "82801AA USB", NULL}, - {0x2413, "82801AA SMBus", NULL}, - {0x2415, "82801AA AC'97 Audio", NULL}, - {0x2416, "82801AA AC'97 Modem", NULL}, - {0x2418, "82801AA PCI Bridge", NULL}, - {0x2420, "82801AB ISA Bridge (LPC)", NULL}, - {0x2421, "82801AB IDE", NULL}, - {0x2422, "82801AB USB", NULL}, - {0x2423, "82801AB SMBus", NULL}, - {0x2425, "82801AB AC'97 Audio", NULL}, - {0x2426, "82801AB AC'97 Modem", NULL}, - {0x2428, "82801AB PCI Bridge", NULL}, - {0x2440, "82801BA ISA Bridge (LPC)", NULL}, - {0x2442, "82801BA/BAM USB (Hub #1)", NULL}, - {0x2443, "82801BA/BAM SMBus", NULL}, - {0x2444, "82801BA/BAM USB (Hub #2)", NULL}, - {0x2445, "82801BA/BAM AC'97 Audio", NULL}, - {0x2446, "82801BA/BAM AC'97 Modem", NULL}, - {0x2448, "82801 Mobile PCI Bridge", NULL}, - {0x2449, "82801BA/BAM/CA/CAM Ethernet Controller", NULL}, - {0x244A, "82801BAM IDE U100", NULL}, - {0x244B, "82801BA IDE U100", NULL}, - {0x244C, "82801BAM ISA Bridge (LPC)", NULL}, - {0x244E, "82801 PCI Bridge", NULL}, - {0x2450, "82801E ISA Bridge (LPC)", NULL}, - {0x2452, "82801E USB", NULL}, - {0x2453, "82801E SMBus", NULL}, - {0x2459, "82801E Ethernet Controller 0", NULL}, - {0x245B, "82801E IDE U100", NULL}, - {0x245D, "82801E Ethernet Controller 1", NULL}, - {0x245E, "82801E PCI Bridge", NULL}, - {0x2480, "82801CA LPC Interface Controller", NULL}, - {0x2482, "82801CA/CAM USB (Hub #1)", NULL}, - {0x2483, "82801CA/CAM SMBus Controller", NULL}, - {0x2484, "82801CA/CAM USB (Hub #2)", NULL}, - {0x2485, "82801CA/CAM AC'97 Audio Controller", NULL}, - {0x2486, "82801CA/CAM AC'97 Modem Controller", NULL}, - {0x2487, "82801CA/CAM USB (Hub #3)", NULL}, - {0x248A, "82801CAM IDE U100", NULL}, - {0x248B, "82801CA Ultra ATA Storage Controller", NULL}, - {0x248C, "82801CAM ISA Bridge (LPC)", NULL}, - {0x24C0, "82801DB/DBL (ICH4/ICH4-L) LPC Interface Bridge", NULL}, - {0x24C1, "82801DBL (ICH4-L) IDE Controller", NULL}, - {0x24C2, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #1", NULL}, - {0x24C3, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) SMBus Controller", NULL}, - {0x24C4, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #2", NULL}, - {0x24C5, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller", NULL}, - {0x24C6, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Modem Controller", NULL}, - {0x24C7, "82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) USB UHCI Controller #3", NULL}, - {0x24CA, "82801DBM (ICH4-M) IDE Controller", NULL}, - {0x24CB, "82801DB (ICH4) IDE Controller", NULL}, - {0x24CC, "82801DBM (ICH4-M) LPC Interface Bridge", NULL}, - {0x24CD, "82801DB/DBM (ICH4/ICH4-M) USB2 EHCI Controller", NULL}, - {0x24D0, "82801EB/ER (ICH5/ICH5R) LPC Interface Bridge", NULL}, - {0x24D1, "82801EB (ICH5) SATA Controller", NULL}, - {0x24D2, "82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1", NULL}, - {0x24D3, "82801EB/ER (ICH5/ICH5R) SMBus Controller", NULL}, - {0x24D4, "82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2", NULL}, - {0x24D5, "82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller", NULL}, - {0x24D6, "82801EB/ER (ICH5/ICH5R) AC'97 Modem Controller", NULL}, - {0x24D7, "82801EB/ER (ICH5/ICH5R) USB UHCI Controller #3", NULL}, - {0x24DB, "82801EB/ER (ICH5/ICH5R) IDE Controller", NULL}, - {0x24DC, "82801EB (ICH5) LPC Interface Bridge", NULL}, - {0x24DD, "82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller", NULL}, - {0x24DE, "82801EB/ER (ICH5/ICH5R) USB UHCI Controller #4", NULL}, - {0x24DF, "82801ER (ICH5R) SATA Controller", NULL}, - {0x2500, "82820 820 (Camino) Chipset Host Bridge (MCH)", NULL}, - {0x2501, "82820 820 (Camino) Chipset Host Bridge (MCH)", NULL}, - {0x250B, "82820 820 (Camino) Chipset Host Bridge", NULL}, - {0x250F, "82820 820 (Camino) Chipset AGP Bridge", NULL}, - {0x2520, "82805AA MTH Memory Translator Hub", NULL}, - {0x2521, "82804AA MRH-S Memory Repeater Hub for SDRAM", NULL}, - {0x2530, "82850 850 (Tehama) Chipset Host Bridge (MCH)", NULL}, - {0x2531, "82860 860 (Wombat) Chipset Host Bridge (MCH)", NULL}, - {0x2532, "82850 850 (Tehama) Chipset AGP Bridge", NULL}, - {0x2533, "82860 860 (Wombat) Chipset AGP Bridge", NULL}, - {0x2534, "82860 860 (Wombat) Chipset PCI Bridge", NULL}, - {0x2540, "E7500 Memory Controller Hub", NULL}, - {0x2541, "E7500/E7501 Host RASUM Controller", NULL}, - {0x2543, "E7500/E7501 Hub Interface B PCI-to-PCI Bridge", NULL}, - {0x2544, "E7500/E7501 Hub Interface B RASUM Controller", NULL}, - {0x2545, "E7500/E7501 Hub Interface C PCI-to-PCI Bridge", NULL}, - {0x2546, "E7500/E7501 Hub Interface C RASUM Controller", NULL}, - {0x2547, "E7500/E7501 Hub Interface D PCI-to-PCI Bridge", NULL}, - {0x2548, "E7500/E7501 Hub Interface D RASUM Controller", NULL}, - {0x254C, "E7501 Memory Controller Hub", NULL}, - {0x2550, "E7505 Memory Controller Hub", NULL}, - {0x2551, "E7505/E7205 Series RAS Controller", NULL}, - {0x2552, "E7505/E7205 PCI-to-AGP Bridge", NULL}, - {0x2553, "E7505 Hub Interface B PCI-to-PCI Bridge", NULL}, - {0x2554, "E7505 Hub Interface B PCI-to-PCI Bridge RAS Controller", NULL}, - {0x255D, "E7205 Memory Controller Hub", NULL}, - {0x2560, "82845G/GL[Brookdale-G]/GE/PE DRAM Controller/Host-Hub Interface", NULL}, - {0x2561, "82845G/GL[Brookdale-G]/GE/PE Host-to-AGP Bridge", NULL}, - {0x2562, "82845G/GL[Brookdale-G]/GE Chipset Integrated Graphics Device", NULL}, - {0x2570, "82865G/PE/P DRAM Controller/Host-Hub Interface", NULL}, - {0x2571, "82865G/PE/P PCI to AGP Controller", NULL}, - {0x2572, "82865G Integrated Graphics Controller", NULL}, - {0x2573, "82865G/PE/P PCI to CSA Bridge", NULL}, - {0x2576, "82865G/PE/P Processor to I/O Memory Interface", NULL}, - {0x2578, "82875P/E7210 Memory Controller Hub", NULL}, - {0x2579, "82875P Processor to AGP Controller", NULL}, - {0x257B, "82875P/E7210 Processor to PCI to CSA Bridge", NULL}, - {0x257E, "82875P/E7210 Processor to I/O Memory Interface", NULL}, - {0x2580, "915G/P/GV/GL/PL/910GL Express Memory Controller Hub", NULL}, - {0x2581, "915G/P/GV/GL/PL/910GL Express PCI Express Root Port", NULL}, - {0x2582, "82915G/GV/910GL Express Chipset Family Graphics Controller", NULL}, - {0x2584, "925X/XE Express Memory Controller Hub", NULL}, - {0x2585, "925X/XE Express PCI Express Root Port", NULL}, - {0x2588, "E7220/E7221 Memory Controller Hub", NULL}, - {0x2589, "E7220/E7221 PCI Express Root Port", NULL}, - {0x258A, "E7221 Integrated Graphics Controller", NULL}, - {0x2590, "Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller", NULL}, - {0x2591, "Mobile 915GM/PM Express PCI Express Root Port", NULL}, - {0x2592, "Mobile 915GM/GMS/910GML Express Graphics Controller", NULL}, - {0x25A1, "6300ESB LPC Interface Controller", NULL}, - {0x25A2, "6300ESB PATA Storage Controller", NULL}, - {0x25A3, "6300ESB SATA Storage Controller", NULL}, - {0x25A4, "6300ESB SMBus Controller", NULL}, - {0x25A6, "6300ESB AC'97 Audio Controller", NULL}, - {0x25A7, "6300ESB AC'97 Modem Controller", NULL}, - {0x25A9, "6300ESB USB Universal Host Controller", NULL}, - {0x25AA, "6300ESB USB Universal Host Controller", NULL}, - {0x25AB, "6300ESB Watchdog Timer", NULL}, - {0x25AC, "6300ESB I/O Advanced Programmable Interrupt Controller", NULL}, - {0x25AD, "6300ESB USB2 Enhanced Host Controller", NULL}, - {0x25AE, "6300ESB 64-bit PCI-X Bridge", NULL}, - {0x25B0, "6300ESB SATA RAID Controller", NULL}, - {0x25C0, "Workstation Memory Controller Hub", NULL}, - {0x25D0, "Server Memory Controller Hub", NULL}, - {0x25D4, "Server Memory Contoller Hub", NULL}, - {0x25D8, "Server Memory Controller Hub", NULL}, - {0x25E2, "Server PCI Express x4 Port 2", NULL}, - {0x25E3, "Server PCI Express x4 Port 3", NULL}, - {0x25E4, "Server PCI Express x4 Port 4", NULL}, - {0x25E5, "Server PCI Express x4 Port 5", NULL}, - {0x25E6, "Server PCI Express x4 Port 6", NULL}, - {0x25E7, "Server PCI Express x4 Port 7", NULL}, - {0x25E8, "Server AMB Memory Mapped Registers", NULL}, - {0x25F0, "Server Error Reporting Registers", NULL}, - {0x25F1, "Reserved Registers", NULL}, - {0x25F3, "Reserved Registers", NULL}, - {0x25F5, "Server FBD Registers", NULL}, - {0x25F6, "Server FBD Registers", NULL}, - {0x25F7, "Server PCI Express x8 Port 2-3", NULL}, - {0x25F8, "Server PCI Express x8 Port 4-5", NULL}, - {0x25F9, "Server PCI Express x8 Port 6-7", NULL}, - {0x25FA, "Server PCI Express x16 Port 4-7", NULL}, - {0x2600, "E8500/E8501 Hub Interface 1.5", NULL}, - {0x2601, "E8500/E8501 PCI Express x4 Port D", NULL}, - {0x2602, "E8500/E8501 PCI Express x4 Port C0", NULL}, - {0x2603, "E8500/E8501 PCI Express x4 Port C1", NULL}, - {0x2604, "E8500/E8501 PCI Express x4 Port B0", NULL}, - {0x2605, "E8500/E8501 PCI Express x4 Port B1", NULL}, - {0x2606, "E8500/E8501 PCI Express x4 Port A0", NULL}, - {0x2607, "E8500/E8501 PCI Express x4 Port A1", NULL}, - {0x2608, "E8500/E8501 PCI Express x8 Port C", NULL}, - {0x2609, "E8500/E8501 PCI Express x8 Port B", NULL}, - {0x260A, "E8500/E8501 PCI Express x8 Port A", NULL}, - {0x260C, "E8500/E8501 IMI Registers", NULL}, - {0x2610, "E8500/E8501 Front Side Bus, Boot, and Interrupt Registers", NULL}, - {0x2611, "E8500/E8501 Address Mapping Registers", NULL}, - {0x2612, "E8500/E8501 RAS Registers", NULL}, - {0x2613, "E8500/E8501 Reserved Registers", NULL}, - {0x2614, "E8500/E8501 Reserved Registers", NULL}, - {0x2615, "E8500/E8501 Miscellaneous Registers", NULL}, - {0x2617, "E8500/E8501 Reserved Registers", NULL}, - {0x2618, "E8500/E8501 Reserved Registers", NULL}, - {0x2619, "E8500/E8501 Reserved Registers", NULL}, - {0x261A, "E8500/E8501 Reserved Registers", NULL}, - {0x261B, "E8500/E8501 Reserved Registers", NULL}, - {0x261C, "E8500/E8501 Reserved Registers", NULL}, - {0x261D, "E8500/E8501 Reserved Registers", NULL}, - {0x261E, "E8500/E8501 Reserved Registers", NULL}, - {0x2620, "E8500/E8501 eXternal Memory Bridge", NULL}, - {0x2621, "E8500/E8501 XMB Miscellaneous Registers", NULL}, - {0x2622, "E8500/E8501 XMB Memory Interleaving Registers", NULL}, - {0x2623, "E8500/E8501 XMB DDR Initialization and Calibration", NULL}, - {0x2624, "E8500/E8501 XMB Reserved Registers", NULL}, - {0x2625, "E8500/E8501 XMB Reserved Registers", NULL}, - {0x2626, "E8500/E8501 XMB Reserved Registers", NULL}, - {0x2627, "E8500/E8501 XMB Reserved Registers", NULL}, - {0x2640, "82801FB/FR (ICH6/ICH6R) LPC Interface Bridge", NULL}, - {0x2641, "82801FBM (ICH6M) LPC Interface Bridge", NULL}, - {0x2642, "82801FW/FRW (ICH6W/ICH6RW) LPC Interface Bridge", NULL}, - {0x2651, "82801FB/FW (ICH6/ICH6W) SATA Controller", NULL}, - {0x2652, "82801FR/FRW (ICH6R/ICH6RW) SATA Controller", NULL}, - {0x2653, "82801FBM (ICH6M) SATA Controller", NULL}, - {0x2658, "82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1", NULL}, - {0x2659, "82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2", NULL}, - {0x265A, "82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3", NULL}, - {0x265B, "82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4", NULL}, - {0x265C, "82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller", NULL}, - {0x2660, "82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1", NULL}, - {0x2662, "82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 2", NULL}, - {0x2664, "82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 3", NULL}, - {0x2666, "82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 4", NULL}, - {0x2668, "82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller", NULL}, - {0x266A, "82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller", NULL}, - {0x266C, "82801FB/FBM/FR/FW/FRW (ICH6 Family) LAN Controller", NULL}, - {0x266D, "82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller", NULL}, - {0x266E, "82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller", NULL}, - {0x266F, "82801FB/FBM/FR/FW/FRW (ICH6 Family) IDE Controller", NULL}, - {0x2670, "Enterprise Southbridge LPC", NULL}, - {0x2680, "Enterprise Southbridge SATA IDE", NULL}, - {0x2681, "Enterprise Southbridge SATA AHCI", NULL}, - {0x2682, "Enterprise Southbridge SATA RAID", NULL}, - {0x2683, "Enterprise Southbridge SATA RAID", NULL}, - {0x2688, "Enterprise Southbridge UHCI USB #1", NULL}, - {0x2689, "Enterprise Southbridge UHCI USB #2", NULL}, - {0x268A, "Enterprise Southbridge UHCI USB #3", NULL}, - {0x268B, "Enterprise Southbridge UHCI USB #4", NULL}, - {0x268C, "Enterprise Southbridge EHCI USB", NULL}, - {0x2690, "Enterprise Southbridge PCI Express Root Port 1", NULL}, - {0x2692, "Enterprise Southbridge PCI Express Root Port 2", NULL}, - {0x2694, "Enterprise Southbridge PCI Express Root Port 3", NULL}, - {0x2696, "Enterprise Southbridge PCI Express Root Port 4", NULL}, - {0x2698, "Enterprise Southbridge AC '97 Audio", NULL}, - {0x2699, "Enterprise Southbridge AC '97 Modem", NULL}, - {0x269A, "Enterprise Southbridge High Definition Audio", NULL}, - {0x269B, "Enterprise Southbridge SMBus", NULL}, - {0x269E, "Enterprise Southbridge PATA", NULL}, - {0x2770, "945G/GZ/P/PL Express Memory Controller Hub", NULL}, - {0x2771, "945G/GZ/P/PL Express PCI Express Root Port", NULL}, - {0x2772, "945G/GZ Express Integrated Graphics Controller", NULL}, - {0x2774, "955X Express Memory Controller Hub", NULL}, - {0x2775, "955X Express PCI Express Root Port", NULL}, - {0x2776, "945G/GZ Express Integrated Graphics Controller", NULL}, - {0x2778, "E7230 Memory Controller Hub", NULL}, - {0x2779, "E7230 PCI Express Root Port", NULL}, - {0x277A, "975X Express PCI Express Root Port", NULL}, - {0x277C, "975X Express Memory Controller Hub", NULL}, - {0x277D, "975X Express PCI Express Root Port", NULL}, - {0x2782, "82915G Express Chipset Family Graphics Controller", NULL}, - {0x2792, "Mobile 915GM/GMS/910GML Express Graphics Controller", NULL}, - {0x27A0, "Mobile 945GM/PM/GMS/940GML and 945GT Express Memory Controller Hub", NULL}, - {0x27A1, "Mobile 945GM/PM/GMS/940GML and 945GT Express PCI Express Root Port", NULL}, - {0x27A2, "Mobile 945GM/GMS/940GML Express Integrated Graphics Controller", NULL}, - {0x27A6, "Mobile 945GM/GMS/940GML Express Integrated Graphics Controller", NULL}, - {0x27B0, "82801GH (ICH7DH) LPC Interface Bridge", NULL}, - {0x27B8, "82801GB/GR (ICH7 Family) LPC Interface Bridge", NULL}, - {0x27B9, "82801GBM (ICH7-M) LPC Interface Bridge", NULL}, - {0x27BD, "82801GHM (ICH7-M DH) LPC Interface Bridge", NULL}, - {0x27C0, "82801GB/GR/GH (ICH7 Family) Serial ATA Storage Controller IDE", NULL}, - {0x27C1, "82801GR/GH (ICH7 Family) Serial ATA Storage Controller AHCI", NULL}, - {0x27C3, "82801GR/GH (ICH7 Family) Serial ATA Storage Controller RAID", NULL}, - {0x27C4, "82801GBM/GHM (ICH7 Family) Serial ATA Storage Controller IDE", NULL}, - {0x27C5, "82801GBM/GHM (ICH7 Family) Serial ATA Storage Controller AHCI", NULL}, - {0x27C6, "82801GHM (ICH7-M DH) Serial ATA Storage Controller RAID", NULL}, - {0x27C8, "82801G (ICH7 Family) USB UHCI #1", NULL}, - {0x27C9, "82801G (ICH7 Family) USB UHCI #2", NULL}, - {0x27CA, "82801G (ICH7 Family) USB UHCI #3", NULL}, - {0x27CB, "82801G (ICH7 Family) USB UHCI #4", NULL}, - {0x27CC, "82801G (ICH7 Family) USB2 EHCI Controller", NULL}, - {0x27D0, "82801G (ICH7 Family) PCI Express Port 1", NULL}, - {0x27D2, "82801G (ICH7 Family) PCI Express Port 2", NULL}, - {0x27D4, "82801G (ICH7 Family) PCI Express Port 3", NULL}, - {0x27D6, "82801G (ICH7 Family) PCI Express Port 4", NULL}, - {0x27D8, "82801G (ICH7 Family) High Definition Audio Controller", NULL}, - {0x27DA, "82801G (ICH7 Family) SMBus Controller", NULL}, - {0x27DC, "82801G (ICH7 Family) LAN Controller", NULL}, - {0x27DD, "82801G (ICH7 Family) AC'97 Modem Controller", NULL}, - {0x27DE, "82801G (ICH7 Family) AC'97 Audio Controller", NULL}, - {0x27DF, "82801G (ICH7 Family) IDE Controller", NULL}, - {0x27E0, "82801GR/GH/GHM (ICH7 Family) PCI Express Port 5", NULL}, - {0x27E2, "82801GR/GH/GHM (ICH7 Family) PCI Express Port 6", NULL}, - {0x2810, "LPC Interface Controller", NULL}, - {0x2811, "Mobile LPC Interface Controller", NULL}, - {0x2812, "LPC Interface Controller", NULL}, - {0x2814, "LPC Interface Controller", NULL}, - {0x2815, "Mobile LPC Interface Controller", NULL}, - {0x2820, "SATA Controller 1 IDE", NULL}, - {0x2821, "SATA Controller AHCI", NULL}, - {0x2822, "SATA Controller RAID", NULL}, - {0x2824, "SATA Controller AHCI", NULL}, - {0x2825, "SATA Controller 2 IDE", NULL}, - {0x2828, "Mobile SATA Controller IDE", NULL}, - {0x2829, "Mobile SATA Controller AHCI", NULL}, - {0x282A, "Mobile SATA Controller RAID", NULL}, - {0x2830, "USB UHCI Controller #1", NULL}, - {0x2831, "USB UHCI Controller #2", NULL}, - {0x2832, "USB UHCI Controller #3", NULL}, - {0x2834, "USB UHCI Controller #4", NULL}, - {0x2835, "USB UHCI Controller #5", NULL}, - {0x2836, "USB2 EHCI Controller #1", NULL}, - {0x283A, "USB2 EHCI Controller #2", NULL}, - {0x283E, "SMBus Controller", NULL}, - {0x283F, "PCI Express Port 1", NULL}, - {0x2841, "PCI Express Port 2", NULL}, - {0x2843, "PCI Express Port 3", NULL}, - {0x2845, "PCI Express Port 4", NULL}, - {0x2847, "PCI Express Port 5", NULL}, - {0x2849, "PCI Express Port 6", NULL}, - {0x284B, "HD Audio Controller", NULL}, - {0x284F, "Thermal Subsystem", NULL}, - {0x2850, "Mobile IDE Controller", NULL}, - {0x2970, "Memory Controller Hub", NULL}, - {0x2971, "PCI Express Root Port", NULL}, - {0x2972, "Integrated Graphics Controller", NULL}, - {0x2973, "Integrated Graphics Controller", NULL}, - {0x2974, "HECI Controller", NULL}, - {0x2976, "PT IDER Controller", NULL}, - {0x2977, "KT Controller", NULL}, - {0x2990, "Memory Controller Hub", NULL}, - {0x2991, "PCI Express Root Port", NULL}, - {0x2992, "Integrated Graphics Controller", NULL}, - {0x2993, "Integrated Graphics Controller", NULL}, - {0x2994, "HECI Controller", NULL}, - {0x2995, "HECI Controller", NULL}, - {0x2996, "PT IDER Controller", NULL}, - {0x2997, "KT Controller", NULL}, - {0x29A0, "Memory Controller Hub", NULL}, - {0x29A1, "PCI Express Root Port", NULL}, - {0x29A2, "Integrated Graphics Controller", NULL}, - {0x29A3, "Integrated Graphics Controller", NULL}, - {0x29A4, "HECI Controller", NULL}, - {0x29A5, "HECI Controller", NULL}, - {0x29A6, "PT IDER Controller", NULL}, - {0x29A7, "KT Controller", NULL}, - {0x3092, "Integrated RAID", NULL}, - {0x3200, "GD31244 PCI-X SATA HBA", NULL}, - {0x3340, "82855PM Processor to I/O Controller", NULL}, - {0x3341, "82855PM Processor to AGP Controller", NULL}, - {0x3500, "Enterprise Southbridge PCI Express Upstream Port", NULL}, - {0x3501, "Enterprise Southbridge PCI Express Upstream Port", NULL}, - {0x3504, "Enterprise Southbridge IOxAPIC", NULL}, - {0x3505, "Enterprise Southbridge IOxAPIC", NULL}, - {0x350C, "Enterprise Southbridge PCI Express to PCI-X Bridge", NULL}, - {0x350D, "Enterprise Southbridge PCI Express to PCI-X Bridge", NULL}, - {0x3510, "Enterprise Southbridge PCI Express Downstream Port E1", NULL}, - {0x3511, "Enterprise Southbridge PCI Express Downstream Port E1", NULL}, - {0x3514, "Enterprise Southbridge PCI Express Downstream Port E2", NULL}, - {0x3515, "Enterprise Southbridge PCI Express Downstream Port E2", NULL}, - {0x3518, "Enterprise Southbridge PCI Express Downstream Port E3", NULL}, - {0x3519, "Enterprise Southbridge PCI Express Downstream Port E3", NULL}, - {0x3575, "82830 830 Chipset Host Bridge", NULL}, - {0x3576, "82830 830 Chipset AGP Bridge", NULL}, - {0x3577, "82830 CGC [Chipset Graphics Controller]", NULL}, - {0x3578, "82830 830 Chipset Host Bridge", NULL}, - {0x3580, "82852/82855 GM/GME/PM/GMV Processor to I/O Controller", NULL}, - {0x3581, "82852/82855 GM/GME/PM/GMV Processor to AGP Controller", NULL}, - {0x3582, "82852/855GM Integrated Graphics Device", NULL}, - {0x3584, "82852/82855 GM/GME/PM/GMV Processor to I/O Controller", NULL}, - {0x3585, "82852/82855 GM/GME/PM/GMV Processor to I/O Controller", NULL}, - {0x3590, "E7520 Memory Controller Hub", NULL}, - {0x3591, "E7525/E7520 Error Reporting Registers", NULL}, - {0x3592, "E7320 Memory Controller Hub", NULL}, - {0x3593, "E7320 Error Reporting Registers", NULL}, - {0x3594, "E7520 DMA Controller", NULL}, - {0x3595, "E7525/E7520/E7320 PCI Express Port A", NULL}, - {0x3596, "E7525/E7520/E7320 PCI Express Port A1", NULL}, - {0x3597, "E7525/E7520 PCI Express Port B", NULL}, - {0x3598, "E7520 PCI Express Port B1", NULL}, - {0x3599, "E7520 PCI Express Port C", NULL}, - {0x359A, "E7520 PCI Express Port C1", NULL}, - {0x359B, "E7525/E7520/E7320 Extended Configuration Registers", NULL}, - {0x359E, "E7525 Memory Controller Hub", NULL}, - {0x4220, "PRO/Wireless 2200BG Network Connection", NULL}, - {0x4222, "PRO/Wireless 3945ABG Network Connection", NULL}, - {0x4223, "PRO/Wireless 2915ABG Network Connection", NULL}, - {0x4224, "PRO/Wireless 2915ABG Network Connection", NULL}, - {0x4227, "PRO/Wireless 3945ABG Network Connection", NULL}, - {0x5200, "EtherExpress PRO/100 Intelligent Server", NULL}, - {0x5201, "EtherExpress PRO/100 Intelligent Server", NULL}, - {0x530D, "80310 IOP [IO Processor]", NULL}, - {0x7000, "82371SB PIIX3 ISA [Natoma/Triton II]", NULL}, - {0x7010, "82371SB PIIX3 IDE [Natoma/Triton II]", NULL}, - {0x7020, "82371SB PIIX3 USB [Natoma/Triton II]", NULL}, - {0x7030, "430VX - 82437VX TVX [Triton VX]", NULL}, - {0x7050, "Intercast Video Capture Card", NULL}, - {0x7051, "PB 642365-003 (Business Video Conferencing Card)", NULL}, - {0x7100, "430TX - 82439TX MTXC", NULL}, - {0x7110, "82371AB/EB/MB PIIX4 ISA", NULL}, - {0x7111, "82371AB/EB/MB PIIX4 IDE", NULL}, - {0x7112, "82371AB/EB/MB PIIX4 USB", NULL}, - {0x7113, "82371AB/EB/MB PIIX4 ACPI", NULL}, - {0x7120, "82810 GMCH [Graphics Memory Controller Hub]", NULL}, - {0x7121, "82810 CGC [Chipset Graphics Controller]", NULL}, - {0x7122, "82810 DC-100 GMCH [Graphics Memory Controller Hub]", NULL}, - {0x7123, "82810 DC-100 CGC [Chipset Graphics Controller]", NULL}, - {0x7124, "82810E DC-133 GMCH [Graphics Memory Controller Hub]", NULL}, - {0x7125, "82810E DC-133 CGC [Chipset Graphics Controller]", NULL}, - {0x7126, "82810 DC-133 System and Graphics Controller", NULL}, - {0x7128, "82810-M DC-100 System and Graphics Controller", NULL}, - {0x712A, "82810-M DC-133 System and Graphics Controller", NULL}, - {0x7180, "440LX/EX - 82443LX/EX Host bridge", NULL}, - {0x7181, "440LX/EX - 82443LX/EX AGP bridge", NULL}, - {0x7190, "440BX/ZX/DX - 82443BX/ZX/DX Host bridge", NULL}, - {0x7191, "440BX/ZX/DX - 82443BX/ZX/DX AGP bridge", NULL}, - {0x7192, "440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled)", NULL}, - {0x7194, "82440MX Host Bridge", NULL}, - {0x7195, "82440MX AC'97 Audio Controller", NULL}, - {0x7196, "82440MX AC'97 Modem Controller", NULL}, - {0x7198, "82440MX ISA Bridge", NULL}, - {0x7199, "82440MX EIDE Controller", NULL}, - {0x719A, "82440MX USB Universal Host Controller", NULL}, - {0x719B, "82440MX Power Management Controller", NULL}, - {0x71A0, "440GX - 82443GX Host bridge", NULL}, - {0x71A1, "440GX - 82443GX AGP bridge", NULL}, - {0x71A2, "440GX - 82443GX Host bridge (AGP disabled)", NULL}, - {0x7600, "82372FB PIIX5 ISA", NULL}, - {0x7601, "82372FB PIIX5 IDE", NULL}, - {0x7602, "82372FB PIIX5 USB", NULL}, - {0x7603, "82372FB PIIX5 SMBus", NULL}, - {0x7800, "82740 (i740) AGP Graphics Accelerator", NULL}, - {0x84C4, "450KX/GX [Orion] - 82454KX/GX PCI bridge", NULL}, - {0x84C5, "450KX/GX [Orion] - 82453KX/GX Memory controller", NULL}, - {0x84CA, "450NX - 82451NX Memory & I/O Controller", NULL}, - {0x84CB, "450NX - 82454NX/84460GX PCI Expander Bridge", NULL}, - {0x84E0, "460GX - 84460GX System Address Controller (SAC)", NULL}, - {0x84E1, "460GX - 84460GX System Data Controller (SDC)", NULL}, - {0x84E2, "460GX - 84460GX AGP Bridge (GXB function 2)", NULL}, - {0x84E3, "460GX - 84460GX Memory Address Controller (MAC)", NULL}, - {0x84E4, "460GX - 84460GX Memory Data Controller (MDC)", NULL}, - {0x84E6, "460GX - 82466GX Wide and fast PCI eXpander Bridge (WXB)", NULL}, - {0x84EA, "460GX - 84460GX AGP Bridge (GXB function 1)", NULL}, - {0x8500, "IXP4XX Intel Network Processor (IXP420/421/422/425/IXC1100)", NULL}, - {0x9000, "IXP2000 Family Network Processor", NULL}, - {0x9001, "IXP2400 Network Processor", NULL}, - {0x9002, "IXP2300 Network Processor", NULL}, - {0x9004, "IXP2800 Network Processor", NULL}, - {0x9621, "Integrated RAID", NULL}, - {0x9622, "Integrated RAID", NULL}, - {0x9641, "Integrated RAID", NULL}, - {0x96A1, "Integrated RAID", NULL}, - {0xB152, "21152 PCI-to-PCI Bridge", NULL}, - {0xB154, "21154 PCI-to-PCI Bridge", NULL}, - {0xB555, "21555 Non transparent PCI-to-PCI Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_8800[] = { - {0x2008, "Video assistent component", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_8C4A[] = { - {0x1980, "W89C940 misprogrammed [ne2k]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_8E2E[] = { - {0x3000, "ET32P2", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9004[] = { - {0x0078, "AHA-2940U_CN", NULL}, - {0x1078, "AIC-7810", NULL}, - {0x1160, "AIC-1160 [Family Fibre Channel Adapter]", NULL}, - {0x2178, "AIC-7821", NULL}, - {0x3860, "AHA-2930CU", NULL}, - {0x3B78, "AHA-4844W/4844UW", NULL}, - {0x5075, "AIC-755x", NULL}, - {0x5078, "AHA-7850", NULL}, - {0x5175, "AIC-755x", NULL}, - {0x5178, "AIC-7851", NULL}, - {0x5275, "AIC-755x", NULL}, - {0x5278, "AIC-7852", NULL}, - {0x5375, "AIC-755x", NULL}, - {0x5378, "AIC-7850", NULL}, - {0x5475, "AIC-755x", NULL}, - {0x5478, "AIC-7850", NULL}, - {0x5575, "AVA-2930", NULL}, - {0x5578, "AIC-7855", NULL}, - {0x5647, "ANA-7711 TCP Offload Engine", NULL}, - {0x5675, "AIC-755x", NULL}, - {0x5678, "AIC-7856", NULL}, - {0x5775, "AIC-755x", NULL}, - {0x5778, "AIC-7850", NULL}, - {0x5800, "AIC-5800", NULL}, - {0x5900, "ANA-5910/5930/5940 ATM155 & 25 LAN Adapter", NULL}, - {0x5905, "ANA-5910A/5930A/5940A ATM Adapter", NULL}, - {0x6038, "AIC-3860", NULL}, - {0x6075, "AIC-1480 / APA-1480", NULL}, - {0x6078, "AIC-7860", NULL}, - {0x6178, "AIC-7861", NULL}, - {0x6278, "AIC-7860", NULL}, - {0x6378, "AIC-7860", NULL}, - {0x6478, "AIC-786x", NULL}, - {0x6578, "AIC-786x", NULL}, - {0x6678, "AIC-786x", NULL}, - {0x6778, "AIC-786x", NULL}, - {0x6915, "ANA620xx/ANA69011A", NULL}, - {0x7078, "AHA-294x / AIC-7870", NULL}, - {0x7178, "AHA-2940/2940W / AIC-7871", NULL}, - {0x7278, "AHA-3940/3940W / AIC-7872", NULL}, - {0x7378, "AHA-3985 / AIC-7873", NULL}, - {0x7478, "AHA-2944/2944W / AIC-7874", NULL}, - {0x7578, "AHA-3944/3944W / AIC-7875", NULL}, - {0x7678, "AHA-4944W/UW / AIC-7876", NULL}, - {0x7710, "ANA-7711F Network Accelerator Card (NAC) - Optical", NULL}, - {0x7711, "ANA-7711C Network Accelerator Card (NAC) - Copper", NULL}, - {0x7778, "AIC-787x", NULL}, - {0x7810, "AIC-7810", NULL}, - {0x7815, "AIC-7815 RAID+Memory Controller IC", NULL}, - {0x7850, "AIC-7850", NULL}, - {0x7855, "AHA-2930", NULL}, - {0x7860, "AIC-7860", NULL}, - {0x7870, "AIC-7870", NULL}, - {0x7871, "AHA-2940", NULL}, - {0x7872, "AHA-3940", NULL}, - {0x7873, "AHA-3980", NULL}, - {0x7874, "AHA-2944", NULL}, - {0x7880, "AIC-7880P", NULL}, - {0x7890, "AIC-7890", NULL}, - {0x7891, "AIC-789x", NULL}, - {0x7892, "AIC-789x", NULL}, - {0x7893, "AIC-789x", NULL}, - {0x7894, "AIC-789x", NULL}, - {0x7895, "AHA-2940U/UW / AHA-39xx / AIC-7895", NULL}, - {0x7896, "AIC-789x", NULL}, - {0x7897, "AIC-789x", NULL}, - {0x8078, "AIC-7880U", NULL}, - {0x8178, "AHA-2940U/UW/D / AIC-7881U", NULL}, - {0x8278, "AHA-3940U/UW/UWD / AIC-7882U", NULL}, - {0x8378, "AHA-3940U/UW / AIC-7883U", NULL}, - {0x8478, "AHA-2944UW / AIC-7884U", NULL}, - {0x8578, "AHA-3944U/UWD / AIC-7885", NULL}, - {0x8678, "AHA-4944UW / AIC-7886", NULL}, - {0x8778, "AHA-2940UW Pro / AIC-788x", NULL}, - {0x8878, "AHA-2930UW / AIC-7888", NULL}, - {0x8B78, "ABA-1030", NULL}, - {0xEC78, "AHA-4944W/UW", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9005[] = { - {0x0010, "AHA-2940U2/U2W", NULL}, - {0x0011, "AHA-2930U2", NULL}, - {0x0013, "78902", NULL}, - {0x001F, "AHA-2940U2/U2W / 7890/7891", NULL}, - {0x0020, "AIC-7890", NULL}, - {0x002F, "AIC-7890", NULL}, - {0x0030, "AIC-7890", NULL}, - {0x003F, "AIC-7890", NULL}, - {0x0050, "AHA-3940U2x/395U2x", NULL}, - {0x0051, "AHA-3950U2D", NULL}, - {0x0053, "AIC-7896 SCSI Controller", NULL}, - {0x005F, "AIC-7896U2/7897U2", NULL}, - {0x0080, "AIC-7892A U160/m", NULL}, - {0x0081, "AIC-7892B U160/m", NULL}, - {0x0083, "AIC-7892D U160/m", NULL}, - {0x008F, "AIC-7892P U160/m", NULL}, - {0x00C0, "AHA-3960D / AIC-7899A U160/m", NULL}, - {0x00C1, "AIC-7899B U160/m", NULL}, - {0x00C3, "AIC-7899D U160/m", NULL}, - {0x00C5, "RAID subsystem HBA", NULL}, - {0x00CF, "AIC-7899P U160/m", NULL}, - {0x0241, "Serial ATA II RAID 1420SA", NULL}, - {0x0250, "ServeRAID Controller", NULL}, - {0x0279, "ServeRAID 6M", NULL}, - {0x0283, "AAC-RAID", NULL}, - {0x0284, "AAC-RAID", NULL}, - {0x0285, "AAC-RAID", NULL}, - {0x0286, "AAC-RAID (Rocket)", NULL}, - {0x0500, "Obsidian chipset SCSI controller", NULL}, - {0x0503, "Scamp chipset SCSI controller", NULL}, - {0x0910, "AUA-3100B", NULL}, - {0x091E, "AUA-3100B", NULL}, - {0x8000, "ASC-29320A U320", NULL}, - {0x800F, "AIC-7901 U320", NULL}, - {0x8010, "ASC-39320 U320", NULL}, - {0x8011, "ASC-39320D", NULL}, - {0x8012, "ASC-29320 U320", NULL}, - {0x8013, "ASC-29320B U320", NULL}, - {0x8014, "ASC-29320LP U320", NULL}, - {0x8015, "ASC-39320B U320", NULL}, - {0x8016, "ASC-39320A U320", NULL}, - {0x8017, "ASC-29320ALP U320", NULL}, - {0x801C, "ASC-39320D U320", NULL}, - {0x801D, "AIC-7902B U320", NULL}, - {0x801E, "AIC-7901A U320", NULL}, - {0x801F, "AIC-7902 U320", NULL}, - {0x8080, "ASC-29320A U320 w/HostRAID", NULL}, - {0x808F, "AIC-7901 U320 w/HostRAID", NULL}, - {0x8090, "ASC-39320 U320 w/HostRAID", NULL}, - {0x8091, "ASC-39320D U320 w/HostRAID", NULL}, - {0x8092, "ASC-29320 U320 w/HostRAID", NULL}, - {0x8093, "ASC-29320B U320 w/HostRAID", NULL}, - {0x8094, "ASC-29320LP U320 w/HostRAID", NULL}, - {0x8095, "ASC-39320(B) U320 w/HostRAID", NULL}, - {0x8096, "ASC-39320A U320 w/HostRAID", NULL}, - {0x8097, "ASC-29320ALP U320 w/HostRAID", NULL}, - {0x809C, "ASC-39320D(B) U320 w/HostRAID", NULL}, - {0x809D, "AIC-7902(B) U320 w/HostRAID", NULL}, - {0x809E, "AIC-7901A U320 w/HostRAID", NULL}, - {0x809F, "AIC-7902 U320 w/HostRAID", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_907F[] = { - {0x2015, "IDE-2015PL", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9412[] = { - {0x6565, "6565", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9699[] = { - {0x6565, "6565", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9710[] = { - {0x7780, "USB IRDA-port", NULL}, - {0x9805, "PCI 1 port parallel adapter", NULL}, - {0x9815, "PCI 9815 Multi-I/O Controller", NULL}, - {0x9835, "PCI 9835 Multi-I/O Controller", NULL}, - {0x9845, "PCI 9845 Multi-I/O Controller", NULL}, - {0x9855, "PCI 9855 Multi-I/O Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_9902[] = { - {0x0001, "SG2010 PCI over Starfabric Bridge", NULL}, - {0x0002, "SG2010 PCI to Starfabric Gateway", NULL}, - {0x0003, "SG1010 Starfabric Switch and PCI Bridge", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_A727[] = { - {0x0013, "3CRPAG175 Wireless PC Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_AECB[] = { - {0x6250, "VITC/LTC Timecode Reader card [PCI-VLTC/RDR]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_AFFE[] = { - {0xDEAD, "Sirrix.PCI4S0 4-port ISDN S0 interface", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_CAFE[] = { - {0x0003, "Luna K3 Hardware Security Module", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_CDDD[] = { - {0x0101, "DeepSea 1 High Speed Stereo Vision Frame Grabber", NULL}, - {0x0200, "DeepSea 2 High Speed Stereo Vision Frame Grabber", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_D161[] = { - {0x0205, "Wildcard TE205P", NULL}, - {0x0210, "Wildcard TE210P", NULL}, - {0x0405, "Wildcard TE405P (2nd Gen)", NULL}, - {0x0410, "Wildcard TE410P (2nd Gen)", NULL}, - {0x2400, "Wildcard TDM2400P", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_D4D4[] = { - {0x0601, "PCI Mezzanine Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_DEAF[] = { - {0x9050, "PC Weasel Virtual VGA", NULL}, - {0x9051, "PC Weasel Serial Port", NULL}, - {0x9052, "PC Weasel Watchdog Timer", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_E000[] = { - {0xE000, "W89C940", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_E159[] = { - {0x0001, "Tiger3XX Modem/ISDN interface", NULL}, - {0x0002, "Tiger100APC ISDN chipset", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_EA01[] = { - {0x000A, "PCI-773 Temperature Card", NULL}, - {0x0032, "PCI-730 & PC104P-30 Card", NULL}, - {0x003E, "PCI-762 Opto-Isolator Card", NULL}, - {0x0041, "PCI-763 Reed Relay Card", NULL}, - {0x0043, "PCI-769 Opto-Isolator Reed Relay Combo Card", NULL}, - {0x0046, "PCI-766 Analog Output Card", NULL}, - {0x0052, "PCI-703 Analog I/O Card", NULL}, - {0x0800, "PCI-800 Digital I/O Card", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_EA60[] = { - {0x9896, "Digi32", NULL}, - {0x9897, "Digi32 Pro", NULL}, - {0x9898, "Digi32/8", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_EACE[] = { - {0x3100, "DAG 3.10 OC-3/OC-12", NULL}, - {0x3200, "DAG 3.2x OC-3/OC-12", NULL}, - {0x320E, "DAG 3.2E Fast Ethernet", NULL}, - {0x340E, "DAG 3.4E Fast Ethernet", NULL}, - {0x341E, "DAG 3.41E Fast Ethernet", NULL}, - {0x3500, "DAG 3.5 OC-3/OC-12", NULL}, - {0x351C, "DAG 3.5ECM Fast Ethernet", NULL}, - {0x4100, "DAG 4.10 OC-48", NULL}, - {0x4110, "DAG 4.11 OC-48", NULL}, - {0x4220, "DAG 4.2 OC-48", NULL}, - {0x422E, "DAG 4.2E Dual Gigabit Ethernet", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_EC80[] = { - {0xEC00, "F5D6000", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_EDD8[] = { - {0xA091, "1000PV [Stingray]", NULL}, - {0xA099, "2000PV [Stingray]", NULL}, - {0xA0A1, "2000MT", NULL}, - {0xA0A9, "2000MI", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_F1D0[] = { - {0xC0FE, "Xena HS/HD-R", NULL}, - {0xC0FF, "Kona/Xena 2", NULL}, - {0xCAFE, "Kona SD", NULL}, - {0xCFEE, "Xena LS/SD-22-DA/SD-DA", NULL}, - {0xDCAF, "Kona HD", NULL}, - {0xDFEE, "Xena HD-DA", NULL}, - {0xEFAC, "Xena SD-MM/SD-22-MM", NULL}, - {0xFACD, "Xena HD-MM", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FA57[] = { - {0x0001, "PMC [Pattern Matching Chip]", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FEDA[] = { - {0xA0FA, "BCM4210 iLine10 HomePNA 2.0", NULL}, - {0xA10E, "BCM4230 iLine10 HomePNA 2.0", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FEDE[] = { - {0x0003, "TABIC PCI v3", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FFFD[] = { - {0x0101, "PCI Event Channel Controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FFFE[] = { - {0x0405, "Virtual SVGA 4.0", NULL}, - {0x0710, "Virtual SVGA", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor_FFFF[] = { - {0x0000, "Non-VGA unclassified device", NULL}, - {0x0001, "VGA compatible unclassified device", NULL}, - {0x0000, "SCSI storage controller", NULL}, - {0x0001, "IDE interface", NULL}, - {0x0002, "Floppy disk controller", NULL}, - {0x0003, "IPI bus controller", NULL}, - {0x0004, "RAID bus controller", NULL}, - {0x0005, "ATA controller", NULL}, - {0x0006, "SATA controller", NULL}, - {0x0007, "Serial Attached SCSI controller", NULL}, - {0x0080, "Mass storage controller", NULL}, - {0x0000, "Ethernet controller", NULL}, - {0x0001, "Token ring network controller", NULL}, - {0x0002, "FDDI network controller", NULL}, - {0x0003, "ATM network controller", NULL}, - {0x0004, "ISDN controller", NULL}, - {0x0080, "Network controller", NULL}, - {0x0000, "VGA compatible controller", NULL}, - {0x0001, "XGA compatible controller", NULL}, - {0x0002, "3D controller", NULL}, - {0x0080, "Display controller", NULL}, - {0x0000, "Multimedia video controller", NULL}, - {0x0001, "Multimedia audio controller", NULL}, - {0x0002, "Computer telephony device", NULL}, - {0x0003, "Audio device", NULL}, - {0x0080, "Multimedia controller", NULL}, - {0x0000, "RAM memory", NULL}, - {0x0001, "FLASH memory", NULL}, - {0x0080, "Memory controller", NULL}, - {0x0000, "Host bridge", NULL}, - {0x0001, "ISA bridge", NULL}, - {0x0002, "EISA bridge", NULL}, - {0x0003, "MicroChannel bridge", NULL}, - {0x0004, "PCI bridge", NULL}, - {0x0005, "PCMCIA bridge", NULL}, - {0x0006, "NuBus bridge", NULL}, - {0x0007, "CardBus bridge", NULL}, - {0x0008, "RACEway bridge", NULL}, - {0x0009, "Semi-transparent PCI-to-PCI bridge", NULL}, - {0x000A, "InfiniBand to PCI host bridge", NULL}, - {0x0080, "Bridge", NULL}, - {0x0000, "Serial controller", NULL}, - {0x0001, "Parallel controller", NULL}, - {0x0002, "Multiport serial controller", NULL}, - {0x0003, "Modem", NULL}, - {0x0080, "Communication controller", NULL}, - {0x0000, "PIC", NULL}, - {0x0001, "DMA controller", NULL}, - {0x0002, "Timer", NULL}, - {0x0003, "RTC", NULL}, - {0x0004, "PCI Hot-plug controller", NULL}, - {0x0080, "System peripheral", NULL}, - {0x0000, "Keyboard controller", NULL}, - {0x0001, "Digitizer Pen", NULL}, - {0x0002, "Mouse controller", NULL}, - {0x0003, "Scanner controller", NULL}, - {0x0004, "Gameport controller", NULL}, - {0x0080, "Input device controller", NULL}, - {0x0000, "Generic Docking Station", NULL}, - {0x0080, "Docking Station", NULL}, - {0x0000, "386", NULL}, - {0x0001, "486", NULL}, - {0x0002, "Pentium", NULL}, - {0x0010, "Alpha", NULL}, - {0x0020, "Power PC", NULL}, - {0x0030, "MIPS", NULL}, - {0x0040, "Co-processor", NULL}, - {0x0000, "FireWire (IEEE 1394)", NULL}, - {0x0001, "ACCESS Bus", NULL}, - {0x0002, "SSA", NULL}, - {0x0003, "USB Controller", NULL}, - {0x0004, "Fibre Channel", NULL}, - {0x0005, "SMBus", NULL}, - {0x0006, "InfiniBand", NULL}, - {0x0000, "IRDA controller", NULL}, - {0x0001, "Consumer IR controller", NULL}, - {0x0010, "RF controller", NULL}, - {0x0080, "Wireless controller", NULL}, - {0x0000, "I2O", NULL}, - {0x0000, "Satellite TV controller", NULL}, - {0x0001, "Satellite audio communication controller", NULL}, - {0x0003, "Satellite voice communication controller", NULL}, - {0x0004, "Satellite data communication controller", NULL}, - {0x0000, "Network and computing encryption device", NULL}, - {0x0010, "Entertainment encryption device", NULL}, - {0x0080, "Encryption controller", NULL}, - {0x0000, "DPIO module", NULL}, - {0x0001, "Performance counters", NULL}, - {0x0010, "Communication synchronizer", NULL}, - {0x0080, "Signal processing controller", NULL}, - {0x0000, "", NULL}, -}; - -pci_desc tab_vendor[] = { -{0x0000, "Gammagraphx, Inc.", NULL}, -{0x001A, "Ascend Communications, Inc.", NULL}, -{0x0033, "Paradyne corp.", NULL}, -{0x003D, "Lockheed Martin-Marietta Corp", NULL}, -{0x0059, "Tiger Jet Network Inc. (Wrong ID)", NULL}, -{0x0070, "Hauppauge computer works Inc.", NULL}, -{0x0071, "Nebula Electronics Ltd.", NULL}, -{0x0095, "Silicon Image, Inc. (Wrong ID)", tab_vendor_0095}, -{0x00A7, "Teles AG (Wrong ID)", NULL}, -{0x0100, "Ncipher Corp Ltd", NULL}, -{0x018A, "LevelOne", tab_vendor_018A}, -{0x021B, "Compaq Computer Corporation", tab_vendor_021B}, -{0x0270, "Hauppauge computer works Inc. (Wrong ID)", NULL}, -{0x0291, "Davicom Semiconductor, Inc.", tab_vendor_0291}, -{0x02AC, "SpeedStream", tab_vendor_02AC}, -{0x0357, "TTTech AG", tab_vendor_0357}, -{0x0432, "SCM Microsystems, Inc.", tab_vendor_0432}, -{0x045E, "Microsoft", tab_vendor_045E}, -{0x04CF, "Myson Century, Inc", tab_vendor_04CF}, -{0x050D, "Belkin", tab_vendor_050D}, -{0x05E3, "CyberDoor", tab_vendor_05E3}, -{0x066F, "Sigmatel Inc.", NULL}, -{0x0675, "Dynalink", tab_vendor_0675}, -{0x067B, "Prolific Technology, Inc.", tab_vendor_067B}, -{0x0721, "Sapphire, Inc.", NULL}, -{0x07E2, "ELMEG Communication Systems GmbH", NULL}, -{0x0925, "VIA Technologies, Inc. (Wrong ID)", NULL}, -{0x09C1, "Arris", tab_vendor_09C1}, -{0x0A89, "BREA Technologies Inc", NULL}, -{0x0B49, "ASCII Corporation", tab_vendor_0B49}, -{0x0E11, "Compaq Computer Corporation", tab_vendor_0E11}, -{0x0E55, "HaSoTec GmbH", NULL}, -{0x1000, "LSI Logic / Symbios Logic", tab_vendor_1000}, -{0x1001, "Kolter Electronic", tab_vendor_1001}, -{0x1002, "ATI Technologies Inc", tab_vendor_1002}, -{0x1003, "ULSI Systems", tab_vendor_1003}, -{0x1004, "VLSI Technology Inc", tab_vendor_1004}, -{0x1005, "Avance Logic Inc. [ALI]", tab_vendor_1005}, -{0x1006, "Reply Group", NULL}, -{0x1007, "NetFrame Systems Inc", NULL}, -{0x1008, "Epson", NULL}, -{0x100A, "Phoenix Technologies", NULL}, -{0x100B, "National Semiconductor Corporation", tab_vendor_100B}, -{0x100C, "Tseng Labs Inc", tab_vendor_100C}, -{0x100D, "AST Research Inc", NULL}, -{0x100E, "Weitek", tab_vendor_100E}, -{0x1010, "Video Logic, Ltd.", NULL}, -{0x1011, "Digital Equipment Corporation", tab_vendor_1011}, -{0x1012, "Micronics Computers Inc", NULL}, -{0x1013, "Cirrus Logic", tab_vendor_1013}, -{0x1014, "IBM", tab_vendor_1014}, -{0x1015, "LSI Logic Corp of Canada", NULL}, -{0x1016, "ICL Personal Systems", NULL}, -{0x1017, "SPEA Software AG", tab_vendor_1017}, -{0x1018, "Unisys Systems", NULL}, -{0x1019, "Elitegroup Computer Systems", NULL}, -{0x101A, "AT&T GIS (NCR)", tab_vendor_101A}, -{0x101B, "Vitesse Semiconductor", NULL}, -{0x101C, "Western Digital", tab_vendor_101C}, -{0x101E, "American Megatrends Inc.", tab_vendor_101E}, -{0x101F, "PictureTel", NULL}, -{0x1020, "Hitachi Computer Products", NULL}, -{0x1021, "OKI Electric Industry Co. Ltd.", NULL}, -{0x1022, "Advanced Micro Devices [AMD]", tab_vendor_1022}, -{0x1023, "Trident Microsystems", tab_vendor_1023}, -{0x1024, "Zenith Data Systems", NULL}, -{0x1025, "Acer Incorporated [ALI]", tab_vendor_1025}, -{0x1028, "Dell", tab_vendor_1028}, -{0x1029, "Siemens Nixdorf IS", NULL}, -{0x102A, "LSI Logic", tab_vendor_102A}, -{0x102B, "Matrox Graphics, Inc.", tab_vendor_102B}, -{0x102C, "Chips and Technologies", tab_vendor_102C}, -{0x102D, "Wyse Technology Inc.", tab_vendor_102D}, -{0x102E, "Olivetti Advanced Technology", NULL}, -{0x102F, "Toshiba America", tab_vendor_102F}, -{0x1030, "TMC Research", NULL}, -{0x1031, "Miro Computer Products AG", tab_vendor_1031}, -{0x1032, "Compaq", NULL}, -{0x1033, "NEC Corporation", tab_vendor_1033}, -{0x1034, "Framatome Connectors USA Inc.", NULL}, -{0x1035, "Comp. & Comm. Research Lab", NULL}, -{0x1036, "Future Domain Corp.", tab_vendor_1036}, -{0x1037, "Hitachi Micro Systems", NULL}, -{0x1038, "AMP, Inc", NULL}, -{0x1039, "Silicon Integrated Systems [SiS]", tab_vendor_1039}, -{0x103A, "Seiko Epson Corporation", NULL}, -{0x103B, "Tatung Co. of America", NULL}, -{0x103C, "Hewlett-Packard Company", tab_vendor_103C}, -{0x103E, "Solliday Engineering", NULL}, -{0x103F, "Synopsys/Logic Modeling Group", NULL}, -{0x1040, "Accelgraphics Inc.", NULL}, -{0x1041, "Computrend", NULL}, -{0x1042, "Micron", tab_vendor_1042}, -{0x1043, "ASUSTeK Computer Inc.", tab_vendor_1043}, -{0x1044, "Adaptec (formerly DPT)", tab_vendor_1044}, -{0x1045, "OPTi Inc.", tab_vendor_1045}, -{0x1046, "IPC Corporation, Ltd.", NULL}, -{0x1047, "Genoa Systems Corp", NULL}, -{0x1048, "Elsa AG", tab_vendor_1048}, -{0x1049, "Fountain Technologies, Inc.", NULL}, -{0x104A, "STMicroelectronics", tab_vendor_104A}, -{0x104B, "BusLogic", tab_vendor_104B}, -{0x104C, "Texas Instruments", tab_vendor_104C}, -{0x104D, "Sony Corporation", tab_vendor_104D}, -{0x104E, "Oak Technology, Inc", tab_vendor_104E}, -{0x104F, "Co-time Computer Ltd", NULL}, -{0x1050, "Winbond Electronics Corp", tab_vendor_1050}, -{0x1051, "Anigma, Inc.", NULL}, -{0x1052, "?Young Micro Systems", NULL}, -{0x1053, "Young Micro Systems", NULL}, -{0x1054, "Hitachi, Ltd", NULL}, -{0x1055, "Efar Microsystems", tab_vendor_1055}, -{0x1056, "ICL", NULL}, -{0x1057, "Motorola", tab_vendor_1057}, -{0x1058, "Electronics & Telecommunications RSH", NULL}, -{0x1059, "Teknor Industrial Computers Inc", NULL}, -{0x105A, "Promise Technology, Inc.", tab_vendor_105A}, -{0x105B, "Foxconn International, Inc.", NULL}, -{0x105C, "Wipro Infotech Limited", NULL}, -{0x105D, "Number 9 Computer Company", tab_vendor_105D}, -{0x105E, "Vtech Computers Ltd", NULL}, -{0x105F, "Infotronic America Inc", NULL}, -{0x1060, "United Microelectronics [UMC]", tab_vendor_1060}, -{0x1061, "I.I.T.", tab_vendor_1061}, -{0x1062, "Maspar Computer Corp", NULL}, -{0x1063, "Ocean Office Automation", NULL}, -{0x1064, "Alcatel", NULL}, -{0x1065, "Texas Microsystems", NULL}, -{0x1066, "PicoPower Technology", tab_vendor_1066}, -{0x1067, "Mitsubishi Electric", tab_vendor_1067}, -{0x1068, "Diversified Technology", NULL}, -{0x1069, "Mylex Corporation", tab_vendor_1069}, -{0x106A, "Aten Research Inc", NULL}, -{0x106B, "Apple Computer Inc.", tab_vendor_106B}, -{0x106C, "Hynix Semiconductor", tab_vendor_106C}, -{0x106D, "Sequent Computer Systems", NULL}, -{0x106E, "DFI, Inc", NULL}, -{0x106F, "City Gate Development Ltd", NULL}, -{0x1070, "Daewoo Telecom Ltd", NULL}, -{0x1071, "Mitac", tab_vendor_1071}, -{0x1072, "GIT Co Ltd", NULL}, -{0x1073, "Yamaha Corporation", tab_vendor_1073}, -{0x1074, "NexGen Microsystems", tab_vendor_1074}, -{0x1075, "Advanced Integrations Research", NULL}, -{0x1076, "Chaintech Computer Co. Ltd", NULL}, -{0x1077, "QLogic Corp.", tab_vendor_1077}, -{0x1078, "Cyrix Corporation", tab_vendor_1078}, -{0x1079, "I-Bus", NULL}, -{0x107A, "NetWorth", NULL}, -{0x107B, "Gateway 2000", NULL}, -{0x107C, "LG Electronics [Lucky Goldstar Co. Ltd]", NULL}, -{0x107D, "LeadTek Research Inc.", tab_vendor_107D}, -{0x107E, "Interphase Corporation", tab_vendor_107E}, -{0x107F, "Data Technology Corporation", tab_vendor_107F}, -{0x1080, "Contaq Microsystems", tab_vendor_1080}, -{0x1081, "Supermac Technology", tab_vendor_1081}, -{0x1082, "EFA Corporation of America", NULL}, -{0x1083, "Forex Computer Corporation", tab_vendor_1083}, -{0x1084, "Parador", NULL}, -{0x1085, "Tulip Computers Int.B.V.", NULL}, -{0x1086, "J. Bond Computer Systems", NULL}, -{0x1087, "Cache Computer", NULL}, -{0x1088, "Microcomputer Systems (M) Son", NULL}, -{0x1089, "Data General Corporation", NULL}, -{0x108A, "SBS Technologies", tab_vendor_108A}, -{0x108C, "Oakleigh Systems Inc.", NULL}, -{0x108D, "Olicom", tab_vendor_108D}, -{0x108E, "Sun Microsystems Computer Corp.", tab_vendor_108E}, -{0x108F, "Systemsoft", NULL}, -{0x1090, "Compro Computer Services, Inc.", NULL}, -{0x1091, "Intergraph Corporation", tab_vendor_1091}, -{0x1092, "Diamond Multimedia Systems", tab_vendor_1092}, -{0x1093, "National Instruments", tab_vendor_1093}, -{0x1094, "First International Computers [FIC]", NULL}, -{0x1095, "Silicon Image, Inc.", tab_vendor_1095}, -{0x1096, "Alacron", NULL}, -{0x1097, "Appian Technology", NULL}, -{0x1098, "Quantum Designs (H.K.) Ltd", tab_vendor_1098}, -{0x1099, "Samsung Electronics Co., Ltd", NULL}, -{0x109A, "Packard Bell", NULL}, -{0x109B, "Gemlight Computer Ltd.", NULL}, -{0x109C, "Megachips Corporation", NULL}, -{0x109D, "Zida Technologies Ltd.", NULL}, -{0x109E, "Brooktree Corporation", tab_vendor_109E}, -{0x109F, "Trigem Computer Inc.", NULL}, -{0x10A0, "Meidensha Corporation", NULL}, -{0x10A1, "Juko Electronics Ind. Co. Ltd", NULL}, -{0x10A2, "Quantum Corporation", NULL}, -{0x10A3, "Everex Systems Inc", NULL}, -{0x10A4, "Globe Manufacturing Sales", NULL}, -{0x10A5, "Smart Link Ltd.", tab_vendor_10A5}, -{0x10A6, "Informtech Industrial Ltd.", NULL}, -{0x10A7, "Benchmarq Microelectronics", NULL}, -{0x10A8, "Sierra Semiconductor", tab_vendor_10A8}, -{0x10A9, "Silicon Graphics, Inc.", tab_vendor_10A9}, -{0x10AA, "ACC Microelectronics", tab_vendor_10AA}, -{0x10AB, "Digicom", NULL}, -{0x10AC, "Honeywell IAC", NULL}, -{0x10AD, "Symphony Labs", tab_vendor_10AD}, -{0x10AE, "Cornerstone Technology", NULL}, -{0x10AF, "Micro Computer Systems Inc", NULL}, -{0x10B0, "CardExpert Technology", NULL}, -{0x10B1, "Cabletron Systems Inc", NULL}, -{0x10B2, "Raytheon Company", NULL}, -{0x10B3, "Databook Inc", tab_vendor_10B3}, -{0x10B4, "STB Systems Inc", tab_vendor_10B4}, -{0x10B5, "PLX Technology, Inc.", tab_vendor_10B5}, -{0x10B6, "Madge Networks", tab_vendor_10B6}, -{0x10B7, "3Com Corporation", tab_vendor_10B7}, -{0x10B8, "Standard Microsystems Corp [SMC]", tab_vendor_10B8}, -{0x10B9, "ALi Corporation", tab_vendor_10B9}, -{0x10BA, "Mitsubishi Electric Corp.", tab_vendor_10BA}, -{0x10BB, "Dapha Electronics Corporation", NULL}, -{0x10BC, "Advanced Logic Research", NULL}, -{0x10BD, "Surecom Technology", tab_vendor_10BD}, -{0x10BE, "Tseng Labs International Co.", NULL}, -{0x10BF, "Most Inc", NULL}, -{0x10C0, "Boca Research Inc.", NULL}, -{0x10C1, "ICM Co., Ltd.", NULL}, -{0x10C2, "Auspex Systems Inc.", NULL}, -{0x10C3, "Samsung Semiconductors, Inc.", tab_vendor_10C3}, -{0x10C4, "Award Software International Inc.", NULL}, -{0x10C5, "Xerox Corporation", NULL}, -{0x10C6, "Rambus Inc.", NULL}, -{0x10C7, "Media Vision", NULL}, -{0x10C8, "Neomagic Corporation", tab_vendor_10C8}, -{0x10C9, "Dataexpert Corporation", NULL}, -{0x10CA, "Fujitsu Microelectr., Inc.", NULL}, -{0x10CB, "Omron Corporation", NULL}, -{0x10CC, "Mai Logic Incorporated", tab_vendor_10CC}, -{0x10CD, "Advanced System Products, Inc", tab_vendor_10CD}, -{0x10CE, "Radius", NULL}, -{0x10CF, "Fujitsu Limited.", tab_vendor_10CF}, -{0x10D1, "FuturePlus Systems Corp.", NULL}, -{0x10D2, "Molex Incorporated", NULL}, -{0x10D3, "Jabil Circuit Inc", NULL}, -{0x10D4, "Hualon Microelectronics", NULL}, -{0x10D5, "Autologic Inc.", NULL}, -{0x10D6, "Cetia", NULL}, -{0x10D7, "BCM Advanced Research", NULL}, -{0x10D8, "Advanced Peripherals Labs", NULL}, -{0x10D9, "Macronix, Inc. [MXIC]", tab_vendor_10D9}, -{0x10DA, "Compaq IPG-Austin", tab_vendor_10DA}, -{0x10DB, "Rohm LSI Systems, Inc.", NULL}, -{0x10DC, "CERN/ECP/EDU", tab_vendor_10DC}, -{0x10DD, "Evans & Sutherland", tab_vendor_10DD}, -{0x10DE, "nVidia Corporation", tab_vendor_10DE}, -{0x10DF, "Emulex Corporation", tab_vendor_10DF}, -{0x10E0, "Integrated Micro Solutions Inc.", tab_vendor_10E0}, -{0x10E1, "Tekram Technology Co.,Ltd.", tab_vendor_10E1}, -{0x10E2, "Aptix Corporation", NULL}, -{0x10E3, "Tundra Semiconductor Corp.", tab_vendor_10E3}, -{0x10E4, "Tandem Computers", tab_vendor_10E4}, -{0x10E5, "Micro Industries Corporation", NULL}, -{0x10E6, "Gainbery Computer Products Inc.", NULL}, -{0x10E7, "Vadem", NULL}, -{0x10E8, "Applied Micro Circuits Corp.", tab_vendor_10E8}, -{0x10E9, "Alps Electric Co., Ltd.", NULL}, -{0x10EA, "Intergraphics Systems", tab_vendor_10EA}, -{0x10EB, "Artists Graphics", tab_vendor_10EB}, -{0x10EC, "Realtek Semiconductor Co., Ltd.", tab_vendor_10EC}, -{0x10ED, "Ascii Corporation", tab_vendor_10ED}, -{0x10EE, "Xilinx Corporation", tab_vendor_10EE}, -{0x10EF, "Racore Computer Products, Inc.", tab_vendor_10EF}, -{0x10F0, "Peritek Corporation", NULL}, -{0x10F1, "Tyan Computer", NULL}, -{0x10F2, "Achme Computer, Inc.", NULL}, -{0x10F3, "Alaris, Inc.", NULL}, -{0x10F4, "S-MOS Systems, Inc.", NULL}, -{0x10F5, "NKK Corporation", tab_vendor_10F5}, -{0x10F6, "Creative Electronic Systems SA", NULL}, -{0x10F7, "Matsushita Electric Industrial Co., Ltd.", NULL}, -{0x10F8, "Altos India Ltd", NULL}, -{0x10F9, "PC Direct", NULL}, -{0x10FA, "Truevision", tab_vendor_10FA}, -{0x10FB, "Thesys Gesellschaft fuer Mikroelektronik mbH", tab_vendor_10FB}, -{0x10FC, "I-O Data Device, Inc.", tab_vendor_10FC}, -{0x10FD, "Soyo Computer, Inc", NULL}, -{0x10FE, "Fast Multimedia AG", NULL}, -{0x10FF, "NCube", NULL}, -{0x1100, "Jazz Multimedia", NULL}, -{0x1101, "Initio Corporation", tab_vendor_1101}, -{0x1102, "Creative Labs", tab_vendor_1102}, -{0x1103, "Triones Technologies, Inc.", tab_vendor_1103}, -{0x1104, "RasterOps Corp.", NULL}, -{0x1105, "Sigma Designs, Inc.", tab_vendor_1105}, -{0x1106, "VIA Technologies, Inc.", tab_vendor_1106}, -{0x1107, "Stratus Computers", tab_vendor_1107}, -{0x1108, "Proteon, Inc.", tab_vendor_1108}, -{0x1109, "Cogent Data Technologies, Inc.", tab_vendor_1109}, -{0x110A, "Siemens Nixdorf AG", tab_vendor_110A}, -{0x110B, "Chromatic Research Inc.", tab_vendor_110B}, -{0x110C, "Mini-Max Technology, Inc.", NULL}, -{0x110D, "Znyx Advanced Systems", NULL}, -{0x110E, "CPU Technology", NULL}, -{0x110F, "Ross Technology", NULL}, -{0x1110, "Powerhouse Systems", tab_vendor_1110}, -{0x1111, "Santa Cruz Operation", NULL}, -{0x1112, "Osicom Technologies Inc", tab_vendor_1112}, -{0x1113, "Accton Technology Corporation", tab_vendor_1113}, -{0x1114, "Atmel Corporation", tab_vendor_1114}, -{0x1115, "3D Labs", NULL}, -{0x1116, "Data Translation", tab_vendor_1116}, -{0x1117, "Datacube, Inc", tab_vendor_1117}, -{0x1118, "Berg Electronics", NULL}, -{0x1119, "ICP Vortex Computersysteme GmbH", tab_vendor_1119}, -{0x111A, "Efficient Networks, Inc", tab_vendor_111A}, -{0x111B, "Teledyne Electronic Systems", NULL}, -{0x111C, "Tricord Systems Inc.", tab_vendor_111C}, -{0x111D, "Integrated Device Technology, Inc.", tab_vendor_111D}, -{0x111E, "Eldec", NULL}, -{0x111F, "Precision Digital Images", tab_vendor_111F}, -{0x1120, "EMC Corporation", NULL}, -{0x1121, "Zilog", NULL}, -{0x1122, "Multi-tech Systems, Inc.", NULL}, -{0x1123, "Excellent Design, Inc.", NULL}, -{0x1124, "Leutron Vision AG", NULL}, -{0x1125, "Eurocore", NULL}, -{0x1126, "Vigra", NULL}, -{0x1127, "FORE Systems Inc", tab_vendor_1127}, -{0x1129, "Firmworks", NULL}, -{0x112A, "Hermes Electronics Company, Ltd.", NULL}, -{0x112B, "Linotype - Hell AG", NULL}, -{0x112C, "Zenith Data Systems", NULL}, -{0x112D, "Ravicad", NULL}, -{0x112E, "Infomedia Microelectronics Inc.", NULL}, -{0x112F, "Imaging Technology Inc", tab_vendor_112F}, -{0x1130, "Computervision", NULL}, -{0x1131, "Philips Semiconductors", tab_vendor_1131}, -{0x1132, "Mitel Corp.", NULL}, -{0x1133, "Eicon Networks Corporation", tab_vendor_1133}, -{0x1134, "Mercury Computer Systems", tab_vendor_1134}, -{0x1135, "Fuji Xerox Co Ltd", tab_vendor_1135}, -{0x1136, "Momentum Data Systems", NULL}, -{0x1137, "Cisco Systems Inc", NULL}, -{0x1138, "Ziatech Corporation", tab_vendor_1138}, -{0x1139, "Dynamic Pictures, Inc", tab_vendor_1139}, -{0x113A, "FWB Inc", NULL}, -{0x113B, "Network Computing Devices", NULL}, -{0x113C, "Cyclone Microsystems, Inc.", tab_vendor_113C}, -{0x113D, "Leading Edge Products Inc", NULL}, -{0x113E, "Sanyo Electric Co - Computer Engineering Dept", NULL}, -{0x113F, "Equinox Systems, Inc.", tab_vendor_113F}, -{0x1140, "Intervoice Inc", NULL}, -{0x1141, "Crest Microsystem Inc", NULL}, -{0x1142, "Alliance Semiconductor Corporation", tab_vendor_1142}, -{0x1143, "NetPower, Inc", NULL}, -{0x1144, "Cincinnati Milacron", tab_vendor_1144}, -{0x1145, "Workbit Corporation", tab_vendor_1145}, -{0x1146, "Force Computers", NULL}, -{0x1147, "Interface Corp", NULL}, -{0x1148, "SysKonnect", tab_vendor_1148}, -{0x1149, "Win System Corporation", NULL}, -{0x114A, "VMIC", tab_vendor_114A}, -{0x114B, "Canopus Co., Ltd", NULL}, -{0x114C, "Annabooks", NULL}, -{0x114D, "IC Corporation", NULL}, -{0x114E, "Nikon Systems Inc", NULL}, -{0x114F, "Digi International", tab_vendor_114F}, -{0x1150, "Thinking Machines Corp", NULL}, -{0x1151, "JAE Electronics Inc.", NULL}, -{0x1152, "Megatek", NULL}, -{0x1153, "Land Win Electronic Corp", NULL}, -{0x1154, "Melco Inc", NULL}, -{0x1155, "Pine Technology Ltd", NULL}, -{0x1156, "Periscope Engineering", NULL}, -{0x1157, "Avsys Corporation", NULL}, -{0x1158, "Voarx R & D Inc", tab_vendor_1158}, -{0x1159, "Mutech Corp", tab_vendor_1159}, -{0x115A, "Harlequin Ltd", NULL}, -{0x115B, "Parallax Graphics", NULL}, -{0x115C, "Photron Ltd.", NULL}, -{0x115D, "Xircom", tab_vendor_115D}, -{0x115E, "Peer Protocols Inc", NULL}, -{0x115F, "Maxtor Corporation", NULL}, -{0x1160, "Megasoft Inc", NULL}, -{0x1161, "PFU Limited", NULL}, -{0x1162, "OA Laboratory Co Ltd", NULL}, -{0x1163, "Rendition", tab_vendor_1163}, -{0x1164, "Advanced Peripherals Technologies", NULL}, -{0x1165, "Imagraph Corporation", tab_vendor_1165}, -{0x1166, "Broadcom", tab_vendor_1166}, -{0x1167, "Mutoh Industries Inc", NULL}, -{0x1168, "Thine Electronics Inc", NULL}, -{0x1169, "Centre for Development of Advanced Computing", NULL}, -{0x116A, "Polaris Communications", tab_vendor_116A}, -{0x116B, "Connectware Inc", NULL}, -{0x116C, "Intelligent Resources Integrated Systems", NULL}, -{0x116D, "Martin-Marietta", NULL}, -{0x116E, "Electronics for Imaging", NULL}, -{0x116F, "Workstation Technology", NULL}, -{0x1170, "Inventec Corporation", NULL}, -{0x1171, "Loughborough Sound Images Plc", NULL}, -{0x1172, "Altera Corporation", NULL}, -{0x1173, "Adobe Systems, Inc", NULL}, -{0x1174, "Bridgeport Machines", NULL}, -{0x1175, "Mitron Computer Inc.", NULL}, -{0x1176, "SBE Incorporated", NULL}, -{0x1177, "Silicon Engineering", NULL}, -{0x1178, "Alfa, Inc.", tab_vendor_1178}, -{0x1179, "Toshiba America Info Systems", tab_vendor_1179}, -{0x117A, "A-Trend Technology", NULL}, -{0x117B, "L G Electronics, Inc.", NULL}, -{0x117C, "Atto Technology", tab_vendor_117C}, -{0x117D, "Becton & Dickinson", NULL}, -{0x117E, "T/R Systems", NULL}, -{0x117F, "Integrated Circuit Systems", NULL}, -{0x1180, "Ricoh Co Ltd", tab_vendor_1180}, -{0x1181, "Telmatics International", NULL}, -{0x1183, "Fujikura Ltd", NULL}, -{0x1184, "Forks Inc", NULL}, -{0x1185, "Dataworld International Ltd", NULL}, -{0x1186, "D-Link System Inc", tab_vendor_1186}, -{0x1187, "Advanced Technology Laboratories, Inc.", NULL}, -{0x1188, "Shima Seiki Manufacturing Ltd.", NULL}, -{0x1189, "Matsushita Electronics Co Ltd", NULL}, -{0x118A, "Hilevel Technology", NULL}, -{0x118B, "Hypertec Pty Limited", NULL}, -{0x118C, "Corollary, Inc", tab_vendor_118C}, -{0x118D, "BitFlow Inc", tab_vendor_118D}, -{0x118E, "Hermstedt GmbH", NULL}, -{0x118F, "Green Logic", NULL}, -{0x1190, "Tripace", tab_vendor_1190}, -{0x1191, "Artop Electronic Corp", tab_vendor_1191}, -{0x1192, "Densan Company Ltd", NULL}, -{0x1193, "Zeitnet Inc.", tab_vendor_1193}, -{0x1194, "Toucan Technology", NULL}, -{0x1195, "Ratoc System Inc", NULL}, -{0x1196, "Hytec Electronics Ltd", NULL}, -{0x1197, "Gage Applied Sciences, Inc.", tab_vendor_1197}, -{0x1198, "Lambda Systems Inc", NULL}, -{0x1199, "Attachmate Corporation", NULL}, -{0x119A, "Mind Share, Inc.", NULL}, -{0x119B, "Omega Micro Inc.", tab_vendor_119B}, -{0x119C, "Information Technology Inst.", NULL}, -{0x119D, "Bug, Inc. Sapporo Japan", NULL}, -{0x119E, "Fujitsu Microelectronics Ltd.", tab_vendor_119E}, -{0x119F, "Bull HN Information Systems", NULL}, -{0x11A0, "Convex Computer Corporation", NULL}, -{0x11A1, "Hamamatsu Photonics K.K.", NULL}, -{0x11A2, "Sierra Research and Technology", NULL}, -{0x11A3, "Deuretzbacher GmbH & Co. Eng. KG", NULL}, -{0x11A4, "Barco Graphics NV", NULL}, -{0x11A5, "Microunity Systems Eng. Inc", NULL}, -{0x11A6, "Pure Data Ltd.", NULL}, -{0x11A7, "Power Computing Corp.", NULL}, -{0x11A8, "Systech Corp.", NULL}, -{0x11A9, "InnoSys Inc.", tab_vendor_11A9}, -{0x11AA, "Actel", NULL}, -{0x11AB, "Marvell Technology Group Ltd.", tab_vendor_11AB}, -{0x11AC, "Canon Information Systems Research Aust.", NULL}, -{0x11AD, "Lite-On Communications Inc", tab_vendor_11AD}, -{0x11AE, "Aztech System Ltd", NULL}, -{0x11AF, "Avid Technology Inc.", tab_vendor_11AF}, -{0x11B0, "V3 Semiconductor Inc.", tab_vendor_11B0}, -{0x11B1, "Apricot Computers", NULL}, -{0x11B2, "Eastman Kodak", NULL}, -{0x11B3, "Barr Systems Inc.", NULL}, -{0x11B4, "Leitch Technology International", NULL}, -{0x11B5, "Radstone Technology Plc", NULL}, -{0x11B6, "United Video Corp", NULL}, -{0x11B7, "Motorola", NULL}, -{0x11B8, "XPoint Technologies, Inc", tab_vendor_11B8}, -{0x11B9, "Pathlight Technology Inc.", tab_vendor_11B9}, -{0x11BA, "Videotron Corp", NULL}, -{0x11BB, "Pyramid Technology", NULL}, -{0x11BC, "Network Peripherals Inc", tab_vendor_11BC}, -{0x11BD, "Pinnacle Systems Inc.", tab_vendor_11BD}, -{0x11BE, "International Microcircuits Inc", NULL}, -{0x11BF, "Astrodesign, Inc.", NULL}, -{0x11C0, "Hewlett Packard", NULL}, -{0x11C1, "Agere Systems", tab_vendor_11C1}, -{0x11C2, "Sand Microelectronics", NULL}, -{0x11C3, "NEC Corporation", NULL}, -{0x11C4, "Document Technologies, Inc", NULL}, -{0x11C5, "Shiva Corporation", NULL}, -{0x11C6, "Dainippon Screen Mfg. Co. Ltd", NULL}, -{0x11C7, "D.C.M. Data Systems", NULL}, -{0x11C8, "Dolphin Interconnect Solutions AS", tab_vendor_11C8}, -{0x11C9, "Magma", tab_vendor_11C9}, -{0x11CA, "LSI Systems, Inc", NULL}, -{0x11CB, "Specialix Research Ltd.", tab_vendor_11CB}, -{0x11CC, "Michels & Kleberhoff Computer GmbH", NULL}, -{0x11CD, "HAL Computer Systems, Inc.", NULL}, -{0x11CE, "Netaccess", NULL}, -{0x11CF, "Pioneer Electronic Corporation", NULL}, -{0x11D0, "Lockheed Martin Federal Systems-Manassas", NULL}, -{0x11D1, "Auravision", tab_vendor_11D1}, -{0x11D2, "Intercom Inc.", NULL}, -{0x11D3, "Trancell Systems Inc", NULL}, -{0x11D4, "Analog Devices", tab_vendor_11D4}, -{0x11D5, "Ikon Corporation", tab_vendor_11D5}, -{0x11D6, "Tekelec Telecom", NULL}, -{0x11D7, "Trenton Technology, Inc.", NULL}, -{0x11D8, "Image Technologies Development", NULL}, -{0x11D9, "TEC Corporation", NULL}, -{0x11DA, "Novell", NULL}, -{0x11DB, "Sega Enterprises Ltd", NULL}, -{0x11DC, "Questra Corporation", NULL}, -{0x11DD, "Crosfield Electronics Limited", NULL}, -{0x11DE, "Zoran Corporation", tab_vendor_11DE}, -{0x11DF, "New Wave PDG", NULL}, -{0x11E0, "Cray Communications A/S", NULL}, -{0x11E1, "GEC Plessey Semi Inc.", NULL}, -{0x11E2, "Samsung Information Systems America", NULL}, -{0x11E3, "Quicklogic Corporation", tab_vendor_11E3}, -{0x11E4, "Second Wave Inc", NULL}, -{0x11E5, "IIX Consulting", NULL}, -{0x11E6, "Mitsui-Zosen System Research", NULL}, -{0x11E7, "Toshiba America, Elec. Company", NULL}, -{0x11E8, "Digital Processing Systems Inc.", NULL}, -{0x11E9, "Highwater Designs Ltd.", NULL}, -{0x11EA, "Elsag Bailey", NULL}, -{0x11EB, "Formation Inc.", NULL}, -{0x11EC, "Coreco Inc", NULL}, -{0x11ED, "Mediamatics", NULL}, -{0x11EE, "Dome Imaging Systems Inc", NULL}, -{0x11EF, "Nicolet Technologies B.V.", NULL}, -{0x11F0, "Compu-Shack", tab_vendor_11F0}, -{0x11F1, "Symbios Logic Inc", NULL}, -{0x11F2, "Picture Tel Japan K.K.", NULL}, -{0x11F3, "Keithley Metrabyte", NULL}, -{0x11F4, "Kinetic Systems Corporation", tab_vendor_11F4}, -{0x11F5, "Computing Devices International", NULL}, -{0x11F6, "Compex", tab_vendor_11F6}, -{0x11F7, "Scientific Atlanta", NULL}, -{0x11F8, "PMC-Sierra Inc.", tab_vendor_11F8}, -{0x11F9, "I-Cube Inc", NULL}, -{0x11FA, "Kasan Electronics Company, Ltd.", NULL}, -{0x11FB, "Datel Inc", NULL}, -{0x11FC, "Silicon Magic", NULL}, -{0x11FD, "High Street Consultants", NULL}, -{0x11FE, "Comtrol Corporation", tab_vendor_11FE}, -{0x11FF, "Scion Corporation", tab_vendor_11FF}, -{0x1200, "CSS Corporation", NULL}, -{0x1201, "Vista Controls Corp", NULL}, -{0x1202, "Network General Corp.", tab_vendor_1202}, -{0x1203, "Bayer Corporation, Agfa Division", NULL}, -{0x1204, "Lattice Semiconductor Corporation", NULL}, -{0x1205, "Array Corporation", NULL}, -{0x1206, "Amdahl Corporation", NULL}, -{0x1208, "Parsytec GmbH", tab_vendor_1208}, -{0x1209, "SCI Systems Inc", NULL}, -{0x120A, "Synaptel", NULL}, -{0x120B, "Adaptive Solutions", NULL}, -{0x120C, "Technical Corp.", NULL}, -{0x120D, "Compression Labs, Inc.", NULL}, -{0x120E, "Cyclades Corporation", tab_vendor_120E}, -{0x120F, "Essential Communications", tab_vendor_120F}, -{0x1210, "Hyperparallel Technologies", NULL}, -{0x1211, "Braintech Inc", NULL}, -{0x1212, "Kingston Technology Corp.", NULL}, -{0x1213, "Applied Intelligent Systems, Inc.", NULL}, -{0x1214, "Performance Technologies, Inc.", NULL}, -{0x1215, "Interware Co., Ltd", NULL}, -{0x1216, "Purup Prepress A/S", NULL}, -{0x1217, "O2 Micro, Inc.", tab_vendor_1217}, -{0x1218, "Hybricon Corp.", NULL}, -{0x1219, "First Virtual Corporation", NULL}, -{0x121A, "3Dfx Interactive, Inc.", tab_vendor_121A}, -{0x121B, "Advanced Telecommunications Modules", NULL}, -{0x121C, "Nippon Texaco., Ltd", NULL}, -{0x121D, "Lippert Automationstechnik GmbH", NULL}, -{0x121E, "CSPI", NULL}, -{0x121F, "Arcus Technology, Inc.", NULL}, -{0x1220, "Ariel Corporation", tab_vendor_1220}, -{0x1221, "Contec Co., Ltd", NULL}, -{0x1222, "Ancor Communications, Inc.", NULL}, -{0x1223, "Artesyn Communication Products", tab_vendor_1223}, -{0x1224, "Interactive Images", NULL}, -{0x1225, "Power I/O, Inc.", NULL}, -{0x1227, "Tech-Source", tab_vendor_1227}, -{0x1228, "Norsk Elektro Optikk A/S", NULL}, -{0x1229, "Data Kinesis Inc.", NULL}, -{0x122A, "Integrated Telecom", NULL}, -{0x122B, "LG Industrial Systems Co., Ltd", NULL}, -{0x122C, "Sican GmbH", NULL}, -{0x122D, "Aztech System Ltd", tab_vendor_122D}, -{0x122E, "Xyratex", NULL}, -{0x122F, "Andrew Corporation", NULL}, -{0x1230, "Fishcamp Engineering", NULL}, -{0x1231, "Woodward McCoach, Inc.", NULL}, -{0x1232, "GPT Limited", NULL}, -{0x1233, "Bus-Tech, Inc.", NULL}, -{0x1234, "Technical Corp.", NULL}, -{0x1235, "Risq Modular Systems, Inc.", NULL}, -{0x1236, "Sigma Designs Corporation", tab_vendor_1236}, -{0x1237, "Alta Technology Corporation", NULL}, -{0x1238, "Adtran", NULL}, -{0x1239, "3DO Company", NULL}, -{0x123A, "Visicom Laboratories, Inc.", NULL}, -{0x123B, "Seeq Technology, Inc.", NULL}, -{0x123C, "Century Systems, Inc.", NULL}, -{0x123D, "Engineering Design Team, Inc.", tab_vendor_123D}, -{0x123E, "Simutech, Inc.", NULL}, -{0x123F, "C-Cube Microsystems", tab_vendor_123F}, -{0x1240, "Marathon Technologies Corp.", NULL}, -{0x1241, "DSC Communications", NULL}, -{0x1242, "JNI Corporation", tab_vendor_1242}, -{0x1243, "Delphax", NULL}, -{0x1244, "AVM Audiovisuelles MKTG & Computer System GmbH", tab_vendor_1244}, -{0x1245, "A.P.D., S.A.", NULL}, -{0x1246, "Dipix Technologies, Inc.", NULL}, -{0x1247, "Xylon Research, Inc.", NULL}, -{0x1248, "Central Data Corporation", NULL}, -{0x1249, "Samsung Electronics Co., Ltd.", NULL}, -{0x124A, "AEG Electrocom GmbH", NULL}, -{0x124B, "SBS/Greenspring Modular I/O", tab_vendor_124B}, -{0x124C, "Solitron Technologies, Inc.", NULL}, -{0x124D, "Stallion Technologies, Inc.", tab_vendor_124D}, -{0x124E, "Cylink", NULL}, -{0x124F, "Infortrend Technology, Inc.", tab_vendor_124F}, -{0x1250, "Hitachi Microcomputer System Ltd", NULL}, -{0x1251, "VLSI Solutions Oy", NULL}, -{0x1253, "Guzik Technical Enterprises", NULL}, -{0x1254, "Linear Systems Ltd.", NULL}, -{0x1255, "Optibase Ltd", tab_vendor_1255}, -{0x1256, "Perceptive Solutions, Inc.", tab_vendor_1256}, -{0x1257, "Vertex Networks, Inc.", NULL}, -{0x1258, "Gilbarco, Inc.", NULL}, -{0x1259, "Allied Telesyn International", tab_vendor_1259}, -{0x125A, "ABB Power Systems", NULL}, -{0x125B, "Asix Electronics Corporation", tab_vendor_125B}, -{0x125C, "Aurora Technologies, Inc.", tab_vendor_125C}, -{0x125D, "ESS Technology", tab_vendor_125D}, -{0x125E, "Specialvideo Engineering SRL", NULL}, -{0x125F, "Concurrent Technologies, Inc.", NULL}, -{0x1260, "Intersil Corporation", tab_vendor_1260}, -{0x1261, "Matsushita-Kotobuki Electronics Industries, Ltd.", NULL}, -{0x1262, "ES Computer Company, Ltd.", NULL}, -{0x1263, "Sonic Solutions", NULL}, -{0x1264, "Aval Nagasaki Corporation", NULL}, -{0x1265, "Casio Computer Co., Ltd.", NULL}, -{0x1266, "Microdyne Corporation", tab_vendor_1266}, -{0x1267, "S. A. Telecommunications", tab_vendor_1267}, -{0x1268, "Tektronix", NULL}, -{0x1269, "Thomson-CSF/TTM", NULL}, -{0x126A, "Lexmark International, Inc.", NULL}, -{0x126B, "Adax, Inc.", NULL}, -{0x126C, "Northern Telecom", tab_vendor_126C}, -{0x126D, "Splash Technology, Inc.", NULL}, -{0x126E, "Sumitomo Metal Industries, Ltd.", NULL}, -{0x126F, "Silicon Motion, Inc.", tab_vendor_126F}, -{0x1270, "Olympus Optical Co., Ltd.", NULL}, -{0x1271, "GW Instruments", NULL}, -{0x1272, "Telematics International", NULL}, -{0x1273, "Hughes Network Systems", tab_vendor_1273}, -{0x1274, "Ensoniq", tab_vendor_1274}, -{0x1275, "Network Appliance Corporation", NULL}, -{0x1276, "Switched Network Technologies, Inc.", NULL}, -{0x1277, "Comstream", NULL}, -{0x1278, "Transtech Parallel Systems Ltd.", tab_vendor_1278}, -{0x1279, "Transmeta Corporation", tab_vendor_1279}, -{0x127A, "Rockwell International", tab_vendor_127A}, -{0x127B, "Pixera Corporation", NULL}, -{0x127C, "Crosspoint Solutions, Inc.", NULL}, -{0x127D, "Vela Research", NULL}, -{0x127E, "Winnov, L.P.", NULL}, -{0x127F, "Fujifilm", NULL}, -{0x1280, "Photoscript Group Ltd.", NULL}, -{0x1281, "Yokogawa Electric Corporation", NULL}, -{0x1282, "Davicom Semiconductor, Inc.", tab_vendor_1282}, -{0x1283, "Integrated Technology Express, Inc.", tab_vendor_1283}, -{0x1284, "Sahara Networks, Inc.", NULL}, -{0x1285, "Platform Technologies, Inc.", tab_vendor_1285}, -{0x1286, "Mazet GmbH", NULL}, -{0x1287, "M-Pact, Inc.", tab_vendor_1287}, -{0x1288, "Timestep Corporation", NULL}, -{0x1289, "AVC Technology, Inc.", NULL}, -{0x128A, "Asante Technologies, Inc.", NULL}, -{0x128B, "Transwitch Corporation", NULL}, -{0x128C, "Retix Corporation", NULL}, -{0x128D, "G2 Networks, Inc.", tab_vendor_128D}, -{0x128E, "Hoontech Corporation/Samho Multi Tech Ltd.", tab_vendor_128E}, -{0x128F, "Tateno Dennou, Inc.", NULL}, -{0x1290, "Sord Computer Corporation", NULL}, -{0x1291, "NCS Computer Italia", NULL}, -{0x1292, "Tritech Microelectronics Inc", NULL}, -{0x1293, "Media Reality Technology", NULL}, -{0x1294, "Rhetorex, Inc.", NULL}, -{0x1295, "Imagenation Corporation", NULL}, -{0x1296, "Kofax Image Products", NULL}, -{0x1297, "Holco Enterprise Co, Ltd/Shuttle Computer", NULL}, -{0x1298, "Spellcaster Telecommunications Inc.", NULL}, -{0x1299, "Knowledge Technology Lab.", NULL}, -{0x129A, "VMetro, inc.", tab_vendor_129A}, -{0x129B, "Image Access", NULL}, -{0x129C, "Jaycor", NULL}, -{0x129D, "Compcore Multimedia, Inc.", NULL}, -{0x129E, "Victor Company of Japan, Ltd.", NULL}, -{0x129F, "OEC Medical Systems, Inc.", NULL}, -{0x12A0, "Allen-Bradley Company", NULL}, -{0x12A1, "Simpact Associates, Inc.", NULL}, -{0x12A2, "Newgen Systems Corporation", NULL}, -{0x12A3, "Lucent Technologies", tab_vendor_12A3}, -{0x12A4, "NTT Electronics Technology Company", NULL}, -{0x12A5, "Vision Dynamics Ltd.", NULL}, -{0x12A6, "Scalable Networks, Inc.", NULL}, -{0x12A7, "AMO GmbH", NULL}, -{0x12A8, "News Datacom", NULL}, -{0x12A9, "Xiotech Corporation", NULL}, -{0x12AA, "SDL Communications, Inc.", NULL}, -{0x12AB, "Yuan Yuan Enterprise Co., Ltd.", tab_vendor_12AB}, -{0x12AC, "Measurex Corporation", NULL}, -{0x12AD, "Multidata GmbH", NULL}, -{0x12AE, "Alteon Networks Inc.", tab_vendor_12AE}, -{0x12AF, "TDK USA Corp", NULL}, -{0x12B0, "Jorge Scientific Corp", NULL}, -{0x12B1, "GammaLink", NULL}, -{0x12B2, "General Signal Networks", NULL}, -{0x12B3, "Inter-Face Co Ltd", NULL}, -{0x12B4, "FutureTel Inc", NULL}, -{0x12B5, "Granite Systems Inc.", NULL}, -{0x12B6, "Natural Microsystems", NULL}, -{0x12B7, "Cognex Modular Vision Systems Div. - Acumen Inc.", NULL}, -{0x12B8, "Korg", NULL}, -{0x12B9, "3Com Corp, Modem Division", tab_vendor_12B9}, -{0x12BA, "BittWare, Inc.", NULL}, -{0x12BB, "Nippon Unisoft Corporation", NULL}, -{0x12BC, "Array Microsystems", NULL}, -{0x12BD, "Computerm Corp.", NULL}, -{0x12BE, "Anchor Chips Inc.", tab_vendor_12BE}, -{0x12BF, "Fujifilm Microdevices", NULL}, -{0x12C0, "Infimed", NULL}, -{0x12C1, "GMM Research Corp", NULL}, -{0x12C2, "Mentec Limited", NULL}, -{0x12C3, "Holtek Microelectronics Inc", tab_vendor_12C3}, -{0x12C4, "Connect Tech Inc", tab_vendor_12C4}, -{0x12C5, "Picture Elements Incorporated", tab_vendor_12C5}, -{0x12C6, "Mitani Corporation", NULL}, -{0x12C7, "Dialogic Corp", NULL}, -{0x12C8, "G Force Co, Ltd", NULL}, -{0x12C9, "Gigi Operations", NULL}, -{0x12CA, "Integrated Computing Engines", NULL}, -{0x12CB, "Antex Electronics Corporation", NULL}, -{0x12CC, "Pluto Technologies International", NULL}, -{0x12CD, "Aims Lab", NULL}, -{0x12CE, "Netspeed Inc.", NULL}, -{0x12CF, "Prophet Systems, Inc.", NULL}, -{0x12D0, "GDE Systems, Inc.", NULL}, -{0x12D1, "PSITech", NULL}, -{0x12D2, "NVidia / SGS Thomson (Joint Venture)", tab_vendor_12D2}, -{0x12D3, "Vingmed Sound A/S", NULL}, -{0x12D4, "Ulticom (Formerly DGM&S)", tab_vendor_12D4}, -{0x12D5, "Equator Technologies Inc", tab_vendor_12D5}, -{0x12D6, "Analogic Corp", NULL}, -{0x12D7, "Biotronic SRL", NULL}, -{0x12D8, "Pericom Semiconductor", tab_vendor_12D8}, -{0x12D9, "Aculab PLC", tab_vendor_12D9}, -{0x12DA, "True Time Inc.", NULL}, -{0x12DB, "Annapolis Micro Systems, Inc", NULL}, -{0x12DC, "Symicron Computer Communication Ltd.", NULL}, -{0x12DD, "Management Graphics", NULL}, -{0x12DE, "Rainbow Technologies", tab_vendor_12DE}, -{0x12DF, "SBS Technologies Inc", NULL}, -{0x12E0, "Chase Research", tab_vendor_12E0}, -{0x12E1, "Nintendo Co, Ltd", NULL}, -{0x12E2, "Datum Inc. Bancomm-Timing Division", NULL}, -{0x12E3, "Imation Corp - Medical Imaging Systems", NULL}, -{0x12E4, "Brooktrout Technology Inc", NULL}, -{0x12E5, "Apex Semiconductor Inc", NULL}, -{0x12E6, "Cirel Systems", NULL}, -{0x12E7, "Sunsgroup Corporation", NULL}, -{0x12E8, "Crisc Corp", NULL}, -{0x12E9, "GE Spacenet", NULL}, -{0x12EA, "Zuken", NULL}, -{0x12EB, "Aureal Semiconductor", tab_vendor_12EB}, -{0x12EC, "3A International, Inc.", NULL}, -{0x12ED, "Optivision Inc.", NULL}, -{0x12EE, "Orange Micro", NULL}, -{0x12EF, "Vienna Systems", NULL}, -{0x12F0, "Pentek", NULL}, -{0x12F1, "Sorenson Vision Inc", NULL}, -{0x12F2, "Gammagraphx, Inc.", NULL}, -{0x12F3, "Radstone Technology", NULL}, -{0x12F4, "Megatel", NULL}, -{0x12F5, "Forks", NULL}, -{0x12F6, "Dawson France", NULL}, -{0x12F7, "Cognex", NULL}, -{0x12F8, "Electronic Design GmbH", tab_vendor_12F8}, -{0x12F9, "Four Fold Ltd", NULL}, -{0x12FB, "Spectrum Signal Processing", tab_vendor_12FB}, -{0x12FC, "Capital Equipment Corp", NULL}, -{0x12FD, "I2S", NULL}, -{0x12FE, "ESD Electronic System Design GmbH", NULL}, -{0x12FF, "Lexicon", NULL}, -{0x1300, "Harman International Industries Inc", NULL}, -{0x1302, "Computer Sciences Corp", NULL}, -{0x1303, "Innovative Integration", NULL}, -{0x1304, "Juniper Networks", NULL}, -{0x1305, "Netphone, Inc", NULL}, -{0x1306, "Duet Technologies", NULL}, -{0x1307, "Measurement Computing", tab_vendor_1307}, -{0x1308, "Jato Technologies Inc.", tab_vendor_1308}, -{0x1309, "AB Semiconductor Ltd", NULL}, -{0x130A, "Mitsubishi Electric Microcomputer", NULL}, -{0x130B, "Colorgraphic Communications Corp", NULL}, -{0x130C, "Ambex Technologies, Inc", NULL}, -{0x130D, "Accelerix Inc", NULL}, -{0x130E, "Yamatake-Honeywell Co. Ltd", NULL}, -{0x130F, "Advanet Inc", NULL}, -{0x1310, "Gespac", NULL}, -{0x1311, "Videoserver, Inc", NULL}, -{0x1312, "Acuity Imaging, Inc", NULL}, -{0x1313, "Yaskawa Electric Co.", NULL}, -{0x1316, "Teradyne Inc", NULL}, -{0x1317, "Linksys", tab_vendor_1317}, -{0x1318, "Packet Engines Inc.", tab_vendor_1318}, -{0x1319, "Fortemedia, Inc", tab_vendor_1319}, -{0x131A, "Finisar Corp.", NULL}, -{0x131C, "Nippon Electro-Sensory Devices Corp", NULL}, -{0x131D, "Sysmic, Inc.", NULL}, -{0x131E, "Xinex Networks Inc", NULL}, -{0x131F, "Siig Inc", tab_vendor_131F}, -{0x1320, "Crypto AG", NULL}, -{0x1321, "Arcobel Graphics BV", NULL}, -{0x1322, "MTT Co., Ltd", NULL}, -{0x1323, "Dome Inc", NULL}, -{0x1324, "Sphere Communications", NULL}, -{0x1325, "Salix Technologies, Inc", NULL}, -{0x1326, "Seachange international", NULL}, -{0x1327, "Voss scientific", NULL}, -{0x1328, "quadrant international", NULL}, -{0x1329, "Productivity Enhancement", NULL}, -{0x132A, "Microcom Inc.", NULL}, -{0x132B, "Broadband Technologies", NULL}, -{0x132C, "Micrel Inc", NULL}, -{0x132D, "Integrated Silicon Solution, Inc.", NULL}, -{0x1330, "MMC Networks", NULL}, -{0x1331, "Radisys Corp.", tab_vendor_1331}, -{0x1332, "Micro Memory", tab_vendor_1332}, -{0x1334, "Redcreek Communications, Inc", NULL}, -{0x1335, "Videomail, Inc", NULL}, -{0x1337, "Third Planet Publishing", NULL}, -{0x1338, "BT Electronics", NULL}, -{0x133A, "Vtel Corp", NULL}, -{0x133B, "Softcom Microsystems", NULL}, -{0x133C, "Holontech Corp", NULL}, -{0x133D, "SS Technologies", NULL}, -{0x133E, "Virtual Computer Corp", NULL}, -{0x133F, "SCM Microsystems", NULL}, -{0x1340, "Atalla Corp", NULL}, -{0x1341, "Kyoto Microcomputer Co", NULL}, -{0x1342, "Promax Systems Inc", NULL}, -{0x1343, "Phylon Communications Inc", NULL}, -{0x1344, "Crucial Technology", NULL}, -{0x1345, "Arescom Inc", NULL}, -{0x1347, "Odetics", NULL}, -{0x1349, "Sumitomo Electric Industries, Ltd.", NULL}, -{0x134A, "DTC Technology Corp.", tab_vendor_134A}, -{0x134B, "ARK Research Corp.", NULL}, -{0x134C, "Chori Joho System Co. Ltd", NULL}, -{0x134D, "PCTel Inc", tab_vendor_134D}, -{0x134E, "CSTI", NULL}, -{0x134F, "Algo System Co Ltd", NULL}, -{0x1350, "Systec Co. Ltd", NULL}, -{0x1351, "Sonix Inc", NULL}, -{0x1353, "Thales Idatys", tab_vendor_1353}, -{0x1354, "Dwave System Inc", NULL}, -{0x1355, "Kratos Analytical Ltd", NULL}, -{0x1356, "The Logical Co", NULL}, -{0x1359, "Prisa Networks", NULL}, -{0x135A, "Brain Boxes", NULL}, -{0x135B, "Giganet Inc", NULL}, -{0x135C, "Quatech Inc", tab_vendor_135C}, -{0x135D, "ABB Network Partner AB", NULL}, -{0x135E, "Sealevel Systems Inc", tab_vendor_135E}, -{0x135F, "I-Data International A-S", NULL}, -{0x1360, "Meinberg Funkuhren", tab_vendor_1360}, -{0x1361, "Soliton Systems K.K.", NULL}, -{0x1362, "Fujifacom Corporation", NULL}, -{0x1363, "Phoenix Technology Ltd", NULL}, -{0x1364, "ATM Communications Inc", NULL}, -{0x1365, "Hypercope GmbH", NULL}, -{0x1366, "Teijin Seiki Co. Ltd", NULL}, -{0x1367, "Hitachi Zosen Corporation", NULL}, -{0x1368, "Skyware Corporation", NULL}, -{0x1369, "Digigram", NULL}, -{0x136A, "High Soft Tech", NULL}, -{0x136B, "Kawasaki Steel Corporation", tab_vendor_136B}, -{0x136C, "Adtek System Science Co Ltd", NULL}, -{0x136D, "Gigalabs Inc", NULL}, -{0x136F, "Applied Magic Inc", NULL}, -{0x1370, "ATL Products", NULL}, -{0x1371, "CNet Technology Inc", tab_vendor_1371}, -{0x1373, "Silicon Vision Inc", NULL}, -{0x1374, "Silicom Ltd.", tab_vendor_1374}, -{0x1375, "Argosystems Inc", NULL}, -{0x1376, "LMC", NULL}, -{0x1377, "Electronic Equipment Production & Distribution GmbH", NULL}, -{0x1378, "Telemann Co. Ltd", NULL}, -{0x1379, "Asahi Kasei Microsystems Co Ltd", NULL}, -{0x137A, "Mark of the Unicorn Inc", tab_vendor_137A}, -{0x137B, "PPT Vision", NULL}, -{0x137C, "Iwatsu Electric Co Ltd", NULL}, -{0x137D, "Dynachip Corporation", NULL}, -{0x137E, "Patriot Scientific Corporation", NULL}, -{0x137F, "Japan Satellite Systems Inc", NULL}, -{0x1380, "Sanritz Automation Co Ltd", NULL}, -{0x1381, "Brains Co. Ltd", NULL}, -{0x1382, "Marian - Electronic & Software", tab_vendor_1382}, -{0x1383, "Controlnet Inc", NULL}, -{0x1384, "Reality Simulation Systems Inc", NULL}, -{0x1385, "Netgear", tab_vendor_1385}, -{0x1386, "Video Domain Technologies", NULL}, -{0x1387, "Systran Corp", NULL}, -{0x1388, "Hitachi Information Technology Co Ltd", NULL}, -{0x1389, "Applicom International", tab_vendor_1389}, -{0x138A, "Fusion Micromedia Corp", NULL}, -{0x138B, "Tokimec Inc", NULL}, -{0x138C, "Silicon Reality", NULL}, -{0x138D, "Future Techno Designs pte Ltd", NULL}, -{0x138E, "Basler GmbH", NULL}, -{0x138F, "Patapsco Designs Inc", NULL}, -{0x1390, "Concept Development Inc", NULL}, -{0x1391, "Development Concepts Inc", NULL}, -{0x1392, "Medialight Inc", NULL}, -{0x1393, "Moxa Technologies Co Ltd", tab_vendor_1393}, -{0x1394, "Level One Communications", tab_vendor_1394}, -{0x1395, "Ambicom Inc", NULL}, -{0x1396, "Cipher Systems Inc", NULL}, -{0x1397, "Cologne Chip Designs GmbH", tab_vendor_1397}, -{0x1398, "Clarion co. Ltd", NULL}, -{0x1399, "Rios systems Co Ltd", NULL}, -{0x139A, "Alacritech Inc", tab_vendor_139A}, -{0x139B, "Mediasonic Multimedia Systems Ltd", NULL}, -{0x139C, "Quantum 3d Inc", NULL}, -{0x139D, "EPL limited", NULL}, -{0x139E, "Media4", NULL}, -{0x139F, "Aethra s.r.l.", NULL}, -{0x13A0, "Crystal Group Inc", NULL}, -{0x13A1, "Kawasaki Heavy Industries Ltd", NULL}, -{0x13A2, "Ositech Communications Inc", NULL}, -{0x13A3, "Hifn Inc.", tab_vendor_13A3}, -{0x13A4, "Rascom Inc", NULL}, -{0x13A5, "Audio Digital Imaging Inc", NULL}, -{0x13A6, "Videonics Inc", NULL}, -{0x13A7, "Teles AG", NULL}, -{0x13A8, "Exar Corp.", tab_vendor_13A8}, -{0x13A9, "Siemens Medical Systems, Ultrasound Group", NULL}, -{0x13AA, "Broadband Networks Inc", NULL}, -{0x13AB, "Arcom Control Systems Ltd", NULL}, -{0x13AC, "Motion Media Technology Ltd", NULL}, -{0x13AD, "Nexus Inc", NULL}, -{0x13AE, "ALD Technology Ltd", NULL}, -{0x13AF, "T.Sqware", NULL}, -{0x13B0, "Maxspeed Corp", NULL}, -{0x13B1, "Tamura corporation", NULL}, -{0x13B2, "Techno Chips Co. Ltd", NULL}, -{0x13B3, "Lanart Corporation", NULL}, -{0x13B4, "Wellbean Co Inc", NULL}, -{0x13B5, "ARM", NULL}, -{0x13B6, "Dlog GmbH", NULL}, -{0x13B7, "Logic Devices Inc", NULL}, -{0x13B8, "Nokia Telecommunications oy", NULL}, -{0x13B9, "Elecom Co Ltd", NULL}, -{0x13BA, "Oxford Instruments", NULL}, -{0x13BB, "Sanyo Technosound Co Ltd", NULL}, -{0x13BC, "Bitran Corporation", NULL}, -{0x13BD, "Sharp corporation", NULL}, -{0x13BE, "Miroku Jyoho Service Co. Ltd", NULL}, -{0x13BF, "Sharewave Inc", NULL}, -{0x13C0, "Microgate Corporation", tab_vendor_13C0}, -{0x13C1, "3ware Inc", tab_vendor_13C1}, -{0x13C2, "Technotrend Systemtechnik GmbH", NULL}, -{0x13C3, "Janz Computer AG", NULL}, -{0x13C4, "Phase Metrics", NULL}, -{0x13C5, "Alphi Technology Corp", NULL}, -{0x13C6, "Condor Engineering Inc", tab_vendor_13C6}, -{0x13C7, "Blue Chip Technology Ltd", NULL}, -{0x13C8, "Apptech Inc", NULL}, -{0x13C9, "Eaton Corporation", NULL}, -{0x13CA, "Iomega Corporation", NULL}, -{0x13CB, "Yano Electric Co Ltd", NULL}, -{0x13CC, "Metheus Corporation", NULL}, -{0x13CD, "Compatible Systems Corporation", NULL}, -{0x13CE, "Cocom A/S", NULL}, -{0x13CF, "Studio Audio & Video Ltd", NULL}, -{0x13D0, "Techsan Electronics Co Ltd", tab_vendor_13D0}, -{0x13D1, "Abocom Systems Inc", tab_vendor_13D1}, -{0x13D2, "Shark Multimedia Inc", NULL}, -{0x13D3, "IMC Networks", NULL}, -{0x13D4, "Graphics Microsystems Inc", NULL}, -{0x13D5, "Media 100 Inc", NULL}, -{0x13D6, "K.I. Technology Co Ltd", NULL}, -{0x13D7, "Toshiba Engineering Corporation", NULL}, -{0x13D8, "Phobos corporation", NULL}, -{0x13D9, "Apex PC Solutions Inc", NULL}, -{0x13DA, "Intresource Systems pte Ltd", NULL}, -{0x13DB, "Janich & Klass Computertechnik GmbH", NULL}, -{0x13DC, "Netboost Corporation", NULL}, -{0x13DD, "Multimedia Bundle Inc", NULL}, -{0x13DE, "ABB Robotics Products AB", NULL}, -{0x13DF, "E-Tech Inc", tab_vendor_13DF}, -{0x13E0, "GVC Corporation", NULL}, -{0x13E1, "Silicom Multimedia Systems Inc", NULL}, -{0x13E2, "Dynamics Research Corporation", NULL}, -{0x13E3, "Nest Inc", NULL}, -{0x13E4, "Calculex Inc", NULL}, -{0x13E5, "Telesoft Design Ltd", NULL}, -{0x13E6, "Argosy research Inc", NULL}, -{0x13E7, "NAC Incorporated", NULL}, -{0x13E8, "Chip Express Corporation", NULL}, -{0x13E9, "Intraserver Technology Inc", NULL}, -{0x13EA, "Dallas Semiconductor", NULL}, -{0x13EB, "Hauppauge Computer Works Inc", NULL}, -{0x13EC, "Zydacron Inc", NULL}, -{0x13ED, "Raytheion E-Systems", NULL}, -{0x13EE, "Hayes Microcomputer Products Inc", NULL}, -{0x13EF, "Coppercom Inc", NULL}, -{0x13F0, "Sundance Technology Inc / IC Plus Corp", tab_vendor_13F0}, -{0x13F1, "Oce' - Technologies B.V.", NULL}, -{0x13F2, "Ford Microelectronics Inc", NULL}, -{0x13F3, "Mcdata Corporation", NULL}, -{0x13F4, "Troika Networks, Inc.", tab_vendor_13F4}, -{0x13F5, "Kansai Electric Co. Ltd", NULL}, -{0x13F6, "C-Media Electronics Inc", tab_vendor_13F6}, -{0x13F7, "Wildfire Communications", NULL}, -{0x13F8, "Ad Lib Multimedia Inc", NULL}, -{0x13F9, "NTT Advanced Technology Corp.", NULL}, -{0x13FA, "Pentland Systems Ltd", NULL}, -{0x13FB, "Aydin Corp", NULL}, -{0x13FC, "Computer Peripherals International", NULL}, -{0x13FD, "Micro Science Inc", NULL}, -{0x13FE, "Advantech Co. Ltd", tab_vendor_13FE}, -{0x13FF, "Silicon Spice Inc", NULL}, -{0x1400, "Artx Inc", tab_vendor_1400}, -{0x1401, "CR-Systems A/S", NULL}, -{0x1402, "Meilhaus Electronic GmbH", NULL}, -{0x1403, "Ascor Inc", NULL}, -{0x1404, "Fundamental Software Inc", NULL}, -{0x1405, "Excalibur Systems Inc", NULL}, -{0x1406, "Oce' Printing Systems GmbH", NULL}, -{0x1407, "Lava Computer mfg Inc", tab_vendor_1407}, -{0x1408, "Aloka Co. Ltd", NULL}, -{0x1409, "Timedia Technology Co Ltd", tab_vendor_1409}, -{0x140A, "DSP Research Inc", NULL}, -{0x140B, "Ramix Inc", NULL}, -{0x140C, "Elmic Systems Inc", NULL}, -{0x140D, "Matsushita Electric Works Ltd", NULL}, -{0x140E, "Goepel Electronic GmbH", NULL}, -{0x140F, "Salient Systems Corp", NULL}, -{0x1410, "Midas lab Inc", NULL}, -{0x1411, "Ikos Systems Inc", NULL}, -{0x1412, "VIA Technologies Inc.", tab_vendor_1412}, -{0x1413, "Addonics", NULL}, -{0x1414, "Microsoft Corporation", NULL}, -{0x1415, "Oxford Semiconductor Ltd", tab_vendor_1415}, -{0x1416, "Multiwave Innovation pte Ltd", NULL}, -{0x1417, "Convergenet Technologies Inc", NULL}, -{0x1418, "Kyushu electronics systems Inc", NULL}, -{0x1419, "Excel Switching Corp", NULL}, -{0x141A, "Apache Micro Peripherals Inc", NULL}, -{0x141B, "Zoom Telephonics Inc", NULL}, -{0x141D, "Digitan Systems Inc", NULL}, -{0x141E, "Fanuc Ltd", NULL}, -{0x141F, "Visiontech Ltd", NULL}, -{0x1420, "Psion Dacom plc", tab_vendor_1420}, -{0x1421, "Ads Technologies Inc", NULL}, -{0x1422, "Ygrec Systems Co Ltd", NULL}, -{0x1423, "Custom Technology Corp.", NULL}, -{0x1424, "Videoserver Connections", NULL}, -{0x1425, "Chelsio Communications Inc", tab_vendor_1425}, -{0x1426, "Storage Technology Corp.", NULL}, -{0x1427, "Better On-Line Solutions", NULL}, -{0x1428, "Edec Co Ltd", NULL}, -{0x1429, "Unex Technology Corp.", NULL}, -{0x142A, "Kingmax Technology Inc", NULL}, -{0x142B, "Radiolan", NULL}, -{0x142C, "Minton Optic Industry Co Ltd", NULL}, -{0x142D, "Pix stream Inc", NULL}, -{0x142E, "Vitec Multimedia", tab_vendor_142E}, -{0x142F, "Radicom Research Inc", NULL}, -{0x1430, "ITT Aerospace/Communications Division", NULL}, -{0x1431, "Gilat Satellite Networks", NULL}, -{0x1432, "Edimax Computer Co.", tab_vendor_1432}, -{0x1433, "Eltec Elektronik GmbH", NULL}, -{0x1435, "RTD Embedded Technologies, Inc.", NULL}, -{0x1436, "CIS Technology Inc", NULL}, -{0x1437, "Nissin Inc Co", NULL}, -{0x1438, "Atmel-dream", NULL}, -{0x1439, "Outsource Engineering & Mfg. Inc", NULL}, -{0x143A, "Stargate Solutions Inc", NULL}, -{0x143B, "Canon Research Center, America", NULL}, -{0x143C, "Amlogic Inc", NULL}, -{0x143D, "Tamarack Microelectronics Inc", NULL}, -{0x143E, "Jones Futurex Inc", NULL}, -{0x143F, "Lightwell Co Ltd - Zax Division", NULL}, -{0x1440, "ALGOL Corp.", NULL}, -{0x1441, "AGIE Ltd", NULL}, -{0x1442, "Phoenix Contact GmbH & Co.", NULL}, -{0x1443, "Unibrain S.A.", NULL}, -{0x1444, "TRW", NULL}, -{0x1445, "Logical DO Ltd", NULL}, -{0x1446, "Graphin Co Ltd", NULL}, -{0x1447, "AIM GmBH", NULL}, -{0x1448, "Alesis Studio Electronics", NULL}, -{0x1449, "TUT Systems Inc", NULL}, -{0x144A, "Adlink Technology", tab_vendor_144A}, -{0x144B, "Loronix Information Systems Inc", NULL}, -{0x144C, "Catalina Research Inc", NULL}, -{0x144D, "Samsung Electronics Co Ltd", NULL}, -{0x144E, "OLITEC", NULL}, -{0x144F, "Askey Computer Corp.", NULL}, -{0x1450, "Octave Communications Ind.", NULL}, -{0x1451, "SP3D Chip Design GmBH", NULL}, -{0x1453, "MYCOM Inc", NULL}, -{0x1454, "Altiga Networks", NULL}, -{0x1455, "Logic Plus Plus Inc", NULL}, -{0x1456, "Advanced Hardware Architectures", NULL}, -{0x1457, "Nuera Communications Inc", NULL}, -{0x1458, "Giga-byte Technology", tab_vendor_1458}, -{0x1459, "DOOIN Electronics", NULL}, -{0x145A, "Escalate Networks Inc", NULL}, -{0x145B, "PRAIM SRL", NULL}, -{0x145C, "Cryptek", NULL}, -{0x145D, "Gallant Computer Inc", NULL}, -{0x145E, "Aashima Technology B.V.", NULL}, -{0x145F, "Baldor Electric Company", tab_vendor_145F}, -{0x1460, "DYNARC INC", NULL}, -{0x1461, "Avermedia Technologies Inc", tab_vendor_1461}, -{0x1462, "Micro-Star International Co., Ltd.", tab_vendor_1462}, -{0x1463, "Fast Corporation", NULL}, -{0x1464, "Interactive Circuits & Systems Ltd", NULL}, -{0x1465, "GN NETTEST Telecom DIV.", NULL}, -{0x1466, "Designpro Inc.", NULL}, -{0x1467, "DIGICOM SPA", NULL}, -{0x1468, "AMBIT Microsystem Corp.", NULL}, -{0x1469, "Cleveland Motion Controls", NULL}, -{0x146A, "IFR", NULL}, -{0x146B, "Parascan Technologies Ltd", NULL}, -{0x146C, "Ruby Tech Corp.", tab_vendor_146C}, -{0x146D, "Tachyon, INC.", NULL}, -{0x146E, "Williams Electronics Games, Inc.", NULL}, -{0x146F, "Multi Dimensional Consulting Inc", NULL}, -{0x1470, "Bay Networks", NULL}, -{0x1471, "Integrated Telecom Express Inc", NULL}, -{0x1472, "DAIKIN Industries, Ltd", NULL}, -{0x1473, "ZAPEX Technologies Inc", NULL}, -{0x1474, "Doug Carson & Associates", NULL}, -{0x1475, "PICAZO Communications", NULL}, -{0x1476, "MORTARA Instrument Inc", NULL}, -{0x1477, "Net Insight", NULL}, -{0x1478, "DIATREND Corporation", NULL}, -{0x1479, "TORAY Industries Inc", NULL}, -{0x147A, "FORMOSA Industrial Computing", NULL}, -{0x147B, "ABIT Computer Corp.", NULL}, -{0x147C, "AWARE, Inc.", NULL}, -{0x147D, "Interworks Computer Products", NULL}, -{0x147E, "Matsushita Graphic Communication Systems, Inc.", NULL}, -{0x147F, "NIHON UNISYS, Ltd.", NULL}, -{0x1480, "SCII Telecom", NULL}, -{0x1481, "BIOPAC Systems Inc", NULL}, -{0x1482, "ISYTEC - Integrierte Systemtechnik GmBH", NULL}, -{0x1483, "LABWAY Corporation", NULL}, -{0x1484, "Logic Corporation", NULL}, -{0x1485, "ERMA - Electronic GmBH", NULL}, -{0x1486, "L3 Communications Telemetry & Instrumentation", NULL}, -{0x1487, "MARQUETTE Medical Systems", NULL}, -{0x1488, "KONTRON Electronik GmBH", NULL}, -{0x1489, "KYE Systems Corporation", NULL}, -{0x148A, "OPTO", NULL}, -{0x148B, "INNOMEDIALOGIC Inc.", NULL}, -{0x148C, "C.P. Technology Co. Ltd", NULL}, -{0x148D, "DIGICOM Systems, Inc.", tab_vendor_148D}, -{0x148E, "OSI Plus Corporation", NULL}, -{0x148F, "Plant Equipment, Inc.", NULL}, -{0x1490, "Stone Microsystems PTY Ltd.", NULL}, -{0x1491, "ZEAL Corporation", NULL}, -{0x1492, "Time Logic Corporation", NULL}, -{0x1493, "MAKER Communications", NULL}, -{0x1494, "WINTOP Technology, Inc.", NULL}, -{0x1495, "TOKAI Communications Industry Co. Ltd", NULL}, -{0x1496, "JOYTECH Computer Co., Ltd.", NULL}, -{0x1497, "SMA Regelsysteme GmBH", tab_vendor_1497}, -{0x1498, "TEWS Datentechnik GmBH", tab_vendor_1498}, -{0x1499, "EMTEC CO., Ltd", NULL}, -{0x149A, "ANDOR Technology Ltd", NULL}, -{0x149B, "SEIKO Instruments Inc", NULL}, -{0x149C, "OVISLINK Corp.", NULL}, -{0x149D, "NEWTEK Inc", tab_vendor_149D}, -{0x149E, "Mapletree Networks Inc.", NULL}, -{0x149F, "LECTRON Co Ltd", NULL}, -{0x14A0, "SOFTING GmBH", NULL}, -{0x14A1, "Systembase Co Ltd", NULL}, -{0x14A2, "Millennium Engineering Inc", NULL}, -{0x14A3, "Maverick Networks", NULL}, -{0x14A4, "GVC/BCM Advanced Research", NULL}, -{0x14A5, "XIONICS Document Technologies Inc", NULL}, -{0x14A6, "INOVA Computers GmBH & Co KG", NULL}, -{0x14A7, "MYTHOS Systems Inc", NULL}, -{0x14A8, "FEATRON Technologies Corporation", NULL}, -{0x14A9, "HIVERTEC Inc", NULL}, -{0x14AA, "Advanced MOS Technology Inc", NULL}, -{0x14AB, "Mentor Graphics Corp.", NULL}, -{0x14AC, "Novaweb Technologies Inc", NULL}, -{0x14AD, "Time Space Radio AB", NULL}, -{0x14AE, "CTI, Inc", NULL}, -{0x14AF, "Guillemot Corporation", tab_vendor_14AF}, -{0x14B0, "BST Communication Technology Ltd", NULL}, -{0x14B1, "Nextcom K.K.", NULL}, -{0x14B2, "ENNOVATE Networks Inc", NULL}, -{0x14B3, "XPEED Inc", tab_vendor_14B3}, -{0x14B4, "PHILIPS Business Electronics B.V.", NULL}, -{0x14B5, "Creamware GmBH", tab_vendor_14B5}, -{0x14B6, "Quantum Data Corp.", NULL}, -{0x14B7, "PROXIM Inc", tab_vendor_14B7}, -{0x14B8, "Techsoft Technology Co Ltd", NULL}, -{0x14B9, "AIRONET Wireless Communications", tab_vendor_14B9}, -{0x14BA, "INTERNIX Inc.", NULL}, -{0x14BB, "SEMTECH Corporation", NULL}, -{0x14BC, "Globespan Semiconductor Inc.", NULL}, -{0x14BD, "CARDIO Control N.V.", NULL}, -{0x14BE, "L3 Communications", NULL}, -{0x14BF, "SPIDER Communications Inc.", NULL}, -{0x14C0, "COMPAL Electronics Inc", NULL}, -{0x14C1, "MYRICOM Inc.", tab_vendor_14C1}, -{0x14C2, "DTK Computer", NULL}, -{0x14C3, "MEDIATEK Corp.", NULL}, -{0x14C4, "IWASAKI Information Systems Co Ltd", NULL}, -{0x14C5, "Automation Products AB", NULL}, -{0x14C6, "Data Race Inc", NULL}, -{0x14C7, "Modular Technology Holdings Ltd", NULL}, -{0x14C8, "Turbocomm Tech. Inc.", NULL}, -{0x14C9, "ODIN Telesystems Inc", NULL}, -{0x14CA, "PE Logic Corp.", NULL}, -{0x14CB, "Billionton Systems Inc", NULL}, -{0x14CC, "NAKAYO Telecommunications Inc", NULL}, -{0x14CD, "Universal Scientific Ind.", NULL}, -{0x14CE, "Whistle Communications", NULL}, -{0x14CF, "TEK Microsystems Inc.", NULL}, -{0x14D0, "Ericsson Axe R & D", NULL}, -{0x14D1, "Computer Hi-Tech Co Ltd", NULL}, -{0x14D2, "Titan Electronics Inc", tab_vendor_14D2}, -{0x14D3, "CIRTECH (UK) Ltd", NULL}, -{0x14D4, "Panacom Technology Corp", NULL}, -{0x14D5, "Nitsuko Corporation", NULL}, -{0x14D6, "Accusys Inc", NULL}, -{0x14D7, "Hirakawa Hewtech Corp", NULL}, -{0x14D8, "HOPF Elektronik GmBH", NULL}, -{0x14D9, "Alliance Semiconductor Corporation", tab_vendor_14D9}, -{0x14DA, "National Aerospace Laboratories", NULL}, -{0x14DB, "AFAVLAB Technology Inc", tab_vendor_14DB}, -{0x14DC, "Amplicon Liveline Ltd", tab_vendor_14DC}, -{0x14DD, "Boulder Design Labs Inc", NULL}, -{0x14DE, "Applied Integration Corporation", NULL}, -{0x14DF, "ASIC Communications Corp", NULL}, -{0x14E1, "INVERTEX", NULL}, -{0x14E2, "INFOLIBRIA", NULL}, -{0x14E3, "AMTELCO", NULL}, -{0x14E4, "Broadcom Corporation", tab_vendor_14E4}, -{0x14E5, "Pixelfusion Ltd", NULL}, -{0x14E6, "SHINING Technology Inc", NULL}, -{0x14E7, "3CX", NULL}, -{0x14E8, "RAYCER Inc", NULL}, -{0x14E9, "GARNETS System CO Ltd", NULL}, -{0x14EA, "Planex Communications, Inc", tab_vendor_14EA}, -{0x14EB, "SEIKO EPSON Corp", NULL}, -{0x14EC, "ACQIRIS", NULL}, -{0x14ED, "DATAKINETICS Ltd", NULL}, -{0x14EE, "MASPRO KENKOH Corp", NULL}, -{0x14EF, "CARRY Computer ENG. CO Ltd", NULL}, -{0x14F0, "CANON RESEACH CENTRE FRANCE", NULL}, -{0x14F1, "Conexant", tab_vendor_14F1}, -{0x14F2, "MOBILITY Electronics", tab_vendor_14F2}, -{0x14F3, "BroadLogic", tab_vendor_14F3}, -{0x14F4, "TOKYO Electronic Industry CO Ltd", NULL}, -{0x14F5, "SOPAC Ltd", NULL}, -{0x14F6, "COYOTE Technologies LLC", NULL}, -{0x14F7, "WOLF Technology Inc", NULL}, -{0x14F8, "AUDIOCODES Inc", tab_vendor_14F8}, -{0x14F9, "AG COMMUNICATIONS", NULL}, -{0x14FA, "WANDEL & GOLTERMANN", NULL}, -{0x14FB, "TRANSAS MARINE (UK) Ltd", NULL}, -{0x14FC, "Quadrics Ltd", tab_vendor_14FC}, -{0x14FD, "JAPAN Computer Industry Inc", NULL}, -{0x14FE, "ARCHTEK TELECOM Corp", NULL}, -{0x14FF, "TWINHEAD INTERNATIONAL Corp", NULL}, -{0x1500, "DELTA Electronics, Inc", tab_vendor_1500}, -{0x1501, "BANKSOFT CANADA Ltd", NULL}, -{0x1502, "MITSUBISHI ELECTRIC LOGISTICS SUPPORT Co Ltd", NULL}, -{0x1503, "KAWASAKI LSI USA Inc", NULL}, -{0x1504, "KAISER Electronics", NULL}, -{0x1505, "ITA INGENIEURBURO FUR TESTAUFGABEN GmbH", NULL}, -{0x1506, "CHAMELEON Systems Inc", NULL}, -{0x1507, "Motorola ? / HTEC", tab_vendor_1507}, -{0x1508, "HONDA CONNECTORS/MHOTRONICS Inc", NULL}, -{0x1509, "FIRST INTERNATIONAL Computer Inc", NULL}, -{0x150A, "FORVUS RESEARCH Inc", NULL}, -{0x150B, "YAMASHITA Systems Corp", NULL}, -{0x150C, "KYOPAL CO Ltd", NULL}, -{0x150D, "WARPSPPED Inc", NULL}, -{0x150E, "C-PORT Corp", NULL}, -{0x150F, "INTEC GmbH", NULL}, -{0x1510, "BEHAVIOR TECH Computer Corp", NULL}, -{0x1511, "CENTILLIUM Technology Corp", NULL}, -{0x1512, "ROSUN Technologies Inc", NULL}, -{0x1513, "Raychem", NULL}, -{0x1514, "TFL LAN Inc", NULL}, -{0x1515, "Advent design", NULL}, -{0x1516, "MYSON Technology Inc", tab_vendor_1516}, -{0x1517, "ECHOTEK Corp", NULL}, -{0x1518, "PEP MODULAR Computers GmbH", NULL}, -{0x1519, "TELEFON AKTIEBOLAGET LM Ericsson", NULL}, -{0x151A, "Globetek", tab_vendor_151A}, -{0x151B, "COMBOX Ltd", NULL}, -{0x151C, "DIGITAL AUDIO LABS Inc", tab_vendor_151C}, -{0x151D, "Fujitsu Computer Products Of America", NULL}, -{0x151E, "MATRIX Corp", NULL}, -{0x151F, "TOPIC SEMICONDUCTOR Corp", tab_vendor_151F}, -{0x1520, "CHAPLET System Inc", NULL}, -{0x1521, "BELL Corp", NULL}, -{0x1522, "MainPine Ltd", tab_vendor_1522}, -{0x1523, "MUSIC Semiconductors", NULL}, -{0x1524, "ENE Technology Inc", tab_vendor_1524}, -{0x1525, "IMPACT Technologies", NULL}, -{0x1526, "ISS, Inc", NULL}, -{0x1527, "SOLECTRON", NULL}, -{0x1528, "ACKSYS", NULL}, -{0x1529, "AMERICAN MICROSystems Inc", NULL}, -{0x152A, "QUICKTURN DESIGN Systems", NULL}, -{0x152B, "FLYTECH Technology CO Ltd", NULL}, -{0x152C, "MACRAIGOR Systems LLC", NULL}, -{0x152D, "QUANTA Computer Inc", NULL}, -{0x152E, "MELEC Inc", NULL}, -{0x152F, "PHILIPS - CRYPTO", NULL}, -{0x1530, "ACQIS Technology Inc", NULL}, -{0x1531, "CHRYON Corp", NULL}, -{0x1532, "ECHELON Corp", tab_vendor_1532}, -{0x1533, "BALTIMORE", NULL}, -{0x1534, "ROAD Corp", NULL}, -{0x1535, "EVERGREEN Technologies Inc", NULL}, -{0x1537, "DATALEX COMMUNCATIONS", NULL}, -{0x1538, "ARALION Inc", tab_vendor_1538}, -{0x1539, "ATELIER INFORMATIQUES et ELECTRONIQUE ETUDES S.A.", NULL}, -{0x153A, "ONO SOKKI", NULL}, -{0x153B, "TERRATEC Electronic GmbH", tab_vendor_153B}, -{0x153C, "ANTAL Electronic", NULL}, -{0x153D, "FILANET Corp", NULL}, -{0x153E, "TECHWELL Inc", NULL}, -{0x153F, "MIPS Technologies, Inc.", tab_vendor_153F}, -{0x1540, "PROVIDEO MULTIMEDIA Co Ltd", NULL}, -{0x1541, "MACHONE Communications", NULL}, -{0x1542, "Concurrent Computer Corporation", NULL}, -{0x1543, "SILICON Laboratories", tab_vendor_1543}, -{0x1544, "DCM DATA Systems", NULL}, -{0x1545, "VISIONTEK", NULL}, -{0x1546, "IOI Technology Corp", NULL}, -{0x1547, "MITUTOYO Corp", NULL}, -{0x1548, "JET PROPULSION Laboratory", NULL}, -{0x1549, "INTERCONNECT Systems Solutions", NULL}, -{0x154A, "MAX Technologies Inc", NULL}, -{0x154B, "COMPUTEX Co Ltd", NULL}, -{0x154C, "VISUAL Technology Inc", NULL}, -{0x154D, "PAN INTERNATIONAL Industrial Corp", NULL}, -{0x154E, "SERVOTEST Ltd", NULL}, -{0x154F, "STRATABEAM Technology", NULL}, -{0x1550, "OPEN NETWORK Co Ltd", NULL}, -{0x1551, "SMART Electronic DEVELOPMENT GmBH", NULL}, -{0x1552, "RACAL AIRTECH Ltd", NULL}, -{0x1553, "CHICONY Electronics Co Ltd", NULL}, -{0x1554, "PROLINK Microsystems Corp", NULL}, -{0x1555, "GESYTEC GmBH", NULL}, -{0x1556, "PLD APPLICATIONS", NULL}, -{0x1557, "MEDIASTAR Co Ltd", NULL}, -{0x1558, "CLEVO/KAPOK Computer", NULL}, -{0x1559, "SI LOGIC Ltd", NULL}, -{0x155A, "INNOMEDIA Inc", NULL}, -{0x155B, "PROTAC INTERNATIONAL Corp", NULL}, -{0x155C, "Cemax-Icon Inc", NULL}, -{0x155D, "Mac System Co Ltd", NULL}, -{0x155E, "LP Elektronik GmbH", NULL}, -{0x155F, "Perle Systems Ltd", NULL}, -{0x1560, "Terayon Communications Systems", NULL}, -{0x1561, "Viewgraphics Inc", NULL}, -{0x1562, "Symbol Technologies", NULL}, -{0x1563, "A-Trend Technology Co Ltd", NULL}, -{0x1564, "Yamakatsu Electronics Industry Co Ltd", NULL}, -{0x1565, "Biostar Microtech Int'l Corp", NULL}, -{0x1566, "Ardent Technologies Inc", NULL}, -{0x1567, "Jungsoft", NULL}, -{0x1568, "DDK Electronics Inc", NULL}, -{0x1569, "Palit Microsystems Inc.", NULL}, -{0x156A, "Avtec Systems", NULL}, -{0x156B, "2wire Inc", NULL}, -{0x156C, "Vidac Electronics GmbH", NULL}, -{0x156D, "Alpha-Top Corp", NULL}, -{0x156E, "Alfa Inc", NULL}, -{0x156F, "M-Systems Flash Disk Pioneers Ltd", NULL}, -{0x1570, "Lecroy Corp", NULL}, -{0x1571, "Contemporary Controls", tab_vendor_1571}, -{0x1572, "Otis Elevator Company", NULL}, -{0x1573, "Lattice - Vantis", NULL}, -{0x1574, "Fairchild Semiconductor", NULL}, -{0x1575, "Voltaire Advanced Data Security Ltd", NULL}, -{0x1576, "Viewcast COM", NULL}, -{0x1578, "HITT", tab_vendor_1578}, -{0x1579, "Dual Technology Corp", NULL}, -{0x157A, "Japan Elecronics Ind Inc", NULL}, -{0x157B, "Star Multimedia Corp", NULL}, -{0x157C, "Eurosoft (UK)", tab_vendor_157C}, -{0x157D, "Gemflex Networks", NULL}, -{0x157E, "Transition Networks", NULL}, -{0x157F, "PX Instruments Technology Ltd", NULL}, -{0x1580, "Primex Aerospace Co", NULL}, -{0x1581, "SEH Computertechnik GmbH", NULL}, -{0x1582, "Cytec Corp", NULL}, -{0x1583, "Inet Technologies Inc", NULL}, -{0x1584, "Uniwill Computer Corp", NULL}, -{0x1585, "Logitron", NULL}, -{0x1586, "Lancast Inc", NULL}, -{0x1587, "Konica Corp", NULL}, -{0x1588, "Solidum Systems Corp", NULL}, -{0x1589, "Atlantek Microsystems Pty Ltd", NULL}, -{0x158A, "Digalog Systems Inc", NULL}, -{0x158B, "Allied Data Technologies", NULL}, -{0x158C, "Hitachi Semiconductor & Devices Sales Co Ltd", NULL}, -{0x158D, "Point Multimedia Systems", NULL}, -{0x158E, "Lara Technology Inc", NULL}, -{0x158F, "Ditect Coop", NULL}, -{0x1590, "3pardata Inc", NULL}, -{0x1591, "ARN", NULL}, -{0x1592, "Syba Tech Ltd", tab_vendor_1592}, -{0x1593, "Bops Inc", NULL}, -{0x1594, "Netgame Ltd", NULL}, -{0x1595, "Diva Systems Corp", NULL}, -{0x1596, "Folsom Research Inc", NULL}, -{0x1597, "Memec Design Services", NULL}, -{0x1598, "Granite Microsystems", NULL}, -{0x1599, "Delta Electronics Inc", NULL}, -{0x159A, "General Instrument", NULL}, -{0x159B, "Faraday Technology Corp", NULL}, -{0x159C, "Stratus Computer Systems", NULL}, -{0x159D, "Ningbo Harrison Electronics Co Ltd", NULL}, -{0x159E, "A-Max Technology Co Ltd", NULL}, -{0x159F, "Galea Network Security", NULL}, -{0x15A0, "Compumaster SRL", NULL}, -{0x15A1, "Geocast Network Systems", NULL}, -{0x15A2, "Catalyst Enterprises Inc", tab_vendor_15A2}, -{0x15A3, "Italtel", NULL}, -{0x15A4, "X-Net OY", NULL}, -{0x15A5, "Toyota Macs Inc", NULL}, -{0x15A6, "Sunlight Ultrasound Technologies Ltd", NULL}, -{0x15A7, "SSE Telecom Inc", NULL}, -{0x15A8, "Shanghai Communications Technologies Center", NULL}, -{0x15AA, "Moreton Bay", NULL}, -{0x15AB, "Bluesteel Networks Inc", NULL}, -{0x15AC, "North Atlantic Instruments", NULL}, -{0x15AD, "VMware Inc", tab_vendor_15AD}, -{0x15AE, "Amersham Pharmacia Biotech", NULL}, -{0x15B0, "Zoltrix International Ltd", NULL}, -{0x15B1, "Source Technology Inc", NULL}, -{0x15B2, "Mosaid Technologies Inc", NULL}, -{0x15B3, "Mellanox Technologies", tab_vendor_15B3}, -{0x15B4, "CCI/TRIAD", NULL}, -{0x15B5, "Cimetrics Inc", NULL}, -{0x15B6, "Texas Memory Systems Inc", NULL}, -{0x15B7, "Sandisk Corp", NULL}, -{0x15B8, "ADDI-DATA GmbH", NULL}, -{0x15B9, "Maestro Digital Communications", NULL}, -{0x15BA, "Impacct Technology Corp", NULL}, -{0x15BB, "Portwell Inc", NULL}, -{0x15BC, "Agilent Technologies", tab_vendor_15BC}, -{0x15BD, "DFI Inc", NULL}, -{0x15BE, "Sola Electronics", NULL}, -{0x15BF, "High Tech Computer Corp (HTC)", NULL}, -{0x15C0, "BVM Ltd", NULL}, -{0x15C1, "Quantel", NULL}, -{0x15C2, "Newer Technology Inc", NULL}, -{0x15C3, "Taiwan Mycomp Co Ltd", NULL}, -{0x15C4, "EVSX Inc", NULL}, -{0x15C5, "Procomp Informatics Ltd", tab_vendor_15C5}, -{0x15C6, "Technical University of Budapest", NULL}, -{0x15C7, "Tateyama System Laboratory Co Ltd", tab_vendor_15C7}, -{0x15C8, "Penta Media Co Ltd", NULL}, -{0x15C9, "Serome Technology Inc", NULL}, -{0x15CA, "Bitboys OY", NULL}, -{0x15CB, "AG Electronics Ltd", NULL}, -{0x15CC, "Hotrail Inc", NULL}, -{0x15CD, "Dreamtech Co Ltd", NULL}, -{0x15CE, "Genrad Inc", NULL}, -{0x15CF, "Hilscher GmbH", NULL}, -{0x15D1, "Infineon Technologies AG", NULL}, -{0x15D2, "FIC (First International Computer Inc)", NULL}, -{0x15D3, "NDS Technologies Israel Ltd", NULL}, -{0x15D4, "Iwill Corp", NULL}, -{0x15D5, "Tatung Co", NULL}, -{0x15D6, "Entridia Corp", NULL}, -{0x15D7, "Rockwell-Collins Inc", NULL}, -{0x15D8, "Cybernetics Technology Co Ltd", NULL}, -{0x15D9, "Super Micro Computer Inc", NULL}, -{0x15DA, "Cyberfirm Inc", NULL}, -{0x15DB, "Applied Computing Systems Inc", NULL}, -{0x15DC, "Litronic Inc", tab_vendor_15DC}, -{0x15DD, "Sigmatel Inc", NULL}, -{0x15DE, "Malleable Technologies Inc", NULL}, -{0x15DF, "Infinilink Corp", NULL}, -{0x15E0, "Cacheflow Inc", NULL}, -{0x15E1, "Voice Technologies Group Inc", NULL}, -{0x15E2, "Quicknet Technologies Inc", NULL}, -{0x15E3, "Networth Technologies Inc", NULL}, -{0x15E4, "VSN Systemen BV", NULL}, -{0x15E5, "Valley technologies Inc", NULL}, -{0x15E6, "Agere Inc", NULL}, -{0x15E7, "Get Engineering Corp", NULL}, -{0x15E8, "National Datacomm Corp", tab_vendor_15E8}, -{0x15E9, "Pacific Digital Corp", tab_vendor_15E9}, -{0x15EA, "Tokyo Denshi Sekei K.K.", NULL}, -{0x15EB, "Drsearch GmbH", NULL}, -{0x15EC, "Beckhoff GmbH", tab_vendor_15EC}, -{0x15ED, "Macrolink Inc", NULL}, -{0x15EE, "In Win Development Inc", NULL}, -{0x15EF, "Intelligent Paradigm Inc", NULL}, -{0x15F0, "B-Tree Systems Inc", NULL}, -{0x15F1, "Times N Systems Inc", NULL}, -{0x15F2, "Diagnostic Instruments Inc", NULL}, -{0x15F3, "Digitmedia Corp", NULL}, -{0x15F4, "Valuesoft", NULL}, -{0x15F5, "Power Micro Research", NULL}, -{0x15F6, "Extreme Packet Device Inc", NULL}, -{0x15F7, "Banctec", NULL}, -{0x15F8, "Koga Electronics Co", NULL}, -{0x15F9, "Zenith Electronics Corp", NULL}, -{0x15FA, "J.P. Axzam Corp", NULL}, -{0x15FB, "Zilog Inc", NULL}, -{0x15FC, "Techsan Electronics Co Ltd", NULL}, -{0x15FD, "N-CUBED.NET", NULL}, -{0x15FE, "Kinpo Electronics Inc", NULL}, -{0x15FF, "Fastpoint Technologies Inc", NULL}, -{0x1600, "Northrop Grumman - Canada Ltd", NULL}, -{0x1601, "Tenta Technology", NULL}, -{0x1602, "Prosys-tec Inc", NULL}, -{0x1603, "Nokia Wireless Communications", NULL}, -{0x1604, "Central System Research Co Ltd", NULL}, -{0x1605, "Pairgain Technologies", NULL}, -{0x1606, "Europop AG", NULL}, -{0x1607, "Lava Semiconductor Manufacturing Inc", NULL}, -{0x1608, "Automated Wagering International", NULL}, -{0x1609, "Scimetric Instruments Inc", NULL}, -{0x1612, "Telesynergy Research Inc.", NULL}, -{0x1619, "FarSite Communications Ltd", tab_vendor_1619}, -{0x161F, "Rioworks", NULL}, -{0x1626, "TDK Semiconductor Corp.", tab_vendor_1626}, -{0x1629, "Kongsberg Spacetec AS", tab_vendor_1629}, -{0x1637, "Linksys", tab_vendor_1637}, -{0x1638, "Standard Microsystems Corp [SMC]", tab_vendor_1638}, -{0x163C, "Smart Link Ltd.", tab_vendor_163C}, -{0x1657, "Brocade Communications Systems, Inc.", NULL}, -{0x165A, "Epix Inc", tab_vendor_165A}, -{0x165D, "Hsing Tech. Enterprise Co., Ltd.", NULL}, -{0x165F, "Linux Media Labs, LLC", tab_vendor_165F}, -{0x1661, "Worldspace Corp.", NULL}, -{0x1668, "Actiontec Electronics Inc", tab_vendor_1668}, -{0x166D, "Broadcom Corporation", tab_vendor_166D}, -{0x1677, "Bernecker + Rainer", tab_vendor_1677}, -{0x167B, "ZyDAS Technology Corp.", tab_vendor_167B}, -{0x1681, "Hercules", tab_vendor_1681}, -{0x1682, "XFX Pine Group Inc.", NULL}, -{0x1688, "CastleNet Technology Inc.", tab_vendor_1688}, -{0x168C, "Atheros Communications, Inc.", tab_vendor_168C}, -{0x1695, "EPoX Computer Co., Ltd.", NULL}, -{0x169C, "Netcell Corporation", tab_vendor_169C}, -{0x16A5, "Tekram Technology Co.,Ltd.", NULL}, -{0x16AB, "Global Sun Technology Inc", tab_vendor_16AB}, -{0x16AE, "Safenet Inc", tab_vendor_16AE}, -{0x16AF, "SparkLAN Communications, Inc.", NULL}, -{0x16B4, "Aspex Semiconductor Ltd", NULL}, -{0x16B8, "Sonnet Technologies, Inc.", NULL}, -{0x16BE, "Creatix Polymedia GmbH", NULL}, -{0x16C8, "Octasic Inc.", NULL}, -{0x16C9, "EONIC B.V. The Netherlands", NULL}, -{0x16CA, "CENATEK Inc", tab_vendor_16CA}, -{0x16CD, "Densitron Technologies", NULL}, -{0x16CE, "Roland Corp.", NULL}, -{0x16DF, "PIKA Technologies Inc.", NULL}, -{0x16E3, "European Space Agency", tab_vendor_16E3}, -{0x16EC, "U.S. Robotics", tab_vendor_16EC}, -{0x16ED, "Sycron N. V.", tab_vendor_16ED}, -{0x16F3, "Jetway Information Co., Ltd.", NULL}, -{0x16F4, "Vweb Corp", tab_vendor_16F4}, -{0x16F6, "VideoTele.com, Inc.", NULL}, -{0x1702, "Internet Machines Corporation (IMC)", NULL}, -{0x1705, "Digital First, Inc.", NULL}, -{0x170B, "NetOctave", tab_vendor_170B}, -{0x170C, "YottaYotta Inc.", NULL}, -{0x1725, "Vitesse Semiconductor", tab_vendor_1725}, -{0x172A, "Accelerated Encryption", tab_vendor_172A}, -{0x1734, "Fujitsu Siemens Computer GmbH", NULL}, -{0x1737, "Linksys", tab_vendor_1737}, -{0x173B, "Altima (nee Broadcom)", tab_vendor_173B}, -{0x1743, "Peppercon AG", tab_vendor_1743}, -{0x1749, "RLX Technologies", NULL}, -{0x174B, "PC Partner Limited", NULL}, -{0x174D, "WellX Telecom SA", NULL}, -{0x175C, "AudioScience Inc", NULL}, -{0x175E, "Sanera Systems, Inc.", NULL}, -{0x1775, "SBS Technologies", NULL}, -{0x1787, "Hightech Information System Ltd.", NULL}, -{0x1796, "Research Centre Juelich", tab_vendor_1796}, -{0x1797, "JumpTec h, GMBH", NULL}, -{0x1799, "Belkin", tab_vendor_1799}, -{0x179C, "Data Patterns", tab_vendor_179C}, -{0x17A0, "Genesys Logic, Inc", tab_vendor_17A0}, -{0x17AA, "Lenovo", NULL}, -{0x17AF, "Hightech Information System Ltd.", NULL}, -{0x17B3, "Hawking Technologies", tab_vendor_17B3}, -{0x17B4, "Indra Networks, Inc.", tab_vendor_17B4}, -{0x17C0, "Wistron Corp.", NULL}, -{0x17C2, "Newisys, Inc.", NULL}, -{0x17CB, "Airgo Networks Inc", NULL}, -{0x17CC, "NetChip Technology, Inc", tab_vendor_17CC}, -{0x17CF, "Z-Com, Inc.", NULL}, -{0x17D3, "Areca Technology Corp.", tab_vendor_17D3}, -{0x17D5, "S2io Inc.", tab_vendor_17D5}, -{0x17DE, "KWorld Computer Co. Ltd.", NULL}, -{0x17EE, "Connect Components Ltd", NULL}, -{0x17F2, "Albatron Corp.", NULL}, -{0x17FE, "Linksys, A Division of Cisco Systems", tab_vendor_17FE}, -{0x17FF, "Benq Corporation", NULL}, -{0x1813, "Ambient Technologies Inc", tab_vendor_1813}, -{0x1814, "RaLink", tab_vendor_1814}, -{0x1820, "InfiniCon Systems Inc.", NULL}, -{0x1822, "Twinhan Technology Co. Ltd", tab_vendor_1822}, -{0x182D, "SiteCom Europe BV", tab_vendor_182D}, -{0x1830, "Credence Systems Corporation", NULL}, -{0x183B, "MikroM GmbH", tab_vendor_183B}, -{0x1849, "ASRock Incorporation", NULL}, -{0x1851, "Microtune, Inc.", NULL}, -{0x1852, "Anritsu Corp.", NULL}, -{0x1854, "LG Electronics, Inc.", NULL}, -{0x185B, "Compro Technology, Inc.", NULL}, -{0x185F, "Wistron NeWeb Corp.", NULL}, -{0x1864, "SilverBack", tab_vendor_1864}, -{0x1867, "Topspin Communications", tab_vendor_1867}, -{0x187E, "ZyXEL Communication Corporation", NULL}, -{0x1888, "Varisys Ltd", tab_vendor_1888}, -{0x1890, "Egenera, Inc.", NULL}, -{0x1894, "KNC One", NULL}, -{0x1896, "B&B Electronics Manufacturing Company, Inc.", NULL}, -{0x18A1, "Astute Networks Inc.", NULL}, -{0x18AC, "DViCO Corporation", tab_vendor_18AC}, -{0x18B8, "Ammasso", tab_vendor_18B8}, -{0x18BC, "Info-Tek Corp.", NULL}, -{0x18C8, "Cray Inc", NULL}, -{0x18C9, "ARVOO Engineering BV", NULL}, -{0x18CA, "XGI - Xabre Graphics Inc", tab_vendor_18CA}, -{0x18D2, "Sitecom", tab_vendor_18D2}, -{0x18DD, "Artimi Inc", tab_vendor_18DD}, -{0x18E6, "MPL AG", tab_vendor_18E6}, -{0x18EC, "Cesnet, z.s.p.o.", tab_vendor_18EC}, -{0x18F7, "Commtech, Inc.", tab_vendor_18F7}, -{0x18FB, "Resilience Corporation", NULL}, -{0x1923, "Sangoma Technologies Corp.", tab_vendor_1923}, -{0x1924, "Level 5 Networks Inc.", NULL}, -{0x192E, "TransDimension", NULL}, -{0x1931, "Option N.V.", NULL}, -{0x1942, "ClearSpeed Technology plc", tab_vendor_1942}, -{0x1957, "Freescale Semiconductor Inc", tab_vendor_1957}, -{0x1958, "Faster Technology, LLC.", NULL}, -{0x1966, "Orad Hi-Tec Systems", tab_vendor_1966}, -{0x196A, "Sensory Networks Inc.", tab_vendor_196A}, -{0x197B, "JMicron Technologies, Inc.", tab_vendor_197B}, -{0x1989, "Montilio Inc.", tab_vendor_1989}, -{0x1993, "Innominate Security Technologies AG", NULL}, -{0x19A8, "DAQDATA GmbH", NULL}, -{0x19AC, "Kasten Chase Applied Research", NULL}, -{0x19AE, "Progeny Systems Corporation", tab_vendor_19AE}, -{0x19D4, "Quixant Limited", NULL}, -{0x19E2, "Vector Informatik GmbH", NULL}, -{0x1A08, "Sierra semiconductor", tab_vendor_1A08}, -{0x1B13, "Jaton Corp", NULL}, -{0x1C1C, "Symphony", tab_vendor_1C1C}, -{0x1D44, "DPT", tab_vendor_1D44}, -{0x1DE1, "Tekram Technology Co.,Ltd.", tab_vendor_1DE1}, -{0x1FC0, "Tumsan Oy", tab_vendor_1FC0}, -{0x1FC1, "PathScale, Inc", tab_vendor_1FC1}, -{0x1FCE, "Cognio Inc.", tab_vendor_1FCE}, -{0x2000, "Smart Link Ltd.", NULL}, -{0x2001, "Temporal Research Ltd", NULL}, -{0x2003, "Smart Link Ltd.", NULL}, -{0x2004, "Smart Link Ltd.", NULL}, -{0x21C3, "21st Century Computer Corp.", NULL}, -{0x2348, "Racore", tab_vendor_2348}, -{0x2646, "Kingston Technologies", NULL}, -{0x270B, "Xantel Corporation", NULL}, -{0x270F, "Chaintech Computer Co. Ltd", NULL}, -{0x2711, "AVID Technology Inc.", NULL}, -{0x2A15, "3D Vision(?)", NULL}, -{0x3000, "Hansol Electronics Inc.", NULL}, -{0x3142, "Post Impression Systems.", NULL}, -{0x3388, "Hint Corp", tab_vendor_3388}, -{0x3411, "Quantum Designs (H.K.) Inc", NULL}, -{0x3513, "ARCOM Control Systems Ltd", NULL}, -{0x3842, "eVga.com. Corp.", tab_vendor_3842}, -{0x38EF, "4Links", NULL}, -{0x3D3D, "3DLabs", tab_vendor_3D3D}, -{0x4005, "Avance Logic Inc.", tab_vendor_4005}, -{0x4033, "Addtron Technology Co, Inc.", tab_vendor_4033}, -{0x4143, "Digital Equipment Corp", NULL}, -{0x4144, "Alpha Data", tab_vendor_4144}, -{0x416C, "Aladdin Knowledge Systems", tab_vendor_416C}, -{0x4321, "Tata Power Strategic Electronics Division", NULL}, -{0x4444, "Internext Compression Inc", tab_vendor_4444}, -{0x4468, "Bridgeport machines", NULL}, -{0x4594, "Cogetec Informatique Inc", NULL}, -{0x45FB, "Baldor Electric Company", NULL}, -{0x4680, "Umax Computer Corp", NULL}, -{0x4843, "Hercules Computer Technology Inc", NULL}, -{0x4916, "RedCreek Communications Inc", tab_vendor_4916}, -{0x4943, "Growth Networks", NULL}, -{0x494F, "ACCES I/O Products, Inc.", tab_vendor_494F}, -{0x4978, "Axil Computer Inc", NULL}, -{0x4A14, "NetVin", tab_vendor_4A14}, -{0x4B10, "Buslogic Inc.", NULL}, -{0x4C48, "LUNG HWA Electronics", NULL}, -{0x4C53, "SBS Technologies", tab_vendor_4C53}, -{0x4CA1, "Seanix Technology Inc", NULL}, -{0x4D51, "MediaQ Inc.", tab_vendor_4D51}, -{0x4D54, "Microtechnica Co Ltd", NULL}, -{0x4DDC, "ILC Data Device Corp", tab_vendor_4DDC}, -{0x5046, "GemTek Technology Corporation", tab_vendor_5046}, -{0x5053, "Voyetra Technologies", tab_vendor_5053}, -{0x5136, "S S Technologies", NULL}, -{0x5143, "Qualcomm Inc", NULL}, -{0x5145, "Ensoniq (Old)", tab_vendor_5145}, -{0x5168, "Animation Technologies Inc.", tab_vendor_5168}, -{0x5301, "Alliance Semiconductor Corp.", tab_vendor_5301}, -{0x5333, "S3 Inc.", tab_vendor_5333}, -{0x544C, "Teralogic Inc", tab_vendor_544C}, -{0x5455, "Technische University Berlin", tab_vendor_5455}, -{0x5519, "Cnet Technologies, Inc.", NULL}, -{0x5544, "Dunord Technologies", tab_vendor_5544}, -{0x5555, "Genroco, Inc", tab_vendor_5555}, -{0x5654, "VoiceTronix Pty Ltd", tab_vendor_5654}, -{0x5700, "Netpower", NULL}, -{0x5851, "Exacq Technologies", NULL}, -{0x6356, "UltraStor", NULL}, -{0x6374, "c't Magazin fuer Computertechnik", tab_vendor_6374}, -{0x6409, "Logitec Corp.", NULL}, -{0x6666, "Decision Computer International Co.", tab_vendor_6666}, -{0x7063, "pcHDTV", tab_vendor_7063}, -{0x7604, "O.N. Electronic Co Ltd.", NULL}, -{0x7BDE, "MIDAC Corporation", NULL}, -{0x7FED, "PowerTV", NULL}, -{0x8008, "Quancom Electronic GmbH", tab_vendor_8008}, -{0x807D, "Asustek Computer, Inc.", NULL}, -{0x8086, "Intel Corporation", tab_vendor_8086}, -{0x8401, "TRENDware International Inc.", NULL}, -{0x8800, "Trigem Computer Inc.", tab_vendor_8800}, -{0x8866, "T-Square Design Inc.", NULL}, -{0x8888, "Silicon Magic", NULL}, -{0x8912, "TRX", NULL}, -{0x8C4A, "Winbond", tab_vendor_8C4A}, -{0x8E0E, "Computone Corporation", NULL}, -{0x8E2E, "KTI", tab_vendor_8E2E}, -{0x9004, "Adaptec", tab_vendor_9004}, -{0x9005, "Adaptec", tab_vendor_9005}, -{0x907F, "Atronics", tab_vendor_907F}, -{0x919A, "Gigapixel Corp", NULL}, -{0x9412, "Holtek", tab_vendor_9412}, -{0x9699, "Omni Media Technology Inc", tab_vendor_9699}, -{0x9710, "NetMos Technology", tab_vendor_9710}, -{0x9902, "Stargen Inc.", tab_vendor_9902}, -{0xA0A0, "AOPEN Inc.", NULL}, -{0xA0F1, "UNISYS Corporation", NULL}, -{0xA200, "NEC Corporation", NULL}, -{0xA259, "Hewlett Packard", NULL}, -{0xA25B, "Hewlett Packard GmbH PL24-MKT", NULL}, -{0xA304, "Sony", NULL}, -{0xA727, "3Com Corporation", tab_vendor_A727}, -{0xAA42, "Scitex Digital Video", NULL}, -{0xAC1E, "Digital Receiver Technology Inc", NULL}, -{0xAC3D, "Actuality Systems", NULL}, -{0xAECB, "Adrienne Electronics Corporation", tab_vendor_AECB}, -{0xAFFE, "Sirrix AG security technologies", tab_vendor_AFFE}, -{0xB1B3, "Shiva Europe Limited", NULL}, -{0xBD11, "Pinnacle Systems, Inc. (Wrong ID)", NULL}, -{0xC001, "TSI Telsys", NULL}, -{0xC0A9, "Micron/Crucial Technology", NULL}, -{0xC0DE, "Motorola", NULL}, -{0xC0FE, "Motion Engineering, Inc.", NULL}, -{0xCA50, "Varian Australia Pty Ltd", NULL}, -{0xCAFE, "Chrysalis-ITS", tab_vendor_CAFE}, -{0xCCCC, "Catapult Communications", NULL}, -{0xCDDD, "Tyzx, Inc.", tab_vendor_CDDD}, -{0xD161, "Digium, Inc.", tab_vendor_D161}, -{0xD4D4, "Dy4 Systems Inc", tab_vendor_D4D4}, -{0xD531, "I+ME ACTIA GmbH", NULL}, -{0xD84D, "Exsys", NULL}, -{0xDEAD, "Indigita Corporation", NULL}, -{0xDEAF, "Middle Digital Inc.", tab_vendor_DEAF}, -{0xE000, "Winbond", tab_vendor_E000}, -{0xE159, "Tiger Jet Network Inc.", tab_vendor_E159}, -{0xE4BF, "EKF Elektronik GmbH", NULL}, -{0xE55E, "Essence Technology, Inc.", NULL}, -{0xEA01, "Eagle Technology", tab_vendor_EA01}, -{0xEA60, "RME", tab_vendor_EA60}, -{0xEABB, "Aashima Technology B.V.", NULL}, -{0xEACE, "Endace Measurement Systems, Ltd", tab_vendor_EACE}, -{0xEC80, "Belkin Corporation", tab_vendor_EC80}, -{0xECC0, "Echo Digital Audio Corporation", NULL}, -{0xEDD8, "ARK Logic Inc", tab_vendor_EDD8}, -{0xF1D0, "AJA Video", tab_vendor_F1D0}, -{0xFA57, "Interagon AS", tab_vendor_FA57}, -{0xFAB7, "Fabric7 Systems, Inc.", NULL}, -{0xFEBD, "Ultraview Corp.", NULL}, -{0xFEDA, "Broadcom Inc", tab_vendor_FEDA}, -{0xFEDE, "Fedetec Inc.", tab_vendor_FEDE}, -{0xFFFD, "XenSource, Inc.", tab_vendor_FFFD}, -{0xFFFE, "VMWare Inc", tab_vendor_FFFE}, -{0xFFFF, "Illegal Vendor ID", tab_vendor_FFFF}, -{0x0000, "", NULL}, -}; diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pci.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pci.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pci.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-pci.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,354 +0,0 @@ -#ifndef MEMTEST_PCI_H - #define MEMTEST_PCI_H - -#define PCI_CONF_TYPE_NONE 0 -#define PCI_CONF_TYPE_1 1 -#define PCI_CONF_TYPE_2 2 - -#define PCI_CONF1_ADDRESS(bus, dev, fn, reg) (0x80000000 | (bus << 16) | (dev << 11) | (fn << 8) | (reg & ~3)) -#define PCI_CONF2_ADDRESS(dev, reg) (unsigned short)(0xC000 | (dev << 8) | reg) - - -int pci_conf_read(unsigned bus, unsigned dev, unsigned fn, unsigned reg, - unsigned len, unsigned int *value); -int pci_conf_write(unsigned bus, unsigned dev, unsigned fn, unsigned reg, - unsigned len, unsigned int value); -int pci_init(void); - -/* - * Under PCI, each device has 256 bytes of configuration address space, - * of which the first 64 bytes are standardized as follows: - */ -#define PCI_VENDOR_ID 0x00 /* 16 bits */ -#define PCI_DEVICE_ID 0x02 /* 16 bits */ -#define PCI_COMMAND 0x04 /* 16 bits */ -#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ -#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ -#define PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */ -#define PCI_COMMAND_SPECIAL 0x8 /* Enable response to special cycles */ -#define PCI_COMMAND_INVALIDATE 0x10 /* Use memory write and invalidate */ -#define PCI_COMMAND_VGA_PALETTE 0x20 /* Enable palette snooping */ -#define PCI_COMMAND_PARITY 0x40 /* Enable parity checking */ -#define PCI_COMMAND_WAIT 0x80 /* Enable address/data stepping */ -#define PCI_COMMAND_SERR 0x100 /* Enable SERR */ -#define PCI_COMMAND_FAST_BACK 0x200 /* Enable back-to-back writes */ - -#define PCI_STATUS 0x06 /* 16 bits */ -#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */ -#define PCI_STATUS_66MHZ 0x20 /* Support 66 Mhz PCI 2.1 bus */ -#define PCI_STATUS_UDF 0x40 /* Support User Definable Features [obsolete] */ -#define PCI_STATUS_FAST_BACK 0x80 /* Accept fast-back to back */ -#define PCI_STATUS_PARITY 0x100 /* Detected parity error */ -#define PCI_STATUS_DEVSEL_MASK 0x600 /* DEVSEL timing */ -#define PCI_STATUS_DEVSEL_FAST 0x000 -#define PCI_STATUS_DEVSEL_MEDIUM 0x200 -#define PCI_STATUS_DEVSEL_SLOW 0x400 -#define PCI_STATUS_SIG_TARGET_ABORT 0x800 /* Set on target abort */ -#define PCI_STATUS_REC_TARGET_ABORT 0x1000 /* Master ack of " */ -#define PCI_STATUS_REC_MASTER_ABORT 0x2000 /* Set on master abort */ -#define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000 /* Set when we drive SERR */ -#define PCI_STATUS_DETECTED_PARITY 0x8000 /* Set on parity error */ - -#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 - revision */ -#define PCI_REVISION_ID 0x08 /* Revision ID */ -#define PCI_CLASS_PROG 0x09 /* Reg. Level Programming Interface */ -#define PCI_CLASS_DEVICE 0x0a /* Device class */ - -#define PCI_CACHE_LINE_SIZE 0x0c /* 8 bits */ -#define PCI_LATENCY_TIMER 0x0d /* 8 bits */ -#define PCI_HEADER_TYPE 0x0e /* 8 bits */ -#define PCI_HEADER_TYPE_NORMAL 0 -#define PCI_HEADER_TYPE_BRIDGE 1 -#define PCI_HEADER_TYPE_CARDBUS 2 - -#define PCI_BIST 0x0f /* 8 bits */ -#define PCI_BIST_CODE_MASK 0x0f /* Return result */ -#define PCI_BIST_START 0x40 /* 1 to start BIST, 2 secs or less */ -#define PCI_BIST_CAPABLE 0x80 /* 1 if BIST capable */ - -/* - * Base addresses specify locations in memory or I/O space. - * Decoded size can be determined by writing a value of - * 0xffffffff to the register, and reading it back. Only - * 1 bits are decoded. - */ -#define PCI_BASE_ADDRESS_0 0x10 /* 32 bits */ -#define PCI_BASE_ADDRESS_1 0x14 /* 32 bits [htype 0,1 only] */ -#define PCI_BASE_ADDRESS_2 0x18 /* 32 bits [htype 0 only] */ -#define PCI_BASE_ADDRESS_3 0x1c /* 32 bits */ -#define PCI_BASE_ADDRESS_4 0x20 /* 32 bits */ -#define PCI_BASE_ADDRESS_5 0x24 /* 32 bits */ -#define PCI_BASE_ADDRESS_SPACE 0x01 /* 0 = memory, 1 = I/O */ -#define PCI_BASE_ADDRESS_SPACE_IO 0x01 -#define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00 -#define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06 -#define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00 /* 32 bit address */ -#define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02 /* Below 1M [obsolete] */ -#define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */ -#define PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */ -#define PCI_BASE_ADDRESS_MEM_MASK (~0x0fUL) -#define PCI_BASE_ADDRESS_IO_MASK (~0x03UL) -/* bit 1 is reserved if address_space = 1 */ - - -/* Device classes and subclasses */ -#define PCI_CLASS_NOT_DEFINED 0x0000 -#define PCI_CLASS_NOT_DEFINED_VGA 0x0001 - -#define PCI_BASE_CLASS_BRIDGE 0x06 -#define PCI_CLASS_BRIDGE_HOST 0x0600 - -#endif /* MEMTEST_PCI_H */ - -#ifndef uchar -#define uchar unsigned char -#endif -#ifndef ushort -#define ushort unsigned short -#endif -#ifndef ulong -#define ulong unsigned int -#endif - - -/*MOI MOI*/ -typedef struct pci_info { - ushort vendor_id; /* vendor id */ - ushort device_id; /* device id */ - ushort command; /* bus number */ - ushort status; /* device number on bus */ - uchar revision; /* revision id */ - uchar class_api; /* specific register interface type */ - uchar class_sub; /* specific device function */ - uchar class_base; /* device type (display vs network, etc) */ - uchar line_size; /* cache line size in 32 bit words */ - uchar latency; /* latency timer */ - uchar header_type; /* header type */ - uchar bist; /* built-in self-test */ - - - union { - struct { - //0x10 - ulong base_registers[6]; /* base registers, viewed from host */ - ulong cardbus_cis; /* CardBus CIS pointer */ - - - ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */ - ushort subsystem_id; /* subsystem (add-in card) id */ - //0x30 - ulong rom_base; /* rom base address, viewed from host */ - ulong rom_base_pci; /* rom base addr, viewed from pci */ - ulong rom_size; /* rom size */ - - //0x3c - uchar interrupt_line; /* interrupt line */ - uchar interrupt_pin; /* interrupt pin */ - - //0x3e - uchar min_grant; /* burst period @ 33 Mhz */ - uchar max_latency; /* how often PCI access needed */ - - - } h0; - struct { - //0x10 - ulong base_registers[2]; /* base registers, viewed from host */ - - ulong base_registers_pci[2]; /* base registers, viewed from pci */ - ulong base_register_sizes[2]; /* size of what base regs point to */ - uchar base_register_flags[2]; /* flags from base address fields */ - - uchar primary_bus; - uchar secondary_bus; - uchar subordinate_bus; - uchar secondary_latency; - uchar io_base; - uchar io_limit; - ushort secondary_status; - ushort memory_base; - ushort memory_limit; - ushort prefetchable_memory_base; - ushort prefetchable_memory_limit; - ulong prefetchable_memory_base_upper32; - ulong prefetchable_memory_limit_upper32; - //0x30 - ushort io_base_upper16; - ushort io_limit_upper16; - ulong rom_base; /* rom base address, viewed from host */ - ulong rom_base_pci; /* rom base addr, viewed from pci */ - - //0x3c - uchar interrupt_line; /* interrupt line */ - uchar interrupt_pin; /* interrupt pin */ - ushort bridge_control; - } h1; - } u; -} pci_info; - - - -typedef struct _pci_info { - ushort vendor_id; /* vendor id */ - ushort device_id; /* device id */ - uchar bus; /* bus number */ - uchar device; /* device number on bus */ - uchar function; /* function number in device */ - uchar revision; /* revision id */ - uchar class_api; /* specific register interface type */ - uchar class_sub; /* specific device function */ - uchar class_base; /* device type (display vs network, etc) */ - uchar line_size; /* cache line size in 32 bit words */ - uchar latency; /* latency timer */ - uchar header_type; /* header type */ - uchar bist; /* built-in self-test */ - uchar reserved; /* filler, for alignment */ - union { - struct { - ulong cardbus_cis; /* CardBus CIS pointer */ - ushort subsystem_id; /* subsystem (add-in card) id */ - ushort subsystem_vendor_id; /* subsystem (add-in card) vendor id */ - ulong rom_base; /* rom base address, viewed from host */ - ulong rom_base_pci; /* rom base addr, viewed from pci */ - ulong rom_size; /* rom size */ - ulong base_registers[6]; /* base registers, viewed from host */ - ulong base_registers_pci[6]; /* base registers, viewed from pci */ - ulong base_register_sizes[6]; /* size of what base regs point to */ - uchar base_register_flags[6]; /* flags from base address fields */ - uchar interrupt_line; /* interrupt line */ - uchar interrupt_pin; /* interrupt pin */ - uchar min_grant; /* burst period @ 33 Mhz */ - uchar max_latency; /* how often PCI access needed */ - } _h0; - struct { - ulong base_registers[2]; /* base registers, viewed from host */ - ulong base_registers_pci[2]; /* base registers, viewed from pci */ - ulong base_register_sizes[2]; /* size of what base regs point to */ - uchar base_register_flags[2]; /* flags from base address fields */ - uchar primary_bus; - uchar secondary_bus; - uchar subordinate_bus; - uchar secondary_latency; - uchar io_base; - uchar io_limit; - ushort secondary_status; - ushort memory_base; - ushort memory_limit; - ushort prefetchable_memory_base; - ushort prefetchable_memory_limit; - ulong prefetchable_memory_base_upper32; - ulong prefetchable_memory_limit_upper32; - ushort io_base_upper16; - ushort io_limit_upper16; - ulong rom_base; /* rom base address, viewed from host */ - ulong rom_base_pci; /* rom base addr, viewed from pci */ - uchar interrupt_line; /* interrupt line */ - uchar interrupt_pin; /* interrupt pin */ - ushort bridge_control; - } _h1; - } _u; -} _pci_info; - - - - -/* --- - offsets in PCI configuration space to the elements of the predefined - header common to all header types ---- */ - -#define PCI_vendor_id 0x00 /* (2 byte) vendor id */ -#define PCI_device_id 0x02 /* (2 byte) device id */ -#define PCI_command 0x04 /* (2 byte) command */ -#define PCI_status 0x06 /* (2 byte) status */ -#define PCI_revision 0x08 /* (1 byte) revision id */ -#define PCI_class_api 0x09 /* (1 byte) specific register interface type */ -#define PCI_class_sub 0x0a /* (1 byte) specific device function */ -#define PCI_class_base 0x0b /* (1 byte) device type (display vs network, etc) */ -#define PCI_line_size 0x0c /* (1 byte) cache line size in 32 bit words */ -#define PCI_latency 0x0d /* (1 byte) latency timer */ -#define PCI_header_type 0x0e /* (1 byte) header type */ -#define PCI_bist 0x0f /* (1 byte) built-in self-test */ - - - -/* --- - offsets in PCI configuration space to the elements of the predefined - header common to header types 0x00 and 0x01 ---- */ -#define PCI_base_registers 0x10 /* base registers (size varies) */ -#define PCI_interrupt_line 0x3c /* (1 byte) interrupt line */ -#define PCI_interrupt_pin 0x3d /* (1 byte) interrupt pin */ - - - - -/* --- - offsets in PCI configuration space to the elements of header type 0x00 ---- */ - -#define PCI_cardbus_cis 0x28 /* (4 bytes) CardBus CIS (Card Information Structure) pointer (see PCMCIA v2.10) */ -#define PCI_subsystem_vendor_id 0x2c /* (2 bytes) subsystem (add-in card) vendor id */ -#define PCI_subsystem_id 0x2e /* (2 bytes) subsystem (add-in card) id */ -#define PCI_rom_base 0x30 /* (4 bytes) expansion rom base address */ -#define PCI_min_grant 0x3e /* (1 byte) burst period @ 33 Mhz */ -#define PCI_max_latency 0x3f /* (1 byte) how often PCI access needed */ - - -/* --- - offsets in PCI configuration space to the elements of header type 0x01 (PCI-to-PCI bridge) ---- */ - -#define PCI_primary_bus 0x18 -#define PCI_secondary_bus 0x19 -#define PCI_subordinate_bus 0x1A -#define PCI_secondary_latency 0x1B -#define PCI_io_base 0x1C -#define PCI_io_limit 0x1D -#define PCI_secondary_status 0x1E -#define PCI_memory_base 0x20 -#define PCI_memory_limit 0x22 -#define PCI_prefetchable_memory_base 0x24 -#define PCI_prefetchable_memory_limit 0x26 -#define PCI_prefetchable_memory_base_upper32 0x28 -#define PCI_prefetchable_memory_limit_upper32 0x2C -#define PCI_io_base_upper16 0x30 -#define PCI_io_limit_upper16 0x32 -#define PCI_bridge_rom_base 0x38 -#define PCI_bridge_control 0x3E - - - -/* --- - values for the class_base field in the common header ---- */ - -#define PCI_early 0x00 /* built before class codes defined */ -#define PCI_mass_storage 0x01 /* mass storage_controller */ -#define PCI_network 0x02 /* network controller */ -#define PCI_display 0x03 /* display controller */ -#define PCI_multimedia 0x04 /* multimedia device */ -#define PCI_memory 0x05 /* memory controller */ -#define PCI_bridge 0x06 /* bridge controller */ -#define PCI_simple_communications 0x07 /* simple communications controller */ -#define PCI_base_peripheral 0x08 /* base system peripherals */ -#define PCI_input 0x09 /* input devices */ -#define PCI_docking_station 0x0a /* docking stations */ -#define PCI_processor 0x0b /* processors */ -#define PCI_serial_bus 0x0c /* serial_bus_controller */ - -#define PCI_undefined 0xFF /* not in any defined class */ - - - -struct pci_desc -{ - unsigned int id; - unsigned char name[130]; - struct pci_desc* list; -}; - -typedef struct pci_desc pci_desc; - - diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-syscalls.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-syscalls.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-syscalls.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-syscalls.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#ifndef KE2DBG_SYSCALLS_H - #define KE2DBG_SYSCALLS_H - -#include -#include -#include - -#include -#include -#include - -typedef void (*sighandler_t)(int); - -asmlinkage ssize_t sys_read(int, void *, size_t); -asmlinkage ssize_t sys_write(int, const void *, size_t); -asmlinkage int sys_open(const char *, int, int); -asmlinkage int sys_close(int); -asmlinkage sighandler_t sys_signal(int, sighandler_t); -asmlinkage int sys_execve(struct pt_regs); -asmlinkage int sys_fsync(int); -asmlinkage int sys_readdir(unsigned int, struct dirent *, unsigned int); -asmlinkage int sys_fork(struct pt_regs); -asmlinkage long sys_exit(int); -asmlinkage long sys_rename(const char *, const char *); -asmlinkage long sys_munmap(unsigned long, size_t); -asmlinkage long sys_mmap2(unsigned long, unsigned long, unsigned long, - unsigned long, unsigned long , unsigned long); -asmlinkage long sys_unlink(const char *); -asmlinkage long sys_mprotect(unsigned long, size_t, unsigned long); -asmlinkage long sys_wait4(pid_t, int *, int, struct rusage *); -asmlinkage long sys_waitpid(pid_t, int *, int); -asmlinkage long sys_access(const char *, int); -asmlinkage long sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -asmlinkage long sys_dup2(unsigned int, unsigned int); -asmlinkage off_t sys_lseek(unsigned int, off_t, unsigned int); -asmlinkage long sys_mkdir(const char *, int); -asmlinkage long sys_nanosleep(struct timespec *, struct timespec *); - -#endif diff -Nru eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-vars.h.svn-base eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-vars.h.svn-base --- eresi-0.8a25/libe2dbg/kernel/include/.svn/text-base/ke2dbg-vars.h.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/include/.svn/text-base/ke2dbg-vars.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -/* - * This file is part of the Rasta Ring 0 debug - * - * Copyright (C) 2004 Droids Corporation. - * - * $Id: ke2dbg-vars.h,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ - -#ifndef VARS_H -#define VARS_H - -#include "ke2dbg-config.h" - -#ifndef NULL -#define NULL 0 -#endif - - -#define KE2DBG_CONFIG ".e2dbgrc" - -/* We check whether an ASM style has been chosen */ -#if defined(_MSC_VER) && defined(__GNUC__) -#error Your config.h is wrong : you cannot use MSC_VER *and* GNUC -#endif /* both MSC_VER and GNUC */ -#if ! defined(_MSC_VER) && ! defined(__GNUC__) -#error Your config.h is wrong : you must choose either MSC_VER or GNUC -#endif /* neither MSC_VER nor GNUC */ - -/* - * We check wether a video mode has been chosen. If VIDEO_FB has been - * chosen, a value for SCREEN_ADRESSE needs to be set. - */ -#if defined VIDEO_FB && defined VIDEO_AA -#error Your config.h is wrong : you cannot use VIDEO_FB *and* VIDEO_AA -#endif /* both VIDEO_FB and VIDEO_AA */ -#if ! defined VIDEO_FB && ! defined VIDEO_AA -#error Your config.h is wrong : you must choose either VIDEO_FB or VIDEO_AA -#endif /* neither VIDEO_FB nor VIDEO_AA */ -#if defined VIDEO_FB && ! defined SCREEN_ADRESSE -#error Your config.h is wrong : if you want to use VIDEO_FB, you must define SCREEN_ADRESSE -#endif /* VIDEO_FB without SCREEN_ADRESSE */ - -/* We check that an OS has been chosen */ - -#if defined LINUX_26 && ! defined LINUX -#define LINUX -#warning I set LINUX macro because you have set LINUX_26 -#endif /* LINUX_26 without LINUX */ - -#if defined FREEBSD || defined OPENBSD || defined NETBSD -#define XBSD -#endif - -#if ! defined LINUX && ! defined XBSD && ! defined WIN32 -#error Set your OS in config.h ! (and RTFM) -#endif /* no OS set */ - -#if (defined LINUX && (defined XBSD || defined WIN32)) || (defined XBSD && defined WIN32) -#error You must chose only *one* OS in config.h -#endif - -#if (defined FREEBSD && (defined OPENBSD || defined NETBSD)) || (defined OPENBSD && defined NETBSD) -#error You must chose only *one* OS in config.h -#endif - -#if defined(__GNUC__) -#define _asm_ __asm__ __volatile__ -#endif /* GNUC */ - -#ifdef LINUX - -#define KERNEL_B 0xC0000000 - -#ifndef __KERNEL__ -#define __KERNEL__ -#endif /* __KERNEL__ */ - -#ifndef MODULE -#define MODULE -#endif /* MODULE */ - -#include -#include -#include - -#define Out_Debug_String(a) printk(a) -#define __declspec_naked __attribute__((cdecl)) - -#ifdef LINUX_26 - -#define fake_naked - -#if defined(__GNUC__) -#define RING_HOOO_SEGMENT "$0x7b" -//#define RING_HOOO_SEGMENT "$0x60" -#elif defined(_MSC_VER) -#define RING_HOOO_SEGMENT 0x7b -#endif - -#define RING_HOOO_SEGMENT_VALUE 0x7b -//#define RING_HOOO_SEGMENT_VALUE 0x60 - -#else /* LINUX_24 */ - -#define fake_naked _asm_("\t" \ - "add $0x08, %esp\n\t" \ - "popl %ebp\n" \ -); - -#if defined(__GNUC__) -#define RING_HOOO_SEGMENT "$0x18" -#elif defined(_MSC_VER) -#define RING_HOOO_SEGMENT 0x18 -#endif - -#define RING_HOOO_SEGMENT_VALUE 0x18 - -#endif /* LINUX_26 */ - -#endif /* LINUX */ - -#ifdef XBSD /* Generic stuffs for *BSD */ - -#if defined(__GNUC__) -#define RING_HOOO_SEGMENT "$0x10" -#elif defined(_MSC_VER) -#define RING_HOOO_SEGMENT 0x10 -#endif - -#define RING_HOOO_SEGMENT_VALUE 0x10 - -#include -#include - -#ifdef FREEBSD -#include -#include - -#define KERNEL_B 0xC0000000 -#endif /* FREEBSD */ - -#ifdef OPENBSD -#include -#include -#include -#include - -#define KERNEL_B 0xD0000000 -#endif /* OPENBSD */ - -#ifdef NETBSD -#include -#include -#include -#include - -#define KERNEL_B 0xC0000000 -#endif /* NETBSD */ - -#define __declspec_naked __attribute__((cdecl)) -#define fake_naked _asm_("\t" \ - "popl %ebp\n" \ -); -#define Out_Debug_String(a) printf(a) -#endif /* XBSD */ - -#ifdef WIN32 -#define KERNEL_B 0xC2690000 - -//#include - -extern unsigned int DbgPrint(char* Format,...); -#define Out_Debug_String(_X_) \ - DbgPrint("CANCEL.SYS: ");\ - DbgPrint(_X_); - - - - - - - -#if defined(__GNUC__) -#define RING_HOOO_SEGMENT "$0x30" -#elif defined(_MSC_VER) -#define RING_HOOO_SEGMENT 0x30 -#endif - - -#define RING_HOOO_SEGMENT_VALUE 0x30 -/* -#include -#include -extern void Out_Debug_String(char* psz); -*/ -#define fake_naked -#define __declspec_naked __declspec(naked) - -#endif /* WIN32 */ - - -#define MAX_INT 255 - -#endif /* VARS_H */ diff -Nru eresi-0.8a25/libe2dbg/kernel/interrupts.c eresi-0.0.20110516/libe2dbg/kernel/interrupts.c --- eresi-0.8a25/libe2dbg/kernel/interrupts.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/interrupts.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/interrupts.c +* @file libe2dbg/kernel/interrupts.c * */ #include "ke2dbg.h" @@ -1513,7 +1513,7 @@ /* Initialize REVM interpreter */ e2dbg_kpresence_set(1); revm_init(); - revm_setup(0, NULL, REVM_STATE_DEBUGGER, REVM_SIDE_SERVER); + revm_setup(0, NULL, REVM_STATE_EMBEDDED, REVM_SIDE_SERVER); revm_config(KE2DBG_CONFIG); ke2dbg_commands_install(); return (dwRetVal); diff -Nru eresi-0.8a25/libe2dbg/kernel/kentry.c eresi-0.0.20110516/libe2dbg/kernel/kentry.c --- eresi-0.8a25/libe2dbg/kernel/kentry.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/kentry.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/kentry.c +* @file libe2dbg/kernel/kentry.c */ #include #include diff -Nru eresi-0.8a25/libe2dbg/kernel/kern-bp.c eresi-0.0.20110516/libe2dbg/kernel/kern-bp.c --- eresi-0.8a25/libe2dbg/kernel/kern-bp.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/kern-bp.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/kern-bp.c +* @file libe2dbg/kernel/kern-bp.c */ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/keyboard.c eresi-0.0.20110516/libe2dbg/kernel/keyboard.c --- eresi-0.8a25/libe2dbg/kernel/keyboard.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/keyboard.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/keyboard.c +* @file libe2dbg/kernel/keyboard.c */ #include "ke2dbg.h" #include "ke2dbg-keyb.h" @@ -429,7 +429,7 @@ } */ - world.curjob->curcmd = world.curjob->script[0]; + world.curjob->curcmd = world.curjob->recur[0].script; switch (revm_execmd()) { case REVM_SCRIPT_CONTINUE: diff -Nru eresi-0.8a25/libe2dbg/kernel/libc-wrapper.c eresi-0.0.20110516/libe2dbg/kernel/libc-wrapper.c --- eresi-0.8a25/libe2dbg/kernel/libc-wrapper.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/libc-wrapper.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - ** @file libe2dbg/kernel/libc-wrapper.c +* @file libe2dbg/kernel/libc-wrapper.c **/ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/Makefile eresi-0.0.20110516/libe2dbg/kernel/Makefile --- eresi-0.8a25/libe2dbg/kernel/Makefile 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/Makefile 2011-05-16 11:35:06.000000000 +0000 @@ -2,7 +2,7 @@ ## Makefile for kernel part of libe2dbg in the ERESI framework ## ## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id: Makefile,v 1.1 2008-02-16 12:32:27 thor Exp $ +## $Id: Makefile 1311 2009-01-14 20:36:48Z may $ ## ifneq ($(KERNELRELEASE),) @@ -11,10 +11,10 @@ -I$(src)/../../libelfsh/include/ -I$(src)/../../libasm/include/ \ -I$(src)/../../libstderesi/include/ -I$(src)/../../libmjollnir/include/ \ -I$(src)/../../libaspect/include -I$(src)/../../librevm/include/ \ - -I$(src)/../../libedfmt/include/ -DELFSH_INTERN -DE2DBG_INTERN \ - -DERESI32 -Wno-strict-prototypes + -I$(src)/../../libedfmt/include/ -DE2DBG_INTERN \ + -I$(src)/../../libetrace/include/ -DERESI32 -Wno-strict-prototypes -EXTRAOBJ := ../../libasm/libasm.o ../../libmjollnir/libmjollnir32.o \ +EXTRAOBJ := ../../libasm/libasm32.o ../../libmjollnir/libmjollnir32.o \ ../../libelfsh/libelfsh32.o ../../libedfmt/libedfmt32.o \ ../../librevm/revm-api.32.o ../../libaspect/libaspect32.o \ ../../librevm/revm-machine.32.o ../../librevm/revm-lang.32.o \ diff -Nru eresi-0.8a25/libe2dbg/kernel/page.c eresi-0.0.20110516/libe2dbg/kernel/page.c --- eresi-0.8a25/libe2dbg/kernel/page.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/page.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libke2dbg/kernel/page.c +* @file libe2dbg/kernel/page.c */ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/pci.c eresi-0.0.20110516/libe2dbg/kernel/pci.c --- eresi-0.8a25/libe2dbg/kernel/pci.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/pci.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/pci.c +* @file libe2dbg/kernel/pci.c */ #include "ke2dbg.h" #include "ke2dbg-pci.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/ports.c eresi-0.0.20110516/libe2dbg/kernel/ports.c --- eresi-0.8a25/libe2dbg/kernel/ports.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/ports.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/ports.c +* @file libe2dbg/kernel/ports.c */ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/strings.c eresi-0.0.20110516/libe2dbg/kernel/strings.c --- eresi-0.8a25/libe2dbg/kernel/strings.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/strings.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/strings.c +* @file libe2dbg/kernel/strings.c * * * Imported from glibc-2.7 diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/kernel/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/kernel/.svn/all-wcprops 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/libe2dbg/kernel -END -kern-bp.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/kern-bp.c -END -utils.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/utils.c -END -keyboard.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libe2dbg/kernel/keyboard.c -END -commands.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libe2dbg/kernel/commands.c -END -libasm-enums.err -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/libasm-enums.err -END -video.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/video.c -END -buffering.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/buffering.c -END -ports.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/ports.c -END -pci.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/pci.c -END -kentry.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/kentry.c -END -page.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/page.c -END -interrupts.c -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/946/trunk/libe2dbg/kernel/interrupts.c -END -idt.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/idt.c -END -libc-wrapper.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/947/trunk/libe2dbg/kernel/libc-wrapper.c -END -strings.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libe2dbg/kernel/strings.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/950/trunk/libe2dbg/kernel/Makefile -END -syscalls.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/947/trunk/libe2dbg/kernel/syscalls.c -END diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/entries eresi-0.0.20110516/libe2dbg/kernel/.svn/entries --- eresi-0.8a25/libe2dbg/kernel/.svn/entries 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,235 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg/kernel -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kern-bp.c -file - - - - -2008-04-06T23:16:29.247137Z -00521d9af6ba935a7228afdbcc394fb9 -2008-02-16T12:32:28.000000Z -843 -thor - -utils.c -file - - - - -2008-04-06T23:16:29.283905Z -0305f387d005e776d916cdcecba6fd8a -2008-02-16T12:32:28.000000Z -843 -thor - -keyboard.c -file - - - - -2008-04-06T23:16:29.272901Z -dd0aa945c438651a9887fa18a10d6881 -2008-03-27T22:53:48.747992Z -946 -may - -commands.c -file - - - - -2008-04-06T23:16:29.295977Z -539236f905039225cbc21b00e18b7352 -2008-03-27T22:53:48.747992Z -946 -may - -libasm-enums.err -file - - - - -2008-04-06T23:16:29.307261Z -13f3beb70a9cd4e8ec25a7e20177b543 -2008-02-16T12:32:28.000000Z -843 -thor - -include -dir - -video.c -file - - - - -2008-04-06T23:16:29.318607Z -8a5ecfd12ee70bb9df31f23c5b5624f7 -2008-02-16T12:32:28.000000Z -843 -thor - -buffering.c -file - - - - -2008-04-06T23:16:29.341221Z -32a843c218d47fdacca892c1890b91dd -2008-02-16T12:32:28.000000Z -843 -thor - -ports.c -file - - - - -2008-04-06T23:16:29.329888Z -57ae0e9830f9e039c07067d44e35ba38 -2008-02-16T12:32:28.000000Z -843 -thor - -pci.c -file - - - - -2008-04-06T23:16:29.352876Z -ff29c3538366d7283eb250432b470e5d -2008-02-16T12:32:28.000000Z -843 -thor - -kentry.c -file - - - - -2008-04-06T23:16:29.375900Z -34bf36d90806c880d67728a5c1b6c492 -2008-02-16T12:32:28.000000Z -843 -thor - -page.c -file - - - - -2008-04-06T23:16:29.363905Z -a7b07c08beaf2c8113f8d4efdab9129a -2008-02-16T12:32:28.000000Z -843 -thor - -interrupts.c -file - - - - -2008-04-06T23:16:29.387298Z -541202b990e886accae8893d0b99411e -2008-03-27T22:53:48.747992Z -946 -may - -idt.c -file - - - - -2008-04-06T23:16:29.398876Z -9c7805195187c46141ed1158d7299b1a -2008-02-16T12:32:28.000000Z -843 -thor - -libc-wrapper.c -file - - - - -2008-04-06T23:16:29.410214Z -5a2bda5a46bf08a13f716a683799f0e8 -2008-03-28T09:54:54.348685Z -947 -pouik - -strings.c -file - - - - -2008-04-06T23:16:29.421614Z -58a31e7ddf18e9bc2462c1821fbdfdd7 -2008-02-16T12:32:28.000000Z -843 -thor - -Makefile -file - - - - -2008-04-06T23:16:29.433015Z -549f679efb7afc04a8bc4550e0d56f08 -2008-03-29T07:54:04.209482Z -950 -enioh - -syscalls.c -file - - - - -2008-04-06T23:16:29.443899Z -bd3cdc3d39eacb9729b500d18d5e8100 -2008-03-28T09:54:54.348685Z -947 -pouik - diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/format eresi-0.0.20110516/libe2dbg/kernel/.svn/format --- eresi-0.8a25/libe2dbg/kernel/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/buffering.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/buffering.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/buffering.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/buffering.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,181 +0,0 @@ -/** - * @file libe2dbg/kernel/buffering.c - * - * - */ - -#include "ke2dbg.h" - -int infobuffer; /* =DESACTIVADO; */ -int bufferindex=0; -int insertbufferindex=0; -char buff_cmd[BUFFERMAXCMD][80]; -int insertcmdindex; -int cmdindex; -char buffering[BUFFERMAXLINES][80]; /* 200 lines and 80 chars */ - - -/** - * nettoie le buffer de log - */ -void ke2dbg_logbuf_clean(void) -{ - int x,y=0; - char *ptr; - for (x=0;x50?50:len; - - for (i=0;i=BUFFERMAXLINES) - { - for (i=0;i0) bufferindex--; - -} - -/** - * descend de 10 ligne dans le buffer de log - */ -void ke2dbg_logbuf_downlines(void) -{ - int i; - for (i=0;i<10;i++) - ke2dbg_logbuf_downline(); -} - -/** - * remonte de 10 ligne dans le buffer de log - */ -void ke2dbg_logbuf_uplines(void) -{ - int i; - for (i=0;i<10;i++) - ke2dbg_logbuf_upline(); -} - -/** - * - */ -void ke2dbg_logbuf_start(void) -{ - ke2dbg_ClearAW(); - ke2dbg_logbuf_clean(); - - bufferindex=0; - insertbufferindex=0; -} - -/** - * - */ -void ke2dbg_logbuf_end(void) -{ - -} - -/** - * - */ -void ke2dbg_logbuf_restore(void) -{ - -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/commands.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/commands.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/commands.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/commands.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,325 +0,0 @@ -/** - * @file libe2dbg/kernel/commands.c - * - * - */ -#include "ke2dbg.h" - - -/** - * - * - */ -void ke2dbg_commands_install() -{ - revm_command_add(CMD_RASTA , (void *) cmd_rr0d_rasta, (void *) NULL, 0, ""); - revm_command_add(CMD_RASTA_OFF, (void *) cmd_rr0d_rasta_off, (void *) NULL, 0, ""); - revm_command_add(CMD_FOOL, (void *) cmd_rr0d_foolmode, (void *) NULL, 0, ""); - revm_command_add(CMD_FOOL_OFF, (void *) cmd_rr0d_unfoolmode, (void *) NULL, 0, ""); - revm_command_add(CMD_IDT , (void *) cmd_rr0d_idt, (void *) NULL, 0, ""); - revm_command_add(CMD_BPM , (void *) cmd_rr0d_bpm, (void *) revm_getoption, 1, ""); - revm_command_add(CMD_RINFO, (void *) cmd_rr0d_info, (void *) revm_getoption, 1, ""); - revm_command_add(CMD_EDITMEM, (void *) cmd_rr0d_editmem, (void *) NULL, 0, ""); - revm_command_add(CMD_INTHOOK, (void *) cmd_rr0d_inthook, (void *) revm_getoption, 0, ""); - revm_command_add(CMD_RDTSCHOOK, (void *) cmd_rr0d_rdtschook, (void *) NULL, 0, ""); - - /* It is lacking some commands ! */ - /* - cmd_rr0d_set - cmd_rr0d_print - cmd_rr0d_insertbp - cmd_rr0d_removebp - - what about stepping ? - - @todo need to add b/delete/stepping to eresi vectors - */ - -} - -/** - * - * @return Always 0 - */ -int cmd_rr0d_rasta() -{ - rasta_mode = 1; - ke2dbg_allwin_refresh(); - return (0); -} - -/** - * - * @return Always 0 - */ -int cmd_rr0d_rasta_off() -{ - rasta_mode = 0; - ke2dbg_allwin_refresh(); - return (0); -} - -/** - * - * @return Always 0 - */ -int cmd_rr0d_idt() -{ - ke2dbg_idt_print((unsigned long *) idt_[0]); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_bpm() -{ - ke2dbg_hwbp_set(ke2dbg_virt2lin_convert(current_reg_stack.reg_CS, adresse_ret_1)); - return (0); -} - - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_info() -{ - ke2dbg_page_display(adresse_ret_1); - kedbg_physpage_get(adresse_ret_1); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_editmem() -{ - if (cursor_X == 0 && cursor_Y == 0) - { - cursor_X = 15; - cursor_Y = data_win_y; - } - - cursor_old_color = screen_colors[cursor_Y][cursor_X]; - ke2dbg_cursor_update(cursor_X, cursor_Y); - ke2dbg_logbuf_insert("MeM Edit mode"); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_inthook() -{ - ke2dbg_sprintf(debug__, "inthook N=%d ", adresse_ret_1); - ke2dbg_logbuf_insert(debug__); - if (adresse_ret_1 >=MAX_INT) - { - ke2dbg_logbuf_insert("too big int, man"); - return (-1); - } - - if (is_int_hooked[adresse_ret_1]) - tmp_int[adresse_ret_1] =(void *) ke2dbg_idt_modify( (unsigned int)old_int[adresse_ret_1], - (unsigned int*)idt_[0]+2*adresse_ret_1); - else - { - if (addrnewint[adresse_ret_1]==(unsigned long)NULL) - { - ke2dbg_sprintf(debug__, - "humm, ke2dbg doesn't know how to handle int %d yet, man", adresse_ret_1); - ke2dbg_logbuf_insert(debug__); - return (-1); - } - old_int[adresse_ret_1] =(void *) ke2dbg_idt_modify( (unsigned int)addrnewint[adresse_ret_1], - (unsigned int*)idt_[0]+2*adresse_ret_1); - } - is_int_hooked[adresse_ret_1] = is_int_hooked[adresse_ret_1] ? 0 : 1; - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_rdtschook() -{ - /* TEST RDTSC disable */ - if (hook_rdtsc) - ke2dbg_cr4_set(ke2dbg_cr4_get() & (~0x4)); - else - ke2dbg_cr4_set(ke2dbg_cr4_get() | (0x4)); - hook_rdtsc = (hook_rdtsc ? 0 : 1); - ke2dbg_sprintf(debug__, "AP cr4: %.8X",ke2dbg_cr4_get()); - Out_Debug_String(debug__); - ke2dbg_output(debug__); - return (0); -} - -/** - * - * @return Always 0 - */ -int cmd_rr0d_foolmode() -{ - fOOl_mode = 1; - ke2dbg_allwin_refresh(); - return (0); -} - -/** - * - * @return Always 0 - */ -int cmd_rr0d_unfoolmode() -{ - fOOl_mode = 0; - ke2dbg_allwin_refresh(); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_print() -{ - eresi_Addr val; - - switch(adresse_ret_2) - { - case 0: - val = reg_stack->reg_EAX; - break; - case 1: - val = reg_stack->reg_EBX; - break; - case 2: - val = reg_stack->reg_ECX; - break; - case 3: - val = reg_stack->reg_EDX; - break; - case 4: - val = reg_stack->reg_ESI; - break; - case 5: - val = reg_stack->reg_EDI; - break; - case 6: - val = reg_stack->reg_EIP; - break; - case 7: - val = reg_stack->reg_ESP; - break; - case 8: - val = reg_stack->reg_EBP; - break; - case 9: - val = ke2dbg_dr0_get(); - break; - case 10: - val = ke2dbg_dr1_get(); - break; - case 11: - val = ke2dbg_dr2_get(); - break; - case 12: - val = ke2dbg_dr3_get(); - break; - case 13: - val = ke2dbg_dr6_get(); - break; - case 14: - val = ke2dbg_dr7_get(); - break; - default: - val = 0xDEADFACE; - break; - } - ke2dbg_sprintf(debug__, "%.8X", val); - ke2dbg_logbuf_insert(debug__); - return (0); -} - - - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_set() -{ - switch (adresse_ret_2) - { - case 0: - reg_stack->reg_EAX = adresse_ret_1; - break; - case 1: - reg_stack->reg_EBX = adresse_ret_1; - break; - case 2: - reg_stack->reg_ECX = adresse_ret_1; - break; - case 3: - reg_stack->reg_EDX = adresse_ret_1; - break; - case 4: - reg_stack->reg_ESI = adresse_ret_1; - break; - case 5: - reg_stack->reg_EDI = adresse_ret_1; - break; - case 6: - reg_stack->reg_EIP = adresse_ret_1; - break; - case 7: - reg_stack->reg_ESP = adresse_ret_1; - break; - case 8: - reg_stack->reg_EBP = adresse_ret_1; - break; - default: - break; - } - ke2dbg_sprintf(debug__, "%X <= cr3", ke2dbg_basetp()); - ke2dbg_logbuf_insert(debug__); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_insertbp() -{ - ke2dbg_insert_bp(current_reg_stack.reg_CS, adresse_ret_1, BP_CLASSIC); - return (0); -} - - -/** - * - * @return Always 0 - */ -int cmd_rr0d_removebp() -{ - if (ke2dbg_erase_breakpoint(adresse_ret_1)==-1) - { - ke2dbg_logbuf_insert("not a green break point, man"); - return (-1); - } - return (0); -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/idt.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/idt.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/idt.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/idt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,169 +0,0 @@ -/** - * @file libe2dbg/kernel/buffering.c - * - * - */ -#include "ke2dbg.h" - - -/** - * Get IDT address - */ -unsigned int* ke2dbg_idt_getbase() -{ - _asm_("sidt idt_"); - - idt_[0]=(idt_[0]>>16); - idt_[1]=(idt_[1]<<16); - idt_[0]=(idt_[0]|idt_[1]); - - return (unsigned int*)idt_[0]; -} - - -/** - * Get the linear address for GDT - */ -unsigned int* ke2dbg_gdt_getbase() -{ - _asm_("sgdt gdt_"); - - gdt_[0]=(gdt_[0]>>16); - gdt_[1]=(gdt_[1]<<16); - gdt_[0]=(gdt_[0]|gdt_[1]); - - return (unsigned int*)gdt_[0]; -}; - -/** - * - */ -unsigned int ke2dbg_ldt_getbase(void) -{ - _asm_("sldt ldt_\n"); - - return ldt_[0]; -} - -/** - * - */ -unsigned int ke2dbg_virt2lin_convert(unsigned int segment, unsigned int adresse) -{ - unsigned int index; - unsigned int * dt_base; - unsigned int tmp_ldt; - unsigned int data1, data2; - unsigned int adresse_base; - - dt_base = ke2dbg_gdt_getbase(); - if (segment & 0x4) - { - tmp_ldt = ke2dbg_ldt_getbase(); - - tmp_ldt = tmp_ldt>>3; - - data1 = dt_base[tmp_ldt*2]; - data2 = dt_base[tmp_ldt*2+1]; - - adresse_base= (data1 & 0xffff0000)>>16; - adresse_base+=(data2 & 0x000000ff)<<16; - adresse_base+=(data2 & 0xff000000); - dt_base = (unsigned int*)adresse_base; - } - - index = segment >>3; - data1 = dt_base[index*2]; - data2 = dt_base[index*2+1]; - - adresse_base= (data1 & 0xffff0000)>>16; - adresse_base+=(data2 & 0x000000ff)<<16; - adresse_base+=(data2 & 0xff000000); - //if (segment & 4) - // printk("local! %X \n", adresse_base); - return adresse+adresse_base; - - -} - - -/** - * Print content of IDT - * @param adresse_idt - */ -void ke2dbg_idt_print(unsigned long *adresse_idt) -{ - unsigned int offset; - unsigned int selecteur; - int x; - char tmp[2048]; - - ke2dbg_logbuf_insert("[_ idt list _]"); - ke2dbg_logbuf_insert("--------------------"); - - for(x=0;x<=0x80;) - { - offset=((unsigned long) (*adresse_idt) & 0xffff); - selecteur=((unsigned long) (*adresse_idt) & 0xffff0000)>>16; - adresse_idt++; - offset=offset+((unsigned long) (*adresse_idt) & 0xffff0000); - adresse_idt++; - ke2dbg_sprintf(debug__, "%.2X %.8X %.8X", x, selecteur, offset); - x++; - - offset=((unsigned long) (*adresse_idt) & 0xffff); - selecteur=((unsigned long) (*adresse_idt) & 0xffff0000)>>16; - adresse_idt++; - offset=offset+((unsigned long) (*adresse_idt) & 0xffff0000); - adresse_idt++; - ke2dbg_sprintf(tmp, "%s ³ %.2X %.8X %.8X", debug__, x, selecteur, offset); - x++; - - offset=((unsigned long) (*adresse_idt) & 0xffff); - selecteur=((unsigned long) (*adresse_idt) & 0xffff0000)>>16; - adresse_idt++; - offset=offset+((unsigned long) (*adresse_idt) & 0xffff0000); - adresse_idt++; - ke2dbg_sprintf(debug__, "%s ³ %.2X %.8X %.8X", tmp, x, selecteur, offset); - x++; - - ke2dbg_logbuf_insert(debug__); - - } -} - -/** - * modifie l'entrée de l'idt par l'arg de la - * fonction passée en parametre - * renvoie l'ancien pointeur de l'entrée - * @param newhandler - * @param idtentry - * - * - */ -unsigned long ke2dbg_idt_modify(unsigned int newhandle,unsigned int *idtentry) -{ - unsigned long aux; - - - aux=((unsigned long) (*idtentry) & 0xffff); - *idtentry=(((unsigned long) (*idtentry) & 0xffff0000)|(newhandle & 0xffff)); - idtentry++; - aux=aux+((unsigned long) (*idtentry) & 0xffff0000); - *idtentry=(((unsigned long) (*idtentry) & 0xffff)|(newhandle & 0xffff0000)); - return aux; - -} - -/** - * @param idtentry - */ -unsigned long ke2dbg_idt_readent(unsigned int *idtentry) -{ - unsigned long aux; - - aux=((unsigned long) (*idtentry) & 0xffff); - idtentry++; - aux=aux+((unsigned long) (*idtentry) & 0xffff0000); - return aux; -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/interrupts.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/interrupts.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/interrupts.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/interrupts.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1596 +0,0 @@ -/** - * @file libe2dbg/kernel/interrupts.c - * - */ -#include "ke2dbg.h" - - -/* FB PCI AGP */ -unsigned char fb_hw_padding_var1[0x1000]; -unsigned char fb_hw_flying_page1[1024*0x1000]; -unsigned char fb_hw_padding_var2[0x1000]; -unsigned int fb_hw_flying_page1_sav = 0; -unsigned int fb_hw_flying_page1_level = 0; -/********************/ - -unsigned int stackptr; -void *oldkbd; -void *old_int[MAX_INT]; -void *tmpkbd; -void *tmp_int[MAX_INT]; -unsigned long addrnewkbd; -unsigned long addrnewint[MAX_INT]; -int is_int_hooked[MAX_INT]; - -char debug_[1024] = {0}; -unsigned char key_scan_code = 0; -int fired = 0; -unsigned int in_hlt = 0; -Reg_struct old_reg_data = {0}; -unsigned int asm_lines_adresse[100]={0}; -unsigned int asm_lines_adresse_n = 0; -char asm_line[78] = " "; -char tab_true_byte[500]; - -int num_old_bp = -1; -int step_on = 0; -int spawn_bp = 0; -int spawn_hw_bp = 0; -int id_hw_bp = 0; -unsigned int dr7_value = 0; -unsigned int old_id_hw_bp = 0; - -int bp_num; -int test_=0; - -unsigned int uuu; -unsigned int gdt_limit; -unsigned long idt_[2]; -unsigned long gdt_[2]; -unsigned long ldt_[1]; -eresi_Addr data_ptr; -unsigned int old_data_ptr; -unsigned int update_disasm=1; -unsigned int force_disasm=0; -eresi_Addr code_ptr; -eresi_Addr old_code_ptr; -Reg_struct current_reg_stack; -Reg_struct *reg_stack; -eresi_Addr stack_ptr; -unsigned int oo; -unsigned int saved_eflag; -eresi_Addr current_CS; -eresi_Addr current_DS; -eresi_Addr ring0_ES; -eresi_Addr ring0_FS; -eresi_Addr ring0_GS; -unsigned int mycr2; - -volatile unsigned int ooooooo; - -#define STEP_INTO 0x42 -#define STEP_OVER 0x44 -#define RUN 0xd8 - -unsigned char scratch[0x100]="\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -????????????????\ -"; - - - - - -/** - * Print register state when kernel stopped - * @bug affichage des GS FS en 16bit - * @param regstack -*/ -void ke2dbg_register_print(Reg_struct *regstack) -{ - - ke2dbg_sprintf( debug_, "%.8X", regstack->reg_EAX); - ke2dbg_text_display(5 , 1, debug_); - if (regstack->reg_EAX== old_reg_data.reg_EAX) - ke2dbg_memcpy(&screen_colors[1][5], " ", 8); - else - ke2dbg_memcpy(&screen_colors[1][5], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X", regstack->reg_EBX); - ke2dbg_text_display(18, 1, debug_); - if (regstack->reg_EBX== old_reg_data.reg_EBX) - ke2dbg_memcpy(&screen_colors[1][18], " ", 8); - else - ke2dbg_memcpy(&screen_colors[1][18], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_ECX ); - ke2dbg_text_display(31, 1, debug_); - if (regstack->reg_ECX== old_reg_data.reg_ECX) - ke2dbg_memcpy(&screen_colors[1][31], " ", 8); - else - ke2dbg_memcpy(&screen_colors[1][31], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_EDX ); - ke2dbg_text_display(44, 1, debug_); - if (regstack->reg_EDX== old_reg_data.reg_EDX) - ke2dbg_memcpy(&screen_colors[1][44], " ", 8); - else - ke2dbg_memcpy(&screen_colors[1][44], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_EDI ); - ke2dbg_text_display(57, 1, debug_); - if (regstack->reg_EDI== old_reg_data.reg_EDI) - ke2dbg_memcpy(&screen_colors[1][57], " ", 8); - else - ke2dbg_memcpy(&screen_colors[1][57], "11111111", 8); - - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_ESI ); - ke2dbg_text_display(5 , 2, debug_); - if (regstack->reg_ESI== old_reg_data.reg_ESI) - ke2dbg_memcpy(&screen_colors[2][5], " ", 8); - else - ke2dbg_memcpy(&screen_colors[2][5], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_EBP ); - ke2dbg_text_display(18, 2, debug_); - if (regstack->reg_EBP== old_reg_data.reg_EBP) - ke2dbg_memcpy(&screen_colors[2][18], " ", 8); - else - ke2dbg_memcpy(&screen_colors[2][18], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_ESP ); - ke2dbg_text_display(31, 2, debug_); - if (regstack->reg_ESP== old_reg_data.reg_ESP) - ke2dbg_memcpy(&screen_colors[2][31], " ", 8); - else - ke2dbg_memcpy(&screen_colors[2][31], "11111111", 8); - - ke2dbg_sprintf( debug_, "%.8X",regstack->reg_EIP ); - ke2dbg_text_display(44, 2, debug_); - if (regstack->reg_EIP== old_reg_data.reg_EIP) - ke2dbg_memcpy(&screen_colors[2][44], " ", 8); - else - ke2dbg_memcpy(&screen_colors[2][44], "11111111", 8); - - - debug_[4]=0; - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_CS); - ke2dbg_text_display(5 , 3, debug_); - if (regstack->reg_CS== old_reg_data.reg_CS) - ke2dbg_memcpy(&screen_colors[3][5], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][5], "11111111", 8); - - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_DS); - ke2dbg_text_display(18, 3, debug_); - if (regstack->reg_DS== old_reg_data.reg_DS) - ke2dbg_memcpy(&screen_colors[3][18], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][18], "11111111", 8); - - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_ES); - ke2dbg_text_display(31, 3, debug_); - if (regstack->reg_ES== old_reg_data.reg_ES) - ke2dbg_memcpy(&screen_colors[3][31], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][31], "11111111", 8); - - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_SS); - ke2dbg_text_display(44, 3, debug_); - if (regstack->reg_SS== old_reg_data.reg_SS) - ke2dbg_memcpy(&screen_colors[3][44], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][44], "11111111", 8); - - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_FS); - ke2dbg_text_display(57, 3, debug_); - if (regstack->reg_FS== old_reg_data.reg_FS) - ke2dbg_memcpy(&screen_colors[3][57], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][57], "11111111", 8); - - ke2dbg_sprintf(debug_, "%.2X", regstack->reg_GS); - ke2dbg_text_display(70, 3, debug_); - if (regstack->reg_GS== old_reg_data.reg_GS) - ke2dbg_memcpy(&screen_colors[3][70], " ", 8); - else - ke2dbg_memcpy(&screen_colors[3][70], "11111111", 8); - - - ke2dbg_sprintf(debug_, "%.8X", key_scan_code); - ke2dbg_text_display(43, cmd_win_y+1, debug_); - - - ke2dbg_text_display(53, 2, "FLG="); - - - ke2dbg_sprintf( debug_, "%c%c%c%c%c%c%c%c%c", - regstack->reg_EFLAG&0x800?'O':'o', - regstack->reg_EFLAG&0x400?'D':'d', - regstack->reg_EFLAG&0x200?'I':'i', - regstack->reg_EFLAG&0x100?'T':'t', - regstack->reg_EFLAG&0x80 ?'S':'s', - regstack->reg_EFLAG&0x40 ?'Z':'z', - //20 - regstack->reg_EFLAG&0x10 ?'A':'a', - //8 - regstack->reg_EFLAG&0x4 ?'P':'p', - //2 - regstack->reg_EFLAG&0x1 ?'C':'c' ); - ke2dbg_text_display(57, 2, debug_); - - - screen_colors[2][57]= (regstack->reg_EFLAG&0x800)==(old_reg_data.reg_EFLAG&0x800)?' ':'1'; - screen_colors[2][58]= (regstack->reg_EFLAG&0x400)==(old_reg_data.reg_EFLAG&0x400)?' ':'1'; - screen_colors[2][59]= (regstack->reg_EFLAG&0x200)==(old_reg_data.reg_EFLAG&0x200)?' ':'1'; - screen_colors[2][60]= (regstack->reg_EFLAG&0x100)==(old_reg_data.reg_EFLAG&0x100)?' ':'1'; - screen_colors[2][61]= (regstack->reg_EFLAG&0x80) ==(old_reg_data.reg_EFLAG&0x80)?' ':'1'; - screen_colors[2][62]= (regstack->reg_EFLAG&0x40) ==(old_reg_data.reg_EFLAG&0x40)?' ':'1'; - screen_colors[2][63]= (regstack->reg_EFLAG&0x10) ==(old_reg_data.reg_EFLAG&0x10)?' ':'1'; - screen_colors[2][64]= (regstack->reg_EFLAG&0x4) ==(old_reg_data.reg_EFLAG&0x4)?' ':'1'; - screen_colors[2][65]= (regstack->reg_EFLAG&0x1) ==(old_reg_data.reg_EFLAG&0x1)?' ':'1'; - - if (fired) - ke2dbg_sprintf(debug_, "%.8X", 0xDEADBEEF); - else - ke2dbg_sprintf(debug_, "%.8X", 0); - - ke2dbg_text_display(43, cmd_win_y+2, debug_); - - ke2dbg_display_refresh(); -} - - - -/** - * affiche les codes des touches appuyées - * @param oo - * - */ -void ke2dbg_keystate_print (unsigned int oo) -{ - - - ke2dbg_sprintf(debug_, "Key: %.8X", oo); - ke2dbg_text_display(52, cmd_win_y+1, debug_); - - ke2dbg_sprintf(debug_, "shift: %.1X ctrl: %.1X alt: %.1X", - shift_key, - ctrl_key, - alt_key); - ke2dbg_text_display(52, cmd_win_y, debug_); - ke2dbg_display_refresh(); - -} - - - - -/** - * affiche le contenu de la fenetre de code - * disasm le code a l'adresse specifie - * si la page memoire de l'adresse specifiee - * pas, affiche le disasm de ????? - * cache egalement les octet des brea points - * BUG: lors de la remontee du code asm, mauvaise - * adresse. (retro dasm...) - * - * @param selector - * @param current_eip - */ -void ke2dbg_printf_disasm(eresi_Addr selector, eresi_Addr current_eip) -{ - unsigned int i, ii; - unsigned int vic; - unsigned int decal_printf=0; - unsigned int x=0; - unsigned int index_chaine=0; - - eresi_Addr virtual_eip; - - unsigned char *symbol_name; - unsigned int j; - char asm_out[80]; - asm_instr my_ins; - - if (current_eip != 0) - code_ptr = (unsigned int)current_eip; - - selector = selector & 0xFFFF; - virtual_eip = ke2dbg_virt2lin_convert(selector, (unsigned int)current_eip); - current_eip = virtual_eip; - - if ( (!ke2dbg_page_exist(virtual_eip)) || (!ke2dbg_page_exist(virtual_eip+0x70)) ) - { - for (i=0;i<0x70;i++) - tab_true_byte[i] = '?'; - } - else - { - for (i=0;i<0x70;i++) - tab_true_byte[i] = ke2dbg_true_byte_bp((char *) current_eip + i); - } - - - - asm_lines_adresse_n = 0; - for (i=0;i+decal_printfreg_EIP)) - { - for (ii=14;ii<78;ii++) - screen_colors[code_win_y+i][ii]='2'; - } - else - { - for (ii=14;ii<78;ii++) - screen_colors[code_win_y+i][ii]=' '; - } - - symbol_name = elfsh_reverse_symbol(world.curjob->curfile, current_eip + x, NULL); - - if (symbol_name) - { - - for (j=1;j<15;j++) - { - put_XY_char(j, code_win_y+i+decal_printf, ' '); - } - - j=0; - while(symbol_name[j]) - { - put_XY_char(j+15, code_win_y+i+decal_printf, symbol_name[j]); - j++; - } - - put_XY_char(j+15, code_win_y+i+decal_printf, ':'); - - for (j++;j<78-15;j++) - { - put_XY_char(j+15, code_win_y+i+decal_printf, ' '); - - } - - decal_printf++; - // printf("symbol found:) %s", symbol_name); - } - //#endif - - if (!(i+decal_printfproc); - if (!vic) - { - ke2dbg_sprintf(asm_out, "0x%.2X", *(unsigned char *) current_eip + x); - vic=1; - } - - code_dim_line[i] = vic; - - for (ii = 0 ; iireg_EIP)) - asm_line[77] ='<'; - ke2dbg_print_CW(asm_line, i+decal_printf); - - x+=vic; - } - - ke2dbg_codewin_refresh(); - ke2dbg_display_refresh(); - -} - - - -/** - * affiche la fenetre data. si les pages memoire - * de l'adresse ne sont pas presente, affiche des - * ????? - * @param selecter - * @param ptr - */ -void ke2dbg_data_dump(eresi_Addr selector, eresi_Addr ptr) -{ - unsigned int i, ii; - eresi_Addr virtual_eip; - unsigned char buff[1024]; - unsigned int index_chaine; - - - if (ptr == 0) - ptr = data_ptr; - else - data_ptr = ptr; - - selector = selector & 0xFFFF; - virtual_eip = ke2dbg_virt2lin_convert(selector, (unsigned int)ptr); - ptr = virtual_eip; - - for (i=0;i<0x10 * data_win_dim;i++) - { - if (!ke2dbg_page_exist(virtual_eip+i)) - tab_true_byte[i] = scratch[i]; - else - tab_true_byte[i] = ke2dbg_true_byte_bp((char *) ptr + i); - } - - /* print data en hexa */ - for (i = 0; i < data_win_dim; i++) - { - index_chaine = 0; - index_chaine += ke2dbg_sprintf(buff, "%.4X:%.8X ", selector, ptr + i * 16); - - for (ii = 0; ii < 16; ii++) - index_chaine += ke2dbg_sprintf(buff + index_chaine, "%.2X ", - tab_true_byte[i * 16 + ii] & 0xFF); - - for (ii = 0; ii < 16; ii++) - index_chaine += ke2dbg_sprintf(buff + index_chaine, "%c", - tab_true_byte[i*0x10+ii] ? tab_true_byte[i * 16 + ii] & 0xff : '.'); - - for (ii = 0; ii < 78; ii++) - put_XY_char(ii + 1, data_win_y + i, buff[ii]); - } - - ke2dbg_Refresh_DW(); - ke2dbg_display_refresh(); -} - - -#if defined(__GNUC__) -#define DUMMY_ERR_CODE\ - _asm_("\t"\ - "pushl $0xBADCAFFE\n\t"\ -); - -/*TODO: BUG: ERR de prot gnrale a cause de la restauration de GS ?!? */ - - -#define HOOK_INT_HEADER_ASM(old_hooker)\ - _asm_("\t"\ - "pushl $0xDEADBEEF\n\t"\ - "push %ds\n\t"\ - "push "\ - RING_HOOO_SEGMENT\ - "\n\t"\ - "pop %ds\n\t"\ - "push %gs\n\t"\ - "push %fs\n\t"\ - "push %es\n\t"\ - "mov ring0_ES, %es\n\t"\ - "mov ring0_FS, %fs\n\t"\ - "pusha\n\t"\ - "movl %esp, reg_stack\n\t"\ - );\ - reg_stack->reg_dummy_ret = (unsigned int)old_hooker; - - - -#define HOOK_INT_END_NOERR_ASM(hooker)\ - _asm_("\t"\ - "popa\n\t"\ - "pop %es\n\t"\ - "pop %fs\n\t"\ - "pop %gs\n\t"\ - "cmp $0, fired\n\t"\ - "pop %ds\n\t"\ - "jz not_"hooker"\n\t"\ - "addl $4, %esp\n\t"\ - "addl $4, %esp\n\t"\ - "iret\n\t"\ -"not_"hooker":\n\t"\ - "ret $0x4\n\t"\ - ); - - -#define HOOK_INT_END_ERR_ASM(hooker)\ - _asm_("\t"\ - "popa\n\t"\ - "pop %es\n\t"\ - "pop %fs\n\t"\ - "pop %gs\n\t"\ - "cmp $0, fired\n\t"\ - "pop %ds\n\t"\ - "jz not_"hooker"\n\t"\ - "addl $4, %esp\n\t"\ - "addl $4, %esp\n\t"\ - "iret\n\t"\ -"not_"hooker":\n\t"\ - "ret\n\t"\ - ); -#endif - - -/** - * handler du clavier: - * fonction appelee par l'interruption declenchee - * par l'appuie d'une touche. appele le - * de touche (commande....) - * BUG: scancode extended, (double octet en - * parametre ) - */ -void _ke2dbg_kbdhandle () -{ - unsigned int oo; - /* needed by "boucle de tempo pour ack du 8259" */ - int i; - - //oo = ke2dbg_keystroke_print(); - oo = ke2dbg_scancode_read(); - ke2dbg_handle_scancode((unsigned char)oo); - - if (fired) - { - - if (old_data_ptr!= data_ptr) - { - ke2dbg_data_dump (current_reg_stack.reg_DS, data_ptr); - old_data_ptr = data_ptr; - } - - if (old_code_ptr!= code_ptr) - { - - ke2dbg_printf_disasm (current_reg_stack.reg_CS, code_ptr); - old_code_ptr = code_ptr; - } - - ke2dbg_keystate_print(oo); - - } - - ke2dbg_keystate_print(oo); - - /* boucle de tempo pour ack du 8259 */ - for(i=0;i<100000;i++); - - -} - -/** - * - */ -void __declspec_naked ke2dbg_kbdhandle(void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(oldkbd); - ke2dbg_keystroke_print(); - //_ke2dbg_kbdhandle(); - //HOOK_INT_END_NOERR_ASM("kbh"); - - -#if defined(__GNUC__) - _asm_("\t" - "popa\n\t" - "pop %es\n\t" - "pop %fs\n\t" - "pop %gs\n\t" - "cmp $0, fired\n\t" - "pop %ds\n\t" - "jz not_hook\n\t" - "pushl %eax\n\t" - "mov $0x20, %al\n\t" - "out %al, $0x20\n\t" - "popl %eax\n\t" - "addl $4, %esp\n\t" /*sucre le ret*/ - "addl $4, %esp\n\t" /*sucre le dummy err*/ - "iret\n\t" - "not_hook:\n\t" - "ret $0x4\n\t" - ); -#endif - -} - - - -/** - * rr0d stepping function - * Scan keyboard from here since we are already in interrupt - */ -void ke2dbg_step (void) -{ - int ret=0; - asm_instr my_ins; - int eip_in_asm_win = 0; - unsigned int i; - unsigned char *adresse; - -#if defined(__GNUC__) - _asm_("push %eax;\n" - "pushf;\n" - "pop %eax;\n" - "mov %eax, saved_eflag;\n" - "pop %eax;\n" - "cli;\n" - ); -#endif - - ke2dbg_screen_dump(); - - if (fired) - { - adresse = (unsigned char*) ke2dbg_virt2lin_convert(reg_stack->reg_CS, reg_stack->reg_EIP); - ret = asm_read_instr(&my_ins, (u_char *) adresse, 32, world.curjob->proc); - - debug_[0] = '0' + ret; - debug_[1] = 'Ä'; - - switch (my_ins.instr) - { - - case ASM_CALL: - strcpy(&debug_[2], "CALL"); - debug_[6] = 0; - break; - case ASM_PUSHF: - strcpy(&debug_[2], "pushf/d"); - debug_[6] = 0; - break; - case ASM_POPF: - strcpy(&debug_[2], "popf/d"); - debug_[6] = 0; - break; - case ASM_CLI: - strcpy(&debug_[2], "cli"); - debug_[6] = 0; - break; - case ASM_STI: - strcpy(&debug_[2], "int XX"); - debug_[6] = 0; - break; - case ASM_INT: - break; - default: - strcpy(debug_, "ÄÄÄÄÄÄÄÄÄÄÄÄ"); - debug_[10]=0; - ret = 0; - break; - } - - ke2dbg_text_display(52, cmd_win_y-1, debug_); - } - - - do - { - if (fired) - { - key_scan_code = (unsigned char)ke2dbg_scancode_read(); - ke2dbg_handle_scancode(key_scan_code); - - - //if (old_data_ptr!= data_ptr) - { - ke2dbg_data_dump(current_reg_stack.reg_DS, data_ptr); - old_data_ptr = data_ptr; - } - - eip_in_asm_win = 0; - for (i=0;ireg_CS, (unsigned int)reg_stack->reg_EIP) == - asm_lines_adresse[i]) - { - eip_in_asm_win = 1; - break; - } - - if (!eip_in_asm_win && !force_disasm) - { - code_ptr = reg_stack->reg_EIP; - update_disasm=1; - } - - - if (update_disasm) - { - update_disasm = 0; - ke2dbg_printf_disasm(current_reg_stack.reg_CS, code_ptr); - } - - ke2dbg_register_print(reg_stack); - - if (key_scan_code) - ke2dbg_keystate_print(key_scan_code); - } - - - }while( ((key_scan_code & 0xFF) != STEP_INTO) && - ((key_scan_code & 0xFF) != STEP_OVER) && - ((key_scan_code & 0xFF) != RUN) && - (fired)); - - switch((key_scan_code & 0xFF)) - { - case STEP_INTO: - ke2dbg_screen_restore(0); - break; - default: - ke2dbg_screen_restore(1); - break; - } - -#if defined(__GNUC__) - _asm_("push %eax;\n" - "mov saved_eflag, %eax;\n" - "push %eax;\n" - "popf;\n" - "pop %eax;\n" - ); -#endif - - if ((key_scan_code & 0xFF) == RUN) - { - reg_stack->reg_EFLAG= 0xfffffeff & reg_stack->reg_EFLAG; - step_on = 0; - // fired=0; - } - - if ( ((key_scan_code & 0xFF) == STEP_INTO) || (((key_scan_code & 0xFF) == STEP_OVER)&&(!ret))) - { - step_on = 1; - //in case the sucker did popf with tf off ;) - //humm, I love this smell - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - } - - if (((key_scan_code & 0xFF) == STEP_OVER)&&(ret)) - { - - step_on = 0; - reg_stack->reg_EFLAG= 0xfffffeff & reg_stack->reg_EFLAG; - ke2dbg_insert_bp(current_reg_stack.reg_CS, current_reg_stack.reg_EIP+ret, BP_ONE_SHOT); - } - - - old_reg_data = *reg_stack; - -} - - -/*handler de la division par 0 */ -void _ke2dbg_int0_handle (void) -{ - - if (!fired) - { - ke2dbg_allwin_refresh(); - ke2dbg_display_refresh(); - } - - current_reg_stack = *reg_stack; - force_disasm = 0; - update_disasm = 1; - - /* - ke2dbg_data_dump(reg_stack->reg_DS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_printf_disasm(reg_stack->reg_CS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - */ - - fired=1; - - if (fired) - { ke2dbg_logbuf_insert("(_.-div 0 h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-div 0 ziiip -._)"); } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - if (fired) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - ke2dbg_step(); - -} - -/** - * - */ -void __declspec_naked ke2dbg_int0_handle (void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(old_int[0]); - _ke2dbg_int0_handle(); - HOOK_INT_END_NOERR_ASM("int0"); -}; - - -/** - * handler de l'interruption 1 - *(appelee quant le trap flag est a 1 (pas a pas) - * - * - */ -void _ke2dbg_int1_handle (void) -{ - - - current_reg_stack = *reg_stack; - fired = 1; - force_disasm = 0; - update_disasm = 1; - - ke2dbg_dr7_set(dr7_value); - ke2dbg_sprintf(debug_, "int1: %X", reg_stack->reg_EIP); - ke2dbg_logbuf_insert(debug_); - - - //printk("int1 enter dr7 val:%X\n", ke2dbg_dr7_get()); - /* - if (!ke2dbg_is_hw_breakpoint(reg_stack->reg_EIP)) - { - ke2dbg_logbuf_insert("YuuuupPP tuch DRX"); - */ - //printk("ADD: %X\n", reg_stack->reg_EIP); - /* - ke2dbg_data_dump(reg_stack->reg_DS, (unsigned char*)data_ptr); - ke2dbg_printf_disasm(reg_stack->reg_CS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - step_on = 1; - ke2dbg_step(); - } - */ - - /*int ret;*/ - - if (spawn_bp) - { - ke2dbg_spawn_breakpoint(num_old_bp); - spawn_bp = 0; - if (step_on == 0) - { - ke2dbg_logbuf_insert("YuuuupPP1 "); - return; - } - } - - - if (old_id_hw_bp) - { - ke2dbg_idhwbp_enable(id_hw_bp); - old_id_hw_bp = 0; - if (step_on == 0) - { - ke2dbg_logbuf_insert("YuuuupPP2 "); - return; - } - - } - - - //printk("int1-1 enter dr7 val:%X\n", ke2dbg_dr7_get()); - /* - ke2dbg_data_dump(reg_stack->reg_DS, (unsigned char*)data_ptr); - ke2dbg_printf_disasm(reg_stack->reg_CS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - */ - /*respawn hw bp*/ - - //printk("int1-2 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - if (id_hw_bp) - { - ke2dbg_idhwbp_enable(id_hw_bp); - } - - //printk("int1-3 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - /*if single step caused by hw bp*/ - - - if ((id_hw_bp=ke2dbg_hwbp_check()) != 0) - { - - - - - - // ke2dbg_dr7_set(ke2dbg_dr7_get() | (3 << (id_hw_bp>>1))); - /* - switch(id_hw_bp) - { - case 1: - ke2dbg_dr7_set(ke2dbg_dr7_get() | 0x3<<0); - break; - case 2: - ke2dbg_dr7_set(ke2dbg_dr7_get() | 0x3<<2); - break; - case 4: - ke2dbg_dr7_set(ke2dbg_dr7_get() | 0x3<<4); - break; - case 8: - ke2dbg_dr7_set(ke2dbg_dr7_get() | 0x3<<6); - break; - default: - ke2dbg_logbuf_insert("YuuuupPP HW Str4ngE"); - break; - - - } - */ - - //ke2dbg_dr0_set(0); - - fired=1; - ke2dbg_logbuf_insert("(_.-HW BP SpAWN InT 1-._)"); - - - step_on=1; - ke2dbg_idhwbp_disable(id_hw_bp); - - - old_id_hw_bp = id_hw_bp; - - - - - - } - - - //printk("int1-4 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - if (step_on) - { - if (fired) - { ke2dbg_logbuf_insert("(_.-int 1 h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-int 1 ziiip -._)"); } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - - - ke2dbg_step(); - - if (id_hw_bp) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - } - else - { - reg_stack->reg_EFLAG= 0xfffffeff & reg_stack->reg_EFLAG; - } - - /*TEST TEST ice 386*/ - - dr7_value = ke2dbg_dr7_get(); - /* - ke2dbg_dr6_set( 0); - ke2dbg_dr6_set( ke2dbg_dr6_get() | (1 << 13)); - */ - //printk("int ret dr7 val:%X\n", ke2dbg_dr7_get()); - - -} - -/** - * - */ -void __declspec_naked ke2dbg_int1_handle (void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(old_int[1]); - _ke2dbg_int1_handle(); - HOOK_INT_END_NOERR_ASM("int1"); - - -}; - - -/** - * handler de l'interruption 3 - * gere les break point software, met en mode pas a - * pas, ... - */ -void _ke2dbg_int3_handle (void) -{ - - if (!fired) - { - ke2dbg_allwin_refresh(); - ke2dbg_display_refresh(); - } - - fired=1; - current_reg_stack = *reg_stack; - force_disasm = 0; - update_disasm = 1; - - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - -/* - __asm("push %eax\n" - "push %ds\n" - "pop %eax\n" - "movl %eax, test_\n" - "pop %eax\n" - ); - - printk("ds: %p\n", test_); - - __asm("push %eax\n" - "push %cs\n" - "pop %eax\n" - "movl %eax, test_\n" - "pop %eax\n" - ); - - printk("cs: %p\n", test_); -*/ - //printk("int3 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - if ( (bp_num=ke2dbg_is_breakpoint((unsigned char*)reg_stack->reg_EIP-1))!=-1) - { - reg_stack->reg_EIP--; - if (reg_stack->reg_EIP!=list_breakpoints[bp_num].address) - { - ke2dbg_logbuf_insert("breakpoint diff mapping...changing @"); - list_breakpoints[bp_num].address = reg_stack->reg_EIP; - } - - if ((bp_num == unmapped_bp_to_shoot) && (unmapped_bp_to_shoot!=-1)) - { - ke2dbg_sprintf(debug_, "ke2dbg is deleting a unwanted bp@ %.8X n %d", reg_stack->reg_EIP,bp_num); - ke2dbg_logbuf_insert( debug_); - - list_breakpoints[bp_num].address = reg_stack->reg_EIP; - ke2dbg_erase_breakpoint(bp_num); - unmapped_bp_to_shoot = -1; - return; - - } - - ke2dbg_pass_breakpoint(bp_num); - - num_old_bp = bp_num; - spawn_bp = 1; - } - - - //printk("int3-1 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - if ((bp_num!=-1)&&(list_breakpoints[bp_num].attrib==BP_ONE_SHOT)) - ke2dbg_erase_breakpoint(bp_num); - - //printk("int3-2 enter dr7 val:%X\n", ke2dbg_dr7_get()); - /* - ke2dbg_data_dump(reg_stack->reg_DS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_printf_disasm(reg_stack->reg_CS, (unsigned char*)reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - */ - - if (fired) - { ke2dbg_logbuf_insert("(_.-int 3 h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-int 3 ziiip -._)"); } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - - //printk("int3-3 enter dr7 val:%X\n", ke2dbg_dr7_get()); - - ke2dbg_step(); - - //printk("int3-4 enter dr7 val:%X\n", ke2dbg_dr7_get()); - if ( spawn_bp) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - //printk("int3 ret dr7 val:%X\n", ke2dbg_dr7_get()); - - - dr7_value = ke2dbg_dr7_get(); -} - -/** - * - */ -void __declspec_naked ke2dbg_int3_handle (void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(old_int[3]); - _ke2dbg_int3_handle(); - HOOK_INT_END_NOERR_ASM("int3"); - -}; - - - -/** - * handler de invalid opcode - */ -void _ke2dbg_int6_handle (void) -{ - - if (!fired) - { - ke2dbg_allwin_refresh(); - ke2dbg_display_refresh(); - } - - current_reg_stack = *reg_stack; - force_disasm = 0; - update_disasm = 1; - - fired=1; - - if (fired) - { ke2dbg_logbuf_insert("(_.-invalid op h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-invalid op ziiip -._)"); } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - if (fired) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - ke2dbg_step(); - -} - -/** - * - */ -void __declspec_naked ke2dbg_int6_handle (void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(old_int[6]); - _ke2dbg_int6_handle(); - HOOK_INT_END_NOERR_ASM("int6"); -} - - -/** - * handler d' erreur de protection generale - * ps: l'interruption de la mort - * superstitieux s'abstenir, ca porte malheur. - */ -void _ke2dbg_int13_handle (void) -{ - - if (!fired) - { - ke2dbg_allwin_refresh(); - ke2dbg_display_refresh(); - } - - current_reg_stack = *reg_stack; - force_disasm = 0; - update_disasm = 1; - - fired=1; - - if (fired) - { ke2dbg_logbuf_insert("(_.-general prot fault h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-general prot fault ziiip -._)"); } - - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - if (fired) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - ke2dbg_step(); - -} - -/** - * - */ -void __declspec_naked ke2dbg_int13_handle (void) -{ - fake_naked; - - HOOK_INT_HEADER_ASM(old_int[13]); - _ke2dbg_int13_handle(); - HOOK_INT_END_ERR_ASM("int13"); -} - - -/** - * handler de page fault - */ -void _ke2dbg_int14_handle (void) -{ - current_reg_stack = *reg_stack; - - ke2dbg_data_dump(reg_stack->reg_DS, reg_stack->reg_EIP); - ke2dbg_printf_disasm(reg_stack->reg_CS, reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - - fired=0; - - if (fired) - { ke2dbg_logbuf_insert("(_.-div 14 h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-div 14 ziiip -._)"); } - - - // if (reg_stack->reg_ERROR!=4 && reg_stack->reg_ERROR!=6 && reg_stack->reg_ERROR!=7) - { - - debug_[8]=' '; - // ke2dbg_logbuf_insert( debug_+9); -#if defined(__GNUC__) - _asm_("pushl %eax\n" - "movl %cr2, %eax\n" - "movl %eax, mycr2\n" - "popl %eax\n"); -#endif - /* - hexatoascii(mycr2, debug_+9); - debug_[18]=0; - ke2dbg_logbuf_insert( debug_); - */ - } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - if (fired) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - ke2dbg_step(); - -} - -/** - * - */ -void __declspec_naked ke2dbg_int14_handle (void) -{ - fake_naked; - - HOOK_INT_HEADER_ASM(old_int[14]); - _ke2dbg_int14_handle(); - HOOK_INT_END_ERR_ASM("int14"); -} - - - - -/** - * handler de l'interruption 80 - */ -void _ke2dbg_int128_handle (void) -{ - current_reg_stack = *reg_stack; - - ke2dbg_data_dump(reg_stack->reg_DS, reg_stack->reg_EIP); - ke2dbg_printf_disasm(reg_stack->reg_CS, reg_stack->reg_EIP); - ke2dbg_register_print(reg_stack); - - fired=0; - - if (fired) - { ke2dbg_logbuf_insert("(_.-int128 h00keD-._)"); } - else - { ke2dbg_logbuf_insert("(_.-int128 ziiip -._)"); } - - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); - ke2dbg_display_refresh(); - - if (fired) - reg_stack->reg_EFLAG= 0x100 | reg_stack->reg_EFLAG; - - ke2dbg_step(); - -} - -/** - * - */ -void __declspec_naked ke2dbg_int128_handle (void) -{ - fake_naked; - - DUMMY_ERR_CODE; - HOOK_INT_HEADER_ASM(old_int[128]); - _ke2dbg_int128_handle(); - HOOK_INT_END_NOERR_ASM("int128"); -} - - -/** - * - */ -int ke2dbg_init(void) -{ - unsigned int hw_video_addess = 0; - int dwRetVal = 0; - unsigned int idt; - unsigned int i; - -#ifdef VIDEO_FB - screen_adresse = SCREEN_ADRESSE; -#endif /* VIDEO_FB */ - - font_x = 8; - font_y = 12; - font_bpp = 8; - - - data_ptr = 0; - old_data_ptr = 1; - code_ptr = 0; - old_code_ptr = 1; - - data_win_y = 5;//5; - data_win_dim = 3;//10; - - code_win_y = data_win_y+data_win_dim+1;//11;//16; - code_win_dim = 8;//10; - - buff_win_y = code_win_y+code_win_dim+1;//17;//27; - buff_win_dim = 4;//8; - - cmd_win_y = buff_win_y+buff_win_dim+1;//23;//37; - cmd_win_dim = 3;//3; - - ke2dbg_screen_prepare(); - - screen_offset_x = 0; - screen_offset_y = 0; - - screen_bpp = 2; - - insertcmdindex = 0; - cmdindex = 0; - - reg_stack = ¤t_reg_stack; - current_reg_stack.reg_EIP = 0xC0000000; - current_reg_stack.reg_CS = RING_HOOO_SEGMENT_VALUE; - - pagedir = (unsigned int) ke2dbg_basetp(); - Out_Debug_String("chop cr3...ok\n\r"); - - idt = (unsigned int) ke2dbg_idt_getbase(); - Out_Debug_String("chop idt...\n\r"); - - //hexatoascii(idt,debug__); - - /*sav les valeur de es fs gs*/ -#if defined(__GNUC__) - __asm( - "push %eax\n" - "xor %eax, %eax\n" - "mov %es, %ax\n" - "mov %eax, ring0_ES\n" - "mov %fs, %ax\n" - "mov %eax, ring0_FS\n" - "mov %gs, %ax\n" - "mov %eax, ring0_GS\n" - "pop %eax" - ); -#endif - - ke2dbg_hwbp_reset(); - - for (i=0;i -#include -#include - -extern int ke2dbg_init(void); -extern void ke2dbg_cleanup(void); - -/** - * - */ -int init_module() -{ - MODULE_LICENSE("GPL"); - ke2dbg_init(); - return 0; -} - -/** - * - */ -void cleanup_module() -{ - ke2dbg_cleanup(); -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/kern-bp.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/kern-bp.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/kern-bp.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/kern-bp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ -/** - * @file libe2dbg/kernel/kern-bp.c - */ -#include "ke2dbg.h" - -Bp_struct list_breakpoints[NUM_BREAKPOINTS]={ - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, -}; - -Bp_struct list_hw_breakpoints[NUM_HW_BREAKPOINTS]={ - {0,0,0,0,0}, {0,0,0,0,0}, - {0,0,0,0,0}, {0,0,0,0,0}, -}; - -int unmapped_bp_to_shoot=-1; -unsigned int debug_reg_value; -unsigned int iop; - - - - -/** - * insertion d'un breakpoint: - * /!\ la page de memoire doit etre deja bonne - * sauvegarde l'ancien octet ecrasé par le break - * point, et ajoute dans la liste des bp. - */ -int ke2dbg_insert_bp(unsigned int cs, unsigned int dir, unsigned int attrib) -{ - int x=0; - unsigned int info_page_src; - unsigned int level; - unsigned int padresse; - unsigned char *ptr = (unsigned char*)ke2dbg_virt2lin_convert(cs, dir); - - if (!ptr) - { - ke2dbg_output("All but this address man"); - return -1; - } - - if (!ke2dbg_page_exist((unsigned int) ptr)) - { - ke2dbg_output("page doesn't exist, man"); - return -1; - } - - info_page_src = ke2dbg_pageinfo_get((unsigned int)ptr, NULL, NULL, &level ); - padresse = (info_page_src & 0xfffff000) + ((unsigned int)ptr & 0xfff); - - - for (x=0;x= HW_MAGIC_VALUE) && (bp < HW_MAGIC_VALUE + NUM_HW_BREAKPOINTS)) - { - bp-=HW_MAGIC_VALUE; - - switch(bp) - { - case 0: - ke2dbg_dr0_set(0); break; - case 1: - ke2dbg_dr1_set(0); break; - case 2: - ke2dbg_dr2_set(0); break; - case 3: - ke2dbg_dr3_set(0); break; - default: - ke2dbg_output("but man, what are u doin' there?"); - break; - } - - list_hw_breakpoints[bp].address=0; - return bp; - } - - if (bp>NUM_BREAKPOINTS) - return -1; - - if (!list_breakpoints[bp].address) - return -1; - - - if (!ke2dbg_page_exist(list_breakpoints[bp].address)) - { - ke2dbg_output("yup! bp is not in ram anymore!! system may be unstable"); - return -1; - } - - padresse = ke2dbg_linear2physical((unsigned int)list_breakpoints[bp].address); - - if (padresse !=list_breakpoints[bp].paddress) - { - if ((unmapped_bp_to_shoot!=bp)) - { - ke2dbg_output("lin@ doesnt match phys@. fall back in int del"); - unmapped_bp_to_shoot = bp; - return -1; - } - } - - pbp= (unsigned char *) list_breakpoints[bp].address; - - write_save_dirty( pbp, list_breakpoints[bp].value); - - list_breakpoints[bp].address=0; - list_breakpoints[bp].value=0; - return bp; -} - - - -/** - * remet le bon octet ecrasé par le bp, sans - * l'enlever de la liste des bp - * /!\ la page doit etre en mem - * - */ -int ke2dbg_pass_breakpoint(unsigned int bp) -{ - unsigned char *pbp; - - if (bp>NUM_BREAKPOINTS) - return -1; - - if (list_breakpoints[bp].address) - { - pbp= (unsigned char *) list_breakpoints[bp].address; - write_save_dirty( pbp, list_breakpoints[bp].value); - return bp; - } - else - { - return -1; - } - -} - -/** - * remet un CC sur l'adresse du bp spécifié - * /!\ la page doit etre en mem - */ -int ke2dbg_spawn_breakpoint(unsigned int bp) -{ - unsigned char *pbp; - - if (bp>NUM_BREAKPOINTS) - return -1; - - if (list_breakpoints[bp].address) - { - pbp= (unsigned char *) list_breakpoints[bp].address; - //write_save_dirty( pbp, list_breakpoints[bp].value); - write_save_dirty( pbp, 0xCC); - return bp; - } - else - { - return -1; - } -} - - -/** - * affiche la liste des breakpoint - * (dans la fenetre de log) - * - * - */ -void ke2dbg_display_breakpoints() -{ - unsigned int i=0; - - ke2dbg_output("[_Break point List_]"); - - for (i=0;i - */ -unsigned int ke2dbg_dr0_get() -{ -#if defined(__GNUC__) - get_val("dr0"); -#elif defined(_MSC_VER) - get_val(dr0); -#endif - - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr1_get() -{ -#if defined(__GNUC__) - get_val("dr1"); -#elif defined(_MSC_VER) - get_val(dr1); -#endif - - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr2_get() -{ -#if defined(__GNUC__) - get_val("dr2"); -#elif defined(_MSC_VER) - get_val(dr2); -#endif - - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr3_get() -{ -#if defined(__GNUC__) - get_val("dr3"); -#elif defined(_MSC_VER) - get_val(dr3); -#endif - - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr4_get() -{ - /* -#if defined(__GNUC__) - get_val("dr4"); -#elif defined(_MSC_VER) - get_val(dr4); -#endif - */ - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr5_get() -{ - /* -#if defined(__GNUC__) - get_val("dr5"); -#elif defined(_MSC_VER) - get_val(dr5); -#endif - */ - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr6_get() -{ -#if defined(__GNUC__) - get_val("dr6"); -#elif defined(_MSC_VER) - get_val(dr6); -#endif - - return debug_reg_value; -} - -/** - * @return Return register - */ -unsigned int ke2dbg_dr7_get() -{ -#if defined(__GNUC__) - get_val("dr7"); -#elif defined(_MSC_VER) - get_val(dr7); -#endif - - return debug_reg_value; -} - - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr0_set(unsigned int value) -{ - debug_reg_value = value; - - -#if defined(__GNUC__) - set_val("dr0"); -#elif defined(_MSC_VER) - set_val(dr0); -#endif - -} - - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr1_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - set_val("dr1"); -#elif defined(_MSC_VER) - set_val(dr1); -#endif - -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr2_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - set_val("dr2"); -#elif defined(_MSC_VER) - set_val(dr2); -#endif - -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr3_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - set_val("dr3"); -#elif defined(_MSC_VER) - set_val(dr3); -#endif - -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr4_set(unsigned int value) -{ - debug_reg_value = value; - /* -#if defined(__GNUC__) - set_val("dr4"); -#elif defined(_MSC_VER) - set_val(dr4); -#endif - */ -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr5_set(unsigned int value) -{ - debug_reg_value = value; - /* -#if defined(__GNUC__) - set_val("dr5"); -#elif defined(_MSC_VER) - set_val(dr5); -#endif - */ -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr6_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - set_val("dr6"); -#elif defined(_MSC_VER) - set_val(dr6); -#endif - -} - -/** - * Set register to value - * @param value - */ -void ke2dbg_dr7_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - set_val("dr7"); -#elif defined(_MSC_VER) - set_val(dr7); -#endif - -} - -/** - * Return content of register cr4 - * @return Value of register cr4 - */ -unsigned int ke2dbg_cr4_get() -{ -#if defined(__GNUC__) - //get_val("cr4"); -#elif defined(_MSC_VER) - //get_val(cr4); -#endif - - return debug_reg_value; -} - -/** - * Set cr4 to value - * @param value New value of cr4 - */ -void ke2dbg_cr4_set(unsigned int value) -{ - debug_reg_value = value; - -#if defined(__GNUC__) - //set_val("cr4"); -#elif defined(_MSC_VER) - //set_val(cr4); -#endif - -} - -/** - * - */ -void ke2dbg_hwbp_reset() -{ - int x; - - for (x=0;x3)) - { - ke2dbg_output("Oao, only 4 hw bp on 86, man"); - return ; - } - - mask_current_bp = 0x3<<(num_debug_reg*2); - /*only exec*/ - mask_current_bp &= ~(((0x0<<(num_debug_reg*2)) << 16)); - - /*TEST TEST*/ - - - dr7_val = ke2dbg_dr7_get(); - - - dr7_val |= (mask_ge_le | mask_current_bp); - - - ke2dbg_dr7_set(dr7_val); - switch(num_debug_reg) - { - case 0: - ke2dbg_dr0_set(ad); break; - case 1: - ke2dbg_dr1_set(ad); break; - case 2: - ke2dbg_dr2_set(ad); break; - case 3: - ke2dbg_dr3_set(ad); break; - default: - ke2dbg_output("but man, what are u doin' there?"); - break; - } - - list_hw_breakpoints[num_debug_reg].address = ad; - - -} - - -/** - * @return - */ -int ke2dbg_hwbp_check() -{ - unsigned int dr6_val; - - dr6_val = ke2dbg_dr6_get(); - return dr6_val & 0xf; -} - -/** - * @param i - */ -void ke2dbg_hwbp_enable(int i) -{ - unsigned int mask= 0x3 << (2*i); - unsigned int dr7_val; - - dr7_val = ke2dbg_dr7_get(); - dr7_val|= mask; - ke2dbg_dr7_set(dr7_val); - -} - -/** - * @param i - */ -void ke2dbg_hwbp_disable(int i) -{ - unsigned int mask=~(0x3 << (2*i)); - unsigned int dr7_val; - - dr7_val = ke2dbg_dr7_get(); - dr7_val&= mask; - ke2dbg_dr7_set(dr7_val); - -} - -/** - * @param id_hw_bp - */ -void ke2dbg_idhwbp_enable(int id_hw_bp) -{ - int i; - - for (i=0;i<4;i++) - { - if (id_hw_bp & (1<= 0) - { - *state = mychar; - return 1; - } - key_code_loc = 0; - return 0; -} - -/** - * @return - */ -unsigned int ke2dbg_scancode_read(void) -{ - unsigned char state; - unsigned char m1, m2, m3; - unsigned char signe_X, signe_Y, of_X, of_Y, b1, b2, b3; - int pX, pY; - - if (myke2dbg_keyboard_wait(&state)) - { - key_state = state; - if (!(key_state & 0x20)) - key_code_loc = ke2dbg_inb(KEYBOARD_PORT_60); - else - { - myke2dbg_keyboard_wait(&state); - m1 = ke2dbg_inb(KEYBOARD_PORT_60); - myke2dbg_keyboard_wait(&state); - m2 = ke2dbg_inb(KEYBOARD_PORT_60); - myke2dbg_keyboard_wait(&state); - m3 = ke2dbg_inb(KEYBOARD_PORT_60); - - b1 = m1 & 1; - b2 = m1 & 2; - b3 = m1 & 4; - - signe_X = m1 & 16; - signe_Y = m1 & 32; - - of_X = m1 & 64; - of_Y = m1 & 128; - - m2 = signe_X?((~m2)):m2; - m3 = signe_Y?((~m3)):m3; - - if (of_X) - m2 = 0; - if (of_Y) - m3 = 0; - - pX = m2; - pY = m3; - - if (pX>0) - pX=pX/3 +1; - if (pY>0) - pY=pY/3 +1; - - pX = signe_X?-pX:pX; - pY = signe_Y?pY:-pY; - - ke2dbg_sprintf(debug__, "%d %d", pX, pY); - ke2dbg_logbuf_insert(debug__); - ke2dbg_cursor_update(cursor_X+pX, cursor_Y+pY); - } - } - - return key_code_loc; -} - - - - -/** - * Translate raw keyboard data to ascii - * @param scancode - * @return - */ -char ke2dbg_scan_to_ascii(int scancode) -{ - int down = scancode & 0x80; - - switch (scancode & 0x7f) - { - case 42: - case 54: - shift_key = !down; - break; - - case 29: - ctrl_key = !down; - break; - - case 56: - alt_key = !down; - break; - /* - case 58: - shift_key = !shift_key; - break; - */ - } - - switch (scancode) - { - case 14: return KBDEL; - case 88: return KBF12; - case 87: return KBF11; - case 72: return KBCURSORUP; - case 80: return KBCURSORDOWN; - case 56: return KBLEFTALT; - case 54: return KBRIGHTSHIFT; - case 42: return KBLEFTSHIFT; - case 73: return KBPAGEUP; - case 81: return KBPAGEDOWN; - case 75: return KBCURSORLEFT; - case 77: return KBCURSORRIGHT; - case 1: return KBESC; - - }; - - if (scancode <= 0x80) - return (shift_key ? scantable_MAJ[scancode] : - scantable_N_MAJ[scancode]); - - return KBUP; -} - - - - -/** - * essaye de remonter le listing asm - * de facon un peu pourie (brute - * force...) - * - * @param cur_eip - * @param min_back_line - * @return - */ -long back_disasm(unsigned int cur_eip, int min_back_line) -{ - int back_dec = (min_back_line<10)?10*3:min_back_line*3; - unsigned int tmp_eip; - int num_instr=0; - int ret; - int guard=15; - unsigned int testing_eip; - asm_instr my_ins; - - cur_eip=ke2dbg_virt2lin_convert(current_reg_stack.reg_CS, cur_eip ); - - if (!(ke2dbg_page_exist(cur_eip))) - return 0; - - while((!ke2dbg_page_exist(cur_eip-back_dec))&& (back_dec>0)) - back_dec--; - - if (back_dec==0) - return 0; - - testing_eip= cur_eip - back_dec; - - do - { - if (!ke2dbg_page_exist(testing_eip-1)) - break; - - testing_eip--; - tmp_eip = testing_eip; - num_instr=0; - - do - { - ret = asm_read_instr(&my_ins, (u_char *) tmp_eip, 32, world.curjob->proc); - tmp_eip += ret; - num_instr++; - } while ((ret) && (tmp_eip < cur_eip)); - - guard--; - - } while ((tmp_eip != cur_eip) && (guard >= 0)); - - while (num_instr > min_back_line) - { - testing_eip += asm_read_instr(&my_ins, (u_char *) testing_eip, 32, world.curjob->proc); - num_instr--; - } - - return (cur_eip - testing_eip); -} - - -/** - * ajoute un caractere a la commande courante - * - * @param car - */ -void ke2dbg_cmdkey_insert(char car) /* A new key is pressed and is added to the command */ -{ - accessline[cmd_win_y]=1; - Command[CommandLength]=car; - - screen_lines[cmd_win_y][1+CommandLength]=car; - CommandLength++; - Command[CommandLength]=0x0; -} - -/** - * Clear current command line - */ -void ke2dbg_command_clear() -{ - ke2dbg_line_delete(cmd_win_y); - CommandLength=0; -} - -/** - * Remove char from current line (= backspace) - */ -void ke2dbg_cmdkey_delete() -{ - accessline[cmd_win_y]=1; - if (CommandLength) { - - screen_lines[cmd_win_y][CommandLength]=' '; - - - CommandLength--; - Command[CommandLength]=0x0; - }; -} - - -/** - * Handler for ENTER key - */ -void ke2dbg_keyb_enter() -{ - char **argv; - int argc; - - if (!fired || !CommandLength) - return; - ke2dbg_logbuf_insert(Command); - ke2dbg_command_insert(Command); - - /* Parse command for the kernel debugger */ - argv = revm_input(&argc, Command); - if (argv == ((char **) REVM_INPUT_VOID)) - return; - else if (!argv) - { - revm_cleanup(); - return; - } - if (revm_parseopt(argc, argv) < 0) - { - //XFREE(__FILE__, __FUNCTION__, __LINE__, argv); - return; - } - - /* FIXME-XXX: Seems like this is necessary at some - point but not sure yet in which commands, only - when the original parse_command() return those - values. - - switch (ret) - { - case 2: - data_ptr = adresse_ret_1; - break; - - case 3: - code_ptr = adresse_ret_2; - force_disasm = 1; - update_disasm = 1; - } - */ - - world.curjob->curcmd = world.curjob->script[0]; - switch (revm_execmd()) - { - case REVM_SCRIPT_CONTINUE: - //printf(" [*] e2dbg continue from revm_execmd \n"); - revm_cleanup(); - return; - case REVM_SCRIPT_ERROR: - profiler_error(); - default: - break; - } - - ke2dbg_command_clear(); - ke2dbg_line_delete(cmd_win_y); - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); -} - - - -/* -int old_keyb_enter() -{ - int ret; - - ret = parse_command(Command); - if (ret > 1) - { - ke2dbg_logbuf_insert(cmd_result); - - switch (ret) - { - case 2: - data_ptr = adresse_ret_1; - break; - - case 3: - code_ptr = adresse_ret_2; - force_disasm = 1; - update_disasm = 1; - break; - - case 4: - cmd_rr0d_rasta(); - break; - - case 5: - cmd_rr0d_rasta_off(); - break; - - case 6: - cmd_rr0d_set(); - break; - - case 8: - cmd_help(); - break; - - case 9: - cmd_rr0d_insertbp(); - break; - - case 10: - cmd_rr0d_removebp(); - break; - - case 11: - ke2dbg_display_breakpoints(); - break; - - case 12: - cmd_rr0d_idt(); - break; - - case 13: - cmd_rr0d_bpm(); - break; - - case 15: - cmd_rr0d_info(); - break; - - case 16: - cmd_sym(); - break; - - case 17: - cmd_rr0d_editmem(); - break; - - case 18: - cmd_rr0d_inthook(); - break; - - case 19: - cmd_rr0d_rdtschook(); - break; - - case 20: - cmd_rr0d_foolmode(); - break; - - case 21: - cmd_rr0d_unfoolmode(); - break; - - case 0xff: - cmd_rr0d_print(); - break; - - default: - ke2dbg_sprintf(debug__, "%.8X", adresse_ret_1); - ke2dbg_logbuf_insert(debug__); - break; - } - } - else - ke2dbg_logbuf_insert("BaD Command man"); - - ke2dbg_command_clear(); - ke2dbg_line_delete(cmd_win_y); - ke2dbg_logbuf_print(); - ke2dbg_Refresh_AW(); -} -*/ - -/** - * @param scancode - */ -void ke2dbg_handle_scancode(unsigned char scancode) -{ - int i; - char car; - int len; - unsigned int local_data_ptr; - unsigned int local_data_byte; - - if ((scancode & 0x7f ) == CTRL_KEY) - { - if (scancode & 0x80) - ctrl_key = 0; - else - ctrl_key = 1; - } - - if (ctrl_key) - if ((scancode & 0x7f ) == F_KEY) - { - if (!(scancode & 0x80)) - { - - ctrl_key = 0; - fired = !fired; - return; - } - } - - car = ke2dbg_scan_to_ascii((int) scancode); - switch (car) - { - - /* Exec a commandSi se pulsó enter borra linea y indice igual a 0 */ - case KBENTER: - ke2dbg_keyb_enter(); - break; - - /* Delete the last character pressed */ - case KBDEL: - if (fired) - ke2dbg_cmdkey_delete(); - break; - - case KBPAGEUP: - - /* - if ((infobuffer==ACTIVADO) && (fired)) - ke2dbg_logbuf_upline(); - else if ((disasmindex!=0) && (fired)) - {retrocededesasm(); - }; - */ - - if (fired) - { - if (edit_mode) - { - ke2dbg_cursor_update(cursor_X, cursor_Y-10); - break; - } - - if ((!alt_key)&&(!ctrl_key)&&(!shift_key)) - { - ke2dbg_logbuf_uplines(); - ke2dbg_logbuf_print(); - } - - if (((alt_key)&&(!ctrl_key)&&(!shift_key))) - { - data_ptr-=0x100; - - } - - - if ((!alt_key)&&(ctrl_key)&&(!shift_key)) - { - /* - len=0; - for (i=0;i='0' && car <='9')|| - (car>='a' && car <='f')|| - (car>='A' && car <='F'))) - break; - - if ((car>='0' && car <='9')) - car-='0'; - - if ((car>='a' && car <='f')) - car=car-'a'+10; - - if ((car>='A' && car <='F')) - car=car-'A'+10; - - local_data_ptr = data_ptr + - (cursor_Y-data_win_y) * 0x10 + (cursor_X-14)/3; - - if (ke2dbg_page_exist(local_data_ptr)) - { - local_data_byte = *((unsigned char*)local_data_ptr); - switch((cursor_X)%3) - { - case 0: - local_data_byte&=0xf; - local_data_byte+=car<<4; - break; - - case 1: - local_data_byte&=0xf0; - local_data_byte+=car; - break; - } - write_save_dirty( (unsigned char*)local_data_ptr, - (unsigned char)local_data_byte); - } - - ke2dbg_cursor_update(cursor_X+1, cursor_Y); - ke2dbg_data_dump(current_reg_stack.reg_DS, data_ptr); - } - -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/libasm-enums.err.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/libasm-enums.err.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/libasm-enums.err.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/libasm-enums.err.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1119 +0,0 @@ -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:52: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:52: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:53: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:55: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:55: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:56: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:56: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:53: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:52: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:52: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:61: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:61: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:61: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:62: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:62: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:62: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:62: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:62: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:59: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:65: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:121: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.o: In function `ke2dbg_screen_prepare': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/video.c:117: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:20: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:20: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:22: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:22: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_clean': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:18: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:30: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:30: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:31: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:30: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:31: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:31: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:31: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:31: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `strcpy': -/usr/src/linux-headers-2.6.20-16-generic/include/asm/string.h:30: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `strcpy': -/usr/src/linux-headers-2.6.20-16-generic/include/asm/string.h:30: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `strcpy': -/usr/src/linux-headers-2.6.20-16-generic/include/asm/string.h:30: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `strcpy': -/usr/src/linux-headers-2.6.20-16-generic/include/asm/string.h:32: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `strcpy': -/usr/src/linux-headers-2.6.20-16-generic/include/asm/string.h:32: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:33: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:33: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:33: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:33: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:33: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_insert': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:34: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:40: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:43: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:43: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:43: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:43: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:43: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_command_recall': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:48: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o: In function `ke2dbg_logbuf_end': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.c:141: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/buffering.o:(.bss+0x2e0): multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:61: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:68: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:69: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:69: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:73: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:80: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:80: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:81: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_inl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:85: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:93: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:93: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:93: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_outb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:99: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:99: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:99: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:99: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_outw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:110: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:110: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:110: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:110: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_outl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:121: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:121: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:121: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:121: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `bad': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:130: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:130: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:130: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:130: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:144: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:144: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:144: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:155: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:144: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:155: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:156: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:156: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:159: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:159: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:159: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:159: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_sprintf': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:159: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_isdigit': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:281: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o: In function `ke2dbg_isspace': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:292: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:17: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:17: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:17: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:17: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:20: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:23: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:23: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:24: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:24: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:24: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:24: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:45: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:46: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:21: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:46: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:46: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:34: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:34: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:34: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:34: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:34: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:35: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:35: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:35: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:37: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:59: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.o: In function `pci_conf_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/pci.c:77: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_basetp': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:32: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_basetp': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:32: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_basetp': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:32: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_basetp': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:32: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:34: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:34: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:47: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:47: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:48: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:48: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:76: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:76: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:76: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:76: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:121: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:122: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:124: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:124: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:125: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:126: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:128: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:130: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:130: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:130: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:135: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:134: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:137: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:144: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:145: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:147: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:147: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:147: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:147: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:151: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:153: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:153: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:155: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:159: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:139: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_pageinfo_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:140: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `ke2dbg_page_exist': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:164: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `write_save_dirty': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:295: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.o: In function `kedbg_physpage_get': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/page.c:307: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:226: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:227: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:228: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:229: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:230: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_register_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:231: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_printf_disasm': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:319: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.o: In function `ke2dbg_printf_disasm': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/interrupts.c:336: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:6: multiple definition of `ke2dbg_inb' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:61: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:18: multiple definition of `ke2dbg_inw' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:73: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:30: multiple definition of `ke2dbg_inl' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:85: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:44: multiple definition of `ke2dbg_outb' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:99: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:55: multiple definition of `ke2dbg_outw' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:110: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:66: multiple definition of `ke2dbg_outl' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/utils.c:121: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:6: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:13: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:14: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:14: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:18: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:25: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:25: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:26: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_inl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:30: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:38: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:38: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:38: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outb': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:44: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:44: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:44: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:44: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outw': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:55: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:55: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:55: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:55: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o: In function `ke2dbg_outl': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.c:66: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x54): multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x58): multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x5c): multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x60): multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x64): multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x68): multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x6c): multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x70): multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x74): multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x78): multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x7c): multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x80): multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x84): multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x88): multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x8c): multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x90): multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x94): multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x98): multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x9c): multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0xa0): multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x2a0): multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ports.o:(.bss+0x2c0): multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:8: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:9: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:10: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:11: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `ke2dbg_commands_install': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:12: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `cmd_rr0d_inthook': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:89: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.o: In function `cmd_rr0d_inthook': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/commands.c:107: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_wait': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:44: multiple definition of `e_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:149: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_wait': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:48: multiple definition of `e_op_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:148: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_wait': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:48: multiple definition of `e_vector_arch' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_wait': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:48: multiple definition of `e_proc_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:50: multiple definition of `e_libasm_errorcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:50: multiple definition of `e_ia32_prefix' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:151: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:54: multiple definition of `e_ia32_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:55: multiple definition of `e_asm_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:62: multiple definition of `e_asm_operand_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:155: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:62: multiple definition of `e_asm_enc' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:62: multiple definition of `e_asm_size' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:63: multiple definition of `e_asm_reg8' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:161: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:60: multiple definition of `e_asm_reg16' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:60: multiple definition of `e_asm_reg32' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:163: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:60: multiple definition of `e_asm_regmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:61: multiple definition of `e_asm_regxmm' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:165: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:63: multiple definition of `e_asm_sreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:63: multiple definition of `e_asm_creg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:69: multiple definition of `e_asm_dreg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:173: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:70: multiple definition of `e_sparc_flags' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:77: multiple definition of `e_sparc_gregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:70: multiple definition of `e_sparc_sregisters' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:175: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:81: multiple definition of `e_sparc_state_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:72: multiple definition of `e_sparc_privileged_registers' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:73: multiple definition of `e_sparc_condition_codes' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:177: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:73: multiple definition of `e_sparc_opcode' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:178: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:73: multiple definition of `e_sparc_instr' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:180: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:80: multiple definition of `opcode_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:80: multiple definition of `SPECIAL_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keyboard_write': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:81: multiple definition of `REGIMM_rt_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:134: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:84: multiple definition of `SPECIAL2_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:89: multiple definition of `SPECIAL3_function_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:89: multiple definition of `MOVCI_tf_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:132: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:89: multiple definition of `SRL_shiftrotate_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:91: multiple definition of `SRLV_shiftrotate_field_ecoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:91: multiple definition of `BSHFL_sa_field_encoding' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:136: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:92: multiple definition of `e_mips_instr_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:118: multiple definition of `e_mips_register_types' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:119: multiple definition of `e_mips_operand_type' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:138: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:95: multiple definition of `e_fix_compile_errors' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_keystroke_print': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:97: multiple definition of `quit_msg' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:157: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_scancode_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:199: multiple definition of `prompt_token_setup' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:436: first defined here -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.o: In function `ke2dbg_scancode_read': -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/keyboard.c:201: multiple definition of `prompt_token' -/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.o:/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/kern-bp.c:460: first defined here -make[2]: *** [/home/lmbdwr/ERESI/cvs/libe2dbg/kernel/ke2dbg.o] Error 1 -make[1]: *** [_module_/home/lmbdwr/ERESI/cvs/libe2dbg/kernel] Error 2 -make: *** [all] Error 2 diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/libc-wrapper.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/libc-wrapper.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/libc-wrapper.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/libc-wrapper.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/** - ** @file libe2dbg/kernel/libc-wrapper.c - **/ - -#include "ke2dbg.h" -#include "ke2dbg-syscalls.h" - -ssize_t read(int fd, void *buf, size_t count) -{ - return sys_read(fd, buf, count); -} - -ssize_t write(int fd, const void *buf, size_t count) -{ - return sys_write(fd, buf, count); -} - -int open(const char *pathname, int flags, int mode) -{ - return sys_open(pathname, flags, mode); -} - -int close(int fd) -{ - return sys_close(fd); -} - -sighandler_t signal(int signum, sighandler_t handler) -{ - return sys_signal(signum, handler); -} - -int fsync(int fd) -{ - return sys_fsync(fd); -} - -int readdir(unsigned int fd, struct dirent *dirp, unsigned int count) -{ - return sys_readdir(fd, dirp, count); -} - -//FIXME int sys_fork(struct pt_regs regs) - -void exit(int error_code) -{ - sys_exit(error_code); - return; -} - -int rename(const char *oldname, const char *newname) -{ - return sys_rename(oldname, newname); -} - -int munmap(unsigned long addr, size_t len) -{ - return sys_munmap(addr, len); -} - -/*FIXME -long mmap(unsigned long addr, unsigned long len, - unsigned long prot, unsigned long flags, - unsigned long fd, unsigned long pgoff) -{ - return sys_mmap2(addr, len, prot, flags, fd, pgoff); - }*/ - -int unlink(const char *pathname) -{ - return sys_unlink(pathname); -} - -int mprotect(unsigned long start, size_t len, unsigned long prot) -{ - return sys_mprotect(start, len, prot); -} - -// FIXME long sys_wait4(pid_t pid, int *stat_addr, int options, struct rusage *ru) - -// FIXME long sys_waitpid(pid_t pid, int *stat_addr, int options) - - -int access(const char *filename, int mode) -{ - return sys_access(filename, mode); -} - -//FIXME asmlinkage long sys_access(const char *, int); -//FIXME asmlinkage long sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -//FIXME asmlinkage long sys_dup2(unsigned int, unsigned int); -//FIXME asmlinkage off_t sys_lseek(unsigned int, off_t, unsigned int); -//FIXME asmlinkage long sys_mkdir(const char *, int); -//FIXME asmlinkage long sys_nanosleep(struct timespec *, struct timespec *); diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -## -## Makefile for kernel part of libe2dbg in the ERESI framework -## -## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id: Makefile,v 1.1 2008-02-16 12:32:27 thor Exp $ -## - -ifneq ($(KERNELRELEASE),) - -EXTRA_CFLAGS := -g3 -Wall -I/usr/include -I$(src)/include -I$(src)/../include \ - -I$(src)/../../libelfsh/include/ -I$(src)/../../libasm/include/ \ - -I$(src)/../../libstderesi/include/ -I$(src)/../../libmjollnir/include/ \ - -I$(src)/../../libaspect/include -I$(src)/../../librevm/include/ \ - -I$(src)/../../libedfmt/include/ -DELFSH_INTERN -DE2DBG_INTERN \ - -DERESI32 -Wno-strict-prototypes - -EXTRAOBJ := ../../libasm/libasm.o ../../libmjollnir/libmjollnir32.o \ - ../../libelfsh/libelfsh32.o ../../libedfmt/libedfmt32.o \ - ../../librevm/revm-api.32.o ../../libaspect/libaspect32.o \ - ../../librevm/revm-machine.32.o ../../librevm/revm-lang.32.o \ - ../../libstderesi/libstderesi32.o ../../libregex/regex.o \ - ../../libetrace/libetrace32.o ../../librevm/revm-io.32.o \ - ../../libe2dbg/common/*.32.o - -ke2dbg-y := kern-bp.o kentry.o video.o buffering.o utils.o pci.o page.o \ - interrupts.o ports.o commands.o keyboard.o idt.o syscalls.o libc-wrapper.o $(EXTRAOBJ) - -obj-m := ke2dbg.o - -else - -ke2dbg.ko: - $(MAKE) -C /lib/modules/`uname -r`/build M=`pwd`/ - -all: ke2dbg.ko - -clean:: - @$(RM) *.o *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean:: clean - @$(RM) *.ko - -endif diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/page.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/page.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/page.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/page.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,425 +0,0 @@ -/** - * @file libke2dbg/kernel/page.c - */ -#include "ke2dbg.h" - - -unsigned int pagedir; -int init_p=0; -unsigned int saved_wp_bit=0; -unsigned char flying_page1[0x4000] = {'o'}; - - - - -/** - * renvoie l'adresse du repertoire des pages - * /!\ dépendant de l'os pour l'adresse base du - * kernel: sous win c2690000 sous nux c0000000 - */ -unsigned int *ke2dbg_basetp(void) -{ - -#if defined(__GNUC__) - _asm_("\t" - "movl %cr3, %eax\n\t" - "movl %eax, pagedir\n" - ); -#elif defined(_MSC_VER) - __asm{ - mov eax, cr3 - mov pagedir, eax - }; -#endif - - /* /!\ BUG KERNEL BASE */ - pagedir += KERNEL_B; - return (unsigned int*)pagedir; -} - - - -/** - * affiche (plus) les info des tables - */ -void ke2dbg_pageinfo_print(void) -{ - unsigned int *page_tab; - int i; - unsigned int ke2dbg_pageinfo_print; - unsigned int adr; - unsigned int info; - - page_tab = ke2dbg_basetp(); - for (i=0;i<1024;i++) - { - ke2dbg_pageinfo_print = page_tab[i]; - /* KERNEL_B */ - adr = ke2dbg_pageinfo_print & 0xFFFFF000; - info =ke2dbg_pageinfo_print & 0x00000FFF; - - if (!(info & 1)) - continue; -#if 0 - printf("%.8X %.8X %.3X %.8X ", ke2dbg_pageinfo_print, adr, info, i*0x00400000); - printf("p:%d ", (info&1)?1:0); /* p */ - printf("r:%d ", (info&2)?1:0); /* r */ - printf("a:%d ", (info&0x20)?1:0); /* access */ - printf("mode:%d ", (info&0x4)?1:0); /* mode */ - printf("\n"); -#endif - - } - -} - - - -/** - * renvoie l'attribut de la page et affecte le niveau: - * (si level!=NULL) 0: merdouille; 1: 1er niveau; 2: 2 eme niveau - * - * @param adresse - * @param tab_page - * @param tab_page_entry - * @param level - * @return - */ -unsigned int ke2dbg_pageinfo_get(unsigned int adresse, unsigned int *tab_page, - unsigned int *tab_page_entry, unsigned int *level) -{ - - -#if defined FREEBSD - /*TODO: non quand meme, faudrait faire qq chose pour les *bsd*/ - - if (level) - *level=0; - - if (tab_page) - *tab_page = (unsigned int)PTD; - - if (!(PTD[adresse >> 22] & 1)) - return 0; - - if (PTD[adresse >> 22]&0x80) - { - if (level) - *level=1; - return PTD[adresse >> 22]; - } - - if (level) - *level=2; - - if (!(PTmap[adresse >> 12] & 1)) - return 0; - - if (tab_page_entry) - *tab_page_entry = (unsigned int)PTmap; - - - return PTmap[adresse >> 12]; - - //return 1; -#else - unsigned int *page_tab; - unsigned int *sub_page_tab; - int page_dir; - int page; - unsigned int ke2dbg_pageinfo_print; - unsigned int sub_ke2dbg_pageinfo_print; - unsigned int tmp; - - - if (level) - *level=0; - - page_tab = ke2dbg_basetp(); - page_dir = (adresse>>22) & 0x3FF; - ke2dbg_pageinfo_print = page_tab[page_dir]; - - if (tab_page) - { - tmp = (unsigned int)(ke2dbg_pageinfo_print & 0xFFFFF000)+KERNEL_B; - *tab_page = (unsigned int)tmp; - } - - if (!(ke2dbg_pageinfo_print&1)) - return 0; - - if (ke2dbg_pageinfo_print&0x80) - { - if (level) - *level=1; - return ke2dbg_pageinfo_print; - } - - if (level) - *level=2; - - tmp = (ke2dbg_pageinfo_print & 0xFFFFF000)+KERNEL_B; - sub_page_tab = (unsigned int*)tmp; - - if (tab_page_entry) - *tab_page_entry = (unsigned int)sub_page_tab; - - page= (adresse>>12) & 0x3FF; - - sub_ke2dbg_pageinfo_print = sub_page_tab[page]; - - return sub_ke2dbg_pageinfo_print; -#endif -} - -/** - * renvoie si une page est présente en memoire - * - * @param adresse - * @return - */ -int ke2dbg_page_exist(unsigned int adresse) -{ - return ke2dbg_pageinfo_get(adresse, NULL, NULL, NULL) & 1; -} - -/** - * @param adresse - * @param data - * @param level - * @return - */ -unsigned int ke2dbg_pageinfo_set(unsigned int adresse, unsigned int data, unsigned int level) -{ - unsigned int *page_tab; - unsigned int *sub_page_tab; - unsigned int ke2dbg_pageinfo_print; - - ke2dbg_pageinfo_print = ke2dbg_pageinfo_get(adresse, - (unsigned int*)&page_tab, - (unsigned int*)&sub_page_tab, - NULL); - - if (!ke2dbg_pageinfo_print) - return 0; - - if (level==0) - return 0; - - if (level==1) - { - page_tab[(adresse>>22) & 0x3FF]=data; - return 0x1337; - } - - if (level==2) - { - sub_page_tab[(adresse>>12) & 0x3FF]=data; - } - return 0x1337; -} - -/** - * @param ptr - * @return - */ -unsigned int ke2dbg_linear2physical(unsigned int ptr) -{ - unsigned int info_page_src; - info_page_src = ke2dbg_pageinfo_get(ptr, NULL, NULL, NULL ); - return (info_page_src & 0xfffff000) + (ptr & 0xfff); -} - - -/** - * @param ptr - */ -void ke2dbg_page_display(unsigned int ptr) -{ - unsigned char debug[80]; - unsigned int page_ad; - - - page_ad = ke2dbg_pageinfo_get(ptr, NULL, NULL, NULL ); - - if (!(page_ad & 0x1)) - { - ke2dbg_output("Not present"); - return; - } - ke2dbg_sprintf(debug, "%.8X %.8X %s %s %s %s %s %s", - ptr, - page_ad, - (page_ad & 0x2)?"R/W":"R", - (page_ad & 0x4)?"U":"S", - (page_ad & 0x20)?"a":"!a", - (page_ad & 0x40)?"d":"!d", - (page_ad & 0x80)?"4M":"4K", - (page_ad & 0x100)?"G":"L"); - ke2dbg_output(debug); - -} - -/** - * - */ -void ke2dbg_wpbit_reset(void) -{ -#if defined(__GNUC__) - _asm_( - "push %eax\n\t" - "movl %cr0,%eax\n\t" - "movl %eax, saved_wp_bit\n\t" - "andl $0xFFFEFFFF,%eax\n\t" - "movl %eax,%cr0\n\t" - "pop %eax\n\t" - ); -#elif defined(_MSC_VER) - _asm{ - push eax - mov eax, cr0 - mov saved_wp_bit, eax - and eax, 0xFFFEFFFF - mov cr0, eax - pop eax - }; -#endif - - - saved_wp_bit = saved_wp_bit & 0x00010000; -} - -/** - * - */ -void ke2dbg_wpbit_set(void) -{ - -#if defined(__GNUC__) - _asm_( - "push %eax\n\t" - "movl %cr0,%eax\n\t" - "andl $0xFFFEFFFF, %eax\n\t" - "orl saved_wp_bit, %eax\n\t" - "movl %eax,%cr0\n\t" - "pop %eax\n\t" - ); -#elif defined(_MSC_VER) - _asm{ - push eax - mov eax,cr0 - and eax, 0xFFFEFFFF - or eax, saved_wp_bit - mov cr0,eax - pop eax - }; -#endif - - -} - - -/** - * @param ptr - * @param o - * @return - */ -int write_save_dirty(unsigned char* ptr, unsigned char o) -{ - - unsigned int info_page_src; - unsigned int level; - - info_page_src = ke2dbg_pageinfo_get((unsigned int)ptr, NULL, NULL, &level ); - ke2dbg_wpbit_reset(); - *ptr = o; - - ke2dbg_pageinfo_set((unsigned int)ptr, info_page_src, level); - ke2dbg_wpbit_set(); - return 0; -} - -/** - * @param ad - * @return - */ -unsigned int kedbg_physpage_get(unsigned int ad) -{ - unsigned char debug[80]; - unsigned int i; - unsigned int info_page_src; - unsigned int level; - - ad &= 0xFFFFF000; - for (i=0;i<0xFFFF0000;i+=0x1000) - { - info_page_src = ke2dbg_pageinfo_get((unsigned int)i, NULL, NULL, &level )& 0xFFFFF000; - if (info_page_src == ad) - { - ke2dbg_sprintf(debug, "%.8X", i); - ke2dbg_output(debug); - } - } - - return 0; -} - -/** - * @param ptr - * @param v - */ -void poked1(unsigned int ptr, unsigned int v) -{ - unsigned int info_page_src; - unsigned int level; - unsigned char* ptr_flying = (unsigned char*)(((unsigned int) &flying_page1[0x1000]) & 0xFFFFF000); - unsigned int ptr_hi = ptr & 0xFFFFF000; - unsigned int ptr_lo = ptr & 0x00000FFF; - //unsigned char debug[80]; - //unsigned int toto; - ptr_lo &= 0xFFFFFFFC; - -#if defined(__GNUC__) - _asm_("\t" - "pushl %eax\n\t" - "movl %cr3, %eax\n\t" - "movl %eax, %cr3\n" - "popl %eax\n\t" - ); -#endif - - info_page_src = ke2dbg_pageinfo_get((unsigned int)ptr_flying, NULL, NULL, &level ); - - if (info_page_src & 0x80) - { - Out_Debug_String("bad\n"); - return; - } - - //printk("%X %X %X %X\n", ptr_flying, ptr_hi + (info_page_src & 0x00000FFF), &ptr_flying[ptr_lo], level); - ke2dbg_wpbit_reset(); - - ke2dbg_pageinfo_set((unsigned int)ptr_flying, ptr_hi + (info_page_src & 0x00000EFF), level); - -#if defined(__GNUC__) - _asm_("\t" - "pushl %eax\n\t" - "movl %cr3, %eax\n\t" - "movl %eax, %cr3\n" - "popl %eax\n\t" ); -#endif - - *((unsigned int*)(&ptr_flying[ptr_lo])) =v; - - ke2dbg_pageinfo_set((unsigned int)ptr_flying, info_page_src, level); - -#if defined(__GNUC__) - _asm_("\t" - "pushl %eax\n\t" - "movl %cr3, %eax\n\t" - "movl %eax, %cr3\n" - "popl %eax\n\t"); -#endif - - ke2dbg_wpbit_set(); -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/pci.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/pci.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/pci.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/pci.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,309 +0,0 @@ -/** - * @file libe2dbg/kernel/pci.c - */ -#include "ke2dbg.h" -#include "ke2dbg-pci.h" -#include "ke2dbg-pcidata.h" - - -static unsigned char pci_conf_type = PCI_CONF_TYPE_1;//PCI_CONF_TYPE_NONE; - -/** - * @param bus - * @param dev - * @param reg - * @param len - * @param value - * @return - */ -int pci_conf_read(unsigned bus, unsigned dev, unsigned fn, unsigned reg, unsigned len, unsigned int *value) -{ - int result; - - if (!value || (bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) - return -1; - - result = -1; - switch(pci_conf_type) { - case PCI_CONF_TYPE_1: - ke2dbg_outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8); - switch(len) { - case 1: *value = ke2dbg_inb(0xCFC + (reg & 3)); result = 0; break; - case 2: *value = ke2dbg_inw(0xCFC + (reg & 2)); result = 0; break; - case 4: *value = ke2dbg_inl(0xCFC); result = 0; break; - } - break; - case PCI_CONF_TYPE_2: - ke2dbg_outb(0xF0 | (fn << 1), 0xCF8); - ke2dbg_outb((unsigned char)bus, 0xCFA); - - switch(len) { - case 1: *value = ke2dbg_inb(PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - case 2: *value = ke2dbg_inw(PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - case 4: *value = ke2dbg_inl(PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - } - ke2dbg_outb(0, 0xCF8); - break; - } - return result; -} - -/** - * - * @param bus - * @param dev - * @param fn - * @param reg - * @param len - * @param value - */ -int pci_conf_write(unsigned bus, unsigned dev, unsigned fn, unsigned reg, unsigned len, unsigned int value) -{ - int result; - - if ((bus > 255) || (dev > 31) || (fn > 7) || (reg > 255)) - return -1; - - result = -1; - switch(pci_conf_type) { - case PCI_CONF_TYPE_1: - ke2dbg_outl(PCI_CONF1_ADDRESS(bus, dev, fn, reg), 0xCF8); - switch(len) { - case 1: ke2dbg_outb((unsigned char)value, 0xCFC + (reg & 3)); result = 0; break; - case 2: ke2dbg_outw((unsigned short)value, 0xCFC + (reg & 2)); result = 0; break; - case 4: ke2dbg_outl(value, 0xCFC); result = 0; break; - } - break; - case PCI_CONF_TYPE_2: - ke2dbg_outb(0xF0 | (fn << 1), 0xCF8); - ke2dbg_outb((unsigned char)bus, 0xCFA); - - switch(len) { - case 1: ke2dbg_outb((unsigned char)value, PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - case 2: ke2dbg_outw((unsigned short)value, PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - case 4: ke2dbg_outl(value, PCI_CONF2_ADDRESS(dev, reg)); result = 0; break; - } - ke2dbg_outb(0, 0xCF8); - break; - } - return result; -} - - -/** - * @param v - * @param d - * @param out_char - * @return - */ -unsigned int pci_get_name(unsigned int v, unsigned int d, unsigned char *out_char) -{ - unsigned int i, ii; - pci_desc* vendor; - pci_desc* device; - unsigned int precision = 0; - - - - for(i=0;i< sizeof(tab_vendor)/sizeof(pci_desc);i++) - { - vendor=&tab_vendor[i]; - if (vendor->id != v) - continue; - - //printf("%s\n", vendor->name); - strcpy(out_char, vendor->name); - strcat(out_char, " "); - precision=1; - if (vendor->list == NULL) - continue; - - for(ii=0;;ii++) - { - device = &(vendor->list[ii]); - if (device->id == 0) - break; - - - if (device->id == d) - //printf("%s\n", device->name); - strcat(out_char, device->name); - } - - - precision=2; - return precision; - } - - - return precision; -} - -/** - * - */ -void pci_list_controller(void) -{ - - - int i; - unsigned int ctrl_bus; - unsigned int ctrl_dev; - unsigned int ctrl_fn; - - int result; - unsigned int tmp; - unsigned int vendor; - unsigned int device; - unsigned char pci_data[0x40]; - unsigned char debug[256]; - - - for (ctrl_bus = 0;ctrl_bus<255;ctrl_bus++) - for (ctrl_dev = 0;ctrl_dev<31;ctrl_dev++) - for (ctrl_fn = 0;ctrl_fn<7;ctrl_fn++) - { - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, PCI_vendor_id ,2, &vendor ); - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, PCI_device_id ,2, &device ); - - if ((vendor == 0xFFFF || device == 0xFFFF ) || - (vendor == 0x0 && device == 0x0)) - continue; - ke2dbg_sprintf(debug, "%.4X %.4X\n", vendor, device); - Out_Debug_String(debug); - pci_get_name(vendor, device, debug); - strcat(debug, "\n"); - Out_Debug_String(debug); - - for (i=0;i<0x40;i++) - { - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, i,1, &tmp); - pci_data[i] = (unsigned char)(tmp&0xff); -#ifdef PCI_DEBUG - ke2dbg_sprintf(debug, "%.2X ", tmp&0xFF); - Out_Debug_String(debug); - if (i%16==15) - Out_Debug_String("\n"); -#endif - - } - - - - } - - - -} - -/** - * If a display is found, give back its reg adress - */ -unsigned int pci_detect_display(void) -{ - - - int i; - unsigned int ctrl_bus; - unsigned int ctrl_dev; - unsigned int ctrl_fn; - - unsigned int header_type_tmp; - - int result; - unsigned int tmp; - unsigned int vendor; - unsigned int device; - unsigned char pci_data[0x40]; - pci_info* p_pci_info; - - unsigned char debug[256]; - unsigned int reg1_address; - - Out_Debug_String("Start pci scan\n"); - - - for (ctrl_bus = 0;ctrl_bus<255;ctrl_bus++) - for (ctrl_dev = 0;ctrl_dev<31;ctrl_dev++) - for (ctrl_fn = 0;ctrl_fn<7;ctrl_fn++) - { - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, PCI_vendor_id ,2, &vendor ); - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, PCI_device_id ,2, &device ); - - if ((vendor == 0xFFFF || device == 0xFFFF ) || - (vendor == 0x0 && device == 0x0)) - continue; - - ke2dbg_sprintf(debug, "%.4X %.4X\n", vendor, device); - Out_Debug_String(debug); - - - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, PCI_header_type,1, &header_type_tmp); - - header_type_tmp&=0x7F; - - ke2dbg_sprintf(debug, "Header type %.2X\n", header_type_tmp); - Out_Debug_String(debug); - - for (i=0;i<0x40;i++) - { - result = pci_conf_read(ctrl_bus, ctrl_dev, ctrl_fn, i,1, &tmp); - pci_data[i] = (unsigned char)(tmp&0xff); -#ifdef PCI_DEBUG - ke2dbg_sprintf(debug, "%.2X ", tmp&0xFF); - Out_Debug_String(debug); - if (i%16==15) - Out_Debug_String("\n"); -#endif - } - - p_pci_info = (pci_info*)pci_data; - - - //If its not a display device - if (p_pci_info->class_base != 3) - continue; - - if (header_type_tmp == 0) - { - reg1_address = p_pci_info->u.h0.base_registers[1]; - } - else if (header_type_tmp == 1) - { - reg1_address = p_pci_info->u.h1.base_registers[1]; - } - else - { - Out_Debug_String("Strange Header...\n"); - continue; - } - - - if (reg1_address & PCI_BASE_ADDRESS_SPACE) - { - Out_Debug_String("Device with io...\n"); - continue; - } - - reg1_address &= ~PCI_BASE_ADDRESS_SPACE_IO; - reg1_address &= PCI_BASE_ADDRESS_MEM_MASK; - - pci_get_name(vendor, device, debug); - - Out_Debug_String("____________\n"); - Out_Debug_String(debug); - Out_Debug_String("\n____________\n"); - - ke2dbg_sprintf(debug, "Good one, returning %.8X\n", reg1_address); - Out_Debug_String(debug); - - return reg1_address; - - } - - Out_Debug_String("Pci scan: failed\n"); - - return 0; - -} - diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/ports.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/ports.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/ports.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/ports.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -/** - * @file libe2dbg/kernel/ports.c - */ -#include "ke2dbg.h" - -/** - * @param Port - * @return - */ -unsigned char ke2dbg_inb (unsigned int Port) -{ - unsigned char Value; -#if defined(__GNUC__) - __asm__("inb %w1, %0;\n\t" - : "=a" (Value) - : "d" (Port)); -#endif - return(Value); -} - -/** - * @param Port - * @return - */ - -unsigned short ke2dbg_inw (unsigned int Port) -{ - unsigned short Value; -#if defined(__GNUC__) - __asm__("inw %w1, %0;\n\t" - : "=a" (Value) - : "d" (Port)); -#endif - return(Value); -} - -/** - * @param Port - * @return - */ - -unsigned int ke2dbg_inl (unsigned int Port) -{ - unsigned int Value; -#if defined(__GNUC__) - __asm__("inl %w1, %0;\n\t" - : "=a" (Value) - : "d" (Port)); -#endif - return(Value); -} - -/** - * @param Value - * @param Port - * @return - */ -void ke2dbg_outb (unsigned char Value, unsigned int Port) -{ -#if defined(__GNUC__) - __asm__("outb %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); -#endif -} - - -/** - * @param Value - * @param Port - * @return - */ -void ke2dbg_outw (unsigned short Value, unsigned int Port) -{ -#if defined(__GNUC__) - __asm__("outw %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); -#endif -} - -/** - * @param Value - * @param Port - * @return - */ -void ke2dbg_outl (unsigned int Value, unsigned int Port) -{ -#if defined(__GNUC__) - __asm__("outl %0, %w1\n\t" - : - : "a" (Value), - "d" (Port)); -#endif -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/strings.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/strings.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/strings.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/strings.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,349 +0,0 @@ -/** - * @file libe2dbg/kernel/strings.c - * - * - * Imported from glibc-2.7 - */ -#include "ke2dbg.h" - -/** - * Compare S1 and S2, returning less than, equal to or - * greater than zero if S1 is lexicographically less than, - * equal to or greater than S2. - * @param p1 - * @param p2 - * @return - */ -int strcmp (const char *p1, const char *p2) -{ - register const unsigned char *s1 = (const unsigned char *) p1; - register const unsigned char *s2 = (const unsigned char *) p2; - unsigned reg_char c1, c2; - - do - { - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0') - return c1 - c2; - } - while (c1 == c2); - - return c1 - c2; -} - -/** - * - * @param s1 - * @param s2 - * @param n - */ -char *strncat (char *s1, const char *s2, size_t n) -{ - reg_char c; - char *s = s1; - - /* Find the end of S1. */ - do - c = *s1++; - while (c != '\0'); - - /* Make S1 point before next character, so we can increment - it while memory is read (wins on pipelined cpus). */ - s1 -= 2; - - if (n >= 4) - { - size_t n4 = n >> 2; - do - { - c = *s2++; - *++s1 = c; - if (c == '\0') - return s; - c = *s2++; - *++s1 = c; - if (c == '\0') - return s; - c = *s2++; - *++s1 = c; - if (c == '\0') - return s; - c = *s2++; - *++s1 = c; - if (c == '\0') - return s; - } while (--n4 > 0); - n &= 3; - } - - while (n > 0) - { - c = *s2++; - *++s1 = c; - if (c == '\0') - return s; - n--; - } - - if (c != '\0') - *++s1 = '\0'; - - return s; -} - -/** - * - * @param s1 - * @param s2 - * @param n - */ -char *strncpy (char *s1, const char *s2, size_t n) -{ - reg_char c; - char *s = s1; - - --s1; - - if (n >= 4) - { - size_t n4 = n >> 2; - - for (;;) - { - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - c = *s2++; - *++s1 = c; - if (c == '\0') - break; - if (--n4 == 0) - goto last_chars; - } - n = n - (s1 - s) - 1; - if (n == 0) - return s; - goto zero_fill; - } - - last_chars: - n &= 3; - if (n == 0) - return s; - - do - { - c = *s2++; - *++s1 = c; - if (--n == 0) - return s; - } - while (c != '\0'); - - zero_fill: - do - *++s1 = '\0'; - while (--n > 0); - - return s; -} - -/** - * Compare no more than N characters of S1 and S2, - * returning less than, equal to or greater than zero - * if S1 is lexicographically less than, equal to or - * greater than S2. - * - * @param s1 - * @param s2 - * @param n - */ -int strncmp (const char *s1, const char *s2, size_t n) -{ - unsigned reg_char c1 = '\0'; - unsigned reg_char c2 = '\0'; - - if (n >= 4) - { - size_t n4 = n >> 2; - do - { - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - } while (--n4 > 0); - n &= 3; - } - - while (n > 0) - { - c1 = (unsigned char) *s1++; - c2 = (unsigned char) *s2++; - if (c1 == '\0' || c1 != c2) - return c1 - c2; - n--; - } - - return c1 - c2; -} - -/** - * Append SRC on the end of DEST. - * - * - */ -char *strcat (char *dest, const char *src) -{ - char *s1 = dest; - const char *s2 = src; - reg_char c; - - /* Find the end of the string. */ - do - c = *s1++; - while (c != '\0'); - - /* Make S1 point before the next character, so we can increment - it while memory is read (wins on pipelined cpus). */ - s1 -= 2; - - do - { - c = *s2++; - *++s1 = c; - } - while (c != '\0'); - - return dest; -} - - -/** - * Parse S into tokens separated by characters in DELIM. - * If S is NULL, the saved pointer in SAVE_PTR is used as - * the next starting point. For example: - * char s[] = "-abc-=-def"; - * char *sp; - * x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def" - * x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL - * x = strtok_r(NULL, "=", &sp); // x = NULL - * // s = "abc\0-def\0" - * - * @param s - * @param delim - * @param save_ptr - * @return - */ -char *strtok_r (char *s, const char *delim, char **save_ptr) -{ - char *token; - - if (s == NULL) - s = *save_ptr; - - /* Scan leading delimiters. */ - s += strspn (s, delim); - if (*s == '\0') - { - *save_ptr = s; - return NULL; - } - - /* Find the end of the token. */ - token = s; - s = strpbrk (token, delim); - if (s == NULL) - /* This token finishes the string. */ - *save_ptr = __rawmemchr (token, '\0'); - else - { - /* Terminate the token and make *SAVE_PTR point past it. */ - *s = '\0'; - *save_ptr = s + 1; - } - return token; -} - -/** - * Set N bytes of S to 0. - * - * @param s - * @param len - */ -void bzero (void *s, size_t len) -{ - long int dstp = (long int) s; - const op_t zero = 0; - - if (len >= 8) - { - size_t xlen; - - /* There are at least some bytes to zero. No need to test - for LEN == 0 in this alignment loop. */ - while (dstp % OPSIZ != 0) - { - ((byte *) dstp)[0] = 0; - dstp += 1; - len -= 1; - } - - /* Write 8 op_t per iteration until less than 8 op_t remain. */ - xlen = len / (OPSIZ * 8); - while (xlen != 0) - { - ((op_t *) dstp)[0] = zero; - ((op_t *) dstp)[1] = zero; - ((op_t *) dstp)[2] = zero; - ((op_t *) dstp)[3] = zero; - ((op_t *) dstp)[4] = zero; - ((op_t *) dstp)[5] = zero; - ((op_t *) dstp)[6] = zero; - ((op_t *) dstp)[7] = zero; - dstp += 8 * OPSIZ; - xlen -= 1; - } - len %= OPSIZ * 8; - - /* Write 1 op_t per iteration until less than op_t remain. */ - xlen = len / OPSIZ; - while (xlen != 0) - { - ((op_t *) dstp)[0] = zero; - dstp += OPSIZ; - xlen -= 1; - } - len %= OPSIZ; - } - - /* Write the last few bytes. */ - while (len != 0) - { - ((byte *) dstp)[0] = 0; - dstp += 1; - len -= 1; - } -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/syscalls.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/syscalls.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/syscalls.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/syscalls.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,388 +0,0 @@ -/** - ** @file libe2dbg/kernel/syscalls.c - **/ - -#include "ke2dbg.h" -#include "ke2dbg-syscalls.h" - -static void **ke2dbg_syscalltable; - -asmlinkage int (*ke2dbg_sys_read)(int, void *, size_t); -asmlinkage int (*ke2dbg_sys_write)(int, const void *, size_t); -asmlinkage int (*ke2dbg_sys_open)(const char *, int, int); -asmlinkage int (*ke2dbg_sys_close)(int); -asmlinkage sighandler_t (*ke2dbg_sys_signal)(int, sighandler_t); -asmlinkage int (*ke2dbg_sys_execve)(struct pt_regs); -asmlinkage int (*ke2dbg_sys_fsync)(int); -asmlinkage int (*ke2dbg_sys_readdir)(unsigned int, struct dirent *, unsigned int); -asmlinkage int (*ke2dbg_sys_fork)(struct pt_regs); -asmlinkage long (*ke2dbg_sys_exit)(int); -asmlinkage long (*ke2dbg_sys_rename)(const char *, const char *); -asmlinkage long (*ke2dbg_sys_munmap)(unsigned long, size_t); -asmlinkage long (*ke2dbg_sys_mmap2)(unsigned long, unsigned long, unsigned long, - unsigned long, unsigned long , unsigned long); -asmlinkage long (*ke2dbg_sys_unlink)(const char *); -asmlinkage long (*ke2dbg_sys_mprotect)(unsigned long, size_t, unsigned long); -asmlinkage long (*ke2dbg_sys_wait4)(pid_t, int *, int, struct rusage *); -asmlinkage long (*ke2dbg_sys_waitpid)(pid_t, int *, int); -asmlinkage long (*ke2dbg_sys_access)(const char *, int); -asmlinkage long (*ke2dbg_sys_select)(int, fd_set *, fd_set *, fd_set *, struct timeval *); -asmlinkage long (*ke2dbg_sys_dup2)(unsigned int, unsigned int); -asmlinkage off_t (*ke2dbg_sys_lseek)(unsigned int, off_t, unsigned int); -asmlinkage long (*ke2dbg_sys_mkdir)(const char *, int); -asmlinkage long (*ke2dbg_sys_nanosleep)(struct timespec *, struct timespec *); - -int ke2dbg_init_syscalltable(unsigned long value) -{ - ke2dbg_syscalltable = (void **)value; - - ke2dbg_sys_read = ke2dbg_syscalltable[__NR_read]; - ke2dbg_sys_open = ke2dbg_syscalltable[__NR_open]; - ke2dbg_sys_close = ke2dbg_syscalltable[__NR_close]; - ke2dbg_sys_signal = ke2dbg_syscalltable[__NR_signal]; - ke2dbg_sys_execve = ke2dbg_syscalltable[__NR_execve]; - ke2dbg_sys_fsync = ke2dbg_syscalltable[__NR_fsync]; - ke2dbg_sys_readdir = ke2dbg_syscalltable[__NR_readdir]; - ke2dbg_sys_fork = ke2dbg_syscalltable[__NR_fork]; - ke2dbg_sys_exit = ke2dbg_syscalltable[__NR_exit]; - ke2dbg_sys_rename = ke2dbg_syscalltable[__NR_rename]; - ke2dbg_sys_munmap = ke2dbg_syscalltable[__NR_munmap]; - ke2dbg_sys_mmap2 = ke2dbg_syscalltable[__NR_mmap2]; - ke2dbg_sys_unlink = ke2dbg_syscalltable[__NR_unlink]; - ke2dbg_sys_mprotect = ke2dbg_syscalltable[__NR_mprotect]; - ke2dbg_sys_wait4 = ke2dbg_syscalltable[__NR_wait4]; - ke2dbg_sys_waitpid = ke2dbg_syscalltable[__NR_waitpid]; - ke2dbg_sys_access = ke2dbg_syscalltable[__NR_access]; - ke2dbg_sys_select = ke2dbg_syscalltable[__NR_select]; - ke2dbg_sys_dup2 = ke2dbg_syscalltable[__NR_dup2]; - ke2dbg_sys_lseek = ke2dbg_syscalltable[__NR_lseek]; - ke2dbg_sys_mkdir = ke2dbg_syscalltable[__NR_mkdir]; - ke2dbg_sys_nanosleep = ke2dbg_syscalltable[__NR_nanosleep]; - - return 0; -} - -asmlinkage ssize_t sys_read(int fd, void *buf, size_t count) -{ - ssize_t r; - mm_segment_t oldfs; - - oldfs = get_fs(); - set_fs(KERNEL_DS); - - r = ke2dbg_sys_read(fd, buf, count); - - set_fs(oldfs); - return r; -} - -asmlinkage ssize_t sys_write(int fd, const void *buf, size_t count) -{ - ssize_t r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_write(fd, buf, count); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_open(const char *pathname, int flags, int mode) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_open(pathname, flags, mode); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_close(int fd) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_close(fd); - - set_fs(oldfs); - - return r; -} - -asmlinkage sighandler_t sys_signal(int signum, sighandler_t handler) -{ - sighandler_t r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_signal(signum, handler); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_execve(struct pt_regs regs) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_execve(regs); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_fsync(int fd) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_fsync(fd); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_readdir(unsigned int fd, struct dirent *dirp, unsigned int count) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_readdir(fd, dirp, count); - - set_fs(oldfs); - - return r; -} - -asmlinkage int sys_fork(struct pt_regs regs) -{ - int r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_fork(regs); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_exit(int error_code) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_exit(error_code); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_rename(const char *oldname, const char *newname) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_rename(oldname, newname); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_munmap(unsigned long addr, size_t len) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_munmap(addr, len); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, - unsigned long prot, unsigned long flags, - unsigned long fd, unsigned long pgoff) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_mmap2(addr, len, prot, flags, fd, pgoff); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_unlink(const char *pathname) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_unlink(pathname); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_mprotect(unsigned long start, size_t len, unsigned long prot) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_mprotect(start, len, prot); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_wait4(pid_t pid, int *stat_addr, int options, struct rusage *ru) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_wait4(pid, stat_addr, options, ru); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_waitpid(pid_t pid, int *stat_addr, int options) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_waitpid(pid, stat_addr, options); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_access(const char *filename, int mode) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_access(filename, mode); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_select(int n, fd_set *inp, fd_set *outp, - fd_set *exp, struct timeval *tvp) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_select(n, inp, outp, exp, tvp); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_dup2(unsigned int oldfd, unsigned int newfd) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_dup2(oldfd, newfd); - - set_fs(oldfs); - - return r; -} - -asmlinkage off_t sys_lseek(unsigned int fd, off_t offset, unsigned int origin) -{ - off_t r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_lseek(fd, offset, origin); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_mkdir(const char *pathname, int mode) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_mkdir(pathname, mode); - - set_fs(oldfs); - - return r; -} - -asmlinkage long sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp) -{ - long r; - mm_segment_t oldfs = get_fs(); - - set_fs(KERNEL_DS); - - r = ke2dbg_sys_nanosleep(rqtp, rmtp); - - set_fs(oldfs); - - return r; -} diff -Nru eresi-0.8a25/libe2dbg/kernel/.svn/text-base/utils.c.svn-base eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/utils.c.svn-base --- eresi-0.8a25/libe2dbg/kernel/.svn/text-base/utils.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/.svn/text-base/utils.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,692 +0,0 @@ -/** - * @file libe2dbg/kernel/utils.c - * - */ -#include "ke2dbg.h" - - -/*TRUE STDLIB*/ -#ifndef NULL -#define NULL ((unsigned char*)0) -#endif -#define _U 0x00000001 /* Upper case */ -#define _L 0x00000002 /* Lower case */ -#define _N 0x00000004 /* Numeral (digit) */ -#define _S 0x00000008 /* Spacing character */ -#define _P 0x00000010 /* Punctuation */ -#define _C 0x00000020 /* Control character */ -#define _B 0x00000040 /* Blank */ -#define _X 0x00000080 /* heXadecimal digit */ - -unsigned int _mb_cur_max; - -char _ctype_[] = { 0, - - /* 0 1 2 3 4 5 6 7 */ - - /* 0*/ _C, _C, _C, _C, _C, _C, _C, _C, - /* 10*/ _C, _S|_C, _S|_C, _S|_C, _S|_C, _S|_C, _C, _C, - /* 20*/ _C, _C, _C, _C, _C, _C, _C, _C, - /* 30*/ _C, _C, _C, _C, _C, _C, _C, _C, - /* 40*/ (char)(_S|_B), _P, _P, _P, _P, _P, _P, _P, - /* 50*/ _P, _P, _P, _P, _P, _P, _P, _P, - /* 60*/ _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, - /* 70*/ _N|_X, _N|_X, _P, _P, _P, _P, _P, _P, - /*100*/ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, - /*110*/ _U, _U, _U, _U, _U, _U, _U, _U, - /*120*/ _U, _U, _U, _U, _U, _U, _U, _U, - /*130*/ _U, _U, _U, _P, _P, _P, _P, _P, - /*140*/ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, - /*150*/ _L, _L, _L, _L, _L, _L, _L, _L, - /*160*/ _L, _L, _L, _L, _L, _L, _L, _L, - /*170*/ _L, _L, _L, _P, _P, _P, _P, _C, - /*200*/ 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/** - * @param fmt - */ -static void bad ( char *fmt) -{ - //printf("bad fmt in ke2dbg_sprintf, starting with \"%s\"\n", fmt); - //exit(1); -} - -#define put(x) *outbuf++ = (char)x - - - -unsigned char hexabuf_M[] = "0123456789ABCDEF"; -unsigned char hexabuf_L[] = "0123456789abcdef"; - -/** - * @param outbuf - * @param fmt - * @return - */ -int ke2dbg_sprintf( char *outbuf, char *fmt, ...) -{ - char *ob0, *s; - char buf[32]; - va_list ap; - //long i/*, j*/; - unsigned int i, j; - int signed_entry; - char* hexabuf = (unsigned char)0; - int fixed_len; - unsigned char c; - - va_start(ap, fmt); - ob0 = outbuf; - for(;;) { - for(;;) { - switch(i = *fmt++) { - case 0: - goto done; - case '%': - break; - default: - put(i); - continue; - } - break; - } - fixed_len=0; - special_char: - switch(*fmt++) { - - case '.': - for(i=0;i<8;i++) - { - c = *fmt++; - if (c>='0' && c <='9') - { - fixed_len*=10; - fixed_len+=c-'0'; - } - else - break; - } - fmt--; - goto special_char; - continue; - case 'c': - i = va_arg(ap, int); - put(i); - continue; - case 'l': - if ((*fmt != 'd')&& (*fmt != 'x') && (*fmt != 'X')) - bad(fmt); - if ((*fmt == 'x') || (*fmt == 'X')) - goto special_char; - - fmt++; - //i = va_arg(ap, long); - signed_entry = va_arg(ap, long); - goto have_i; - case 'd': - //i = va_arg(ap, int); - signed_entry = va_arg(ap, int); - have_i: - if (signed_entry < 0) { - put('-'); - signed_entry = -signed_entry; - } - s = buf; - i = signed_entry; - do { - j = i / 10; - *s++ = i - 10*j + '0'; - fixed_len--; - } - while((i = j)); - while(fixed_len-->0) put('0'); - do { - i = *--s; - put(i); - } - while(s > buf); - continue; - case 'x': - hexabuf = hexabuf_L; - goto have_hexa; - case 'X': - hexabuf = hexabuf_M; - have_hexa: - i = va_arg(ap, int); - s = buf; - do { - j = i / 16; - *s++ = hexabuf[i - 16*j]; - fixed_len--; - } - while((i = j)); - while(fixed_len-->0) put('0'); - do { - i = *--s; - put(i); - } - while(s > buf); - continue; - - - case 's': - s = va_arg(ap, char*); - while((i = *s++)) - { put(i); } - continue; - default: - bad(fmt); - } - } - done: - *outbuf = 0; - return outbuf - ob0; -} - -/** - * @param c - * @return - */ -int ke2dbg_isalpha(register int c) -{ - return((_ctype_+1)[c]&(_U|_L)); -} - -/** - * @param c - * @return - */ -int ke2dbg_isupper(register int c) -{ - return((_ctype_+1)[c]&_U); -} - -/** - * @param c - * @return - */ -int ke2dbg_islower(register int c) -{ - return((_ctype_+1)[c]&_L); -} - -/** - * @param c - * @return - */ -int ke2dbg_isdigit(register int c) -{ - return((_ctype_+1)[c]&_N); -} - -/** - * @param c - * @return - */ -int ke2dbg_isxdigit(register int c) -{ - return((_ctype_+1)[c]&_X); -} - - -/** - * @param c - * @return - */ -int ke2dbg_isspace(register int c) -{ - return((_ctype_+1)[c]&_S); -} - - -/** - * @param c - * @return - */ -int ke2dbg_ispunct(register int c) -{ - return((_ctype_+1)[c]&_P); -} - - -/** - * @param c - * @return - */ -int ke2dbg_isalnum(register int c) -{ - return((_ctype_+1)[c]&(_U|_L|_N)); -} - - -/** - * @param c - * @return - */ -int ke2dbg_isprint(register int c) -{ - return((_ctype_+1)[c]&(_P|_U|_L|_N|_B)); -} - - -/** - * @param c - * @return - */ -int ke2dbg_isgraph(register int c) -{ - return((_ctype_+1)[c]&(_P|_U|_L|_N)); -} - - -/** - * @param c - * @return - */ -int ke2dbg_iscntrl(register int c) -{ - return((_ctype_+1)[c]&_C); -} - -/** - * @param c - * @return - */ -int ke2dbg_isascii(register int c) -{ - return((unsigned)(c)<=0177); -} - -/** - * @param c - * @return - */ -int ke2dbg_toascii(register int c) -{ - return((c)&0177); -} - - - - - -/** - * @param p - * @return - */ -int ke2dbg_atoi( char *p) -{ - int n; - int c, neg = 0; - unsigned char *up = (unsigned char *)p; - - if (!ke2dbg_isdigit(c = *up)) { - while (ke2dbg_isspace(c)) - c = *++up; - switch (c) { - case '-': - neg++; - /* FALLTHROUGH */ - case '+': - c = *++up; - } - if (!ke2dbg_isdigit(c)) - return (0); - } - for (n = '0' - c; ke2dbg_isdigit(c = *++up); ) { - n *= 10; /* two steps to avoid unnecessary overflow */ - n += '0' - c; /* accum neg to avoid surprises at MAX */ - } - return (neg ? n : -n); -} - -/** - * @param sp - * @param c - * @return - */ -char * ke2dbg_strchr( char *sp, int c) -{ - do { - if (*sp == (char)c) - return ((char *)sp); - } while (*sp++); - return (NULL); -} - -/** - * @param s1 - * @param s2 - * @return - */ -int ke2dbg_strcmp( char *s1, char *s2) -{ - if (s1 == s2) - return (0); - while (*s1 == *s2++) - if (*s1++ == '\0') - return (0); - return (*(unsigned char *)s1 - *(unsigned char *)--s2); -} - -/** - * @param s - * @return - */ -unsigned int ke2dbg_strlen( char *s) -{ - char *s0 = s + 1; - - while (*s++ != '\0') - ; - return (s - s0); -} - -/** - * @param s1 - * @param s2 - * @param n - * @return - */ -int ke2dbg_strnicmp ( char *s1, char *s2,size_t n) -{ - char c1,c2; - - if(n==0) return 0; - - do { - c1 = *s1++; if(ke2dbg_islower(c1)) c1=ke2dbg_toupper(c1); - c2 = *s2++; if(ke2dbg_islower(c2)) c2=ke2dbg_toupper(c2); - } while(c1==c2 && c1 && c2 && --n>0); - - if(n==0 || c1==c2) return 0; - if(c1=='\0' || c1>3; - int tmp_decal_font_x=0; - int tmp_decal_screen_x=0; - int tmp_font_y_m_y=0; - //unsigned char debug[80]; - - - x1 = x - screen_offset_x; - y1 = y - screen_offset_y; - - //__asm{int 3}; -// font_x = 8; -/* -ke2dbg_sprintf(debug, "%.8X %.8X %.8X\n\r", font_x, x1, y1); -Out_Debug_String(debug); -*/ - - - char_font_x = font_x * (int)a; - char_screen_x = font_x * x + font_y * y * SCREEN_MAX_X; - - //__asm{int 3}; -// ke2dbg_sprintf(debug, "->%X %X \n\r", font_x, font_y); -// Out_Debug_String(debug); - - for (x_pix = 0; x_pix < font_x; x_pix++) - { - tmp_decal_font_x = char_font_x + x_pix; - tmp_decal_screen_x = char_screen_x + x_pix; - for (y_pix = 0; y_pix < font_y; y_pix++) - { - tmp_font_y_m_y = (font_y-y_pix)*SCREEN_MAX_X; - color = (font_data[(tmp_decal_font_x + y_pix*font_next_line)*byte_per_pixel+0]>>3); - - -// ke2dbg_sprintf(debug, "mode %.8X %.8X \n\r", rasta_mode, fOOl_mode); -// Out_Debug_String(debug); - - - if (rasta_mode) - { - /*Rasta Mode*/ - switch(color) - { - case 0: - break; - - default: - switch (x%3) - { - case 0: color = 0x0780; break; - case 1: color = 0xf800; break; - case 2: color = 0xffe0; break; - } - - break; - - } - } - if (fOOl_mode) - { - /*f001 Mode*/ - /* 0 blk, 1 darkbl, 2 darkgr, 3 cyan, 4 red, 5 purpur, 6 orange, 7 lgray, 8 dgray, - 9 lblue, 10 lgrn, 11 lblu, 12 lred, 13 lping, 14 yell, 15 white */ - - switch ( ((x+fOOl_mode_color_shift)>>2)%8) - { - case 0: color = 0x1; break; - case 1: color = 0x9; break; - case 2: color = 0x3; break; - case 3: color = 0xb; break; - case 4: color = 0xf; break; - case 5: color = 0xb; break; - case 6: color = 0x3; break; - case 7: color = 0x9; break; - } - - - } - - if (!rasta_mode && !fOOl_mode) - - { -// ke2dbg_sprintf(debug, "normal mode %.8X %.8X %.8X %X\n\r", a, x1, y1, color); -//Out_Debug_String(debug); - - /*Normal mode*/ - if ((x1<80) && (y1<40)) - { - if (!color) - { - if (x1 == cursor_X && y1 == cursor_Y) - color = 0xc618; - } - else - { - switch(screen_colors[y1][x1]) - { - case 0: - break; - case ' ': color = 0xc618; break; - case '1': color = 0x0780; break; - case '2': color = 0x9CD3; break; - case '8': color = 0x44b0; break; - default: - break; - - } - } - } - - } - /* - #ifdef BYTE_PER_PIXEL_HALF - *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff; - #endif - - - #ifdef BYTE_PER_PIXEL_ONE - *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff; - #endif - #ifdef BYTE_PER_PIXEL_TWO - *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color; - #endif - #ifdef BYTE_PER_PIXEL_THREE - *((char*)screen_adresse+0+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff; - #endif - */ - //__asm{int 3}; - #ifdef BYTE_PER_PIXEL_FOUR - #ifdef HW_FB - poked1(screen_adresse+4*(tmp_decal_screen_x + (tmp_font_y_m_y)) , color); - #else - *((int*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color; - #endif - #endif - - /* - switch(screen_bpp) - { - case 1: - *((char*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff; - break; - case 2: - *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color; - break; - case 3: - *((char*)screen_adresse+0+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=color&0xff; - *((char*)screen_adresse+1+2*(tmp_decal_screen_x + (tmp_font_y_m_y)))=(color>>8)&0xff; - break; - case 4: - *((int*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color; - break; - - default: - *((short*)screen_adresse+(tmp_decal_screen_x + (tmp_font_y_m_y)))=color; - break; - - } - */ - - - } - } - -} -#endif - -#ifdef VIDEO_AA -#define TEXT_MODE_ADDRESS 0xC00B8000 - -unsigned char videobaselow; -unsigned char videobasehigh; - -/** - * - */ -void ke2dbg_membase_read(void) - { -#ifdef ATT_ASM - __asm("\n\t" - "movw $0x3d4,%dx\n\t" - "movb $0x0c,%al\n\t" - "outb %al,%dx\n\t" - "movw $0x3d5,%dx\n\t" - "inb %dx,%al\n\t" - "movb %al,(videobasehigh); \n\t" - "movw $0x3d4,%dx\n\t" - "movb $0x0d,%al\n\t" - "outb %al,%dx\n\t" - "movw $0x3d5,%dx\n\t" - "inb %dx,%al\n\t" - "movb %al,(videobaselow);\n\t" - ); -#endif - }; - -/** - * - */ -void ke2dbg_membase_restore(void) - { -#ifdef ATT_ASM - __asm("\n\t" - "movw $0x3d4,%dx\n\t" - "movb $0x0c,%al\n\t" - "outb %al,%dx\n\t" - "movw $0x3d5,%dx\n\t" - "movb (videobasehigh),%al \n\t" - "outb %al,%dx\n\t" - "movw $0x3d4,%dx\n\t" - "movb $0x0d,%al\n\t" - "outb %al,%dx\n\t" - "movw $0x3d5,%dx\n\t" - "movb (videobaselow),%al \n\t" - "outb %al,%dx\n\t" - ); -#endif - }; - -/** - * - */ -void ke2dbg_memreset(void) - { -#ifdef ATT_ASM - __asm("\n\t" - "movw $0x3d4,%dx\n\t" - "movw $0x000c,%ax\n\t" - "outw %ax,%dx\n\t" - "movw $0x000d,%ax\n\t" - "outw %ax,%dx\n\t" - ); -#endif - - }; - -/** - * - */ -void ke2dbg_display_start(void) -{ - - //printk("read..."); - ke2dbg_membase_read(); - //printk("mem to 0..."); - ke2dbg_memreset(); -}; - -/** - * - */ -void kedbg_display_end(void) -{ - - //printk("mem base..."); - ke2dbg_membase_restore(); -}; - - -/** - * @param a - * @param x - * @param y - */ -void print_char(unsigned char a, unsigned int x, unsigned int y) -{ - char *ptr=(char *) TEXT_MODE_ADDRESS/*+80*10*2*/; - int color=0; - - if ((y>25)||(x>80)) - return; - - //ke2dbg_display_start(); - - ptr=ptr+(2*80*y); - ptr=ptr+(x*2); - - *ptr=a; - ptr++; - - if (rasta_mode) - { - /*Rasta Mode*/ - switch (x%3) - { - case 0: color = 0x4; break; - case 1: color = 0xE; break; - case 2: color = 0xA; break; - } - - - } - - if (fOOl_mode) - { - /*f001 Mode*/ - /* 0 blk, 1 darkbl, 2 darkgr, 3 cyan, 4 red, 5 purpur, 6 orange, 7 lgray, 8 dgray, - 9 lblue, 10 lgrn, 11 lblu, 12 lred, 13 lping, 14 yell, 15 white */ - - switch ( ((x+fOOl_mode_color_shift)>>2)%8) - { - case 0: color = 0x1; break; - case 1: color = 0x9; break; - case 2: color = 0x3; break; - case 3: color = 0xb; break; - case 4: color = 0xf; break; - case 5: color = 0xb; break; - case 6: color = 0x3; break; - case 7: color = 0x9; break; - } - } - - /*Normal mode*/ - if (!rasta_mode && !fOOl_mode && x < 80 && y < 40) - switch (screen_colors[y][x]) - { - case 0: - break; - case ' ': - color = 0x7; - break; - case '0': - color = 0xc7; - break; - case '1': - color = 0x3; - break; - case '2': - color = 0x8; - break; - case '8': - color = 0x2; - break; - default: - break; - } - - *ptr = (char) color; -} - -#endif /* VIDEO_AA */ - - -/** - * Draw a string at position x-y - * - * @param string - * @param x - * @param y - * - */ -void Put_String(char* string, unsigned int x, unsigned int y) -{ - unsigned int i; - - for (i=0;i78) - break; - }; -} - -/** - * @param ptr - * @param ligne - */ -void ke2dbg_print_AW(char* ptr, int ligne) -{ - ke2dbg_text_display(1,buff_win_y+ligne,ptr); -} - -/** - * @param ptr - * @param ligne - */ -void ke2dbg_print_DW(char* ptr, int ligne) -{ - ke2dbg_text_display(1,data_win_y+ligne,ptr); -} - -/** - * @param ptr - * @param ligne - */ -void ke2dbg_print_CW(char* ptr, int ligne) -{ - ke2dbg_text_display(1,code_win_y+ligne,ptr); -} - - -/** - * rafraichi la fenetre de log - */ -void ke2dbg_Refresh_AW() -{ - unsigned int i; - for (i=buff_win_y;i<=buff_win_y + buff_win_dim;i++) - accessline[i]=1; -} - -/** - * rafraichi la fenetre de data - */ - -void ke2dbg_Refresh_DW() -{ - unsigned int i; - for (i=data_win_y;i data_win_y + data_win_dim - 1) - y = (unsigned int )(data_win_y + data_win_dim-1); - - if (x > 80 - 1) - x = 80 - 1; - - if ((x < 80) && (y < 40)) - { - accessline[y] = 1; - accessline[cursor_Y] = 1; - screen_colors[cursor_Y][cursor_X] = (char)cursor_old_color; - - if (x < 63) - if (!((x + 1) % 3)) - x = (x > cursor_X ? x + 1 : x - 1); - - cursor_old_color = screen_colors[y][x]; - screen_colors[y][x] = (char) cursor_color; - cursor_X = x; - cursor_Y = y; - } - - ke2dbg_display_refresh(); -} - -/** - * - */ -void ke2dbg_cursor_erase() -{ - if ((cursor_X < 80) && (cursor_Y < 40)) - { - accessline[cursor_Y]=1; - screen_colors[cursor_Y][cursor_X] = (char) cursor_old_color; - } - ke2dbg_display_refresh(); -} - -/** - * @param str - */ -void ke2dbg_output(char *str) -{ - ke2dbg_logbuf_insert(str); - ke2dbg_logbuf_print(); - ke2dbg_display_refresh(); -} diff -Nru eresi-0.8a25/libe2dbg/kernel/syscalls.c eresi-0.0.20110516/libe2dbg/kernel/syscalls.c --- eresi-0.8a25/libe2dbg/kernel/syscalls.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/syscalls.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - ** @file libe2dbg/kernel/syscalls.c +* @file libe2dbg/kernel/syscalls.c **/ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/utils.c eresi-0.0.20110516/libe2dbg/kernel/utils.c --- eresi-0.8a25/libe2dbg/kernel/utils.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/utils.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/utils.c +* @file libe2dbg/kernel/utils.c * */ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/kernel/video.c eresi-0.0.20110516/libe2dbg/kernel/video.c --- eresi-0.8a25/libe2dbg/kernel/video.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/kernel/video.c 2011-05-16 11:35:06.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file libe2dbg/kernel/video.c +* @file libe2dbg/kernel/video.c * */ #include "ke2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/Makefile eresi-0.0.20110516/libe2dbg/Makefile --- eresi-0.8a25/libe2dbg/Makefile 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/Makefile 2011-05-16 11:35:07.000000000 +0000 @@ -2,7 +2,7 @@ ## Makefile for libe2dbg in the ERESI framework ## ## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id: Makefile,v 1.17 2008-02-16 12:32:27 thor Exp $ +## $Id: Makefile 1311 2009-01-14 20:36:48Z may $ ## include ../config.h @@ -21,28 +21,29 @@ LDFLAGS32 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) LDFLAGS64 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) -EXTRAOBJ32 = ../libasm/libasm.o ../libmjollnir/libmjollnir32.o \ +EXTRAOBJ32 = ../libasm/libasm32.o ../libmjollnir/libmjollnir32.o \ ../libelfsh/libelfsh32.o ../libedfmt/libedfmt32.o \ - ../liballocproxy/liballocproxy.o ../librevm/revm-*.32.o \ - ../libaspect/libaspect32.o ../libstderesi/libstderesi32.o \ - $(LDDUMPOBJ) + ../liballocproxy/liballocproxy.o ../librevm/revm-*.32.o \ + ../libaspect/libaspect32.o ../libstderesi/libstderesi32.o \ + ../libetrace/libetrace32.o $(LDDUMPOBJ32) -EXTRAOBJ64 = ../libasm/libasm.o ../libmjollnir/libmjollnir64.o \ +EXTRAOBJ64 = ../libasm/libasm64.o ../libmjollnir/libmjollnir64.o \ ../libelfsh/libelfsh64.o ../libedfmt/libedfmt64.o \ ../liballocproxy/liballocproxy.o ../librevm/revm-*.64.o \ ../libaspect/libaspect64.o ../libstderesi/libstderesi64.o \ - $(LDDUMPOBJ) + ../libetrace/libetrace64.o $(LDDUMPOBJ64) -COBJ32 = common/*.32.o +COBJ32 = common/libe2dbg-common32.o COBJ64 = common/*.64.o KOBJ32 = kernel/*.32.o KOBJ64 = kernel/*.64.o -UOBJ32 = user/*.32.o +UOBJ32 = user/libe2dbg-user32.o UOBJ64 = user/*.64.o all : all32 all64 all32 : mod32 lib32 +all32 : lib32 mod32 : $(MAKE) -C common all32 @@ -51,9 +52,9 @@ $(MAKE) -C kernel endif -$(DBGNAME32O): +$(DBGNAME32O): mod32 @$(CC) -shared $(COBJ32) $(EXTRAOBJ32) $(UOBJ32) $(LDFLAGS32) \ - $(KERNSHLIB32) -o $(DBGNAME32).so + -o $(DBGNAME32).so @$(AR) $(DBGNAME32).a $(COBJ32) $(UOBJ32) $(EXTRAOBJ32) @$(RANLIB) $(DBGNAME32).a @$(LD) -r $(COBJ32) $(EXTRAOBJ32) $(UOBJ32) -o $(DBGNAME32O) @@ -69,9 +70,9 @@ $(MAKE) -C common all64 $(MAKE) -C user all64 -$(DBGNAME64O) : - @$(CC) -shared $(OBJ64) $(EXTRAOBJ64) $(UOBJ64) $(LDFLAGS64) \ - $(KERNSHLIB64) -o $(DBGNAME64).so +$(DBGNAME64O) : mod64 + @$(CC) -shared $(COBJ64) $(EXTRAOBJ64) $(UOBJ64) $(LDFLAGS64) \ + -o $(DBGNAME64).so @$(AR) $(DBGNAME64).a $(OBJ64) @$(RANLIB) $(DBGNAME64).a @$(LD) -r $(OBJ64) $(EXTRAOBJ64) -o $(DBGNAME64O) diff -Nru eresi-0.8a25/libe2dbg/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/950/trunk/libe2dbg -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/950/trunk/libe2dbg/Makefile -END diff -Nru eresi-0.8a25/libe2dbg/.svn/entries eresi-0.0.20110516/libe2dbg/.svn/entries --- eresi-0.8a25/libe2dbg/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kernel -dir - -include -dir - -common -dir - -Makefile -file - - - - -2008-04-06T23:16:30.108372Z -f7adff10c889345a8f2a887324c54d73 -2008-03-29T07:54:04.209482Z -950 -enioh - -user -dir - diff -Nru eresi-0.8a25/libe2dbg/.svn/format eresi-0.0.20110516/libe2dbg/.svn/format --- eresi-0.8a25/libe2dbg/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libe2dbg/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libe2dbg/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -## -## Makefile for libe2dbg in the ERESI framework -## -## Started on Tue Aug 16 06:32:29 2005 jfv -## $Id: Makefile,v 1.17 2008-02-16 12:32:27 thor Exp $ -## - -include ../config.h - -LD ?= ld -RM = rm -f -DBGNAME32 = libe2dbg32 -DBGNAME64 = libe2dbg64 -DBGNAME32O = e2dbg-rel32.o -DBGNAME64O = e2dbg-rel64.o -KDBGNAME32O = ke2dbg-rel32.o -KDBGNAME64O = ke2dbg-rel64.o -AR = ar rc -STRIP = strip - -LDFLAGS32 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) -LDFLAGS64 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) - -EXTRAOBJ32 = ../libasm/libasm.o ../libmjollnir/libmjollnir32.o \ - ../libelfsh/libelfsh32.o ../libedfmt/libedfmt32.o \ - ../liballocproxy/liballocproxy.o ../librevm/revm-*.32.o \ - ../libaspect/libaspect32.o ../libstderesi/libstderesi32.o \ - $(LDDUMPOBJ) - -EXTRAOBJ64 = ../libasm/libasm.o ../libmjollnir/libmjollnir64.o \ - ../libelfsh/libelfsh64.o ../libedfmt/libedfmt64.o \ - ../liballocproxy/liballocproxy.o ../librevm/revm-*.64.o \ - ../libaspect/libaspect64.o ../libstderesi/libstderesi64.o \ - $(LDDUMPOBJ) - -COBJ32 = common/*.32.o -COBJ64 = common/*.64.o -KOBJ32 = kernel/*.32.o -KOBJ64 = kernel/*.64.o -UOBJ32 = user/*.32.o -UOBJ64 = user/*.64.o - -all : all32 all64 - -all32 : mod32 lib32 - -mod32 : - $(MAKE) -C common all32 - $(MAKE) -C user all32 -ifdef USE_KE2DBG - $(MAKE) -C kernel -endif - -$(DBGNAME32O): - @$(CC) -shared $(COBJ32) $(EXTRAOBJ32) $(UOBJ32) $(LDFLAGS32) \ - $(KERNSHLIB32) -o $(DBGNAME32).so - @$(AR) $(DBGNAME32).a $(COBJ32) $(UOBJ32) $(EXTRAOBJ32) - @$(RANLIB) $(DBGNAME32).a - @$(LD) -r $(COBJ32) $(EXTRAOBJ32) $(UOBJ32) -o $(DBGNAME32O) - #$(STRIP) $(DBGNAME32O) - -lib32: $(DBGNAME32O) -lib64: $(DBGNAME64O) - - -all64 : mod64 lib64 - -mod64 : - $(MAKE) -C common all64 - $(MAKE) -C user all64 - -$(DBGNAME64O) : - @$(CC) -shared $(OBJ64) $(EXTRAOBJ64) $(UOBJ64) $(LDFLAGS64) \ - $(KERNSHLIB64) -o $(DBGNAME64).so - @$(AR) $(DBGNAME64).a $(OBJ64) - @$(RANLIB) $(DBGNAME64).a - @$(LD) -r $(OBJ64) $(EXTRAOBJ64) -o $(DBGNAME64O) - #$(STRIP) $(DBGNAME64O) - -# This target is work in progress (static files debugger) -et_rel : ${OBJ} - $(CC) -c $(CFLAGS) $(SRC_DYN) -o $(OBJ_DYN) - $(LD) ${OBJ_DYN} ${OBJ} ../libasm/libasm.a \ - ../libelfsh/libelfsh.a ../liballocproxy.a \ - /usr/lib/libdl.a /usr/lib/libc.a -r \ - -o $(DBGNAME)_rel.o - -clean : - @$(MAKE) -C common clean - @$(MAKE) -C kernel clean - @$(MAKE) -C user clean - @$(RM) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) $(KDBGNAME64O) $(KDBGNAME32O) $(DBGNAME32O) $(DBGNAME64O) - @$(RM) $(DBGNAME32).so $(DBGNAME64).so $(DBGNAME32).a $(DBGNAME64).a - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - - diff -Nru eresi-0.8a25/libe2dbg/user/alloc-proxy.c eresi-0.0.20110516/libe2dbg/user/alloc-proxy.c --- eresi-0.8a25/libe2dbg/user/alloc-proxy.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/alloc-proxy.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,12 +1,16 @@ /** - * @file alloc-proxy.c +* @file libe2dbg/user/alloc-proxy.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/alloc-proxy.c * Allocator wrapper for the Embedded ELF Debugger * * Select the allocator depending on the thread ID of the caller * * Started Fri Oct 7 21:05:26 CEST 2005 crew * - * $Id: alloc-proxy.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: alloc-proxy.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" @@ -132,11 +136,7 @@ * @param nbr * @return */ -#if __FreeBSD__ > 5 || defined(__OpenBSD__) void *calloc(size_t t, size_t nbr) -#else -void *calloc(size_t t, u_int nbr) -#endif { void *(*callocptr)(); void *chunk; @@ -423,8 +423,10 @@ */ void wait4exit(void *a) { - fprintf(stderr, "\n [*] Debuggee wait4exit called \n"); - while (!e2dbgworld.exited) + int idx; + + //fprintf(stderr, "\n [*] Debuggee wait4exit called \n"); + for (idx = 0; !e2dbgworld.exited && idx < 2; idx++) sleep(1); exit(0); } @@ -465,6 +467,17 @@ /** + * Wrapper for exit_group + * @param err Return value. + */ +int exit_group(int exitcode) +{ + write(2, " [*] Now exiting all threads\n\n", 30); + _exit(exitcode); +} + + +/** * Wrapper for heap initialisation * @param first_time * @return diff -Nru eresi-0.8a25/libe2dbg/user/continue.c eresi-0.0.20110516/libe2dbg/user/continue.c --- eresi-0.8a25/libe2dbg/user/continue.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/continue.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file continue.c +* @file libe2dbg/user/continue.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/continue.c * * The continue command in e2dbg * * - * $Id: continue.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: continue.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" @@ -17,7 +21,7 @@ if (e2dbgworld.curthread && e2dbgworld.curthread->count == E2DBG_BREAK_FINISHED) e2dbg_thread_contall(); - + #if __DEBUG_THREADS_ else if (!e2dbgworld.curthread) e2dbg_output(" [*] e2dbg_start_proc -NOT- doing CONTALL" @@ -41,7 +45,7 @@ if (world.curjob->curfile->running) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Process is already started", -1); + "Process is already started", -1); if (!world.state.revm_quiet) e2dbg_output(" [*] Starting process\n"); e2dbg_start_proc(); @@ -54,7 +58,7 @@ * See the count in e2dbg/signal.c that makes e2dbg need this * @return */ -int cmd_cont() +int cmd_cont() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -72,15 +76,6 @@ /* Restart the debuggee */ e2dbg_start_proc(); - - /* - if (!e2dbgworld.curthread->step) - { - e2dbg_start_proc(); - e2dbg_start_proc(); - } - */ - e2dbg_output("\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); } diff -Nru eresi-0.8a25/libe2dbg/user/dbg-amd64.c eresi-0.0.20110516/libe2dbg/user/dbg-amd64.c --- eresi-0.8a25/libe2dbg/user/dbg-amd64.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/dbg-amd64.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,331 @@ +/** +* @file libe2dbg/user/dbg-amd64.c +** @ingroup user +*/ +/* +** dbg-amd64.c for e2dbg in the ERESI framework +** +** Debugger backend for the AMD64 architecture +** +** Those hooks stay in the debugger and not in libelfsh. +** +** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter +** +** Started Sat Sep 24 07:17:33 2005 jfv +** $Id: dbg-amd64.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + +/* Regvars handler for the AMD64 architecture on BSD */ +void e2dbg_get_regvars_amd64_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); + E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); + E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); + E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); + E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); + E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); + E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); + //E2DBG_GETREG(E2DBG_SSPVAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); + E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); + E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); + E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); + E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); + E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); + E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); + //E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Regvars handler for the AMD64 architecture on SYSV */ +void e2dbg_get_regvars_amd64_sysv() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + E2DBG_GETREG(E2DBG_R8_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R8]); + E2DBG_GETREG(E2DBG_R9_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R9]); + E2DBG_GETREG(E2DBG_R10_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R10]); + E2DBG_GETREG(E2DBG_R11_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R11]); + E2DBG_GETREG(E2DBG_R12_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R12]); + E2DBG_GETREG(E2DBG_R13_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R13]); + E2DBG_GETREG(E2DBG_R14_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R14]); + E2DBG_GETREG(E2DBG_R15_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R15]); + E2DBG_GETREG(E2DBG_RDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RDI]); + E2DBG_GETREG(E2DBG_RSI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RSI]); + E2DBG_GETREG(E2DBG_RBP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RBP]); + E2DBG_GETREG(E2DBG_RBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RBX]); + E2DBG_GETREG(E2DBG_RDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RDX]); + E2DBG_GETREG(E2DBG_RAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RAX]); + E2DBG_GETREG(E2DBG_RCX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RCX]); + E2DBG_GETREG(E2DBG_RSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RSP]); + E2DBG_GETREG(E2DBG_RIP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RIP]); + E2DBG_GETREG(E2DBG_EFLAGS_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL]); + E2DBG_GETREG(E2DBG_CS_VAR, ((e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] >> 48) & 0xFFFF)); + E2DBG_GETREG(E2DBG_GS_VAR, ((e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] >> 32) & 0xFFFF)); + E2DBG_GETREG(E2DBG_FS_VAR, ((e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] >> 16) & 0xFFFF)); + E2DBG_GETREG(E2DBG_CR2_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CR2]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Regvars handler for the AMD64 architecture */ +void e2dbg_set_regvars_amd64_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) + +#elif !defined(sun) && defined(__FreeBSD__) + E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); + E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); + E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); + E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); + E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); + E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); + E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); + //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); + E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); + E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); + E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); + E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); + E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); + E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); + //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/* Regvars handler for the AMD64 architecture on SYSV */ +void e2dbg_set_regvars_amd64_sysv() +{ +#if defined(__amd64__) && defined(__linux__) + u_short reg16; + eresi_Addr reg64; + revmexpr_t *e; +#endif + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + E2DBG_SETREG(E2DBG_R8_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R8]); + E2DBG_SETREG(E2DBG_R9_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R9]); + E2DBG_SETREG(E2DBG_R10_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R10]); + E2DBG_SETREG(E2DBG_R11_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R11]); + E2DBG_SETREG(E2DBG_R12_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R12]); + E2DBG_SETREG(E2DBG_R13_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R13]); + E2DBG_SETREG(E2DBG_R14_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R14]); + E2DBG_SETREG(E2DBG_R15_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_R15]); + E2DBG_SETREG(E2DBG_RDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RDI]); + E2DBG_SETREG(E2DBG_RSI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RSI]); + E2DBG_SETREG(E2DBG_RBP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RBP]); + E2DBG_SETREG(E2DBG_RBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RBX]); + E2DBG_SETREG(E2DBG_RDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RDX]); + E2DBG_SETREG(E2DBG_RAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RAX]); + E2DBG_SETREG(E2DBG_RCX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RCX]); + E2DBG_SETREG(E2DBG_RSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RSP]); + E2DBG_SETREG(E2DBG_RIP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RIP]); + E2DBG_SETREG(E2DBG_EFLAGS_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL]); + + reg64 = e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS]; + + reg16 = (reg64 & 0xFFFF000000000000) >> 48; + e = revm_expr_get(E2DBG_CS_VAR); + if (e && e->value) + reg16 = e->value->immed_val.half; + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] = + (reg64 & 0x0000FFFFFFFFFFFF) | ((uint64_t) reg16 << 48); + + reg16 = (reg64 & 0x0000FFFF00000000) >> 32; + e = revm_expr_get(E2DBG_GS_VAR); + if (e && e->value) + reg16 = e->value->immed_val.half; + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] = + (reg64 & 0xFFFF0000FFFFFFFF) | ((uint64_t) reg16 << 32); + + reg16 = (reg64 & 0x00000000FFFF0000) >> 16; + e = revm_expr_get(E2DBG_FS_VAR); + if (e && e->value) + reg16 = e->value->immed_val.half; + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CSGSFS] = + (reg64 & 0xFFFFFFFF0000FFFF) | ((uint64_t) reg16 << 16); + + E2DBG_SETREG(E2DBG_CR2_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_CR2]); +#endif + + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getpc_bsd_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + +/* Get Program Counter register on Sys V */ +eresi_Addr* e2dbg_getpc_sysv_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RIP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getfp_bsd_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.mc_ebp); +#elif defined(__NetBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + +/* Get Program Counter register on Sys V */ +eresi_Addr* e2dbg_getfp_sysv_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_RBP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + +/* Enable stepping on BSD */ +void e2dbg_setstep_bsd_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; +#elif defined(__NetBSD__) + e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Enable stepping on Sys V */ +void e2dbg_setstep_sysv_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Disable stepping on Sys V */ +void e2dbg_resetstep_sysv_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__amd64__) && defined(__linux__) + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Disable stepping on BSD */ +void e2dbg_resetstep_bsd_amd64() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; +#elif defined(__NetBSD__) + e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** + * Get the next frame pointer given the current one + */ +void *e2dbg_bt_amd64(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + ((void *) *(eresi_Addr*) frame)); +} + +/** + * Get the return address giving the current frame pointer + */ +void *e2dbg_getret_amd64(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (void *) (*((eresi_Addr *) frame + 1))); +} + + +/** + * Write a breakpoint 0xCC in memory + * One of the 2 breakpoint technique of e2dbg + */ +int e2dbg_break_amd64(elfshobj_t *f, + elfshbp_t *bp) +{ + int prot; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:amd64] bp->addr %08X \n", bp->addr); +#endif + + bp->savedinstr[0] = *(eresi_Addr *) bp->addr; + prot = elfsh_munprotect(f, bp->addr, 4); + if (prot == (-1)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:amd64] after munprotect\n"); +#endif + *(u_char *) bp->addr = 0xCC; +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:amd64] after write\n"); +#endif + elfsh_mprotect(f, bp->addr, 4, prot); +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:amd64] after mprotect\n"); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); +} diff -Nru eresi-0.8a25/libe2dbg/user/dbg-ia32.c eresi-0.0.20110516/libe2dbg/user/dbg-ia32.c --- eresi-0.8a25/libe2dbg/user/dbg-ia32.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/dbg-ia32.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,326 @@ +/** +* @file libe2dbg/user/dbg-ia32.c +** @ingroup user +*/ +/* +** dbg-ia32.c for e2dbg in the ERESI framework +** +** Debugger backend for the IA32 architecture +** +** Those hooks stay in the debugger and not in libelfsh. +** +** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter +** +** Started Sat Sep 24 07:17:33 2005 jfv +** $Id: dbg-ia32.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + + +/* Printregs handlers for the IA32 architecture on FreeBSD */ +void e2dbg_print_regvars_ia32_freebsd() +{ +#if defined(__i386__) && defined(__FreeBSD__) + e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.mc_eax); + e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.mc_ebx); + e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.mc_ecx); + e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.mc_edx); + e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.mc_esi); + e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.mc_edi); + e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.mc_esp); + e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.mc_ebp); + e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#endif +} + +/* Printregs handlers for the IA32 architecture on NetBSD */ +void e2dbg_print_regvars_ia32_netbsd() +{ +#if defined(__i386__) && defined(__NetBSD__) + e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); + e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); + e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); + e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); + e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); + e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); + e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); + e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif +} +/* Printregs handlers for the IA32 architecture on NetBSD */ +void e2dbg_print_regvars_ia32_sysv() +{ +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + e2dbg_register_dump("EAX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); + e2dbg_register_dump("EBX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); + e2dbg_register_dump("ECX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); + e2dbg_register_dump("EDX", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); + e2dbg_register_dump("ESI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); + e2dbg_register_dump("EDI", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); + e2dbg_register_dump("ESP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); + e2dbg_register_dump("EBP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); + e2dbg_register_dump("EIP", e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); +#endif +} + +/* Regvars handler for the IA32 architecture on BSD */ +void e2dbg_get_regvars_ia32_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); + E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); + E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); + E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); + E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); + E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); + E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); + //E2DBG_GETREG(E2DBG_SSPVAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); + E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); + E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); + E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); + E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); + E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); + E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); + //E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Regvars handler for the IA32 architecture on SYSV */ +void e2dbg_get_regvars_ia32_sysv() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + E2DBG_GETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); + E2DBG_GETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); + E2DBG_GETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); + E2DBG_GETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); + E2DBG_GETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); + E2DBG_GETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); + E2DBG_GETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); + E2DBG_GETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); + E2DBG_GETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Regvars handler for the IA32 architecture */ +void e2dbg_set_regvars_ia32_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); + E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ebx); + E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ecx); + E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edx); + E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_esi); + E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_edi); + E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_esp); + //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_ebp); + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); + E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBX]); + E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ECX]); + E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDX]); + E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESI]); + E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EDI]); + E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_ESP]); + //E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.mc_ssp); /* XXX */ + E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/* Regvars handler for the IA32 architecture on SYSV */ +void e2dbg_set_regvars_ia32_sysv() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + E2DBG_SETREG(E2DBG_EAX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EAX]); + E2DBG_SETREG(E2DBG_EBX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBX]); + E2DBG_SETREG(E2DBG_ECX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ECX]); + E2DBG_SETREG(E2DBG_EDX_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDX]); + E2DBG_SETREG(E2DBG_ESI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESI]); + E2DBG_SETREG(E2DBG_EDI_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EDI]); + E2DBG_SETREG(E2DBG_SP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_ESP]); + E2DBG_SETREG(E2DBG_SSP_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_UESP]); + E2DBG_SETREG(E2DBG_FP_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getpc_bsd_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(__NetBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + +/* Get Program Counter register on Sys V */ +eresi_Addr* e2dbg_getpc_sysv_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EIP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getfp_bsd_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.mc_ebp); +#elif defined(__NetBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + &e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); + +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + +/* Get Program Counter register on Sys V */ +eresi_Addr* e2dbg_getfp_sysv_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EBP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + +/* Enable stepping on BSD */ +void e2dbg_setstep_bsd_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; +#elif defined(__NetBSD__) + e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Enable stepping on Sys V */ +void e2dbg_setstep_sysv_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Disable stepping on Sys V */ +void e2dbg_resetstep_sysv_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(__i386__) && (defined(__linux__) || defined(sun)) + e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Disable stepping on BSD */ +void e2dbg_resetstep_bsd_ia32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if !defined(sun) && !defined(__amd64__) && defined(__FreeBSD__) //|| defined (__OpenBSD__) + e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; +#elif defined(__NetBSD__) + e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** + * Get the next frame pointer given the current one + */ +void *e2dbg_bt_ia32(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + ((void *) *(long*) frame)); +} + +/** + * Get the return address giving the current frame pointer + */ +void *e2dbg_getret_ia32(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + printf("Ret found at %p - %#x\n", ((long *) frame + 1), *((long *) frame + 1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (void *) (*((long *) frame + 1))); +} + + +/** + * Write a breakpoint 0xCC in memory + * One of the 2 breakpoint technique of e2dbg + */ +int e2dbg_break_ia32(elfshobj_t *f, + elfshbp_t *bp) +{ + int prot; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] bp->addr %08X \n", bp->addr); +#endif + + bp->savedinstr[0] = *(u_long *) bp->addr; + prot = elfsh_munprotect(f, bp->addr, 4); + if (prot == (-1)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after munprotect\n"); +#endif + *(u_char *) bp->addr = 0xCC; +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after write\n"); +#endif + elfsh_mprotect(f, bp->addr, 4, prot); +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:ia32] after mprotect\n"); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); +} diff -Nru eresi-0.8a25/libe2dbg/user/dbg-mips.c eresi-0.0.20110516/libe2dbg/user/dbg-mips.c --- eresi-0.8a25/libe2dbg/user/dbg-mips.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/dbg-mips.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,61 @@ +/** +* @file libe2dbg/user/dbg-mips.c +** @ingroup user +*/ +/* +** dbg-mips.c for e2dbg in the ERESI framework +** +** INCOMPLETE Debugger backend for the MIPS architecture +** +** Those hooks stay in the debugger and not in libelfsh. +** +** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter +** +** Started Sat Sep 24 07:17:33 2005 jfv +** $Id: dbg-mips.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + + +/* Printregs handlers for the IA32 architecture on NetBSD */ +void e2dbg_print_regvars_mips_irix() +{ +#if defined(IRIX) && defined(__mips) + e2dbg_register_dump("R0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_R0]); + e2dbg_register_dump("AT", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_AT]); + e2dbg_register_dump("V0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V0]); + e2dbg_register_dump("V1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_V1]); + e2dbg_register_dump("A0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A0]); + e2dbg_register_dump("A1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A1]); + e2dbg_register_dump("A2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A2]); + e2dbg_register_dump("A3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A3]); + e2dbg_register_dump("A4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A4]); + e2dbg_register_dump("A5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A5]); + e2dbg_register_dump("A6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A6]); + e2dbg_register_dump("A7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_A7]); + e2dbg_register_dump("T0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T0]); + e2dbg_register_dump("T1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T1]); + e2dbg_register_dump("T2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T2]); + e2dbg_register_dump("T3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T3]); + e2dbg_register_dump("S0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S0]); + e2dbg_register_dump("S1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S1]); + e2dbg_register_dump("S2", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S2]); + e2dbg_register_dump("S3", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S3]); + e2dbg_register_dump("S4", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S4]); + e2dbg_register_dump("S5", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S5]); + e2dbg_register_dump("S6", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S6]); + e2dbg_register_dump("S7", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S7]); + e2dbg_register_dump("T8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T8]); + e2dbg_register_dump("T9", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_T9]); + e2dbg_register_dump("K0", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K0]); + e2dbg_register_dump("K1", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_K1]); + e2dbg_register_dump("GP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_GP]); + e2dbg_register_dump("SP", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SP]); + e2dbg_register_dump("S8", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_S8]); + e2dbg_register_dump("RA", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_RA]); + e2dbg_register_dump("MDLO", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDLO]); + e2dbg_register_dump("MDHI", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_MDHI]); + e2dbg_register_dump("EPC", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_EPC]); + e2dbg_register_dump("SR", e2dbgworld.curthread->context->uc_mcontext.__gregs[CTX_SR]); +#endif +} diff -Nru eresi-0.8a25/libe2dbg/user/dbg-sparc32.c eresi-0.0.20110516/libe2dbg/user/dbg-sparc32.c --- eresi-0.8a25/libe2dbg/user/dbg-sparc32.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/dbg-sparc32.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,348 @@ +/** +* @file libe2dbg/user/dbg-sparc32.c +** @ingroup user +*/ +/* +** dbg-sparc32.c for e2dbg in the ERESI framework +** +** Debugger backend for the SPARC32 architecture +** +** Those hooks stay in the debugger and not in libelfsh. +** +** Vectors can also be accessed with 'vectors' cmd in any eresi interpreter +** +** Started Thu Jun 07 07:17:33 2007 mayhem +** $Id: dbg-sparc32.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libe2dbg.h" + + +/* Regvars handler for the IA32 architecture on BSD */ +void e2dbg_get_regvars_sparc32_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); +#elif defined(SPARC) && defined(__NetBSD__) + //E2DBG_GETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Regvars handler for the IA32 architecture on SYSV */ +void e2dbg_get_regvars_sparc32_sysv() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + E2DBG_GETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); + E2DBG_GETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); + E2DBG_GETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); + E2DBG_GETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); + E2DBG_GETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); + E2DBG_GETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); + E2DBG_GETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); + E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); + E2DBG_GETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); + E2DBG_GETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); + E2DBG_GETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); + E2DBG_GETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); + E2DBG_GETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); + E2DBG_GETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); + E2DBG_GETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); + E2DBG_GETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); + E2DBG_GETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); + E2DBG_GETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Regvars handler for the IA32 architecture */ +void e2dbg_set_regvars_sparc32_bsd() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.mc_eax); +#elif defined(SPARC) && defined(__NetBSD__) + //E2DBG_SETREG(ELFSH_EAXVAR, e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EAX]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/* Regvars handler for the IA32 architecture on SYSV */ +void e2dbg_set_regvars_sparc32_sysv() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + E2DBG_SETREG(E2DBG_PC_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); + E2DBG_SETREG(E2DBG_NPC_VAR, e2dbgworld.curthread->context->uc_mcontext.gregs[REG_nPC]); + E2DBG_SETREG(E2DBG_Y_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_Y]); + E2DBG_SETREG(E2DBG_G1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G1]); + E2DBG_SETREG(E2DBG_G2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G2]); + E2DBG_SETREG(E2DBG_G3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G3]); + E2DBG_SETREG(E2DBG_G4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G4]); + E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G5]); + E2DBG_SETREG(E2DBG_G5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G6]); + E2DBG_SETREG(E2DBG_G7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_G7]); + E2DBG_SETREG(E2DBG_O0_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O0]); + E2DBG_SETREG(E2DBG_O1_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O1]); + E2DBG_SETREG(E2DBG_O2_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O2]); + E2DBG_SETREG(E2DBG_O3_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O3]); + E2DBG_SETREG(E2DBG_O4_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O4]); + E2DBG_SETREG(E2DBG_O5_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O5]); + E2DBG_SETREG(E2DBG_O6_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); + E2DBG_SETREG(E2DBG_O7_VAR , e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O7]); +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getpc_bsd_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + //&e2dbgworld.curthread->context->uc_mcontext.mc_eip); +#elif defined(SPARC) && defined(__NetBSD__) + //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EIP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + +/* Get Program Counter register on Sys V */ +eresi_Addr* e2dbg_getpc_sysv_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *) &e2dbgworld.curthread->context->uc_mcontext.gregs[REG_PC]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + + +/* Get Program Counter register */ +eresi_Addr* e2dbg_getfp_bsd_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + //&e2dbgworld.curthread->context->uc_mcontext.mc_ebp); +#elif defined(__NetBSD__) + //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + //&e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EBP]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + +/* Get Program Stack Pointer register on Sys V */ +/* On SPARC, we use SP and not FP in that handler */ +eresi_Addr* e2dbg_getfp_sysv_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (eresi_Addr *)&e2dbgworld.curthread->context->uc_mcontext.gregs[REG_O6]); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + + +/* Enable stepping on BSD */ +void e2dbg_setstep_bsd_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //e2dbgworld.curthread->context->uc_mcontext.mc_eflags |= 0x100; +#elif defined(SPARC) && defined(__NetBSD__) + //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Enable stepping on Sys V */ +void e2dbg_setstep_sysv_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] |= 0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/* Disable stepping on Sys V */ +void e2dbg_resetstep_sysv_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__linux__) || defined(sun)) + //e2dbgworld.curthread->context->uc_mcontext.gregs[REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/* Disable stepping on BSD */ +void e2dbg_resetstep_bsd_sparc32() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(SPARC) && (defined(__FreeBSD__) || defined (__OpenBSD__)) + //e2dbgworld.curthread->context->uc_mcontext.mc_eflags &= ~0x100; +#elif defined(SPARC) && defined(__NetBSD__) + //e2dbgworld.curthread->context->uc_mcontext.__gregs[_REG_EFL] &= ~0x100; +#endif + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/** + * Get the next frame pointer given the current one + */ +void *e2dbg_bt_sparc32(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + ((void *) *(long*) frame + 14)); +} + + +/** + * Get the return address giving the current frame pointer + */ +void *e2dbg_getret_sparc32(void *frame) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!frame) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (void *) (*((long *) frame + 15))); +} + + +/** + * Write a sparc breakpoint in memory + * One of the 2 breakpoint technique of e2dbg + */ +#if !defined(SPARC) +int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) +{ + return (0); +} +#else +int e2dbg_break_sparc32(elfshobj_t *f, elfshbp_t *bp) +{ + int prot; + unsigned long addr; + unsigned long long addr64; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] bp->addr %016x \n", bp->addr); +#endif + + memcpy(bp->savedinstr, (u_char *) bp->addr, 8); + + prot = elfsh_munprotect(f, bp->addr, 8); + if (prot == (-1)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Munprotect failed", (-1)); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after munprotect\n"); +#endif + + //*(u_long *) bp->addr = 0x91d02001; /* opcode for ta 1 */ + + *((u_long *) bp->addr) = 0x01000000; /* put nop here */ + *((u_long *) bp->addr + 1) = 0x01000000; /* put nop here */ + + addr = (bp->addr & (~7)); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address to be flushed: %016lx \n", addr); +#endif + + /* FIXME: Testing .... nothing is working until now */ + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (0)); + + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (8)); + + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (16)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (0)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (8)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr), + "r" (16)); + + addr64 = 0xffffffff00000000 + addr; + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] Address64 to be flushed: %016llx \n", addr64); +#endif + + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (0)); + + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (8)); + + __asm__ __volatile__("iflush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (16)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (0)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (8)); + + __asm__ __volatile__("flush %0 + %1 \n\t" :: + "r" ((unsigned long) addr64), + "r" (16)); + + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after sleep & write\n"); +#endif + + elfsh_mprotect(f, bp->addr, 8, prot); + + sleep(2); + +#if __DEBUG_BREAKPOINTS__ + fprintf(stderr, "[DEBUG_BREAKPOINTS:sparc32] after mprotect\n"); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); +} +#endif /* defined(SPARC) */ + + diff -Nru eresi-0.8a25/libe2dbg/user/delbreak.c eresi-0.0.20110516/libe2dbg/user/delbreak.c --- eresi-0.8a25/libe2dbg/user/delbreak.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/delbreak.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,14 @@ +/** +* @file libe2dbg/user/delbreak.c +** @ingroup user +*/ +#include "libe2dbg.h" + + +/* Vector handler for userland breakpoint deletion */ +int e2dbg_delbreak_user(elfshbp_t *bp) +{ + *(u_char *) bp->addr = bp->savedinstr[0]; + return (0); +} + diff -Nru eresi-0.8a25/libe2dbg/user/delete.c eresi-0.0.20110516/libe2dbg/user/delete.c --- eresi-0.8a25/libe2dbg/user/delete.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/delete.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/** - * @file delete.c - * - * Delete breakpoints - * - * Started on Tue Aug 16 09:38:03 2005 jfv - * - * $Id: delete.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/** - * Delete a breakpoint - * @return - */ -int cmd_delete() -{ - eresi_Addr addr; - elfshbp_t *bp; - char *name; - int prot; - elfsh_SAddr off; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lookup breakpoint */ - bp = e2dbg_breakpoint_lookup(revm_lookup_string(world.curjob->curcmd->param[0])); - if (!bp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown breakpoint", -1); - addr = bp->addr; - - /* Delete the breakpoint */ - prot = elfsh_munprotect(bp->obj, addr, 1); - *(u_char *) addr = bp->savedinstr[0]; - elfsh_mprotect(addr, 1, prot); - - name = revm_resolve(bp->obj, addr, &off); - snprintf(logbuf, BUFSIZ, XFMT, addr); - hash_del(&e2dbgworld.bp, logbuf); - - if (off) - snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT - " <%s + " UFMT "> removed\n\n", addr, name, off); - else - snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT " <%s> removed\n\n", - addr, name); - e2dbg_output(logbuf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libe2dbg/user/e2dbg.c eresi-0.0.20110516/libe2dbg/user/e2dbg.c --- eresi-0.8a25/libe2dbg/user/e2dbg.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/e2dbg.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,41 +1,47 @@ /** - * @file e2dbg.c +* @file libe2dbg/user/e2dbg.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/e2dbg.c * * Starting routines for the debugger * * Started on Fri Jun 05 15:21:56 2005 jfv * * - * $Id: e2dbg.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: e2dbg.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" /* The debugger world */ -e2dbgworld_t e2dbgworld; - - -/** - * Debugger library initialisation - * Only useful when debugger takes control by .ctors - */ -void e2dbg_init(void) +/* e2dbgworld_t e2dbgworld; */ +void e2dbg_register_command(void) { -#if __DEBUG_E2DBG__ - write(2, " [D] Calling DLSYM_INIT from e2dbg_init() !\n", 45); -#endif - - aspect_called_ctors_inc(); - - e2dbg_dlsym_init(); - - if (aspect_called_ctors_finished()) - e2dbg_presence_reset(); - -#if __DEBUG_E2DBG__ - write(2, " [D] Finished e2dbg ctors \n", 27); -#endif + /* Debugger only script commands */ + revm_command_add(CMD_MODE , (void *) cmd_mode , revm_getvarparams, 0, HLP_MODE); + revm_command_add(CMD_LINKMAP , (void *) cmd_linkmap , NULL, 1, HLP_LINKMAP); + revm_command_add(CMD_BT , (void *) cmd_bt , NULL, 1, HLP_BT); + revm_command_add(CMD_BT2 , (void *) cmd_bt , NULL, 1, HLP_BT); + revm_command_add(CMD_BP , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); + revm_command_add(CMD_WATCH , (void *) cmd_watch , revm_getvarparams, 1, HLP_WATCH); + revm_command_add(CMD_BP2 , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); + revm_command_add(CMD_STACK , (void *) cmd_stack , revm_getoption, 1, HLP_STACK); + revm_command_add(CMD_DBGSTACK , (void *) cmd_dbgstack , revm_getoption, 1, HLP_DBGSTACK); + revm_command_add(CMD_DUMPREGS , (void *) cmd_dumpregs , NULL, 1, HLP_DUMPREGS); + revm_command_add(CMD_DELETE , (void *) cmd_delete , revm_getvarparams, 1, HLP_DELETE); + revm_command_add(CMD_CONTINUE , (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); + revm_command_add(CMD_CONTINUE2, (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); + revm_command_add(CMD_START , (void *) cmd_start , (void *) NULL, 1, HLP_START); + revm_command_add(CMD_STEP , (void *) cmd_step , (void *) NULL, 1, HLP_STEP); + revm_command_add(CMD_DISPLAY , (void *) cmd_display , revm_getvarparams, 1, HLP_DISPLAY); + revm_command_add(CMD_UNDISPLAY, (void *) cmd_undisplay, revm_getvarparams, 1, HLP_UNDISPLAY); + revm_command_add(CMD_RSHT , (void *) cmd_rsht , revm_getregxoption, 1, HLP_RSHT); + revm_command_add(CMD_RPHT , (void *) cmd_rpht , revm_getregxoption, 1, HLP_RPHT); + revm_command_add(CMD_THREADS , (void *) cmd_threads , revm_getvarparams, 1, HLP_THREADS); + revm_command_add(CMD_ITRACE , (void *) cmd_itrace , revm_getvarparams, 1, HLP_ITRACE); } @@ -48,7 +54,7 @@ { int ac; char **av; - int ret; + elfshobj_t *ret; static int first = 1; #if __DEBUG_E2DBG__ @@ -63,7 +69,7 @@ #if __DEBUG_E2DBG__ fprintf(stderr, "[e2dbg_entry] CHECKPOINT 1\n"); #endif - + /* We have a debugger script pending, continue it */ if (e2dbgworld.sourcing) { @@ -88,7 +94,7 @@ #endif if (av && ac) - revm_setup(ac, av, REVM_STATE_DEBUGGER, REVM_SIDE_SERVER); + revm_setup(ac, av, REVM_STATE_EMBEDDED, REVM_SIDE_SERVER); #if __DEBUG_E2DBG__ fprintf(stderr, "[e2dbg_entry] CHECKPOINT 4\n"); @@ -97,29 +103,7 @@ /* Only on first execution */ if (first) { - /* Debugger only script commands */ - revm_command_add(CMD_MODE , (void *) cmd_mode , revm_getvarparams, 0, HLP_MODE); - revm_command_add(CMD_LINKMAP , (void *) cmd_linkmap , NULL, 1, HLP_LINKMAP); - revm_command_add(CMD_BT , (void *) cmd_bt , NULL, 1, HLP_BT); - revm_command_add(CMD_BT2 , (void *) cmd_bt , NULL, 1, HLP_BT); - revm_command_add(CMD_BP , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); - revm_command_add(CMD_WATCH , (void *) cmd_watch , revm_getvarparams, 1, HLP_WATCH); - revm_command_add(CMD_BP2 , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); - revm_command_add(CMD_STACK , (void *) cmd_stack , revm_getoption, 1, HLP_STACK); - revm_command_add(CMD_DBGSTACK , (void *) cmd_dbgstack , revm_getoption, 1, HLP_DBGSTACK); - revm_command_add(CMD_DUMPREGS , (void *) cmd_dumpregs , NULL, 1, HLP_DUMPREGS); - revm_command_add(CMD_DELETE , (void *) cmd_delete , revm_getoption, 1, HLP_DELETE); - revm_command_add(CMD_CONTINUE , (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); - revm_command_add(CMD_CONTINUE2, (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); - revm_command_add(CMD_START , (void *) cmd_start , (void *) NULL, 1, HLP_START); - revm_command_add(CMD_STEP , (void *) cmd_step , (void *) NULL, 1, HLP_STEP); - revm_command_add(CMD_DISPLAY , (void *) cmd_display , revm_getvarparams, 1, HLP_DISPLAY); - revm_command_add(CMD_UNDISPLAY, (void *) cmd_undisplay, revm_getvarparams, 1, HLP_UNDISPLAY); - revm_command_add(CMD_RSHT , (void *) cmd_rsht , revm_getregxoption, 1, HLP_RSHT); - revm_command_add(CMD_RPHT , (void *) cmd_rpht , revm_getregxoption, 1, HLP_RPHT); - revm_command_add(CMD_THREADS , (void *) cmd_threads , revm_getvarparams, 1, HLP_THREADS); - revm_command_add(CMD_ITRACE , (void *) cmd_itrace , (void *) NULL , 1, HLP_ITRACE); - + e2dbg_register_command(); #if __DEBUG_E2DBG__ fprintf(stderr, "[e2dbg_entry] CHECKPOINT 4bis\n"); #endif @@ -134,7 +118,7 @@ fprintf(stderr, "[e2dbg_entry] CHECKPOINT 5\n"); #endif - if (world.state.revm_mode == REVM_STATE_DEBUGGER && av && + if (world.state.revm_mode == REVM_STATE_EMBEDDED && av && e2dbg_setup(av[1]) < 0) { profiler_error(); @@ -148,7 +132,7 @@ ret = revm_run(ac, av); SETSIG; - return (ret); + return (ret ? 0 : -1); } @@ -166,14 +150,14 @@ fprintf(stderr, "[e2dbg_setup] Starting \n"); #endif - e2dbg_setup_hooks(); + e2dbg_user_hooks_install(); revm_initio(); revm_config(E2DBG_CONFIG); e2dbg_linkmap_load(name); /* Everything was OK */ e2dbg_output("\n"); - elfsh_set_debug_mode(); + elfsh_set_runtime_mode(); revm_doswitch(1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libe2dbg/user/e2dbg-misc.c eresi-0.0.20110516/libe2dbg/user/e2dbg-misc.c --- eresi-0.8a25/libe2dbg/user/e2dbg-misc.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/e2dbg-misc.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,67 +1,21 @@ /** - * @file e2dbg-misc.c +* @file libe2dbg/user/e2dbg-misc.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/e2dbg-misc.c * * Misc routines for the debugger * * Started on Fri Jun 05 15:21:56 2005 jfv * * - * $Id: e2dbg-misc.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: e2dbg-misc.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" -/** - * Get the parent object of a breakpoint. - * Thats needed for the mprotect stuff inside the breakpoint handler - * @param addr - * @return - */ -elfshobj_t *e2dbg_get_parent_object(eresi_Addr addr) -{ - elfsh_Phdr *cur; - elfshobj_t *curfile; - elfshsect_t *cursect; - char **keys; - int index; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (index = 0; index < keynbr; index++) - { - curfile = hash_get(&world.curjob->loaded, keys[index]); - cursect = elfsh_get_parent_section(curfile, addr, NULL); - if (cursect) - { - cur = elfsh_get_parent_segment(curfile, cursect); - if (cur) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, curfile); - } - } - - /* Parent object not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent object addr", (NULL)); -} - - -/** - * Realize the output. - * @todo: XXX: Need a vector - * @param str - * @return - */ -int e2dbg_output(char *str) -{ - //revm_output(str); - fprintf(stderr, str); - return (0); -} - - /** * Get the identity of the current process or thread * @return @@ -135,10 +89,9 @@ /** * Only called when running a monothread program - * @param start * @return */ -int e2dbg_curthread_init(void *start) +int e2dbg_curthread_init(void) { e2dbgthread_t *new; char *key; diff -Nru eresi-0.8a25/libe2dbg/user/entry.c eresi-0.0.20110516/libe2dbg/user/entry.c --- eresi-0.8a25/libe2dbg/user/entry.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/entry.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,13 +1,14 @@ /** - * @file entry.c - * - * The debugger file for OS dependant entry points + * @defgroup user Userland debugging API. + * @ingroup libe2dbg + */ +/** +* @file libe2dbg/user/entry.c + * @brief The debugger file for OS dependant entry points + * @ingroup user * * Started on Tue Jul 11 20:37:33 2003 jfv - * - * - * $Id: entry.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * + * $Id: entry.c 1397 2009-09-13 02:19:08Z may $ */ #include "libe2dbg.h" diff -Nru eresi-0.8a25/libe2dbg/user/init.c eresi-0.0.20110516/libe2dbg/user/init.c --- eresi-0.8a25/libe2dbg/user/init.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/init.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,28 @@ +/** +* @file libe2dbg/user/init.c +** @ingroup user +*/ +#include "libe2dbg.h" + + +/** + * Debugger library initialisation + * Only useful when debugger takes control by .ctors + */ +void e2dbg_init(void) +{ +#if __DEBUG_E2DBG__ + write(2, " [D] Calling DLSYM_INIT from e2dbg_init() !\n", 45); +#endif + + aspect_called_ctors_inc(); + + e2dbg_dlsym_init(); + + if (aspect_called_ctors_finished()) + e2dbg_presence_reset(); + +#if __DEBUG_E2DBG__ + write(2, " [D] Finished e2dbg ctors \n", 27); +#endif +} diff -Nru eresi-0.8a25/libe2dbg/user/linkmap.c eresi-0.0.20110516/libe2dbg/user/linkmap.c --- eresi-0.8a25/libe2dbg/user/linkmap.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/linkmap.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,9 +1,13 @@ /** - * @file linkmap.c +* @file libe2dbg/user/linkmap.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/linkmap.c * * Started on Tue Aug 16 09:38:03 2005 jfv * - * $Id: linkmap.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: linkmap.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" @@ -39,7 +43,7 @@ fprintf(stderr, "[e2dbg] Starting Loading LINKMAP !! \n"); #endif - e2dbg_setup_hooks(); + e2dbg_user_hooks_install(); revm_config(E2DBG_CONFIG); /* Load debugged file */ @@ -56,6 +60,7 @@ #endif world.curjob->curfile->linkmap = E2DBG_DYNAMIC_LINKMAP; + world.curjob->curfile->iotype = ELFSH_IOTYPE_EMBEDDED; world.curjob->curfile->running = 0; } @@ -126,7 +131,7 @@ //fprintf(stderr, "[e2dbg_linkmap_load] after ELF header \n"); /* Get ALTGOT entry */ - data = elfsh_get_raw(got); + data = elfsh_readmem(got); //fprintf(stderr, "[e2dbg_linkmap_load] after get_raw (data = %08X) \n", data); @@ -154,12 +159,7 @@ world.curjob->curfile->linkmap); #endif - - - - revm_doswitch(1); - /* now load all linkmap's files */ for (actual = elfsh_linkmap_get_lprev(world.curjob->curfile->linkmap); @@ -175,9 +175,11 @@ ename = elfsh_linkmap_get_lname(actual); if (ename && *ename && !revm_is_loaded(ename)) { - if (revm_file_load(ename, elfsh_linkmap_get_laddr(actual), - world.curjob->curfile->linkmap) < 0) + if (revm_file_load(ename, + elfsh_linkmap_get_laddr(actual), + world.curjob->curfile->linkmap) < 0) e2dbg_output(" [EE] Loading failed"); + world.curjob->curfile->iotype = ELFSH_IOTYPE_EMBEDDED; } } @@ -200,14 +202,15 @@ if (ename && *ename && !revm_is_loaded(ename)) { if (revm_file_load(ename, elfsh_linkmap_get_laddr(actual), - world.curjob->curfile->linkmap) < 0) + world.curjob->curfile->linkmap) < 0) e2dbg_output(" [EE] Loading failed"); + world.curjob->curfile->iotype = ELFSH_IOTYPE_EMBEDDED; } } /* Everything was OK */ e2dbg_output("\n"); - //elfsh_set_debug_mode(); + //elfsh_set_runtime_mode(); revm_doswitch(1); done = 1; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -215,96 +218,4 @@ -/** - * Dump the linkmap - * @param file - * @return - */ -int e2dbg_linkmap_print(elfshobj_t *file) -{ - char logbuf[BUFSIZ]; -#if defined(sun) - Link_map *actual; -#else - elfshlinkmap_t *actual; -#endif - int i = 1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - if (!file->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No linkmap", -1); - - e2dbg_output(" .::. Linkmap entries .::. \n"); - - for (actual = elfsh_linkmap_get_lprev(file->linkmap); actual != NULL; - actual = elfsh_linkmap_get_lprev(actual), i++) - { - snprintf(logbuf, BUFSIZ - 1, - " [%02u] addr : " XFMT " dyn : " XFMT " - %s\n", i, - (eresi_Addr) elfsh_linkmap_get_laddr(actual), - (eresi_Addr) elfsh_linkmap_get_lld(actual), - elfsh_linkmap_get_lname(actual)); - e2dbg_output(logbuf); - } - - for (actual = file->linkmap; actual != NULL; - actual = elfsh_linkmap_get_lnext(actual), i++) - { - snprintf(logbuf, BUFSIZ - 1, - " [%02u] addr : "XFMT" dyn : "XFMT" - %s\n", i, - (eresi_Addr) elfsh_linkmap_get_laddr(actual), - (eresi_Addr) elfsh_linkmap_get_lld(actual), - elfsh_linkmap_get_lname(actual)); - e2dbg_output(logbuf); - } - - e2dbg_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Linkmap dump command - * @return -*/ -int cmd_linkmap() -{ - int old; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_is_debug_mode()) - { - if (!world.curjob) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current workspace", -1); - - if (!world.curjob->curfile) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current file", -1); - - old = world.curjob->curfile->id; - - /* switch to the main program file */ - revm_doswitch(1); - ret = e2dbg_linkmap_print(world.curjob->curfile); - revm_doswitch(old); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Debug mode only command", (-1)); -} - - - - diff -Nru eresi-0.8a25/libe2dbg/user/Makefile eresi-0.0.20110516/libe2dbg/user/Makefile --- eresi-0.8a25/libe2dbg/user/Makefile 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/Makefile 2011-05-16 11:35:07.000000000 +0000 @@ -2,44 +2,57 @@ ## Makefile for userland part of libe2dbg in the ERESI framework ## ## Started on Wed Dec 19 06:32:29 2005 jfv -## $Id +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ ## include ../../config.h -SRC = e2dbg.c delete.c signal.c linkmap.c continue.c \ - alloc-proxy.c resolv.c threads.c entry.c e2dbg-misc.c +LD ?= ld +SRC = init.c e2dbg.c signal.c linkmap.c continue.c \ + alloc-proxy.c resolv.c threads.c entry.c e2dbg-misc.c \ + dbg-ia32.c dbg-sparc32.c dbg-amd64.c delbreak.c \ + register.c step.c dbg-mips.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) +OBJNAME32 = libe2dbg-user32 CC ?= gcc RM = rm -f CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ + -I ../../libgdbwrap/include/ \ -I../../libelfsh/include/ -I../../libdump/include/ \ -I../../libasm/include/ -I../../libstderesi/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ -I../../libaspect/include -I../../librevm/include/ \ -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINCINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI32 + -I../../libetrace/include/ \ + -DE2DBG_PRESENT -DE2DBG_INTERN $(ASMOPT) $(EXTRACFLAGS) \ + -DERESI32 CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ + -I ../../libgdbwrap/include/ \ -I../../libelfsh/include/ -I../../libdump/include/ \ -I../../libasm/include/ -I../../libstderesi/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ -I../../libaspect/include -I../../librevm/include/ \ -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI64 + -I../../libetrace/include/ \ + -DE2DBG_PRESENT -DE2DBG_INTERN $(ASMOPT) $(EXTRACFLAGS) \ + -DERESI64 all : all32 all64 all32 : ${OBJ32} + $(LD) -r $(OBJ32) -o $(OBJNAME32).o all64 : ${OBJ64} + $(LD) -r $(OBJ64) -o $(OBJNAME64).o + +#$(OBJNAME32) :$(CC) $(SRC) $(OBJ32) -o $(OBJNAME).so +# $(LD) -r $(OBJ32) -o $(OBJNAME32).so clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *.o *~ \#* *\# .\#* @$(RM) include/*~ include/\#* include/*\# include/.\#* fclean : clean diff -Nru eresi-0.8a25/libe2dbg/user/register.c eresi-0.0.20110516/libe2dbg/user/register.c --- eresi-0.8a25/libe2dbg/user/register.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/register.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,375 @@ +/** +* @file libe2dbg/user/register.c +** @ingroup user +*/ +#include "libe2dbg.h" + + +static void e2dbg_user_register_hooks(void) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Linux / AMD64 target */ + e2dbg_register_gregshook(ELFSH_ARCH_AMD64, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_get_regvars_amd64_sysv); + e2dbg_register_sregshook(ELFSH_ARCH_AMD64, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_set_regvars_amd64_sysv); + e2dbg_register_getpchook(ELFSH_ARCH_AMD64, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_getpc_sysv_amd64); + e2dbg_register_setstephook(ELFSH_ARCH_AMD64, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_setstep_sysv_amd64); + e2dbg_register_resetstephook(ELFSH_ARCH_AMD64, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_resetstep_sysv_amd64); + e2dbg_register_nextfphook(ELFSH_ARCH_AMD64, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_bt_amd64); + e2dbg_register_getfphook(ELFSH_ARCH_AMD64, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getfp_sysv_amd64); + e2dbg_register_getrethook(ELFSH_ARCH_AMD64, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getret_amd64); + e2dbg_register_breakhook(ELFSH_ARCH_AMD64, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_break_amd64); + + /* Initialize vectors */ + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_get_regvars_ia32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_get_regvars_ia32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_get_regvars_ia32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_get_regvars_ia32_sysv); + e2dbg_register_gregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_get_regvars_ia32_sysv); + + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_set_regvars_ia32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_set_regvars_ia32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_set_regvars_ia32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_set_regvars_ia32_sysv); + e2dbg_register_sregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_set_regvars_ia32_sysv); + + e2dbg_register_pregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, ELFSH_OS_LINUX, + e2dbg_print_regvars_ia32_sysv); + e2dbg_register_pregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, ELFSH_OS_SOLARIS, + e2dbg_print_regvars_ia32_sysv); + e2dbg_register_pregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, ELFSH_OS_FREEBSD, + e2dbg_print_regvars_ia32_freebsd); + e2dbg_register_pregshook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, ELFSH_OS_NETBSD, + e2dbg_print_regvars_ia32_netbsd); + e2dbg_register_pregshook(ELFSH_ARCH_MIPS32, ELFSH_HOST_USER, ELFSH_OS_IRIX, + e2dbg_print_regvars_mips_irix); + e2dbg_register_pregshook(ELFSH_ARCH_MIPS64, ELFSH_HOST_USER, ELFSH_OS_IRIX, + e2dbg_print_regvars_mips_irix); + + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_ia32); + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_getpc_bsd_ia32); + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_ia32); + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_getpc_sysv_ia32); + e2dbg_register_getpchook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_ia32); + + e2dbg_register_setstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_ia32); + e2dbg_register_setstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_setstep_bsd_ia32); + e2dbg_register_setstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_ia32); + e2dbg_register_setstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_setstep_sysv_ia32); + e2dbg_register_setstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_ia32); + + e2dbg_register_resetstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_ia32); + e2dbg_register_resetstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_ia32); + e2dbg_register_resetstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_ia32); + e2dbg_register_resetstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_resetstep_sysv_ia32); + e2dbg_register_resetstephook(ELFSH_ARCH_IA32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_ia32); + + + /* For sparc32 */ + + e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_get_regvars_sparc32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_get_regvars_sparc32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_get_regvars_sparc32_bsd); + e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_get_regvars_sparc32_sysv); + e2dbg_register_gregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_get_regvars_sparc32_sysv); + + + e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_set_regvars_sparc32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_set_regvars_sparc32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_set_regvars_sparc32_bsd); + e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_set_regvars_sparc32_sysv); + e2dbg_register_sregshook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_set_regvars_sparc32_sysv); + + + e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_getpc_bsd_sparc32); + e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_getpc_bsd_sparc32); + e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_getpc_bsd_sparc32); + e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_getpc_sysv_sparc32); + e2dbg_register_getpchook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_getpc_sysv_sparc32); + + e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_setstep_bsd_sparc32); + e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_setstep_bsd_sparc32); + e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_setstep_bsd_sparc32); + e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_setstep_sysv_sparc32); + e2dbg_register_setstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_setstep_sysv_sparc32); + + e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_FREEBSD, e2dbg_resetstep_bsd_sparc32); + e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_NETBSD, e2dbg_resetstep_bsd_sparc32); + e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_OPENBSD, e2dbg_resetstep_bsd_sparc32); + e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_LINUX, e2dbg_resetstep_sysv_sparc32); + e2dbg_register_resetstephook(ELFSH_ARCH_SPARC32, ELFSH_HOST_USER, + ELFSH_OS_SOLARIS, e2dbg_resetstep_sysv_sparc32); + + + /***********************************/ + /* Now nextfp hooks */ + /***********************************/ + + /* Usual nextfp targets for ET_EXEC/ET_DYN on IA32 */ + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_bt_ia32); + e2dbg_register_nextfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_bt_ia32); + + /* Now for sparc */ + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_bt_sparc32); + e2dbg_register_nextfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_bt_sparc32); + + + + /************************************/ + /* Now getfp hooks */ + /***********************************/ + + /* Usual getfp targets for ET_EXEC/ET_DYN on IA32 */ + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getfp_sysv_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_ia32); + e2dbg_register_getfphook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_ia32); + + /* Now for sparc */ + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getfp_sysv_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_getfp_bsd_sparc32); + e2dbg_register_getfphook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_getfp_sysv_sparc32); + + + /***********************************/ + /* Now register getret hooks */ + /***********************************/ + + /* Usual getret targets for ET_EXEC/IA32 */ + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_getret_ia32); + e2dbg_register_getrethook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_getret_ia32); + + /* Now for sparc32 */ + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_getret_sparc32); + e2dbg_register_getrethook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_getret_sparc32); + + /***********************************/ + /* Now register breakpoint hooks */ + /***********************************/ + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_break_ia32); + e2dbg_register_breakhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_break_ia32); + + /* Now for sparc */ + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_FREEBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_NETBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_OPENBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, + ELFSH_OS_SOLARIS, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_LINUX, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_FREEBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_NETBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_OPENBSD, e2dbg_break_sparc32); + e2dbg_register_breakhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_LIB, + ELFSH_OS_SOLARIS, e2dbg_break_ia32); + + /* Now delete break hook */ + e2dbg_register_delbreakhook(ELFSH_HOST_USER, e2dbg_delbreak_user); + + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +int e2dbg_user_hooks_install(void) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + static Bool done; + + if (!done) + { + e2dbg_setup_hooks(); + e2dbg_user_register_hooks(); + } + done = TRUE; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libe2dbg/user/resolv.c eresi-0.0.20110516/libe2dbg/user/resolv.c --- eresi-0.8a25/libe2dbg/user/resolv.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/resolv.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,11 +1,15 @@ /** - * @file resolv.c +* @file libe2dbg/user/resolv.c +** @ingroup user +*/ +/** +* @file libe2dbg/user/resolv.c * * Contains the linkmap related resolving builtins in e2dbg * * Last Update Thu Oct 13 19:37:26 2005 mm * - * $Id: resolv.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: resolv.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" @@ -167,7 +171,7 @@ #if __DEBUG_E2DBG__ write(2, " Success !\n", 11); len = snprintf(buf, sizeof(buf), - " [*] REFADDR = %08X and FOUNDREF = %08X and GOT = %08X \n", + " [*] REFADDR = " XFMT " / FOUNDREF = " XFMT " / GOT = " XFMT " \n", refaddr, found_ref, got); write(2, buf, len); #endif @@ -280,7 +284,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] SYMOFF = %u (%08X), STROFF = %u (%08X), STRSZ = %u \n", + " [*] SYMOFF = "UFMT" ("XFMT"), STROFF = "UFMT" ("XFMT"), STRSZ = "UFMT" \n", obj.symoff, obj.symoff, obj.stroff, obj.stroff, obj.strsz); write(2, buf, len); #endif @@ -290,7 +294,7 @@ /* XXX: Assume that dynamic strtab is always just after dynamic symtab */ for (curoff = 0; obj.symoff + curoff < obj.stroff; curoff += sizeof(elfsh_Sym)) { - memcpy(&cursym, (void *)obj.symoff + curoff, sizeof(elfsh_Sym)); + memcpy(&cursym, (void *) obj.symoff + curoff, sizeof(elfsh_Sym)); if (cursym.st_name >= obj.strsz) continue; if (!strcmp(strtab + cursym.st_name, sym2resolve) && @@ -300,7 +304,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] FOUNDSYM (%s) = %08X \n", + " [*] FOUNDSYM (%s) = " XFMT "\n", strtab + cursym.st_name, found_sym); write(2, buf, len); #endif @@ -356,7 +360,7 @@ exit(-1); #endif - snprintf(path, BUFSIZ, "%s/libe2dbg%s.so", ELFSH_DBGPATH, version); + snprintf(path, BUFSIZ, "%s/libe2dbg%s.so", E2DBG_PATH, version); #if defined(linux) baseaddr = e2dbg_dlsect(path, ".got.plt", @@ -367,14 +371,14 @@ #endif #if __DEBUG_E2DBG__ - len = sprintf(buf, " [*] Base address - 1st = %08X\n", baseaddr); + len = sprintf(buf, " [*] Base address - 1st = " XFMT "\n", baseaddr); write(2, buf, len); #endif got = (eresi_Addr *) baseaddr; #if __DEBUG_E2DBG__ - len = sprintf(buf, " [*] GOT address = %08X\n", (eresi_Addr) got); + len = sprintf(buf, " [*] GOT address = " XFMT "\n", (eresi_Addr) got); write(2, buf, len); #endif @@ -390,7 +394,7 @@ #if __DEBUG_E2DBG__ len = sprintf(buf, - " [*] Guessed Linkmap address = %08X \n--------------\n", + " [*] Guessed Linkmap address = " XFMT " \n--------------\n", (eresi_Addr) lm); write(2, buf, len); #endif @@ -442,7 +446,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc MALLOC() sym = %08X \n", + " [*] Libc MALLOC() sym = " XFMT " \n", e2dbgworld.syms.mallocsym); write(2, buf, len); #endif @@ -457,7 +461,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc CALLOC() sym = %08X \n", + " [*] Libc CALLOC() sym = " XFMT "\n", e2dbgworld.syms.callocsym); write(2, buf, len); #endif @@ -469,7 +473,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc REALLOC() sym = %08X \n", + " [*] Libc REALLOC() sym = " XFMT "\n", e2dbgworld.syms.reallocsym); write(2, buf, len); #endif @@ -481,7 +485,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc FREE() sym = %08X \n", e2dbgworld.syms.freesym); + " [*] Libc FREE() sym = " XFMT " \n", e2dbgworld.syms.freesym); write(2, buf, len); #endif @@ -492,7 +496,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc VALLOC() sym = %08X \n", + " [*] Libc VALLOC() sym = " XFMT " \n", e2dbgworld.syms.vallocsym); write(2, buf, len); #endif @@ -504,7 +508,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] Libc SIGNAL() sym = %08X \n", + " [*] Libc SIGNAL() sym = " XFMT "\n", e2dbgworld.syms.signal); write(2, buf, len); #endif @@ -540,7 +544,7 @@ #if __DEBUG_E2DBG__ len = snprintf(buf, sizeof(buf), - " [*] PIE _end resolved = %08X \n", + " [*] PIE _end resolved = " XFMT " \n", e2dbgworld.syms.piebase); write(2, buf, len); #endif diff -Nru eresi-0.8a25/libe2dbg/user/signal.c eresi-0.0.20110516/libe2dbg/user/signal.c --- eresi-0.8a25/libe2dbg/user/signal.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/signal.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,17 +1,61 @@ /** - * @file signal.c + * @file libe2dbg/user/signal.c + * @ingroup user + */ + +/** + * @file libe2dbg/user/signal.c * * The debugger file for signal handlers * * Started on Tue Feb 11 21:17:33 2003 jfv * Last update Wed Aug 13 23:22:59 2005 jfv * - * $Id: signal.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: signal.c 1427 2010-07-09 20:54:05Z thorkill $ * */ #include "libe2dbg.h" +/** ARCH/OS dependent handler for checking values in registers */ +#if defined(__linux__) && defined(__i386__) +void e2dbg_watch_check_ia32_sysv(u_int regidx, char *regstr) +{ + char buff[BUFSIZ]; + u_int idx; + + for (idx = 0; idx < E2DBG_STEPCMD_MAX && e2dbgworld.tracedata[idx]; idx++) + if (e2dbgworld.curthread->context->uc_mcontext.gregs[regidx] == e2dbgworld.tracedata[idx]) + { + snprintf(buff, BUFSIZ, " [*] TRACED %s ("XFMT") found in register %s \n", + e2dbgworld.tracedstr[idx], e2dbgworld.tracedata[idx], regstr); + e2dbg_output(buff); + + /* Disable stepping and tracing */ + if (e2dbgworld.curthread->trace) + e2dbg_step(); + e2dbgworld.curthread->trace = 0; + } +} +#endif + +/** Check if any traced variable is used in the current instruction */ +void e2dbg_watch() +{ +#if defined(__linux__) && defined(__i386__) + e2dbg_watch_check_ia32_sysv(REG_EAX, "EAX"); + e2dbg_watch_check_ia32_sysv(REG_EBX, "EBX"); + e2dbg_watch_check_ia32_sysv(REG_ECX, "ECX"); + e2dbg_watch_check_ia32_sysv(REG_EDX, "EDX"); + e2dbg_watch_check_ia32_sysv(REG_ESI, "ESI"); + e2dbg_watch_check_ia32_sysv(REG_EDI, "EDI"); + e2dbg_watch_check_ia32_sysv(REG_ESP, "ESP"); + e2dbg_watch_check_ia32_sysv(REG_EBP, "EBP"); + e2dbg_watch_check_ia32_sysv(REG_EIP, "EIP"); +#endif +} + + /** * Signal handler for SIGSEGV @@ -31,7 +75,18 @@ argv[0] = E2DBG_ARGV0; argv[1] = NULL; - fprintf(stderr, "\n\n ******* Segfault, entering E2dbg ******** \n\n"); + switch (signum) + { + case SIGSEGV: + fprintf(stderr, "\n\n ******* SIGSEGV: entering E2dbg ******** \n\n"); + break; + case SIGBUS: + fprintf(stderr, "\n\n ******* SIGBUS : entering E2dbg ******** \n\n"); + break; + default: + fprintf(stderr, "\n\n ******* SIGNAL : entering E2dbg ******** \n\n"); + break; + } sleep(1); params.ac = 1; @@ -89,7 +144,7 @@ /* Set all registers as variables and get PC */ //e2dbgworld.context = (ucontext_t *) pcontext; - e2dbg_setup_hooks(); + e2dbg_user_hooks_install(); e2dbg_getregs(); argv[0] = E2DBG_ARGV0; argv[1] = NULL; @@ -131,7 +186,7 @@ /* Set all registers as variables and get PC */ //e2dbgworld.context = (ucontext_t *) pcontext; - e2dbg_setup_hooks(); + e2dbg_user_hooks_install(); e2dbg_getregs(); argv[0] = E2DBG_ARGV0; argv[1] = NULL; @@ -245,7 +300,7 @@ sect = elfsh_get_parent_section(parent, addr, NULL); name = revm_resolve(parent, addr, &off); sym = elfsh_get_metasym_by_value(parent, addr, &off, ELFSH_LOWSYM); - revm_object_display(sect, sym, 16, 0, off, addr, name, REVM_VIEW_DISASM); + revm_object_display(sect, sym, 16, off, 0, addr, name, REVM_VIEW_DISASM, 0); } #endif @@ -279,7 +334,7 @@ /* Set all registers as variables and get PC */ argv[0] = "e2dbg"; argv[1] = NULL; - e2dbg_setup_hooks(); + e2dbg_user_hooks_install(); e2dbg_getregs(); pc = e2dbg_getpc(); @@ -315,30 +370,37 @@ /* We are single-stepping, display the instruction at $pc */ if (e2dbgworld.stoppedthread->step) { + +#if __DEBUG_BP__ fprintf(stderr, "Single-stepping -IS- enabled \n"); +#endif - ret = asm_read_instr(&ptr, (u_char *) *pc, 16, &world.proc); + ret = asm_read_instr(&ptr, (u_char *) *pc, 16, world.curjob->proc); if (!ret) ret++; sect = elfsh_get_parent_section(parent, (eresi_Addr) *pc, NULL); name = revm_resolve(parent, (eresi_Addr) *pc, &off); + off = 0; sym = elfsh_get_metasym_by_value(parent, (eresi_Addr) *pc, &off, ELFSH_LOWSYM); #if __DEBUG_BP__ - printf("Found parent = %08X (%s) in step (name = %s, parentsect = %s) \n", - (eresi_Addr) parent, parent->name, name, sect->name); + printf("Found parent = %08X (%s) in step (name = %s, parentsect = %s) off = %u\n", + (eresi_Addr) parent, parent->name, name, sect->name, off); #endif - revm_object_display(sect, sym, ret, 0, off, - ((eresi_Addr) *pc), name, REVM_VIEW_DISASM); + revm_instr_display(-1, *pc, 0, 20, name, off, (char *) *pc); e2dbg_display(e2dbgworld.displaycmd, e2dbgworld.displaynbr); if (!e2dbgworld.stoppedthread->trace) e2dbg_entry(NULL); + else + e2dbg_watch(); + return; } +#if __DEBUG_BP__ else fprintf(stderr, "Single-stepping is -NOT- enabled \n"); - +#endif /* Here starts the real stuff ** @@ -435,11 +497,14 @@ else printf(" [*] %spoint found at " XFMT " <%s> in thread %u \n\n", s, *pc - bpsz, name, (unsigned int) e2dbgworld.stoppedthread->tid); + + revm_doswitch(parent->id); + mjr_set_current_context(&world.mjr_session, parent->name); *pc -= bpsz; prot = elfsh_munprotect(bp->obj, *pc, bpsz); memcpy((u_char *) *pc, bp->savedinstr, bpsz); - elfsh_mprotect(*pc, bpsz, prot); + elfsh_mprotect(bp->obj, *pc, bpsz, prot); e2dbg_setstep(); #if __DEBUG_BP__ @@ -458,7 +523,12 @@ #if __DEBUG_BP__ fprintf(stderr, " Breakpoint desinstalled at addr %08X \n", *pc); #endif - e2dbg_display(bp->cmd, bp->cmdnbr); + + if (bp->cmdnbr) + e2dbg_display(bp->cmd, bp->cmdnbr); + else + e2dbg_display(e2dbgworld.displaycmd, e2dbgworld.displaynbr); + #if __DEBUG_BP__ fprintf(stderr, " e2dbg display ! \n"); #endif @@ -497,20 +567,30 @@ /* Do not allow processing of 2 breakpoint at the same time */ /* We update the current thread information */ e2dbg_presence_set(); + revm_proc_init(); + if (!e2dbgworld.curbp || e2dbgworld.curbp->tid != e2dbg_self()) { e2dbg_mutex_lock(&e2dbgworld.dbgbp); #if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) e2dbg_output("-------------- ON-BREAK REGISTERS ----------------------->\n"); - cmd_dumpregs(); + //cmd_dumpregs(); e2dbg_output("<------------------------------------------------------\n"); e2dbg_output("------------------------------------->\n"); e2dbg_output(" [*] BP MUTEX LOCKED [e2dbg_generic_breakpoint] \n"); - e2dbg_threads_print(); + //e2dbg_threads_print(); #endif } + /* + if (e2dbgworld.stoppedthread == NULL) + { + fprintf(stderr, "************** STOPPED THREAD == NULL !!!!!!!!! *********************** \n"); + sleep(20); + } + */ + /* Get the current thread */ stopped = (pthread_t) e2dbg_self(); snprintf(key, sizeof(key), "%u", (unsigned int) stopped); @@ -532,8 +612,8 @@ /* We do this only at the first state (count = 0) of the breakpoint */ if (!e2dbgworld.stoppedthread->count) { - e2dbg_thread_stopall(SIGUSR2); - usleep(100000); + if (e2dbg_thread_stopall(SIGUSR2)) + usleep(100000); } #if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) else diff -Nru eresi-0.8a25/libe2dbg/user/step.c eresi-0.0.20110516/libe2dbg/user/step.c --- eresi-0.8a25/libe2dbg/user/step.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/step.c 2011-05-16 11:35:07.000000000 +0000 @@ -0,0 +1,105 @@ +/** +* @file libe2dbg/user/step.c +** @ingroup user +*/ +/* +** delete.c for e2dbg +** +** Delete breakpoints +** +** Started on Tue Aug 16 09:38:03 2005 jfv +** +** $Id: step.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libe2dbg.h" + + +/* Perform stepping */ +int e2dbg_step() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Checking stepping flag in the thread structure */ + if (e2dbgworld.curthread->step) + { + if (e2dbg_resetstep() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to disable stepping", -1); + e2dbg_output("\n [*] Disabled stepping\n\n"); + e2dbgworld.curthread->step = 0; + e2dbgworld.curthread->count = E2DBG_BREAK_NONE; + e2dbgworld.curthread->was_step = 1; + } + + /* Disable stepping and continue */ + else + { + if (e2dbg_setstep() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to enable stepping", -1); + e2dbg_output("\n [*] Enabled stepping \n\n"); + e2dbgworld.curthread->step = 1; + e2dbg_setregs(); + if (e2dbgworld.stoppedthread->tid != e2dbgworld.curthread->tid) + e2dbgworld.curthread = e2dbgworld.stoppedthread; + e2dbg_thread_contall(); + world.curjob->curfile->running = 1; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/* Step command */ +int cmd_step() +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + retry: + if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) + { + if (e2dbgworld.sourcing) + goto retry; + else + printf("wasnt sourcing ... existing \n"); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "You must be in a SIGTRAP handler to step", -1); + } + + ret = e2dbg_step(); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + +/* Step-trace command */ +int cmd_itrace() +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + retry: + if (!e2dbgworld.curthread || !e2dbgworld.curthread->context) + { + if (e2dbgworld.sourcing) + goto retry; + else + printf("wasnt sourcing ... existing \n"); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "You must be in a SIGTRAP handler to step", -1); + } + + /* Enable or disable trace flag */ + if (e2dbgworld.curthread->trace) + e2dbgworld.curthread->trace = 0; + else + e2dbgworld.curthread->trace = 1; + ret = e2dbg_step(); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} diff -Nru eresi-0.8a25/libe2dbg/user/.svn/all-wcprops eresi-0.0.20110516/libe2dbg/user/.svn/all-wcprops --- eresi-0.8a25/libe2dbg/user/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/946/trunk/libe2dbg/user -END -entry.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libe2dbg/user/entry.c -END -delete.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libe2dbg/user/delete.c -END -e2dbg.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/914/trunk/libe2dbg/user/e2dbg.c -END -continue.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/843/trunk/libe2dbg/user/continue.c -END -alloc-proxy.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libe2dbg/user/alloc-proxy.c -END -resolv.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libe2dbg/user/resolv.c -END -threads.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libe2dbg/user/threads.c -END -linkmap.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libe2dbg/user/linkmap.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/843/trunk/libe2dbg/user/Makefile -END -e2dbg-misc.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libe2dbg/user/e2dbg-misc.c -END -signal.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libe2dbg/user/signal.c -END diff -Nru eresi-0.8a25/libe2dbg/user/.svn/entries eresi-0.0.20110516/libe2dbg/user/.svn/entries --- eresi-0.8a25/libe2dbg/user/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libe2dbg/user -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -entry.c -file - - - - -2008-04-06T23:16:29.900887Z -87319b00e7a67982e5a4591e31d3641d -2008-03-27T22:53:48.747992Z -946 -may - -delete.c -file - - - - -2008-04-06T23:16:29.932152Z -2f54ac107904e113e0b9edb157dfd04b -2008-03-27T22:53:48.747992Z -946 -may - -e2dbg.c -file - - - - -2008-04-06T23:16:29.936891Z -e4d1e075702c8784443147d7748a4ba6 -2008-03-18T16:49:26.066981Z -914 -pouik - -continue.c -file - - - - -2008-04-06T23:16:29.948475Z -fcb0452bc671318aa0dff725ee6bbe89 -2008-02-16T12:32:28.000000Z -843 -thor - -alloc-proxy.c -file - - - - -2008-04-06T23:16:29.961886Z -d24f6cef5198f3f570a0224e12c03886 -2008-03-27T22:53:48.747992Z -946 -may - -resolv.c -file - - - - -2008-04-06T23:16:29.970985Z -61f0b8cd54a3fd10f37f213f441b29f5 -2008-03-27T22:53:48.747992Z -946 -may - -threads.c -file - - - - -2008-04-06T23:16:29.982386Z -cbeb687e8ecff9a17d948d9540c61a36 -2008-03-27T22:53:48.747992Z -946 -may - -linkmap.c -file - - - - -2008-04-06T23:16:29.993536Z -a93c90447b1da8cc5e0578f45b45c911 -2008-03-27T22:53:48.747992Z -946 -may - -Makefile -file - - - - -2008-04-06T23:16:30.005067Z -70408401494142cd3fd4d72ce2d93187 -2008-02-16T12:32:28.000000Z -843 -thor - -e2dbg-misc.c -file - - - - -2008-04-06T23:16:30.016368Z -71567e5c3d2dfed06b113937f4142ece -2008-03-27T22:53:48.747992Z -946 -may - -signal.c -file - - - - -2008-04-06T23:16:30.027889Z -0039cd446d309fbbd1df05c8bed9b1f3 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/format eresi-0.0.20110516/libe2dbg/user/.svn/format --- eresi-0.8a25/libe2dbg/user/.svn/format 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/alloc-proxy.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/alloc-proxy.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/alloc-proxy.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/alloc-proxy.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,499 +0,0 @@ -/** - * @file alloc-proxy.c - * Allocator wrapper for the Embedded ELF Debugger - * - * Select the allocator depending on the thread ID of the caller - * - * Started Fri Oct 7 21:05:26 CEST 2005 crew - * - * $Id: alloc-proxy.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/** - * Wrapper for malloc - * @param t - * @return - */ -void *malloc(size_t t) -{ - void *(*mallocptr)(); - void *chunk; -#if __DEBUG_EMALLOC__ - char buf[256]; - u_int len; -#endif - -#if __DEBUG_EMALLOC__ - write(2, "Calling HOOKED malloc\n", 22); -#endif - - if (!e2dbgworld.syms.mallocsym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;41m", 7); - write(2, "LIBC malloc used\n", 17); - write(2, "\033[00m", 5); -#endif - mallocptr = (void *) e2dbgworld.syms.mallocsym; - if (!e2dbgworld.syms.mallocsym) - { - write(2, " [!] Unable to use original malloc \n", 36); - return (NULL); - } - chunk = mallocptr(t); - } - else - { - chunk = aproxy_malloc(t); -#if __DEBUG_EMALLOC__ - len = snprintf(buf, sizeof(buf), - "E2DBG malloc used [ret = %08X, len = %u] \n", - (eresi_Addr) chunk, t); - write(2, buf, len); -#endif - } - - if (!chunk) - write(2, " [!] Malloc failed \n", 20); - -#if __DEBUG_EMALLOC__ - write(2, "Finished HOOKED malloc\n", 23); -#endif - - return (chunk); -} - - - - -/** - * Wrapper for valloc - * @param t - * @return - */ -void *valloc(size_t t) -{ - void *(*vallocptr)(); - void *chunk; - -#if __DEBUG_EMALLOC__ - write(2, "Calling HOOKED valloc\n", 22); -#endif - - if (!e2dbgworld.syms.vallocsym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;41m", 7); - write(2, "LIBC valloc used\n", 17); - write(2, "\033[00m", 5); -#endif - vallocptr = (void *) e2dbgworld.syms.vallocsym; - if (!e2dbgworld.syms.vallocsym) - { - write(2, " [!] Unable to use original valloc \n", 36); - return (NULL); - } - chunk = vallocptr(t); - } - else - { -#if __DEBUG_EMALLOC__ - write(2, "E2DBG valloc used\n", 18); -#endif - chunk = (void *) aproxy_valloc(t); - } - - if (!chunk) - write(2, " [!] Valloc failed \n", 20); - -#if __DEBUG_EMALLOC__ - write(2, "Finished HOOKED valloc\n", 23); -#endif - - return (chunk); -} - - - - - -/** - * Wrapper for calloc - * @param t - * @param nbr - * @return - */ -#if __FreeBSD__ > 5 || defined(__OpenBSD__) -void *calloc(size_t t, size_t nbr) -#else -void *calloc(size_t t, u_int nbr) -#endif -{ - void *(*callocptr)(); - void *chunk; - - //static int cnt = 0; - -#if __DEBUG_EMALLOC__ - u_int len; - - write(2, "Calling HOOKED calloc \n", 23); -#endif - - /* - if (t == 1) - { - t = nbr; - nbr = 1; - } - */ - - //e2dbg_self(); - - if (!e2dbgworld.syms.callocsym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;32m", 7); - write(2, "LIBC calloc used\n", 17); - write(2, "\033[00m", 5); -#endif - - /* - if (cnt < 2) - { - callocptr = (void *) (*(long *) e2dbgworld.mallochooksym); - cnt++; - } - else - */ - callocptr = (void *) e2dbgworld.syms.mallocsym; - - if (!callocptr) - { - write(2, " [!] Unable to use original calloc \n", 36); - return (NULL); - } - - //write(2, "Calling libc calloc \n", 20); - -#if __DEBUG_EMALLOC__ - { - char buff[256]; - len = snprintf(buff, sizeof(buff), - "Calling LIBC calloc at addr %08X\n", - (eresi_Addr) callocptr); - write(2, buff, len); - } -#endif - - chunk = callocptr(t * nbr); -#if __DEBUG_EMALLOC__ - write(2, "Libc m/calloc returned\n", 23); -#endif - if (chunk) - memset(chunk, 0x00, t * nbr); - } - else - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;31m", 7); - write(2, "E2DBG calloc used\n", 18); - write(2, "\033[00m", 5); -#endif - //chunk = aproxy_calloc(t, nbr); - chunk = aproxy_malloc(t * nbr); - if (chunk) - memset(chunk, 0x00, t * nbr); - } - -#if __DEBUG_EMALLOC__ - if (!chunk) - { - char buff[256]; - len = snprintf(buff, sizeof(buff), - " ! Calloc failed (%u * %u sz) \n", - t, nbr); - write(2, buff, len); - } - else - { - char buff[256]; - len = snprintf(buff, sizeof(buff), - " Calloc (%u * %u sz) returned %08X\n", - t, nbr, (eresi_Addr) chunk); - write(2, buff, len); - } - write(2, "Finished HOOKED calloc \n", 24); -#endif - - return (chunk); -} - - - -/** - * Wrapper for memalign - * @param t - * @param nbr - */ -void *memalign(size_t t, u_int nbr) -{ - void *(*memalignptr)(); - void *chunk; - - //static int cnt = 0; - -#if __DEBUG_EMALLOC__ - u_int len; - - write(2, "Calling HOOKED memalign \n", 23); -#endif - - if (!e2dbgworld.syms.memalignsym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;32m", 7); - write(2, "LIBC memalign used\n", 17); - write(2, "\033[00m", 5); -#endif - - /* - if (!cnt) - { - memalignptr = (void *) (*(long *) e2dbgworld.memalignhooksym); - cnt++; - } - else - */ - - memalignptr = (void *) e2dbgworld.syms.memalignsym; - - if (!memalignptr) - { - write(2, " [!] Unable to use original memalign \n", 36); - return (NULL); - } - chunk = (void *) memalignptr(t, nbr); - } - else - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;31m", 7); - write(2, "E2DBG memalign used\n", 18); - write(2, "\033[00m", 5); -#endif - chunk = (void *) aproxy_memalign(t, nbr); - } - -#if __DEBUG_EMALLOC__ - if (!chunk) - { - char buff[256]; - len = snprintf(buff, sizeof(buff), - " ! Memalign failed (%u * %u sz) \n", - t, nbr); - write(2, buff, len); - } - write(2, "Finished HOOKED memalign \n", 24); -#endif - - return (chunk); -} - - - -/** - * Wrapper for realloc - * @param a - * @param t - * @return - */ -void *realloc(void *a, size_t t) -{ - void *b; - void *(*reallocptr)(); - - //e2dbg_self(); - -#if __DEBUG_EMALLOC__ - write(2, "Calling HOOKED realloc\n", 23); -#endif - - if (!e2dbgworld.syms.reallocsym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;41m", 7); - write(2, "LIBC realloc used\n", 18); - write(2, "\033[00m", 5); -#endif - reallocptr = (void *) e2dbgworld.syms.reallocsym; - if (!e2dbgworld.syms.reallocsym) - { - write(2, " [!] Unable to use original realloc \n", 37); - return (NULL); - } - b = reallocptr(a, t); - } - else - { -#if __DEBUG_EMALLOC__ - write(2, "E2DBG realloc used\n", 19); -#endif - b = aproxy_realloc(a, t); - } - - if (!b) - write(2, " [!] Realloc failed \n", 20); - -#if __DEBUG_EMALLOC__ - write(2, "Finished HOOKED realloc\n", 24); -#endif - - return (b); -} - -/** - * Wrapper for free - * @param a Pointer to memory to free. - * @return - */ -void free(void *a) -{ - void (*freeptr)(); - - //e2dbg_self(); - -#if __DEBUG_EMALLOC__ - write(2, "Calling HOOKED free\n", 20); -#endif - - if (!e2dbgworld.syms.freesym) - e2dbg_dlsym_init(); - - if (e2dbg_presence_get() == 0) - { -#if __DEBUG_EMALLOC__ - write(2, "\033[1;41m", 7); - write(2, "LIBC free used\n", 15); - write(2, "\033[00m", 5); -#endif - freeptr = (void *) e2dbgworld.syms.freesym; - if (!e2dbgworld.syms.freesym) - { - write(2, " [!] Unable to use original free \n", 34); - return; - } - freeptr(a); - } - else - { -#if __DEBUG_EMALLOC__ - write(2, "E2DBG free used\n", 16); -#endif - aproxy_free(a); - } - -#if __DEBUG_EMALLOC__ - write(2, "Finished HOOKED free\n", 21); -#endif -} - -/** - * FIXME - * @param a - * @return - */ -void wait4exit(void *a) -{ - fprintf(stderr, "\n [*] Debuggee wait4exit called \n"); - while (!e2dbgworld.exited) - sleep(1); - exit(0); -} - - -/** - * Wrapper for _exit - * @param err Return value. - */ -void _exit(int err) -{ - /* If another thread did an exit, just signal it and return */ - if (e2dbg_presence_get() == 0) - { - printf(" [*] Thread ID %u exited \n", - (unsigned int) e2dbg_self()); - while (1) - sleep(1); - } - - while (1) - if (e2dbgworld.exited) - { - if (!e2dbgworld.debuggee_exited) - write(2, " [*] Legit program terminating\n\n", 32); - e2dbgworld.debuggee_exited = 1; - syscall(1, 0); - raise(SIGKILL); - } - else - { - e2dbgworld.exited = 1; - write(2, " [*] Debugger exited\n", 21); - syscall(1, 0); - raise(SIGKILL); - } -} - - -/** - * Wrapper for heap initialisation - * @param first_time - * @return - */ -/* -void __libc_malloc_pthread_startup (int first_time) -{ - void (*pthstartupptr)(); - - if (!e2dbgworld.syms.pthstartupsym) - e2dbg_dlsym_init(); - - pthstartupptr = (void *) e2dbgworld.syms.pthstartupsym; - write(2, "Calling __libc_malloc_pthread_startup HOOK ! \n", 46); - pthstartupptr(first_time); - write(2, "Finished LIBC pthread startup ! \n", 33); - write(2, "Calling __aproxy_libc_malloc_pthread_startup HOOK ! \n", 52); - __aproxy_libc_malloc_pthread_startup (first_time); - write(2,g "Finished OURS pthread startup ! \n", 33); -} -*/ - - -/* Not sure it is useful / bugless, just a try */ -/* -void* _int_malloc(size_t p) { return (malloc(p)); } -void* _int_valloc(size_t p) { return (valloc(p)); } -void* _int_calloc(size_t p, size_t n) { return (calloc(p, n)); } -void* _int_realloc(char *p, size_t n) { return (realloc(p, n)); } -void* _int_memalign(size_t p, size_t n) { return (memalign(p, n)); } -void _int_free(void *p) { free(p); } -*/ diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/continue.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/continue.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/continue.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/continue.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/** - * @file continue.c - * - * The continue command in e2dbg - * - * - * $Id: continue.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - -/** - * (re)start a process in e2dbg - */ -void e2dbg_start_proc() -{ - if (e2dbgworld.curthread && - e2dbgworld.curthread->count == E2DBG_BREAK_FINISHED) - e2dbg_thread_contall(); - -#if __DEBUG_THREADS_ - else if (!e2dbgworld.curthread) - e2dbg_output(" [*] e2dbg_start_proc -NOT- doing CONTALL" - " because curthread = NULL\n"); - else - printf(" [*] e2dbg_start_proc -NOT- doing CONTALL (count = %u)\n", - e2dbgworld.curthread->count); -#endif - - world.curjob->curfile->running = 1; -} - - -/** - * Start cmd - * @return - */ -int cmd_start() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curfile->running) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Process is already started", -1); - if (!world.state.revm_quiet) - e2dbg_output(" [*] Starting process\n"); - e2dbg_start_proc(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); -} - - -/** - * Cont makes start 3 times for unlocking mutexes around the signal handlers. - * See the count in e2dbg/signal.c that makes e2dbg need this - * @return - */ -int cmd_cont() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!world.curjob->curfile->running) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Current object not running", -1); - - if (!world.state.revm_quiet) - e2dbg_output(" [*] Continuing process\n"); - - /* Set back the current thread to the stopped thread */ - e2dbg_setregs(); - if (e2dbgworld.stoppedthread->tid != e2dbgworld.curthread->tid) - e2dbgworld.curthread = e2dbgworld.stoppedthread; - - /* Restart the debuggee */ - e2dbg_start_proc(); - - /* - if (!e2dbgworld.curthread->step) - { - e2dbg_start_proc(); - e2dbg_start_proc(); - } - */ - - e2dbg_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); -} diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/delete.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/delete.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/delete.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/delete.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/** - * @file delete.c - * - * Delete breakpoints - * - * Started on Tue Aug 16 09:38:03 2005 jfv - * - * $Id: delete.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/** - * Delete a breakpoint - * @return - */ -int cmd_delete() -{ - eresi_Addr addr; - elfshbp_t *bp; - char *name; - int prot; - elfsh_SAddr off; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lookup breakpoint */ - bp = e2dbg_breakpoint_lookup(revm_lookup_string(world.curjob->curcmd->param[0])); - if (!bp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown breakpoint", -1); - addr = bp->addr; - - /* Delete the breakpoint */ - prot = elfsh_munprotect(bp->obj, addr, 1); - *(u_char *) addr = bp->savedinstr[0]; - elfsh_mprotect(addr, 1, prot); - - name = revm_resolve(bp->obj, addr, &off); - snprintf(logbuf, BUFSIZ, XFMT, addr); - hash_del(&e2dbgworld.bp, logbuf); - - if (off) - snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT - " <%s + " UFMT "> removed\n\n", addr, name, off); - else - snprintf(logbuf, BUFSIZ, " [*] Breakpoint at " AFMT " <%s> removed\n\n", - addr, name); - e2dbg_output(logbuf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/e2dbg.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/e2dbg.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/e2dbg.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/e2dbg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -/** - * @file e2dbg.c - * - * Starting routines for the debugger - * - * Started on Fri Jun 05 15:21:56 2005 jfv - * - * - * $Id: e2dbg.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/* The debugger world */ -e2dbgworld_t e2dbgworld; - - -/** - * Debugger library initialisation - * Only useful when debugger takes control by .ctors - */ -void e2dbg_init(void) -{ -#if __DEBUG_E2DBG__ - write(2, " [D] Calling DLSYM_INIT from e2dbg_init() !\n", 45); -#endif - - aspect_called_ctors_inc(); - - e2dbg_dlsym_init(); - - if (aspect_called_ctors_finished()) - e2dbg_presence_reset(); - -#if __DEBUG_E2DBG__ - write(2, " [D] Finished e2dbg ctors \n", 27); -#endif -} - - -/** - * Configure and launch the VM from the debugger. - * @param params - * @return - */ -int e2dbg_entry(e2dbgparams_t *params) -{ - int ac; - char **av; - int ret; - static int first = 1; - -#if __DEBUG_E2DBG__ - write(2, "[e2dbg_entry] CHECKPOINT 0\n", 27); -#endif - - /* Initial settings */ - ac = (params ? params->ac : 0); - av = (params ? params->av : NULL); - CLRSIG; - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 1\n"); -#endif - - /* We have a debugger script pending, continue it */ - if (e2dbgworld.sourcing) - { - fprintf(stderr, "e2dbg_entry called with SOURCED program ! calling execscript \n"); - - revm_execscript(); - if (e2dbgworld.sourcing) - return (0); - } - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 2\n"); -#endif - - /* If the breakpoint is a watchpoint, do not call the debugger */ - /* Displays have been executed already so its no problem to ret */ - if (e2dbg_is_watchpoint(e2dbgworld.curbp)) - return (0); - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 3\n"); -#endif - - if (av && ac) - revm_setup(ac, av, REVM_STATE_DEBUGGER, REVM_SIDE_SERVER); - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 4\n"); -#endif - - /* Only on first execution */ - if (first) - { - /* Debugger only script commands */ - revm_command_add(CMD_MODE , (void *) cmd_mode , revm_getvarparams, 0, HLP_MODE); - revm_command_add(CMD_LINKMAP , (void *) cmd_linkmap , NULL, 1, HLP_LINKMAP); - revm_command_add(CMD_BT , (void *) cmd_bt , NULL, 1, HLP_BT); - revm_command_add(CMD_BT2 , (void *) cmd_bt , NULL, 1, HLP_BT); - revm_command_add(CMD_BP , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); - revm_command_add(CMD_WATCH , (void *) cmd_watch , revm_getvarparams, 1, HLP_WATCH); - revm_command_add(CMD_BP2 , (void *) cmd_bp , revm_getvarparams, 1, HLP_BP); - revm_command_add(CMD_STACK , (void *) cmd_stack , revm_getoption, 1, HLP_STACK); - revm_command_add(CMD_DBGSTACK , (void *) cmd_dbgstack , revm_getoption, 1, HLP_DBGSTACK); - revm_command_add(CMD_DUMPREGS , (void *) cmd_dumpregs , NULL, 1, HLP_DUMPREGS); - revm_command_add(CMD_DELETE , (void *) cmd_delete , revm_getoption, 1, HLP_DELETE); - revm_command_add(CMD_CONTINUE , (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); - revm_command_add(CMD_CONTINUE2, (void *) cmd_cont , (void *) NULL, 1, HLP_CONTINUE); - revm_command_add(CMD_START , (void *) cmd_start , (void *) NULL, 1, HLP_START); - revm_command_add(CMD_STEP , (void *) cmd_step , (void *) NULL, 1, HLP_STEP); - revm_command_add(CMD_DISPLAY , (void *) cmd_display , revm_getvarparams, 1, HLP_DISPLAY); - revm_command_add(CMD_UNDISPLAY, (void *) cmd_undisplay, revm_getvarparams, 1, HLP_UNDISPLAY); - revm_command_add(CMD_RSHT , (void *) cmd_rsht , revm_getregxoption, 1, HLP_RSHT); - revm_command_add(CMD_RPHT , (void *) cmd_rpht , revm_getregxoption, 1, HLP_RPHT); - revm_command_add(CMD_THREADS , (void *) cmd_threads , revm_getvarparams, 1, HLP_THREADS); - revm_command_add(CMD_ITRACE , (void *) cmd_itrace , (void *) NULL , 1, HLP_ITRACE); - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 4bis\n"); -#endif - - if (!e2dbgworld.curthread || !e2dbgworld.curthread->step) - revm_banner_print(av[1]); - - first = 0; - } - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 5\n"); -#endif - - if (world.state.revm_mode == REVM_STATE_DEBUGGER && av && - e2dbg_setup(av[1]) < 0) - { - profiler_error(); - exit(-1); - } - revm_doswitch(1); - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_entry] CHECKPOINT 6\n"); -#endif - - ret = revm_run(ac, av); - SETSIG; - return (ret); -} - - - -/** - * Load all process files in the debugger - * @param name - * @return - */ -int e2dbg_setup(char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_E2DBG__ - fprintf(stderr, "[e2dbg_setup] Starting \n"); -#endif - - e2dbg_setup_hooks(); - revm_initio(); - revm_config(E2DBG_CONFIG); - e2dbg_linkmap_load(name); - - /* Everything was OK */ - e2dbg_output("\n"); - elfsh_set_debug_mode(); - revm_doswitch(1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/e2dbg-misc.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/e2dbg-misc.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/e2dbg-misc.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/e2dbg-misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -/** - * @file e2dbg-misc.c - * - * Misc routines for the debugger - * - * Started on Fri Jun 05 15:21:56 2005 jfv - * - * - * $Id: e2dbg-misc.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/** - * Get the parent object of a breakpoint. - * Thats needed for the mprotect stuff inside the breakpoint handler - * @param addr - * @return - */ -elfshobj_t *e2dbg_get_parent_object(eresi_Addr addr) -{ - elfsh_Phdr *cur; - elfshobj_t *curfile; - elfshsect_t *cursect; - char **keys; - int index; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (index = 0; index < keynbr; index++) - { - curfile = hash_get(&world.curjob->loaded, keys[index]); - cursect = elfsh_get_parent_section(curfile, addr, NULL); - if (cursect) - { - cur = elfsh_get_parent_segment(curfile, cursect); - if (cur) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, curfile); - } - } - - /* Parent object not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent object addr", (NULL)); -} - - -/** - * Realize the output. - * @todo: XXX: Need a vector - * @param str - * @return - */ -int e2dbg_output(char *str) -{ - //revm_output(str); - fprintf(stderr, str); - return (0); -} - - -/** - * Get the identity of the current process or thread - * @return - */ -int e2dbg_self() -{ -#if 0 - printf("Entering e2dbg_self : threadnbr = %u \n", e2dbgworld.threadnbr); -#endif - - if (e2dbgworld.threadnbr == 1) - return (getpid()); - return ((int) pthread_self()); -} - - -/** - * Send a signal - * @param pid - * @param sig - * @return - */ -int e2dbg_kill(int pid, int sig) -{ - if (e2dbgworld.threadnbr == 1) - return (kill(pid, sig)); - else - return (pthread_kill((pthread_t) pid, sig)); -} - -/** - * Determine stack address - * @param cur - * @return - */ -static void e2dbg_stack_get(e2dbgthread_t *cur) -{ - struct rlimit rlp; - int index; - -#if __DEBUG_THREADS__ - int ret; - char logbuf[BUFSIZ]; -#endif - - getrlimit(RLIMIT_STACK, &rlp); - cur->stacksize = rlp.rlim_cur; - - cur->stackaddr = (eresi_Addr) environ; - - for (index = 0; environ[index]; index++) - { - if ((eresi_Addr) environ[index] > cur->stackaddr) - cur->stackaddr = (eresi_Addr) environ[index]; - if ((eresi_Addr) (environ + index) > cur->stackaddr) - cur->stackaddr = (eresi_Addr) environ + index; - } - - cur->stackaddr = cur->stackaddr - cur->stacksize; - -#if __DEBUG_THREADS__ - ret = snprintf(logbuf, BUFSIZ, - "\n [D] Thread ID %u has stack at addr %08X with size %u (environ = %08X) max = %08X\n", - (unsigned int) cur->tid, cur->stackaddr, cur->stacksize, - (eresi_Addr) environ, (eresi_Addr) (cur->stackaddr + cur->stacksize)); - write(1, logbuf, ret); -#endif - -} - - -/** - * Only called when running a monothread program - * @param start - * @return - */ -int e2dbg_curthread_init(void *start) -{ - e2dbgthread_t *new; - char *key; - -#if __DEBUG_THREADS__ - char logbuf[BUFSIZ]; - int ret; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(e2dbgthread_t), -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,key, 15, -1); - snprintf(key, 15, "%u", (unsigned int) getpid()); - new->tid = (pthread_t) getpid(); - new->entry = (void *) e2dbgworld.real_main; - new->initial = 1; - time(&new->stime); - hash_add(&e2dbgworld.threads, key, new); - e2dbgworld.curthread = new; - e2dbgworld.threadnbr = 1; - e2dbg_stack_get(new); - -#if __DEBUG_THREADS__ - ret = snprintf(logbuf, BUFSIZ, " [D] Thread INITIAL has ID %u, stack at addr %08X with size %u \n", - (unsigned int) new->tid, new->stackaddr, new->stacksize); - write(1, logbuf, ret); -#endif - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/entry.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/entry.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/entry.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/entry.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,359 +0,0 @@ -/** - * @file entry.c - * - * The debugger file for OS dependant entry points - * - * Started on Tue Jul 11 20:37:33 2003 jfv - * - * - * $Id: entry.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - - - -/** - * Our fake main function - * @param argc - * @param argv - * @param aux - * @return - */ -int e2dbg_fake_main(int argc, char **argv, char **aux) -{ - e2dbgparams_t params; - char *args[3]; - char *pn; - int ret; - -#if __DEBUG_E2DBG__ - char logbuf[BUFSIZ]; - unsigned int len; - int idx; -#endif - -#if defined(__FreeBSD__) || defined(__NetBSD__) - pn = __progname; -#elif defined(sun) - pn = getexecname(); -#else - pn = __progname_full; -#endif - -#if __DEBUG_E2DBG__ - write(1, "Calling e2dbg_fake_main ! \n", 27); - for (idx = 0; argv[idx]; idx++) - { - write(1, "argv = ", 7); - write(1, argv[idx], strlen(argv[idx])); - write(1, "\n", 1); - } - write(1, "__progname_full = ", 18); - write(1, pn, strlen(pn)); - write(1, "\n", 1); -#endif - - /* Create the debugger thread */ - args[0] = E2DBG_ARGV0; - args[1] = pn; - //args[1] = argv[0]; - args[2] = NULL; - params.ac = 2; - params.av = args; - - e2dbg_presence_set(); - - /* Initialize a "fake" thread if we are debugging a monothread program */ - if (e2dbgworld.curthread == NULL) - e2dbg_curthread_init(); - - /* Make sure libstderesi handlers are filled */ - eresi_stdconstructor(); - - /* Call the debugger */ - e2dbg_entry(¶ms); - -#if __DEBUG_E2DBG__ - write(1, "[(e2dbg_fake_main] Calling ON_EXIT \n", 46); -#endif - - /* Wait for debuggee exit */ - on_exit((void *) wait4exit, NULL); - SETSIG; - -#if __DEBUG_E2DBG__ - len = snprintf(logbuf, BUFSIZ, - "[e2dbg_fake_main] Calling main %08X curthr %08X id %u\n", - (eresi_Addr) e2dbgworld.real_main, - (eresi_Addr) e2dbgworld.curthread, - (unsigned int) getpid()); - write(1, logbuf, len); -#endif - - /* Call the original main */ - e2dbg_presence_reset(); - ret = (*e2dbgworld.real_main)(argc, argv, aux); - -#if __DEBUG_E2DBG__ - len = snprintf(logbuf, BUFSIZ, - "[e2dbg_fake_main] Main returned %u\n", ret); - write(1, logbuf, len); -#endif - - /* Force PIE binaries to exit */ - if (world.curjob->curfile->hdr->e_type == ET_DYN) - wait4exit(NULL); - - return (ret); -} - - - - -#if defined(linux) - - -/** - * Entry point for Linux - * @param main - * @param argc - * @param ubp_av - * @param init - * @param fini - * @param rtld_fini - * @param stack_end - * @return - */ -int __libc_start_main(int (*main) (int, char **, char **aux), - int argc, char **ubp_av, - // FIXME on PPC - //ElfW(auxv_t) *__unbounded auxvec, - void (*init) (void), - void (*fini) (void), - void (*rtld_fini) (void), - void *__unbounded stack_end) -{ - eresi_Addr orig; - int (*libcstartmain)(); - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - e2dbg_presence_set(); - -#if __DEBUG_E2DBG__ - write(1, "[(e2dbg)__libc_start_main] there\n", 33); -#endif - - /* Find the real symbol in libc */ - orig = (eresi_Addr) e2dbg_dlsym("__libc_start_main"); - if (!orig) - { - write(1, "Error : Orig __libc_start_main not found\n", 41); - return (-1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig __libc_start_main not found", (-1)); - } - - /* Save the libcstartmain for future references */ - libcstartmain = (void *) orig; - -#if __DEBUG_E2DBG__ - write(1, "[(e2dbg)__libc_start_main] there 2\n", 35); -#endif - - /* Load the debugger in a new thread */ - e2dbgworld.preloaded = 1; - //CLRSIG; - - /* Initalize mutexes */ - e2dbg_mutex_init(&e2dbgworld.dbgbp); - -#if __DEBUG_E2DBG__ - write(1, "[(e2dbg)__libc_start_main] there 3 \n", 35); -#endif - - e2dbgworld.real_main = main; - ret = libcstartmain(e2dbg_fake_main, argc, ubp_av, init, - fini, rtld_fini, stack_end); - - /* Never reached */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(sun) - - -/** - * Find the number of arguments by inspecting the environment on the stack - * @param args - * @return - */ - -int e2dbg_get_args(char **args) -{ - char *str; - int argc; - int index; - - str = ((char *) environ[0] - 2); - argc = 0; - - /* First find the number of arguments */ - again: - while (*str) - str--; - str++; - argc++; - if (access(str, F_OK)) - { - str -= 2; - goto again; - } - - /* Then fill the argv array */ - args[0] = E2DBG_ARGV0; - for (index = 1; index < argc + 1 && index < 42; index++) - { - args[index] = str; - while (*str) - str++; - str++; - } - args[index] = NULL; - return (argc); -} - - - -/** - * Entry point on FreeBSD - * @param fini - * @return - */ -int atexit(void (*fini)(void)) -{ - eresi_Addr orig; - int (*libc_atexit)(); - char *args[42]; - static short int bFusible = 0; - e2dbgparams_t params; - int argc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - e2dbg_presence_set(); - -#if __DEBUG_E2DBG__ - printf("[(e2dbg)atexit] there\n"); -#endif - - /* Find the real symbol */ - orig = (eresi_Addr) e2dbg_dlsym("atexit"); - if (!orig) - { - write(1, "Error : Orig atexit not found\n", 30); - return (-1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig atexit not found", (-1)); - } - libc_atexit = (void *) orig; - -#if __DEBUG_E2DBG__ - printf("[(e2dbg)atexit 2 : envp = %08X \n", (eresi_Addr) environ); -#endif - - /* Initialize a "fake" thread if we are debugging a monothread program */ - if (e2dbgworld.curthread == NULL) - e2dbg_curthread_init(); - -#if __DEBUG_E2DBG__ - printf("[(e2dbg) atexit 3 \n"); -#endif - - /* Load the debugger only one time */ - if (bFusible == 0) - { - bFusible = 1; - - /* Get argv / argc */ - argc = e2dbg_get_args(args); - params.ac = argc; - params.av = args; - - /* Load the debugger in a new thread */ - e2dbgworld.preloaded = 1; - - /* Initalize mutexes */ - e2dbg_mutex_init(&e2dbgworld.dbgbp); - e2dbg_entry(¶ms); - } - -#if __DEBUG_E2DBG__ - printf("[e2dbg-fbsd: atexit 3]\n"); -#endif - - /* Recall the original function */ - e2dbg_presence_reset(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - libc_atexit(fini)); -} - -/** - * Entry point for Solaris - * @param argc - * @param ubp_av - * @return - */ -/* - void __fpstart(int argc, char **ubp_av) - { - eresi_Addr orig; - int (*realfpstart)(); - char *argv[3]; - e2dbgparams_t params; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - #if __DEBUG_E2DBG__ - printf("[e2dbg__fpstart] Start\n"); - #endif - - //Find the real symbol - orig = (eresi_Addr) e2dbg_dlsym("__fpstart"); - if (!orig) - { - write(1, "Error : Orig __fpstart not found\n", 33); - return; - } - realfpstart = (void *) orig; - - #if __DEBUG_E2DBG__ - printf("[e2dbg__fpstart] 2\n"); - #endif - - //Load the debugger - argv[0] = E2DBG_ARGV0; - argv[1] = ubp_av[0]; - argv[2] = NULL; - params.ac = 2; - params.av = argv; - //CLRSIG; - e2dbgworld.preloaded = 1; - e2dbg_entry(¶ms); - //SETSIG; - - #if __DEBUG_E2DBG__ - printf("[e2dbg__fpstart] End \n"); - #endif - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - } -*/ - - -#else - #warning "E2DBG Not yet implemented on this OS/Arch" -#endif diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/linkmap.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/linkmap.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/linkmap.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/linkmap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,310 +0,0 @@ -/** - * @file linkmap.c - * - * Started on Tue Aug 16 09:38:03 2005 jfv - * - * $Id: linkmap.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - -/** - * Load linkmap - * @param name - * @return - */ -int e2dbg_linkmap_load(char *name) -{ - static int done = 0; - elfshsect_t *got; - eresi_Addr *linkmap_entry; - void *data; -#if defined(sun) - Link_map *actual; -#else - elfshlinkmap_t *actual; -#endif - char *gotname; - char *ename; - elfsh_Ehdr *hdr; - u_int elftypenum; - elfsh_Sym *endsym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (done) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg] Starting Loading LINKMAP !! \n"); -#endif - - e2dbg_setup_hooks(); - revm_config(E2DBG_CONFIG); - - /* Load debugged file */ - if (name) - { - - /* No need to fill ET_EXEC base addr */ - if (!revm_is_loaded(name) && revm_file_load(name, 0, NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load file", -1); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] file %s loaded\n", name); -#endif - - world.curjob->curfile->linkmap = E2DBG_DYNAMIC_LINKMAP; - world.curjob->curfile->running = 0; - } - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Before switch\n"); -#endif - - /* Switch to obj 1 */ - if (revm_doswitch(1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot switch on object 1", -1); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] After switch \n"); -#endif - - /* Base address for PIE binaries have to be imported */ - if (world.curjob->curfile->hdr->e_type == ET_DYN && - !world.curjob->curfile->rhdr.base) - { -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Inside ET_DYN condition\n"); -#endif - - endsym = elfsh_get_symbol_by_name(world.curjob->curfile, "_end"); - - fprintf(stderr, "endsym = " AFMT " \n", (eresi_Addr) endsym); - sleep(1); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Filling PIE base" - " (_end ondisk = " AFMT " / _end in memory = " AFMT ") ! \n", - endsym->st_value, e2dbgworld.syms.piebase); -#endif - - world.curjob->curfile->rhdr.base = e2dbgworld.syms.piebase - - endsym->st_value; - } - - /* Get ALTGOT or GOT if we used LD_PRELOAD */ - if (!e2dbgworld.preloaded) - { - gotname = ELFSH_SECTION_NAME_ALTGOT; - got = elfsh_get_section_by_name(world.curjob->curfile, - gotname, NULL, NULL, NULL); - } - else - got = elfsh_get_gotsct(world.curjob->curfile); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] %s section at " XFMT "\n", - got->name, got->shdr->sh_addr); - fprintf(stderr, "[e2dbg_linkmap_load] BASE = %08x\n", - world.curjob->curfile->rhdr.base); -#endif - - - /* Fix first file linkmap entry */ - if (world.curjob->curfile->linkmap == E2DBG_DYNAMIC_LINKMAP) - { - /* Fix first file linkmap entry */ - hdr = elfsh_get_hdr(world.curjob->curfile); - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get ELF header", -1); - elftypenum = elfsh_get_objtype(hdr); - - //fprintf(stderr, "[e2dbg_linkmap_load] after ELF header \n"); - - /* Get ALTGOT entry */ - data = elfsh_get_raw(got); - - //fprintf(stderr, "[e2dbg_linkmap_load] after get_raw (data = %08X) \n", data); - - linkmap_entry = elfsh_get_got_entry_by_index(data, 1); - - //fprintf(stderr, "[e2dbg_linkmap_load] after entry_by_index (linkmap_entry = %08x)\n", - // linkmap_entry); - -#if defined(__FreeBSD__) || defined(__NetBSD__) - world.curjob->curfile->linkmap = (elfshlinkmap_t *) - &((Obj_Entry *) elfsh_get_got_val(linkmap_entry))->linkmap; -#elif defined(sun) - world.curjob->curfile->linkmap = e2dbgworld.syms.map; -#else - world.curjob->curfile->linkmap = (elfshlinkmap_t *) elfsh_get_got_val(linkmap_entry); -#endif - - } - -#if __DEBUG_LINKMAP__ - else - fprintf(stderr, "[e2dbg_linkmap_load] Linkmap was -NOT- dynamic\n"); - - fprintf(stderr, "[e2dbg_linkmap_load] LINKMAP Found at " XFMT "\n", - world.curjob->curfile->linkmap); -#endif - - - - - - revm_doswitch(1); - - - /* now load all linkmap's files */ - for (actual = elfsh_linkmap_get_lprev(world.curjob->curfile->linkmap); - actual != NULL; - actual = elfsh_linkmap_get_lprev(actual)) - { - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Running on LINKMAP PREV " XFMT "\n", - actual); -#endif - - ename = elfsh_linkmap_get_lname(actual); - if (ename && *ename && !revm_is_loaded(ename)) - { - if (revm_file_load(ename, elfsh_linkmap_get_laddr(actual), - world.curjob->curfile->linkmap) < 0) - e2dbg_output(" [EE] Loading failed"); - } - } - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Running on LINKMAP NEXT\n"); -#endif - - for (actual = elfsh_linkmap_get_lnext(world.curjob->curfile->linkmap); - actual != NULL; - actual = elfsh_linkmap_get_lnext(actual)) - { - - ename = elfsh_linkmap_get_lname(actual); - -#if __DEBUG_LINKMAP__ - fprintf(stderr, "[e2dbg_linkmap_load] Running on LINKMAP NEXT " XFMT " (%s baseaddr %08X) \n", - actual, ename, actual->laddr); -#endif - - if (ename && *ename && !revm_is_loaded(ename)) - { - if (revm_file_load(ename, elfsh_linkmap_get_laddr(actual), - world.curjob->curfile->linkmap) < 0) - e2dbg_output(" [EE] Loading failed"); - } - } - - /* Everything was OK */ - e2dbg_output("\n"); - //elfsh_set_debug_mode(); - revm_doswitch(1); - done = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Dump the linkmap - * @param file - * @return - */ -int e2dbg_linkmap_print(elfshobj_t *file) -{ - char logbuf[BUFSIZ]; -#if defined(sun) - Link_map *actual; -#else - elfshlinkmap_t *actual; -#endif - int i = 1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - if (!file->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No linkmap", -1); - - e2dbg_output(" .::. Linkmap entries .::. \n"); - - for (actual = elfsh_linkmap_get_lprev(file->linkmap); actual != NULL; - actual = elfsh_linkmap_get_lprev(actual), i++) - { - snprintf(logbuf, BUFSIZ - 1, - " [%02u] addr : " XFMT " dyn : " XFMT " - %s\n", i, - (eresi_Addr) elfsh_linkmap_get_laddr(actual), - (eresi_Addr) elfsh_linkmap_get_lld(actual), - elfsh_linkmap_get_lname(actual)); - e2dbg_output(logbuf); - } - - for (actual = file->linkmap; actual != NULL; - actual = elfsh_linkmap_get_lnext(actual), i++) - { - snprintf(logbuf, BUFSIZ - 1, - " [%02u] addr : "XFMT" dyn : "XFMT" - %s\n", i, - (eresi_Addr) elfsh_linkmap_get_laddr(actual), - (eresi_Addr) elfsh_linkmap_get_lld(actual), - elfsh_linkmap_get_lname(actual)); - e2dbg_output(logbuf); - } - - e2dbg_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Linkmap dump command - * @return -*/ -int cmd_linkmap() -{ - int old; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_is_debug_mode()) - { - if (!world.curjob) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current workspace", -1); - - if (!world.curjob->curfile) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No current file", -1); - - old = world.curjob->curfile->id; - - /* switch to the main program file */ - revm_doswitch(1); - ret = e2dbg_linkmap_print(world.curjob->curfile); - revm_doswitch(old); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Debug mode only command", (-1)); -} - - - - - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -## -## Makefile for userland part of libe2dbg in the ERESI framework -## -## Started on Wed Dec 19 06:32:29 2005 jfv -## $Id -## - -include ../../config.h - -SRC = e2dbg.c delete.c signal.c linkmap.c continue.c \ - alloc-proxy.c resolv.c threads.c entry.c e2dbg-misc.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -RM = rm -f - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ - -I../../libelfsh/include/ -I../../libdump/include/ \ - -I../../libasm/include/ -I../../libstderesi/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libaspect/include -I../../librevm/include/ \ - -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINCINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI32 - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) $(BUILDOP) \ - -I../../libelfsh/include/ -I../../libdump/include/ \ - -I../../libasm/include/ -I../../libstderesi/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libaspect/include -I../../librevm/include/ \ - -I../../libedfmt/include/ -I../../liballocproxy/include/ \ - $(KERNSHINC) $(KERNSH) -DE2DBG_PRESENT \ - -DELFSH_INTERN -DE2DBG_INTERN $(ASMOPT) -DERESI64 - -all : all32 all64 - -all32 : ${OBJ32} - -all64 : ${OBJ64} - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/resolv.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/resolv.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/resolv.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/resolv.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,554 +0,0 @@ -/** - * @file resolv.c - * - * Contains the linkmap related resolving builtins in e2dbg - * - * Last Update Thu Oct 13 19:37:26 2005 mm - * - * $Id: resolv.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - -#include - -/* Reference symbol for the debugger */ -int reference = 42; - - -/** - * Our own dlsect without malloc. - * Useful in the early stage of mapping when malloc symbol is not yet known - * @param objname - * @param sect2resolve - * @param refaddr - * @param refsym - * @return - */ -eresi_Addr e2dbg_dlsect(char *objname, char *sect2resolve, - eresi_Addr refaddr, char *refsym) -{ - e2dbgobj_t obj; - elfsh_Phdr *pht; - elfsh_Dyn *dyn; - u_int nbr, nbr2; - elfsh_Sym cursym; - char *strtab; - eresi_Addr got; - u_int curoff; - eresi_Addr found_ref = 0; - -#if __DEBUG_E2DBG__ - char buf[BUFSIZ]; - u_int len; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_E2DBG__ - write(2, " [*] e2dbg_dlsect called for resolving ", 39); - write(2, sect2resolve, strlen(sect2resolve)); - write(2, " in ", 4); - write(2, objname, strlen(objname)); - write(2, "\n", 1); -#endif - - memset(&obj, 0x00, sizeof(obj)); - XOPEN(obj.fd, objname, O_RDONLY, 0, 0); - XREAD(obj.fd, &obj.e, sizeof(elfsh_Ehdr), 0); - -#if __DEBUG_E2DBG__ - write(2, " [*] 1", 6); -#endif - - XSEEK(obj.fd, obj.e.e_phoff, SEEK_SET, 0); - pht = alloca(obj.e.e_phnum * sizeof(elfsh_Phdr)); - -#if __DEBUG_E2DBG__ - write(2, "2", 1); -#endif - - XREAD(obj.fd, pht, obj.e.e_phnum * sizeof(elfsh_Phdr), 0); - for (nbr = 0; nbr < obj.e.e_phnum; nbr++) - if (pht[nbr].p_type == PT_DYNAMIC) - { - obj.dynoff = pht[nbr].p_offset; - break; - } - -#if __DEBUG_E2DBG__ - write(2, "3", 1); -#endif - - XSEEK(obj.fd, obj.dynoff, SEEK_SET, 0); - dyn = alloca(pht[nbr].p_filesz); - -#if __DEBUG_E2DBG__ - write(2, "4", 1); -#endif - - XREAD(obj.fd, dyn, pht[nbr].p_filesz, 0); - for (nbr2 = 0; nbr2 < pht[nbr].p_filesz / sizeof(elfsh_Dyn); nbr2++) - { - if (dyn[nbr2].d_tag == DT_SYMTAB) - obj.symoff = dyn[nbr2].d_un.d_val; - else if (dyn[nbr2].d_tag == DT_STRTAB) - obj.stroff = dyn[nbr2].d_un.d_val; - else if (dyn[nbr2].d_tag == DT_STRSZ) - obj.strsz = dyn[nbr2].d_un.d_val; - else if (dyn[nbr2].d_tag == DT_PLTGOT) - got = (eresi_Addr) dyn[nbr2].d_un.d_val; - } - -#if __DEBUG_E2DBG__ - write(2, "5", 1); -#endif - - strtab = alloca(obj.strsz); - if (!strtab) - { - write(2, " Failed to alloca string table\n", 31); - return (-1); - } - if (!obj.symoff) - { - write(2, " Unable to find SYMOFF from PT_DYNAMIC\n", 39); - return (-1); - } - - if (!obj.stroff) - { - write(2, " Unable to find STROFF rom PT_DYNAMIC\n", 39); - return (-1); - } - - if (!obj.strsz) - { - write(2, " Unable to find STRSZ from PT_DYNAMIC\n", 39); - return (-1); - } - - if (!got) - { - write(2, " Unable to find PLTGOT from PT_DYNAMIC\n", 39); - return (-1); - } - -#if __DEBUG_E2DBG__ - write(1, "6", 1); -#endif - - XSEEK(obj.fd, obj.stroff, SEEK_SET, 0); - XREAD(obj.fd, strtab, obj.strsz, 0); - -#if __DEBUG_E2DBG__ - write(1, "7", 1); -#endif - - /* XXX: Assume that strtab is always just after symtab */ - for (curoff = 0; obj.symoff + curoff < obj.stroff; curoff += sizeof(elfsh_Sym)) - { - XSEEK(obj.fd, obj.symoff + curoff, SEEK_SET, 0); - XREAD(obj.fd, &cursym, sizeof(elfsh_Sym), 0); - if (cursym.st_name >= obj.strsz) - continue; - if (!strcmp(strtab + cursym.st_name, refsym)) - found_ref = cursym.st_value; - } - -#if __DEBUG_E2DBG__ - write(2, "8", 1); -#endif - - if (!found_ref) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find reference symbol in object", 0); - -#if __DEBUG_E2DBG__ - write(2, " Success !\n", 11); - len = snprintf(buf, sizeof(buf), - " [*] REFADDR = %08X and FOUNDREF = %08X and GOT = %08X \n", - refaddr, found_ref, got); - write(2, buf, len); -#endif - - /* Close the file */ - XCLOSE(obj.fd, 0); - - /* The reference addr is useful to deduce library base addresses */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - got + refaddr - found_ref); -} - - - -/** - * Our own dlsym without malloc. - * Useful in the early stage of mapping when malloc symbol is not yet known - * @param sym2resolve - * @return - */ -eresi_Addr e2dbg_dlsym(char *sym2resolve) -{ - e2dbgobj_t obj; - elfsh_Dyn *dyn; - u_int nbr2; - elfsh_Sym cursym; - char *strtab; - u_int curoff; - eresi_Addr found_sym = 0; - elfshlinkmap_t *curobj; - elfsh_Ehdr hdr; - -#if __DEBUG_E2DBG__ - char buf[BUFSIZ]; - u_int len; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First go after the e2dbg and the binary linkmap entries */ - curobj = e2dbgworld.syms.map; - - /* Come back at the beginning of the linkmap */ - while (curobj->lprev) - curobj = curobj->lprev; - - /* Iterate on the linkmap to resolve symbols in library priority order */ - for (; curobj; curobj = curobj->lnext) - { - - if (!curobj->lname || !*curobj->lname || strstr(curobj->lname, "e2dbg")) - continue; - memset(&obj, 0x00, sizeof(obj)); - XOPEN(obj.fd, curobj->lname, O_RDONLY, 0, 0); - XREAD(obj.fd, &hdr, sizeof(hdr), 0); - if (hdr.e_type != ET_DYN) - { - XCLOSE(obj.fd, 0); - continue; - } - -#if __DEBUG_E2DBG__ - write(2, " [*] e2dbg_dlsym called for resolving ", 38); - write(2, sym2resolve, strlen(sym2resolve)); - write(2, " in ", 4); - write(2, curobj->lname, strlen(curobj->lname)); - write(2, "\n", 1); -#endif - - dyn = curobj->lld; - - /* Getting needed address in the memory mapped PT_DYNAMIC segment */ - for (nbr2 = 0; dyn[nbr2].d_tag != DT_NULL; nbr2++) - { - if (dyn[nbr2].d_tag == DT_SYMTAB) -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(sun) - obj.symoff = curobj->laddr + dyn[nbr2].d_un.d_val; -#else - obj.symoff = dyn[nbr2].d_un.d_val; -#endif - else if (dyn[nbr2].d_tag == DT_STRTAB) -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(sun) - obj.stroff = curobj->laddr + dyn[nbr2].d_un.d_val; -#else - obj.stroff = dyn[nbr2].d_un.d_val; -#endif - else if (dyn[nbr2].d_tag == DT_STRSZ) - obj.strsz = dyn[nbr2].d_un.d_val; - } - strtab = (char *) obj.stroff; - - /* Checking if everything is ok */ - if (!obj.symoff) - { - write(2, " Unable to find SYMOFF from PT_DYNAMIC\n", 39); - return (-1); - } - - if (!obj.stroff) - { - write(2, " Unable to find STROFF rom PT_DYNAMIC\n", 39); - return (-1); - } - - if (!obj.strsz) - { - write(2, " Unable to find STRSZ from PT_DYNAMIC\n", 39); - return (-1); - } - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] SYMOFF = %u (%08X), STROFF = %u (%08X), STRSZ = %u \n", - obj.symoff, obj.symoff, obj.stroff, obj.stroff, obj.strsz); - write(2, buf, len); -#endif - - XCLOSE(obj.fd, 0); - - /* XXX: Assume that dynamic strtab is always just after dynamic symtab */ - for (curoff = 0; obj.symoff + curoff < obj.stroff; curoff += sizeof(elfsh_Sym)) - { - memcpy(&cursym, (void *)obj.symoff + curoff, sizeof(elfsh_Sym)); - if (cursym.st_name >= obj.strsz) - continue; - if (!strcmp(strtab + cursym.st_name, sym2resolve) && - cursym.st_value) - { - found_sym = cursym.st_value; - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] FOUNDSYM (%s) = %08X \n", - strtab + cursym.st_name, found_sym); - write(2, buf, len); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - curobj->laddr + found_sym); - } - } - } - - /* We did not find the symbol in the linkmap ... */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find looked up symbol in object", 0); -} - - - -/** - * Get the address of the linkmap without any malloc, - * for early stage resolving - * @return - */ -elfshlinkmap_t* e2dbg_linkmap_getaddr() -{ - eresi_Addr baseaddr; - char path[BUFSIZ]; - eresi_Addr *got; - elfshlinkmap_t *lm; - char *version; -#if defined(__FreeBSD__) || defined(__NetBSD__) - Obj_Entry *oe; -#elif defined(sun) - Dl_info info; -#endif - - -#if __DEBUG_E2DBG__ - char buf[BUFSIZ]; - u_int len; -#endif - -#if __DEBUG_E2DBG__ - len = sprintf(buf, " [*] e2dbg_linkmap_getaddr called\n"); - write(2, buf, len); -#endif - -#if defined(ERESI32) - version = "32"; -#elif defined(ERESI64) - version = "64"; -#else - printf("Unknown debugger version : fatal error \n"); - exit(-1); -#endif - - snprintf(path, BUFSIZ, "%s/libe2dbg%s.so", ELFSH_DBGPATH, version); - -#if defined(linux) - baseaddr = e2dbg_dlsect(path, ".got.plt", - (eresi_Addr) &reference, "reference"); -#else - baseaddr = e2dbg_dlsect(path, ".got", - (eresi_Addr) &reference, "reference"); -#endif - -#if __DEBUG_E2DBG__ - len = sprintf(buf, " [*] Base address - 1st = %08X\n", baseaddr); - write(2, buf, len); -#endif - - got = (eresi_Addr *) baseaddr; - -#if __DEBUG_E2DBG__ - len = sprintf(buf, " [*] GOT address = %08X\n", (eresi_Addr) got); - write(2, buf, len); -#endif - - /* BSD and Solaris have an intermediate structure between GOT[1] and the linkmap entry */ -#if defined(__FreeBSD__) || defined(__NetBSD__) - oe = (Obj_Entry *) got[1]; - lm = (elfshlinkmap_t *) &oe->linkmap; -#elif defined(sun) - dladdr1(&reference, &info, (void **) &lm, RTLD_DL_LINKMAP); -#else - lm = (elfshlinkmap_t *) got[1]; -#endif - -#if __DEBUG_E2DBG__ - len = sprintf(buf, - " [*] Guessed Linkmap address = %08X \n--------------\n", - (eresi_Addr) lm); - write(2, buf, len); -#endif - - return (lm); -} - - - -/** - * Resolve malloc/realloc/free from standard libc - * @return - */ -int e2dbg_dlsym_init() -{ - static int done = 0; - u_char dbgmode; - -#if !defined(__FreeBSD__) - void *handle; -#endif - -#if __DEBUG_E2DBG__ - char buf[BUFSIZ]; - u_int len; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_E2DBG__ - write(2, " [D] e2dbg_dlsym_init CALLED\n", 29); -#endif - - if (done) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); - -#if __DEBUG_E2DBG__ - write(2, " [D] e2dbg_dlsym_init EXECUTED\n", 31); -#endif - - /* Get the address of the linkmap without calling malloc */ - e2dbgworld.syms.map = e2dbg_linkmap_getaddr(); - - /* Only use our own dlsym here, do not use the libc handler */ - e2dbgworld.syms.mallocsym = (eresi_Addr) e2dbg_dlsym("malloc"); - if (!e2dbgworld.syms.mallocsym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig malloc not found", (-1)); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc MALLOC() sym = %08X \n", - e2dbgworld.syms.mallocsym); - write(2, buf, len); -#endif - - e2dbgworld.syms.callocsym = (eresi_Addr) e2dbg_dlsym("calloc"); - if (!e2dbgworld.syms.callocsym) - { - dlerror(); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig calloc not found", (-1)); - } - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc CALLOC() sym = %08X \n", - e2dbgworld.syms.callocsym); - write(2, buf, len); -#endif - - e2dbgworld.syms.reallocsym = (eresi_Addr) e2dbg_dlsym("realloc"); - if (!e2dbgworld.syms.reallocsym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig realloc not found", (-1)); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc REALLOC() sym = %08X \n", - e2dbgworld.syms.reallocsym); - write(2, buf, len); -#endif - - e2dbgworld.syms.freesym = (eresi_Addr) e2dbg_dlsym("free"); - if (!e2dbgworld.syms.freesym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig free not found", (-1)); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc FREE() sym = %08X \n", e2dbgworld.syms.freesym); - write(2, buf, len); -#endif - - e2dbgworld.syms.vallocsym = (eresi_Addr) e2dbg_dlsym("valloc"); - if (!e2dbgworld.syms.vallocsym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig valloc not found", (-1)); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc VALLOC() sym = %08X \n", - e2dbgworld.syms.vallocsym); - write(2, buf, len); -#endif - - e2dbgworld.syms.signal = (eresi_Addr) e2dbg_dlsym("signal"); - if (!e2dbgworld.syms.signal) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Orig signal not found", (-1)); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] Libc SIGNAL() sym = %08X \n", - e2dbgworld.syms.signal); - write(2, buf, len); -#endif - - - /* Non fatal symbols, especially on BSD */ - e2dbgworld.syms.memalignsym = (eresi_Addr) e2dbg_dlsym("memalign"); - e2dbgworld.syms.pthreadcreate = (eresi_Addr) e2dbg_dlsym("pthread_create"); - e2dbgworld.syms.pthreadexit = (eresi_Addr) e2dbg_dlsym("pthread_exit"); - - /* Now we can use malloc cause allocation symbols are resolved */ - /* The allocator proxy will select between legit or alternative syms */ - done = 1; - dbgmode = e2dbg_presence_get(); - e2dbg_presence_set(); - hash_init(&e2dbgworld.threads, "threads" , 29, ASPECT_TYPE_UNKNOW); - hash_init(&e2dbgworld.bp , "breakpoints", 51, ASPECT_TYPE_UNKNOW); - - /* If we are dealing with a PIE binary, compute his base address using - _end. This symbol is always defined in dynamic binaries, even when - stripped. It is also important that the chosen symbol points in the - data PT_LOAD, since each PT_LOAD have a different base address and - we want the one that contains the GOT section, which itself contains - the linkmap address in its second entry */ -#if !defined(__FreeBSD__) - handle = dlopen(NULL, RTLD_LAZY); - e2dbgworld.syms.piebase = (eresi_Addr) dlsym(handle, "_end"); - dlclose(handle); -#endif - - if (!dbgmode) - e2dbg_presence_reset(); - -#if __DEBUG_E2DBG__ - len = snprintf(buf, sizeof(buf), - " [*] PIE _end resolved = %08X \n", - e2dbgworld.syms.piebase); - write(2, buf, len); -#endif - -#if __DEBUG_E2DBG__ - write(2, " [D] e2dbg_dlsym_init FINISHED\n", 31); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/signal.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/signal.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/signal.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/signal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,582 +0,0 @@ -/** - * @file signal.c - * - * The debugger file for signal handlers - * - * Started on Tue Feb 11 21:17:33 2003 jfv - * Last update Wed Aug 13 23:22:59 2005 jfv - * - * $Id: signal.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" - - - -/** - * Signal handler for SIGSEGV - * @param signum - * @param info - * @param pcontext - * @param - */ -void e2dbg_sigsegv_handler(int signum, siginfo_t *info, void *pcontext) -{ - char *argv[2]; - ucontext_t *context; - e2dbgparams_t params; - - CLRSIG; - context = (ucontext_t *) pcontext; - argv[0] = E2DBG_ARGV0; - argv[1] = NULL; - - fprintf(stderr, "\n\n ******* Segfault, entering E2dbg ******** \n\n"); - sleep(1); - - params.ac = 1; - params.av = argv; - e2dbg_presence_set(); - e2dbg_entry(¶ms); - e2dbg_presence_reset(); - SETSIG; -} - -/** - * Internal Signal handler for SIGSEGV - * @param signum - * @param info - * @param pcontext - * @return - */ -void e2dbg_internal_sigsegv_handler(int signum, siginfo_t *info, - void *pcontext) -{ - ucontext_t *context; - - CLRSIG; - if (profiler_enabled()) - profiler_disable_all(); - context = (ucontext_t *) pcontext; - fprintf(stderr, "\n [!] Segfault in E2dbg, exiting ...\n\n"); - e2dbg_bt(); - cmd_quit(); - SETSIG; -} - -/** - * Signal handler for SIGINT - * @param signum - * @param info - * @param pcontext - * @return - */ -void e2dbg_sigint_handler(int signum, siginfo_t *info, void *pcontext) -{ - char *argv[2]; - e2dbgparams_t params; - e2dbgthread_t *curthread; - char key[15]; - - CLRSIG; - e2dbg_presence_set(); - - /* Get the current thread */ - snprintf(key, sizeof(key), "%u", (unsigned int) e2dbg_self()); - curthread = hash_get(&e2dbgworld.threads, key); - curthread->context = (ucontext_t *) pcontext; - - /* Set all registers as variables and get PC */ - //e2dbgworld.context = (ucontext_t *) pcontext; - - e2dbg_setup_hooks(); - e2dbg_getregs(); - argv[0] = E2DBG_ARGV0; - argv[1] = NULL; - e2dbg_output(" [*] Interrupted, entering E2dbg ...\n"); - params.ac = 1; - params.av = argv; - e2dbg_entry(¶ms); - e2dbg_presence_reset(); - SETSIG; -} - - -/** - * Signal handler for SIGSTOP - * @param signum - * @param info - * @param pcontext - * @return - */ -void e2dbg_sigstop_handler(int signum, siginfo_t *info, void *pcontext) -{ - char *argv[2]; - e2dbgparams_t params; - e2dbgthread_t *curthread; - char key[15]; - - CLRSIG; - e2dbg_presence_set(); - -#if __DEBUG_THREADS__ - printf("\n [*] SIGSTOP handler for thread %u \n", (unsigned int) e2dbg_self()); -#endif - - /* Get the current thread */ - snprintf(key, sizeof(key), "%u", (unsigned int) e2dbg_self()); - curthread = hash_get(&e2dbgworld.threads, key); - curthread->context = (ucontext_t *) pcontext; - - /* Set all registers as variables and get PC */ - //e2dbgworld.context = (ucontext_t *) pcontext; - - e2dbg_setup_hooks(); - e2dbg_getregs(); - argv[0] = E2DBG_ARGV0; - argv[1] = NULL; - e2dbg_output(" [*] Interrupted, entering E2dbg ...\n"); - params.ac = 1; - params.av = argv; - e2dbg_entry(¶ms); - e2dbg_presence_reset(); - SETSIG; -} - -/** - * Signal handler for SIGUSR2 - * @param signum - * @param info - * @param pcontext - * @return - */ -void e2dbg_thread_sigusr2(int signum, siginfo_t *info, void *pcontext) -{ - e2dbgthread_t *curthread; - char key[15]; - - /* Get the current thread */ - snprintf(key, sizeof(key), "%u", (unsigned int) e2dbg_self()); - curthread = hash_get(&e2dbgworld.threads, key); - curthread->context = (ucontext_t *) pcontext; - curthread->state = E2DBG_THREAD_SIGUSR2; - - -#if __DEBUG_THREADS__ - fprintf(stderr, " ************ [T] SIGUSR2 received by %u ******** \n", - (unsigned int) curthread->tid); -#endif - - /* Make it wait until the breakpoint is finished to process */ - e2dbgworld.threadsyncnbr++; - e2dbg_mutex_lock(&e2dbgworld.dbgbp); - e2dbg_mutex_unlock(&e2dbgworld.dbgbp); - curthread->state = E2DBG_THREAD_RUNNING; - -#if __DEBUG_THREADS__ - fprintf(stderr, " ********** [T] Thread %u getting out of SIGUSR2 handler ******* \n", - (unsigned int) curthread->tid); -#endif - -} - - - - -/** - * Signal handler for SIGTRAP - * @param signum - * @param info - * @param pcontext - * @return - */ -void e2dbg_sigtrap_handler(int signum, siginfo_t *info, void *pcontext) -{ - char *argv[2]; - ucontext_t *context; - e2dbgparams_t params; - - CLRSIG; - e2dbg_presence_set(); - -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__) - if (!e2dbg_presence_get()) - e2dbg_output(" [*] Debuggee in SIGTRAP handler\n"); - else - e2dbg_output(" [*] Debugger in SIGTRAP handler\n"); -#endif - - context = (ucontext_t *) pcontext; - argv[0] = E2DBG_ARGV0; - argv[1] = NULL; - e2dbg_output(" [*] SIGTRAP : Entering E2dbg.\n"); - params.ac = 1; - params.av = argv; - e2dbg_entry(¶ms); - e2dbg_presence_reset(); - SETSIG; -} - - -#if __DEBUG_BP__ -/** - * @param str - * @param bp - * @param pc - * @param parent - * @return - */ -void bpdebug(char *str, elfshbp_t *bp, eresi_Addr pc, elfshobj_t *parent) -{ - eresi_Addr addr; - int off; - char *name; - elfshsect_t *sect; - elfsh_Sym *sym; - - off = (bp ? 0 : e2dbgworld.stoppedthread->count == E2DBG_BREAK_HIT ? 3 : 6); - addr = (bp ? bp->addr : pc - off); - - fprintf(stderr, "%s (PC = %08X) ::: parent = %s (BP DESCRIPTOR = %08X) \n", - str, pc, (parent ? parent->name : "NONE !!!!"), (eresi_Addr) bp); - if (!bp) - return; - - sect = elfsh_get_parent_section(parent, addr, NULL); - name = revm_resolve(parent, addr, &off); - sym = elfsh_get_metasym_by_value(parent, addr, &off, ELFSH_LOWSYM); - revm_object_display(sect, sym, 16, 0, off, addr, name, REVM_VIEW_DISASM); -} -#endif - - -/** - * Signal handler for SIGUSR1 in debugger - * - */ -void e2dbg_do_breakpoint() -{ - char *argv[2]; - char buf[32]; - elfshbp_t *bp; - int prot; - char *name; - elfsh_SAddr off; - int ret; - asm_instr ptr; - char *s; - eresi_Addr *pc; - eresi_Addr savedpc; - u_int bpsz; - elfshsect_t *sect; - elfshobj_t *parent; - elfsh_Sym *sym; - -#if __DEBUG_BP__ - fprintf(stderr, "Entering breakpoint handler ... \n"); -#endif - - /* Set all registers as variables and get PC */ - argv[0] = "e2dbg"; - argv[1] = NULL; - e2dbg_setup_hooks(); - e2dbg_getregs(); - pc = e2dbg_getpc(); - - parent = e2dbg_get_parent_object((eresi_Addr) *pc); - bpsz = elfsh_get_breaksize(parent); - - /* Print variables and registers on breakpoints */ - //if (!world.state.revm_quiet) - //cmd_vlist(); - - /* Try to find the breakpoint at current instruction pointer */ -#if __DEBUG_BP__ - fprintf(stderr, "[PC = %08X] Trying to find breakpoint at addr %08X (bpsize = %u)\n", - *pc, *pc - bpsz, bpsz); -#endif - - snprintf(buf, sizeof(buf), XFMT, *pc - bpsz); - bp = hash_get(&e2dbgworld.bp, buf); - -#if __DEBUG_BP__ - bpdebug("BEFORE", bp, *pc, parent); - if (bp) - fprintf(stderr, " SAVED INSTR BYTE = %02X and PC-BPSZ BYTE = %02X \n", - bp->savedinstr[0], *((u_char *) *pc - bpsz)); - else - fprintf(stderr, "No BP found at %08X ! \n", *pc); -#endif - - /* If we are single-stepping or if we are stepping the breaked instruction */ - if (!bp || (bp->savedinstr[0] == *((u_char *) *pc - bpsz))) - { - - /* We are single-stepping, display the instruction at $pc */ - if (e2dbgworld.stoppedthread->step) - { - fprintf(stderr, "Single-stepping -IS- enabled \n"); - - ret = asm_read_instr(&ptr, (u_char *) *pc, 16, &world.proc); - if (!ret) - ret++; - sect = elfsh_get_parent_section(parent, (eresi_Addr) *pc, NULL); - name = revm_resolve(parent, (eresi_Addr) *pc, &off); - sym = elfsh_get_metasym_by_value(parent, (eresi_Addr) *pc, - &off, ELFSH_LOWSYM); - -#if __DEBUG_BP__ - printf("Found parent = %08X (%s) in step (name = %s, parentsect = %s) \n", - (eresi_Addr) parent, parent->name, name, sect->name); -#endif - - revm_object_display(sect, sym, ret, 0, off, - ((eresi_Addr) *pc), name, REVM_VIEW_DISASM); - e2dbg_display(e2dbgworld.displaycmd, e2dbgworld.displaynbr); - if (!e2dbgworld.stoppedthread->trace) - e2dbg_entry(NULL); - } - else - fprintf(stderr, "Single-stepping is -NOT- enabled \n"); - - - /* Here starts the real stuff - ** - ** count == E2DBG_BREAK_EXEC -> execute restored instruction - ** count == E2DBG_BREAK_FINISHED -> restore breakpoint - ** count > E2DBG_BREAK_MAX -> e2dbg is getting debugged by a third party debugger - */ - e2dbgworld.stoppedthread->count++; - -#if __DEBUG_BP__ - printf(" [C] Count %u -> %u for thread ID %u \n", - e2dbgworld.stoppedthread->count - 1, - e2dbgworld.stoppedthread->count, - ((unsigned int) e2dbgworld.stoppedthread->tid)); -#endif - - /* execute the previously restored instruction */ - if (e2dbgworld.stoppedthread->count == E2DBG_BREAK_EXEC && - !e2dbgworld.stoppedthread->step) - { -#if __DEBUG_BP__ - printf(" [*] [pc = %08x] Debuggee executed restored instruction \n", *pc); -#endif - return; - } - - /* Suggested by andrewg, useful when debugging valgrind */ - if (e2dbgworld.stoppedthread->count > E2DBG_BREAK_MAX && - !e2dbgworld.stoppedthread->step) - { - printf(".::- E2DBG WARNING -::.\n" - "Breakpoint triggered at location " AFMT " which we don't know about.\n\n" - "This may be an anti-debug trick or the program MAY be inside another\n" - "debugger that uses breakpoints. (count = " UFMT ", step is off)\n\n" - "This use of e2dbg is unsupported for now, exiting .. \n\n", - *pc - bpsz, e2dbgworld.stoppedthread->count); - return; - } - - /* Test if we need to reinstall a breakpoint */ - snprintf(buf, sizeof(buf), XFMT, e2dbgworld.stoppedthread->past); - bp = hash_get(&e2dbgworld.bp, buf); - - /* Call the architecture dependant hook for putting back the breakpoint */ - if (bp) - { - ret = e2dbg_setbreak(bp->obj, bp); - if (ret < 0) - { - e2dbg_output(" [E] Breakpoint reinsertion failed"); - return; - } - -#if __DEBUG_BP__ - fprintf(stderr, " Breakpoint reinserted at " AFMT " ! \n", bp->addr); -#endif - - e2dbgworld.stoppedthread->past = 0; - } -#if __DEBUG_BP__ - else - fprintf(stderr, "Breakpoint was deleted from " AFMT " : not reinstalling ! \n", - e2dbgworld.stoppedthread->past); - bpdebug("AFTER SETBREAK", bp, *pc, parent); -#endif - - /* remove trace flag */ - if (!e2dbgworld.stoppedthread->step) - { -#if __DEBUG_BP__ - fprintf(stderr, " [S] [PC = " AFMT "] RESETING STEP MODE ! \n", *pc); -#endif - e2dbg_resetstep(); - return; - } - } - - - /* Breakpoint case */ - else - { - name = revm_resolve(parent, (eresi_Addr) *pc - bpsz, &off); - s = (e2dbg_is_watchpoint(bp) ? "Watch" : "Break"); - - -#if __DEBUG_BP__ - printf(" [C] Count set to 1 for thread ID %u \n", - (unsigned int) e2dbgworld.stoppedthread->tid); -#endif - - if (off) - printf(" [*] %spoint found at " XFMT " <%s + " DFMT "> in thread %u \n\n", - s, *pc - bpsz, name, off, (unsigned int) e2dbgworld.stoppedthread->tid); - else - printf(" [*] %spoint found at " XFMT " <%s> in thread %u \n\n", - s, *pc - bpsz, name, (unsigned int) e2dbgworld.stoppedthread->tid); - - *pc -= bpsz; - prot = elfsh_munprotect(bp->obj, *pc, bpsz); - memcpy((u_char *) *pc, bp->savedinstr, bpsz); - elfsh_mprotect(*pc, bpsz, prot); - e2dbg_setstep(); - -#if __DEBUG_BP__ - fprintf(stderr, " [S] SETTING STEP MODE ! \n"); -#endif - - e2dbgworld.stoppedthread->past = *pc; - e2dbgworld.stoppedthread->count = E2DBG_BREAK_HIT; - e2dbgworld.curbp = bp; - bp->tid = (uint32_t) e2dbgworld.stoppedthread->tid; - -#if __DEBUG_BP__ - bpdebug("AFTER RESET BREAK", bp, (eresi_Addr) *pc + bpsz, parent); -#endif - -#if __DEBUG_BP__ - fprintf(stderr, " Breakpoint desinstalled at addr %08X \n", *pc); -#endif - e2dbg_display(bp->cmd, bp->cmdnbr); -#if __DEBUG_BP__ - fprintf(stderr, " e2dbg display ! \n"); -#endif - -#if __DEBUG_BP__ - fprintf(stderr, "PC before entry is addr %08X \n", *pc); -#endif - - savedpc = *pc; - e2dbg_entry(NULL); - *pc = savedpc; - -#if __DEBUG_BP__ - fprintf(stderr, "[PC = %08X] RETURNED FROM HANDLER WITH STEP ENABLED \n", - *pc); -#endif - } -} - - -/** - * The breakpoint routine. Save registers and callback - * @param signum - * @param info - * @param pcontext - * @return -*/ -void e2dbg_generic_breakpoint(int signum, - siginfo_t *info, - void *pcontext) -{ - ucontext_t *context; - char key[15]; - pthread_t stopped; - - /* Do not allow processing of 2 breakpoint at the same time */ - /* We update the current thread information */ - e2dbg_presence_set(); - if (!e2dbgworld.curbp || e2dbgworld.curbp->tid != e2dbg_self()) - { - e2dbg_mutex_lock(&e2dbgworld.dbgbp); - -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) - e2dbg_output("-------------- ON-BREAK REGISTERS ----------------------->\n"); - cmd_dumpregs(); - e2dbg_output("<------------------------------------------------------\n"); - e2dbg_output("------------------------------------->\n"); - e2dbg_output(" [*] BP MUTEX LOCKED [e2dbg_generic_breakpoint] \n"); - e2dbg_threads_print(); -#endif - } - - /* Get the current thread */ - stopped = (pthread_t) e2dbg_self(); - snprintf(key, sizeof(key), "%u", (unsigned int) stopped); - e2dbgworld.curthread = hash_get(&e2dbgworld.threads, key); - e2dbgworld.stoppedthread = e2dbgworld.curthread; - -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) - fprintf(stderr, "\n [*] Thread entering generic breakpoint (ID %u) \n", - (unsigned int) e2dbgworld.stoppedthread->tid); - fflush(stdout); -#endif - - e2dbgworld.stoppedthread->state = E2DBG_THREAD_BREAKING; - context = (ucontext_t *) pcontext; - e2dbgworld.stoppedthread->context = context; - - /* We first get contexts for all other threads (except debugger) using SIGUSR2 */ - /* Then we stop all threads */ - /* We do this only at the first state (count = 0) of the breakpoint */ - if (!e2dbgworld.stoppedthread->count) - { - e2dbg_thread_stopall(SIGUSR2); - usleep(100000); - } -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) - else - fprintf(stderr, " NOT COLLECTING THREADS CONTEXTS (stopped thread %u state count = %u) \n", - (u_int) e2dbgworld.stoppedthread->tid, e2dbgworld.stoppedthread->count); -#endif - - /* Call the real breakpoint code */ - e2dbg_do_breakpoint(); - - /* Continue all threads */ - if (e2dbgworld.stoppedthread->count == E2DBG_BREAK_FINISHED || - e2dbgworld.curthread->step || e2dbgworld.curthread->was_step) - { - e2dbg_thread_contall(); - e2dbgworld.curthread->was_step = 0; - e2dbgworld.stoppedthread->count = E2DBG_BREAK_NONE; - e2dbgworld.curbp = NULL; - - /* Allow another breakpoint to be processed */ - if (e2dbg_mutex_unlock(&e2dbgworld.dbgbp) != 0) - e2dbg_output(" [*] Debuggee Cannot unlock breakpoint mutex ! \n"); -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) - else - { - e2dbg_output(" [*] BP MUTEX UNLOCKED [e2dbg_generic_breakpoint] \n"); - e2dbg_output("<-------------------------------------\n"); - } -#endif - } - -#if (__DEBUG_THREADS__ || __DEBUG_E2DBG__ || __DEBUG_MUTEX__ || __DEBUG_BP__) - else - fprintf(stderr, " NOT CONTINUING BECAUSE STOPPED THREAD (%u) STATE COUNT = %u \n", - (u_int) e2dbgworld.stoppedthread->tid, e2dbgworld.stoppedthread->count); -#endif - - e2dbgworld.stoppedthread->state = E2DBG_THREAD_RUNNING; - e2dbg_presence_reset(); - SETSIG; - -#if __DEBUG_BP__ - fprintf(stderr, " RETURNING FROM GENERIC SIGNAL HANDLER \n"); -#endif -} - diff -Nru eresi-0.8a25/libe2dbg/user/.svn/text-base/threads.c.svn-base eresi-0.0.20110516/libe2dbg/user/.svn/text-base/threads.c.svn-base --- eresi-0.8a25/libe2dbg/user/.svn/text-base/threads.c.svn-base 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/.svn/text-base/threads.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,544 +0,0 @@ -/* - * @file threads.c - * - * Hook the threads API for keeping thread debugger information - * accurately up2date - * - * Last Update Thu July 06 19:37:26 2006 mm - * - * $Id: threads.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libe2dbg.h" -#include - - -/** - * Hooked start routine for all threads - * @param param - * @return - * - */ -static void* e2dbg_thread_start(void *param) -{ - e2dbgthread_t *cur; - //e2dbgthread_t *stopped; - void* (*start)(void *param); - char key[15]; - pthread_attr_t attr; - int ret; -#if __DEBUG_THREADS__ - char logbuf[BUFSIZ]; -#endif - - sigset_t mask; - sigset_t oldmask; - - /* Do not allow to start a thread while another one is created or breaking */ - SETSIG; - e2dbg_mutex_lock(&e2dbgworld.dbgbp); - e2dbg_presence_set(); - - /* Set the mask of signals to be handled by this thread */ - sigemptyset (&mask); - sigaddset (&mask, SIGUSR2); - sigaddset (&mask, SIGSEGV); - sigaddset (&mask, SIGBUS); - sigaddset (&mask, SIGTRAP); - //sigaddset (&mask, SIGSTOP); - sigaddset (&mask, SIGINT); - sigaddset (&mask, SIGILL); - ret = pthread_sigmask(SIG_UNBLOCK, &mask, &oldmask); - -#if __DEBUG_THREADS__ - if (ret) - fprintf(stderr, "Error while setting sigmask : returned %d \n", ret); - else - fprintf(stderr, "Sigmask set succesfully \n"); - e2dbg_output(" [*] BP MUTEX LOCKED [e2dbg_thread_start] \n"); -#endif - - snprintf(key, sizeof(key), "%u", (unsigned int) pthread_self()); - cur = hash_get(&e2dbgworld.threads, key); - -#if __DEBUG_THREADS__ - fprintf(stderr, " [*] Starting thread ID %u \n", (unsigned int) pthread_self()); -#endif - - /* Register the thread as started */ - e2dbgworld.threadnbr++; - cur->state = E2DBG_THREAD_STARTED; - if (e2dbgworld.threadnbr == 1) - cur->initial = 1; - - /* Get stack information for this thread */ -#if defined(linux) - pthread_getattr_np(cur->tid, &attr); - ret = pthread_attr_getstack(&attr, (void **) &cur->stackaddr, (size_t *) &cur->stacksize); -#elif defined(__FreeBSD__) - pthread_attr_get_np(cur->tid, &attr); - ret = pthread_attr_getstack(&attr, (void **) &cur->stackaddr, (size_t *) &cur->stacksize); -#else - pthread_attr_getstacksize(cur->attr, (size_t *) &cur->stacksize); - ret = pthread_attr_getstackaddr(cur->attr, (void **) &cur->stackaddr); -#endif - - /* Check for errors */ -#if __DEBUG_THREADS__ - if (ret) - write(1, "Problem during pthread_attr_getstack\n", 37); - else - { - ret = snprintf(logbuf, BUFSIZ, " [D] Thread ID %u has stack at addr %08X with size %u \n", - (unsigned int) cur->tid, cur->stackaddr, cur->stacksize); - write(1, logbuf, ret); - } -#endif - - /* Unlock the mutex */ - start = (void *) cur->entry; - -#if __DEBUG_THREADS__ - e2dbg_output(" [*] BP MUTEX UNLOCKED [e2dbg_thread_start] \n"); -#endif - - e2dbg_mutex_unlock(&e2dbgworld.dbgbp); - - /* Call the real entry point */ - e2dbg_presence_reset(); - return ((*start)(param)); -} - - -/** - * Hook for pthread_create - * @param __threadp - * @param __attr - * @param __start_routine - * @param __arg - * @return - */ -#if defined(sun) -int pthread_create(pthread_t *__threadp, - const pthread_attr_t *__attr, - void * (*__start_routine)(void *), - void *__arg) -{ - int (*fct)(pthread_t *__threadp, - __const pthread_attr_t *__attr, - void *__start_routine, - void *__arg); -#else -int pthread_create (pthread_t *__restrict __threadp, - __const pthread_attr_t *__restrict __attr, - void *(*__start_routine) (void *), - void *__restrict __arg) -{ - int (*fct)(pthread_t *__restrict __threadp, - __const pthread_attr_t *__restrict __attr, - void *__start_routine, - void *__restrict __arg); -#endif - - e2dbgthread_t *new; - char *key; - int ret; - - NOPROFILER_IN(); - e2dbg_presence_set(); - - /* Do not allow to create a thread while another one is breaking */ - e2dbg_mutex_lock(&e2dbgworld.dbgbp); - -#if __DEBUG_THREADS__ - e2dbg_output(" [*] BP MUTEX LOCKED [pthread_create] \n"); -#endif - - fct = (void *) e2dbgworld.syms.pthreadcreate; - ret = (*fct)(__threadp, __attr, e2dbg_thread_start, __arg); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(e2dbgthread_t), -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,key, 15, -1); - snprintf(key, 15, "%u", *(unsigned int *) __threadp); - new->tid = *(pthread_t *) __threadp; - new->entry = __start_routine; - new->attr = __attr; - time(&new->stime); - hash_add(&e2dbgworld.threads, key, new); - - /* Unlock the thread mutex */ -#if __DEBUG_THREADS__ - e2dbg_output(" [*] BP MUTEX UNLOCKED [pthread_create] \n"); -#endif - - e2dbg_presence_reset(); - e2dbg_mutex_unlock(&e2dbgworld.dbgbp); - NOPROFILER_ROUT(ret); -} - - - -/** - * Hook for pthread_exit - * @param retval - * @return -*/ -void pthread_exit(void *retval) -{ - void (*fct)(void *retval); - - fct = (void *) e2dbgworld.syms.pthreadexit; - -#if __DEBUG_THREADS__ - printf(" [D] PTHREAD_EXIT ! Calling back original at %08X \n", (eresi_Addr) fct); -#endif - - e2dbgworld.threadnbr--; - (*fct)(retval); - while (1) - sleep(1); -} - - -/** - * Hook for signal - * @param signum - * @param fctptr - * @return - */ -/* -__sighandler_t signal(int signum, __sighandler_t fctptr) -{ - __sighandler_t (*fct)(int signum, __sighandler_t fctptr); - - fct = (void *) e2dbgworld.signal; - -#if __DEBUG_THREADS__ - printf(" [D] THREAD %u SIGNAL (SIGNUM %u) Calling back original at %08X \n", - (unsigned int) pthread_self(), signum, (eresi_Addr) fct); -#endif - - return ((*fct)(signum, fctptr)); -} -*/ - - - - -/** - * Print all threads state - */ -void e2dbg_threads_print() -{ - e2dbgthread_t *cur; - u_int index; - char logbuf[BUFSIZ]; - char *stime, *nl, *state, *entry; - char c; - char **keys; - int keynbr; - - keys = hash_get_keys(&e2dbgworld.threads, &keynbr); - - /* Iterate on the threads hash table */ - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.threads, keys[index]); - stime = ctime(&cur->stime); - nl = strchr(stime, '\n'); - if (nl) - *nl = 0x00; - c = (e2dbgworld.curthread == cur ? '*' : ' '); - switch (cur->state) - { - case E2DBG_THREAD_INIT: /* The thread has not started yet */ - state = "INIT"; - break; - case E2DBG_THREAD_STARTED: /* The thread has started */ - state = "STARTED"; - break; - case E2DBG_THREAD_BREAKING: /* The thread is processing a breakpoint */ - state = "BREAKING"; - break; - case E2DBG_THREAD_SIGUSR2: /* The thread is processing a SIGUSR2 */ - state = "SIGUSR2"; - break; - case E2DBG_THREAD_BREAKUSR2: /* The thread is beeing debugged */ - state = "POSTUSR2"; - break; - case E2DBG_THREAD_STOPPING: /* The thread is beeing stopped */ - state = "STOPPING"; - break; - case E2DBG_THREAD_RUNNING: /* The thread is running, been continued already */ - state = "RUNNING"; - break; - case E2DBG_THREAD_FINISHED: /* The thread is finished */ - state = "FINISHED"; - break; - default: - state = "UNKNOWN"; - } - entry = revm_resolve(world.curjob->curfile, (eresi_Addr) cur->entry, NULL); - snprintf(logbuf, BUFSIZ, - " Thread ID %10u %c %8s --[ started on %s from %s \n", - (unsigned int) cur->tid, c, state, stime, entry); - fprintf(stderr, logbuf); - //e2dbg_output(logbuf); - } - - if (index == 0) - e2dbg_output("\n [*] No threads in this process \n\n"); - else - e2dbg_output("\n"); -} - - -/** - * Switch on another thread and and Print all threads - * @return - */ -int cmd_threads() -{ - e2dbgthread_t *cur; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Change current working thread if passed a parameter */ - if (world.curjob->curcmd->param[0]) - { - - //snprintf(logbuf, BUFSIZ, "%lu", strtoul(world.curjob->curcmd->param[0])); - cur = hash_get(&e2dbgworld.threads, world.curjob->curcmd->param[0]); - if (!cur) - { - printf("Unknown thread -%s- \n", world.curjob->curcmd->param[0]); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown thread", (-1)); - } - - /* Save modified registers in curthread, and load the new registers set */ - e2dbg_setregs(); - e2dbgworld.curthread = cur; - e2dbg_getregs(); - snprintf(logbuf, BUFSIZ, " [*] Switched to thread %s \n\n", - world.curjob->curcmd->param[0]); - e2dbg_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Print all threads */ - e2dbg_threads_print(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Stop all threads when a breakpoint happens - * @param signum - * @return - */ -int e2dbg_thread_stopall(int signum) -{ - e2dbgthread_t *cur; - u_int index; - char **keys; - int keynbr; - char *sig; - int total; - int ret; - -#if __DEBUG_THREADS__ - u_int called = rand() % 1000; - - /* - printf(" [*] Stopping all user threads \n"); - printf("******** [%u] STOPALL (%u) threads [cur = %u [cnt = %u] dbg = %u ] ******* \n", - called, e2dbgworld.threadnbr, - (unsigned int) e2dbgworld.stoppedthread->tid, - e2dbgworld.curthread->count, e2dbg_getid()); - */ -#endif - - /* Iterate on the hash table of threads */ - sig = (signum == SIGUSR2 ? "SIGUSR2 to" : "Stopping"); - keys = hash_get_keys(&e2dbgworld.threads, &keynbr); - for (total = index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.threads, keys[index]); - - /* Do not get the context of initializing threads */ - if (cur->state == E2DBG_THREAD_INIT) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- %s thread ID %-10u (initializing) \n", - sig, (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->state == E2DBG_THREAD_BREAKING || cur->state == E2DBG_THREAD_STOPPING) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- %s thread ID %-10u (already done or breaking) \n", - sig, (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->state == E2DBG_THREAD_SIGUSR2 || cur->state == E2DBG_THREAD_BREAKUSR2) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- %s thread ID %-10u (inside sigusr2) \n", - sig, (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->initial) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- %s thread ID %-10u (initial) \n", - sig, (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->tid == e2dbgworld.stoppedthread->tid) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- %s thread ID %-10u (current) \n", - sig, (unsigned int) cur->tid); -#endif - continue; - } - -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [T] Sending %s to thread ID %-10u \n", - (signum == SIGUSR2 ? "SIGUSR2" : "SIGSTOP"), - (unsigned int) cur->tid); -#endif - - /* If we send a SIGUSR2, increment the number of contexts to get */ - /* In case the thread is already stopped, send a CONT signal first */ - total++; - if (signum == SIGUSR2) - e2dbgworld.threadgotnbr++; - else - cur->state = E2DBG_THREAD_STOPPING; - - ret = e2dbg_kill((int) cur->tid, signum); - if (ret) - fprintf(stderr, "e2dbg_kill returned value %d \n", ret); - } - - -#if __DEBUG_THREADS__ - //e2dbg_threads_print(); - //printf("--------- END OF STOPALL %u ------------ \n", called); -#endif - - return (total); -} - - - - - -/** - * Continue all threads after a breakpoint - */ -void e2dbg_thread_contall() -{ - e2dbgthread_t *cur; - char **keys; - int keynbr; - u_int index; - -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, " [*] Continuing all threads (current number of threads = %u) \n", - e2dbgworld.threadnbr); - e2dbg_threads_print(); -#endif - - keys = hash_get_keys(&e2dbgworld.threads, &keynbr); - - /* Wake up all other threads after */ - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&e2dbgworld.threads, keys[index]); - - /* Do not get the context of initializing threads */ - if (cur->state == E2DBG_THREAD_INIT) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- Continuing thread ID %-10u (initializing) \n", - (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->state == E2DBG_THREAD_SIGUSR2 || cur->state == E2DBG_THREAD_BREAKUSR2) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- Continuing thread ID %-10u (inside sigusr2) \n", - (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->state == E2DBG_THREAD_BREAKING) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- Continuing thread ID %-10u (current) \n", - (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->initial) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- Continuing thread ID %-10u (initial) \n", - (unsigned int) cur->tid); -#endif - continue; - } - - if (cur->tid == e2dbgworld.stoppedthread->tid) - { -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] -NOT- Continuing thread ID %-10u (stopping) \n", - (unsigned int) cur->tid); -#endif - continue; - } - -#if 1 //(__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, - " [*] Continuing thread ID %-10u \n", - (unsigned int) cur->tid); -#endif - - cur->state = E2DBG_THREAD_RUNNING; - e2dbg_kill((int) cur->tid, SIGCONT); - } - -#if (__DEBUG_THREADS__ || __DEBUG_BP__) - fprintf(stderr, " [*] End of thread continuations signal sending \n"); -#endif - -} - diff -Nru eresi-0.8a25/libe2dbg/user/threads.c eresi-0.0.20110516/libe2dbg/user/threads.c --- eresi-0.8a25/libe2dbg/user/threads.c 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libe2dbg/user/threads.c 2011-05-16 11:35:07.000000000 +0000 @@ -1,12 +1,16 @@ +/** +* @file libe2dbg/user/threads.c +** @ingroup user +*/ /* - * @file threads.c +* @file libe2dbg/user/threads.c * * Hook the threads API for keeping thread debugger information * accurately up2date * * Last Update Thu July 06 19:37:26 2006 mm * - * $Id: threads.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: threads.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libe2dbg.h" diff -Nru eresi-0.8a25/libedfmt/api.c eresi-0.0.20110516/libedfmt/api.c --- eresi-0.8a25/libedfmt/api.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/api.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,12 +1,10 @@ /** - * @file api.c +* @file libedfmt/api.c * @ingroup libedfmt - * api.c for libedfmt (The Elf debug format library of ELFsh) + * @brief Generic internal API for libedfmt. * * Started Jan 26 2007 11:54:22 mxatone - * - * $Id: api.c,v 1.15 2007-06-02 08:28:50 mxatone Exp $ - * + * $Id: api.c 1391 2009-09-07 08:04:38Z may */ #include "libedfmt.h" @@ -360,7 +358,7 @@ if (!file) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramter", NULL); + "Invalid parameter", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (edfmtinfo_t *) file->debug_format.uni); @@ -835,10 +833,51 @@ lvar->scope = EDFMT_SCOPE_GLOBAL; lvar->addr = addr; lvar->type = type; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lvar); } +hash_t *edfmt_hfuncs_get() +{ + if (uniinfo == NULL || uniinfo->lfile == NULL) + return (NULL); + return &(uniinfo->lfile->hfunc); + +} + +char *edfmt_srcline_get(char *buf, eresi_Addr addr) +{ + hash_t *htable; + int keynbr; + char **keys; + int index; + edfmtfunc_t *lfunc; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!uniinfo) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Global pointer uninitialise", NULL); + + /* Setup hash table depending of current scope */ + htable = API_GET_FROM_SCOPE(hfunc); + keys = hash_get_keys(htable, &keynbr); + buf = NULL; + if (keys) + { + for (index = 0; index < keynbr; index++) + { + lfunc = (edfmtfunc_t *) hash_get(htable, keys[index]); + if (lfunc->start <= addr && lfunc->end >= addr) + { + // FIXME: srcLine is an integer! need to open file and read line! + //buf = lfunc->srcLine; + buf = "READ FILE!"; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); + } + } + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); +} + /** * Create a function * @param name new function name @@ -848,12 +887,11 @@ * @return result function */ edfmtfunc_t *edfmt_add_func(char *name, edfmttype_t *ret, - eresi_Addr start, eresi_Addr end) + eresi_Addr start, eresi_Addr end, u_int srcLine) { edfmtfunc_t *lfunc; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name || !ret) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid paramters", NULL); @@ -862,6 +900,7 @@ lfunc->rettype = ret; lfunc->start = start; lfunc->end = end; + lfunc->srcLine = srcLine; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lfunc); } diff -Nru eresi-0.8a25/libedfmt/doc/.svn/all-wcprops eresi-0.0.20110516/libedfmt/doc/.svn/all-wcprops --- eresi-0.8a25/libedfmt/doc/.svn/all-wcprops 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/896/trunk/libedfmt/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/896/trunk/libedfmt/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libedfmt/doc/.svn/entries eresi-0.0.20110516/libedfmt/doc/.svn/entries --- eresi-0.8a25/libedfmt/doc/.svn/entries 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libedfmt/doc -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:31.866876Z -17b84fa27e17df27260fde88cc3c637d -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/libedfmt/doc/.svn/format eresi-0.0.20110516/libedfmt/doc/.svn/format --- eresi-0.8a25/libedfmt/doc/.svn/format 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libedfmt/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libedfmt/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libedfmt/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libedfmt - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./ include - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.h *.c - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libedfmt - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/libedfmt/dwarf2-abbrev.c eresi-0.0.20110516/libedfmt/dwarf2-abbrev.c --- eresi-0.8a25/libedfmt/dwarf2-abbrev.c 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/dwarf2-abbrev.c 2011-05-16 11:34:51.000000000 +0000 @@ -1,13 +1,11 @@ -/* -** @file dwarf2-abbrev.c +/** +* @file libedfmt/dwarf2-abbrev.c ** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-abbrev.c,v 1.14 2007-05-20 19:13:57 mxatone Exp $ +** @brief Abbreviation table access for DWARF2 debug format. ** +** Started Dec 26 2006 10:49:45 mxatone +** $Id: dwarf2-abbrev.c 1397 2009-09-13 02:19:08Z may $ */ - #include "libedfmt.h" char *alloc_pool = NULL; @@ -86,7 +84,7 @@ int edfmt_dwarf2_abbrev_enum_clean(hash_t *abbrev_table) { char **keys; - u_int index; + int index; int keynbr; u_long *value; @@ -275,7 +273,7 @@ char *ptr; u_char addr[10]; /* 10 should be enough */ u_int data; - long ddata; + long ddata; /* FIXME: this is not a 64b type...*/ NOPROFILER_IN(); @@ -632,7 +630,7 @@ spos++; break; case DW_OP_pick: - if (spos + buf[++i] < 0) + if (((int) spos + buf[++i]) < 0) break; stack[spos+1].op = stack[spos - buf[i]].op; @@ -663,7 +661,7 @@ stack[spos - 2].value = tmp_value; break; case DW_OP_abs: - if (stack[spos].value < 0) + if (((int) stack[spos].value) < 0) stack[spos].value = - stack[spos].value; break; case DW_OP_and: @@ -909,8 +907,9 @@ u_int basic_block; u_int end_sequence; u_long tmpf; - - u_int i, bsize; + int i; + u_int i2; + u_int bsize; u_char opc, ext_opc; char *read_addr; @@ -961,8 +960,8 @@ case DW_LNE_set_address: DW2_GETPTR(read_addr, current_cu->addr_size, -1); - for (i = 0; i < current_cu->addr_size; i++) - dwarf2_ipos(read_addr[i], line, u_char); + for (i2 = 0; i2 < current_cu->addr_size; i2++) + dwarf2_ipos(read_addr[i2], line, u_char); addr = *(eresi_Addr *) read_addr; break; diff -Nru eresi-0.8a25/libedfmt/dwarf2.c eresi-0.0.20110516/libedfmt/dwarf2.c --- eresi-0.8a25/libedfmt/dwarf2.c 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/dwarf2.c 2011-05-16 11:34:51.000000000 +0000 @@ -1,20 +1,18 @@ -/* -** @file dwarf2.c +/** +** @brief Implement DWARF2 support in libedfmt +* @file libedfmt/dwarf2.c ** @ingroup libedfmt ** ** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2.c,v 1.19 2007-05-20 19:13:57 mxatone Exp $ -** +** $Id: dwarf2.c 1399 2009-09-16 14:22:04Z eduardo $ */ #include "libedfmt.h" /** * This file implements DWARF2 support for libedfmt. - * specificitation @ http://dwarf.freestandards.org/Download.php - * @file dwarf2.c + * specification @ http://dwarf.freestandards.org/Download.php +* @file libedfmt/dwarf2.c */ #define DWARF2_ABBREV_NAME "dwarf2_abbrev_table" @@ -66,6 +64,8 @@ dw2_sections.info.sect = edfmt_get_sect(file, ELFSH_SECTION_DW2_INFO, ELFSH_SECTION_NAME_DW2_INFO, 0); +// char *edfmt_srcline_get(eresi_Addr address) + dw2_sections.info.data = dw2_sections.info.sect->data; if (dw2_sections.info.sect == NULL || dw2_sections.info.data == NULL) @@ -114,11 +114,14 @@ if (pointers[i]->sect != NULL) pointers[i]->data = pointers[i]->sect->data; } - + /* Start into the block entrie */ if (edfmt_dwarf2_block_entrie(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 block parsing failed", -1); + { + profiler_disable_err(); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "DWARF2 block parsing failed", -1); + } /* Parse cfa informations */ /* TODO: reimplement it when it will be usefull @@ -140,11 +143,14 @@ int edfmt_dwarf2_block_entrie(elfshobj_t *file) { edfmtdw2cu_t *tcu; + u_int nbr = 0; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); while (dwarf2_pos(info) < dwarf2_size(info)) { + nbr++; + /* Alloc a new compil unit */ XALLOC(__FILE__, __FUNCTION__, __LINE__,tcu, sizeof(edfmtdw2cu_t), -1); @@ -168,12 +174,18 @@ /* Read DWARF2 .dwarf2_info header */ dwarf2_ipos(current_cu->length, info, u_int); + + /* A compil unit bigger than the section ? */ + if (current_cu->length > dwarf2_size(info)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "DWARF2 compil unit size incorrect", -1); + current_cu->end_pos = dwarf2_pos(info) + current_cu->length; /* A compil unit bigger than the section ? */ if (current_cu->end_pos > dwarf2_size(info)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 compil unit size incorrect", -1); + "DWARF2 compil unit end position incorrect", -1); dwarf2_ipos(current_cu->version, info, u_short); @@ -197,14 +209,14 @@ dwarf2_pos(abbrev) = current_cu->offset; /* Loop on the current compil unit */ - if (edfmt_dwarf2_block_loop(current_cu->end_pos) < 0) + if (edfmt_dwarf2_block_loop() < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "DWARF2 block looping failed", -1); /* We update info position, to finish at the right offset */ dwarf2_pos(info) = current_cu->end_pos; } - + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -247,10 +259,10 @@ } /** - * Manage parsing loops. On the new layout thif function just fill abbrev hash table + * Manage parsing loops. On the new layout this function just fill abbrev hash table * @param endpos represent the end position to read on the current compile unit (deprecate) */ -int edfmt_dwarf2_block_loop(u_int endpos) +int edfmt_dwarf2_block_loop() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/libedfmt/dwarf2-cfa.c eresi-0.0.20110516/libedfmt/dwarf2-cfa.c --- eresi-0.8a25/libedfmt/dwarf2-cfa.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/dwarf2-cfa.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,11 +1,10 @@ -/* -** @file dwarf2-cfa.c +/** +* @file libedfmt/dwarf2-cfa.c ** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-cfa.c,v 1.7 2007-03-07 16:45:35 thor Exp $ +** @brief DWARF2 CFA data handling ** +** Started Dec 26 2006 10:49:45 mxatone +** $Id: dwarf2-cfa.c 1397 2009-09-13 02:19:08Z may $ */ #include "libedfmt.h" diff -Nru eresi-0.8a25/libedfmt/dwarf2-trans.c eresi-0.0.20110516/libedfmt/dwarf2-trans.c --- eresi-0.8a25/libedfmt/dwarf2-trans.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/dwarf2-trans.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,18 +1,17 @@ -/* -** @file dwarf2.c +/** +* @file libedfmt/dwarf2-trans.c ** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-trans.c,v 1.12 2007-08-25 17:13:05 mxatone Exp $ +** @brief Translation from DWARF2 to EDFMT format. ** +** Started Dec 26 2006 10:49:45 mxatone +** $Id: dwarf2-trans.c 1400 2009-09-28 01:55:54Z eduardo $ */ #include "libedfmt.h" /** * This file implements DWARF2 transformation - * @file dwarf2-trans.c +* @file libedfmt/dwarf2-trans.c */ #define DWARF2_HNAME_TRANS_TREF "dwarf2_trans_typeref" @@ -214,6 +213,8 @@ int fileid, inc = 0, addtype = 1, base = 0, op = 0; edfmtfunc_t *func; + u_int srcLine = 0; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!abbrev) @@ -239,10 +240,10 @@ */ if (abbrev->tag != DW_TAG_compile_unit) { - DWARF2_TRANS_GETATTR(fileid, abbrev, DW_AT_decl_file, u.udata, -1); + // DWARF2_TRANS_GETATTR(fileid, abbrev, DW_AT_decl_file, u.udata, -1); inc = 1; - if (fileid > 0 && fileid < current_cu->files_number) + if (fileid > 0 && fileid < (int) current_cu->files_number) { fileid--; pstr = current_cu->dirs[current_cu->files_dindex[fileid] - 1]; @@ -273,7 +274,7 @@ edfmt_reset_file(); } } - + // printf("edfmt_dwarf2_transform_abbrev_parse in dwarf2-trans.c\n"); /** * A TAG represent an element of the dwarf2 format, each TAG are linked by child / parent * alike structure. You can get more information on the dwarf2 documentation @@ -318,7 +319,6 @@ break; DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - type = edfmt_dwarf2_trans_gettype(iref); if (!type) @@ -474,8 +474,11 @@ low = *(eresi_Addr *) vbuf; DWARF2_TRANS_GETATTR(vbuf, abbrev, DW_AT_high_pc, u.vbuf, 0); if (vbuf) + high = *(eresi_Addr *) vbuf; - + + DWARF2_TRANS_GETATTR(srcLine, abbrev, DW_AT_decl_line, u.udata, 0); + /* Resolve return type */ DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); type = edfmt_dwarf2_trans_gettype(iref); @@ -484,7 +487,8 @@ break; /* Transform the function */ - func = edfmt_add_func(str, type, low, high); + //func = edfmt_add_func(str, type, low, high, linhaTeste); + func = edfmt_add_func(str, type, low, high, srcLine); if (func) { diff -Nru eresi-0.8a25/libedfmt/dwarf2-utils.c eresi-0.0.20110516/libedfmt/dwarf2-utils.c --- eresi-0.8a25/libedfmt/dwarf2-utils.c 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/dwarf2-utils.c 2011-05-16 11:34:51.000000000 +0000 @@ -1,10 +1,10 @@ -/* -** @file dwarf2-utils.c +/** +* @file libedfmt/dwarf2-utils.c ** @ingroup libedfmt ** Started Dec 26 2006 10:49:45 mxatone ** ** -** $Id: dwarf2-utils.c,v 1.7 2007-03-07 16:45:35 thor Exp $ +** $Id: dwarf2-utils.c 1397 2009-09-13 02:19:08Z may $ ** */ @@ -52,7 +52,7 @@ long sum = 0; u_int read = 0; u_char c; - int s = 0; + u_int s = 0; NOPROFILER_IN(); @@ -64,7 +64,7 @@ s += 7; } while ((c & 128) != 0); - if ((s < 8 * sizeof(sum)) && (c & 0x40)) + if ((s < (8 * sizeof(sum))) && (c & 0x40)) sum |= -(((long)1) << s); if (bread) diff -Nru eresi-0.8a25/libedfmt/edfmt.c eresi-0.0.20110516/libedfmt/edfmt.c --- eresi-0.8a25/libedfmt/edfmt.c 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/edfmt.c 2011-05-16 11:34:51.000000000 +0000 @@ -1,12 +1,10 @@ -/* -** @file edfmt.c +/** +* @file libedfmt/edfmt.c ** @ingroup libedfmt +** @brief External interface functions for the ERESI debug format ** ** Started Dec 25 2006 15:41:35 mxatone -** -** -** $Id: edfmt.c,v 1.14 2007-11-30 10:13:54 may Exp $ -** +** $Id: edfmt.c 1399 2009-09-16 14:22:04Z eduardo $ */ #include "libedfmt.h" @@ -74,21 +72,22 @@ /* The internal basename function */ static char *edfmt_basename(char *str) { - char *cur; - char *ret; + volatile char *cur; + volatile char *ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); ret = NULL; cur = str; - while ((cur = strchr(cur, '/'))) + while ((cur = strchr((char *) cur, '/'))) if (!*(cur + 1)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No basename", (NULL)); else ret = ++cur; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (char *) (ret)); } + /** * Main point of the debug format library * This function manages this steps for every debugging formats: @@ -100,7 +99,7 @@ int edfmt_format(elfshobj_t *file) { u_int i; - elfshsect_t *sect = NULL; + volatile elfshsect_t *sect = NULL; u_int count = 0; char *base; @@ -120,8 +119,8 @@ /* We won't analyze libe2dbg library because, there's far too many information in this library, which allocate too much memory */ - if (!strcmp(base, "libe2dbg32.so") - || !strcmp(base, "libe2dbg64.so")) + if (!strcmp(base, "libe2dbg32.so") || + !strcmp(base, "libe2dbg64.so")) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "We don't analyze e2dbg library", -1); } @@ -136,8 +135,7 @@ if (sect != NULL && debug_format[i].func != NULL) { /* Parse */ - if (debug_format[i].func) - debug_format[i].func(file); + debug_format[i].func(file); /* Transform */ if (debug_format[i].trans) diff -Nru eresi-0.8a25/libedfmt/edfmt-utils.c eresi-0.0.20110516/libedfmt/edfmt-utils.c --- eresi-0.8a25/libedfmt/edfmt-utils.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/edfmt-utils.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,12 +1,9 @@ -/* -** @file edfmt-utils.c +/** +* @file libedfmt/edfmt-utils.c ** @ingroup libedfmt ** ** Started Jan 13 2007 18:09:02 mxatone -** -** -** $Id: edfmt-utils.c,v 1.11 2007-07-17 18:11:24 may Exp $ -** +** $Id: edfmt-utils.c 1397 2009-09-13 02:19:08Z may $ */ #include "libedfmt.h" diff -Nru eresi-0.8a25/libedfmt/include/libedfmt-api.h eresi-0.0.20110516/libedfmt/include/libedfmt-api.h --- eresi-0.8a25/libedfmt/include/libedfmt-api.h 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/libedfmt-api.h 2011-05-16 11:34:51.000000000 +0000 @@ -4,7 +4,7 @@ ** Started Fev 02 2006 09:53:25 mxatone ** ** -** $Id: libedfmt-api.h,v 1.11 2007-06-02 08:28:51 mxatone Exp $ +** $Id: libedfmt-api.h 1440 2010-12-29 02:22:03Z may $ ** */ @@ -90,6 +90,7 @@ eresi_Addr end; /* End address */ struct s_efunc *next; + u_int srcLine; } edfmtfunc_t; diff -Nru eresi-0.8a25/libedfmt/include/libedfmt-dwarf2.h eresi-0.0.20110516/libedfmt/include/libedfmt-dwarf2.h --- eresi-0.8a25/libedfmt/include/libedfmt-dwarf2.h 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/libedfmt-dwarf2.h 2011-05-16 11:34:51.000000000 +0000 @@ -4,7 +4,7 @@ ** Started on Mon Dec 25 18:08:03 2006 mxatone ** ** -** $Id: libedfmt-dwarf2.h,v 1.14 2007-07-19 15:20:15 mxatone Exp $ +** $Id: libedfmt-dwarf2.h 1384 2009-09-04 10:23:51Z may $ ** */ @@ -60,9 +60,9 @@ union { char *vbuf; /* DW_FORM_ref_addr, DW_FORM_addr, DW_FORM_block[1-4], DW_FORM_block */ - u_long udata; /* DW_FORM_udata, DW_FORM_data[1-4], DW_FORM_flag, DW_FORM_data8 + int64_t udata; /* DW_FORM_udata, DW_FORM_data[1-4], DW_FORM_flag, DW_FORM_data8 DW_FORM_ref[1-8], DW_FORM_ref_udata */ - long sdata; /* DW_FORM_sdata */ + uint64_t sdata; /* DW_FORM_sdata */ char *str; /* DW_FORM_string, DW_FORM_strp */ } u; @@ -260,17 +260,28 @@ #define dwarf2_a_pos(name) (dwarf2_data(name) + dwarf2_pos(name)) #define dwarf2_ac_pos(name) (char *) dwarf2_a_pos(name) +/* For big-endian targets */ #define dwarf2_get_1(val) (val[0]) #define dwarf2_get_2(val) (val[0] | (val[1] << 8)) #define dwarf2_get_4(val) (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24)) #define dwarf2_get_8(val) (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24) \ | (val[4] << 32) | (val[5] << 40) | (val[6] << 48) | (val[7] << 56)) +#define dwarf2_get_pos_be(val, name, type) \ + val = (type) (sizeof(type) == 1 ? dwarf2_get_1(dwarf2_a_pos(name)) \ + : (sizeof(type) == 2 ? dwarf2_get_2(dwarf2_a_pos(name)) \ + : (sizeof(type) == 4 ? dwarf2_get_4(dwarf2_a_pos(name)) \ + : (sizeof(type) == 8 ? dwarf2_get_8((int64_t)dwarf2_a_pos(name)) : 0)))) + +/* Little endian targets */ +#define dwarf2_get_pos_le(val, name, type) val = *(type *) dwarf2_a_pos(name) + +/* Top level macro */ #define dwarf2_get_pos(val, name, type) \ -val = (type) (sizeof(type) == 1 ? dwarf2_get_1(dwarf2_a_pos(name)) \ - : (sizeof(type) == 2 ? dwarf2_get_2(dwarf2_a_pos(name)) \ - : (sizeof(type) == 4 ? dwarf2_get_4(dwarf2_a_pos(name)) \ - : (sizeof(type) == 8 ? dwarf2_get_8(dwarf2_a_pos(name)) : 0 )))) + if (elfsh_get_encoding(dwarf2_info->cu_list->fileobj->hdr) == ELFDATA2LSB) \ + dwarf2_get_pos_le(val, name, type); \ + else \ + dwarf2_get_pos_be(val, name, type) #define dwarf2_inc_pos(name, value) \ do { \ @@ -285,22 +296,22 @@ #define dwarf2_read_1(val, name) \ do { \ - dwarf2_get_pos(val, name, char); \ + dwarf2_get_pos(val, name, uint8_t); \ } while(0) #define dwarf2_read_2(val, name) \ do { \ - dwarf2_get_pos(val, name, short); \ + dwarf2_get_pos(val, name, uint16_t); \ } while(0) #define dwarf2_read_4(val, name) \ do { \ - dwarf2_get_pos(val, name, int); \ + dwarf2_get_pos(val, name, uint32_t); \ } while(0) #define dwarf2_read_8(val, name) \ do { \ - dwarf2_get_pos(val, name, long); \ + dwarf2_get_pos(val, name, uint64_t); \ } while(0) #define dwarf2_iread_1(val, name) \ diff -Nru eresi-0.8a25/libedfmt/include/libedfmt.h eresi-0.0.20110516/libedfmt/include/libedfmt.h --- eresi-0.8a25/libedfmt/include/libedfmt.h 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/libedfmt.h 2011-05-16 11:34:51.000000000 +0000 @@ -4,7 +4,7 @@ ** Started Dec 25 2006 15:41:35 mxatone ** ** -** $Id: libedfmt.h,v 1.16 2007-03-07 16:45:35 thor Exp $ +** $Id: libedfmt.h 1399 2009-09-16 14:22:04Z eduardo $ ** */ @@ -74,7 +74,7 @@ edfmtvar_t *edfmt_add_var_global(edfmttype_t *type, char *name, eresi_Addr addr); edfmtfunc_t *edfmt_add_func(char *name, edfmttype_t *ret, - eresi_Addr start, eresi_Addr end); + eresi_Addr start, eresi_Addr end, u_int srcLine); edfmtfuncarg_t *edfmt_add_arg(edfmtfunc_t *func, char *name, u_int reg, int pos, edfmttype_t *type); edfmttype_t *edfmt_check_type(char *name); @@ -113,7 +113,7 @@ int edfmt_dwarf2_parse(elfshobj_t *file); int edfmt_dwarf2_clean(elfshobj_t *file); int edfmt_dwarf2_block_entrie(elfshobj_t *file); -int edfmt_dwarf2_block_loop(u_int endpos); +int edfmt_dwarf2_block_loop(); int edfmt_dwarf2_build_tree(edfmtdw2abbent_t *parent, edfmtdw2abbent_t *fent, edfmtdw2abbent_t *ref); diff -Nru eresi-0.8a25/libedfmt/include/libedfmt-stabs.h eresi-0.0.20110516/libedfmt/include/libedfmt-stabs.h --- eresi-0.8a25/libedfmt/include/libedfmt-stabs.h 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/libedfmt-stabs.h 2011-05-16 11:34:51.000000000 +0000 @@ -4,7 +4,7 @@ ** Started Sat 13 2006 09:52:12 mxatone ** ** -** $Id: libedfmt-stabs.h,v 1.9 2007-08-17 01:45:46 heroine Exp $ +** $Id: libedfmt-stabs.h 1311 2009-01-14 20:36:48Z may $ ** */ @@ -17,8 +17,7 @@ #define STABS_FILE_IT 20 /* Some define shortcut */ -#define STABS_IVD_STR(_str) \ -(!_str || !*_str || !**_str) +#define STABS_IVD_STR(_str) (!*_str || !**_str) #define stabs_c_ent \ stabs_ent[stabs_index] diff -Nru eresi-0.8a25/libedfmt/include/.svn/all-wcprops eresi-0.0.20110516/libedfmt/include/.svn/all-wcprops --- eresi-0.8a25/libedfmt/include/.svn/all-wcprops 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libedfmt/include -END -libedfmt-dwarf2.h -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/946/trunk/libedfmt/include/libedfmt-dwarf2.h -END -libedfmt-api.h -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/946/trunk/libedfmt/include/libedfmt-api.h -END -libedfmt-stabs.h -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/946/trunk/libedfmt/include/libedfmt-stabs.h -END -libedfmt.h -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libedfmt/include/libedfmt.h -END diff -Nru eresi-0.8a25/libedfmt/include/.svn/entries eresi-0.0.20110516/libedfmt/include/.svn/entries --- eresi-0.8a25/libedfmt/include/.svn/entries 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libedfmt/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libedfmt-dwarf2.h -file - - - - -2008-04-06T23:15:30.842509Z -d5d2ecfe38f3885c2b0f437ce0b70f22 -2008-03-27T22:53:48.747992Z -946 -may - -libedfmt-api.h -file - - - - -2008-04-06T23:15:31.638877Z -8c92cb5475d1d248d395705d01556990 -2008-03-27T22:53:48.747992Z -946 -may - -libedfmt-stabs.h -file - - - - -2008-04-06T23:15:31.749880Z -281f9973fdce9714a8b7ef6b5b6f97e6 -2008-03-27T22:53:48.747992Z -946 -may - -libedfmt.h -file - - - - -2008-04-06T23:15:31.760905Z -8f47a6ac368eb1a2ea3a6b814ffe7c29 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libedfmt/include/.svn/format eresi-0.0.20110516/libedfmt/include/.svn/format --- eresi-0.8a25/libedfmt/include/.svn/format 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-api.h.svn-base eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-api.h.svn-base --- eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-api.h.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-api.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -/* -** libedfmt-api.h for libedfmt (The Elf debug format library of ELFsh) -** -** Started Fev 02 2006 09:53:25 mxatone -** -** -** $Id: libedfmt-api.h,v 1.11 2007-06-02 08:28:51 mxatone Exp $ -** -*/ - -#ifndef __LIBEDFMT_API_H__ -#define __LIBEDFMT_API_H__ - -#define EDFMT_NAME_SIZE 256 - -/* Declare structures needed */ -struct s_efile; -typedef struct s_efile edfmtfile_t; - -typedef struct s_etype -{ - char name[EDFMT_NAME_SIZE]; - -#define EDFMT_TYPE_UNK 0 /* Unknown type */ -#define EDFMT_TYPE_BASIC 1 /* Basic type like: int, char, long ...*/ -#define EDFMT_TYPE_ARRAY 2 /* Array with size and parent type */ -#define EDFMT_TYPE_PTR 3 /* Pointer type, that point to a parent type */ -#define EDFMT_TYPE_STRUCT 4 /* Structure type with childs */ -#define EDFMT_TYPE_UNION 5 /* Union type with childs */ -#define EDFMT_TYPE_ATTR 6 /* Structure attribute */ -#define EDFMT_TYPE_VOID 7 /* Void pointer */ -#define EDFMT_TYPE_LINK 8 /* Link type using parent */ - u_char type; - - int start; - int tmp_ssize; /* Temporary structure size */ - int size; - - /* Flags */ - u_char valid; - u_char parsed; - - struct s_etype *parent; /* Used in structure attribute, array and pointer */ - struct s_etype *child; /* Used in structure and attribute */ - struct s_etype *next; /* Next element on a list */ - - edfmtfile_t *file; /* Point to my file */ -} edfmttype_t; - -typedef struct s_evar -{ - char name[EDFMT_NAME_SIZE]; - -#define EDFMT_SCOPE_UNK 0 -#define EDFMT_SCOPE_GLOBAL 1 -#define EDFMT_SCOPE_FUNC 2 - u_char scope; - - eresi_Addr addr; /* Global address */ - u_int reg; /* Func reg base */ - int stackpos; /* Func stack position */ - - edfmttype_t *type; - - struct s_evar *next; -} edfmtvar_t; - -typedef struct s_efunc_arg -{ - char name[EDFMT_NAME_SIZE]; - - u_int reg; /* Reg base */ - int pos; /* Reg or stack position */ - - edfmttype_t *type; /* Argument type */ - - struct s_efunc_arg *next; -} edfmtfuncarg_t; - -typedef struct s_efunc -{ - char name[EDFMT_NAME_SIZE]; - - int argc; /* Argument number */ - edfmtfuncarg_t *arguments; /* Argument list */ - - edfmttype_t *rettype; /* Return type */ - - eresi_Addr start; /* Start address */ - eresi_Addr end; /* End address */ - - struct s_efunc *next; -} edfmtfunc_t; - - -struct s_efile -{ - char name[EDFMT_NAME_SIZE]; - - eresi_Addr start; /* Start address */ - eresi_Addr end; /* End address */ - - /* Types */ - edfmttype_t *types; - edfmttype_t *ltype; - hash_t htype; - - /* Variables */ - edfmtvar_t *vars; - edfmtvar_t *lvar; - hash_t hvar; - - /* Functions */ - edfmtfunc_t *funcs; - edfmtfunc_t *lfunc; - hash_t hfunc; - - struct s_efile *next; - - /* Intra file dependences */ - struct s_efile *parent; - struct s_efile *child; - struct s_efile *lchild; -}; - -typedef struct s_einfo -{ - /* File list */ - edfmtfile_t *files; - edfmtfile_t *lfile; - - /* Types */ - edfmttype_t *types; - edfmttype_t *ltype; - hash_t htype; - - /* Variables */ - edfmtvar_t *vars; - edfmtvar_t *lvar; - hash_t hvar; - - /* Function */ - edfmtfunc_t *funcs; - edfmtfunc_t *lfunc; - hash_t hfunc; - - /* Allocated pool */ - char *alloc_pool; - int alloc_pos; - int alloc_size; -} edfmtinfo_t; - -#define HASH_ADDX(_table, _name, _value) \ -do { \ - if (hash_get(_table, _name) != NULL) \ - hash_set(_table, _name, (void *) _value); \ - else \ - hash_add(_table, strdup(_name), (void *) _value); \ -} while (0) - -#endif diff -Nru eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-dwarf2.h.svn-base eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-dwarf2.h.svn-base --- eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-dwarf2.h.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-dwarf2.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1019 +0,0 @@ -/* -** libedfmt-dwarf2.h for libedfmt (The Elf debug format library of ELFsh) -** -** Started on Mon Dec 25 18:08:03 2006 mxatone -** -** -** $Id: libedfmt-dwarf2.h,v 1.14 2007-07-19 15:20:15 mxatone Exp $ -** -*/ - -#ifndef __DWARF_2_H__ -#define __DWARF_2_H__ - -#define DW2_MACRON_SIZE 50 - -/* Structures */ -typedef struct s_dw2sect -{ - elfshsect_t *sect; - void *data; - u_long pos; // Position -} edfmtdw2sect_t; - -/* Every DWARF2 section is kept on this structure */ -typedef struct s_dw2sectlist -{ - edfmtdw2sect_t info; - edfmtdw2sect_t abbrev; - edfmtdw2sect_t aranges; - edfmtdw2sect_t frame; - edfmtdw2sect_t line; - edfmtdw2sect_t macinfo; - edfmtdw2sect_t pubnames; - edfmtdw2sect_t str; - edfmtdw2sect_t loc; -} edfmtdw2sectlist_t; - -/* Forward declaration */ -struct s_dw2abbent; -typedef struct s_dw2abbent edfmtdw2abbent_t; -struct s_dw2cu; -typedef struct s_dw2cu edfmtdw2cu_t; - -/* Descripbe a location */ -typedef struct s_dw2loc -{ - u_int op; - eresi_Addr value; -} edfmtdw2loc_t; - -/* Describe an abbrev attribute */ -typedef struct s_dw2abbattr -{ - u_int attr; - u_int form; - u_long asize; - u_long infopos; - - /* Form value */ - union - { - char *vbuf; /* DW_FORM_ref_addr, DW_FORM_addr, DW_FORM_block[1-4], DW_FORM_block */ - u_long udata; /* DW_FORM_udata, DW_FORM_data[1-4], DW_FORM_flag, DW_FORM_data8 - DW_FORM_ref[1-8], DW_FORM_ref_udata */ - long sdata; /* DW_FORM_sdata */ - char *str; /* DW_FORM_string, DW_FORM_strp */ - } u; - - edfmtdw2loc_t loc; /* DW_AT_location */ -} edfmtdw2abbattr_t; - -/* Describe an abbrev entitie */ -struct s_dw2abbent -{ - u_int key; /* Key that represent the element */ - char ckey[EDFMT_CKEY_SIZE]; /* String representation for hash table */ - u_int tag; /* A type (sort of) of this element */ - u_char children; /* Do we have children ? */ - u_int level; /* Children lvel */ - -#define DW2_MAX_ATTR 50 - edfmtdw2abbattr_t attr[DW2_MAX_ATTR]; /* List of attributes */ - u_int attrsize; /* Current attribute size */ - - u_int sib; /* Next position */ - u_int child; /* Child position */ -}; - -/** - * XXX: Use when it will be usefull - * Describe a macro - */ -typedef struct s_dw2macro -{ - u_char def; - int fileno; - int line; - char name[DW2_MACRON_SIZE]; - char *str; - - struct s_dw2macro *next; -} edfmtdw2macro_t; - -/** - * XXX: Use when it will be usefull - * A column description - */ -typedef struct s_dw2cfareg -{ -#define DW2_CFA_T_UNDEF 0 -#define DW2_CFA_T_SAME 1 -#define DW2_CFA_T_OFFSET 2 -#define DW2_CFA_T_REG 3 -#define DW2_CFA_T_ARCH 4 - int type; - union { - eresi_Addr offset; - int reg; - } u; -} edfmtdw2cfareg_t; - -/** - * XXX: Use when it will be usefull - * A givent state - */ -typedef struct s_dw2cfastate -{ - eresi_Addr addr; - char caddr[EDFMT_CADDR_SIZE]; - - int cfa_reg; - eresi_Addr cfa_offset; - -#define DW2_CFA_MAX_REG 16 -#define CFA_C_REG(_a) (DW2_CFA_MAX_REG > _a) - edfmtdw2cfareg_t reg[DW2_CFA_MAX_REG]; - - struct s_dw2cfastate *next; -} edfmtdw2cfastate_t; - -/** - * XXX: Use when it will be usefull - * Cfa section header representation - */ -typedef struct s_dw2cfahead -{ - u_int offset; - u_int init_offset; - u_int end_offset; - u_int length; - u_int cid; - u_int version; - char *augmentation; - u_long code_align_factor; - long data_align_factor; - u_int return_addr_reg; - - edfmtdw2cfastate_t init; -} edfmtdw2cfahead_t; - -/** - * XXX: Use when it will be usefull - * Line section header representation - */ -typedef struct s_dw2linehead -{ - /* Header informations */ - u_int total_length; - u_short version; - u_int prologue_length; - u_int min_length_instr; - u_int default_stmt; - int line_base; - u_int line_range; - u_int opcode_base; - char *std_opcode_length; - - char **dirs; - char **files_name; - u_int *files_dindex; - u_int *files_time; - u_int *files_len; - - u_int dirs_number; - u_int files_number; - - /* Deducted positions */ - u_long end_pos; - u_long prologue_pos; -} edfmtdw2linehead_t; - -/** - * XXX: Use when it will be usefull - * Describe a line information - */ -typedef struct s_dw2line -{ - /* Main informations */ - eresi_Addr addr; - u_int line; - u_int column; - - /* References */ - edfmtdw2cu_t *cu; - u_int fileid; - - struct s_dw2line *next; -} edfmtdw2line_t; - -/** - * Describe a compil unit - */ -struct s_dw2cu -{ - /* Header informations */ - u_int length; /* Compile unit length without this entry */ - u_int version; /* DWARF2 version */ - u_int offset; /* Abbrev offset */ - u_int addr_size; /* Address size on this compile unit */ - u_int start_pos; /* Start position of the compile unit (before the header) */ - u_int end_pos; /* End position of the compile unit */ - u_int info_pos; /* Right after the header */ - - /* Designed file */ - elfshobj_t *fileobj; - - /* Store abbrev table informations */ - hash_t abbrev_table; - - /* Files informations */ - char **dirs; - char **files_name; - u_int *files_dindex; - u_int *files_time; - u_int *files_len; - u_long files_number; - - struct s_dw2cu *next; -}; - -/** - * Main structure of dwarf2 - */ -typedef struct s_dw2info -{ - edfmtdw2cu_t *cu_list; /* Compile unit list */ - edfmtdw2sectlist_t sections; /* Section pointers & informations */ -} edfmtdw2info_t; - -/* Variables */ -extern edfmtdw2info_t *dwarf2_info; - -/* References */ -extern edfmtdw2cu_t *current_cu; - -/* I/O management */ -#define dwarf2_pos(name) dwarf2_info->sections.name.pos -#define dwarf2_size(name) dwarf2_info->sections.name.sect->shdr->sh_size -#define dwarf2_data(name) ((char *)dwarf2_info->sections.name.data) -#define dwarf2_a_pos(name) (dwarf2_data(name) + dwarf2_pos(name)) -#define dwarf2_ac_pos(name) (char *) dwarf2_a_pos(name) - -#define dwarf2_get_1(val) (val[0]) -#define dwarf2_get_2(val) (val[0] | (val[1] << 8)) -#define dwarf2_get_4(val) (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24)) -#define dwarf2_get_8(val) (val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24) \ - | (val[4] << 32) | (val[5] << 40) | (val[6] << 48) | (val[7] << 56)) - -#define dwarf2_get_pos(val, name, type) \ -val = (type) (sizeof(type) == 1 ? dwarf2_get_1(dwarf2_a_pos(name)) \ - : (sizeof(type) == 2 ? dwarf2_get_2(dwarf2_a_pos(name)) \ - : (sizeof(type) == 4 ? dwarf2_get_4(dwarf2_a_pos(name)) \ - : (sizeof(type) == 8 ? dwarf2_get_8(dwarf2_a_pos(name)) : 0 )))) - -#define dwarf2_inc_pos(name, value) \ -do { \ - dwarf2_info->sections.name.pos += value; \ -} while(0) - -#define dwarf2_ipos(val, name, type) \ -do { \ - dwarf2_get_pos(val, name, type); \ - dwarf2_inc_pos(name, sizeof(type)); \ -} while(0) - -#define dwarf2_read_1(val, name) \ -do { \ - dwarf2_get_pos(val, name, char); \ -} while(0) - -#define dwarf2_read_2(val, name) \ -do { \ - dwarf2_get_pos(val, name, short); \ -} while(0) - -#define dwarf2_read_4(val, name) \ -do { \ - dwarf2_get_pos(val, name, int); \ -} while(0) - -#define dwarf2_read_8(val, name) \ -do { \ - dwarf2_get_pos(val, name, long); \ -} while(0) - -#define dwarf2_iread_1(val, name) \ -do { \ - dwarf2_read_1(val, name); \ - dwarf2_inc_pos(name, 1); \ -} while(0) - -#define dwarf2_iread_2(val, name) \ -do { \ - dwarf2_read_2(val, name); \ - dwarf2_inc_pos(name, 2); \ -} while(0) - -#define dwarf2_iread_4(val, name) \ -do { \ - dwarf2_read_4(val, name); \ - dwarf2_inc_pos(name, 4); \ -} while(0) - -#define dwarf2_iread_8(val, name) \ -do { \ - dwarf2_read_8(val, name); \ - dwarf2_inc_pos(name, 8); \ -} while(0) - -#define dwarf2_iuleb128(val, name) \ -do { \ - u_int bsize; \ - val = edfmt_read_uleb128(dwarf2_a_pos(name), &bsize); \ - dwarf2_inc_pos(name, bsize); \ -} while (0) - -#define dwarf2_ileb128(val, name) \ -do { \ - u_int bsize; \ - val = edfmt_read_leb128(dwarf2_a_pos(name), &bsize); \ - dwarf2_inc_pos(name, bsize); \ -} while (0) - -#define dwarf2_uleb128(val, name) \ -do { \ - u_int bsize; \ - val = edfmt_read_uleb128(dwarf2_a_pos(name), &bsize); \ -} while (0) - -#define dwarf2_leb128(val, name) \ -do { \ - u_int bsize; \ - val = edfmt_read_leb128(dwarf2_a_pos(name), &bsize); \ -} while (0) - -#define dwarf2_istr(val, name) \ -do { \ - val = dwarf2_ac_pos(name); \ - dwarf2_inc_pos(name, strlen(val)+1); \ -} while (0) - -/* Transformation management */ -#define DWARF2_TRANS_GETATTR(_out, _in, _type, _param, _default) \ -do { \ - edfmtdw2abbattr_t *attr; \ - _out = _default; \ - attr = edfmt_dwarf2_getattr(_in, _type); \ - if (attr) \ - _out = attr->_param; \ -} while (0) - -/* Most of this enums are from gdb 6.4 dwarf 2 header - you can see dwarf 2 documentation for more information */ - -#define DW_CHILDREN_no 0 -#define DW_CHILDREN_yes 1 - -/* Tags */ -enum dwarf2_tag - { - DW_TAG_padding = 0x00, - DW_TAG_array_type = 0x01, - DW_TAG_class_type = 0x02, - DW_TAG_entry_point = 0x03, - DW_TAG_enumeration_type = 0x04, - DW_TAG_formal_parameter = 0x05, - DW_TAG_imported_declaration = 0x08, - DW_TAG_label = 0x0a, - DW_TAG_lexical_block = 0x0b, - DW_TAG_member = 0x0d, - DW_TAG_pointer_type = 0x0f, - DW_TAG_reference_type = 0x10, - DW_TAG_compile_unit = 0x11, - DW_TAG_string_type = 0x12, - DW_TAG_structure_type = 0x13, - DW_TAG_subroutine_type = 0x15, - DW_TAG_typedef = 0x16, - DW_TAG_union_type = 0x17, - DW_TAG_unspecified_parameters = 0x18, - DW_TAG_variant = 0x19, - DW_TAG_common_block = 0x1a, - DW_TAG_common_inclusion = 0x1b, - DW_TAG_inheritance = 0x1c, - DW_TAG_inlined_subroutine = 0x1d, - DW_TAG_module = 0x1e, - DW_TAG_ptr_to_member_type = 0x1f, - DW_TAG_set_type = 0x20, - DW_TAG_subrange_type = 0x21, - DW_TAG_with_stmt = 0x22, - DW_TAG_access_declaration = 0x23, - DW_TAG_base_type = 0x24, - DW_TAG_catch_block = 0x25, - DW_TAG_const_type = 0x26, - DW_TAG_constant = 0x27, - DW_TAG_enumerator = 0x28, - DW_TAG_file_type = 0x29, - DW_TAG_friend = 0x2a, - DW_TAG_namelist = 0x2b, - DW_TAG_namelist_item = 0x2c, - DW_TAG_packed_type = 0x2d, - DW_TAG_subprogram = 0x2e, - DW_TAG_template_type_param = 0x2f, - DW_TAG_template_value_param = 0x30, - DW_TAG_thrown_type = 0x31, - DW_TAG_try_block = 0x32, - DW_TAG_variant_part = 0x33, - DW_TAG_variable = 0x34, - DW_TAG_volatile_type = 0x35, - /* DWARF 3. */ - DW_TAG_dwarf_procedure = 0x36, - DW_TAG_restrict_type = 0x37, - DW_TAG_interface_type = 0x38, - DW_TAG_namespace = 0x39, - DW_TAG_imported_module = 0x3a, - DW_TAG_unspecified_type = 0x3b, - DW_TAG_partial_unit = 0x3c, - DW_TAG_imported_unit = 0x3d, - /* SGI/MIPS Extensions. */ - DW_TAG_MIPS_loop = 0x4081, - /* HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . */ - DW_TAG_HP_array_descriptor = 0x4090, - /* GNU extensions. */ - DW_TAG_format_label = 0x4101, /* For FORTRAN 77 and Fortran 90. */ - DW_TAG_function_template = 0x4102, /* For C++. */ - DW_TAG_class_template = 0x4103, /* For C++. */ - DW_TAG_GNU_BINCL = 0x4104, - DW_TAG_GNU_EINCL = 0x4105, - /* Extensions for UPC. See: http://upc.gwu.edu/~upc. */ - DW_TAG_upc_shared_type = 0x8765, - DW_TAG_upc_strict_type = 0x8766, - DW_TAG_upc_relaxed_type = 0x8767, - /* PGI (STMicroelectronics) extensions. No documentation available. */ - DW_TAG_PGI_kanji_type = 0xA000, - DW_TAG_PGI_interface_block = 0xA020 - }; - -#define DW_TAG_lo_user 0x4080 -#define DW_TAG_hi_user 0xffff - -/* Childs */ -#define DW_children_no 0 -#define DW_children_yes 1 - -/* Forms */ -enum dwarf2_form - { - DW_FORM_addr = 0x01, - DW_FORM_block2 = 0x03, - DW_FORM_block4 = 0x04, - DW_FORM_data2 = 0x05, - DW_FORM_data4 = 0x06, - DW_FORM_data8 = 0x07, - DW_FORM_string = 0x08, - DW_FORM_block = 0x09, - DW_FORM_block1 = 0x0a, - DW_FORM_data1 = 0x0b, - DW_FORM_flag = 0x0c, - DW_FORM_sdata = 0x0d, - DW_FORM_strp = 0x0e, - DW_FORM_udata = 0x0f, - DW_FORM_ref_addr = 0x10, - DW_FORM_ref1 = 0x11, - DW_FORM_ref2 = 0x12, - DW_FORM_ref4 = 0x13, - DW_FORM_ref8 = 0x14, - DW_FORM_ref_udata = 0x15, - DW_FORM_indirect = 0x16 - }; - -/* Attributes */ -enum dwarf2_attribute - { - DW_AT_sibling = 0x01, - DW_AT_location = 0x02, - DW_AT_name = 0x03, - DW_AT_ordering = 0x09, - DW_AT_subscr_data = 0x0a, - DW_AT_byte_size = 0x0b, - DW_AT_bit_offset = 0x0c, - DW_AT_bit_size = 0x0d, - DW_AT_element_list = 0x0f, - DW_AT_stmt_list = 0x10, - DW_AT_low_pc = 0x11, - DW_AT_high_pc = 0x12, - DW_AT_language = 0x13, - DW_AT_member = 0x14, - DW_AT_discr = 0x15, - DW_AT_discr_value = 0x16, - DW_AT_visibility = 0x17, - DW_AT_import = 0x18, - DW_AT_string_length = 0x19, - DW_AT_common_reference = 0x1a, - DW_AT_comp_dir = 0x1b, - DW_AT_const_value = 0x1c, - DW_AT_containing_type = 0x1d, - DW_AT_default_value = 0x1e, - DW_AT_inline = 0x20, - DW_AT_is_optional = 0x21, - DW_AT_lower_bound = 0x22, - DW_AT_producer = 0x25, - DW_AT_prototyped = 0x27, - DW_AT_return_addr = 0x2a, - DW_AT_start_scope = 0x2c, - DW_AT_stride_size = 0x2e, - DW_AT_upper_bound = 0x2f, - DW_AT_abstract_origin = 0x31, - DW_AT_accessibility = 0x32, - DW_AT_address_class = 0x33, - DW_AT_artificial = 0x34, - DW_AT_base_types = 0x35, - DW_AT_calling_convention = 0x36, - DW_AT_count = 0x37, - DW_AT_data_member_location = 0x38, - DW_AT_decl_column = 0x39, - DW_AT_decl_file = 0x3a, - DW_AT_decl_line = 0x3b, - DW_AT_declaration = 0x3c, - DW_AT_discr_list = 0x3d, - DW_AT_encoding = 0x3e, - DW_AT_external = 0x3f, - DW_AT_frame_base = 0x40, - DW_AT_friend = 0x41, - DW_AT_identifier_case = 0x42, - DW_AT_macro_info = 0x43, - DW_AT_namelist_items = 0x44, - DW_AT_priority = 0x45, - DW_AT_segment = 0x46, - DW_AT_specification = 0x47, - DW_AT_static_link = 0x48, - DW_AT_type = 0x49, - DW_AT_use_location = 0x4a, - DW_AT_variable_parameter = 0x4b, - DW_AT_virtuality = 0x4c, - DW_AT_vtable_elem_location = 0x4d, - /* DWARF 3 values. */ - DW_AT_allocated = 0x4e, - DW_AT_associated = 0x4f, - DW_AT_data_location = 0x50, - DW_AT_stride = 0x51, - DW_AT_entry_pc = 0x52, - DW_AT_use_UTF8 = 0x53, - DW_AT_extension = 0x54, - DW_AT_ranges = 0x55, - DW_AT_trampoline = 0x56, - DW_AT_call_column = 0x57, - DW_AT_call_file = 0x58, - DW_AT_call_line = 0x59, - /* SGI/MIPS extensions. */ - DW_AT_MIPS_fde = 0x2001, - DW_AT_MIPS_loop_begin = 0x2002, - DW_AT_MIPS_tail_loop_begin = 0x2003, - DW_AT_MIPS_epilog_begin = 0x2004, - DW_AT_MIPS_loop_unroll_factor = 0x2005, - DW_AT_MIPS_software_pipeline_depth = 0x2006, - DW_AT_MIPS_linkage_name = 0x2007, - DW_AT_MIPS_stride = 0x2008, - DW_AT_MIPS_abstract_name = 0x2009, - DW_AT_MIPS_clone_origin = 0x200a, - DW_AT_MIPS_has_inlines = 0x200b, - /* HP extensions. */ - DW_AT_HP_block_index = 0x2000, - DW_AT_HP_unmodifiable = 0x2001, /* Same as DW_AT_MIPS_fde. */ - DW_AT_HP_actuals_stmt_list = 0x2010, - DW_AT_HP_proc_per_section = 0x2011, - DW_AT_HP_raw_data_ptr = 0x2012, - DW_AT_HP_pass_by_reference = 0x2013, - DW_AT_HP_opt_level = 0x2014, - DW_AT_HP_prof_version_id = 0x2015, - DW_AT_HP_opt_flags = 0x2016, - DW_AT_HP_cold_region_low_pc = 0x2017, - DW_AT_HP_cold_region_high_pc = 0x2018, - DW_AT_HP_all_variables_modifiable = 0x2019, - DW_AT_HP_linkage_name = 0x201a, - DW_AT_HP_prof_flags = 0x201b, /* In comp unit of procs_info for -g. */ - /* GNU extensions. */ - DW_AT_sf_names = 0x2101, - DW_AT_src_info = 0x2102, - DW_AT_mac_info = 0x2103, - DW_AT_src_coords = 0x2104, - DW_AT_body_begin = 0x2105, - DW_AT_body_end = 0x2106, - DW_AT_GNU_vector = 0x2107, - /* VMS extensions. */ - DW_AT_VMS_rtnbeg_pd_address = 0x2201, - /* UPC extension. */ - DW_AT_upc_threads_scaled = 0x3210, - /* PGI (STMicroelectronics) extensions. */ - DW_AT_PGI_lbase = 0x3a00, - DW_AT_PGI_soffset = 0x3a01, - DW_AT_PGI_lstride = 0x3a02 - }; - -#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */ -#define DW_AT_hi_user 0x3ff0 /* Implementation-defined range end. */ - -/* Location atom */ -enum dwarf_location_atom - { - DW_OP_addr = 0x03, - DW_OP_deref = 0x06, - DW_OP_const1u = 0x08, - DW_OP_const1s = 0x09, - DW_OP_const2u = 0x0a, - DW_OP_const2s = 0x0b, - DW_OP_const4u = 0x0c, - DW_OP_const4s = 0x0d, - DW_OP_const8u = 0x0e, - DW_OP_const8s = 0x0f, - DW_OP_constu = 0x10, - DW_OP_consts = 0x11, - DW_OP_dup = 0x12, - DW_OP_drop = 0x13, - DW_OP_over = 0x14, - DW_OP_pick = 0x15, - DW_OP_swap = 0x16, - DW_OP_rot = 0x17, - DW_OP_xderef = 0x18, - DW_OP_abs = 0x19, - DW_OP_and = 0x1a, - DW_OP_div = 0x1b, - DW_OP_minus = 0x1c, - DW_OP_mod = 0x1d, - DW_OP_mul = 0x1e, - DW_OP_neg = 0x1f, - DW_OP_not = 0x20, - DW_OP_or = 0x21, - DW_OP_plus = 0x22, - DW_OP_plus_uconst = 0x23, - DW_OP_shl = 0x24, - DW_OP_shr = 0x25, - DW_OP_shra = 0x26, - DW_OP_xor = 0x27, - DW_OP_bra = 0x28, - DW_OP_eq = 0x29, - DW_OP_ge = 0x2a, - DW_OP_gt = 0x2b, - DW_OP_le = 0x2c, - DW_OP_lt = 0x2d, - DW_OP_ne = 0x2e, - DW_OP_skip = 0x2f, - DW_OP_lit0 = 0x30, - DW_OP_lit1 = 0x31, - DW_OP_lit2 = 0x32, - DW_OP_lit3 = 0x33, - DW_OP_lit4 = 0x34, - DW_OP_lit5 = 0x35, - DW_OP_lit6 = 0x36, - DW_OP_lit7 = 0x37, - DW_OP_lit8 = 0x38, - DW_OP_lit9 = 0x39, - DW_OP_lit10 = 0x3a, - DW_OP_lit11 = 0x3b, - DW_OP_lit12 = 0x3c, - DW_OP_lit13 = 0x3d, - DW_OP_lit14 = 0x3e, - DW_OP_lit15 = 0x3f, - DW_OP_lit16 = 0x40, - DW_OP_lit17 = 0x41, - DW_OP_lit18 = 0x42, - DW_OP_lit19 = 0x43, - DW_OP_lit20 = 0x44, - DW_OP_lit21 = 0x45, - DW_OP_lit22 = 0x46, - DW_OP_lit23 = 0x47, - DW_OP_lit24 = 0x48, - DW_OP_lit25 = 0x49, - DW_OP_lit26 = 0x4a, - DW_OP_lit27 = 0x4b, - DW_OP_lit28 = 0x4c, - DW_OP_lit29 = 0x4d, - DW_OP_lit30 = 0x4e, - DW_OP_lit31 = 0x4f, - DW_OP_reg0 = 0x50, - DW_OP_reg1 = 0x51, - DW_OP_reg2 = 0x52, - DW_OP_reg3 = 0x53, - DW_OP_reg4 = 0x54, - DW_OP_reg5 = 0x55, - DW_OP_reg6 = 0x56, - DW_OP_reg7 = 0x57, - DW_OP_reg8 = 0x58, - DW_OP_reg9 = 0x59, - DW_OP_reg10 = 0x5a, - DW_OP_reg11 = 0x5b, - DW_OP_reg12 = 0x5c, - DW_OP_reg13 = 0x5d, - DW_OP_reg14 = 0x5e, - DW_OP_reg15 = 0x5f, - DW_OP_reg16 = 0x60, - DW_OP_reg17 = 0x61, - DW_OP_reg18 = 0x62, - DW_OP_reg19 = 0x63, - DW_OP_reg20 = 0x64, - DW_OP_reg21 = 0x65, - DW_OP_reg22 = 0x66, - DW_OP_reg23 = 0x67, - DW_OP_reg24 = 0x68, - DW_OP_reg25 = 0x69, - DW_OP_reg26 = 0x6a, - DW_OP_reg27 = 0x6b, - DW_OP_reg28 = 0x6c, - DW_OP_reg29 = 0x6d, - DW_OP_reg30 = 0x6e, - DW_OP_reg31 = 0x6f, - DW_OP_breg0 = 0x70, - DW_OP_breg1 = 0x71, - DW_OP_breg2 = 0x72, - DW_OP_breg3 = 0x73, - DW_OP_breg4 = 0x74, - DW_OP_breg5 = 0x75, - DW_OP_breg6 = 0x76, - DW_OP_breg7 = 0x77, - DW_OP_breg8 = 0x78, - DW_OP_breg9 = 0x79, - DW_OP_breg10 = 0x7a, - DW_OP_breg11 = 0x7b, - DW_OP_breg12 = 0x7c, - DW_OP_breg13 = 0x7d, - DW_OP_breg14 = 0x7e, - DW_OP_breg15 = 0x7f, - DW_OP_breg16 = 0x80, - DW_OP_breg17 = 0x81, - DW_OP_breg18 = 0x82, - DW_OP_breg19 = 0x83, - DW_OP_breg20 = 0x84, - DW_OP_breg21 = 0x85, - DW_OP_breg22 = 0x86, - DW_OP_breg23 = 0x87, - DW_OP_breg24 = 0x88, - DW_OP_breg25 = 0x89, - DW_OP_breg26 = 0x8a, - DW_OP_breg27 = 0x8b, - DW_OP_breg28 = 0x8c, - DW_OP_breg29 = 0x8d, - DW_OP_breg30 = 0x8e, - DW_OP_breg31 = 0x8f, - DW_OP_regx = 0x90, - DW_OP_fbreg = 0x91, - DW_OP_bregx = 0x92, - DW_OP_piece = 0x93, - DW_OP_deref_size = 0x94, - DW_OP_xderef_size = 0x95, - DW_OP_nop = 0x96, - /* DWARF 3 extensions. */ - DW_OP_push_object_address = 0x97, - DW_OP_call2 = 0x98, - DW_OP_call4 = 0x99, - DW_OP_call_ref = 0x9a, - /* GNU extensions. */ - DW_OP_GNU_push_tls_address = 0xe0, - /* HP extensions. */ - DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */ - DW_OP_HP_is_value = 0xe1, - DW_OP_HP_fltconst4 = 0xe2, - DW_OP_HP_fltconst8 = 0xe3, - DW_OP_HP_mod_range = 0xe4, - DW_OP_HP_unmod_range = 0xe5, - DW_OP_HP_tls = 0xe6 - }; - -#define DW_OP_lo_user 0xe0 /* Implementation-defined range start. */ -#define DW_OP_hi_user 0xff /* Implementation-defined range end. */ - -/* Type encodings. */ -enum dwarf2_type - { - DW_ATE_void = 0x0, - DW_ATE_address = 0x1, - DW_ATE_boolean = 0x2, - DW_ATE_complex_float = 0x3, - DW_ATE_float = 0x4, - DW_ATE_signed = 0x5, - DW_ATE_signed_char = 0x6, - DW_ATE_unsigned = 0x7, - DW_ATE_unsigned_char = 0x8, - /* DWARF 3. */ - DW_ATE_imaginary_float = 0x9, - DW_ATE_decimal_float = 0xf, - /* HP extensions. */ - DW_ATE_HP_float80 = 0x80, /* Floating-point (80 bit). */ - DW_ATE_HP_complex_float80 = 0x81, /* Complex floating-point (80 bit). */ - DW_ATE_HP_float128 = 0x82, /* Floating-point (128 bit). */ - DW_ATE_HP_complex_float128 = 0x83, /* Complex floating-point (128 bit). */ - DW_ATE_HP_floathpintel = 0x84, /* Floating-point (82 bit IA64). */ - DW_ATE_HP_imaginary_float80 = 0x85, - DW_ATE_HP_imaginary_float128 = 0x86 - }; - -#define DW_ATE_lo_user 0x80 -#define DW_ATE_hi_user 0xff - -/* Array ordering names and codes. */ -enum dwarf2_array_dim_ordering - { - DW_ORD_row_major = 0, - DW_ORD_col_major = 1 - }; - -/* Access attribute. */ -enum dwarf2_access_attribute - { - DW_ACCESS_public = 1, - DW_ACCESS_protected = 2, - DW_ACCESS_private = 3 - }; - -/* Visibility. */ -enum dwarf2_visibility_attribute - { - DW_VIS_local = 1, - DW_VIS_exported = 2, - DW_VIS_qualified = 3 - }; - -/* Virtuality. */ -enum dwarf2_virtuality_attribute - { - DW_VIRTUALITY_none = 0, - DW_VIRTUALITY_virtual = 1, - DW_VIRTUALITY_pure_virtual = 2 - }; - -/* Case sensitivity. */ -enum dwarf2_id_case - { - DW_ID_case_sensitive = 0, - DW_ID_up_case = 1, - DW_ID_down_case = 2, - DW_ID_case_insensitive = 3 - }; - -/* Calling convention. */ -enum dwarf2_calling_convention - { - DW_CC_normal = 0x1, - DW_CC_program = 0x2, - DW_CC_nocall = 0x3, - DW_CC_GNU_renesas_sh = 0x40 - }; - -#define DW_CC_lo_user 0x40 -#define DW_CC_hi_user 0xff - -/* Inline attribute. */ -enum dwarf2_inline_attribute - { - DW_INL_not_inlined = 0, - DW_INL_inlined = 1, - DW_INL_declared_not_inlined = 2, - DW_INL_declared_inlined = 3 - }; - -/* Discriminant lists. */ -enum dwarf2_discrim_list - { - DW_DSC_label = 0, - DW_DSC_range = 1 - }; - -/* Line number opcodes. */ -enum dwarf2_line_number_ops - { - DW_LNS_extended_op = 0, - DW_LNS_copy = 1, - DW_LNS_advance_pc = 2, - DW_LNS_advance_line = 3, - DW_LNS_set_file = 4, - DW_LNS_set_column = 5, - DW_LNS_negate_stmt = 6, - DW_LNS_set_basic_block = 7, - DW_LNS_const_add_pc = 8, - DW_LNS_fixed_advance_pc = 9, - /* DWARF 3. */ - DW_LNS_set_prologue_end = 10, - DW_LNS_set_epilogue_begin = 11, - DW_LNS_set_isa = 12 - }; - -/* Line number extended opcodes. */ -enum dwarf2_line_number_x_ops - { - DW_LNE_end_sequence = 1, - DW_LNE_set_address = 2, - DW_LNE_define_file = 3, - /* HP extensions. */ - DW_LNE_HP_negate_is_UV_update = 0x11, - DW_LNE_HP_push_context = 0x12, - DW_LNE_HP_pop_context = 0x13, - DW_LNE_HP_set_file_line_column = 0x14, - DW_LNE_HP_set_routine_name = 0x15, - DW_LNE_HP_set_sequence = 0x16, - DW_LNE_HP_negate_post_semantics = 0x17, - DW_LNE_HP_negate_function_exit = 0x18, - DW_LNE_HP_negate_front_end_logical = 0x19, - DW_LNE_HP_define_proc = 0x20 - }; - -/* Call frame information. */ -enum dwarf2_call_frame_info - { - DW_CFA_advance_loc = 0x40, - DW_CFA_offset = 0x80, - DW_CFA_restore = 0xc0, - DW_CFA_nop = 0x00, - DW_CFA_set_loc = 0x01, - DW_CFA_advance_loc1 = 0x02, - DW_CFA_advance_loc2 = 0x03, - DW_CFA_advance_loc4 = 0x04, - DW_CFA_offset_extended = 0x05, - DW_CFA_restore_extended = 0x06, - DW_CFA_undefined = 0x07, - DW_CFA_same_value = 0x08, - DW_CFA_register = 0x09, - DW_CFA_remember_state = 0x0a, - DW_CFA_restore_state = 0x0b, - DW_CFA_def_cfa = 0x0c, - DW_CFA_def_cfa_register = 0x0d, - DW_CFA_def_cfa_offset = 0x0e, - /* DWARF 3. */ - DW_CFA_def_cfa_expression = 0x0f, - DW_CFA_expression = 0x10, - DW_CFA_offset_extended_sf = 0x11, - DW_CFA_def_cfa_sf = 0x12, - DW_CFA_def_cfa_offset_sf = 0x13, - /* SGI/MIPS specific. */ - DW_CFA_MIPS_advance_loc8 = 0x1d, - /* GNU extensions. */ - DW_CFA_GNU_window_save = 0x2d, - DW_CFA_GNU_args_size = 0x2e, - DW_CFA_GNU_negative_offset_extended = 0x2f - }; - -#define DW_CIE_ID 0xffffffff -#define DW_CIE_VERSION 1 - -#define DW_CFA_extended 0 -#define DW_CFA_lo_user 0x1c -#define DW_CFA_hi_user 0x3f - -#define DW_ADDR_none 0 - -/* Source language names and codes. */ -enum dwarf2_source_language - { - DW_LANG_C89 = 0x0001, - DW_LANG_C = 0x0002, - DW_LANG_Ada83 = 0x0003, - DW_LANG_C_plus_plus = 0x0004, - DW_LANG_Cobol74 = 0x0005, - DW_LANG_Cobol85 = 0x0006, - DW_LANG_Fortran77 = 0x0007, - DW_LANG_Fortran90 = 0x0008, - DW_LANG_Pascal83 = 0x0009, - DW_LANG_Modula2 = 0x000a, - DW_LANG_Java = 0x000b, - /* DWARF 3. */ - DW_LANG_C99 = 0x000c, - DW_LANG_Ada95 = 0x000d, - DW_LANG_Fortran95 = 0x000e, - /* MIPS. */ - DW_LANG_Mips_Assembler = 0x8001, - /* UPC. */ - DW_LANG_Upc = 0x8765 - }; - -#define DW_LANG_lo_user 0x8000 /* Implementation-defined range start. */ -#define DW_LANG_hi_user 0xffff /* Implementation-defined range start. */ - -/* Names and codes for macro information. */ -enum dwarf2_macinfo_record_type - { - DW_MACINFO_define = 1, - DW_MACINFO_undef = 2, - DW_MACINFO_start_file = 3, - DW_MACINFO_end_file = 4, - DW_MACINFO_vendor_ext = 255 - }; - -#define DW_EH_PE_absptr 0x00 -#define DW_EH_PE_omit 0xff - -#define DW_EH_PE_uleb128 0x01 -#define DW_EH_PE_udata2 0x02 -#define DW_EH_PE_udata4 0x03 -#define DW_EH_PE_udata8 0x04 -#define DW_EH_PE_sleb128 0x09 -#define DW_EH_PE_sdata2 0x0A -#define DW_EH_PE_sdata4 0x0B -#define DW_EH_PE_sdata8 0x0C -#define DW_EH_PE_signed 0x08 - -#define DW_EH_PE_pcrel 0x10 -#define DW_EH_PE_textrel 0x20 -#define DW_EH_PE_datarel 0x30 -#define DW_EH_PE_funcrel 0x40 -#define DW_EH_PE_aligned 0x50 - -#define DW_EH_PE_indirect 0x80 -#endif diff -Nru eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt.h.svn-base eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt.h.svn-base --- eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt.h.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,148 +0,0 @@ -/* -** libedfmt.h for libedfmt (The Elf debug format library of ELFsh) -** -** Started Dec 25 2006 15:41:35 mxatone -** -** -** $Id: libedfmt.h,v 1.16 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#ifndef __LIBEDFMT_H__ -#define __LIBEDFMT_H__ - -#include "libelfsh.h" - -/* Defines */ -#define UNKNOWN_FORMAT 0 -#define STABS_FORMAT 1 -#define DWARF2_FORMAT 2 - -#define EDFMT_CLINE_SIZE 30 -#define EDFMT_CADDR_SIZE 30 -#define EDFMT_CKEY_SIZE 30 - -/* Debug Flags */ -#define __DEBUG_STABS__ 0 -#define __DEBUG_DWARF2__ 0 - -/* Allocate pool steps */ -#define DWARF2_ALLOC_STEP 4096 -#define STABS_ALLOC_STEP 4096 -#define API_ALLOC_STEP 4096 - -/* Include debug format headers */ -#include "libedfmt-api.h" -#include "libedfmt-dwarf2.h" -#include "libedfmt-stabs.h" - -/* Structures */ -typedef struct s_edfmtmanage -{ - char *sect_name; /* Section name */ - u_int sect_hash; /* Section hash */ - int (*func)(elfshobj_t*); /* Management function */ - int (*trans)(elfshobj_t*); /* Transform function */ - int (*clean)(elfshobj_t*); /* Clean function */ -} edfmtmanage_t; - -/* api.c */ -int edfmt_add_init(elfshobj_t *file); -int edfmt_add_end(); -int edfmt_update_type(edfmttype_t *type); -int edfmt_update_var(edfmtvar_t *var); -int edfmt_update_func(edfmtfunc_t *func); -int edfmt_change_type_nfile(edfmttype_t *type); -edfmtfile_t *edfmt_restore_parent_file(); -edfmtfile_t *edfmt_get_current_file(); -edfmtfile_t *edfmt_get_inc_file(edfmtfile_t *file, char *name); -edfmtfile_t *edfmt_add_file(edfmtfile_t *parent_file, char *name, eresi_Addr start, eresi_Addr end); -int edfmt_reset_file(); -int edfmt_reactive_file(); -edfmtinfo_t *edfmt_get_uniinfo(elfshobj_t *file); -edfmttype_t *edfmt_add_type_unk(char *name); -edfmttype_t *edfmt_add_type_basic(char *name, int size); -edfmttype_t *edfmt_add_type_array(char *name, int size, edfmttype_t *type); -edfmttype_t *edfmt_add_type_ptr(char *name, edfmttype_t *type); -edfmttype_t *edfmt_add_type_struct(char *name, int size); -edfmttype_t *edfmt_add_type_union(char *name, int size); -edfmttype_t *edfmt_add_type_attr(edfmttype_t *tstruct, char *name, - int start, int size, edfmttype_t *type); -edfmttype_t *edfmt_add_type_void(char *name); -edfmttype_t *edfmt_add_type_link(char *name, edfmttype_t *type); - -edfmtvar_t *edfmt_add_var_global(edfmttype_t *type, char *name, - eresi_Addr addr); -edfmtfunc_t *edfmt_add_func(char *name, edfmttype_t *ret, - eresi_Addr start, eresi_Addr end); -edfmtfuncarg_t *edfmt_add_arg(edfmtfunc_t *func, char *name, - u_int reg, int pos, edfmttype_t *type); -edfmttype_t *edfmt_check_type(char *name); -edfmtvar_t *edfmt_check_var(char *name); -edfmtfunc_t *edfmt_check_func(char *name); - -/* edfmt.c */ -int edfmt_format(elfshobj_t *file); -elfshsect_t *edfmt_get_sect(elfshobj_t *file, u_int hash, char *hash_name, - u_int strhash); -/* edfmt-utils.c */ -char *edfmt_ckey(char *buf, u_int size, long key); -char *edfmt_cline(char *buf, u_int size, u_int line, char *file); -char *edfmt_caddr(char *buf, u_int size, eresi_Addr addr); -eresi_Addr edfmt_lookup_addr(elfshobj_t *file, char *param); -void *edfmt_alloc_pool(char **pool, int *apos, int *asize, - int astep, int nsize); -int edfmt_clean_pool(char **pool); - -/* stabs.c */ -edfmtstabsinfo_t *edfmt_stabs_getinfo(elfshobj_t *file); -int edfmt_stabs_parse(elfshobj_t *file); -int edfmt_stabs_clean(elfshobj_t *file); - -/* stabs-trans.c */ -int edfmt_stabs_transform(elfshobj_t *file); - -/* stabs-utils.c */ -char *edfmt_stabs_readstr(char *buf, u_int size, char **str, char c_delim); -int edfmt_stabs_readnumber(char **str, char c_delim, long *set_num); -int edfmt_stabs_typenum(edfmtstabstypenum_t *tnum, char **str); -int edfmt_stabs_ctypenum(char *buf, u_int size, edfmtstabstypenum_t *tnum); - -/* dwarf2.c */ -edfmtdw2info_t *edfmt_dwarf2_getinfo(elfshobj_t *file); -int edfmt_dwarf2_parse(elfshobj_t *file); -int edfmt_dwarf2_clean(elfshobj_t *file); -int edfmt_dwarf2_block_entrie(elfshobj_t *file); -int edfmt_dwarf2_block_loop(u_int endpos); -int edfmt_dwarf2_build_tree(edfmtdw2abbent_t *parent, - edfmtdw2abbent_t *fent, - edfmtdw2abbent_t *ref); -int edfmt_dwarf2_getent(edfmtdw2cu_t *cu, - edfmtdw2abbent_t *abbent, - u_int pos); - -/* dwarf2-trans.c */ -int edfmt_dwarf2_transform_abbrev(u_int pos); -edfmttype_t *edfmt_dwarf2_transform_abbrev_parse(edfmtdw2abbent_t *abbrev); -int edfmt_dwarf2_transform(elfshobj_t *file); -edfmtdw2abbattr_t *edfmt_dwarf2_getattr(edfmtdw2abbent_t *abbrev, u_int attr); - -/* dwarf2-utils.c */ -u_long edfmt_read_uleb128(void *data, u_int *bread); -long edfmt_read_leb128(void *data, u_int *bread); - -/* dwarf2-abbrev.c */ -int edfmt_dwarf2_loc(edfmtdw2loc_t *loc, u_char *buf, u_int size); -int edfmt_dwarf2_line(u_long offset); -int edfmt_dwarf2_line_rec(edfmtdw2cu_t *cu, u_int line, u_int column, eresi_Addr addr, u_int fid); -int edfmt_dwarf2_mac(u_long offset); -int edfmt_dwarf2_abbrev_read(edfmtdw2abbent_t *abbent, u_long pos, u_long ipos); -int edfmt_dwarf2_abbrev_enum(hash_t *abbrev_table); -int edfmt_dwarf2_abbrev_enum_clean(hash_t *abbrev_table); -int edfmt_dwarf2_form(edfmtdw2abbent_t *abbent, u_int pos); -int edfmt_dwarf2_form_value(edfmtdw2abbattr_t *attr); - -/* dwarf2-cfa */ -int edfmt_dwarf2_cfa(); - -#endif diff -Nru eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-stabs.h.svn-base eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-stabs.h.svn-base --- eresi-0.8a25/libedfmt/include/.svn/text-base/libedfmt-stabs.h.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/include/.svn/text-base/libedfmt-stabs.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,409 +0,0 @@ -/* -** libedfmt-stabs.h for libedfmt (The Elf debug format library of ELFsh) -** -** Started Sat 13 2006 09:52:12 mxatone -** -** -** $Id: libedfmt-stabs.h,v 1.9 2007-08-17 01:45:46 heroine Exp $ -** -*/ - -#ifndef __STABS_H__ -#define __STABS_H__ - -#define STABS_MAX_ARGUMENTS 20 -#define STABS_NAME_SIZE 90 -#define STABS_CTYPENUM_SIZE 20 -#define STABS_FILE_IT 20 - -/* Some define shortcut */ -#define STABS_IVD_STR(_str) \ -(!_str || !*_str || !**_str) - -#define stabs_c_ent \ -stabs_ent[stabs_index] - -#define stabs_c_str \ -(stabs_datastr + stabs_c_ent.strindex) - -/** - * @brief Represent an entrie on the stab section - */ -typedef struct s_stabsent -{ - eresi_Addr strindex; /*!< The index to find the string on the string stab section */ - u_char type; /*!< Type id */ - u_char other; /*!< Never use, already @ 0 */ - u_short desc; /*!< Used to store short information like line */ - eresi_Addr value; /*!< Used to store addr aligned informations */ -} edfmtstabsent_t; - -/* Forward declaration */ -struct s_edfmtbstabsdata; -typedef struct s_stabsdata edfmtstabsdata_t; -struct s_stabstype; -typedef struct s_stabstype edfmtstabstype_t; - -/** - * @brief A type is defined as two number, file and type number - */ -typedef struct s_stabstypenum -{ - long file; /*!< TO COMPLETE */ - long number; /*!< TO COMPLETE */ -} edfmtstabstypenum_t; - -/** - * @brief A structure attribute - */ -typedef struct s_stabsattr -{ - char name[STABS_NAME_SIZE]; /*!< TO COMPLETE */ - - edfmtstabstype_t *type; - - - long start; /*!< Start offset */ - long size; /*!< Start size */ - - struct s_stabsattr *next; /*!< TO COMPLETE */ -} edfmtstabsattr_t; - -/** - * @brief Describe a structure - */ -typedef struct s_stabsstruct -{ - - long size; /*!< Total size */ - - - edfmtstabsattr_t *attr; /*!< Attribute list */ -} edfmtstabsstruct_t; - -/** - * @brief Describe an enum - */ -typedef struct s_stabsenum -{ - char name[STABS_NAME_SIZE]; - long value; - - struct s_stabsenum *next; -} edfmtstabsenum_t; - -/** - * In stabs, a basic type is describe by its range - * We get those informations (except too long numbers) - * only for parsing purpore, resolve basic type size - * should use name matching engine - */ -typedef struct s_stabsrange -{ - long low; - long high; - - /* We don't always have size information */ - long size; -} edfmtstabsrange_t; - -/** - * @brief Describe an array - */ -typedef struct s_stabsarray -{ - long low; - long high; - -#define STABS_ARRAY_STRING (1 << 1) -#define STABS_ARRAY_VECTOR (1 << 2) - long type; - - edfmtstabstype_t *link; -} edfmtstabsarray_t; - -/** - * @brief Represent a function - */ -typedef struct s_stabsfunc -{ - u_int s_line; /* Start line */ - eresi_Addr s_addr; /* Start address */ - eresi_Addr e_addr; /* End address */ - - edfmtstabsdata_t *args[STABS_MAX_ARGUMENTS]; - - /* Return type */ - edfmtstabstype_t *rettype; - - /* Data parent */ - edfmtstabsdata_t *data; - - /* Next entrie */ - struct s_stabsfunc *next; -} edfmtstabsfunc_t; - -/** - * @brief Describe a type, a type isn't always basic - */ -struct s_stabstype -{ -#define STABS_TYPE_UNK 0 -#define STABS_TYPE_STRUCT 1 -#define STABS_TYPE_UNION 2 -#define STABS_TYPE_LINK 3 -#define STABS_TYPE_RANGE 4 -#define STABS_TYPE_ARRAY 5 -#define STABS_TYPE_VOID 6 -#define STABS_TYPE_ENUM 7 -#define STABS_TYPE_CMEMBER 8 -#define STABS_TYPE_PTR 9 -#define STABS_TYPE_REF 10 -#define STABS_TYPE_FUNC 11 -#define STABS_TYPE_VOLATILE 12 -#define STABS_TYPE_CONST 13 -#define STABS_TYPE_CLINK 14 - u_char type; - - edfmtstabstypenum_t num; - char cnum[STABS_CTYPENUM_SIZE]; - - /** - * Depend of the field type, we will use on of this union - * entry - */ - union { - edfmtstabsstruct_t struct_union; - edfmtstabsenum_t *enum_attr; - struct s_stabstype *link; - edfmtstabsrange_t r; - edfmtstabsarray_t arr; - } u; - - /* Data parent */ - edfmtstabsdata_t *data; - struct s_stabstype *parent_link; - - /* Transformated type link */ - edfmttype_t *transtype; - - struct s_stabstype *next; -}; - -/** - * Data structure represent a scoped type - * there is many type apply on different scope: - * function, variables, etc etc .. - */ -struct s_stabsdata -{ - char name[STABS_NAME_SIZE]; - -#define STABS_SCOPE_UNK 0 -#define STABS_SCOPE_TYPE 1 -#define STABS_SCOPE_LVAR 2 -#define STABS_SCOPE_ARG 3 -#define STABS_SCOPE_GFUNC 4 -#define STABS_SCOPE_LFUNC 5 -#define STABS_SCOPE_GVAR 6 -#define STABS_SCOPE_ARGRREG 7 -#define STABS_SCOPE_ARGREF 8 -#define STABS_SCOPE_CONST_F 9 -#define STABS_SCOPE_CONST_I 10 -#define STABS_SCOPE_CONST_E 11 -#define STABS_SCOPE_ARGREG 12 -#define STABS_SCOPE_VARREG 13 -#define STABS_SCOPE_STATICVAR 14 -#define STABS_SCOPE_PSTATICVAR 15 - u_char scope; - - edfmtstabstype_t *type; - - /* This union depend of the scope field */ - union { - eresi_Addr addr; - eresi_Addr stackpos; - eresi_Addr reg; - edfmtstabsfunc_t func; - double fl; - int i; - } u; - - struct s_stabsdata *next; -}; - -/** - * Describe a relation between a line and an address - */ -typedef struct s_stabsline -{ - u_int line; - eresi_Addr addr; - - struct s_stabsline *next; -} edfmtstabsline_t; - -/** - * @brief Describe a file - * - * There is two different types of files so (object file) and include (header file) - * - an object file wouldn't have any parent - * - an include file can have others include file but always have a parent - */ -typedef struct s_stabsfile -{ - /** - * Path and file, and include file wouldn't have a path, - * an absolute path is on file field - */ - char *path; - char *file; - - eresi_Addr s_addr; - eresi_Addr e_addr; - - /* Function pointers */ - edfmtstabsfunc_t *func; - edfmtstabsfunc_t *last_func; - - /* Lines pointers */ - edfmtstabsline_t *line; - edfmtstabsline_t *last_line; - - /* Variable */ - edfmtstabsdata_t *vars; - edfmtstabsdata_t *lvar; - - /* Types */ - edfmtstabstype_t *types; - edfmtstabstype_t *ltype; - - /* Include & parent pointers */ - struct s_stabsfile *inc; - struct s_stabsfile *last_inc; - - struct s_stabsfile *parent; - - /* This field is use both by so and include files */ - struct s_stabsfile *next; -} edfmtstabsfile_t; - -/** - * This structure is the information center - */ -typedef struct s_stabsinfo -{ - /* Files informations */ - char **dir_list; - char **file_list; - u_int index_list; - u_int num_list; - - char *alloc_pool; - int alloc_pos; - int alloc_size; - - /* File list */ - edfmtstabsfile_t *file; -} edfmtstabsinfo_t; - -enum stabs_type - { - STABS_TYPE_GSYM = 0x20, - STABS_TYPE_FNAME = 0x22, - STABS_TYPE_FUN = 0x24, - STABS_TYPE_STSYM = 0x26, - STABS_TYPE_LCSYM = 0x28, - STABS_TYPE_MAIN = 0x2a, - STABS_TYPE_ROSYM = 0x2c, - STABS_TYPE_PC = 0x30, - STABS_TYPE_NSYMS = 0x32, - STABS_TYPE_NOMAP = 0x34, - STABS_TYPE_OBJ = 0x38, - STABS_TYPE_OPT = 0x3c, - STABS_TYPE_RSYM = 0x40, - STABS_TYPE_M2C = 0x42, - STABS_TYPE_SLINE = 0x44, - STABS_TYPE_DSLINE = 0x46, - STABS_TYPE_BSLINE = 0x48, - //STABS_TYPE_BROWS = 0x48, ?? - STABS_TYPE_DEFD = 0x4a, - STABS_TYPE_FLINE = 0x4c, - STABS_TYPE_EHDECL = 0x50, - //STABS_TYPE_MOD2 = 0x50, ?? - STABS_TYPE_CATCH = 0x54, - STABS_TYPE_SSYM = 0x60, - STABS_TYPE_ENDM = 0x62, - STABS_TYPE_SO = 0x64, - STABS_TYPE_LSYM = 0x80, - STABS_TYPE_BINCL = 0x82, - STABS_TYPE_SOL = 0x84, - STABS_TYPE_PSYM = 0xa0, - STABS_TYPE_EINCL = 0xa2, - STABS_TYPE_ENTRY = 0xa4, - STABS_TYPE_LBRAC = 0xc0, - STABS_TYPE_EXCL = 0xc2, - STABS_TYPE_SCOPE = 0xc4, - STABS_TYPE_RBRAC = 0xe0, - STABS_TYPE_BCOMM = 0xe2, - STABS_TYPE_ECOMM = 0xe4, - STABS_TYPE_ECOML = 0xe8, - STABS_TYPE_WITH = 0xea, - STABS_TYPE_NBTEXT = 0xf0, - STABS_TYPE_NBDATA = 0xf2, - STABS_TYPE_NBBSS = 0xf4, - STABS_TYPE_NBSTS = 0xf6, - STABS_TYPE_NBLCS = 0xf8 - }; - -#define STABS_IS_SPECIAL(_x) \ -(_x == '-' || _x == '(' || (_x >= '0' && _x <= '9')) - -#define STABS_STR_DELIM ':' - -/* Symbol type */ -#define STABS_STR_T_PARAM_RREG 'a' -#define STABS_STR_T_CONST 'c' -#define STABS_STR_T_CONST_FLOAT 'r' -#define STABS_STR_T_CONST_INT 'i' -#define STABS_STR_T_CONST_ENUM 'e' -#define STABS_STR_T_FFUNC 'f' -#define STABS_STR_T_GFUNC 'F' -#define STABS_STR_T_GVAR 'G' -#define STABS_STR_T_ICONST 'i' -#define STABS_STR_T_ARGLIST 'p' -#define STABS_STR_T_PARAM_REG 'R' -#define STABS_STR_T_VAR_REG 'r' -#define STABS_STR_T_VAR_FSCOPE 'S' -#define STABS_STR_T_VAR_LOCAL 's' -#define STABS_STR_T_TYPE_NAME 't' -#define STABS_STR_T_TYPE_STRUCT 'T' -#define STABS_STR_T_PARAM_REF 'v' -#define STABS_STR_T_PROC_SVAR 'V' - -/* Type descriptor */ -#define STABS_STR_D_METHOD '#' -#define STABS_STR_D_PTR '*' -#define STABS_STR_D_REF '&' -#define STABS_STR_D_ATTR '@' -#define STABS_STR_D_ARRAY 'a' -#define STABS_STR_D_VOLATILE 'B' -#define STABS_STR_D_ENUM 'e' -#define STABS_STR_D_TFUNC 'f' -#define STABS_STR_D_CONST 'k' -#define STABS_STR_D_RANGE 'r' -#define STABS_STR_D_STRUCT 's' -#define STABS_STR_D_BITSTRING 'S' -#define STABS_STR_D_UNION 'u' -#define STABS_STR_D_CREF 'x' - -/* AIX attributes */ -#define STABS_STR_AIX_SIZE 's' -#define STABS_STR_AIX_STRING 'S' -#define STABS_STR_AIX_VECTOR 'V' - -/* Usefull local functions */ -edfmtstabstype_t *edfmt_stabs_type(char **str, char *link); -edfmtstabsdata_t *edfmt_stabs_data(char **str); - -#endif diff -Nru eresi-0.8a25/libedfmt/Makefile eresi-0.0.20110516/libedfmt/Makefile --- eresi-0.8a25/libedfmt/Makefile 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/Makefile 2011-05-16 11:34:52.000000000 +0000 @@ -18,13 +18,13 @@ NAME32 = libedfmt32 NAME64 = libedfmt64 -CFLAGS32 += -Wall -fPIC -g3 -O2 -Iinclude -I ../libaspect/include/ \ - -I../libelfsh/include/ -DELFSH_INTERN -DERESI32 +CFLAGS32 += -Wall -fPIC -g3 -Iinclude -I ../libaspect/include/ \ + -I../libelfsh/include/ -DERESI32 $(EXTRACFLAGS) -CFLAGS64 += -Wall -fPIC -g3 -O2 -Iinclude -I ../libaspect/include/ \ - -I../libelfsh/include/ -DELFSH_INTERN -DERESI64 +CFLAGS64 += -Wall -fPIC -g3 -Iinclude -I ../libaspect/include/ \ + -I../libelfsh/include/ -DERESI64 $(EXTRACFLAGS) -LDFLAGS32 += -L../libaspect/ -laspect32 -L../libelfsh/ -lelfsh32 +LDFLAGS32 += -L../libaspect/ -laspect32 -L../libelfsh/ -lelfsh32 # -L../liballocproxy -lallocproxy LDFLAGS64 += -L../libaspect/ -laspect64 -L../libelfsh/ -lelfsh64 \ diff -Nru eresi-0.8a25/libedfmt/stabs.c eresi-0.0.20110516/libedfmt/stabs.c --- eresi-0.8a25/libedfmt/stabs.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/stabs.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,15 +1,14 @@ /** - * @defgroup libedfmt Libedfmt : The Elf debug format library of ELFsh + * @defgroup libedfmt libedfmt: The ERESI debug formats library + * @brief Implement DWARF2, STABS, and the ERESI debug formats. */ -/* -** @file stabs.c +/** +* @file libedfmt/stabs.c ** @ingroup libedfmt +** @brief Interface routines for STABS debug format. ** ** Started Jan 01 2007 21:30:13 mxatone -** -** -** $Id: stabs.c,v 1.18 2007-06-02 08:28:51 mxatone Exp $ -** +** $Id: stabs.c 1397 2009-09-13 02:19:08Z may $ */ #include "libedfmt.h" @@ -21,7 +20,7 @@ * This version of stabs format parsing has been approved for x86 * and gentoo linux, some bugs can append on Sparc, more test will * be done to make this work correctly - * @file stabs.c +* @file libedfmt/stabs.c */ #define STABS_HNAME_TYPE_REF "stabs_type_reference" @@ -287,8 +286,7 @@ break; } - /* Ok we have a max arguments, but if you got more than 20 arguments, - blame yourself !! */ + /* Ok we have a max arguments, but if you got more than 20 arguments, blame yourself !! */ if (arg_index < STABS_MAX_ARGUMENTS) { my_str = stabs_c_str; diff -Nru eresi-0.8a25/libedfmt/stabs-trans.c eresi-0.0.20110516/libedfmt/stabs-trans.c --- eresi-0.8a25/libedfmt/stabs-trans.c 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/stabs-trans.c 2011-05-16 11:34:51.000000000 +0000 @@ -1,19 +1,17 @@ -/* -** @file stabs-trans.c +/** +* @file libedfmt/stabs-trans.c ** @ingroup libedfmt +** @brief Translation from STABS to EDFMT debug format. ** ** Started Fev 02 2007 14:35:03 mxatone -** -** -** $Id: stabs-trans.c,v 1.11 2007-06-02 19:18:11 mxatone Exp $ -** +** $Id: stabs-trans.c 1399 2009-09-16 14:22:04Z eduardo $ */ #include "libedfmt.h" /** * Translation from stabs representation into uniform format - * @file stabs-trans.c +* @file libedfmt/stabs-trans.c */ #define STABS_HNAME_TYPE_ADD "stabs_type_added" @@ -289,7 +287,7 @@ continue; uni_func = edfmt_add_func(func->data->name, func->rettype->transtype, - func->s_addr, func->e_addr); + func->s_addr, func->e_addr, 0); if (!uni_func) continue; diff -Nru eresi-0.8a25/libedfmt/stabs-utils.c eresi-0.0.20110516/libedfmt/stabs-utils.c --- eresi-0.8a25/libedfmt/stabs-utils.c 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/stabs-utils.c 2011-05-16 11:34:52.000000000 +0000 @@ -1,11 +1,10 @@ -/* -** @file stabs-utils.c +/** +* @file libedfmt/stabs-utils.c ** @ingroup libedfmt -** Started Jan 01 2007 21:30:13 mxatone -** -** -** $Id: stabs-utils.c,v 1.6 2007-03-07 16:45:35 thor Exp $ +** @brief Low-level utils for STABS parsing. ** +** Started Jan 01 2007 21:30:13 mxatone +** $Id: stabs-utils.c 1397 2009-09-13 02:19:08Z may $ */ #include "libedfmt.h" @@ -30,7 +29,7 @@ delim = strchr(*str, c_delim); - csize = delim ? delim - *str + 1 : size; + csize = delim ? (u_int) (delim - *str) + 1 : size; if (csize > size) csize = size; diff -Nru eresi-0.8a25/libedfmt/.svn/all-wcprops eresi-0.0.20110516/libedfmt/.svn/all-wcprops --- eresi-0.8a25/libedfmt/.svn/all-wcprops 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/950/trunk/libedfmt -END -edfmt.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/910/trunk/libedfmt/edfmt.c -END -stabs-trans.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/910/trunk/libedfmt/stabs-trans.c -END -dwarf2-utils.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/910/trunk/libedfmt/dwarf2-utils.c -END -dwarf2-abbrev.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/946/trunk/libedfmt/dwarf2-abbrev.c -END -dwarf2.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/910/trunk/libedfmt/dwarf2.c -END -api.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libedfmt/api.c -END -dwarf2-trans.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libedfmt/dwarf2-trans.c -END -stabs-utils.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/910/trunk/libedfmt/stabs-utils.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/950/trunk/libedfmt/Makefile -END -dwarf2-cfa.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libedfmt/dwarf2-cfa.c -END -stabs.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/910/trunk/libedfmt/stabs.c -END -edfmt-utils.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libedfmt/edfmt-utils.c -END diff -Nru eresi-0.8a25/libedfmt/.svn/entries eresi-0.0.20110516/libedfmt/.svn/entries --- eresi-0.8a25/libedfmt/.svn/entries 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libedfmt -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -edfmt.c -file - - - - -2008-04-06T23:15:31.924879Z -2d2648c9aebea3b27b962234d43e1cc2 -2008-03-14T10:02:38.365034Z -910 -enioh - -stabs-trans.c -file - - - - -2008-04-06T23:15:31.965904Z -7f560c0576580a3809fb0bb3236cfcd9 -2008-03-14T10:02:38.365034Z -910 -enioh - -include -dir - -dwarf2-utils.c -file - - - - -2008-04-06T23:15:31.977188Z -33a18c4ee64b60670eb958fe75b9194a -2008-03-14T10:02:38.365034Z -910 -enioh - -doc -dir - -dwarf2-abbrev.c -file - - - - -2008-04-06T23:15:31.987903Z -f24ca30fa6df578770cee80fdca73ae7 -2008-03-27T22:53:48.747992Z -946 -may - -dwarf2.c -file - - - - -2008-04-06T23:15:31.999879Z -c72f95c0b04ea8153bdc9b06d27807a0 -2008-03-14T10:02:38.365034Z -910 -enioh - -api.c -file - - - - -2008-04-06T23:15:32.010903Z -6f2044fdd14bdab12745502017dae9cd -2008-03-27T22:53:48.747992Z -946 -may - -dwarf2-trans.c -file - - - - -2008-04-06T23:15:32.022557Z -e192079ad02d600012271197fce60e9e -2008-03-27T22:53:48.747992Z -946 -may - -stabs-utils.c -file - - - - -2008-04-06T23:15:32.033958Z -a9d1f252c16bda7d580e495d819b462d -2008-03-14T10:02:38.365034Z -910 -enioh - -Makefile -file - - - - -2008-04-06T23:15:32.044888Z -e5445e38a1d80bae03d694024f5edd52 -2008-03-29T07:54:04.209482Z -950 -enioh - -dwarf2-cfa.c -file - - - - -2008-04-06T23:15:32.056643Z -6e2a163cd0162ea33797390cb673c0f6 -2008-03-27T22:53:48.747992Z -946 -may - -stabs.c -file - - - - -2008-04-06T23:15:32.067986Z -1ab33b942229cb7ed426630009776eca -2008-03-14T10:02:38.365034Z -910 -enioh - -edfmt-utils.c -file - - - - -2008-04-06T23:15:32.079329Z -9befb96e5567b28a6a39c3efc55ff182 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libedfmt/.svn/format eresi-0.0.20110516/libedfmt/.svn/format --- eresi-0.8a25/libedfmt/.svn/format 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/api.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/api.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/api.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/api.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,909 +0,0 @@ -/** - * @file api.c - * @ingroup libedfmt - * api.c for libedfmt (The Elf debug format library of ELFsh) - * - * Started Jan 26 2007 11:54:22 mxatone - * - * $Id: api.c,v 1.15 2007-06-02 08:28:50 mxatone Exp $ - * - */ - -#include "libedfmt.h" - -/** - * Unique debug format base variable - */ -edfmtinfo_t *uniinfo = NULL; - -u_char file_active = 0; -elfshobj_t *cu_obj = NULL; - -#define API_HTYPE_NAME "edfmt_api_htype" -#define API_HVAR_NAME "edfmt_api_hvar" -#define API_HFUNC_NAME "edfmt_api_hfunc" - -#define API_GETPTR(_var, _size, _ret) \ -do { \ - _var = edfmt_alloc_pool(&(uniinfo->alloc_pool), \ - &(uniinfo->alloc_pos), \ - &(uniinfo->alloc_size), \ - API_ALLOC_STEP, _size); \ -if (_var == NULL) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Pool allocation failed", _ret); \ -} while (0) - -#define EDFMT_COPY_NAME(_dest, _source) \ -do { \ - int index, len; \ - if (strlen(_source) >= EDFMT_NAME_SIZE) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Invalid name size", NULL); \ - strcpy(_dest->name, _source); \ - len = strlen(_dest->name); \ - for (index = 0; index < len; index++) \ - if (_dest->name[index] == ' ') \ - _dest->name[index] = '_'; \ -} while (0) - -#define EDFMT_NEW_TYPE(_type, _name, _up, _ret) \ -do { \ - _type = edfmt_check_type(_name); \ - if (_type) \ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, _type); \ - API_GETPTR(_type, sizeof(edfmttype_t), _ret); \ - EDFMT_COPY_NAME(_type, _name); \ - _type->valid = 1; \ - if (_up) \ - edfmt_update_type(_type); \ -} while(0) - -#define EDFMT_NEW_VAR(_var, _name, _up, _ret) \ -do { \ - _var = edfmt_check_var(_name); \ - if (_var) \ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, _var); \ - API_GETPTR(_var, sizeof(edfmtvar_t), _ret); \ - EDFMT_COPY_NAME(_var, _name); \ - if (_up) \ - edfmt_update_var(_var); \ -} while(0) - -#define EDFMT_NEW_FUNC(_func, _name, _up, _ret) \ -do { \ - _func = edfmt_check_func(_name); \ - if (_func) \ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, _func); \ - API_GETPTR(_func, sizeof(edfmtfunc_t), _ret); \ - EDFMT_COPY_NAME(_func, _name); \ - if (_up) \ - edfmt_update_func(_func); \ -} while(0) - -#define EDFMT_NEW_ARG(_arg, _name, _ret) \ -do { \ - API_GETPTR(_arg, sizeof(edfmtfuncarg_t), _ret); \ - EDFMT_COPY_NAME(_arg, _name); \ -} while(0) - -/** - * Init an add context - * @param input file to init - */ -int edfmt_add_init(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cu_obj = file; - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file object", NULL); - - /* Init the object if needed */ - if (file->debug_format.uni == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - file->debug_format.uni, sizeof(edfmtinfo_t), NULL); - uniinfo = file->debug_format.uni; - - hash_init(&(uniinfo->htype), API_HTYPE_NAME, 30, ASPECT_TYPE_UNKNOW); - hash_init(&(uniinfo->hvar), API_HVAR_NAME, 30, ASPECT_TYPE_UNKNOW); - hash_init(&(uniinfo->hfunc), API_HFUNC_NAME, 30, ASPECT_TYPE_UNKNOW); - } - else - { - uniinfo = file->debug_format.uni; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * End an add context - */ -int edfmt_add_end() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - while (uniinfo && uniinfo->lfile && uniinfo->lfile->parent != NULL) - uniinfo->lfile = uniinfo->lfile->parent; - - /* Reset global pointers */ - cu_obj = NULL; - uniinfo = NULL; - file_active = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * We don't use the same hash tables depending of the current scope - */ -#define API_GET_FROM_SCOPE(_name) \ -uniinfo->lfile == NULL ? &(uniinfo->_name) : &(uniinfo->lfile->_name); - -/** - * Check if we already have this type, then avoid loosing precious time - * @param name check if a type already exist - * @return type found or NULL - */ -edfmttype_t *edfmt_check_type(char *name) -{ - edfmttype_t *seek_type = NULL; - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", NULL); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(htype); - - /* Research on the right table */ - seek_type = (edfmttype_t *) hash_get(htable, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, seek_type); -} - -/** - * Check if we already have this variable, then avoid loosing precious time - * @param name check if this variable exist - * @return var found or NULL - */ -edfmtvar_t *edfmt_check_var(char *name) -{ - edfmtvar_t *seek_var = NULL; - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", NULL); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(hvar); - - /* Research on the right table */ - seek_var = (edfmtvar_t *) hash_get(htable, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, seek_var); -} - -/** - * Check if we already have this function, then avoid loosing precious time - * @param name check if this function exist - * @return function found or NULL - */ -edfmtfunc_t *edfmt_check_func(char *name) -{ - edfmtfunc_t *seek_func = NULL; - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", NULL); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(hfunc); - - /* Research on the right table */ - seek_func = (edfmtfunc_t *) hash_get(htable, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, seek_func); -} - -/** - * Update type list linked list - * @param type input new type - */ -int edfmt_update_type(edfmttype_t *type) -{ - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", 0); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(htype); - - type->file = uniinfo->lfile; - - /* Global scope */ - if (uniinfo->lfile == NULL) - { - if (uniinfo->types == NULL) - uniinfo->types = type; - else - uniinfo->ltype->next = type; - - uniinfo->ltype = type; - } - else /* Local scope */ - { - if (uniinfo->lfile->types == NULL) - uniinfo->lfile->types = type; - else - uniinfo->lfile->ltype->next = type; - - uniinfo->lfile->ltype = type; - } - - hash_add(htable, strdup(type->name), (void *) type); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Update var linked list - * @param var input new var - */ -int edfmt_update_var(edfmtvar_t *var) -{ - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", NULL); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(hvar); - - /* Global scope */ - if (uniinfo->lfile == NULL || file_active == 0) - { - if (uniinfo->vars == NULL) - uniinfo->vars = var; - else - uniinfo->lvar->next = var; - - uniinfo->lvar = var; - } - else - { - /* Local scope */ - if (uniinfo->lfile->vars == NULL) - uniinfo->lfile->vars = var; - else - uniinfo->lfile->lvar->next = var; - - uniinfo->lfile->lvar = var; - } - - hash_add(htable, strdup(var->name), (void *) var); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Update function linked list - * @param func input new function - */ -int edfmt_update_func(edfmtfunc_t *func) -{ - hash_t *htable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Global pointer uninitialise", NULL); - - /* Setup hash table depending of current scope */ - htable = API_GET_FROM_SCOPE(hfunc); - - /* Global scope */ - if (uniinfo->lfile == NULL || file_active == 0) - { - if (uniinfo->funcs == NULL) - uniinfo->funcs = func; - else - uniinfo->lfunc->next = func; - - uniinfo->lfunc = func; - } - else - { - /* Local scope */ - if (uniinfo->lfile->funcs == NULL) - uniinfo->lfile->funcs = func; - else - uniinfo->lfile->lfunc->next = func; - - uniinfo->lfile->lfunc = func; - } - - hash_add(htable, strdup(func->name), (void *) func); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Retrieve uniinfo pointer - * @param file source file - * @return unform information structure - */ -edfmtinfo_t *edfmt_get_uniinfo(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramter", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (edfmtinfo_t *) file->debug_format.uni); -} - -/** - * Sometime you add an element on the wrong context, you didn't really know - * where this element belong to, this function delete the type from its previous - * emplacement and add it the current file context - * @param type source type - */ -int edfmt_change_type_nfile(edfmttype_t *type) -{ - edfmttype_t *tmp_type = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramter", -1); - - /* Delete in its file */ - if (type->file == NULL) - { - if (uniinfo->types == type) - uniinfo->types = type->next; - else - tmp_type = uniinfo->types; - } - else - { - if (type->file->types == type) - type->file->types = type->next; - else - tmp_type = type->file->types; - } - - if (tmp_type != NULL) - { - /* Find our type in the file */ - while (tmp_type && tmp_type->next != type) - tmp_type = tmp_type->next; - - /* We update the precedent file */ - if (tmp_type && tmp_type->next) - tmp_type->next = type->next; - } - - if (edfmt_check_type(type->name) == NULL) - { - /* Add to the current file */ - edfmt_update_type(type); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Restore parent file - * this function restore a parent file (.c file), it helps to - * manage symbols declared for a given header then reback on the normal file - * This function was add for dwarf2 support. - * @return parent file - */ -edfmtfile_t *edfmt_restore_parent_file() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (uniinfo->lfile == NULL || uniinfo->lfile->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No parents", NULL); - - uniinfo->lfile = uniinfo->lfile->parent; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, uniinfo->lfile); -} - -/** - * Retreive current file - * @return parent file - */ -edfmtfile_t *edfmt_get_current_file() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!uniinfo) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No uniform informations", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, uniinfo->lfile); -} - -/** - * Search for a specific included file - * @param file base file - * @param name include name - * @return include file pointer or NULL - */ -edfmtfile_t *edfmt_get_inc_file(edfmtfile_t *file, char *name) -{ - edfmtfile_t *inc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (inc = file->child; inc != NULL; inc = inc->next) - { - if (!strcmp(name, inc->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, inc); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Add a new file - * @param parent_file parent file (optional) - * @param name filename - * @param start starting address (optional) - * @param end ending address (optional) - * @return created file - */ -edfmtfile_t *edfmt_add_file(edfmtfile_t *parent_file, char *name, - eresi_Addr start, eresi_Addr end) -{ - edfmtfile_t *file, *already_file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramter", NULL); - - /* We update link between new and parent file */ - if (parent_file != NULL) - { - already_file = edfmt_get_inc_file(parent_file, name); - - if (already_file != NULL) - { - uniinfo->lfile = already_file; - file_active = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, already_file); - } - } - - XALLOC(__FILE__, __FUNCTION__, __LINE__,file, sizeof(edfmtfile_t), NULL); - - EDFMT_COPY_NAME(file, name); - file->start = start; - file->end = end; - - /* Init hash tables */ - hash_init(&(file->htype), API_HTYPE_NAME, 30, ASPECT_TYPE_UNKNOW); - hash_init(&(file->hvar), API_HVAR_NAME, 30, ASPECT_TYPE_UNKNOW); - hash_init(&(file->hfunc), API_HFUNC_NAME, 30, ASPECT_TYPE_UNKNOW); - - /* Update pointers depending if he get a parrent */ - if (parent_file != NULL) - { - if (parent_file->child == NULL) - parent_file->child = file; - else - parent_file->lchild->next = file; - - parent_file->lchild = file; - file->parent = parent_file; - } - else - { - if (uniinfo->files == NULL) - uniinfo->files = file; - else - while (uniinfo->files->parent != NULL) - uniinfo->files = uniinfo->files->parent; - - if (uniinfo->lfile != NULL) - uniinfo->lfile->next = file; - } - - uniinfo->lfile = file; - file_active = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); -} - -/** - * Reset file activity - */ -int edfmt_reset_file() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - file_active = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Reactive file activity - */ -int edfmt_reactive_file() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - file_active = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create an unknown type - * @param name new type name - * @return result type - */ -edfmttype_t *edfmt_add_type_unk(char *name) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_UNK; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a basic type - * @param name new type name - * @param size type size - * @return result type - */ -edfmttype_t *edfmt_add_type_basic(char *name, int size) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_BASIC; - ltype->size = size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create an array type - * @param name new type name - * @param size type size - * @param type sub type - * @return result type - */ -edfmttype_t *edfmt_add_type_array(char *name, - int size, edfmttype_t *type) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_ARRAY; - ltype->parent = type; - ltype->size = size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a ptr type - * @param name new type name - * @param type sub type - * @return result type - */ -edfmttype_t *edfmt_add_type_ptr(char *name, edfmttype_t *type) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_PTR; - ltype->parent = type; - ltype->size = sizeof(void *); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a structure type - * @param name new type name - * @param size structure size - * @return result type - */ -edfmttype_t *edfmt_add_type_struct(char *name, int size) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_STRUCT; - ltype->size = size; - ltype->valid = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create an union type - * @param name new type name - * @param size union size - * @return result type - */ -edfmttype_t *edfmt_add_type_union(char *name, int size) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_UNION; - ltype->size = size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create an attribute type - * @param tstruct structure type - * @param name new type name - * @param start start offset - * @param size member size - * @param type member type - * @return result type - */ -edfmttype_t *edfmt_add_type_attr(edfmttype_t *tstruct, char *name, - int start, int size, edfmttype_t *type) -{ - edfmttype_t *ltype, *last = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!tstruct || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 0, NULL); - ltype->type = EDFMT_TYPE_ATTR; - ltype->parent = tstruct; - ltype->child = type; - ltype->start = start; - ltype->size = size ? size : ltype->size; - - if (ltype->size <= 0) - ltype->size = tstruct->size - start; - - tstruct->tmp_ssize += ltype->size; - - /* Update valid flag */ - tstruct->valid = tstruct->tmp_ssize == tstruct->size ? 1 : 0; - - if (type && type->size > 0) - ltype->size = type->size; - - if (tstruct->child == NULL) - tstruct->child = ltype; - else - { - /* Iterate to find the end */ - for (last = tstruct->child; last && last->next; last = last->next); - - if (last) - { - if (tstruct->type != EDFMT_TYPE_UNION && - last->size == tstruct->size - last->start) - last->size = start - last->start; - - last->next = ltype; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a void type - * @param name new type name - * @return result type - */ -edfmttype_t *edfmt_add_type_void(char *name) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_VOID; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a link type - * @param name new type name - * @param type link to this type - * @return result type - */ -edfmttype_t *edfmt_add_type_link(char *name, edfmttype_t *type) -{ - edfmttype_t *ltype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_TYPE(ltype, name, 1, NULL); - ltype->type = EDFMT_TYPE_LINK; - ltype->parent = type; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ltype); -} - -/** - * Create a global variable - * @param type variable type - * @param name variable name - * @param addr variable address - * @return result variable - */ -edfmtvar_t *edfmt_add_var_global(edfmttype_t *type, char *name, eresi_Addr addr) -{ - edfmtvar_t *lvar; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!type || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_VAR(lvar, name, 1, NULL); - lvar->scope = EDFMT_SCOPE_GLOBAL; - lvar->addr = addr; - lvar->type = type; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lvar); -} - -/** - * Create a function - * @param name new function name - * @param ret return type - * @param start start address - * @param end end addresss - * @return result function - */ -edfmtfunc_t *edfmt_add_func(char *name, edfmttype_t *ret, - eresi_Addr start, eresi_Addr end) -{ - edfmtfunc_t *lfunc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_FUNC(lfunc, name, 1, NULL); - lfunc->rettype = ret; - lfunc->start = start; - lfunc->end = end; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lfunc); -} - -/** - * Add arguments on a function - * @param func function structure (parent) - * @param name argument name - * @param reg base reg - * @param pos position (from reg or stack) - * @param type argument type - * @return result function argument - */ -edfmtfuncarg_t *edfmt_add_arg(edfmtfunc_t *func, char *name, - u_int reg, int pos, edfmttype_t *type) -{ - edfmtfuncarg_t *larg, *find; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!func || !name || !type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - EDFMT_NEW_ARG(larg, name, NULL); - larg->type = type; - larg->reg = reg; - larg->pos = pos; - - /* Search last argument */ - for (find = func->arguments; - find != NULL && find->next != NULL; - find = find->next); - - /* Update pointer as needed */ - if (find == NULL) - func->arguments = larg; - else - find->next = larg; - - /* Then update arg counting variable */ - func->argc++; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, larg); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-abbrev.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-abbrev.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-abbrev.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-abbrev.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1155 +0,0 @@ -/* -** @file dwarf2-abbrev.c -** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-abbrev.c,v 1.14 2007-05-20 19:13:57 mxatone Exp $ -** -*/ - -#include "libedfmt.h" - -char *alloc_pool = NULL; -int alloc_pos = 0; -int alloc_size = 0; - -#define DW2_GETPTR(_var, _size, _ret) \ -do { \ - _var = edfmt_alloc_pool(&alloc_pool, \ - &alloc_pos, \ - &alloc_size, \ - DWARF2_ALLOC_STEP, _size); \ -if (_var == NULL) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Pool allocation failed", _ret); \ -} while (0) - -/** - * Lookup on abbrev_table and retrieve en abbrev entity (structure) - * @param num_fetch used to found the abbrev entity on the abbrev hash table - * @return abbrev entity structure - */ -static edfmtdw2abbent_t *edfmt_dwarf2_lookup_abbrev(u_int num_fetch) -{ - char ckey[EDFMT_CKEY_SIZE]; - edfmtdw2abbent_t *res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - edfmt_ckey(ckey, EDFMT_CKEY_SIZE, num_fetch); - res = (edfmtdw2abbent_t *) hash_get(&(current_cu->abbrev_table), ckey); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); -} - -/** - * Read an abbrev entry @ this position - * @param ent abbrev entity to fill - * @param fnum abbrev entity fetch number - * @param ipos abbrev entity key to set - */ -int edfmt_dwarf2_abbrev_read(edfmtdw2abbent_t *ent, u_long fnum, u_long ipos) -{ - edfmtdw2abbent_t *fetch; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!ent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Do we have this section ? */ - if (dwarf2_data(abbrev) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".debug_abbrev section not available", -1); - - fetch = edfmt_dwarf2_lookup_abbrev(fnum); - - if (!fetch) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No entry found", -1); - - memcpy(ent, fetch, sizeof(edfmtdw2abbent_t)); - - /* Fill main data */ - ent->key = ipos; - //edfmt_ckey(ent->ckey, EDFMT_CKEY_SIZE, ipos); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Clean allocated buffer for enumeration - * @param abbrev_table store abbrev entities (structure) - */ -int edfmt_dwarf2_abbrev_enum_clean(hash_t *abbrev_table) -{ - char **keys; - u_int index; - int keynbr; - u_long *value; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (!abbrev_table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid arguments", -1); - - /* Clean every elements on the hash table */ - keys = hash_get_keys(abbrev_table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - value = (u_long *) hash_get(abbrev_table, keys[index]); - - if (value) - XFREE(__FILE__, __FUNCTION__, __LINE__,value); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Parse the .debug_abbrev format and store the result on the abbrev table - * @param abbrev_table store abbrev entities (structure) - */ -int edfmt_dwarf2_abbrev_enum(hash_t *abbrev_table) -{ - u_int num; - u_int base; - edfmtdw2abbent_t *ent; - char ckey[EDFMT_CKEY_SIZE]; - u_int allocattr = 0; - u_int attri = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!abbrev_table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid arguments", -1); - - /* Do we have this section ? */ - if (dwarf2_data(abbrev) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".debug_abbrev section not available", -1); - - base = dwarf2_pos(abbrev); - - do { - /* Fetch the key number */ - dwarf2_iuleb128(num, abbrev); - - /* A level end */ - if (num == 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - DW2_GETPTR(ent, sizeof(edfmtdw2abbent_t), -1); - - dwarf2_iuleb128(ent->tag, abbrev); - dwarf2_iread_1(ent->children, abbrev); - - attri = allocattr = 0; - - /* Parse attributes */ - do { - /* Fill attribute structure */ - dwarf2_iuleb128(ent->attr[attri].attr, abbrev); - dwarf2_iuleb128(ent->attr[attri].form, abbrev); - } while (ent->attr[attri++].attr && attri < DW2_MAX_ATTR); - - ent->attrsize = attri > 1 ? attri - 1 : attri; - - /* Add into abbrev table */ - edfmt_ckey(ckey, EDFMT_CKEY_SIZE, num); - hash_add(abbrev_table, strdup(ckey), (void *) ent); - } while (dwarf2_pos(abbrev) < dwarf2_size(abbrev)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Increment the info position without reading every elements - * then we avoid losing data access time on elements that we don't need. - * @param attr abbrev attribute to iterate - */ -static int edfmt_dwarf2_form_it(edfmtdw2abbattr_t *attr) -{ - long data; - u_long size; - u_int form; - - NOPROFILER_IN(); - - /* We keep current position then we can read value for a specific element later */ - attr->infopos = dwarf2_pos(info); - form = attr->form; - -fvstart: - - /** - * I will not explain every element because it will be too long - * you can read dwarf2 documentation for more information. - */ - switch (form) - { - case DW_FORM_ref_addr: - dwarf2_inc_pos(info, current_cu->addr_size); - break; - case DW_FORM_addr: - dwarf2_inc_pos(info, current_cu->addr_size); - break; - case DW_FORM_block1: - dwarf2_iread_1(size, info); - if (size > 0) - dwarf2_inc_pos(info, size); - break; - case DW_FORM_block2: - dwarf2_iread_2(size, info); - if (size > 0) - dwarf2_inc_pos(info, size); - break; - case DW_FORM_block4: - dwarf2_iread_4(size, info); - if (size > 0) - dwarf2_inc_pos(info, size); - break; - case DW_FORM_ref1: - case DW_FORM_data1: - dwarf2_inc_pos(info, 1); - break; - case DW_FORM_ref2: - case DW_FORM_data2: - dwarf2_inc_pos(info, 2); - break; - case DW_FORM_ref4: - case DW_FORM_strp: - case DW_FORM_data4: - dwarf2_inc_pos(info, 4); - break; - case DW_FORM_ref8: - case DW_FORM_data8: - dwarf2_inc_pos(info, 8); - break; - case DW_FORM_string: - dwarf2_inc_pos(info, strlen(dwarf2_ac_pos(info))+1); - break; - case DW_FORM_block: - dwarf2_iuleb128(size, info); - dwarf2_inc_pos(info, size); - break; - case DW_FORM_flag: - dwarf2_inc_pos(info, 1); - break; - case DW_FORM_udata: - dwarf2_iuleb128(size, info); - break; - case DW_FORM_sdata: - dwarf2_ileb128(data, info); - break; - case DW_FORM_ref_udata: - dwarf2_iuleb128(size, info); - break; - case DW_FORM_indirect: - dwarf2_ileb128(data, info); - form = data; - goto fvstart; - break; - } - - NOPROFILER_ROUT(0); -} - -/** - * Parse a form value - * @param attr abbrev attribute to fill - */ -int edfmt_dwarf2_form_value(edfmtdw2abbattr_t *attr) -{ - u_int i; - char *ptr; - u_char addr[10]; /* 10 should be enough */ - u_int data; - long ddata; - - NOPROFILER_IN(); - - if (dwarf2_data(info) == NULL) - NOPROFILER_ROUT(-1); - - /* Reset position on saved value */ - dwarf2_pos(info) = attr->infopos; - -fvstart: - - /** - * I will not explain every element because it will be too long - * you can read dwarf2 documentation for more information. - */ - switch (attr->form) - { - case DW_FORM_ref_addr: - for (i = 0; i < current_cu->addr_size; i++) - dwarf2_ipos(addr[i], info, u_char); - - attr->u.udata = *(u_long *) addr; - break; - case DW_FORM_addr: - DW2_GETPTR(attr->u.vbuf, current_cu->addr_size, -1); - for (i = 0; i < current_cu->addr_size; i++) - dwarf2_ipos(attr->u.vbuf[i], info, u_char); - break; - case DW_FORM_block1: - case DW_FORM_block2: - case DW_FORM_block4: - switch (attr->form) - { - case DW_FORM_block1: - dwarf2_iread_1(attr->asize, info); - break; - case DW_FORM_block2: - dwarf2_iread_2(attr->asize, info); - break; - case DW_FORM_block4: - dwarf2_iread_4(attr->asize, info); - break; - } - - if (attr->asize > 0) - { - DW2_GETPTR(attr->u.vbuf, attr->asize, -1); - - for (i = 0; i < attr->asize; i++) - dwarf2_ipos(attr->u.vbuf[i], info, u_char); - } - break; - case DW_FORM_data1: - dwarf2_iread_1(ddata, info); - attr->u.udata = (u_long) ddata & 0xFF; - break; - case DW_FORM_data2: - dwarf2_iread_2(ddata, info); - attr->u.udata = (u_long) ddata & 0xFFFF; - break; - case DW_FORM_data4: - dwarf2_iread_4(ddata, info); - attr->u.udata = (u_long) ddata & 0xFFFFFFFF; - break; - case DW_FORM_data8: - dwarf2_iread_8(ddata, info); - attr->u.udata = (u_long) ddata; - break; - case DW_FORM_string: - attr->u.str = dwarf2_ac_pos(info); - dwarf2_inc_pos(info, strlen(attr->u.str)+1); - break; - case DW_FORM_block: - dwarf2_iuleb128(attr->asize, info); - - DW2_GETPTR(attr->u.vbuf, attr->asize, -1); - - for (i = 0; i < attr->asize; i++) - dwarf2_ipos(attr->u.vbuf[i], info, char); - break; - case DW_FORM_flag: - dwarf2_iread_1(ddata, info); - attr->u.udata = (u_long) ddata & 0xFF; - break; - case DW_FORM_strp: - ptr = (char *) dwarf2_data(str); - dwarf2_iread_4(data, info); - attr->u.str = (char *) ptr + data; - break; - case DW_FORM_udata: - dwarf2_iuleb128(attr->u.udata, info); - break; - case DW_FORM_sdata: - dwarf2_ileb128(attr->u.sdata, info); - break; - case DW_FORM_ref1: - dwarf2_iread_1(attr->u.udata, info); - break; - case DW_FORM_ref2: - dwarf2_iread_2(attr->u.udata, info); - break; - case DW_FORM_ref4: - dwarf2_iread_4(attr->u.udata, info); - break; - case DW_FORM_ref8: - dwarf2_iread_8(attr->u.udata, info); - break; - case DW_FORM_ref_udata: - dwarf2_iuleb128(attr->u.udata, info); - break; - case DW_FORM_indirect: - /* Read form from .debug_info */ - dwarf2_ileb128(data, info); - - /* Update attribute value and relaunch the function */ - attr->form = data; - goto fvstart; - break; - } - - NOPROFILER_ROUT(0); -} - - -/** - * Follow .debug_info form using abbrev_table as structure reference - * @param abbent abbrev entity to fill - * @param pos info position - */ -int edfmt_dwarf2_form(edfmtdw2abbent_t *abbent, u_int pos) -{ - u_int num_fetch, i; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do we have this section ? */ - if (dwarf2_data(abbrev) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".debug_info section not available", -1); - - dwarf2_pos(info) = pos; - - /* Retrieve abbrev number */ - dwarf2_iuleb128(num_fetch, info); - - /* We didn't use num_fetch == 0 */ - if (num_fetch == 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Retreive an abbrev element */ - if (edfmt_dwarf2_abbrev_read(abbent, num_fetch, pos) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to read the structure", -1); - - /* Resolv form value for each attribute */ - for (i = 0; abbent->attr[i].attr; i++) - { - switch(abbent->attr[i].attr) - { - /* This tag inform for the next element (after childs) we have to get it */ - case DW_AT_sibling: - abbent->attr[i].infopos = dwarf2_pos(info); - edfmt_dwarf2_form_value(abbent->attr + i); - abbent->sib = current_cu->start_pos + abbent->attr[i].u.udata; - break; - default: - /* All other elements are just iterate */ - edfmt_dwarf2_form_it(abbent->attr + i); - } - } - - /* Update some position depending of the current status */ - if (abbent->children) - abbent->child = dwarf2_pos(info); - else if (abbent->sib <= 0) - abbent->sib = dwarf2_pos(info); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * Read macinfo data - */ -int edfmt_dwarf2_mac(u_long offset) -{ - int line = 0, file = 0; - u_char type; - u_int i; - char *str = NULL; - edfmtdw2macro_t *mac; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do we have this section ? */ - if (dwarf2_data(macinfo) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".debug_macinfo section not available", -1); - - /* Update position offset */ - dwarf2_pos(macinfo) = offset; - - do { - dwarf2_iread_1(type, macinfo); - - switch(type) - { - case DW_MACINFO_define: - case DW_MACINFO_undef: - DW2_GETPTR(mac, sizeof(edfmtdw2macro_t), -1); - - mac->fileno = file; - mac->def = type == DW_MACINFO_define ? 1 : 0; - - dwarf2_iuleb128(mac->line, macinfo); - mac->str = dwarf2_ac_pos(macinfo); - dwarf2_inc_pos(macinfo, strlen(mac->str)+1); - - /* Find the first space or ( */ - for (i = 0; i < DW2_MACRON_SIZE && mac->str[i]; i++) - if (mac->str[i] == ' ' || mac->str[i] == '(') - break; - - /* Copy the name */ - strncpy(mac->name, mac->str, i); - mac->name[DW2_MACRON_SIZE - 1] = 0x00; - - /* Add macro into compil unit */ - /* TODO: Reuse when it will be usefull - if (current_cu->macro == NULL) - current_cu->macro = mac; - else - current_cu->last_macro->next = mac; - - current_cu->last_macro = mac; - */ - break; - case DW_MACINFO_start_file: - dwarf2_iuleb128(line, macinfo); - dwarf2_iuleb128(file, macinfo); - break; - case DW_MACINFO_end_file: - file = 0; - line = 0; - break; - case DW_MACINFO_vendor_ext: - dwarf2_iuleb128(line, macinfo); - dwarf2_istr(str, macinfo); - - /* Add vendor parse engine here ? - But I don't know any vendor extension so ... */ - break; - } - } while (type != 0 && dwarf2_pos(macinfo) < dwarf2_size(macinfo)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Parse a dwarf2 location, this location describe where an element is store - * @param loc information will be store on this structure - * @param buf location is read from this buffer - * @param size size of the buffer - */ -int edfmt_dwarf2_loc(edfmtdw2loc_t *loc, u_char *buf, u_int size) -{ - u_int i, spos, bsize, tmp_op; - eresi_Addr tmp_value; - edfmtdw2loc_t stack[75]; - int bra; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (buf == NULL || size == 0 || loc == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", -1); - - spos = 0; - stack[spos].op = 0; - stack[spos].value = 0; - - /* Iterate for each part of the block */ - for (i = 0; i < size; i++) - { - /* Push a stack operand */ - stack[++spos].op = buf[i]; - - /** - * I will not explain every element because it will be too long - * you can read dwarf2 documentation for more information. - */ - switch(buf[i]) - { - case DW_OP_addr: - stack[spos].value = *(eresi_Addr *) (buf + (++i)); - i += sizeof(eresi_Addr) - 1; - break; - case DW_OP_deref: - stack[spos].op = DW_OP_addr; - if (stack[spos].value != NULL) - stack[spos].value = *(eresi_Addr *) stack[spos].value; - break; - case DW_OP_const1u: - stack[spos].value = *(u_char *) (buf + (++i)); - i++; - break; - case DW_OP_const1s: - stack[spos].value = *(char *) (buf + (++i)); - i++; - break; - case DW_OP_const2u: - stack[spos].value = *(u_short *) (buf + (++i)); - i += 2; - break; - case DW_OP_const2s: - stack[spos].value = *(short *) (buf + (++i)); - i += 2; - break; - case DW_OP_const4u: - stack[spos].value = *(u_int *) (buf + (++i)); - i += 4; - break; - case DW_OP_const4s: - stack[spos].value = *(int *) (buf + (++i)); - i += 4; - break; - case DW_OP_const8u: - stack[spos].value = *(u_long *) (buf + (++i)); - i += 8; - break; - case DW_OP_const8s: - stack[spos].value = *(long *) (buf + (++i)); - i += 8; - break; - case DW_OP_constu: - stack[spos].value = edfmt_read_uleb128(buf + (++i), &bsize); - i += bsize; - break; - case DW_OP_consts: - stack[spos].value = edfmt_read_leb128(buf + (++i), &bsize); - i += bsize; - break; - case DW_OP_dup: - stack[spos+1].op = stack[spos].op; - stack[spos+1].value = stack[spos].value; - spos++; - break; - case DW_OP_drop: - spos--; - break; - case DW_OP_over: - stack[spos+1].op = stack[spos - 1].op; - stack[spos+1].value = stack[spos - 1].value; - spos++; - break; - case DW_OP_pick: - if (spos + buf[++i] < 0) - break; - - stack[spos+1].op = stack[spos - buf[i]].op; - stack[spos+1].value = stack[spos - buf[i]].value; - spos++; - break; - case DW_OP_swap: - tmp_op = stack[spos].op; - tmp_value = stack[spos].value; - stack[spos].op = stack[spos - 1].op; - stack[spos].value = stack[spos - 1].value; - stack[spos - 1].op = tmp_op; - stack[spos - 1].value = tmp_value; - break; - case DW_OP_rot: - tmp_op = stack[spos].op; - tmp_value = stack[spos].value; - stack[spos].op = stack[spos - 1].op; - stack[spos].value = stack[spos - 1].value; - stack[spos - 1].op = tmp_op; - stack[spos - 1].value = tmp_value; - - tmp_op = stack[spos+1].op; - tmp_value = stack[spos+1].value; - stack[spos+1].op = stack[spos - 2].op; - stack[spos+1].value = stack[spos - 2].value; - stack[spos - 2].op = tmp_op; - stack[spos - 2].value = tmp_value; - break; - case DW_OP_abs: - if (stack[spos].value < 0) - stack[spos].value = - stack[spos].value; - break; - case DW_OP_and: - stack[spos - 1].value &= stack[spos].value; - spos--; - break; - case DW_OP_div: - stack[spos - 1].value /= stack[spos].value; - spos--; - break; - case DW_OP_minus: - stack[spos - 1].value -= stack[spos].value; - spos--; - break; - case DW_OP_mod: - stack[spos - 1].value = stack[spos - 1].value % stack[spos].value; - spos--; - break; - case DW_OP_mul: - stack[spos - 1].value *= stack[spos].value; - spos--; - break; - case DW_OP_neg: - stack[spos].value = -stack[spos].value; - break; - case DW_OP_not: - stack[spos].value = !stack[spos].value; - break; - case DW_OP_or: - stack[spos - 1].value |= stack[spos].value; - spos--; - break; - case DW_OP_plus: - stack[spos - 1].value += stack[spos].value; - spos--; - break; - case DW_OP_plus_uconst: - stack[spos].value += edfmt_read_uleb128(buf + (++i), &bsize); - i += bsize; - break; - case DW_OP_shl: - stack[spos - 1].value <<= stack[spos].value; - spos--; - break; - case DW_OP_shr: - stack[spos - 1].value >>= stack[spos].value; - spos--; - break; - case DW_OP_xor: - stack[spos - 1].value ^= stack[spos].value; - spos--; - break; - case DW_OP_bra: - bra = *(short *) (buf + (++i)); - i += 2; - - if (stack[spos].value != 0) - i += bra; - spos--; - break; - case DW_OP_eq: - stack[spos - 1].value = (stack[spos].value == stack[spos - 1].value); - spos--; - break; - case DW_OP_ge: - stack[spos - 1].value = (stack[spos].value >= stack[spos - 1].value); - spos--; - break; - case DW_OP_gt: - stack[spos - 1].value = (stack[spos].value > stack[spos - 1].value); - spos--; - break; - case DW_OP_le: - stack[spos - 1].value = (stack[spos].value <= stack[spos - 1].value); - spos--; - break; - case DW_OP_lt: - stack[spos - 1].value = (stack[spos].value < stack[spos - 1].value); - spos--; - break; - case DW_OP_ne: - stack[spos - 1].value = (stack[spos].value != stack[spos - 1].value); - spos--; - break; - case DW_OP_skip: - bra = *(short *) (buf + (++i)); - i += 2; - i += bra; - break; - case DW_OP_lit0: - case DW_OP_lit1: - case DW_OP_lit2: - case DW_OP_lit3: - case DW_OP_lit4: - case DW_OP_lit5: - case DW_OP_lit6: - case DW_OP_lit7: - case DW_OP_lit8: - case DW_OP_lit9: - case DW_OP_lit10: - case DW_OP_lit11: - case DW_OP_lit12: - case DW_OP_lit13: - case DW_OP_lit14: - case DW_OP_lit15: - case DW_OP_lit16: - case DW_OP_lit17: - case DW_OP_lit18: - case DW_OP_lit19: - case DW_OP_lit20: - case DW_OP_lit21: - case DW_OP_lit22: - case DW_OP_lit23: - case DW_OP_lit24: - case DW_OP_lit25: - case DW_OP_lit26: - case DW_OP_lit27: - case DW_OP_lit28: - case DW_OP_lit29: - case DW_OP_lit30: - case DW_OP_lit31: - stack[spos].value = buf[i] - DW_OP_lit0; - break; - case DW_OP_reg0: - case DW_OP_reg1: - case DW_OP_reg2: - case DW_OP_reg3: - case DW_OP_reg4: - case DW_OP_reg5: - case DW_OP_reg6: - case DW_OP_reg7: - case DW_OP_reg8: - case DW_OP_reg9: - case DW_OP_reg10: - case DW_OP_reg11: - case DW_OP_reg12: - case DW_OP_reg13: - case DW_OP_reg14: - case DW_OP_reg15: - case DW_OP_reg16: - case DW_OP_reg17: - case DW_OP_reg18: - case DW_OP_reg19: - case DW_OP_reg20: - case DW_OP_reg21: - case DW_OP_reg22: - case DW_OP_reg23: - case DW_OP_reg24: - case DW_OP_reg25: - case DW_OP_reg26: - case DW_OP_reg27: - case DW_OP_reg28: - case DW_OP_reg29: - case DW_OP_reg30: - case DW_OP_reg31: - stack[spos].value = buf[i] - DW_OP_reg0; - break; - case DW_OP_breg0: - case DW_OP_breg1: - case DW_OP_breg2: - case DW_OP_breg3: - case DW_OP_breg4: - case DW_OP_breg5: - case DW_OP_breg6: - case DW_OP_breg7: - case DW_OP_breg8: - case DW_OP_breg9: - case DW_OP_breg10: - case DW_OP_breg11: - case DW_OP_breg12: - case DW_OP_breg13: - case DW_OP_breg14: - case DW_OP_breg15: - case DW_OP_breg16: - case DW_OP_breg17: - case DW_OP_breg18: - case DW_OP_breg19: - case DW_OP_breg20: - case DW_OP_breg21: - case DW_OP_breg22: - case DW_OP_breg23: - case DW_OP_breg24: - case DW_OP_breg25: - case DW_OP_breg26: - case DW_OP_breg27: - case DW_OP_breg28: - case DW_OP_breg29: - case DW_OP_breg30: - case DW_OP_breg31: - stack[spos].value = buf[i] - DW_OP_breg0; - break; - case DW_OP_regx: - stack[spos].value = edfmt_read_uleb128(buf + (++i), &bsize); - i += bsize; - break; - case DW_OP_fbreg: - stack[spos].value = edfmt_read_leb128(buf + (++i), &bsize); - i += bsize; - break; - case DW_OP_bregx: - stack[spos].value = edfmt_read_uleb128(buf + (++i), &bsize); - i += bsize; - break; - /* - TODO: Find how we can parse that correctly - case DW_OP_deref_size: - stack[spos].op = DW_OP_addr; - tmp_value = stack[spos].value; - stack[spos].value = 0; - for (z = 0, i++; z < buf[i]; z++) - stack[spos].value = ((char*)&tmp_value)[z]; - break; - */ - case DW_OP_nop: - break; - case DW_OP_shra: - case DW_OP_piece: - case DW_OP_xderef_size: - case DW_OP_xderef: - /* Unimplemented, for multiple addresse space architecture ? */ - break; - } - } - - /* Save location value */ - loc->op = stack[spos].op; - loc->value = stack[spos].value; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * Parse data part of .debug_line format - */ -static int edfmt_dwarf2_line_data(edfmtdw2linehead_t *header) -{ - eresi_Addr addr; - u_int file; - u_int line; - u_int column; - u_int is_stmt; - u_int basic_block; - u_int end_sequence; - u_long tmpf; - - u_int i, bsize; - u_char opc, ext_opc; - char *read_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (header == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Loop until end position */ - while (dwarf2_pos(line) < header->end_pos) - { - addr = 0; - file = 1; - line = 1; - column = 0; - is_stmt = header->default_stmt; - basic_block = 0; - end_sequence = 0; - - while (!end_sequence) - { - dwarf2_iread_1(opc, line); - - if (opc >= header->opcode_base) - { - opc -= header->opcode_base; - line += header->line_base + (opc % header->line_range); - addr += (opc / header->line_range) * header->min_length_instr; - - edfmt_dwarf2_line_rec(current_cu, line, column, addr, file - 1); - basic_block = 1; - } - else - { - switch(opc) - { - case DW_LNS_extended_op: - dwarf2_iuleb128(tmpf, line); - - dwarf2_iread_1(ext_opc, line); - switch(ext_opc) - { - case DW_LNE_end_sequence: - end_sequence = 1; - edfmt_dwarf2_line_rec(current_cu, line, column, addr, file - 1); - break; - case DW_LNE_set_address: - DW2_GETPTR(read_addr, current_cu->addr_size, -1); - - for (i = 0; i < current_cu->addr_size; i++) - dwarf2_ipos(read_addr[i], line, u_char); - - addr = *(eresi_Addr *) read_addr; - break; - case DW_LNE_define_file: - header->files_number++; - /* Realloc pointers */ - XREALLOC(__FILE__, __FUNCTION__, __LINE__,header->files_name, header->files_name, - sizeof(char*)*header->files_number, -1); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,header->files_dindex, header->files_dindex, - sizeof(u_int)*header->files_number, -1); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,header->files_time, header->files_time, - sizeof(u_int)*header->files_number, -1); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,header->files_len, header->files_len, - sizeof(u_int)*header->files_number, -1); - - /* Read information and fill new entrie */ - dwarf2_istr(header->files_name[header->files_number], line); - dwarf2_iuleb128(header->files_dindex[header->files_number], line); - dwarf2_iuleb128(header->files_time[header->files_number], line); - dwarf2_iuleb128(header->files_len[header->files_number], line); - break; - } - break; - case DW_LNS_copy: - basic_block = 0; - edfmt_dwarf2_line_rec(current_cu, line, column, addr, file - 1); - break; - case DW_LNS_advance_pc: - dwarf2_iuleb128(tmpf, line); - addr += tmpf * header->min_length_instr; - break; - case DW_LNS_advance_line: - dwarf2_ileb128(tmpf, line); - line += tmpf; - break; - case DW_LNS_set_file: - dwarf2_iuleb128(file, line); - break; - case DW_LNS_set_column: - dwarf2_iuleb128(column, line); - break; - case DW_LNS_negate_stmt: - is_stmt = !is_stmt; - break; - case DW_LNS_set_basic_block: - basic_block = 1; - break; - case DW_LNS_const_add_pc: - addr += ((255 - header->opcode_base) / header->line_range) - * header->min_length_instr; - break; - case DW_LNS_fixed_advance_pc: - dwarf2_iread_2(bsize, line); - addr += bsize; - break; - default: - for (i = 0; i < header->std_opcode_length[opc]; i++) - dwarf2_iuleb128(tmpf, line); - } - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * Parse .debug_line - */ -int edfmt_dwarf2_line(u_long offset) -{ - u_int i; - edfmtdw2linehead_t header; - u_long prev_pos, tmpf; - char *strf; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Update position offset */ - dwarf2_pos(line) = offset; - - /* Parse the header */ - dwarf2_iread_4(header.total_length, line); - header.end_pos = dwarf2_pos(line) + header.total_length; - dwarf2_iread_2(header.version, line); - dwarf2_iread_4(header.prologue_length, line); - header.prologue_pos = dwarf2_pos(line); - dwarf2_iread_1(header.min_length_instr, line); - dwarf2_iread_1(header.default_stmt, line); - dwarf2_iread_1(header.line_base, line); - dwarf2_iread_1(header.line_range, line); - dwarf2_iread_1(header.opcode_base, line); - header.std_opcode_length = dwarf2_ac_pos(line); - dwarf2_inc_pos(line, header.opcode_base - 1); - - /* Dir first pass */ - prev_pos = dwarf2_pos(line); - for (i = 0; (dwarf2_ac_pos(line))[0] != '\0'; i++) - dwarf2_inc_pos(line, strlen(dwarf2_ac_pos(line))+1); - dwarf2_pos(line) = prev_pos; - - DW2_GETPTR(header.dirs, sizeof(char*)*i, -1); - header.dirs_number = i+1; - - /* Dir second pass */ - for (i = 0; (dwarf2_ac_pos(line))[0] != '\0'; i++) - { - header.dirs[i] = dwarf2_ac_pos(line); - dwarf2_inc_pos(line, strlen(dwarf2_ac_pos(line))+1); - } - dwarf2_inc_pos(line, 1); - - /* Filename first pass */ - prev_pos = dwarf2_pos(line); - for (i = 0; (dwarf2_ac_pos(line))[0] != '\0'; i++) - { - dwarf2_istr(strf, line); - dwarf2_iuleb128(tmpf, line); - dwarf2_iuleb128(tmpf, line); - dwarf2_iuleb128(tmpf, line); - } - dwarf2_pos(line) = prev_pos; - - DW2_GETPTR(header.files_name, sizeof(char*)*i, -1); - DW2_GETPTR(header.files_dindex, sizeof(u_int)*i, -1); - DW2_GETPTR(header.files_time, sizeof(u_int)*i, -1); - DW2_GETPTR(header.files_len, sizeof(u_int)*i, -1); - - header.files_number = i+1; - - /* Filename second pass */ - for (i = 0; (dwarf2_ac_pos(line))[0] != '\0'; i++) - { - dwarf2_istr(header.files_name[i], line); - dwarf2_iuleb128(header.files_dindex[i], line); - dwarf2_iuleb128(header.files_time[i], line); - dwarf2_iuleb128(header.files_len[i], line); - } - dwarf2_inc_pos(line, 1); - - /* Check position validity */ - if (header.prologue_pos + header.prologue_length != dwarf2_pos(line)) - dwarf2_pos(line) = header.prologue_pos + header.prologue_length; - - /* Save files & directories list */ - current_cu->dirs = header.dirs; - current_cu->files_name = header.files_name; - current_cu->files_dindex = header.files_dindex; - current_cu->files_time = header.files_time; - current_cu->files_len = header.files_len; - current_cu->files_number = header.files_number; - - /* Parse the rest */ - edfmt_dwarf2_line_data(&header); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * Record a new line entry - */ -int edfmt_dwarf2_line_rec(edfmtdw2cu_t *cu, u_int line, u_int column, - eresi_Addr addr, u_int fid) -{ - edfmtdw2line_t *pline; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - DW2_GETPTR(pline, sizeof(edfmtdw2line_t), -1); - - pline->addr = addr; - pline->line = line; - pline->column = column; - pline->fileid = fid; - pline->cu = cu; - - /* Add line informations */ - /* TODO: Reuse when it will be usefull - if (cu->line == NULL) - cu->line = pline; - else - cu->last_line->next = pline; - - cu->last_line = pline; - */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-cfa.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-cfa.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-cfa.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-cfa.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,304 +0,0 @@ -/* -** @file dwarf2-cfa.c -** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-cfa.c,v 1.7 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * XXX: Re use it when it will be usefull - * Submit a new row state - */ -static int edfmt_dwarf2_cfa_newstate(edfmtdw2cfastate_t *reg) -{ - edfmtdw2cfastate_t *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (reg == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,tmp, sizeof(edfmtdw2cfastate_t), -1); - memcpy(tmp, reg, sizeof(edfmtdw2cfastate_t)); - - /* Add local and gloabal */ - /* TODO: Reuse when it will be usefull - if (current_cu->cfa == NULL) - current_cu->cfa = tmp; - else - current_cu->last_cfa->next = tmp; - - current_cu->last_cfa = tmp; - */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * Parse .debug_frame FDE + data - */ -static int edfmt_dwarf2_cfa_data(edfmtdw2cfastate_t *state, - edfmtdw2cfahead_t *header, u_char init) -{ - u_char cfa, cfa_data, scfa, c_low, c_high; - int data, reg; - eresi_Addr nloc; - edfmtdw2cfastate_t save_stack[20]; - int isave_pos = 0; - int cie; - int length, addr_range, addr_start; - u_long last_pos; - u_long max_pos; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!init) - { - *state = header->init; - } - else - { - /* Reset current state except location */ - nloc = state->addr; - memset(state, 0x00, sizeof(edfmtdw2cfastate_t)); - state->addr = nloc; - nloc = 0; - } - - /* We read FDE if we aren't on init state */ - if (!init) - { - dwarf2_iread_4(length, frame); // Length (without length) - last_pos = dwarf2_pos(frame); - dwarf2_iread_4(cie, frame); // Cie ptr - dwarf2_iread_4(addr_start, frame); // Initial location - dwarf2_iread_4(addr_range, frame); // Address range - - state->addr = addr_start; - } - else - { - last_pos = length = addr_range = addr_start = 0; - } - - /* Max position (end of while loop) */ - max_pos = init ? header->end_offset : last_pos + length; - - do { - dwarf2_iread_1(cfa, frame); - scfa = cfa; - - /* Find low and high parts of the id */ - c_low = (cfa >> 6) & 0xFF; - c_high = (cfa & (~(0xc0))) & 0xFF; - - /* Dispatch */ - cfa = c_low ? cfa - c_high : c_high; - cfa_data = c_low ? c_high : c_low; - - switch (cfa) - { - case DW_CFA_advance_loc: - case DW_CFA_advance_loc1: - case DW_CFA_advance_loc2: - case DW_CFA_advance_loc4: - switch (cfa) - { - case DW_CFA_advance_loc: - data = cfa_data; - break; - case DW_CFA_advance_loc1: - dwarf2_iread_1(data, frame); - break; - case DW_CFA_advance_loc2: - dwarf2_iread_2(data, frame); - break; - case DW_CFA_advance_loc4: - dwarf2_iread_4(data, frame); - break; - default: - data = 0; - } - - if (!init && cfa == DW_CFA_advance_loc) - edfmt_dwarf2_cfa_newstate(state); - - state->addr += data * header->code_align_factor; - break; - case DW_CFA_offset_extended: - case DW_CFA_offset: - - if (cfa == DW_CFA_offset) - reg = cfa_data; - else - dwarf2_iuleb128(reg, frame); - - dwarf2_ileb128(data, frame); - - if (!CFA_C_REG(reg)) - break; - - state->reg[reg].type = DW2_CFA_T_OFFSET; - state->reg[reg].u.offset = data * header->data_align_factor; - break; - case DW_CFA_restore_extended: - case DW_CFA_restore: - if (init) - break; - - if (cfa ==DW_CFA_restore) - data = cfa_data; - else - dwarf2_iuleb128(data, frame); - - if (!CFA_C_REG(data)) - break; - - state->reg[data] = header->init.reg[data]; - break; - case DW_CFA_set_loc: - nloc = *(eresi_Addr *) dwarf2_a_pos(frame); - dwarf2_inc_pos(frame, sizeof(eresi_Addr)); - if (nloc > state->addr) - { - if (!init) - edfmt_dwarf2_cfa_newstate(state); - state->addr = nloc; - } - break; - case DW_CFA_same_value: - case DW_CFA_undefined: - dwarf2_iuleb128(data, frame); - - if (!CFA_C_REG(data)) - break; - - memset(&state->reg[data], 0x00, sizeof(edfmtdw2cfareg_t)); - state->reg[data].type = (cfa == DW_CFA_undefined ? DW2_CFA_T_UNDEF : DW2_CFA_T_SAME); - break; - case DW_CFA_register: - dwarf2_iuleb128(data, frame); - dwarf2_iuleb128(reg, frame); - - if (!CFA_C_REG(reg) || !CFA_C_REG(data)) - break; - - state->reg[reg] = state->reg[data]; - break; - case DW_CFA_remember_state: - if (isave_pos >= 20) - break; - save_stack[isave_pos++] = *state; - break; - case DW_CFA_restore_state: - if (isave_pos <= 0) - break; - *state = save_stack[--isave_pos]; - break; - case DW_CFA_def_cfa: - dwarf2_iuleb128(reg, frame); - dwarf2_iuleb128(data, frame); - - state->cfa_reg = reg; - state->cfa_offset = (eresi_Addr) data; - break; - case DW_CFA_def_cfa_register: - dwarf2_iuleb128(reg, frame); - - state->cfa_reg = reg; - break; - case DW_CFA_def_cfa_offset: - dwarf2_iuleb128(data, frame); - - state->cfa_offset = (eresi_Addr) data; - break; - case DW_CFA_nop: - break; - default: - /* Unknown cfa, oupssss ? */ - break; - } - } while (dwarf2_pos(frame) < dwarf2_size(frame) && - dwarf2_pos(frame) < max_pos); - - if (!init) - { - edfmt_dwarf2_cfa_newstate(state); - state->addr = addr_start + addr_range; - } - - /* If it's initialisation, we copy at the end */ - if (init) - header->init = *state; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * XXX: Re use it when it will be usefull - * .debug_frame parsing entry point - */ -int edfmt_dwarf2_cfa() -{ - edfmtdw2cfahead_t header; - edfmtdw2cfastate_t state; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (dwarf2_data(frame) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".debug_frame section not available", -1); - - /* Reset frame position */ - dwarf2_pos(frame) = 0; - - /* Reset state */ - memset(&state, 0x00, sizeof(edfmtdw2cfastate_t)); - - do { - /* Reset header */ - memset(&header, 0x00, sizeof(edfmtdw2cfahead_t)); - - header.offset = dwarf2_pos(frame); - - /* Read CIE header */ - dwarf2_iread_4(header.length, frame); - header.end_offset = dwarf2_pos(frame) + header.length; - dwarf2_iread_4(header.cid, frame); - dwarf2_iread_1(header.version, frame); - dwarf2_istr(header.augmentation, frame); - dwarf2_iuleb128(header.code_align_factor, frame); - dwarf2_ileb128(header.data_align_factor, frame); - dwarf2_iread_1(header.return_addr_reg, frame); - - header.init_offset = dwarf2_pos(frame); - - /* Read init */ - edfmt_dwarf2_cfa_data(&state, &header, 1); - - /* Correct length */ - if (header.end_offset != dwarf2_pos(frame)) - dwarf2_pos(frame) = header.end_offset; - - do { - edfmt_dwarf2_cfa_data(&state, &header, 0); - - /* We aren't at the end */ - if (dwarf2_pos(frame) < dwarf2_size(frame)) - { - /* Check if the next header is a CIE */ - if (header.cid == *(u_int *) (dwarf2_ac_pos(frame)+4)) - break; - } - } while(dwarf2_pos(frame) < dwarf2_size(frame)); - } while (dwarf2_pos(frame) < dwarf2_size(frame)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/dwarf2.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/dwarf2.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,317 +0,0 @@ -/* -** @file dwarf2.c -** @ingroup libedfmt -** -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2.c,v 1.19 2007-05-20 19:13:57 mxatone Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * This file implements DWARF2 support for libedfmt. - * specificitation @ http://dwarf.freestandards.org/Download.php - * @file dwarf2.c - */ - -#define DWARF2_ABBREV_NAME "dwarf2_abbrev_table" - -/** - * Dwarf2 information structure - */ -edfmtdw2info_t *dwarf2_info = NULL; - -/** - * Current compil unit pointer - */ -edfmtdw2cu_t *current_cu = NULL; - -/** - * Retrieve dwarf2 info pointer from a file pointer - * @param file file target - * @return dwarf2 information structure - */ -edfmtdw2info_t *edfmt_dwarf2_getinfo(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (edfmtdw2info_t *) file->debug_format.dwarf2); -} - -/** - * Parse the DWARF-2 debug format - * @param file file target - */ -int edfmt_dwarf2_parse(elfshobj_t *file) -{ - edfmtdw2sect_t *pointers[9]; - char *names[9]; - u_int hash[9]; - u_int i; - edfmtdw2sectlist_t dw2_sections; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (edfmt_dwarf2_getinfo(file) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Full fill with 0 */ - memset(&dw2_sections, 0x00, sizeof(edfmtdw2sectlist_t)); - - /* We already have it ! */ - dw2_sections.info.sect = edfmt_get_sect(file, ELFSH_SECTION_DW2_INFO, - ELFSH_SECTION_NAME_DW2_INFO, 0); - - dw2_sections.info.data = dw2_sections.info.sect->data; - - if (dw2_sections.info.sect == NULL || dw2_sections.info.data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Main DWARF2 section unavailable", -1); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, dwarf2_info, sizeof(edfmtdw2info_t), -1); - memcpy(&(dwarf2_info->sections), &dw2_sections, sizeof(edfmtdw2sectlist_t)); - - /* Local table system to full fill every pointers correctly */ - pointers[0] = &(dwarf2_info->sections.abbrev); // Supported - pointers[1] = &(dwarf2_info->sections.aranges); // Unsupported - pointers[2] = &(dwarf2_info->sections.frame); // Supported - pointers[3] = &(dwarf2_info->sections.line); // Supported - pointers[4] = &(dwarf2_info->sections.macinfo); // Supported - pointers[5] = &(dwarf2_info->sections.pubnames); // Unsupported - pointers[6] = &(dwarf2_info->sections.str); // Supported - pointers[7] = &(dwarf2_info->sections.loc); // Supported - pointers[8] = NULL; - - names[0] = ELFSH_SECTION_NAME_DW2_ABBREV; - names[1] = ELFSH_SECTION_NAME_DW2_ARANGES; - names[2] = ELFSH_SECTION_NAME_DW2_FRAME; - names[3] = ELFSH_SECTION_NAME_DW2_LINE; - names[4] = ELFSH_SECTION_NAME_DW2_MACINFO; - names[5] = ELFSH_SECTION_NAME_DW2_PUBNAMES; - names[6] = ELFSH_SECTION_NAME_DW2_STR; - names[7] = ELFSH_SECTION_NAME_DW2_LOC; - names[8] = NULL; - - hash[0] = ELFSH_SECTION_DW2_ABBREV; - hash[1] = ELFSH_SECTION_DW2_ARANGES; - hash[2] = ELFSH_SECTION_DW2_FRAME; - hash[3] = ELFSH_SECTION_DW2_LINE; - hash[4] = ELFSH_SECTION_DW2_MACINFO; - hash[5] = ELFSH_SECTION_DW2_PUBNAMES; - hash[6] = ELFSH_SECTION_DW2_STR; - hash[7] = ELFSH_SECTION_DW2_LOC; - hash[8] = NULL; - - /* Use the table to fill every pointers and report a problem */ - for (i = 0; names[i] != NULL; i++) - { - pointers[i]->sect = edfmt_get_sect(file, hash[i], names[i], 0); - - if (pointers[i]->sect != NULL) - pointers[i]->data = pointers[i]->sect->data; - } - - /* Start into the block entrie */ - if (edfmt_dwarf2_block_entrie(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 block parsing failed", -1); - - /* Parse cfa informations */ - /* TODO: reimplement it when it will be usefull - edfmt_dwarf2_cfa(); - */ - - /* Update file pointer */ - file->debug_format.dwarf2 = (void *) dwarf2_info; - dwarf2_info = NULL; - current_cu = NULL; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Central parse function that find every compilation unit - * @param file file target - */ -int edfmt_dwarf2_block_entrie(elfshobj_t *file) -{ - edfmtdw2cu_t *tcu; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - while (dwarf2_pos(info) < dwarf2_size(info)) - { - /* Alloc a new compil unit */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,tcu, sizeof(edfmtdw2cu_t), -1); - - tcu->fileobj = file; - - /* Update current pointer */ - if (current_cu != NULL) - { - current_cu->next = tcu; - } - else - { - /* Init info structure */ - dwarf2_info->cu_list = tcu; - } - - current_cu = current_cu ? current_cu->next : tcu; - - /* Set compil unit start position */ - current_cu->start_pos = dwarf2_pos(info); - - /* Read DWARF2 .dwarf2_info header */ - dwarf2_ipos(current_cu->length, info, u_int); - current_cu->end_pos = dwarf2_pos(info) + current_cu->length; - - /* A compil unit bigger than the section ? */ - if (current_cu->end_pos > dwarf2_size(info)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 compil unit size incorrect", -1); - - dwarf2_ipos(current_cu->version, info, u_short); - - /* Need this exact version */ - if (current_cu->version != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 version check failed", -1); - - dwarf2_ipos(current_cu->offset, info, u_int); - - /* Valid offset ? */ - if (current_cu->offset >= dwarf2_size(abbrev)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 compil unit abbrev offset incorrect", -1); - - dwarf2_ipos(current_cu->addr_size, info, u_char); - - current_cu->info_pos = dwarf2_pos(info); - - /* Update abbrev position */ - dwarf2_pos(abbrev) = current_cu->offset; - - /* Loop on the current compil unit */ - if (edfmt_dwarf2_block_loop(current_cu->end_pos) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 block looping failed", -1); - - /* We update info position, to finish at the right offset */ - dwarf2_pos(info) = current_cu->end_pos; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Retrieve en abbrev entity from a compil unit - * @param cu compile unit target - * @param abbent abbrev entity that will be fill - * @param pos position to read - */ -int edfmt_dwarf2_getent(edfmtdw2cu_t *cu, edfmtdw2abbent_t *abbent, - u_int pos) -{ - edfmtdw2info_t *pinfo; - edfmtdw2cu_t *pcu; - int ret = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (cu == NULL || abbent == NULL || cu->fileobj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Save current pointers */ - pinfo = dwarf2_info; - dwarf2_info = (edfmtdw2info_t *) cu->fileobj->debug_format.dwarf2; - pcu = current_cu; - current_cu = cu; - - memset(abbent, 0x00, sizeof(edfmtdw2abbent_t)); - - /* Parse info part */ - if (edfmt_dwarf2_form(abbent, pos) < 0) - ret = -1; - - /* Restore ex pointers */ - dwarf2_info = pinfo; - current_cu = pcu; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Manage parsing loops. On the new layout thif function just fill abbrev hash table - * @param endpos represent the end position to read on the current compile unit (deprecate) - */ -int edfmt_dwarf2_block_loop(u_int endpos) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (current_cu->abbrev_table.ent == NULL) - hash_init(&(current_cu->abbrev_table), DWARF2_ABBREV_NAME, 30, ASPECT_TYPE_UNKNOW); - - /* Parse abbrev table on the appropriate offset */ - if (edfmt_dwarf2_abbrev_enum(&(current_cu->abbrev_table)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DWARF2 abbrev enum failed", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Clean allocated buffer for this file - * @param file file to clean - */ -int edfmt_dwarf2_clean(elfshobj_t *file) -{ - edfmtdw2cu_t *cu, *cunext = NULL; - edfmtdw2info_t *dw2_info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parmaters", -1); - - dw2_info = edfmt_dwarf2_getinfo(file); - - if (dw2_info == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Each compile unit */ - for (cu = dw2_info->cu_list; cu != NULL; cunext = cu, cu = cu->next) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, cunext); - - /* Clean the abbrev table */ - hash_destroy(&(cu->abbrev_table)); - - /* Filenames and directories */ - if (cu->dirs) - XFREE(__FILE__, __FUNCTION__, __LINE__, cu->dirs); - - if (cu->files_name) - XFREE(__FILE__, __FUNCTION__, __LINE__, cu->files_name); - - if (cu->files_dindex) - XFREE(__FILE__, __FUNCTION__, __LINE__, cu->files_dindex); - - if (cu->files_time) - XFREE(__FILE__, __FUNCTION__, __LINE__, cu->files_time); - - if (cu->files_len) - XFREE(__FILE__, __FUNCTION__, __LINE__, cu->files_len); - } - - if (cunext) - XFREE(__FILE__, __FUNCTION__, __LINE__, cunext); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-trans.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-trans.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-trans.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-trans.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,640 +0,0 @@ -/* -** @file dwarf2.c -** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-trans.c,v 1.12 2007-08-25 17:13:05 mxatone Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * This file implements DWARF2 transformation - * @file dwarf2-trans.c - */ - -#define DWARF2_HNAME_TRANS_TREF "dwarf2_trans_typeref" - -/** - * Temporary buffer outside function to optimize function recursion - */ -char buf[BUFSIZ]; - -/** - * Transform hash table - */ -hash_t types_ref; - -/** - * Search a type from its name - * @param str search type from this name - * @return return founded type - */ -static edfmttype_t *edfmt_dwarf2_searchtype_str(char *str) -{ - edfmttype_t *type = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - type = (edfmttype_t *) hash_get(&types_ref, str); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/** - * Search a type from its abbrev structure (retrieve its name) - * @param abbrev get the name from this abbrev entity and search this type - * @return return founded type - */ -static edfmttype_t *edfmt_dwarf2_searchtype(edfmtdw2abbent_t *abbrev) -{ - edfmttype_t *type = NULL; - edfmtdw2abbattr_t *attr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - attr = edfmt_dwarf2_getattr(abbrev, DW_AT_name); - - if (attr) - type = (edfmttype_t *) hash_get(&types_ref, attr->u.str); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/** - * Get a type starting by try to resolve it fast - * @param pos retrive the type from this position - * @return return founded type - */ -static edfmttype_t *edfmt_dwarf2_trans_gettype(u_int pos) -{ - edfmtdw2abbent_t ref; - edfmttype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (pos <= 0 - || current_cu == NULL - || pos > current_cu->length) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - if (edfmt_dwarf2_getent(current_cu, &ref, current_cu->start_pos + pos) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "dwarf2 getenv failed", NULL); - - type = edfmt_dwarf2_searchtype(&ref); - - if (type == NULL) - type = edfmt_dwarf2_transform_abbrev_parse(&ref); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/** - * Get an attribut from an abbrev entity - * @param abbent abbrev entity that host the attribute - * @param attr attribute id - * @return return the abbrev attribute structure from attr id - */ -edfmtdw2abbattr_t *edfmt_dwarf2_getattr(edfmtdw2abbent_t *abbent, u_int attr) -{ - edfmtdw2info_t *pinfo; - u_int i; - u_char *bufptr; - u_short len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (abbent != NULL) - { - /* We search the right entry on every attribute */ - for (i = 0; abbent->attr[i].attr; i++) - { - if (abbent->attr[i].attr == attr) - { - /* Save current pointers */ - pinfo = dwarf2_info; - dwarf2_info = (edfmtdw2info_t *) current_cu->fileobj->debug_format.dwarf2; - - edfmt_dwarf2_form_value(abbent->attr + i); - - /* Transformation from based values */ - switch(abbent->attr[i].attr) - { - case DW_AT_frame_base: - case DW_AT_data_member_location: - case DW_AT_location: - switch(abbent->attr[i].form) - { - case DW_FORM_block1: - edfmt_dwarf2_loc(&(abbent->attr[i].loc), (u_char *) abbent->attr[i].u.vbuf, - abbent->attr[i].asize); - break; - /* We have to use .debug_loc */ - case DW_FORM_data8: - case DW_FORM_data4: - /* We need loc section */ - if (dwarf2_data(loc) == NULL) - break; - - /* Set position */ - dwarf2_pos(loc) = abbent->attr[i].u.udata; - bufptr = (u_char *) dwarf2_a_pos(loc); - - /* Read length, we don't care about start & end */ - len = *(u_short *) (bufptr + (current_cu->addr_size * 2)); - - /* Update the position right after the two addresses */ - dwarf2_pos(loc) += (current_cu->addr_size * 2) + sizeof(u_short); - - /* We don't want to be on another section */ - if (dwarf2_pos(loc) + len > dwarf2_size(loc)) - break; - - /* Read the location */ - edfmt_dwarf2_loc(&(abbent->attr[i].loc), - (u_char *) dwarf2_a_pos(loc), len); - break; - } - break; - /* TODO: reuse when it will be usefull - case DW_AT_stmt_list: - edfmt_dwarf2_line(ent->attr[i].u.udata); - break; - case DW_AT_macro_info: - edfmt_dwarf2_mac(ent->attr[i].u.udata); - break; - */ - } - - /* Restore ex pointers */ - dwarf2_info = pinfo; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, abbent->attr + i); - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Get an addresse from a buffer - * @param vbuf buffer that store the addresse - * @return the addresse or 0 - */ -eresi_Addr edfmt_dwarf2_getaddr(char *vbuf) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!vbuf) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", (eresi_Addr) 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, *(eresi_Addr *) vbuf); -} - -/** - * This parsing function is the main function of transformation - * @param abbrev analyze the abbrev entity - * @return retunr generated type - */ -edfmttype_t *edfmt_dwarf2_transform_abbrev_parse(edfmtdw2abbent_t *abbrev) -{ - char *str = NULL, *comp_dir, *vbuf, *vbufs, *pstr; - long size = 0; - edfmttype_t *type = NULL, *etype; - u_long iref, itref; - edfmtdw2abbent_t ref, tref; - edfmtdw2abbattr_t *attr; - eresi_Addr low = 0, high = 0; - int fileid, inc = 0, addtype = 1, base = 0, op = 0; - edfmtfunc_t *func; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!abbrev) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* Retrieve abbrev name */ - DWARF2_TRANS_GETATTR(str, abbrev, DW_AT_name, u.str, NULL); - - //type = edfmt_dwarf2_searchtype(abbrev->ckey); - if (str) - { - type = edfmt_dwarf2_searchtype_str(str); - - /* Already parsed ? */ - if (type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); - } - - /** - * If we're not with a compil unit tag, we can have a specific dedicated file - * this is the way to handle header files in dwarf2 - */ - if (abbrev->tag != DW_TAG_compile_unit) - { - DWARF2_TRANS_GETATTR(fileid, abbrev, DW_AT_decl_file, u.udata, -1); - - inc = 1; - if (fileid > 0 && fileid < current_cu->files_number) - { - fileid--; - pstr = current_cu->dirs[current_cu->files_dindex[fileid] - 1]; - if (pstr != NULL - && current_cu->files_dindex[fileid] < current_cu->files_number - && current_cu->files_dindex[fileid] > 0) - { - size = strlen(pstr); - snprintf(buf, BUFSIZ - 1, "%s%s%s", - pstr, - pstr[size - 1] != '/' ? "/" : "", - current_cu->files_name[fileid]); - } - else - { - snprintf(buf, BUFSIZ - 1, "%s", - current_cu->files_name[fileid]); - } - - edfmt_add_file(edfmt_get_current_file(), buf, 0, 0); - - pstr = NULL; - size = 0; - } - else if (fileid >= 0) - { - inc++; - edfmt_reset_file(); - } - } - - /** - * A TAG represent an element of the dwarf2 format, each TAG are linked by child / parent - * alike structure. You can get more information on the dwarf2 documentation - */ - switch(abbrev->tag) - { - /* Represent an object file (only .c) */ - case DW_TAG_compile_unit: - if (!str) - break; - - /* If we don't have a global path, we try to read a directory */ - if (str[0] != '/') - { - DWARF2_TRANS_GETATTR(comp_dir, abbrev, DW_AT_comp_dir, u.str, NULL); - - if (comp_dir) - { - snprintf(buf, BUFSIZ - 1, "%s%s%s", - comp_dir, - comp_dir[strlen(comp_dir) - 1] != '/' ? "" : "/", - str); - str = buf; - } - } - - /* Lower and high bound addresses of the file into the object */ - DWARF2_TRANS_GETATTR(vbuf, abbrev, DW_AT_low_pc, u.vbuf, NULL); - DWARF2_TRANS_GETATTR(vbufs, abbrev, DW_AT_high_pc, u.vbuf, NULL); - - /* Add a new file */ - edfmt_add_file(NULL, str, - edfmt_dwarf2_getaddr(vbuf), - edfmt_dwarf2_getaddr(vbufs)); - break; - - /* Represente a global variable */ - case DW_TAG_variable: - attr = edfmt_dwarf2_getattr(abbrev, DW_AT_location); - - if (!attr || attr->loc.op != DW_OP_addr) - break; - - DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - - type = edfmt_dwarf2_trans_gettype(iref); - - if (!type) - break; - - edfmt_add_var_global(type, str, attr->loc.value); - break; - - /* An elementary type */ - case DW_TAG_base_type: - DWARF2_TRANS_GETATTR(size, abbrev, DW_AT_byte_size, u.udata, -1); - type = edfmt_add_type_basic(str, (int) size); - break; - - /* Rename a given type on another (like typedef) */ - case DW_TAG_typedef: - DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - - type = edfmt_dwarf2_trans_gettype(iref); - - if (!type) - break; - - type = edfmt_add_type_link(str, type); - break; - - /* Pointer or refence on a given type */ - case DW_TAG_pointer_type: - case DW_TAG_reference_type: - DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - - type = edfmt_dwarf2_trans_gettype(iref); - - if (type) - { - snprintf(buf, BUFSIZ - 1, "*%s", type->name); - } - else /* We've got a void* */ - { - type = edfmt_add_type_void("void"); - snprintf(buf, BUFSIZ - 1, "void*"); - } - - type = edfmt_add_type_ptr(buf, type); - break; - - /* An array - its size can be dynamic, that can create some problem then be aware */ - case DW_TAG_array_type: - if (abbrev->child > 0 && edfmt_dwarf2_getent(current_cu, &tref, abbrev->child) == 0 - && tref.tag == DW_TAG_subrange_type) - { - DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - - type = edfmt_dwarf2_trans_gettype(iref); - - if (!type) - break; - - DWARF2_TRANS_GETATTR(size, &tref, DW_AT_upper_bound, u.udata, -1); - - if (size < 0) - size = 1; - - snprintf(buf, BUFSIZ - 1, "%s[%d]", type->name, (int) size+1); - type = edfmt_add_type_array(buf, (int) size, type); - } - break; - - /** - * Structure and union are parsed together because they used the same parsing - * structure - */ - case DW_TAG_structure_type: - case DW_TAG_union_type: - if (abbrev->child) - { - DWARF2_TRANS_GETATTR(size, abbrev, DW_AT_byte_size, u.udata, -1); - - /* If we don't have a name, let generate one */ - if (!str) - { - snprintf(buf, BUFSIZ - 1, "s_(%u)", abbrev->key); - str = buf; - } - - /* Use the right uniform format function */ - if (abbrev->tag == DW_TAG_union_type) - type = edfmt_add_type_union(str, (int) size); - else - type = edfmt_add_type_struct(str, (int) size); - - /* We add our structure right before members to avoid pointers infinite loop */ - if (type && str) - HASH_ADDX(&types_ref, str, (void *) type); - - /* We get every childs here, a child represent a structure / union member */ - for (iref = abbrev->child; iref > 0; iref = ref.sib) - { - /* Retrieve and fill the structure correctly */ - if (edfmt_dwarf2_getent(current_cu, &ref, iref) < 0) - break; - - /* Do we have a member ? */ - if (ref.tag == DW_TAG_member) - { - DWARF2_TRANS_GETATTR(str, &ref, DW_AT_name, u.str, NULL); - DWARF2_TRANS_GETATTR(itref, &ref, DW_AT_type, u.udata, 0); - - /* We need a type for this element */ - if (itref == 0) - continue; - - /* We retrieve the type */ - etype = edfmt_dwarf2_trans_gettype(itref); - - if (!etype) - continue; - - /* On structure we read location information */ - if (DW_TAG_union_type != abbrev->tag) - { - attr = edfmt_dwarf2_getattr(&ref, DW_AT_data_member_location); - - if (!str || !attr) - continue; - - base = (int) attr->loc.value; - } - - /* Add the attribute */ - edfmt_add_type_attr(type, str, base, 0, etype); - } - else - { - /* We handle other elements in case of .. */ - edfmt_dwarf2_transform_abbrev_parse(&ref); - } - } - - /* We won't have to re-parse structure members */ - abbrev->child = 0; - - /* We already add our type and we want to return the right information */ - addtype = 0; - } - break; - - /* Represent a fonction */ - case DW_TAG_subprogram: - /* Try to read addresses */ - DWARF2_TRANS_GETATTR(vbuf, abbrev, DW_AT_low_pc, u.vbuf, 0); - if (vbuf) - low = *(eresi_Addr *) vbuf; - DWARF2_TRANS_GETATTR(vbuf, abbrev, DW_AT_high_pc, u.vbuf, 0); - if (vbuf) - high = *(eresi_Addr *) vbuf; - - /* Resolve return type */ - DWARF2_TRANS_GETATTR(iref, abbrev, DW_AT_type, u.udata, 0); - type = edfmt_dwarf2_trans_gettype(iref); - - if (!type) - break; - - /* Transform the function */ - func = edfmt_add_func(str, type, low, high); - - if (func) - { - /** - * Parse and add arguments, this disposion is quite the same used - * for structure / union - */ - for (iref = abbrev->child; iref > 0; iref = ref.sib) - { - /* Read a structure */ - if (edfmt_dwarf2_getent(current_cu, &ref, iref) < 0) - break; - - /* Do we have a parameter */ - if (ref.tag == DW_TAG_formal_parameter) - { - DWARF2_TRANS_GETATTR(str, &ref, DW_AT_name, u.str, NULL); - DWARF2_TRANS_GETATTR(itref, &ref, DW_AT_type, u.udata, 0); - - type = edfmt_dwarf2_trans_gettype(itref); - attr = edfmt_dwarf2_getattr(&ref, DW_AT_location); - - if (!type || !attr) - continue; - - /* Support based reg */ - if (attr->loc.op >= DW_OP_breg0 && attr->loc.op <= DW_OP_breg31) - op = attr->loc.op - DW_OP_breg0; - - edfmt_add_arg(func, str, op, (int) attr->loc.value, type); - } - else - { - /* We parse in cas of ... */ - edfmt_dwarf2_transform_abbrev_parse(&ref); - } - } - - /* We won't have to re-parse function arguments */ - abbrev->child = 0; - } - break; - } - - /* Restore a parent for a specific include */ - if (inc == 1) - edfmt_restore_parent_file(); - else if (inc == 2) - edfmt_reactive_file(); - - /* Add type into the hash table */ - if (type && addtype && str) - HASH_ADDX(&types_ref, str, (void *) type); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/* Use in global scope to improve speed */ -#define DW2_MAX_LEVEL 20 -edfmtdw2abbent_t abbrev[DW2_MAX_LEVEL]; -int abbrev_level = 0; - -/** - * Loop for a given compile unit depending of its position - * @param pos starting position - */ -int edfmt_dwarf2_transform_abbrev(u_int pos) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (pos == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (abbrev_level >= DW2_MAX_LEVEL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - while (pos > 0 && pos < current_cu->end_pos) - { - if (edfmt_dwarf2_getent(current_cu, &(abbrev[abbrev_level]), pos) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't retrieve abbrev entitie", -1); - - edfmt_dwarf2_transform_abbrev_parse(&(abbrev[abbrev_level])); - - /* Parse childs too */ - if (abbrev[abbrev_level].child > 0) - { - abbrev_level++; - edfmt_dwarf2_transform_abbrev(abbrev[abbrev_level - 1].child); - abbrev_level--; - } - - pos = abbrev[abbrev_level].sib; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Transform dwarf2 informations - * Entrypoint for transformation from dwarf2 to uniform format - * @param file transform this file - */ -int edfmt_dwarf2_transform(elfshobj_t *file) -{ - edfmtdw2info_t *tinfo; - edfmtdw2cu_t *tcu; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - tinfo = (edfmtdw2info_t *) file->debug_format.dwarf2; - - if (tinfo == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No debug information for dwarf2", -1); - - tcu = (edfmtdw2cu_t *) tinfo->cu_list; - - if (tcu == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No compile unit information for dwarf2", -1); - - if (types_ref.ent == NULL) - hash_init(&types_ref, DWARF2_HNAME_TRANS_TREF, 200, ASPECT_TYPE_UNKNOW); - - /* Setup the file */ - edfmt_add_init(file); - - /* Iterate through compile unit */ - while (tcu != NULL) - { - current_cu = tcu; - - abbrev_level = 0; - edfmt_dwarf2_transform_abbrev(tcu->info_pos); - - tcu = tcu->next; - } - - hash_empty(DWARF2_HNAME_TRANS_TREF); - - current_cu = NULL; - - /* Clean current file context */ - edfmt_add_end(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-utils.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-utils.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/dwarf2-utils.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/dwarf2-utils.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -/* -** @file dwarf2-utils.c -** @ingroup libedfmt -** Started Dec 26 2006 10:49:45 mxatone -** -** -** $Id: dwarf2-utils.c,v 1.7 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * Read an unsigned leb128 number as describe on the dwarf2 documentation - * a little bit optimize - * @param data pointer to a buffer where we'll read - * @param bread store size readed - * @return final value - */ -u_long edfmt_read_uleb128(void *data, u_int *bread) -{ - u_long sum = 0; - u_int read = 0; - u_char c; - int s = 0; - - NOPROFILER_IN(); - - do { - c = *(u_char *) (data + read) & 0xFF; - read++; - sum |= ((u_long)(c & 127) << s); - - s += 7; - } while ((c & 128) != 0); - - if (bread) - *bread = read; - - NOPROFILER_ROUT(sum); -} - -/** - * Read a signed leb128 number as describe on the dwarf2 documentation - * a little bit optimize - * @param data pointer to a buffer where we'll read - * @param bread store size readed - * @return final value - */ -long edfmt_read_leb128(void *data, u_int *bread) -{ - long sum = 0; - u_int read = 0; - u_char c; - int s = 0; - - NOPROFILER_IN(); - - do { - c = *(u_char *) (data + read) & 0xFF; - read++; - sum |= ((long)(c & 127) << s); - - s += 7; - } while ((c & 128) != 0); - - if ((s < 8 * sizeof(sum)) && (c & 0x40)) - sum |= -(((long)1) << s); - - if (bread) - *bread = read; - - NOPROFILER_ROUT(sum); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/edfmt.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/edfmt.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/edfmt.c.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/edfmt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,159 +0,0 @@ -/* -** @file edfmt.c -** @ingroup libedfmt -** -** Started Dec 25 2006 15:41:35 mxatone -** -** -** $Id: edfmt.c,v 1.14 2007-11-30 10:13:54 may Exp $ -** -*/ - -#include "libedfmt.h" - -#define EDFMT_SET_FUNCS(_name) _name##_parse, _name##_transform, _name##_clean - -/** - * This structure list all debug format that we support and with which function - * For the moment we support stabs & dwarf2, we check if one of this debug format is present - * with checking each one sections exist. - */ -edfmtmanage_t debug_format[] = - { - { ELFSH_SECTION_NAME_STAB , ELFSH_SECTION_STAB , EDFMT_SET_FUNCS(edfmt_stabs) }, - { ELFSH_SECTION_NAME_DW2_INFO, ELFSH_SECTION_DW2_INFO, EDFMT_SET_FUNCS(edfmt_dwarf2) }, - { NULL , 0 , NULL, NULL, NULL } - }; - -/** - * Retrieve a specific section if this section is available - * @param file host file - * @param hash hash id - * @param hash_name section name - * @param strhash hash id for the linked string section - */ -elfshsect_t *edfmt_get_sect(elfshobj_t *file, u_int hash, char *hash_name, - u_int strhash) -{ - elfshsect_t *sect; - int strindex; - int index; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Section pointer already set ? */ - if (file->secthash[hash] == NULL) - { - sect = elfsh_get_section_by_name(file, hash_name, - &index, &strindex, &nbr); - if (NULL == sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get a debug format section by name", NULL); - - file->secthash[hash] = sect; - - /* Data pointer is an assert condition */ - if (file->secthash[hash]->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load debug format section", NULL); - - if (strhash > 0) - { - sect = elfsh_get_section_by_index(file, strindex, NULL, NULL); - if (sect) - file->secthash[strhash] = sect; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - file->secthash[hash]); -} - - -/* The internal basename function */ -static char *edfmt_basename(char *str) -{ - char *cur; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = NULL; - cur = str; - while ((cur = strchr(cur, '/'))) - if (!*(cur + 1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No basename", (NULL)); - else - ret = ++cur; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * Main point of the debug format library - * This function manages this steps for every debugging formats: - * - Parse the format and create / init an interface for the next step. - * - Transform the debugging format representation in the uniform debugging format. - * - Clean elements allocated by the first step. - * @param file target file - */ -int edfmt_format(elfshobj_t *file) -{ - u_int i; - elfshsect_t *sect = NULL; - u_int count = 0; - char *base; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong file object", -1); - - - if (file->name) - { - /* Retrieve file basename */ - base = edfmt_basename(file->name); - if (base == NULL) - base = file->name; - - /* We won't analyze libe2dbg library because, there's far too many information - in this library, which allocate too much memory */ - if (!strcmp(base, "libe2dbg32.so") - || !strcmp(base, "libe2dbg64.so")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "We don't analyze e2dbg library", -1); - } - - /* We call every elements of the structure */ - for (i = 0; debug_format[i].sect_name != NULL; i++) - { - /* Check if the debugging section exist */ - sect = edfmt_get_sect(file, debug_format[i].sect_hash, - debug_format[i].sect_name, 0); - - if (sect != NULL && debug_format[i].func != NULL) - { - /* Parse */ - if (debug_format[i].func) - debug_format[i].func(file); - - /* Transform */ - if (debug_format[i].trans) - debug_format[i].trans(file); - - /* Clean */ - if (debug_format[i].clean) - debug_format[i].clean(file); - count++; - } - } - - /* No debugging format sections found */ - if (count == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find at leat one debug format", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/edfmt-utils.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/edfmt-utils.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/edfmt-utils.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/edfmt-utils.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -/* -** @file edfmt-utils.c -** @ingroup libedfmt -** -** Started Jan 13 2007 18:09:02 mxatone -** -** -** $Id: edfmt-utils.c,v 1.11 2007-07-17 18:11:24 may Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * Create a string from a key (used in hash table) - * @param buf destination buffer - * @param size size of the buffer - * @param key key to transform - * @return the modified pointer or NULL - */ -char *edfmt_ckey(char *buf, u_int size, long key) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (buf == NULL || size == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* That big but malloc fault on small chunk ! */ - snprintf(buf, size - 1, "%08ld", key); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); -} - -/** - * Create a string from a file + line (used in hash table) - * @param buf destination buffer - * @param size size of the buffer - * @param line line number - * @param file filename - * @return the modified pointer or NULL - */ -char *edfmt_cline(char *buf, u_int size, u_int line, char *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (buf == NULL || size == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - snprintf(buf, size - 1, "%s:%d", file, line); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); -} - - - - - - -/** - * Create a string from an addr (used in hash table) - * @param buf destination buffer - * @param size size of the buffer - * @param addr address to transform - * @return the modified pointer or NULL - */ -char *edfmt_caddr(char *buf, u_int size, eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (buf == NULL || size == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - snprintf(buf, size - 1, XFMT, addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); -} - -/** - * like revm_lookup_addr - Get address value - * @param file host file - * @param param name to search - * @return addresse found or 0 - */ -eresi_Addr edfmt_lookup_addr(elfshobj_t *file, char *param) -{ - elfsh_Sym *sym; - char eol; - int ret; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lookup .symtab */ - sym = elfsh_get_symbol_by_name(file, param); - if (sym != NULL && sym->st_value > 0) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_value); - } - - /* Lookup .dynsym */ - sym = elfsh_get_dynsymbol_by_name(file, param); - if (sym != NULL && sym->st_value > 0) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_value); - } - - /* Lookup hexadecimal numeric value */ - ret = sscanf(param, XFMT "%c", &val, &eol); - if (ret == 1) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, val); - } - - /* No match -- returns ERR */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup address object", (eresi_Addr) 0); -} - - - -/** - * Create an allocation pool used to store different data and optimize performance - * This pool didn't realloc the buffer each time it needs more memory, but create a new - * buffer and store reference of the previous (like a linked list). - * - * Reallocation isn't used because I already have some pointer inside in the allocation and - * if I made a XREALLOC the whole buffer would be recreate on another memory part, and some - * pointers would be lost. - * @param pool pool pointer - * @param apos pool position - * @param asize pool size - * @param astep pool step - * @param nsize needed size - * @return pointer on the allocated memory - */ -void *edfmt_alloc_pool(char **pool, int *apos, int *asize, - int astep, int nsize) -{ - char *prevpool; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!pool || !apos || astep <= 0 || !asize || nsize <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* First allocation */ - if (*pool == NULL || *asize == 0) - { - /* We add a void* blanked that indicate that its the first block*/ - XALLOC(__FILE__, __FUNCTION__, __LINE__, *pool, astep+sizeof(void*), NULL); - *asize = astep; - *apos += sizeof(void*); - } - else if (*apos + nsize >= *asize) - { - *asize = 0; - *apos = 0; - do { - *asize += astep; - } while (*apos + nsize >= *asize); - - prevpool = *pool; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, *pool, *asize+sizeof(void*), NULL); - *apos += 4; - - /* Store previous block address then we can retrieve it later */ - *(void **) *pool = prevpool; - } - - /* Save current position and update position pointer */ - ret = (char *) *pool + *apos; - *apos += nsize; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (void *) ret); -} - -/** - * Clean an allocated pool - * @param pool pool pointer - */ -int edfmt_clean_pool(char **pool) -{ - char *prevpool = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!pool) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Iterate and free each block */ - do { - prevpool = *(void **) *pool; - XFREE(__FILE__, __FUNCTION__, __LINE__, *pool); - *pool = prevpool; - } while (*pool != NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -## -## Makefile for libedfmt -## -## Started on Tue Dec 26 11:05:39 2006 mxatone -## -include ../config.h - -CC ?= gcc -LD ?= ld -RM = rm -f -AR = ar rc - -SRC = edfmt.c edfmt-utils.c dwarf2.c dwarf2-utils.c dwarf2-abbrev.c \ - dwarf2-cfa.c dwarf2-trans.c stabs.c stabs-trans.c stabs-utils.c api.c -OBJ = $(SRC:.c=.o) -OBJ32 = ${SRC:.c=.32.o} -OBJ64 = ${SRC:.c=.64.o} -NAME32 = libedfmt32 -NAME64 = libedfmt64 - -CFLAGS32 += -Wall -fPIC -g3 -O2 -Iinclude -I ../libaspect/include/ \ - -I../libelfsh/include/ -DELFSH_INTERN -DERESI32 - -CFLAGS64 += -Wall -fPIC -g3 -O2 -Iinclude -I ../libaspect/include/ \ - -I../libelfsh/include/ -DELFSH_INTERN -DERESI64 - -LDFLAGS32 += -L../libaspect/ -laspect32 -L../libelfsh/ -lelfsh32 -# -L../liballocproxy -lallocproxy - -LDFLAGS64 += -L../libaspect/ -laspect64 -L../libelfsh/ -lelfsh64 \ - -L../liballocproxy/ -lallocproxy - -all : all32 all64 - -libedfmt32.so : $(OBJ32) - @$(CC) $(LDFLAGS32) -shared $(OBJ32) -o $(NAME32).so - @$(AR) $(NAME32).a $(OBJ32) - @$(RANLIB) $(NAME32).a - @$(LD) -r $(OBJ32) -o $(NAME32).o -all32: libedfmt32.so - -libedfmt64.so : $(OBJ64) - @$(CC) $(LDFLAGS64) -shared $(OBJ64) -o $(NAME64).so - @$(AR) $(NAME64).a $(OBJ64) - @$(RANLIB) $(NAME64).a - @$(LD) -r $(OBJ64) -o $(NAME64).o - -all64: libedfmt64.so - -clean : - @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\# \ - include/*~ include/.\#* - -docs: - doxygen doc/doxygen.conf - -fclean : clean - @$(RM) $(NAME).so $(NAME).a \ - $(NAME32).so $(NAME32).a \ - $(NAME64).so $(NAME64).a - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/stabs.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/stabs.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/stabs.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/stabs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1276 +0,0 @@ -/** - * @defgroup libedfmt Libedfmt : The Elf debug format library of ELFsh - */ -/* -** @file stabs.c -** @ingroup libedfmt -** -** Started Jan 01 2007 21:30:13 mxatone -** -** -** $Id: stabs.c,v 1.18 2007-06-02 08:28:51 mxatone Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * This file implements stab support for libedfmt. - * specificitation @ http://wwwcdf.pd.infn.it/localdoc/stabs.pdf - * - - * This version of stabs format parsing has been approved for x86 - * and gentoo linux, some bugs can append on Sparc, more test will - * be done to make this work correctly - * @file stabs.c - */ - -#define STABS_HNAME_TYPE_REF "stabs_type_reference" -#define STABS_HNAME_TYPE_CROSS_REF "stabs_type_reference" -#define STABS_HNAME_RES_SIZE "stabs_resolve_size" - -/** - * This function is called a lot of time, we win some time - */ -#define STABS_DATA(_str) (!STABS_IVD_STR(_str) ? edfmt_stabs_data(_str) : NULL) - -/** - * Temporary structure for the next table - */ -typedef struct s_res_size -{ - char *name; - long size; -} edfmt_res_size_t; - -/** - * This table store size for every basic elements - * Stabs doens't get size information but range information that are - * hard to parse and can create some bug, then we won't use it - */ -edfmt_res_size_t resolved_table[] = - { - {"int" , sizeof(int) }, - {"char" , sizeof(char) }, - {"long int" , sizeof(long int) }, - {"unsigned int" , sizeof(unsigned int) }, - {"long unsigned int" , sizeof(long unsigned int) }, - {"long long int" , sizeof(long long int) }, - {"long long unsigned int", sizeof(long long unsigned int) }, - {"short int" , sizeof(short int) }, - {"short unsigned int" , sizeof(short unsigned int) }, - {"signed char" , sizeof(signed char) }, - {"unsigned char" , sizeof(unsigned char) }, - {"float" , sizeof(float) }, - {"double" , sizeof(double) }, - {"long double" , sizeof(long double) }, - { NULL , 0 } - }; - -/** - * Local resolv table - */ -hash_t resolved_size; - -/* Global position variables */ -elfshsect_t *stabs_sect; -elfshsect_t *stabs_sect_str; - -edfmtstabsent_t *stabs_ent; - -/* Index */ -u_int stabs_index; -u_int stabs_num; -char *stabs_datastr; - -/* File structure pointers */ -edfmtstabsfile_t *root_file = NULL; -edfmtstabsfile_t *current_file = NULL; -edfmtstabsfile_t *last_file = NULL; - -/** - * Current function we are in - */ -edfmtstabsfunc_t *current_func = NULL; - -/* Temporary hash table used for type resolution */ -hash_t type_ref; -hash_t type_cross_ref; - -/** - * Contain main informations - */ -edfmtstabsinfo_t *stabs_info = NULL; - -/** - * Macro to gain time when fetch allocation pointer from the stabs pool - */ -#define STABS_GETPTR(_var, _size, _ret) \ -do { \ - _var = edfmt_alloc_pool(&(stabs_info->alloc_pool), \ - &(stabs_info->alloc_pos), \ - &(stabs_info->alloc_size), \ - STABS_ALLOC_STEP, _size); \ -if (_var == NULL) \ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, \ - "Pool allocation failed", _ret); \ -} while (0) - - -/** - * Actual parsed file - */ -elfshobj_t *afile = NULL; - -/** - * Retreive stabs info pointer - * @param file retrieve stabs information from this file - */ -edfmtstabsinfo_t *edfmt_stabs_getinfo(elfshobj_t *file) -{ - edfmtstabsinfo_t *fstabs = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - fstabs = (edfmtstabsinfo_t *) file->debug_format.stabs; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, fstabs); -} - -/** - * Init resolved_size hash table table - */ -static int edfmt_stabs_initrestable() -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (resolved_size.ent == NULL) - { - hash_init(&resolved_size, STABS_HNAME_RES_SIZE, 20, ASPECT_TYPE_UNKNOW); - - for (index = 0; resolved_table[index].name != NULL; index++) - hash_add(&resolved_size, strdup(resolved_table[index].name), - (void *) &(resolved_table[index])); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Update a cross reference - * @param type watch if we got a type waiting for this type - * @param token help to make an unique search name - */ -static int edfmt_stabs_update_cref(edfmtstabstype_t *type, u_char token) -{ - char buf[BUFSIZ]; - edfmtstabstype_t *seek_type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (type == NULL || type->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - snprintf(buf, BUFSIZ - 1, "%c%s", token, type->data->name); - - seek_type = (edfmtstabstype_t *) hash_get(&type_cross_ref, buf); - - if (seek_type) - { - seek_type->u.link = type; - hash_del(&type_cross_ref, buf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Add a new file on the list - * @param dir new directory - * @parma file new filename - */ -int edfmt_stabs_addfile(char *dir, char *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (stabs_info == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid stabs_info", -1); - - /* At the end of the list ? */ - if (stabs_info->index_list >= stabs_info->num_list) - { - stabs_info->num_list += STABS_FILE_IT; - if (stabs_info->dir_list == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,stabs_info->dir_list, stabs_info->num_list * sizeof(char *), -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,stabs_info->file_list, stabs_info->num_list * sizeof(char *), -1); - } - else - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__,stabs_info->dir_list, stabs_info->dir_list, - stabs_info->num_list * sizeof(char *), -1); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,stabs_info->file_list, stabs_info->file_list, - stabs_info->num_list * sizeof(char *), -1); - } - } - - /* Update list pointers */ - stabs_info->dir_list[stabs_info->index_list] = dir; - stabs_info->file_list[stabs_info->index_list] = file; - - stabs_info->index_list++; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Parse a function - * @param func store information on this structure - * @param str pointer on the string to parse - */ -int edfmt_stabs_func(edfmtstabsfunc_t *func, char **str) -{ - char *my_str; - u_int arg_index = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (func == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* End of the current function ? */ - if (STABS_IVD_STR(str)) - { - if (current_func) - { - current_func->e_addr = func->s_addr + stabs_c_ent.value; - current_func = NULL; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (current_file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid current_file", NULL); - - current_func = func; - - /* Fill start infos */ - func->s_addr = stabs_c_ent.value; - func->s_line = stabs_c_ent.desc; - - func->rettype = edfmt_stabs_type(str, NULL); - - /* Update pointer list */ - if (current_file->func == NULL) - current_file->func = func; - else - current_file->last_func->next = func; - - current_file->last_func = func; - - /* Parse every param symbols next entries */ - for(stabs_index = stabs_index + 1;stabs_index < stabs_num; stabs_index++) - { - if (stabs_c_ent.type != STABS_TYPE_PSYM) - { - stabs_index--; - break; - } - - /* Ok we have a max arguments, but if you got more than 20 arguments, - blame yourself !! */ - if (arg_index < STABS_MAX_ARGUMENTS) - { - my_str = stabs_c_str; - func->args[arg_index++] = STABS_DATA(&my_str); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Parse a type range - * @param type type structure to fill - * @param str pointer on the string to parse - */ -int edfmt_stabs_range(edfmtstabstype_t *type, char **str) -{ - edfmtstabstype_t *rtype = NULL; - long low, high; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == type || STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* First we got a type */ - rtype = edfmt_stabs_type(str, NULL); - - if (**str == ';') - (*str)++; - - low = high = 0; - - /* Then a low range number */ - edfmt_stabs_readnumber(str, ';', &low); - - if (**str != ';') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid str informations", -1); - - (*str)++; - - /* And a high range number */ - edfmt_stabs_readnumber(str, ';', &high); - - if (**str != ';') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid str informations", -1); - - (*str)++; - - /* Fill range felds, but we will use only link (mainly) */ - type->type = STABS_TYPE_RANGE; - type->u.link = rtype; - - /** - * We don't read correctly very big numbers as we didn't need them - * but we still save those information - */ - type->u.r.low = low; - type->u.r.high = high; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Parse an array - * @param type structure to fill - * @param str pointer on the string to parse - * @param isString indicate if this array is a string - * @param isVector indicate if this array is a vector - */ -int edfmt_stabs_array(edfmtstabstype_t *type, char **str, - u_char isString, u_char isVector) -{ - edfmtstabstype_t *rtype; - long low, high; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == type || STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - low = high = 0; - - if (**str == 'r') - (*str)++; - - /* This type describe how index is managed .. we don't need it */ - edfmt_stabs_type(str, NULL); - - if (**str == ';') - (*str)++; - - /* Should be zero */ - edfmt_stabs_readnumber(str, ';', &low); - - if (**str != ';') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid str informations", -1); - - (*str)++; - - /* Represent the size */ - edfmt_stabs_readnumber(str, ';', &high); - - if (**str != ';') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid str informations", -1); - - (*str)++; - - /* Describe array type */ - rtype = edfmt_stabs_type(str, NULL); - - type->u.arr.low = low; - type->u.arr.high = high; - type->u.arr.link = rtype; - - if (isString) - type->u.arr.type = STABS_ARRAY_STRING; - - if (isVector) - type->u.arr.type |= STABS_ARRAY_VECTOR; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Read a structure - * @param tstruct structure to fill - * @param str pointer on the string to parse - */ -int edfmt_stabs_struct(edfmtstabsstruct_t *tstruct, char **str) -{ - edfmtstabsattr_t *tattr = NULL, *lattr = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == tstruct || STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - /* Read structure size */ - edfmt_stabs_readnumber(str, 0, &tstruct->size); - - do { - /* Allocate for a member */ - STABS_GETPTR(tattr, sizeof(edfmtstabsattr_t), -1); - - /* Update link between elements */ - if (tstruct->attr == NULL) - tstruct->attr = tattr; - else - lattr->next = tattr; - - lattr = tattr; - - /* Member name */ - edfmt_stabs_readstr(tattr->name, STABS_NAME_SIZE, str, ':'); - - if ((*str)[-1] != ':') - break; - - /* Member type */ - tattr->type = edfmt_stabs_type(str, NULL); - - if (**str != ',') - break; - - (*str)++; - - /* Start at */ - edfmt_stabs_readnumber(str, ',', &tattr->start); - tattr->start /= 8; - - if (**str != ',') - break; - - (*str)++; - - /* End at */ - edfmt_stabs_readnumber(str, ';', &tattr->size); - tattr->size /= 8; - - if (**str != ';') - break; - - (*str)++; - } while (**str != ';'); - - (*str)++; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Read an enum table - * @param str pointer on the string to parse - * @return created structure that store enum informations - */ -edfmtstabsenum_t *edfmt_stabs_enum(char **str) -{ - edfmtstabsenum_t *root_attr = NULL; - edfmtstabsenum_t *enum_attr = NULL; - edfmtstabsenum_t *last_attr = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - - while (**str != ';') - { - STABS_GETPTR(enum_attr, sizeof(edfmtstabsenum_t), NULL); - - if (root_attr == NULL) - root_attr = enum_attr; - - if (last_attr) - last_attr->next = enum_attr; - - last_attr = enum_attr; - - /* Read name */ - edfmt_stabs_readstr(enum_attr->name, STABS_NAME_SIZE, str, ':'); - - if ((*str)[-1] != ':') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong string pattern", NULL); - - /* Read value */ - if(edfmt_stabs_readnumber(str, ',', &enum_attr->value) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong string pattern", NULL); - - if (**str == ',') - (*str)++; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, root_attr); -} - -/** - * Read a type, that an important fonction. - * Stabs use type in an embedded form, a type can be declare in the center - * of a structure - * @param str pointer on the string to parse - * @return the generated type structure or an existing structure - */ -edfmtstabstype_t *edfmt_stabs_type(char **str, char *link) -{ - char *save_str; - char token; - edfmtstabstypenum_t tnum; - edfmtstabstype_t *type; - char ctypenum[STABS_CTYPENUM_SIZE]; - char name[STABS_NAME_SIZE]; - long tsize = 0; - u_char isString = 0; - u_char isVector = 0; - int addtype = 1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - - tnum.file = tnum.number = 0; - - /* Default case */ - if (link) - *link = 0; - - /* Retrieve the type number */ - if (STABS_IS_SPECIAL(**str)) - { - edfmt_stabs_typenum(&tnum, str); - - if (**str != '=') - { - edfmt_stabs_ctypenum(ctypenum, STABS_CTYPENUM_SIZE, &tnum); - type = hash_get(&type_ref, ctypenum); - - if (link) - *link = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); - } - - (*str)++; - } - else - { - /* Anonymous type */ - tnum.file = tnum.number = -1; - } - - STABS_GETPTR(type, sizeof(edfmtstabstype_t), NULL); - type->num = tnum; - - typestart: - token = *(*str)++; - - /* Parse type descriptor */ - if (STABS_IS_SPECIAL(token)) - { - (*str)--; - save_str = *str; - edfmt_stabs_typenum(&tnum, str); - - /* VOID case */ - if (**str != '=' && type->num.file >= 0 - && type->num.file == tnum.file - && type->num.number == tnum.number) - { - type->type = STABS_TYPE_VOID; - } - else - { - /* Restore string position */ - *str = save_str; - type->type = STABS_TYPE_LINK; - type->u.link = edfmt_stabs_type(str, NULL); - if (type->u.link) - type->u.link->parent_link = type; - } - } - else - { - /** - * Stabs is a really strange and difficult format - * You should read the documentation, you'll see that stabs can - * be different depending of the architecture, which create a lot of issue. - */ - type->type = STABS_TYPE_UNK; - switch(token) - { - case STABS_STR_D_METHOD: - /** - * We don't support C++ for the moment - * as clear representation isn't set for - * the moment, we will see - */ - break; - case STABS_STR_D_PTR: - case STABS_STR_D_REF: - case STABS_STR_D_TFUNC: - case STABS_STR_D_VOLATILE: - case STABS_STR_D_CONST: - switch(token) - { - case STABS_STR_D_PTR: - type->type = STABS_TYPE_PTR; - break; - case STABS_STR_D_REF: - type->type = STABS_TYPE_REF; - break; - case STABS_STR_D_TFUNC: - type->type = STABS_TYPE_FUNC; - break; - case STABS_STR_D_VOLATILE: - type->type = STABS_TYPE_VOLATILE; - break; - case STABS_STR_D_CONST: - type->type = STABS_TYPE_CONST; - break; - } - type->u.link = edfmt_stabs_type(str, NULL); - break; - case STABS_STR_D_ATTR: - /* GNU C++ way - Class member*/ - if (STABS_IS_SPECIAL(**str)) - { - /** - * We don't support C++ for the moment - * as clear representation isn't set for - * the moment, we will see - */ - break; - } - else - { - /* AIX way - Attribute */ - switch (*(*str)++) - { - case STABS_STR_AIX_SIZE: - edfmt_stabs_readnumber(str, ';', &tsize); - - if (**str != ';') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid AIX attribute", NULL); - - (*str)++; - break; - case STABS_STR_AIX_STRING: - isString = 1; - break; - case STABS_STR_AIX_VECTOR: - isVector = 1; - break; - } - goto typestart; - } - break; - case STABS_STR_D_CREF: - /* We get the name from with the first part, then we can search the correct type */ - type->type = STABS_TYPE_CLINK; - edfmt_stabs_readstr(name, STABS_NAME_SIZE, str, STABS_STR_DELIM); - HASH_ADDX(&type_cross_ref, name, type); - break; - case STABS_STR_D_ARRAY: - type->type = STABS_TYPE_ARRAY; - edfmt_stabs_array(type, str, isString, isVector); - break; - case STABS_STR_D_ENUM: - type->type = STABS_TYPE_ENUM; - type->u.enum_attr = edfmt_stabs_enum(str); - break; - case STABS_STR_D_RANGE: - edfmt_stabs_range(type, str); - break; - case STABS_STR_D_STRUCT: - case STABS_STR_D_UNION: - type->type = token == STABS_STR_D_STRUCT ? STABS_TYPE_STRUCT : STABS_TYPE_UNION; - - edfmt_stabs_ctypenum(type->cnum, STABS_CTYPENUM_SIZE, &type->num); - - HASH_ADDX(&type_ref, type->cnum, type); - addtype = 0; - - edfmt_stabs_struct(&(type->u.struct_union), str); - break; - case STABS_STR_D_BITSTRING: - break; - } - } - - /* Add it into hash table */ - if (type && addtype) - { - edfmt_stabs_ctypenum(type->cnum, STABS_CTYPENUM_SIZE, &type->num); - HASH_ADDX(&type_ref, type->cnum, type); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - -/** - * Parse the string - * A data element represent the whole string - * @param str pointer on the string to parse - * @return return a data structure - */ -edfmtstabsdata_t *edfmt_stabs_data(char **str) -{ - edfmt_res_size_t *res; - char token, *save_str, link; - char name[STABS_NAME_SIZE]; - edfmtstabsdata_t *data; - edfmtstabstype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - -#if __DEBUG_STABS__ - printf("[DEBUG_STABS] (0x%x) %s - %s - %s\n", - stabs_c_ent.type, - current_file ? current_file->path : "?", - current_file ? current_file->file : "?", - *str); -#endif - - edfmt_stabs_readstr(name, STABS_NAME_SIZE, str, STABS_STR_DELIM); - - if ((*str)[-1] != STABS_STR_DELIM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Stabs type not found", NULL); - - STABS_GETPTR(data, sizeof(edfmtstabsdata_t), NULL); - - strncpy(data->name, name, STABS_NAME_SIZE); - data->name[STABS_NAME_SIZE - 1] = 0x00; - - if (STABS_IS_SPECIAL(**str)) - { - data->scope = STABS_SCOPE_LVAR; - data->type = edfmt_stabs_type(str, NULL); - data->u.stackpos = stabs_c_ent.value; - } - else - { - data->scope = STABS_SCOPE_UNK; - - token = *(*str)++; - - switch(token) - { - /* A reference using a register */ - case STABS_STR_T_PARAM_RREG: - data->scope = STABS_SCOPE_ARGRREG; - data->u.reg = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* A constant */ - case STABS_STR_T_CONST: - if (**str == '=') - (*str)++; - - /* More information on the type */ - switch(*(*str)++) - { - case STABS_STR_T_CONST_FLOAT: - data->scope = STABS_SCOPE_CONST_F; - data->u.fl = atof(*str); - break; - case STABS_STR_T_CONST_INT: - data->scope = STABS_SCOPE_CONST_I; - data->u.i = atoi(*str); - break; - case STABS_STR_T_CONST_ENUM: - data->scope = STABS_SCOPE_CONST_E; - data->type = edfmt_stabs_type(str, NULL); - - if (**str == ',') - (*str)++; - - data->u.i = atoi(*str); - break; - } - break; - - /* Local and global function */ - case STABS_STR_T_FFUNC: - case STABS_STR_T_GFUNC: - data->scope = token == STABS_STR_T_FFUNC ? STABS_SCOPE_LFUNC : STABS_SCOPE_GFUNC; - data->u.func.data = data; - - /* Parse function informations (arguments etc ..) */ - edfmt_stabs_func(&data->u.func, str); - break; - - /* Global symbol (like a global enum) */ - case STABS_STR_T_GVAR: - data->scope = STABS_SCOPE_GVAR; - data->type = edfmt_stabs_type(str, NULL); - - if (data->type == NULL) - break; - - data->u.addr = edfmt_lookup_addr(afile, data->name); - break; - - /* Integer constant */ - case STABS_STR_T_ICONST: - data->scope = STABS_SCOPE_CONST_I; - data->u.i = atoi(*str); - break; - - /* Function argument */ - case STABS_STR_T_ARGLIST: - data->scope = STABS_SCOPE_ARG; - data->u.stackpos = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* Argument pass into a register */ - case STABS_STR_T_PARAM_REG: - data->scope = STABS_SCOPE_ARGREG; - data->u.reg = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* Variable stored in a register */ - case STABS_STR_T_VAR_REG: - data->scope = STABS_SCOPE_VARREG; - data->u.reg = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* Static variable */ - case STABS_STR_T_VAR_FSCOPE: - data->scope = STABS_SCOPE_STATICVAR; - data->u.addr = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* Local variable */ - case STABS_STR_T_VAR_LOCAL: - data->scope = STABS_SCOPE_LVAR; - data->type = edfmt_stabs_type(str, NULL); - data->u.stackpos = stabs_c_ent.value; - break; - - /* New type */ - case STABS_STR_T_TYPE_STRUCT: - case STABS_STR_T_TYPE_NAME: - data->scope = STABS_SCOPE_TYPE; - save_str = *str; - - data->type = edfmt_stabs_type(str, &link); - - /* If its a link, we duplicate it and then avoid infinite loop - on type list of the file */ - if (link) - { - type = data->type; - STABS_GETPTR(data->type, sizeof(edfmtstabstype_t), NULL); - memcpy(data->type, type, sizeof(edfmtstabstype_t)); - data->type->next = NULL; - } - - data->type->data = data; - - /* Resolve size for range types */ - if (data->type->type == STABS_TYPE_RANGE) - { - res = hash_get(&resolved_size, data->name); - - if (res) - data->type->u.r.size = res->size; - } - - /* Cross reference types */ - if (data->type->type == STABS_TYPE_STRUCT - || data->type->type == STABS_TYPE_UNION - || data->type->type == STABS_TYPE_ENUM) - { - switch(data->type->type) - { - case STABS_TYPE_STRUCT: - token = STABS_STR_D_STRUCT; - break; - case STABS_TYPE_UNION: - token = STABS_STR_D_UNION; - break; - case STABS_TYPE_ENUM: - token = STABS_STR_D_ENUM; - break; - } - - edfmt_stabs_update_cref(data->type, token); - } - break; - - /* Argument passed by reference */ - case STABS_STR_T_PARAM_REF: - data->scope = STABS_SCOPE_ARGREF; - data->u.stackpos = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - - /* Procedure static variable */ - case STABS_STR_T_PROC_SVAR: - data->scope = STABS_SCOPE_PSTATICVAR; - data->u.addr = stabs_c_ent.value; - data->type = edfmt_stabs_type(str, NULL); - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, data); -} - -/** - * Main stabs function - * Contain the string and more global informations - * @param file file to parse - */ -int edfmt_stabs_parse(elfshobj_t *file) -{ - char *str, *sfile; - edfmtstabsfile_t *tmp; - u_char parse_str; - u_char inc; - edfmtstabsline_t *line; - edfmtstabsdata_t *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (edfmt_stabs_getinfo(file) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Retrieve stabs section */ - stabs_sect = edfmt_get_sect(file, ELFSH_SECTION_STAB, ELFSH_SECTION_NAME_STAB, - ELFSH_SECTION_STABSTR); - - if (NULL == stabs_sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "STABS section not found", -1); - - /* Retrieve stabs string section */ - stabs_sect_str = file->secthash[ELFSH_SECTION_STABSTR]; - - if (NULL == stabs_sect_str) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "STABS string section not found", -1); - - afile = file; - - edfmt_stabs_initrestable(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, stabs_info, sizeof(edfmtstabsinfo_t), -1); - - /* Init hash tables */ - if (type_ref.ent == NULL) - hash_init(&type_ref, STABS_HNAME_TYPE_REF, 50, ASPECT_TYPE_UNKNOW); - - if (type_cross_ref.ent == NULL) - hash_init(&type_cross_ref, STABS_HNAME_TYPE_CROSS_REF, 50, ASPECT_TYPE_UNKNOW); - - /* Initialise global variables */ - stabs_datastr = (char *) stabs_sect_str->data; - stabs_ent = (edfmtstabsent_t *) stabs_sect->data; - stabs_num = stabs_sect->shdr->sh_size / sizeof(edfmtstabsent_t); - - for (stabs_index = 0; stabs_index < stabs_num; stabs_index++) - { - inc = 0; - str = stabs_c_str; - parse_str = 1; - - switch(stabs_c_ent.type) - { - /* Compiler information */ - case STABS_TYPE_OPT: - parse_str = 0; - break; - - /* Manage line numbers */ - case STABS_TYPE_DSLINE: - case STABS_TYPE_BSLINE: - case STABS_TYPE_FLINE: - case STABS_TYPE_SLINE: - if (!current_file) - break; - - sfile = current_file->file; - if (current_file->file && current_file->file[0]) - { - sfile = strrchr(current_file->file, '\\'); - - sfile = sfile && sfile[1] != '\0' ? sfile+1 : current_file->file; - } - - STABS_GETPTR(line, sizeof(edfmtstabsline_t), -1); - - /* Fill right informations */ - line->line = (u_int) stabs_c_ent.desc; - line->addr = stabs_c_ent.value; - - /* Update pointers */ - if (current_file->line == NULL) - current_file->line = line; - else - current_file->last_line->next = line; - - current_file->last_line = line; - break; - - case STABS_TYPE_BINCL: - if (!current_file) - break; - - inc = 1; - - /* Include or SO file */ - case STABS_TYPE_SO: - parse_str = 0; - if (!inc && (!str || !str[0])) - { - if (!current_file) - break; - - /* We have the end addr */ - current_file->e_addr = stabs_c_ent.value; - - /* Update pointers */ - last_file = current_file; - current_file = NULL; - -#if __DEBUG_STABS__ - printf("[DEBUG_STABS] ------------------------------------------------\n"); -#endif - break; - } - - /* We just setup dir name, now it will be filename */ - if (!inc && current_file != NULL && current_file->file == NULL) - { - current_file->file = str; - edfmt_stabs_addfile(current_file->path, current_file->file); - break; - } - else if (inc) - { - edfmt_stabs_addfile(NULL, str); - } - - STABS_GETPTR(tmp, sizeof(edfmtstabsfile_t), -1); - - if (inc) - tmp->file = str; - else - tmp->path = str; - -#if __DEBUG_STABS__ - printf("[DEBUG_STABS] - %s%s -----------------------------------------------\n", - inc ? "[i] " : "", - str); -#endif - - tmp->s_addr = stabs_c_ent.value; - - if (!inc) - { - /* Update first file if needed */ - if (stabs_info->file == NULL) - stabs_info->file = tmp; - - /* Update current or last file */ - if (current_file != NULL) - { - last_file = current_file; - - if (current_file->next == tmp) - break; - - current_file->next = tmp; - } - else if (last_file != NULL) - { - last_file->next = tmp; - } - } - else - { - if (!current_file) - break; - - /* Do we already have some include ? */ - if (current_file->last_inc) - { - if (current_file->last_inc->next == tmp) - break; - - current_file->last_inc->next = tmp; - current_file->last_inc = tmp; - } - else - { - current_file->inc = tmp; - current_file->last_inc = tmp; - } - - tmp->parent = current_file; - } - - current_file = tmp; - break; - - /* End include */ - case STABS_TYPE_EINCL: - if (current_file && current_file->parent) - current_file = current_file->parent; - break; - - /* Differents symbols */ - case STABS_TYPE_FUN: - case STABS_TYPE_STSYM: - case STABS_TYPE_SSYM: - case STABS_TYPE_PSYM: - case STABS_TYPE_GSYM: - case STABS_TYPE_LSYM: - break; - case STABS_TYPE_LBRAC: - case STABS_TYPE_RBRAC: - /* We didn't use brac for the moment */ - parse_str = 0; - break; - case STABS_TYPE_EXCL: - /* Stabs manual: Place holder for a deleted include file - TODO: understand it, we already have EINCL for close an include file */ - parse_str = 0; - break; - default: - parse_str = 0; - break; - } - - if (parse_str) - { - data = STABS_DATA(&str); - - if (data && current_file) - { - /* TODO: Add more informations */ - switch(data->scope) - { - case STABS_SCOPE_TYPE: - if (current_file->types == NULL) - current_file->types = data->type; - else - { - if (current_file->ltype == data->type) - break; - - current_file->ltype->next = data->type; - } - current_file->ltype = data->type; - break; - case STABS_SCOPE_GVAR: - if (current_file->vars == NULL) - current_file->vars = data; - else - { - if (current_file->lvar == data) - break; - - current_file->lvar->next = data; - } - current_file->lvar = data; - break; - } - } - } - else - { -#if __DEBUG_STABS__ - printf("[DEBUG_STABS]!(0x%x) %s - %s - %s\n", - stabs_c_ent.type, - current_file ? current_file->path : "?", - current_file ? current_file->file : "?", - str); -#endif - } - } - - /* Clean hash tables */ - hash_empty(STABS_HNAME_TYPE_REF); - hash_empty(STABS_HNAME_TYPE_CROSS_REF); - - file->debug_format.stabs = (void *) stabs_info; - stabs_info = NULL; - root_file = current_file = last_file = NULL; - current_func = NULL; - afile = NULL; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Clean stabs allocated structures - * @param file to clean - */ -int edfmt_stabs_clean(elfshobj_t *file) -{ - edfmtstabsinfo_t *info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - info = edfmt_stabs_getinfo(file); - - if (!info) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (info->dir_list) - XFREE(__FILE__, __FUNCTION__, __LINE__, info->dir_list); - - if (info->file_list) - XFREE(__FILE__, __FUNCTION__, __LINE__, info->file_list); - - if (info->alloc_pool) - edfmt_clean_pool(&(info->alloc_pool)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/stabs-trans.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/stabs-trans.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/stabs-trans.c.svn-base 2008-04-06 23:15:30.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/stabs-trans.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,406 +0,0 @@ -/* -** @file stabs-trans.c -** @ingroup libedfmt -** -** Started Fev 02 2007 14:35:03 mxatone -** -** -** $Id: stabs-trans.c,v 1.11 2007-06-02 19:18:11 mxatone Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * Translation from stabs representation into uniform format - * @file stabs-trans.c - */ - -#define STABS_HNAME_TYPE_ADD "stabs_type_added" - -/** - * Type hash table - * store added type - */ -hash_t types_added; - -/** - * Optimize stack allocation by setting a global pointer for string things - */ -char buf[BUFSIZ]; - -/** - * Advanced iterating of a structure element - * @param type type input - * @param main_type (0 = resolve way, 1 = main way) - * @return generated uniform type - */ -static edfmttype_t *edfmt_stabs_transform_type_adv(edfmtstabstype_t *type, u_char main_type) -{ - edfmttype_t *etype = NULL; - edfmttype_t *stype = NULL; - edfmttype_t *ftype = NULL; - edfmtstabsattr_t *attr; - char *str = NULL; - int addtype = 1; - u_char wasclink = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* Do we already have a type for this entry ? */ - if (type->transtype != NULL) - { - if (main_type) - edfmt_change_type_nfile(type->transtype); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type->transtype); - } - - /* Thread by type */ - switch(type->type) - { - case STABS_TYPE_UNION: - case STABS_TYPE_STRUCT: - if (type->data) - str = type->data->name; - - /* Resolve a name from a parent link */ - if (!str && type->parent_link && type->parent_link->data) - str = type->parent_link->data->name; - - /* If we didn't have any name, we generate it */ - if (!str) - { - snprintf(buf, BUFSIZ - 1, "s_(%d)", rand() % 99999); - str = buf; - } - - if (type->type == STABS_TYPE_STRUCT) - { - etype = edfmt_add_type_struct(str, - (int) type->u.struct_union.size); - } - else - { - etype = edfmt_add_type_union(str, - (int) type->u.struct_union.size); - } - - /* Add the new type to avoid infinite loop */ - if (etype) - { - type->transtype = etype; - HASH_ADDX(&types_added, type->cnum, etype); - addtype = 0; - } - - /* Add structure / union members */ - for (attr = type->u.struct_union.attr; attr != NULL; attr = attr->next) - { - if (attr->type) - { - stype = edfmt_stabs_transform_type_adv(attr->type, 0); - - ftype = edfmt_add_type_attr(etype, attr->name, - attr->start, attr->size, stype); - } - } - break; - case STABS_TYPE_RANGE: - /* A range is a basic type */ - etype = edfmt_add_type_basic(type->data->name, (int) type->u.r.size); - break; - case STABS_TYPE_ARRAY: - stype = edfmt_stabs_transform_type_adv(type->u.arr.link, 0); - - str = type->data->name; - if (str == NULL) - { - /* Generate an array type */ - snprintf(buf, BUFSIZ - 1, "%s[%ld]", stype->name, type->u.arr.high+1); - str = buf; - } - - etype = edfmt_add_type_array(str, - type->u.arr.high, - stype); - break; - case STABS_TYPE_VOID: - etype = edfmt_add_type_void(type->data->name); - break; - case STABS_TYPE_CONST: - case STABS_TYPE_FUNC: - case STABS_TYPE_LINK: - case STABS_TYPE_REF: - case STABS_TYPE_PTR: - case STABS_TYPE_CLINK: - if (type->type == STABS_TYPE_CLINK) - { - /* Cross reference not found, that can happen */ - if (type->u.link == NULL) - { - etype = edfmt_add_type_unk("unk_cref"); - } - else - { - wasclink = 1; - type->type = STABS_TYPE_LINK; - } - } - - if (etype == NULL) - { - stype = edfmt_stabs_transform_type_adv(type->u.link, 0); - - if (!stype) - break; - - switch(type->type) - { - case STABS_TYPE_CONST: - snprintf(buf, BUFSIZ - 1, "(const:%s)", stype->name); - str = buf; - break; - case STABS_TYPE_FUNC: - snprintf(buf, BUFSIZ - 1, "(func:%s)()", stype->name); - stype->size = sizeof(void *); - str = buf; - break; - case STABS_TYPE_PTR: - stype->size = sizeof(void *); - default: - str = type->data->name; - if (str == NULL || !str[0]) - { - if (wasclink) - { - snprintf(buf, BUFSIZ - 1, "%s", stype->name); - str = buf; - } - else - { - snprintf(buf, BUFSIZ - 1, "*%s", stype->name); - str = buf; - } - } - } - - if (type->type == STABS_TYPE_LINK) - etype = edfmt_add_type_link(str, stype); - else - etype = edfmt_add_type_ptr(str, stype); - } - break; - case STABS_TYPE_VOLATILE: - case STABS_TYPE_ENUM: - /* Not yet */ - break; - } - - if (etype && addtype) - { - type->transtype = etype; - HASH_ADDX(&types_added, type->cnum, etype); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, etype); -} - -/** - * This function iterate from normal way - * @param type_list input stabs type list - * @see edfmt_stabs_transform_type_adv - */ -static int edfmt_stabs_transform_type(edfmtstabstype_t *type_list) -{ - edfmtstabstype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!type_list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - for (type = type_list; type != NULL; type = type->next) - edfmt_stabs_transform_type_adv(type, 1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Transform a variable - * @param var_list input stabs variable list - */ -static int edfmt_stabs_transform_var(edfmtstabsdata_t *var_list) -{ - edfmttype_t *stype; - edfmtstabsdata_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!var_list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - for (var = var_list; var != NULL; var = var->next) - { - if (!var->type) - continue; - - /* For the moment we handle only global variables */ - switch(var->scope) - { - case STABS_SCOPE_GVAR: - stype = edfmt_stabs_transform_type_adv(var->type, 0); - - edfmt_add_var_global(stype, var->name, var->u.addr); - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Transform a function - * @param func_list input stabs function list - */ -static int edfmt_stabs_transform_func(edfmtstabsfunc_t *func_list) -{ - edfmtstabsfunc_t *func; - edfmtstabsdata_t *arg_func; - edfmtfunc_t *uni_func; - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!func_list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - /* Stabs function is a simple linked list without any child */ - for (func = func_list; func != NULL; func = func->next) - { - if (!func->data || !func->rettype) - continue; - - uni_func = edfmt_add_func(func->data->name, func->rettype->transtype, - func->s_addr, func->e_addr); - - if (!uni_func) - continue; - - /* We add each argument using uni_func pointer */ - for (index = 0; index < STABS_MAX_ARGUMENTS && func->args[index]; index++) - { - arg_func = func->args[index]; - - if (!arg_func->type) - continue; - - switch(arg_func->scope) - { - case STABS_SCOPE_ARG: - edfmt_add_arg(uni_func, arg_func->name, 0, arg_func->u.stackpos, - arg_func->type->transtype); - break; - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Organize the whole transformation of the stabs format - * @param sfile tranform this file list - * @param parent parent file - */ -static int edfmt_stabs_transform_adv(edfmtstabsfile_t *sfile, - edfmtfile_t *parent) -{ - edfmtfile_t *mparent; - edfmtstabsfile_t *tfile; - char name[EDFMT_NAME_SIZE]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!sfile) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - if (types_added.ent == NULL) - hash_init(&types_added, STABS_HNAME_TYPE_ADD, 50, ASPECT_TYPE_UNKNOW); - - /* Iterate each element of the file list */ - for (tfile = sfile; tfile != NULL; tfile = tfile->next) - { - snprintf(name, EDFMT_NAME_SIZE - 1, - "%s%s%s", - tfile->path ? tfile->path : "", - tfile->path && tfile->file ? \ - (tfile->path[strlen(tfile->path)-1] == '/' ? "" : "/") : "", - tfile->file ? tfile->file : ""); - - mparent = edfmt_add_file(parent, name, tfile->s_addr, tfile->e_addr); - - if (tfile->types) - edfmt_stabs_transform_type(tfile->types); - - if (tfile->vars) - edfmt_stabs_transform_var(tfile->vars); - - if (tfile->inc) - edfmt_stabs_transform_adv(tfile->inc, mparent); - - if (tfile->func) - edfmt_stabs_transform_func(tfile->func); - } - - hash_empty(STABS_HNAME_TYPE_ADD); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Transform stabs informations - Entry point - * @param file file to transform from stabs to uniform format - * @see edfmt_stabs_transform_adv - */ -int edfmt_stabs_transform(elfshobj_t *file) -{ - edfmtstabsinfo_t *tinfo; - edfmtstabsfile_t *tfile; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - tinfo = (edfmtstabsinfo_t *) file->debug_format.stabs; - - if (tinfo == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No debug information for stabs", -1); - - tfile = (edfmtstabsfile_t *) tinfo->file; - - if (tfile == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No file information for stabs", -1); - - /* Init api */ - edfmt_add_init(file); - - edfmt_stabs_transform_adv(tfile, NULL); - - /* Reset api */ - edfmt_add_end(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libedfmt/.svn/text-base/stabs-utils.c.svn-base eresi-0.0.20110516/libedfmt/.svn/text-base/stabs-utils.c.svn-base --- eresi-0.8a25/libedfmt/.svn/text-base/stabs-utils.c.svn-base 2008-04-06 23:15:31.000000000 +0000 +++ eresi-0.0.20110516/libedfmt/.svn/text-base/stabs-utils.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -/* -** @file stabs-utils.c -** @ingroup libedfmt -** Started Jan 01 2007 21:30:13 mxatone -** -** -** $Id: stabs-utils.c,v 1.6 2007-03-07 16:45:35 thor Exp $ -** -*/ - -#include "libedfmt.h" - -/** - * Read a stabs name, delimited by a special char - * @param buf store resulting string - * @param size size of the buffer - * @param str pointer on the string to parse - * @param c_delim delimitation string - */ -char *edfmt_stabs_readstr(char *buf, u_int size, char **str, char c_delim) -{ - u_int csize; - char *delim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == buf || size == 0 || STABS_IVD_STR(str) || c_delim == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - delim = strchr(*str, c_delim); - - csize = delim ? delim - *str + 1 : size; - - if (csize > size) - csize = size; - - /* Copy the name into buf string */ - strncpy(buf, *str, csize); - buf[csize - 1] = 0x00; - - *str += csize; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); -} - -/** - * Read a number from a string - * We didn't support octal numbers very well, in fact this informations is quite - * uninsteresting, we know the architecture and the type name, it would be far - * more easy to use an hash table to understand perfectly which type we are - * talking about. - * @param str pointer on the string to parse - * @param c_delim delimitation char, it will break on every char that isn't a number - * @param set_num result number - */ -int edfmt_stabs_readnumber(char **str, char c_delim, long *set_num) -{ - int sign = 1; - int base = 10; - long num = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (STABS_IVD_STR(str) || !set_num) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - if (**str == '-') - { - sign = -1; - (*str)++; - } - - if (**str == '0') - { - base = 8; - (*str)++; - } - - for (;**str >= '0' && **str <= ('0' + base); (*str)++) - { - num *= base; - num += **str - '0'; - } - - if (c_delim && **str != c_delim) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - *set_num = num * sign; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Read a type number (num,num) or num - * @param tnum store typenum informations - * @param str pointer on the string to parse - */ -int edfmt_stabs_typenum(edfmtstabstypenum_t *tnum, char **str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (STABS_IVD_STR(str)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - /* With two ids ? */ - if (**str == '(') - { - (*str)++; - - /* First element, the file id */ - if (edfmt_stabs_readnumber(str, ',', &tnum->file) != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - (*str)++; - - /* Second element the real id */ - if (edfmt_stabs_readnumber(str, ')', &tnum->number) != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - (*str)++; - } - else - { - /* We support basic typenums */ - tnum->file = 0; - if (edfmt_stabs_readnumber(str, 0, &tnum->number) != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create a string from a typenum - * A typenum represent a type using 1 or 2 ids, on the documentation we see only 1 id - * but now there's two ids, the first describe the file. - * @param buf store string - * @param size size of the buffer - * @param tnum input type number - */ -int edfmt_stabs_ctypenum(char *buf, u_int size, edfmtstabstypenum_t *tnum) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!buf || size == 0 || !tnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - snprintf(buf, size - 1, "(%ld,%ld)", tnum->file, tnum->number); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/alpha64.c eresi-0.0.20110516/libelfsh/alpha64.c --- eresi-0.8a25/libelfsh/alpha64.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/alpha64.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file alpha64.c +* @file libelfsh/alpha64.c * @ingroup libelfsh ** Alpha64.c for libelfsh ** @@ -8,7 +8,7 @@ ** Skeleton cut & pasted from the sparc64 backend ** ** -** $Id: alpha64.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: alpha64.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -16,12 +16,12 @@ /** - * Static hooking for Alpha64 + * @brief Static hooking for Alpha64 (UNIMPLEMENTED) * @param sect elfsh section object * @param name the name of the section * @param sym the name of symbol * @param addr the address - * @return + * @return Always -1 (UNIMPLEMENTED) */ int elfsh_cflow_alpha64(elfshobj_t *sect, char *name, @@ -51,7 +51,9 @@ -/** ALTPLT hijacking on ALPHA64 +/** + * @brief ALTPLT hijacking on ALPHA64 + * * On ALPHA we dont have any relative operands while those * bytes are copied. @@ -70,10 +72,10 @@ * If we dont do this ALTPLT hijack, we cannot call the original * function from the hook function that was setup in PLT. * - * @param file elfshobj - * @param symbol elfsh symbol sturcture - * @param addr address - * @return + * @param file The parent file where redirection will take place. + * @param symbol Unused. + * @param addr Unused. + * @return Success (0) or Error (-1). */ int elfsh_hijack_altplt_alpha64(elfshobj_t *file, elfsh_Sym *symbol, @@ -151,7 +153,7 @@ /* 00 00 60 d0 bsr t2,120000ae0 */ opcode[11] = 0xd0600000; - elfsh_raw_write(file, altpltprolog->shdr->sh_offset, + elfsh_writememf(file, altpltprolog->shdr->sh_offset, opcode, sizeof(uint32_t) * 12); @@ -159,7 +161,7 @@ off = ((-52) >> 2); off = (off & (~(0xffffffff << 20))); opcode[0] = 0xc0900000 | (uint32_t) off; - elfsh_raw_write(file, altplt->shdr->sh_offset, + elfsh_writememf(file, altplt->shdr->sh_offset, opcode, sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -167,11 +169,11 @@ /** - * PLT hijacking on ALPHA64 - * @param file elfshobj - * @param symbol elfsh symbol sturcture - * @param addr address - * @return + * @brief PLT redirection on ALPHA64 + * @param file The parent file where redirection take place. + * @param symbol Symbol indicating address to redirect. + * @param addr Address to redirect to. + * @return Success (0) or Error (-1). */ int elfsh_hijack_plt_alpha64(elfshobj_t *file, elfsh_Sym *symbol, @@ -221,9 +223,9 @@ opcode[0] = swap32(opcode[0]); opcode[1] = swap32(opcode[1]); opcode[2] = swap32(opcode[2]); - elfsh_raw_write(file, foffset, opcode, sizeof(uint32_t) * 3); + elfsh_writememf(file, foffset, opcode, sizeof(uint32_t) * 3); #else - elfsh_raw_write(file, foffset, opcode, sizeof(uint32_t) * 3); + elfsh_writememf(file, foffset, opcode, sizeof(uint32_t) * 3); #endif PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -233,11 +235,10 @@ /** - * Find the address of modgot entry for this value - * - * @param modgot - * @param addr - * @return + * @brief Find the address of modgot entry from its value. + * @param modgot Section descriptor for .mod.o.got + * @param addr Address to find. + * @return The address of the correspinding MODGOT slot, or NULL if not found. */ eresi_Addr elfsh_modgot_find(elfshsect_t *modgot, eresi_Addr addr) { @@ -246,7 +247,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cur = elfsh_get_raw(modgot); + cur = elfsh_readmem(modgot); for (idx = 0; idx < modgot->shdr->sh_size / sizeof(eresi_Addr); idx++) { @@ -263,11 +264,10 @@ } /** - * Handle the mod.o.got section - * - * @param infile - * @param modrel - * @return + * @brief Create the mod.o.got section for a newly injected ET_REL object. + * @param infile Host file where the injection takes place. + * @param modrel Relocation section for the injected ET_REL object. + * @return Descriptor on the injected mod.o.got section or NULL if error. */ elfshsect_t *elfsh_modgot_alpha64(elfshsect_t *infile, elfshsect_t *modrel) { @@ -309,14 +309,13 @@ for (idx = 0; idx < sctcur->shdr->sh_size / size; idx++) { relcur = (IS_REL(modrel) ? - (void *) ((elfsh_Rel *) elfsh_get_raw(sctcur) + idx) : - (void *) ((elfsh_Rela *) elfsh_get_raw(sctcur) + idx)); + (void *) ((elfsh_Rel *) elfsh_readmem(sctcur) + idx) : + (void *) ((elfsh_Rela *) elfsh_readmem(sctcur) + idx)); if (elfsh_get_reltype(relcur) == R_ALPHA_LITERAL) needed++; } - - printf("Size for modgot = %u entries \n", needed); + //printf("Size for modgot = %u entries \n", needed); /* ** Inject section. Here we are sure that it was loaded in last @@ -334,7 +333,7 @@ if (modgot == NULL) goto bad; - got = elfsh_get_raw(modgot); + got = elfsh_readmem(modgot); /* ** Fill the mod.o.got with pointers to the real data @@ -347,8 +346,8 @@ for (idx = 0; idx < sctcur->shdr->sh_size / size; idx++) { relcur = (IS_REL(modrel) ? - (void *) ((elfsh_Rel *) elfsh_get_raw(sctcur) + idx) : - (void *) ((elfsh_Rela *) elfsh_get_raw(sctcur) + idx)); + (void *) ((elfsh_Rel *) elfsh_readmem(sctcur) + idx) : + (void *) ((elfsh_Rela *) elfsh_readmem(sctcur) + idx)); /* Now there are many possible computations for the address */ if (elfsh_get_reltype(relcur) == R_ALPHA_LITERAL) @@ -412,15 +411,15 @@ /** - * Perform relocation on entry for ALPHA64 architecture. + * @brief Perform relocation on entry for ALPHA64 architecture. * Only the types that are needed for relocating ET_REL objects * are filled, others might come on the need. - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return + * @param new The section to relocate within the host file. + * @param cur The relocation entry to perform. + * @param dword The location of the dword to relocate. + * @param addr Address value needed for performing relocation. + * @param mod Relocation section from the ET_REL object. + * @return Success (0) or Error (-1). */ int elfsh_relocate_alpha64(elfshsect_t *new, elfsh_Rela *cur, @@ -651,8 +650,8 @@ break; default: -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unsupported relocation type", - -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unsupported relocation type", + -1); break; } diff -Nru eresi-0.8a25/libelfsh/altgot.c eresi-0.0.20110516/libelfsh/altgot.c --- eresi-0.8a25/libelfsh/altgot.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/altgot.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file altgot.c +* @file libelfsh/altgot.c * @ingroup libelfsh ** altgot.c for libelfsh ** @@ -7,19 +7,16 @@ ** of the ALTGOT technique. ** ** Started on Wed Jun 08 21:20:07 2005 mm -** -** -** $Id: altgot.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** +** $Id: altgot.c 1397 2009-09-13 02:19:08Z may $ */ #include "libelfsh.h" /** - * Shift the relocation HI16 and L16 for mips binaries + * @brief Shift the relocation HI16 and L16 for mips binaries * We have to do that using a signature since no relocation - * tables are available in ET_EXEC files on mips. + * tables are available in ET_EXEC files on MIPS. * * 3c1c0000 lui gp,0x0 * 279c0000 addiu gp,gp,0 @@ -28,9 +25,9 @@ * .alt.got address that we need to add to the HI16 relocations * matching the signature. * - * @param file - * @param diff - * @return + * @param file Parent file. + * @param diff Absolute difference to shift with. + * @return Nothing. */ void elfsh_shift_mips_relocs(elfshobj_t *file, eresi_Addr diff) { @@ -73,18 +70,17 @@ /** - * Shift the ALPHA relocations - * - * @param file - * @param name - * @param altgot + * @brief Shift the ALPHA relocation table. + * @param file The file where to relocate the table. + * @param name Name of symbol for which to relocate entry. + * @param altgot Descriptor for the ALTGOT section. * @param off - * @return + * @return Success (0) or Error (-1). */ -int elfsh_shift_alpha_relocs(elfshobj_t *file, - char *name, - elfshsect_t *altgot, - u_int off) +int elfsh_shift_alpha_relocs(elfshobj_t *file, + char *name, + elfshsect_t *altgot, + u_int off) { u_int entsz; elfsh_Rela *rel; @@ -124,12 +120,11 @@ /** - * Shift the SPARC relocation to make points the entries inside .alt.plt instead of .plt - * - * @param file - * @param diff - * @param relplt - * @return + * @brief Shift the SPARC relocation to make points the entries inside .alt.plt instead of .plt + * @param file The host file where shift must happens. + * @param diff Absolute difference to shift to. + * @param relplt Section descriptor for the .relplt section. + * @return Always 0. */ int elfsh_shift_generic_relocs(elfshobj_t *file, eresi_Addr diff, @@ -150,14 +145,13 @@ /** - * Shift relocation tables at some point for allowing non-present symbol resolving - * mostly applied on section injection for ET_DYN objects - * - * @param file - * @param diff - * @param relplt - * @param limit - * @return + * @brief Shift relocation tables at some point for allowing non-present symbol resolving + * mostly applied on section injection for ET_DYN objects. + * @param file The host file where shift must happens. + * @param diff Absolute difference to shift to. + * @param relplt Section descriptor for the .relplt section. + * @param limit Upper limit address beyond which shifting must not be performed (or ELFSH_NOLIMIT) + * @return Always 0. */ int elfsh_shift_ia32_relocs(elfshobj_t *file, eresi_Addr diff, @@ -194,12 +188,11 @@ } /** - * Same arch independant code for the SPARC case - * - * @param file - * @param diff - * @param relplt - * @return + * @brief Shift relocations on the SPARC architecture. + * @param file Host file. + * @param diff Difference for shift. + * @param relplt Descriptor for the .relplt section. + * @return Always 0. */ int elfsh_shift_sparc_relocs(elfshobj_t *file, eresi_Addr diff, @@ -214,15 +207,14 @@ /** - * Change the DT_PLTGOT entry in the .dynamic - * section to change the relocation base address - * - * @param file - * @param altgot - * @param got - * @param plt - * @param altplt - * @return + * @brief Change the DT_PLTGOT entry in the .dynamic section to change + * the relocation base address. + * @param file The host file. + * @param altgot Section descriptor for the .elfsh.altgot section. + * @param got Section descriptor for the .got section. + * @param plt Section descriptor for the .plt section. + * @param altplt Section descriptor for the .elfsh.altplt section. + * @return Success (0) or Error (-1). */ int elfsh_redirect_pltgot(elfshobj_t *file, elfshsect_t *altgot, diff -Nru eresi-0.8a25/libelfsh/altplt.c eresi-0.0.20110516/libelfsh/altplt.c --- eresi-0.8a25/libelfsh/altplt.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/altplt.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file altplt.c +* @file libelfsh/altplt.c * @ingroup libelfsh ** altplt.c for libelfsh ** @@ -9,24 +9,22 @@ ** Started on Tue May 26 11:40:07 2001 mm ** ** -** $Id: altplt.c,v 1.12 2008-02-16 12:32:27 thor Exp $ +** $Id: altplt.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" /** - * The first PLT entry is always a special case and it is handled by this - * function - * - * @param new + * @brief Patch the first PLT entry (a special case which must handled by this function). + * @param enew * @param off - * @param symtab - * @param file - * @param extplt - * @param plt + * @param symtab Section descriptor for the symbol table. + * @param file Host file. + * @param extplt Section descriptor for the previously injected .elfsh.extplt + * @param plt Section descriptor for the .plt section. * @param diff - * @return + * @return Success (0) or Error (-1). */ int elfsh_altplt_firstent(elfshsect_t *enew, u_int *off, @@ -92,12 +90,11 @@ /** - * Copy the PLT of an ET_EXEC object for the ALTPLT technique. - * Copy the GOT of an ET_EXEC object for the ALTGOT technique. - * - * @param file - * @param mod - * @return + * @brief Copy the PLT of an ET_EXEC object for the ALTPLT technique. + * and the GOT of an ET_EXEC object for the ALTGOT technique. + * @param file Host file. + * @param mod Always inject sections with size being a multiple of mod. + * @return Success (0) or Error (-1). */ int elfsh_relink_plt(elfshobj_t *file, u_int mod) { @@ -219,7 +216,7 @@ else { XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - memcpy(prologdata, elfsh_get_raw(plt), sz); + memcpy(prologdata, elfsh_readmem(plt), sz); name = ELFSH_SECTION_NAME_ALTPLT; } enew = elfsh_create_section(name); @@ -248,7 +245,7 @@ 0, 0, sz, 0, 0, 0, sizeof(eresi_Addr)); XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - memcpy(prologdata, elfsh_get_raw(got), got->shdr->sh_size); + memcpy(prologdata, elfsh_readmem(got), got->shdr->sh_size); if (elfsh_insert_mapped_section(file, altgot, hdr, prologdata, ELFSH_DATA_INJECTION, mod) < 0) @@ -262,7 +259,7 @@ ".alt.got insertion failed", -1); file->secthash[ELFSH_SECTION_ALTGOT] = altgot; altgot->curend = got->shdr->sh_size; - memset(elfsh_get_raw(altgot) + got->shdr->sh_size, 0x00, got->shdr->sh_size); + memset(elfsh_readmem(altgot) + got->shdr->sh_size, 0x00, got->shdr->sh_size); altgot->shdr->sh_entsize = sizeof(eresi_Addr); } @@ -276,7 +273,7 @@ 0, 0, extplt_size, 0, 0, 0, 0); XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, plt->shdr->sh_size, -1); - memcpy(prologdata, elfsh_get_raw(plt), plt->shdr->sh_size); + memcpy(prologdata, elfsh_readmem(plt), plt->shdr->sh_size); if (elfsh_insert_mapped_section(file, extplt, hdr, prologdata, mode, mod) < 0) @@ -311,7 +308,7 @@ continue; /* Get the existing symbol name for this plt entry ... */ - sym = elfsh_get_sym_by_value(elfsh_get_raw(dynsym), + sym = elfsh_get_sym_by_value(elfsh_readmem(dynsym), dynsym->shdr->sh_size / sizeof(elfsh_Sym), plt->shdr->sh_addr + off, NULL, ELFSH_EXACTSYM); @@ -413,7 +410,7 @@ /** - * On MIPS there is no .plt section : call to libraries are done + * @brief On MIPS there is no .plt section : call to libraries are done * using an indirect jump on .got value directly from .text. If * we want to be able to call the original function from the hook * function, we need to create a plt-like section and mirror the @@ -432,8 +429,8 @@ * technique (call's the original functions using the injected 'old_' * symbol) just like ALTPLT redirection on other architectures. -mm * - * @param file - * @return + * @param file Host file. + * @return Success (0) or Error (-1). */ int elfsh_build_plt(elfshobj_t *file) { @@ -468,7 +465,7 @@ ** that delimit the beginning and the end of plt. This is MIPS specific ** since only MIPS needs this. */ - tdata = elfsh_get_raw(text); + tdata = elfsh_readmem(text); for (off = 0; off < text->shdr->sh_size; off += 4) if (!memcmp(tdata + off, buff, sizeof(buff))) { @@ -538,11 +535,10 @@ /** - * This is the main entry point for the ALTPLT, ALTGOT, and EXTPLT techniques - * - * @param file - * @param modulo - * @return + * @brief Main function performing ALTPLT, ALTGOT, and EXTPLT techniques. + * @param file The host file. + * @param modulo Always inject sections with a size being a multiple of mod. + * @return Success (0) or Error (-1). */ int elfsh_copy_plt(elfshobj_t *file, u_int modulo) { diff -Nru eresi-0.8a25/libelfsh/bp.c eresi-0.0.20110516/libelfsh/bp.c --- eresi-0.8a25/libelfsh/bp.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/bp.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file bp.c +* @file libelfsh/bp.c * @ingroup libelfsh ** bp.c for elfsh ** @@ -7,7 +7,7 @@ ** Updated Tue Oct 11 19:07:13 2005 mm ** ** -** $Id: bp.c,v 1.7 2007-06-27 11:25:12 heroine Exp $ +** $Id: bp.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/bss.c eresi-0.0.20110516/libelfsh/bss.c --- eresi-0.8a25/libelfsh/bss.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/bss.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file bss.c +* @file libelfsh/bss.c * @ingroup libelfsh ** bss.c for elfsh ** @@ -11,7 +11,7 @@ ** Last update Sat Jul 30 17:34:52 2005 jfv ** ** -** $Id: bss.c,v 1.16 2008-02-16 12:32:27 thor Exp $ +** $Id: bss.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -170,7 +170,7 @@ elfshsect_t *next; elfshsect_t *actual; u_int size; - elfsh_Off size2; + eresi_Off size2; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/libelfsh/bt.c eresi-0.0.20110516/libelfsh/bt.c --- eresi-0.8a25/libelfsh/bt.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/bt.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file bt.c +* @file libelfsh/bt.c * @ingroup libelfsh ** bt.c for elfsh ** ** Started on Wed Jul 27 04:08:52 2005 ym ** ** -** $Id: bt.c,v 1.3 2007-06-27 11:25:12 heroine Exp $ +** $Id: bt.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/comment.c eresi-0.0.20110516/libelfsh/comment.c --- eresi-0.8a25/libelfsh/comment.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/comment.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file comment.c +* @file libelfsh/comment.c * @ingroup libelfsh ** comment.c for elfsh in ** @@ -9,7 +9,7 @@ ** Started on Sun Dec 1 09:22:45 2002 jfv ** ** -** $Id: comment.c,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: comment.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -37,10 +37,10 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get .comment by name", NULL); - if (NULL == elfsh_get_raw(enew)) + if (NULL == elfsh_readmem(enew)) { enew->data = elfsh_load_section(file, enew->shdr); - if (NULL == elfsh_get_raw(enew)) + if (NULL == elfsh_readmem(enew)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to load .comment", NULL); } @@ -71,7 +71,7 @@ "Unable to get .comments", NULL); index = act = 0; - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_COMMENT]); + data = elfsh_readmem(file->secthash[ELFSH_SECTION_COMMENT]); while (!data[index] && CHECK_SZ) index++; while (act != range && CHECK_SZ) diff -Nru eresi-0.8a25/libelfsh/copy.c eresi-0.0.20110516/libelfsh/copy.c --- eresi-0.8a25/libelfsh/copy.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/copy.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file copy.c +* @file libelfsh/copy.c * @ingroup libelfsh ** copy.c for elfsh ** ** Started on Tue Mar 4 01:15:23 2003 jfv ** Last update Tue Mar 11 21:26:07 2003 jfv ** -** $Id: copy.c,v 1.11 2008-02-16 12:32:27 thor Exp $ +** $Id: copy.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/ctors.c eresi-0.0.20110516/libelfsh/ctors.c --- eresi-0.8a25/libelfsh/ctors.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/ctors.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file ctors.c +* @file libelfsh/ctors.c * @ingroup libelfsh * * Started on Tue Feb 26 22:11:12 2002 jfv * - * $Id: ctors.c,v 1.7 2008-02-16 12:32:27 thor Exp $ + * $Id: ctors.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" @@ -54,7 +54,7 @@ *num = enew->shdr->sh_size / sizeof(eresi_Addr); /* Return a pointer on the data. Also work in debug mode */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_readmem(enew))); } diff -Nru eresi-0.8a25/libelfsh/debug.c eresi-0.0.20110516/libelfsh/debug.c --- eresi-0.8a25/libelfsh/debug.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/debug.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file debug.c +* @file libelfsh/debug.c * @ingroup libelfsh * * Started on Thu Apr 3 21:36:55 2003 jfv * - * $Id: debug.c,v 1.9 2008-02-16 12:32:27 thor Exp $ + * $Id: debug.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" @@ -32,7 +32,7 @@ sctname = elfsh_get_section_name(obj, actual); if (sctname == NULL) sctname = "UNK"; - data = elfsh_get_raw(actual); + data = elfsh_readmem(actual); if (data == (u_char *)NULL) data = (u_char *)"\xFF\xFF\xFF"; printf(" [%03u:%03u] %-15s HDRNAM: %-15s BYTES[%02X %02X %02X] P(%8p) " diff -Nru eresi-0.8a25/libelfsh/doc/.svn/all-wcprops eresi-0.0.20110516/libelfsh/doc/.svn/all-wcprops --- eresi-0.8a25/libelfsh/doc/.svn/all-wcprops 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/807/trunk/libelfsh/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/807/trunk/libelfsh/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libelfsh/doc/.svn/entries eresi-0.0.20110516/libelfsh/doc/.svn/entries --- eresi-0.8a25/libelfsh/doc/.svn/entries 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libelfsh/doc -http://svn.eresi-project.org/svn - - - -2007-10-14T00:03:46.000000Z -807 -heroine - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:33.883881Z -86ba94f57f2697ecf6f19cb7738d4606 -2007-10-14T00:03:46.000000Z -807 -heroine - diff -Nru eresi-0.8a25/libelfsh/doc/.svn/format eresi-0.0.20110516/libelfsh/doc/.svn/format --- eresi-0.8a25/libelfsh/doc/.svn/format 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libelfsh/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libelfsh/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libelfsh/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libelfsh - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./ include - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libelfsh - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = YES diff -Nru eresi-0.8a25/libelfsh/dtors.c eresi-0.0.20110516/libelfsh/dtors.c --- eresi-0.8a25/libelfsh/dtors.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/dtors.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file dtors.c +* @file libelfsh/dtors.c * @ingroup libelfsh * * Started on Tue Feb 26 22:12:38 2002 jfv * - * $Id: dtors.c,v 1.7 2008-02-16 12:32:27 thor Exp $ + * $Id: dtors.c 1397 2009-09-13 02:19:08Z may $ * */ @@ -52,7 +52,7 @@ /* Return data */ if (num != NULL) *num = enew->shdr->sh_size / sizeof(eresi_Addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_readmem(enew))); } diff -Nru eresi-0.8a25/libelfsh/dumpregs.c eresi-0.0.20110516/libelfsh/dumpregs.c --- eresi-0.8a25/libelfsh/dumpregs.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/dumpregs.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file dumpregs.c +* @file libelfsh/dumpregs.c * @ingroup libelfsh ** dumpregs.c for elfsh ** ** Started on Wed Jul 27 04:08:52 2005 ym ** ** -** $Id: dumpregs.c,v 1.5 2008-02-16 12:32:27 thor Exp $ +** $Id: dumpregs.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/dwarf.c eresi-0.0.20110516/libelfsh/dwarf.c --- eresi-0.8a25/libelfsh/dwarf.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/dwarf.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file dwarf.c +* @file libelfsh/dwarf.c * @ingroup libelfsh ** dwarf.c for libelfsh ** @@ -12,17 +12,37 @@ int elfsh_get_dwarf(elfshobj_t *file) { + void *data; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - elfsh_get_dwarf_info(file, NULL); - elfsh_get_dwarf_abbrev(file, NULL); - elfsh_get_dwarf_aranges(file, NULL); - elfsh_get_dwarf_frame(file, NULL); - elfsh_get_dwarf_line(file, NULL); - elfsh_get_dwarf_macinfo(file, NULL); - elfsh_get_dwarf_pubnames(file, NULL); - elfsh_get_dwarf_str(file, NULL); - elfsh_get_dwarf_loc(file, NULL); + data = elfsh_get_dwarf_info(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for INFO\n"); + data = elfsh_get_dwarf_abbrev(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for ABBREV\n"); + data = elfsh_get_dwarf_aranges(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for ARANGES\n"); + data = elfsh_get_dwarf_frame(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for FRAME\n"); + data = elfsh_get_dwarf_line(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for LINE\n"); + data = elfsh_get_dwarf_macinfo(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for MACINFO\n"); + data = elfsh_get_dwarf_pubnames(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for PUBNAMES\n"); + data = elfsh_get_dwarf_str(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for STR\n"); + data = elfsh_get_dwarf_loc(file, NULL); + //if (data == NULL) + //fprintf(stderr, "Failed to load section data for LOC\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -68,7 +88,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_INFO]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_INFO]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -114,7 +134,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_ABBREV]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_ABBREV]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -160,7 +180,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_ARANGES]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_ARANGES]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -206,7 +226,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_FRAME]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_FRAME]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -252,7 +272,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_LINE]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_LINE]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -298,7 +318,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_MACINFO]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_MACINFO]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -344,7 +364,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_PUBNAMES]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_PUBNAMES]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -390,7 +410,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_STR]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_STR]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -436,7 +456,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_LOC]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DW2_LOC]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } diff -Nru eresi-0.8a25/libelfsh/dynamic.c eresi-0.0.20110516/libelfsh/dynamic.c --- eresi-0.8a25/libelfsh/dynamic.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/dynamic.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file dynamic.c +* @file libelfsh/dynamic.c * @ingroup libelfsh ** dynamic.c for libelfsh ** ** Started on Tue Feb 27 04:36:53 2001 jfv ** ** -** $Id: dynamic.c,v 1.11 2008-02-16 12:32:27 thor Exp $ +** $Id: dynamic.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -36,7 +36,7 @@ #else #error Unexpected __BYTE_ORDER ! #endif - dyn = (elfsh_Dyn *) elfsh_get_raw(newent); + dyn = (elfsh_Dyn *) elfsh_readmem(newent); for (idx = 0; idx < newent->shdr->sh_size / sizeof(elfsh_Dyn); idx++) { dyn[idx].d_tag = swaplong(dyn[idx].d_tag); @@ -86,7 +86,7 @@ elfsh_endianize_dynamic(newent); } - ret = (elfsh_Dyn *) elfsh_get_raw(newent); + ret = (elfsh_Dyn *) elfsh_readmem(newent); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -141,6 +141,7 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (d->d_un.d_val)); } + /** * Change the val field of the dynamic entry * @param d @@ -159,6 +160,7 @@ } + /** * Retreive the information giving the entry * @param file elfsh object. @@ -184,7 +186,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid .dynstr offset", NULL); - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); + data = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSTR]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((char *) data + ent->d_un.d_val)); } diff -Nru eresi-0.8a25/libelfsh/dynsym.c eresi-0.0.20110516/libelfsh/dynsym.c --- eresi-0.8a25/libelfsh/dynsym.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/dynsym.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,39 +1,37 @@ /** - * @file dynsym.c +* @file libelfsh/dynsym.c * @ingroup libelfsh ** Dynsym.c for libelfsh ** ** Started on Mon Feb 26 04:13:29 2001 jfv -** -** -** $Id: dynsym.c,v 1.21 2008-02-16 12:32:27 thor Exp $ +** $Id: dynsym.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" + /** * Return the dynsymbol name giving its index in the dynamic symbol string table * @param file - * @param s - * @return + * @param s + * @return A pointer on the symbol name */ char *elfsh_get_dynsymbol_name(elfshobj_t *file, elfsh_Sym *s) { - char *ret; - void *rdata; + char *ret; + void *rdata; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!file || !s) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - + "Invalid NULL parameter", NULL); + if (file->secthash[ELFSH_SECTION_DYNSYM] == NULL) if (NULL == elfsh_get_dynsymtab(file, NULL)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", NULL); - - rdata = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); + "Unable to get DYNSYM", NULL); + + rdata = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSTR]); ret = (char *) rdata + s->st_name; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -67,7 +65,7 @@ "Cannot retreive symbol table", -1); /* Else use the symbol string table */ - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); + data = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSTR]); if (file->secthash[ELFSH_SECTION_DYNSTR] == NULL || data == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -80,8 +78,8 @@ new_len = strlen(name); /* Do not allocate new place if possible */ - if (len >= new_len) - strcpy(str, name); + if (len > new_len) + strncpy(str, name, new_len + 1); /* Append the name to .strtab */ else s->st_name = elfsh_insert_in_dynstr(file, name); @@ -129,11 +127,13 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get DYNSYM by type", NULL); } - - newent->data = elfsh_load_section(file, newent->shdr); - if (newent->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load DYNSYM", NULL); + if (newent->data == NULL) + { + newent->data = elfsh_load_section(file, newent->shdr); + if (newent->data == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to load DYNSYM", NULL); + } file->secthash[ELFSH_SECTION_DYNSYM] = newent; /* Endianize table */ @@ -144,12 +144,13 @@ if (newent == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get DYNSTR by index", NULL); - - newent->data = elfsh_load_section(file, newent->shdr); if (newent->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load DYNSTR", NULL); - + { + newent->data = elfsh_load_section(file, newent->shdr); + if (newent->data == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to load DYNSTR", NULL); + } file->secthash[ELFSH_SECTION_DYNSTR] = newent; /* Fixup the dynamic symbol table */ @@ -176,7 +177,7 @@ if (num != NULL) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSYM]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -252,7 +253,7 @@ "No parent section", NULL); /* handle dynamic case */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) value -= file->rhdr.base; if (offset) @@ -276,14 +277,15 @@ file->secthash[ELFSH_SECTION_DYNSYM]); if (pltsym) { - *offset = 0; + if (offset) + *offset = 0; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_dynsymbol_name(file, pltsym))); } } /* handle dynamic case */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) value -= file->rhdr.base; /* Else look in the table */ @@ -343,16 +345,17 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get DYNSYM section pointer", NULL); + /* if (file->dynsymhash.ent) { - /* idx is the symbol number in the section */ + //idx is the symbol number in the section idx = (int) hash_get(&file->dynsymhash, name); #if __DEBUG_HASH_BY_NAME__ printf("[DEBUG_HASH_BY_NAME] DYNSYM HASH Search by name for %s => %d\n", name, idx); #else - /* Check if idx is in the section */ + //Check if idx is in the section if (idx <= 0 || idx >= sect->shdr->sh_size) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Symbol not found", NULL); @@ -360,11 +363,12 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); #endif } +*/ for (idx = 0; idx < size; idx++) { actual = elfsh_get_dynsymbol_name(file, sym + idx); - if (actual && !strcmp(actual, name)) + if (actual != NULL && !strcmp(actual, name)) { #if __DEBUG_HASH_BY_NAME__ printf("[DEBUG_HASH_BY_NAME] DYNSYM ITERATE Search by name for %s => %d\n", @@ -379,7 +383,7 @@ #endif PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); + "Symbol not found", NULL); } diff -Nru eresi-0.8a25/libelfsh/elf.c eresi-0.0.20110516/libelfsh/elf.c --- eresi-0.8a25/libelfsh/elf.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/elf.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file elf.c +* @file libelfsh/elf.c * @ingroup libelfsh ** elf.c for libelfsh ** ** Started on Mon Feb 26 04:09:38 2001 jfv ** Last update Mon Apr 21 20:58:41 2003 jfv ** -** $Id: elf.c,v 1.19 2008-02-16 12:32:27 thor Exp $ +** $Id: elf.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -56,7 +56,7 @@ if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - hdr->e_shoff = (elfsh_Off) off; + hdr->e_shoff = (eresi_Off) off; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -65,13 +65,13 @@ * @param hdr * @return */ -elfsh_Off elfsh_get_shtoff(elfsh_Ehdr *hdr) +eresi_Off elfsh_get_shtoff(elfsh_Ehdr *hdr) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); + "Invalid NULL parameter", (eresi_Off) -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_shoff)); } @@ -122,7 +122,7 @@ if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - hdr->e_phoff = (elfsh_Off) num; + hdr->e_phoff = (eresi_Off) num; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -131,13 +131,13 @@ * @param hdr * @return */ -elfsh_Off elfsh_get_phtoff(elfsh_Ehdr *hdr) +eresi_Off elfsh_get_phtoff(elfsh_Ehdr *hdr) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); + "Invalid NULL parameter", (eresi_Off) -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_phoff)); } @@ -154,7 +154,7 @@ if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - *((elfsh_Off *) hdr->e_ident + EI_RPHT) = (elfsh_Off) num; + *((eresi_Off *) hdr->e_ident + EI_RPHT) = (eresi_Off) num; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -163,15 +163,15 @@ * @param hdr * @return */ -elfsh_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr) +eresi_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); + "Invalid NULL parameter", (eresi_Off) -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (*(elfsh_Off *) hdr->e_ident + EI_RPHT)); + (*(eresi_Off *) hdr->e_ident + EI_RPHT)); } /** @@ -552,7 +552,6 @@ int elfsh_set_class(elfsh_Ehdr *hdr, eresi_Addr eclass) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!hdr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); @@ -626,21 +625,24 @@ * @param file * @return */ +/* int elfsh_check_hdr_machine(elfshobj_t *file) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + // /usr/include/elf.h e_machine may be > 18. + // disabling this check for the moment. - /** /usr/include/elf.h e_machine may be > 18. - * disabling this check for the moment. if (file->hdr->e_machine > 16) { file->hdr->e_machine = ET_NONE; PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "file->hdr->e_machine is not valid", NULL); } - */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +*/ + + /** * Sanity check of version value @@ -653,11 +655,11 @@ if (file->hdr->e_version != EV_CURRENT) { - file->hdr->e_version = EV_CURRENT; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_version is not valid", NULL); + file->hdr->e_version = EV_CURRENT; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "file->hdr->e_version is not valid", NULL); } - + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -670,7 +672,7 @@ { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (file->hdr->e_phoff > (elfsh_Off) file->fstat.st_size) + if (file->hdr->e_phoff > (eresi_Off) file->fstat.st_size) { file->hdr->e_phoff = ET_NONE; PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -689,7 +691,7 @@ { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (file->hdr->e_shoff > (elfsh_Off) file->fstat.st_size) + if (file->hdr->e_shoff > (eresi_Off) file->fstat.st_size) { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "file->hdr->e_shoff > file length", NULL); @@ -708,7 +710,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); elfsh_check_hdr_type(file); - elfsh_check_hdr_machine(file); + //elfsh_check_hdr_machine(file); elfsh_check_hdr_version(file); elfsh_check_hdr_phoff(file); elfsh_check_hdr_shoff(file); @@ -812,10 +814,9 @@ * @param file * @return */ -int elfsh_get_core_notes(elfshobj_t *file) +int elfsh_get_core_notes(elfshobj_t *file) { elfsh_Nhdr nhdr; - int i, offset, filesz, j, namesz, descsz; int pos; diff -Nru eresi-0.8a25/libelfsh/extplt.c eresi-0.0.20110516/libelfsh/extplt.c --- eresi-0.8a25/libelfsh/extplt.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/extplt.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file extplt.c +* @file libelfsh/extplt.c * @ingroup libelfsh * extplt.c for libelfsh * @@ -8,7 +8,7 @@ * * Started on Wed Jun 12 21:20:07 2005 mm * - * $Id: extplt.c,v 1.20 2008-02-16 12:32:27 thor Exp $ + * $Id: extplt.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" @@ -116,7 +116,7 @@ "Invalid Parameters", -1); /* Dynsym data & size */ - ret = elfsh_get_raw(dynsym); + ret = elfsh_readmem(dynsym); size = dynsym->curend ? dynsym->curend / sizeof(elfsh_Sym) : dynsym->shdr->sh_size / sizeof(elfsh_Sym); @@ -138,7 +138,7 @@ "Cannot find dynamic symbol by name", -1); /* Hash pointer */ - data = elfsh_get_raw(hash); + data = elfsh_readmem(hash); /* Get bucket & chain pointers */ bucket = elfsh_get_hashbucket(data); @@ -261,7 +261,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTDYNSYM", -1); enew->shdr->sh_entsize = sizeof(elfsh_Sym); - data = elfsh_get_raw(enew); + data = elfsh_readmem(enew); /* Take the fixed ondisk version of dynsym as original data */ memcpy(data, dynsym->data, dynsym->shdr->sh_size); @@ -283,8 +283,8 @@ if (!enew) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTDYNSTR", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(dynstr), dynstr->shdr->sh_size); + data = elfsh_readmem(enew); + memcpy(data, elfsh_readmem(dynstr), dynstr->shdr->sh_size); dynent = elfsh_get_dynamic_entry_by_type(file, DT_STRTAB); if (!dynent) @@ -308,8 +308,8 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTRELGOT", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(relgot), relgot->shdr->sh_size); + data = elfsh_readmem(enew); + memcpy(data, elfsh_readmem(relgot), relgot->shdr->sh_size); dynent = elfsh_get_dynamic_entry_by_type(file, IS_REL(dynamic) ? DT_REL : DT_RELA); if (!dynent) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -328,8 +328,8 @@ if (!enew) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTRELPLT", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(relplt), relplt->shdr->sh_size); + data = elfsh_readmem(enew); + memcpy(data, elfsh_readmem(relplt), relplt->shdr->sh_size); dynent = elfsh_get_dynamic_entry_by_type(file, DT_JMPREL); if (!dynent) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -350,8 +350,8 @@ if (!enew) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTVERSYM", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(versym), versym->shdr->sh_size); + data = elfsh_readmem(enew); + memcpy(data, elfsh_readmem(versym), versym->shdr->sh_size); enew->curend = versym->shdr->sh_size; enew->shdr->sh_type = versym->shdr->sh_type; @@ -374,8 +374,8 @@ if (!enew) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to inject ALTHASHM", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(hash), hash->shdr->sh_size); + data = elfsh_readmem(enew); + memcpy(data, elfsh_readmem(hash), hash->shdr->sh_size); enew->curend = hash->shdr->sh_size; enew->shdr->sh_type = hash->shdr->sh_type; @@ -583,11 +583,11 @@ 0, 0, 0); sym.st_name = dynstr->curend; elfsh_set_symbol_bind(&sym, STB_GLOBAL); - memcpy(elfsh_get_raw(dynsym) + dynsym->curend, &sym, sizeof(sym)); + memcpy(elfsh_readmem(dynsym) + dynsym->curend, &sym, sizeof(sym)); dynsym->curend += sizeof(elfsh_Sym); /* Insert string referenced by the previous injected symbol */ - memcpy(elfsh_get_raw(dynstr) + dynstr->curend, name, len + 1); + memcpy(elfsh_readmem(dynstr) + dynstr->curend, name, len + 1); dynstr->curend += len + 1; elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_DYNSYM]); @@ -613,6 +613,6 @@ "Unable to add an entry on ALTHASH", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - elfsh_get_raw(dynsym) + dynsym->curend - sizeof(elfsh_Sym)); + elfsh_readmem(dynsym) + dynsym->curend - sizeof(elfsh_Sym)); } diff -Nru eresi-0.8a25/libelfsh/fixup.c eresi-0.0.20110516/libelfsh/fixup.c --- eresi-0.8a25/libelfsh/fixup.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/fixup.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file fixup.c +* @file libelfsh/fixup.c * @ingroup libelfsh ** fixup.c for elfsh ** ** Started on Fri Jul 27 04:56:06 2001 jfv ** ** -** $Id: fixup.c,v 1.13 2008-02-16 12:32:27 thor Exp $ +** $Id: fixup.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -32,7 +32,7 @@ elfsh_Sym newent; elfsh_Sym *actual; eresi_Addr startaddr; - u_int index; + int index; char *str; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -82,20 +82,32 @@ { actual->st_size = list->shdr->sh_size; str = elfsh_get_symbol_name(file, actual); + if (str == NULL || !*str) - actual->st_name = elfsh_insert_in_strtab(file, list->name); + { + actual->st_name = elfsh_insert_in_strtab(file, list->name); + str = list->name; + } } } /* Fixup all 0 length non-section-typed symbols */ actual = symtab->data; for (index = 0; - index < symtab->shdr->sh_size / sizeof(elfsh_Sym); + index < (int) (symtab->shdr->sh_size / sizeof(elfsh_Sym)); index++, actual++) - if (elfsh_get_symbol_type(actual) != STT_BLOCK && - actual->st_value && !actual->st_size && - index + 1 < symtab->shdr->sh_size / sizeof(elfsh_Sym)) + if ((elfsh_get_symbol_type(actual) != STT_SECTION) && + (actual->st_shndx != SHN_ABS) && + (actual->st_shndx != SHN_UNDEF) && + (actual->st_shndx != SHN_COMMON) && + (actual->st_value != 0) && + (actual->st_size == 0) && + (index + 1 < (int) (symtab->shdr->sh_size / sizeof(elfsh_Sym))) && + (actual->st_shndx == actual[1].st_shndx) && + (actual->st_value < actual[1].st_value)) + { actual->st_size = actual[1].st_value - actual->st_value; + } /* Fixup _start symbol value [and create it if unexistant] */ actual = elfsh_get_symbol_by_name(symtab->parent, ELFSH_STARTSYM); @@ -175,7 +187,7 @@ "Cannot find RELPLT", NULL); /* On Sparc, some of the first entries are reserved */ - if (FILE_IS_SPARC(plt->parent) && off < elfsh_get_first_pltentsz(file)) + if (FILE_IS_SPARC(plt->parent) && off < (u_int) elfsh_get_first_pltentsz(file)) { #if __DEBUG_COPYPLT__ diff -Nru eresi-0.8a25/libelfsh/got.c eresi-0.0.20110516/libelfsh/got.c --- eresi-0.8a25/libelfsh/got.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/got.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file got.c +* @file libelfsh/got.c * @ingroup libelfsh ** got.c for elfsh ** ** Started on Sun Jun 24 21:30:41 2001 jfv ** Last update Thu May 15 04:39:15 2003 jfv ** -** $Id: got.c,v 1.11 2008-02-16 12:32:27 thor Exp $ +** $Id: got.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -77,7 +77,7 @@ #else #error Unexpected __BYTE_ORDER ! #endif - cur = elfsh_get_raw(newsect); + cur = elfsh_readmem(newsect); for (idx = 0; idx < newsect->shdr->sh_size / newsect->shdr->sh_entsize; idx++) cur[idx] = swaplong(cur[idx]); } @@ -134,7 +134,7 @@ /* Final things */ if (num != NULL) *num = enew->shdr->sh_size / enew->shdr->sh_entsize; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_readmem(enew))); } @@ -488,88 +488,3 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - - - -/** - * Only used on BeoS - * Tested and developed by zadig@myrealbox.com - * - * @param file - * @param name - * @param rel_entry - * @param - */ -int elfsh_get_got_symbol_reloc(elfshobj_t *file, - uint8 *name, - elfsh_Rel *rel_entry) -{ - elfshsect_t *got, *rel_got; - u_int index, got_rel_index; - u_int entsz; - int got_index; - elfsh_Off off; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - entsz = elfsh_get_pltentsz(file); - if (entsz < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid PLT entry size", -1); - - if (NULL == elfsh_get_dynsymtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", -1); - - if (NULL == elfsh_get_symtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB", -1); - - /* get got section index */ - got = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_GOT, - &got_index, NULL, NULL); - if (got == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT", -1); - - /* search the got relocation section */ - rel_got = NULL; - for (got_rel_index = 0; got_rel_index < file->hdr->e_shnum; got_rel_index++) - { - rel_got = elfsh_get_section_by_index(file, got_rel_index, - NULL, NULL); - if (rel_got->shdr->sh_info == got_index) - break; - } - - if ((rel_got == NULL) || (rel_got->shdr->sh_info != got_index)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT relocations", -1); - - /* search for the requested symbol */ - off = entsz; - data = elfsh_get_raw(rel_got); - for (index = 0; - index < (rel_got->shdr->sh_size / rel_got->shdr->sh_entsize); - off += entsz, index ++) - { - elfsh_Rel *cur_rel; - cur_rel = ((elfsh_Rel*) data) + index; - if(strcmp(elfsh_get_symname_from_reloc(file, cur_rel), name) == 0) - { - *rel_entry = *cur_rel; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", -1); -} - - - - diff -Nru eresi-0.8a25/libelfsh/hash.c eresi-0.0.20110516/libelfsh/hash.c --- eresi-0.8a25/libelfsh/hash.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/hash.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file hash.c +* @file libelfsh/hash.c * @ingroup libelfsh ** hash.c for libelfsh ** ** Started on Mon Feb 26 04:15:44 2001 jfv ** ** -** $Id: hash.c,v 1.13 2007-08-25 17:13:05 mxatone Exp $ +** $Id: hash.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -404,7 +404,7 @@ file->secthash[ELFSH_SECTION_HASH] = enew; } - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_HASH]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_HASH]); /* Search number of entry do we get here */ nbr = file->secthash[ELFSH_SECTION_HASH]->shdr->sh_size; @@ -502,7 +502,7 @@ ** The first fetched dynamic symbol isnt the one we are looking for ** so we loop on the entry . */ - for (sym = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]); + for (sym = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSYM]); index < nchain; index = symid) { @@ -634,7 +634,7 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); /* Debug mode use a different dependences technique for mapped files */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) { filehash = hash_find("files"); diff -Nru eresi-0.8a25/libelfsh/hijack.c eresi-0.0.20110516/libelfsh/hijack.c --- eresi-0.8a25/libelfsh/hijack.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/hijack.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file hijack.c +* @file libelfsh/hijack.c * @ingroup libelfsh ** hijack.c in elfsh ** ** Started on Tue Feb 4 14:41:34 2003 emsi ** ** -** $Id: hijack.c,v 1.12 2008-02-16 12:32:27 thor Exp $ +** $Id: hijack.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -134,7 +134,7 @@ "Unable to perform CFLOW redir", -1); /* Perform a second stage runtime relocation after injecting this new old symbol */ - if (elfsh_is_debug_mode() && elfsh_save_relocate(file) < 0) + if (elfsh_is_runtime_mode() && elfsh_save_relocate(file) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed second stage runtime relocation", -1); diff -Nru eresi-0.8a25/libelfsh/hooks.c eresi-0.0.20110516/libelfsh/hooks.c --- eresi-0.8a25/libelfsh/hooks.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/hooks.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file hooks.c +* @file libelfsh/hooks.c * @ingroup libelfsh ** hooks.c for libelfsh (The ELF shell library) ** @@ -10,454 +10,11 @@ ** Started Jan 11 2004 02:57:03 jfv ** ** -** $Id: hooks.c,v 1.26 2008-02-16 12:32:27 thor Exp $ +** $Id: hooks.c 1435 2010-12-11 06:16:51Z may $ ** */ #include "libelfsh.h" -hash_t interp_hash; - - -u_char elfsh_ostype[5] = { - ELFOSABI_LINUX, - ELFOSABI_FREEBSD, - ELFOSABI_NETBSD, - ELFOSABI_OPENBSD, - ELFOSABI_SOLARIS, -}; - - -/** - * Default hooks handlers - * - * @param null - * @param null2 - * @param null3 - * @return - */ -int elfsh_default_plthandler(elfshobj_t *null, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used for encoding a random PLT entry - * Do nothing by default, this is not fatal - * - * @param file - * @param sect - * @param diff - * @return - */ -int elfsh_default_encodeplthandler(elfshobj_t *file, - elfshsect_t *sect, - eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used for encoding of the first PLT entry - * - * @param file - * @param sect - * @param sect2 - * @return - */ -int elfsh_default_encodeplt1handler(elfshobj_t *file, - elfshsect_t *sect, - elfshsect_t *sect2, - eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * - * @param null - * @param null2 - * @param null3 - * @param null4 - * @param null5 - */ -int elfsh_default_relhandler(elfshsect_t *null, - elfsh_Rel * null2, - eresi_Addr * null3, - eresi_Addr null4, - elfshsect_t *null5) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * - * @param null - * @param nulls - * @param null2 - * @param null3 - * @return - */ -int elfsh_default_cflowhandler(elfshobj_t *null, - char *nulls, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - -/** - * - * @param o - * @param d - * @param t - * @param f - * @return - */ -int elfsh_default_extplthandler(elfshsect_t *o, elfshsect_t *d, - elfshsect_t *t, elfshsect_t *f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used on architectures where altplt hijack is not required, thus induce no fatal error - * DO NOT use this as a default handler, unless you know exactly what you are doing - * - * @param null - * @param null2 - * @param null3 - * @return - */ -int elfsh_void_altplthandler(elfshobj_t *null, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * - * @param addr - * @return - */ -int elfsh_default_argchandler(eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Registration handlers - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_altplthook(u_char archtype, - u_char objtype, - u_char ostype, - void *fct) -{ - vector_t *altplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(altplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register an EXTPLT handler - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_extplthook(u_char archtype, - u_char objtype, - u_char ostype, - void *fct) -{ - vector_t *extplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - extplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(extplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register an PLT handler - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_plthook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *plt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - plt = aspect_vector_get(ELFSH_HOOK_PLT); - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(plt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Register an ENCODEPLT handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_encodeplthook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *encodeplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(encodeplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Register an ENCODEPLT1 handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_encodeplt1hook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *encodeplt1; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(encodeplt1, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Register an ET_REL injection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_relhook(u_char archtype, u_char objtype, u_char ostype, - void *fct) -{ - vector_t *rel; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - rel = aspect_vector_get(ELFSH_HOOK_REL); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(rel, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register a control flow redirection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_cflowhook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *cflow; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(cflow, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register a args counting redirection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_argchook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *argcp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - argcp = aspect_vector_get(ELFSH_HOOK_ARGC); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(argcp, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - /** @@ -468,19 +25,22 @@ { u_int *dims; char **strdims; + u_int *tdims; + char **tstrdims; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); aspect_init(); /* All hooks have the same dimensions here */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 4 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 4 * sizeof(char *), -1); - dims[0] = ELFSH_ARCHNUM; - dims[1] = ELFSH_TYPENUM; - dims[2] = ELFSH_OSNUM; - strdims[0] = "ARCHTYPE"; - strdims[1] = "ELFTYPE"; - strdims[2] = "OSTYPE"; + XALLOC(__FILE__, __FUNCTION__, __LINE__, dims , 4 * sizeof(u_int) , -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, strdims , 4 * sizeof(char *), -1); + + dims[0] = ELFSH_ARCH_NUM; + dims[1] = ELFSH_FILE_NUM; + dims[2] = ELFSH_OS_NUM; + strdims[0] = "ARCHTYPE"; + strdims[1] = "ELFTYPE"; + strdims[2] = "OSTYPE"; aspect_register_vector(ELFSH_HOOK_ALTPLT, elfsh_default_plthandler, @@ -507,17 +67,57 @@ elfsh_default_argchandler, dims, strdims, 3, ASPECT_TYPE_CADDR); + /* Now register IO vectors */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, tdims , 3 * sizeof(u_int) , -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, tstrdims, 3 * sizeof(char *), -1); + tdims[0] = ELFSH_OS_NUM; + tdims[1] = ELFSH_IOTYPE_NUM; + tstrdims[0] = "OSTYPE"; + tstrdims[1] = "IOTYPE"; + + /* Put our default handlers for userland */ + aspect_register_vector(ELFSH_HOOK_READMEM, elfsh_default_readmem, + tdims, tstrdims, 2, ASPECT_TYPE_CADDR); + aspect_register_vector(ELFSH_HOOK_WRITEMEM, elfsh_default_writemem, + tdims, tstrdims, 2, ASPECT_TYPE_CADDR); + aspect_register_vector(ELFSH_HOOK_READMEMA, elfsh_default_readmema, + tdims, tstrdims, 2, ASPECT_TYPE_CADDR); + + XALLOC(__FILE__, __FUNCTION__, __LINE__, dims , 3 * sizeof(u_int), -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, strdims , 3 * sizeof(char *), -1); + dims[0] = ELFSH_HOST_NUM; + dims[1] = LIBELFSH_MODE_NUM; + strdims[0] = "HOSTTYPE"; + strdims[1] = "EXECMODE"; + + aspect_register_vector(ELFSH_HOOK_READMEMF, elfsh_default_readmemf, + dims, strdims, 2, ASPECT_TYPE_CADDR); + aspect_register_vector(ELFSH_HOOK_WRITEMEMF, elfsh_default_writememf, + dims, strdims, 2, ASPECT_TYPE_CADDR); + + /* Now the allocation, mprotect and munprotect vectors */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, dims , 2 * sizeof(u_int), -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, strdims , 2 * sizeof(char *), -1); + dims[0] = ELFSH_HOST_NUM; + strdims[0] = "HOSTTYPE"; + + aspect_register_vector(ELFSH_HOOK_ALLOC, elfsh_default_rmaphandler, + dims, strdims, 1, ASPECT_TYPE_CADDR); + aspect_register_vector(ELFSH_HOOK_MPROTECT, elfsh_void_mprotecthandler, + dims, strdims, 1, ASPECT_TYPE_CADDR); + aspect_register_vector(ELFSH_HOOK_MUNPROTECT, elfsh_void_munprotecthandler, + dims, strdims, 1, ASPECT_TYPE_CADDR); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** - * Initialize ALTPLT hijack and ET_REL injection handlers in their hook + * @brief Initialize all vectors of libelfsh */ -void elfsh_setup_hooks() +void elfsh_setup_hooks() { - //u_int i, j, k; - static int done = 0; + static int done = 0; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -532,87 +132,87 @@ /**************************************/ /* Usual PLT targets for ET_EXEC/i386 */ - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); /* Usual PLT targets for ET_EXEC/Sparc32 */ - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_sparc32); /* Usual PLT targets for ET_EXEC/Sparc64 */ - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_sparc64); /* Usual PLT targets for ET_EXEC/IA64 */ - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia64); /* Usual PLT targets for ET_EXEC/Alpha64 */ - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_alpha64); /* Usual PLT targets for ET_EXEC/MIPS32 */ - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_mips32); /* Usual PLT targets for ET_EXEC/MIPS64 */ - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_plt_mips64); /***************************************/ @@ -620,87 +220,87 @@ /**************************************/ /* Usual ALTPLT targets for ET_EXEC/i386 */ - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_void_altplthandler); /* Usual ALTPLT targets for ET_EXEC/Sparc32 */ - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_sparc32); /* Usual ALTPLT targets for ET_EXEC/Sparc64 */ - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_sparc64); /* Usual ALTPLT targets for ET_EXEC/IA64 */ - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_ia64); /* Usual ALTPLT targets for ET_EXEC/Alpha64 */ - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_alpha64); /* Usual ALTPLT targets for ET_EXEC/MIPS32 */ - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_mips32); /* Usual ALTPLT targets for ET_EXEC/MIPS64 */ - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_hijack_altplt_mips64); /***********************************/ @@ -709,87 +309,87 @@ /* Usual REL targets for ET_EXEC/i386 */ - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_ia32); /* Usual REL targets for ET_EXEC/Sparc32 */ - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_sparc32); /* Usual REL targets for ET_EXEC/Sparc64 */ - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_sparc64); /* Usual REL targets for ET_EXEC/IA64 */ - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_ia64); /* Usual REL targets for ET_EXEC/Alpha64 */ - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_alpha64); /* Usual REL targets for ET_EXEC/MIPS32 */ - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_mips32); /* Usual REL targets for ET_EXEC/MIPS64 */ - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_relocate_mips64); /***********************************/ @@ -797,824 +397,290 @@ /***********************************/ /* Usual REL targets for ET_EXEC/IA32 */ - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_ia32); /* Usual CFLOW targets for ET_EXEC/IA64 */ - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_ia64); /* Usual CFLOW targets for ET_EXEC/SPARC32 */ - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_sparc32); /* Usual CFLOW targets for ET_EXEC/SPARC64 */ - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_sparc64); /* Usual CFLOW targets for ET_EXEC/ALPHA64 */ - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_alpha64); /* Usual CFLOW targets for ET_EXEC/MIPS32 */ - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_mips32); /* Usual CFLOW targets for ET_EXEC/MIPS64 */ - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, + elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_cflow_ia32); + elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_BEOS, elfsh_cflow_ia32); /* Usual REL/PLT/ALTPLT targets for ET_DYN/x86 */ - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_BEOS, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_NETBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_BEOS, elfsh_relocate_ia32); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_void_altplthandler); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_relocate_ia32); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_BEOS, elfsh_void_altplthandler); - + /***********************************/ /* Now register encodeplt points hooks */ /***********************************/ /* Usual ENCODEPLT breakpoint targets for ET_EXEC/IA32 */ - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_FREEBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_NETBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); + elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_BEOS, elfsh_encodeplt_ia32); /* Usual ENCODEPLT1 targets for ET_EXEC/IA32 */ - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_FREEBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_NETBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); + elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_BEOS, elfsh_encodeplt1_ia32); + /*** Now EXTPLT handlers ***/ /* Usual EXTPLT targets for ET_EXEC/IA32 */ - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_LINUX, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_FREEBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_NETBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_OPENBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_SOLARIS, elfsh_extplt_ia32); + elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, + ELFSH_OS_BEOS, elfsh_extplt_ia32); + /***************************************/ /****** ARGC arguments counting ******/ /**************************************/ - /* Usual ARGC targets for ET_EXEC/i386 */ - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_LINUX, elfsh_args_count_ia32); + + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_LIB, ELFSH_OS_LINUX, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_FREEBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_NETBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_OPENBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, ELFSH_OS_SOLARIS, elfsh_args_count_ia32); + elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_FILE_EXEC, + ELFSH_OS_BEOS, elfsh_args_count_ia32); - done++; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Call the relocation hook - * @param file - * @param s - * @param r - * @param l - * @param a - * @param m - * @return - */ -int elfsh_rel(elfshobj_t *file, elfshsect_t *s, elfsh_Rel *r, - eresi_Addr *l, eresi_Addr a, elfshsect_t *m) -{ - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - vector_t *rel; - - //eresi_Addr ***hook; - u_int dim[3]; - - int (*fct)(elfshsect_t *n, - elfsh_Rel *n2, - eresi_Addr *n3, - eresi_Addr n4, - elfshsect_t *n5); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - rel = aspect_vector_get(ELFSH_HOOK_REL); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "RELOCATION handler unexistant for this ARCH/OS", -1); - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(rel, dim); - ret = fct(s, r, l, a, m); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Relocation handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Call the relocation hook - * @param file - * @param name - * @param old - * @param new - * @return - */ -int elfsh_cflow(elfshobj_t *file, char *name, elfsh_Sym *old, - eresi_Addr new) -{ - vector_t *cflow; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *n, char *n2, elfsh_Sym *n3, eresi_Addr n4); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "CFLOW handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(cflow, dim); - ret = fct(file, name, old, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Call the PLT hook - * @param file - * @param s - * @param new - * @return - */ -int elfsh_plt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) -{ - vector_t *plt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfsh_Sym *s, eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - plt = aspect_vector_get(ELFSH_HOOK_PLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(plt, dim); - ret = fct(file, s, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ENCODEPLT hook - * - * @param file - * @param plt - * @param diff - * @param off - * @return - */ -int elfsh_encodeplt(elfshobj_t *file, elfshsect_t *plt, - eresi_Addr diff, u_int off) -{ - vector_t *encodeplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfshsect_t *s, eresi_Addr a, u_int off); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ENCODEPLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(encodeplt, dim); - - ret = fct(file, plt, diff, off); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT encoding handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ENCODEPLT1 hook - * - * @param file - * @param plt - * @param extplt - * @param diff - * @return - */ -int elfsh_encodeplt1(elfshobj_t *file, elfshsect_t *plt, - elfshsect_t *extplt, eresi_Addr diff) -{ - vector_t *encodeplt1; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfshsect_t *s, elfshsect_t *s2, - eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ENCODEPLT1 handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(encodeplt1, dim); - ret = fct(file, plt, extplt, diff); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT1 encoding handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ALTPLT hook - * - * @param file - * @param s - * @param new - * @return - */ -int elfsh_altplt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) -{ - vector_t *altplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *file, elfsh_Sym *s, eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(altplt, dim); - ret = fct(file, s, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Call the EXTPLT hook - * - * @param extplt - * @param altgot - * @param dynsym - * @param relplt - * @return - */ -int elfsh_extplt(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt) -{ - vector_t *vextplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - vextplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(extplt->parent); - elftype = elfsh_get_elftype(extplt->parent); - ostype = elfsh_get_ostype(extplt->parent); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "EXTPLT handler unexistant for this ARCH/OS", -1); - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(vextplt, dim); - ret = fct(extplt, altgot, dynsym, relplt); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "EXTPLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Call the arg count hook - * - * @param file - * @param off - * @param vaddr - * @return - */ -int *elfsh_args_count(elfshobj_t *file, u_int off, eresi_Addr vaddr) -{ - vector_t *argch; - u_char archtype; - u_char elftype; - u_char ostype; - int *(*fct)(elfshobj_t *file, u_int off, eresi_Addr vaddr); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - argch = aspect_vector_get(ELFSH_HOOK_ARGC); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ARGC handler unexistant for this ARCH/OS", NULL); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(argch, dim); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, fct(file, off, vaddr)); -} - - - - -/** - * Translate ELF architecture type into ELFsh architecture type - * - * @param file - * @return - */ -u_char elfsh_get_archtype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file argument!", (ELFSH_ARCH_ERROR)); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA32)); - case EM_SPARC: - case EM_SPARC32PLUS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC32)); - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC64)); - case EM_PARISC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PARISC)); - case EM_IA_64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA64)); - case EM_PPC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC32)); - case EM_PPC64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC64)); - case EM_SVX: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_CRAY)); - case EM_ALPHA: -#if EM_ALPHA != EM_ALPHA_EXP - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ALPHA64)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_MIPS32)); - case EM_ARM: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ARM)); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ERROR)); - } -} - - -/** - * Translate ELF object type into ELFsh object type - * @param file - * @return - */ -u_char elfsh_get_elftype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_objtype(file->hdr)) - { - case ET_EXEC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_EXEC)); - case ET_DYN: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_DYN)); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_ERROR)); - } -} - - -/** - * Retreive ELFsh OS type from ELF header - * @param file - * @return - */ -u_char elfsh_get_real_ostype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (file->hdr->e_ident[EI_OSABI]) - { - case ELFOSABI_LINUX: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_LINUX)); - case ELFOSABI_FREEBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_FREEBSD)); - case ELFOSABI_NETBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_NETBSD)); - case ELFOSABI_OPENBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_OPENBSD)); - case ELFOSABI_SOLARIS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_SOLARIS)); - case 0: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_ERROR)); - } -} - - -/** - * For now, always return the type of a userland process - * Need to be extended for the kernel memory type - * - * @param file - * @return - */ -u_char elfsh_get_hosttype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (E2DBG_HOST_PROC)); -} - - -/** - * Fill up ELFsh Operating System type - * - * @param file - * @return - */ -u_char elfsh_get_ostype(elfshobj_t *file) -{ - u_char *res; - char *interp; - char *end; - char r; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First try */ - r = elfsh_get_real_ostype(file); - switch (r) - { - /* Information not present */ - case 0: - break; - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r)); - } - - /* Smart intermediate way, fingerprint by .interp section */ - /* Not aware of any other software using this technique */ - if (elfsh_get_interp(file)) - { - if (!interp_hash.size) - { - hash_init(&interp_hash, "interpreters", 10, ASPECT_TYPE_STR); - hash_add(&interp_hash, - "/lib/ld-linux.so", - &elfsh_ostype[ELFSH_OS_LINUX]); - hash_add(&interp_hash, - "/usr/libexec/ld-elf.so", - &elfsh_ostype[ELFSH_OS_FREEBSD]); - hash_add(&interp_hash, - "/usr/libexec/ld-eld_so", - &elfsh_ostype[ELFSH_OS_NETBSD]); - hash_add(&interp_hash, - "??????????????", - &elfsh_ostype[ELFSH_OS_OPENBSD]); - hash_add(&interp_hash, - "/usr/lib/ld.so", - &elfsh_ostype[ELFSH_OS_SOLARIS]); - - } - - - /* Only useful for objects with .interp section */ - /* e.g. : ET_EXEC, and some special ET_DYN like libc */ - interp = (char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]); - end = strstr(".so", interp); - if (end) - *(end + 3) = 0x00; - res = hash_get(&interp_hash, interp); - if (res) - { - file->hdr->e_ident[EI_OSABI] = *res; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_real_ostype(file))); - } - } - - /* Fatalist */ -#if defined(__linux__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_LINUX); -#elif defined(__FreeBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_FREEBSD); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_NETBSD); -#elif defined(__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_OPENBSD); -#elif defined(sun) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_SOLARIS); -#elif defined(__BEOS__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_BEOS); -#else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_ERROR); -#endif -} + /* Register handlers for READMEM hook */ + elfsh_register_readmem(ELFSH_OS_LINUX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_LINUX, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_BEOS, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_BEOS, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_IRIX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_IRIX, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_HPUX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_HPUX, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + /* It appears that the OS field of some binary is set to 'ELF_OSABI_ARM' ... */ + elfsh_register_readmem(ELFSH_OS_ARM, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw); + elfsh_register_readmem(ELFSH_OS_ARM, ELFSH_IOTYPE_STATIC , elfsh_get_raw); + + /* Register handlers for READMEMA hook */ + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_NETBSD, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_NETBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_EMBEDDED, elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_BEOS, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_BEOS, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_IRIX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_IRIX, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_HPUX, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_HPUX, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_ARM, ELFSH_IOTYPE_EMBEDDED , elfsh_get_raw_by_addr); + elfsh_register_readmema(ELFSH_OS_ARM, ELFSH_IOTYPE_STATIC , elfsh_get_raw_by_addr); + + /* Register handlers for WRITEMEM hook */ + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_FREEBSD, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_EMBEDDED, elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_OPENBSD, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_EMBEDDED, elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_SOLARIS, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_BEOS, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_BEOS, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_IRIX, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_IRIX, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_HPUX, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_HPUX, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_ARM, ELFSH_IOTYPE_EMBEDDED , elfsh_memcpy); + elfsh_register_writemem(ELFSH_OS_ARM, ELFSH_IOTYPE_STATIC , elfsh_memcpy); + + /* Register handlers for READMEMF/WRITEMEMF hook */ + elfsh_register_readmemf(ELFSH_HOST_USER, LIBELFSH_MODE_STATIC, elfsh_raw_read); + elfsh_register_readmemf(ELFSH_HOST_USER, LIBELFSH_MODE_RUNTIME, elfsh_raw_read); + elfsh_register_writememf(ELFSH_HOST_USER, LIBELFSH_MODE_STATIC, elfsh_raw_write); + elfsh_register_writememf(ELFSH_HOST_USER, LIBELFSH_MODE_RUNTIME, elfsh_raw_write); -/** - * Return the page size - * - * @param file - * @return - */ -int elfsh_get_pagesize(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + /* Register handlers for the ALLOC hook */ + elfsh_register_allochook(ELFSH_HOST_USER, elfsh_map_userland); - switch (elfsh_get_archtype(file)) - { - case ELFSH_ARCH_IA32: - case ELFSH_ARCH_MIPS32: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4096); - case ELFSH_ARCH_SPARC32: - case ELFSH_ARCH_SPARC64: - case ELFSH_ARCH_PARISC: - case ELFSH_ARCH_IA64: - case ELFSH_ARCH_ALPHA64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 8192); - case ELFSH_ARCH_PPC32: - case ELFSH_ARCH_PPC64: - case ELFSH_ARCH_CRAY: - case ELFSH_ARCH_ERROR: - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", 0); - } -} + /* Register handlers for the ALLOC hook */ + elfsh_register_mprotecthook(ELFSH_HOST_USER, elfsh_mprotect_userland); -/** - * Return the page size - * - * @param file - * @return - */ -u_int elfsh_get_breaksize(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + /* Register handlers for the ALLOC hook */ + elfsh_register_munprotecthook(ELFSH_HOST_USER, elfsh_munprotect_userland); - switch (elfsh_get_archtype(file)) - { - case ELFSH_ARCH_IA32: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - case ELFSH_ARCH_MIPS32: - case ELFSH_ARCH_SPARC32: - case ELFSH_ARCH_SPARC64: - case ELFSH_ARCH_PARISC: - case ELFSH_ARCH_ALPHA64: - case ELFSH_ARCH_PPC32: - case ELFSH_ARCH_PPC64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4); - case ELFSH_ARCH_IA64: - case ELFSH_ARCH_CRAY: - case ELFSH_ARCH_ERROR: - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", 0); - } + done++; + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } - diff -Nru eresi-0.8a25/libelfsh/ia32.c eresi-0.0.20110516/libelfsh/ia32.c --- eresi-0.8a25/libelfsh/ia32.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/ia32.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file ia32.c +* @file libelfsh/ia32.c * @ingroup libelfsh * ia32.c for libelfsh * * Started on Fri Jan 11 03:05:37 2003 jfv * * - * $Id: ia32.c,v 1.23 2008-02-16 12:32:27 thor Exp $ + * $Id: ia32.c 1435 2010-12-11 06:16:51Z may $ * */ #include "libelfsh.h" @@ -16,9 +16,6 @@ #define ELFSH_IA32_PROLOG_MSTEP 3 static asm_processor proc; static u_char proc_init = 0; -static int args[ELFSH_TRACE_MAX_ARGS+1]; -static u_int arg_count; -static u_int max_arg_offset; #define ELFSH_IA32_PUSH_REGBASE(_i) \ (_i.instr == ASM_PUSH \ @@ -75,8 +72,11 @@ /* 6 is the size of the first instruction of a .plt entry on x86 */ gotent = extplt->shdr->sh_addr + extplt->curend + 6; - memcpy(elfsh_get_raw(altgot) + altgot->curend, - (char *) &gotent, sizeof(gotent)); + + memcpy(elfsh_readmem(altgot) + altgot->curend, (char *) &gotent, sizeof(gotent)); + //elfsh_writemem(altgot->parent, altgot->shdr->sh_addr + altgot->curend, + // (char *) &gotent, sizeof(gotent)); + altgot->curend += sizeof(gotent); #if __DEBUG_EXTPLT__ @@ -85,21 +85,25 @@ #endif /* 7 is the offset for the relocation offset location, encoded in GOT */ - ent = elfsh_get_raw(extplt) + extplt->curend; + ent = elfsh_readmem(extplt) + extplt->curend; reloc = (int *) ((char *) ent + 7); prot = elfsh_munprotect(extplt->parent, (eresi_Addr) reloc, - (char *) reloc - (char *) elfsh_get_raw(extplt)); + (char *) reloc - (char *) elfsh_readmem(extplt)); *reloc = relplt->curend; - elfsh_mprotect((eresi_Addr) reloc, - (char *) reloc - (char *) elfsh_get_raw(extplt), prot); + elfsh_mprotect(extplt->parent, + (eresi_Addr) reloc, + (char *) reloc - (char *) elfsh_readmem(extplt), prot); extplt->curend += elfsh_get_pltentsz(extplt->parent); /* Insert relocation entry pointing on the new PLT entry */ relentsz = IS_REL(extplt) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela); r = elfsh_create_relent(R_386_JMP_SLOT, dynsym->curend / sizeof(elfsh_Sym), altgot->shdr->sh_addr + altgot->curend - sizeof(eresi_Addr)); - memcpy(elfsh_get_raw(relplt) + relplt->curend, &r, relentsz); + + memcpy(elfsh_readmem(relplt) + relplt->curend, &r, relentsz); + //elfsh_writemem(relplt->parent, relplt->shdr->sh_addr + relplt->curend, &r, relentsz); + relplt->curend += relentsz; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -315,7 +319,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid address to hijack", -1); - ret = elfsh_raw_read(file, off, buff, 32); + ret = elfsh_readmemf(file, off, buff, 32); if (ret != 32) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Function too small to be hijacked", -1); @@ -328,12 +332,12 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get and inject .hooks", -1); - hook = elfsh_get_raw(hooks) + hooks->curend; + hook = elfsh_readmem(hooks) + hooks->curend; /* Determine the minimal aligned length */ if (!proc_init) { - asm_init_ia32(&proc); + asm_init_arch(&proc, ASM_PROC_IA32); proc_init = 1; } for (idx = ret = 0; ret < 5 && idx < 5; idx++) @@ -343,11 +347,11 @@ prot = elfsh_munprotect(file, (eresi_Addr) hook, 16); memset(hook, 0x90, 40); memcpy(hook, "\xe9\x00\x00\x00\x00", 5); - *(uint32_t *) ((char *) hook + 1) = addr - (hooks->shdr->sh_addr + (hook + 1 - (char *) elfsh_get_raw(hooks)) + 4); + *(uint32_t *) ((char *) hook + 1) = addr - (hooks->shdr->sh_addr + (hook + 1 - (char *) elfsh_readmem(hooks)) + 4); memcpy(hook + 5, buff, ret); memcpy(hook + 5 + ret, "\xe9\x00\x00\x00\x00", 5); *(uint32_t *) ((char *) hook + 6 + ret) = symbol->st_value - (hooks->shdr->sh_addr + hooks->curend + 10); - elfsh_mprotect((eresi_Addr) hook, 16, prot); + elfsh_mprotect(file, (eresi_Addr) hook, 16, prot); /* We need to grab the parent section to compute the remaining offset */ source = elfsh_get_parent_section_by_foffset(file, off, NULL); @@ -364,15 +368,13 @@ /* Ret: the minimal instruction aligned length for installing the hook caller-side properly */ hookbuf = alloca(ret); - //prot = elfsh_munprotect(hookbuf, 16); memcpy(hookbuf, "\xe9\x00\x00\x00\x00", 5); *(uint32_t *) ((char *) hookbuf + 1) = (hooks->shdr->sh_addr + hooks->curend) - (symbol->st_value + 5); memset(hookbuf + 5, 0x90, ret - 5); - len = elfsh_raw_write(file, off, hookbuf, ret); + len = elfsh_writememf(file, off, hookbuf, ret); if (len != ret) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Error during hook installation", -1); - //elfsh_mprotect(hookbuf, 16, prot); /* Insert the old symbol on the original saved bytes (do the insertion AFTER all use of symbol !!) */ snprintf(bufname, BUFSIZ, "old_%s", name); @@ -382,8 +384,6 @@ elfsh_insert_funcsym(file, bufname, hooks->shdr->sh_addr + hooks->curend, ret + 10, hooks->index); - - #if __DEBUG_CFLOW__ printf("[DEBUG_CFLOW] hook_legit_func = %08X, old_legit_func = %08X \n", hooks->shdr->sh_addr + hooks->curend, @@ -429,19 +429,19 @@ prot = elfsh_munprotect(file, symbol->st_value, elfsh_get_pltentsz(file)); - elfsh_raw_write(file, foffset, &opcode, sizeof(opcode)); + elfsh_writememf(file, foffset, &opcode, sizeof(opcode)); /* Byte order test for cross-endianess ability */ #if __BYTE_ORDER == __BIG_ENDIAN displacement = swap32(displacement); - elfsh_raw_write(file, foffset + sizeof(opcode), + elfsh_writememf(file, foffset + sizeof(opcode), &displacement, sizeof(displacement)); #else - elfsh_raw_write(file, foffset + sizeof(opcode), + elfsh_writememf(file, foffset + sizeof(opcode), &displacement, sizeof(displacement)); #endif - elfsh_mprotect(symbol->st_value, + elfsh_mprotect(file, symbol->st_value, elfsh_get_pltentsz(file), prot); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -468,6 +468,8 @@ { elfsh_Shdr *section; elfsh_Sym *symbol; + elfsh_Rel *rel_entry; + uint32_t rel_offset; char *symname; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -496,7 +498,19 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find GOT for GOTPC", -1); } - *dword = cur->r_offset - section->sh_addr; + + //*dword = cur->r_offset - section->sh_addr; + symname = elfsh_get_symname_from_reloc(mod->parent, cur); + if (symname == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find symbol in host", -1); + rel_entry = elfsh_get_relent_by_name(new->parent, symname); + if (rel_entry == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find relocation in host", -1); + *dword = elfsh_get_reloffset(rel_entry) - section->sh_addr; + + break; case R_386_PLT32: @@ -569,11 +583,13 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find GOT for GOTPC", -1); } - *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2; + rel_offset = (elfsh_get_ostype(new->parent) == ELFSH_OS_BEOS ? 3 : 2); + *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + rel_offset; + #if __DEBUG_RELADD__ printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", - section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2, *dword); + section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + rel_offset, *dword); #endif break; @@ -617,11 +633,17 @@ } /** - * - * @param add + * @brief Add the infered parameter to the function parameters list. + * @param add Size of current reserved stack frame (does not include parameters) + * @param args The function parameter sizes array pointer. + * @param arg_count A pointer on the argument counter. + * @param max_arg_offset A pointer on the current biggest argument stack offset. * @return */ -static int elfsh_ac_largs_add(int add) +static int elfsh_ac_largs_add(int add, + int *args, + u_int *arg_count, + u_int *max_arg_offset) { u_int index; #if __DEBUG_ARG_COUNT__ @@ -635,20 +657,20 @@ "Invalid argument", -1); /* Empty list or next value is > to current max_arg_offset */ - if ((arg_count == 0 && args[arg_count] == 0) - || max_arg_offset < add) + if ((*arg_count == 0 && args[*arg_count] == 0) + || *max_arg_offset < add) { #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] MAX OR FIRST = %d\n", add); #endif - max_arg_offset = add; - args[arg_count++] = add; + *max_arg_offset = add; + args[(*arg_count)++] = add; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /* Already got it */ - if (max_arg_offset == add) + if (*max_arg_offset == add) { #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] ALREADY = %d\n", add); @@ -672,34 +694,34 @@ /* We sort result */ if (args[index] > add) { - if (arg_count == ELFSH_TRACE_MAX_ARGS) + if (*arg_count == ELFSH_TRACE_MAX_ARGS) { #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] MAX ARGUMENT\n"); #endif - arg_count--; + (*arg_count)--; } #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] Next values (b):\n"); - for (z = index; z < arg_count; z++) + for (z = index; z < *arg_count; z++) printf("[DEBUG_ARG_COUNT] :%d -> %d\n", z, args[z]); #endif /* Move arguments */ - memmove(&args[index + 1], &args[index], (arg_count - index)*sizeof(int)); + memmove(&args[index + 1], &args[index], (*arg_count - index) * sizeof(int)); #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] Next values (a):\n"); - for (z = index; z < arg_count + 1; z++) + for (z = index; z < *arg_count + 1; z++) printf("[DEBUG_ARG_COUNT] :%d -> %d\n", z, args[z]); #endif args[index] = add; - arg_count++; + (*arg_count)++; break; } } @@ -732,10 +754,10 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get an anonymous section", 0); - data = elfsh_get_raw(text); + data = elfsh_readmem(text); len = text->shdr->sh_size; - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? + base_vaddr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(text) ? file->rhdr.base + elfsh_get_section_addr(text->shdr) : elfsh_get_section_addr(text->shdr)); @@ -790,13 +812,14 @@ if (sect) { - buf = elfsh_get_raw(sect); + buf = elfsh_readmem(sect); buf += vaddr - (sect->parent->rhdr.base + sect->shdr->sh_addr); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } + /** * TODO: implement forward / backward * @@ -823,11 +846,16 @@ int regbased = -1; int next_regbased = -1; + int args[ELFSH_TRACE_MAX_ARGS+1]; + u_int arg_count; + u_int max_arg_offset; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!proc_init) { - asm_init_ia32(&proc); + asm_init_arch(&proc, ASM_PROC_IA32); proc_init = 1; } max_arg_offset = 0; @@ -950,7 +978,7 @@ #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] EBP (1) @ +%d (%x) - %d\n", index, index, op); #endif - elfsh_ac_largs_add(op); + elfsh_ac_largs_add(op, args, &arg_count, &max_arg_offset); } op = elfsh_ac_is_arg_ebp(&i.op[1], regbased); @@ -960,85 +988,88 @@ #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] EBP (2) @ +%d (%x) - %d\n", index, index, op); #endif - elfsh_ac_largs_add(op); + elfsh_ac_largs_add(op, args, &arg_count, &max_arg_offset); } #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] @ +%d (%x) i.instr = %d\n", index, index, i.instr); #endif } + else + { + // WRONG: We can have ESP based parameters even with a valid EBP. + + /* sub $esp, x */ + if (i.instr == ASM_SUB && i.op[0].baser == ASM_REG_ESP) { - /* sub $esp, x */ - if (i.instr == ASM_SUB && i.op[0].baser == ASM_REG_ESP) - { - reserv += i.op[1].imm; - + reserv += i.op[1].imm; + #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, - i.op[1].imm, reserv); + printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, + i.op[1].imm, reserv); #endif - continue; - } - /* add $esp, x */ - else if (i.instr == ASM_ADD && i.op[0].baser == ASM_REG_ESP) - { - reserv -= i.op[1].imm; - + continue; + } + /* add $esp, x */ + else if (i.instr == ASM_ADD && i.op[0].baser == ASM_REG_ESP) + { + reserv -= i.op[1].imm; + #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, - i.op[1].imm, reserv); + printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, + i.op[1].imm, reserv); #endif - continue; - } - - /* ESP based argument */ - op = elfsh_ac_is_arg_esp(&i.op[0], reserv); - - if (op > 0) - { + continue; + } + + /* ESP based argument */ + op = elfsh_ac_is_arg_esp(&i.op[0], reserv); + + if (op > 0) + { #if __DEBUG_ARG_COUNT__ printf("[DEBUG_ARG_COUNT] ESP (1) @ +%d (%x) - %d\n", index, index, op); #endif - elfsh_ac_largs_add(op); - } - - op = elfsh_ac_is_arg_esp(&i.op[1], reserv); - - if (op > 0) - { + elfsh_ac_largs_add(op, args, &arg_count, &max_arg_offset); + } + + op = elfsh_ac_is_arg_esp(&i.op[1], reserv); + + if (op > 0) + { #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] ESP (2) @ +%d (%x) - %d\n", index, index, op); + printf("[DEBUG_ARG_COUNT] ESP (2) @ +%d (%x) - %d\n", index, index, op); #endif - elfsh_ac_largs_add(op); - } - - /* On esp based functions, sometimes compiler optimisation is to not - clear argument after a call (just at the end). Then we need to update - stack state. Problem found in setupterm() */ - if (i.instr == ASM_PUSH) - { - reserv += sizeof(eresi_Addr); + elfsh_ac_largs_add(op, args, &arg_count, &max_arg_offset); + } + + /* On esp based functions, sometimes compiler optimisation is to not + clear argument after a call (just at the end). Then we need to update + stack state. Problem found in setupterm() */ + if (i.instr == ASM_PUSH) + { + reserv += sizeof(eresi_Addr); #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, - sizeof(eresi_Addr), reserv); + printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, + sizeof(eresi_Addr), reserv); #endif - } - else if (i.instr == ASM_POP) - { - reserv -= sizeof(eresi_Addr); + } + else if (i.instr == ASM_POP) + { + reserv -= sizeof(eresi_Addr); #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, - sizeof(eresi_Addr), reserv); + printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, + sizeof(eresi_Addr), reserv); #endif - } - else - { + } + else + { #if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] @ +%d (%x) i.instr = %d\n", index, index, i.instr); + printf("[DEBUG_ARG_COUNT] @ +%d (%x) i.instr = %d\n", index, index, i.instr); #endif - } } + } } else break; @@ -1082,7 +1113,6 @@ } } - setargs: */ @@ -1095,7 +1125,7 @@ Sometimes first argument is not use (__xstat64() case) which creates a bug into arguments number Offset 8 should always be first argument */ - elfsh_ac_largs_add(0x8); + elfsh_ac_largs_add(0x8, args, &arg_count, &max_arg_offset); for (index = 0; index < ELFSH_TRACE_MAX_ARGS && index < arg_count; index++) { diff -Nru eresi-0.8a25/libelfsh/ia64.c eresi-0.0.20110516/libelfsh/ia64.c --- eresi-0.8a25/libelfsh/ia64.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/ia64.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file ia64.c +* @file libelfsh/ia64.c * @ingroup libelfsh ** ia64.c for libelfsh ** @@ -8,7 +8,7 @@ ** Skeleton cut & pasted from the sparc64 backend ** ** -** $Id: ia64.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: ia64.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-alpha.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-alpha.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-alpha.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-alpha.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:57:27 2004 jfv ** ** -** $Id: libelfsh-alpha.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-alpha.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-bsd.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-bsd.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-bsd.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-bsd.h 2011-05-16 11:34:53.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file libelfsh-bsd.h +* @file libelfsh/include/libelfsh/libelfsh-bsd.h * @ingroup libelfsh * @brief Various undefined macros on BSD * * Last update Mon Feb 26 05:05:27 2005 jfv * - * $Id: libelfsh-bsd.h 958 2008-04-03 11:41:49Z thorkill $ + * $Id: libelfsh-bsd.h 1397 2009-09-13 02:19:08Z may $ * */ @@ -764,3 +764,83 @@ /* Legal values for the note segment descriptor types for object files. */ #define NT_VERSION 1 /* Contains a version string. */ + +/* Architectures undefined on BSD */ +#if __FreeBSD_version < 602000 +/* Values for e_machine. */ +#define EM_NONE 0 /* Unknown machine. */ +#define EM_M32 1 /* AT&T WE32100. */ +#define EM_SPARC 2 /* Sun SPARC. */ +#define EM_386 3 /* Intel i386. */ +#define EM_68K 4 /* Motorola 68000. */ +#define EM_88K 5 /* Motorola 88000. */ +#define EM_860 7 /* Intel i860. */ +#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */ +#define EM_S370 9 /* IBM System/370. */ +#define EM_MIPS_RS3_LE 10 /* MIPS R3000 Little-Endian. */ +#define EM_PARISC 15 /* HP PA-RISC. */ +#define EM_VPP500 17 /* Fujitsu VPP500. */ +#define EM_SPARC32PLUS 18 /* SPARC v8plus. */ +#define EM_960 19 /* Intel 80960. */ +#define EM_PPC 20 /* PowerPC 32-bit. */ +#define EM_PPC64 21 /* PowerPC 64-bit. */ +#define EM_S390 22 /* IBM System/390. */ +#define EM_V800 36 /* NEC V800. */ +#define EM_FR20 37 /* Fujitsu FR20. */ +#define EM_RH32 38 /* TRW RH-32. */ +#define EM_RCE 39 /* Motorola RCE. */ +#define EM_ARM 40 /* ARM. */ +#define EM_SH 42 /* Hitachi SH. */ +#define EM_SPARCV9 43 /* SPARC v9 64-bit. */ +#define EM_TRICORE 44 /* Siemens TriCore embedded processor. */ +#define EM_ARC 45 /* Argonaut RISC Core. */ +#define EM_H8_300 46 /* Hitachi H8/300. */ +#define EM_H8_300H 47 /* Hitachi H8/300H. */ +#define EM_H8S 48 /* Hitachi H8S. */ +#define EM_H8_500 49 /* Hitachi H8/500. */ +#define EM_IA_64 50 /* Intel IA-64 Processor. */ +#define EM_MIPS_X 51 /* Stanford MIPS-X. */ +#define EM_COLDFIRE 52 /* Motorola ColdFire. */ +#define EM_68HC12 53 /* Motorola M68HC12. */ +#define EM_MMA 54 /* Fujitsu MMA. */ +#define EM_PCP 55 /* Siemens PCP. */ +#define EM_NCPU 56 /* Sony nCPU. */ +#define EM_NDR1 57 /* Denso NDR1 microprocessor. */ +#define EM_STARCORE 58 /* Motorola Star*Core processor. */ +#define EM_ME16 59 /* Toyota ME16 processor. */ +#define EM_ST100 60 /* STMicroelectronics ST100 processor. */ +#define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ processor. */ +#define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ + +#endif + +#define EM_FAKE_ALPHA 41 /* Digital Alpha */ +#define EM_PDSP 63 /* Sony DSP Processor */ +#define EM_FX66 66 /* Siemens FX66 microcontroller */ +#define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ +#define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ +#define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ +#define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ +#define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ +#define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ +#define EM_ST19 74 /* STMicroelectronics ST19 8 bit mc */ +#define EM_VAX 75 /* Digital VAX */ +#define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ +#define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ +#define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ +#define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ +#define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ +#define EM_HUANY 81 /* Harvard University machine-independent object files */ +#define EM_PRISM 82 /* SiTera Prism */ +#define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ +#define EM_FR30 84 /* Fujitsu FR30 */ +#define EM_D10V 85 /* Mitsubishi D10V */ +#define EM_D30V 86 /* Mitsubishi D30V */ +#define EM_V850 87 /* NEC v850 */ +#define EM_M32R 88 /* Mitsubishi M32R */ +#define EM_MN10300 89 /* Matsushita MN10300 */ +#define EM_MN10200 90 /* Matsushita MN10200 */ +#define EM_PJ 91 /* picoJava */ +#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ +#define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ +#define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-compat.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-compat.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-compat.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-compat.h 2011-05-16 11:34:53.000000000 +0000 @@ -4,7 +4,7 @@ ** Started on Tue Feb 18 04:15:42 2003 jfv ** Last update Mon Feb 23 16:23:43 2004 jfv ** -** $Id: libelfsh-compat.h 946 2008-03-27 22:53:48Z may $ +** $Id: libelfsh-compat.h 1311 2009-01-14 20:36:48Z may $ ** */ @@ -16,8 +16,10 @@ #define MAP_ANONYMOUS MAP_ANON #endif -#if !defined(__BEOS__) -typedef char uint8; +#if defined(__BEOS__) + #include +#else + typedef char uint8; #endif #include "libelfsh-ia64.h" /* IA64 defines sometimes not present */ @@ -41,10 +43,6 @@ #include "libelfsh-bsd.h" /* Various BSD need this */ #endif -#if defined(ELFSH_INTERN) - #include "libelfsh-internal.h" -#endif - /* Portability Stuffs */ #ifdef __KERNEL__ #include "libelfsh-versions.h" @@ -77,6 +75,14 @@ #define STT_NUM 7 #endif +#ifndef EM_486 + #define EM_486 6 +#endif + +#ifndef EM_NCUBE + #define EM_NCUBE 16 +#endif + /* ELFOSABI index in e_ident[] */ #ifndef EI_OSABI #define EI_OSABI 7 @@ -129,8 +135,6 @@ typedef Elf64_Ehdr elfsh_Ehdr; typedef Elf64_Word elfsh_Word; typedef Elf64_Half elfsh_Half; -typedef Elf64_Addr eresi_Addr; -typedef Elf64_Off elfsh_Off; typedef Elf64_Rel elfsh_Rel; typedef Elf64_Rela elfsh_Rela; typedef Elf64_Sword elfsh_Sword; @@ -152,19 +156,6 @@ #define ELFSH_M_SIZE ELF64_M_SIZE #define ELFSH_M_INFO ELF64_M_INFO -#if __WORDSIZE == 32 - #define XFMT "0x%016llX" - #define AFMT "%016llX" - #define UFMT "%016llu" - #define DFMT "%016lld" - #define RDFMT "%lld" -#elif __WORDSIZE == 64 - #define XFMT "0x%016lX" - #define AFMT "%016lX" - #define UFMT "%016lu" - #define DFMT "%016ld" - #define RDFMT "%ld" -#endif #if defined(__mips64) #define swaplong(x) swap32(x) @@ -183,8 +174,6 @@ typedef Elf32_Ehdr elfsh_Ehdr; typedef Elf32_Word elfsh_Word; typedef Elf32_Half elfsh_Half; -typedef Elf32_Addr eresi_Addr; -typedef Elf32_Off elfsh_Off; typedef Elf32_Rel elfsh_Rel; typedef Elf32_Rela elfsh_Rela; typedef Elf32_Sword elfsh_Sword; @@ -207,12 +196,6 @@ #define ELFSH_M_SIZE ELF32_M_SIZE #define ELFSH_M_INFO ELF32_M_INFO -#define XFMT "0x%08X" -#define AFMT "%08X" -#define UFMT "%08u" -#define DFMT "%08d" -#define RDFMT "%d" - #define swaplong(x) swap32(x) #endif /* BITS */ @@ -220,7 +203,7 @@ /** * MIPS reginfo structure */ -typedef struct +typedef struct s_reginfo { elfsh_Word ri_gprmask; elfsh_Word ri_cprmask[4]; diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-cray.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-cray.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-cray.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-cray.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:57:27 2005 jfv ** ** -** $Id: libelfsh-cray.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-cray.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-hppa.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-hppa.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-hppa.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-hppa.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:57:27 2004 jfv ** ** -** $Id: libelfsh-hppa.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-hppa.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ia32.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ia32.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ia32.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ia32.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:57:27 2004 yann malcom ** ** -** $Id: libelfsh-ia32.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-ia32.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ia64.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ia64.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ia64.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ia64.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:35:27 2004 jfv ** ** -** $Id: libelfsh-ia64.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-ia64.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-internal.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-internal.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-internal.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-internal.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** libelfsh-internal.h for elfsh -** -** Started on Wed Jan 1 07:51:24 2003 jfv -** Last update Thu Mar 20 06:19:53 2003 jfv -** -** $Id: libelfsh-internal.h 925 2008-03-24 18:25:11Z enioh $ -** -*/ - -#ifndef __LIBELFSH_INTERN_ - #define __LIBELFSH_INTERN_ - -// To remove one day -#define ELFSH_SETERROR(msg, ret) ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, msg, ret) - -#endif /* __LIBELFSH_INTERN_ */ - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-irix.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-irix.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-irix.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-irix.h 2011-05-16 11:34:53.000000000 +0000 @@ -5,7 +5,7 @@ ** ** Last update Mon Aug 23 05:05:27 2005 ym ** -** $Id: libelfsh-irix.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-irix.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-mips.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-mips.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-mips.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-mips.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,11 +7,10 @@ ** Last update Sat Feb 26 20:57:27 2004 jfv ** ** -** $Id: libelfsh-mips.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-mips.h 1311 2009-01-14 20:36:48Z may $ ** */ - #ifndef EM_MIPS #define EM_MIPS 8 #endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ppc.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ppc.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-ppc.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-ppc.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 26 20:57:27 2005 jfv ** ** -** $Id: libelfsh-ppc.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-ppc.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-sparc.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-sparc.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-sparc.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-sparc.h 2011-05-16 11:34:53.000000000 +0000 @@ -7,7 +7,7 @@ ** Last update Sat Feb 27 16:57:02 2005 jfv ** ** -** $Id: libelfsh-sparc.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-sparc.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-sunos.h eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-sunos.h --- eresi-0.8a25/libelfsh/include/libelfsh/libelfsh-sunos.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/libelfsh-sunos.h 2011-05-16 11:34:53.000000000 +0000 @@ -4,7 +4,7 @@ ** Started on Fri Dec 7 21:29:00 2001 jfv ** Last update Mon Feb 26 05:05:27 2005 jfv ** -** $Id: libelfsh-sunos.h 925 2008-03-24 18:25:11Z enioh $ +** $Id: libelfsh-sunos.h 1311 2009-01-14 20:36:48Z may $ ** */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/all-wcprops eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/all-wcprops --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/all-wcprops 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/958/trunk/libelfsh/include/libelfsh -END -libelfsh-compat.h -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/946/trunk/libelfsh/include/libelfsh/libelfsh-compat.h -END -libelfsh-ia64.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-ia64.h -END -libelfsh-alpha.h -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-alpha.h -END -libelfsh-sunos.h -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-sunos.h -END -libelfsh-bsd.h -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/958/trunk/libelfsh/include/libelfsh/libelfsh-bsd.h -END -libelfsh-hppa.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-hppa.h -END -libelfsh-mips.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-mips.h -END -libelfsh-sparc.h -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-sparc.h -END -libelfsh-versions.h -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-versions.h -END -libelfsh-irix.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-irix.h -END -libelfsh-internal.h -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-internal.h -END -libelfsh-cray.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-cray.h -END -libelfsh-ia32.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-ia32.h -END -libelfsh-ppc.h -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/925/trunk/libelfsh/include/libelfsh/libelfsh-ppc.h -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/entries eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/entries --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/entries 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,210 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libelfsh/include/libelfsh -http://svn.eresi-project.org/svn - - - -2008-04-03T11:41:49.560530Z -958 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libelfsh-compat.h -file - - - - -2008-04-06T23:15:35.473881Z -ef28c940689e6d040e9ff3aeac7e6947 -2008-03-27T22:53:48.747992Z -946 -may -has-props - -libelfsh-ia64.h -file - - - - -2008-04-06T23:15:35.540898Z -ef942c88f89610a029f96e4160864874 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-alpha.h -file - - - - -2008-04-06T23:15:35.552298Z -4a00b37eac25cf4bee104c7fc8010bdf -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-sunos.h -file - - - - -2008-04-06T23:15:35.563881Z -d53cbc56f68e3fca1d9526f36a8e151b -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-bsd.h -file - - - - -2008-04-06T23:15:35.575043Z -8cdafa5a2a1bfeb7473408fbd14c8ead -2008-04-03T11:41:49.560530Z -958 -thorkill -has-props - -libelfsh-hppa.h -file - - - - -2008-04-06T23:15:35.587897Z -5cc7469821b0424d8ae78555ef018c75 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-mips.h -file - - - - -2008-04-06T23:15:35.841149Z -1e2c80a86cf39c1646837df242630eb3 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-sparc.h -file - - - - -2008-04-06T23:15:35.876516Z -8565a8fa4a40583e6909daf9a0d6c3ae -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-versions.h -file - - - - -2008-04-06T23:15:35.887900Z -e150a3b68b0bda1d5b8c3cedb0e19604 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-irix.h -file - - - - -2008-04-06T23:15:35.899474Z -60acde3efffcee7a0e3b17d93909cad0 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-internal.h -file - - - - -2008-04-06T23:15:35.910876Z -4af68cb3ef81f9c96ac02e8270768afa -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-cray.h -file - - - - -2008-04-06T23:15:35.922159Z -5e9d34da1e56dd6861f746ff205f6e48 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-ia32.h -file - - - - -2008-04-06T23:15:35.933558Z -434ecfde1e45146cad34a7a355492154 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - -libelfsh-ppc.h -file - - - - -2008-04-06T23:15:35.944908Z -ca084b4e6d4a99af42f3f92b3f494e89 -2008-03-24T18:25:11.790287Z -925 -enioh -has-props - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/format eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/format --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/format 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-alpha.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-alpha.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-alpha.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-alpha.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-bsd.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-bsd.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-bsd.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-bsd.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-compat.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-compat.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-compat.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-compat.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-cray.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-cray.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-cray.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-cray.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-hppa.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-hppa.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-hppa.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-hppa.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia32.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia32.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia32.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia32.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia64.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia64.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia64.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ia64.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-internal.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-internal.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-internal.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-internal.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-irix.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-irix.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-irix.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-irix.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-mips.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-mips.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-mips.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-mips.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ppc.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ppc.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ppc.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-ppc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sparc.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sparc.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sparc.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sparc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sunos.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sunos.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sunos.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-sunos.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-versions.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-versions.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-versions.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/prop-base/libelfsh-versions.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 12 -svn:keywords -V 2 -Id -END diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-alpha.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-alpha.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-alpha.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-alpha.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,194 +0,0 @@ -/* -** -** Compatibility with the Alpha architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2004 jfv -** -** -** $Id$ -** -*/ - -/* Alpha relocations. */ - -#ifndef EM_ALPHA - #define EM_ALPHA 41 -#endif - -#ifndef EM_ALPHA_EXP - #define EM_ALPHA_EXP 36902 -#endif - -#ifndef R_ALPHA_NONE - #define R_ALPHA_NONE 0 /* No reloc */ -#endif - -#ifndef R_ALPHA_REFLONG - #define R_ALPHA_REFLONG 1 /* Direct 32 bit */ -#endif - -#ifndef R_ALPHA_REFQUAD - #define R_ALPHA_REFQUAD 2 /* Direct 64 bit */ -#endif - -#ifndef R_ALPHA_GPREL32 - #define R_ALPHA_GPREL32 3 /* GP relative 32 bit */ -#endif - -#ifndef R_ALPHA_LITERAL - #define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */ -#endif - -#ifndef R_ALPHA_LITUSE - #define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */ -#endif - -#ifndef R_ALPHA_GPDISP - #define R_ALPHA_GPDISP 6 /* Add displacement to GP */ -#endif - -#ifndef R_ALPHA_BRADDR - #define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */ -#endif - -#ifndef R_ALPHA_HINT - #define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */ -#endif - -#ifndef R_ALPHA_SREL16 - #define R_ALPHA_SREL16 9 /* PC relative 16 bit */ -#endif - -#ifndef R_ALPHA_SREL32 - #define R_ALPHA_SREL32 10 /* PC relative 32 bit */ -#endif - -#ifndef R_ALPHA_SREL64 - #define R_ALPHA_SREL64 11 /* PC relative 64 bit */ -#endif - -#ifndef R_ALPHA_OP_PUSH - #define R_ALPHA_OP_PUSH 12 /* OP stack push */ -#endif - -#ifndef R_ALPHA_OP_STORE - #define R_ALPHA_OP_STORE 13 /* OP stack pop and store */ -#endif - -#ifndef R_ALPHA_OP_PSUB - #define R_ALPHA_OP_PSUB 14 /* OP stack subtract */ -#endif - -#ifndef R_ALPHA_OP_PRSHIFT - #define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */ -#endif - -#ifndef R_ALPHA_GPVALUE - #define R_ALPHA_GPVALUE 16 /* Global Pointer value */ -#endif - -#ifndef R_ALPHA_IMMED_GP_16 - #define R_ALPHA_IMMED_GP_16 19 -#endif - -#ifndef R_ALPHA_GPRELHIGH - #define R_ALPHA_GPRELHIGH 17 /* GP relative 32 bit, high 16 bits */ -#endif - -#ifndef R_ALPHA_GPRELLOW - #define R_ALPHA_GPRELLOW 18 /* GP relative 32 bit, low 16 bits */ -#endif - -#ifndef R_ALPHA_GPREL16 - #define R_ALPHA_GPREL16 19 /* GP relative 16 bit */ -#endif - -#ifndef R_ALPHA_IMMED_GP_HI32 - #define R_ALPHA_IMMED_GP_HI32 20 /* Unknown */ -#endif - -#ifndef R_ALPHA_IMMED_SCN_HI32 - #define R_ALPHA_IMMED_SCN_HI32 21 /* Unknown */ -#endif - -#ifndef R_ALPHA_IMMED_BR_HI32 - #define R_ALPHA_IMMED_BR_HI32 22 /* Unknown */ -#endif - -#ifndef R_ALPHA_IMMED_LO32 - #define R_ALPHA_IMMED_LO32 23 /* Unknown */ -#endif - -#ifndef R_ALPHA_COPY - #define R_ALPHA_COPY 24 /* Copy symbol at runtime */ -#endif - -#ifndef R_ALPHA_GLOB_DAT - #define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */ -#endif - -#ifndef R_ALPHA_JMP_SLOT - #define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */ -#endif - -#ifndef R_ALPHA_RELATIVE - #define R_ALPHA_RELATIVE 27 /* Adjust by program base */ -#endif - -#ifndef R_ALPHA_TLS_GD_HI - #define R_ALPHA_TLS_GD_HI 28 -#endif - -#ifndef R_ALPHA_TLSGD - #define R_ALPHA_TLSGD 29 -#endif - -#ifndef R_ALPHA_TLS_LDM - #define R_ALPHA_TLS_LDM 30 -#endif - -#ifndef R_ALPHA_DTPMOD64 - #define R_ALPHA_DTPMOD64 31 -#endif - -#ifndef R_ALPHA_GOTDTPREL - #define R_ALPHA_GOTDTPREL 32 -#endif - -#ifndef R_ALPHA_DTPREL64 - #define R_ALPHA_DTPREL64 33 -#endif - -#ifndef R_ALPHA_DTPRELHI - #define R_ALPHA_DTPRELHI 34 -#endif - -#ifndef R_ALPHA_DTPRELLO - #define R_ALPHA_DTPRELLO 35 -#endif - -#ifndef R_ALPHA_DTPREL16 - #define R_ALPHA_DTPREL16 36 -#endif - -#ifndef R_ALPHA_GOTTPREL - #define R_ALPHA_GOTTPREL 37 -#endif - -#ifndef R_ALPHA_TPREL64 - #define R_ALPHA_TPREL64 38 -#endif - -#ifndef R_ALPHA_TPRELHI - #define R_ALPHA_TPRELHI 39 -#endif - -#ifndef R_ALPHA_TPRELLO - #define R_ALPHA_TPRELLO 40 -#endif - -#ifndef R_ALPHA_TPREL16 - #define R_ALPHA_TPREL16 41 -#endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-bsd.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-bsd.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-bsd.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-bsd.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,766 +0,0 @@ -/** - * @file libelfsh-bsd.h - * @ingroup libelfsh - * @brief Various undefined macros on BSD - * - * Last update Mon Feb 26 05:05:27 2005 jfv - * - * $Id$ - * - */ - -// TODO USE GOOD ELFSH TYPE -/* #include "libelfsh-irix.h" */ - -#include // NEEDED BY Obj_Entry -#include -#include -#include -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include -#elif defined(__OpenBSD__) -#include -#else -#include -#endif - -#if defined(__FreeBSD__) - #define __WORDSIZE __ELF_WORD_SIZE -#endif - -/** - * Lists of shared object dependencies - */ -typedef struct Struct_Needed_Entry -{ - struct Struct_Needed_Entry *next; - struct Struct_Obj_Entry *obj; - unsigned long name; /* Offset in string table */ -} Needed_Entry; - -struct Struct_Obj_Entry; - -/** - * BSD Link map - */ -typedef struct link_map -{ - caddr_t l_addr; /* Base Address of library */ -#ifdef __mips__ - caddr_t l_offs; /* Load Offset of library */ -#endif - const char *l_name; /* Absolute Path to Library */ - const void *l_ld; /* Pointer to .dynamic in memory */ - struct link_map *l_next, *l_prev; /* linked list of of mapped libs */ -} Link_map; - -/** - * Extracted from sys/queue.h on Linux - */ - -#if defined(__OpenBSD__) -#define STAILQ_ENTRY(type) \ -struct { \ - struct type *stqe_next; /* next element */ \ -} -#endif - - -/** - * Lists of shared objects - */ -typedef struct Struct_Objlist_Entry -{ - STAILQ_ENTRY(Struct_Objlist_Entry) link; - struct Struct_Obj_Entry *obj; -} Objlist_Entry; - -#if !defined(__OpenBSD__) -typedef STAILQ_HEAD(Struct_Objlist, Struct_Objlist_Entry) Objlist; -#endif - -#if defined(__FreeBSD__) -/** - * Shared object descriptor. - * - * Items marked with "(%)" are dynamically allocated, and must be freed - * when the structure is destroyed. - * - * CAUTION: It appears that the JDK port peeks into these structures. - * It looks at "next" and "mapbase" at least. Don't add new members - * near the front, until this can be straightened out. - */ -typedef struct Struct_Obj_Entry { - /* - * These two items have to be set right for compatibility with the - * original ElfKit crt1.o. - */ - u_int32_t magic; /* Magic number (sanity check) */ - u_int32_t version; /* Version number of struct format */ - - struct Struct_Obj_Entry *next; - char *path; /* Pathname of underlying file (%) */ - char *origin_path; /* Directory path of origin file */ - int refcount; - int dl_refcount; /* Number of times loaded by dlopen */ - - /* These items are computed by map_object() or by digest_phdr(). */ - caddr_t mapbase; /* Base address of mapped region */ - size_t mapsize; /* Size of mapped region in bytes */ - size_t textsize; /* Size of text segment in bytes */ - u_int32_t vaddrbase; /* Base address in shared object file */ - caddr_t relocbase; /* Relocation constant = mapbase - vaddrbase */ - const u_int32_t *dynamic; /* Dynamic section */ - caddr_t entry; /* Entry point */ - const u_int32_t *phdr; /* Program header if it is mapped, else NULL */ - size_t phsize; /* Size of program header in bytes */ - const char *interp; /* Pathname of the interpreter, if any */ - - /* TLS information */ - int tlsindex; /* Index in DTV for this module */ - void *tlsinit; /* Base address of TLS init block */ - size_t tlsinitsize; /* Size of TLS init block for this module */ - size_t tlssize; /* Size of TLS block for this module */ - size_t tlsoffset; /* Offset of static TLS block for this module */ - size_t tlsalign; /* Alignment of static TLS block */ - - /* Items from the dynamic section. */ - u_int32_t *pltgot; /* PLT or GOT, depending on architecture */ - const u_int32_t *rel; /* Relocation entries */ - unsigned long relsize; /* Size in bytes of relocation info */ - const u_int32_t *rela; /* Relocation entries with addend */ - unsigned long relasize; /* Size in bytes of addend relocation info */ - const u_int32_t *pltrel; /* PLT relocation entries */ - unsigned long pltrelsize; /* Size in bytes of PLT relocation info */ - const u_int32_t *pltrela; /* PLT relocation entries with addend */ - unsigned long pltrelasize; /* Size in bytes of PLT addend reloc info */ - const u_int32_t *symtab; /* Symbol table */ - const char *strtab; /* String table */ - unsigned long strsize; /* Size in bytes of string table */ - - const u_int32_t *buckets; /* Hash table buckets array */ - unsigned long nbuckets; /* Number of buckets */ - const u_int32_t *chains; /* Hash table chain array */ - unsigned long nchains; /* Number of chains */ - - const char *rpath; /* Search path specified in object */ - Needed_Entry *needed; /* Shared objects needed by this one (%) */ - - u_int32_t init; /* Initialization function to call */ - u_int32_t fini; /* Termination function to call */ - - unsigned char mainprog; /* True if this is the main program */ - unsigned char rtld; /* True if this is the dynamic linker */ - unsigned char textrel; /* True if there are relocations to text seg */ - unsigned char symbolic; /* True if generated with "-Bsymbolic" */ - unsigned char bind_now; /* True if all relocations should be made first */ - unsigned char traced; /* Already printed in ldd trace output */ - unsigned char jmpslots_done; /* Already have relocated the jump slots */ - unsigned char init_done; /* Already have added object to init list */ - unsigned char tls_done; /* Already allocated offset for static TLS */ - - struct link_map linkmap; /* for GDB and dlinfo() */ - Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ - Objlist dagmembers; /* DAG has these members (%) */ - dev_t dev; /* Object's filesystem's device */ - ino_t ino; /* Object's inode number */ - void *priv; /* Platform-dependant */ -} Obj_Entry; - -#elif defined(__NetBSD__) - -/* - * Shared object descriptor. - * - * Items marked with "(%)" are dynamically allocated, and must be freed - * when the structure is destroyed. - */ - -#define RTLD_MAGIC 0xd550b87a -#define RTLD_VERSION 1 -#define RTLD_MAIN 0x800 - -typedef struct Struct_Obj_Entry { - u_int32_t magic; /* Magic number (sanity check) */ - u_int32_t version; /* Version number of struct format */ - - struct Struct_Obj_Entry *next; - char *path; /* Pathname of underlying file (%) */ - int refcount; - int dl_refcount; /* Number of times loaded by dlopen */ - - /* These items are computed by map_object() or by digest_phdr(). */ - caddr_t mapbase; /* Base address of mapped region */ - size_t mapsize; /* Size of mapped region in bytes */ - size_t textsize; /* Size of text segment in bytes */ - u_int32_t vaddrbase; /* Base address in shared object file */ - caddr_t relocbase; /* Reloc const = mapbase - *vaddrbase */ - const u_int32_t *dynamic; /* Dynamic section */ - caddr_t entry; /* Entry point */ - const u_int32_t *__junk001; - size_t pathlen; /* Pathname length */ - - /* Items from the dynamic section. */ - u_int32_t *pltgot; /* PLTGOT table */ - const u_int32_t *rel; /* Relocation entries */ - const u_int32_t *rellim; /* Limit of Relocation entries */ - const u_int32_t *rela; /* Relocation entries */ - const u_int32_t *relalim; /* Limit of Relocation entries */ - const u_int32_t *pltrel; /* PLT relocation entries */ - const u_int32_t *pltrellim; /* Limit of PLT relocation entries */ - const u_int32_t *pltrela; /* PLT relocation entries */ - const u_int32_t *pltrelalim; /* Limit of PLT relocation entries */ - const u_int32_t *symtab; /* Symbol table */ - const char *strtab; /* String table */ - unsigned long strsize; /* Size in bytes of string table */ -#ifdef __mips__ - u_int32_t local_gotno; /* Number of local GOT entries */ - u_int32_t symtabno; /* Number of dynamic symbols */ - u_int32_t gotsym; /* First dynamic symbol in GOT */ -#endif - const u_int32_t *buckets; /* Hash table buckets array */ - unsigned long nbuckets; /* Number of buckets */ - const u_int32_t *chains; /* Hash table chain array */ - unsigned long nchains; /* Number of chains */ - - const char *rpaths; /* Search path specified in object */ - Needed_Entry *needed; /* Shared objects needed by this (%) */ - - void (*init)(void); /* Initialization function to call */ - void (*fini)(void); /* Termination function to call */ - - /* Entry points for dlopen() and friends. */ - void *(*dlopen)(const char *, int); - void *(*dlsym)(void *, const char *); - char *(*dlerror)(void); - int (*dlclose)(void *); - int (*dladdr)(const void *, Dl_info *); - - u_int32_t mainprog:1, /* True if this is the main program */ - rtld:1, /* True if this is the dynamic linker */ - textrel:1, /* True if there are relocations to - * text seg */ - symbolic:1, /* True if generated with - * "-Bsymbolic" */ - printed:1, /* True if ldd has printed it */ - isdynamic:1, /* True if this is a pure PIC object */ - mainref:1, /* True if on _rtld_list_main */ - globalref:1; /* True if on _rtld_list_global */ - - struct link_map linkmap; /* for GDB */ - - /* These items are computed by map_object() or by digest_phdr(). */ - const char *interp; /* Pathname of the interpreter, if any */ - Objlist dldags; /* Object belongs to these dlopened DAGs (%) */ - Objlist dagmembers; /* DAG has these members (%) */ - dev_t dev; /* Object's filesystem's device */ - ino_t ino; /* Object's inode number */ -} Obj_Entry; -#endif - -#ifndef STT_TLS - #define STT_TLS 6 - #undef STT_NUM - #define STT_NUM 7 -#endif - - -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ - - -#if __FreeBSD_version >= 603100 -#else - - typedef uint16_t Elf32_Half; - typedef uint32_t Elf32_Word; - -/** - * Version definition sections (32Bit) - */ -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -/** - * Version definition sections (64Bit) - */ -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; -#endif - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -#if __FreeBSD_version < 603100 -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/** - * Auxialiary version information. - */ -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - -/** - * Version dependency section. - */ -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - -#endif - -/** - * Note section contents. Each entry in the note section begins with - * a header of a fixed form. - */ -#if defined(__NetBSD__) || __FreeBSD_version >= 603100 -/* - * Note section are not necessary since residing in already - * we avoid conflicting types - */ -#else -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; -#endif - - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - - -#if (__FreeBSD_version < 603100) || defined(__OpenBSD__) -/** - * Auxiliary needed version information. - */ -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - -#endif - - -/* Advanced .dynamic entries : Undefined on BSD */ -#ifndef O_SYNC - #define O_SYNC O_FSYNC -#endif -#ifndef DT_BIND_NOW - #define DT_BIND_NOW 24 -#endif -#ifndef DT_SYMINENT - #define DT_SYMINIENT 0x6ffffdff -#endif -#ifndef DT_FLAGS - #define DT_FLAGS 30 -#endif -#ifndef DT_VERDEFNUM - #define DT_VERDEFNUM 0x6ffffffd -#endif -#ifndef DT_VERNEEDNUM - #define DT_VERNEEDNUM 0x6fffffff -#endif -#ifndef DT_PLTADSZ - #define DT_PLTPADSZ 0x6ffffdf9 -#endif -#ifndef DT_VERDEF - #define DT_VERDEF 0x6ffffffc -#endif -#ifndef DT_SYMINENT - #define DT_SYMINENT 0x6ffffdff -#endif -#ifndef DT_RELACOUNT - #define DT_RELACOUNT 0x6ffffff9 -#endif -#ifndef DT_RELCOUNT - #define DT_RELCOUNT 0x6ffffffa -#endif -#ifndef DT_SYMINFO - #define DT_SYMINFO 0x6ffffeff -#endif -#ifndef DT_SYMINSZ - #define DT_SYMINSZ 0x6ffffdfe -#endif -#ifndef DT_CHECKSUM - #define DT_CHECKSUM 0x6ffffdf8 -#endif -#ifndef DT_VERSYM - #define DT_VERSYM 0x6ffffff0 -#endif -#ifndef DT_MOVESZ - #define DT_MOVESZ 0x6ffffdfb -#endif -#ifndef DT_VERNEED - #define DT_VERNEED 0x6ffffffe -#endif -#ifndef DT_FILTER - #define DT_FILTER 0x7fffffff -#endif -#ifndef DT_MOVEENT - #define DT_MOVEENT 0x6ffffdfa -#endif -#ifndef DT_AUXILIARY - #define DT_AUXILIARY 0x7ffffffd -#endif -#ifndef DT_INIT_ARRAY - #define DT_INIT_ARRAY 25 -#endif -#ifndef DT_FINI_ARRAY - #define DT_FINI_ARRAY 26 -#endif -#ifndef DT_INIT_ARRAYSZ - #define DT_INIT_ARRAYSZ 27 -#endif -#ifndef DT_FINI_ARRAYSZ - #define DT_FINI_ARRAYSZ 28 -#endif -#ifndef DT_FLAGS_1 - #define DT_FLAGS_1 0x6ffffffb -#endif -#ifndef DT_FEATURE_1 - #define DT_FEATURE_1 0x6ffffdfc -#endif -#ifndef DT_POSFLAG_1 - #define DT_POSFLAG_1 0x6ffffdfd -#endif - -#ifndef ELFMAG - #define ELFMAG "\177ELF" -#endif - - -#ifndef DF_P1_LAZYLOAD - #define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#endif - -#ifndef DF_P1_GROUPPERM - #define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not */ -#endif - -#ifndef DF_ORIGIN - #define DF_ORIGIN 0x00000001 /* Object may use df_origin */ -#endif - -#ifndef DF_SYMBOLIC - #define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#endif - -#ifndef DF_TEXTREL - #define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#endif - -#ifndef DF_BIND_NOW - #define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ -#endif - -#ifndef DF_1_NOW - #define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#endif - -#ifndef DF_1_GLOBAL - #define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#endif - -#ifndef DF_1_GROUP - #define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#endif - -#ifndef DF_1_NODELETE - #define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#endif - -#ifndef DF_1_LOADFLTR - #define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#endif - -#ifndef DF_1_INITFIRST - #define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#endif - -#ifndef DF_1_NOOPEN - #define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#endif - -#ifndef DF_1_ORIGIN - #define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#endif - -#ifndef DF_1_DIRECT - #define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#endif - -#ifndef DF_1_TRANS - #define DF_1_TRANS 0x00000200 -#endif - -#ifndef DF_1_INTERPOSE - #define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#endif - -#ifndef DF_1_NODEFLIB - #define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#endif - -#ifndef DF_1_NODUMP - #define DF_1_NODUMP 0x00001000 -#endif - -#ifndef DF_1_CONFALT - #define DF_1_CONFALT 0x00002000 -#endif - -#ifndef DF_1_ENDFILTEE - #define DF_1_ENDFILTEE 0x00004000 -#endif - - -#ifndef DT_RUNPATH - #define DT_RUNPATH 29 /* Library search path */ -#endif - -#ifndef DT_ENCODING - #define DT_ENCODING 32 /* Start of encoded range */ -#endif - -#ifndef DT_PREINIT_ARRAY - #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#endif - -#ifndef DT_PREINIT_ARRAYSZ - #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#endif - - -#ifndef DT_NUM - #define DT_NUM 34 /* Number used */ -#endif - -#ifndef DTF_1_PARINIT - #define DTF_1_PARINIT 0x00000001 -#endif - -#ifndef DTF_1_CONFEXP - #define DTF_1_CONFEXP 0x00000002 -#endif - - -#ifndef STT_COMMON /* undefined on debian */ - #define STT_COMMON 5 -#endif - -/* Legal values for sh_flags (section flags) undefined on (Free)BSD */ - -#ifndef SHF_WRITE - #define SHF_WRITE (1 << 0) /* Writable */ -#endif - -#ifndef SHF_ALLOC - #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ -#endif - -#ifndef SHF_EXECINSTR - #define SHF_EXECINSTR (1 << 2) /* Executable */ -#endif - -#ifndef SHF_MERGE - #define SHF_MERGE (1 << 4) /* Might be merged */ -#endif - -#ifndef SHF_STRINGS - #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#endif - -#ifndef SHF_INFO_LINK - #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#endif - -#ifndef SHF_LINK_ORDER - #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#endif - -#ifndef SHF_OS_NONCONFORMING - #define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling */ -#endif - -#ifndef SHF_MASKOS - #define SHF_MASKOS 0x0ff00000 /* OS-specific. */ -#endif - -#ifndef SHF_MASKPROC - #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ -#endif - -#ifndef ELF64_ST_VISIBILITY - #define ELF64_ST_VISIBILITY(o) ((o) & 0x03) -#endif - -#ifndef ELF32_ST_VISIBILITY - #define ELF32_ST_VISIBILITY(o) ((o) & 0x03) -#endif - -#if !defined(PT_LOOS) - #define PT_LOOS 0x60000000 /* Start of OS-specific */ -#endif - -#if !defined(DT_LOOS) - #define DT_LOOS 0x60000000 /* Start of OS-specific */ -#endif - -#if !defined(DT_HIOS) - #define DT_HIOS 0x6fffffff /* End of OS-specific */ -#endif - -#if !defined(PT_GNU_EH_FRAME) - #define PT_GNU_EH_FRAME 0x6474e550 -#endif - -#if !defined(STT_NUM) - #define STT_NUM 7 -#endif - -#if !defined(PT_TLS) - #define PT_TLS 7 /* Thread-local storage segment */ -#endif - - - -/* 32bit */ -struct user_fpregs_struct -{ - long int cwd; - long int swd; - long int twd; - long int fip; - long int fcs; - long int foo; - long int fos; - long int st_space [20]; -}; - - -struct user_fpregs_struct64bit -{ - __uint16_t cwd; - __uint16_t swd; - __uint16_t ftw; - __uint16_t fop; - __uint64_t rip; - __uint64_t rdp; - __uint32_t mxcsr; - __uint32_t mxcr_mask; - __uint32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */ - __uint32_t xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */ - __uint32_t padding[24]; -}; - - -/* Legal values for note segment descriptor types for core files. */ - - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ - -/* Legal values for the note segment descriptor types for object files. */ - -#define NT_VERSION 1 /* Contains a version string. */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-compat.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-compat.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-compat.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-compat.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,228 +0,0 @@ -/* -** libelfsh-compat.h for libelfsh -** -** Started on Tue Feb 18 04:15:42 2003 jfv -** Last update Mon Feb 23 16:23:43 2004 jfv -** -** $Id$ -** -*/ - -#undef NULL -#define NULL 0 - -/* BSD patch */ -#ifndef MAP_ANONYMOUS - #define MAP_ANONYMOUS MAP_ANON -#endif - -#if !defined(__BEOS__) -typedef char uint8; -#endif - -#include "libelfsh-ia64.h" /* IA64 defines sometimes not present */ -#include "libelfsh-ia32.h" /* IA32 defines sometimes not present */ -#include "libelfsh-alpha.h" /* Alpha defines sometimes not present */ -#include "libelfsh-mips.h" /* MIPS defines sometimes not present */ -#include "libelfsh-sparc.h" /* SPARC define sometimes not present */ -#include "libelfsh-ppc.h" /* PowerPC define sometimes not present */ -#include "libelfsh-cray.h" /* CRAY define usually not present ;-) */ - -#if defined(IRIX) -#include "libelfsh-irix.h" /* IRIX lakes somes recent ELF extension */ -#endif - -#if defined(sun) /* SunOS has its own include */ - #include - #include "libelfsh-sunos.h" -#endif - -#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - #include "libelfsh-bsd.h" /* Various BSD need this */ -#endif - -#if defined(ELFSH_INTERN) - #include "libelfsh-internal.h" -#endif - -/* Portability Stuffs */ -#ifdef __KERNEL__ - #include "libelfsh-versions.h" -#else -#if defined(__OpenBSD__) || defined(__NetBSD__) - #include -#elif defined(__linux__) || defined(__FreeBSD__) || defined(sun) - #include -#endif -#endif - - -/* Redefinition of BUFSIZ */ -#undef BUFSIZ -#define BUFSIZ 8096 - -#ifndef EM_ALPHA_EXP - #define EM_ALPHA_EXP 0x9026 -#endif - -#ifndef EM_IA_64 - #define EM_IA_64 50 -#endif - -#ifndef EM_PARISC - #define EM_PARISC 15 -#endif - -#ifndef STT_NUM - #define STT_NUM 7 -#endif - -/* ELFOSABI index in e_ident[] */ -#ifndef EI_OSABI -#define EI_OSABI 7 -#endif - -/* ELFOSABI types */ -#ifndef ELFOSABI_NETBSD -#define ELFOSABI_NETBSD 2 -#endif -#ifndef ELFOSABI_LINUX -#define ELFOSABI_LINUX 3 -#endif -#ifndef ELFOSABI_SOLARIS -#define ELFOSABI_SOLARIS 6 -#endif -#ifndef ELFOSABI_FREEBSD -#define ELFOSABI_FREEBSD 9 -#endif -#ifndef ELFOSABI_OPENBSD -#define ELFOSABI_OPENBSD 12 -#endif - -/* Security */ -#ifndef PT_GNU_STACK - #define PT_GNU_STACK (PT_LOOS + 0x474e551) -#endif -#ifndef PT_GNU_RELRO - #define PT_GNU_RELRO (PT_LOOS + 0x474e552) -#endif - -#ifndef PT_PAX_FLAGS - #define PT_PAX_FLAGS 0x65041580 -#endif - - -/* Various printing macros */ -#define XFMT18 " 0x%08X" -#define UFMT14 " %010u" -#define UFMT18 " %010u" -#define UFMT10 "%010u" -#define DFMT11 "%011d" - -/* 64 bits support */ -#if defined(ERESI64) -typedef Elf64_Phdr elfsh_Phdr; -typedef Elf64_Shdr elfsh_Shdr; -typedef Elf64_Nhdr elfsh_Nhdr; -typedef Elf64_Sym elfsh_Sym; -typedef Elf64_Dyn elfsh_Dyn; -typedef Elf64_Ehdr elfsh_Ehdr; -typedef Elf64_Word elfsh_Word; -typedef Elf64_Half elfsh_Half; -typedef Elf64_Addr eresi_Addr; -typedef Elf64_Off elfsh_Off; -typedef Elf64_Rel elfsh_Rel; -typedef Elf64_Rela elfsh_Rela; -typedef Elf64_Sword elfsh_Sword; -typedef Elf64_Verneed elfsh_Verneed; -typedef Elf64_Vernaux elfsh_Vernaux; -typedef Elf64_Verdef elfsh_Verdef; -typedef Elf64_Verdaux elfsh_Verdaux; - -typedef int64_t elfsh_SAddr; - -#define ELFSH_ST_BIND ELF64_ST_BIND -#define ELFSH_ST_TYPE ELF64_ST_TYPE -#define ELFSH_ST_INFO ELF64_ST_INFO -#define ELFSH_ST_VISIBILITY ELF64_ST_VISIBILITY -#define ELFSH_R_SYM ELF64_R_SYM -#define ELFSH_R_TYPE ELF64_R_TYPE -#define ELFSH_R_INFO ELF64_R_INFO -#define ELFSH_M_SYM ELF64_M_SYM -#define ELFSH_M_SIZE ELF64_M_SIZE -#define ELFSH_M_INFO ELF64_M_INFO - -#if __WORDSIZE == 32 - #define XFMT "0x%016llX" - #define AFMT "%016llX" - #define UFMT "%016llu" - #define DFMT "%016lld" - #define RDFMT "%lld" -#elif __WORDSIZE == 64 - #define XFMT "0x%016lX" - #define AFMT "%016lX" - #define UFMT "%016lu" - #define DFMT "%016ld" - #define RDFMT "%ld" -#endif - -#if defined(__mips64) - #define swaplong(x) swap32(x) -#else - #define swaplong(x) swap64(x) -#endif - -/* 32 bits support */ -#elif defined(ERESI32) - -typedef Elf32_Phdr elfsh_Phdr; -typedef Elf32_Shdr elfsh_Shdr; -typedef Elf32_Nhdr elfsh_Nhdr; -typedef Elf32_Sym elfsh_Sym; -typedef Elf32_Dyn elfsh_Dyn; -typedef Elf32_Ehdr elfsh_Ehdr; -typedef Elf32_Word elfsh_Word; -typedef Elf32_Half elfsh_Half; -typedef Elf32_Addr eresi_Addr; -typedef Elf32_Off elfsh_Off; -typedef Elf32_Rel elfsh_Rel; -typedef Elf32_Rela elfsh_Rela; -typedef Elf32_Sword elfsh_Sword; -typedef Elf32_Verneed elfsh_Verneed; -typedef Elf32_Vernaux elfsh_Vernaux; -typedef Elf32_Verdef elfsh_Verdef; -typedef Elf32_Verdaux elfsh_Verdaux; - -/* We always want to manipulate 32bits in this build */ -typedef int32_t elfsh_SAddr; - -#define ELFSH_ST_BIND ELF32_ST_BIND -#define ELFSH_ST_TYPE ELF32_ST_TYPE -#define ELFSH_ST_INFO ELF32_ST_INFO -#define ELFSH_ST_VISIBILITY ELF32_ST_VISIBILITY -#define ELFSH_R_SYM ELF32_R_SYM -#define ELFSH_R_TYPE ELF32_R_TYPE -#define ELFSH_R_INFO ELF32_R_INFO -#define ELFSH_M_SYM ELF32_M_SYM -#define ELFSH_M_SIZE ELF32_M_SIZE -#define ELFSH_M_INFO ELF32_M_INFO - -#define XFMT "0x%08X" -#define AFMT "%08X" -#define UFMT "%08u" -#define DFMT "%08d" -#define RDFMT "%d" - - #define swaplong(x) swap32(x) - -#endif /* BITS */ - -/** - * MIPS reginfo structure - */ -typedef struct -{ - elfsh_Word ri_gprmask; - elfsh_Word ri_cprmask[4]; - elfsh_Sword ri_gp_value; -} elfsh_RegInfo; diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-cray.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-cray.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-cray.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-cray.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/* -** -** Compatibility with the CRAY architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2005 jfv -** -** -** $Id$ -** -*/ - - -#ifndef EM_SVX - #define EM_SVX 73 -#endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-hppa.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-hppa.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-hppa.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-hppa.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,568 +0,0 @@ -/* -** -** Compatibility with the HPPA architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2004 jfv -** -** -** $Id$ -** -*/ - -/* Legal values for e_flags field of Elf32_Ehdr. */ - -#ifndef EF_PARISC_TRAPNIL -#define EF_PARISC_TRAPNIL 0x00010000 /* Trap nil pointer dereference. */ -#endif - -#ifndef EF_PARISC_EXT -#define EF_PARISC_EXT 0x00020000 /* Program uses arch. extensions. */ -#endif - -#ifndef EF_PARISC_LSB -#define EF_PARISC_LSB 0x00040000 /* Program expects little endian. */ -#endif - -#ifndef EF_PARISC_WIDE -#define EF_PARISC_WIDE 0x00080000 /* Program expects wide mode. */ -#endif - -#ifndef EF_PARISC_NO_KABP -#define EF_PARISC_NO_KABP 0x00100000 /* No kernel assisted branch - prediction. */ -#endif - -#ifndef EF_PARISC_LAZYSWAP -#define EF_PARISC_LAZYSWAP 0x00400000 /* Allow lazy swapping. */ -#endif - -#ifndef EF_PARISC_ARCH -#define EF_PARISC_ARCH 0x0000ffff /* Architecture version. */ -#endif - -/* Defined values for `e_flags & EF_PARISC_ARCH' are: */ - -#ifndef EFA_PARISC_1_0 -#define EFA_PARISC_1_0 0x020b /* PA-RISC 1.0 big-endian. */ -#endif - -#ifndef EFA_PARISC_1_1 -#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */ -#endif - -#ifndef EFA_PARISC_2_0 -#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */ -#endif - -/* Additional section indeces. */ - -#ifndef SHN_PARISC_ANSI_COMMON -#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared - symbols in ANSI C. */ -#endif - -#ifndef SHN_PARISC_HUGE_COMMON -#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */ -#endif - -/* Legal values for sh_type field of Elf32_Shdr. */ - -#ifndef SHT_PARISC_EXT -#define SHT_PARISC_EXT 0x70000000 /* Contains product specific ext. */ -#endif - -#ifndef SHT_PARISC_UNWIND -#define SHT_PARISC_UNWIND 0x70000001 /* Unwind information. */ -#endif - -#ifndef SHT_PARISC_DOC -#define SHT_PARISC_DOC 0x70000002 /* Debug info for optimized code. */ -#endif - -/* Legal values for sh_flags field of Elf32_Shdr. */ - -#ifndef SHF_PARISC_SHORT -#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */ -#endif - -#ifndef SHF_PARISC_HUGE -#define SHF_PARISC_HUGE 0x40000000 /* Section far from gp. */ -#endif - -#ifndef SHF_PARISC_SBP -#define SHF_PARISC_SBP 0x80000000 /* Static branch prediction code. */ -#endif - -/* Legal values for ST_TYPE subfield of st_info (symbol type). */ -#ifndef STT_PARISC_MILLICODE -#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */ -#endif - -#ifndef STT_HP_OPAQUE -#define STT_HP_OPAQUE (STT_LOOS + 0x1) -#endif - -#ifndef STT_HP_STUB -#define STT_HP_STUB (STT_LOOS + 0x2) -#endif - -/* HPPA relocs. */ -#ifndef R_PARISC_NONE -#define R_PARISC_NONE 0 /* No reloc. */ -#endif - -#ifndef R_PARISC_DIR32 -#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */ -#endif - -#ifndef R_PARISC_DIR21L -#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR17R -#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR17F -#define R_PARISC_DIR17F 4 /* 17 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR14R -#define R_PARISC_DIR14R 6 /* Right 14 bits of eff. address. */ -#endif - -#ifndef R_PARISC_PCREL32 -#define R_PARISC_PCREL32 9 /* 32-bit rel. address. */ -#endif - -#ifndef R_PARISC_PCREL21L -#define R_PARISC_PCREL21L 10 /* Left 21 bits of rel. address. */ -#endif - -#ifndef R_PARISC_PCREL17R -#define R_PARISC_PCREL17R 11 /* Right 17 bits of rel. address. */ -#endif - -#ifndef R_PARISC_PCREL17F -#define R_PARISC_PCREL17F 12 /* 17 bits of rel. address. */ -#endif - -#ifndef R_PARISC_PCREL14R -#define R_PARISC_PCREL14R 14 /* Right 14 bits of rel. address. */ -#endif - -#ifndef R_PARISC_DPREL21L -#define R_PARISC_DPREL21L 18 /* Left 21 bits of rel. address. */ -#endif - -#ifndef R_PARISC_DPREL14R -#define R_PARISC_DPREL14R 22 /* Right 14 bits of rel. address. */ -#endif - -#ifndef R_PARISC_GPREL21L -#define R_PARISC_GPREL21L 26 /* GP-relative, left 21 bits. */ -#endif - -#ifndef R_PARISC_GPREL14R -#define R_PARISC_GPREL14R 30 /* GP-relative, right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF21L -#define R_PARISC_LTOFF21L 34 /* LT-relative, left 21 bits. */ -#endif - -#ifndef R_PARISC_LTOFF14R -#define R_PARISC_LTOFF14R 38 /* LT-relative, right 14 bits. */ -#endif - -#ifndef R_PARISC_SECREL32 -#define R_PARISC_SECREL32 41 /* 32 bits section rel. address. */ -#endif - -#ifndef R_PARISC_SEGBASE -#define R_PARISC_SEGBASE 48 /* No relocation, set segment base. */ -#endif - -#ifndef R_PARISC_SEGREL32 -#define R_PARISC_SEGREL32 49 /* 32 bits segment rel. address. */ -#endif - -#ifndef R_PARISC_PLTOFF21L -#define R_PARISC_PLTOFF21L 50 /* PLT rel. address, left 21 bits. */ -#endif - -#ifndef R_PARISC_PLTOFF14R -#define R_PARISC_PLTOFF14R 54 /* PLT rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR32 -#define R_PARISC_LTOFF_FPTR32 57 /* 32 bits LT-rel. function pointer. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR21L -#define R_PARISC_LTOFF_FPTR21L 58 /* LT-rel. fct ptr, left 21 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR14R -#define R_PARISC_LTOFF_FPTR14R 62 /* LT-rel. fct ptr, right 14 bits. */ -#endif - -#ifndef R_PARISC_FPTR64 -#define R_PARISC_FPTR64 64 /* 64 bits function address. */ -#endif - -#ifndef R_PARISC_PLABEL32 -#define R_PARISC_PLABEL32 65 /* 32 bits function address. */ -#endif - -#ifndef R_PARISC_PCREL64 -#define R_PARISC_PCREL64 72 /* 64 bits PC-rel. address. */ -#endif - -#ifndef R_PARISC_PCREL22F -#define R_PARISC_PCREL22F 74 /* 22 bits PC-rel. address. */ -#endif - -#ifndef R_PARISC_PCREL14WR -#define R_PARISC_PCREL14WR 75 /* PC-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_PCREL14DR -#define R_PARISC_PCREL14DR 76 /* PC rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_PCREL16F -#define R_PARISC_PCREL16F 77 /* 16 bits PC-rel. address. */ -#endif - -#ifndef R_PARISC_PCREL16WF -#define R_PARISC_PCREL16WF 78 /* 16 bits PC-rel. address. */ -#endif - -#ifndef R_PARISC_PCREL16DF -#define R_PARISC_PCREL16DF 79 /* 16 bits PC-rel. address. */ -#endif - -#ifndef R_PARISC_DIR64 -#define R_PARISC_DIR64 80 /* 64 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR14WR -#define R_PARISC_DIR14WR 83 /* 14 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR14DR -#define R_PARISC_DIR14DR 84 /* 14 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR16F -#define R_PARISC_DIR16F 85 /* 16 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR16WF -#define R_PARISC_DIR16WF 86 /* 16 bits of eff. address. */ -#endif - -#ifndef R_PARISC_DIR16DF -#define R_PARISC_DIR16DF 87 /* 16 bits of eff. address. */ -#endif - -#ifndef R_PARISC_GPREL64 -#define R_PARISC_GPREL64 88 /* 64 bits of GP-rel. address. */ -#endif - -#ifndef R_PARISC_GPREL14WR -#define R_PARISC_GPREL14WR 91 /* GP-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_GPREL14DR -#define R_PARISC_GPREL14DR 92 /* GP-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_GPREL16F -#define R_PARISC_GPREL16F 93 /* 16 bits GP-rel. address. */ -#endif - -#ifndef R_PARISC_GPREL16WF -#define R_PARISC_GPREL16WF 94 /* 16 bits GP-rel. address. */ -#endif - -#ifndef R_PARISC_GPREL16DF -#define R_PARISC_GPREL16DF 95 /* 16 bits GP-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF64 -#define R_PARISC_LTOFF64 96 /* 64 bits LT-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF14WR -#define R_PARISC_LTOFF14WR 99 /* LT-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF14DR -#define R_PARISC_LTOFF14DR 100 /* LT-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF16F -#define R_PARISC_LTOFF16F 101 /* 16 bits LT-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF16WF -#define R_PARISC_LTOFF16WF 102 /* 16 bits LT-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF16DF -#define R_PARISC_LTOFF16DF 103 /* 16 bits LT-rel. address. */ -#endif - -#ifndef R_PARISC_SECREL64 -#define R_PARISC_SECREL64 104 /* 64 bits section rel. address. */ -#endif - -#ifndef R_PARISC_SEGREL64 -#define R_PARISC_SEGREL64 112 /* 64 bits segment rel. address. */ -#endif - -#ifndef R_PARISC_PLTOFF14WR -#define R_PARISC_PLTOFF14WR 115 /* PLT-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_PLTOFF14DR -#define R_PARISC_PLTOFF14DR 116 /* PLT-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_PLTOFF16F -#define R_PARISC_PLTOFF16F 117 /* 16 bits LT-rel. address. */ -#endif - -#ifndef R_PARISC_PLTOFF16WF -#define R_PARISC_PLTOFF16WF 118 /* 16 bits PLT-rel. address. */ -#endif - -#ifndef R_PARISC_PLTOFF16DF -#define R_PARISC_PLTOFF16DF 119 /* 16 bits PLT-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR64 -#define R_PARISC_LTOFF_FPTR64 120 /* 64 bits LT-rel. function ptr. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR14WR -#define R_PARISC_LTOFF_FPTR14WR 123 /* LT-rel. fct. ptr., right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR14DR -#define R_PARISC_LTOFF_FPTR14DR 124 /* LT-rel. fct. ptr., right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR16F -#define R_PARISC_LTOFF_FPTR16F 125 /* 16 bits LT-rel. function ptr. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR16WF -#define R_PARISC_LTOFF_FPTR16WF 126 /* 16 bits LT-rel. function ptr. */ -#endif - -#ifndef R_PARISC_LTOFF_FPTR16DF -#define R_PARISC_LTOFF_FPTR16DF 127 /* 16 bits LT-rel. function ptr. */ -#endif - -#ifndef R_PARISC_LORESERVE -#define R_PARISC_LORESERVE 128 -#endif - -#ifndef R_PARISC_COPY -#define R_PARISC_COPY 128 /* Copy relocation. */ -#endif - -#ifndef R_PARISC_IPLT -#define R_PARISC_IPLT 129 /* Dynamic reloc, imported PLT */ -#endif - -#ifndef R_PARISC_EPLT -#define R_PARISC_EPLT 130 /* Dynamic reloc, exported PLT */ -#endif - -#ifndef R_PARISC_TPREL32 -#define R_PARISC_TPREL32 153 /* 32 bits TP-rel. address. */ -#endif - -#ifndef R_PARISC_TPREL21L -#define R_PARISC_TPREL21L 154 /* TP-rel. address, left 21 bits. */ -#endif - -#ifndef R_PARISC_TPREL14R -#define R_PARISC_TPREL14R 158 /* TP-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_TP21L -#define R_PARISC_LTOFF_TP21L 162 /* LT-TP-rel. address, left 21 bits. */ -#endif - -#ifndef R_PARISC_LTOFF_TP14R -#define R_PARISC_LTOFF_TP14R 166 /* LT-TP-rel. address, right 14 bits.*/ -#endif - -#ifndef R_PARISC_LTOFF_TP14F -#define R_PARISC_LTOFF_TP14F 167 /* 14 bits LT-TP-rel. address. */ -#endif - -#ifndef R_PARISC_TPREL64 -#define R_PARISC_TPREL64 216 /* 64 bits TP-rel. address. */ -#endif - -#ifndef R_PARISC_TPREL14WR -#define R_PARISC_TPREL14WR 219 /* TP-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_TPREL14DR -#define R_PARISC_TPREL14DR 220 /* TP-rel. address, right 14 bits. */ -#endif - -#ifndef R_PARISC_TPREL16F -#define R_PARISC_TPREL16F 221 /* 16 bits TP-rel. address. */ -#endif - -#ifndef R_PARISC_TPREL16WF -#define R_PARISC_TPREL16WF 222 /* 16 bits TP-rel. address. */ -#endif - -#ifndef R_PARISC_TPREL16DF -#define R_PARISC_TPREL16DF 223 /* 16 bits TP-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF_TP64 -#define R_PARISC_LTOFF_TP64 224 /* 64 bits LT-TP-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF_TP14WR -#define R_PARISC_LTOFF_TP14WR 227 /* LT-TP-rel. address, right 14 bits.*/ -#endif - -#ifndef R_PARISC_LTOFF_TP14DR -#define R_PARISC_LTOFF_TP14DR 228 /* LT-TP-rel. address, right 14 bits.*/ -#endif - -#ifndef R_PARISC_LTOFF_TP16F -#define R_PARISC_LTOFF_TP16F 229 /* 16 bits LT-TP-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF_TP16WF -#define R_PARISC_LTOFF_TP16WF 230 /* 16 bits LT-TP-rel. address. */ -#endif - -#ifndef R_PARISC_LTOFF_TP16DF -#define R_PARISC_LTOFF_TP16DF 231 /* 16 bits LT-TP-rel. address. */ -#endif - -#ifndef R_PARISC_HIRESERVE -#define R_PARISC_HIRESERVE 255 -#endif - -/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr. */ - -#ifndef PT_HP_TLS -#define PT_HP_TLS (PT_LOOS + 0x0) -#endif - -#ifndef PT_HP_CORE_NONE -#define PT_HP_CORE_NONE (PT_LOOS + 0x1) -#endif - -#ifndef PT_HP_CORE_VERSION -#define PT_HP_CORE_VERSION (PT_LOOS + 0x2) -#endif - -#ifndef PT_HP_CORE_KERNEL -#define PT_HP_CORE_KERNEL (PT_LOOS + 0x3) -#endif - -#ifndef PT_HP_CORE_COMM -#define PT_HP_CORE_COMM (PT_LOOS + 0x4) -#endif - -#ifndef PT_HP_CORE_PROC -#define PT_HP_CORE_PROC (PT_LOOS + 0x5) -#endif - -#ifndef PT_HP_CORE_LOADABLE -#define PT_HP_CORE_LOADABLE (PT_LOOS + 0x6) -#endif - -#ifndef PT_HP_CORE_STACK -#define PT_HP_CORE_STACK (PT_LOOS + 0x7) -#endif - -#ifndef PT_HP_CORE_SHM -#define PT_HP_CORE_SHM (PT_LOOS + 0x8) -#endif - -#ifndef PT_HP_CORE_MMF -#define PT_HP_CORE_MMF (PT_LOOS + 0x9) -#endif - -#ifndef PT_HP_PARALLEL -#define PT_HP_PARALLEL (PT_LOOS + 0x10) -#endif - -#ifndef PT_HP_FASTBIND -#define PT_HP_FASTBIND (PT_LOOS + 0x11) -#endif - -#ifndef PT_HP_OPT_ANNOT -#define PT_HP_OPT_ANNOT (PT_LOOS + 0x12) -#endif - -#ifndef PT_HP_HSL_ANNOT -#define PT_HP_HSL_ANNOT (PT_LOOS + 0x13) -#endif - -#ifndef PT_HP_STACK -#define PT_HP_STACK (PT_LOOS + 0x14) -#endif - -#ifndef PT_PARISC_ARCHEXT -#define PT_PARISC_ARCHEXT 0x70000000 -#endif - -#ifndef PT_PARISC_UNWIND -#define PT_PARISC_UNWIND 0x70000001 -#endif - -/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr. */ - -#ifndef PF_PARISC_SBP -#define PF_PARISC_SBP 0x08000000 -#endif - -#ifndef PF_HP_PAGE_SIZE -#define PF_HP_PAGE_SIZE 0x00100000 -#endif - -#ifndef PF_HP_FAR_SHARED -#define PF_HP_FAR_SHARED 0x00200000 -#endif - -#ifndef PF_HP_NEAR_SHARED -#define PF_HP_NEAR_SHARED 0x00400000 -#endif - -#ifndef PF_HP_CODE -#define PF_HP_CODE 0x01000000 -#endif - -#ifndef PF_HP_MODIFY -#define PF_HP_MODIFY 0x02000000 -#endif - -#ifndef PF_HP_LAZYSWAP -#define PF_HP_LAZYSWAP 0x04000000 -#endif - -#ifndef PF_HP_SBP -#define PF_HP_SBP 0x08000000 -#endif - - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia32.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia32.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia32.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia32.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,174 +0,0 @@ -/* -** -** Compatibility with the IA32 architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2004 yann malcom -** -** -** $Id$ -** -*/ - - -#ifndef EM_386 - #define EM_386 3 -#endif - - - -/* IA32 relocations. */ -#ifndef R_386_NONE - #define R_386_NONE 0 /* No reloc */ -#endif - -#ifndef R_386_32 - #define R_386_32 1 /* Direct 32 bit */ -#endif - -#ifndef R_386_PC32 - #define R_386_PC32 2 /* PC relative 32 bit */ -#endif - -#ifndef R_386_GOT32 - #define R_386_GOT32 3 /* 32 bit GOT entry */ -#endif - -#ifndef R_386_PLT32 - #define R_386_PLT32 4 /* 32 bit PLT address */ -#endif - -#ifndef R_386_COPY - #define R_386_COPY 5 /* Copy symbol at runtime */ -#endif - -#ifndef R_386_GLOB_DAT - #define R_386_GLOB_DAT 6 /* Create GOT entry */ -#endif - -#ifndef R_386_JMP_SLOT - #define R_386_JMP_SLOT 7 /* Create PLT entry */ -#endif - -#ifndef R_386_RELATIVE - #define R_386_RELATIVE 8 /* Adjust by program base */ -#endif - -#ifndef R_386_GOTOFF - #define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#endif - -#ifndef R_386_GOTPC - #define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ -#endif - -#ifndef R_386_32PLT - #define R_386_32PLT 11 -#endif - -#ifndef R_386_TLS_TPOFF - #define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ -#endif - -#ifndef R_386_TLS_IE - #define R_386_TLS_IE 15 /* Address of GOT entry for static TLS - block offset */ -#endif - -#ifndef R_386_TLS_GOTIE - #define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block - offset */ -#endif - -#ifndef R_386_TLS_LE - #define R_386_TLS_LE 17 /* Offset relative to static TLS - block */ -#endif - -#ifndef R_386_TLS_GD - #define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of - general dynamic thread local data */ -#endif - -#ifndef R_386_TLS_LDM - #define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of - local dynamic thread local data - in LE code */ -#endif - -#ifndef R_386_16 - #define R_386_16 20 -#endif - -#ifndef R_386_PC16 - #define R_386_PC16 21 -#endif - -#ifndef R_386_8 - #define R_386_8 22 -#endif - -#ifndef R_386_PC8 - #define R_386_PC8 23 -#endif - -#ifndef R_386_TLS_GD_32 - #define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic - thread local data */ -#endif - -#ifndef R_386_TLS_GD_PUSH - #define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ -#endif - -#ifndef R_386_TLS_GD_CALL - #define R_386_TLS_GD_CALL 26 /* Relocation for call to - __tls_get_addr() */ -#endif - -#ifndef R_386_TLS_GD_POP - #define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ -#endif - -#ifndef R_386_TLS_LDM_32 - #define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic - thread local data in LE code */ -#endif - -#ifndef R_386_TLS_LDM_PUSH - #define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ -#endif - -#ifndef R_386_TLS_LDM_CALL - #define R_386_TLS_LDM_CALL 30 /* Relocation for call to - __tls_get_addr() in LDM code */ -#endif - -#ifndef R_386_TLS_LDM_POP - #define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ -#endif - -#ifndef R_386_TLS_LDO_32 - #define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ -#endif - -#ifndef R_386_TLS_IE_32 - #define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS - block offset */ -#endif - -#ifndef R_386_TLS_LE_32 - #define R_386_TLS_LE_32 34 /* Negated offset relative to static - TLS block */ -#endif - -#ifndef R_386_TLS_DTPMOD32 - #define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ -#endif - -#ifndef R_386_TLS_DTPOFF32 - #define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ -#endif - - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia64.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia64.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia64.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ia64.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,337 +0,0 @@ -/* -** -** Compatibility with IA64 -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:35:27 2004 jfv -** -** -** $Id$ -** -*/ - -/* IA-64 relocations. */ -#ifndef R_IA64_NONE - #define R_IA64_NONE 0x00 /* none */ -#endif - -#ifndef R_IA64_IMM14 - #define R_IA64_IMM14 0x21 /* symbol + addend, add imm14 */ -#endif - -#ifndef R_IA64_IMM22 - #define R_IA64_IMM22 0x22 /* symbol + addend, add imm22 */ -#endif - -#ifndef R_IA64_IMM64 - #define R_IA64_IMM64 0x23 /* symbol + addend, mov imm64 */ -#endif - -#ifndef R_IA64_DIR32MSB - #define R_IA64_DIR32MSB 0x24 /* symbol + addend, data4 MSB */ -#endif - -#ifndef R_IA64_DIR32LSB - #define R_IA64_DIR32LSB 0x25 /* symbol + addend, data4 LSB */ -#endif - -#ifndef R_IA64_DIR64MSB - #define R_IA64_DIR64MSB 0x26 /* symbol + addend, data8 MSB */ -#endif - -#ifndef R_IA64_DIR64LSB - #define R_IA64_DIR64LSB 0x27 /* symbol + addend, data8 LSB */ -#endif - -#ifndef R_IA64_GPREL22 - #define R_IA64_GPREL22 0x2a /* @gprel(sym + add), add imm22 */ -#endif - -#ifndef R_IA64_GPREL64I - #define R_IA64_GPREL64I 0x2b /* @gprel(sym + add), mov imm64 */ -#endif - -#ifndef R_IA64_GPREL32MSB - #define R_IA64_GPREL32MSB 0x2c /* @gprel(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_GPREL32LSB - #define R_IA64_GPREL32LSB 0x2d /* @gprel(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_GPREL64MSB - #define R_IA64_GPREL64MSB 0x2e /* @gprel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_GPREL64LSB - #define R_IA64_GPREL64LSB 0x2f /* @gprel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_LTOFF22 - #define R_IA64_LTOFF22 0x32 /* @ltoff(sym + add), add imm22 */ -#endif - -#ifndef R_IA64_LTOFF64I - #define R_IA64_LTOFF64I 0x33 /* @ltoff(sym + add), mov imm64 */ -#endif - -#ifndef R_IA64_PLTOFF22 - #define R_IA64_PLTOFF22 0x3a /* @pltoff(sym + add), add imm22 */ -#endif - -#ifndef R_IA64_PLTOFF64I - #define R_IA64_PLTOFF64I 0x3b /* @pltoff(sym + add), mov imm64 */ -#endif - -#ifndef R_IA64_PLTOFF64MSB - #define R_IA64_PLTOFF64MSB 0x3e /* @pltoff(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_PLTOFF64LSB - #define R_IA64_PLTOFF64LSB 0x3f /* @pltoff(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_FPTR64I - #define R_IA64_FPTR64I 0x43 /* @fptr(sym + add), mov imm64 */ -#endif - -#ifndef R_IA64_FPTR32MSB - #define R_IA64_FPTR32MSB 0x44 /* @fptr(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_FPTR32LSB - #define R_IA64_FPTR32LSB 0x45 /* @fptr(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_FPTR64MSB - #define R_IA64_FPTR64MSB 0x46 /* @fptr(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_FPTR64LSB - #define R_IA64_FPTR64LSB 0x47 /* @fptr(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_PCREL60B - #define R_IA64_PCREL60B 0x48 /* @pcrel(sym + add), brl */ -#endif - -#ifndef R_IA64_PCREL21B - #define R_IA64_PCREL21B 0x49 /* @pcrel(sym + add), ptb, call */ -#endif - -#ifndef R_IA64_PCREL21M - #define R_IA64_PCREL21M 0x4a /* @pcrel(sym + add), chk.s */ -#endif - -#ifndef R_IA64_PCREL21F - #define R_IA64_PCREL21F 0x4b /* @pcrel(sym + add), fchkf */ -#endif - -#ifndef R_IA64_PCREL32MSB - #define R_IA64_PCREL32MSB 0x4c /* @pcrel(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_PCREL32LSB - #define R_IA64_PCREL32LSB 0x4d /* @pcrel(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_PCREL64MSB - #define R_IA64_PCREL64MSB 0x4e /* @pcrel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_PCREL64LSB - #define R_IA64_PCREL64LSB 0x4f /* @pcrel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_LTOFF_FPTR22 - #define R_IA64_LTOFF_FPTR22 0x52 /* @ltoff(@fptr(s+a)), imm22 */ -#endif - -#ifndef R_IA64_LTOFF_FPTR64I - #define R_IA64_LTOFF_FPTR64I 0x53 /* @ltoff(@fptr(s+a)), imm64 */ -#endif - -#ifndef R_IA64_LTOFF_FPTR32MSB - #define R_IA64_LTOFF_FPTR32MSB 0x54 /* @ltoff(@fptr(s+a)), data4 MSB */ -#endif - -#ifndef R_IA64_LTOFF_FPTR32LSB - #define R_IA64_LTOFF_FPTR32LSB 0x55 /* @ltoff(@fptr(s+a)), data4 LSB */ -#endif - -#ifndef R_IA64_LTOFF_FPTR64MSB - #define R_IA64_LTOFF_FPTR64MSB 0x56 /* @ltoff(@fptr(s+a)), data8 MSB */ -#endif - -#ifndef R_IA64_LTOFF_FPTR64LSB - #define R_IA64_LTOFF_FPTR64LSB 0x57 /* @ltoff(@fptr(s+a)), data8 LSB */ -#endif - -#ifndef R_IA64_SEGREL32MSB - #define R_IA64_SEGREL32MSB 0x5c /* @segrel(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_SEGREL32LSB - #define R_IA64_SEGREL32LSB 0x5d /* @segrel(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_SEGREL64MSB - #define R_IA64_SEGREL64MSB 0x5e /* @segrel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_SEGREL64LSB - #define R_IA64_SEGREL64LSB 0x5f /* @segrel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_SECREL32MSB - #define R_IA64_SECREL32MSB 0x64 /* @secrel(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_SECREL32LSB - #define R_IA64_SECREL32LSB 0x65 /* @secrel(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_SECREL64MSB - #define R_IA64_SECREL64MSB 0x66 /* @secrel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_SECREL64LSB - #define R_IA64_SECREL64LSB 0x67 /* @secrel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_REL32MSB - #define R_IA64_REL32MSB 0x6c /* data 4 + REL */ -#endif - -#ifndef R_IA64_REL32LSB - #define R_IA64_REL32LSB 0x6d /* data 4 + REL */ -#endif - -#ifndef R_IA64_REL64MSB - #define R_IA64_REL64MSB 0x6e /* data 8 + REL */ -#endif - -#ifndef R_IA64_REL64LSB - #define R_IA64_REL64LSB 0x6f /* data 8 + REL */ -#endif - -#ifndef R_IA64_LTV32MSB - #define R_IA64_LTV32MSB 0x74 /* symbol + addend, data4 MSB */ -#endif - -#ifndef R_IA64_LTV32LSB - #define R_IA64_LTV32LSB 0x75 /* symbol + addend, data4 LSB */ -#endif - -#ifndef R_IA64_LTV64MSB - #define R_IA64_LTV64MSB 0x76 /* symbol + addend, data8 MSB */ -#endif - -#ifndef R_IA64_LTV64LSB - #define R_IA64_LTV64LSB 0x77 /* symbol + addend, data8 LSB */ -#endif - -#ifndef R_IA64_PCREL21BI - #define R_IA64_PCREL21BI 0x79 /* @pcrel(sym + add), 21bit inst */ -#endif - -#ifndef R_IA64_PCREL22 - #define R_IA64_PCREL22 0x7a /* @pcrel(sym + add), 22bit inst */ -#endif - -#ifndef R_IA64_PCREL64I - #define R_IA64_PCREL64I 0x7b /* @pcrel(sym + add), 64bit inst */ -#endif - -#ifndef R_IA64_IPLTMSB - #define R_IA64_IPLTMSB 0x80 /* dynamic reloc, imported PLT, MSB */ -#endif - -#ifndef R_IA64_IPLTLSB - #define R_IA64_IPLTLSB 0x81 /* dynamic reloc, imported PLT, LSB */ -#endif - -#ifndef R_IA64_COPY - #define R_IA64_COPY 0x84 /* copy relocation */ -#endif - -#ifndef R_IA64_SUB - #define R_IA64_SUB 0x85 /* Addend and symbol difference */ -#endif - -#ifndef R_IA64_LTOFF22X - #define R_IA64_LTOFF22X 0x86 /* LTOFF22, relaxable. */ -#endif - -#ifndef R_IA64_LDXMOV - #define R_IA64_LDXMOV 0x87 /* Use of LTOFF22X. */ -#endif - -#ifndef R_IA64_TPREL14 - #define R_IA64_TPREL14 0x91 /* @tprel(sym + add), imm14 */ -#endif - -#ifndef R_IA64_TPREL22 - #define R_IA64_TPREL22 0x92 /* @tprel(sym + add), imm22 */ -#endif - -#ifndef R_IA64_TPREL64I - #define R_IA64_TPREL64I 0x93 /* @tprel(sym + add), imm64 */ -#endif - -#ifndef R_IA64_TPREL64MSB - #define R_IA64_TPREL64MSB 0x96 /* @tprel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_TPREL64LSB - #define R_IA64_TPREL64LSB 0x97 /* @tprel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_LTOFF_TPREL22 - #define R_IA64_LTOFF_TPREL22 0x9a /* @ltoff(@tprel(s+a)), imm2 */ -#endif - -#ifndef R_IA64_DTPMOD64MSB - #define R_IA64_DTPMOD64MSB 0xa6 /* @dtpmod(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_DTPMOD64LSB - #define R_IA64_DTPMOD64LSB 0xa7 /* @dtpmod(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_LTOFF_DTPMOD22 - #define R_IA64_LTOFF_DTPMOD22 0xaa /* @ltoff(@dtpmod(sym + add)), imm22 */ -#endif - -#ifndef R_IA64_DTPREL14 - #define R_IA64_DTPREL14 0xb1 /* @dtprel(sym + add), imm14 */ -#endif - -#ifndef R_IA64_DTPREL22 - #define R_IA64_DTPREL22 0xb2 /* @dtprel(sym + add), imm22 */ -#endif - -#ifndef R_IA64_DTPREL64I - #define R_IA64_DTPREL64I 0xb3 /* @dtprel(sym + add), imm64 */ -#endif - -#ifndef R_IA64_DTPREL32MSB - #define R_IA64_DTPREL32MSB 0xb4 /* @dtprel(sym + add), data4 MSB */ -#endif - -#ifndef R_IA64_DTPREL32LSB - #define R_IA64_DTPREL32LSB 0xb5 /* @dtprel(sym + add), data4 LSB */ -#endif - -#ifndef R_IA64_DTPREL64MSB - #define R_IA64_DTPREL64MSB 0xb6 /* @dtprel(sym + add), data8 MSB */ -#endif - -#ifndef R_IA64_DTPREL64LSB - #define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ -#endif - -#ifndef R_IA64_LTOFF_DTPREL22 - #define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ -#endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-internal.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-internal.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-internal.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-internal.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** libelfsh-internal.h for elfsh -** -** Started on Wed Jan 1 07:51:24 2003 jfv -** Last update Thu Mar 20 06:19:53 2003 jfv -** -** $Id$ -** -*/ - -#ifndef __LIBELFSH_INTERN_ - #define __LIBELFSH_INTERN_ - -// To remove one day -#define ELFSH_SETERROR(msg, ret) ELFSH_PROFILE_ERR(__FILE__, __FUNCTION__, __LINE__, msg, ret) - -#endif /* __LIBELFSH_INTERN_ */ - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-irix.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-irix.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-irix.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-irix.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,461 +0,0 @@ -/* -** libelfsh-irix.h -** -** Various undefined macros on IRIX -** -** Last update Mon Aug 23 05:05:27 2005 ym -** -** $Id$ -** -*/ - -#include -#include - -#ifndef STT_TLS - #define STT_TLS 6 - #undef STT_NUM - #define STT_NUM 7 -#endif - - -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ - - - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - - -/* Legal values for vna_flags. */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* pi3 test */ -typedef struct -{ - Elf32_Word n_namesz; /* Length of the note's name. */ - Elf32_Word n_descsz; /* Length of the note's descriptor. */ - Elf32_Word n_type; /* Type of the note. */ -} Elf32_Nhdr; - -typedef struct -{ - Elf64_Word n_namesz; /* Length of the note's name. */ - Elf64_Word n_descsz; /* Length of the note's descriptor. */ - Elf64_Word n_type; /* Type of the note. */ -} Elf64_Nhdr; - - -#ifndef DT_VERDEFNUM - #define DT_VERDEFNUM 0x6ffffffd -#endif -#ifndef DT_VERNEEDNUM - #define DT_VERNEEDNUM 0x6fffffff -#endif -#ifndef DT_VERNEED - #define DT_VERNEED 0x6ffffffe -#endif -#ifndef DT_VERSYM - #define DT_VERSYM 0x6ffffff0 -#endif -#ifndef DT_VERDEF - #define DT_VERDEF 0x6ffffffc -#endif - -#ifndef STT_COMMON /* undefined on debian */ - #define STT_COMMON 5 -#endif - -#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */ -#define NT_FPREGSET 2 /* Contains copy of fpregset struct */ -#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */ -#define NT_PRXREG 4 /* Contains copy of prxregset struct */ -#define NT_TASKSTRUCT 4 /* Contains copy of task structure */ -#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */ -#define NT_AUXV 6 /* Contains copy of auxv array */ -#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */ -#define NT_ASRS 8 /* Contains copy of asrset struct */ -#define NT_PSTATUS 10 /* Contains copy of pstatus struct */ -#define NT_PSINFO 13 /* Contains copy of psinfo struct */ -#define NT_PRCRED 14 /* Contains copy of prcred struct */ -#define NT_UTSNAME 15 /* Contains copy of utsname struct */ -#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */ -#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */ -#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*/ - -#ifndef SHF_MERGE - #define SHF_MERGE (1 << 4) /* Might be merged */ -#endif - -#ifndef SHF_STRINGS - #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ -#endif - -#ifndef SHF_INFO_LINK - #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ -#endif - -#ifndef SHF_LINK_ORDER - #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ -#endif - - -#define EM_ARM 40 - - -#ifndef DF_P1_LAZYLOAD - #define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#endif - -#ifndef DF_P1_GROUPPERM - #define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not */ -#endif - -#ifndef DF_ORIGIN - #define DF_ORIGIN 0x00000001 /* Object may use df_origin */ -#endif - -#ifndef DF_SYMBOLIC - #define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#endif - -#ifndef DF_TEXTREL - #define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#endif - -#ifndef DF_BIND_NOW - #define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ -#endif - -#ifndef DF_1_NOW - #define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#endif - -#ifndef DF_1_GLOBAL - #define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#endif - -#ifndef DF_1_GROUP - #define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#endif - -#ifndef DF_1_NODELETE - #define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#endif - -#ifndef DF_1_LOADFLTR - #define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#endif - -#ifndef DF_1_INITFIRST - #define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#endif - -#ifndef DF_1_NOOPEN - #define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#endif - -#ifndef DF_1_ORIGIN - #define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#endif - -#ifndef DF_1_DIRECT - #define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#endif - -#ifndef DF_1_TRANS - #define DF_1_TRANS 0x00000200 -#endif - -#ifndef DF_1_INTERPOSE - #define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#endif - -#ifndef DF_1_NODEFLIB - #define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#endif - -#ifndef DF_1_NODUMP - #define DF_1_NODUMP 0x00001000 -#endif - -#ifndef DF_1_CONFALT - #define DF_1_CONFALT 0x00002000 -#endif - -#ifndef DF_1_ENDFILTEE - #define DF_1_ENDFILTEE 0x00004000 -#endif - -#ifndef DTF_1_PARINIT - #define DTF_1_PARINIT 0x00000001 -#endif - -#ifndef DTF_1_CONFEXP - #define DTF_1_CONFEXP 0x00000002 -#endif - -#ifndef O_SYNC - #define O_SYNC O_FSYNC -#endif -#ifndef DT_BIND_NOW - #define DT_BIND_NOW 24 -#endif -#ifndef DT_SYMINENT - #define DT_SYMINIENT 0x6ffffdff -#endif -#ifndef DT_FLAGS - #define DT_FLAGS 30 -#endif -#ifndef DT_VERDEFNUM - #define DT_VERDEFNUM 0x6ffffffd -#endif -#ifndef DT_VERNEEDNUM - #define DT_VERNEEDNUM 0x6fffffff -#endif -#ifndef DT_PLTADSZ - #define DT_PLTPADSZ 0x6ffffdf9 -#endif -#ifndef DT_VERDEF - #define DT_VERDEF 0x6ffffffc -#endif -#ifndef DT_SYMINENT - #define DT_SYMINENT 0x6ffffdff -#endif -#ifndef DT_RELACOUNT - #define DT_RELACOUNT 0x6ffffff9 -#endif -#ifndef DT_RELCOUNT - #define DT_RELCOUNT 0x6ffffffa -#endif -#ifndef DT_SYMINFO - #define DT_SYMINFO 0x6ffffeff -#endif -#ifndef DT_SYMINSZ - #define DT_SYMINSZ 0x6ffffdfe -#endif -#ifndef DT_CHECKSUM - #define DT_CHECKSUM 0x6ffffdf8 -#endif -#ifndef DT_VERSYM - #define DT_VERSYM 0x6ffffff0 -#endif -#ifndef DT_MOVESZ - #define DT_MOVESZ 0x6ffffdfb -#endif -#ifndef DT_VERNEED - #define DT_VERNEED 0x6ffffffe -#endif -#ifndef DT_FILTER - #define DT_FILTER 0x7fffffff -#endif -#ifndef DT_MOVEENT - #define DT_MOVEENT 0x6ffffdfa -#endif -#ifndef DT_AUXILIARY - #define DT_AUXILIARY 0x7ffffffd -#endif -#ifndef DT_INIT_ARRAY - #define DT_INIT_ARRAY 25 -#endif -#ifndef DT_FINI_ARRAY - #define DT_FINI_ARRAY 26 -#endif -#ifndef DT_INIT_ARRAYSZ - #define DT_INIT_ARRAYSZ 27 -#endif -#ifndef DT_FINI_ARRAYSZ - #define DT_FINI_ARRAYSZ 28 -#endif -#ifndef DT_FLAGS_1 - #define DT_FLAGS_1 0x6ffffffb -#endif -#ifndef DT_FEATURE_1 - #define DT_FEATURE_1 0x6ffffdfc -#endif -#ifndef DT_POSFLAG_1 - #define DT_POSFLAG_1 0x6ffffdfd -#endif - -#ifndef DT_RUNPATH - #define DT_RUNPATH 29 /* Library search path */ -#endif - -#ifndef DT_ENCODING - #define DT_ENCODING 32 /* Start of encoded range */ -#endif - -#ifndef DT_PREINIT_ARRAY - #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#endif - -#ifndef DT_PREINIT_ARRAYSZ - #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#endif - - -#ifndef DT_NUM - #define DT_NUM 34 /* Number used */ -#endif - -#if !defined(PT_LOOS) - #define PT_LOOS 0x60000000 /* Start of OS-specific */ -#endif - -#if !defined(PT_GNU_EH_FRAME) - #define PT_GNU_EH_FRAME 0x6474e550 -#endif - -#define ELF32_ST_VISIBILITY(o) ((o) & 0x03) - - -extern char **environ; - -/** - * IRIX doesn't have implementation of function setenv() so we must write own... - * @param name - name of environment variable to set - * @param value - value for environment variable... - * @param overwrite - if overwrite is zero, then the value of name is not changed - * @return - return -1 on error - */ - -int setenv(const char *name, - const char *value, - int overwrite) -{ - char *ptr=NULL; - unsigned int len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* +2 for chars '=' and '\0' */ - len = strlen(name)+strlen(value)+2; - - if (!overwrite) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, ptr, sizeof(char*) * len, -1); - snprintf(ptr,len,"%s=%s",name,value); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (int)(putenv(ptr))); -} - - -/** - * Small wrapper to allow dladdr() usage on IRIX - */ -int dladdr(void *address, Dl_info *dl) { - void *v; - v = _rld_new_interface(_RLD_DLADDR,address,dl); - return (int)v; -} diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-mips.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-mips.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-mips.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-mips.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,433 +0,0 @@ -/* -** -** Compatibility with the MIPS architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2004 jfv -** -** -** $Id$ -** -*/ - - -#ifndef EM_MIPS - #define EM_MIPS 8 -#endif - -#ifndef EM_MIPS_RS3_LE - #define EM_MIPS_RS3_LE 10 -#endif - -#ifndef EM_MIPS_X - #define EM_MIPS_X 51 /* Stanford MIPS-X */ -#endif - -/* MIPS relocations. */ -#ifndef R_MIPS_NONE - #define R_MIPS_NONE 0 /* No reloc */ -#endif - -#ifndef R_MIPS_16 - #define R_MIPS_16 1 /* Direct 16 bit */ -#endif - -#ifndef R_MIPS_32 - #define R_MIPS_32 2 /* Direct 32 bit */ -#endif - -#ifndef R_MIPS_REL32 - #define R_MIPS_REL32 3 /* PC relative 32 bit */ -#endif - -#ifndef R_MIPS_26 - #define R_MIPS_26 4 /* Direct 26 bit shifted */ -#endif - -#ifndef R_MIPS_HI16 - #define R_MIPS_HI16 5 /* High 16 bit */ -#endif - -#ifndef R_MIPS_LO16 - #define R_MIPS_LO16 6 /* Low 16 bit */ -#endif - -#ifndef R_MIPS_GPREL16 - #define R_MIPS_GPREL16 7 /* GP relative 16 bit */ -#endif - -#ifndef R_MIPS_LITERAL - #define R_MIPS_LITERAL 8 /* 16 bit literal entry */ -#endif - -#ifndef R_MIPS_GOT16 - #define R_MIPS_GOT16 9 /* 16 bit GOT entry */ -#endif - -#ifndef R_MIPS_PC16 - #define R_MIPS_PC16 10 /* PC relative 16 bit */ -#endif - -#ifndef R_MIPS_CALL16 - #define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */ -#endif - -#ifndef R_MIPS_GPREL32 - #define R_MIPS_GPREL32 12 /* GP relative 32 bit */ -#endif - -#ifndef R_MIPS_SHIFT5 - #define R_MIPS_SHIFT5 16 -#endif - -#ifndef R_MIPS_SHIFT6 - #define R_MIPS_SHIFT6 17 -#endif - -#ifndef R_MIPS_64 - #define R_MIPS_64 18 -#endif - -#ifndef R_MIPS_GOT_DISP - #define R_MIPS_GOT_DISP 19 -#endif - -#ifndef R_MIPS_GOT_PAGE - #define R_MIPS_GOT_PAGE 20 -#endif - -#ifndef R_MIPS_GOT_OFST - #define R_MIPS_GOT_OFST 21 -#endif - -#ifndef R_MIPS_GOT_HI16 - #define R_MIPS_GOT_HI16 22 -#endif - -#ifndef R_MIPS_GOT_LO16 - #define R_MIPS_GOT_LO16 23 -#endif - -#ifndef R_MIPS_SUB - #define R_MIPS_SUB 24 -#endif - -#ifndef R_MIPS_INSERT_A - #define R_MIPS_INSERT_A 25 -#endif - -#ifndef R_MIPS_INSERT_B - #define R_MIPS_INSERT_B 26 -#endif - -#ifndef R_MIPS_DELETE - #define R_MIPS_DELETE 27 -#endif - -#ifndef R_MIPS_HIGHER - #define R_MIPS_HIGHER 28 -#endif - -#ifndef R_MIPS_HIGHEST - #define R_MIPS_HIGHEST 29 -#endif - -#ifndef R_MIPS_CALL_HI16 - #define R_MIPS_CALL_HI16 30 -#endif - -#ifndef R_MIPS_CALL_LO16 - #define R_MIPS_CALL_LO16 31 -#endif - -#ifndef R_MIPS_SCN_DISP - #define R_MIPS_SCN_DISP 32 -#endif - -#ifndef R_MIPS_REL16 - #define R_MIPS_REL16 33 -#endif - -#ifndef R_MIPS_ADD_IMMEDIATE - #define R_MIPS_ADD_IMMEDIATE 34 -#endif - -#ifndef R_MIPS_PJUMP - #define R_MIPS_PJUMP 35 -#endif - -#ifndef R_MIPS_RELGOT - #define R_MIPS_RELGOT 36 -#endif - -#ifndef R_MIPS_JALR - #define R_MIPS_JALR 37 -#endif - -#ifndef R_MIPS_NUM - #define R_MIPS_NUM 38 -#endif - -/* MIPS Dynamic Type */ - -#ifndef DT_MIPS_RLD_VERSION -#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */ -#endif - -#ifndef DT_MIPS_TIME_STAMP -#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */ -#endif - -#ifndef DT_MIPS_ICHECKSUM -#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */ -#endif - -#ifndef DT_MIPS_IVERSION -#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */ -#endif - -#ifndef DT_MIPS_FLAGS -#define DT_MIPS_FLAGS 0x70000005 /* Flags */ -#endif - -#ifndef DT_MIPS_BASE_ADDRESS -#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */ -#endif - -#ifndef DT_MIPS_MSYM -#define DT_MIPS_MSYM 0x70000007 -#endif - -#ifndef DT_MIPS_CONFLICT -#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */ -#endif - -#ifndef DT_MIPS_LIBLIST -#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */ -#endif - -#ifndef DT_MIPS_LOCAL_GOTNO -#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */ -#endif - -#ifndef DT_MIPS_CONFLICTNO -#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */ -#endif - -#ifndef DT_MIPS_LIBLISTNO -#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */ -#endif - -#ifndef DT_MIPS_SYMTABNO -#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */ -#endif - -#ifndef DT_MIPS_UNREFEXTNO -#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */ -#endif - -#ifndef DT_MIPS_GOTSYM -#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */ -#endif - -#ifndef DT_MIPS_HIPAGENO -#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */ -#endif - -#ifndef DT_MIPS_RLD_MAP -#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */ -#endif - -#ifndef DT_MIPS_DELTA_CLASS -#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */ -#endif - -#ifndef DT_MIPS_DELTA_CLASS_NO -#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in - DT_MIPS_DELTA_CLASS. */ -#endif - -#ifndef DT_MIPS_DELTA_INSTANCE -#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */ -#endif - -#ifndef DT_MIPS_DELTA_INSTANCE_NO -#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in - DT_MIPS_DELTA_INSTANCE. */ -#endif - -#ifndef DT_MIPS_DELTA_RELOC -#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */ -#endif - -#ifndef DT_MIPS_DELTA_RELOC_NO -#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in - DT_MIPS_DELTA_RELOC. */ -#endif - -#ifndef DT_MIPS_DELTA_SYM -#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta - relocations refer to. */ -#endif - -#ifndef DT_MIPS_DELTA_SYM_NO -#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in - DT_MIPS_DELTA_SYM. */ -#endif - -#ifndef DT_MIPS_DELTA_CLASSSYM -#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the - class declaration. */ -#endif - -#ifndef DT_MIPS_DELTA_CLASSSYM_NO -#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in - DT_MIPS_DELTA_CLASSSYM. */ -#endif - -#ifndef DT_MIPS_CXX_FLAGS -#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */ -#endif - -#ifndef DT_MIPS_PIXIE_INIT -#define DT_MIPS_PIXIE_INIT 0x70000023 -#endif - -#ifndef DT_MIPS_SYMBOL_LIB -#define DT_MIPS_SYMBOL_LIB 0x70000024 -#endif - -#ifndef DT_MIPS_LOCALPAGE_GOTIDX -#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025 -#endif - -#ifndef DT_MIPS_LOCAL_GOTIDX -#define DT_MIPS_LOCAL_GOTIDX 0x70000026 -#endif - -#ifndef DT_MIPS_HIDDEN_GOTIDX -#define DT_MIPS_HIDDEN_GOTIDX 0x70000027 -#endif - -#ifndef DT_MIPS_PROTECTED_GOTIDX -#define DT_MIPS_PROTECTED_GOTIDX 0x70000028 -#endif - -#ifndef DT_MIPS_OPTIONS -#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */ -#endif - -#ifndef DT_MIPS_INTERFACE -#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */ -#endif - -#ifndef DT_MIPS_DYNSTR_ALIGN -#define DT_MIPS_DYNSTR_ALIGN 0x7000002b -#endif - -#ifndef DT_MIPS_INTERFACE_SIZE -#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */ -#endif - -#ifndef DT_MIPS_RLD_TEXT_RESOLVE_ADDR -#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve - function stored in GOT. */ -#endif - -#ifndef DT_MIPS_PERF_SUFFIX -#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added - by rld on dlopen() calls. */ -#endif - -#ifndef DT_MIPS_COMPACT_SIZE -#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */ -#endif - -#ifndef DT_MIPS_GP_VALUE -#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */ -#endif - -#ifndef DT_MIPS_AUX_DYNAMIC -#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */ -#endif - - - -/* MIPS DT_MIPS_FLAGS flags */ -#ifndef RHF_NONE -#define RHF_NONE 0 /* No flags */ -#endif - -#ifndef RHF_QUICKSTART -#define RHF_QUICKSTART (1 << 0) /* Object may be quickstarted by loader */ -#endif - -#ifndef RHF_NOTPOT -#define RHF_NOTPOT (1 << 1) /* Hash size not a power of two */ -#endif - -#ifndef RHF_NO_LIBRARY_REPLACEMENT -#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Use default system libraries only */ -#endif - -#ifndef RHF_NO_MOVE -#define RHF_NO_MOVE (1 << 3) /* Do not relocate */ -#endif - -#ifndef RHF_SGI_ONLY -#define RHF_SGI_ONLY (1 << 4) /* XXX */ -#endif - -#ifndef RHF_GUARANTEE_INIT -#define RHF_GUARANTEE_INIT (1 << 5) /* XXX */ -#endif - -#ifndef RHF_DELTA_C_PLUS_PLUS -#define RHF_DELTA_C_PLUS_PLUS (1 << 6) /* XXX */ -#endif - -#ifndef RHF_GUARANTEE_START_INIT -#define RHF_GUARANTEE_START_INIT (1 << 7) /* XXX */ -#endif - -#ifndef RHF_PIXIE -#define RHF_PIXIE (1 << 8) /* XXX */ -#endif - -#ifndef RHF_DEFAULT_DELAY_LOAD -#define RHF_DEFAULT_DELAY_LOAD (1 << 9) /* XXX */ -#endif - -#ifndef RHF_REQUICKSTART -#define RHF_REQUICKSTART (1 << 10) /* XXX */ -#endif - -#ifndef RHF_REQUICKSTARTED -#define RHF_REQUICKSTARTED (1 << 11) /* XXX */ -#endif - -#ifndef RHF_CORD -#define RHF_CORD (1 << 12) /* XXX */ -#endif - -#ifndef RHF_NO_UNRES_UNDEF -#define RHF_NO_UNRES_UNDEF (1 << 13) /* XXX */ -#endif - -#ifndef RHF_RLD_ORDER_SAFE -#define RHF_RLD_ORDER_SAFE (1 << 14) /* XXX */ -#endif - - -/* Global pointer table defines */ -#ifndef PT_MIPS_REGINFO -#define PT_MIPS_REGINFO 0x70000006 -#endif - -#ifndef SHT_MIPS_REGINFO -#define SHT_MIPS_REGINFO 0x70000000 -#endif - - - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ppc.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ppc.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ppc.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-ppc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -/* -** -** Compatibility with the PPC architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 26 20:57:27 2005 jfv -** -** -** $Id$ -** -*/ - - -#ifndef EM_PPC - #define EM_PPC 20 -#endif - -#ifndef EM_PPC64 - #define EM_PPC64 21 -#endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sparc.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sparc.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sparc.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sparc.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -/* -** -** Compatibility with the Sparc architecture -** -** Define all the relocation types that can be undefined on various OS -** -** Last update Sat Feb 27 16:57:02 2005 jfv -** -** -** $Id$ -** -*/ - - -#ifndef EM_SPARC - #define EM_SPARC 2 -#endif - -#ifndef EM_SPARC32PLUS - #define EM_SPARC32PLUS 18 -#endif - -#ifndef EM_SPARCV9 - #define EM_SPARCV9 43 -#endif - - -/* SPARC relocation types, undefined on FreeBSD */ -#ifndef R_SPARC_NONE - #define R_SPARC_NONE 0 -#endif -#ifndef R_SPARC_8 - #define R_SPARC_8 1 -#endif -#ifndef R_SPARC_16 - #define R_SPARC_16 2 -#endif -#ifndef R_SPARC_32 - #define R_SPARC_32 3 -#endif -#ifndef R_SPARC_DISP8 - #define R_SPARC_DISP8 4 -#endif -#ifndef R_SPARC_DISP16 - #define R_SPARC_DISP16 5 -#endif -#ifndef R_SPARC_DISP32 - #define R_SPARC_DISP32 6 -#endif -#ifndef R_SPARC_WDISP30 - #define R_SPARC_WDISP30 7 -#endif -#ifndef R_SPARC_WDISP22 - #define R_SPARC_WDISP22 8 -#endif -#ifndef R_SPARC_HI22 - #define R_SPARC_HI22 9 -#endif -#ifndef R_SPARC_22 - #define R_SPARC_22 10 -#endif -#ifndef R_SPARC_13 - #define R_SPARC_13 11 -#endif -#ifndef R_SPARC_LO10 - #define R_SPARC_LO10 12 -#endif -#ifndef R_SPARC_GOT10 - #define R_SPARC_GOT10 13 -#endif -#ifndef R_SPARC_GOT13 - #define R_SPARC_GOT13 14 -#endif -#ifndef R_SPARC_GOT22 - #define R_SPARC_GOT22 15 -#endif -#ifndef R_SPARC_PC10 - #define R_SPARC_PC10 16 -#endif -#ifndef R_SPARC_PC22 - #define R_SPARC_PC22 17 -#endif -#ifndef R_SPARC_WPLT30 - #define R_SPARC_WPLT30 18 -#endif -#ifndef R_SPARC_COPY - #define R_SPARC_COPY 19 -#endif -#ifndef R_SPARC_GLOB_DAT - #define R_SPARC_GLOB_DAT 20 -#endif -#ifndef R_SPARC_JMP_SLOT - #define R_SPARC_JMP_SLOT 21 -#endif -#ifndef R_SPARC_RELATIVE - #define R_SPARC_RELATIVE 22 -#endif -#ifndef R_SPARC_UA32 - #define R_SPARC_UA32 23 -#endif - - -/* Extended SPARC64 relocation types */ -#ifndef R_SPARC_PLT32 - #define R_SPARC_PLT32 24 -#endif -#ifndef R_SPARC_HIPLT22 - #define R_SPARC_HIPLT22 25 -#endif -#ifndef R_SPARC_LOPLT10 - #define R_SPARC_LOPLT10 26 -#endif -#ifndef R_SPARC_PCPLT32 - #define R_SPARC_PCPLT32 27 -#endif -#ifndef R_SPARC_PCPLT22 - #define R_SPARC_PCPLT22 28 -#endif -#ifndef R_SPARC_PCPLT10 - #define R_SPARC_PCPLT10 29 -#endif -#ifndef R_SPARC_10 - #define R_SPARC_10 30 -#endif -#ifndef R_SPARC_11 - #define R_SPARC_11 31 -#endif -#ifndef R_SPARC_64 - #define R_SPARC_64 32 -#endif -#ifndef R_SPARC_OLO10 - #define R_SPARC_OLO10 33 -#endif -#ifndef R_SPARC_HH22 - #define R_SPARC_HH22 34 -#endif -#ifndef R_SPARC_HM10 - #define R_SPARC_HM10 35 -#endif -#ifndef R_SPARC_LM22 - #define R_SPARC_LM22 36 -#endif -#ifndef R_SPARC_PC_HH22 - #define R_SPARC_PC_HH22 37 -#endif -#ifndef R_SPARC_PC_HM10 - #define R_SPARC_PC_HM10 38 -#endif -#ifndef R_SPARC_PC_LM22 - #define R_SPARC_PC_LM22 39 -#endif -#ifndef R_SPARC_WDISP16 - #define R_SPARC_WDISP16 40 -#endif -#ifndef R_SPARC_WDISP19 - #define R_SPARC_WDISP19 41 -#endif -#ifndef R_SPARC_7 - #define R_SPARC_7 43 -#endif -#ifndef R_SPARC_5 - #define R_SPARC_5 44 -#endif -#ifndef R_SPARC_6 - #define R_SPARC_6 45 -#endif -#ifndef R_SPARC_DISP64 - #define R_SPARC_DISP64 46 -#endif -#ifndef R_SPARC_PLT64 - #define R_SPARC_PLT64 47 -#endif -#ifndef R_SPARC_HIX22 - #define R_SPARC_HIX22 48 -#endif -#ifndef R_SPARC_LOX10 - #define R_SPARC_LOX10 49 -#endif -#ifndef R_SPARC_H44 - #define R_SPARC_H44 50 -#endif -#ifndef R_SPARC_M44 - #define R_SPARC_M44 51 -#endif -#ifndef R_SPARC_L44 - #define R_SPARC_L44 52 -#endif -#ifndef R_SPARC_REGISTE - #define R_SPARC_REGISTER 53 -#endif -#ifndef R_SPARC_UA64 - #define R_SPARC_UA64 54 -#endif -#ifndef R_SPARC_UA16 - #define R_SPARC_UA16 55 -#endif diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sunos.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sunos.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sunos.h.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-sunos.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ -/* -** libelfsh-sunos.h -** -** Started on Fri Dec 7 21:29:00 2001 jfv -** Last update Mon Feb 26 05:05:27 2005 jfv -** -** $Id$ -** -*/ - - -/* -** This include is needed on OS'es like SunOS because -** there is no DT information in elf.h -** This was ripped from elf.h on Linux Slackware 8 . -*/ - -#include -#include -#include - -/* Dynamic section entry. */ - -#if 0 -typedef struct -{ - Elf32_Sword d_tag; /* Dynamic entry type */ - union - { - Elf32_Word d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -typedef struct -{ - Elf64_Sxword d_tag; /* Dynamic entry type */ - union - { - Elf64_Xword d_val; /* Integer value */ - Elf64_Addr d_ptr; /* Address value */ - } d_un; -} Elf64_Dyn; - - -/* Legal values for d_tag (dynamic entry type). */ - -#define DT_NULL 0 /* Marks end of dynamic section */ -#define DT_NEEDED 1 /* Name of needed library */ -#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ -#define DT_PLTGOT 3 /* Processor defined value */ -#define DT_HASH 4 /* Address of symbol hash table */ -#define DT_STRTAB 5 /* Address of string table */ -#define DT_SYMTAB 6 /* Address of symbol table */ -#define DT_RELA 7 /* Address of Rela relocs */ -#define DT_RELASZ 8 /* Total size of Rela relocs */ -#define DT_RELAENT 9 /* Size of one Rela reloc */ -#define DT_STRSZ 10 /* Size of string table */ -#define DT_SYMENT 11 /* Size of one symbol table entry */ -#define DT_INIT 12 /* Address of init function */ -#define DT_FINI 13 /* Address of termination function */ -#define DT_SONAME 14 /* Name of shared object */ -#define DT_RPATH 15 /* Library search path (deprecated) */ -#define DT_SYMBOLIC 16 /* Start symbol search here */ -#define DT_REL 17 /* Address of Rel relocs */ -#define DT_RELSZ 18 /* Total size of Rel relocs */ -#define DT_RELENT 19 /* Size of one Rel reloc */ -#define DT_PLTREL 20 /* Type of reloc in PLT */ -#define DT_DEBUG 21 /* For debugging; unspecified */ -#define DT_TEXTREL 22 /* Reloc might modify .text */ -#define DT_JMPREL 23 /* Address of PLT relocs */ -#endif - -/* the below aren't defined on solaris. they might cause errors if used */ -#define DT_BIND_NOW 24 /* Process relocations of object */ -#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ -#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ -#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ -#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ -#define DT_RUNPATH 29 /* Library search path */ -#define DT_FLAGS 30 /* Flags for the object being loaded */ -#define DT_ENCODING 32 /* Start of encoded range */ -#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ -#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ -#define DT_NUM 34 /* Number used */ - -#if 0 -#define DT_LOPROC 0x70000000 /* Start of processor-specific */ -#define DT_HIPROC 0x7fffffff /* End of processor-specific */ -#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */ - - -/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the - Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's - approach. */ -#define DT_VALRNGLO 0x6ffffd00 -#define DT_CHECKSUM 0x6ffffdf8 -#define DT_PLTPADSZ 0x6ffffdf9 -#define DT_MOVEENT 0x6ffffdfa -#define DT_MOVESZ 0x6ffffdfb -#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ -#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting - the following DT_* entry. */ -#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ -#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ -#define DT_VALRNGHI 0x6ffffdff - -/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the - Dyn.d_un.d_ptr field of the Elf*_Dyn structure. - - If any adjustment is made to the ELF object after it has been - built these entries will need to be adjusted. */ -#define DT_ADDRRNGLO 0x6ffffe00 -#define DT_SYMINFO 0x6ffffeff /* syminfo table */ -#define DT_ADDRRNGHI 0x6ffffeff - - -/* The versioning entry types. The next are defined as part of the - GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition - table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed - versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - -/* Sun added these machine-independent extensions in the "processor-specific" - range. Be compatible. */ -#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ -#define DT_FILTER 0x7fffffff /* Shared object to get values from */ -#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) -#define DT_EXTRANUM 3 - -/* Values of `d_un.d_val' in the DT_FLAGS entry. */ -#define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ -#define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ -#define DF_TEXTREL 0x00000004 /* Object contains text relocations */ -#define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ - -/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 - entry in the dynamic section. */ -#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ -#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ -#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ -#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ -#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ -#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ -#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ -#define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ -#define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ -#define DF_1_TRANS 0x00000200 -#define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ -#define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ -#define DF_1_NODUMP 0x00001000 -#define DF_1_CONFALT 0x00002000 -#define DF_1_ENDFILTEE 0x00004000 - -/* Flags for the feature selection in DT_FEATURE_1. */ -#define DTF_1_PARINIT 0x00000001 -#define DTF_1_CONFEXP 0x00000002 - -/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ -#define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ -#define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not - generally available. */ - -#endif - -/* For ELF64 the definitions are the same. */ -/* -#define ELF32_ST_VISIBILITY(o) ((o & 0x03)) -#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o) -*/ - -/* Symbol visibility specification encoded in the st_other field. */ -#define STV_DEFAULT 0 /* Default symbol visibility rules */ -#define STV_INTERNAL 1 /* Processor specific hidden class */ -#define STV_HIDDEN 2 /* Sym unavailable in other modules */ -#define STV_PROTECTED 3 /* Not preemptible, not exported */ - -/* XXX the below is for i386 relocation types. if there is future expansion - * to suppore more architecures, then the relocation defines should be - * moved into seperate headers and included by the architecture specific - * headers */ - -#define R_386_NONE 0 /* No reloc */ -#define R_386_32 1 /* Direct 32 bit */ -#define R_386_PC32 2 /* PC relative 32 bit */ -#define R_386_GOT32 3 /* 32 bit GOT entry */ -#define R_386_PLT32 4 /* 32 bit PLT address */ -#define R_386_COPY 5 /* Copy symbol at runtime */ -#define R_386_GLOB_DAT 6 /* Create GOT entry */ -#define R_386_JMP_SLOT 7 /* Create PLT entry */ -#define R_386_RELATIVE 8 /* Adjust by program base */ -#define R_386_GOTOFF 9 /* 32 bit offset to GOT */ -#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ - -/* Architecture type */ -#define EM_PARISC 15 -#define EM_PPC64 21 -#define EM_SVX 73 - -/* Linux/BSD Core file support on Solaris */ -#define NT_FPREGSET 2 -#define NT_TASKSTRUCT 4 -#define NT_PRFPXREG 20 - - - - - - diff -Nru eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-versions.h.svn-base eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-versions.h.svn-base --- eresi-0.8a25/libelfsh/include/libelfsh/.svn/text-base/libelfsh-versions.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh/.svn/text-base/libelfsh-versions.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* - * - * - * - * - */ - -/* The versioning entry types. The next are defined as part of the GNU extension. */ -#define DT_VERSYM 0x6ffffff0 - -#define DT_RELACOUNT 0x6ffffff9 -#define DT_RELCOUNT 0x6ffffffa - -/* These were chosen by Sun. */ -#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ -#define DT_VERDEF 0x6ffffffc /* Address of version definition - table */ -#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ -#define DT_VERNEED 0x6ffffffe /* Address of table with needed - versions */ -#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ -#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ -#define DT_VERSIONTAGNUM 16 - - -/* Version definition sections. */ - -typedef struct -{ - Elf32_Half vd_version; /* Version revision */ - Elf32_Half vd_flags; /* Version information */ - Elf32_Half vd_ndx; /* Version Index */ - Elf32_Half vd_cnt; /* Number of associated aux entries */ - Elf32_Word vd_hash; /* Version name hash value */ - Elf32_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf32_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf32_Verdef; - -typedef struct -{ - Elf64_Half vd_version; /* Version revision */ - Elf64_Half vd_flags; /* Version information */ - Elf64_Half vd_ndx; /* Version Index */ - Elf64_Half vd_cnt; /* Number of associated aux entries */ - Elf64_Word vd_hash; /* Version name hash value */ - Elf64_Word vd_aux; /* Offset in bytes to verdaux array */ - Elf64_Word vd_next; /* Offset in bytes to next verdef - entry */ -} Elf64_Verdef; - - -/* Legal values for vd_version (version revision). */ -#define VER_DEF_NONE 0 /* No version */ -#define VER_DEF_CURRENT 1 /* Current version */ -#define VER_DEF_NUM 2 /* Given version number */ - -/* Legal values for vd_flags (version information flags). */ -#define VER_FLG_BASE 0x1 /* Version definition of file itself */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ - -/* Versym symbol index values. */ -#define VER_NDX_LOCAL 0 /* Symbol is local. */ -#define VER_NDX_GLOBAL 1 /* Symbol is global. */ -#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */ -#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */ - -/* Auxialiary version information. */ - -typedef struct -{ - Elf32_Word vda_name; /* Version or dependency names */ - Elf32_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf32_Verdaux; - -typedef struct -{ - Elf64_Word vda_name; /* Version or dependency names */ - Elf64_Word vda_next; /* Offset in bytes to next verdaux - entry */ -} Elf64_Verdaux; - - -/* Version dependency section. */ - -typedef struct -{ - Elf32_Half vn_version; /* Version of structure */ - Elf32_Half vn_cnt; /* Number of associated aux entries */ - Elf32_Word vn_file; /* Offset of filename for this - dependency */ - Elf32_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf32_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf32_Verneed; - -typedef struct -{ - Elf64_Half vn_version; /* Version of structure */ - Elf64_Half vn_cnt; /* Number of associated aux entries */ - Elf64_Word vn_file; /* Offset of filename for this - dependency */ - Elf64_Word vn_aux; /* Offset in bytes to vernaux array */ - Elf64_Word vn_next; /* Offset in bytes to next verneed - entry */ -} Elf64_Verneed; - - -/* Legal values for vn_version (version revision). */ -#define VER_NEED_NONE 0 /* No version */ -#define VER_NEED_CURRENT 1 /* Current version */ -#define VER_NEED_NUM 2 /* Given version number */ - -/* Auxiliary needed version information. */ - -typedef struct -{ - Elf32_Word vna_hash; /* Hash value of dependency name */ - Elf32_Half vna_flags; /* Dependency specific information */ - Elf32_Half vna_other; /* Unused */ - Elf32_Word vna_name; /* Dependency name string offset */ - Elf32_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf32_Vernaux; - -typedef struct -{ - Elf64_Word vna_hash; /* Hash value of dependency name */ - Elf64_Half vna_flags; /* Dependency specific information */ - Elf64_Half vna_other; /* Unused */ - Elf64_Word vna_name; /* Dependency name string offset */ - Elf64_Word vna_next; /* Offset in bytes to next vernaux - entry */ -} Elf64_Vernaux; - - -/* Legal values for vna_flags. */ -#define VER_FLG_WEAK 0x2 /* Weak version identifier */ diff -Nru eresi-0.8a25/libelfsh/include/libelfsh.h eresi-0.0.20110516/libelfsh/include/libelfsh.h --- eresi-0.8a25/libelfsh/include/libelfsh.h 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/libelfsh.h 2011-05-16 11:34:53.000000000 +0000 @@ -1,10 +1,9 @@ /* -** @file libelfsh.h +* @file libelfsh/include/libelfsh.h +* @ingroup libelfsh ** ** Started on Mon Jul 23 15:47:12 2001 jfv -** -** -** $Id: libelfsh.h,v 1.80 2008-02-16 13:44:47 thor Exp $ +** $Id: libelfsh.h 1435 2010-12-11 06:16:51Z may $ ** */ @@ -34,26 +33,31 @@ #ifndef __KERNEL__ #ifdef __BEOS__ -#include + #include + #include #endif #if !defined(__USE_GNU) #define __USE_GNU #endif -#if ! defined(__OpenBSD__) -#include +#if defined(__BEOS__) + #include +#elif !defined(__OpenBSD__) + #include #endif -#if !defined(sgi) +#if !defined(sgi) && !defined(__BEOS__) #include #endif +/* #if defined(__NetBSD__) #include #elif ! (defined(__OpenBSD__)) #include #endif +*/ #endif @@ -83,19 +87,19 @@ #define ELFSH_ARCH_PARISC 4 /* no hooks yet */ #define ELFSH_ARCH_PPC32 5 /* no hooks yet */ #define ELFSH_ARCH_PPC64 6 /* no hooks yet */ -#define ELFSH_ARCH_CRAY 7 /* no hooks yet */ -#define ELFSH_ARCH_ALPHA64 8 -#define ELFSH_ARCH_MIPS32 9 -#define ELFSH_ARCH_MIPS64 10 /* No hooks yet */ -#define ELFSH_ARCH_ARM 11 -#define ELFSH_ARCHNUM 12 +#define ELFSH_ARCH_ALPHA64 7 +#define ELFSH_ARCH_MIPS32 8 +#define ELFSH_ARCH_MIPS64 9 /* No hooks yet */ +#define ELFSH_ARCH_ARM 10 +#define ELFSH_ARCH_AMD64 11 +#define ELFSH_ARCH_NUM 12 #define ELFSH_ARCH_ERROR 0xFF /* ELFsh ELF types */ -#define ELFSH_TYPE_EXEC 0 -#define ELFSH_TYPE_DYN 1 -#define ELFSH_TYPENUM 2 -#define ELFSH_TYPE_ERROR 0xFF +#define ELFSH_FILE_EXEC 0 +#define ELFSH_FILE_LIB 1 +#define ELFSH_FILE_NUM 2 +#define ELFSH_FILE_ERROR 0xFF /* ELFsh OS types */ #define ELFSH_OS_LINUX 0 @@ -103,17 +107,33 @@ #define ELFSH_OS_NETBSD 2 #define ELFSH_OS_OPENBSD 3 #define ELFSH_OS_SOLARIS 4 -#define ELFSH_OS_UNICOS 5 -#define ELFSH_OS_BEOS 6 -#define ELFSH_OS_IOS 7 -#define ELFSH_OSNUM 8 +#define ELFSH_OS_BEOS 5 +#define ELFSH_OS_IRIX 6 +#define ELFSH_OS_HPUX 7 +#define ELFSH_OS_ARM 8 +#define ELFSH_OS_NUM 9 #define ELFSH_OS_ERROR 0xFF -/* (k)e2dbg memory hosting types for the debugger hooks */ -#define E2DBG_HOST_KERN 0 -#define E2DBG_HOST_PROC 1 -#define E2DBG_HOSTNUM 2 -#define E2DBG_HOST_ERROR 0xFF +/* KERNEL / USER / GDBNODE memory hosting type */ +#define ELFSH_HOST_USER 0 +#define ELFSH_HOST_KERN 1 +#define ELFSH_HOST_GDB 2 +#define ELFSH_HOST_NUM 3 +#define ELFSH_HOST_ERROR 0xFF + +/* Number of possible types for READ/WRITE memory hook - some reserved */ +#define ELFSH_IOTYPE_STATIC 0 +#define ELFSH_IOTYPE_EMBEDDED 1 +#define ELFSH_IOTYPE_GDBPROT 2 +#define ELFSH_IOTYPE_JTAG 3 +#define ELFSH_IOTYPE_DEVMEM24 4 +#define ELFSH_IOTYPE_DEVMEM26 5 +#define ELFSH_IOTYPE_DEVKMEM24 6 +#define ELFSH_IOTYPE_DEVKMEM26 7 +#define ELFSH_IOTYPE_KCORE 8 +#define ELFSH_IOTYPE_KVIRTM 9 +#define ELFSH_IOTYPE_NUM 10 +#define ELFSH_IOTYPE_ERROR 0xFF /* libelfsh block hijack types */ #define ELFSH_HIJACK_TYPE_FLOW 0x000000 @@ -133,6 +153,14 @@ #define ELFSH_HOOK_EXTPLT "hook_extplt" #define ELFSH_HOOK_ALTPLT "hook_altplt" #define ELFSH_HOOK_ARGC "hook_argc" +#define ELFSH_HOOK_READMEM "hook_readmem" +#define ELFSH_HOOK_WRITEMEM "hook_writemem" +#define ELFSH_HOOK_READMEMA "hook_readmema" +#define ELFSH_HOOK_READMEMF "hook_readmemf" +#define ELFSH_HOOK_WRITEMEMF "hook_writememf" +#define ELFSH_HOOK_ALLOC "hook_alloc" +#define ELFSH_HOOK_MPROTECT "hook_mprotect" +#define ELFSH_HOOK_MUNPROTECT "hook_munprotect" /* Some defined values */ #define ELFSH_SECTION_NAME_MAPPED ".mapped" @@ -171,16 +199,10 @@ #define ELFSH_SECTION_NAME_GOT ".got" #define ELFSH_SECTION_NAME_RELPLT ".rel.plt" #define ELFSH_SECTION_NAME_RELAPLT ".rela.plt" - #define ELFSH_SECTION_NAME_RELGOT ".rel.got" #define ELFSH_SECTION_NAME_RELDYN ".rel.dyn" #define ELFSH_SECTION_NAME_RELADYN ".rela.dyn" #define ELFSH_SECTION_NAME_RELABSS ".rela.bss" -#define ELFSH_SECTION_NAME_ALTRELDYN ".elfsh.reldyn" -#define ELFSH_SECTION_NAME_ALTRELADYN ".elfsh.reladyn" -#define ELFSH_SECTION_NAME_ALTRELGOT ".elfsh.relgot" -#define ELFSH_SECTION_NAME_ALTRELBSS ".elfsh.relabss" - #define ELFSH_SECTION_NAME_GOTPLT ".got.plt" #define ELFSH_SECTION_NAME_INTERP ".interp" #define ELFSH_SECTION_NAME_SYMTAB ".symtab" @@ -199,6 +221,8 @@ #define ELFSH_SECTION_NAME_EHFRAME ".eh_frame" #define ELFSH_SECTION_NAME_INIT ".init" #define ELFSH_SECTION_NAME_FINI ".fini" + +/* Debug section names */ #define ELFSH_SECTION_NAME_DEBUG ".debug" #define ELFSH_SECTION_NAME_DW2_INFO ".debug_info" #define ELFSH_SECTION_NAME_DW2_ARANGES ".debug_aranges" @@ -210,6 +234,12 @@ #define ELFSH_SECTION_NAME_DW2_MACINFO ".debug_macinfo" #define ELFSH_SECTION_NAME_DW2_LOC ".debug_loc" +/* EELF sections names */ +#define ELFSH_SECTION_NAME_ALTRELDYN ".elfsh.reldyn" +#define ELFSH_SECTION_NAME_ALTRELADYN ".elfsh.reladyn" +#define ELFSH_SECTION_NAME_ALTRELGOT ".elfsh.relgot" +#define ELFSH_SECTION_NAME_ALTRELBSS ".elfsh.relabss" + /* Section index in the secthash */ #define ELFSH_SECTION_NULL 0 #define ELFSH_SECTION_INTERP 1 @@ -261,11 +291,11 @@ #define ELFSH_SECTION_MAX 254 #define ELFSH_SECTION_UNKNOWN 255 - /* Some constants */ #define ELFSH_PLT_ENTRY_SIZE 16 #define ELFSH_SYMTAB_ENTRY_SIZE sizeof(elfsh_Sym) +#define ELFSH_DEVZERO "/dev/zero" #define ELFSH_STARTSYM "_start" #define ELFSH_GOTSYM "_GLOBAL_OFFSET_TABLE_" #define ELFSH_NULL_STRING "(NULL)" @@ -274,7 +304,7 @@ #define ELFSH_SORT_BY_NAME 'n' /* Dedicated to you know who */ -#define ELFSH_MEANING 42 +#define ERESI_MEANING 42 #define ELFSH_SECTION_FIRST 0 #define ELFSH_SECTION_LAST 0xFFFF @@ -312,7 +342,15 @@ #define DUMPABLE(sym) (elfsh_get_symbol_type(sym) == STT_FUNC || \ elfsh_get_symbol_type(sym) == STT_OBJECT || \ elfsh_get_symbol_type(sym) == STT_COMMON || \ - elfsh_get_symbol_type(sym) == STT_SECTION) + elfsh_get_symbol_type(sym) == STT_SECTION || \ + elfsh_get_symbol_type(sym) == STT_BLOCK) + +#define BESTYPE(cand, best) (elfsh_get_symbol_type(cand) == STT_FUNC || \ + (elfsh_get_symbol_type(cand) == STT_SECTION && \ + elfsh_get_symbol_type(best) != STT_FUNC) || \ + (elfsh_get_symbol_type(cand) == STT_BLOCK && \ + elfsh_get_symbol_type(best) != STT_FUNC && \ + elfsh_get_symbol_type(best) != STT_SECTION)) #define FILE_IS_SPARC(obj) (FILE_IS_SPARC32(obj) || FILE_IS_SPARC64(obj)) #define FILE_IS_SPARC32(obj) (((elfsh_get_arch((obj)->hdr) == EM_SPARC) || \ @@ -383,7 +421,7 @@ #define ELFSH_REDIR_ALTGOT 2 u_char type; /* Redirection type */ -#define ELFSH_ORIG_FUNC 0 +#define ERESI_ORIG_FUNC 0 #define ELFSH_HOOK_FUNC 1 char *name[2]; /* Name of involved functions */ eresi_Addr addr[2]; /* Redirection address */ @@ -735,20 +773,17 @@ /** * BSD core file info structure */ -typedef struct bsd_core +typedef struct bsd_core { uint16_t offset; uint16_t filesz; - elfsh_Nhdr nhdr; - long flags; - elfsh_bsdprstatus_t prstatus; elfsh_bsdprpsinfo_t prpsinfo; elfsh_bsdfpregs_t fpregs; -} elfshbsdcore_t; +} elfshbsdcore_t; /** * @brief ELF object structure @@ -777,23 +812,22 @@ int rights; /* 0 = RO, 1 = WR */ time_t loadtime; /* Time of Loading */ u_int id; /* Object ID */ - + u_char hostype; /* !< @brief HOST type used for various runtime features */ + u_char iotype; /* !< @brief IO type used to read and write memory */ char running; /* !< @brief Is the process running ? */ - char scanned; /* !< @brief Has the object already been block scanned ? */ char hdr_broken; /* !< @brief Is the header broken/corrupted ? */ char read; /* !< @brief Has the object already been read ? */ char shtrm; /* !< @brief Mark SHT and Unmapped sections as stripped ? */ char strip; /* !< @brief Mark file as stripped */ char pending; /* !< @brief Beeing injected */ uint32_t nbrm; /* !< @brief Number of section headers to remove at saving */ - char shtrb; /* !< @brief Reconstruct the SHT if non present */ #define ELFSH_MAXREL 1000 /* !< @brief Maximum number of injected ET_REL, change it ! */ struct s_obj *listrel[ELFSH_MAXREL];/* !< @brief Array of injected ET_REL in this object */ u_int nbrel; /* !< @brief Number of injected ET_REL in this object */ - char buff[ELFSH_MEANING]; /* !< @brief Internal buffer, sometimes used to avoid a malloc */ + char buff[ERESI_MEANING]; /* !< @brief Internal buffer, sometimes used to avoid a malloc */ const char *error; /* !< @brief Last error string */ struct s_obj *next; /* !< @brief The list is simply linked */ struct s_obj *original; /* !< @brief Original file (if its a copy) */ @@ -840,10 +874,9 @@ */ typedef struct s_libstate { - -#define LIBELFSH_MODE_UNKNOWN 0 -#define LIBELFSH_MODE_STATIC 1 -#define LIBELFSH_MODE_E2DBG 2 +#define LIBELFSH_MODE_STATIC 0 +#define LIBELFSH_MODE_RUNTIME 1 +#define LIBELFSH_MODE_NUM 2 u_char mode; /* The current working mode (ondisk/memory) */ u_char indebug; /* 1 when inside the debugger */ } libworld_t; @@ -875,51 +908,8 @@ u_char flags; /* !< @brief Breakpoint flags */ } elfshbp_t; -/** - * Trace structure - */ -typedef struct s_traces_args -{ - char *name; - char *typename; - int size; -} elfshtracesargs_t; - -/** - * Documentation missing. - */ -typedef struct s_traces -{ -#define ELFSH_TRACES_TYPE_DEFAULT "global" -#define ELFSH_TRACES_FUNC_SIZE 256 - char funcname[ELFSH_TRACES_FUNC_SIZE]; - elfshobj_t *file; - u_char enable; - u_int offset; - -#define ELFSH_ARG_INTERN 0 -#define ELFSH_ARG_EXTERN 1 - u_char scope; - -#define ELFSH_ARG_SIZE_BASED 0 -#define ELFSH_ARG_TYPE_BASED 1 - u_char type; - - eresi_Addr vaddr; - -#define ELFSH_TRACES_MAX_ARGS 20 - elfshtracesargs_t arguments[ELFSH_TRACES_MAX_ARGS]; - u_int argc; -} elfshtraces_t; - /* Extern data */ extern libworld_t dbgworld; -extern hash_t traces_table; -extern hash_t exclude_table; - -#if defined(KERNSH) -#include "libkernsh.h" -#endif /* ** @@ -1009,17 +999,21 @@ eresi_Addr limit, int inc); int elfsh_resolv_remote_function(elfshobj_t *filein, eresi_Addr vaddrin, elfshobj_t **fileout, eresi_Addr *vaddrout); +elfshobj_t *elfsh_symbol_search(elfshobj_t *file, char *name); + /* obj.c */ +elfshobj_t *elfsh_create_obj(char *name, eresi_Addr start, u_int size, + elfsh_Half arch, elfsh_Half type, u_char enc, u_char clas); elfshobj_t *elfsh_load_obj(char *name); void elfsh_unload_obj(elfshobj_t *file); /* elf.c */ int elfsh_load_hdr(elfshobj_t *file); void *elfsh_get_hdr(elfshobj_t *file); -elfsh_Off elfsh_get_shtoff(elfsh_Ehdr *e); +eresi_Off elfsh_get_shtoff(elfsh_Ehdr *e); elfsh_Half elfsh_get_shtnbr(elfsh_Ehdr *e); -elfsh_Off elfsh_get_phtoff(elfsh_Ehdr *e); +eresi_Off elfsh_get_phtoff(elfsh_Ehdr *e); elfsh_Half elfsh_get_phtnbr(elfsh_Ehdr *e); eresi_Addr elfsh_get_entrypoint(elfsh_Ehdr *e); elfsh_Half elfsh_get_arch(elfsh_Ehdr *e); @@ -1054,7 +1048,7 @@ int elfsh_static_file(elfshobj_t *file); int elfsh_dynamic_file(elfshobj_t *file); int elfsh_set_rphtoff(elfsh_Ehdr *hdr, eresi_Addr num); -elfsh_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr); +eresi_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr); int elfsh_get_core_notes(elfshobj_t *file); @@ -1091,7 +1085,7 @@ elfsh_Word elfsh_get_section_info(elfsh_Shdr *s); elfsh_Word elfsh_get_section_entsize(elfsh_Shdr *s); elfsh_Word elfsh_get_section_link(elfsh_Shdr *s); -elfsh_Off elfsh_get_section_foffset(elfsh_Shdr *s); +eresi_Off elfsh_get_section_foffset(elfsh_Shdr *s); eresi_Addr elfsh_get_section_addr(elfsh_Shdr *s); elfsh_Word elfsh_get_section_align(elfsh_Shdr *s); elfsh_Word elfsh_get_section_size(elfsh_Shdr *s); @@ -1123,7 +1117,7 @@ int elfsh_set_section_name(elfshobj_t *file, elfshsect_t *sect, char *name); char *elfsh_get_section_name(elfshobj_t *file, elfshsect_t *s); elfsh_Shdr elfsh_create_shdr(elfsh_Word name, elfsh_Word type, elfsh_Word flags, - eresi_Addr addr, elfsh_Off offset, elfsh_Word size, + eresi_Addr addr, eresi_Off offset, elfsh_Word size, elfsh_Word link, elfsh_Word info, elfsh_Word align, elfsh_Word entsize); int elfsh_insert_runtime_shdr(elfshobj_t *f, elfsh_Shdr hdr, u_int r, char *name, char sf); @@ -1160,11 +1154,11 @@ eresi_Addr elfsh_get_segment_paddr(elfsh_Phdr *p); eresi_Addr elfsh_get_segment_vaddr(elfsh_Phdr *p); elfsh_Word elfsh_get_segment_type(elfsh_Phdr *p); -elfsh_Off elfsh_get_segment_offset(elfsh_Phdr *p); +eresi_Off elfsh_get_segment_offset(elfsh_Phdr *p); elfsh_Phdr *elfsh_get_pht_entry_by_index(elfsh_Phdr *pht, eresi_Addr index); eresi_Addr elfsh_get_object_baseaddr(elfshobj_t *file); void elfsh_endianize_pht(elfsh_Phdr *pht, char byteorder, uint16_t sz); -elfsh_Phdr elfsh_create_phdr(elfsh_Word t, eresi_Addr a, elfsh_Off z, elfsh_Word al); +elfsh_Phdr elfsh_create_phdr(elfsh_Word t, eresi_Addr a, eresi_Off z, elfsh_Word al); elfsh_Phdr *elfsh_insert_phdr(elfshobj_t *file, elfsh_Phdr *h); int elfsh_remove_phdr(elfshobj_t *current, int index); @@ -1209,8 +1203,6 @@ u_int elfsh_set_got_val(eresi_Addr *got, eresi_Addr val); eresi_Addr elfsh_get_got_addr(eresi_Addr *got); u_int elfsh_set_got_addr(eresi_Addr *got, eresi_Addr val); -int elfsh_get_got_symbol_reloc(elfshobj_t *file, uint8 *name, - elfsh_Rel *rel_entry); int elfsh_endianize_got(elfshsect_t *_new); elfshsect_t *elfsh_get_gotsct(elfshobj_t *file); int elfsh_shift_got(elfshobj_t *file, u_int size, char *name); @@ -1258,7 +1250,6 @@ int elfsh_write_section_data(elfshsect_t *sect, u_int off, char *data, u_int size, u_int sizelem); elfshsect_t *elfsh_get_section_by_nam(elfshobj_t *file, char *name); -void *elfsh_get_raw(elfshsect_t *sect); int elfsh_section_is_runtime(elfshsect_t *sect); elfshsect_t *elfsh_get_rsection_by_index(elfshobj_t *file, eresi_Addr idx, int *stridx, int *num); @@ -1347,10 +1338,8 @@ elfsh_Sword elfsh_get_reladdend(elfsh_Rela *r); int elfsh_set_reladdend(elfsh_Rela *r, eresi_Addr val); int elfsh_endianize_relocs(elfshsect_t *s); -elfsh_Rel elfsh_create_relent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off); -elfsh_Rela elfsh_create_relaent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off, eresi_Addr add); +elfsh_Rel elfsh_create_relent(eresi_Addr type, eresi_Addr sym, eresi_Addr off); +elfsh_Rela elfsh_create_relaent(eresi_Addr type, eresi_Addr sym, eresi_Addr off, eresi_Addr add); /* interp.c */ char *elfsh_get_interp(elfshobj_t *file); @@ -1373,7 +1362,7 @@ int elfsh_relink_plt(elfshobj_t *file, u_int modulo); int elfsh_copy_plt(elfshobj_t *file, u_int modulo); int elfsh_get_plt_symbol_offset(elfshobj_t *file, uint8 *name, - elfsh_Off *off); + eresi_Off *off); int elfsh_build_plt(elfshobj_t *file); int elfsh_altplt_firstent(elfshsect_t *created, u_int *off, @@ -1406,12 +1395,13 @@ int elfsh_extplt_mirror_sections(elfshobj_t *file); elfsh_Sym *elfsh_request_pltent(elfshobj_t *file, char *name); - /* raw.c */ int elfsh_raw_write(elfshobj_t *file, u_int dst, void *src, int len); int elfsh_raw_read(elfshobj_t *file, u_int dst, void *src, int len); int elfsh_get_foffset_from_vaddr(elfshobj_t *file, eresi_Addr vaddr); int elfsh_get_vaddr_from_foffset(elfshobj_t *file, u_int foffset); +void *elfsh_get_raw_by_addr(elfshobj_t *current, eresi_Addr addr, void *buf, u_int size); +void *elfsh_get_raw(elfshsect_t *sect); /* remap.c */ int elfsh_reloc_pht(elfshobj_t *file, eresi_Addr diff); @@ -1436,6 +1426,8 @@ /* save.c */ int elfsh_save_relocate(elfshobj_t *file); int elfsh_save_obj(elfshobj_t *file, char *name); +elfshobj_t *elfsh_save_preconds(elfshobj_t *file); +int elfsh_store_obj(elfshobj_t *file, char *name); /* copy.c */ elfshobj_t *elfsh_copy_obj(elfshobj_t *file); @@ -1514,31 +1506,61 @@ /* hooks.c */ u_char elfsh_get_ostype(elfshobj_t *file); +u_char elfsh_get_iotype(elfshobj_t *file); u_char elfsh_get_hosttype(elfshobj_t *file); u_char elfsh_get_elftype(elfshobj_t *file); u_char elfsh_get_archtype(elfshobj_t *file); + +/* How to fetch handlers in vectors */ +int elfsh_register_vector(char *name, + void *registerfunc, + void *defaultfunc, + u_int *dimensions, + u_int dimsz); + +int elfsh_get_pagesize(elfshobj_t *file); +u_int elfsh_get_breaksize(elfshobj_t *file); +void elfsh_setup_hooks() __attribute__ ((constructor)); + +/* Default handlers for vectors */ int elfsh_default_plthandler(elfshobj_t *n, elfsh_Sym *n2, eresi_Addr n3); int elfsh_default_relhandler(elfshsect_t *n, elfsh_Rel *n2, eresi_Addr *n3, eresi_Addr n4, elfshsect_t *n5); int elfsh_default_cflowhandler(elfshobj_t *n, char *n1, elfsh_Sym *n2, eresi_Addr n3); -int elfsh_default_argchandler(eresi_Addr addr); +int *elfsh_default_argchandler(eresi_Addr addr); +void *elfsh_default_readmem(elfshsect_t *sect); +int elfsh_default_writemem(elfshobj_t *file, eresi_Addr addr, void *data, u_int size); +int elfsh_default_readmema(elfshobj_t *file, eresi_Addr addr, void *buf, u_int sz); +int elfsh_default_writememf(elfshobj_t *file, u_int off, char *buff, int len); +int elfsh_default_readmemf(elfshobj_t *file, u_int off, char *buff, int len); +int elfsh_default_encodeplthandler(elfshobj_t *file, elfshsect_t *sect, eresi_Addr diff); +int elfsh_default_encodeplt1handler(elfshobj_t *file, elfshsect_t *sect, + elfshsect_t *sect2, eresi_Addr diff); +int elfsh_default_extplthandler(elfshsect_t*, elfshsect_t*, elfshsect_t *, elfshsect_t *); +int elfsh_void_altplthandler(elfshobj_t *null, elfsh_Sym *null2, eresi_Addr null3); +eresi_Addr elfsh_default_rmaphandler(elfshobj_t *file, size_t size, int prot); +int elfsh_memcpy(elfshobj_t *null, eresi_Addr addr, void *buf, u_int size); +int elfsh_void_munprotecthandler(elfshobj_t *obj, eresi_Addr addr, uint32_t sz); +int elfsh_void_mprotecthandler(elfshobj_t *obj, eresi_Addr addr, uint32_t sz, int prot); +int elfsh_register_munprotecthook(u_char hostype, void *fct); +int elfsh_register_mprotecthook(u_char hostype, void *fct); +/* Registering API */ int elfsh_register_altplthook(u_char arch, u_char obj, u_char os, void *fct); int elfsh_register_plthook(u_char arch, u_char o, u_char os, void *fct); int elfsh_register_relhook(u_char a, u_char o, u_char os, void *fct); int elfsh_register_cflowhook(u_char a, u_char o, u_char os, void *fct); int elfsh_register_extplthook(u_char a, u_char o, u_char os, void *f); int elfsh_register_argchook(u_char a, u_char o, u_char os, void *fct); +int elfsh_register_readmema(u_int ostype, u_int devicetype, void *fct); +int elfsh_register_readmem(u_int, u_int, void *); +int elfsh_register_writemem(u_int, u_int, void *); +int elfsh_register_writememf(u_int hostype, u_int exectype, void *fct); +int elfsh_register_readmemf(u_int hostype, u_int exectype, void *fct); +int elfsh_register_encodeplthook(u_char archtype, u_char objtype, u_char ostype, void *fct); +int elfsh_register_encodeplt1hook(u_char archtype, u_char objtype, u_char ostype, void *fct); +int elfsh_register_allochook(u_char hostype, void *fct); -int elfsh_register_vector(char *name, - void *registerfunc, - void *defaultfunc, - u_int *dimensions, - u_int dimsz); - -int elfsh_get_pagesize(elfshobj_t *file); -u_int elfsh_get_breaksize(elfshobj_t *file); -void elfsh_setup_hooks(); - +/* Calling a vectored feature */ int elfsh_plt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr created); int elfsh_altplt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr created); int elfsh_cflow(elfshobj_t *file, char *name, elfsh_Sym *old, @@ -1552,7 +1574,14 @@ int elfsh_extplt(elfshsect_t *extplt, elfshsect_t *altgot, elfshsect_t *dynsym, elfshsect_t *relplt); int *elfsh_args_count(elfshobj_t *file, u_int off, eresi_Addr vaddr); - +void *elfsh_readmem(elfshsect_t *base); +void *elfsh_readmema(elfshobj_t *file, eresi_Addr addr, void *buf, u_int size); +int elfsh_readmemf(elfshobj_t *file, u_int foffset, void *dest_buff, int len); +int elfsh_writemem(elfshobj_t *, eresi_Addr, void *, u_int); +int elfsh_writememf(elfshobj_t *file, u_int foffset, void *src_buff, int len); +eresi_Addr elfsh_runtime_map(elfshobj_t *file, u_int memsz, int prot); +int elfsh_munprotect(elfshobj_t *obj, eresi_Addr addr, uint32_t sz); +int elfsh_mprotect(elfshobj_t *obj, eresi_Addr addr, uint32_t sz, int prot); /* sparc32.c */ @@ -1699,17 +1728,17 @@ /* runtime.c */ -eresi_Addr elfsh_runtime_map(elfsh_Phdr *segment); -int elfsh_runtime_unmap(elfsh_Phdr *segment); int elfsh_set_phdr_prot(u_int mode); -int elfsh_munprotect(elfshobj_t *obj, eresi_Addr addr, uint32_t sz); -int elfsh_mprotect(eresi_Addr addr, uint32_t sz, int prot); +eresi_Addr elfsh_map_userland(elfshobj_t *file, u_int memsz, int prot); + +int elfsh_munprotect_userland(elfshobj_t *obj, eresi_Addr addr, uint32_t sz); +int elfsh_mprotect_userland(elfshobj_t *obj, eresi_Addr addr, uint32_t sz, int prot); /* state.c */ u_char elfsh_is_static_mode(); void elfsh_set_static_mode(); -u_char elfsh_is_debug_mode(); -void elfsh_set_debug_mode(); +u_char elfsh_is_runtime_mode(); +void elfsh_set_runtime_mode(); void elfsh_set_mode(u_char mode); u_char elfsh_get_mode(); void elfsh_toggle_mode(); @@ -1736,10 +1765,5 @@ void *elfsh_bt_get_frame(ucontext_t *); #endif -/* bp.c */ -int elfsh_bp_add(hash_t *bps, elfshobj_t *file, - char *resolv, eresi_Addr addr, - u_char flags); - #endif /* __LIBELFSH_H_ */ diff -Nru eresi-0.8a25/libelfsh/include/.svn/all-wcprops eresi-0.0.20110516/libelfsh/include/.svn/all-wcprops --- eresi-0.8a25/libelfsh/include/.svn/all-wcprops 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/958/trunk/libelfsh/include -END -libelfsh.h -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/958/trunk/libelfsh/include/libelfsh.h -END diff -Nru eresi-0.8a25/libelfsh/include/.svn/entries eresi-0.0.20110516/libelfsh/include/.svn/entries --- eresi-0.8a25/libelfsh/include/.svn/entries 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libelfsh/include -http://svn.eresi-project.org/svn - - - -2008-04-03T11:41:49.560530Z -958 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libelfsh -dir - -libelfsh.h -file - - - - -2008-04-06T23:15:35.994892Z -d1b5563f3dfc8ecab062b3aa0c120425 -2008-04-03T11:41:49.560530Z -958 -thorkill - diff -Nru eresi-0.8a25/libelfsh/include/.svn/format eresi-0.0.20110516/libelfsh/include/.svn/format --- eresi-0.8a25/libelfsh/include/.svn/format 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libelfsh/include/.svn/text-base/libelfsh.h.svn-base eresi-0.0.20110516/libelfsh/include/.svn/text-base/libelfsh.h.svn-base --- eresi-0.8a25/libelfsh/include/.svn/text-base/libelfsh.h.svn-base 2008-04-06 23:15:35.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/include/.svn/text-base/libelfsh.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1745 +0,0 @@ -/* -** @file libelfsh.h -** -** Started on Mon Jul 23 15:47:12 2001 jfv -** -** -** $Id: libelfsh.h,v 1.80 2008-02-16 13:44:47 thor Exp $ -** -*/ - -#ifndef __LIBELFSH_H_ -#define __LIBELFSH_H_ - -#include "libvars.h" - -#ifndef __KERNEL__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "libaspect.h" -#include "libelfsh/libelfsh-compat.h" - -#ifndef __KERNEL__ - -#ifdef __BEOS__ -#include -#endif - -#if !defined(__USE_GNU) -#define __USE_GNU -#endif - -#if ! defined(__OpenBSD__) -#include -#endif - -#if !defined(sgi) -#include -#endif - -#if defined(__NetBSD__) -#include -#elif ! (defined(__OpenBSD__)) -#include -#endif - -#endif - -/* Configure the DEBUG modes for various part of the code */ -#define __DEBUG_MAP__ 0 -#define __DEBUG_SECTS__ 0 -#define __DEBUG_SORT__ 0 -#define __DEBUG_RELADD__ 0 -#define __DEBUG_COPYPLT__ 0 -#define __DEBUG_BSS__ 0 -#define __DEBUG_REDIR__ 0 -#define __DEBUG_RUNTIME__ 0 -#define __DEBUG_CFLOW__ 0 -#define __DEBUG_STATIC__ 0 -#define __DEBUG_BREAKPOINTS__ 0 -#define __DEBUG_ETRELintoETDYN__ 0 -#define __DEBUG_EXTPLT__ 0 -#define __DEBUG_TRACES__ 0 -#define __DEBUG_ARG_COUNT__ 0 -#define __DEBUG_HASH_BY_NAME__ 0 - -/* ELFsh architecture types */ -#define ELFSH_ARCH_IA32 0 -#define ELFSH_ARCH_IA64 1 -#define ELFSH_ARCH_SPARC32 2 -#define ELFSH_ARCH_SPARC64 3 -#define ELFSH_ARCH_PARISC 4 /* no hooks yet */ -#define ELFSH_ARCH_PPC32 5 /* no hooks yet */ -#define ELFSH_ARCH_PPC64 6 /* no hooks yet */ -#define ELFSH_ARCH_CRAY 7 /* no hooks yet */ -#define ELFSH_ARCH_ALPHA64 8 -#define ELFSH_ARCH_MIPS32 9 -#define ELFSH_ARCH_MIPS64 10 /* No hooks yet */ -#define ELFSH_ARCH_ARM 11 -#define ELFSH_ARCHNUM 12 -#define ELFSH_ARCH_ERROR 0xFF - -/* ELFsh ELF types */ -#define ELFSH_TYPE_EXEC 0 -#define ELFSH_TYPE_DYN 1 -#define ELFSH_TYPENUM 2 -#define ELFSH_TYPE_ERROR 0xFF - -/* ELFsh OS types */ -#define ELFSH_OS_LINUX 0 -#define ELFSH_OS_FREEBSD 1 -#define ELFSH_OS_NETBSD 2 -#define ELFSH_OS_OPENBSD 3 -#define ELFSH_OS_SOLARIS 4 -#define ELFSH_OS_UNICOS 5 -#define ELFSH_OS_BEOS 6 -#define ELFSH_OS_IOS 7 -#define ELFSH_OSNUM 8 -#define ELFSH_OS_ERROR 0xFF - -/* (k)e2dbg memory hosting types for the debugger hooks */ -#define E2DBG_HOST_KERN 0 -#define E2DBG_HOST_PROC 1 -#define E2DBG_HOSTNUM 2 -#define E2DBG_HOST_ERROR 0xFF - -/* libelfsh block hijack types */ -#define ELFSH_HIJACK_TYPE_FLOW 0x000000 -#define ELFSH_HIJACK_TYPE_GOT 0x010000 -#define ELFSH_HIJACK_TYPE_PLT 0x020000 - -/* The Various relocation stages */ -#define ELFSH_RELOC_STAGE1 1 -#define ELFSH_RELOC_STAGE2 2 - -/* The builtin hooks vectors list */ -#define ELFSH_HOOK_CFLOW "hook_cflow" -#define ELFSH_HOOK_REL "hook_rel" -#define ELFSH_HOOK_PLT "hook_plt" -#define ELFSH_HOOK_ENCODEPLT "hook_encodeplt" -#define ELFSH_HOOK_ENCODEPLT1 "hook_encodeplt1" -#define ELFSH_HOOK_EXTPLT "hook_extplt" -#define ELFSH_HOOK_ALTPLT "hook_altplt" -#define ELFSH_HOOK_ARGC "hook_argc" - -/* Some defined values */ -#define ELFSH_SECTION_NAME_MAPPED ".mapped" -#define ELFSH_SECTION_NAME_UNMAPPED ".unmapped" -#define ELFSH_SECTION_NAME_EXTRAREL ".elfsh.rel" -#define ELFSH_SECTION_NAME_EXTPLT ".elfsh.extplt" -#define ELFSH_SECTION_NAME_ALTPLT ".elfsh.altplt" -#define ELFSH_SECTION_NAME_ALTGOT ".elfsh.altgot" -#define ELFSH_SECTION_NAME_ALTPLTPROLOG ".elfsh.pltprolog" -#define ELFSH_SECTION_NAME_ALTGOTPROLOG ".elfsh.gotprolog" -#define ELFSH_SECTION_NAME_START ".elfsh.start" -#define ELFSH_SECTION_NAME_PADGOT ".elfsh.padgot" -#define ELFSH_SECTION_NAME_HOOKS ".elfsh.hooks" -#define ELFSH_SECTION_NAME_ALTDYNSYM ".elfsh.dynsym" -#define ELFSH_SECTION_NAME_ALTDYNSTR ".elfsh.dynstr" -#define ELFSH_SECTION_NAME_ALTRELPLT ".elfsh.relplt" -#define ELFSH_SECTION_NAME_PADPAGE ".elfsh.padpage" -#define ELFSH_SECTION_NAME_HASH ".hash" -#define ELFSH_SECTION_NAME_VERSYM ".version" -#define ELFSH_SECTION_NAME_ALTVERSYM ".elfsh.version" -#define ELFSH_SECTION_NAME_ALTHASH ".elfsh.hash" -#define ELFSH_SECTION_NAME_EDFMT_BLOCKS ".edfmt.blocks" -#define ELFSH_SECTION_NAME_EDFMT_BCONTROL ".edfmt.bcontrol" -#define ELFSH_SECTION_NAME_EDFMT_FUNCTIONS ".edfmt.function" -#define ELFSH_SECTION_NAME_EDFMT_FCONTROL ".edfmt.fcontrol" - -//#define ELFSH_SECTION_NAME_RPHT ".elfsh.rpht" -#define ELFSH_SECTION_NAME_RSHSTRTAB ".rshstrtab" -#define ELFSH_SECTION_NAME_RSYMTAB ".rsymtab" - -/* We need this for string based research, and for sht reconstruction */ -#define ELFSH_SECTION_NAME_NULL "" -#define ELFSH_SECTION_NAME_PLT ".plt" -#define ELFSH_SECTION_NAME_DTORS ".dtors" -#define ELFSH_SECTION_NAME_CTORS ".ctors" -#define ELFSH_SECTION_NAME_GOT ".got" -#define ELFSH_SECTION_NAME_RELPLT ".rel.plt" -#define ELFSH_SECTION_NAME_RELAPLT ".rela.plt" - -#define ELFSH_SECTION_NAME_RELGOT ".rel.got" -#define ELFSH_SECTION_NAME_RELDYN ".rel.dyn" -#define ELFSH_SECTION_NAME_RELADYN ".rela.dyn" -#define ELFSH_SECTION_NAME_RELABSS ".rela.bss" -#define ELFSH_SECTION_NAME_ALTRELDYN ".elfsh.reldyn" -#define ELFSH_SECTION_NAME_ALTRELADYN ".elfsh.reladyn" -#define ELFSH_SECTION_NAME_ALTRELGOT ".elfsh.relgot" -#define ELFSH_SECTION_NAME_ALTRELBSS ".elfsh.relabss" - -#define ELFSH_SECTION_NAME_GOTPLT ".got.plt" -#define ELFSH_SECTION_NAME_INTERP ".interp" -#define ELFSH_SECTION_NAME_SYMTAB ".symtab" -#define ELFSH_SECTION_NAME_STRTAB ".strtab" -#define ELFSH_SECTION_NAME_DYNSTR ".dynstr" -#define ELFSH_SECTION_NAME_SHSTRTAB ".shstrtab" -#define ELFSH_SECTION_NAME_BSS ".bss" -#define ELFSH_SECTION_NAME_TEXT ".text" -#define ELFSH_SECTION_NAME_DATA ".data" -#define ELFSH_SECTION_NAME_NOTES ".notes" -#define ELFSH_SECTION_NAME_NOTES_ABI ".notes.ABI-tag" -#define ELFSH_SECTION_NAME_DYNAMIC ".dynamic" -#define ELFSH_SECTION_NAME_COMMENT ".comment" -#define ELFSH_SECTION_NAME_RODATA ".rodata" -#define ELFSH_SECTION_NAME_STAB ".stab" -#define ELFSH_SECTION_NAME_EHFRAME ".eh_frame" -#define ELFSH_SECTION_NAME_INIT ".init" -#define ELFSH_SECTION_NAME_FINI ".fini" -#define ELFSH_SECTION_NAME_DEBUG ".debug" -#define ELFSH_SECTION_NAME_DW2_INFO ".debug_info" -#define ELFSH_SECTION_NAME_DW2_ARANGES ".debug_aranges" -#define ELFSH_SECTION_NAME_DW2_PUBNAMES ".debug_pubnames" -#define ELFSH_SECTION_NAME_DW2_ABBREV ".debug_abbrev" -#define ELFSH_SECTION_NAME_DW2_LINE ".debug_line" -#define ELFSH_SECTION_NAME_DW2_FRAME ".debug_frame" -#define ELFSH_SECTION_NAME_DW2_STR ".debug_str" -#define ELFSH_SECTION_NAME_DW2_MACINFO ".debug_macinfo" -#define ELFSH_SECTION_NAME_DW2_LOC ".debug_loc" - -/* Section index in the secthash */ -#define ELFSH_SECTION_NULL 0 -#define ELFSH_SECTION_INTERP 1 -#define ELFSH_SECTION_NOTE 2 -#define ELFSH_SECTION_HASH 3 -#define ELFSH_SECTION_DYNSYM 4 -#define ELFSH_SECTION_DYNSTR 5 -#define ELFSH_SECTION_GNUVERSYM 6 -#define ELFSH_SECTION_GNUVERNEED 7 -#define ELFSH_SECTION_GNUVERDEF 8 -#define ELFSH_SECTION_INIT 10 -#define ELFSH_SECTION_PLT 11 -#define ELFSH_SECTION_TEXT 12 -#define ELFSH_SECTION_FINI 13 -#define ELFSH_SECTION_RODATA 14 -#define ELFSH_SECTION_DATA 15 -#define ELFSH_SECTION_CTORS 17 -#define ELFSH_SECTION_DTORS 18 -#define ELFSH_SECTION_GOT 19 -#define ELFSH_SECTION_DYNAMIC 20 -#define ELFSH_SECTION_BSS 21 -#define ELFSH_SECTION_STAB 22 -#define ELFSH_SECTION_COMMENT 23 -#define ELFSH_SECTION_SHSTRTAB 24 -#define ELFSH_SECTION_SYMTAB 25 -#define ELFSH_SECTION_STRTAB 26 -#define ELFSH_SECTION_STABSTR 27 -#define ELFSH_SECTION_ALTPLT 28 -#define ELFSH_SECTION_PADGOT 28 /* shared */ -#define ELFSH_SECTION_ALTPLTPROLOG 29 -#define ELFSH_SECTION_ALTGOTPROLOG 29 /* shared */ -#define ELFSH_SECTION_ALTGOT 30 -#define ELFSH_SECTION_GOTPLT 31 -#define ELFSH_SECTION_MIPSTART 32 -#define ELFSH_SECTION_EXTPLT 33 -#define ELFSH_SECTION_RSHSTRTAB 34 -#define ELFSH_SECTION_RSYMTAB 35 -#define ELFSH_SECTION_DEBUG 36 -#define ELFSH_SECTION_DW2_INFO 37 -#define ELFSH_SECTION_DW2_ARANGES 38 -#define ELFSH_SECTION_DW2_PUBNAMES 39 -#define ELFSH_SECTION_DW2_ABBREV 40 -#define ELFSH_SECTION_DW2_LINE 41 -#define ELFSH_SECTION_DW2_FRAME 42 -#define ELFSH_SECTION_DW2_STR 43 -#define ELFSH_SECTION_DW2_MACINFO 44 -#define ELFSH_SECTION_DW2_LOC 45 -#define ELFSH_SECTION_VERSYM 46 -#define ELFSH_SECTION_MAX 254 -#define ELFSH_SECTION_UNKNOWN 255 - - -/* Some constants */ -#define ELFSH_PLT_ENTRY_SIZE 16 -#define ELFSH_SYMTAB_ENTRY_SIZE sizeof(elfsh_Sym) - -#define ELFSH_STARTSYM "_start" -#define ELFSH_GOTSYM "_GLOBAL_OFFSET_TABLE_" -#define ELFSH_NULL_STRING "(NULL)" -#define ELFSH_SORT_BY_ADDR 'a' -#define ELFSH_SORT_BY_SIZE 's' -#define ELFSH_SORT_BY_NAME 'n' - -/* Dedicated to you know who */ -#define ELFSH_MEANING 42 - -#define ELFSH_SECTION_FIRST 0 -#define ELFSH_SECTION_LAST 0xFFFF -#define ELFSH_BLOCK_FIRST 0 -#define ELFSH_BLOCK_LAST 0xFFFF - -#define ELFSH_SPARC_LOWADDR 0x2000 -#define ELFSH_INVALID_ADDR 0xFFFFFFFF -#define ELFSH_NOLIMIT 0 - -#define ELFSH_END_CTORS ((eresi_Addr) 0xFFFFFFFF) -#define ELFSH_END_DTORS ELFSH_END_CTORS - -#define ELFSH_SHIFTING_ABSENT 0 -#define ELFSH_SHIFTING_NONE 1 -#define ELFSH_SHIFTING_MIPSPLT 2 -#define ELFSH_SHIFTING_PARTIAL 3 -#define ELFSH_SHIFTING_COMPLETE 4 - -#define ELFSH_UNSET_OFFSET (1 << 30) - -#define ELFSH_LOWSYM 1 -#define ELFSH_HIGHSYM 2 -#define ELFSH_EXACTSYM 3 - -#define ELFSH_DATA_INJECTION 0 -#define ELFSH_CODE_INJECTION 1 -#define ELFSH_UNMAPPED_INJECTION 2 -#define ELFSH_UNKNOWN_INJECTION 3 - -#define ELFSH_TRACE_MAX_ARGS 30 - -#define STT_BLOCK (STT_NUM) - -#define DUMPABLE(sym) (elfsh_get_symbol_type(sym) == STT_FUNC || \ - elfsh_get_symbol_type(sym) == STT_OBJECT || \ - elfsh_get_symbol_type(sym) == STT_COMMON || \ - elfsh_get_symbol_type(sym) == STT_SECTION) - -#define FILE_IS_SPARC(obj) (FILE_IS_SPARC32(obj) || FILE_IS_SPARC64(obj)) -#define FILE_IS_SPARC32(obj) (((elfsh_get_arch((obj)->hdr) == EM_SPARC) || \ - (elfsh_get_arch((obj)->hdr) == EM_SPARC32PLUS)) ? 1 : 0) - -#define FILE_IS_SPARC64(obj) ((elfsh_get_arch((obj)->hdr) == EM_SPARCV9) ? 1 : 0) - -#define FILE_IS_MIPS(obj) (elfsh_get_arch((obj)->hdr) == EM_MIPS || \ - elfsh_get_arch((obj)->hdr) == EM_MIPS_RS3_LE ? 1 : 0) - -#define FILE_IS_IA64(obj) ((elfsh_get_arch((obj)->hdr)) == EM_IA_64 ? 1 : 0) -#define FILE_IS_IA32(obj) ((elfsh_get_arch((obj)->hdr)) == EM_386 ? 1 : 0) - -#define FILE_IS_ALPHA64(obj) ((elfsh_get_arch((obj)->hdr)) == EM_ALPHA || \ - (elfsh_get_arch((obj)->hdr)) == EM_ALPHA_EXP ? 1 : 0) - -#define IS_REL(scn) (FILE_IS_SPARC((scn)->parent) || \ - FILE_IS_SPARC64((scn)->parent) || \ - FILE_IS_IA64((scn)->parent) || \ - FILE_IS_ALPHA64((scn)->parent) ? 0 : 1) - - -#define ELFSH_SELECT_INJECTION(a, b, d) \ -do \ -{ \ - if ((elfsh_get_ostype(a) == ELFSH_OS_FREEBSD || \ - elfsh_get_ostype(a) == ELFSH_OS_BEOS || \ - elfsh_get_ostype(a) == ELFSH_OS_SOLARIS || \ - FILE_IS_ALPHA64(a) || FILE_IS_MIPS(a) || \ - FILE_IS_SPARC(a)) || (b)) \ - d = ELFSH_DATA_INJECTION; \ - else \ - d = ELFSH_CODE_INJECTION; \ -} while (0) - - - -/* Old Pax flags (to be read in elfhdr.e_flags) */ -#define ELFSH_PAX_PAGEEXEC 1 /* Paging based non-exec pages */ -#define ELFSH_PAX_EMULTRAMP 2 /* Emulate trampolines */ -#define ELFSH_PAX_MPROTECT 4 /* Restrict mprotect() */ -#define ELFSH_PAX_RANDMMAP 8 /* Randomize mmap() base */ -#define ELFSH_PAX_RANDEXEC 16 /* Randomize ET_EXEC base */ -#define ELFSH_PAX_SEGMEXEC 32 /* Segmentation based non-exec pages */ - -/* EI_RPHT is not PaX related */ -#define EI_PAX 14 /* Index in e_ident[] where to read flags */ -#define EI_RPHT 10 /* Index in e_ident[] where to read rphtoff */ - -/* Those symbol doesn't exist on every OS */ -#ifndef SHT_GNU_verdef -#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ -#endif -#ifndef SHT_GNU_verneed -#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ -#endif -#ifndef SHT_GNU_versym -#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ -#endif - -/** - * ELFsh redirection abstract unit - */ -typedef struct s_redir -{ -#define ELFSH_REDIR_CFLOW 0 -#define ELFSH_REDIR_ALTPLT 1 -#define ELFSH_REDIR_ALTGOT 2 - u_char type; /* Redirection type */ - -#define ELFSH_ORIG_FUNC 0 -#define ELFSH_HOOK_FUNC 1 - char *name[2]; /* Name of involved functions */ - eresi_Addr addr[2]; /* Redirection address */ -} elfshredir_t; - - -/** - * ELFsh private stab entry - */ -typedef struct s_stab -{ - eresi_Addr strindex; - unsigned char type; - unsigned char other; - unsigned short desc; - eresi_Addr value; -} elfshstabent_t; - - -/** - * ELFsh private .notes entry format - */ -typedef struct s_nentry -{ - int namesz; - int descsz; - int type; - char *note; - char *desc; - struct s_nentry *next; - struct s_nentry *prev; -} elfshnotent_t; - - -/** - * Version structures - */ -typedef struct s_hashneed -{ - elfsh_Verneed *need; - elfsh_Vernaux *aux; -} hashneed_t; - -typedef struct s_hashdef -{ - void *ps; - elfsh_Verdef *def; - elfsh_Word *aux; -} hashdef_t; - - -/** - * ELFsh private relocation format - */ -typedef struct s_rel -{ - u_int idx_src; - u_int off_src; - u_int idx_dst; - u_int off_dst; - -/* The dword is to be patched depending on section's base */ -#define ELFSH_RELOC_SECTBASE 0 - -/* This entry is a false positive : do not relocate */ -#define ELFSH_RELOC_FP 0xFFFFFFFF - u_int type; -} elfshrel_t; - - -/* forward declaration */ -struct s_sect; -struct s_obj; -typedef struct s_sect elfshsect_t; -typedef struct s_obj elfshobj_t; - - -/** - * @brief Section data type - */ -struct s_sect -{ - - /* Filled at creation */ - char *name; /*! Cached name */ - struct s_obj *parent; /*! Parent Object */ - elfsh_Phdr *phdr; /*! the first parent segment */ - - /* Filled at creation, can be modified when SHT is sorted */ - elfsh_Shdr *shdr; /*! section header for this section */ - int index; /*! Section index in sht */ - struct s_sect *next; /*! Next section in the list */ - struct s_sect *prev; /*! Prev section in the list */ - - /* ELFsh section state */ -#define ELFSH_SECTION_ANALYZED (1 << 0) -#define ELFSH_SECTION_INSERTED (1 << 1) -#define ELFSH_SECTION_MOVED (1 << 2) -#define ELFSH_SECTION_REMOVED (1 << 3) -#define ELFSH_SECTION_RUNTIME (1 << 4) - char flags; /*! Analysed/Raw, Orphelin/Inserted, Moved, Removed, Runtime/Static */ - - /* Filled at loading */ - void *data; /*! Section's data cache in file */ - - /* Filled at analysing */ - void *altdata; /*! Type dependant internal format */ - void *terdata; /*! Alternate type dependant internal format */ - void *lastdata; /*! Last type dependant internal format */ - - /* Filled at 'unrelocation' : ELFsh private relocs fmt only used in experimental features */ - elfshrel_t *rel; /*! ELFsh private relocation table for this section */ - u_int srcref; /*! Number of absolute reference FROM this section : sizeof(rel) */ - u_int dstref; /*! Number of absolute reference TO this section */ - - /* Changed during extension */ - u_int curend; /*! Current real end of section : we save room when possible */ - -}; - - -/** - * @brief Link map structure - */ -typedef struct s_link_map -{ - eresi_Addr laddr; /*! Base address shared object is loaded at. */ - char *lname; /*! Absolute file name object was found in. */ - elfsh_Dyn *lld; /*! Dynamic section of the shared object. */ - struct s_link_map *lnext; /*! Next object in linkmap */ - struct s_link_map *lprev; /*! Prev object in linkmap */ -} elfshlinkmap_t; - - -/** - * @brief The runtime ELF header (unofficial ELF extension) - * This structure has been introduced since the Embedded ELF Debugger - */ -typedef struct s_rehdr -{ - uint16_t rphtnbr; /*! Number of entries in RPHT */ - uint16_t rshtnbr; /*! Number of entries in RSHT */ - eresi_Addr base; /*! Base address (runtime ET_DYN object base) */ - -} elfshrhdr_t; - -/** - * Debug format pointers - */ -typedef struct s_dfmt -{ - void *uni; - void *dwarf2; - void *stabs; -} elfshdfmt_t; - -/* core file support linux/bsd */ -#define ELFSH_CORE_LINUX 0x01000 -#define ELFSH_CORE_FREEBSD 0x10000 -#define ELFSH_CORE_HAS_NOTHING 0x00000 -#define ELFSH_CORE_HAS_PRSTATUS 0x00001 -#define ELFSH_CORE_HAS_PRPSINFO 0x00010 -#define ELFSH_CORE_HAS_FPREGSET 0x00100 - -#define elfsh_roundup(x, y) ((((x)+((y)-1))/(y))*(y)) - -#define PRFNAMESZ 16 /* Maximum command length saved */ -#define PRARGSZ 80 /* Maximum argument bytes saved */ -#define PRPSINFO_VERSION 1 /* Current version of prpsinfo_t */ - -/** - * Documentation missing. - */ -typedef struct elfsh_bsdprpsinfo -{ - int pr_version; /*! Version number of struct (1) */ - size_t pr_psinfosz; /*! sizeof(prpsinfo_t) (1) */ - char pr_fname[PRFNAMESZ+1]; /*! Command name, null terminated (1) */ - char pr_psargs[PRARGSZ+1]; /*! Arguments, null terminated (1) */ -} elfsh_bsdprpsinfo_t; - -/** - * Documentation missing. - */ -typedef struct elfsh_bsdureg -{ - unsigned int r_fs; - unsigned int r_es; - unsigned int r_ds; - unsigned int r_edi; - unsigned int r_esi; - unsigned int r_ebp; - unsigned int r_isp; - unsigned int r_ebx; - unsigned int r_edx; - unsigned int r_ecx; - unsigned int r_eax; - unsigned int r_trapno; - unsigned int r_err; - unsigned int r_eip; - unsigned int r_cs; - unsigned int r_eflags; - unsigned int r_esp; - unsigned int r_ss; - unsigned int r_gs; -} elfsh_bsduregset_t; - -/** - * Documentation missing. - */ -typedef struct elfsh_bsdfpreg -{ - unsigned long fpr_env[7]; - unsigned char fpr_acc[8][10]; - unsigned long fpr_ex_sw; - unsigned char fpr_pad[64]; -} elfsh_bsdfpregs_t; - - -#define PRSTATUS_VERSION 1 /* Current version of prstatus_t */ - -/** - * Documentation missing. - */ -typedef struct elfsh_bsdprstatus -{ - int pr_version; /* Version number of struct (1) */ - size_t pr_statussz; /* sizeof(prstatus_t) (1) */ - size_t pr_gregsetsz; /* sizeof(gregset_t) (1) */ - size_t pr_fpregsetsz; /* sizeof(fpregset_t) (1) */ - int pr_osreldate; /* Kernel version (1) */ - int pr_cursig; /* Current signal (1) */ - pid_t pr_pid; /* Process ID (1) */ - elfsh_bsduregset_t pr_reg; /* General purpose registers (1) */ -} elfsh_bsdprstatus_t; - -/** - * Documentation missing. - */ -typedef struct user_regs -{ - long int ebx; - long int ecx; - long int edx; - long int esi; - long int edi; - long int ebp; - long int eax; - long int xds; - long int xes; - long int xfs; - long int xgs; - long int orig_eax; - long int eip; - long int xcs; - long int eflags; - long int esp; - long int xss; -} elfsh_uregset_t; - -/** - * Documentation missing. - */ -typedef struct user_fpregs -{ - long int cwd; - long int swd; - long int twd; - long int fip; - long int fcs; - long int foo; - long int fos; - long int st_space [20]; -} elfsh_fpregs_t; - -/** - * Documentation missing. - * XXX si_signo, si_code, si_errno exists in NetBSD.... - */ -typedef struct s_siginfo -{ - int esh_si_signo; /* Signal number. */ - int esh_si_code; /* Extra code. */ - int esh_si_errno; /* Errno. */ -} elfsh_siginfo_t; - -/** - * Documentation missing. - */ -typedef struct elfsh_prstatus -{ - elfsh_siginfo_t pr_info; /* Info associated with signal. */ - short int pr_cursig; /* Current signal. */ - unsigned long int pr_sigpend; /* Set of pending signals. */ - unsigned long int pr_sighold; /* Set of held signals. */ - pid_t pr_pid; - pid_t pr_ppid; - pid_t pr_pgrp; - pid_t pr_sid; - struct timeval pr_utime; /* User time. */ - struct timeval pr_stime; /* System time. */ - struct timeval pr_cutime; /* Cumulative user time. */ - struct timeval pr_cstime; /* Cumulative system time. */ - elfsh_uregset_t pr_reg; /* GP registers. */ - int pr_fpvalid; /* True if math copro being used. */ -} elfsh_prstatus_t; - -#define ELF_PRARGSZ (80) /* Number of chars for args. */ - -/** - * Documentation missing. - */ -typedef struct elfsh_prpsinfo -{ - char pr_state; /* Numeric process state. */ - char pr_sname; /* Char for pr_state. */ - char pr_zomb; /* Zombie. */ - char pr_nice; /* Nice val. */ - unsigned long int pr_flag; /* Flags. */ - unsigned short int pr_uid; - unsigned short int pr_gid; - int pr_pid, - pr_ppid, - pr_pgrp, - pr_sid; - char pr_fname[16]; /* Filename of executable. */ - char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */ -} elfsh_prpsinfo_t; - -/** - * core file info structure - * needs to be improved - */ -typedef struct linux_core -{ - uint16_t offset; /* offset for note section in the file */ - uint16_t filesz; /* size of the section */ - - elfsh_Nhdr nhdr; /* core files should have only one note entry */ - - long flags; /* ELFSH_CORE_HAS_NOTHING, ELFSH_CORE_HAS_PRSTATUS, ... */ - - elfsh_prstatus_t prstatus; /* PRSTATUS structure */ - elfsh_prpsinfo_t prpsinfo; /* PRPSINFO structure */ - elfsh_fpregs_t fpregs; /* Floating point saved register */ - -} elfshcore_t; - -/** - * BSD core file info structure - */ -typedef struct bsd_core -{ - uint16_t offset; - uint16_t filesz; - - elfsh_Nhdr nhdr; - - long flags; - - elfsh_bsdprstatus_t prstatus; - elfsh_bsdprpsinfo_t prpsinfo; - elfsh_bsdfpregs_t fpregs; - -} elfshbsdcore_t; - -/** - * @brief ELF object structure - */ -struct s_obj -{ - elfsh_Ehdr *hdr; /*!< @brief Elf header */ - elfsh_Shdr *sht; /*!< @brief Section header table */ - elfsh_Phdr *pht; /*!< @brief Program Header table */ - elfshsect_t *sectlist; /*!< @brief Section linked list */ - - elfshrhdr_t rhdr; /*!< The Runtime header */ - elfsh_Shdr *rsht; /*!< The Runtime SHT */ - elfsh_Phdr *rpht; /*!< The Runtime PHT */ - elfshsect_t *rsectlist; /*!< Runtime Section linked list */ - elfshsect_t *secthash[ELFSH_SECTION_MAX]; /*!< Section hash table (common) */ - - elfshcore_t core; - elfshbsdcore_t bsdcore; - int coretype; - - int fd; /*!< @brief File descriptor for the original file */ - char *name; /*!< @brief Object path */ - struct stat fstat; /*!< @brief File stat */ - int type; /* ELFSH_OBJECT_CORE, ELFSH_OBJECT_SHARED, ELFSH_OBJECT_RELOC or ELFSH_OBJECT_EXEC */ - int rights; /* 0 = RO, 1 = WR */ - time_t loadtime; /* Time of Loading */ - u_int id; /* Object ID */ - - char running; /* !< @brief Is the process running ? */ - char scanned; /* !< @brief Has the object already been block scanned ? */ - char hdr_broken; /* !< @brief Is the header broken/corrupted ? */ - char read; /* !< @brief Has the object already been read ? */ - char shtrm; /* !< @brief Mark SHT and Unmapped sections as stripped ? */ - char strip; /* !< @brief Mark file as stripped */ - char pending; /* !< @brief Beeing injected */ - uint32_t nbrm; /* !< @brief Number of section headers to remove at saving */ - - char shtrb; /* !< @brief Reconstruct the SHT if non present */ - -#define ELFSH_MAXREL 1000 /* !< @brief Maximum number of injected ET_REL, change it ! */ - struct s_obj *listrel[ELFSH_MAXREL];/* !< @brief Array of injected ET_REL in this object */ - u_int nbrel; /* !< @brief Number of injected ET_REL in this object */ - - char buff[ELFSH_MEANING]; /* !< @brief Internal buffer, sometimes used to avoid a malloc */ - const char *error; /* !< @brief Last error string */ - struct s_obj *next; /* !< @brief The list is simply linked */ - struct s_obj *original; /* !< @brief Original file (if its a copy) */ - - hash_t redir_hash; /* !< @brief Redirections hash table */ - -#if !defined(sun) - elfshlinkmap_t *linkmap; /* !< @brief Linkmap */ -#else - Link_map *linkmap; /* !< @brief Solaris linkmap */ -#endif - - elfshdfmt_t debug_format; /* !< @brief Debug format informations */ - -#define ELFSH_SYMHASH_NAME "elfsh_symhash" -#define ELFSH_DYNSYMHASH_NAME "elfsh_dynsymhash" - hash_t symhash; /* !< @brief Symtab hash table */ - hash_t dynsymhash; /* !< @brief Dynsym hash table */ - - /* - ** Every object can have childs - ** The number 0 is used as a seperator: - ** 1: (Father) - ** |-> 101 Child1 - ** |-> .... - ** |-> 1012 Child12 - ** - ** Max childs for a father should be 99, then we can control a strange id like 101001 (1 => 10 => 1) - */ -#define ELFSH_CHILD_BASE(o) (o->id * 100 * (o->lastchildid > 9 ? 10 : 1)) -#define ELFSH_CHILD_NEW(o) ELFSH_CHILD_BASE(o) + ++o->lastchildid -#define ELFSH_CHILD_MAX 99 - hash_t child_hash; /* !< @brief Childs hash table */ - hash_t parent_hash; /* !< @brief Immediate parent hash table */ - hash_t root_hash; /* !< @brief Root ELF objects for this file */ - int lastchildid; /* !< @brief Last child id */ -}; - - - -/** - * The library has its world itself - * There stands all the flags that are used by libelfsh - */ -typedef struct s_libstate -{ - -#define LIBELFSH_MODE_UNKNOWN 0 -#define LIBELFSH_MODE_STATIC 1 -#define LIBELFSH_MODE_E2DBG 2 - u_char mode; /* The current working mode (ondisk/memory) */ - u_char indebug; /* 1 when inside the debugger */ -} libworld_t; - - - -/** - * Elfsh break points - */ -typedef struct s_bp -{ - - /* XXX: To comment ! */ -#define UNDEF 0 -#define INSTR 1 - u_char type; - - u_char savedinstr[16]; /* !< @brief Saved bytes at breakpoints addr */ - char *cmd[10]; /* !< @brief Commands to be executed on hit */ - char cmdnbr; /* !< @brief Next available cmd slot */ - eresi_Addr addr; /* !< @brief Address of breakpoint */ - uint32_t id; /* !< @brief Breakpoint ID */ - char *symname; /* !< @brief Symbol match, if any */ - elfshobj_t *obj; /* !< @brief Parent object of breakpoint */ - pid_t tid; /* !< @brief Thread id of breakpoint */ - -#define ELFSH_BP_BREAK 0 /* !< @brief Classical breakpoint */ -#define ELFSH_BP_WATCH 1 /* !< @brief Do not get back to debugger */ - u_char flags; /* !< @brief Breakpoint flags */ -} elfshbp_t; - -/** - * Trace structure - */ -typedef struct s_traces_args -{ - char *name; - char *typename; - int size; -} elfshtracesargs_t; - -/** - * Documentation missing. - */ -typedef struct s_traces -{ -#define ELFSH_TRACES_TYPE_DEFAULT "global" -#define ELFSH_TRACES_FUNC_SIZE 256 - char funcname[ELFSH_TRACES_FUNC_SIZE]; - elfshobj_t *file; - u_char enable; - u_int offset; - -#define ELFSH_ARG_INTERN 0 -#define ELFSH_ARG_EXTERN 1 - u_char scope; - -#define ELFSH_ARG_SIZE_BASED 0 -#define ELFSH_ARG_TYPE_BASED 1 - u_char type; - - eresi_Addr vaddr; - -#define ELFSH_TRACES_MAX_ARGS 20 - elfshtracesargs_t arguments[ELFSH_TRACES_MAX_ARGS]; - u_int argc; -} elfshtraces_t; - -/* Extern data */ -extern libworld_t dbgworld; -extern hash_t traces_table; -extern hash_t exclude_table; - -#if defined(KERNSH) -#include "libkernsh.h" -#endif - -/* - ** - ** Libelfsh API prototypes - ** - ** Check elfsh/doc/libelfsh-api.txt for a complete description - ** - ** XXX: libelfsh-api.txt not updated to 0.5 (it is for 0.43b) - ** FIXME: Please put your comments at the doxygen format - */ - -/* dynamic.c */ -elfsh_Dyn *elfsh_get_dynamic(elfshobj_t *file, u_int *num); -elfsh_Dyn *elfsh_get_dynamic_entry_by_type(elfshobj_t *file, elfsh_Word type); -elfsh_Sword elfsh_get_dynentry_type(elfsh_Dyn *d); -int elfsh_set_dynentry_type(elfsh_Dyn *d, eresi_Addr tag); -elfsh_Word elfsh_get_dynentry_val(elfsh_Dyn *d); -int elfsh_set_dynentry_val(elfsh_Dyn *d, eresi_Addr val); -elfsh_Dyn *elfsh_get_dynamic_entry_by_index(elfsh_Dyn *dynamic, eresi_Addr index); -char *elfsh_get_dynentry_string(elfshobj_t *file, elfsh_Dyn *ent); -int elfsh_endianize_dynamic(elfshsect_t *_new); -int elfsh_shift_dynamic(elfshobj_t *file, u_int size); -int elfsh_get_dynent_by_type(elfshobj_t *robj, elfsh_Dyn *data, elfsh_Word real_index); - -/* symbol.c */ -int elfsh_init_symbol_hashtables(elfshobj_t *file); -elfsh_Sym *elfsh_get_symbol_by_name(elfshobj_t *file, char *name); -char *elfsh_reverse_symbol(elfshobj_t *file, eresi_Addr sym_value, elfsh_SAddr *offset); -char *elfsh_get_symbol_name(elfshobj_t *file, elfsh_Sym *s); -void *elfsh_get_symtab(elfshobj_t *file, int *num); -elfsh_Sym *elfsh_get_symbol_by_value(elfshobj_t *file, eresi_Addr vaddr, int *off, int mode); -elfsh_Sym *elfsh_get_dynsymbol_by_value(elfshobj_t *file, eresi_Addr vaddr, int *off, int mode); -int elfsh_strip(elfshobj_t *file); -int elfsh_set_symbol_name(elfshobj_t *file, elfsh_Sym *s, char *name); -int elfsh_shift_symtab(elfshobj_t *file, eresi_Addr lim, int inc); -int elfsh_insert_sectsym(elfshobj_t *file, elfshsect_t *sect); -int elfsh_get_symbol_foffset(elfshobj_t *file, elfsh_Sym *sym); -int elfsh_insert_symbol(elfshsect_t *sect, elfsh_Sym *sym, char *name); -int elfsh_insert_funcsym(elfshobj_t *file, char *name, eresi_Addr vaddr, - uint32_t sz, uint32_t sctidx); - -/* dynsym.c */ -elfsh_Sym *elfsh_get_dynsymbol_by_name(elfshobj_t *file, char *name); -void *elfsh_get_dynsymtab(elfshobj_t *file, int *num); -char *elfsh_reverse_dynsymbol(elfshobj_t *file, eresi_Addr sym_value, elfsh_SAddr *offset); -char *elfsh_get_dynsymbol_name(elfshobj_t *file, elfsh_Sym *s); -int elfsh_set_dynsymbol_name(elfshobj_t *file, elfsh_Sym *s, char *name); -int elfsh_shift_dynsym(elfshobj_t *file, eresi_Addr limit, int inc); - -/* dwarf.c */ -int elfsh_get_dwarf(elfshobj_t *file); -void *elfsh_get_dwarf_info(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_abbrev(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_aranges(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_frame(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_line(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_macinfo(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_pubnames(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_str(elfshobj_t *file, int *num); -void *elfsh_get_dwarf_loc(elfshobj_t *file, int *num); - -/* sym_common.c */ -elfsh_Sym elfsh_create_symbol(eresi_Addr value, int size, int type, int binding, int vis, int idx); -elfsh_Sym *elfsh_copy_symtab(void *addr, int size); -elfsh_Sym *elfsh_merge_symtabs(elfsh_Sym *one, elfsh_Sym *two, int size_one, int size_two); -elfsh_Sym *elfsh_get_sym_by_value(elfsh_Sym *sym, int num, eresi_Addr vaddr, int *off, int mode); -elfsh_Word elfsh_get_symbol_size(elfsh_Sym *s); -int elfsh_set_symbol_size(elfsh_Sym *s, eresi_Addr size); -eresi_Addr elfsh_get_symbol_value(elfsh_Sym *s); -int elfsh_set_symbol_value(elfsh_Sym *s, eresi_Addr value); -u_char elfsh_get_symbol_bind(elfsh_Sym *s); -u_char elfsh_set_symbol_bind(elfsh_Sym *s, eresi_Addr opt); -u_char elfsh_get_symbol_type(elfsh_Sym *s); -u_char elfsh_set_symbol_type(elfsh_Sym *s, eresi_Addr type); -u_char elfsh_get_symbol_visibility(elfsh_Sym *s); -u_int elfsh_set_symbol_visibility(elfsh_Sym *s, eresi_Addr vis); -u_int elfsh_get_symbol_link(elfsh_Sym *s); -u_int elfsh_set_symbol_link(elfsh_Sym *s, eresi_Addr val); -elfsh_Sym *elfsh_get_symbol_by_index(elfsh_Sym *symtab, eresi_Addr index); -elfsh_Sym *elfsh_get_metasym_by_name(elfshobj_t *file, char *name); -elfsh_Sym *elfsh_get_metasym_by_value(elfshobj_t *file, eresi_Addr vaddr, int *off, int mode); -char *elfsh_reverse_metasym(elfshobj_t *file, eresi_Addr vaddr, elfsh_SAddr *off); -int elfsh_remove_symbol(elfshsect_t *symtab, char *name); -void elfsh_symtab_endianize(elfshsect_t *tab); -int elfsh_endianize_symtab(elfshsect_t *tab); -int elfsh_shift_syms(elfshobj_t *file, elfshsect_t *symtab, - eresi_Addr limit, int inc); -int elfsh_resolv_remote_function(elfshobj_t *filein, eresi_Addr vaddrin, - elfshobj_t **fileout, eresi_Addr *vaddrout); - -/* obj.c */ -elfshobj_t *elfsh_load_obj(char *name); -void elfsh_unload_obj(elfshobj_t *file); - -/* elf.c */ -int elfsh_load_hdr(elfshobj_t *file); -void *elfsh_get_hdr(elfshobj_t *file); -elfsh_Off elfsh_get_shtoff(elfsh_Ehdr *e); -elfsh_Half elfsh_get_shtnbr(elfsh_Ehdr *e); -elfsh_Off elfsh_get_phtoff(elfsh_Ehdr *e); -elfsh_Half elfsh_get_phtnbr(elfsh_Ehdr *e); -eresi_Addr elfsh_get_entrypoint(elfsh_Ehdr *e); -elfsh_Half elfsh_get_arch(elfsh_Ehdr *e); -elfsh_Half elfsh_get_objtype(elfsh_Ehdr *e); -elfsh_Half elfsh_get_shstrtab_index(elfsh_Ehdr *e); -elfsh_Word elfsh_get_version(elfsh_Ehdr *e); -elfsh_Half elfsh_get_ehsize(elfsh_Ehdr *e); -elfsh_Half elfsh_get_phentsize(elfsh_Ehdr *e); -elfsh_Half elfsh_get_shentsize(elfsh_Ehdr *e); -int elfsh_set_shtoff(elfsh_Ehdr *e, eresi_Addr off); -int elfsh_set_shtnbr(elfsh_Ehdr *e, eresi_Addr num); -int elfsh_set_phtoff(elfsh_Ehdr *e, eresi_Addr num); -int elfsh_set_phtnbr(elfsh_Ehdr *e, eresi_Addr num); -int elfsh_set_entrypoint(elfsh_Ehdr *e, eresi_Addr addr); -u_int elfsh_set_arch(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_objtype(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_shstrtab_index(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_version(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_ehsize(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_phentsize(elfsh_Ehdr *e, eresi_Addr val); -u_int elfsh_set_shentsize(elfsh_Ehdr *e, eresi_Addr val); -int elfsh_get_encoding(elfsh_Ehdr *hdr); -int elfsh_set_encoding(elfsh_Ehdr *hdr, eresi_Addr type); -int elfsh_set_flags(elfsh_Ehdr *hdr, eresi_Addr flags); -elfsh_Word elfsh_get_flags(elfsh_Ehdr *hdr); -int elfsh_set_magic(elfsh_Ehdr *hdr, eresi_Addr mag); -int elfsh_get_magic(elfsh_Ehdr *hdr); -int elfsh_set_class(elfsh_Ehdr *hdr, eresi_Addr _class); -int elfsh_get_class(elfsh_Ehdr *hdr); -void elfsh_endianize_elfhdr(elfsh_Ehdr *e, char byteorder); - -int elfsh_static_file(elfshobj_t *file); -int elfsh_dynamic_file(elfshobj_t *file); -int elfsh_set_rphtoff(elfsh_Ehdr *hdr, eresi_Addr num); -elfsh_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr); -int elfsh_get_core_notes(elfshobj_t *file); - - -/* pax.c */ -int elfsh_set_paxflags(elfsh_Ehdr *hdr, eresi_Addr flags); -elfsh_Word elfsh_get_paxflags(elfsh_Ehdr *hdr); -char elfsh_set_pax_pageexec(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_pageexec(elfsh_Ehdr *hdr); -char elfsh_set_pax_emultramp(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_emultramp(elfsh_Ehdr *hdr); -char elfsh_set_pax_mprotect(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_mprotect(elfsh_Ehdr *hdr); -char elfsh_set_pax_randmmap(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_randmmap(elfsh_Ehdr *hdr); -char elfsh_set_pax_randexec(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_randexec(elfsh_Ehdr *hdr); -char elfsh_set_pax_segmexec(elfsh_Ehdr *hdr, eresi_Addr off); -char elfsh_get_pax_segmexec(elfsh_Ehdr *hdr); - - -/* stab.c */ -void *elfsh_get_stab(elfshobj_t *file, int *num); -eresi_Addr elfsh_get_stab_offset(elfshstabent_t *s); -char *elfsh_get_stab_name(elfshobj_t *file, elfshstabent_t *s); -u_int elfsh_get_stab_type(elfshstabent_t *s); - - -/* sht.c */ -elfsh_Shdr *elfsh_get_shtentry_from_sym(elfshobj_t *file, elfsh_Sym *sym); -void *elfsh_get_sht(elfshobj_t *file, int *num); -void *elfsh_get_runtime_sht(elfshobj_t *file, int *num); -int elfsh_load_sht(elfshobj_t *file); -elfsh_Sym *elfsh_get_sym_from_shtentry(elfshobj_t *file, elfsh_Shdr *hdr); -elfsh_Word elfsh_get_section_info(elfsh_Shdr *s); -elfsh_Word elfsh_get_section_entsize(elfsh_Shdr *s); -elfsh_Word elfsh_get_section_link(elfsh_Shdr *s); -elfsh_Off elfsh_get_section_foffset(elfsh_Shdr *s); -eresi_Addr elfsh_get_section_addr(elfsh_Shdr *s); -elfsh_Word elfsh_get_section_align(elfsh_Shdr *s); -elfsh_Word elfsh_get_section_size(elfsh_Shdr *s); -elfsh_Word elfsh_get_section_type(elfsh_Shdr *s); -int elfsh_set_section_info(elfsh_Shdr *s, eresi_Addr info); -int elfsh_set_section_entsize(elfsh_Shdr *s, eresi_Addr entsize); -int elfsh_set_section_link(elfsh_Shdr *s, eresi_Addr link); -int elfsh_set_section_foffset(elfsh_Shdr *s, eresi_Addr offset); -int elfsh_set_section_addr(elfsh_Shdr *s, eresi_Addr addr); -int elfsh_set_section_align(elfsh_Shdr *s, eresi_Addr align); -int elfsh_set_section_size(elfsh_Shdr *s, eresi_Addr size); -int elfsh_set_section_type(elfsh_Shdr *s, eresi_Addr type); -char elfsh_get_section_execflag(elfsh_Shdr *s); -char elfsh_get_section_writableflag(elfsh_Shdr *s); -char elfsh_get_section_allocflag(elfsh_Shdr *s); -char elfsh_get_section_mergeableflag(elfsh_Shdr *s); -char elfsh_get_section_strflag(elfsh_Shdr *s); -char elfsh_get_section_linkflag(elfsh_Shdr *s); -char elfsh_get_section_orderflag(elfsh_Shdr *s); -char elfsh_set_section_execflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_writableflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_allocflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_mergeableflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_strflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_linkflag(elfsh_Shdr *s, eresi_Addr val); -char elfsh_set_section_orderflag(elfsh_Shdr *s, eresi_Addr val); -int elfsh_insert_shdr(elfshobj_t *file, elfsh_Shdr hdr, u_int range, char *name, char shift); -void elfsh_remove_sht(elfshobj_t *file); -int elfsh_set_section_name(elfshobj_t *file, elfshsect_t *sect, char *name); -char *elfsh_get_section_name(elfshobj_t *file, elfshsect_t *s); -elfsh_Shdr elfsh_create_shdr(elfsh_Word name, elfsh_Word type, elfsh_Word flags, - eresi_Addr addr, elfsh_Off offset, elfsh_Word size, - elfsh_Word link, elfsh_Word info, elfsh_Word align, - elfsh_Word entsize); -int elfsh_insert_runtime_shdr(elfshobj_t *f, elfsh_Shdr hdr, u_int r, char *name, char sf); - -int elfsh_sort_sht(elfshobj_t *file); -void elfsh_sync_sectnames(elfshobj_t *file); -void elfsh_sync_sht(elfshobj_t *file); -elfsh_Shdr *elfsh_get_sht_entry_by_index(elfsh_Shdr *s, eresi_Addr index); -elfsh_Shdr *elfsh_get_sht_entry_by_name(elfshobj_t *file, char *name); -int elfsh_endianize_sht(elfsh_Shdr *sht, char byteorder, uint16_t shnum); -int elfsh_filter_sht(elfshobj_t *file); - -/* pht.c */ -void *elfsh_get_pht(elfshobj_t *file, int *num); -elfsh_Phdr *elfsh_get_segment_by_type(elfshobj_t *file, int type, int range); -elfsh_Phdr *elfsh_get_parent_segment(elfshobj_t *file, elfshsect_t *_new); -int elfsh_segment_is_parent(elfshsect_t *_new, elfsh_Phdr *p); -int elfsh_load_pht(elfshobj_t *file); -int elfsh_segment_is_writable(elfsh_Phdr *p); -int elfsh_segment_is_readable(elfsh_Phdr *p); -int elfsh_segment_is_executable(elfsh_Phdr *p); -int elfsh_set_segment_flags(elfsh_Phdr *p, eresi_Addr flags); -int elfsh_set_segment_align(elfsh_Phdr *p, eresi_Addr align); -int elfsh_set_segment_memsz(elfsh_Phdr *p, eresi_Addr memsz); -int elfsh_set_segment_filesz(elfsh_Phdr *p, eresi_Addr filesz); -int elfsh_set_segment_paddr(elfsh_Phdr *p, eresi_Addr paddr); -int elfsh_set_segment_vaddr(elfsh_Phdr *p, eresi_Addr vaddr); -int elfsh_set_segment_type(elfsh_Phdr *p, eresi_Addr type); -int elfsh_set_segment_offset(elfsh_Phdr *p, eresi_Addr offset); -elfsh_Word elfsh_get_segment_flags(elfsh_Phdr *p); -elfsh_Word elfsh_get_segment_align(elfsh_Phdr *p); -elfsh_Word elfsh_get_segment_memsz(elfsh_Phdr *p); -elfsh_Word elfsh_get_segment_filesz(elfsh_Phdr *p); -eresi_Addr elfsh_get_segment_paddr(elfsh_Phdr *p); -eresi_Addr elfsh_get_segment_vaddr(elfsh_Phdr *p); -elfsh_Word elfsh_get_segment_type(elfsh_Phdr *p); -elfsh_Off elfsh_get_segment_offset(elfsh_Phdr *p); -elfsh_Phdr *elfsh_get_pht_entry_by_index(elfsh_Phdr *pht, eresi_Addr index); -eresi_Addr elfsh_get_object_baseaddr(elfshobj_t *file); -void elfsh_endianize_pht(elfsh_Phdr *pht, char byteorder, uint16_t sz); -elfsh_Phdr elfsh_create_phdr(elfsh_Word t, eresi_Addr a, elfsh_Off z, elfsh_Word al); -elfsh_Phdr *elfsh_insert_phdr(elfshobj_t *file, elfsh_Phdr *h); -int elfsh_remove_phdr(elfshobj_t *current, int index); - -void *elfsh_get_rpht(elfshobj_t *file, int *num); -int elfsh_create_rpht(elfshobj_t *file); -elfsh_Phdr *elfsh_insert_runtime_phdr(elfshobj_t *file, elfsh_Phdr *h); - -/* hash.c */ -elfsh_Word elfsh_get_hashchain_num(elfsh_Word *c); -int elfsh_set_hashchain_num(elfsh_Word *c, elfsh_Word v); -elfsh_Word elfsh_get_hashbucket_num(elfsh_Word *b); -int elfsh_set_hashbucket_num(elfsh_Word *b, elfsh_Word v); -elfsh_Word elfsh_get_hashchain_value(elfsh_Word *c); -int elfsh_set_hashchain_value(elfsh_Word *c, elfsh_Word v); -elfsh_Word elfsh_get_hashbucket_value(elfsh_Word *b); -int elfsh_set_hashbucket_value(elfsh_Word *b, elfsh_Word v); -elfsh_Word *elfsh_get_hashchain_by_name(elfshobj_t *f, char *s); -elfsh_Word *elfsh_get_hashchain_by_index(void *p, u_int i); -elfsh_Word *elfsh_get_hashbucket_by_name(elfshobj_t *f, char *s); -elfsh_Word *elfsh_get_hashbucket_by_index(void *p, u_int i); -elfsh_Word *elfsh_get_hashchain(const void *d); -elfsh_Word elfsh_get_hashnchain(const void *d); -elfsh_Word *elfsh_get_hashbucket(const void *d); -elfsh_Word elfsh_get_hashnbucket(const void *d); -void *elfsh_get_hashtable(elfshobj_t *file, int *n); -elfshsect_t *elfsh_get_hashtable_by_range(elfshobj_t *file, eresi_Addr range, int *num); -elfsh_Word elfsh_get_symbol_hash(char *sym_name); -int elfsh_get_dynsymbol_by_hash(elfshobj_t *file, char *sym_name); -elfshobj_t *elfsh_hash_getfile_def(elfshobj_t *file, char *name); -elfsh_Verdef *elfsh_hash_getdef(elfshobj_t *file, char *name, void *defdata, int size); - -/* got.c */ -eresi_Addr *elfsh_get_got(elfshobj_t *file, int *num); -elfshsect_t *elfsh_get_got_by_idx(elfshobj_t *file, eresi_Addr range, u_int *nbr); -eresi_Addr *elfsh_get_got_entry_by_index(eresi_Addr *got, eresi_Addr index); -eresi_Addr *elfsh_get_got_entry_by_name(elfshobj_t *file, char *name); -int elfsh_set_got_entry_by_index(elfshobj_t *file, int index, eresi_Addr a); -int elfsh_set_got_entry_by_name(elfshobj_t *file, char *name, eresi_Addr a); -int elfsh_set_got_entry(eresi_Addr *got, eresi_Addr vaddr); -eresi_Addr elfsh_get_got_entry(eresi_Addr *got); -eresi_Addr elfsh_get_got_val(eresi_Addr *got); -u_int elfsh_set_got_val(eresi_Addr *got, eresi_Addr val); -eresi_Addr elfsh_get_got_addr(eresi_Addr *got); -u_int elfsh_set_got_addr(eresi_Addr *got, eresi_Addr val); -int elfsh_get_got_symbol_reloc(elfshobj_t *file, uint8 *name, - elfsh_Rel *rel_entry); -int elfsh_endianize_got(elfshsect_t *_new); -elfshsect_t *elfsh_get_gotsct(elfshobj_t *file); -int elfsh_shift_got(elfshobj_t *file, u_int size, char *name); - -/* dtors.c */ -eresi_Addr *elfsh_get_dtors(elfshobj_t *file, int *num); -eresi_Addr *elfsh_get_dtors_entry_by_index(eresi_Addr *dtors, eresi_Addr index); -eresi_Addr *elfsh_get_dtors_entry_by_name(elfshobj_t *file, char *name); -eresi_Addr elfsh_get_dtors_entry(eresi_Addr *dtors); -int elfsh_set_dtors_entry_by_index(elfshobj_t *file, int index, eresi_Addr a); -int elfsh_set_dtors_entry_by_name(elfshobj_t *file, char *name, eresi_Addr a); -int elfsh_set_dtors_entry(eresi_Addr *dtors, eresi_Addr vaddr); -int elfsh_shift_dtors(elfshobj_t *file, u_int size); - -/* ctors.c */ -eresi_Addr *elfsh_get_ctors(elfshobj_t *file, int *num); -eresi_Addr *elfsh_get_ctors_entry_by_index(eresi_Addr *ctors, eresi_Addr index); -eresi_Addr *elfsh_get_ctors_entry_by_name(elfshobj_t *file, char *name); -eresi_Addr elfsh_get_ctors_entry(eresi_Addr *ctors); -int elfsh_set_ctors_entry_by_name(elfshobj_t *file, char *name, eresi_Addr a); -int elfsh_set_ctors_entry_by_index(elfshobj_t *file, int index, eresi_Addr a); -int elfsh_set_ctors_entry(eresi_Addr *ctors, eresi_Addr vaddr); -int elfsh_shift_ctors(elfshobj_t *file, u_int size); - -/* section.c */ -elfshsect_t *elfsh_get_section_by_type(elfshobj_t *, u_int type, int range, int *, int *, int *); -elfshsect_t *elfsh_get_section_by_index(elfshobj_t *, eresi_Addr index, int *, int *); -elfshsect_t *elfsh_get_section_by_name(elfshobj_t *, char *name, int *, int *, int *); -elfshsect_t *elfsh_get_parent_section(elfshobj_t *file, eresi_Addr addr, elfsh_SAddr *offset); -elfshsect_t *elfsh_get_parent_section_by_foffset(elfshobj_t *file, u_int foff, elfsh_SAddr *offset); -elfshsect_t *elfsh_create_section(char *name); -elfshsect_t *elfsh_get_section_from_sym(elfshobj_t *file, elfsh_Sym *sym); -void *elfsh_load_section(elfshobj_t *file, elfsh_Shdr *shdr); -void *elfsh_get_anonymous_section(elfshobj_t *file, elfshsect_t *sect); -int elfsh_append_data_to_section(elfshsect_t *sect, void *input, u_int len); -char elfsh_shift_section(elfshsect_t *sct, elfshsect_t *tmp, u_char mode); -int elfsh_fill_section(elfshsect_t *sect, char c, u_int size); -int elfsh_remove_section(elfshobj_t *obj, char *name); -elfshsect_t *elfsh_get_section_list(elfshobj_t *file, int *num); -elfshsect_t *elfsh_get_tail_section(elfshobj_t *file); -elfshsect_t *elfsh_get_section_by_idx(elfshsect_t *list, eresi_Addr index); -void *elfsh_get_section_data(elfshsect_t *obj, u_int off, u_int sizelem); -int elfsh_add_section(elfshobj_t *file, elfshsect_t *sect, u_int index, void *data, int shift); -int elfsh_add_runtime_section(elfshobj_t *file, elfshsect_t *sct, u_int range, void *dat); - -int elfsh_write_section_data(elfshsect_t *sect, u_int off, char *data, u_int size, u_int sizelem); -elfshsect_t *elfsh_get_section_by_nam(elfshobj_t *file, char *name); -void *elfsh_get_raw(elfshsect_t *sect); -int elfsh_section_is_runtime(elfshsect_t *sect); -elfshsect_t *elfsh_get_rsection_by_index(elfshobj_t *file, eresi_Addr idx, int *stridx, int *num); - - - -/* inject.c */ -elfshsect_t *elfsh_insert_section(elfshobj_t *file, char *name, char *data, char mode, u_int size, u_int mod); -int elfsh_insert_unmapped_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data); -int elfsh_insert_mapped_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data, int mode, u_int modulo); -int elfsh_insert_data_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data); -int elfsh_insert_code_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data, u_int mod); -int elfsh_insert_code_section_up(elfshobj_t*, elfshsect_t*, elfsh_Shdr, void*, u_int); -int elfsh_insert_section_idx(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data, u_int index); -int elfsh_insert_static_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data, int mode, u_int mod); -int elfsh_insert_runtime_section(elfshobj_t *file, elfshsect_t *sect, elfsh_Shdr hdr, void *data, int mode, u_int mod); - - -/* version.c */ -elfsh_Vernaux *elfsh_check_defneed_eq(elfshobj_t *file, elfshobj_t *deffile, elfsh_Verneed *need, elfsh_Verdef *def); -elfsh_Word elfsh_get_verneed_aux(elfsh_Verneed *n); -int elfsh_set_verneed_aux(elfsh_Verneed *n, elfsh_Word v); -elfsh_Half elfsh_get_verneed_cnt(elfsh_Verneed *n); -int elfsh_set_verneed_cnt(elfsh_Verneed *n, elfsh_Half v); -elfsh_Word elfsh_get_verneed_file(elfsh_Verneed *n); -int elfsh_set_verneed_file(elfsh_Verneed *n, elfsh_Word v); -elfsh_Word elfsh_get_verneed_next(void *p); -int elfsh_set_verneed_next(void *p, elfsh_Word v); -elfsh_Half elfsh_get_verneed_flags(elfsh_Vernaux *n); -int elfsh_set_verneed_flags(elfsh_Vernaux *n, elfsh_Half v); -elfsh_Word elfsh_get_verneed_hash(elfsh_Vernaux *n); -int elfsh_set_verneed_hash(elfsh_Vernaux *n, elfsh_Word v); -elfsh_Word elfsh_get_verneed_name(elfsh_Vernaux *n); -int elfsh_set_verneed_name(elfsh_Vernaux *n, elfsh_Word v); -elfsh_Half elfsh_get_verneed_ndx(elfsh_Vernaux *n); -int elfsh_set_verneed_ndx(elfsh_Vernaux *n, elfsh_Half v); -elfsh_Verneed *elfsh_get_verneed_by_name(elfshobj_t *f, char *n); -elfsh_Vernaux *elfsh_get_verneed_entry_by_index(void *p, elfsh_Half i); -elfsh_Word elfsh_get_verdef_cname(elfsh_Verdaux *d); -int elfsh_set_verdef_cname(elfsh_Verdaux *d, elfsh_Word v); -elfsh_Word elfsh_get_verdef_next(void *d); -int elfsh_set_verdef_next(void *d, elfsh_Word v); -elfsh_Word elfsh_get_verdef_aux(elfsh_Verdef *d); -int elfsh_set_verdef_aux(elfsh_Verdef *d, elfsh_Word v); -elfsh_Half elfsh_get_verdef_flags(elfsh_Verdef *d); -int elfsh_set_verdef_flags(elfsh_Verdef *d, elfsh_Half v); -elfsh_Word elfsh_get_verdef_hash(elfsh_Verdef *d); -int elfsh_set_verdef_hash(elfsh_Verdef *d, elfsh_Word v); -elfsh_Half elfsh_get_verdef_cnt(elfsh_Verdef *d); -int elfsh_set_verdef_cnt(elfsh_Verdef *d, elfsh_Half v); -elfsh_Half elfsh_get_verdef_ndx(elfsh_Verdef *d); -int elfsh_set_verdef_ndx(elfsh_Verdef *d, elfsh_Half v); -void *elfsh_get_verdef_entry_by_index(void *p, elfsh_Half i); -elfsh_Half *elfsh_get_versym_entry_by_index(elfsh_Half *s, u_int i); -elfsh_Half elfsh_get_versym_val(elfsh_Half *s); -int elfsh_set_versym_val(elfsh_Half *s, elfsh_Half v); -elfsh_Half *elfsh_get_versym_by_name(elfshobj_t *f, char *n); -int elfsh_get_verdauxnamelist(elfshobj_t *f, hashdef_t *hdef, char **n, int nu); -int elfsh_load_needtable(hash_t *t, void *p, u_int s); -int elfsh_load_deftable(hash_t *t, void *p, u_int s); -void *elfsh_get_versymtab(elfshobj_t *f, int *n); -elfshsect_t *elfsh_get_versymtab_by_range(elfshobj_t *file, eresi_Addr range, int *num); -void *elfsh_get_verneedtab(elfshobj_t *f, int *n); -void *elfsh_get_verdeftab(elfshobj_t *f, int *n); -elfshsect_t *elfsh_get_verdeftab_by_idx(elfshobj_t *f, eresi_Addr r, int *n); -void *elfsh_get_verstrtable(elfshobj_t *f); -char *elfsh_get_verneedfile(elfshobj_t *f, elfsh_Verneed *n); -char *elfsh_get_vernauxname(elfshobj_t *f, elfsh_Vernaux *a); -char *elfsh_get_verdauxname(elfshobj_t *f, elfsh_Verdaux *a); - -/* reloc.c */ -elfshsect_t *elfsh_get_reloc(elfshobj_t *file, eresi_Addr range, u_int *num); -void elfsh_free_reloc_list(elfshobj_t *file); -u_int elfsh_set_reltype(elfsh_Rel *r, eresi_Addr type); -u_int elfsh_set_relsym(elfsh_Rel *r, eresi_Addr sym); -int elfsh_set_reloffset(elfsh_Rel *r, eresi_Addr off); -u_int elfsh_get_reltype(elfsh_Rel *r); -u_int elfsh_get_relsym(elfsh_Rel *r); -eresi_Addr elfsh_get_reloffset(elfsh_Rel *r); -void elfsh_setrel(char b); /* scripting flag for dynamic 'Rel vs Rela' info */ -elfsh_Rel *elfsh_get_relent_by_index(elfsh_Rel *table, eresi_Addr index); -elfshrel_t *elfsh_find_rel(elfshsect_t *sect); -int elfsh_insert_relent(elfshsect_t *sect, elfsh_Rel *rel); -char *elfsh_get_symname_from_reloc(elfshobj_t *file, elfsh_Rel *r); -elfsh_Sym *elfsh_get_symbol_from_reloc(elfshobj_t *file, elfsh_Rel *r); -elfsh_Rel *elfsh_get_relent_by_name(elfshobj_t *file, char *name); -elfsh_Sword elfsh_get_reladdend(elfsh_Rela *r); -int elfsh_set_reladdend(elfsh_Rela *r, eresi_Addr val); -int elfsh_endianize_relocs(elfshsect_t *s); -elfsh_Rel elfsh_create_relent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off); -elfsh_Rela elfsh_create_relaent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off, eresi_Addr add); - -/* interp.c */ -char *elfsh_get_interp(elfshobj_t *file); -int elfsh_write_interp(elfshobj_t *file, char *interp); - -/* notes */ -elfshsect_t *elfsh_get_notes(elfshobj_t *file, eresi_Addr range); - -void elfsh_free_notes_list(elfshobj_t *file); - -/* plt.c */ -elfshsect_t *elfsh_get_plt(elfshobj_t *file, int *num); -int elfsh_is_pltentry(elfshobj_t *file, elfsh_Sym *sym); -int elfsh_is_plt(elfshobj_t *file, elfshsect_t *s); -int elfsh_is_altplt(elfshobj_t *file, elfshsect_t *s); -int elfsh_get_pltentsz(elfshobj_t *file); -int elfsh_get_first_pltentsz(elfshobj_t *file); - -/* altplt.c */ -int elfsh_relink_plt(elfshobj_t *file, u_int modulo); -int elfsh_copy_plt(elfshobj_t *file, u_int modulo); -int elfsh_get_plt_symbol_offset(elfshobj_t *file, uint8 *name, - elfsh_Off *off); -int elfsh_build_plt(elfshobj_t *file); -int elfsh_altplt_firstent(elfshsect_t *created, - u_int *off, - elfshsect_t *symtab, - elfshobj_t *file, - elfshsect_t *plt, - elfshsect_t *extplt, - uint32_t diff); - -/* altgot.c */ -int elfsh_redirect_pltgot(elfshobj_t *file, elfshsect_t *altgot, elfshsect_t *got, - elfshsect_t *plt, elfshsect_t *altplt); -int elfsh_shift_generic_relocs(elfshobj_t *file, eresi_Addr diff, - elfshsect_t *relplt); -int elfsh_shift_alpha_relocs(elfshobj_t *file, char *name, - elfshsect_t *altgot, u_int off); -int elfsh_shift_ia32_relocs(elfshobj_t *file, eresi_Addr diff, - elfshsect_t *relplt, eresi_Addr limit); -void elfsh_shift_mips_relocs(elfshobj_t *file, eresi_Addr diff); -int elfsh_shift_sparc_relocs(elfshobj_t *file, eresi_Addr diff, - elfshsect_t *relplt); -int elfsh_reencode_pltentry(elfshobj_t *file, elfshsect_t *plt, - uint32_t diff, u_int off); -int elfsh_reencode_first_pltentry(elfshobj_t *file, elfshsect_t *plt, - uint32_t diff); - -/* extplt.c */ -int elfsh_extplt_expand_versym(elfshobj_t *file, elfshsect_t *versym, char *name); -int elfsh_extplt_expand_hash(elfshobj_t *file, elfshsect_t *hash, elfshsect_t *dynsym, char *name); -int elfsh_extplt_mirror_sections(elfshobj_t *file); -elfsh_Sym *elfsh_request_pltent(elfshobj_t *file, char *name); - - -/* raw.c */ -int elfsh_raw_write(elfshobj_t *file, u_int dst, void *src, int len); -int elfsh_raw_read(elfshobj_t *file, u_int dst, void *src, int len); -int elfsh_get_foffset_from_vaddr(elfshobj_t *file, eresi_Addr vaddr); -int elfsh_get_vaddr_from_foffset(elfshobj_t *file, u_int foffset); - -/* remap.c */ -int elfsh_reloc_pht(elfshobj_t *file, eresi_Addr diff); -int elfsh_reloc_sht(elfshobj_t *file, eresi_Addr diff); -int elfsh_relocate_section(elfshsect_t *sect, eresi_Addr diff); - -int elfsh_reloc_raw(elfshsect_t *cur, eresi_Addr diff); -int elfsh_reloc_symtab(elfshsect_t *s, eresi_Addr diff); -int elfsh_reloc_rel(elfshsect_t *sect, eresi_Addr diff); -int elfsh_reloc_got(elfshsect_t *sect, eresi_Addr diff); -int elfsh_reloc_ctors(elfshsect_t *sect, eresi_Addr diff); -int elfsh_reloc_dtors(elfshsect_t *sect, eresi_Addr diff); -int elfsh_reloc_hash(elfshsect_t *sect, eresi_Addr diff); -int elfsh_reloc_array(elfshobj_t *file, eresi_Addr *array, u_int size, eresi_Addr diff); -int elfsh_relocate(elfshobj_t *file); - -/* map.c */ -int elfsh_read_obj(elfshobj_t *file); -elfshobj_t *elfsh_map_obj(char *name); -elfshsect_t * elfsh_fixup_sctndx(elfshsect_t *symtab); - -/* save.c */ -int elfsh_save_relocate(elfshobj_t *file); -int elfsh_save_obj(elfshobj_t *file, char *name); - -/* copy.c */ -elfshobj_t *elfsh_copy_obj(elfshobj_t *file); - -/* strtab.c */ -int elfsh_insert_in_strtab(elfshobj_t *file, char *name); -int elfsh_insert_in_shstrtab(elfshobj_t *file, char *name); -int elfsh_insert_in_dynstr(elfshobj_t *file, char *name); -elfshsect_t *elfsh_get_strtab(elfshobj_t *file, int index); -elfshsect_t *elfsh_rebuild_strtab(elfshobj_t *file); -int elfsh_insert_in_rshstrtab(elfshobj_t *file, char *name); - -/* fixup.c */ -elfshsect_t *elfsh_fixup_symtab(elfshobj_t *file, int *strindex); -int elfsh_fixup_dynsymtab(elfshsect_t *dynsym); -elfsh_Sym *elfsh_restore_dynsym(elfshobj_t *file, elfshsect_t *plt, u_int off, - elfshsect_t *dynsym); - - -/* sanitize.c */ -void elfsh_update_nameidx(elfshobj_t *file, int offset, int len); -void elfsh_update_linkidx(elfshobj_t *file, int low_index, int diff); -void elfsh_update_linkidx_equ(elfshobj_t *file, int idx, int diff); -void elfsh_update_symlinkidx_equ(elfshobj_t *file, int idx, int diff); -void elfsh_update_shidx(elfshobj_t *file, elfshsect_t *tab, int idx, int diff); -void elfsh_update_symtab_shidx(elfshobj_t *file, int idx, int diff); -void elfsh_update_dynsym_shidx(elfshobj_t *file, int idx, int diff); - - -/* sht_rebuild.c */ -int elfsh_rebuild_sht(elfshobj_t *file); -int elfsh_merge_shtentry(elfshobj_t *file, - int phdr_index, - elfsh_Shdr shdr, - char *name); - -/* comment.c */ -elfshsect_t *elfsh_get_comments(elfshobj_t *file); -char *elfsh_get_comments_entry(elfshobj_t *file, u_int range); - -/* hijack.c */ -int elfsh_hijack_function_by_name(elfshobj_t *file, - uint32_t type, - char *name, - eresi_Addr addr, - eresi_Addr *hooked); - -/* debug.c */ -int elfsh_print_sectlist(elfshobj_t *obj, char *label); -char *elfsh_get_machine_string(elfsh_Half machine); - -/* bss.c */ -int elfsh_fixup_bss_real(elfshobj_t *file, elfshsect_t *bss, char fixflag); -elfshsect_t *elfsh_fixup_bss(elfshobj_t *file); -elfshsect_t *elfsh_add_bss(elfshobj_t *file); -int elfsh_flush_bss(elfshobj_t *file); -int elfsh_cleanup_bss(elfshobj_t *file, elfsh_Phdr *pht); -int elfsh_find_bsslen(elfshobj_t *host, elfshobj_t *rel, char *name); -elfshsect_t *elfsh_insert_runtime_bss(elfshobj_t *file, elfshobj_t *rel); - -/* relinject.c */ -int elfsh_inject_etrel(elfshobj_t *file, elfshobj_t *rel); -int elfsh_relocate_object(elfshobj_t *file, elfshobj_t *rel, u_char stage); -int elfsh_inject_etrel_hash(elfshobj_t *host, elfshobj_t *rel, - hash_t *first, hash_t *second); - - -/* search.c */ -int elfsh_register_working_objects(hash_t *prvhash,hash_t *sharedhash); -elfshobj_t *elfsh_find_obj_by_symbol(char *name); -elfsh_Sym *elfsh_strongest_symbol(elfsh_Sym *choice, elfsh_Sym *candidate); - -/* sort.c */ -int elfsh_sync_sorted_symtab(elfshsect_t *sect); -int elfsh_sort_symtab(elfsh_Sym *symtab, int size, int type); - -/* hooks.c */ -u_char elfsh_get_ostype(elfshobj_t *file); -u_char elfsh_get_hosttype(elfshobj_t *file); -u_char elfsh_get_elftype(elfshobj_t *file); -u_char elfsh_get_archtype(elfshobj_t *file); -int elfsh_default_plthandler(elfshobj_t *n, elfsh_Sym *n2, eresi_Addr n3); -int elfsh_default_relhandler(elfshsect_t *n, elfsh_Rel *n2, eresi_Addr *n3, eresi_Addr n4, elfshsect_t *n5); -int elfsh_default_cflowhandler(elfshobj_t *n, char *n1, elfsh_Sym *n2, eresi_Addr n3); -int elfsh_default_argchandler(eresi_Addr addr); - -int elfsh_register_altplthook(u_char arch, u_char obj, u_char os, void *fct); -int elfsh_register_plthook(u_char arch, u_char o, u_char os, void *fct); -int elfsh_register_relhook(u_char a, u_char o, u_char os, void *fct); -int elfsh_register_cflowhook(u_char a, u_char o, u_char os, void *fct); -int elfsh_register_extplthook(u_char a, u_char o, u_char os, void *f); -int elfsh_register_argchook(u_char a, u_char o, u_char os, void *fct); - -int elfsh_register_vector(char *name, - void *registerfunc, - void *defaultfunc, - u_int *dimensions, - u_int dimsz); - -int elfsh_get_pagesize(elfshobj_t *file); -u_int elfsh_get_breaksize(elfshobj_t *file); -void elfsh_setup_hooks(); - -int elfsh_plt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr created); -int elfsh_altplt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr created); -int elfsh_cflow(elfshobj_t *file, char *name, elfsh_Sym *old, - eresi_Addr created); -int elfsh_rel(elfshobj_t *file, elfshsect_t *s, elfsh_Rel *r, - eresi_Addr *l, eresi_Addr a, elfshsect_t *m); -int elfsh_encodeplt(elfshobj_t *file, elfshsect_t *plt, - eresi_Addr diff, u_int off); -int elfsh_encodeplt1(elfshobj_t *file, elfshsect_t *plt, - elfshsect_t *extplt, eresi_Addr diff); -int elfsh_extplt(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt); -int *elfsh_args_count(elfshobj_t *file, u_int off, eresi_Addr vaddr); - - - -/* sparc32.c */ -int elfsh_cflow_sparc32(elfshobj_t *null, - char *snull, - elfsh_Sym* null2, - eresi_Addr null3); -int elfsh_hijack_plt_sparc32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_sparc32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_sparc32(elfshsect_t *_new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* sparc64.c */ -int elfsh_cflow_sparc64(elfshobj_t *null, - char *snull, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_sparc64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_sparc64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_sparc64(elfshsect_t *_new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* ia64.c */ -int elfsh_cflow_ia64(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_ia64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_ia64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_ia64(elfshsect_t *_new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* alpha64.c */ -int elfsh_cflow_alpha64(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_alpha64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_alpha64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_alpha64(elfshsect_t *_new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* mips32.c */ -int elfsh_cflow_mips32(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_mips32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_mips32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_mips32(elfshsect_t *_new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* mips64.c */ -int elfsh_cflow_mips64(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_mips64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_altplt_mips64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_mips64(elfshsect_t *_new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); - -/* ia32.c */ -int elfsh_reencode_pltentry_ia32(elfshobj_t *file, - elfshsect_t *plt, - uint32_t diff, - u_int off); -int elfsh_reencode_first_pltentry_ia32(elfshobj_t *file, - elfshsect_t *plt, - uint32_t diff); -int elfsh_encodeplt1_ia32(elfshobj_t *file, - elfshsect_t *plt, - elfshsect_t *extplt, - eresi_Addr diff); -int elfsh_encodeplt_ia32(elfshobj_t *file, - elfshsect_t *plt, - eresi_Addr diff, - u_int off); -int elfsh_extplt_ia32(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt); -int elfsh_cflow_ia32(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3); -int elfsh_hijack_plt_ia32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_hijack_plt_ia32_etdyn(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr); -int elfsh_relocate_ia32(elfshsect_t *_new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod); -int *elfsh_args_count_ia32(elfshobj_t *file, u_int off, eresi_Addr vaddr); - -/* reginfo.c */ -elfsh_Sword *elfsh_get_gpvalue_addr(elfshobj_t* file); -int elfsh_set_gpvalue(elfshobj_t* file, eresi_Addr gp); -elfsh_Sword elfsh_get_gpvalue(elfshobj_t* file); - - -/* runtime.c */ -eresi_Addr elfsh_runtime_map(elfsh_Phdr *segment); -int elfsh_runtime_unmap(elfsh_Phdr *segment); -int elfsh_set_phdr_prot(u_int mode); -int elfsh_munprotect(elfshobj_t *obj, eresi_Addr addr, uint32_t sz); -int elfsh_mprotect(eresi_Addr addr, uint32_t sz, int prot); - -/* state.c */ -u_char elfsh_is_static_mode(); -void elfsh_set_static_mode(); -u_char elfsh_is_debug_mode(); -void elfsh_set_debug_mode(); -void elfsh_set_mode(u_char mode); -u_char elfsh_get_mode(); -void elfsh_toggle_mode(); -u_char elfsh_debugger_present(); -void elfsh_error(); - -/* linkmap.c */ -eresi_Addr elfsh_linkmap_get_laddr(elfshlinkmap_t *lm); -void elfsh_linkmap_set_laddr(elfshlinkmap_t *lm, eresi_Addr laddr); -char *elfsh_linkmap_get_lname(elfshlinkmap_t *lm); -void elfsh_linkmap_set_lname(elfshlinkmap_t *lm, char *name); -elfsh_Dyn *elfsh_linkmap_get_lld(elfshlinkmap_t *lm); -void elfsh_linkmap_set_lld(elfshlinkmap_t *lm, elfsh_Dyn *lld); -elfshlinkmap_t *elfsh_linkmap_get_lnext(elfshlinkmap_t *lm); -void elfsh_linkmap_set_lnext(elfshlinkmap_t *lm, elfshlinkmap_t *lnext); -elfshlinkmap_t *elfsh_linkmap_get_lprev(elfshlinkmap_t *lm); -void elfsh_linkmap_set_lprev(elfshlinkmap_t *lm, elfshlinkmap_t *lprev); -elfshlinkmap_t *elfsh_linkmap_by_name(elfshlinkmap_t *lm, char *name); - -/* bt.c */ -void *elfsh_bt(void *frame); - -#ifndef __KERNEL__ -void *elfsh_bt_get_frame(ucontext_t *); -#endif - -/* bp.c */ -int elfsh_bp_add(hash_t *bps, elfshobj_t *file, - char *resolv, eresi_Addr addr, - u_char flags); - - -#endif /* __LIBELFSH_H_ */ diff -Nru eresi-0.8a25/libelfsh/inject.c eresi-0.0.20110516/libelfsh/inject.c --- eresi-0.8a25/libelfsh/inject.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/inject.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,16 +1,16 @@ /** - * @file inject.c + * @file libelfsh/inject.c * @ingroup libelfsh -** inject.c for libelfsh -** -** Contains all section injection API that can be used directly by the user -** -** Started on Thu Jun 09 00:12:42 2005 mm -** -** -** $Id: inject.c,v 1.15 2008-02-16 12:32:27 thor Exp $ -** -*/ + * inject.c for libelfsh + * + * Contains all section injection API that can be used directly by the user + * + * Started on Thu Jun 09 00:12:42 2005 mm + * + * + * $Id: inject.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "libelfsh.h" @@ -19,7 +19,7 @@ /** * Insert a new section at the first place in the executable PT_LOAD * This function is not e2dbg safe and should only be used for ondisk files - * This function is ET_DYN-PaX-pie-hardened-gentoo-safe + * This function is ET_DYN-PaX-pie-hardened-gentoo-safe * @param file * @param sect * @param hdr @@ -28,10 +28,10 @@ * @return */ int elfsh_insert_code_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int mod) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + u_int mod) { elfshsect_t *first; elfsh_Phdr *phdr; @@ -60,35 +60,35 @@ while (phdr && !elfsh_segment_is_executable(phdr)); if (phdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find +x PT_LOAD", -1); - - /* If the executable segment starts at low address, use + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find +x PT_LOAD", -1); + + /* If the executable segment starts at low address, use alternative code section injection */ - if (phdr->p_vaddr <= ELFSH_SPARC_LOWADDR && + if (phdr->p_vaddr <= ELFSH_SPARC_LOWADDR && (elfsh_get_archtype(file) == ELFSH_ARCH_SPARC32 || elfsh_get_archtype(file) == ELFSH_ARCH_SPARC64)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_insert_code_section_up(file, sect, hdr, data, mod))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (elfsh_insert_code_section_up(file, sect, hdr, data, mod))); /* FIXME: just a try on recent ld */ /* So that file offset and vaddr and aligned */ else if (elfsh_get_archtype(file) == ELFSH_ARCH_SPARC32 || - elfsh_get_archtype(file) == ELFSH_ARCH_SPARC64) - elfsh_set_segment_align(phdr, elfsh_get_pagesize(file)); - + elfsh_get_archtype(file) == ELFSH_ARCH_SPARC64) + elfsh_set_segment_align(phdr, elfsh_get_pagesize(file)); + /* Find the first allocatable section */ first = file->sectlist; while (!first->shdr->sh_addr) first = first->next; -#if __DEBUG_RELADD__ +#if __DEBUG_RELADD__ printf("[DEBUG_RELADD] Guard section found : %s (first->next = %p) \n", first->name, first->next); #endif if (first == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find guard section", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find guard section", -1); /* Pad the new section if needed */ /* I KEEP OLD METHOD ON COMMENT (IN CASE) @@ -97,7 +97,7 @@ rsize = hdr.sh_size + mod - (hdr.sh_size % mod); XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); if (data) - memcpy(rdata, data, hdr.sh_size); + memcpy(rdata, data, hdr.sh_size); hdr.sh_size = rsize; data = rdata; } @@ -107,10 +107,10 @@ check = (phdr->p_vaddr - phdr->p_offset) & (phdr->p_align - 1); if (check != 0) { - rsize = hdr.sh_size + (check + 1); + rsize = hdr.sh_size + (check + 1); XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); if (data) - memcpy(rdata, data, hdr.sh_size); + memcpy(rdata, data, hdr.sh_size); hdr.sh_size = rsize; data = rdata; } @@ -119,14 +119,14 @@ if (first->shdr->sh_addr < hdr.sh_size) printf("Trap Error: sh_addr < sh_size !\n"); #endif - + /* Extend the first loadable segment at low addresses */ if (elfsh_get_objtype(file->hdr) != ET_DYN) hdr.sh_addr = first->shdr->sh_addr - hdr.sh_size; else hdr.sh_addr = first->shdr->sh_addr; hdr.sh_offset = first->shdr->sh_offset; - + /* Fixup the file offset */ phdr->p_filesz += hdr.sh_size; phdr->p_memsz += hdr.sh_size; @@ -144,94 +144,94 @@ for (range = 0, cur = file->pht; range < file->hdr->e_phnum; range++) { /* That's how we shift on ET_EXEC */ - if (cur[range].p_type == PT_PHDR && - elfsh_get_objtype(file->hdr) != ET_DYN) - { - cur[range].p_vaddr -= hdr.sh_size; - cur[range].p_paddr -= hdr.sh_size; - } + if (cur[range].p_type == PT_PHDR && + elfsh_get_objtype(file->hdr) != ET_DYN) + { + cur[range].p_vaddr -= hdr.sh_size; + cur[range].p_paddr -= hdr.sh_size; + } else if (cur + range != phdr && cur[range].p_offset >= hdr.sh_offset) - { - cur[range].p_offset += hdr.sh_size; + { + cur[range].p_offset += hdr.sh_size; - /* That's how we shift the address space on ET_DYN */ - if (elfsh_get_objtype(file->hdr) == ET_DYN) - { - cur[range].p_vaddr += hdr.sh_size; - cur[range].p_paddr += hdr.sh_size; - } - } + /* That's how we shift the address space on ET_DYN */ + if (elfsh_get_objtype(file->hdr) == ET_DYN) + { + cur[range].p_vaddr += hdr.sh_size; + cur[range].p_paddr += hdr.sh_size; + } + } } /* Inject our section with the associated header */ index = first->index; if (elfsh_insert_shdr(file, hdr, index, sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert shdr", -1); - + "Unable to insert shdr", -1); + if (elfsh_add_section(file, sect, index, data, - elfsh_get_objtype(file->hdr) == ET_DYN ? - ELFSH_SHIFTING_COMPLETE : ELFSH_SHIFTING_PARTIAL) < 0) - + elfsh_get_objtype(file->hdr) == ET_DYN ? + ELFSH_SHIFTING_COMPLETE : ELFSH_SHIFTING_PARTIAL) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); + "Unable to add section", -1); /* Shift stuff in the ET_DYN */ if (elfsh_get_objtype(file->hdr) == ET_DYN) { for (index = 0; 1; index++) - { - relsect = elfsh_get_reloc(file, (eresi_Addr) index, NULL); - if (!relsect) - { - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not a single relo table found", -1); - break; - } - err = elfsh_shift_ia32_relocs(file, hdr.sh_size, relsect, - sect->shdr->sh_addr + sect->shdr->sh_size); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Problem while shifting relocs", -1); - } + { + relsect = elfsh_get_reloc(file, (eresi_Addr) index, NULL); + if (!relsect) + { + if (!index) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Not a single relo table found", -1); + break; + } + err = elfsh_shift_ia32_relocs(file, hdr.sh_size, relsect, + sect->shdr->sh_addr + sect->shdr->sh_size); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Problem while shifting relocs", -1); + } err = elfsh_shift_symtab(file, sect->shdr->sh_addr, hdr.sh_size); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift symtab in ET_DYN", -1); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot shift symtab in ET_DYN", -1); + err = elfsh_shift_dynsym(file, sect->shdr->sh_addr, hdr.sh_size); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift dynsym in ET_DYN", -1); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot shift dynsym in ET_DYN", -1); + elfsh_update_dynsym_shidx(file, sect->index - 1, 1); elfsh_update_symtab_shidx(file, sect->index - 1, 1); if (elfsh_shift_dynamic(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot shift dynamic in ET_DYN", -1); - if (elfsh_shift_got(file, sect->shdr->sh_size, - ELFSH_SECTION_NAME_GOT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + if (elfsh_shift_got(file, sect->shdr->sh_size, + ELFSH_SECTION_NAME_GOT) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot shift .got in ET_DYN", -1); - + if (elfsh_shift_got(file, sect->shdr->sh_size, - ELFSH_SECTION_NAME_GOTPLT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + ELFSH_SECTION_NAME_GOTPLT) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot shift .got.plt in ET_DYN", -1); - + /* ALTGOT section is not present in unmodified binaries so its not a fatal error */ elfsh_shift_got(file, sect->shdr->sh_size, ELFSH_SECTION_NAME_ALTGOT); - + if (elfsh_shift_dtors(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot shift dtors in ET_DYN", -1); - + if (elfsh_shift_ctors(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot shift ctors in ET_DYN", -1); elfsh_set_entrypoint(file->hdr, elfsh_get_entrypoint(file->hdr) + sect->shdr->sh_size); @@ -241,7 +241,7 @@ /* Inject the SECT symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert section symbol", -1); + "Unable to insert section symbol", -1); /* Okay ! */ @@ -252,9 +252,9 @@ /** - * Insert a new section at the first place in the executable PT_LOAD + * Insert a new section at the first place in the executable PT_LOAD * WORK IN PROGRESS DO NOT USE IT FOR NOW - * This function is not e2dbg safe and should only be used for ondisk files + * This function is not e2dbg safe and should only be used for ondisk files * * @param file * @param sect @@ -264,10 +264,10 @@ * @return */ int elfsh_insert_code_section_up(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int mod) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + u_int mod) { elfshsect_t *last; elfsh_Phdr *phdr; @@ -284,7 +284,7 @@ if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", -1); + "Unable to get SHT", -1); /* Find both PT_LOAD segment */ phdr_code = phdr_data = NULL; @@ -292,43 +292,43 @@ do { phdr = elfsh_get_segment_by_type(file, PT_LOAD, range); -#if __DEBUG_RELADD__ +#if __DEBUG_RELADD__ printf("Found PT_LOAD at range %u \n", range); #endif if (!phdr) - break; + break; range++; if (elfsh_segment_is_executable(phdr)) - { - if (!elfsh_segment_is_writable(phdr)) - phdr_code = phdr; - else - phdr_data = phdr; - } + { + if (!elfsh_segment_is_writable(phdr)) + phdr_code = phdr; + else + phdr_data = phdr; + } } while (phdr); - + if (phdr_code == NULL || phdr_data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find 2 PT_LOAD", -1); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find 2 PT_LOAD", -1); + /* Find the last section of the executable PT_LOAD */ last = file->sectlist; while (!last->phdr || last->phdr->p_vaddr < phdr_data->p_vaddr) last = last->next; if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find last +X section", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find last +X section", -1); last = last->prev; - + /* Pad the new section if needed */ if (mod && (hdr.sh_size % mod)) { rsize = hdr.sh_size + mod - (hdr.sh_size % mod); XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); if (data) - memcpy(rdata, data, hdr.sh_size); + memcpy(rdata, data, hdr.sh_size); hdr.sh_size = rsize; data = rdata; } @@ -352,55 +352,55 @@ for (range = 0, cur = file->pht; range < file->hdr->e_phnum; range++) if (cur != phdr_code && cur[range].p_offset >= last->shdr->sh_offset) { - cur[range].p_offset += hdr.sh_size + alignedsize2; // + alignedsize2; - if (elfsh_get_segment_type(cur + range) == PT_LOAD) - { - elfsh_set_segment_align(cur + range, elfsh_get_pagesize(file)); - - /* Align on file offset */ - /* - if (cur[range].p_offset % elfsh_get_pagesize(file)) - { - printf("Found misaligned foffset in phdr index %u (diff = %u) \n", - range, cur[range].p_offset % elfsh_get_pagesize(file)); - alignedsize = elfsh_get_pagesize(file) - (cur[range].p_offset % elfsh_get_pagesize(file)); - cur[range].p_offset += alignedsize; - } - else - printf("foffset align test not entered\n"); - */ - - /* Align on virtual addr vs file offset */ - if ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)) - { -#if __DEBUG_RELADD__ - printf("Found misaligned off/addr in phdr index %u (diff = %u) \n", - range, (cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); + cur[range].p_offset += hdr.sh_size + alignedsize2; // + alignedsize2; + if (elfsh_get_segment_type(cur + range) == PT_LOAD) + { + elfsh_set_segment_align(cur + range, elfsh_get_pagesize(file)); + + /* Align on file offset */ + /* + if (cur[range].p_offset % elfsh_get_pagesize(file)) + { + printf("Found misaligned foffset in phdr index %u (diff = %u) \n", + range, cur[range].p_offset % elfsh_get_pagesize(file)); + alignedsize = elfsh_get_pagesize(file) - (cur[range].p_offset % elfsh_get_pagesize(file)); + cur[range].p_offset += alignedsize; + } + else + printf("foffset align test not entered\n"); + */ + + /* Align on virtual addr vs file offset */ + if ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)) + { +#if __DEBUG_RELADD__ + printf("Found misaligned off/addr in phdr index %u (diff = %u) \n", + range, (cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); #endif - alignedsize2 = elfsh_get_pagesize(file) - ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); - cur[range].p_offset += alignedsize2; - } -#if __DEBUG_RELADD__ - else - printf("vaddr-foffset align test not entered\n"); + alignedsize2 = elfsh_get_pagesize(file) - ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); + cur[range].p_offset += alignedsize2; + } +#if __DEBUG_RELADD__ + else + printf("vaddr-foffset align test not entered\n"); #endif - } + } } - + /* Inject our section with the associated header */ if (elfsh_insert_shdr(file, hdr, last->index + 1, sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert shdr", -1); - + "Unable to insert shdr", -1); + if (elfsh_add_section(file, sect, last->index + 1, - data, ELFSH_SHIFTING_PARTIAL) < 0) + data, ELFSH_SHIFTING_PARTIAL) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); + "Unable to add section", -1); /* Inject the SECT symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert section symbol", -1); + "Unable to insert section symbol", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); } @@ -410,9 +410,9 @@ /** - * Insert a data section in the object + * Insert a data section in the object * This function is not e2dbg safe and should only be used with ondisk files - * Use elfsh_insert_runtime_section() for runtime injections + * Use elfsh_insert_runtime_section() for runtime injections * * @param file * @param sect @@ -421,9 +421,9 @@ * @return */ int elfsh_insert_data_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data) { elfshsect_t *last; void *rdata; @@ -437,12 +437,12 @@ /* Sanity checks */ if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", -1); + "Unable to get SHT", -1); /* Insert the bss physically in the file if not already done */ if (elfsh_fixup_bss(file) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot fixup .bss", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot fixup .bss", -1); /* Find the PHDR */ range = 0; @@ -455,23 +455,23 @@ while (phdr); phdr = phdr2; if (phdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find last PT_LOAD", -1); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find last PT_LOAD", -1); + /* Iterate and get the real last mapped section */ - last = file->sectlist; - while (last->next != NULL && last->next->shdr->sh_addr != NULL) - last = last->next; - last->phdr = phdr; - - /* Avoid unaligned accesses */ + last = file->sectlist; + while (last->next != NULL && last->next->shdr->sh_addr != NULL) + last = last->next; + last->phdr = phdr; + + /* Avoid unaligned accesses */ if ((last->shdr->sh_addr + last->shdr->sh_size) % sizeof(eresi_Addr)) pad = sizeof(eresi_Addr) - ((last->shdr->sh_addr + last->shdr->sh_size) % sizeof(eresi_Addr)); - + #if __DEBUG_RELADD__ if (pad) - printf("[DEBUG_RELADD] Small gap of %u bytes between %s and %s \n", - pad, last->name, sect->name); + printf("[DEBUG_RELADD] Small gap of %u bytes between %s and %s \n", + pad, last->name, sect->name); #endif /* Extend the segment to insert the new section */ @@ -479,7 +479,7 @@ hdr.sh_offset = last->shdr->sh_offset + last->shdr->sh_size + pad; last->phdr->p_filesz += hdr.sh_size + pad; last->phdr->p_memsz += hdr.sh_size + pad; - + /* Copy the data */ XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, hdr.sh_size, -1); if (data) @@ -488,23 +488,23 @@ /* Inject our section with the associated header */ if (elfsh_insert_shdr(file, hdr, last->index + 1, sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); + "Cannot insert shdr", -1); if (elfsh_add_section(file, sect, last->index + 1, - rdata, ELFSH_SHIFTING_COMPLETE) < 0) + rdata, ELFSH_SHIFTING_COMPLETE) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); + "Cannot add section", -1); /* Next pointers will be updated, we need them for padding */ last = elfsh_get_section_by_name(file, sect->name, 0, 0, 0); if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive injected section", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive injected section", -1); /* Inject the SECT symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); + "Cannot insert section symbol", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); } @@ -512,17 +512,17 @@ /** - * + * * This function need to be modularized so that it can serves for runtime mapping * and also static file mapping in new PT_LOAD. Since thats what this function do - * it shouldnt be a problem. Just a thing to check : make sure the (real) PHT can - * be extended from this function, because PHT extension uses another injection + * it shouldnt be a problem. Just a thing to check : make sure the (real) PHT can + * be extended from this function, because PHT extension uses another injection * internaly so I hope nothing is fucked up -mm * * Make sure also to use a dedicated base addr for the new section if you re - * debugging heap sensible code. + * debugging heap sensible code. * - * Runtime injection : the standard process injection + * Runtime injection : the standard process injection * * @param file * @param sect @@ -532,45 +532,29 @@ * @param mod * @return */ -int elfsh_insert_runtime_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int mod) +int elfsh_insert_runtime_section(elfshobj_t *file, + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + int mode, + u_int mod) { elfsh_Phdr phdr; u_int rsize; char *rdata; int range; - /* - elfshsect_t *bss; - */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* Grab the BSS */ - /* - bss = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_BSS, - NULL, NULL, NULL); - if (!bss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find ondisk BSS", -1); - while (bss->next) - bss = bss->next; - */ - /* Pad the new section if needed */ if (mod && (hdr.sh_size % mod)) { rsize = hdr.sh_size + mod - (hdr.sh_size % mod); XALLOC(__FILE__, __FUNCTION__, __LINE__, rdata, rsize, -1); if (data) - memcpy(rdata, data, hdr.sh_size); + memcpy(rdata, data, hdr.sh_size); else - memset(rdata, 0x00, hdr.sh_size); + memset(rdata, 0x00, hdr.sh_size); hdr.sh_size = rsize; data = rdata; } @@ -580,7 +564,7 @@ { rsize = hdr.sh_size; if (!data) - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, rsize, -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, data, rsize, -1); } /* Create and inject the new PT_LOAD in runtime */ @@ -588,73 +572,55 @@ /* In runtime static binary injection, we need a safe p_vaddr each time we call this function */ phdr.p_flags = elfsh_set_phdr_prot(mode); - phdr.p_vaddr = elfsh_runtime_map(&phdr); + phdr.p_vaddr = elfsh_runtime_map(file, phdr.p_memsz, phdr.p_flags); if (phdr.p_vaddr == ELFSH_INVALID_ADDR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot runtime map", -1); + "Cannot runtime map", -1); /* Copy the data in memory */ -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Writing data (%p) in memory at addr %08X (pid = %hu) \n", - data, phdr.p_vaddr, getpid()); +#if __DEBUG_RUNTIME__ + printf("[DEBUG_RUNTIME] Writing data (%p) in memory at addr %08X (pid = %hu) \n", + data, phdr.p_vaddr, getpid()); #endif -#if defined(KERNSH) - if(kernsh_is_mem_mode()) - { - kernsh_writemem(phdr.p_vaddr, data, rsize); - } - else - { - memcpy((void *) phdr.p_vaddr, data, rsize); - } -#else - memcpy((void *) phdr.p_vaddr, data, rsize); -#endif + /* Write data at address */ + elfsh_writemem(file, phdr.p_vaddr, data, rsize); /* Modify some ondisk information */ phdr.p_paddr = phdr.p_vaddr; hdr.sh_addr = phdr.p_vaddr; - //hdr.sh_offset = bss->shdr->sh_offset + bss->shdr->sh_size; -#if __DEBUG_RUNTIME__ +#if __DEBUG_RUNTIME__ printf("[DEBUG_RUNTIME] Runtime injection of %s section data ! \n", sect->name); #endif - - /* Insert the new program header in the runtime PHDR */ /* XXX: insert in real PHT if doing non-runtime _static file_ injection */ - /* Should already work on runtime static binary modification */ /* Use elfsh_insert_phdr in this static case */ - /* After modification, should be OK at least on x86 */ - //phdr.p_offset = sect->shdr->sh_offset; - sect->phdr = elfsh_insert_runtime_phdr(file, &phdr); + /* After modification, OK at least on x86 */ + sect->phdr = elfsh_insert_runtime_phdr(file, &phdr); if (!sect->phdr) - { - elfsh_runtime_unmap(&phdr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert RPHT entry", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert RPHT entry", -1); /* Synchronize the ondisk perspective */ range = elfsh_insert_runtime_shdr(file, hdr, file->rhdr.rshtnbr, sect->name, 1); if (range < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); + "Cannot insert shdr", -1); if (elfsh_add_runtime_section(file, sect, range, data) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - + "Cannot add section", -1); + /* Inject the SECT symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert sectsym", -1); + "Cannot insert sectsym", -1); -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Runtime injected %s at addr " XFMT "! \n", - sect->name, sect->shdr->sh_addr); +#if __DEBUG_RUNTIME__ + printf("[DEBUG_RUNTIME] Runtime injected %s at addr " XFMT "! \n", + sect->name, sect->shdr->sh_addr); #endif /* Always force file offset 0 for runtime sections */ @@ -665,7 +631,7 @@ /** - * Static binary injection : section injection for static binaries + * Static binary injection : section injection for static binaries * * @param file * @param sect @@ -675,12 +641,12 @@ * @param mod * @return */ -int elfsh_insert_static_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int mod) +int elfsh_insert_static_section(elfshobj_t *file, + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + int mode, + u_int mod) { elfsh_Phdr phdr; elfsh_Phdr *curphdr; @@ -696,12 +662,12 @@ /* Fixup BSS if not already done */ lastsect = elfsh_fixup_bss(file); if (lastsect == NULL) - lastsect = file->sectlist; - + lastsect = file->sectlist; + /* Grab the last mapped section */ while (lastsect->next && lastsect->next->shdr->sh_addr) - lastsect = lastsect->next; - + lastsect = lastsect->next; + #if __DEBUG_STATIC__ printf("[DEBUG_STATIC] Found last section for static injection : %s \n", lastsect->name); @@ -713,7 +679,7 @@ rsize = hdr.sh_size + mod - (hdr.sh_size % mod); XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); if (data) - memcpy(rdata, data, hdr.sh_size); + memcpy(rdata, data, hdr.sh_size); hdr.sh_size = rsize; data = rdata; } @@ -730,7 +696,7 @@ /* If the latest injected PT_LOAD is not big enough or does not match the rights create a new one */ if (curphdr->p_type != PT_LOAD || totsize + rsize > curphdr->p_filesz) // || /* (elfsh_segment_is_executable(curphdr) && elfsh_get_section_writableflag(&hdr)) || - (elfsh_segment_is_writable(curphdr) && elfsh_get_section_execflag(&hdr))) */ + (elfsh_segment_is_writable(curphdr) && elfsh_get_section_execflag(&hdr))) */ phtnew = 1; else { @@ -741,23 +707,23 @@ /* Case where we inject in a new segment */ if (phtnew) { - + /* Create and inject the new PT_LOAD */ phdr = elfsh_create_phdr(PT_LOAD, 0, elfsh_get_pagesize(file), mod); phdr.p_flags = elfsh_set_phdr_prot(mode); phdr.p_vaddr = lastsect->shdr->sh_addr + lastsect->shdr->sh_size; - if (phdr.p_vaddr % elfsh_get_pagesize(file)) - phdr.p_vaddr += elfsh_get_pagesize(file) - phdr.p_vaddr % elfsh_get_pagesize(file); - + if (phdr.p_vaddr % elfsh_get_pagesize(file)) + phdr.p_vaddr += elfsh_get_pagesize(file) - phdr.p_vaddr % elfsh_get_pagesize(file); + /* Modify some ondisk information */ phdr.p_paddr = phdr.p_vaddr; hdr.sh_addr = phdr.p_vaddr; hdr.sh_offset = lastsect->shdr->sh_offset + lastsect->shdr->sh_size; - + /* align section's foffset */ if (hdr.sh_offset % elfsh_get_pagesize(file)) - hdr.sh_offset += elfsh_get_pagesize(file) - hdr.sh_offset % elfsh_get_pagesize(file); - + hdr.sh_offset += elfsh_get_pagesize(file) - hdr.sh_offset % elfsh_get_pagesize(file); + #if __DEBUG_STATIC__ printf("[DEBUG_STATIC] Static injection of %s section data in NEW PHDR! \n", sect->name); #endif @@ -777,26 +743,26 @@ /* Synchronize the ondisk perspective */ if (elfsh_insert_shdr(file, hdr, lastsect->index + 1, sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); + "Cannot insert shdr", -1); if (elfsh_add_section(file, sect, lastsect->index + 1, - data, ELFSH_SHIFTING_PARTIAL) < 0) + data, ELFSH_SHIFTING_PARTIAL) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); + "Cannot add section", -1); /* Inject the SECT symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert sectsym", -1); + "Cannot insert sectsym", -1); /* Insert the new program header in the runtime PHDR */ if (phtnew) { phdr.p_offset = sect->shdr->sh_offset; - sect->phdr = elfsh_insert_phdr(file, &phdr); + sect->phdr = elfsh_insert_phdr(file, &phdr); if (!sect->phdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert PHT entry", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert PHT entry", -1); } else sect->phdr = curphdr; @@ -810,7 +776,7 @@ /** * Insert a mapped section in the object - * This function is e2dbg safe + * This function is e2dbg safe * * @param file * @param sect @@ -821,11 +787,11 @@ * @return */ int elfsh_insert_mapped_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int modulo) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + int mode, + u_int modulo) { int err; @@ -834,16 +800,16 @@ /* Preliminary checks */ mode = (char) mode; if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); /* Runtime injection in memory */ if (elfsh_debugger_present()) { err = elfsh_insert_runtime_section(file, sect, hdr, data, mode, modulo); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot injection runtime section", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot injection runtime section", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -852,8 +818,8 @@ { err = elfsh_insert_static_section(file, sect, hdr, data, mode, modulo); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot injection static section", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot injection static section", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -864,26 +830,26 @@ case ELFSH_CODE_INJECTION: err = elfsh_insert_code_section(file, sect, hdr, data, modulo); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot perform ondisk code injection", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); case ELFSH_DATA_INJECTION: err = elfsh_insert_data_section(file, sect, hdr, data); if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot perform ondisk data injection", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown mode", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown mode", -1); } } /** - * Insert a non-mapped section in the object + * Insert a non-mapped section in the object * * @param file * @param sect @@ -892,9 +858,9 @@ * @return */ int elfsh_insert_unmapped_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data) { elfshsect_t *s; @@ -902,19 +868,19 @@ /* Preliminary checks */ if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); /* Sanity checks */ if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", -1); + "Cannot get SHT", -1); /* Get the last current section */ s = elfsh_get_section_by_index(file, file->hdr->e_shnum - 1, NULL, NULL); if (s == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get last section by index", -1); + "Cannot get last section by index", -1); /* Fix the file offset for the new section */ hdr.sh_offset = s->shdr->sh_offset + s->shdr->sh_size; @@ -923,23 +889,24 @@ if (hdr.sh_offset <= file->hdr->e_shoff && hdr.sh_offset + hdr.sh_size >= file->hdr->e_shoff) hdr.sh_offset = file->hdr->e_shoff + (file->hdr->e_shnum * - file->hdr->e_shentsize); + file->hdr->e_shentsize); /* Inject the new section and the associated header */ if (elfsh_insert_shdr(file, hdr, file->hdr->e_shnum, - sect->name, 1) < 0) + sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); + "Cannot insert shdr", -1); if (elfsh_add_section(file, sect, file->hdr->e_shnum - 1, - data, ELFSH_SHIFTING_COMPLETE) < 0) + data, ELFSH_SHIFTING_COMPLETE) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); + "Cannot add section", -1); /* Inject the symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); + // XXX: no symbol for unmapped section. + //if (elfsh_insert_sectsym(file, sect) < 0) + //PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + // "Cannot insert section symbol", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); } @@ -957,12 +924,12 @@ * @param mod * @return */ -elfshsect_t* elfsh_insert_section(elfshobj_t *file, - char *name, - char *data, - char mode, - u_int size, - u_int mod) +elfshsect_t* elfsh_insert_section(elfshobj_t *file, + char *name, + char *data, + char mode, + u_int size, + u_int mod) { elfshsect_t *sect; elfsh_Shdr hdr; @@ -974,38 +941,38 @@ /* Creation new section */ sect = elfsh_create_section(name); if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create section", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot create section", NULL); /* Preliminary checks */ if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", NULL); switch (mode) { case ELFSH_CODE_INJECTION: hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - 0, 0, size, 0, 0, 0, 0); + 0, 0, size, 0, 0, 0, 0); if (elfsh_insert_mapped_section(file, sect, hdr, data, mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert mapped code section", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert mapped code section", NULL); break; case ELFSH_DATA_INJECTION: - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_WRITE | SHF_ALLOC, - 0, 0, size, 0, 0, 0, 0); + hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_WRITE | SHF_ALLOC, + 0, 0, size, 0, 0, 0, 0); if (elfsh_insert_mapped_section(file, sect, hdr, data, mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert mapped data section", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert mapped data section", NULL); break; case ELFSH_UNMAPPED_INJECTION: hdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, size, 0, 0, 0, 0); if (elfsh_insert_unmapped_section(file, sect, hdr, data) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert unmapped section", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert unmapped section", NULL); break; default: @@ -1019,7 +986,7 @@ /** * Insert a section at the requested index - * Should only be used with ondisk files + * Should only be used with ondisk files * * @param file * @param sect @@ -1029,10 +996,10 @@ * @return */ int elfsh_insert_section_idx(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int index) + elfshsect_t *sect, + elfsh_Shdr hdr, + void *data, + u_int index) { elfshsect_t *s; @@ -1040,18 +1007,18 @@ /* Preliminary checks */ if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", -1); + "Cannot get SHT", -1); /* Get the last current section */ s = elfsh_get_section_by_index(file, index - 1, NULL, NULL); if (s == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get last section by index", -1); + "Cannot get last section by index", -1); /* Fix the file offset for the new section */ hdr.sh_offset = s->shdr->sh_offset + s->shdr->sh_size; @@ -1061,19 +1028,26 @@ /* Inject the new section and the associated header */ if (elfsh_insert_shdr(file, hdr, index, sect->name, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); + "Cannot insert shdr", -1); /* Add the section with absolute shifting */ if (elfsh_add_section(file, sect, index, data, ELFSH_SHIFTING_COMPLETE) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); + "Cannot add section", -1); /* Inject the symbol */ if (elfsh_insert_sectsym(file, sect) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); + "Cannot insert section symbol", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); } +/** + * HANDLER OF THE WRITEMEM VECTOR !!! + */ +int elfsh_memcpy(elfshobj_t *null, eresi_Addr addr, void *buf, u_int size) +{ + return (int)memcpy((void *) addr, buf, size); +} diff -Nru eresi-0.8a25/libelfsh/interp.c eresi-0.0.20110516/libelfsh/interp.c --- eresi-0.8a25/libelfsh/interp.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/interp.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file interp.c +* @file libelfsh/interp.c * @ingroup libelfsh ** interp.c for libelfsh ** ** Started on Sun Jun 10 20:29:18 2001 jfv ** ** -** $Id: interp.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: interp.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -36,7 +36,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "New INTERP path too long", -1); - strcpy(elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]), interp); + strncpy(elfsh_readmem(file->secthash[ELFSH_SECTION_INTERP]), interp, size1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -66,13 +66,13 @@ if (file->secthash[ELFSH_SECTION_INTERP]->data == NULL) { - enew->data = elfsh_load_section(file, - file->secthash[ELFSH_SECTION_INTERP]->shdr); + enew->data = elfsh_load_section(file, file->secthash[ELFSH_SECTION_INTERP]->shdr); if (enew->data == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to load .interp", NULL); } + /* We cannot call elfsh_readmem else we have an infinite loop */ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]))); } diff -Nru eresi-0.8a25/libelfsh/linkmap.c eresi-0.0.20110516/libelfsh/linkmap.c --- eresi-0.8a25/libelfsh/linkmap.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/linkmap.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file linkmap.c +* @file libelfsh/linkmap.c * @ingroup libelfsh ** linkmap.c for libelfsh ** @@ -8,7 +8,7 @@ ** Started on Mon Jul 25 21:26:54 2005 ym ** ** -** $Id: linkmap.c,v 1.5 2008-02-16 12:32:27 thor Exp $ +** $Id: linkmap.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/Makefile eresi-0.0.20110516/libelfsh/Makefile --- eresi-0.8a25/libelfsh/Makefile 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/Makefile 2011-05-16 11:34:54.000000000 +0000 @@ -11,14 +11,20 @@ LD ?= ld RM = rm -f AR = ar rc -CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libetrace/include \ - -I../libaspect/include/ $(KERNSHINC) \ - $(KERNSH) -DERESI32 $(BUILDOP) -CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libetrace/include/ \ - -I../libaspect/include/ $(KERNSHINC) \ - $(KERNSH) -DERESI64 $(BUILDOP) +CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 $(EXTRACFLAGS) \ + -I../libasm/include/ -I../libaspect/include/ \ + -DERESI32 $(BUILDOP) + +CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 $(EXTRACFLAGS) \ + -I../libasm/include/ -I../libaspect/include/ \ + -DERESI64 $(BUILDOP) + +LDFLAGS32 = -L../liballocproxy/ -lallocproxy -L../libaspect/ \ + -laspect32 -L../libasm -lasm32 + +LDFLAGS64 = -L../liballocproxy/ -lallocproxy -L../libaspect/ \ + -laspect64 -L../libasm -lasm64 + SRC = dynamic.c dynsym.c elf.c fixup.c got.c hash.c \ interp.c pht.c plt.c section.c sht.c stab.c \ symbol.c notes.c reloc.c ctors.c dtors.c search.c \ @@ -28,7 +34,9 @@ bss.c sort.c hooks.c ia32.c sparc32.c sparc64.c \ mips32.c alpha64.c ia64.c mips64.c reginfo.c \ altplt.c altgot.c extplt.c runtime.c state.c \ - inject.c linkmap.c bp.c rpht.c version.c dwarf.c + inject.c linkmap.c bp.c rpht.c version.c dwarf.c \ + vectors_default.c vectors_register.c vectors_call.c \ + vectors_fetch.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) @@ -39,9 +47,7 @@ libelfsh32.so : $(OBJ32) - @$(CC) -L../liballocproxy/ -lallocproxy \ - -L../libaspect/ -laspect32 -DERESI32 \ - $(KERNSHLIB32) -shared $(OBJ32) -o $(NAME32).so + @$(CC) $(LDFLAGS32) -shared $(OBJ32) -o $(NAME32).so @$(AR) $(NAME32).a $(OBJ32) @$(RANLIB) $(NAME32).a @$(LD) -r $(OBJ32) -o $(NAME32).o @@ -50,9 +56,7 @@ libelfsh64.so : $(OBJ64) - @$(CC) -L../liballocproxy/ -lallocproxy \ - -L../libaspect/ -laspect64 -DERESI64 \ - $(KERNSHLIB64) -shared $(OBJ64) -o $(NAME64).so + @$(CC) $(LDFLAGS64) -shared $(OBJ64) -o $(NAME64).so @$(AR) $(NAME64).a $(OBJ64) @$(RANLIB) $(NAME64).a @$(LD) -r $(OBJ64) -o $(NAME64).o diff -Nru eresi-0.8a25/libelfsh/map.c eresi-0.0.20110516/libelfsh/map.c --- eresi-0.8a25/libelfsh/map.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/map.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file map.c +* @file libelfsh/map.c * @ingroup libelfsh ** map.c for libelfsh ** ** Started on Sat Mar 2 20:47:36 2002 jfv ** ** -** $Id: map.c,v 1.25 2008-02-16 12:32:27 thor Exp $ +** $Id: map.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -164,8 +164,8 @@ */ elfshsect_t *elfsh_fixup_sctndx(elfshsect_t *symtab) { - int index; - elfsh_Sym *sym; + int index; + elfsh_Sym *sym; elfsh_SAddr offset; elfsh_Shdr *shdr; elfshsect_t *sct; diff -Nru eresi-0.8a25/libelfsh/mips32.c eresi-0.0.20110516/libelfsh/mips32.c --- eresi-0.8a25/libelfsh/mips32.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/mips32.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file mips32.c +* @file libelfsh/mips32.c * @ingroup libelfsh ** mips32.c for libelfsh ** @@ -8,7 +8,7 @@ ** Skeleton cut & pasted from the sparc64 backend ** ** -** $Id: mips32.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: mips32.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -67,7 +67,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid address to hijack", -1); - ret = elfsh_raw_read(file, off, (void *) buff, 3*4); + ret = elfsh_readmemf(file, off, (void *) buff, 3*4); if (ret != 3*4) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Function too small to be hijacked", -1); @@ -102,7 +102,7 @@ ret = 3 * 4; /* Create the hook for this function */ - data = elfsh_get_raw(hooks); + data = elfsh_readmem(hooks); memset(data + hooks->curend, 0x00, 40); // nop /* addi $t, $s, imm : 0010 00ss ssst tttt iiii iiii iiii iiii */ @@ -155,7 +155,7 @@ /* delay slot's NOP */ *((uint32_t *) ((char *) (hookbuf) + 0x8)) = 0x00000000; - len = elfsh_raw_write(file, off, hookbuf, ret); + len = elfsh_writememf(file, off, hookbuf, ret); if (len != ret) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Error during hook installation", -1); @@ -244,13 +244,13 @@ /* Signed 16bits displacement from %gp to last word of .pad.got */ diff = 0x800c; - originstr = elfsh_get_raw(padgot->data) + padgot->shdr->sh_size - 4; + originstr = elfsh_readmem(padgot->data) + padgot->shdr->sh_size - 4; *originstr = altgotprolog->shdr->sh_addr; gotdiff = (uint16_t) got->shdr->sh_addr - altgot->shdr->sh_addr; /* Valid _start signature on Linux, may you FIXME for other OS */ /* lw t9, __libc_start_main_off(gp) */ - originstr = ((uint32_t *) elfsh_get_raw(start) + 19); + originstr = ((uint32_t *) elfsh_readmem(start) + 19); /* Grab infos on .got using .dynamic */ dynent = elfsh_get_dynamic_entry_by_type(file, DT_MIPS_GOTSYM); @@ -267,7 +267,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "GOT smaller than DT_MIPS_GOTSYM", -1); - sym = elfsh_get_raw(dynsym); + sym = elfsh_readmem(dynsym); sym += gotsym; /* Find all .dynsym entries matching external variables @@ -327,8 +327,8 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, ".pad.got section too small", -1); - elfsh_raw_write(file, altgotprolog->shdr->sh_offset, opcode, sizeof(uint32_t) * 7); - elfsh_raw_write(file, padgot->shdr->sh_offset, opcode + 7, sizeof(uint32_t) * (2 + (varnbr * 2))); + elfsh_writememf(file, altgotprolog->shdr->sh_offset, opcode, sizeof(uint32_t) * 7); + elfsh_writememf(file, padgot->shdr->sh_offset, opcode + 7, sizeof(uint32_t) * (2 + (varnbr * 2))); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/mips64.c eresi-0.0.20110516/libelfsh/mips64.c --- eresi-0.8a25/libelfsh/mips64.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/mips64.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file mips64.c +* @file libelfsh/mips64.c * @ingroup libelfsh ** mips64.c for libelfsh ** @@ -8,7 +8,7 @@ ** Skeleton cut & pasted from the sparc64 backend ** ** -** $Id: mips64.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: mips64.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/notes.c eresi-0.0.20110516/libelfsh/notes.c --- eresi-0.8a25/libelfsh/notes.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/notes.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file notes.c +* @file libelfsh/notes.c * @ingroup libelfsh ** notes.c for libelfsh ** @@ -8,7 +8,7 @@ ** Started on Sun Jun 10 22:57:09 2001 jfv ** ** -** $Id: notes.c,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: notes.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/obj.c eresi-0.0.20110516/libelfsh/obj.c --- eresi-0.8a25/libelfsh/obj.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/obj.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,21 +1,170 @@ /** - * @file obj.c + * @file libelfsh/obj.c * @ingroup libelfsh -** obj.c for elfsh -** -** Started on Wed Feb 12 00:07:06 2003 jfv -** Last update Sun Mar 4 00:46:13 2007 thorkill -** -** $Id: obj.c,v 1.11 2008-02-16 12:32:27 thor Exp $ -** -*/ + * obj.c for elfsh + * + * Started on Wed Feb 12 00:07:06 2003 jfv + * Last update Sun Mar 4 00:46:13 2007 thorkill + * + * $Id: obj.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "libelfsh.h" /** - * Open the file 'name' and returns the elfshobj_t - * @param name - * @return + * Create an object map from scratch. Generally used to represent memory without true ELF structure. + * @param name Name to be given to the map. + * @return The elfshobj_t describing the new map. + */ +elfshobj_t *elfsh_create_obj(char *name, eresi_Addr start, u_int size, + elfsh_Half arch, elfsh_Half type, u_char enc, u_char clas) +{ + elfshobj_t *file; + u_int strsize; + elfsh_Shdr maphdr; + elfsh_Shdr symhdr; + elfsh_Shdr strhdr; + elfsh_Shdr shstrhdr; + elfsh_Ehdr *hdr; + elfsh_Shdr *sht; + elfsh_Phdr *pht; + u_int mapsz; + u_int symsz; + u_int strsz; + u_int shstrsz; + u_int symtabsz; + elfshsect_t *mapped; + elfshsect_t *symtab; + elfshsect_t *strtab; + elfshsect_t *shstrtab; + elfsh_Sym mappedsym; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Allocate the map structure */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, file, sizeof(elfshobj_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, hdr, sizeof(elfsh_Ehdr), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, sht, sizeof(elfsh_Shdr) * 4, NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, pht, sizeof(elfsh_Phdr), NULL); + file->name = strdup(name); + file->fd = (-1); + + /* Compute some needed sizes */ + mapsz = strlen(ELFSH_SECTION_NAME_MAPPED); + symsz = strlen(ELFSH_SECTION_NAME_SYMTAB); + strsz = strlen(ELFSH_SECTION_NAME_STRTAB); + shstrsz = strlen(ELFSH_SECTION_NAME_SHSTRTAB); + strsize = 1 + mapsz + symsz + strsz + shstrsz + 4; + symtabsz = sizeof(elfsh_Sym); + + /* Setup header */ + elfsh_set_shentsize(hdr, sizeof(elfsh_Shdr)); + elfsh_set_phentsize(hdr, sizeof(elfsh_Phdr)); + elfsh_set_ehsize(hdr, sizeof(elfsh_Ehdr)); + elfsh_set_version(hdr, EV_CURRENT); + elfsh_set_shstrtab_index(hdr, 3); + elfsh_set_objtype(hdr, ET_EXEC); + elfsh_set_shtnbr(hdr, 4); + elfsh_set_phtnbr(hdr, 1); + elfsh_set_shtoff(hdr, sizeof(elfsh_Ehdr) + sizeof(elfsh_Phdr) + size + symtabsz + (strsize * 2)); + elfsh_set_phtoff(hdr, sizeof(elfsh_Ehdr)); + elfsh_set_arch(hdr, arch); + elfsh_set_objtype(hdr, type); + elfsh_set_entrypoint(hdr, start); + elfsh_set_encoding(hdr, enc); + elfsh_set_class(hdr, clas); + memcpy(hdr->e_ident, ELFMAG, strlen(ELFMAG)); + file->hdr = hdr; + + /* Create sections table */ + maphdr = elfsh_create_shdr(1, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR, 0, + sizeof(elfsh_Ehdr) + sizeof(elfsh_Phdr), + size, 0, 0, sizeof(eresi_Addr), 0); + + symhdr = elfsh_create_shdr(mapsz + 2, SHT_SYMTAB, SHF_WRITE, 0, + sizeof(elfsh_Ehdr) + sizeof(elfsh_Phdr) + size, + symtabsz, 2, 0, 0, sizeof(elfsh_Sym)); + + strhdr = elfsh_create_shdr(mapsz + symsz + 3, SHT_STRTAB, SHF_WRITE, 0, + sizeof(elfsh_Ehdr) + sizeof(elfsh_Phdr) + size + symtabsz, + strsize, 1, 0, 0, 0); + + shstrhdr = elfsh_create_shdr(mapsz + symsz + strsz + 4, SHT_STRTAB, SHF_WRITE, 0, + sizeof(elfsh_Ehdr) + sizeof(elfsh_Phdr) + size + symtabsz + strsize, + strsize, 0, 0, 0, 0); + + memcpy(sht, &maphdr, sizeof(elfsh_Shdr)); + memcpy((char *) sht + sizeof(elfsh_Shdr), &symhdr, sizeof(elfsh_Shdr)); + memcpy((char *) sht + sizeof(elfsh_Shdr) * 2, &strhdr, sizeof(elfsh_Shdr)); + memcpy((char *) sht + sizeof(elfsh_Shdr) * 3, &shstrhdr, sizeof(elfsh_Shdr)); + file->sht = sht; + + /* Create segments table */ + elfsh_set_segment_type(pht, PT_LOAD); + elfsh_set_segment_flags(pht, PF_X | PF_W | PF_R); + elfsh_set_segment_memsz(pht, size); + elfsh_set_segment_filesz(pht, size); + file->pht = pht; + + /* Allocate and fill section descriptors */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, mapped, sizeof(elfshsect_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, symtab, sizeof(elfshsect_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, strtab, sizeof(elfshsect_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, shstrtab, sizeof(elfshsect_t), NULL); + + mapped->name = strdup(ELFSH_SECTION_NAME_MAPPED); + mapped->parent = file; + mapped->phdr = pht; + mapped->shdr = sht; + mapped->next = symtab; + XALLOC(__FILE__, __FUNCTION__, __LINE__, mapped->data, size, NULL); + + symtab->name = strdup(ELFSH_SECTION_NAME_SYMTAB); + symtab->parent = file; + symtab->shdr = (elfsh_Shdr *) ((char *) sht + sizeof(elfsh_Shdr)); + symtab->prev = mapped; + symtab->next = strtab; + symtab->index = 1; + symtab->curend = sizeof(elfsh_Sym); + + XALLOC(__FILE__, __FUNCTION__, __LINE__, symtab->data, sizeof(elfsh_Sym), NULL); + mappedsym = elfsh_create_symbol(0, size, STT_SECTION, 0, 0, 0); + memcpy(symtab->data, &mappedsym, sizeof(elfsh_Sym)); + + strtab->name = strdup(ELFSH_SECTION_NAME_STRTAB); + strtab->parent = file; + strtab->shdr = (elfsh_Shdr *) ((char *) sht + sizeof(elfsh_Shdr) * 2); + strtab->prev = symtab; + strtab->next = shstrtab; + strtab->index = 2; + XALLOC(__FILE__, __FUNCTION__, __LINE__, strtab->data, mapsz + 1, NULL); + strcpy(strtab->data, ELFSH_SECTION_NAME_MAPPED); + + shstrtab->name = strdup(ELFSH_SECTION_NAME_SHSTRTAB); + shstrtab->parent = file; + shstrtab->shdr = (elfsh_Shdr *) ((char *) sht + sizeof(elfsh_Shdr) * 3); + shstrtab->prev = strtab; + shstrtab->index = 3; + XALLOC(__FILE__, __FUNCTION__, __LINE__, shstrtab->data, strsize, NULL); + strcpy(shstrtab->data + 1, ELFSH_SECTION_NAME_MAPPED); + strcpy(shstrtab->data + mapsz + 2, ELFSH_SECTION_NAME_SYMTAB); + strcpy(shstrtab->data + mapsz + symsz + 3, ELFSH_SECTION_NAME_STRTAB); + strcpy(shstrtab->data + mapsz + symsz + strsz + 4, ELFSH_SECTION_NAME_SHSTRTAB); + + /* The final touch */ + file->sectlist = mapped; + file->secthash[ELFSH_SECTION_SYMTAB] = symtab; + file->secthash[ELFSH_SECTION_STRTAB] = strtab; + file->secthash[ELFSH_SECTION_SHSTRTAB] = shstrtab; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); +} + + +/** + * Open the file 'name' and create a descriptor. + * @param name File path to open. + * @return The elfshobj_t describing the loaded file. */ elfshobj_t *elfsh_load_obj(char *name) { @@ -29,14 +178,14 @@ /* Get the file size on disk */ if (0 != fstat(file->fd,&file->fstat)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get fstat(2)", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get fstat(2)", NULL); file->hdr = elfsh_get_hdr(file); file->rights = O_RDONLY; if (file->hdr == NULL || file->name == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get ELF header", NULL); + "Unable to get ELF header", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file)); } @@ -74,13 +223,13 @@ if (sect->altdata) XFREE(__FILE__, __FUNCTION__, __LINE__,sect->altdata); - + if (sect->terdata) XFREE(__FILE__, __FUNCTION__, __LINE__,sect->terdata); if (sect->lastdata) XFREE(__FILE__, __FUNCTION__, __LINE__,sect->lastdata); - + XFREE(__FILE__, __FUNCTION__, __LINE__,sect->name); next = sect->next; XFREE(__FILE__, __FUNCTION__, __LINE__,sect); diff -Nru eresi-0.8a25/libelfsh/pax.c eresi-0.0.20110516/libelfsh/pax.c --- eresi-0.8a25/libelfsh/pax.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/pax.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file pax.c +* @file libelfsh/pax.c * @ingroup libelfsh ** pax.c for elfsh ** ** Started on Tue Feb 11 20:52:36 2003 jfv ** Last update Tue Feb 18 06:17:27 2003 jfv ** -** $Id: pax.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: pax.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/pht.c eresi-0.0.20110516/libelfsh/pht.c --- eresi-0.8a25/libelfsh/pht.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/pht.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file pht.c +* @file libelfsh/pht.c * @ingroup libelfsh ** pht.c for libelfsh ** ** Started on Mon Feb 26 04:07:33 2001 jfv ** ** -** $Id: pht.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: pht.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -285,7 +285,7 @@ if (!p) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL argument", -1); - p->p_offset = (elfsh_Off) offset; + p->p_offset = (eresi_Off) offset; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -294,7 +294,7 @@ * @param p * @return */ -elfsh_Off elfsh_get_segment_offset(elfsh_Phdr *p) +eresi_Off elfsh_get_segment_offset(elfsh_Phdr *p) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -446,7 +446,7 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (actual + index)); /* Fix the address we look for depending on the file type and context */ - addr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(enew) ? + addr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(enew) ? file->rhdr.base + enew->shdr->sh_addr : enew->shdr->sh_addr); /* Try to find in runtime pht */ @@ -567,7 +567,7 @@ */ elfsh_Phdr elfsh_create_phdr(elfsh_Word t, eresi_Addr a, - elfsh_Off z, + eresi_Off z, elfsh_Word al) { elfsh_Phdr new; @@ -712,3 +712,24 @@ current->hdr->e_phnum--; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + + + +/** + * @brief Set PHT entry rights from elfsh section mode. + * @param mode ELFSH_CODE_INJECTION or ELFSH_DATA_INJECTION. + * @return The same rights in PF_* flags format. + */ +int elfsh_set_phdr_prot(u_int mode) +{ + elfsh_Word flags; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + flags = PF_R | PF_W; + // if (mode == ELFSH_CODE_INJECTION) + flags |= PF_X; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (flags)); +} diff -Nru eresi-0.8a25/libelfsh/plt.c eresi-0.0.20110516/libelfsh/plt.c --- eresi-0.8a25/libelfsh/plt.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/plt.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file plt.c +* @file libelfsh/plt.c * @ingroup libelfsh ** plt.c for libelfsh ** ** Started on Tue Jul 24 06:40:07 2001 jfv ** ** -** $Id: plt.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: plt.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/raw.c eresi-0.0.20110516/libelfsh/raw.c --- eresi-0.8a25/libelfsh/raw.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/raw.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,17 +1,85 @@ /** - * @file raw.c + * @file libelfsh/raw.c * @ingroup libelfsh -** raw.c for libelfsh -** -** Started on Wed Feb 27 19:41:45 2002 jfv -** Last update Thu Mar 20 05:47:12 2003 jfv -** -** $Id: raw.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ + * raw.c for libelfsh + * + * Started on Wed Feb 27 19:41:45 2002 jfv + * Last update Thu Mar 20 05:47:12 2003 jfv + * + * $Id: raw.c 1427 2010-07-09 20:54:05Z thorkill $ + * + */ #include "libelfsh.h" +/** + * @brief Get the buffered address from the real virtual address + */ +void *elfsh_get_raw_by_addr(elfshobj_t *current, eresi_Addr addr, void *buf, u_int size) +{ + elfshsect_t *sect; + elfsh_SAddr offset; + + /* This happens when the object is a ERESI variable or when we request + an address in runtime that is not part of any section */ + sect = elfsh_get_parent_section(current, (eresi_Addr) addr, &offset); + if (!sect) + return ((void *) addr); + + /* In debug mode, we return a pointer on the runtime data */ + if (elfsh_is_runtime_mode()) + { + if (!elfsh_section_is_runtime(sect)) + return ((void *) sect->parent->rhdr.base + sect->shdr->sh_addr + offset); + else if (!sect->shdr->sh_addr) + return ((void *) sect->data + offset); + else + return ((void *) sect->shdr->sh_addr + offset); + } + + /* Else we return a pointer on the cache data, doing a copy if requested */ + else + { + if (buf && size) + memcpy(buf, (char *) sect->data + offset, size); + return ((void *) sect->data + offset); + } + +} + + +/** + * @brief Nice embedded debugging trick : return a pointer on the section data. + * @brief This function makes the difference between static data and runtime data. + * @param sect Section to return the data buffer from. + */ +void *elfsh_get_raw(elfshsect_t *sect) +{ + void *dataptr = 0; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (elfsh_is_runtime_mode()) + { + + /* The address of the section */ + dataptr = (void *) sect->shdr->sh_addr; + + /* For runtime injected sections, do not add the base address of the object */ + if (!elfsh_section_is_runtime(sect)) + dataptr += sect->parent->rhdr.base; + + /* For unmapped sections */ + if (!dataptr) + dataptr = sect->data; + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); + } + if (sect) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->data)); + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameter", NULL); +} + /** * Perform a raw write on the object cache data @@ -33,13 +101,6 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(KERNSH) - if (kernsh_raw_write(file, foffset, src_buff, len) == len) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); - } -#endif - sect = elfsh_get_parent_section_by_foffset(file, foffset, NULL); if (sect == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -54,11 +115,11 @@ if (dst == NULL) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) { prot = elfsh_munprotect(file, (eresi_Addr) dst + sect_off, len); memcpy(dst + sect_off, src_buff, len); - elfsh_mprotect((eresi_Addr) dst + sect_off, len, prot); + elfsh_mprotect(file, (eresi_Addr) dst + sect_off, len, prot); } else memcpy(dst + sect_off, src_buff, len); @@ -79,24 +140,18 @@ */ int elfsh_raw_read(elfshobj_t *file, u_int foffset, void *dest_buff, int len) { - elfshsect_t *sect; - void *src; - int sect_off; - + volatile elfshsect_t *sect; + volatile void *src; + volatile int sect_off; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(KERNSH) - if (kernsh_raw_read(file, foffset, dest_buff, len) == len) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); - } -#endif - sect = elfsh_get_parent_section_by_foffset(file, foffset, NULL); if (sect == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid virtual address", -1); + printf("Found sect %s at off %u\n", sect->name, foffset); + sect_off = foffset - sect->shdr->sh_offset; if (sect_off + len > sect->shdr->sh_size) len -= (sect_off + len - sect->shdr->sh_size); diff -Nru eresi-0.8a25/libelfsh/reginfo.c eresi-0.0.20110516/libelfsh/reginfo.c --- eresi-0.8a25/libelfsh/reginfo.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/reginfo.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file reginfo.c +* @file libelfsh/reginfo.c * @ingroup libelfsh ** reginfo.c for libelfsh ** @@ -7,7 +7,7 @@ ** Updated on Wed Mar 23 14:21:32 2005 jfv ** ** -** $Id: reginfo.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: reginfo.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -81,6 +81,6 @@ "Can't read .reginfo section", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (&((elfsh_RegInfo *) elfsh_get_raw(reginfo))->ri_gp_value)); + (&((elfsh_RegInfo *) elfsh_readmem(reginfo))->ri_gp_value)); } diff -Nru eresi-0.8a25/libelfsh/relinject.c eresi-0.0.20110516/libelfsh/relinject.c --- eresi-0.8a25/libelfsh/relinject.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/relinject.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file relinject.c +* @file libelfsh/relinject.c * @ingroup libelfsh ** relinject.c for libelfsh ** @@ -12,7 +12,7 @@ ** Started on Fri Mar 28 14:55:37 2003 jfv ** ** -** $Id: relinject.c,v 1.19 2008-02-16 12:32:27 thor Exp $ +** $Id: relinject.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -182,9 +182,9 @@ u_char stage) { elfsh_Rel *cur; - u_int index; + volatile u_int index; elfsh_Sym *sym; - u_int size; + volatile u_int size; eresi_Addr *dword; eresi_Addr addr; char *name; @@ -244,7 +244,7 @@ "Unable to find symbol in ET_REL", -1); /* Grab a pointer on the dword that need to be relocated */ - dword = (eresi_Addr *) ((char *) elfsh_get_raw(enew) + cur->r_offset); + dword = (eresi_Addr *) ((char *) elfsh_readmem(enew) + cur->r_offset); /* ** If symbol type is NOTYPE, we use ET_EXEC symtab, else if @@ -407,10 +407,8 @@ } } - if (!found) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find any relocation table", -1); - + /* Note that we might have done no relocation if no table was available */ + /* This can happen on very simple .o files */ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/reloc.c eresi-0.0.20110516/libelfsh/reloc.c --- eresi-0.8a25/libelfsh/reloc.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/reloc.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file reloc.c +* @file libelfsh/reloc.c * @ingroup libelfsh ** reloc.c for elfsh ** ** Started on Tue Feb 27 14:34:50 2001 jfv ** ** -** $Id: reloc.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: reloc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -227,7 +227,7 @@ #else #error Unexpected __BYTE_ORDER ! #endif - rel = (void *) elfsh_get_raw(s); + rel = (void *) elfsh_readmem(s); rela = (void *) rel; for (idx = 0; idx < sz; idx++) @@ -398,7 +398,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find DYNSYM", NULL); - sym = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]) + + sym = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSYM]) + (tmp * ELFSH_SYMTAB_ENTRY_SIZE); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym)); } @@ -472,7 +472,7 @@ { for (idx = 0; idx < num; idx++) { - data = elfsh_get_raw(sect); + data = elfsh_readmem(sect); cur = (sect->shdr->sh_type == SHT_RELA ? (void *) ((elfsh_Rela *) data + idx) : (void *) ((elfsh_Rel *) data + idx)); @@ -510,7 +510,7 @@ if (sect == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", NULL); - else if (elfsh_get_raw(sect) == NULL) + else if (elfsh_readmem(sect) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section empty", NULL); else if (sect->shdr->sh_addr == NULL) @@ -534,9 +534,9 @@ sect->srcref = sect->dstref = 0; /* Read the actual section and find valid references */ - str = elfsh_get_raw(sect); + str = elfsh_readmem(sect); for (dword = (int *) str; - ((char *) dword + 4) <= ((char *) elfsh_get_raw(sect) + + ((char *) dword + 4) <= ((char *) elfsh_readmem(sect) + sect->shdr->sh_size); dword = (int *) str) { @@ -557,9 +557,9 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__,rel, sect->srcref * sizeof(elfshrel_t), NULL); /* Read the actual section again and create section rel table */ - str = elfsh_get_raw(sect); + str = elfsh_readmem(sect); for (index = 0, dword = (int *) str; - ((char *) dword + 4) <= ((char *) elfsh_get_raw(sect) + + ((char *) dword + 4) <= ((char *) elfsh_readmem(sect) + sect->shdr->sh_size); dword = (int *) str) { @@ -567,7 +567,7 @@ if (target != NULL) { vaddr = sect->shdr->sh_addr + - (eresi_Addr) ((char *) str - (char *) elfsh_get_raw(sect)); + (eresi_Addr) ((char *) str - (char *) elfsh_readmem(sect)); rel[index].idx_src = sect->index; rel[index].off_src = vaddr - sect->shdr->sh_addr; rel[index].idx_dst = target->index; diff -Nru eresi-0.8a25/libelfsh/remap.c eresi-0.0.20110516/libelfsh/remap.c --- eresi-0.8a25/libelfsh/remap.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/remap.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file remap.c +* @file libelfsh/remap.c * @ingroup libelfsh ** remap.c for elfsh ** @@ -9,7 +9,7 @@ ** Started on Mon Mar 17 09:30:33 2003 jfv ** ** -** $Id: remap.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: remap.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -103,7 +103,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section is not a symbol table", -1); - symtab = elfsh_get_raw(s); + symtab = elfsh_readmem(s); base = elfsh_get_object_baseaddr(s->parent); for (count = i = 0; i < s->shdr->sh_size / sizeof(elfsh_Sym); i++) { @@ -139,7 +139,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - if (elfsh_get_raw(cur) == NULL || cur->rel == NULL) + if (elfsh_readmem(cur) == NULL || cur->rel == NULL) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); /* Read the actual section and find valid references */ @@ -156,7 +156,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid IDX_DST", -1); - str = elfsh_get_raw(cur) + cur->rel[index].off_src; + str = elfsh_readmem(cur) + cur->rel[index].off_src; addr = target->shdr->sh_addr + cur->rel[index].off_dst + diff; memcpy(str, &addr, sizeof(eresi_Addr)); @@ -195,7 +195,7 @@ "Unexpected section type", -1); nbr = sect->shdr->sh_size / sizeof(elfsh_Dyn); - for (dyn = elfsh_get_raw(sect), count = index = 0; index < nbr; index++) + for (dyn = elfsh_readmem(sect), count = index = 0; index < nbr; index++) { val = elfsh_get_dynentry_val(dyn + index); parent = elfsh_get_parent_section(sect->parent, val, NULL); @@ -234,7 +234,7 @@ "Unexpected section type", -1); nbr = sect->shdr->sh_size / sizeof(elfsh_Rel); - for (rel = elfsh_get_raw(sect), count = index = 0; index < nbr; index++) + for (rel = elfsh_readmem(sect), count = index = 0; index < nbr; index++) { parent = elfsh_get_parent_section(sect->parent, rel[index].r_offset, @@ -301,7 +301,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unexpected section name", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_readmem(sect), sect->shdr->sh_size / sizeof(eresi_Addr), diff))); } @@ -323,7 +323,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unexpected section name", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_readmem(sect), sect->shdr->sh_size / sizeof(eresi_Addr), diff))); } @@ -346,7 +346,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unexpected section name", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_readmem(sect), sect->shdr->sh_size / sizeof(eresi_Addr), diff))); } @@ -370,7 +370,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section is not HASH", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_readmem(sect), sect->shdr->sh_size / sizeof(eresi_Addr), diff))); } @@ -388,7 +388,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); ret = 0; - if (sect == NULL || elfsh_get_raw(sect) == NULL) + if (sect == NULL || elfsh_readmem(sect) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL paramater", -1); diff -Nru eresi-0.8a25/libelfsh/rpht.c eresi-0.0.20110516/libelfsh/rpht.c --- eresi-0.8a25/libelfsh/rpht.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/rpht.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file rpht.c +* @file libelfsh/rpht.c * @ingroup libelfsh ** rpht.c for elfsh ** @@ -7,7 +7,7 @@ ** ** Started on Sat Oct 01 14:37:33 2005 jfv ** -** $Id: rpht.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: rpht.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/runtime.c eresi-0.0.20110516/libelfsh/runtime.c --- eresi-0.8a25/libelfsh/runtime.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/runtime.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file runtime.c +* @file libelfsh/runtime.c * @ingroup libelfsh ** runtime.c for libelfsh ** @@ -10,164 +10,56 @@ ** Started Sun 05 May 2005 22:29:54 mm ** ** -** $Id: runtime.c,v 1.9 2008-02-16 12:32:27 thor Exp $ +** $Id: runtime.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "libelfsh.h" -/** - * @brief Set PHT entry rights from elfsh section mode - * @param mode - * @return - */ -int elfsh_set_phdr_prot(u_int mode) -{ - elfsh_Word flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - flags = PF_R | PF_W; - // if (mode == ELFSH_CODE_INJECTION) - flags |= PF_X; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (flags)); -} - -/** - * @brief Map a new area in memory - * @param segment - * @return - */ -eresi_Addr elfsh_runtime_map(elfsh_Phdr *segment) +eresi_Addr elfsh_map_userland(elfshobj_t *file, u_int memsz, int prot) { + int fd; eresi_Addr addr; - int prot = 0; - + int flags; + int rights; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(IRIX) + fd = fopen(ELFSH_DEVZERO, O_RDWR); + if (fd < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to open "ELFSH_DEVZERO, ELFSH_INVALID_ADDR); + flags = MAP_PRIVATE; +#else + fd = 0; + flags = MAP_PRIVATE | MAP_ANONYMOUS; +#endif + + /* Put the mapping rights in mmap format */ + rights = 0; + if (prot & PF_R) + rights |= PROT_READ; + if (prot & PF_W); + rights |= PROT_WRITE; + if (prot & PF_X) + rights |= PROT_EXEC; - if (elfsh_segment_is_readable(segment)) - prot |= PROT_READ; - if (elfsh_segment_is_writable(segment)) - prot |= PROT_WRITE; - if (elfsh_segment_is_executable(segment)) - prot |= PROT_EXEC; - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] MMAP: " XFMT " of %d bytes \n", segment->p_vaddr, segment->p_memsz); -#endif - -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - if(kernsh_alloc(segment->p_memsz, ((unsigned long *)&addr)) == -1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot alloc memory", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (addr)); - } - -#endif + addr = (eresi_Addr) mmap(NULL, memsz, rights, flags, fd, 0); #if defined(IRIX) -{ - int zero; - - zero = fopen("/dev/zero", O_RDWR); - if (zero < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to open /dev/zero", - ELFSH_INVALID_ADDR); - - addr = (eresi_Addr) mmap((void *) 0, segment->p_memsz, - prot, - //elfsh_get_segment_flags(segment), - MAP_PRIVATE, - zero, 0); - close(zero); -} -#else - addr = (eresi_Addr) mmap((void *) 0, segment->p_memsz, - prot, - MAP_PRIVATE | MAP_ANONYMOUS, - 0, 0); + close(fd); #endif - - if (addr == 0 && segment->p_vaddr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mmap refused the mapping", - ELFSH_INVALID_ADDR); - #if __DEBUG_RUNTIME__ - else - printf("[DEBUG_RUNTIME] Section Mapped at addr %08X (%u) with prot %c%c%c\n", - addr, segment->p_memsz, - (elfsh_segment_is_readable(segment) ? 'R' : '-'), - (elfsh_segment_is_writable(segment) ? 'W' : '-'), - (elfsh_segment_is_executable(segment) ? 'X' : '-')); + printf("[DEBUG_RUNTIME] MMAP: " XFMT " of %d bytes \n", addr, memsz); #endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (addr)); -} - - -/** - * @brief Unmap a previously requested area - * @param segment - * @return - */ -int elfsh_runtime_unmap(elfsh_Phdr *segment) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = munmap((void *) segment->p_vaddr, segment->p_memsz); - - //if (!ret) - //memset(segment, 0x00, sizeof(elfsh_Phdr)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Remap an existing zone with a bigger size - * @param segment - * @param moresize - * @return - */ -int elfsh_runtime_remap(elfsh_Phdr *segment, uint32_t moresize) -{ - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_runtime_unmap(segment); - segment->p_memsz += moresize; - addr = elfsh_runtime_map(segment); if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Could not extend mmaped memory", - ELFSH_INVALID_ADDR); - - segment->p_vaddr = segment->p_paddr = addr; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Mmap refused the mapping", ELFSH_INVALID_ADDR); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addr); } -/** - * @brief Synchronize ondisk modifications in memory - * @return Always returns 0 - */ -int elfsh_runtime_sync() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} /** * @brief Put write capability on the zone @@ -176,9 +68,7 @@ * @param sz * @return */ -int elfsh_munprotect(elfshobj_t *file, - eresi_Addr addr, - uint32_t sz) +int elfsh_munprotect_userland(elfshobj_t *file, eresi_Addr addr, uint32_t sz) { elfshsect_t *sect; elfsh_Phdr *phdr; @@ -186,16 +76,7 @@ int prot; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - -#endif - - if (!elfsh_is_debug_mode()) + if (!elfsh_is_runtime_mode()) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); sect = elfsh_get_parent_section(file, addr, NULL); @@ -234,25 +115,16 @@ * @param prot * @return */ -int elfsh_mprotect(eresi_Addr addr, uint32_t sz, int prot) +int elfsh_mprotect_userland(elfshobj_t *file, eresi_Addr addr, uint32_t sz, int prot) { int retval; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - -#endif - if (!elfsh_is_debug_mode()) + if (!elfsh_is_runtime_mode()) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); retval = mprotect((void *) (long) addr - (long) addr % getpagesize(), getpagesize(), prot); - if (retval != 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed munprotect", -1); diff -Nru eresi-0.8a25/libelfsh/sanitize.c eresi-0.0.20110516/libelfsh/sanitize.c --- eresi-0.8a25/libelfsh/sanitize.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sanitize.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file sanitize.c +* @file libelfsh/sanitize.c * @ingroup libelfsh ** sanitize.c for elfsh ** ** Started on Sun Mar 30 04:13:03 2003 jfv ** ** -** $Id: sanitize.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: sanitize.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/save.c eresi-0.0.20110516/libelfsh/save.c --- eresi-0.8a25/libelfsh/save.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/save.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,372 +1,409 @@ /** - * @file save.c +* @file libelfsh/save.c * @ingroup libelfsh ** save.c for elfsh ** ** Started on Tue Mar 4 01:14:01 2003 jfv ** Last update Thu Mar 23 23:21:08 2006 thorkill ** - ** $Id: save.c,v 1.18 2008-02-16 12:32:27 thor Exp $ + ** $Id: save.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" -#include "libetrace.h" /** * @brief Find a string in a random buffer of size n - * @param buffer - * @param neddle - * @param n - * @return + * @param buffer Where to look at. + * @param neddle What to look for. + * @param n Maximum buffer size. + * @return A pointer on the needle, or NULL if not found. */ static char* elfsh_strstr(char *buffer, char *neddle, int n) { - int idx; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; idx < n; idx++) - { - ret = strstr(buffer + idx, neddle); - if (ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find injected names", NULL); + int idx; + char *ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (idx = 0; idx < n; idx++) + { + ret = strstr(buffer + idx, neddle); + if (ret) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find injected names", NULL); } /** - * Find the number of removed shdr before a given index - * @param file - * @param idx - * @return + * @brief Find the number of removed shdr before a given index. + * @param file The file to look at. + * @param idx Only consider sections header until index idx. + * @return The number of previously removed section in this file. */ static int elfsh_find_previous_rmnbr(elfshobj_t *file, u_int idx) { - elfshsect_t *sect; - int index; - int res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = file->sectlist; - for (res = index = 0; index < idx; index++, sect = sect->next) - if (sect->flags & ELFSH_SECTION_REMOVED) - res++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (res)); + elfshsect_t *sect; + u_int index; + int res; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + sect = file->sectlist; + for (res = index = 0; index < idx; index++, sect = sect->next) + if (sect->flags & ELFSH_SECTION_REMOVED) + res++; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (res)); } /** * Save SHT taking care of removed shdr if the file was cleaned up - * @param file - * @param fd - * @return + * @param file The file to save SHT from. + * @param fd File descriptor to use for storing. + * @return Return 1 if SHT has been saved, 0 if not, and -1 on error. */ static int elfsh_save_sht(elfshobj_t *file, int fd) { - elfsh_Shdr *newsht; - elfshsect_t *sect; - int index; - int wrindex; - uint32_t newsize; - uint32_t delsize; - char *first; - char *off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - + elfsh_Shdr *newsht; + elfshsect_t *sect; + int index; + int wrindex; + uint32_t newsize; + uint32_t delsize; + char *first; + char *off; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + #if __DEBUG_MAP__ - printf("[DEBUG_MAP] Writing SHT \t\t\t\t (file offset %u, size %u)\n", - (u_int) file->hdr->e_shoff, - (u_int) (file->hdr->e_shentsize * file->hdr->e_shnum)); + printf("[DEBUG_MAP] Writing SHT \t\t\t\t (file offset %u, size %u)\n", + (u_int) file->hdr->e_shoff, + (u_int) (file->hdr->e_shentsize * file->hdr->e_shnum)); #endif - - /* Allocate */ - newsize = (file->hdr->e_shnum - file->nbrm) * file->hdr->e_shentsize; - newsht = alloca(newsize); - memset(newsht, 0x00, newsize); - sect = file->sectlist; - first = NULL; - - /* Dump new SHT */ - for (wrindex = index = 0; index < file->hdr->e_shnum; index++, sect = sect->next) - if (!(sect->flags & ELFSH_SECTION_REMOVED)) - { - memcpy(newsht + wrindex, file->sht + index, file->hdr->e_shentsize); - newsht[wrindex].sh_link -= elfsh_find_previous_rmnbr(file, newsht[wrindex].sh_link); + + /* Allocate */ + newsize = (file->hdr->e_shnum - file->nbrm) * file->hdr->e_shentsize; + newsht = alloca(newsize); + memset(newsht, 0x00, newsize); + sect = file->sectlist; + first = NULL; + + /* Dump new SHT */ + for (wrindex = index = 0; index < file->hdr->e_shnum; index++, sect = sect->next) + if (!(sect->flags & ELFSH_SECTION_REMOVED)) + { + memcpy(newsht + wrindex, file->sht + index, file->hdr->e_shentsize); + newsht[wrindex].sh_link -= elfsh_find_previous_rmnbr(file, newsht[wrindex].sh_link); #if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Comparing current end from %s (%u vs %u) ! \n", - sect->name, sect->curend, sect->shdr->sh_size); + printf("[DEBUG_SAVE] Comparing current end from %s (%u vs %u) ! \n", + sect->name, sect->curend, sect->shdr->sh_size); #endif - - /* Avoid incorrect data dumping on partially filled sections */ - if (sect->curend) - { + + /* Avoid incorrect data dumping on partially filled sections */ + if (sect->curend) + { #if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Changing %s's size for current end ! \n", sect->name); + printf("[DEBUG_SAVE] Changing %s's size for current end ! \n", sect->name); #endif - newsht[wrindex].sh_size = sect->curend; - } - wrindex++; - } - else if (wrindex == index) - first = sect->name; - - /* Remove remaining section names in .shstrtab */ - sect = file->secthash[ELFSH_SECTION_SHSTRTAB]; - if (sect && first) + newsht[wrindex].sh_size = sect->curend; + } + wrindex++; + } + else if (wrindex == index) + first = sect->name; + + /* Remove remaining section names in .shstrtab */ + sect = file->secthash[ELFSH_SECTION_SHSTRTAB]; + if (sect && first) + { + off = elfsh_strstr(sect->data, first, sect->shdr->sh_size); + if (off) { - off = elfsh_strstr(sect->data, first, sect->shdr->sh_size); - if (off) - { - delsize = sect->shdr->sh_size - ((char *) off - (char *) sect->data); - memset(off, 0x00, delsize); - sect->shdr->sh_size -= delsize; - XSEEK(fd, elfsh_get_section_foffset(sect->shdr), SEEK_SET, -1); - XWRITE(fd, sect->data, sect->shdr->sh_size, -1); - } + delsize = sect->shdr->sh_size - ((char *) off - (char *) sect->data); + memset(off, 0x00, delsize); + sect->shdr->sh_size -= delsize; + XSEEK(fd, elfsh_get_section_foffset(sect->shdr), SEEK_SET, -1); + XWRITE(fd, sect->data, sect->shdr->sh_size, -1); } - - /* Write SHT */ - elfsh_endianize_sht((elfsh_Shdr *) newsht, - file->hdr->e_ident[EI_DATA], - file->hdr->e_shnum - file->nbrm); - XSEEK(fd, file->hdr->e_shoff, SEEK_SET, 0); - XWRITE(fd, newsht, newsize, 0); - + } + + /* Write SHT */ + elfsh_endianize_sht((elfsh_Shdr *) newsht, + file->hdr->e_ident[EI_DATA], + file->hdr->e_shnum - file->nbrm); + XSEEK(fd, file->hdr->e_shoff, SEEK_SET, 0); + XWRITE(fd, newsht, newsize, 0); + #if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Saved SHT -ok- \n"); + printf("[DEBUG_SAVE] Saved SHT -ok- \n"); #endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } /** - * Relocate during save process - * @param file - * @return + * @brief Relocate pending relocations on a file. + * @param file File to relocate. + * @return Success (0) or Error (-1). */ int elfsh_save_relocate(elfshobj_t *file) { - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Force the final relocations to be done (old_* symbols) */ - for (index = 0; index < file->nbrel; index++) - { - + u_int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Force the final relocations to be done (old_* symbols) */ + for (index = 0; index < file->nbrel; index++) + { + #if __DEBUG_MAP__ - printf("[DEBUG_MAP] Now relocating %s in second stage \n", - file->listrel[index]->name); + printf("[DEBUG_MAP] Now relocating %s in second stage \n", + file->listrel[index]->name); #endif - - if (elfsh_relocate_object(file, file->listrel[index], - ELFSH_RELOC_STAGE2) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Final stage relocation failed", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + if (elfsh_relocate_object(file, file->listrel[index], + ELFSH_RELOC_STAGE2) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Final stage relocation failed", -1); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + /** - * Unmap and free all ressources for this file - * @param file - * @param name - * @return + * @brief Prepare the file to be saved on disk. This function is called by elfsh_save_obj. + * @param file File to be saved on disk. + * @return Real file to store on disk. */ -int elfsh_save_obj(elfshobj_t *file, char *name) -{ - int fd; - char written_sht; - elfshsect_t *actual; - int index; - elfsh_Ehdr header; - elfsh_Phdr *pht; - unsigned int totsize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || file->sht == NULL || file->sectlist == NULL || - (file->pht == NULL && elfsh_get_objtype(file->hdr) != ET_REL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid elfshobj_t parameter", -1); - - if (elfsh_save_relocate(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Final stage relocation failed", -1); - - /* Insert a padding section to make the latest top-injected code section starting on a page bound */ - actual = file->sectlist; - while (actual && actual->shdr && !actual->shdr->sh_addr) - actual = actual->next; - - /* Only useful when we injected sections in the first PT_LOAD beforehand */ - if (actual && strstr(actual->name, ".elfsh")) +elfshobj_t *elfsh_save_preconds(elfshobj_t *file) +{ + elfshsect_t *actual; + unsigned int totsize; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (elfsh_save_relocate(file) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Final stage relocation failed", NULL); + + /* Insert a padding section to make the latest top-injected code section starting on a page bound */ + actual = file->sectlist; + while (actual && actual->shdr && !actual->shdr->sh_addr) + actual = actual->next; + + /* Only useful when we injected sections in the first PT_LOAD beforehand */ + if (actual && strstr(actual->name, ".elfsh")) + { + totsize = actual->shdr->sh_addr - sizeof(elfsh_Ehdr) - (sizeof(elfsh_Phdr) * file->hdr->e_phnum); + if (totsize % elfsh_get_pagesize(file)) { - totsize = actual->shdr->sh_addr - sizeof(elfsh_Ehdr) - (sizeof(elfsh_Phdr) * file->hdr->e_phnum); - if (totsize % elfsh_get_pagesize(file)) - { - actual = elfsh_insert_section(file, ELFSH_SECTION_NAME_PADPAGE, + actual = elfsh_insert_section(file, ELFSH_SECTION_NAME_PADPAGE, NULL, ELFSH_CODE_INJECTION, totsize % elfsh_get_pagesize(file), 0); - if (!actual) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject page padding section", -1); - } + if (!actual) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to inject page padding section", NULL); } + } + + /* Copy the object before saving (so that we dont strip the working file) */ + file = elfsh_copy_obj(file); + if (file == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to copy object", NULL); - /* Copy the object before saving (so that we dont strip the working file) */ - file = elfsh_copy_obj(file); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy object", -1); - - /* Apply awaiting function tracing hooks */ - if (file->hdr->e_type != ET_REL && etrace_save(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Tracing failed", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); +} - /* Open the output file */ -#ifdef __BEOS__ - XOPEN(fd, name, O_CREAT | O_RDWR , 0700, -1); -#else - XOPEN(fd, name, O_CREAT | O_RDWR | O_SYNC, 0700, -1); -#endif - /* First reset the endianess */ - if (!file->shtrb && elfsh_dynamic_file(file)) - { - if (elfsh_endianize_got(file->secthash[ELFSH_SECTION_GOT]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize got", -1); - if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_DYNSYM]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize dynsym", -1); - if (elfsh_endianize_dynamic(file->secthash[ELFSH_SECTION_DYNAMIC]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize dynamic", -1); - } - if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_SYMTAB]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize symtab", -1); - - /* Endianize multiple relocation sections */ - for (index = 0; - NULL != (actual = elfsh_get_reloc(file, index, NULL)); - index++) - elfsh_endianize_relocs(actual); - /* Strip the SHT if requested ... */ - if (file->shtrm) - { - file->hdr->e_shoff = 0; - file->hdr->e_shstrndx = 0; - file->hdr->e_shnum = 0; - } - /* .. or rewrite SHT if requested */ - else if (!file->hdr->e_shoff) - { - actual = elfsh_get_tail_section(file); - file->hdr->e_shoff = actual->shdr->sh_offset + actual->shdr->sh_size; - } +/** + * @brief Save a binary file on disk (interface function). + * @param file The file to be saved. + * @param name Name for saved file (full path). + * @return Success (0) or Error (-1). + */ +int elfsh_save_obj(elfshobj_t *file, char *name) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (file == NULL || file->sht == NULL || file->sectlist == NULL || + (file->pht == NULL && elfsh_get_objtype(file->hdr) != ET_REL)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid elfshobj_t parameter", -1); + + file = elfsh_save_preconds(file); + if (!file) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to prepare file for saving", -1); + + if (elfsh_store_obj(file, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to save object", -1); - /* Strip the file if requested */ - if (file->strip) - elfsh_strip(file); - - /* Write the ELF header making sure removed shdr are not written */ - memcpy(&header, file->hdr, file->hdr->e_ehsize); - header.e_shnum -= file->nbrm; - header.e_shstrndx -= elfsh_find_previous_rmnbr(file, header.e_shstrndx); - elfsh_endianize_elfhdr(&header, file->hdr->e_ident[EI_DATA]); - XWRITE(fd, &header, file->hdr->e_ehsize, -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} - /* Write the PHT */ - if (file->pht != NULL) - { - pht = alloca(file->hdr->e_phnum * file->hdr->e_phentsize); - memcpy(pht, file->pht, file->hdr->e_phnum * file->hdr->e_phentsize); - //elfsh_cleanup_bss(file, pht); - elfsh_endianize_pht(pht, file->hdr->e_ident[EI_DATA], file->hdr->e_phnum); - XSEEK(fd, file->hdr->e_phoff, SEEK_SET, -1); - XWRITE(fd, pht, file->hdr->e_phentsize * file->hdr->e_phnum, -1); - } - /* Nullify the first section size, so that we dont write it in the corefile */ + +/** + * @brief Store the binary file on disk. + * @param file The file to be stored. + * @param name The file path to use for storage. + * @return Success (0) or Error (-1). + */ +int elfsh_store_obj(elfshobj_t *file, char *name) +{ + int fd; + char written_sht; + elfshsect_t *actual; + int index; + elfsh_Ehdr header; + elfsh_Phdr *pht; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Open the output file */ +#ifdef __BEOS__ + XOPEN(fd, name, O_CREAT | O_RDWR , 0700, -1); +#else + XOPEN(fd, name, O_CREAT | O_RDWR | O_SYNC, 0700, -1); +#endif + + /* First reset the endianess */ + if (!file->shtrb && elfsh_dynamic_file(file)) + { + if (elfsh_endianize_got(file->secthash[ELFSH_SECTION_GOT]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to endianize got", -1); + if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_DYNSYM]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to endianize dynsym", -1); + if (elfsh_endianize_dynamic(file->secthash[ELFSH_SECTION_DYNAMIC]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to endianize dynamic", -1); + } + if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_SYMTAB]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to endianize symtab", -1); + + /* Endianize multiple relocation sections */ + for (index = 0; + NULL != (actual = elfsh_get_reloc(file, index, NULL)); + index++) + elfsh_endianize_relocs(actual); + + /* Strip the file if requested */ + if (file->strip) + elfsh_strip(file); + + /* Strip the SHT if requested ... */ + if (file->shtrm) + { + file->hdr->e_shoff = 0; + file->hdr->e_shstrndx = 0; + file->hdr->e_shnum = 0; + } + + /* .. or rewrite SHT if requested */ + else if (!file->hdr->e_shoff) + { + actual = elfsh_get_tail_section(file); + file->hdr->e_shoff = actual->shdr->sh_offset + actual->shdr->sh_size; + } + + /* Write the ELF header making sure removed shdr are not written */ + memcpy(&header, file->hdr, file->hdr->e_ehsize); + header.e_shnum -= file->nbrm; + header.e_shstrndx -= elfsh_find_previous_rmnbr(file, header.e_shstrndx); + elfsh_endianize_elfhdr(&header, file->hdr->e_ident[EI_DATA]); + XWRITE(fd, &header, file->hdr->e_ehsize, -1); + + /* Write the PHT */ + if (file->pht != NULL) + { + pht = alloca(file->hdr->e_phnum * file->hdr->e_phentsize); + memcpy(pht, file->pht, file->hdr->e_phnum * file->hdr->e_phentsize); + //elfsh_cleanup_bss(file, pht); + elfsh_endianize_pht(pht, file->hdr->e_ident[EI_DATA], file->hdr->e_phnum); + XSEEK(fd, file->hdr->e_phoff, SEEK_SET, -1); + XWRITE(fd, pht, file->hdr->e_phentsize * file->hdr->e_phnum, -1); + } + + /* Nullify the first section size, so that we dont write it in the corefile */ #if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Rebuild SHT flag is set: %d\n",file->shtrb); + printf("[DEBUG_SAVE] Rebuild SHT flag is set: %d\n",file->shtrb); #endif - if ((file->sectlist) && !file->shtrb) - file->sectlist->shdr->sh_size = 0; - - /* Write each sections in the destination file at their respective offset */ - for (written_sht = 0, actual = file->sectlist; actual; actual = actual->next) + /* If the first section is the null section */ + if (file->sectlist && !file->shtrb && !file->sectlist->shdr->sh_name) + file->sectlist->shdr->sh_size = 0; + + /* Write each sections in the destination file at their respective offset */ + for (written_sht = 0, actual = file->sectlist; actual; actual = actual->next) + { + + /* If SHT is not written yet and current section file offset is bigger */ + if (!written_sht && !file->shtrm && actual->shdr->sh_offset > file->hdr->e_shoff) + written_sht = elfsh_save_sht(file, fd); + + /* We do the check to avoid null sized section like .sbss to fool us */ + if (actual->data != NULL && + actual->shdr->sh_size && + !(actual->next && + actual->next->shdr->sh_offset == actual->shdr->sh_offset)) { - - /* If SHT is not written yet and current section file offset is bigger */ - if (!written_sht && !file->shtrm && actual->shdr->sh_offset > file->hdr->e_shoff) - written_sht = elfsh_save_sht(file, fd); - - /* We do the check to avoid null sized section like .sbss to fool us */ - if (actual->data != NULL && - actual->shdr->sh_size && - !(actual->next && - actual->next->shdr->sh_offset == actual->shdr->sh_offset)) - { - + #if __DEBUG_MAP__ - printf("[DEBUG_MAP] Writing identified section %15s (hdr: %-15s " - "vaddr = " AFMT ", idx %02u, foff %08u, size %08u, data = %08X)\n", - actual->name, elfsh_get_section_name(file, actual), - (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, - (u_int) elfsh_get_section_foffset(actual->shdr), - elfsh_get_section_size(actual->shdr), - (u_int) actual->data); + printf("[DEBUG_MAP] Writing identified section %15s (hdr: %-15s " + "vaddr = " AFMT ", idx %02u, foff %08u, size %08u, data = %08X)\n", + actual->name, elfsh_get_section_name(file, actual), + (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, + (u_int) elfsh_get_section_foffset(actual->shdr), + elfsh_get_section_size(actual->shdr), + (u_int) actual->data); #endif - - /* Write the section */ - XSEEK(fd, elfsh_get_section_foffset(actual->shdr), SEEK_SET, -1); - XWRITE(fd, actual->data, actual->shdr->sh_size, -1); - } - + + /* Write the section */ + XSEEK(fd, elfsh_get_section_foffset(actual->shdr), SEEK_SET, -1); + XWRITE(fd, actual->data, actual->shdr->sh_size, -1); + } + #if __DEBUG_MAP__ - else - printf("[DEBUG_MAP] PASSING identified section %15s (hdr: %-15s " - "vaddr = " AFMT " , idx %02u, foff %08u, size %08u, data = %08X)\n", - actual->name, elfsh_get_section_name(file, actual), - (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, - (u_int) elfsh_get_section_foffset(actual->shdr), - elfsh_get_section_size(actual->shdr), - (u_int) actual->data); + else + printf("[DEBUG_MAP] PASSING identified section %15s (hdr: %-15s " + "vaddr = " AFMT " , idx %02u, foff %08u, size %08u, data = %08X)\n", + actual->name, elfsh_get_section_name(file, actual), + (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, + (u_int) elfsh_get_section_foffset(actual->shdr), + elfsh_get_section_size(actual->shdr), + (u_int) actual->data); #endif - - } - - /* If SHT has not been written yet and current section foffset is bigger */ - if (!written_sht && !file->shtrm) - elfsh_save_sht(file, fd); - - /* If the SHT has been rewritten, we need to rewrite the ELF header in last */ - if (file->shtrb) - { - XSEEK(fd, 0, SEEK_SET, -1); - XWRITE(fd, &header, file->hdr->e_ehsize, -1); - } - + + } + + /* If SHT has not been written yet and current section foffset is bigger */ + if (!written_sht && !file->shtrm) + elfsh_save_sht(file, fd); + + /* If the SHT has been rewritten, we need to rewrite the ELF header in last */ + if (file->shtrb) + { + XSEEK(fd, 0, SEEK_SET, -1); + XWRITE(fd, &header, file->hdr->e_ehsize, -1); + } + #if __DEBUG_MAP__ - /* elfsh_print_sectlist(file); */ + /* elfsh_print_sectlist(file); */ #endif - - elfsh_unload_obj(file); - XCLOSE(fd, -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + elfsh_unload_obj(file); + XCLOSE(fd, -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/search.c eresi-0.0.20110516/libelfsh/search.c --- eresi-0.8a25/libelfsh/search.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/search.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file search.c +* @file libelfsh/search.c * @ingroup libelfsh ** search.c for libelfsh ** @@ -8,7 +8,7 @@ ** ** Started on Sat Nov 25 21:19:53 2006 jfv ** -** $Id: search.c,v 1.8 2008-02-16 12:32:27 thor Exp $ +** $Id: search.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/section.c eresi-0.0.20110516/libelfsh/section.c --- eresi-0.8a25/libelfsh/section.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/section.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,16 +1,15 @@ /** - * @file section.c + * @file libelfsh/section.c * @ingroup libelfsh -** section.c for libelfsh -** -** @brief All handlers and lowlevel routines for sections management -** -** Started on Mon Feb 26 04:12:42 2001 jfv -** -** -** $Id: section.c,v 1.19 2008-02-16 12:32:27 thor Exp $ -** -*/ + * section.c for libelfsh + * + * @brief All handlers and lowlevel routines for sections management. + * + * Started on Mon Feb 26 04:12:42 2001 jfv + * $Id: section.c 1427 2010-07-09 20:54:05Z thorkill $ + * + */ + #include "libelfsh.h" /** @@ -193,13 +192,12 @@ /** - * @brief Add a runtime section - * This function is internal, do not use it directly - * @param file - * @param sct - * @param range - * @param dat - * @return + * @brief Add a runtime section. This function is internal, do not use it directly. + * @param file The host file to add a section to. + * @param sct The section descriptor to add. + * @param range The index where to add the section. + * @param dat The data to put in the section. + * @return Success (0) or Error (-1). */ int elfsh_add_runtime_section(elfshobj_t *file, elfshsect_t *sct, @@ -251,6 +249,7 @@ sname = elfsh_get_section_name(file, section); if (sname == NULL) continue; + if (!strcmp(name, sname)) { if (idx != NULL) @@ -264,7 +263,7 @@ } } PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); + "Section not found", NULL); } /** @@ -288,11 +287,11 @@ if (file == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); + "Invalid NULL parameter", NULL); else if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No SHT", NULL); + "No SHT", NULL); sect = elfsh_get_section_by_name_withlist(file, name, idx, strindex, num, file->sectlist); @@ -302,7 +301,7 @@ if (!sect) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); + "Section not found", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect)); } @@ -429,7 +428,7 @@ int *num) { elfshsect_t *section; - int local; + u_int local; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -472,7 +471,7 @@ int *num) { elfshsect_t *section; - int local; + u_int local; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -502,18 +501,18 @@ } /** - * Load the code of a section giving its header - * Should be called after a elfsh_get_section_by_{name,type} to load the code - * @param file - * @param shdr - * @return + * @brief Load the code of a section giving its header. This function should be called after + * a elfsh_get_section_by_{name,type} to load the code. + * @param file Parent file. + * @param shdr Section header indicating where to load the section data from. + * @return Return a pointer on the loaded section descriptor (elfshsect_t) or NULL if error. */ void *elfsh_load_section(elfshobj_t *file, elfsh_Shdr *shdr) { void *sct; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - + if (shdr == NULL || !shdr->sh_size) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot load NULL section", NULL); @@ -525,10 +524,10 @@ } /** - * Fill an anonymous (unknown content) section - * @param file - * @param sect - * @return + * @brief Load an anonymous (unknown content) section. + * @param file The parent file. + * @param sect The section to be loaded. + * @return Return a pointer on the loaded section descriptor (elfshsect_t) or NULL if error. */ void *elfsh_get_anonymous_section(elfshobj_t *file, elfshsect_t *sect) { @@ -541,16 +540,16 @@ /* If the section is already loaded */ if (sect->data != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(sect))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_readmem(sect))); sect->data = elfsh_load_section(file, sect->shdr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(sect))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_readmem(sect))); } /** - * Creation a new orphelin section - * @param name - * @return + * @brief Create a new orphelin section from its name. + * @param name The name of the section to create. + * @return The descriptor of the newly created function. */ elfshsect_t *elfsh_create_section(char *name) { @@ -568,11 +567,11 @@ } /** - * Return the parent section for this virtual address - * @param file - * @param value - * @param offset - * @return + * @brief Return the parent section for its address. + * @param file The parent file. + * @param value The virtual address. + * @param offset Will be filled to indicate the offset within the section we want to read to. + * @return The section descriptor, or NULL if error. */ elfshsect_t *elfsh_get_parent_section(elfshobj_t *file, eresi_Addr value, @@ -582,7 +581,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (file == NULL || NULL == value) + if (file == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameter", NULL); @@ -591,7 +590,7 @@ "Cannot get SHT", NULL); /* ET_DYN objects have a relative addressing inside the ELF file */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) value -= file->rhdr.base; /* Look in static sections */ @@ -605,7 +604,7 @@ } /* ... but if the sections are runtime injected, their address is absolute */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) value += file->rhdr.base; /* Now look in runtime sections list */ @@ -636,7 +635,6 @@ { elfshsect_t *s; char i; - u_int bval; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -646,9 +644,7 @@ for (s = file->sectlist; s; s = s->next) { - bval = (s->next != NULL ? s->next->shdr->sh_offset : - s->shdr->sh_offset + s->shdr->sh_size); - i = INTERVAL(s->shdr->sh_offset, foff, bval); + i = INTERVAL(s->shdr->sh_offset, foff, s->shdr->sh_offset + s->shdr->sh_size); if (i && elfsh_get_section_type(s->shdr) != SHT_NOBITS) { if (offset != NULL) @@ -720,7 +716,7 @@ } -/* +/** * This function is quite context dependant and should be rewritten. * Symbol table shifting might be avoided in some obscure * not-yet-encountered cases. For now it works as requested quite @@ -852,6 +848,7 @@ elfsh_Sym *sym; u_int idx; u_int size; + void *tofree; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -884,7 +881,7 @@ obj->hdr->e_shnum--; XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, obj->hdr->e_shnum * sizeof(elfsh_Shdr), -1); memcpy(enew, obj->sht, obj->hdr->e_shnum * sizeof(elfsh_Shdr)); - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->sht); + tofree = obj->sht; obj->sht = enew; elfsh_sync_sht(obj); elfsh_sync_sectnames(obj); @@ -940,58 +937,20 @@ } /* Free deleted section */ - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->name); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->data); + XFREE(__FILE__, __FUNCTION__, __LINE__, todel->name); + XFREE(__FILE__, __FUNCTION__, __LINE__, todel->data); if (todel->altdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->altdata); + XFREE(__FILE__, __FUNCTION__, __LINE__, todel->altdata); if (todel->terdata) XFREE(__FILE__, __FUNCTION__, __LINE__,todel->terdata); if (todel->rel) - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->rel); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel); + XFREE(__FILE__, __FUNCTION__, __LINE__, todel->rel); + XFREE(__FILE__, __FUNCTION__, __LINE__, todel); + XFREE(__FILE__, __FUNCTION__, __LINE__, tofree); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * Nice embedded debugging trick - * Return a pointer on the section data - * This function makes the difference between data and pdata, beeing the process data - * @param sect - */ -void *elfsh_get_raw(elfshsect_t *sect) -{ - void *dataptr = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(KERNSH) - dataptr = kernsh_elfsh_get_raw(sect); - if (dataptr != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); -#endif - - if (elfsh_is_debug_mode()) - { - - /* The address of the section */ - dataptr = (void *) sect->shdr->sh_addr; - - /* For runtime injected sections, do not add the base address of the object */ - if (!elfsh_section_is_runtime(sect)) - dataptr += sect->parent->rhdr.base; - - /* For unmapped sections */ - if (!dataptr) - dataptr = sect->data; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); - } - if (sect) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->data)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameter", NULL); -} /** * Return the last section of the list @@ -1039,7 +998,7 @@ */ /** - * Return the section list + * @brief Return the section list * @param file * @param num * @return @@ -1061,7 +1020,7 @@ } /** - * Return the section list + * @brief Return the section list * @param file * @param num * @return @@ -1084,7 +1043,7 @@ /** - * Return the section giving its index + * @brief Return the section giving its index * @param list * @param index * @return @@ -1102,10 +1061,10 @@ } /** - * Return the section giving its name - * @param file - * @param name - * @return + * @brief Return the section giving its name (internal handler). + * @param file The parent file where to read the section. + * @param name The name of the section. + * @return The section descriptor or NULL if error. */ elfshsect_t *elfsh_get_section_by_nam(elfshobj_t *file, char *name) { @@ -1116,11 +1075,11 @@ } /** - * Section objects 'raw' child read access - * @param obj - * @param off - * @param sizelem - * @return + * @brief Raw read access to a section data. + * @param obj The section to read. + * @param off The object index to read in the section, or 1 if reading raw. + * @param sizelem The object size within this section, or 1 if reading raw. + * @return A pointer on the section's data or NULL if error. */ void *elfsh_get_section_data(elfshsect_t *obj, u_int off, u_int sizelem) @@ -1142,19 +1101,19 @@ "Offset too big", NULL); /* Return the data */ - data = elfsh_get_raw(obj); + data = elfsh_readmem(obj); data += (off * sizelem); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (data)); } /** - * Section objects 'raw' child write access - * @param sect - * @param off - * @param data - * @param size - * @param sizelem - * @return + * @brief Raw acess to section data. + * @param sect The section to access. + * @param off The offset within the section where to write. + * @param data The data to write (raw format). + * @param size The number of elements to write. + * @param sizelem The size of elements to write. + * @return Error (-1) or Success (0). */ int elfsh_write_section_data(elfshsect_t *sect, u_int off, @@ -1162,7 +1121,8 @@ u_int size, u_int sizelem) { - void *rdata; + void *rdata; + u_char iotype; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -1175,16 +1135,24 @@ if ((off * sizelem) + size > sect->shdr->sh_size) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section is too small", -1); + iotype = sect->parent->iotype; + + /* Vectors used differently depending on IO Type ! */ + if (iotype == ELFSH_IOTYPE_STATIC || iotype == ELFSH_IOTYPE_EMBEDDED) + { + rdata = elfsh_readmem(sect); + memcpy(rdata + (off * sizelem), data, size); + } + else + elfsh_writemem(sect->parent, sect->shdr->sh_addr + (off * sizelem), data, size); - rdata = elfsh_get_raw(sect); - memcpy(rdata + (off * sizelem), data, size); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** - * Is it a runtime section ? - * @param sect - * @return + * @brief Tell if a section exists on disk. + * @param sect The section + * @return Exist (0) or does not exist (1) on disk. */ int elfsh_section_is_runtime(elfshsect_t *sect) { diff -Nru eresi-0.8a25/libelfsh/sht.c eresi-0.0.20110516/libelfsh/sht.c --- eresi-0.8a25/libelfsh/sht.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sht.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file sht.c +* @file libelfsh/sht.c * @ingroup libelfsh ** sht.c for libelfsh ** ** Started on Mon Feb 26 04:16:18 2001 jfv ** -** $Id: sht.c,v 1.9 2008-02-16 12:32:27 thor Exp $ +** $Id: sht.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -427,7 +427,8 @@ for (current = file->secthash[ELFSH_SECTION_SYMTAB]->data; index < nbr; index++) if (elfsh_get_symbol_type(current + index) == STT_SECTION && - current[index].st_value == hdr->sh_addr) + current[index].st_value == hdr->sh_addr && + current[index].st_size == hdr->sh_size) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (current + index)); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -453,7 +454,7 @@ elfsh_Word type, elfsh_Word flags, eresi_Addr addr, - elfsh_Off offset, + eresi_Off offset, elfsh_Word size, elfsh_Word link, elfsh_Word info, @@ -744,7 +745,7 @@ /* Do not allocate new place if possible */ if (len >= new_len) - strcpy(str, name); + strncpy(str, name, new_len); /* Append the name to the section string table */ else if (!elfsh_section_is_runtime(s)) @@ -1126,7 +1127,7 @@ * @param s * @return */ -elfsh_Off elfsh_get_section_foffset(elfsh_Shdr *s) +eresi_Off elfsh_get_section_foffset(elfsh_Shdr *s) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -1149,7 +1150,7 @@ if (NULL == s) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter ", -1); - s->sh_offset = (elfsh_Off) offset; + s->sh_offset = (eresi_Off) offset; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/sht_rebuild.c eresi-0.0.20110516/libelfsh/sht_rebuild.c --- eresi-0.8a25/libelfsh/sht_rebuild.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sht_rebuild.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file sht_rebuild.c +* @file libelfsh/sht_rebuild.c * @ingroup libelfsh ** sht_rebuild.c for elfsh ** @@ -8,7 +8,7 @@ ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ** ** Started on Tue Mar 26 19:07:23 2002 jfv - ** $Id: sht_rebuild.c,v 1.24 2008-02-16 12:32:27 thor Exp $ + ** $Id: sht_rebuild.c 1397 2009-09-13 02:19:08Z may $ */ #include "libelfsh.h" #include "libasm.h" @@ -61,7 +61,7 @@ if (file->sht[index].sh_offset == shdr.sh_offset && len < 4) { /* In the rare case where both names have equal lenght, we can optimize a bit */ - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_SHSTRTAB]); + data = elfsh_readmem(file->secthash[ELFSH_SECTION_SHSTRTAB]); len = (file->sht[index].sh_name ? strlen(data + file->sht[index].sh_name) : 0); if (len == namelen) { @@ -207,7 +207,7 @@ * @param num * @return */ -static int elfsh_init_sht(elfshobj_t *file, u_int num) +static int elfsh_init_sht(elfshobj_t *file, u_int num) { elfsh_Shdr shdr; elfshsect_t *sect; @@ -216,8 +216,12 @@ void *data; unsigned int nnames,lnames,dnames; unsigned int tlsnames,ehnames,snames; - long type, total, section_offset, base_addr = 0, dyn_addr = 0, dyn_size = 0; + unsigned int dyn_size = 0; + long type, total, section_offset; + eresi_Addr sect_addr, base_addr = 0, dyn_addr = 0; int flags; + elfsh_Dyn *dyn; + elfsh_Word sect_size, ent_size; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -240,7 +244,7 @@ } } total++; - file->hdr->e_shnum = 100;//total+1; /* total, for the shstrtab */ + file->hdr->e_shnum = total+1; /* total, for the shstrtab */ file->hdr->e_shentsize = sizeof(elfsh_Shdr); /* insert the sht at the end of the file */ @@ -251,7 +255,7 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, file->sht, file->hdr->e_shentsize * (total + 8), -1); - printf("SHT @ 0x%p\n", file->sht); + //printf("SHT @ 0x%p\n", file->sht); snames = ehnames = tlsnames = nnames = lnames = dnames = 0; /* rebuild the sht based on the pht entries */ @@ -362,7 +366,7 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); sect->name=strdup(name); - printf("IDX[%d]: %s\n", idx, sect->name); + //printf("IDX[%d]: %s\n", idx, sect->name); if (elfsh_add_section(file, sect, idx++, data, ELFSH_SHIFTING_ABSENT)<0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to add section", -1); @@ -399,19 +403,15 @@ for (idx= 0, sect = file->sectlist; sect; sect=sect->next, idx++) { sect->shdr->sh_name = elfsh_insert_in_shstrtab(file, sect->name); - printf("name[%d][%d]:%s @ 0x%08x\n", idx, sect->shdr->sh_name, + printf("name[%d][%d]:%s @ " XFMT "\n", idx, sect->shdr->sh_name, sect->name, sect->shdr->sh_addr); section_offset += strlen(sect->name)+1; } #endif + /* final round for the sht reconstruction extract data from the .dynamic section - - WORK IN PROGRESS. */ - elfsh_Dyn *dyn; - eresi_Addr sect_addr; - elfsh_Word sect_size, ent_size; #if 1 /* .dynstr */ @@ -420,8 +420,7 @@ sect_addr = dyn->d_un.d_ptr; dyn = elfsh_get_dynamic_entry_by_type(file, DT_STRSZ); sect_size = dyn->d_un.d_val; - printf("@" XFMT " => SECT SIZE: %x %ld bytes\n", sect_addr - base_addr, sect_size, sect_size); - + shdr = elfsh_create_shdr(0, SHT_STRTAB, SHF_ALLOC, sect_addr, section_offset, sect_size,0,0,0, 0); @@ -434,7 +433,7 @@ XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - printf("READ: %d bytes\n", read(file->fd, data, sect_size)); + //printf("READ: %d bytes data @ %p (%ld)\n", read(file->fd, data, sect_size), data, sect_size); if(elfsh_add_section(file, sect, idx, data, ELFSH_SHIFTING_ABSENT)<0) @@ -471,9 +470,11 @@ sect->name = strdup(".dynsym"); XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, - ((sect_size / dyn->d_un.d_val) * ent_size)+1, -1); - XREAD(file->fd, data, (sect_size*6), -1); + //XALLOC(__FILE__, __FUNCTION__, __LINE__, data, + // ((sect_size / dyn->d_un.d_val) * ent_size)+1, -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); + XREAD(file->fd, data, sect_size, -1); + //XREAD(file->fd, data, (sect_size*6), -1); if(elfsh_add_section(file, sect, idx, data,ELFSH_SHIFTING_ABSENT)<0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -603,7 +604,7 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); sect->name = strdup(".got"); - printf("OFFSET: " AFMT " (size: " DFMT ")\n", sect_addr, (dyn_size)); + //printf("OFFSET: " AFMT " (size: " DFMT ")\n", sect_addr, (dyn_size)); XSEEK(file->fd, sect_addr - (base_addr + 0x1000), SEEK_SET, -1); XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); XREAD(file->fd, data, sect_size, -1); @@ -633,15 +634,15 @@ case EM_SPARC32PLUS: case EM_SPARC: case EM_SPARCV9: - asm_init_sparc(&proc); + asm_init_arch(&proc, ASM_PROC_SPARC); break; case EM_386: - asm_init_ia32(&proc); + asm_init_arch(&proc, ASM_PROC_IA32); break; case EM_MIPS: case EM_MIPS_RS3_LE: case EM_MIPS_X: - asm_init_mips(&proc); + asm_init_arch(&proc, ASM_PROC_MIPS); break; } @@ -702,13 +703,13 @@ case EM_SPARC32PLUS: case EM_SPARC: case EM_SPARCV9: - asm_init_sparc(&proc); + asm_init_arch(&proc, ASM_PROC_SPARC); break; case EM_386: - asm_init_ia32(&proc); + asm_init_arch(&proc, ASM_PROC_IA32); break; case EM_MIPS: - asm_init_mips(&proc); + asm_init_arch(&proc, ASM_PROC_MIPS); break; } @@ -778,8 +779,8 @@ for (idx= 0, sect = file->sectlist; sect; sect=sect->next, idx++) { sect->shdr->sh_name = elfsh_insert_in_shstrtab(file, sect->name); - printf("name[%d][%d]:%s @ 0x%08x\n", idx, sect->shdr->sh_name, - sect->name, sect->shdr->sh_addr); + //printf("name[%d][%d]:%s @ 0x%08x\n", idx, sect->shdr->sh_name, + // sect->name, sect->shdr->sh_addr); section_offset += strlen(sect->name) + 1; } #endif diff -Nru eresi-0.8a25/libelfsh/sort.c eresi-0.0.20110516/libelfsh/sort.c --- eresi-0.8a25/libelfsh/sort.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sort.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file sort.c +* @file libelfsh/sort.c * @ingroup libelfsh ** sort.c for elfsh ** @@ -9,7 +9,7 @@ ** Started on Wed May 21 15:27:15 2003 jfv ** ** -** $Id: sort.c,v 1.9 2008-02-16 12:32:27 thor Exp $ +** $Id: sort.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/sparc32.c eresi-0.0.20110516/libelfsh/sparc32.c --- eresi-0.8a25/libelfsh/sparc32.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sparc32.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file sparc32.c +* @file libelfsh/sparc32.c * @ingroup libelfsh * sparc32.c for libelfsh * * Started on Fri Jan 11 03:05:37 2003 jfv * * - * $Id: sparc32.c,v 1.8 2008-02-16 12:32:27 thor Exp $ + * $Id: sparc32.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" @@ -49,7 +49,7 @@ "Invalid address to hijack", -1); /* Read two instruction */ - ret = elfsh_raw_read(file, off, buff, 8); + ret = elfsh_readmemf(file, off, buff, 8); if (ret != 8) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to read an opcode", -1); @@ -62,7 +62,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get and inject .hooks", -1); - hook = elfsh_get_raw(hooks) + hooks->curend; + hook = elfsh_readmem(hooks) + hooks->curend; opcode = (uint32_t *) hook; #define SPARC32_B_OPCODE(_size) 0x10000000 + (_size < 0 ? 0xb00000 : 0x800000) + (((_size - (_size % 4)) / 4) & 0xFFFFF) @@ -71,7 +71,7 @@ /* Create the hook for this function */ prot = elfsh_munprotect(file, (eresi_Addr) hook, 28); - diff = addr - (hooks->shdr->sh_addr + (hook - (char *) elfsh_get_raw(hooks))); + diff = addr - (hooks->shdr->sh_addr + (hook - (char *) elfsh_readmem(hooks))); opcode[0] = SPARC32_B_OPCODE(diff); // b opcode[1] = SPARC32_NOP; @@ -84,7 +84,7 @@ opcode[5] = SPARC32_B_OPCODE(diff); // b opcode[6] = SPARC32_NOP; - elfsh_mprotect((eresi_Addr) hook, 28, prot); + elfsh_mprotect(file, (eresi_Addr) hook, 28, prot); opcode = (void *) buff; @@ -93,7 +93,7 @@ opcode[0] = SPARC32_B_OPCODE(diff); opcode[1] = SPARC32_NOP; - ret = elfsh_raw_write(file, off, buff, 8); + ret = elfsh_writememf(file, off, buff, 8); if (ret != 8) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Error during hook installation", -1); @@ -156,7 +156,7 @@ opcode[2] = 0x01000000; foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); + elfsh_writememf(file, foffset, opcode, 3 * sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -200,7 +200,7 @@ opcode[2] = 0x01000000; foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); + elfsh_writememf(file, foffset, opcode, 3 * sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -308,7 +308,7 @@ opcode[11] = 0xe623e008; foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 12 * sizeof(uint32_t)); + elfsh_writememf(file, foffset, opcode, 12 * sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/sparc64.c eresi-0.0.20110516/libelfsh/sparc64.c --- eresi-0.8a25/libelfsh/sparc64.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sparc64.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file sparc64.c +* @file libelfsh/sparc64.c * @ingroup libelfsh * sparc64.c for libelfsh * @@ -10,7 +10,7 @@ * 64 bits backend work-in-progress * * - * $Id: sparc64.c,v 1.7 2008-02-16 12:32:27 thor Exp $ + * $Id: sparc64.c 1440 2010-12-29 02:22:03Z may $ * */ #include "libelfsh.h" @@ -74,7 +74,7 @@ opcode[2] = 0x01000000; foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); + elfsh_writememf(file, foffset, opcode, 3 * sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -112,7 +112,7 @@ { int foffset; uint32_t addrh, addrl; - uint32_t opcode[11]; + uint32_t opcode[12]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -162,7 +162,7 @@ opcode[11] = 0xe623e008; foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 12 * sizeof(uint32_t)); + elfsh_writememf(file, foffset, opcode, 12 * sizeof(uint32_t)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libelfsh/stab.c eresi-0.0.20110516/libelfsh/stab.c --- eresi-0.8a25/libelfsh/stab.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/stab.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file stabs.c +* @file libelfsh/stab.c * @ingroup libelfsh * stabs.c for libelfsh * * Started on Mon Feb 26 04:14:06 2001 jfv * * - * $Id: stab.c,v 1.9 2008-02-16 12:32:27 thor Exp $ + * $Id: stab.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" @@ -33,7 +33,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot retreive stabs section", NULL); - str = (char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_STABSTR]) + s->strindex; + str = (char *) elfsh_readmem(file->secthash[ELFSH_SECTION_STABSTR]) + s->strindex; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str)); } @@ -90,7 +90,7 @@ *num = nbr / sizeof(elfshstabent_t); } - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_STAB]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_STAB]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } diff -Nru eresi-0.8a25/libelfsh/state.c eresi-0.0.20110516/libelfsh/state.c --- eresi-0.8a25/libelfsh/state.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/state.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,13 +1,10 @@ /** - * @file state.c +* @file libelfsh/state.c * @ingroup libelfsh * @brief Provide initialization and debugger state related functions. * * Started on Sat Jun 2 15:20:18 2005 jfv - * - * - * $Id: state.c,v 1.17 2008-02-16 12:32:27 thor Exp $ - * + * $Id: state.c 1397 2009-09-13 02:19:08Z may $ */ #include "libelfsh.h" @@ -57,17 +54,17 @@ /** * @ brief check if we are running in debug mode */ -u_char elfsh_is_debug_mode() +Bool elfsh_is_runtime_mode() { - return (dbgworld.mode == LIBELFSH_MODE_E2DBG); + return (dbgworld.mode == LIBELFSH_MODE_RUNTIME); } /** * @brief set debug mode */ -void elfsh_set_debug_mode() +void elfsh_set_runtime_mode() { - elfsh_set_mode(LIBELFSH_MODE_E2DBG); + elfsh_set_mode(LIBELFSH_MODE_RUNTIME); dbgworld.indebug = 1; } @@ -79,7 +76,6 @@ { //fprintf(stderr, "MODE changed for [%s] ! \n", //(mode == LIBELFSH_MODE_STATIC ? "static" : "dynamic")); - dbgworld.mode = mode; } @@ -106,10 +102,10 @@ void elfsh_toggle_mode() { - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) elfsh_set_static_mode(); else - elfsh_set_debug_mode(); + elfsh_set_runtime_mode(); } /** diff -Nru eresi-0.8a25/libelfsh/strip.c eresi-0.0.20110516/libelfsh/strip.c --- eresi-0.8a25/libelfsh/strip.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/strip.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file strip.c +* @file libelfsh/strip.c * @ingroup libelfsh * Made by jfv * Login @@ -7,7 +7,7 @@ * Started on Sat Mar 15 03:45:54 2003 jfv * Last update Mon Mar 17 04:40:35 2003 jfv * - * $Id: strip.c,v 1.7 2008-02-16 12:32:27 thor Exp $ + * $Id: strip.c 1397 2009-09-13 02:19:08Z may $ * */ diff -Nru eresi-0.8a25/libelfsh/strtab.c eresi-0.0.20110516/libelfsh/strtab.c --- eresi-0.8a25/libelfsh/strtab.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/strtab.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file strtab.c +* @file libelfsh/strtab.c * @ingroup libelfsh * strtab.c for libelfsh * * Started on Sun Mar 10 03:24:23 2002 jfv * Last update Sun May 25 17:40:19 2003 jfv * - * $Id: strtab.c,v 1.10 2008-02-16 12:32:27 thor Exp $ + * $Id: strtab.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" diff -Nru eresi-0.8a25/libelfsh/.svn/all-wcprops eresi-0.0.20110516/libelfsh/.svn/all-wcprops --- eresi-0.8a25/libelfsh/.svn/all-wcprops 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,359 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/958/trunk/libelfsh -END -ia32.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libelfsh/ia32.c -END -alpha64.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/alpha64.c -END -altplt.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/altplt.c -END -interp.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/908/trunk/libelfsh/interp.c -END -comment.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/908/trunk/libelfsh/comment.c -END -dwarf.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/908/trunk/libelfsh/dwarf.c -END -section.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/section.c -END -sht_rebuild.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libelfsh/sht_rebuild.c -END -symbol.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/symbol.c -END -elf.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/elf.c -END -obj.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/908/trunk/libelfsh/obj.c -END -inject.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/inject.c -END -rpht.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/908/trunk/libelfsh/rpht.c -END -extplt.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/extplt.c -END -mips64.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/mips64.c -END -sparc64.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/sparc64.c -END -runtime.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/runtime.c -END -dynsym.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/dynsym.c -END -hash.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libelfsh/hash.c -END -dynamic.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/dynamic.c -END -sanitize.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/908/trunk/libelfsh/sanitize.c -END -debug.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/908/trunk/libelfsh/debug.c -END -hijack.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/hijack.c -END -altgot.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/altgot.c -END -pht.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/pht.c -END -linkmap.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/linkmap.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/950/trunk/libelfsh/Makefile -END -sht.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/sht.c -END -save.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libelfsh/save.c -END -strtab.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/908/trunk/libelfsh/strtab.c -END -plt.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/908/trunk/libelfsh/plt.c -END -bp.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/908/trunk/libelfsh/bp.c -END -strip.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/908/trunk/libelfsh/strip.c -END -ia64.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libelfsh/ia64.c -END -reloc.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/reloc.c -END -remap.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/remap.c -END -bt.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/908/trunk/libelfsh/bt.c -END -search.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/908/trunk/libelfsh/search.c -END -copy.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/908/trunk/libelfsh/copy.c -END -mips32.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libelfsh/mips32.c -END -map.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/map.c -END -sparc32.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/sparc32.c -END -relinject.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/946/trunk/libelfsh/relinject.c -END -state.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/908/trunk/libelfsh/state.c -END -sym_common.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libelfsh/sym_common.c -END -hooks.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/hooks.c -END -version.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/version.c -END -dumpregs.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/908/trunk/libelfsh/dumpregs.c -END -bss.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/bss.c -END -sort.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/908/trunk/libelfsh/sort.c -END -notes.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/notes.c -END -pax.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/pax.c -END -got.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/got.c -END -raw.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libelfsh/raw.c -END -reginfo.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/libelfsh/reginfo.c -END -stab.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libelfsh/stab.c -END -ctors.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/ctors.c -END -fixup.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/fixup.c -END -dtors.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libelfsh/dtors.c -END diff -Nru eresi-0.8a25/libelfsh/.svn/entries eresi-0.0.20110516/libelfsh/.svn/entries --- eresi-0.8a25/libelfsh/.svn/entries 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,742 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libelfsh -http://svn.eresi-project.org/svn - - - -2008-04-03T11:41:49.560530Z -958 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -ia32.c -file - - - - -2008-04-06T23:15:37.464127Z -018f239c8c671b56b71259c88e5719df -2008-03-27T22:53:48.747992Z -946 -may - -alpha64.c -file - - - - -2008-04-06T23:15:37.488149Z -31cf4c12ffd1fd7310f5eabba89344e5 -2008-03-27T22:53:48.747992Z -946 -may - -altplt.c -file - - - - -2008-04-06T23:15:37.500137Z -53d17a85898c45f666b1b373b271545f -2008-03-27T22:53:48.747992Z -946 -may - -interp.c -file - - - - -2008-04-06T23:15:37.511648Z -f5cdff6295a4e144c34c2da57e1cffde -2008-03-14T09:47:56.675030Z -908 -enioh - -comment.c -file - - - - -2008-04-06T23:15:37.522903Z -a4cb5c59fdff157be6e9aa3bb1953b2b -2008-03-14T09:47:56.675030Z -908 -enioh - -dwarf.c -file - - - - -2008-04-06T23:15:37.534506Z -f8edd6fd904f2aedaffdc120d37576f9 -2008-03-14T09:47:56.675030Z -908 -enioh - -section.c -file - - - - -2008-04-06T23:15:37.545928Z -170f910e7f80d25b0cd126aa7d350ae7 -2008-03-27T22:53:48.747992Z -946 -may - -sht_rebuild.c -file - - - - -2008-04-06T23:15:37.557367Z -c7b1913106074718519be703252dbf5e -2008-03-27T22:53:48.747992Z -946 -may - -symbol.c -file - - - - -2008-04-06T23:15:37.568900Z -d080ecb0d473608043d1c6681e0648a0 -2008-03-27T22:53:48.747992Z -946 -may - -elf.c -file - - - - -2008-04-06T23:15:37.580396Z -39138bbe7f2a958c68b6092d7806a64a -2008-03-27T22:53:48.747992Z -946 -may - -obj.c -file - - - - -2008-04-06T23:15:37.591876Z -fca49e9abcdb605614a99bde33689b7a -2008-03-14T09:47:56.675030Z -908 -enioh - -inject.c -file - - - - -2008-04-06T23:15:37.603179Z -ee4ec1a16a454336362a5a9e95d5500a -2008-03-27T22:53:48.747992Z -946 -may - -rpht.c -file - - - - -2008-04-06T23:15:37.613899Z -2cf7685c521f07bec9a6b6dde835a591 -2008-03-14T09:47:56.675030Z -908 -enioh - -extplt.c -file - - - - -2008-04-06T23:15:37.626175Z -2c279d85f68148a5220f2c1ede58458e -2008-03-27T22:53:48.747992Z -946 -may - -sparc64.c -file - - - - -2008-04-06T23:15:37.648900Z -19fad9ca56b6e7e4cc3c64c877bd883c -2008-03-27T22:53:48.747992Z -946 -may - -mips64.c -file - - - - -2008-04-06T23:15:37.637024Z -fbc36cedbb43c7c681b3d1d34b5fb95f -2008-03-27T22:53:48.747992Z -946 -may - -runtime.c -file - - - - -2008-04-06T23:15:37.683426Z -818c88957fd7fb542c0168c9a6069681 -2008-03-27T22:53:48.747992Z -946 -may - -dynsym.c -file - - - - -2008-04-06T23:15:37.671899Z -78865413d898cffcb9683980f0f61e86 -2008-03-27T22:53:48.747992Z -946 -may - -hash.c -file - - - - -2008-04-06T23:15:37.660550Z -c430d82f949e6ac8ee6d850a00129218 -2008-03-27T22:53:48.747992Z -946 -may - -dynamic.c -file - - - - -2008-04-06T23:15:37.694960Z -c4d054c37d8e2d467a8648a3958c1fea -2008-03-27T22:53:48.747992Z -946 -may - -doc -dir - -sanitize.c -file - - - - -2008-04-06T23:15:37.718216Z -cb4688b7ba37a3ed3f382db14b15d267 -2008-03-14T09:47:56.675030Z -908 -enioh - -debug.c -file - - - - -2008-04-06T23:15:37.706877Z -a31ea59f2a82208a4420e1789a7b63e1 -2008-03-14T09:47:56.675030Z -908 -enioh - -hijack.c -file - - - - -2008-04-06T23:15:37.728899Z -175ea0f85bee9b5208ceced14e58b07b -2008-03-27T22:53:48.747992Z -946 -may - -altgot.c -file - - - - -2008-04-06T23:15:37.741180Z -8b1ce2f0f8b611048112ab9ef50feb29 -2008-03-27T22:53:48.747992Z -946 -may - -pht.c -file - - - - -2008-04-06T23:15:37.765877Z -8a0e18d75d6d828aaf543975188d090a -2008-03-27T22:53:48.747992Z -946 -may - -linkmap.c -file - - - - -2008-04-06T23:15:37.753899Z -758a17cb53b5784f6152a86a7bdea172 -2008-03-27T22:53:48.747992Z -946 -may - -Makefile -file - - - - -2008-04-06T23:15:37.777160Z -fa94119a1f2696942ae8068e82e13a79 -2008-03-29T07:54:04.209482Z -950 -enioh - -sht.c -file - - - - -2008-04-06T23:15:37.800193Z -a697b0922f6903aff45a54457d307e56 -2008-03-27T22:53:48.747992Z -946 -may - -save.c -file - - - - -2008-04-06T23:15:37.787901Z -30eb54fbcd7626e5cdd408ddfc95215b -2008-03-27T22:53:48.747992Z -946 -may - -plt.c -file - - - - -2008-04-06T23:15:37.811651Z -c7b5afe9e6dbd4f8470b51cee1a7a495 -2008-03-14T09:47:56.675030Z -908 -enioh - -strtab.c -file - - - - -2008-04-06T23:15:37.822903Z -882e07ca2aa0062cc1469db2423c7fe3 -2008-03-14T09:47:56.675030Z -908 -enioh - -bp.c -file - - - - -2008-04-06T23:15:37.834684Z -a1730f7810d77e15da07bd9fd0f6f78d -2008-03-14T09:47:56.675030Z -908 -enioh - -strip.c -file - - - - -2008-04-06T23:15:37.845905Z -746918e6c2dcb0de65445ab078eb073c -2008-03-14T09:47:56.675030Z -908 -enioh - -include -dir - -ia64.c -file - - - - -2008-04-06T23:15:37.857660Z -8e5b04cbe0be63511dc8a629e3760049 -2008-03-27T22:53:48.747992Z -946 -may - -reloc.c -file - - - - -2008-04-06T23:15:37.868900Z -2aa9aab75df212494f8fe8503c815f7b -2008-03-27T22:53:48.747992Z -946 -may - -remap.c -file - - - - -2008-04-06T23:15:37.880634Z -59ab7c822a092e70043872c9e9d01837 -2008-03-27T22:53:48.747992Z -946 -may - -bt.c -file - - - - -2008-04-06T23:15:37.892151Z -02b2b9d85c6094f602ad5c7d162af638 -2008-03-14T09:47:56.675030Z -908 -enioh - -search.c -file - - - - -2008-04-06T23:15:37.903667Z -fb489c521abe7926c2f6c9a42ca77a96 -2008-03-14T09:47:56.675030Z -908 -enioh - -copy.c -file - - - - -2008-04-06T23:15:37.915182Z -b5373ccf6de034a6ff370f97e9cc4c0f -2008-03-14T09:47:56.675030Z -908 -enioh - -mips32.c -file - - - - -2008-04-06T23:15:37.926876Z -93a994484279e9ec8fa7c5e10a70fb67 -2008-03-27T22:53:48.747992Z -946 -may - -map.c -file - - - - -2008-04-06T23:15:37.938215Z -917b0cf3b5a0aa4e4064286dc86be1f2 -2008-03-27T22:53:48.747992Z -946 -may - -sparc32.c -file - - - - -2008-04-06T23:15:37.949877Z -a1aa796d229b5af18573c5d0aec613a6 -2008-03-27T22:53:48.747992Z -946 -may - -relinject.c -file - - - - -2008-04-06T23:15:37.961886Z -d4e7ba7502fb26a585f352affdaf4099 -2008-03-27T22:53:48.747992Z -946 -may - -state.c -file - - - - -2008-04-06T23:15:37.972876Z -b0997da0ea8bb31bbc5531c5a388d3e0 -2008-03-14T09:47:56.675030Z -908 -enioh - -sym_common.c -file - - - - -2008-04-06T23:15:37.983876Z -9cab518b40bcdcd28f404eb95a678844 -2008-03-27T22:53:48.747992Z -946 -may - -hooks.c -file - - - - -2008-04-06T23:15:37.995876Z -dfac96706a0bd0a2ea2cf17f87ef69b4 -2008-03-27T22:53:48.747992Z -946 -may - -version.c -file - - - - -2008-04-06T23:15:38.007127Z -0caae996d464778a5df9e0271e6f10a5 -2008-03-27T22:53:48.747992Z -946 -may - -dumpregs.c -file - - - - -2008-04-06T23:15:38.018876Z -d6dafa80ed5c99ec6bc73806302ba410 -2008-03-14T09:47:56.675030Z -908 -enioh - -bss.c -file - - - - -2008-04-06T23:15:38.030404Z -e216a06fba67c825e1fecd135a7fb53b -2008-03-27T22:53:48.747992Z -946 -may - -sort.c -file - - - - -2008-04-06T23:15:38.041921Z -8214f42fb68e1eaa4378fe74bb52afae -2008-03-14T09:47:56.675030Z -908 -enioh - -notes.c -file - - - - -2008-04-06T23:15:38.053437Z -d516b250d9522f3d28db1eb77ddd49d7 -2008-03-27T22:53:48.747992Z -946 -may - -pax.c -file - - - - -2008-04-06T23:15:38.064955Z -51ad3150fec9103d0a195c188c4cee5b -2008-03-27T22:53:48.747992Z -946 -may - -got.c -file - - - - -2008-04-06T23:15:38.077880Z -f9698970e407c40a49fceaa2b3e4cbb9 -2008-03-27T22:53:48.747992Z -946 -may - -raw.c -file - - - - -2008-04-06T23:15:38.088899Z -cf662fa74a807c2892f032ce3ac66624 -2008-03-27T22:53:48.747992Z -946 -may - -reginfo.c -file - - - - -2008-04-06T23:15:38.100896Z -6de833b4e4580da11a2165a22feebbf8 -2008-03-27T22:53:48.747992Z -946 -may - -stab.c -file - - - - -2008-04-06T23:15:38.112697Z -3995aee701b283d12ea415f779134b23 -2008-03-27T22:53:48.747992Z -946 -may - -ctors.c -file - - - - -2008-04-06T23:15:38.123903Z -e6e01e796218ca2736e8925089ed7620 -2008-03-27T22:53:48.747992Z -946 -may - -fixup.c -file - - - - -2008-04-06T23:15:38.135613Z -38de3239a4ad35d16c23976bfbef0cc7 -2008-03-27T22:53:48.747992Z -946 -may - -dtors.c -file - - - - -2008-04-06T23:15:38.147129Z -b9a15e90268000d148823a09a1125f96 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libelfsh/.svn/format eresi-0.0.20110516/libelfsh/.svn/format --- eresi-0.8a25/libelfsh/.svn/format 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/alpha64.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/alpha64.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/alpha64.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/alpha64.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,670 +0,0 @@ -/** - * @file alpha64.c - * @ingroup libelfsh -** Alpha64.c for libelfsh -** -** Started on Sat Feb 26 23:25:37 2005 jfv -** -** Skeleton cut & pasted from the sparc64 backend -** -** -** $Id: alpha64.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Static hooking for Alpha64 - * @param sect elfsh section object - * @param name the name of the section - * @param sym the name of symbol - * @param addr the address - * @return - */ -int elfsh_cflow_alpha64(elfshobj_t *sect, - char *name, - elfsh_Sym *sym, - eresi_Addr addr) -{ - // uint32_t cur; - - - // opcodes to hijack - // 0xc3 (br) - // 0xe0 / 0xe1 (blbc) - // 0xe4 / 0xe5 / 0xe6 / 0xe7 (beq) (21bits of offset) - // 0xf4 / 0xf5 / 0xf7 (bne) - // 0x6a / 0x6b (jsr/jmp) - // 0xe8 (blt) - // 0xec / 0xed (ble) - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - - - - - -/** ALTPLT hijacking on ALPHA64 - * On ALPHA we dont have any relative operands while those - * bytes are copied. - - * However since we only have 32 bytes free in the first - * PLT entry, we cannot insert this 12 instrs length code - * updating the first entry of .alt.plt by the first entry - * of .plt at runtime (since this last is only filled at - * runtime). - - * Because alpha does not provide an instruction that only - * load the 2 low bytes part of a register, we use different - * register values depending on the addresses we need to - * read/write. The only predictable register value is %gp - * whoose value is always .got+0x8000 - - * If we dont do this ALTPLT hijack, we cannot call the original - * function from the hook function that was setup in PLT. - * - * @param file elfshobj - * @param symbol elfsh symbol sturcture - * @param addr address - * @return - */ -int elfsh_hijack_altplt_alpha64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - eresi_Addr result, result2; - uint32_t opcode[12]; - uint32_t off; - elfshsect_t *altplt; - elfshsect_t *altpltprolog; - elfshsect_t *plt; - elfshsect_t *got; - uint16_t hi, low, hi2, low2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Regular checks */ - if (!FILE_IS_ALPHA64(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_ALPHA while the elf file is not " - "ALPHA\n", -1); - - got = file->secthash[ELFSH_SECTION_GOT]; - plt = file->secthash[ELFSH_SECTION_PLT]; - altplt = file->secthash[ELFSH_SECTION_ALTPLT]; - altpltprolog = file->secthash[ELFSH_SECTION_ALTPLTPROLOG]; - if (!plt || !altplt || !got || !altpltprolog) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find one of the PLT sections", - -1); - - /* Compute offsets */ - result = plt->shdr->sh_addr - (got->shdr->sh_addr + 0x8000); - off = (uint32_t) result; - hi = (off & 0xFFFF0000) >> 16; - low = (off & 0xFFFF); - result2 = altplt->shdr->sh_addr - (got->shdr->sh_addr + 0x8000); - off = (uint32_t) result2; - hi2 = (off & 0xFFFF0000) >> 16; - low2 = (off & 0xFFFF); - - /* 00 00 3d 24 ldah t0,0(gp) */ - opcode[0] = 0x243d0000 | (uint16_t) hi; - - /* 00 00 3d 20 lda t0,0(t0|gp) */ - opcode[1] = (((short) low > 0) ? 0x20210000 : 0x203D0000) | (uint16_t) low; - - /* 00 00 7d 24 ldah t2,0(gp) */ - opcode[2] = 0x247d0000 | (uint16_t) hi2; - - /* 00 00 7d 20 lda t2,0(t2|gp) */ - opcode[3] = (((short) low2 > 0) ? 0x20630000 : 0x207d0000) | (uint16_t) low2; - - /* 02 14 64 40 addq t2,0x20,t1 */ - opcode[4] = 0x40641402; - - /* 00 00 81 a4 ldq t3,0(t0) */ - opcode[5] = 0xa4810000; - - /* 00 00 83 b4 stq t3,0(t2) */ - opcode[6] = 0xb4830000; - - /* 03 14 61 40 addq t2,0x8,t2 */ - opcode[7] = 0x40611403; - - /* 01 14 21 40 addq t0,0x8,t0 */ - opcode[8] = 0x40211401; - - /* a0 0d 43 40 cmple t1,t2,v0 */ - opcode[9] = 0x40430da0; - - /* fa ff 1f e4 beq v0,120000ac4 */ - opcode[10] = 0xe41ffffa; - - /* 00 00 60 d0 bsr t2,120000ae0 */ - opcode[11] = 0xd0600000; - - elfsh_raw_write(file, altpltprolog->shdr->sh_offset, - opcode, sizeof(uint32_t) * 12); - - - /* Last but not least : redirect .alt.plt + 0 on .alt.plt.prolog */ - off = ((-52) >> 2); - off = (off & (~(0xffffffff << 20))); - opcode[0] = 0xc0900000 | (uint32_t) off; - elfsh_raw_write(file, altplt->shdr->sh_offset, - opcode, sizeof(uint32_t)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * PLT hijacking on ALPHA64 - * @param file elfshobj - * @param symbol elfsh symbol sturcture - * @param addr address - * @return - */ -int elfsh_hijack_plt_alpha64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t opcode[3]; - uint32_t off; - uint16_t hi, low; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_ALPHA && file->hdr->e_machine != EM_ALPHA_EXP) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_ALPHA while the elf file is not " - "ALPHA\n", -1); - - if (addr > symbol->st_value) - { - opcode[2] = 0xc3800000; /* forward br */ - off = ((addr - 4) - symbol->st_value - 8) >> 2; - } - else - { - opcode[2] = 0xc3900000; /* backward br */ - off = ((addr + 4) - symbol->st_value - 8) >> 2; - } - - hi = ((off << 2) & 0xFFFF0000) >> 16; - low = ((off << 2) + 12) & 0xFFFF; - off = (off & (~(0xffffffff << 20))); - - /* Set t12 to the address of the called function */ - opcode[0] = 0x277b0000 | (uint16_t) hi; - opcode[1] = 0x237b0000 | (uint16_t) low; - opcode[2] |= (uint32_t) off; - -#if __DEBUG_REDIR__ - printf("[DEBUG_REDIR] hookaddr = " XFMT " mem2patch = " XFMT - "computed offset = %08X (real = %08X), final opcode = %08X \n", - addr, symbol->st_value, off, (off << 2), opcode); -#endif - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - -#if __BYTE_ORDER == __BIG_ENDIAN - opcode[0] = swap32(opcode[0]); - opcode[1] = swap32(opcode[1]); - opcode[2] = swap32(opcode[2]); - elfsh_raw_write(file, foffset, opcode, sizeof(uint32_t) * 3); -#else - elfsh_raw_write(file, foffset, opcode, sizeof(uint32_t) * 3); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Find the address of modgot entry for this value - * - * @param modgot - * @param addr - * @return - */ -eresi_Addr elfsh_modgot_find(elfshsect_t *modgot, eresi_Addr addr) -{ - unsigned int idx; - eresi_Addr *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cur = elfsh_get_raw(modgot); - for (idx = 0; idx < modgot->shdr->sh_size / sizeof(eresi_Addr); idx++) - { - - //printf("[modgot_find] Compare entries %016lX - %016lX \n", - // cur[idx], addr); - - if (cur[idx] == addr) - { - printf("returned success in modgot_find \n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (modgot->shdr->sh_addr + idx * sizeof(eresi_Addr))); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handle the mod.o.got section - * - * @param infile - * @param modrel - * @return - */ -elfshsect_t *elfsh_modgot_alpha64(elfshsect_t *infile, elfshsect_t *modrel) -{ - elfshsect_t *modgot; - elfshsect_t *sctcur; - elfshsect_t *sect; - elfsh_Rel *relcur; - char *buff; - unsigned int idx; - unsigned int gotidx; - unsigned int size; - unsigned int needed; - char *data; - elfsh_Shdr hdr; - eresi_Addr *got; - elfsh_Sym *sym; - char *name; - char tmpname[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Create or return existing mod.o.got section */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,buff, strlen(modrel->parent->name) + 4 + 1, NULL); - sprintf(buff, "%s.got", modrel->parent->name); - modgot = elfsh_get_section_by_name(infile->parent, buff, 0, 0, 0); - if (modgot) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,buff); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (modgot)); - } - - needed = 0; - modgot = elfsh_create_section(buff); - size = (IS_REL(modrel) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela)); - - /* Allocate mod.o.got from the number of LITERAL relocations */ - for (sctcur = modrel->parent->sectlist; sctcur; sctcur = sctcur->next) - if (sctcur->shdr->sh_type == SHT_REL || sctcur->shdr->sh_type == SHT_RELA) - for (idx = 0; idx < sctcur->shdr->sh_size / size; idx++) - { - relcur = (IS_REL(modrel) ? - (void *) ((elfsh_Rel *) elfsh_get_raw(sctcur) + idx) : - (void *) ((elfsh_Rela *) elfsh_get_raw(sctcur) + idx)); - if (elfsh_get_reltype(relcur) == R_ALPHA_LITERAL) - needed++; - } - - - printf("Size for modgot = %u entries \n", needed); - - /* - ** Inject section. Here we are sure that it was loaded in last - ** for this module and all ET_REL symbols have been injected. - */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, needed * sizeof(eresi_Addr), NULL); - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_WRITE | SHF_ALLOC, - 0, 0, needed * sizeof(eresi_Addr), 0, 0, 0, 0); - - if (elfsh_insert_mapped_section(infile->parent, modgot, hdr, - data, ELFSH_DATA_INJECTION, 0) < 0) - goto bad; - - modgot = elfsh_get_section_by_name(infile->parent, buff, NULL, NULL, NULL); - if (modgot == NULL) - goto bad; - - got = elfsh_get_raw(modgot); - - /* - ** Fill the mod.o.got with pointers to the real data - ** A Real pain .. need to be modularized with the elfsh_relocate_etrel_section() code - ** -may - */ - gotidx = 0; - for (sctcur = modrel->parent->sectlist; sctcur; sctcur = sctcur->next) - if (sctcur->shdr->sh_type == SHT_REL || sctcur->shdr->sh_type == SHT_RELA) - for (idx = 0; idx < sctcur->shdr->sh_size / size; idx++) - { - relcur = (IS_REL(modrel) ? - (void *) ((elfsh_Rel *) elfsh_get_raw(sctcur) + idx) : - (void *) ((elfsh_Rela *) elfsh_get_raw(sctcur) + idx)); - - /* Now there are many possible computations for the address */ - if (elfsh_get_reltype(relcur) == R_ALPHA_LITERAL) - { - - sym = elfsh_get_symbol_from_reloc(sctcur->parent, relcur); - name = elfsh_get_symname_from_reloc(sctcur->parent, relcur); - if (!sym || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Symbol or Name not found for LITERAL", - NULL); - - if (elfsh_get_symbol_bind(sym) != STB_LOCAL && /* patch BeoS */ - (elfsh_get_symbol_type(sym) == STT_NOTYPE || - elfsh_get_symbol_link(sym) == SHN_COMMON)) - { - - sym = elfsh_get_metasym_by_name(infile->parent, name); - if (sym == NULL) - { - printf("missing sym = %s \n", name); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - " Cant find requested symbol in ET_EXEC\n", NULL); - } - got[gotidx] = sym->st_value; - } - - else - { - - /* Find target section in ET_REL */ - sect = elfsh_get_section_by_index(sctcur->parent, sym->st_shndx, - NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find extracted section in ET_REL\n", NULL); - - /* Find corresponding inserted section in ET_EXEC */ - snprintf(tmpname, sizeof(tmpname), "%s%s", sctcur->parent->name, sect->name); - sect = elfsh_get_section_by_name(infile->parent, tmpname, 0, 0, 0); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find inserted section in ET_EXEC\n", NULL); - - /* Compute pointer value */ - got[gotidx] = sect->shdr->sh_addr + sym->st_value; - - } - - printf("MODGOT : found a literal and filling modgot with " XFMT "\n", - got[gotidx]); - gotidx++; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (modgot)); - bad: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Bad return for modgot", NULL); -} - - - - -/** - * Perform relocation on entry for ALPHA64 architecture. - * Only the types that are needed for relocating ET_REL objects - * are filled, others might come on the need. - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_alpha64(elfshsect_t *new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - elfshsect_t *modgot; - eresi_Addr result; - int retval; - uint32_t *dw; - uint32_t off; - uint16_t hi, low; - eresi_Addr val; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - printf("relocata_alpha64 Input addr = " XFMT "\n", addr); - - -#define ADD (cur->r_addend) -#define BAS (elfsh_get_object_baseaddr(new->parent)) -#define PLA (new->shdr->sh_addr + cur->r_offset) -#define SYM (addr) -#define SETSYM(a) (addr = a, printf("SETSYM addr set to " XFMT "\n", a)) -#define GP (elfsh_get_sht_entry_by_name(new->parent, ".got")->sh_addr+0x8000) - -#define VERIFY8(x) (((x) & (0xFFFFFFFF << 8)) ? 1 : 0) -#define VERIFY13(x) (((x) & (0xFFFFFFFF << 13)) ? 1 : 0) -#define VERIFY16(x) (((x) & (0xFFFFFFFF << 16)) ? 1 : 0) -#define VERIFY22(x) (((x) & (0xFFFFFFFF << 22)) ? 1 : 0) -#define VERIFY30(x) (((x) & (0xFFFFFFFF << 30)) ? 1 : 0) -#define VERIFY32(x) (((x) & (0xFFFFFFFF << 0)) ? 1 : 0) - -#define TRUNCATE8(x) ((x) & ~(0xFFFFFFFF << 8)) -#define TRUNCATE13(x) ((x) & ~(0xFFFFFFFF << 13)) -#define TRUNCATE16(x) ((x) & ~(0xFFFFFFFF << 16)) -#define TRUNCATE22(x) ((x) & ~(0xFFFFFFFF << 22)) -#define TRUNCATE30(x) ((x) & ~(0xFFFFFFFF << 30)) -#define TRUNCATE32(x) (x) /* XXX just assume its 32bit */ - -#define TRUNCATE16HI(x) ((x) & ~(0xFFFFFFFF >> 16)) - - /* We compute a 32bit dword offset for using with <= 32bit relocations */ - dw = (uint32_t *) dword; - retval = result = 0; - - switch (elfsh_get_reltype((elfsh_Rel *) cur)) - { - /* cases ... */ - case R_ALPHA_NONE: - printf ("R_ALPHA_NONE\n"); - break; - case R_ALPHA_REFLONG: - printf ("R_ALPHA_REFLONG\n"); - result = TRUNCATE32(addr); - break; - case R_ALPHA_REFQUAD: - printf ("R_ALPHA_REFQUAD\n"); - result = addr; - break; - case R_ALPHA_GPREL32: - printf ("R_ALPHA_GPREL32\n"); - // XXX - break; - - - /* - On alpha, each static object in the relocatable file that have - an address filled by R_ALPHA_LITERAL has an entry in .got - which is filled at compil time and loaded in a register - at runtime using this relocation. The .got entry is supposed - to contains the absolute address of the object. This is alpha - specific and we have to reconstruct this behavior for the injected - module with a new section : mod.o.got - -mm - */ - case R_ALPHA_LITERAL: - - printf ("R_ALPHA_LITERAL : GP displacement for symbol \n"); - - modgot = elfsh_modgot_alpha64(new, mod); - if (modgot == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,"modgot failed", -1); - val = elfsh_modgot_find(modgot, addr); - SETSYM(val); - - //elfsh_print_sectlist(new->parent, "MODGOT"); - - if (SYM > GP) - { - result = SYM - GP; - low = (uint16_t) result; - } - else - { - result = GP - SYM; - low = (uint16_t) result; - low = -low; - } - - printf ("SYM : " XFMT " \n", SYM); - printf ("GP : " XFMT " \n" , GP); - printf ("low : %hd \n", low); - - // seems to be badly encoded - *dw += low; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - case R_ALPHA_LITUSE: - printf ("R_ALPHA_LITUSE\n"); - // XXX - break; - - case R_ALPHA_GPDISP: - printf ("R_ALPHA_GPDISP : GP displacement for current addr \n"); - - if (PLA < (GP)) - result = (GP) - PLA; - else - result = PLA - (GP); - - // The particular case of elfsh makes the high offset always 0 - // since the .got stay the same on function hijack and the injected - // code is always mapped after the .got in a 16bits shift interval - off = (uint32_t) result; - hi = 0; - low = TRUNCATE16(off); - - if (PLA > (GP)) - low = -low; - - if (off > 0xFFFF) - printf("[debug_alpha_reloc] warning : difference does not make in 16bits %08X \n", off); - else - { - printf("[debug_alpha_reloc] offset = %08X low = %04X high = %04X \n", off, low, hi); - } - - *(dw + (ADD / 4)) += low; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - - case R_ALPHA_BRADDR: - printf ("R_ALPHA_BRADDR\n"); - // XXX - break; - case R_ALPHA_HINT: - printf ("R_ALPHA_HINT\n"); - // XXX - - break; - case R_ALPHA_SREL16: - printf ("R_ALPHA_SREL16\n"); - // XXX - break; - case R_ALPHA_SREL32: - printf ("R_ALPHA_SREL32\n"); - // XXX - break; - case R_ALPHA_SREL64: - printf ("R_ALPHA_SREL64\n"); - // XXX - break; - case R_ALPHA_OP_PUSH: - printf ("R_ALPHA_OP_PUSH\n"); - // XXX - break; - case R_ALPHA_OP_STORE: - printf ("R_ALPHA_OP_STORE\n"); - // XXX - break; - case R_ALPHA_OP_PSUB: - printf ("R_ALPHA_OP_PSUB\n"); - // XXX - break; - case R_ALPHA_OP_PRSHIFT: - printf ("R_ALPHA_PRSHIFT\n"); - // XXX - break; - case R_ALPHA_GPVALUE: - printf ("R_ALPHA_GPVALUE\n"); - // XXX - break; - case R_ALPHA_GPRELHIGH: - printf ("R_ALPHA_GPRELHIGH\n"); - // XXX - break; - case R_ALPHA_GPRELLOW: - printf ("R_ALPHA_GPRELLOW\n"); - // XXX - break; - case R_ALPHA_IMMED_GP_16: - printf ("R_ALPHA_IMMED_GP_16\n"); - // XXX - break; - case R_ALPHA_IMMED_GP_HI32: - printf ("R_ALPHA_IMMED_GP_HI32\n"); - // XXX - break; - case R_ALPHA_IMMED_SCN_HI32: - printf ("R_ALPHA_IMMED_SCN_HI32\n"); - // XXX - break; - case R_ALPHA_IMMED_BR_HI32: - printf ("R_ALPHA_IMMED_BR_HI32\n"); - // XXX - break; - case R_ALPHA_IMMED_LO32: - printf ("R_ALPHA_IMMED_LO32\n"); - // XXX - break; - case R_ALPHA_COPY: - printf ("R_ALPHA_COPY\n"); - // XXX - break; - case R_ALPHA_GLOB_DAT: - printf ("R_ALPHA_GLOB_DAT\n"); - // XXX - break; - case R_ALPHA_JMP_SLOT: - printf ("R_ALPHA_JMP_SLOT\n"); - // XXX - break; - case R_ALPHA_RELATIVE: - printf ("R_ALPHA_RELATIVE\n"); - // XXX - break; - - default: -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unsupported relocation type", - -1); - break; - } - - *dword += result; - -#undef ADD -#undef BAS -#undef PLA -#undef SYM -#undef SETSYM -#undef GP - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/altgot.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/altgot.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/altgot.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/altgot.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,284 +0,0 @@ -/** - * @file altgot.c - * @ingroup libelfsh -** altgot.c for libelfsh -** -** This file contain the architecture -dependant- code -** of the ALTGOT technique. -** -** Started on Wed Jun 08 21:20:07 2005 mm -** -** -** $Id: altgot.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Shift the relocation HI16 and L16 for mips binaries - * We have to do that using a signature since no relocation - * tables are available in ET_EXEC files on mips. - * - * 3c1c0000 lui gp,0x0 - * 279c0000 addiu gp,gp,0 - * - * diff contains the difference to add to the offset for obtaining - * .alt.got address that we need to add to the HI16 relocations - * matching the signature. - * - * @param file - * @param diff - * @return - */ -void elfsh_shift_mips_relocs(elfshobj_t *file, eresi_Addr diff) -{ - uint32_t *dword; - uint32_t *dword2; - elfshsect_t *current; - uint32_t dw, dw2; - char patch; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First re-relocate some entries */ - for (current = file->sectlist; current; current = current->next) - for (dword = (uint32_t *) current->data, dword2 = dword + 1; - ((char *) dword + 8) <= ((char *) current->data + current->shdr->sh_size); - dword++, dword2++) - { - dw = *dword & 0xFFFF0000; - dw2 = *dword2 & 0xFFFF0000; - if (dw == 0x3c1c0000 && dw2 == 0x279c0000) - { - - patch = ((!strcmp(current->name, ELFSH_SECTION_NAME_TEXT) && - ((char*) dword - (char *) current->data) > 0x100) ? 0 : 1); - str = (patch ? "patching" : "not patching"); - printf("[DEBUG_SHIFTMIPS] Found dw/dw2 at address " XFMT " / " XFMT " (%s) -> %s \n", - (eresi_Addr) current->shdr->sh_addr + ((char*) dword - (char *) current->data), - (eresi_Addr) current->shdr->sh_addr + ((char*) dword2 - (char *) current->data), - current->name, str); - - if (patch) - *dword2 += ((uint32_t) diff); - - } - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Shift the ALPHA relocations - * - * @param file - * @param name - * @param altgot - * @param off - * @return - */ -int elfsh_shift_alpha_relocs(elfshobj_t *file, - char *name, - elfshsect_t *altgot, - u_int off) -{ - u_int entsz; - elfsh_Rela *rel; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Find the relocation entry */ - entsz = elfsh_get_pltentsz(file); - rel = (elfsh_Rela *) elfsh_get_relent_by_name(file, name); - if (rel == NULL) - { -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Did not find relocation entry from symbol %s \n", name); -#endif - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__,"Unable to get relocation entry", -1); - } - -#if __DEBUG_COPYPLT__ - else - printf("[DEBUG_COPYPLT] Found relocation entry (" AFMT ") from symbol %s \n", - elfsh_get_reloffset((elfsh_Rel *) rel), name); -#endif - - /* Compute the new value */ - addr = altgot->shdr->sh_addr + (((off - 8) / entsz) * sizeof(eresi_Addr)); - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Setting relocation entry to " AFMT " \n", addr); -#endif - - /* Write it */ - elfsh_set_reloffset((elfsh_Rel *) rel, addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Shift the SPARC relocation to make points the entries inside .alt.plt instead of .plt - * - * @param file - * @param diff - * @param relplt - * @return - */ -int elfsh_shift_generic_relocs(elfshobj_t *file, - eresi_Addr diff, - elfshsect_t *relplt) -{ - elfsh_Rela *l; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < relplt->shdr->sh_size / sizeof(elfsh_Rela); index++) - { - l = (elfsh_Rela *) relplt->data + index; - elfsh_set_reloffset((elfsh_Rel *) l, elfsh_get_reloffset((elfsh_Rel *) l) + diff); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Shift relocation tables at some point for allowing non-present symbol resolving - * mostly applied on section injection for ET_DYN objects - * - * @param file - * @param diff - * @param relplt - * @param limit - * @return - */ -int elfsh_shift_ia32_relocs(elfshobj_t *file, - eresi_Addr diff, - elfshsect_t *relplt, - eresi_Addr limit) -{ - elfsh_Rel *l; - int index; - eresi_Addr reloff; - elfshsect_t *parent; - elfsh_SAddr off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (index = 0; index < relplt->shdr->sh_size / sizeof(elfsh_Rel); index++) - { - l = (elfsh_Rel *) relplt->data + index; - if (ELFSH_NOLIMIT == limit || elfsh_get_reloffset((elfsh_Rel *) l) >= limit) - { - reloff = elfsh_get_reloffset((elfsh_Rel *) l); - reloff += diff; - elfsh_set_reloffset((elfsh_Rel *) l, reloff); - - /* Shifting memory -pointed- by the relative relocation */ - if (elfsh_get_reltype(l) != R_386_RELATIVE) - continue; - parent = elfsh_get_parent_section(file, reloff, &off); - if (strstr(parent->name, "got") || strstr(parent->name, "bss") || - strstr(parent->name, "elfsh")) - continue; - *(eresi_Addr *) ((char *) parent->data + off) += diff; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Same arch independant code for the SPARC case - * - * @param file - * @param diff - * @param relplt - * @return - */ -int elfsh_shift_sparc_relocs(elfshobj_t *file, - eresi_Addr diff, - elfshsect_t *relplt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_shift_generic_relocs(file, diff, relplt))); -} - - - - -/** - * Change the DT_PLTGOT entry in the .dynamic - * section to change the relocation base address - * - * @param file - * @param altgot - * @param got - * @param plt - * @param altplt - * @return - */ -int elfsh_redirect_pltgot(elfshobj_t *file, - elfshsect_t *altgot, - elfshsect_t *got, - elfshsect_t *plt, - elfshsect_t *altplt) -{ - elfsh_Sym *sym; - elfsh_Dyn *dyn; - elfshsect_t *relplt; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get the DT_PLTGOT entry in .dynamic */ - dyn = elfsh_get_dynamic_entry_by_type(file, DT_PLTGOT); - if (!dyn) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find DT_PLTGOT", -1); - - /* Get the PLT related relocation table */ - name = IS_REL(plt) ? ELFSH_SECTION_NAME_RELPLT : ELFSH_SECTION_NAME_RELAPLT; - relplt = elfsh_get_section_by_name(plt->parent, name, 0, 0, 0); - if (!relplt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find RELPLT section by name", -1); - - /* On MIPS we change it from .got to .alt.got : ALTGOT technique */ - if (FILE_IS_MIPS(file) || FILE_IS_IA32(file)) - { - elfsh_set_dynentry_val(dyn, altgot->shdr->sh_addr); - - if (FILE_IS_MIPS(file)) - { - elfsh_set_gpvalue(file, altgot->shdr->sh_addr + 0x8000 - 0x10); - sym = elfsh_get_dynsymbol_by_name(file, "_gp_disp"); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Could not find _gp_disp ", -1); - sym->st_value = altgot->shdr->sh_addr + 0x8000 - 0x10; - elfsh_shift_mips_relocs(file, altgot->shdr->sh_addr - got->shdr->sh_addr); - } - else - elfsh_shift_ia32_relocs(file, - altgot->shdr->sh_addr - got->shdr->sh_addr, relplt, - ELFSH_NOLIMIT); - } - - /* On SPARC we change it from .plt to .alt.plt : ALTPLT technique */ - else if (FILE_IS_SPARC(file)) - { - elfsh_set_dynentry_val(dyn, altplt->shdr->sh_addr); - elfsh_shift_sparc_relocs(file, altplt->shdr->sh_addr - plt->shdr->sh_addr, relplt); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/altplt.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/altplt.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/altplt.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/altplt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,562 +0,0 @@ -/** - * @file altplt.c - * @ingroup libelfsh -** altplt.c for libelfsh -** -** This file contain the architecture independant code -** for ALTPLT technique -** -** Started on Tue May 26 11:40:07 2001 mm -** -** -** $Id: altplt.c,v 1.12 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * The first PLT entry is always a special case and it is handled by this - * function - * - * @param new - * @param off - * @param symtab - * @param file - * @param extplt - * @param plt - * @param diff - * @return - */ -int elfsh_altplt_firstent(elfshsect_t *enew, - u_int *off, - elfshsect_t *symtab, - elfshobj_t *file, - elfshsect_t *extplt, - elfshsect_t *plt, - uint32_t diff) -{ - u_int entsz; - elfsh_Sym newsym; - elfsh_Sym *sym; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Insert plt+0 symbol */ - entsz = elfsh_get_pltentsz(file); - newsym = elfsh_create_symbol(enew->shdr->sh_addr, entsz, STT_FUNC, 0, 0, 0); - if (elfsh_insert_symbol(symtab, &newsym, "old_dlresolve") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert old_dlresolve symbol", -1); - - *off = *off - entsz + elfsh_get_first_pltentsz(file); - - /* On MIPS we have to callback __libc_start_main and not .plt+0 */ - if (FILE_IS_MIPS(plt->parent)) - { - sym = elfsh_get_dynsymbol_by_name(file, "__libc_start_main"); - if (!sym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find __libc_start_main", -1); - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Found __libc_start_main MIPS at addr " - XFMT "\n", sym->st_value); -#endif - - addr = sym->st_value; - } - else - addr = plt->shdr->sh_addr; - - /* Call the libelfsh hook ALTPLT */ - if (elfsh_altplt(file, &newsym, addr) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT failed", -1); - - /* On IA32, reencode the PLT and EXTPLT entries to use the ALTGOT */ - /* The hook does nothing on other archs for now */ - if (FILE_IS_IA32(file)) - if (elfsh_encodeplt1(file, plt, extplt, diff) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Reencoding of (EXT)PLT+0 failed", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - - -/** - * Copy the PLT of an ET_EXEC object for the ALTPLT technique. - * Copy the GOT of an ET_EXEC object for the ALTGOT technique. - * - * @param file - * @param mod - * @return - */ -int elfsh_relink_plt(elfshobj_t *file, u_int mod) -{ - elfshsect_t *got; - elfshsect_t *plt; - elfshsect_t *symtab; - elfshsect_t *dynsym; - elfshsect_t *prolog; - elfshsect_t *extplt = NULL; - elfshsect_t *altgot = NULL; /* shut the nice talkative */ - elfshsect_t *enew = NULL; /* compiler also know as gcc */ - elfsh_Shdr hdr; - elfsh_Sym *sym; - elfsh_Sym newsym; - char buf[BUFSIZ]; - u_int off; - u_int entsz; - int mode; - eresi_Addr addr; - char *prologdata; - u_int sz; - char *name; - u_char ostype; - eresi_Addr diff; - u_int extplt_size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get PLT */ - if (file->secthash[ELFSH_SECTION_ALTPLT] != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - plt = elfsh_get_plt(file, NULL); - if (NULL == plt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT section not found", -1); - entsz = elfsh_get_pltentsz(file); - if (entsz < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get PLT entry size", -1); - - /* Get GOT (recent ld call it .got.plt) */ - got = elfsh_get_gotsct(file); - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GOT section not found", -1); - - /* Get symtabs */ - if (NULL == elfsh_get_dynsymtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DYNSYM not found", -1); - if (NULL == elfsh_get_symtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SYMTAB not found", -1); - - /* Some fingerprint */ - ostype = elfsh_get_ostype(file); - if (ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid OS target", -1); - - /* Insert alternative .plt */ - dynsym = file->secthash[ELFSH_SECTION_DYNSYM]; - symtab = file->secthash[ELFSH_SECTION_SYMTAB]; - - /* FreeBSD and BeoS is incompatible with pre-interp injection */ - /* Solaris needs self-mutating code for ALTPLT technique */ - /* %gp offsets on ALPHA/MIPS requires data injection */ - ELFSH_SELECT_INJECTION(file,NULL,mode); - - /* Map .alt.plt.prolog on ALPHA, or .alt.got.prolog on MIPS */ - if (FILE_IS_MIPS(file) || FILE_IS_ALPHA64(file)) - { - if (FILE_IS_MIPS(file)) - { - name = ELFSH_SECTION_NAME_ALTGOTPROLOG; - sz = 28; - } - else - { - name = ELFSH_SECTION_NAME_ALTPLTPROLOG; - sz = 48; - } - prolog = elfsh_create_section(name); - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - 0, 0, sz, 0, 0, 0, 0); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - - if (elfsh_insert_mapped_section(file, - prolog, hdr, prologdata, - mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.{plt,got}.prolog insertion failed", -1); - - enew = elfsh_get_section_by_name(file, name, NULL, NULL, NULL); - if (enew == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.{plt,got}.prolog insertion failed", -1); - file->secthash[ELFSH_SECTION_ALTPLTPROLOG] = enew; - } - - /* Map .alt.plt (or .pad.got on MIPS) - - On MIPS we use .pad.got in order to align .alt.got on a 0x1000 - bound boundary. - - On ALPHA and SPARC, .alt.plt will be relocated instead of .plt - */ - sz = plt->shdr->sh_size; - if (FILE_IS_MIPS(file)) - { - addr = enew->shdr->sh_addr + enew->shdr->sh_size; - if ((addr - (got->shdr->sh_addr)) % 1024) - sz = 1024 - ((addr - (got->shdr->sh_addr)) % 1024); - XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - memset(prologdata, 0x00, sz); - name = ELFSH_SECTION_NAME_PADGOT; - } - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - memcpy(prologdata, elfsh_get_raw(plt), sz); - name = ELFSH_SECTION_NAME_ALTPLT; - } - enew = elfsh_create_section(name); - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - 0, 0, sz, 0, 0, 0, 0); - if (elfsh_insert_mapped_section(file, enew, hdr, prologdata, mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.plt|.pad.got insertion failed", -1); - enew = elfsh_get_section_by_name(file, name, NULL, NULL, NULL); - if (enew == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.plt|.pad.got insertion failed", -1); - file->secthash[ELFSH_SECTION_ALTPLT] = enew; - - - /* Map .alt.got (all architectures except SPARC) */ - /* On IA32, remap GOT with a doubled size for non-present symbol resolving */ - if (FILE_IS_MIPS(file) || FILE_IS_ALPHA64(file) || FILE_IS_IA32(file)) - { - sz = (FILE_IS_MIPS(file) ? got->shdr->sh_size : - FILE_IS_IA32(file) ? got->shdr->sh_size * 4 : - plt->shdr->sh_size / elfsh_get_pltentsz(file) * sizeof(eresi_Addr)); - - altgot = elfsh_create_section(ELFSH_SECTION_NAME_ALTGOT); - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_ALLOC | SHF_WRITE, - 0, 0, sz, 0, 0, 0, sizeof(eresi_Addr)); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, sz, -1); - memcpy(prologdata, elfsh_get_raw(got), got->shdr->sh_size); - - if (elfsh_insert_mapped_section(file, altgot, hdr, prologdata, - ELFSH_DATA_INJECTION, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.got insertion failed", -1); - - altgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_ALTGOT, - NULL, NULL, NULL); - if (altgot == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".alt.got insertion failed", -1); - file->secthash[ELFSH_SECTION_ALTGOT] = altgot; - altgot->curend = got->shdr->sh_size; - memset(elfsh_get_raw(altgot) + got->shdr->sh_size, 0x00, got->shdr->sh_size); - altgot->shdr->sh_entsize = sizeof(eresi_Addr); - } - - - /* Insert EXTPLT in order to be able to resolve non present symbols */ - if (FILE_IS_IA32(file)) - { - extplt_size = plt->shdr->sh_size * 2; - extplt = elfsh_create_section(ELFSH_SECTION_NAME_EXTPLT); - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR, - 0, 0, extplt_size, 0, 0, 0, 0); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, prologdata, plt->shdr->sh_size, -1); - memcpy(prologdata, elfsh_get_raw(plt), plt->shdr->sh_size); - - if (elfsh_insert_mapped_section(file, extplt, hdr, prologdata, - mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".ext.plt insertion failed", -1); - extplt = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_EXTPLT, - NULL, NULL, NULL); - if (extplt == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".ext.plt insertion failed", -1); - file->secthash[ELFSH_SECTION_EXTPLT] = extplt; - extplt->curend = elfsh_get_first_pltentsz(file); - } - - - - /* Loop on .plt and inject 'old_symnam' symbols */ - for (off = 0; off < plt->shdr->sh_size; off += entsz) - { - - /* SPARC does not have ALTGOT */ - if (FILE_IS_MIPS(file) || FILE_IS_ALPHA64(file) || FILE_IS_IA32(file)) - diff = (uint32_t) altgot->shdr->sh_addr - got->shdr->sh_addr; - else - diff = 0; - - /* Special case for the first plt entry */ - if (off == 0 && elfsh_altplt_firstent(enew, &off, symtab, file, extplt, plt, diff) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT on first entry failed", -1); - else if (off == 0) - continue; - - /* Get the existing symbol name for this plt entry ... */ - sym = elfsh_get_sym_by_value(elfsh_get_raw(dynsym), - dynsym->shdr->sh_size / sizeof(elfsh_Sym), - plt->shdr->sh_addr + off, - NULL, ELFSH_EXACTSYM); - - /* New versions of ld do not fill the vaddr of dynamic symbols, - do it ourself. Do not insert old symbol in emergency cases */ - if (sym == NULL) - { - if ((sym = elfsh_restore_dynsym(file, plt, off, dynsym)) == NULL) - continue; - - name = elfsh_get_dynsymbol_name(file, sym); - - /* __gmon_start__ should not be resolved - if it was not already done by gcc */ - if (name && !strcmp(name, "__gmon_start__")) - sym->st_value = 0x0; - } - - /* ... and we inject the 'old' occurence symbol pointing in - .alt.plt (.plt on MIPS) */ - if (!FILE_IS_MIPS(file)) - addr = enew->shdr->sh_addr + off; - else - addr = plt->shdr->sh_addr + off; - -#if __BYTE_ORDER == __BIG_ENDIAN - if (file->hdr->e_ident[EI_DATA] == ELFDATA2LSB) -#elif __BYTE_ORDER == __LITTLE_ENDIAN - if (file->hdr->e_ident[EI_DATA] == ELFDATA2MSB) -#else -#error Unexpected __BYTE_ORDER ! -#endif - addr = swaplong(addr); - - /* Injection */ - name = elfsh_get_dynsymbol_name(file, sym); - newsym = elfsh_create_symbol(addr, entsz, STT_FUNC, 0, 0, 0); - snprintf(buf, BUFSIZ, "old_%s", name); - if (elfsh_insert_symbol(symtab, &newsym, buf) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "old_* symbol injection failed", -1); - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Symbol at .plt + %u injected" - " succesfully (%s) \n", off, buf); -#endif - - /* On ALPHA, shift the relocation offset from .got to .alt.got to avoid - hooks removing when calling back the original function. */ - if (FILE_IS_ALPHA64(file) && - elfsh_shift_alpha_relocs(file, name, altgot, off) < 0) - continue; - - /* Reencode the PLT entry to use the alternative GOT */ - /* This condition is for compatibility with other archs where EXTPLT - is not yet supported. For those we do not enter the hook */ - if (FILE_IS_IA32(file)) - { - diff = (eresi_Addr) altgot->shdr->sh_addr - got->shdr->sh_addr; - elfsh_encodeplt(file, plt, diff, off); - if (file->hdr->e_type == ET_DYN) - elfsh_encodeplt(file, file->secthash[ELFSH_SECTION_ALTPLT], - diff, off); - diff = (eresi_Addr) altgot->shdr->sh_addr - got->shdr->sh_addr + - got->shdr->sh_size; - elfsh_encodeplt(file, extplt, diff, off); - } - } - - /* Activate ALTGOT */ - if (elfsh_redirect_pltgot(file, altgot, got, plt, enew) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLTGOT redirection failed", -1); - - /* Activate EXTPLT */ - if (elfsh_extplt_mirror_sections(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section mirroring failed", -1); - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Section Mirrored Successfully ! \n"); -#endif - - - /* Everything is 0k4y */ - if (elfsh_sync_sorted_symtab(symtab) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "symtab synchronisation failed", -1); - if (elfsh_sync_sorted_symtab(dynsym) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "dynsym synchronisation failed", -1); - elfsh_sync_sectnames(file); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * On MIPS there is no .plt section : call to libraries are done - * using an indirect jump on .got value directly from .text. If - * we want to be able to call the original function from the hook - * function, we need to create a plt-like section and mirror the - * Global Offset Table (.got). - * - * By default, .got points in some code stub standing in .text. This - * code stubs looks much like a PLT. Indeed, there is a kind of PLT - * on MIPS but it is embedded in the .text section. What we do in this - * function is to disambiguize .plt and .text, so that we can apply - * ALTPLT technique as well on MIPS. - * - * Unlike on ALPHA, we cannot move relocations from .got to .alt.got - * since MIPS binaries have no relocation tables in ET_EXEC objects. - * What we do instead is changing the processor specific DT_PLTGOT - * entry in the .dynamic section and continue to rely on the ALTPLT - * technique (call's the original functions using the injected 'old_' - * symbol) just like ALTPLT redirection on other architectures. -mm - * - * @param file - * @return - */ -int elfsh_build_plt(elfshobj_t *file) -{ - elfshsect_t *text; - elfsh_SAddr off; - char buff[16] = {0x00}; - eresi_Addr pltaddr = 0; - eresi_Addr pltend = 0; - elfsh_Shdr start; - elfsh_Shdr plt; - elfshsect_t *enew; - eresi_Addr lsize; - unsigned int size; - char *data; - char *tdata; - unsigned int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First checks */ - text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &off); - if (!text) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section from entry point", -1); - if (!elfsh_get_anonymous_section(file, text)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get an anonymous section", -1); - - - /* - ** Find the embedded plt by searching the nop;nop;nop;nop; signature - ** that delimit the beginning and the end of plt. This is MIPS specific - ** since only MIPS needs this. - */ - tdata = elfsh_get_raw(text); - for (off = 0; off < text->shdr->sh_size; off += 4) - if (!memcmp(tdata + off, buff, sizeof(buff))) - { - pltaddr = text->shdr->sh_addr + off + 16; - for (off += 16; off < text->shdr->sh_size; off += 4) - if (!memcmp(tdata + off, buff, 16)) - { - pltend = text->shdr->sh_addr + off + 16; - goto found; - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find PLT end", -1); - } - - found: - idx = text->index; - if (!pltaddr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find PLT start", -1); - - /* - ** Now create additional section header table entries so that we reduce the - ** MIPS model to our standard ALTPLT/ALTGOT model. - ** - ** Do not use the elfsh_insert_*_section() since we want no address space - ** shifting. - */ - - /* .start */ - lsize = pltaddr - text->shdr->sh_addr; - size = (unsigned int) lsize; - start = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - text->shdr->sh_addr, text->shdr->sh_offset, - size, 0, 0, 0, 0); - enew = elfsh_create_section(ELFSH_SECTION_NAME_START); - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, size, -1); - memcpy(data, tdata, size); - elfsh_insert_shdr(file, start, idx, enew->name, 0); - elfsh_add_section(file, enew, idx, data, ELFSH_SHIFTING_MIPSPLT); - file->secthash[ELFSH_SECTION_MIPSTART] = enew; - - /* .plt */ - lsize = pltend - pltaddr; - size = (unsigned int) lsize; - plt = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - start.sh_addr + start.sh_size, - start.sh_offset + start.sh_size, - size, 0, 0, 0, 0); - enew = elfsh_create_section(ELFSH_SECTION_NAME_PLT); - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, size, -1); - memcpy(data, tdata + start.sh_size, size); - elfsh_insert_shdr(file, plt, idx + 1, enew->name, 0); - elfsh_add_section(file, enew, idx + 1, data, ELFSH_SHIFTING_MIPSPLT); - - /* Shift .text data, sh_offset, sh_addr, and sh_size correctly */ - text->shdr->sh_offset += (start.sh_size + plt.sh_size); - text->shdr->sh_addr += (start.sh_size + plt.sh_size); - memmove(tdata, - tdata + start.sh_size + plt.sh_size, - text->shdr->sh_size - (start.sh_size + plt.sh_size)); - text->shdr->sh_size -= (start.sh_size + plt.sh_size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * This is the main entry point for the ALTPLT, ALTGOT, and EXTPLT techniques - * - * @param file - * @param modulo - * @return - */ -int elfsh_copy_plt(elfshobj_t *file, u_int modulo) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Some sanity checks */ - if (elfsh_static_file(file)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (FILE_IS_MIPS(file) && - elfsh_dynamic_file(file) && - (elfsh_build_plt(file) < 0)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to build MIPS plt", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - elfsh_relink_plt(file, modulo)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/bp.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/bp.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/bp.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/bp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/** - * @file bp.c - * @ingroup libelfsh -** bp.c for elfsh -** -** Started Fri Jul 29 15:41:20 2005 ym -** Updated Tue Oct 11 19:07:13 2005 mm -** -** -** $Id: bp.c,v 1.7 2007-06-27 11:25:12 heroine Exp $ -** -*/ -#include "libelfsh.h" - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/bss.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/bss.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/bss.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/bss.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,508 +0,0 @@ -/** - * @file bss.c - * @ingroup libelfsh -** bss.c for elfsh -** -** Contain various bss handling routines for injection -** -** This file contains FILE MODIFICATION only (no debugger) -** -** Started on Sun Apr 6 08:35:07 2003 jfv -** Last update Sat Jul 30 17:34:52 2005 jfv -** -** -** $Id: bss.c,v 1.16 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Clean the BSS (remove all its data from the file and fixup PHT) - * @param file - * @return - */ -int elfsh_flush_bss(elfshobj_t *file) -{ - elfshsect_t *bss; - elfshsect_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - bss = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_BSS, - NULL, NULL, NULL); - if (!bss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find BSS", NULL); - - if (bss->phdr->p_filesz != bss->phdr->p_memsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (bss->next && bss->next->shdr->sh_addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not latest mapped, cannot flush", -1); - - /* Fixup PHT */ - bss->phdr->p_filesz -= bss->shdr->sh_size; - file->hdr->e_shoff -= bss->shdr->sh_size; - for (next = bss->next; next != NULL; next = next->next) - next->shdr->sh_offset -= bss->shdr->sh_size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Set memsz and filesz as seemingfull vanilla values by inadvertancy - * Multiple BSS safe - * @param file - * @param pht - * @return - */ -int elfsh_cleanup_bss(elfshobj_t *file, elfsh_Phdr *pht) -{ - elfshsect_t *bss; - u_int range = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - bss = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_BSS, NULL, NULL, NULL); - if (!bss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find BSS", -1); - - for (range = 0; range < file->hdr->e_phnum; range++) - if (elfsh_get_segment_type(pht + range) == PT_LOAD && - elfsh_segment_is_writable(pht + range)) - { - pht[range].p_memsz += bss->shdr->sh_size; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find data PT_LOAD", -1); -} - - - -/** - * Put the bss physically in the file - * @param file - * @return - */ -elfshsect_t *elfsh_fixup_bss(elfshobj_t *file) -{ - static elfshobj_t *obj = NULL; - static elfshsect_t *last = NULL; - elfshsect_t *bss = NULL; - u_int idx = 0; - char fixflag; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - - /* We add a static variable for making the code reentrant, how fancy */ - if (file == obj && last != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (last)); - - fixflag = 0; - for (bss = file->sectlist; idx < file->hdr->e_shnum; idx++, bss = bss->next) - if (elfsh_get_section_type(bss->shdr) == SHT_NOBITS) - { - if (bss->shdr->sh_size == 0) - { -#if __DEBUG_BSS__ - printf("[DEBUG_BSS] A zero sized bss has been found\n"); -#endif - if (bss->next && bss->next->shdr->sh_addr != bss->shdr->sh_addr) - { - bss->shdr->sh_size = bss->next->shdr->sh_addr - bss->shdr->sh_addr; - fixflag = 1; -#if __DEBUG_BSS__ - printf("[DEBUG_BSS] Fixing with size = %u \n", bss->shdr->sh_size); -#endif - } - else - { -#if __DEBUG_BSS__ - puts("[DEBUG_BSS] Not fixing, continue"); -#endif - continue; - } - } -#if __DEBUG_BSS__ - else - printf("[DEBUG_BSS] BSSzone found with size = %u \n", bss->shdr->sh_size); -#endif - obj = file; - last = bss; - elfsh_fixup_bss_real(file, bss, fixflag); - } -#if __DEBUG_BSS__ - printf("[DEBUG_BSS] RETURNED %s as last bss \n", (last != 0x0) ? last->name: "null"); - fflush(stdout); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (last)); -} - - - -/** - * The real function that fixup the bss - * fixflag indicate if the section was nullsized and fixed - * This file is not DBG safe - * - * @param file - * @param bss - * @param fixflag - * @return - */ -int elfsh_fixup_bss_real(elfshobj_t *file, - elfshsect_t *bss, - char fixflag) -{ - elfshsect_t *next; - elfshsect_t *actual; - u_int size; - elfsh_Off size2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fixup file offset of BSS section and makes it matches the previous - section file offset added to the previous size. Necessary on - Linux/MIPS GNU ld version 2.14.90.0.8 20040114, maybe others. - If we dont do that we have a phdr size problem. - This has to happen _BEFORE_ the shift in elfsh_add_bsszone. - */ - if (bss->prev != NULL && - bss->prev->shdr->sh_offset + bss->prev->shdr->sh_size != bss->shdr->sh_offset) - { - size = bss->shdr->sh_offset - (bss->prev->shdr->sh_offset + bss->prev->shdr->sh_size); - for (next = bss; next != NULL; next = next->next) - next->shdr->sh_offset -= size; - } - - /* Make sure the virtual address difference and the file offset difference is identical - from the section before bss, and bss */ - if (bss->prev != NULL && bss->shdr->sh_offset - bss->prev->shdr->sh_offset != - bss->shdr->sh_addr - bss->prev->shdr->sh_addr) - { - unsigned int diff = - (bss->shdr->sh_addr - bss->prev->shdr->sh_addr) - - (bss->shdr->sh_offset - bss->prev->shdr->sh_offset); - - for (next = bss; next != NULL; next = next->next) - next->shdr->sh_offset += diff; - } - - - /* Fixup file offset for section after bss in case they overlap. - It happens on Solaris 8.0 with ld solaris-ELF 4.0 - This has to happen _BEFORE_ the shift in elfsh_add_bsszone. - */ - if (bss->next != NULL && - bss->next->shdr->sh_offset <= bss->shdr->sh_offset + bss->shdr->sh_size && - elfsh_get_section_type(bss->next->shdr) != SHT_NOBITS && !fixflag) - { -#if __DEBUG_BSS__ - printf("[DEBUG_BSS] Fixing up overlapping sections\n"); -#endif - size = bss->shdr->sh_offset - bss->next->shdr->sh_offset; - file->hdr->e_shoff += size; - for (next = bss->next; next != NULL; next = next->next) - next->shdr->sh_offset += size; - } - - /* Avoid unaligned accesses on ALPHA */ - if (elfsh_get_archtype(bss->parent) == ELFSH_ARCH_ALPHA64) - size2 = sizeof(eresi_Addr) - (bss->shdr->sh_size % sizeof(eresi_Addr)); - else - size2 = 0; - - /* Find BSS segment */ - if (bss->phdr == NULL) - { - actual = bss->prev; - while (actual->phdr == NULL) - actual = actual->prev; - bss->phdr = actual->phdr; - } - - /* Allocate BSS data */ - if (bss->data == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,bss->data, bss->shdr->sh_size + size2, -1); - bss->phdr->p_filesz += bss->shdr->sh_size + size2; - bss->phdr->p_memsz += size2; - -#if __DEBUG_BSS__ - printf("Allocated BSS data of " UFMT " bytes with %u bytes of padding \n", - bss->shdr->sh_size, size2); -#endif - - } - - /* Extend physical bss and the segment for .bss if PHT exists */ - else - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__,bss->data, bss->data, bss->shdr->sh_size + size2, -1); - bss->phdr->p_filesz += bss->shdr->sh_size + size2; - bss->phdr->p_memsz += size2; - -#if __DEBUG_BSS__ - printf("[DEBUG_BSS] PT_LOAD BSS FILESZ now = " UFMT " [bss reallocated] \n", - bss->shdr->sh_size + size2); -#endif - - } - - /* Update the SHT file offset if necessary */ - if (bss->parent->hdr->e_shoff > bss->shdr->sh_offset) - bss->parent->hdr->e_shoff += bss->shdr->sh_size + size2; - - /* Update the vaddr and file offset for all next sections */ - for (actual = bss->next; actual != NULL; actual = actual->next) - actual->shdr->sh_offset += bss->shdr->sh_size + size2; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Find the BSS section for this module - * - * @param file - * @param name - * @return - */ -elfshsect_t *elfsh_find_bss(elfshobj_t *file, char *name) -{ - elfshsect_t *cur; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Find zone */ - snprintf(buff, sizeof(buff), "%s.bss", name); - cur = elfsh_get_section_by_name(file, buff, 0, 0, 0); - if (cur == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find module BSS", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); -} - -/** - * Find BSS size in a relocatable object - * - * @param host - * @param rel - * @param bssname - * @return - */ -int elfsh_find_bsslen(elfshobj_t *host, - elfshobj_t *rel, - char *bssname) -{ - elfshsect_t *host_bss; - elfshsect_t *host_symtab; - elfsh_Sym *symtab; - elfsh_Sym enew; - int size; - u_int index; - char *name; - char buff[BUFSIZ]; - eresi_Addr bss_size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (host == NULL || rel == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Init some stuff */ - elfsh_get_symtab(host, NULL); - host_symtab = host->secthash[ELFSH_SECTION_SYMTAB]; - symtab = elfsh_get_symtab(rel, &size); - if (symtab == NULL || host_symtab == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol tables", -1); - - snprintf(buff, sizeof(buff), "%s%s", rel->name, bssname); - host_bss = elfsh_get_section_by_name(host, buff, 0, 0, 0); - if (host_bss == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Host's bss not found", -1); - - if (host_bss == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find host BSS", -1); - - bss_size = host_bss->shdr->sh_addr; - - /* Parse symtab and find all COMMON symbols */ - for (index = 0; index < size; index++) - if (elfsh_get_symbol_link(symtab + index) == SHN_COMMON) - { - - /* Align symbol size as needed */ - if (symtab[index].st_value) - while (bss_size % symtab[index].st_value) - bss_size++; - - - /* Create and inject symbol in ET_EXEC */ - enew = elfsh_create_symbol(bss_size, - symtab[index].st_size, - STT_OBJECT, STB_LOCAL, - 0, host_bss->index); - - name = elfsh_get_symbol_name(rel, symtab + index); - elfsh_insert_symbol(host_symtab, &enew, name); - bss_size += symtab[index].st_size; - } - - bss_size -= host_bss->shdr->sh_addr; - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Found BSS zone lenght [%08u] for module [%s] \n", - bss_size, rel->name); -#endif - - elfsh_sync_sorted_symtab(host_symtab); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (bss_size)); -} - - - -/** THIS SEEMS TO BE BUGGY ON SOLARIS -- TRYING TO FIX IT --- SORRY FOR INCONVENIENCE **/ - -/** - * Insert the BSS section in the destination file - * - * @param file - * @param rel - * @param bssname - * @return - */ -elfshsect_t *elfsh_insert_bss(elfshobj_t *file, elfshobj_t *rel, char *bssname) -{ - int pagesize; - elfshsect_t *newbss; - int bsslen; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - pagesize = elfsh_get_pagesize(file); - snprintf(buf, sizeof(buf), "%s%s", rel->name, bssname); - newbss = elfsh_insert_section(file, buf, NULL, ELFSH_DATA_INJECTION, pagesize, 0); - if (!newbss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert bss section", NULL); - - // The size of the BSS is found in the host directly, so this call must be after the previous - bsslen = elfsh_find_bsslen(file, rel, bssname); - if (bsslen == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find bss size", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newbss); -} - - - - -/** - * Map a new BSS in the current file or process as an additional section - * - * @param file - * @param rel - * @return - */ -elfshsect_t* elfsh_insert_runtime_bss(elfshobj_t *file, elfshobj_t *rel) -{ - elfshsect_t* newbss; - elfshsect_t* current; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - newbss = NULL; - current = rel->sectlist; - for (current = rel->sectlist; current; current = current->next) - { - if (elfsh_get_section_type(current->shdr) != SHT_NOBITS) - continue; - newbss = elfsh_insert_bss(file, rel, current->name); - if (!newbss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert runtime bss", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newbss); - } - - // There was simply no bss in the relocatable file, create it with standard name - if (!newbss) - { - newbss = elfsh_insert_bss(file, rel, ELFSH_SECTION_NAME_BSS); - if (!newbss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert runtime bss", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newbss); -} - - -/** - * Map a new BSS in the current file or process as an additional section - * @param file - * @param rel - * @return - */ -/* -elfshsect_t *elfsh_insert_runtime_bss(elfshobj_t *file, elfshobj_t *rel) -{ - elfshsect_t *newbss; - int bsslen; - char buf[BUFSIZ]; - elfshsect_t *current; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - newbss = NULL; - current = rel->sectlist; - for (current = rel->sectlist; current; current = current->next) - { - if (elfsh_get_section_type(current->shdr) != SHT_NOBITS) - continue; - - snprintf(buf, sizeof(buf), "%s%s", rel->name, current->name); - newbss = elfsh_insert_section(file, buf, NULL, ELFSH_DATA_INJECTION, - elfsh_get_pagesize(file), 0); - if (!newbss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert runtime bss", NULL); - - bsslen = elfsh_find_bsslen(file, rel, current->name); - if (bsslen == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find bss size", NULL); - } - - //There was simply no bss in the relocatable file, its not an error - if (!newbss) - newbss = (elfshsect_t *) 0xdeadbeef; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newbss); -} -*/ diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/bt.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/bt.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/bt.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/bt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -/** - * @file bt.c - * @ingroup libelfsh -** bt.c for elfsh -** -** Started on Wed Jul 27 04:08:52 2005 ym -** -** -** $Id: bt.c,v 1.3 2007-06-27 11:25:12 heroine Exp $ -** -*/ -#include "libelfsh.h" - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/comment.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/comment.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/comment.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/comment.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,94 +0,0 @@ -/** - * @file comment.c - * @ingroup libelfsh -** comment.c for elfsh in -** -** Made by jfv -** Login -** -** Started on Sun Dec 1 09:22:45 2002 jfv -** -** -** $Id: comment.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Get comment section - * @param file - * @return - */ -elfshsect_t *elfsh_get_comments(elfshobj_t *file) -{ - elfshsect_t *enew; - int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL paramater", NULL); - - enew = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_COMMENT, - NULL, NULL, &size); - if (NULL == enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get .comment by name", NULL); - - if (NULL == elfsh_get_raw(enew)) - { - enew->data = elfsh_load_section(file, enew->shdr); - if (NULL == elfsh_get_raw(enew)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load .comment", NULL); - } - - file->secthash[ELFSH_SECTION_COMMENT] = enew; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (enew)); -} - - -/** - * Get an entry from .comment - * @param file - * @param range - * @return - */ -char *elfsh_get_comments_entry(elfshobj_t *file, u_int range) -{ - int index; - int act; - char *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#define CHECK_SZ (index < file->secthash[ELFSH_SECTION_COMMENT]->shdr->sh_size) - - if (!file->secthash[ELFSH_SECTION_COMMENT] && !elfsh_get_comments(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get .comments", NULL); - - index = act = 0; - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_COMMENT]); - while (!data[index] && CHECK_SZ) - index++; - while (act != range && CHECK_SZ) - if (!data[index]) - { - act++; - while (!data[index] && CHECK_SZ) - index++; - } - else - index++; - -#undef CHECK_SZ - - if (index < file->secthash[ELFSH_SECTION_COMMENT]->shdr->sh_size) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (data + index)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get .comments entry", NULL); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/copy.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/copy.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/copy.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/copy.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -/** - * @file copy.c - * @ingroup libelfsh -** copy.c for elfsh -** -** Started on Tue Mar 4 01:15:23 2003 jfv -** Last update Tue Mar 11 21:26:07 2003 jfv -** -** $Id: copy.c,v 1.11 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Used by elfsh_save_obj(). Do not use outside ELFsh - * May not be perfect, to modify if some param is zeroified because of the copy - * - * @param file - * @return - */ -elfshobj_t *elfsh_copy_obj(elfshobj_t *file) -{ - elfshobj_t *copy; - elfshsect_t *cur; - elfshsect_t *enew; - elfshsect_t *tmp; - int range; - int cnt; - int index; - elfsh_Phdr *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (elfsh_read_obj(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't copy file object", NULL); - - - /* Do copy */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,copy, sizeof(elfshobj_t), NULL); - copy->name = strdup(file->name); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,copy->hdr, sizeof(elfsh_Ehdr), NULL); - memcpy(copy->hdr, file->hdr, sizeof(elfsh_Ehdr)); - copy->rights = file->rights; - XALLOC(__FILE__, __FUNCTION__, __LINE__,copy->pht, sizeof(elfsh_Phdr) * file->hdr->e_phnum, NULL); - memcpy(copy->pht, file->pht, sizeof(elfsh_Phdr) * file->hdr->e_phnum); - XALLOC(__FILE__, __FUNCTION__, __LINE__,copy->sht, sizeof(elfsh_Shdr) * file->hdr->e_shnum, NULL); - memcpy(copy->sht, file->sht, sizeof(elfsh_Shdr) * file->hdr->e_shnum); - copy->read = file->read; - copy->shtrm = file->shtrm; - copy->shtrb = file->shtrb; - copy->strip = file->strip; - copy->nbrm = file->nbrm; - copy->fstat = file->fstat; - copy->id = file->id; - copy->fd = file->fd; - copy->pending = file->pending; - copy->linkmap = file->linkmap; - copy->rhdr.base = file->rhdr.base; - copy->original = file; - - /* Arrange sectlist. Partially ripped from elfsh_add_section() . */ - for (range = 0, cur = file->sectlist; cur; cur = cur->next, range++) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, sizeof(elfshsect_t), NULL); - enew->shdr = copy->sht + range; - enew->parent = copy; - enew->index = range; - enew->name = strdup(cur->name); - - enew->flags = cur->flags; - - if (enew->shdr->sh_size && cur->data) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew->data, enew->shdr->sh_size, NULL); - memcpy(enew->data, cur->data, enew->shdr->sh_size); - } - - /* Set phdr pointer */ - for (index = 0, actual = enew->parent->pht; index < enew->parent->hdr->e_phnum; - index++) - if (INTERVAL(actual[index].p_vaddr, enew->shdr->sh_addr, - actual[index].p_vaddr + actual[index].p_memsz)) - enew->phdr = actual + index; - - enew->curend = cur->curend; - - /* Insert enew section in sectlist */ - for (tmp = copy->sectlist; tmp != NULL && tmp->next != NULL; tmp = tmp->next) - if (tmp->index == range) - { - /* Insert the enew section */ - enew->prev = tmp->prev; - enew->next = tmp; - if (enew->prev != NULL) - enew->prev->next = enew; - else - copy->sectlist = enew; - tmp->prev = enew; - } - - /* The section is the first one inserted */ - if (!tmp) - { - copy->sectlist = enew; - copy->sectlist->prev = enew; - } - - /* The section must be inserted at the last place */ - else if (!tmp->next) - { - tmp->next = enew; - enew->prev = tmp; - copy->sectlist->prev = enew; - } - - /* Fill secthash */ - for (cnt = 0; cnt < ELFSH_SECTION_MAX; cnt++) - if (file->secthash[cnt] == cur) - copy->secthash[cnt] = enew; - - } - - /* XXX-runtimelist to copy as well */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (copy)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/ctors.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/ctors.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/ctors.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/ctors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -/** - * @file ctors.c - * @ingroup libelfsh - * - * Started on Tue Feb 26 22:11:12 2002 jfv - * - * $Id: ctors.c,v 1.7 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - - - -/** - * Read the constructor array in .ctors - * @param file - * @param num - * @return - */ -eresi_Addr *elfsh_get_ctors(elfshobj_t *file, int *num) -{ - elfshsect_t *enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Find ctors */ - enew = file->secthash[ELFSH_SECTION_CTORS]; - if (enew == NULL) - { - enew = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_CTORS, - NULL, NULL, NULL); - if (NULL == enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get CTORS by name", NULL); - } - - /* Read ctors */ - if (NULL == enew->data) - { - enew->data = elfsh_load_section(file, enew->shdr); - if (NULL == enew->data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load CTORS", NULL); - file->secthash[ELFSH_SECTION_CTORS] = enew; - } - - /* Return data */ - if (num != NULL) - *num = enew->shdr->sh_size / sizeof(eresi_Addr); - - /* Return a pointer on the data. Also work in debug mode */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); -} - - - - -/** - * Shift CTORS on ET_DYN - * @param file - * @param size - * @return - */ -int elfsh_shift_ctors(elfshobj_t *file, u_int size) -{ - elfshsect_t *ctors; - int nbr; - u_int idx; - eresi_Addr *addr; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ctors = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_CTORS, - NULL, NULL, &nbr); - if (!ctors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive CTORS in ET_DYN", -1); - nbr = nbr / sizeof(eresi_Addr); - for (idx = 0; idx < nbr; idx++) - { - addr = elfsh_get_ctors_entry_by_index(ctors->data, idx); - if (*addr && *addr != ELFSH_END_CTORS) - *addr += size; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - - -/** - * Modify a CTORS entry using its index - * @param file - * @param index - * @param addr - * @return - */ -int elfsh_set_ctors_entry_by_index(elfshobj_t *file, - int index, - eresi_Addr addr) -{ - eresi_Addr *ctors; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ctors = elfsh_get_ctors(file, &nbr); - if (NULL == ctors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get CTORS", -1); - - if (index >= nbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "CTORS index too big", -1); - - ctors[index] = addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Modify a CTORS entry using its name - * @param file - * @param name - * @param new_addr - * @return - */ -int elfsh_set_ctors_entry_by_name(elfshobj_t *file, - char *name, - eresi_Addr new_addr) -{ - eresi_Addr *ctors; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ctors = elfsh_get_ctors_entry_by_name(file, name); - if (NULL == ctors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get CTORS entry by name", -1); - *ctors = new_addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Return a entry giving its parent and its index - * @param ctors - * @param index - * @return - */ -eresi_Addr *elfsh_get_ctors_entry_by_index(eresi_Addr *ctors, eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == ctors) -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", - NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ctors + index)); -} - - - -/** - * Return an entry giving the matching symbol name - * @param file - * @param name - * @return - */ -eresi_Addr *elfsh_get_ctors_entry_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - eresi_Addr *ctors; - int nbr; - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", - NULL); - ctors = elfsh_get_ctors(file, &nbr); - sym = elfsh_get_metasym_by_name(file, name); - if (sym == NULL || ctors == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol with this name", NULL); - - /* Find the entry */ - for (idx = 0; idx < nbr; idx++) - if (ctors[idx] == sym->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ctors + idx)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "CTORS entry not found", - NULL); -} - - -/** - * Return a entry giving its parent and its index : used as INTERNAL hash handler - * @param ctors - * @param vaddr - * @return - */ -int elfsh_set_ctors_entry(eresi_Addr *ctors, eresi_Addr vaddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == ctors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - *ctors = vaddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return a entry value giving its parent and its index : used as INTERNAL hash handler - * @param ctors - * @return - */ -eresi_Addr elfsh_get_ctors_entry(eresi_Addr *ctors) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == ctors) -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*ctors)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/debug.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/debug.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/debug.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/debug.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -/** - * @file debug.c - * @ingroup libelfsh - * - * Started on Thu Apr 3 21:36:55 2003 jfv - * - * $Id: debug.c,v 1.9 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -/** - * Debug : print the section list - * @param obj - * @param label - * @return - */ -int elfsh_print_sectlist(elfshobj_t *obj, char *label) -{ - elfshsect_t *actual; - u_int index; - u_char *data; - char *sctname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - printf(" [SCTLIST][%s]\n", label); - for (index = 0, actual = obj->sectlist; - actual != NULL; - index++, actual = actual->next) - { - sctname = elfsh_get_section_name(obj, actual); - if (sctname == NULL) - sctname = "UNK"; - data = elfsh_get_raw(actual); - if (data == (u_char *)NULL) - data = (u_char *)"\xFF\xFF\xFF"; - printf(" [%03u:%03u] %-15s HDRNAM: %-15s BYTES[%02X %02X %02X] P(%8p) " - "A(%8p) N(%8p) SCTIDX(%03u) HDRFOFF:%010u SZ:%010u VADDR:%08X \n", - index, actual->index, - (actual->name != NULL ? actual->name : "UNK"), - sctname, - (u_int) data[0], - (u_int) data[1], - (u_int) data[2], - actual->prev, - actual, - actual->next, - actual->index, - (u_int) actual->shdr->sh_offset, - (u_int) actual->shdr->sh_size, - (u_int) actual->shdr->sh_addr); - } - puts(" [EOL]\n"); - fflush(stdout); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return architecture string related to e_machine - * generated with - * cat /usr/include/elf.h | grep EM_ \ - * awk -F\ \ - * '{print "case "$3": return @"$2" : "$5 $6" "$7" "$8" "$9" "$20"@;" }' \ - * | sed s/@/\"/g | sed 's/\*\///g' - * - * @param machine Machine to get description string - * @return A pointer to a static string to describe machine - */ -char *elfsh_get_machine_string(elfsh_Half machine) -{ - switch(machine) - { - case 0: return "EM_NONE : Nomachine"; - case 1: return "EM_M32 : AT&TWE 32100"; - case 2: return "EM_SPARC : SUNSPARC"; - case 3: return "EM_386 : Intel80386"; - case 4: return "EM_68K : Motorolam68k family"; - case 5: return "EM_88K : Motorolam88k family"; - case 7: return "EM_860 : Intel80860"; - case 8: return "EM_MIPS : MIPSR3000 big-endian"; - case 9: return "EM_S370 : IBMSystem/370"; - case 10: return "EM_MIPS_RS3_LE : MIPSR3000 little-endian"; - case 15: return "EM_PARISC : HPPA"; - case 17: return "EM_VPP500 : FujitsuVPP500"; - case 18: return "EM_SPARC32PLUS : Sun's\"v8plus\""; - case 19: return "EM_960 : Intel80960"; - case 20: return "EM_PPC : PowerPC"; - case 21: return "EM_PPC64 : PowerPC64-bit"; - case 22: return "EM_S390 : IBMS390"; - case 36: return "EM_V800 : NECV800 series"; - case 37: return "EM_FR20 : FujitsuFR20"; - case 38: return "EM_RH32 : TRWRH-32"; - case 39: return "EM_RCE : MotorolaRCE"; - case 40: return "EM_ARM : ARM"; - case 41: return "EM_FAKE_ALPHA : DigitalAlpha"; - case 42: return "EM_SH : HitachiSH"; - case 43: return "EM_SPARCV9 : SPARCv9 64-bit"; - case 44: return "EM_TRICORE : SiemensTricore"; - case 45: return "EM_ARC : ArgonautRISC Core"; - case 46: return "EM_H8_300 : HitachiH8/300"; - case 47: return "EM_H8_300H : HitachiH8/300H"; - case 48: return "EM_H8S : HitachiH8S"; - case 49: return "EM_H8_500 : HitachiH8/500"; - case 50: return "EM_IA_64 : IntelMerced"; - case 51: return "EM_MIPS_X : StanfordMIPS-X"; - case 52: return "EM_COLDFIRE : MotorolaColdfire"; - case 53: return "EM_68HC12 : MotorolaM68HC12"; - case 54: return "EM_MMA : FujitsuMMA Multimedia Accelerator"; - case 55: return "EM_PCP : SiemensPCP"; - case 56: return "EM_NCPU : SonynCPU embeeded RISC"; - case 57: return "EM_NDR1 : DensoNDR1 microprocessor"; - case 58: return "EM_STARCORE : MotorolaStart*Core processor"; - case 59: return "EM_ME16 : ToyotaME16 processor"; - case 60: return "EM_ST100 : STMicroelectronicST100 processor"; - case 61: return "EM_TINYJ : AdvancedLogic Corp. Tinyj emb.fam"; - case 62: return "EM_X86_64 : AMDx86-64 architecture"; - case 63: return "EM_PDSP : SonyDSP Processor"; - case 66: return "EM_FX66 : SiemensFX66 microcontroller"; - case 67: return "EM_ST9PLUS : STMicroelectronicsST9+ 8/16 mc"; - case 68: return "EM_ST7 : STmicroelectronicsST7 8 bit mc"; - case 69: return "EM_68HC16 : MotorolaMC68HC16 microcontroller"; - case 70: return "EM_68HC11 : MotorolaMC68HC11 microcontroller"; - case 71: return "EM_68HC08 : MotorolaMC68HC08 microcontroller"; - case 72: return "EM_68HC05 : MotorolaMC68HC05 microcontroller"; - case 73: return "EM_SVX : SiliconGraphics SVx"; - case 74: return "EM_ST19 : STMicroelectronicsST19 8 bit mc"; - case 75: return "EM_VAX : DigitalVAX"; - case 76: return "EM_CRIS : AxisCommunications 32-bit embedded processor"; - case 77: return "EM_JAVELIN : InfineonTechnologies" - " 32-bit embedded processor"; - case 78: return "EM_FIREPATH : Element14 64-bit DSP Processor"; - case 79: return "EM_ZSP : LSILogic 16-bit DSP Processor"; - case 80: return "EM_MMIX : DonaldKnuth's educational" - "64-bit processor"; - case 81: return "EM_HUANY : HarvardUniversity machine-independent" - "object files"; - case 82: return "EM_PRISM : SiTeraPrism"; - case 83: return "EM_AVR : AtmelAVR 8-bit microcontroller"; - case 84: return "EM_FR30 : FujitsuFR30"; - case 85: return "EM_D10V : MitsubishiD10V"; - case 86: return "EM_D30V : MitsubishiD30V"; - case 87: return "EM_V850 : NECv850"; - case 88: return "EM_M32R : MitsubishiM32R"; - case 89: return "EM_MN10300 : MatsushitaMN10300"; - case 90: return "EM_MN10200 : MatsushitaMN10200"; - case 91: return "EM_PJ : picoJava"; - case 92: return "EM_OPENRISC : OpenRISC32-bit embedded processor"; - case 93: return "EM_ARC_A5 : ARCCores Tangent-A5"; - case 94: return "EM_XTENSA : TensilicaXtensa Architecture"; - default: - return "unsupported ascii machine string"; - } -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/dtors.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/dtors.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/dtors.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/dtors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -/** - * @file dtors.c - * @ingroup libelfsh - * - * Started on Tue Feb 26 22:12:38 2002 jfv - * - * $Id: dtors.c,v 1.7 2008-02-16 12:32:27 thor Exp $ - * - */ - -#include "libelfsh.h" - - -/** - * Read the destructor array in .dtors - * @param file - * @param num - * @return - */ -eresi_Addr *elfsh_get_dtors(elfshobj_t *file, int *num) -{ - elfshsect_t *enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Load dtors */ - enew = file->secthash[ELFSH_SECTION_DTORS]; - if (enew == NULL) - { - enew = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DTORS, - NULL, NULL, NULL); - if (NULL == enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DTORS by name", NULL); - } - - /* Read dtors */ - if (NULL == enew->data) - { - enew->data = elfsh_load_section(file, enew->shdr); - if (NULL == enew->data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load DTORS", NULL); - file->secthash[ELFSH_SECTION_DTORS] = enew; - } - - /* Return data */ - if (num != NULL) - *num = enew->shdr->sh_size / sizeof(eresi_Addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); -} - - - - -/** - * Shift DTORS on ET_DYN - * @param file - * @param size - * @return - */ -int elfsh_shift_dtors(elfshobj_t *file, u_int size) -{ - elfshsect_t *dtors; - int nbr; - u_int idx; - eresi_Addr *addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dtors = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DTORS, - NULL, NULL, &nbr); - if (!dtors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive DTORS in ET_DYN", -1); - nbr = nbr / sizeof(eresi_Addr); - for (idx = 0; idx < nbr; idx++) - { - addr = elfsh_get_dtors_entry_by_index(dtors->data, idx); - if (*addr && *addr != ELFSH_END_DTORS) - *addr += size; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - -/** - * Modify a DTORS entry - * @param file - * @param index - * @param addr - * @return - */ -int elfsh_set_dtors_entry_by_index(elfshobj_t *file, - int index, eresi_Addr addr) -{ - int nbr; - eresi_Addr *dtors; - u_int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dtors = elfsh_get_dtors(file, &nbr); - if (NULL == dtors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DTORS entry", -1); - - size = file->secthash[ELFSH_SECTION_DTORS]->shdr->sh_size / sizeof(eresi_Addr); - if (index >= size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DTORS index too big", -1); - - dtors[index] = addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Modify a DTORS entry using its name - * @param file - * @param name - * @param new_addr - * @return - */ -int elfsh_set_dtors_entry_by_name(elfshobj_t *file, - char *name, - eresi_Addr new_addr) -{ - eresi_Addr *dtors; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dtors = elfsh_get_dtors_entry_by_name(file, name); - if (NULL == dtors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set DTORS entry by name", -1); - *dtors = new_addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Get DTORS entry by name - * @param file - * @param name - * @return - */ -eresi_Addr *elfsh_get_dtors_entry_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - eresi_Addr *dtors; - int nbr; - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - dtors = elfsh_get_dtors(file, &nbr); - sym = elfsh_get_metasym_by_name(file, name); - if (sym == NULL || dtors == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DTORS entry by name", NULL); - - /* Find the entry */ - for (idx = 0; idx < nbr; idx++) - if (dtors[idx] == sym->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dtors + idx)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DTORS entry not found", NULL); -} - - - -/** - * Return a entry giving its parent and its index : used as INTERNAL hash handler - * @param dtors - * @param index - * @return - */ -eresi_Addr *elfsh_get_dtors_entry_by_index(eresi_Addr *dtors, eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (dtors == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dtors + index)); -} - - -/** - * Return a entry giving its parent and its index : used as INTERNAL hash handler - * @param dtors - * @param vaddr - * @return - */ -int elfsh_set_dtors_entry(eresi_Addr *dtors, eresi_Addr vaddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == dtors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - *dtors = vaddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return a entry value giving its parent and its index : used as INTERNAL hash handler - * @param dtors - * @return - */ -eresi_Addr elfsh_get_dtors_entry(eresi_Addr *dtors) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == dtors) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*dtors)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/dumpregs.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/dumpregs.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/dumpregs.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/dumpregs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/** - * @file dumpregs.c - * @ingroup libelfsh -** dumpregs.c for elfsh -** -** Started on Wed Jul 27 04:08:52 2005 ym -** -** -** $Id: dumpregs.c,v 1.5 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -//static elfshia32regs_t regs; - - -struct s_regs_ia32 -{ - uint32_t esp; - uint32_t eax; - uint32_t ebp; - uint32_t edi; - uint32_t esi; - uint32_t edx; - uint32_t ecx; - uint32_t ebx; - uint32_t es; /* 16bits but we want to keep alignment */ - uint32_t ds; /* 16bits but we want to keep alignment */ -} ia32regs_t; - - - -/** - * The breakpoint routine. Save registers and callback - */ -void elfsh_genericbp_ia32() -{ - //ia32regs_t breakpoint; - - /* Save registers value */ - /* - __asm__ volatile ( - "movl %%esp, 0(%esp) \n" - "addl 48 , 0(%%esp) \n" - "movl %%eax, 4(%%esp) \n" - "movl %%ebp, 8(%%esp) \n" - "movl %%edi, 12(%esp) \n" - "movl %%esi, 16(%%esp) \n" - "movl %%edx, 20(%%esp) \n" - "movl %%ecx, 24(%%esp) \n" - "movl %%ebx, 28(%%esp) \n" - "movl %%es, 32(%%esp) \n" - "movl %%ds, 36(%%esp) \n" - ); - */ - /* Restore all registers */ - /*__asm__ volatile ("pop %%ebx \n" - "pop %%ecx \n" - "pop %%edx \n" - "pop %%esi \n" - "pop %%edi \n" - "pop %%ebp \n" - "pop %%eax \n" - "pop %%ds \n" - "pop %%es \n" - "pop %%esp \n" - ); - */ - - /* XXX: need to trampoline on the intercepted function */ -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/dwarf.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/dwarf.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/dwarf.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/dwarf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,442 +0,0 @@ -/** - * @file dwarf.c - * @ingroup libelfsh -** dwarf.c for libelfsh -** -** Started on Fri Mao 17 23:11:47 2007 mxatone -** -** -** -*/ -#include "libelfsh.h" - -int elfsh_get_dwarf(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_get_dwarf_info(file, NULL); - elfsh_get_dwarf_abbrev(file, NULL); - elfsh_get_dwarf_aranges(file, NULL); - elfsh_get_dwarf_frame(file, NULL); - elfsh_get_dwarf_line(file, NULL); - elfsh_get_dwarf_macinfo(file, NULL); - elfsh_get_dwarf_pubnames(file, NULL); - elfsh_get_dwarf_str(file, NULL); - elfsh_get_dwarf_loc(file, NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Load dwarf info table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_info(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_INFO] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_INFO, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf info table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf info table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_INFO] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_INFO]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_INFO]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf abbrev table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_abbrev(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_ABBREV] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_ABBREV, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf abbrev table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf abbrev table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_ABBREV] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_ABBREV]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_ABBREV]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf aranges table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_aranges(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_ARANGES] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_ARANGES, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf aranges table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf aranges table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_ARANGES] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_ARANGES]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_ARANGES]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf frame table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_frame(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_FRAME] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_FRAME, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf frame table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf frame table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_FRAME] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_FRAME]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_FRAME]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf line table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_line(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_LINE] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_LINE, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf line table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf line table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_LINE] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_LINE]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_LINE]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf macinfo table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_macinfo(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_MACINFO] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_MACINFO, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf abbrev table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf abbrev table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_MACINFO] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_MACINFO]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_MACINFO]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf pubnames table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_pubnames(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_PUBNAMES] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_PUBNAMES, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf pubnames table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf pubnames table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_PUBNAMES] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_PUBNAMES]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_PUBNAMES]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf str table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_str(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_STR] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_STR, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf str table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf str table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_STR] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_STR]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_STR]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Load dwarf loc table - * @param file file objet - * @param num object number pointer - * @return data pointer - */ -void *elfsh_get_dwarf_loc(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DW2_LOC] == NULL) - { - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DW2_LOC, 0, - &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Dwarf loc table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Dwarf loc table", - NULL); - } - - file->secthash[ELFSH_SECTION_DW2_LOC] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_DW2_LOC]->shdr->sh_size; - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DW2_LOC]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/dynamic.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/dynamic.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/dynamic.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/dynamic.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,314 +0,0 @@ -/** - * @file dynamic.c - * @ingroup libelfsh -** dynamic.c for libelfsh -** -** Started on Tue Feb 27 04:36:53 2001 jfv -** -** -** $Id: dynamic.c,v 1.11 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Change endianess of .dynamic - * @param newent - * @return - */ -int elfsh_endianize_dynamic(elfshsect_t *newent) -{ - elfsh_Dyn *dyn; - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity check */ - if (!newent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (newent->parent->hdr->e_ident[EI_DATA] == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (newent->parent->hdr->e_ident[EI_DATA] == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - dyn = (elfsh_Dyn *) elfsh_get_raw(newent); - for (idx = 0; idx < newent->shdr->sh_size / sizeof(elfsh_Dyn); idx++) - { - dyn[idx].d_tag = swaplong(dyn[idx].d_tag); - dyn[idx].d_un.d_val = swaplong(dyn[idx].d_un.d_val); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Return a ptr on the dynamic section - * @param file - * @param num - * @return - */ -elfsh_Dyn *elfsh_get_dynamic(elfshobj_t *file, u_int *num) -{ - elfshsect_t *newent = NULL; /* to shut gcc up with -Wall */ - int nbr; - elfsh_Dyn *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DYNAMIC] == NULL) - { - newent = elfsh_get_section_by_type(file, SHT_DYNAMIC, NULL, NULL, &nbr, 0); - if (newent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get .dynamic by type", NULL); - file->secthash[ELFSH_SECTION_DYNAMIC] = newent; - } - - newent = file->secthash[ELFSH_SECTION_DYNAMIC]; - nbr = file->secthash[ELFSH_SECTION_DYNAMIC]->shdr->sh_size / - sizeof(elfsh_Dyn); - if (num != NULL) - *num = nbr; - - if (newent->data == NULL) - { - newent->data = elfsh_load_section(file, newent->shdr); - if (newent->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load .dynamic", NULL); - elfsh_endianize_dynamic(newent); - } - - ret = (elfsh_Dyn *) elfsh_get_raw(newent); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - -/** - * Return the tag field of the dynamic entry - * @param d - * @return - */ -elfsh_Sword elfsh_get_dynentry_type(elfsh_Dyn *d) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (d == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (d->d_tag)); -} - -/** - * Change the tag field of the dynamic entry - * @param d - * @param tag - * @return - */ -int elfsh_set_dynentry_type(elfsh_Dyn *d, eresi_Addr tag) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (d == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - d->d_tag = (elfsh_Sword) tag; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the tag field of the dynamic entry - * @param d - * @return - */ -elfsh_Word elfsh_get_dynentry_val(elfsh_Dyn *d) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (d == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", 0xFFFFFFFF); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (d->d_un.d_val)); -} - -/** - * Change the val field of the dynamic entry - * @param d - * @param val - * @return - */ -int elfsh_set_dynentry_val(elfsh_Dyn *d, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (d == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - d->d_un.d_val = (elfsh_Word) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Retreive the information giving the entry - * @param file elfsh object. - * @param ent - * @return - */ -char *elfsh_get_dynentry_string(elfshobj_t *file, elfsh_Dyn *ent) -{ - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - if (file->secthash[ELFSH_SECTION_DYNSYM] == NULL && - elfsh_get_dynsymtab(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", NULL); - - if (ent->d_un.d_val > file->secthash[ELFSH_SECTION_DYNSTR]->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid .dynstr offset", NULL); - - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((char *) data + ent->d_un.d_val)); -} - - -/** - * Get .dynamic entries by type - * @param file - * @param type - * @return - */ -elfsh_Dyn *elfsh_get_dynamic_entry_by_type(elfshobj_t *file, - elfsh_Word type) -{ - u_int index; - u_int size; - elfsh_Dyn *table; - elfsh_Sword res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - table = elfsh_get_dynamic(file, &size); - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNAMIC", NULL); - - for (index = 0; index < size; index++) - { - res = elfsh_get_dynentry_type(table + index); - if (res != -1 && res == (elfsh_Sword) type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (table + index)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No dynamic entry with that type", NULL); -} - -/** - * Return a elfsh_Dyn entry by its index - * @param dynamic - * @param index - * @return - */ -elfsh_Dyn *elfsh_get_dynamic_entry_by_index(elfsh_Dyn *dynamic, - eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dynamic + index)); -} - -/** - * Say if the entry is a pointer - * @param ent - * @return - */ -int elfsh_shiftable_dynent(elfsh_Dyn *ent) -{ - switch (elfsh_get_dynentry_type(ent)) - { - case DT_INIT: - case DT_FINI: - case DT_HASH: - case DT_STRTAB: - case DT_SYMTAB: - case DT_JMPREL: - case DT_REL: - case DT_VERNEED: - case DT_VERSYM: - case DT_VERDEF: - case DT_PLTGOT: - return (1); - default: - return (0); - } - return (0); -} - - - -/** - * Shift the .dynamic section in ET_DYN files - * - * @param file - * @param size - * @return - */ -int elfsh_shift_dynamic(elfshobj_t *file, u_int size) -{ - elfsh_Dyn *dyn; - u_int nbr; - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dyn = elfsh_get_dynamic(file, &nbr); - if (dyn == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find .dynamic in ET_DYN", -1); - for (idx = 0; idx < nbr; idx++) - if (elfsh_shiftable_dynent(dyn + idx)) - elfsh_set_dynentry_val(dyn + idx, - elfsh_get_dynentry_val(dyn + idx) + size); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - - -/** - * FIXME: TEST? - * Just a test - * @param robj - * @param data - * @param real_index - * @return - */ -int elfsh_get_dynent_by_type(elfshobj_t *robj, - elfsh_Dyn *data, - elfsh_Word real_index) -{ - elfsh_Dyn *ent; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ent = elfsh_get_dynamic_entry_by_type(robj, real_index); - idx = (int) ((char *) ent - (char *) data); - idx = idx / sizeof(elfsh_Dyn); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/dynsym.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/dynsym.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/dynsym.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/dynsym.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,417 +0,0 @@ -/** - * @file dynsym.c - * @ingroup libelfsh -** Dynsym.c for libelfsh -** -** Started on Mon Feb 26 04:13:29 2001 jfv -** -** -** $Id: dynsym.c,v 1.21 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Return the dynsymbol name giving its index in the dynamic symbol string table - * @param file - * @param s - * @return - */ -char *elfsh_get_dynsymbol_name(elfshobj_t *file, elfsh_Sym *s) -{ - char *ret; - void *rdata; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - if (file->secthash[ELFSH_SECTION_DYNSYM] == NULL) - if (NULL == elfsh_get_dynsymtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", NULL); - - rdata = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); - ret = (char *) rdata + s->st_name; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Return the used offset in .dynstr or -1 if failed - * @param file - * @param s - * @param name - * @return - */ -int elfsh_set_dynsymbol_name(elfshobj_t *file, - elfsh_Sym *s, char *name) -{ - char *str; - u_int len; - u_int new_len; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || s == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (file->secthash[ELFSH_SECTION_DYNSYM] == NULL && - elfsh_get_dynsymtab(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive symbol table", -1); - - /* Else use the symbol string table */ - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); - if (file->secthash[ELFSH_SECTION_DYNSTR] == NULL || - data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSTR", NULL); - - /* Change the name */ - str = (char *) file->secthash[ELFSH_SECTION_DYNSTR]->data; - str += s->st_name; - len = strlen(str); - new_len = strlen(name); - - /* Do not allocate new place if possible */ - if (len >= new_len) - strcpy(str, name); - /* Append the name to .strtab */ - else - s->st_name = elfsh_insert_in_dynstr(file, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->st_name)); -} - - - - - - -/** - * Return a ptr on the dynamic symbol table num is filled with the entries total number - * @param file - * @param num - * @return - */ -void *elfsh_get_dynsymtab(elfshobj_t *file, int *num) -{ - elfshsect_t *newent; - int strindex; - int nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - //fprintf(stderr, "Calling get_dynsymtab ! \n"); - - /* Load the .dynsym */ - if (file->secthash[ELFSH_SECTION_DYNSYM] == NULL) - { - newent = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_ALTDYNSYM, - NULL, &strindex, &nbr); - if (newent == NULL) - { - newent = elfsh_get_section_by_type(file, SHT_DYNSYM, 0, - NULL, &strindex, &nbr); - if (newent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM by type", NULL); - } - - newent->data = elfsh_load_section(file, newent->shdr); - if (newent->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load DYNSYM", NULL); - file->secthash[ELFSH_SECTION_DYNSYM] = newent; - - /* Endianize table */ - elfsh_endianize_symtab(newent); - - /* Now retreive the dynamic symbol string table .dynstr */ - newent = elfsh_get_section_by_index(file, strindex, NULL, &nbr); - if (newent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSTR by index", NULL); - - newent->data = elfsh_load_section(file, newent->shdr); - if (newent->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load DYNSTR", NULL); - - file->secthash[ELFSH_SECTION_DYNSTR] = newent; - - /* Fixup the dynamic symbol table */ - elfsh_fixup_dynsymtab(file->secthash[ELFSH_SECTION_DYNSYM]); - - /* Sort the table */ - elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_DYNSYM]); - newent->curend = newent->shdr->sh_size; - } - - /* - fprintf(stderr, "dynsym curend = %u (%u entries) shsize = %u (%u entries) \n", - file->secthash[ELFSH_SECTION_DYNSYM]->curend, - file->secthash[ELFSH_SECTION_DYNSYM]->curend / sizeof(elfsh_Sym), - file->secthash[ELFSH_SECTION_DYNSYM]->shdr->sh_size, - file->secthash[ELFSH_SECTION_DYNSYM]->shdr->sh_size / sizeof(elfsh_Sym)); - */ - - nbr = - file->secthash[ELFSH_SECTION_DYNSYM]->curend ? - file->secthash[ELFSH_SECTION_DYNSYM]->curend / sizeof(elfsh_Sym) : - file->secthash[ELFSH_SECTION_DYNSYM]->shdr->sh_size / sizeof(elfsh_Sym); - - if (num != NULL) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Get symtab entry by vaddr - * @param file - * @param vaddr - * @param off - * @param mode - * @return - */ -elfsh_Sym *elfsh_get_dynsymbol_by_value(elfshobj_t *file, - eresi_Addr vaddr, - int *off, - int mode) -{ - int num; - elfsh_Sym *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_dynsymtab(file, &num); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive DYNSYM", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_sym_by_value(data, num, vaddr, off, mode))); -} - - -/** - * Return the dynamic symbol name giving its value, - * Fill 'offset' with the difference between sym->st_value and 'value' - * - * @param file - * @param value - * @param offset - * @return - */ -char *elfsh_reverse_dynsymbol(elfshobj_t *file, - eresi_Addr value, - elfsh_SAddr *offset) -{ - elfshsect_t *sect; - elfsh_Sym *sorted; - int num; - int index; - char *str; - elfsh_Sym *pltsym; - elfshsect_t *plt; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (!value || value == (eresi_Addr) -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (offset) - *offset = 0; - - /* If there is no symtab, resolve using SHT */ - if (elfsh_get_dynsymtab(file, &num) == NULL) - { - sect = elfsh_get_parent_section(file, value, offset); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No parent section", NULL); - - /* handle dynamic case */ - if (elfsh_is_debug_mode()) - value -= file->rhdr.base; - - if (offset) - *offset = (elfsh_SAddr) (sect->shdr->sh_addr - value); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_section_name(file, sect))); - } - - /* Else use the sorted-by-address symbol table to match what we want */ - if (file->secthash[ELFSH_SECTION_DYNSYM]->altdata == NULL) - elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_DYNSYM]); - sorted = (elfsh_Sym *) file->secthash[ELFSH_SECTION_DYNSYM]->altdata; - - /* Restore dynsym if pointing inside PLT and we did not find it */ - plt = file->secthash[ELFSH_SECTION_PLT]; - sect = elfsh_get_parent_section(file, value, offset); - if (plt && sect && sect->name && !strcmp(sect->name, ELFSH_SECTION_NAME_PLT)) - { - pltsym = elfsh_restore_dynsym(file, plt, *offset, - file->secthash[ELFSH_SECTION_DYNSYM]); - if (pltsym) - { - *offset = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_dynsymbol_name(file, pltsym))); - } - } - - /* handle dynamic case */ - if (elfsh_is_debug_mode()) - value -= file->rhdr.base; - - /* Else look in the table */ - for (index = 0; index < num; index++) - if (sorted[index].st_value <= value && DUMPABLE(sorted + index) && - (index + 1 >= num || sorted[index + 1].st_value > value)) - { - - if (offset) - *offset = (elfsh_SAddr) (value - sorted[index].st_value); - str = elfsh_get_dynsymbol_name(file, sorted + index); - if (!*str) - str = NULL; - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str)); - } - - /* Not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No valid symbol interval", NULL); -} - - -/** - * Return the symbol entry giving its name - * @param file target file - * @param name dynamic symbol name - * @return symbol pointer or NULL - */ -elfsh_Sym *elfsh_get_dynsymbol_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - int idx; - int size = 0; - char *actual; - elfshsect_t *sect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check arguments */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - sym = (elfsh_Sym *) elfsh_get_dynsymtab(file, &size); - - /* Check DYNSYM section data pointer */ - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", NULL); - - sect = file->secthash[ELFSH_SECTION_DYNSYM]; - - /* Check DYNSYM section pointer */ - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM section pointer", NULL); - - if (file->dynsymhash.ent) - { - /* idx is the symbol number in the section */ - idx = (int) hash_get(&file->dynsymhash, name); - -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] DYNSYM HASH Search by name for %s => %d\n", - name, idx); -#else - /* Check if idx is in the section */ - if (idx <= 0 || idx >= sect->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); -#endif - } - - for (idx = 0; idx < size; idx++) - { - actual = elfsh_get_dynsymbol_name(file, sym + idx); - if (actual && !strcmp(actual, name)) - { -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] DYNSYM ITERATE Search by name for %s => %d\n", - name, idx); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); - } - } - -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] DYNSYM ITERATE Search by name for %s => NOT FOUND\n", name); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); -} - - - -/** - * Shift the dynamic symbol table, mostly useful on ET_DYN objects - * @param file - * @param limit - * @param inc - * @return - */ -int elfsh_shift_dynsym(elfshobj_t *file, eresi_Addr limit, int inc) -{ - elfshsect_t *actual; - int err; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - actual = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_ALTDYNSYM, - NULL, NULL, NULL); - if (!actual) - { - actual = elfsh_get_section_by_type(file, SHT_DYNSYM, 0, NULL, NULL, NULL); - if (actual == NULL || actual->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find DYNSYM by type", -1); - } - - err = elfsh_shift_syms(file, actual, limit, inc); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to shift DYNSYM", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/elf.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/elf.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/elf.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/elf.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,931 +0,0 @@ -/** - * @file elf.c - * @ingroup libelfsh -** elf.c for libelfsh -** -** Started on Mon Feb 26 04:09:38 2001 jfv -** Last update Mon Apr 21 20:58:41 2003 jfv -** -** $Id: elf.c,v 1.19 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Change the ELF header flags field - * @param hdr - * @param flags - * @return - */ -int elfsh_set_flags(elfsh_Ehdr *hdr, eresi_Addr flags) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_flags = (elfsh_Word) flags; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the ELF header flags field - * @param hdr - * @return - */ -elfsh_Word elfsh_get_flags(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Word) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_flags)); -} - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -int elfsh_set_shtoff(elfsh_Ehdr *hdr, eresi_Addr off) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_shoff = (elfsh_Off) off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -elfsh_Off elfsh_get_shtoff(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_shoff)); -} - - -/** - * Change the section header table entry count - * @param hdr - * @param num - * @return - */ -int elfsh_set_shtnbr(elfsh_Ehdr *hdr, eresi_Addr num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_shnum = (elfsh_Half) num; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table entry count - * @param hdr - * @return - */ -elfsh_Half elfsh_get_shtnbr(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_shnum)); -} - - -/** - * Change the program header table file offset - * @param hdr - * @param num - * @return - */ -int elfsh_set_phtoff(elfsh_Ehdr *hdr, eresi_Addr num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_phoff = (elfsh_Off) num; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the program header table file offset - * @param hdr - * @return - */ -elfsh_Off elfsh_get_phtoff(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_phoff)); -} - -/** - * Change the program header table file offset - * @param hdr - * @param num - * @return - */ -int elfsh_set_rphtoff(elfsh_Ehdr *hdr, eresi_Addr num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - *((elfsh_Off *) hdr->e_ident + EI_RPHT) = (elfsh_Off) num; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the program header table file offset - * @param hdr - * @return - */ -elfsh_Off elfsh_get_rphtoff(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Off) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (*(elfsh_Off *) hdr->e_ident + EI_RPHT)); -} - -/** - * Change the program header table entry count - * @param hdr - * @param num - * @return - */ -int elfsh_set_phtnbr(elfsh_Ehdr *hdr, eresi_Addr num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_phnum = (elfsh_Half) num; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the program header table entry count - * @param hdr - * @return - */ -elfsh_Half elfsh_get_phtnbr(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_phnum)); -} - -/** - * Change the program entry point - * @param hdr - * @param addr - * @return - */ -int elfsh_set_entrypoint(elfsh_Ehdr *hdr, eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_entry = addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the program entry point - * @param hdr - * @return - */ -eresi_Addr elfsh_get_entrypoint(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (eresi_Addr) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_entry)); -} - -/** - * Return the machine type giving its e_arch field - * @param hdr - * @param num - * @return - */ -elfsh_Half elfsh_get_arch(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_machine)); -} - -/** - * Change the machine type e_arch field - * @param hdr - * @param val - * @return - */ -u_int elfsh_set_arch(elfsh_Ehdr *hdr, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - hdr->e_machine = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the ELF object type giving its e_type field - * @param hdr - * @return - */ -elfsh_Half elfsh_get_objtype(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_type)); -} - -/** - * Return the ELF object type giving its e_type field - * @param e - * @param val - * @return - */ -u_int elfsh_set_objtype(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - e->e_type = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the ELF section string table index field - * @param e - * @return - */ -elfsh_Half elfsh_get_shstrtab_index(elfsh_Ehdr *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (e->e_shstrndx)); -} - -/** - * Set the ELF section string table index field - * @param e - * @param val - * @return - */ -u_int elfsh_set_shstrtab_index(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", (u_int) -1); - e->e_shstrndx = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Change the e_version flag - * @param e - * @param val - * @return - */ -u_int elfsh_set_version(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - e->e_version = (elfsh_Word) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Read the version flags - * @param e - * @return - */ -elfsh_Word elfsh_get_version(elfsh_Ehdr *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Word) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (e->e_version)); -} - -/** - * Change the ELF header size field - * @param e - * @param val - * @return - */ -u_int elfsh_set_ehsize(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - e->e_ehsize = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the ELF header size field - * @param e - * @return - */ -elfsh_Half elfsh_get_ehsize(elfsh_Ehdr *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (e->e_ehsize)); -} - -/** - * Change the Program Header Entry size field - * @param e - * @param val - * @return - */ -u_int elfsh_set_phentsize(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - e->e_phentsize = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the Program Header Entry size field - * @param e - * @return - */ -elfsh_Half elfsh_get_phentsize(elfsh_Ehdr *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (e->e_phentsize)); -} - -/** - * Change the Section Header Entry size field - * @param e - * @param val - * @return - */ -u_int elfsh_set_shentsize(elfsh_Ehdr *e, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (u_int) -1); - e->e_shentsize = (elfsh_Half) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the Section Header Entry size field - * @param e - * @return - */ -elfsh_Half elfsh_get_shentsize(elfsh_Ehdr *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (elfsh_Half) -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (e->e_shentsize)); -} - - -/** - * Return the encoding type - * @param hdr - * @return - */ -int elfsh_get_encoding(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_ident[EI_DATA])); -} - -/** - * Change the encoding (little endian, big endian, or else) - * @param hdr - * @param type - * @return - */ -int elfsh_set_encoding(elfsh_Ehdr *hdr, eresi_Addr type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_ident[EI_DATA] = (u_char) type; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the magic - * @param hdr - * @return - */ -int elfsh_get_magic(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (hdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*(u_int *) hdr->e_ident)); -} - -/** - * Change the magic - * @param hdr - * @param mag - * @return - */ -int elfsh_set_magic(elfsh_Ehdr *hdr, eresi_Addr mag) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (hdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - *(u_int *) hdr->e_ident = (u_int) mag; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the class - * @param hdr - * @return - */ -int elfsh_get_class(elfsh_Ehdr *hdr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (hdr->e_ident[EI_CLASS])); -} - -/** - * Change the class - * @param hdr - * @param eclass - * @return - */ -int elfsh_set_class(elfsh_Ehdr *hdr, eresi_Addr eclass) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - hdr->e_ident[EI_CLASS] = (u_char) eclass; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Endianize ELF header - * @param e - * @param byteorder - * @return - */ -void elfsh_endianize_elfhdr(elfsh_Ehdr *e, char byteorder) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (byteorder == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (byteorder == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - e->e_type = swap16(e->e_type); - e->e_machine = swap16(e->e_machine); - e->e_version = swap32(e->e_version); - e->e_entry = swaplong(e->e_entry); - e->e_phoff = swaplong(e->e_phoff); - e->e_shoff = swaplong(e->e_shoff); - e->e_flags = swap32(e->e_flags); - e->e_ehsize = swap16(e->e_ehsize); - e->e_phentsize = swap16(e->e_phentsize); - e->e_phnum = swap16(e->e_phnum); - e->e_shentsize = swap16(e->e_shentsize); - e->e_shnum = swap16(e->e_shnum); - e->e_shstrndx = swap16(e->e_shstrndx); - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Sanity check of header type - * @param file - * @return - */ -int elfsh_check_hdr_type(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (file->hdr->e_type) - { - case ET_NONE: break; - case ET_REL: break; - case ET_EXEC: break; - case ET_DYN: break; - case ET_CORE: break; - default: - file->hdr->e_type = ET_NONE; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_type is not valid", NULL); - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Sanity check of machin type - * @param file - * @return - */ -int elfsh_check_hdr_machine(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /** /usr/include/elf.h e_machine may be > 18. - * disabling this check for the moment. - if (file->hdr->e_machine > 16) { - file->hdr->e_machine = ET_NONE; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_machine is not valid", NULL); - } - */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Sanity check of version value - * @param file - * @return - */ -int elfsh_check_hdr_version(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_version != EV_CURRENT) - { - file->hdr->e_version = EV_CURRENT; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_version is not valid", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Sanity check of phoff value - * @param file - * @return - */ -int elfsh_check_hdr_phoff(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_phoff > (elfsh_Off) file->fstat.st_size) - { - file->hdr->e_phoff = ET_NONE; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_phoff > file length", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Sanity check of shoff value - * @param file - * @return - */ -int elfsh_check_hdr_shoff(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_shoff > (elfsh_Off) file->fstat.st_size) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_shoff > file length", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * perform some sanity checks on ELF header - * @param file - * @return - */ -int elfsh_check_hdr(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_check_hdr_type(file); - elfsh_check_hdr_machine(file); - elfsh_check_hdr_version(file); - elfsh_check_hdr_phoff(file); - elfsh_check_hdr_shoff(file); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Load the ELF header - * @param file - * @return - */ -int elfsh_load_hdr(elfshobj_t *file) -{ - int len; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sizeof(elfsh_Ehdr))); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, sizeof(elfsh_Ehdr), -1); - file->hdr = (elfsh_Ehdr *) data; - if ((len = read(file->fd, file->hdr, sizeof(elfsh_Ehdr))) <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, (char *)PROFILER_ERRORS_ARRAY, - len); - - if (config_safemode() && (!file->hdr->e_shnum)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_shnum is not valid", -1); - - if (config_safemode() && (!file->hdr->e_shentsize && (file->hdr->e_type != ET_CORE))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "file->hdr->e_shentsize is not valid", -1); - - elfsh_endianize_elfhdr(file->hdr, file->hdr->e_ident[EI_DATA]); - - /* If we are in safe mode, we check the ELF header */ - if (config_safemode()) - elfsh_check_hdr(file); - -#if defined(ERESI32) - if (file->hdr->e_ident[EI_CLASS] != ELFCLASS32) -#elif defined(ERESI64) - if (file->hdr->e_ident[EI_CLASS] != ELFCLASS64) -#endif - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Wrong ELFsh configuration for this ELF class", - -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (len)); -} - -/** - * Return a ptr on the ELF header (load it before if not done yet) - * @param file - * @return - */ -void *elfsh_get_hdr(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->hdr)); - else if (elfsh_load_hdr(file) <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load ELF header", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->hdr)); -} - - -/** - * - * @param file - * @return 1 if the file is static or dynamic - */ -int elfsh_static_file(elfshobj_t *file) -{ - elfsh_Phdr *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - p = elfsh_get_segment_by_type(file, PT_DYNAMIC, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p ? 0 : 1)); -} - -/** - * @param file - * @return 1 if the file is dynamic - */ -int elfsh_dynamic_file(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (!elfsh_static_file(file))); -} - -/** - * Get notes section from core - * @param file - * @return - */ -int elfsh_get_core_notes(elfshobj_t *file) -{ - elfsh_Nhdr nhdr; - - int i, offset, filesz, - j, namesz, descsz; - int pos; - char name[18]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->pht == NULL) - elfsh_load_pht(file); - - for (i = 0; i != file->hdr->e_phnum; i++) - { - if (elfsh_get_segment_type(&file->pht[i]) == PT_NOTE) - { - offset = elfsh_get_segment_offset(&file->pht[i]); - filesz = elfsh_get_segment_filesz(&file->pht[i]); - - if(lseek(file->fd, offset, SEEK_SET) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - pos = lseek(file->fd, 0L, SEEK_CUR); - - for(j = 0; pos < offset + filesz; j++) - { - if(read(file->fd, &nhdr, sizeof(nhdr)) != sizeof(nhdr)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - namesz = elfsh_roundup(nhdr.n_namesz, 4); - descsz = elfsh_roundup(nhdr.n_descsz, 4); - - if(namesz > 16) continue; - - if(read(file->fd, name, namesz) != namesz) - break; - name[namesz] = 0; - - switch(elfsh_get_ostype(file)) - { - case ELFSH_OS_LINUX: - file->coretype = ELFSH_CORE_LINUX; - file->core.filesz = filesz; - break; - case ELFSH_OS_FREEBSD: - file->coretype = ELFSH_CORE_FREEBSD; - file->bsdcore.filesz = filesz; - break; - } - - switch(nhdr.n_type) - { - case NT_PRPSINFO: - if(file->coretype == ELFSH_CORE_FREEBSD) - { - if(read(file->fd, &file->bsdcore.prpsinfo, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->bsdcore.flags |= ELFSH_CORE_HAS_PRPSINFO; - } - else - { - if(read(file->fd, &file->core.prpsinfo, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->core.flags |= ELFSH_CORE_HAS_PRPSINFO; - } - break; - case NT_PRSTATUS: - if(file->coretype == ELFSH_CORE_FREEBSD) - { - if(read(file->fd, &file->bsdcore.prstatus, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->bsdcore.flags |= ELFSH_CORE_HAS_PRSTATUS; - } - else - { - if(read(file->fd, &file->core.prstatus, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->core.flags |= ELFSH_CORE_HAS_PRSTATUS; - } - break; - case NT_FPREGSET: - if(file->coretype == ELFSH_CORE_FREEBSD) - { - if(read(file->fd, &file->bsdcore.fpregs, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->bsdcore.flags |= ELFSH_CORE_HAS_FPREGSET; - } - else - { - if(read(file->fd, &file->core.fpregs, descsz) != descsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - file->core.flags |= ELFSH_CORE_HAS_FPREGSET; - } - break; - case NT_AUXV: /* TODO: figure out how use this data in a auxv vector */ - // if (read(file->fd, &file->core.auxv, descsz) != descsz) - // PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - case NT_TASKSTRUCT: - case NT_PLATFORM: - case NT_GWINDOWS: - case NT_ASRS: - case NT_PSTATUS: - case NT_PRCRED: - case NT_UTSNAME: - case NT_LWPSTATUS: - case NT_LWPSINFO: - case NT_PRFPXREG: - default: break; - } - pos = lseek(file->fd, 0L, SEEK_CUR); - } - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/extplt.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/extplt.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/extplt.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/extplt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,618 +0,0 @@ -/** - * @file extplt.c - * @ingroup libelfsh - * extplt.c for libelfsh - * - * This file contain the architecture -dependant- code - * for the EXTPLT technique (unknown symbol resolution) - * - * Started on Wed Jun 12 21:20:07 2005 mm - * - * $Id: extplt.c,v 1.20 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -/** - * Add a new entry on ALTVERSYM (.elfsh.version) - * @param file elfsh object. - * @param versym section pointer of target section - * @param name function name - */ -int elfsh_extplt_expand_versym(elfshobj_t *file, elfshsect_t *versym, char *name) -{ - elfsh_Verneed *verneed; - elfsh_Verdef *sym_verdef; - elfsh_Vernaux *auxneed; - elfshobj_t *sym_file; - char *filename; - size_t len; - u_int index; - elfsh_Half *ent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !versym || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Parameters", -1); - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) != ELFSH_OS_LINUX) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Search the correct file using hash version section - as every linker should do */ - sym_file = elfsh_hash_getfile_def(file, name); - if (!sym_file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find a file for this function", -1); - - if (sym_file->id == file->id) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Same file for def", -1); - - /* We search the filename (we have a path) */ - len = strlen(sym_file->name); - filename = sym_file->name; - - for (index = len; index > 0; index--) - if (sym_file->name[index] == '/') - break; - - if (INTERVAL(0, index+1, len)) - filename = sym_file->name + index + 1; - - /* Retrieve symbol verdef/verneed pointer */ - verneed = elfsh_get_verneed_by_name(file, filename); - sym_verdef = elfsh_hash_getdef(sym_file, name, NULL, 0); - - if (!verneed || !sym_verdef) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find version definition / need for this symbol", -1); - - /* If we have a good entry we just have to add a symbol, else we should create a new - verneed entry linked with verdef references */ - auxneed = elfsh_check_defneed_eq(file, sym_file, verneed, sym_verdef); - if (auxneed == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find equivalence between def and need", -1); - - /* Add an entry */ - ent = versym->data + versym->curend; - *ent = (elfsh_Half) auxneed->vna_other & 0x7fff; - versym->curend += sizeof(elfsh_Half); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Add a new entry on ALTHASH (.elfsh.hash) - * @param file - * @param hash section pointer of target section - * @param dynsym - * @param name function name - */ -int elfsh_extplt_expand_hash(elfshobj_t *file, elfshsect_t *hash, - elfshsect_t *dynsym, char *name) -{ - elfsh_Word strhash; - elfsh_Word nchain; - elfsh_Word nbucket; - elfsh_Word *bucket; - elfsh_Word *chain; - elfsh_Word symid; - elfsh_Word index; - elfsh_Word symindex; - void *data; - u_char set = 0; - elfsh_Sym *ret; - int size = 0; - char *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !hash || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Parameters", -1); - - /* Dynsym data & size */ - ret = elfsh_get_raw(dynsym); - - size = dynsym->curend ? dynsym->curend / sizeof(elfsh_Sym) : - dynsym->shdr->sh_size / sizeof(elfsh_Sym); - - if (ret == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", -1); - - /* Find current symbol index */ - for (symindex = 0; symindex < size; symindex++) - { - actual = elfsh_get_dynsymbol_name(file, ret + symindex); - if (actual && !strcmp(actual, name)) - break; - } - - if (symindex >= size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find dynamic symbol by name", -1); - - /* Hash pointer */ - data = elfsh_get_raw(hash); - - /* Get bucket & chain pointers */ - bucket = elfsh_get_hashbucket(data); - chain = elfsh_get_hashchain(data); - - /* Get parts numbers */ - nchain = elfsh_get_hashnchain(data); - nbucket = elfsh_get_hashnbucket(data); - - strhash = elfsh_get_symbol_hash(name); - - /* Loop */ - for (index = bucket[strhash % nbucket]; index < nchain; index = symid) - { - symid = chain[index]; - - if (symid == STN_UNDEF) - { - /* Set our symbol @ tail. Next element undefine */ - elfsh_set_hashchain_value(&chain[index], symindex); - chain[symindex] = STN_UNDEF; - set = 1; - break; - } - } - - if (set == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Chain end not found", -1); - - /* Update chain number */ - *(((elfsh_Word *) data)+1) += 1; - hash->curend += sizeof(elfsh_Word); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * When performing EXTPLT technique, we need to mirror some sections - * if we want to be able to extend them : .rel(a).{got,dyn,plt}, .dynsym, .dynstr - * @param file - */ -int elfsh_extplt_mirror_sections(elfshobj_t *file) -{ - elfshsect_t *dynsym; - elfshsect_t *dynstr; - elfshsect_t *relplt; - elfshsect_t *versym = NULL; - elfshsect_t *hash; - elfshsect_t *dynamic; - elfshsect_t *enew; - elfsh_Dyn *dynent; - elfsh_Dyn *versyment; - elfsh_Dyn *hashent; - elfshsect_t *relgot; - char *data; - char *name; - char *relgotname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Grab needed pointers */ - dynsym = file->secthash[ELFSH_SECTION_DYNSYM]; - dynstr = file->secthash[ELFSH_SECTION_DYNSTR]; - dynamic = file->secthash[ELFSH_SECTION_DYNAMIC]; - hash = file->secthash[ELFSH_SECTION_HASH]; - - if (!dynsym || !dynstr || !dynamic || !hash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Call ALTPLT (elfsh_copy_plt) first", -1); - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) == ELFSH_OS_LINUX) - { - versym = file->secthash[ELFSH_SECTION_GNUVERSYM]; - - if (!versym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Call ALTPLT (elfsh_copy_plt) first", -1); - } - - /* grab relocation tables */ - name = (FILE_IS_SPARC(file) ? ELFSH_SECTION_NAME_RELAPLT : ELFSH_SECTION_NAME_RELPLT); - relplt = elfsh_get_section_by_name(file, name, 0, 0, 0); - if (!relplt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find PLT relocation table", -1); - - /* Pretty ugly code that needs to be cleaned up in a separate function */ - relgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RELGOT, 0, 0, 0); - if (!relgot) - { - relgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RELDYN, 0, 0, 0); - if (!relgot) - { - relgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RELABSS, 0, 0, 0); - if (!relgot) - { - relgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RELADYN, 0, 0, 0); - relgotname = ELFSH_SECTION_NAME_ALTRELADYN; - } - else - relgotname = ELFSH_SECTION_NAME_ALTRELBSS; - } - else - relgotname = ELFSH_SECTION_NAME_ALTRELDYN; - } - else - relgotname = ELFSH_SECTION_NAME_ALTRELGOT; - - fprintf(stderr, "found relgotname = %s \n", relgotname); - - - /* Copy a double sized .dynsym somewhere else */ - enew = elfsh_insert_section(file, ELFSH_SECTION_NAME_ALTDYNSYM, NULL, - ELFSH_DATA_INJECTION, dynsym->shdr->sh_size * 4, - sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTDYNSYM", -1); - enew->shdr->sh_entsize = sizeof(elfsh_Sym); - data = elfsh_get_raw(enew); - - /* Take the fixed ondisk version of dynsym as original data */ - memcpy(data, dynsym->data, dynsym->shdr->sh_size); - - dynent = elfsh_get_dynamic_entry_by_type(file, DT_SYMTAB); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_SYMTAB", -1); - elfsh_set_dynentry_val(dynent, enew->shdr->sh_addr); - enew->curend = dynsym->shdr->sh_size; - enew->shdr->sh_type = dynsym->shdr->sh_type; - file->secthash[ELFSH_SECTION_DYNSYM] = enew; - elfsh_sync_sorted_symtab(enew); - - /* Same for dynstr */ - enew = elfsh_insert_section(file, ELFSH_SECTION_NAME_ALTDYNSTR, NULL, - ELFSH_DATA_INJECTION, dynstr->shdr->sh_size * 2, - sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTDYNSTR", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(dynstr), dynstr->shdr->sh_size); - - dynent = elfsh_get_dynamic_entry_by_type(file, DT_STRTAB); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_STRTAB", -1); - elfsh_set_dynentry_val(dynent, enew->shdr->sh_addr); - enew->curend = dynstr->shdr->sh_size; - enew->shdr->sh_type = dynstr->shdr->sh_type; - file->secthash[ELFSH_SECTION_DYNSTR] = enew; - - /* Cross references those last 2 sections */ - elfsh_set_section_link(file->secthash[ELFSH_SECTION_DYNSYM]->shdr, enew->index); - elfsh_set_section_link(enew->shdr, file->secthash[ELFSH_SECTION_DYNSYM]->index); - - /* Same for .rel.got, if relgot is NULL then there is no .rel.got, its not an error */ - if (relgot) - { - enew = elfsh_insert_section(file, relgotname, NULL, ELFSH_DATA_INJECTION, - relgot->shdr->sh_size, sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTRELGOT", -1); - - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(relgot), relgot->shdr->sh_size); - dynent = elfsh_get_dynamic_entry_by_type(file, IS_REL(dynamic) ? DT_REL : DT_RELA); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_REL", -1); - elfsh_set_dynentry_val(dynent, enew->shdr->sh_addr); - enew->curend = relgot->shdr->sh_size; - enew->shdr->sh_type = relgot->shdr->sh_type; - enew->shdr->sh_link = file->secthash[ELFSH_SECTION_DYNSYM]->index; - enew->shdr->sh_entsize = IS_REL(dynamic) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela); - } - - /* Same for .rel.plt */ - enew = elfsh_insert_section(file, ELFSH_SECTION_NAME_ALTRELPLT, NULL, - ELFSH_DATA_INJECTION, relplt->shdr->sh_size * 4, - sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTRELPLT", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(relplt), relplt->shdr->sh_size); - dynent = elfsh_get_dynamic_entry_by_type(file, DT_JMPREL); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_RELPLT", -1); - elfsh_set_dynentry_val(dynent, enew->shdr->sh_addr); - enew->curend = relplt->shdr->sh_size; - enew->shdr->sh_type = relplt->shdr->sh_type; - enew->shdr->sh_link = file->secthash[ELFSH_SECTION_DYNSYM]->index; - enew->shdr->sh_entsize = IS_REL(dynamic) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela); - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) == ELFSH_OS_LINUX) - { - /* Same for .gnu.version */ - enew = elfsh_insert_section(file, ELFSH_SECTION_NAME_ALTVERSYM, NULL, - ELFSH_DATA_INJECTION, versym->shdr->sh_size * 4, - sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTVERSYM", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(versym), versym->shdr->sh_size); - - enew->curend = versym->shdr->sh_size; - enew->shdr->sh_type = versym->shdr->sh_type; - enew->shdr->sh_link = file->secthash[ELFSH_SECTION_GNUVERSYM]->index; - enew->shdr->sh_entsize = sizeof(elfsh_Half); - file->secthash[ELFSH_SECTION_VERSYM] = enew; - - /* Redirect on .dynamic section */ - versyment = elfsh_get_dynamic_entry_by_type(file, DT_VERSYM); - if (!versyment) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_VERSYM", -1); - elfsh_set_dynentry_val(versyment, enew->shdr->sh_addr); - } - - /* Same for .hash */ - enew = elfsh_insert_section(file, ELFSH_SECTION_NAME_ALTHASH, NULL, - ELFSH_DATA_INJECTION, hash->shdr->sh_size * 4, - sizeof(eresi_Addr)); - if (!enew) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ALTHASHM", -1); - data = elfsh_get_raw(enew); - memcpy(data, elfsh_get_raw(hash), hash->shdr->sh_size); - - enew->curend = hash->shdr->sh_size; - enew->shdr->sh_type = hash->shdr->sh_type; - enew->shdr->sh_link = file->secthash[ELFSH_SECTION_HASH]->index; - enew->shdr->sh_entsize = sizeof(elfsh_Word); - file->secthash[ELFSH_SECTION_HASH] = enew; - - /* Redirect on .dynamic section */ - hashent = elfsh_get_dynamic_entry_by_type(file, DT_HASH); - if (!hashent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_HASH", -1); - elfsh_set_dynentry_val(hashent, enew->shdr->sh_addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Insert a new function entry point for dynamic resolution - * Return the symbol pointing on this new definition (its .plt entry) - * - * @param file - * @param name - * @return - */ -elfsh_Sym *elfsh_request_pltent(elfshobj_t *file, char *name) -{ - u_int sz; - elfshsect_t *relplt; - elfshsect_t *extplt; - elfshsect_t *altgot; - elfshsect_t *dynsym; - elfshsect_t *dynstr; - elfshsect_t *altversym = NULL; - elfshsect_t *althash; - u_int relentsz; - elfsh_Sym sym; - u_int len; - elfsh_Dyn *dynent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - len = strlen(name); - - // This information is not always interering, add it when you need it - // add a DEBUG_ define, but do not commit uncommented. - //fprintf(stderr, "Requesting a new PLT entry for symbol %s \n", name); - - /* Get needed sections */ - extplt = file->secthash[ELFSH_SECTION_EXTPLT]; - if (!extplt) - { - extplt = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_EXTPLT, - NULL, NULL, NULL); - if (extplt == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "EXTPLT not found : Copy PLT first", NULL); - file->secthash[ELFSH_SECTION_EXTPLT] = extplt; - } - - relplt = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_ALTRELPLT, - 0, 0, 0); - if (!relplt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find RELPLT section", NULL); - - altgot = file->secthash[ELFSH_SECTION_ALTGOT]; - if (!altgot) - { - altgot = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_ALTGOT, - NULL, NULL, NULL); - if (!altgot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTGOT not found : Copy PLT first", NULL); - file->secthash[ELFSH_SECTION_ALTGOT] = altgot; - } - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) == ELFSH_OS_LINUX) - { - altversym = file->secthash[ELFSH_SECTION_VERSYM]; - if (!altversym) - { - altversym = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_VERSYM, - NULL, NULL, NULL); - file->secthash[ELFSH_SECTION_VERSYM] = altversym; - } - } - - althash = file->secthash[ELFSH_SECTION_HASH]; - if (!althash) - { - althash = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HASH, - NULL, NULL, NULL); - if (!althash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTHASH not found : Copy HASH first", NULL); - file->secthash[ELFSH_SECTION_HASH] = althash; - } - - dynsym = file->secthash[ELFSH_SECTION_DYNSYM]; - if (!dynsym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find DYNSYM section", NULL); - dynstr = file->secthash[ELFSH_SECTION_DYNSTR]; - if (!dynstr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find DYNSTR section", NULL); - - /* Check room inside sections */ - sz = elfsh_get_pltentsz(file); - if (extplt->curend + sz > extplt->shdr->sh_size) - { - if (extplt->shdr->sh_offset + extplt->curend + sz < - extplt->next->shdr->sh_offset) - extplt->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in EXTPLT", NULL); - } - - relentsz = IS_REL(extplt) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela); - if (relplt->curend + relentsz > relplt->shdr->sh_size) - { - if (relplt->shdr->sh_offset + relplt->curend + sz < - relplt->next->shdr->sh_offset) - relplt->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in RELPLT copy", NULL); - } - - if (dynsym->curend + sizeof(elfsh_Sym) > dynsym->shdr->sh_size) - { - if (dynsym->shdr->sh_offset + dynsym->curend + sz < - dynsym->next->shdr->sh_offset) - dynsym->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in DYNSYM copy", NULL); - } - if (dynstr->curend + len > dynstr->shdr->sh_size) - { - if (dynstr->shdr->sh_offset + dynstr->curend + sz < - dynstr->next->shdr->sh_offset) - dynstr->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in DYNSTR copy", NULL); - } - if (altgot->curend + sizeof(eresi_Addr) > altgot->shdr->sh_size) - { - if (altgot->shdr->sh_offset + altgot->curend + sz < - altgot->next->shdr->sh_offset) - altgot->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in ALTGOT", NULL); - } - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) == ELFSH_OS_LINUX && altversym) - { - if (altversym->curend + sizeof(elfsh_Half) > altversym->shdr->sh_size) - { - if (altversym->shdr->sh_offset + altversym->curend + sz < - altversym->next->shdr->sh_offset) - altversym->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in ALTVERSYM", NULL); - } - } - if (althash->curend + sizeof(elfsh_Word) > althash->shdr->sh_size) - { - if (althash->shdr->sh_offset + althash->curend + sz < - althash->next->shdr->sh_offset) - althash->shdr->sh_size += sz; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No room anymore in ALTHASH", NULL); - } - - /* The EXTPLT hook will allocate a new relentry and gotentry */ - if (elfsh_extplt(extplt, altgot, dynsym, relplt) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to satisfy EXTPLT handler", NULL); - - /* Change RELPLT size in .dynamic */ - dynent = elfsh_get_dynamic_entry_by_type(file, DT_PLTRELSZ); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_PLTRELSZ", NULL); - elfsh_set_dynentry_val(dynent, elfsh_get_dynentry_val(dynent) + relentsz); - - /* Insert symbol referenced by previous injected reloc entry. - We do not indicate a link with EXTPLT section because an external symbol - should not be link on a local section or it will be resolv as a local symbol. */ - sym = elfsh_create_symbol(extplt->shdr->sh_addr + extplt->curend - elfsh_get_pltentsz(file), - elfsh_get_pltentsz(file), STT_FUNC, - 0, 0, 0); - sym.st_name = dynstr->curend; - elfsh_set_symbol_bind(&sym, STB_GLOBAL); - memcpy(elfsh_get_raw(dynsym) + dynsym->curend, &sym, sizeof(sym)); - dynsym->curend += sizeof(elfsh_Sym); - - /* Insert string referenced by the previous injected symbol */ - memcpy(elfsh_get_raw(dynstr) + dynstr->curend, name, len + 1); - dynstr->curend += len + 1; - elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_DYNSYM]); - - /* Change DYNSTR size in .dynamic */ - dynent = elfsh_get_dynamic_entry_by_type(file, DT_STRSZ); - if (!dynent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DT_STRSZ", NULL); - elfsh_set_dynentry_val(dynent, elfsh_get_dynentry_val(dynent) + len + 1); - - /* Versym expand is only for linux */ - if (elfsh_get_ostype(file) == ELFSH_OS_LINUX && altversym) - { - /* Insert version symbol */ - if (elfsh_extplt_expand_versym(file, altversym, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add an entry on ALTVERSYM", NULL); - } - - /* Expend .hash */ - if (elfsh_extplt_expand_hash(file, althash, dynsym, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add an entry on ALTHASH", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - elfsh_get_raw(dynsym) + dynsym->curend - sizeof(elfsh_Sym)); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/fixup.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/fixup.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/fixup.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/fixup.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,318 +0,0 @@ -/** - * @file fixup.c - * @ingroup libelfsh -** fixup.c for elfsh -** -** Started on Fri Jul 27 04:56:06 2001 jfv -** -** -** $Id: fixup.c,v 1.13 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * TERMINAL FUNCTION ! Fixup size for section symbols, if symtab doesnt exist, create it - * This function only works on FILE and is not e2dbg safe - * - * @param file - * @param strindex - * @return - */ -elfshsect_t *elfsh_fixup_symtab(elfshobj_t *file, int *strindex) -{ - elfshsect_t *symtab; - elfshsect_t *strtab; - elfshsect_t *got; - elfshsect_t *list; - elfshsect_t *parent; - elfsh_Shdr hdr; - elfsh_Sym newent; - elfsh_Sym *actual; - eresi_Addr startaddr; - u_int index; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Create symbol table if it does not exist */ - if (file->secthash[ELFSH_SECTION_SYMTAB] == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,symtab, sizeof (elfshsect_t), NULL); - hdr = elfsh_create_shdr(0, SHT_SYMTAB, 0, 0, 0, 0, 0, 0, 0, sizeof(elfsh_Sym)); - symtab->name = strdup(ELFSH_SECTION_NAME_SYMTAB); - - index = elfsh_insert_unmapped_section(file, symtab, hdr, NULL); - if (index < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert SYMTAB", NULL); - file->secthash[ELFSH_SECTION_SYMTAB] = symtab; - } - else - symtab = file->secthash[ELFSH_SECTION_SYMTAB]; - - /* Load strtab */ - strtab = elfsh_get_strtab(file, -1); - - elfsh_set_section_link(symtab->shdr, strtab->index); - if (strindex != NULL) - *strindex = strtab->index; - - /* Endianize symbol table */ - symtab->shdr->sh_entsize = sizeof(elfsh_Sym); - elfsh_endianize_symtab(symtab); - - /* Walk to the sht and fixup the symbol table */ - for (list = file->sectlist; list != NULL; list = list->next) - { - - /* Create STT_SECTION symbol if unexistant */ - actual = elfsh_get_sym_from_shtentry(file, list->shdr); - if (actual == NULL) - elfsh_insert_sectsym(file, list); - - /* Fixup STT_SECTION symbol */ - else - { - actual->st_size = list->shdr->sh_size; - str = elfsh_get_symbol_name(file, actual); - if (str == NULL || !*str) - actual->st_name = elfsh_insert_in_strtab(file, list->name); - } - } - - /* Fixup all 0 length non-section-typed symbols */ - actual = symtab->data; - for (index = 0; - index < symtab->shdr->sh_size / sizeof(elfsh_Sym); - index++, actual++) - if (elfsh_get_symbol_type(actual) != STT_BLOCK && - actual->st_value && !actual->st_size && - index + 1 < symtab->shdr->sh_size / sizeof(elfsh_Sym)) - actual->st_size = actual[1].st_value - actual->st_value; - - /* Fixup _start symbol value [and create it if unexistant] */ - actual = elfsh_get_symbol_by_name(symtab->parent, ELFSH_STARTSYM); - if (actual == NULL) - { - startaddr = elfsh_get_entrypoint(symtab->parent->hdr); - parent = elfsh_get_parent_section(symtab->parent, startaddr, NULL); - if (parent != NULL) - { - newent = elfsh_create_symbol(startaddr, 0, STT_FUNC, - 0, 0, parent->index); - elfsh_insert_symbol(symtab, &newent, ELFSH_STARTSYM); - } - } - else - { - elfsh_set_symbol_size(actual, 0); - elfsh_set_symbol_type(actual, STT_FUNC); - } - - /* _GLOBAL_OFFSET_TABLE_ injection if not present */ - got = elfsh_get_section_by_name(symtab->parent, ELFSH_SECTION_NAME_GOT, - NULL, NULL, NULL); - actual = elfsh_get_symbol_by_name(symtab->parent, ELFSH_GOTSYM); - if (actual == NULL && got != NULL) - { - newent = elfsh_create_symbol(got->shdr->sh_addr, 0, STT_OBJECT, - 0, 0, got->index); - elfsh_insert_symbol(symtab, &newent, ELFSH_GOTSYM); - } - - /* Fix sctndx */ - if (elfsh_fixup_sctndx(symtab) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to fixup sctndx", NULL); - - /* Resynchronize cached sorted symtab and return */ - elfsh_sync_sorted_symtab(symtab); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (symtab)); -} - - - - -/** - * Recompute .dynsym symbols address which are zeroed by new versions of ld - * - * @param file - * @param plt - * @param off - * @param dynsym - * @return - */ -elfsh_Sym *elfsh_restore_dynsym(elfshobj_t *file, elfshsect_t *plt, - u_int off, elfshsect_t *dynsym) - -{ - u_int entsz; - uint32_t index; - elfsh_Rel *reldyn; - elfsh_Sym *sym; - elfshsect_t *relplt; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Grab values */ - entsz = elfsh_get_pltentsz(file); - sym = NULL; - - /* Get the PLT related relocation table */ - name = IS_REL(plt) ? ELFSH_SECTION_NAME_RELPLT : ELFSH_SECTION_NAME_RELAPLT; - relplt = elfsh_get_section_by_name(plt->parent, name, 0, 0, 0); - if (!relplt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find RELPLT", NULL); - - /* On Sparc, some of the first entries are reserved */ - if (FILE_IS_SPARC(plt->parent) && off < elfsh_get_first_pltentsz(file)) - { - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Passing reserved PLT entry on SPARC\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not patching reserved PLT entry", NULL); - } - - /* On some architecture the first plt entry size is different than entsz */ - index = (off - elfsh_get_first_pltentsz(file) + entsz) / entsz; - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not patching first PLT entry", NULL); - index--; - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] New gnu-ld detected -> looking for reloc index = %u \n", index); -#endif - - /* Necessary for get_relent_by_index who does not know about IS_REL */ - elfsh_setrel(IS_REL(plt)); - - if (IS_REL(plt) ? - (sizeof(elfsh_Rel) * index) >= relplt->shdr->sh_size : - (sizeof(elfsh_Rela) * index) >= relplt->shdr->sh_size) - { - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Found END of relocation table, symbol not inserted \n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not patching PLT entry without relocation entry", NULL); - } - - /* Fixup missing .dynsym value */ - reldyn = elfsh_get_relent_by_index(relplt->data, index); - index = elfsh_get_relsym(reldyn); - if (reldyn) - { - sym = elfsh_get_symbol_by_index(dynsym->data, index); - if (sym && !sym->st_value) - sym->st_value = plt->shdr->sh_addr + off; - } - - /* If still not found */ - if (sym == NULL || sym->st_value == NULL) - { - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Cannot find symbol at PLT OFFSET + %u (.plt + off = " XFMT " ) object %s \n", - off, (eresi_Addr) plt->shdr->sh_addr + off, plt->parent->name); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not patching PLT entry without valid symbol", NULL); - } - -#if __DEBUG_COPYPLT__ - printf("[DEBUG_COPYPLT] Found symbol [%s] for PLT OFFSET + %u (.plt + off = " XFMT " ) object %s\n", - elfsh_get_dynsymbol_name(file, sym), off, (eresi_Addr) plt->shdr->sh_addr + off, plt->parent->name); -#endif - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym); -} - - - - -/** - * Fixup the dynamic symbol table (recompute all zeroed symbols) - * Useful on recent versions of ld - * - * @param dynsym - * @return - */ -int elfsh_fixup_dynsymtab(elfshsect_t *dynsym) -{ - elfshsect_t *plt; - u_int off; - u_int entsz; - elfsh_Sym *sym; - char *name; - int mode; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get PLT */ - plt = elfsh_get_plt(dynsym->parent, NULL); - if (!plt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PLT", -1); - - mode = elfsh_get_mode(); - elfsh_set_static_mode(); - - entsz = elfsh_get_pltentsz(plt->parent); - - /* Loop on .plt and inject 'old_symnam' symbols */ - for (off = 0; off < plt->shdr->sh_size; off += entsz) - { - - /* Special case for the first plt entry */ - if (!off) - { - off = off - entsz + elfsh_get_first_pltentsz(dynsym->parent); - continue; - } - - /* Get the existing symbol name for this plt entry ... */ - sym = elfsh_get_sym_by_value(dynsym->data, - dynsym->shdr->sh_size / sizeof(elfsh_Sym), - plt->shdr->sh_addr + off, NULL, ELFSH_EXACTSYM); - - - - /* New versions of ld do not fill the vaddr of dynamic symbols, do it ourself */ - if (sym == NULL) - { - sym = elfsh_restore_dynsym(dynsym->parent, plt, off, dynsym); - - if (sym != NULL) - { - name = elfsh_get_dynsymbol_name(plt->parent, sym); - - /* __gmon_start__ should not be resolved - if it was not already done by gcc */ - if (name && !strcmp(name, "__gmon_start__")) - sym->st_value = 0x0; - } - } - } - - elfsh_set_mode(mode); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/got.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/got.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/got.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/got.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,575 +0,0 @@ -/** - * @file got.c - * @ingroup libelfsh -** got.c for elfsh -** -** Started on Sun Jun 24 21:30:41 2001 jfv -** Last update Thu May 15 04:39:15 2003 jfv -** -** $Id: got.c,v 1.11 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - - -/** - * Shift GOT on ET_DYN - * - * @param file - * @param size - * @param name - * @return - */ -int elfsh_shift_got(elfshobj_t *file, - u_int size, - char *name) -{ - elfshsect_t *got; - int nbr; - u_int idx; - eresi_Addr *addr; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if __DEBUG_ETRELintoETDYN__ - printf("[DEBUG_ETRELintoETDYN] Shifting GOT from %u bytes \n", size); -#endif - - got = elfsh_get_section_by_name(file, name, - NULL, NULL, &nbr); - if (!got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive GOT in ET_DYN", -1); - nbr = nbr / sizeof(eresi_Addr); - for (idx = 0; idx < nbr; idx++) - { - addr = elfsh_get_got_entry_by_index(got->data, idx); - if (*addr) - *addr += size; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Change endianess of GOT - * - * @param newsect - * @return - */ -int elfsh_endianize_got(elfshsect_t *newsect) -{ - eresi_Addr *cur; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!newsect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (newsect->parent->hdr->e_ident[EI_DATA] == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (newsect->parent->hdr->e_ident[EI_DATA] == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - cur = elfsh_get_raw(newsect); - for (idx = 0; idx < newsect->shdr->sh_size / newsect->shdr->sh_entsize; idx++) - cur[idx] = swaplong(cur[idx]); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Read the global offset table in section .got - * - * @param file - * @param num - * @return - */ -eresi_Addr *elfsh_get_got(elfshobj_t *file, int *num) -{ - elfshsect_t *enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - else if (file->sectlist == NULL && elfsh_read_obj(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to read object", NULL); - - /* Read GOT */ - /* Now called .got.plt on new ld */ - enew = file->secthash[ELFSH_SECTION_GOT]; - if (enew == NULL) - { - enew = elfsh_get_gotsct(file); - if (enew == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT by name", NULL); - } - - /* Load GOT data */ - if (enew->data == NULL) - { - enew->data = elfsh_load_section(file, enew->shdr); - if (enew->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load GOT", NULL); - file->secthash[ELFSH_SECTION_GOT] = enew; - - /* Arrange endianess if necessary */ - elfsh_endianize_got(enew); - } - - /* Final things */ - if (num != NULL) - *num = enew->shdr->sh_size / enew->shdr->sh_entsize; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(enew))); -} - - - - -/** - * Return the real GOT section - * - * @param file - * @return - */ -elfshsect_t *elfsh_get_gotsct(elfshobj_t *file) -{ - elfshsect_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - new = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_ALTGOT, - NULL, NULL, NULL); - if (new) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); - new = file->secthash[ELFSH_SECTION_GOT]; - if (new) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); - new = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_GOTPLT, - NULL, NULL, NULL); - if (new) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); - new = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_GOT, - NULL, NULL, NULL); - if (new) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT by name", NULL); -} - - -/** - * Return the 'range'th got - seems ok - * - * @param file - * @param range - * @param nbr - * @return - */ -elfshsect_t *elfsh_get_got_by_idx(elfshobj_t *file, - eresi_Addr range, - u_int *nbr) -{ - elfshsect_t *got; - elfshsect_t *cursect; - u_int idx; - char *name; - eresi_Addr rank = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == 0x0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No file selected", NULL); - - if (file->sectlist == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", NULL); - - for (idx = 0; idx < elfsh_get_shtnbr(file->hdr); idx++) - { - - cursect = elfsh_get_section_by_index(file, idx, NULL, NULL); - name = cursect->name; - - if (strstr(name, "got")) - { - - got = elfsh_get_section_by_name(file, name, - NULL, NULL, NULL); - if (got == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT by name", NULL); - - /* Load GOT data */ - if (got->data == NULL) - { - - got->data = elfsh_load_section(file, got->shdr); - - if (got->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load got", NULL); - - // file->secthash[ELFSH_SECTION_GOT] = got; - - /* Arrange endianess if necessary */ - elfsh_endianize_got(got); - } - - if (rank == range) - { - if (nbr != NULL) - *nbr = got->shdr->sh_size / got->shdr->sh_entsize; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (got)); - } - - rank++; - } - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot reach requested range", NULL); -} - - - - -/** - * Modify a GOT entry - * - * @param file - * @param i - * @param n - * @return - */ -int elfsh_set_got_entry_by_index(elfshobj_t *file, - int i, - eresi_Addr n) -{ - int nbr; - eresi_Addr *got; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - got = elfsh_get_got(file, &nbr); - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT", -1); - if (i >= nbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GOT index too big", -1); - got[i] = n; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Modify the got entry for the dynamic symbol 'n' - * - * @param f - * @param n - * @param a - * @return - */ -int elfsh_set_got_entry_by_name(elfshobj_t *f, - char *n, - eresi_Addr a) -{ - eresi_Addr *got; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (f == NULL || n == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - got = elfsh_get_got_entry_by_name(f, n); - if (got == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT entry by name", -1); - *got = a; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Return a entry giving its parent and its index - * @param got - * @param index - * @return - */ -eresi_Addr *elfsh_get_got_entry_by_index(eresi_Addr *got, - eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (got == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (got + index)); -} - - - -/** - * Return a entry giving its parent and its index - * - * @param file - * @param name - * @return - */ -eresi_Addr *elfsh_get_got_entry_by_name(elfshobj_t *file, char *name) -{ - int nbr; - u_int index; - eresi_Addr *got; - elfsh_Sym *sym; - u_int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - got = elfsh_get_got(file, &nbr); - sym = elfsh_get_dynsymbol_by_name(file, name); - if (got == NULL || sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol", NULL); - - /* Get PLT info */ - if (!elfsh_is_pltentry(file, sym)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol is not PLT entry", NULL); - sz = elfsh_get_pltentsz(file); - - /* Find the entry */ - for (index = 0; index < nbr; index++) - if (INTERVAL(sym->st_value, got[index], sym->st_value + sz)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (got + index)); - - /* Not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GOT entry not found", NULL); -} - - - - -/** - * Return a entry giving its parent and - * its index : used as INTERNAL hash handler - * - * @param got - * @param vaddr - * @return - */ -int elfsh_set_got_entry(eresi_Addr *got, eresi_Addr vaddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - *got = vaddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Return a entry value giving its parent and its - * index : used as INTERNAL hash handler - * - * @param got - * @return - */ -eresi_Addr elfsh_get_got_entry(eresi_Addr *got) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*got)); -} - - - -/** - * Return a GOT entry value - * - * @param got - * @return - */ -eresi_Addr elfsh_get_got_val(eresi_Addr *got) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*got)); -} - - - -/** - * Return a GOT entry address - * - * @param got - * @return - */ -eresi_Addr elfsh_get_got_addr(eresi_Addr *got) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*got)); -} - - - -/** - * Change a GOT entry val - * - * @param got - * @param val - * @return - */ -u_int elfsh_set_got_val(eresi_Addr *got, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == got) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - *got = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Change a GOT entry addr - * - * @param got - * @param val - * @return - */ -u_int elfsh_set_got_addr(eresi_Addr *got, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // XXX Not yet implemented ... and not going to be - printf("[DEBUG] elfsh_set_got_addr\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Only used on BeoS - * Tested and developed by zadig@myrealbox.com - * - * @param file - * @param name - * @param rel_entry - * @param - */ -int elfsh_get_got_symbol_reloc(elfshobj_t *file, - uint8 *name, - elfsh_Rel *rel_entry) -{ - elfshsect_t *got, *rel_got; - u_int index, got_rel_index; - u_int entsz; - int got_index; - elfsh_Off off; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - entsz = elfsh_get_pltentsz(file); - if (entsz < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid PLT entry size", -1); - - if (NULL == elfsh_get_dynsymtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", -1); - - if (NULL == elfsh_get_symtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB", -1); - - /* get got section index */ - got = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_GOT, - &got_index, NULL, NULL); - if (got == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT", -1); - - /* search the got relocation section */ - rel_got = NULL; - for (got_rel_index = 0; got_rel_index < file->hdr->e_shnum; got_rel_index++) - { - rel_got = elfsh_get_section_by_index(file, got_rel_index, - NULL, NULL); - if (rel_got->shdr->sh_info == got_index) - break; - } - - if ((rel_got == NULL) || (rel_got->shdr->sh_info != got_index)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GOT relocations", -1); - - /* search for the requested symbol */ - off = entsz; - data = elfsh_get_raw(rel_got); - for (index = 0; - index < (rel_got->shdr->sh_size / rel_got->shdr->sh_entsize); - off += entsz, index ++) - { - elfsh_Rel *cur_rel; - cur_rel = ((elfsh_Rel*) data) + index; - if(strcmp(elfsh_get_symname_from_reloc(file, cur_rel), name) == 0) - { - *rel_entry = *cur_rel; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", -1); -} - - - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/hash.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/hash.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/hash.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/hash.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,737 +0,0 @@ -/** - * @file hash.c - * @ingroup libelfsh -** hash.c for libelfsh -** -** Started on Mon Feb 26 04:15:44 2001 jfv -** -** -** $Id: hash.c,v 1.13 2007-08-25 17:13:05 mxatone Exp $ -** -*/ -#include "libelfsh.h" - -static void *lastdata; - -/** - * Return the chain number - * @param chain chain element - * @return num value - */ -elfsh_Word elfsh_get_hashchain_num(elfsh_Word *chain) -{ - elfsh_Word nchain; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (lastdata == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - " Cannot get HASH", 0); - - nchain = elfsh_get_hashnchain(lastdata); - - lastdata = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (nchain)); -} - -/** - * Set a value for the chain number - * @param chain chain element - * @param new num value - */ -int elfsh_set_hashchain_num(elfsh_Word *chain, elfsh_Word val) -{ - elfsh_Word *c; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (lastdata == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - c = (elfsh_Word*) lastdata; - - *(c + 1) = val; - - lastdata = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the bucket number - * @param bucket bucket element - * @return number value - */ -elfsh_Word elfsh_get_hashbucket_num(elfsh_Word *bucket) -{ - elfsh_Word nbucket; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (lastdata == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", 0); - - nbucket = elfsh_get_hashnbucket(lastdata); - - lastdata = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (nbucket)); -} - -/** - * Set a value for the bucket number - * @param bucket bucket element - * @param val new number - */ -int elfsh_set_hashbucket_num(elfsh_Word *bucket, elfsh_Word val) -{ - elfsh_Word *b; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (lastdata == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - b = (elfsh_Word*) lastdata; - - *b = val; - - lastdata = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a value for a chain - * @param chain chain element - * @return value - */ -elfsh_Word elfsh_get_hashchain_value(elfsh_Word *chain) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (chain == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*chain)); -} - -/** - * Set a value for a chain value - * @param chain chain element - * @param val new value - */ -int elfsh_set_hashchain_value(elfsh_Word *chain, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (chain == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - *chain = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a value for a bucket - * @param bucket bucket element - * @return value - */ -elfsh_Word elfsh_get_hashbucket_value(elfsh_Word *bucket) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (bucket == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*bucket)); -} - -/** - * Set a value for a bucket value - * @param bucket bucket element - * @param val new value - */ -int elfsh_set_hashbucket_value(elfsh_Word *bucket, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (bucket == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - *bucket = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Get hash chain by name - * @param file target file - * @param sname symbol name - * @return chain - */ -elfsh_Word *elfsh_get_hashchain_by_name(elfshobj_t *file, char *sname) -{ - elfsh_Sym *sym; - void *data; - elfsh_Word *chain; - elfsh_Word nchain; - u_int index; - elfsh_Word symid; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_hashtable(file, NULL); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - " Cannot get HASH", 0); - - sym = elfsh_get_dynsymtab(file, NULL); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get DYNSYM", 0); - - lastdata = data; - - chain = elfsh_get_hashchain(data); - nchain = elfsh_get_hashnchain(data); - - for (index = 0; index < nchain; index++) - { - symid = chain[index]; - name = elfsh_get_dynsymbol_name(file, sym + symid); - - if (!strcmp(sname, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (chain + index)); - - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); -} - -/** - * Get hash chain by index - * @param ps data pointer - * @param index chain index - * @return chain entry - */ -elfsh_Word *elfsh_get_hashchain_by_index(void *ps, u_int index) -{ - elfsh_Word *chain; - elfsh_Word nchain; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - chain = elfsh_get_hashchain(ps); - nchain = elfsh_get_hashnchain(ps); - - lastdata = ps; - - if (index < nchain) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (chain + index)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); -} - -/** - * Get hash bucket by name - * @param file target file - * @param symbol name - * @return bucket - */ -elfsh_Word *elfsh_get_hashbucket_by_name(elfshobj_t *file, char *sname) -{ - elfsh_Sym *sym; - void *data; - elfsh_Word *bucket; - elfsh_Word nbucket; - int index; - elfsh_Word symid; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_hashtable(file, NULL); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - " Cannot get HASH", 0); - - sym = elfsh_get_dynsymtab(file, NULL); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get DYNSYM", 0); - - lastdata = data; - - bucket = elfsh_get_hashbucket(data); - nbucket = elfsh_get_hashnbucket(data); - - for (index = 0; index < nbucket; index++) - { - symid = bucket[index]; - name = elfsh_get_dynsymbol_name(file, sym + symid); - - if (!strcmp(sname, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (bucket + index)); - - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); -} - -/** - * Get hash bucket by index - * @param ps data pointer - * @parma index bucket index - * @return pointer on the bucket - */ -elfsh_Word *elfsh_get_hashbucket_by_index(void *ps, u_int index) -{ - elfsh_Word *bucket; - elfsh_Word nbucket; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - bucket = elfsh_get_hashbucket(ps); - nbucket = elfsh_get_hashnbucket(ps); - - lastdata = ps; - - if (index < nbucket) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (bucket + index)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); -} - -/** - * Get chain - * @param data element pointer - * @return value - */ -elfsh_Word *elfsh_get_hashchain(const void *data) -{ - elfsh_Word *bucket; - elfsh_Word nbucket; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - nbucket = elfsh_get_hashnbucket(data); - bucket = elfsh_get_hashbucket(data); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((elfsh_Word *) bucket + nbucket)); -} - -/** - * Get n chain - * @param data element pointer - * @return value - */ -elfsh_Word elfsh_get_hashnchain(const void *data) -{ - elfsh_Word *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - p = (elfsh_Word *) data; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*(p + 1))); -} - -/** - * Get bucket - * @param data element pointer - * @return value - */ -elfsh_Word *elfsh_get_hashbucket(const void *data) -{ - elfsh_Word *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - p = (elfsh_Word *) data; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p + 2)); -} - -/** - * Get n bucket - * @param data element pointer - * @return value - */ -elfsh_Word elfsh_get_hashnbucket(const void *data) -{ - elfsh_Word *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - p = (elfsh_Word *) data; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*p)); -} - -/** - * Return a pointer on the symbol hash table and load it if needed - * @param file target file - * @param num number of entities (optional) - * @return data pointer - */ -void *elfsh_get_hashtable(elfshobj_t *file, int *num) -{ - elfshsect_t *enew; - int nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_HASH] == NULL) - { - enew = elfsh_get_section_by_type(file, SHT_HASH, NULL, NULL, &nbr, 0); - if (enew == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get HASH by type", NULL); - - enew->data = elfsh_load_section(file, enew->shdr); - if (!enew->data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No Hash table", NULL); - - file->secthash[ELFSH_SECTION_HASH] = enew; - } - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_HASH]); - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_HASH]->shdr->sh_size; - nbr /= sizeof(elfsh_Word); - - if (num != NULL) - *num = nbr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * Return a pointer on a symbol hash table (depending of range value) and load it if needed - * @param file target file - * @param range range index - * @param num number of entities (optional) - * @return section pointer - */ -elfshsect_t *elfsh_get_hashtable_by_range(elfshobj_t *file, eresi_Addr range, int *num) -{ - elfshsect_t *new; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - new = elfsh_get_section_by_type(file, SHT_HASH, range, NULL, &nbr, 0); - if (new == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get HASH by type", NULL); - - if (!new->data) - { - new->data = elfsh_load_section(file, new->shdr); - if (!new->data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No Hash table", NULL); - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_HASH]->shdr->sh_size; - nbr /= sizeof(elfsh_Word); - - if (num != NULL) - *num = nbr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, new); -} - -/** - * Return the symbol value giving its name using the symbol hash table - * @param file target file - * @param name symbol name - * @return symbol value or 0 - */ -int elfsh_get_dynsymbol_by_hash(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - void *data; - char *sname; - elfsh_Word hash; - elfsh_Word nbucket; - elfsh_Word nchain; - elfsh_Word *chain; - elfsh_Word *bucket; - int index; - elfsh_Word symid; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_hashtable(file, NULL); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - " Cannot get HASH", 0); - - sym = elfsh_get_dynsymtab(file, NULL); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get DYNSYM", 0); - - hash = elfsh_get_symbol_hash(name); - nbucket = elfsh_get_hashnbucket(data); - nchain = elfsh_get_hashnchain(data); - bucket = elfsh_get_hashbucket(data); - chain = elfsh_get_hashchain(data); - - index = bucket[hash % nbucket]; - sname = elfsh_get_dynsymbol_name(file, sym + index); - - if (!strcmp(name, sname)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym[index].st_value)); - - /* - ** The first fetched dynamic symbol isnt the one we are looking for - ** so we loop on the entry . - */ - for (sym = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]); - index < nchain; index = symid) - { - -#if __DEBUG__ - printf("[LIBELFSH] Hash LOOP on bucket [%u] \n", (u_int) index); -#endif - - if (chain[index] == STN_UNDEF) - break; - - symid = chain[index]; - - sname = elfsh_get_dynsymbol_name(file, &sym[symid]); - if (!strcmp(name, sname)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym[chain[index]].st_value)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No Hash found for the symbol", 0); -} - -/** - * Pick up a version definition entry from a name - * @param file host file - * @param name function name - * @param defdata version def section data pointer - * @param size section size - * @return a pointer on version definition entry - */ -elfsh_Verdef *elfsh_hash_getdef(elfshobj_t *file, char *name, void *defdata, int size) -{ - elfsh_Verdef *table; - elfsh_Half *sym; - u_int offset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - /* We can get elements if we do not already have them */ - if (defdata == NULL) - { - defdata = elfsh_get_verdeftab(file, &size); - - if (defdata == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find version def section", NULL); - } - - /* Get version symbol to check that is a def and not a need*/ - sym = elfsh_get_versym_by_name(file, name); - - if (sym) - { - /* Search on the verdef table */ - for (offset = 0; offset < size; offset += table->vd_next) - { - table = defdata + offset; - - /* This symbol was a definition */ - if (table->vd_ndx == *sym) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, table); - - if (table->vd_next == 0) - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Check if this file match directly - * @param file target file - * @param name function name - * @return file object - */ -static elfshobj_t *elfsh_hash_getfile_def_direct(elfshobj_t *file, char *name) -{ - int defsize; - void *defdata; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if a version def section exist else we do nothing */ - defdata = elfsh_get_verdeftab(file, &defsize); - - if (defdata) - { - /* Try on the current file */ - if (elfsh_get_dynsymbol_by_hash(file, name) > 0 - && elfsh_hash_getdef(file, name, defdata, defsize)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Research a function on dependences file using hash version - * @param file target file - * @param name function name - * @return file object - */ -elfshobj_t *elfsh_hash_getfile_def(elfshobj_t *file, char *name) -{ - char **keys; - u_int index; - int keynbr; - elfshobj_t *getfile; -#if defined(sun) - Link_map *actual; -#else - elfshlinkmap_t *actual; -#endif - char *fname; - hash_t *filehash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We need original file to use child_hash */ - if (file->original) - file = file->original; - - /* Check directly this file */ - if (elfsh_hash_getfile_def_direct(file, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file); - - /* Debug mode use a different dependences technique for mapped files */ - if (elfsh_is_debug_mode()) - { - filehash = hash_find("files"); - - if (!filehash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find file list", NULL); - - /* Iterate linkmap list */ - for (actual = elfsh_linkmap_get_lnext(file->linkmap); - actual != NULL; - actual = elfsh_linkmap_get_lnext(actual)) - { - fname = elfsh_linkmap_get_lname(actual); - - if (fname && *fname) - { - getfile = (elfshobj_t *) hash_get(filehash, fname); - - if (getfile) - { - /* Check directly this file */ - if (elfsh_hash_getfile_def_direct(getfile, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, getfile); - } - } - } - } - else /* Use static file dependence hash table */ - { - if (hash_size(&file->child_hash)) - { - /* Search on his childs */ - keys = hash_get_keys(&file->child_hash, &keynbr); - if (keys) - { - for (index = 0; index < keynbr; index++) - { - getfile = (elfshobj_t *) hash_get(&file->child_hash, keys[index]); - if (getfile) - { - getfile = elfsh_hash_getfile_def(getfile, name); - - if (getfile) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, getfile); - } - } - - hash_free_keys(keys); - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Get the hash for the symbol name . Adapted from the ELF TIS reference - * @param name input name to hash - * @return hash value - */ -elfsh_Word elfsh_get_symbol_hash(char *name) -{ - unsigned long h; - unsigned long g; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (h = 0; *name; h &= ~g) - { - h = (h << 4) + *name++; - if ((g = h & 0xF0000000)) - h ^= g >> 24; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_Word) (h)); -} - - - - - - - - - - - - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/hijack.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/hijack.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/hijack.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/hijack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,180 +0,0 @@ -/** - * @file hijack.c - * @ingroup libelfsh -** hijack.c in elfsh -** -** Started on Tue Feb 4 14:41:34 2003 emsi -** -** -** $Id: hijack.c,v 1.12 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Perform custom function hijack, return 0 on success -1 on error - * - * @param file - * @param type - * @param name - * @param addr - * @param hooked - * @return - */ -int elfsh_hijack_function_by_name(elfshobj_t *file, - uint32_t type, - char *name, - eresi_Addr addr, - eresi_Addr *hooked) -{ - elfsh_Sym *symbol; - elfsh_Sym *symbol2; - int ret; - int ispltent; - elfshsect_t *hooks; - uint32_t pgsize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_setup_hooks(); - - /* Sanity checks */ - if (file == NULL || name == NULL || addr == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (elfsh_copy_plt(file, elfsh_get_pagesize(file)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy PLT", -1); - - /* Guess the hijack type */ - switch (type) - { - - /* static function hijacking */ - /* This type is general enough for redirecting on the good hijack technique - ** if it finds that the current file architecture is not suited to the - ** requested hijack type. - */ - case ELFSH_HIJACK_TYPE_FLOW: - - /* If the hook section does not exist, create it */ - hooks = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HOOKS, 0, 0, 0); - if (!hooks) - { - pgsize = elfsh_get_pagesize(file); - hooks = elfsh_insert_section(file, - ELFSH_SECTION_NAME_HOOKS, - NULL, - ELFSH_CODE_INJECTION, - pgsize - 1, pgsize); - if (!hooks) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get and inject .hooks", -1); - hooks->curend = 0; - } - - /* Resolve hooked function symbol */ - symbol = elfsh_get_symbol_by_name(file, name); - if (!symbol || symbol->st_value == 0) - symbol = elfsh_get_dynsymbol_by_name(file, name); - if (!symbol && elfsh_debugger_present()) - { - elfsh_toggle_mode(); - symbol2 = elfsh_get_dynsymbol_by_name(file, name); - elfsh_toggle_mode(); - } - else - symbol2 = NULL; - if (!symbol && !symbol2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown function (no symbol)", -1); - if (!symbol || (!symbol->st_value && symbol2)) - symbol = symbol2; - ispltent = elfsh_is_pltentry(file, symbol); - -#if __DEBUG_REDIR__ - fprintf(stderr, "[DEBUG_REDIR] Symbol %s [file %s] resolved at %08X isplt(%u)\n", - name, file->name, symbol->st_value, ispltent); -#endif - - /* Perform PLT redirection if we deal with a PLT symbol */ - if (ispltent == 1) - { - - /* MIPS handling */ - if (FILE_IS_MIPS(file)) - { - if (hooked) - *hooked = * (u_long *) elfsh_get_got_entry_by_name(file, name); - ret = elfsh_set_got_entry_by_name(file, name, addr); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to patch GOT entry", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Hook using ALTPLT technique */ - if (hooked) - *hooked = symbol->st_value; - ret = elfsh_plt(file, symbol, addr); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to perform ALTPLT", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_REDIR_ALTPLT); - } - - /* If not a PLT entry, we do a control flow hijack */ - if (hooked) - *hooked = symbol->st_value; - ret = elfsh_cflow(file, name, symbol, addr); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to perform CFLOW redir", -1); - - /* Perform a second stage runtime relocation after injecting this new old symbol */ - if (elfsh_is_debug_mode() && elfsh_save_relocate(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed second stage runtime relocation", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_REDIR_CFLOW); - - /* GOT entry hijacking */ - case ELFSH_HIJACK_TYPE_GOT: - if (hooked) - *hooked = *(u_long *) elfsh_get_got_entry_by_name(file, name); - ret = elfsh_set_got_entry_by_name(file, name, addr); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to patch GOT entry", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_REDIR_ALTGOT); - - /* PLT hijack */ - case ELFSH_HIJACK_TYPE_PLT: - if (FILE_IS_MIPS(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "There is not PLT to hijack on MIPS", -1); - - symbol = elfsh_get_dynsymbol_by_name(file, name); - if (NULL == symbol) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown dynamic symbol", -1); - - if (!elfsh_is_pltentry(file, symbol)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol is not a PLT entry", -1); - - /* Now use ELFsh 0.6 hooks model */ - if (hooked) - *hooked = symbol->st_value; - ret = elfsh_plt(file, symbol, addr); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to do ALTPLT", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_REDIR_ALTPLT); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown redirection type", -1); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/hooks.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/hooks.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/hooks.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/hooks.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1620 +0,0 @@ -/** - * @file hooks.c - * @ingroup libelfsh -** hooks.c for libelfsh (The ELF shell library) -** -** All the function pointers for all provided techniques. -** -** This is using the libaspect vectors -** -** Started Jan 11 2004 02:57:03 jfv -** -** -** $Id: hooks.c,v 1.26 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -hash_t interp_hash; - - -u_char elfsh_ostype[5] = { - ELFOSABI_LINUX, - ELFOSABI_FREEBSD, - ELFOSABI_NETBSD, - ELFOSABI_OPENBSD, - ELFOSABI_SOLARIS, -}; - - -/** - * Default hooks handlers - * - * @param null - * @param null2 - * @param null3 - * @return - */ -int elfsh_default_plthandler(elfshobj_t *null, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used for encoding a random PLT entry - * Do nothing by default, this is not fatal - * - * @param file - * @param sect - * @param diff - * @return - */ -int elfsh_default_encodeplthandler(elfshobj_t *file, - elfshsect_t *sect, - eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used for encoding of the first PLT entry - * - * @param file - * @param sect - * @param sect2 - * @return - */ -int elfsh_default_encodeplt1handler(elfshobj_t *file, - elfshsect_t *sect, - elfshsect_t *sect2, - eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * - * @param null - * @param null2 - * @param null3 - * @param null4 - * @param null5 - */ -int elfsh_default_relhandler(elfshsect_t *null, - elfsh_Rel * null2, - eresi_Addr * null3, - eresi_Addr null4, - elfshsect_t *null5) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * - * @param null - * @param nulls - * @param null2 - * @param null3 - * @return - */ -int elfsh_default_cflowhandler(elfshobj_t *null, - char *nulls, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - -/** - * - * @param o - * @param d - * @param t - * @param f - * @return - */ -int elfsh_default_extplthandler(elfshsect_t *o, elfshsect_t *d, - elfshsect_t *t, elfshsect_t *f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Used on architectures where altplt hijack is not required, thus induce no fatal error - * DO NOT use this as a default handler, unless you know exactly what you are doing - * - * @param null - * @param null2 - * @param null3 - * @return - */ -int elfsh_void_altplthandler(elfshobj_t *null, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * - * @param addr - * @return - */ -int elfsh_default_argchandler(eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Registration handlers - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_altplthook(u_char archtype, - u_char objtype, - u_char ostype, - void *fct) -{ - vector_t *altplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(altplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register an EXTPLT handler - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_extplthook(u_char archtype, - u_char objtype, - u_char ostype, - void *fct) -{ - vector_t *extplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - extplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(extplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register an PLT handler - * - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_plthook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *plt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - plt = aspect_vector_get(ELFSH_HOOK_PLT); - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(plt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Register an ENCODEPLT handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_encodeplthook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *encodeplt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(encodeplt, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Register an ENCODEPLT1 handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_encodeplt1hook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *encodeplt1; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(encodeplt1, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Register an ET_REL injection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_relhook(u_char archtype, u_char objtype, u_char ostype, - void *fct) -{ - vector_t *rel; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - rel = aspect_vector_get(ELFSH_HOOK_REL); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(rel, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register a control flow redirection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_cflowhook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *cflow; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(cflow, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Register a args counting redirection handler - * @param archtype - * @param objtype - * @param ostype - * @param fct - * @return - */ -int elfsh_register_argchook(u_char archtype, u_char objtype, - u_char ostype, void *fct) -{ - vector_t *argcp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - argcp = aspect_vector_get(ELFSH_HOOK_ARGC); - - if (archtype >= ELFSH_ARCHNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Architecture type", -1); - if (objtype >= ELFSH_TYPENUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Object type", -1); - if (ostype >= ELFSH_OSNUM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid Operating System type", -1); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = objtype; - dim[2] = ostype; - aspect_vectors_insert(argcp, dim, (unsigned long) fct); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Initialize hook hash table - * @return - */ -int elfsh_init_vectors() -{ - u_int *dims; - char **strdims; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - aspect_init(); - - /* All hooks have the same dimensions here */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 4 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 4 * sizeof(char *), -1); - dims[0] = ELFSH_ARCHNUM; - dims[1] = ELFSH_TYPENUM; - dims[2] = ELFSH_OSNUM; - strdims[0] = "ARCHTYPE"; - strdims[1] = "ELFTYPE"; - strdims[2] = "OSTYPE"; - - aspect_register_vector(ELFSH_HOOK_ALTPLT, - elfsh_default_plthandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_PLT, - elfsh_default_plthandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_REL, - elfsh_default_relhandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_CFLOW, - elfsh_default_cflowhandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_EXTPLT, - elfsh_default_extplthandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_ENCODEPLT, - elfsh_default_encodeplthandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_ENCODEPLT1, - elfsh_default_encodeplt1handler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(ELFSH_HOOK_ARGC, - elfsh_default_argchandler, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Initialize ALTPLT hijack and ET_REL injection handlers in their hook - */ -void elfsh_setup_hooks() -{ - //u_int i, j, k; - static int done = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if already initialized */ - if (done) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - elfsh_init_vectors(); - - /***************************************/ - /****** PLT hijacking handlers *********/ - /**************************************/ - - /* Usual PLT targets for ET_EXEC/i386 */ - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); - - /* Usual PLT targets for ET_EXEC/Sparc32 */ - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_sparc32); - elfsh_register_plthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_sparc32); - - /* Usual PLT targets for ET_EXEC/Sparc64 */ - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_sparc64); - elfsh_register_plthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_sparc64); - - /* Usual PLT targets for ET_EXEC/IA64 */ - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_ia64); - elfsh_register_plthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia64); - - /* Usual PLT targets for ET_EXEC/Alpha64 */ - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_alpha64); - elfsh_register_plthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_alpha64); - - /* Usual PLT targets for ET_EXEC/MIPS32 */ - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_mips32); - elfsh_register_plthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_mips32); - - /* Usual PLT targets for ET_EXEC/MIPS64 */ - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_plt_mips64); - elfsh_register_plthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_mips64); - - /***************************************/ - /****** ALTPLT hijacking handlers ******/ - /**************************************/ - - /* Usual ALTPLT targets for ET_EXEC/i386 */ - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_void_altplthandler); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_void_altplthandler); - - /* Usual ALTPLT targets for ET_EXEC/Sparc32 */ - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_sparc32); - elfsh_register_altplthook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_sparc32); - - /* Usual ALTPLT targets for ET_EXEC/Sparc64 */ - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_sparc64); - elfsh_register_altplthook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_sparc64); - - /* Usual ALTPLT targets for ET_EXEC/IA64 */ - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_ia64); - elfsh_register_altplthook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_ia64); - - /* Usual ALTPLT targets for ET_EXEC/Alpha64 */ - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_alpha64); - elfsh_register_altplthook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_alpha64); - - /* Usual ALTPLT targets for ET_EXEC/MIPS32 */ - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_mips32); - elfsh_register_altplthook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_mips32); - - /* Usual ALTPLT targets for ET_EXEC/MIPS64 */ - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_hijack_altplt_mips64); - elfsh_register_altplthook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_hijack_altplt_mips64); - - /***********************************/ - /* Now register Relocation hooks */ - /***********************************/ - - - /* Usual REL targets for ET_EXEC/i386 */ - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_ia32); - - /* Usual REL targets for ET_EXEC/Sparc32 */ - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_sparc32); - elfsh_register_relhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_sparc32); - - /* Usual REL targets for ET_EXEC/Sparc64 */ - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_sparc64); - elfsh_register_relhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_sparc64); - - /* Usual REL targets for ET_EXEC/IA64 */ - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_ia64); - elfsh_register_relhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_ia64); - - /* Usual REL targets for ET_EXEC/Alpha64 */ - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_alpha64); - elfsh_register_relhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_alpha64); - - /* Usual REL targets for ET_EXEC/MIPS32 */ - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_mips32); - elfsh_register_relhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_mips32); - - /* Usual REL targets for ET_EXEC/MIPS64 */ - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_relocate_mips64); - elfsh_register_relhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_relocate_mips64); - - /***********************************/ - /* Now register Control flow hooks */ - /***********************************/ - - /* Usual REL targets for ET_EXEC/IA32 */ - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_ia32); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_ia32); - - /* Usual CFLOW targets for ET_EXEC/IA64 */ - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_ia64); - elfsh_register_cflowhook(ELFSH_ARCH_IA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_ia64); - - /* Usual CFLOW targets for ET_EXEC/SPARC32 */ - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_sparc32); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_sparc32); - - /* Usual CFLOW targets for ET_EXEC/SPARC64 */ - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_sparc64); - elfsh_register_cflowhook(ELFSH_ARCH_SPARC64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_sparc64); - - /* Usual CFLOW targets for ET_EXEC/ALPHA64 */ - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_alpha64); - elfsh_register_cflowhook(ELFSH_ARCH_ALPHA64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_alpha64); - - /* Usual CFLOW targets for ET_EXEC/MIPS32 */ - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_mips32); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_mips32); - - /* Usual CFLOW targets for ET_EXEC/MIPS64 */ - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_MIPS64, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_cflow_mips64); - elfsh_register_cflowhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_cflow_ia32); - - /* Usual REL/PLT/ALTPLT targets for ET_DYN/x86 */ - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_BEOS, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, elfsh_hijack_plt_ia32); - elfsh_register_plthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, elfsh_hijack_plt_ia32); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_BEOS, elfsh_relocate_ia32); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_void_altplthandler); - elfsh_register_relhook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_relocate_ia32); - elfsh_register_altplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_BEOS, elfsh_void_altplthandler); - - /***********************************/ - /* Now register encodeplt points hooks */ - /***********************************/ - - /* Usual ENCODEPLT breakpoint targets for ET_EXEC/IA32 */ - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, elfsh_encodeplt_ia32); - elfsh_register_encodeplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, elfsh_encodeplt_ia32); - - /* Usual ENCODEPLT1 targets for ET_EXEC/IA32 */ - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, elfsh_encodeplt1_ia32); - elfsh_register_encodeplt1hook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, elfsh_encodeplt1_ia32); - - /*** Now EXTPLT handlers ***/ - - /* Usual EXTPLT targets for ET_EXEC/IA32 */ - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_LINUX, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_FREEBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_NETBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_OPENBSD, elfsh_extplt_ia32); - elfsh_register_extplthook(ELFSH_ARCH_IA32, ELFSH_TYPE_DYN, - ELFSH_OS_SOLARIS, elfsh_extplt_ia32); - - /***************************************/ - /****** ARGC arguments counting ******/ - /**************************************/ - - /* Usual ARGC targets for ET_EXEC/i386 */ - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_LINUX, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_FREEBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_NETBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_OPENBSD, elfsh_args_count_ia32); - elfsh_register_argchook(ELFSH_ARCH_IA32, ELFSH_TYPE_EXEC, - ELFSH_OS_SOLARIS, elfsh_args_count_ia32); - - done++; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Call the relocation hook - * @param file - * @param s - * @param r - * @param l - * @param a - * @param m - * @return - */ -int elfsh_rel(elfshobj_t *file, elfshsect_t *s, elfsh_Rel *r, - eresi_Addr *l, eresi_Addr a, elfshsect_t *m) -{ - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - vector_t *rel; - - //eresi_Addr ***hook; - u_int dim[3]; - - int (*fct)(elfshsect_t *n, - elfsh_Rel *n2, - eresi_Addr *n3, - eresi_Addr n4, - elfshsect_t *n5); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - rel = aspect_vector_get(ELFSH_HOOK_REL); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "RELOCATION handler unexistant for this ARCH/OS", -1); - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(rel, dim); - ret = fct(s, r, l, a, m); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Relocation handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Call the relocation hook - * @param file - * @param name - * @param old - * @param new - * @return - */ -int elfsh_cflow(elfshobj_t *file, char *name, elfsh_Sym *old, - eresi_Addr new) -{ - vector_t *cflow; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *n, char *n2, elfsh_Sym *n3, eresi_Addr n4); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "CFLOW handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(cflow, dim); - ret = fct(file, name, old, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Call the PLT hook - * @param file - * @param s - * @param new - * @return - */ -int elfsh_plt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) -{ - vector_t *plt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfsh_Sym *s, eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - plt = aspect_vector_get(ELFSH_HOOK_PLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(plt, dim); - ret = fct(file, s, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ENCODEPLT hook - * - * @param file - * @param plt - * @param diff - * @param off - * @return - */ -int elfsh_encodeplt(elfshobj_t *file, elfshsect_t *plt, - eresi_Addr diff, u_int off) -{ - vector_t *encodeplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfshsect_t *s, eresi_Addr a, u_int off); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ENCODEPLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(encodeplt, dim); - - ret = fct(file, plt, diff, off); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT encoding handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ENCODEPLT1 hook - * - * @param file - * @param plt - * @param extplt - * @param diff - * @return - */ -int elfsh_encodeplt1(elfshobj_t *file, elfshsect_t *plt, - elfshsect_t *extplt, eresi_Addr diff) -{ - vector_t *encodeplt1; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *f, elfshsect_t *s, elfshsect_t *s2, - eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ENCODEPLT1 handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(encodeplt1, dim); - ret = fct(file, plt, extplt, diff); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT1 encoding handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * Call the ALTPLT hook - * - * @param file - * @param s - * @param new - * @return - */ -int elfsh_altplt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) -{ - vector_t *altplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshobj_t *file, elfsh_Sym *s, eresi_Addr a); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT handler unexistant for this ARCH/OS", -1); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(altplt, dim); - ret = fct(file, s, new); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ALTPLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Call the EXTPLT hook - * - * @param extplt - * @param altgot - * @param dynsym - * @param relplt - * @return - */ -int elfsh_extplt(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt) -{ - vector_t *vextplt; - u_char archtype; - u_char elftype; - u_char ostype; - int ret; - int (*fct)(elfshsect_t *extplt, elfshsect_t *altgot, - elfshsect_t *dynsym, elfshsect_t *relplt); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - vextplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(extplt->parent); - elftype = elfsh_get_elftype(extplt->parent); - ostype = elfsh_get_ostype(extplt->parent); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "EXTPLT handler unexistant for this ARCH/OS", -1); - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(vextplt, dim); - ret = fct(extplt, altgot, dynsym, relplt); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "EXTPLT redirection handler failed", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Call the arg count hook - * - * @param file - * @param off - * @param vaddr - * @return - */ -int *elfsh_args_count(elfshobj_t *file, u_int off, eresi_Addr vaddr) -{ - vector_t *argch; - u_char archtype; - u_char elftype; - u_char ostype; - int *(*fct)(elfshobj_t *file, u_int off, eresi_Addr vaddr); - u_int dim[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - argch = aspect_vector_get(ELFSH_HOOK_ARGC); - - /* Fingerprint binary */ - archtype = elfsh_get_archtype(file); - elftype = elfsh_get_elftype(file); - ostype = elfsh_get_ostype(file); - if (archtype == ELFSH_ARCH_ERROR || - elftype == ELFSH_TYPE_ERROR || - ostype == ELFSH_OS_ERROR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ARGC handler unexistant for this ARCH/OS", NULL); - - dim[0] = archtype; - dim[1] = elftype; - dim[2] = ostype; - fct = aspect_vectors_select(argch, dim); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, fct(file, off, vaddr)); -} - - - - -/** - * Translate ELF architecture type into ELFsh architecture type - * - * @param file - * @return - */ -u_char elfsh_get_archtype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file argument!", (ELFSH_ARCH_ERROR)); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA32)); - case EM_SPARC: - case EM_SPARC32PLUS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC32)); - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC64)); - case EM_PARISC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PARISC)); - case EM_IA_64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA64)); - case EM_PPC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC32)); - case EM_PPC64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC64)); - case EM_SVX: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_CRAY)); - case EM_ALPHA: -#if EM_ALPHA != EM_ALPHA_EXP - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ALPHA64)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_MIPS32)); - case EM_ARM: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ARM)); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ERROR)); - } -} - - -/** - * Translate ELF object type into ELFsh object type - * @param file - * @return - */ -u_char elfsh_get_elftype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_objtype(file->hdr)) - { - case ET_EXEC: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_EXEC)); - case ET_DYN: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_DYN)); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_TYPE_ERROR)); - } -} - - -/** - * Retreive ELFsh OS type from ELF header - * @param file - * @return - */ -u_char elfsh_get_real_ostype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (file->hdr->e_ident[EI_OSABI]) - { - case ELFOSABI_LINUX: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_LINUX)); - case ELFOSABI_FREEBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_FREEBSD)); - case ELFOSABI_NETBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_NETBSD)); - case ELFOSABI_OPENBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_OPENBSD)); - case ELFOSABI_SOLARIS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_SOLARIS)); - case 0: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_ERROR)); - } -} - - -/** - * For now, always return the type of a userland process - * Need to be extended for the kernel memory type - * - * @param file - * @return - */ -u_char elfsh_get_hosttype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (E2DBG_HOST_PROC)); -} - - -/** - * Fill up ELFsh Operating System type - * - * @param file - * @return - */ -u_char elfsh_get_ostype(elfshobj_t *file) -{ - u_char *res; - char *interp; - char *end; - char r; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First try */ - r = elfsh_get_real_ostype(file); - switch (r) - { - /* Information not present */ - case 0: - break; - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r)); - } - - /* Smart intermediate way, fingerprint by .interp section */ - /* Not aware of any other software using this technique */ - if (elfsh_get_interp(file)) - { - if (!interp_hash.size) - { - hash_init(&interp_hash, "interpreters", 10, ASPECT_TYPE_STR); - hash_add(&interp_hash, - "/lib/ld-linux.so", - &elfsh_ostype[ELFSH_OS_LINUX]); - hash_add(&interp_hash, - "/usr/libexec/ld-elf.so", - &elfsh_ostype[ELFSH_OS_FREEBSD]); - hash_add(&interp_hash, - "/usr/libexec/ld-eld_so", - &elfsh_ostype[ELFSH_OS_NETBSD]); - hash_add(&interp_hash, - "??????????????", - &elfsh_ostype[ELFSH_OS_OPENBSD]); - hash_add(&interp_hash, - "/usr/lib/ld.so", - &elfsh_ostype[ELFSH_OS_SOLARIS]); - - } - - - /* Only useful for objects with .interp section */ - /* e.g. : ET_EXEC, and some special ET_DYN like libc */ - interp = (char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]); - end = strstr(".so", interp); - if (end) - *(end + 3) = 0x00; - res = hash_get(&interp_hash, interp); - if (res) - { - file->hdr->e_ident[EI_OSABI] = *res; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_real_ostype(file))); - } - } - - /* Fatalist */ -#if defined(__linux__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_LINUX); -#elif defined(__FreeBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_FREEBSD); -#elif defined(__NetBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_NETBSD); -#elif defined(__OpenBSD__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_OPENBSD); -#elif defined(sun) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_SOLARIS); -#elif defined(__BEOS__) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_BEOS); -#else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_ERROR); -#endif -} - -/** - * Return the page size - * - * @param file - * @return - */ -int elfsh_get_pagesize(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_archtype(file)) - { - case ELFSH_ARCH_IA32: - case ELFSH_ARCH_MIPS32: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4096); - case ELFSH_ARCH_SPARC32: - case ELFSH_ARCH_SPARC64: - case ELFSH_ARCH_PARISC: - case ELFSH_ARCH_IA64: - case ELFSH_ARCH_ALPHA64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 8192); - case ELFSH_ARCH_PPC32: - case ELFSH_ARCH_PPC64: - case ELFSH_ARCH_CRAY: - case ELFSH_ARCH_ERROR: - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", 0); - } -} - -/** - * Return the page size - * - * @param file - * @return - */ -u_int elfsh_get_breaksize(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_archtype(file)) - { - case ELFSH_ARCH_IA32: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - case ELFSH_ARCH_MIPS32: - case ELFSH_ARCH_SPARC32: - case ELFSH_ARCH_SPARC64: - case ELFSH_ARCH_PARISC: - case ELFSH_ARCH_ALPHA64: - case ELFSH_ARCH_PPC32: - case ELFSH_ARCH_PPC64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4); - case ELFSH_ARCH_IA64: - case ELFSH_ARCH_CRAY: - case ELFSH_ARCH_ERROR: - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", 0); - } -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/ia32.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/ia32.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/ia32.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/ia32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1136 +0,0 @@ -/** - * @file ia32.c - * @ingroup libelfsh - * ia32.c for libelfsh - * - * Started on Fri Jan 11 03:05:37 2003 jfv - * - * - * $Id: ia32.c,v 1.23 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" -#include "libasm.h" - -#define ELFSH_IA32_ARG_MAXSIZE 512 -#define ELFSH_IA32_PROLOG_MSTEP 3 -static asm_processor proc; -static u_char proc_init = 0; -static int args[ELFSH_TRACE_MAX_ARGS+1]; -static u_int arg_count; -static u_int max_arg_offset; - -#define ELFSH_IA32_PUSH_REGBASE(_i) \ -(_i.instr == ASM_PUSH \ - && _i.op[0].regset == ASM_REGSET_R32 \ - && (_i.op[0].content & ~ASM_OP_FIXED) == ASM_OP_BASE) - -#define ELFSH_IA32_MOV_REGBASE(_i, _reg) \ -(_i.instr == ASM_MOV \ - && _i.op[0].baser == _reg \ - && _i.op[1].baser == ASM_REG_ESP \ - && _i.op[0].regset == ASM_REGSET_R32 \ - && _i.op[1].regset == ASM_REGSET_R32 \ - && (_i.op[0].content & ~ASM_OP_FIXED) == ASM_OP_BASE \ - && (_i.op[1].content & ~ASM_OP_FIXED) == ASM_OP_BASE) - -/** - * Start of hook code for EXTPLT - * - * @param extplt - * @param altgot - * @param dynsym - * @param relplt - * @return - */ -int elfsh_extplt_ia32(elfshsect_t *extplt, - elfshsect_t *altgot, - elfshsect_t *dynsym, - elfshsect_t *relplt) -{ - int prot; - int *reloc; - eresi_Addr gotent; - elfsh_Rel r; - char *ent; - u_int relentsz; - elfshsect_t *plt; - elfshsect_t *got; - eresi_Addr diff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - plt = elfsh_get_plt(extplt->parent, NULL); - - /* Do we need to encode extplt entry ? */ - if (plt && extplt->curend >= plt->shdr->sh_size) - { - got = elfsh_get_gotsct(extplt->parent); - if (got) - { - diff = (eresi_Addr) altgot->shdr->sh_addr - got->shdr->sh_addr; - elfsh_reencode_pltentry_ia32(extplt->parent, extplt, diff, extplt->curend); - } - } - - /* 6 is the size of the first instruction of a .plt entry on x86 */ - gotent = extplt->shdr->sh_addr + extplt->curend + 6; - memcpy(elfsh_get_raw(altgot) + altgot->curend, - (char *) &gotent, sizeof(gotent)); - altgot->curend += sizeof(gotent); - -#if __DEBUG_EXTPLT__ - printf("[DEBUG_EXTPLT] Set ALTGOT entry " XFMT " to value " XFMT "\n", - altgot->shdr->sh_addr + altgot->curend, gotent); -#endif - - /* 7 is the offset for the relocation offset location, encoded in GOT */ - ent = elfsh_get_raw(extplt) + extplt->curend; - reloc = (int *) ((char *) ent + 7); - prot = elfsh_munprotect(extplt->parent, - (eresi_Addr) reloc, - (char *) reloc - (char *) elfsh_get_raw(extplt)); - *reloc = relplt->curend; - elfsh_mprotect((eresi_Addr) reloc, - (char *) reloc - (char *) elfsh_get_raw(extplt), prot); - extplt->curend += elfsh_get_pltentsz(extplt->parent); - - /* Insert relocation entry pointing on the new PLT entry */ - relentsz = IS_REL(extplt) ? sizeof(elfsh_Rel) : sizeof(elfsh_Rela); - r = elfsh_create_relent(R_386_JMP_SLOT, dynsym->curend / sizeof(elfsh_Sym), - altgot->shdr->sh_addr + altgot->curend - sizeof(eresi_Addr)); - memcpy(elfsh_get_raw(relplt) + relplt->curend, &r, relentsz); - relplt->curend += relentsz; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * On IA32 we need to reencode the PLT so that it uses the .alt.got instead of .got - * Should work on both ET_EXEC and ET_DYN (similar encoding offsets even if different jmp) - * - * @param file - * @param plt - * @param diff - * @param off - * @return - */ -int elfsh_reencode_pltentry_ia32(elfshobj_t *file, - elfshsect_t *plt, - uint32_t diff, - u_int off) -{ - char *pltent; - uint32_t *got; - elfshsect_t *relplt; - elfshsect_t *realplt; - u_int resoff; - int entsz; - u_int32_t *align; - u_int is_extplt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || plt == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* 12 is the size of 3 reserved PLT entries on x86 */ - is_extplt = !strcmp(plt->name, ELFSH_SECTION_NAME_EXTPLT); - - resoff = (is_extplt ? 12 : 0); - - if (is_extplt) - { - realplt = elfsh_get_plt(file, NULL); - - /* Do we need to copy previous element ? */ - if (off >= realplt->shdr->sh_size) - { - entsz = elfsh_get_pltentsz(file); - - /* We need at least one element */ - if (off < entsz + elfsh_get_first_pltentsz(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find a previous extplt element", -1); - - memcpy(plt->data + off, plt->data + off - entsz, entsz); - - pltent = plt->data + off + 12; - align = (uint32_t *) pltent; - *align -= 16; - - diff = resoff + 4; - } - } - - /* Add ALTGOT addr difference to the GOT offset encoded in PLT */ - pltent = plt->data + off + 2; - got = (uint32_t *) pltent; - *got += diff - resoff; - - /* If thats EXTPLT we are reencoding, shift the pushed reloc offsets as well */ - if (is_extplt) - { - relplt = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RELPLT, 0, 0, 0); - if (relplt == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive .rel.plt", -1); - - pltent = plt->data + off + 7; - got = (uint32_t *) pltent; - *got = relplt->shdr->sh_size; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * On IA32 we need to reencode the PLT so that it uses the .alt.got instead of .got - * Should work on both ET_EXEC and ET_DYN - * - * @param file - * @param plt - * @param diff - * @return - */ -int elfsh_reencode_first_pltentry_ia32(elfshobj_t *file, - elfshsect_t *plt, - uint32_t diff) -{ - char *pltent; - uint32_t *got; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || plt == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* The first GOT address is at offset .plt+2 on IA32 */ - pltent = plt->data + 2; - got = (uint32_t *) pltent; - *got += diff; - - /* The second GOT address is at offset .plt+8 on IA32 */ - pltent = plt->data + 8; - got = (uint32_t *) pltent; - *got += diff; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Hook for ENCODEPLT1 on IA32 : Simple wrapper for both calls - * - * @param file - * @param plt - * @param extplt - * @param diff - * @return - */ -int elfsh_encodeplt1_ia32(elfshobj_t *file, - elfshsect_t *plt, - elfshsect_t *extplt, - eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (elfsh_reencode_first_pltentry_ia32(file, plt, diff) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Reencoding of PLT+0 failed", -1); - - if (elfsh_reencode_first_pltentry_ia32(file, extplt, diff) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Reencoding of EXTPLT+0 failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Hook for ENCODEPLT on IA32 - * - * @param file - * @param plt - * @param diff - * @param off - * @return - */ -int elfsh_encodeplt_ia32(elfshobj_t *file, - elfshsect_t *plt, - eresi_Addr diff, - u_int off) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (elfsh_reencode_pltentry_ia32(file, plt, diff, off) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Reencoding of PLT+0 failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Static hooking for IA32 - * @param file - * @param name - * @param symbol - * @param addr - * @return - */ -int elfsh_cflow_ia32(elfshobj_t *file, - char *name, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - elfshsect_t *hooks; - elfshsect_t *source; - asm_instr instrs[5]; - u_char buff[32]; - u_int ret, len; - int off; - int idx; - char *hookbuf; - char *hook; - char bufname[BUFSIZ]; - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_CFLOW__ - printf("[DEBUG_CFLOW] Requesting hijack addr = %08X, sym.st_value = %08X, name = %s\n", - addr, symbol->st_value, name); -#endif - - /* Resolve parameters */ - off = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - if (!off) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid address to hijack", -1); - - ret = elfsh_raw_read(file, off, buff, 32); - if (ret != 32) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function too small to be hijacked", -1); - - /* If the hook section does not exist, create it */ - hooks = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HOOKS, - 0, 0, 0); - - if (!hooks) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get and inject .hooks", -1); - - hook = elfsh_get_raw(hooks) + hooks->curend; - - /* Determine the minimal aligned length */ - if (!proc_init) - { - asm_init_ia32(&proc); - proc_init = 1; - } - for (idx = ret = 0; ret < 5 && idx < 5; idx++) - ret += asm_read_instr(instrs + idx, buff + ret, 32 - ret, &proc); - - /* Create the hook for this function */ - prot = elfsh_munprotect(file, (eresi_Addr) hook, 16); - memset(hook, 0x90, 40); - memcpy(hook, "\xe9\x00\x00\x00\x00", 5); - *(uint32_t *) ((char *) hook + 1) = addr - (hooks->shdr->sh_addr + (hook + 1 - (char *) elfsh_get_raw(hooks)) + 4); - memcpy(hook + 5, buff, ret); - memcpy(hook + 5 + ret, "\xe9\x00\x00\x00\x00", 5); - *(uint32_t *) ((char *) hook + 6 + ret) = symbol->st_value - (hooks->shdr->sh_addr + hooks->curend + 10); - elfsh_mprotect((eresi_Addr) hook, 16, prot); - - /* We need to grab the parent section to compute the remaining offset */ - source = elfsh_get_parent_section_by_foffset(file, off, NULL); - if (!source) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section for hooked addr", -1); - - /* Install the hook */ -#if __DEBUG_CFLOW__ - printf("[DEBUG_CFLOW] Installing hook with addr %08X (curhookent addr = %08X with curend = %u symbol.st_value %08X) \n", - ((hooks->shdr->sh_addr + hooks->curend) - (symbol->st_value + 5)), - (hooks->shdr->sh_addr + hooks->curend), hooks->curend, symbol->st_value); -#endif - - /* Ret: the minimal instruction aligned length for installing the hook caller-side properly */ - hookbuf = alloca(ret); - //prot = elfsh_munprotect(hookbuf, 16); - memcpy(hookbuf, "\xe9\x00\x00\x00\x00", 5); - *(uint32_t *) ((char *) hookbuf + 1) = (hooks->shdr->sh_addr + hooks->curend) - (symbol->st_value + 5); - memset(hookbuf + 5, 0x90, ret - 5); - len = elfsh_raw_write(file, off, hookbuf, ret); - if (len != ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during hook installation", -1); - //elfsh_mprotect(hookbuf, 16, prot); - - /* Insert the old symbol on the original saved bytes (do the insertion AFTER all use of symbol !!) */ - snprintf(bufname, BUFSIZ, "old_%s", name); - elfsh_insert_funcsym(file, bufname, hooks->shdr->sh_addr + hooks->curend + 5, - ret + 5, hooks->index); - snprintf(bufname, BUFSIZ, "hook_%s", name); - elfsh_insert_funcsym(file, bufname, hooks->shdr->sh_addr + hooks->curend, - ret + 10, hooks->index); - - - -#if __DEBUG_CFLOW__ - printf("[DEBUG_CFLOW] hook_legit_func = %08X, old_legit_func = %08X \n", - hooks->shdr->sh_addr + hooks->curend, - hooks->shdr->sh_addr + hooks->curend + 5); -#endif - - /* Everything OK, ret usually is 6 on x86 */ - hooks->curend += ret + 10; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * PLT hijacking on i386 for ET_DYN objects - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_ia32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint8_t opcode; - uint32_t displacement; - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_386) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "File is not IA32", -1); - - /* Compute jmp displacement, 5 is the length of jmp opcode */ - /* Direct jmp with full displacement */ - opcode = 0xE9; - displacement = addr - symbol->st_value - 5; - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - prot = elfsh_munprotect(file, - symbol->st_value, - elfsh_get_pltentsz(file)); - elfsh_raw_write(file, foffset, &opcode, sizeof(opcode)); - - /* Byte order test for cross-endianess ability */ -#if __BYTE_ORDER == __BIG_ENDIAN - displacement = swap32(displacement); - elfsh_raw_write(file, foffset + sizeof(opcode), - &displacement, sizeof(displacement)); -#else - elfsh_raw_write(file, foffset + sizeof(opcode), - &displacement, sizeof(displacement)); -#endif - - elfsh_mprotect(symbol->st_value, - elfsh_get_pltentsz(file), prot); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Perform relocation on entry for INTEL architecture. - * XXX: not endianess independant - ym - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_ia32(elfshsect_t *new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - elfsh_Shdr *section; - elfsh_Sym *symbol; - char *symname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_reltype(cur)) - { - - /* Absolute reference */ - case R_386_32: - *dword = addr; - break; - - /* Relative reference */ - case R_386_PC32: - *dword = addr - (new->shdr->sh_addr + cur->r_offset + 4); - break; - - case R_386_GOT32: - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOTPLT); - if (section == NULL) - { - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOT); - if (!section) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find GOT for GOTPC", -1); - } - *dword = cur->r_offset - section->sh_addr; - break; - - case R_386_PLT32: - if (elfsh_static_file(new->parent)) - { -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] R_386_PLT32 on STATIC file : %s \n", - new->parent->name); -#endif - symname = elfsh_get_symname_from_reloc(mod->parent, cur); -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] R_386_PLT32 : %s\n", symname); -#endif - if (symname == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol name", -1); - - - symbol = elfsh_get_symbol_from_reloc(mod->parent, cur); - if (symbol == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol", -1); - *dword = symbol->st_value + addr - (new->shdr->sh_addr + cur->r_offset + 4); - } - else - { - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_PLT); - if (section == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find PLT fot PLT32", -1); - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] R_386_PLT32: *dword value was %08X \n", *dword); -#endif - - /* Basicaly the same */ - *dword = addr - (new->shdr->sh_addr + cur->r_offset + 4); - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] R_386_PLT32 on DYNAMIC file : set dword[*%08X] = %08X (reach PLT entry %08X) \n", - new->shdr->sh_addr + cur->r_offset, *dword, addr); -#endif - - } - break; - - case R_386_GOTOFF: - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOTPLT); - if (section == NULL) - { - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOT); - if (!section) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find GOT for GOTPC", -1); - } - *dword = addr - section->sh_addr; - break; - - case R_386_GOTPC: - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOTPLT); - if (section == NULL) - { - section = elfsh_get_sht_entry_by_name(new->parent, - ELFSH_SECTION_NAME_GOT); - if (!section) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find GOT for GOTPC", -1); - } - *dword = section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2; - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] R_386_GOTPC : *dword=%08X, non added *dword was %08X \n", - section->sh_addr - (new->shdr->sh_addr + cur->r_offset) + 2, *dword); -#endif - - break; - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported relocation type", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Personnal func / define for args_count - * - * @param op - * @param regbased - * @return - */ -static int elfsh_ac_is_arg_ebp(asm_operand *op, int regbased) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* imm value must be superior to 4 because it is return addr - malloc() use to look at the return address which make arg count - think that malloc should take 2 arguments. - */ - if (op->baser == regbased && op->imm > 4) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, op->imm); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -static int elfsh_ac_is_arg_esp(asm_operand *op, int sub) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (op->baser == ASM_REG_ESP && op->imm > sub) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, op->imm - sub); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * - * @param add - * @return - */ -static int elfsh_ac_largs_add(int add) -{ - u_int index; -#if __DEBUG_ARG_COUNT__ - u_int z; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (add == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Empty list or next value is > to current max_arg_offset */ - if ((arg_count == 0 && args[arg_count] == 0) - || max_arg_offset < add) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] MAX OR FIRST = %d\n", add); -#endif - - max_arg_offset = add; - args[arg_count++] = add; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Already got it */ - if (max_arg_offset == add) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] ALREADY = %d\n", add); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - for (index = 0; index < ELFSH_TRACE_MAX_ARGS; index++) - { - /* Already add ? */ - if (args[index] == add) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] ALREADY = %d\n", add); -#endif - - break; - } - - /* We sort result */ - if (args[index] > add) - { - if (arg_count == ELFSH_TRACE_MAX_ARGS) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] MAX ARGUMENT\n"); -#endif - - arg_count--; - } - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] Next values (b):\n"); - - for (z = index; z < arg_count; z++) - printf("[DEBUG_ARG_COUNT] :%d -> %d\n", z, args[z]); -#endif - - /* Move arguments */ - memmove(&args[index + 1], &args[index], (arg_count - index)*sizeof(int)); - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] Next values (a):\n"); - - for (z = index; z < arg_count + 1; z++) - printf("[DEBUG_ARG_COUNT] :%d -> %d\n", z, args[z]); -#endif - - args[index] = add; - arg_count++; - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* -Used with Forward analysis -TODO: Keep it ? -static eresi_Addr elfsh_ac_foundcallto(elfshobj_t *file, eresi_Addr vaddr, eresi_Addr *before) -{ - u_int index; - asm_instr i; - int ret; - elfsh_SAddr foffset; - elfsh_Word len; - elfshsect_t *text; - char *data; - eresi_Addr base_vaddr, last_vaddr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &foffset); - if (!text) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section from entry point", 0); - - if (!elfsh_get_anonymous_section(file, text)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get an anonymous section", 0); - - data = elfsh_get_raw(text); - len = text->shdr->sh_size; - - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? - file->rhdr.base + elfsh_get_section_addr(text->shdr) : - elfsh_get_section_addr(text->shdr)); - - last_vaddr = base_vaddr; - - for (index = 0; index < len; index += ret) - { - // Read an instruction - if ((ret = asm_read_instr(&i, (u_char *) (data + index), len - index, &proc))) - { - // Search a call to our address (near call) - if (i.instr == ASM_CALL) - { - if (base_vaddr + index + i.op[0].imm + i.len == vaddr) - { - if (before) - *before = last_vaddr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, base_vaddr + index); - } - last_vaddr = base_vaddr + index; - } - else if (i.instr == ASM_RET) - { - last_vaddr = base_vaddr + index; - } - } - - if (ret <= 0) - ret = 1; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} -*/ - -/** - * - * @param file - * @param vaddr - * @return - */ -static char *elfsh_ac_get_sect_ptr(elfshobj_t *file, eresi_Addr vaddr) -{ - elfshsect_t *sect; - elfsh_SAddr foffset; - char *buf = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = elfsh_get_parent_section(file, vaddr, &foffset); - - if (sect) - { - buf = elfsh_get_raw(sect); - buf += vaddr - (sect->parent->rhdr.base + sect->shdr->sh_addr); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); -} - -/** - * TODO: implement forward / backward - * - * @param file - * @param foffset - * @param vaddr - * @return - */ -int *elfsh_args_count_ia32(elfshobj_t *file, u_int foffset, eresi_Addr vaddr) -{ - int index; - int ret; - int reserv = 0; - int ffp = 1; - const int asm_len = 1024; - //int len = 0; - int *final_args; - //eresi_Addr f_vaddr, up_vaddr; - asm_instr i; - char *data; - int op; - u_char prolog_setup = 0; - u_int icount, regicount; - int regbased = -1; - int next_regbased = -1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!proc_init) - { - asm_init_ia32(&proc); - proc_init = 1; - } - max_arg_offset = 0; - - /* Find the real function if this vaddr point to plt section */ - elfsh_resolv_remote_function(file, vaddr, &file, &vaddr); - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] Arg count into file: %s with addr: 0x%x \n", file->name, vaddr); -#endif - - data = elfsh_ac_get_sect_ptr(file, vaddr); - - if (!data) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - /* Prepare args */ - memset(args, 0x00, (ELFSH_TRACE_MAX_ARGS+1)*sizeof(int)); - arg_count = 0; - - reserv = 0; - regicount = 0; - - /* Enumerate all arguments */ - for (icount = index = 0; index < asm_len && data; index += ret, icount++) - { - /* Read an instruction */ - if ((ret = asm_read_instr(&i, (u_char *) (data + index), asm_len - index, &proc)) > 0) - { - /* After 10 instruction, - no prolog anlysis should be done */ - if (!prolog_setup && icount == 10) - prolog_setup = 1; - - /* We don't want to read another function */ - if (i.instr == ASM_RET) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] RET @ +%d (%x)\n", index, index); -#endif - break; - } - - /* Seek if we are near a ebp like prolog */ - if (!prolog_setup) - { - if (ELFSH_IA32_PUSH_REGBASE(i)) - { - /* We register pushed register and go to see if - next instruction will be a mov $reg, $esp (look after) - - This detection algorithm has been update for getopt() - where I found a dispositin like this: - - push $ebp - xor $eax, $eax - mov $ebp, $esp - */ - regbased = i.op[0].baser; - regicount = 0; - } - else if (regbased != -1) - { - /* mov %reg, %esp */ - if (ELFSH_IA32_MOV_REGBASE(i, regbased)) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] EBP like based found @ +%d (%x) / reg = %d\n", - index, index, regbased); -#endif - - /* We have a ebp like register, then prolog is found - and now we will see for argument based on it */ - prolog_setup = 1; - ffp = 0; - continue; - } - - /* We use a counter to control how many instruction can be behind - the push & the mov */ - if (regicount < ELFSH_IA32_PROLOG_MSTEP) - regicount++; - else - regbased = -1; /* Reset based register */ - } - } - else - { - /* TODO: Find a better way to find function end */ - if (ELFSH_IA32_PUSH_REGBASE(i)) - { - /* This time we try to see if we reach another function - Some function does not rely on ret - This fix has been made for my exit() function which did not - has a ret, then we start parsing on_exit() */ - next_regbased = i.op[0].baser; - regicount = 0; - } - else - { - /* If its true, we reached another function */ - if (ELFSH_IA32_MOV_REGBASE(i, next_regbased)) - break; - - if (regicount < ELFSH_IA32_PROLOG_MSTEP) - regicount++; - else - next_regbased = -1; /* Reset based register */ - } - - } - - if (ffp == 0) - { - /* EBP based argument */ - op = elfsh_ac_is_arg_ebp(&i.op[0], regbased); - - if (op > 0) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] EBP (1) @ +%d (%x) - %d\n", index, index, op); -#endif - elfsh_ac_largs_add(op); - } - - op = elfsh_ac_is_arg_ebp(&i.op[1], regbased); - - if (op > 0) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] EBP (2) @ +%d (%x) - %d\n", index, index, op); -#endif - elfsh_ac_largs_add(op); - } - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] @ +%d (%x) i.instr = %d\n", index, index, i.instr); -#endif - } - else - { - /* sub $esp, x */ - if (i.instr == ASM_SUB && i.op[0].baser == ASM_REG_ESP) - { - reserv += i.op[1].imm; - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, - i.op[1].imm, reserv); -#endif - continue; - } - /* add $esp, x */ - else if (i.instr == ASM_ADD && i.op[0].baser == ASM_REG_ESP) - { - reserv -= i.op[1].imm; - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, - i.op[1].imm, reserv); -#endif - continue; - } - - /* ESP based argument */ - op = elfsh_ac_is_arg_esp(&i.op[0], reserv); - - if (op > 0) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] ESP (1) @ +%d (%x) - %d\n", index, index, op); -#endif - elfsh_ac_largs_add(op); - } - - op = elfsh_ac_is_arg_esp(&i.op[1], reserv); - - if (op > 0) - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] ESP (2) @ +%d (%x) - %d\n", index, index, op); -#endif - elfsh_ac_largs_add(op); - } - - /* On esp based functions, sometimes compiler optimisation is to not - clear argument after a call (just at the end). Then we need to update - stack state. Problem found in setupterm() */ - if (i.instr == ASM_PUSH) - { - reserv += sizeof(eresi_Addr); -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) += %d / %d\n", index, index, - sizeof(eresi_Addr), reserv); -#endif - } - else if (i.instr == ASM_POP) - { - reserv -= sizeof(eresi_Addr); -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] reserv @ +%d (%x) -= %d / %d\n", index, index, - sizeof(eresi_Addr), reserv); -#endif - } - else - { -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] @ +%d (%x) i.instr = %d\n", index, index, i.instr); -#endif - } - } - } - else - break; - - ret = asm_instr_len(&i); - if (!ret) - ret++; - } - - /* Do we have something ? */ - /* - if (arg_count > 0) - goto setargs; - */ - - /** - * Backward anlysis - * We analyse a call to a specific function - * TODO: Keep this part ? at least optimise it. Seeking a call everytime is too long - - f_vaddr = elfsh_ac_foundcallto(file, vaddr, &up_vaddr); - - if (f_vaddr > 0) - { - data = elfsh_ac_get_sect_ptr(file, up_vaddr); - len = f_vaddr - up_vaddr; - - for (index = 0; index < len && data ; index += ret) - { - // Read an instruction - if ((ret = asm_read_instr(&i, (u_char *) (data + index), len - index, &proc))) - { - // We don't want to read another function - if (i.instr == ASM_MOV && i.op[0].baser == ASM_REG_ESP) - elfsh_ac_largs_add(i.op[0].imm + 16); - } - - ret = asm_instr_len(&i); - if (!ret) - ret++; - } - } - - - setargs: - */ - - /* No arguments */ - if (arg_count == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find arguments", NULL); - - /* Add first offset - Sometimes first argument is not use (__xstat64() case) - which creates a bug into arguments number - Offset 8 should always be first argument */ - elfsh_ac_largs_add(0x8); - - for (index = 0; index < ELFSH_TRACE_MAX_ARGS && index < arg_count; index++) - { - /* Last entry */ - if (index + 1 == arg_count) - { - /* Can't know last argument size, presume eresi_Addr - size. This issue seems impossible to resolve without - an advanced analyse engine */ - args[index] = (int) sizeof(eresi_Addr); - } - else - { - /* Argument size is next_offset - my_offset */ - args[index] = args[index + 1] - args[index]; - } - - /* Aligned on address size (at least) */ - if (args[index] < (int) sizeof(eresi_Addr) - || args[index] > ELFSH_IA32_ARG_MAXSIZE) - args[index] = (int) sizeof(eresi_Addr); - } - - XALLOC(__FILE__, __FUNCTION__, __LINE__, final_args, - (arg_count + 1) * sizeof(int), NULL); - - /* Copy current arguments */ - memcpy(final_args, args, (arg_count + 1) * sizeof(int)); - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] arg_count = %d\n[DEBUG_ARG_COUNT] RETURN LIST:\n", arg_count); - - for (index = 0; index < arg_count + 1; index++) - printf("[DEBUG_ARG_COUNT] [%02d] %d\n", index, final_args[index]); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, final_args); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/ia64.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/ia64.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/ia64.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/ia64.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/** - * @file ia64.c - * @ingroup libelfsh -** ia64.c for libelfsh -** -** Started on Sat Feb 26 23:25:37 2005 jfv -** -** Skeleton cut & pasted from the sparc64 backend -** -** -** $Id: ia64.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Static hooking for IA64 - * @param null - * @param sname - * @param null2 - * @param null3 - * @return - */ -int elfsh_cflow_ia64(elfshobj_t *null, - char *sname, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - -/** - * PLT hijacking on IA64 - * - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_ia64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * ALTPLT hijacking on IA64 - * - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_altplt_ia64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * Perform relocation on entry for IA64 architecture - * - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_ia64(elfshsect_t *new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - int retval; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retval = 0; - switch (elfsh_get_reltype((elfsh_Rel *)cur)) - { - /* cases ... */ - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unsupported relocation type", - -1); - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/inject.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/inject.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/inject.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1079 +0,0 @@ -/** - * @file inject.c - * @ingroup libelfsh -** inject.c for libelfsh -** -** Contains all section injection API that can be used directly by the user -** -** Started on Thu Jun 09 00:12:42 2005 mm -** -** -** $Id: inject.c,v 1.15 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - - -/** - * Insert a new section at the first place in the executable PT_LOAD - * This function is not e2dbg safe and should only be used for ondisk files - * This function is ET_DYN-PaX-pie-hardened-gentoo-safe - * @param file - * @param sect - * @param hdr - * @param data - * @param mod - * @return - */ -int elfsh_insert_code_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int mod) -{ - elfshsect_t *first; - elfsh_Phdr *phdr; - elfsh_Phdr *cur; - int range; - char *rdata; - u_int rsize; - u_int index; - int err; - elfshsect_t *relsect; - int check; - eresi_Addr entrypoint; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get SHT", -1); - - /* Find the first executable PT_LOAD segment */ - range = 0; - do - { - phdr = elfsh_get_segment_by_type(file, PT_LOAD, range); - range++; - } - while (phdr && !elfsh_segment_is_executable(phdr)); - - if (phdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find +x PT_LOAD", -1); - - /* If the executable segment starts at low address, use - alternative code section injection */ - if (phdr->p_vaddr <= ELFSH_SPARC_LOWADDR && - (elfsh_get_archtype(file) == ELFSH_ARCH_SPARC32 || - elfsh_get_archtype(file) == ELFSH_ARCH_SPARC64)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_insert_code_section_up(file, sect, hdr, data, mod))); - - /* FIXME: just a try on recent ld */ - /* So that file offset and vaddr and aligned */ - else if (elfsh_get_archtype(file) == ELFSH_ARCH_SPARC32 || - elfsh_get_archtype(file) == ELFSH_ARCH_SPARC64) - elfsh_set_segment_align(phdr, elfsh_get_pagesize(file)); - - /* Find the first allocatable section */ - first = file->sectlist; - while (!first->shdr->sh_addr) - first = first->next; - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Guard section found : %s (first->next = %p) \n", first->name, first->next); -#endif - - if (first == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find guard section", -1); - - /* Pad the new section if needed */ - /* I KEEP OLD METHOD ON COMMENT (IN CASE) - if (mod && (hdr.sh_size % mod)) - { - rsize = hdr.sh_size + mod - (hdr.sh_size % mod); - XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - hdr.sh_size = rsize; - data = rdata; - } - */ - - /* New method that how we should do no ? */ - check = (phdr->p_vaddr - phdr->p_offset) & (phdr->p_align - 1); - if (check != 0) - { - rsize = hdr.sh_size + (check + 1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - hdr.sh_size = rsize; - data = rdata; - } - -#ifdef __BEOS__ - if (first->shdr->sh_addr < hdr.sh_size) - printf("Trap Error: sh_addr < sh_size !\n"); -#endif - - /* Extend the first loadable segment at low addresses */ - if (elfsh_get_objtype(file->hdr) != ET_DYN) - hdr.sh_addr = first->shdr->sh_addr - hdr.sh_size; - else - hdr.sh_addr = first->shdr->sh_addr; - hdr.sh_offset = first->shdr->sh_offset; - - /* Fixup the file offset */ - phdr->p_filesz += hdr.sh_size; - phdr->p_memsz += hdr.sh_size; - - /* On ET_DYN, we put the new section at the end, so we dont do this */ - if (elfsh_get_objtype(file->hdr) != ET_DYN) - { - phdr->p_vaddr -= hdr.sh_size; - phdr->p_paddr -= hdr.sh_size; - } - - entrypoint = elfsh_get_entrypoint(file->hdr); - - /* Fixup file offset for all loadable segments and fixup PHDR base vaddr */ - for (range = 0, cur = file->pht; range < file->hdr->e_phnum; range++) - { - /* That's how we shift on ET_EXEC */ - if (cur[range].p_type == PT_PHDR && - elfsh_get_objtype(file->hdr) != ET_DYN) - { - cur[range].p_vaddr -= hdr.sh_size; - cur[range].p_paddr -= hdr.sh_size; - } - else if (cur + range != phdr && cur[range].p_offset >= hdr.sh_offset) - { - cur[range].p_offset += hdr.sh_size; - - /* That's how we shift the address space on ET_DYN */ - if (elfsh_get_objtype(file->hdr) == ET_DYN) - { - cur[range].p_vaddr += hdr.sh_size; - cur[range].p_paddr += hdr.sh_size; - } - } - } - - /* Inject our section with the associated header */ - index = first->index; - if (elfsh_insert_shdr(file, hdr, index, sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert shdr", -1); - - if (elfsh_add_section(file, sect, index, data, - elfsh_get_objtype(file->hdr) == ET_DYN ? - ELFSH_SHIFTING_COMPLETE : ELFSH_SHIFTING_PARTIAL) < 0) - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - /* Shift stuff in the ET_DYN */ - if (elfsh_get_objtype(file->hdr) == ET_DYN) - { - for (index = 0; 1; index++) - { - relsect = elfsh_get_reloc(file, (eresi_Addr) index, NULL); - if (!relsect) - { - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not a single relo table found", -1); - break; - } - err = elfsh_shift_ia32_relocs(file, hdr.sh_size, relsect, - sect->shdr->sh_addr + sect->shdr->sh_size); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Problem while shifting relocs", -1); - } - - err = elfsh_shift_symtab(file, sect->shdr->sh_addr, hdr.sh_size); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift symtab in ET_DYN", -1); - - err = elfsh_shift_dynsym(file, sect->shdr->sh_addr, hdr.sh_size); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift dynsym in ET_DYN", -1); - - elfsh_update_dynsym_shidx(file, sect->index - 1, 1); - elfsh_update_symtab_shidx(file, sect->index - 1, 1); - - if (elfsh_shift_dynamic(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift dynamic in ET_DYN", -1); - - if (elfsh_shift_got(file, sect->shdr->sh_size, - ELFSH_SECTION_NAME_GOT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift .got in ET_DYN", -1); - - if (elfsh_shift_got(file, sect->shdr->sh_size, - ELFSH_SECTION_NAME_GOTPLT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift .got.plt in ET_DYN", -1); - - /* ALTGOT section is not present in unmodified binaries so its not a fatal error */ - elfsh_shift_got(file, sect->shdr->sh_size, ELFSH_SECTION_NAME_ALTGOT); - - if (elfsh_shift_dtors(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift dtors in ET_DYN", -1); - - if (elfsh_shift_ctors(file, sect->shdr->sh_size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot shift ctors in ET_DYN", -1); - - elfsh_set_entrypoint(file->hdr, elfsh_get_entrypoint(file->hdr) + sect->shdr->sh_size); - } - - - /* Inject the SECT symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert section symbol", -1); - - - /* Okay ! */ - sect->phdr = phdr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - - -/** - * Insert a new section at the first place in the executable PT_LOAD - * WORK IN PROGRESS DO NOT USE IT FOR NOW - * This function is not e2dbg safe and should only be used for ondisk files - * - * @param file - * @param sect - * @param hdr - * @param data - * @param mod - * @return - */ -int elfsh_insert_code_section_up(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int mod) -{ - elfshsect_t *last; - elfsh_Phdr *phdr; - elfsh_Phdr *phdr_code; - elfsh_Phdr *phdr_data; - elfsh_Phdr *cur; - int range; - char *rdata; - u_int rsize; - u_int alignedsize; - u_int alignedsize2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", -1); - - /* Find both PT_LOAD segment */ - phdr_code = phdr_data = NULL; - range = 0; - do - { - phdr = elfsh_get_segment_by_type(file, PT_LOAD, range); -#if __DEBUG_RELADD__ - printf("Found PT_LOAD at range %u \n", range); -#endif - if (!phdr) - break; - range++; - if (elfsh_segment_is_executable(phdr)) - { - if (!elfsh_segment_is_writable(phdr)) - phdr_code = phdr; - else - phdr_data = phdr; - } - } - while (phdr); - - if (phdr_code == NULL || phdr_data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find 2 PT_LOAD", -1); - - /* Find the last section of the executable PT_LOAD */ - last = file->sectlist; - while (!last->phdr || last->phdr->p_vaddr < phdr_data->p_vaddr) - last = last->next; - if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find last +X section", -1); - - last = last->prev; - - /* Pad the new section if needed */ - if (mod && (hdr.sh_size % mod)) - { - rsize = hdr.sh_size + mod - (hdr.sh_size % mod); - XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - hdr.sh_size = rsize; - data = rdata; - } - -#ifdef __BEOS__ - if (last->shdr->sh_addr < hdr.sh_size) - printf("Trap Error: sh_addr < sh_size !\n"); -#endif - - /* Extend the executable segment at high addresses */ - hdr.sh_addr = last->shdr->sh_addr + last->shdr->sh_size; - hdr.sh_offset = last->shdr->sh_offset + last->shdr->sh_size; - phdr_code->p_filesz += hdr.sh_size; - phdr_code->p_memsz += hdr.sh_size; - - /* Fixup file offset for all loadable segments and fixup PHDR base vaddr */ - alignedsize = alignedsize2 = 0; - elfsh_set_segment_align(phdr_code, elfsh_get_pagesize(file)); - - /* This section injection requires strong alignment constraints */ - for (range = 0, cur = file->pht; range < file->hdr->e_phnum; range++) - if (cur != phdr_code && cur[range].p_offset >= last->shdr->sh_offset) - { - cur[range].p_offset += hdr.sh_size + alignedsize2; // + alignedsize2; - if (elfsh_get_segment_type(cur + range) == PT_LOAD) - { - elfsh_set_segment_align(cur + range, elfsh_get_pagesize(file)); - - /* Align on file offset */ - /* - if (cur[range].p_offset % elfsh_get_pagesize(file)) - { - printf("Found misaligned foffset in phdr index %u (diff = %u) \n", - range, cur[range].p_offset % elfsh_get_pagesize(file)); - alignedsize = elfsh_get_pagesize(file) - (cur[range].p_offset % elfsh_get_pagesize(file)); - cur[range].p_offset += alignedsize; - } - else - printf("foffset align test not entered\n"); - */ - - /* Align on virtual addr vs file offset */ - if ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)) - { -#if __DEBUG_RELADD__ - printf("Found misaligned off/addr in phdr index %u (diff = %u) \n", - range, (cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); -#endif - alignedsize2 = elfsh_get_pagesize(file) - ((cur[range].p_vaddr - cur[range].p_offset) % elfsh_get_pagesize(file)); - cur[range].p_offset += alignedsize2; - } -#if __DEBUG_RELADD__ - else - printf("vaddr-foffset align test not entered\n"); -#endif - } - } - - /* Inject our section with the associated header */ - if (elfsh_insert_shdr(file, hdr, last->index + 1, sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert shdr", -1); - - if (elfsh_add_section(file, sect, last->index + 1, - data, ELFSH_SHIFTING_PARTIAL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - /* Inject the SECT symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert section symbol", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - - - - -/** - * Insert a data section in the object - * This function is not e2dbg safe and should only be used with ondisk files - * Use elfsh_insert_runtime_section() for runtime injections - * - * @param file - * @param sect - * @param hdr - * @param data - * @return - */ -int elfsh_insert_data_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data) -{ - elfshsect_t *last; - void *rdata; - u_int pad = 0; - elfsh_Phdr *phdr = NULL, *phdr2 = NULL; - u_int range; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", -1); - - /* Insert the bss physically in the file if not already done */ - if (elfsh_fixup_bss(file) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot fixup .bss", -1); - - /* Find the PHDR */ - range = 0; - do - { - phdr2 = phdr; - phdr = elfsh_get_segment_by_type(file, PT_LOAD, range); - range++; - } - while (phdr); - phdr = phdr2; - if (phdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find last PT_LOAD", -1); - - /* Iterate and get the real last mapped section */ - last = file->sectlist; - while (last->next != NULL && last->next->shdr->sh_addr != NULL) - last = last->next; - last->phdr = phdr; - - /* Avoid unaligned accesses */ - if ((last->shdr->sh_addr + last->shdr->sh_size) % sizeof(eresi_Addr)) - pad = sizeof(eresi_Addr) - ((last->shdr->sh_addr + last->shdr->sh_size) % sizeof(eresi_Addr)); - -#if __DEBUG_RELADD__ - if (pad) - printf("[DEBUG_RELADD] Small gap of %u bytes between %s and %s \n", - pad, last->name, sect->name); -#endif - - /* Extend the segment to insert the new section */ - hdr.sh_addr = last->shdr->sh_addr + last->shdr->sh_size + pad; - hdr.sh_offset = last->shdr->sh_offset + last->shdr->sh_size + pad; - last->phdr->p_filesz += hdr.sh_size + pad; - last->phdr->p_memsz += hdr.sh_size + pad; - - /* Copy the data */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, hdr.sh_size, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - - /* Inject our section with the associated header */ - if (elfsh_insert_shdr(file, hdr, last->index + 1, sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); - - if (elfsh_add_section(file, sect, last->index + 1, - rdata, ELFSH_SHIFTING_COMPLETE) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - - /* Next pointers will be updated, we need them for padding */ - last = elfsh_get_section_by_name(file, sect->name, 0, 0, 0); - if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive injected section", -1); - - /* Inject the SECT symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - - -/** - * - * This function need to be modularized so that it can serves for runtime mapping - * and also static file mapping in new PT_LOAD. Since thats what this function do - * it shouldnt be a problem. Just a thing to check : make sure the (real) PHT can - * be extended from this function, because PHT extension uses another injection - * internaly so I hope nothing is fucked up -mm - * - * Make sure also to use a dedicated base addr for the new section if you re - * debugging heap sensible code. - * - * Runtime injection : the standard process injection - * - * @param file - * @param sect - * @param hdr - * @param data - * @param mode - * @param mod - * @return - */ -int elfsh_insert_runtime_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int mod) -{ - elfsh_Phdr phdr; - u_int rsize; - char *rdata; - int range; - /* - elfshsect_t *bss; - */ - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Grab the BSS */ - /* - bss = elfsh_get_section_by_name(file, - ELFSH_SECTION_NAME_BSS, - NULL, NULL, NULL); - if (!bss) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find ondisk BSS", -1); - while (bss->next) - bss = bss->next; - */ - - /* Pad the new section if needed */ - if (mod && (hdr.sh_size % mod)) - { - rsize = hdr.sh_size + mod - (hdr.sh_size % mod); - XALLOC(__FILE__, __FUNCTION__, __LINE__, rdata, rsize, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - else - memset(rdata, 0x00, hdr.sh_size); - hdr.sh_size = rsize; - data = rdata; - } - - /* If someone provided a NULL data pointer, provide a zero'd zone */ - else - { - rsize = hdr.sh_size; - if (!data) - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, rsize, -1); - } - - /* Create and inject the new PT_LOAD in runtime */ - phdr = elfsh_create_phdr(PT_LOAD, 0, rsize, mod); - - /* In runtime static binary injection, we need a safe p_vaddr each time we call this function */ - phdr.p_flags = elfsh_set_phdr_prot(mode); - phdr.p_vaddr = elfsh_runtime_map(&phdr); - if (phdr.p_vaddr == ELFSH_INVALID_ADDR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot runtime map", -1); - - /* Copy the data in memory */ -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Writing data (%p) in memory at addr %08X (pid = %hu) \n", - data, phdr.p_vaddr, getpid()); -#endif - -#if defined(KERNSH) - if(kernsh_is_mem_mode()) - { - kernsh_writemem(phdr.p_vaddr, data, rsize); - } - else - { - memcpy((void *) phdr.p_vaddr, data, rsize); - } -#else - memcpy((void *) phdr.p_vaddr, data, rsize); -#endif - - /* Modify some ondisk information */ - phdr.p_paddr = phdr.p_vaddr; - hdr.sh_addr = phdr.p_vaddr; - //hdr.sh_offset = bss->shdr->sh_offset + bss->shdr->sh_size; - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Runtime injection of %s section data ! \n", sect->name); -#endif - - - - /* Insert the new program header in the runtime PHDR */ - /* XXX: insert in real PHT if doing non-runtime _static file_ injection */ - /* Should already work on runtime static binary modification */ - /* Use elfsh_insert_phdr in this static case */ - /* After modification, should be OK at least on x86 */ - //phdr.p_offset = sect->shdr->sh_offset; - sect->phdr = elfsh_insert_runtime_phdr(file, &phdr); - if (!sect->phdr) - { - elfsh_runtime_unmap(&phdr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert RPHT entry", -1); - } - - /* Synchronize the ondisk perspective */ - range = elfsh_insert_runtime_shdr(file, hdr, file->rhdr.rshtnbr, sect->name, 1); - if (range < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); - - if (elfsh_add_runtime_section(file, sect, range, data) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - - /* Inject the SECT symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert sectsym", -1); - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Runtime injected %s at addr " XFMT "! \n", - sect->name, sect->shdr->sh_addr); -#endif - - /* Always force file offset 0 for runtime sections */ - sect->shdr->sh_offset = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - - -/** - * Static binary injection : section injection for static binaries - * - * @param file - * @param sect - * @param hdr - * @param data - * @param mode - * @param mod - * @return - */ -int elfsh_insert_static_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int mod) -{ - elfsh_Phdr phdr; - elfsh_Phdr *curphdr; - u_int rsize; - char *rdata; - elfshsect_t *lastsect; - elfshsect_t *cursect; - unsigned int phtnew; - unsigned int totsize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fixup BSS if not already done */ - lastsect = elfsh_fixup_bss(file); - if (lastsect == NULL) - lastsect = file->sectlist; - - /* Grab the last mapped section */ - while (lastsect->next && lastsect->next->shdr->sh_addr) - lastsect = lastsect->next; - - -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Found last section for static injection : %s \n", lastsect->name); -#endif - - /* Pad the new section if needed */ - if (mod && (hdr.sh_size % mod)) - { - rsize = hdr.sh_size + mod - (hdr.sh_size % mod); - XALLOC(__FILE__, __FUNCTION__, __LINE__,rdata, rsize, -1); - if (data) - memcpy(rdata, data, hdr.sh_size); - hdr.sh_size = rsize; - data = rdata; - } - else - rsize = hdr.sh_size; - - /* Find an existing PT_LOAD for loading the new section, if possible */ - phtnew = 0; - curphdr = &file->pht[file->hdr->e_phnum - 1]; - for (totsize = 0, cursect = file->sectlist; cursect; cursect = cursect->next) - if (cursect->phdr == curphdr) - totsize += cursect->shdr->sh_size; - - /* If the latest injected PT_LOAD is not big enough or does not match the rights create a new one */ - if (curphdr->p_type != PT_LOAD || totsize + rsize > curphdr->p_filesz) // || - /* (elfsh_segment_is_executable(curphdr) && elfsh_get_section_writableflag(&hdr)) || - (elfsh_segment_is_writable(curphdr) && elfsh_get_section_execflag(&hdr))) */ - phtnew = 1; - else - { - curphdr->p_filesz += rsize; - curphdr->p_memsz += rsize; - } - - /* Case where we inject in a new segment */ - if (phtnew) - { - - /* Create and inject the new PT_LOAD */ - phdr = elfsh_create_phdr(PT_LOAD, 0, elfsh_get_pagesize(file), mod); - phdr.p_flags = elfsh_set_phdr_prot(mode); - phdr.p_vaddr = lastsect->shdr->sh_addr + lastsect->shdr->sh_size; - if (phdr.p_vaddr % elfsh_get_pagesize(file)) - phdr.p_vaddr += elfsh_get_pagesize(file) - phdr.p_vaddr % elfsh_get_pagesize(file); - - /* Modify some ondisk information */ - phdr.p_paddr = phdr.p_vaddr; - hdr.sh_addr = phdr.p_vaddr; - hdr.sh_offset = lastsect->shdr->sh_offset + lastsect->shdr->sh_size; - - /* align section's foffset */ - if (hdr.sh_offset % elfsh_get_pagesize(file)) - hdr.sh_offset += elfsh_get_pagesize(file) - hdr.sh_offset % elfsh_get_pagesize(file); - -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Static injection of %s section data in NEW PHDR! \n", sect->name); -#endif - } - - /* Case where we reuse a PT_LOAD */ - else - { - hdr.sh_addr = curphdr->p_vaddr + curphdr->p_memsz - rsize; - hdr.sh_offset = curphdr->p_offset + curphdr->p_memsz - rsize; - -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Static injection of %s section data with EXISTING PHDR! \n", sect->name); -#endif - } - - /* Synchronize the ondisk perspective */ - if (elfsh_insert_shdr(file, hdr, lastsect->index + 1, sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); - - if (elfsh_add_section(file, sect, lastsect->index + 1, - data, ELFSH_SHIFTING_PARTIAL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - - /* Inject the SECT symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert sectsym", -1); - - /* Insert the new program header in the runtime PHDR */ - if (phtnew) - { - phdr.p_offset = sect->shdr->sh_offset; - sect->phdr = elfsh_insert_phdr(file, &phdr); - if (!sect->phdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert PHT entry", -1); - } - else - sect->phdr = curphdr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - - - - -/** - * Insert a mapped section in the object - * This function is e2dbg safe - * - * @param file - * @param sect - * @param hdr - * @param data - * @param mode - * @param modulo - * @return - */ -int elfsh_insert_mapped_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - int mode, - u_int modulo) -{ - int err; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - mode = (char) mode; - if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Runtime injection in memory */ - if (elfsh_debugger_present()) - { - err = elfsh_insert_runtime_section(file, sect, hdr, data, mode, modulo); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot injection runtime section", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Static binary injection ondisk */ - if (elfsh_static_file(file)) - { - err = elfsh_insert_static_section(file, sect, hdr, data, mode, modulo); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot injection static section", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Dynamic binary injection ondisk */ - switch (mode) - { - - case ELFSH_CODE_INJECTION: - err = elfsh_insert_code_section(file, sect, hdr, data, modulo); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform ondisk code injection", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - case ELFSH_DATA_INJECTION: - err = elfsh_insert_data_section(file, sect, hdr, data); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform ondisk data injection", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown mode", -1); - } -} - - -/** - * Insert a non-mapped section in the object - * - * @param file - * @param sect - * @param hdr - * @param data - * @return - */ -int elfsh_insert_unmapped_section(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Sanity checks */ - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", -1); - - /* Get the last current section */ - s = elfsh_get_section_by_index(file, file->hdr->e_shnum - 1, NULL, NULL); - if (s == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get last section by index", -1); - - /* Fix the file offset for the new section */ - hdr.sh_offset = s->shdr->sh_offset + s->shdr->sh_size; - - /* Make sure the new unmapped section do not overlap SHT */ - if (hdr.sh_offset <= file->hdr->e_shoff && - hdr.sh_offset + hdr.sh_size >= file->hdr->e_shoff) - hdr.sh_offset = file->hdr->e_shoff + (file->hdr->e_shnum * - file->hdr->e_shentsize); - - /* Inject the new section and the associated header */ - if (elfsh_insert_shdr(file, hdr, file->hdr->e_shnum, - sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); - - if (elfsh_add_section(file, sect, file->hdr->e_shnum - 1, - data, ELFSH_SHIFTING_COMPLETE) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - - /* Inject the symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - -/** - * Insert a section in the object - * This function is e2dbg safe - * - * @param file - * @param name - * @param data - * @param mode - * @param size - * @param mod - * @return - */ -elfshsect_t* elfsh_insert_section(elfshobj_t *file, - char *name, - char *data, - char mode, - u_int size, - u_int mod) -{ - elfshsect_t *sect; - elfsh_Shdr hdr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (data == NULL) - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, size, NULL); - - /* Creation new section */ - sect = elfsh_create_section(name); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create section", NULL); - - /* Preliminary checks */ - if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - switch (mode) - { - - case ELFSH_CODE_INJECTION: - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, - 0, 0, size, 0, 0, 0, 0); - if (elfsh_insert_mapped_section(file, sect, hdr, data, mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert mapped code section", NULL); - break; - - case ELFSH_DATA_INJECTION: - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_WRITE | SHF_ALLOC, - 0, 0, size, 0, 0, 0, 0); - if (elfsh_insert_mapped_section(file, sect, hdr, data, mode, mod) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert mapped data section", NULL); - break; - - case ELFSH_UNMAPPED_INJECTION: - hdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, size, 0, 0, 0, 0); - if (elfsh_insert_unmapped_section(file, sect, hdr, data) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert unmapped section", NULL); - break; - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown mode", NULL); - } - - sect = elfsh_get_section_by_name(file, name, NULL, NULL, NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect)); -} - - -/** - * Insert a section at the requested index - * Should only be used with ondisk files - * - * @param file - * @param sect - * @param hdr - * @param data - * @param index - * @return - */ -int elfsh_insert_section_idx(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Shdr hdr, - void *data, - u_int index) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", -1); - - /* Get the last current section */ - s = elfsh_get_section_by_index(file, index - 1, NULL, NULL); - if (s == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get last section by index", -1); - - /* Fix the file offset for the new section */ - hdr.sh_offset = s->shdr->sh_offset + s->shdr->sh_size; - if (s->shdr->sh_addr) - hdr.sh_addr = s->shdr->sh_addr + s->shdr->sh_size; - - /* Inject the new section and the associated header */ - if (elfsh_insert_shdr(file, hdr, index, sect->name, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert shdr", -1); - - /* Add the section with absolute shifting */ - if (elfsh_add_section(file, sect, index, data, ELFSH_SHIFTING_COMPLETE) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add section", -1); - - /* Inject the symbol */ - if (elfsh_insert_sectsym(file, sect) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert section symbol", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->index)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/interp.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/interp.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/interp.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/interp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/** - * @file interp.c - * @ingroup libelfsh -** interp.c for libelfsh -** -** Started on Sun Jun 10 20:29:18 2001 jfv -** -** -** $Id: interp.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * modify the niterpreter string : the new name len must be <= to the old one - * @param file - * @param interp - * @return - */ -int elfsh_write_interp(elfshobj_t *file, char *interp) -{ - char *actual; - u_int size1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - actual = elfsh_get_interp(file); - if (!actual) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find .interp section", -1); - - size1 = strlen(interp); - if (size1 >= file->secthash[ELFSH_SECTION_INTERP]->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "New INTERP path too long", -1); - - strcpy(elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]), interp); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Find the interpreter (pht lookup method) - * @param file - * @return - */ -char *elfsh_get_interp(elfshobj_t *file) -{ - elfshsect_t *enew = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_INTERP] == NULL) - { - enew = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_INTERP, - NULL, NULL, NULL); - if (enew == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get .interp by name", NULL); - file->secthash[ELFSH_SECTION_INTERP] = enew; - } - - if (file->secthash[ELFSH_SECTION_INTERP]->data == NULL) - { - enew->data = elfsh_load_section(file, - file->secthash[ELFSH_SECTION_INTERP]->shdr); - if (enew->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load .interp", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_INTERP]))); -} - - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/linkmap.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/linkmap.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/linkmap.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/linkmap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,221 +0,0 @@ -/** - * @file linkmap.c - * @ingroup libelfsh -** linkmap.c for libelfsh -** -** TODO: Add linkmap object in scripting -** -** Started on Mon Jul 25 21:26:54 2005 ym -** -** -** $Id: linkmap.c,v 1.5 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - */ - -eresi_Addr elfsh_linkmap_get_laddr(elfshlinkmap_t *lm) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (NULL)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lm->laddr); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @param laddr - * @return - */ -void elfsh_linkmap_set_laddr(elfshlinkmap_t *lm, eresi_Addr laddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - lm->laddr = laddr; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - */ -char *elfsh_linkmap_get_lname(elfshlinkmap_t *lm) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument",(NULL)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (lm->lname)); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @param name - * @return - */ -void elfsh_linkmap_set_lname(elfshlinkmap_t *lm, char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - lm->lname = name; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - */ -elfsh_Dyn *elfsh_linkmap_get_lld(elfshlinkmap_t *lm) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument",(NULL)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lm->lld); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @param lld - * @return - */ -void elfsh_linkmap_set_lld(elfshlinkmap_t *lm, elfsh_Dyn *lld) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - lm->lld = lld; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - */ -elfshlinkmap_t *elfsh_linkmap_get_lnext(elfshlinkmap_t *lm) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument",(NULL)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lm->lnext); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @param lnext - * @return - */ -void elfsh_linkmap_set_lnext(elfshlinkmap_t *lm, elfshlinkmap_t *lnext) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - lm->lnext = lnext; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - */ -elfshlinkmap_t *elfsh_linkmap_get_lprev(elfshlinkmap_t *lm) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument",(NULL)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, lm->lprev); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @return - * - */ -void elfsh_linkmap_set_lprev(elfshlinkmap_t *lm, - elfshlinkmap_t *lprev) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!lm) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - - lm->lprev = lprev; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Documentation missing. - * @param lm Pointer to linkmap structure. - * @param name - * @return - */ -elfshlinkmap_t *elfsh_linkmap_by_name(elfshlinkmap_t *lm, char *name) -{ - elfshlinkmap_t *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!lm || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument",(NULL)); - - for (actual = elfsh_linkmap_get_lprev(lm); actual != NULL; - actual = elfsh_linkmap_get_lprev(actual)) - if (!strcmp(name, elfsh_linkmap_get_lname(actual))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, actual); - - - for (actual = lm; actual != NULL; actual = elfsh_linkmap_get_lnext(actual)) - if (!strcmp(name, elfsh_linkmap_get_lname(actual))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, actual); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Linkmap entry not found", (NULL)); -} - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -## -## Makefile.am -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## Last update Mon Feb 23 17:22:18 2004 jfv -## - -include ../config.h - -CC ?= gcc -LD ?= ld -RM = rm -f -AR = ar rc -CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libetrace/include \ - -I../libaspect/include/ $(KERNSHINC) \ - $(KERNSH) -DERESI32 $(BUILDOP) -CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libetrace/include/ \ - -I../libaspect/include/ $(KERNSHINC) \ - $(KERNSH) -DERESI64 $(BUILDOP) -SRC = dynamic.c dynsym.c elf.c fixup.c got.c hash.c \ - interp.c pht.c plt.c section.c sht.c stab.c \ - symbol.c notes.c reloc.c ctors.c dtors.c search.c \ - raw.c map.c strtab.c sht_rebuild.c comment.c \ - sym_common.c hijack.c obj.c pax.c save.c copy.c \ - strip.c remap.c relinject.c sanitize.c debug.c \ - bss.c sort.c hooks.c ia32.c sparc32.c sparc64.c \ - mips32.c alpha64.c ia64.c mips64.c reginfo.c \ - altplt.c altgot.c extplt.c runtime.c state.c \ - inject.c linkmap.c bp.c rpht.c version.c dwarf.c - -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -NAME32 = libelfsh32 -NAME64 = libelfsh64 - -all : all32 all64 - - -libelfsh32.so : $(OBJ32) - @$(CC) -L../liballocproxy/ -lallocproxy \ - -L../libaspect/ -laspect32 -DERESI32 \ - $(KERNSHLIB32) -shared $(OBJ32) -o $(NAME32).so - @$(AR) $(NAME32).a $(OBJ32) - @$(RANLIB) $(NAME32).a - @$(LD) -r $(OBJ32) -o $(NAME32).o - -all32: libelfsh32.so - - -libelfsh64.so : $(OBJ64) - @$(CC) -L../liballocproxy/ -lallocproxy \ - -L../libaspect/ -laspect64 -DERESI64 \ - $(KERNSHLIB64) -shared $(OBJ64) -o $(NAME64).so - @$(AR) $(NAME64).a $(OBJ64) - @$(RANLIB) $(NAME64).a - @$(LD) -r $(OBJ64) -o $(NAME64).o - -all64: libelfsh64.so - -clean : - @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\# \ - include/*~ include/.\#* include/libelfsh/\#* \ - include/libelfsh/*\# include/libelfsh/*~ \ - include/libelfsh/.\#* - -fclean : clean - @$(RM) *.so *.a - - -docs: - doxygen doc/doxygen.conf - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/map.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/map.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/map.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/map.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,248 +0,0 @@ -/** - * @file map.c - * @ingroup libelfsh -** map.c for libelfsh -** -** Started on Sat Mar 2 20:47:36 2002 jfv -** -** -** $Id: map.c,v 1.25 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Fixup the binary, inject symbols and sort SHT - * @param file - * @return - */ -void elfsh_fixup(elfshobj_t *file) -{ - elfsh_Shdr *got; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_type == ET_REL || elfsh_static_file(file)) - elfsh_sort_sht(file); - - /* .got sht entsize fixup */ - got = elfsh_get_sht_entry_by_name(file, ELFSH_SECTION_NAME_GOT); - if (got != NULL && got->sh_entsize == 0) - got->sh_entsize = sizeof(eresi_Addr); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Load all the part of the binary. - * This function should not be used by e2dbg - * @param file - * @return - */ -int elfsh_read_obj(elfshobj_t *file) -{ - elfshsect_t *actual; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->read) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (file->sht == NULL && NULL == elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to grab SHT", -1); - if (NULL == elfsh_get_pht(file, NULL) && file->hdr->e_type != ET_REL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to grab PHT", -1); - -#if __DEBUG_MAP__ - puts("[DEBUG:read_obj] Loading all known typed sections\n"); -#endif - - /* Fill multiple relocation sections */ - for (index = 0; NULL != - (actual = elfsh_get_reloc(file, index, NULL)); - index++); - - /* - ** Load sections placed after symtab - ** Added for Solaris - */ - elfsh_get_comments(file); - elfsh_get_dwarf(file); - elfsh_get_stab(file, NULL); - - if (file->hdr->e_type == ET_CORE) - { - elfsh_get_core_notes(file); - goto out; - } - - - /* - ** We cannot use simply elfsh_get_anonymous_section() here - ** because the object's section hash ptrs would not be filled. - */ - elfsh_get_symtab(file, NULL); - - /* Fixup stuffs in the SHT */ - elfsh_fixup(file); - - elfsh_get_dynsymtab(file, NULL); - elfsh_get_stab(file, NULL); - elfsh_get_dynamic(file, NULL); - elfsh_get_ctors(file, NULL); - elfsh_get_dtors(file, NULL); - elfsh_get_got(file, NULL); - elfsh_get_interp(file); - - elfsh_get_versymtab(file, NULL); - elfsh_get_verneedtab(file, NULL); - elfsh_get_verdeftab(file, NULL); - elfsh_get_hashtable(file, NULL); - - //elfsh_get_comments(file); - elfsh_get_plt(file, NULL); - - /* Fill the multiple notes sections */ - for (index = 0; NULL != elfsh_get_notes(file, index); index++); - - /* Loop on the section header table and load all unknown-typed sections */ - for (actual = file->sectlist; actual; actual = actual->next) - { - /* Fix first section size */ - if (actual->shdr->sh_size == 0 && actual->next && - actual->next->shdr->sh_offset != actual->shdr->sh_offset && - actual->next->shdr->sh_addr != actual->shdr->sh_addr) - actual->shdr->sh_size = - actual->next->shdr->sh_offset - actual->shdr->sh_offset; - - /* If the section data has to be loaded, load it */ - /* In case of bss, only load if BSS data is inserted in the file */ - if (actual->data == NULL && actual->shdr->sh_size) - { - if ((actual->shdr->sh_type == SHT_NOBITS && - actual->shdr->sh_offset == actual->next->shdr->sh_offset) || - (actual->next != NULL && actual->next->shdr->sh_offset == actual->shdr->sh_offset)) - continue; - -#if __DEBUG_MAP__ - printf("[LIBELFSH] Loading anonymous section %15s \n", - elfsh_get_section_name(file, actual)); -#endif - elfsh_get_anonymous_section(file, actual); - } - } - - /* Fixup various symbols like dynamic ones that are NULL */ - /* Non fatal error */ - if (file->secthash[ELFSH_SECTION_DYNSYM]) - elfsh_fixup_dynsymtab(file->secthash[ELFSH_SECTION_DYNSYM]); - -out: - /* We close the file descriptor after file mapping so we can open more files */ - if (file->fd >= 0) { -#if __DEBUG_MAP__ - printf("[LIBELFSH] Closing descriptor %d \n", - file->fd); -#endif - - XCLOSE(file->fd, -1); - /* neutralize file descriptor */ - file->fd = -1; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Called from elfsh_fixup_symtab - * When trying to inject part of the libc, some bss symbols have a wrong sctndx - * @param symtab - * @return - */ -elfshsect_t *elfsh_fixup_sctndx(elfshsect_t *symtab) -{ - int index; - elfsh_Sym *sym; - elfsh_SAddr offset; - elfsh_Shdr *shdr; - elfshsect_t *sct; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //return (symtab); // XXX - - sym = symtab->data; - shdr = symtab->parent->sht + symtab->index; - - for (index = 0; index < shdr->sh_size / sizeof(elfsh_Sym); index++) - { - if (elfsh_get_symbol_link(sym + index) != SHN_COMMON) - { - if (elfsh_get_symbol_type(sym + index) == STT_SECTION) - continue; - - sct = elfsh_get_parent_section(symtab->parent, - elfsh_get_symbol_value(sym + index), - &offset); - - if (sct == NULL) - { - sct = elfsh_get_section_by_index(symtab->parent, - elfsh_get_symbol_link(sym + index), - NULL, - NULL); - if (sct && elfsh_get_section_type(sct->shdr) == SHT_NOBITS) - { - -#if __DEBUG_MAP__ - printf(" [*] Symbol [%s] sctndx changed from %u to SHN_COMMON\n", - elfsh_get_symbol_name(symtab->parent, sym + index), - elfsh_get_symbol_link(sym + index)); -#endif - - elfsh_set_symbol_link(sym + index, SHN_COMMON); - continue; - } - - } - - if (sct && elfsh_get_section_type(sct->shdr) == SHT_NOBITS) - { - elfsh_set_symbol_link(sym + index, SHN_COMMON); -#if __DEBUG_MAP__ - printf(" [*] Symbol [%s] sctndx changed to SHN_COMMON\n", - elfsh_get_symbol_name(symtab->parent, sym + index)); -#endif - } - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, symtab); -} - -/** - * Map in memory all ressources for this file - * @param name - * @return - */ -elfshobj_t *elfsh_map_obj(char *name) -{ - elfshobj_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - file = elfsh_load_obj(name); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load object", NULL); - - file->rights = O_RDWR; - - elfsh_read_obj(file); - - hash_init(&file->redir_hash, "redirections", 51, ASPECT_TYPE_UNKNOW); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/mips32.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/mips32.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/mips32.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/mips32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,670 +0,0 @@ -/** - * @file mips32.c - * @ingroup libelfsh -** mips32.c for libelfsh -** -** Started on Sat Feb 26 23:25:37 2005 jfv -** -** Skeleton cut & pasted from the sparc64 backend -** -** -** $Id: mips32.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Static hooking for Mips32 - * Note : a new technique is beeing considered that - * may invalidate this handler as it (at least - * change the way it should be implemented) - * - * Make sure to ask anything before deciding to implement it - * - * @param file - * @param name - * @param symbol - * @param addr - */ -int elfsh_cflow_mips32(elfshobj_t *file, - char *name, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - elfshsect_t *hooks; - elfshsect_t *source; - uint32_t buff[3]; - int ret, len; - int off; - char *hookbuf; - char *hook; - //elfsh_Sym sym; - char bufname[BUFSIZ]; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* - func+0: [addu t9, (hook-func)] - func+4: [jump hook] - func+8: [nop] - func+c: [???] - - hook: ... - - old_entry+0: [addu t9, (func-old_entry)] - old_entry+4: [instr1] - old_entry+8: [instr2] - old_entry+c: [instr3] - old_entry+10: [jmp func+8] - old_entry+14: [nop] - - */ - - /* Resolve parameters */ - off = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - if (!off) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid address to hijack", -1); - - ret = elfsh_raw_read(file, off, (void *) buff, 3*4); - if (ret != 3*4) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function too small to be hijacked", -1); - - /* If the hook section does not exist, create it */ - hooks = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HOOKS, 0, 0, 0); - if (!hooks) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get .HOOKS", -1); - - hook = (char *) (hooks->shdr->sh_addr + hooks->curend); - - if (((uint32_t) symbol->st_value & 0xf0000000) != (addr & 0xf0000000)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "hook function too far from hijacked function", -1); - - if (((uint32_t) hook & 0xf0000000) != ((symbol->st_value + 0x8) & 0xf0000000)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "hook section too far from hijacked function", -1); - - if ((addr - (uint32_t) symbol->st_value) & (0xffffffff<<16)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "hook function too far from hijacked function", -1); - - if (((uint32_t) symbol->st_value - (uint32_t) hook) & (0xffffffff<<16)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "hook section too far from hijacked function", -1); - - /* Determine the minimal aligned length */ - /* RISC's powa */ - /* 3 instructions : 1 add t9..., 1 jmp, 1 nop for delay slot */ - ret = 3 * 4; - - /* Create the hook for this function */ - data = elfsh_get_raw(hooks); - memset(data + hooks->curend, 0x00, 40); // nop - - /* addi $t, $s, imm : 0010 00ss ssst tttt iiii iiii iiii iiii */ - *((uint32_t *) ((char *) (data + hooks->curend) + 0x0)) = 0x23390000; - *((uint32_t *) ((char *) (data + hooks->curend) + 0x0)) |= - (((uint32_t) symbol->st_value - (uint32_t)hook) & 0x0000ffff); - - /* first three hijacked function's instructions */ - *((uint32_t *) ((char *) (data + hooks->curend) + 0x4)) = buff[0]; - *((uint32_t *) ((char *) (data + hooks->curend) + 0x8)) = buff[1]; - *((uint32_t *) ((char *) (data + hooks->curend) + 0xc)) = buff[2]; - - /* non-linked jump to func + 8 (where should be a NOP) */ - /* mips32 jump use the 4 MSB of PC reg and 26 bits from instruction left - shited by 2 */ - memcpy(data + hooks->curend + 0x10, "\x08\x00\x00\x00", 4); - *((uint32_t *) ((char *) (data + hooks->curend) + 0x10)) |= ((symbol->st_value + 0x8) & (~ 0xe0000000 ))>>2; - - /* NOTE : there must be a NOP after this last jump */ - - /* Insert the old symbol on the original saved bytes */ - //name = elfsh_get_symbol_name(file, symbo); - snprintf(bufname, BUFSIZ, "old_%s", name); - elfsh_insert_funcsym(file, bufname, (eresi_Addr) hook, - ret + 0x10, hooks->index); - - /* - snprintf(bufname, BUFSIZ, "hook_%s", name); - elfsh_insert_funcsym(file, bufname, addr, - ret + 8, hooks->index); - */ - - /* We need to grab the parent section to compute the remaining offset */ - source = elfsh_get_parent_section_by_foffset(file, off, NULL); - if (!source) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section for hooked addr", -1); - - /* Install the hook */ - hookbuf = alloca(ret); - - /* patch t9 reg */ - *((uint32_t *) ((char *) (hookbuf) + 0x0)) = 0x23390000; - *((uint32_t *) ((char *) (hookbuf) + 0x0)) |= ((addr - symbol->st_value) & - 0x0000ffff); - /* jump to hook func */ - *((uint32_t *) ((char *) (hookbuf) + 0x4)) = 0x08000000; - *((uint32_t *) ((char *) (hookbuf) + 0x4)) |= ((uint32_t) (addr ) & - (~0xe0000000))>>2; - /* delay slot's NOP */ - *((uint32_t *) ((char *) (hookbuf) + 0x8)) = 0x00000000; - - len = elfsh_raw_write(file, off, hookbuf, ret); - if (len != ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during hook installation", -1); - - /* Everything OK, ret is always 3*4 on mips32 (RISC strike again) */ - hooks->curend += ret + 6; // (6 = 1 add, 3 instr, 1 jump, 1 nop) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * PLT hijacking on MIPS32, not needed thus unimplemented for now - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_mips32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS\n", 0); -} - - - - - - -/** - * ALTPLT hijacking on MIPS32 - * - * On MIPS we need to restore 2 words from .alt.got to .got - * and callback __libc_start_main. - * - * Update: we also need to copy .got values for extern - * variables. We put ld/st pairs in .pad.got so that we - * fill those only one time, before calling __libc_start_main - * - * The code works and is functional -mm - * - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_altplt_mips32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - elfshsect_t *altgotprolog, *altgot, *padgot, *got, *start; - elfshsect_t *dynsym, *dynamic; - elfsh_Sym *sym; - elfsh_Dyn *dynent, *dynent2; - uint32_t gotno, gotsym; - u_int varnbr, gotnbr, symnbr; - u_int opcodendx, gotindex, index, varindex; - uint32_t *opcode; - uint16_t diff; - uint16_t gotdiff; - uint32_t *originstr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Regular checks */ - if (!FILE_IS_MIPS(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "File is not MIPS", -1); - - altgotprolog = file->secthash[ELFSH_SECTION_ALTGOTPROLOG]; - altgot = file->secthash[ELFSH_SECTION_ALTGOT]; - padgot = file->secthash[ELFSH_SECTION_PADGOT]; - got = file->secthash[ELFSH_SECTION_GOT]; - start = file->secthash[ELFSH_SECTION_MIPSTART]; - dynsym = file->secthash[ELFSH_SECTION_DYNSYM]; - dynamic = file->secthash[ELFSH_SECTION_DYNAMIC]; - - if (!altgotprolog || !altgot || !got || !padgot || !dynsym || !dynamic) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find GOT, ALTGOTPROLOG, ALTGOT" - " PADGOT, DYSYM, DYNAMIC or MIPSTART section", -1); - - /* Signed 16bits displacement from %gp to last word of .pad.got */ - diff = 0x800c; - originstr = elfsh_get_raw(padgot->data) + padgot->shdr->sh_size - 4; - *originstr = altgotprolog->shdr->sh_addr; - gotdiff = (uint16_t) got->shdr->sh_addr - altgot->shdr->sh_addr; - - /* Valid _start signature on Linux, may you FIXME for other OS */ - /* lw t9, __libc_start_main_off(gp) */ - originstr = ((uint32_t *) elfsh_get_raw(start) + 19); - - /* Grab infos on .got using .dynamic */ - dynent = elfsh_get_dynamic_entry_by_type(file, DT_MIPS_GOTSYM); - gotsym = (dynent ? elfsh_get_dynentry_val(dynent) : 0); - symnbr = dynamic->shdr->sh_size / sizeof(elfsh_Sym); - if (symnbr < gotsym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DYNSYM smaller than DT_MIPS_GOTSYM", -1); - - dynent2 = elfsh_get_dynamic_entry_by_type(file, DT_MIPS_LOCAL_GOTNO); - gotno = (dynent2 ? elfsh_get_dynentry_val(dynent2) : 0); - gotnbr = got->shdr->sh_size / sizeof(eresi_Addr); - if (gotnbr < gotno) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "GOT smaller than DT_MIPS_GOTSYM", -1); - - sym = elfsh_get_raw(dynsym); - sym += gotsym; - - /* Find all .dynsym entries matching external variables - (Assuming .got and .rel entries are in the same order) - Copy their .alt.got entries value in .got - */ - for (varnbr = 0, gotindex = gotno, index = gotsym; - index < symnbr && gotno < gotnbr; index++, gotindex++) - if (elfsh_get_symbol_type(sym + index) == STT_OBJECT && !sym[index].st_value) - varnbr++; - - printf("[DEBUG_GOTPLT:mips] Found %u extern variables\n", varnbr); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,opcode, (9 + (varnbr * 2)) * sizeof(uint32_t), -1); - - /* - __asm__("addi $t0, $gp, 0x8010;"); - __asm__("addi $t1, $t0, gotdiff;"); - __asm__("lw $t2, 0($t0);"); - __asm__("lw $t3, 4($t0);"); - __asm__("sw $t2, 0($t1);"); - __asm__("sw $t3, 4($t1);"); - __asm__("lw $t9, __libc_start_main_off($gp)"); <=== - __asm__("jr $t9;"); - __asm__("nop;"); - */ - opcode[0] = 0x23888010; /* compute .alt.got addr */ - opcode[1] = 0x21090000 | gotdiff; /* compute .got addr */ - opcode[2] = 0x8d0a0000; /* load first .alt.got word */ - opcode[3] = 0x8d0b0004; /* load second .alt.got word */ - opcode[4] = 0xad2a0000; /* write first .alt.got word into .got */ - opcode[5] = 0xad2b0004; /* write second .alt.got word into .got */ - opcode[6] = *originstr; /* reload __libc_start_main addr into $t9 */ - - /* Compute the static __libc_start_main hijack in .start */ - *originstr = (*originstr & 0xFFFF0000) | diff; - - /* Now generate the ld/st pairs a la mano residing in .pad.got */ - printf("Using GOTNO = %u and GOTSYM = %u\n", gotno, gotsym); - - opcodendx = 7; - for (index = varindex = 0, gotindex = gotno; varindex < varnbr; index++, gotindex++) - if (elfsh_get_symbol_type(sym + index) == STT_OBJECT && !sym[index].st_value) - { - - printf("Using GOT index %u \n", gotindex); - - opcode[opcodendx++] = 0x8d0a0000 | (uint16_t) gotindex * sizeof(eresi_Addr); - opcode[opcodendx++] = 0xad2a0000 | (uint16_t) gotindex * sizeof(eresi_Addr); - varindex++; - } - - opcode[opcodendx++] = 0x0320f809; /* call restored $t9 */ - opcode[opcodendx++] = 0x00000000; /* nop delay slot */ - - if (padgot->shdr->sh_size < sizeof(uint32_t) * varnbr * 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - ".pad.got section too small", -1); - - elfsh_raw_write(file, altgotprolog->shdr->sh_offset, opcode, sizeof(uint32_t) * 7); - elfsh_raw_write(file, padgot->shdr->sh_offset, opcode + 7, sizeof(uint32_t) * (2 + (varnbr * 2))); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Perform relocation on entry for MIPS32 architecture - * XXX Not really endianess respectful - ym - * - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_mips32(elfshsect_t *new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - int retval; - static u_int HI16_todo = 0; - static elfsh_Rel *HI16_cur = NULL; - static eresi_Addr *HI16_dword = NULL; - static eresi_Addr HI16_addr = NULL; - - eresi_Addr old_HI16_dword = NULL; - - -#define VERIFY16(x) (((x) & (0xFFFFFFFF << 16)) ? 1 : 0) - -#define TRUNCATE16(x) ((x) & ~(0xFFFFFFFF << 16)) -#define TRUNCATE32(x) (x) /* XXX just assume its 32bits */ - -#define ISLOCAL(x) (x->r_info & STB_LOCAL) -#define ISEXTERNAL(x) (!(x->r_info & STB_LOCAL)) -#define ISGPDISP(x) (elfsh_get_symbol_by_name(new->parent, "_gp_disp")->st_value == \ - elfsh_get_symbol_from_reloc(new->parent, x)->st_value) - - -#define S (addr) /* XXX Assume we only face local symbols */ -#define A (*dword) -#define P (new->shdr->sh_addr + cur->r_offset) -#define G (addr - elfsh_get_sht_entry_by_name(new->parent, ".got")->sh_addr) - /* XXX what if there is no .got ? */ -#define GP (elfsh_get_gpvalue_addr(new->parent)?(*(elfsh_get_gpvalue_addr(new->parent))):NULL) - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retval = 0; - switch (elfsh_get_reltype(cur)) - { - /* cases ... */ - case R_MIPS_NONE: - break; - case R_MIPS_16: - break; - case R_MIPS_32: - /* External symbol case */ - /* - S : Represents the value of the symbol whose index resides in the - relocation entry, - unless the the symbol is STB_LOCAL and is of type - STT_SECTION in which case S represents the original sh_addr - minus the final sh_addr. - A : addend - - TRUNCATE32(S + A) - */ - - /* Local symbol case */ - /* - TRUNCATE32(S + A) - */ - - printf("[DEBUG] elfsh_relocate_mips32 : R_MIPS_32 \n"); - - *dword += TRUNCATE32(S + A); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - - case R_MIPS_REL32: - break; - case R_MIPS_26: - break; - case R_MIPS_HI16: - /* _gp_disp case */ - /* - AHI : addend of HI16 reloc (this reloc) - ALO : addend of LO16 reloc (next to this LO16 reloc) - AHL = (AHI << 16) + (short) ALO. - - P : Represents the place (section offset or address) of the - storage unit being relocated (computed using r_offset). - GP : Represents the final gp value to be used for the relocatable, - executable, or shared object file being produced. - - VERIFY16(((AHL + GP - P) - (short) (AHL + GP - P))>>16) - */ - - /* Local symbol case */ - /* - AHL, S : see above - - TRUNCATE16(((AHL + S) - (short) (AHL + S))>>16) - */ - - /* External symbol case */ - /* - AHL, S : see above - - NOTE : Does it exist ? - - TRUNCATE16(((AHL + S) - (short) (AHL + S))>>16) - */ - - - /* remember last R_MIPS_HI16 */ - HI16_todo = 1; - HI16_cur = cur; - HI16_dword = dword; - HI16_addr = addr; - - /* as all HI16 must be followed by a LO16 we wont do the relocation - right now - */ - printf("[DEBUG] elfsh_relocate_mips32 : R_MIPS_HI16 \n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - - case R_MIPS_LO16: - /* _gp_disp case */ - /* - AHI : addend of HI16 reloc (previously encoutred) - ALO : addend of LO16 reloc (this reloc) - - AHL = (AHI << 16) + (short) ALO. - - P, GP : see above - - VERIFY16(AHL + GP + P + 4) - */ - - /* Local symbol case */ - /* - AHL : see _gp_disp case - S : see above - - TRUNCATE16(AHL + S) - */ - - /* External symbol case */ - /* - AHL, S : see above - - Does it exists ? - - TRUNCATE16(AHL + S); - */ - - printf("[DEBUG] elfsh_relocate_mips32 : R_MIPS_LO16 \n"); - - if (HI16_cur == NULL || HI16_dword == NULL) - { - printf("[DEBUG] elfsh_relocate_mips32: You loose\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid HI16 relocation context", -1); - } - - /* - (*HI16_dword) will be modified during HI16 relocation - and we need it to perform LO16 reloc - */ - old_HI16_dword = *HI16_dword; - - if (HI16_todo == 1) - { - /* gpdisp case */ - if (ISGPDISP(HI16_cur)) - { - /* VERIFY16(((AHL + GP - P) - (short) (AHL + GP - P))>>16) : - P = new->shdr->sh_addr + HI16_cur->r_offset - AHL = ((old_HI16_dword << 16) + (short) A) - GP = GP - */ - *HI16_dword += - VERIFY16((((old_HI16_dword << 16) + (short) A) + /* AHL */ - GP - /* GP */ - (new->shdr->sh_addr + HI16_cur->r_offset) - /* P */ - (short) (((old_HI16_dword << 16) + (short) A) + /* AHL */ - GP - /* GP */ - (new->shdr->sh_addr + HI16_cur->r_offset)) /* P */ - )>>16); - } - /* local symbol */ - else if (ISLOCAL(HI16_cur) || ISEXTERNAL(HI16_cur)) - { - /* TRUNCATE16(((AHL + S) - (short) (AHL + S))>>16) - AHL = (see above) - S = HI16_addr - */ - HI16_dword += TRUNCATE16((((((old_HI16_dword << 16) + (short) A))/*AHL*/ - + HI16_addr/*S*/) - - (short) (((old_HI16_dword << 16) - + (short) A)/*AHL*/ - + HI16_addr/*S*/))>>16); - - - - } - - HI16_todo = 0; - } - - if (ISGPDISP(cur)) - { - *dword = VERIFY16(((old_HI16_dword << 16) + (short) A) + GP + P + 4); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - } - - - if (ISLOCAL(cur)) - { - *dword = TRUNCATE16(((old_HI16_dword << 16) + (short) A) + S); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - } - - if (ISEXTERNAL(cur)) - { - *dword = TRUNCATE16(((old_HI16_dword << 16) + (short) A) + S); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown relocation type", -1); - - case R_MIPS_GPREL16: - break; - case R_MIPS_LITERAL: - break; - case R_MIPS_GOT16: - /* External symbol case */ - /* - G : Represents the offset into the global offset table at which the - address of the relocation entry symbol resides during execution. - - VERIFIY16(G) - */ - - /* Local Symbol case */ - /* - In the local case, the R_MIPS_GOT16 must be followed immediately - with a R_MIPS_LO16 relocation. The AHL addend is extracted and - the section in which the referenced data item resides is determined - (requiring that all sections in an object module have unique - addresses and not overlap). From this address the final address of - the data item is calculated. If necessary, a global offset table - entry is created to hold the high 16 bits of this address (an - existing entry is used when possible). The rel16 field is replaced - by the offset of this entry in the global offset table. The lo16 - field in the following R_MIPS_LO16 relocation is replaced by the - low 16 bits of the actual destination address. This is meant for - local data references in position-independent code so that only one - global offset table entry is necessary for every 64 KBytes of local - data. - - ... - */ - printf("[DEBUG] elfsh_relocate_mips32 : R_MIPS_GOT16 \n"); - - if (ISLOCAL(cur)) - { - *dword += VERIFY16(G); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - } - - if (ISEXTERNAL(cur)) - { - printf("External symbol MIMPS_GOT16 reloc not yet implemented\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown MIPS relocation type", -1); - - case R_MIPS_PC16: - break; - case R_MIPS_CALL16: - /* only one case */ - /* - G : see above - - VERIFY16(G) - */ - printf("[DEBUG] elfsh_relocate_mips32 : R_MIPS_CALL16 \n"); - *dword += VERIFY16(G); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); - - case R_MIPS_GPREL32: - case R_MIPS_SHIFT5: - case R_MIPS_SHIFT6: - case R_MIPS_64: - case R_MIPS_GOT_DISP: - case R_MIPS_GOT_PAGE: - case R_MIPS_GOT_OFST: - case R_MIPS_GOT_HI16: - case R_MIPS_GOT_LO16: - case R_MIPS_SUB: - case R_MIPS_INSERT_A: - case R_MIPS_INSERT_B: - case R_MIPS_DELETE: - case R_MIPS_HIGHER: - case R_MIPS_HIGHEST: - case R_MIPS_CALL_HI16: - case R_MIPS_CALL_LO16: - case R_MIPS_SCN_DISP: - case R_MIPS_REL16: - case R_MIPS_ADD_IMMEDIATE: - case R_MIPS_PJUMP: - case R_MIPS_RELGOT: - case R_MIPS_JALR: - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported relocation type", -1); - break; - } - -#undef S -#undef A -#undef P -#undef G -#undef GP - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/mips64.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/mips64.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/mips64.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/mips64.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/** - * @file mips64.c - * @ingroup libelfsh -** mips64.c for libelfsh -** -** Started on Sat Feb 26 23:57:21 2005 jfv -** -** Skeleton cut & pasted from the sparc64 backend -** -** -** $Id: mips64.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Static hooking for Mips64 - * @param null - * @param snull - * @param null2 - * @param null3 - * @return - */ -int elfsh_cflow_mips64(elfshobj_t *null, - char *snull, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - -/** - * PLT hijacking on MIPS64 - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_mips64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * ALTPLT hijacking on MIPS64 - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_altplt_mips64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - - - -/** - * Perform relocation on entry for MIPS64 architecture - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_mips64(elfshsect_t *new, - elfsh_Rel *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - int retval; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - retval = 0; - switch (elfsh_get_reltype(cur)) - { - /* cases ... */ - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported relocation type", -1); - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/notes.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/notes.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/notes.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/notes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,110 +0,0 @@ -/** - * @file notes.c - * @ingroup libelfsh -** notes.c for libelfsh -** -** Functions of this files are not intended to be used with e2dbg -** -** Started on Sun Jun 10 22:57:09 2001 jfv -** -** -** $Id: notes.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * Return the content of the 'range'th section of type SHT_NOTE - * @param file - * @param range - * @return - */ -elfshsect_t *elfsh_get_notes(elfshobj_t *file, eresi_Addr range) -{ - elfshsect_t *notes; - elfshnotent_t *e; - elfshnotent_t *tmp; - int offset; - int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Search and load the section if necessary */ - notes = elfsh_get_section_by_type(file, SHT_NOTE, range, - NULL, NULL, &size); - if (notes == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get .notes by type", NULL); - if (notes->data == NULL) - { - notes->data = elfsh_load_section(file, notes->shdr); - if (notes->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get .notes data", NULL); - } - - /* Parse all the note entries of the section */ - for (offset = 0; offset < size; - offset += (e->namesz + e->descsz + sizeof(int) * 3)) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,e, sizeof(elfshnotent_t), NULL); - e->namesz = * (int *) notes->data; - e->namesz += e->namesz % 4; - e->descsz = * (int *) notes->data + 1; - e->descsz += e->descsz % 4; - - /* Sanity check */ - if (offset + sizeof(int) * 3 + e->namesz > size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Corrupted Notes section", NULL); - - e->note = strdup((char *) notes->data + offset + sizeof(int) * 3); - - e->desc = strdup((char *) notes->data + offset + sizeof(int) * 3 - - + e->namesz); - - /* Put the note entry at the end of the list */ - if (notes->altdata == NULL) - notes->altdata = e; - else - { - tmp = notes->altdata; - while (tmp->next) - tmp = tmp->next; - tmp->next = e; - e->prev = tmp; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (notes)); -} - - -/** - * Free the notes section linked list - * @param file - */ -void elfsh_free_notes(elfshobj_t *file) -{ - elfshnotent_t *e; - elfshnotent_t *etmp; - elfshsect_t *sect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (sect = file->sectlist; sect; sect = sect->next) - if (sect->data && sect->shdr->sh_type == SHT_NOTE) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->data); - for (e = sect->altdata; e; e = etmp) - { - etmp = e->next; - XFREE(__FILE__, __FUNCTION__, __LINE__,e->note); - XFREE(__FILE__, __FUNCTION__, __LINE__,e->desc); - XFREE(__FILE__, __FUNCTION__, __LINE__,e); - } - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/obj.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/obj.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/obj.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/obj.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/** - * @file obj.c - * @ingroup libelfsh -** obj.c for elfsh -** -** Started on Wed Feb 12 00:07:06 2003 jfv -** Last update Sun Mar 4 00:46:13 2007 thorkill -** -** $Id: obj.c,v 1.11 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Open the file 'name' and returns the elfshobj_t - * @param name - * @return - */ -elfshobj_t *elfsh_load_obj(char *name) -{ - elfshobj_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,file, sizeof(elfshobj_t), NULL); - XOPEN(file->fd, name, O_RDONLY, 0, NULL); - file->name = strdup(name); - - /* Get the file size on disk */ - if (0 != fstat(file->fd,&file->fstat)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get fstat(2)", NULL); - - file->hdr = elfsh_get_hdr(file); - file->rights = O_RDONLY; - if (file->hdr == NULL || file->name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get ELF header", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file)); -} - - - -/** - * Free the ELF descriptor and its fields - * @param file The elfsh obj - */ -void elfsh_unload_obj(elfshobj_t *file) -{ - elfshsect_t *sect; - elfshsect_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XFREE(__FILE__, __FUNCTION__, __LINE__, file->hdr); - XFREE(__FILE__, __FUNCTION__, __LINE__, file->pht); - XFREE(__FILE__, __FUNCTION__, __LINE__, file->sht); - - for (sect = file->sectlist; sect; sect = next) - { - /* FIXME: Prevent dobule free() */ - if (sect->data == sect->altdata) - sect->altdata = NULL; - - if (sect->data == sect->terdata) - sect->terdata = NULL; - - if (sect->data == sect->lastdata) - sect->lastdata = NULL; - - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->data); - - if (sect->altdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->altdata); - - if (sect->terdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->terdata); - - if (sect->lastdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->lastdata); - - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->name); - next = sect->next; - XFREE(__FILE__, __FUNCTION__, __LINE__,sect); - } - - if (file->fd) - close(file->fd); - - XFREE(__FILE__, __FUNCTION__, __LINE__,file->name); - XFREE(__FILE__, __FUNCTION__, __LINE__,file); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/pax.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/pax.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/pax.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/pax.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,308 +0,0 @@ -/** - * @file pax.c - * @ingroup libelfsh -** pax.c for elfsh -** -** Started on Tue Feb 11 20:52:36 2003 jfv -** Last update Tue Feb 18 06:17:27 2003 jfv -** -** $Id: pax.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Change the ELF header flags field - * @param hdr - * @param flags - * @return - */ -int elfsh_set_paxflags(elfsh_Ehdr *hdr, eresi_Addr flags) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - *pax_flags = (elfsh_Word) flags; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the ELF header flags field - * @param hdr - * @return - */ -elfsh_Word elfsh_get_paxflags(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*pax_flags)); -} - - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_pageexec(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (off) - *pax_flags |= ELFSH_PAX_PAGEEXEC; - else - *pax_flags &= (~ELFSH_PAX_PAGEEXEC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_pageexec(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((*pax_flags & ELFSH_PAX_PAGEEXEC) && - !(*pax_flags & ELFSH_PAX_SEGMEXEC))); -} - - - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_emultramp(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (off) - *pax_flags |= ELFSH_PAX_EMULTRAMP; - else - *pax_flags &= (~ELFSH_PAX_EMULTRAMP); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_emultramp(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((*pax_flags & ELFSH_PAX_EMULTRAMP))); -} - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_mprotect(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (!off) - *pax_flags |= ELFSH_PAX_MPROTECT; - else - *pax_flags &= (~ELFSH_PAX_MPROTECT); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_mprotect(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (!(*pax_flags & ELFSH_PAX_MPROTECT))); -} - - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_randmmap(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (!off) - *pax_flags |= ELFSH_PAX_RANDMMAP; - else - *pax_flags &= (~ELFSH_PAX_RANDMMAP); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_randmmap(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (!(*pax_flags & ELFSH_PAX_RANDMMAP))); -} - - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_randexec(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (off) - *pax_flags |= ELFSH_PAX_RANDEXEC; - else - *pax_flags &= (~ELFSH_PAX_RANDEXEC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_randexec(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((*pax_flags & ELFSH_PAX_RANDEXEC))); -} - - -/** - * Change the section header table file offset - * @param hdr - * @param off - * @return - */ -char elfsh_set_pax_segmexec(elfsh_Ehdr *hdr, eresi_Addr off) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - if (!off) - *pax_flags |= ELFSH_PAX_SEGMEXEC; - else - *pax_flags &= (~ELFSH_PAX_SEGMEXEC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the section header table file offset - * @param hdr - * @return - */ -char elfsh_get_pax_segmexec(elfsh_Ehdr *hdr) -{ - u_short *pax_flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!hdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - pax_flags = (u_short *) ((char *) hdr->e_ident + EI_PAX); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (!(*pax_flags & ELFSH_PAX_SEGMEXEC))); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/pht.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/pht.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/pht.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/pht.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,714 +0,0 @@ -/** - * @file pht.c - * @ingroup libelfsh -** pht.c for libelfsh -** -** Started on Mon Feb 26 04:07:33 2001 jfv -** -** -** $Id: pht.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Check if segment is readable - * @param p - * @return - */ -int elfsh_segment_is_readable(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((p->p_flags & PF_R))); -} - -/** - * Check if segment is writable - * @param p - * @return - */ -int elfsh_segment_is_writable(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((p->p_flags & PF_W))); -} -/** - * Check if segment is executable - * @param p - * @return - */ -int elfsh_segment_is_executable(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((p->p_flags & PF_X))); -} - -/** - * Tiny write access functions for program headers - * @param p - * @param flags - * @return - */ -int elfsh_set_segment_flags(elfsh_Phdr *p, eresi_Addr flags) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - - p->p_flags = (elfsh_Word) flags; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Word elfsh_get_segment_flags(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_flags)); -} - -/** - * Documentation missing. - * @param p - * @param align - * @return - */ -int elfsh_set_segment_align(elfsh_Phdr *p, eresi_Addr align) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_align = (elfsh_Word) align; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Word elfsh_get_segment_align(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_align)); -} - -/** - * Documentation missing. - * @param p - * @param memsz - * @return - */ -int elfsh_set_segment_memsz(elfsh_Phdr *p, eresi_Addr memsz) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_memsz = (elfsh_Word) memsz; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Word elfsh_get_segment_memsz(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_memsz)); -} - -/** - * Documentation missing. - * @param p - * @param filesz - * @return - */ -int elfsh_set_segment_filesz(elfsh_Phdr *p, eresi_Addr filesz) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_filesz = (elfsh_Word) filesz; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Word elfsh_get_segment_filesz(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_filesz)); -} - -/** - * Documentation missing. - * @param p - * @param paddr - * @return - */ -int elfsh_set_segment_paddr(elfsh_Phdr *p, eresi_Addr paddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_paddr = paddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -eresi_Addr elfsh_get_segment_paddr(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_paddr)); -} - -/** - * Documentation missing. - * @param p - * @param vaddr - * @return - */ -int elfsh_set_segment_vaddr(elfsh_Phdr *p, eresi_Addr vaddr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_vaddr = vaddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -eresi_Addr elfsh_get_segment_vaddr(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_vaddr)); -} - -/** - * Documentation missing. - * @param p - * @param type - * @return - */ -int elfsh_set_segment_type(elfsh_Phdr *p, eresi_Addr type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_type = (elfsh_Word) type; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Word elfsh_get_segment_type(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_type)); -} - -/** - * Documentation missing. - * @param p - * @param offset - * @return - */ -int elfsh_set_segment_offset(elfsh_Phdr *p, eresi_Addr offset) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - p->p_offset = (elfsh_Off) offset; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Documentation missing. - * @param p - * @return - */ -elfsh_Off elfsh_get_segment_offset(elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!p) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (p->p_offset)); -} - -/** - * Retreive the 'range'th segment header of type 'type' - * @param file - * @param type - * @param range - * @return - */ -elfsh_Phdr *elfsh_get_segment_by_type(elfshobj_t *file, - int type, - int range) -{ - elfsh_Phdr *pht; - int index; - int max; - int cnt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First PHT checks */ - pht = elfsh_get_pht(file, &max); - if (NULL == pht) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PHT", NULL); - - /* Simple find-by-type loop */ - for (cnt = index = 0; index < max; index++) - if (elfsh_get_segment_type(pht + index) == type) - { - if (cnt == range) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (&pht[index])); - cnt++; - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find PHDR by type", NULL); -} - - -/** - * Change endianess of PHT - * @param p - * @param byteorder - * @param sz - * @return - */ -void elfsh_endianize_pht(elfsh_Phdr *p, char byteorder, uint16_t sz) -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (byteorder == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (byteorder == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - - for (index = 0; index < sz; index++) - { - p->p_type = swap32(p->p_type); - p->p_offset = swaplong(p->p_offset); - p->p_vaddr = swaplong(p->p_vaddr); - p->p_paddr = swaplong(p->p_paddr); - p->p_filesz = swaplong(p->p_filesz); - p->p_memsz = swaplong(p->p_memsz); - p->p_flags = swap32(p->p_flags); - p->p_align = swaplong(p->p_align); - p++; - } - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Return an array of program (segment) header - * @param file - * @return - */ -int elfsh_load_pht(elfshobj_t *file) -{ - int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - (char *)"Invalid NULL parameter", -1); - - else if (file->pht != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - else if (!file->hdr->e_phoff) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, (char *)"No PHT", -1); - - if (file->hdr->e_phoff > file->fstat.st_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - (char *)"PHT file offset is larger than the file itself", -1); - - size = file->hdr->e_phentsize * file->hdr->e_phnum; - XSEEK(file->fd, file->hdr->e_phoff, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,file->pht, size, -1); - XREAD(file->fd, file->pht, size, -1); - - /* Deal with cross-endianess binaries */ - elfsh_endianize_pht(file->pht, - file->hdr->e_ident[EI_DATA], - file->hdr->e_phnum); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Find the parent segment for this section - * @param file - * @param new - * @return - */ -elfsh_Phdr *elfsh_get_parent_segment(elfshobj_t *file, elfshsect_t *enew) -{ - elfsh_Phdr *actual; - int index; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (NULL == enew || NULL == enew->parent || NULL == file || - (NULL == enew->parent->pht && elfsh_load_pht(enew->parent)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Try to find in pht */ - for (index = 0, actual = enew->parent->pht; index < enew->parent->hdr->e_phnum; - index++) - if (INTERVAL(actual[index].p_vaddr, enew->shdr->sh_addr, - actual[index].p_vaddr + actual[index].p_memsz)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (actual + index)); - - /* Fix the address we look for depending on the file type and context */ - addr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(enew) ? - file->rhdr.base + enew->shdr->sh_addr : enew->shdr->sh_addr); - - /* Try to find in runtime pht */ - for (index = 0, actual = enew->parent->rpht; index < enew->parent->rhdr.rphtnbr; - index++) - { - - //printf("RPHT parent : Trying to match interval %08X <= %08X < %08X \n", - //actual[index].p_vaddr, addr, actual[index].p_vaddr + actual[index].p_memsz); - - if (INTERVAL(actual[index].p_vaddr, addr, - actual[index].p_vaddr + actual[index].p_memsz)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (actual + index)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent PHDR", NULL); -} - - -/** - * Tell if the section belongs to the segment or not - * @param new - * @param p - * @return - */ -int elfsh_segment_is_parent(elfshsect_t *new, elfsh_Phdr *p) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* For SHT matchs */ - if (p->p_offset && new->shdr->sh_offset) - { - if (INTERVAL(p->p_offset, new->shdr->sh_offset, p->p_offset + p->p_filesz)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - - /* Added for RSHT matchs */ - else if (new->shdr->sh_addr && - INTERVAL(p->p_vaddr, new->shdr->sh_addr, p->p_vaddr + p->p_memsz)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Get the base virtual address for an object - * @param file - * @return - */ -eresi_Addr elfsh_get_object_baseaddr(elfshobj_t *file) -{ - int nbr; - u_int index; - eresi_Addr vaddr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (elfsh_get_pht(file, &nbr) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot read PHT", -1); - - vaddr = (eresi_Addr) -1; - for (index = 0; index < nbr; index++) - if (file->pht[index].p_type == PT_LOAD && file->pht[index].p_vaddr < vaddr) - vaddr = file->pht[index].p_vaddr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_objtype(file->hdr) == ET_DYN ? - vaddr + file->rhdr.base : vaddr)); -} - - -/** - * Return a ptr on the program header table - * @param file - * @param num - * @return - */ -void *elfsh_get_pht(elfshobj_t *file, int *num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->pht == NULL && elfsh_load_pht(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load PHT", NULL); - if (num != NULL) - *num = file->hdr->e_phnum; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->pht)); -} - -/** - * Return a entry giving its parent and its index - * @param pht - * @param index - * @return - */ -elfsh_Phdr *elfsh_get_pht_entry_by_index(elfsh_Phdr *pht, - eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (pht + index)); -} - - - -/** - * Create a new PHT entry - * @param t - * @param a - * @param z - * @param al - * @return - */ -elfsh_Phdr elfsh_create_phdr(elfsh_Word t, - eresi_Addr a, - elfsh_Off z, - elfsh_Word al) -{ - elfsh_Phdr new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - bzero(&new, sizeof(elfsh_Phdr)); - new.p_type = t; - new.p_vaddr = new.p_paddr = a; - new.p_filesz = new.p_memsz = z; - new.p_align = al; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/** - * Insert a PHT entry ondisk - * Should be OK if called in last from section injection routine - * @param file - * @param h - * @return - */ -elfsh_Phdr *elfsh_insert_phdr(elfshobj_t *file, elfsh_Phdr *h) -{ - elfshsect_t *cur; - elfsh_Phdr *enew; - elfsh_Phdr *phdr; - elfsh_Phdr *curphdr; - elfsh_SAddr range; - int pagesize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if we extended the PHT already */ - if (elfsh_dynamic_file(file)) - { - phdr = elfsh_get_segment_by_type(file, PT_PHDR, 0); - if (!phdr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find PT_PHDR segment", NULL); - - if (!(phdr->p_filesz % elfsh_get_pagesize(file)) && - (file->hdr->e_phnum + 1) * file->hdr->e_phentsize <= phdr->p_filesz) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, (file->hdr->e_phnum + 1) * elfsh_get_phentsize(file->hdr), - NULL); - memcpy(enew, file->pht, - file->hdr->e_phnum * elfsh_get_phentsize(file->hdr)); - goto end; - } - } - - /* Find the first executable PT_LOAD segment */ - range = 0; - do - { - phdr = elfsh_get_segment_by_type(file, PT_LOAD, range); - range++; - } - while (phdr && !elfsh_segment_is_executable(phdr)); - if (phdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find +x PT_LOAD", NULL); - - /* Copy beginning of new PHT */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, (file->hdr->e_phnum + 1) * elfsh_get_phentsize(file->hdr), NULL); - memcpy(enew, file->pht, file->hdr->e_phnum * elfsh_get_phentsize(file->hdr)); - - /* Update it so that it covers the whole new PT_PHDR */ - pagesize = elfsh_get_pagesize(file); - phdr = enew + (phdr - file->pht); - phdr->p_filesz += pagesize; - phdr->p_memsz += pagesize; - phdr->p_vaddr -= pagesize; - phdr->p_paddr -= pagesize; - - /* Update all section file offsets */ - for (cur = file->sectlist; cur != NULL; cur = cur->next) - if (cur->shdr->sh_offset) - cur->shdr->sh_offset += elfsh_get_pagesize(file); - - /* Update all PHT file offsets */ - for (range = 0, curphdr = enew; - range < file->hdr->e_phnum; - range++, curphdr++) - if (elfsh_get_segment_type(curphdr) == PT_PHDR) - { - curphdr->p_paddr -= elfsh_get_pagesize(file); - curphdr->p_vaddr -= elfsh_get_pagesize(file); - if (curphdr->p_filesz < elfsh_get_pagesize(file)) - { - curphdr->p_filesz = 0; - curphdr->p_memsz = 0; - } - curphdr->p_filesz += elfsh_get_pagesize(file); - curphdr->p_memsz += elfsh_get_pagesize(file); - } - else if (curphdr != phdr && curphdr->p_offset) - curphdr->p_offset += elfsh_get_pagesize(file); - - /* Fixup SHT file offset */ - file->hdr->e_shoff += elfsh_get_pagesize(file); - - /* Fixup injected-PHDR file offset given the chosen virtual address */ - end: - if (h->p_vaddr) - { - cur = elfsh_get_parent_section(file, h->p_vaddr, &range); - h->p_offset = cur->shdr->sh_offset + range; - } - memcpy(enew + file->hdr->e_phnum, h, elfsh_get_phentsize(file->hdr)); - - /* Everything OK */ - file->hdr->e_phnum++; - XFREE(__FILE__, __FUNCTION__, __LINE__,file->pht); - file->pht = enew; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, enew + (file->hdr->e_phnum - 1)); -} - - -/** - * Remove a PHDR - * @param current - * @param index - * @return - */ -int elfsh_remove_phdr(elfshobj_t *current, int index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index < 0 || index >= current->hdr->e_phnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid index for PHDR", -1); - - if (!current->hdr->e_phnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PHT is already empty", -1); - - if (current->hdr->e_phnum != 1) - memcpy(current->pht + index, current->pht + index + 1, - (current->hdr->e_phnum - index - 1) * current->hdr->e_phentsize); - current->hdr->e_phnum--; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/plt.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/plt.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/plt.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/plt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,205 +0,0 @@ -/** - * @file plt.c - * @ingroup libelfsh -** plt.c for libelfsh -** -** Started on Tue Jul 24 06:40:07 2001 jfv -** -** -** $Id: plt.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Load the Procedure Linkage Table - * @param file - * @param num - * @return - */ -elfshsect_t *elfsh_get_plt(elfshobj_t *file, int *num) -{ - elfshsect_t *actual; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", NULL); - - for (actual = file->sectlist; actual != NULL; actual = actual->next) - if (elfsh_is_plt(file, actual)) - { - ret = elfsh_get_anonymous_section(file, actual); - if (!ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PLT", NULL); - file->secthash[ELFSH_SECTION_PLT] = actual; - } - else if (elfsh_is_altplt(file, actual)) - { - ret = elfsh_get_anonymous_section(file, actual); - if (!ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get ALTPLT", NULL); - file->secthash[ELFSH_SECTION_ALTPLT] = actual; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (file->secthash[ELFSH_SECTION_PLT])); -} - - -/** - * Return 1 if the section is the plt or 0 if its not - * @param file - * @param sct - * @return - */ -int elfsh_is_plt(elfshobj_t *file, elfshsect_t *sct) -{ - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - name = elfsh_get_section_name(file, sct); - if (name != NULL && !strcmp(name, ELFSH_SECTION_NAME_PLT)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return 1 if the section is the plt or 0 if its not - * @param file - * @param sct - * @return - */ -int elfsh_is_altplt(elfshobj_t *file, elfshsect_t *sct) -{ - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - name = elfsh_get_section_name(file, sct); - if (name != NULL && !strcmp(name, ELFSH_SECTION_NAME_ALTPLT)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return 1 if the symbol points in the PLT, 0 if not, -1 if the PLT cant be found - * @param file - * @param sym - * @return - */ -int elfsh_is_pltentry(elfshobj_t *file, elfsh_Sym *sym) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sym == NULL || elfsh_get_plt(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (sym->st_size != file->secthash[ELFSH_SECTION_PLT]->shdr->sh_size) - { - if (INTERVAL(file->secthash[ELFSH_SECTION_PLT]->shdr->sh_addr, - sym->st_value, - file->secthash[ELFSH_SECTION_PLT]->shdr->sh_addr + - file->secthash[ELFSH_SECTION_PLT]->shdr->sh_size)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the size of 1 PLT entry - * @param file - * @return - */ -int elfsh_get_pltentsz(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - /* XXX: case EM_486: */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (16)); - case EM_SPARC: - case EM_SPARC32PLUS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (12)); - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (32)); - case EM_ALPHA: -#if (EM_ALPHA != EM_ALPHA_EXP) - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (12)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (16)); - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", -1); - } -} - - -/** - * Return the size of the FIRST PLT entry on this arch - * Its a different size on Alpha and Sparc - * @param file - * @return - */ -int elfsh_get_first_pltentsz(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - /* XXX: case EM_486: */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (16)); - case EM_SPARC: - case EM_SPARC32PLUS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (48)); - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (124)); - case EM_ALPHA: -#if (EM_ALPHA != EM_ALPHA_EXP) - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (32)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (16)); - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture", -1); - } -} - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/raw.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/raw.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/raw.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/raw.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -/** - * @file raw.c - * @ingroup libelfsh -** raw.c for libelfsh -** -** Started on Wed Feb 27 19:41:45 2002 jfv -** Last update Thu Mar 20 05:47:12 2003 jfv -** -** $Id: raw.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Perform a raw write on the object cache data - * @param file - * @param foffset - * @param src_buff - * @param len - * @return - */ -int elfsh_raw_write(elfshobj_t *file, - u_int foffset, - void *src_buff, - int len) -{ - elfshsect_t *sect; - int sect_off; - void *dst; - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(KERNSH) - if (kernsh_raw_write(file, foffset, src_buff, len) == len) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); - } -#endif - - sect = elfsh_get_parent_section_by_foffset(file, foffset, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address", -1); - - sect_off = foffset - sect->shdr->sh_offset; - if (sect_off + len > sect->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section too short", -1); - - dst = elfsh_get_anonymous_section(file, sect); - if (dst == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (elfsh_is_debug_mode()) - { - prot = elfsh_munprotect(file, (eresi_Addr) dst + sect_off, len); - memcpy(dst + sect_off, src_buff, len); - elfsh_mprotect((eresi_Addr) dst + sect_off, len, prot); - } - else - memcpy(dst + sect_off, src_buff, len); - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (len)); -} - - - -/** - * Perform a raw read on the object cache data - * @param file - * @param foffset - * @param dest_buff - * @param len - * @return - */ -int elfsh_raw_read(elfshobj_t *file, u_int foffset, void *dest_buff, int len) -{ - elfshsect_t *sect; - void *src; - int sect_off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(KERNSH) - if (kernsh_raw_read(file, foffset, dest_buff, len) == len) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); - } -#endif - - sect = elfsh_get_parent_section_by_foffset(file, foffset, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address", -1); - - sect_off = foffset - sect->shdr->sh_offset; - if (sect_off + len > sect->shdr->sh_size) - len -= (sect_off + len - sect->shdr->sh_size); - - src = elfsh_get_anonymous_section(file, sect); - if (src == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - memcpy(dest_buff, src + sect_off, len); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (len)); -} - - -/** - * Retreive the file offset from the virtual address - * @param file - * @param vaddr - * @return - */ -int elfsh_get_foffset_from_vaddr(elfshobj_t *file, eresi_Addr vaddr) -{ - elfshsect_t *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!vaddr) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - for (actual = file->sectlist; actual; actual = actual->next) - if (INTERVAL(actual->shdr->sh_addr, vaddr, - actual->shdr->sh_addr + actual->shdr->sh_size)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (actual->shdr->sh_offset + - (vaddr - actual->shdr->sh_addr))); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Retreive the virtual address given the file offset - * @param file - * @param foffset - * @return - */ -int elfsh_get_vaddr_from_foffset(elfshobj_t *file, u_int foffset) -{ - elfshsect_t *root; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - root = elfsh_get_parent_section_by_foffset(file, foffset, NULL); - if (root) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (root->shdr->sh_addr + (foffset - root->shdr->sh_offset))); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/reginfo.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/reginfo.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/reginfo.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/reginfo.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/** - * @file reginfo.c - * @ingroup libelfsh -** reginfo.c for libelfsh -** -** Started on Wed Mar 23 14:18:20 2005 ym -** Updated on Wed Mar 23 14:21:32 2005 jfv -** -** -** $Id: reginfo.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Get gpvalue - * @param file - * @return - */ -elfsh_Sword elfsh_get_gpvalue(elfshobj_t* file) -{ - elfsh_Sword *gp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - gp = elfsh_get_gpvalue_addr(file); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*gp)); -} - - -/** - * Set gpvalue - * @param file - * @param gp - * @return - */ -int elfsh_set_gpvalue(elfshobj_t* file, eresi_Addr gp) -{ - elfsh_Sword rgp; - elfsh_Sword *agp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - rgp = (elfsh_Sword) gp; - agp = elfsh_get_gpvalue_addr(file); - if (!agp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get GP value", -1); - *agp = rgp; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return a pointer on ".reginfo" ri_gp_value - * @param file - * @return - */ -elfsh_Sword *elfsh_get_gpvalue_addr(elfshobj_t* file) -{ - elfshsect_t *reginfo; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - reginfo = elfsh_get_section_by_name(file,".reginfo", NULL, NULL, NULL); - - if (reginfo == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No .reginfo section", NULL); - - if (reginfo->data == NULL) - reginfo->data = elfsh_load_section(file, reginfo->shdr); - - if (reginfo->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't read .reginfo section", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (&((elfsh_RegInfo *) elfsh_get_raw(reginfo))->ri_gp_value)); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/relinject.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/relinject.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/relinject.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/relinject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,750 +0,0 @@ -/** - * @file relinject.c - * @ingroup libelfsh -** relinject.c for libelfsh -** -** This file contains all functions for relocating a ET_REL -** object. It calls the relocation hook for keeping an abstraction -** on various routines. -** -** BeoS fixes by zadig -** -** Started on Fri Mar 28 14:55:37 2003 jfv -** -** -** $Id: relinject.c,v 1.19 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - - -/** - * Perform relocation on entry (Now use ELFsh 0.6 hooks model) - * @param new - * @param reloc - * @param dword - * @param addr - * @param mod - * @return - */ -static int elfsh_relocate_entry(elfshsect_t *enew, - void *reloc, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = elfsh_rel(enew->parent, enew, reloc, dword, addr, mod); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to relocate object", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Find the host symbol we rely on for performing the relocation - * @param enew - * @param reltab - * @param sym - * @param name - * @param stage - * @param symtype - * @return - */ -static int elfsh_find_relocsym(elfshsect_t *enew, elfshsect_t *reltab, - elfsh_Sym **sym, char *name, char stage, - elfsh_Half symtype) - -{ - elfshobj_t *dep; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If this symbol is a old_ one, accept it to be relocated in 2nd stage */ - /* This is because function redirection may be done after ET_REL injection */ - if (strstr(name, "old_") && stage == ELFSH_RELOC_STAGE1) - { -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] %s symbol not found at RELOC_STAGE1, continue\n", name); -#endif - if (enew->parent->nbrel < ELFSH_MAXREL) - { - if (enew->parent->listrel[enew->parent->nbrel] != reltab->parent) - { - - enew->parent->listrel[enew->parent->nbrel++] = reltab->parent; -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] %s object relocation will have a second stage\n", - reltab->parent->name); -#endif - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); - } - } - - - /* We have a different behavior depending on the symbol type */ - switch (symtype) - { - /* The symbol is not found so we request a enew PLT entry for it */ - case STT_NOTYPE: - if (!elfsh_static_file(enew->parent)) - { - *sym = elfsh_request_pltent(enew->parent, name); - if (*sym) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - else - { -#if __DEBUG_STATIC__ - printf("STT_NOTYPE in static file while relocating %s\n", reltab->parent->name); -#endif - - dep = elfsh_find_obj_by_symbol(name); - - /* no symbol found */ - if (dep == ((void *) -1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ET_REL dependence", -1); - - /* Use stage 2 relocation as the best et_rel is beeing inserted */ - if (dep == NULL) - { -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Loop in dependency detected -> STAGE2 relocation\n"); -#endif - if (enew->parent->nbrel < ELFSH_MAXREL && - enew->parent->listrel[enew->parent->nbrel] != reltab->parent) - { - enew->parent->listrel[enew->parent->nbrel++] = reltab->parent; -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] %s object relocation will have a second stage\n", reltab->parent->name); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add stage 2 relocation", -1); - } - - /* symbol found, gonna try to inject et_rel */ - if (dep != NULL && dep != reltab->parent && elfsh_inject_etrel(enew->parent, dep) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ET_REL dependence", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (2)); - - } - break; - case STT_SECTION: - printf("STT_SECTION\n"); - break; - case STT_FUNC: - printf("STT_FUNC\n"); - break; - case STT_OBJECT: - printf("STT_OBJECT\n"); - break; - case STT_COMMON: - printf("STT_COMMON\n"); - break; - case STT_BLOCK: - printf("STT_BLOCK\n"); - } - - -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Not found after OLD check : sym = %s \n", name); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find requested symbol in ET_EXEC\n", -1); -} - - - - -/** - * Relocate the just injected section - * @param enew - * @param reltab - * @param stage - * @return - */ -static int elfsh_relocate_etrel_section(elfshsect_t *enew, - elfshsect_t *reltab, - u_char stage) -{ - elfsh_Rel *cur; - u_int index; - elfsh_Sym *sym; - u_int size; - eresi_Addr *dword; - eresi_Addr addr; - char *name; - char tmpname[BUFSIZ]; - elfshsect_t *sect; - u_int entsz; - elfshsect_t *plt; - void *data; - elfsh_Half symtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* ET_REL object is not mapped we use unconditionaly - the ondisk relocation tables for such operation */ - data = reltab->data; - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] Using reloc table from %s [%s] data at %p \n", - reltab->parent->name, reltab->name, data); -#endif - - /* Loop on the relocation table entries */ - size = (reltab->shdr->sh_type == SHT_RELA ? - sizeof(elfsh_Rela) : sizeof(elfsh_Rel)); - size = reltab->shdr->sh_size / size; - - plt = elfsh_get_plt(enew->parent, NULL); - if (NULL == plt && elfsh_dynamic_file(enew->parent)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get plt", -1); - - entsz = elfsh_get_pltentsz(enew->parent); - if (entsz < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get pltentsz", -1); - - for (index = 0; index < size; index++) - { - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] relocation loop stage %u for section %s index %u \n", - stage, enew->name, index); -#endif - - /* We try a enew relocation now that the ET_REL dependence is mapped */ - retry: - - /* Get symbol value in ET_REL */ - cur = (reltab->shdr->sh_type == SHT_RELA ? - (void *) (((elfsh_Rela *) data) + index) : - (void *) (((elfsh_Rel *) data) + index)); - sym = elfsh_get_symbol_from_reloc(reltab->parent, cur); - name = elfsh_get_symname_from_reloc(reltab->parent, cur); - - if (sym == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol in ET_REL", -1); - - /* Grab a pointer on the dword that need to be relocated */ - dword = (eresi_Addr *) ((char *) elfsh_get_raw(enew) + cur->r_offset); - - /* - ** If symbol type is NOTYPE, we use ET_EXEC symtab, else if - ** symbol link is COMMON, we use ET_REL symbol inserted in ET_EXEC - ** during BSS sizescan in bss.c:elfsh_find_bsslen() - */ - symtype = elfsh_get_symbol_type(sym); - if (elfsh_get_symbol_bind(sym) != STB_LOCAL && /* patch BEOS */ - (symtype == STT_NOTYPE || elfsh_get_symbol_link(sym) == SHN_COMMON)) - { - if (stage == ELFSH_RELOC_STAGE2 && !strstr(name, "old_")) - continue; - - /* If the symbol is not found and we are still in - the first stage relocation, just pass it */ - sym = elfsh_get_metasym_by_name(enew->parent, name); - if (!sym) - { - switch (elfsh_find_relocsym(enew, reltab, &sym, name, stage, symtype)) - { - case 2: -#if __DEBUG_STATIC__ - fprintf(stderr, "[DEBUG_STATIC] RETRY\n"); -#endif - goto retry; - break; - case 0: - continue; - case 1: - break; - case -1: - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to satisfy symbol in ET_REL", -1); - } - } - - addr = sym->st_value; - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] Relocate using existing symbol %-20s " AFMT "]\n", - name, (eresi_Addr) addr); -#endif - - } - - - /* Compute addr giving the injected section's vaddr in ET_EXEC */ - else - { - - /* All the following relocs are computed in stage 1 */ - if (stage == ELFSH_RELOC_STAGE2) - continue; - - /* Find target section in ET_REL */ - sect = elfsh_get_section_by_index(reltab->parent, sym->st_shndx, - NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find extracted section in ET_REL", -1); - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] Found -%s- section (idx = %u), now looking at " - "injected base address\n", sect->name, sect->index); -#endif - - /* Find corresponding inserted section in ET_EXEC */ - snprintf(tmpname, sizeof(tmpname), "%s%s", reltab->parent->name, sect->name); - sect = elfsh_get_section_by_name(enew->parent, tmpname, NULL, NULL, NULL); - - if (sect == NULL) - { - -#if __DEBUG_RELADD__ - elfsh_print_sectlist(reltab->parent, "HEH"); - fprintf(stderr, "[DEBUG_RELADD] Did not found %s section (sym = %s) \n", - tmpname, name); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find inserted section in ET_EXEC", -1); - } - - /* Compute pointer value */ - addr = sect->shdr->sh_addr; - addr += ((elfsh_get_symbol_type(sym) == STT_SECTION && - !FILE_IS_SPARC(sect->parent) && - !FILE_IS_ALPHA64(sect->parent) && - !FILE_IS_MIPS(sect->parent)) ? - *dword : sym->st_value); - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] Relocate using section %-20s base [-> " AFMT "] \n", - sect->name, (eresi_Addr) addr); -#endif - - - } - - /* Perform relocation */ - if (elfsh_relocate_entry(enew, cur, dword, addr, reltab) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to relocate entry", -1); - - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Relocate the object - * @param file - * @param rel - * @param stage - * @return - */ -int elfsh_relocate_object(elfshobj_t *file, elfshobj_t *rel, u_char stage) -{ - elfshsect_t *sect; - elfshsect_t *reltab; - char sctname[BUFSIZ]; - u_int index; - u_int found; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Last pass : relocate each inserted section */ - for (found = index = 0; index < rel->hdr->e_shnum; index++) - { - sect = elfsh_get_section_by_index(rel, index, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant get section in ET_REL", -1); - - /* Check if the section is mapped */ - if (elfsh_get_section_allocflag(sect->shdr) && sect->shdr->sh_size && - sect->shdr->sh_type == SHT_PROGBITS) - { - - /* Find the associate relocation section */ - snprintf(sctname, sizeof(sctname), "%s%s", - (IS_REL(sect) ? ".rel" : ".rela"), sect->name); - reltab = elfsh_get_section_by_name(rel, sctname, NULL, NULL, NULL); - if (reltab == NULL) - continue; - found++; - - /* Find the injected instance of this allocatable section in the ET_EXEC */ - snprintf(sctname, sizeof(sctname), "%s%s", sect->parent->name, sect->name); - sect = elfsh_get_section_by_name(file, sctname, NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant get section in ET_EXEC", -1); - if (elfsh_relocate_etrel_section(sect, reltab, stage) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to relocate section", -1); - } - } - - if (!found) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find any relocation table", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Inject a section from ET_REL object into ET_EXEC - * @param file - * @param sect - * @param mod - * @return - */ -static int elfsh_inject_etrel_section(elfshobj_t *file, elfshsect_t *sect, u_int mod) -{ - elfsh_Shdr hdr; - elfshsect_t *enew; - char *newname; - char writable; - int mode; - char *data; - u_int modulo; - elfshsect_t *plt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_dynamic_file(file) && NULL == (plt = elfsh_get_plt(file, NULL))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PLT", -1); - - /* else create a new section */ - hdr = elfsh_create_shdr(0, sect->shdr->sh_type, sect->shdr->sh_flags, - 0, 0, sect->shdr->sh_size, 0, 0, 0, 0); - XALLOC(__FILE__, __FUNCTION__, __LINE__,newname, strlen(sect->parent->name) + strlen(sect->name) + 2, -1); - sprintf(newname, "%s%s", sect->parent->name, sect->name); - enew = elfsh_create_section(newname); - - /* Copy the data */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,data, sect->shdr->sh_size, -1); - memcpy(data, sect->data, sect->shdr->sh_size); - - /* Inject new section by top or after bss depending on its type */ - writable = elfsh_get_section_writableflag(sect->shdr); - - /* FreeBSD is incompatible with pre-interp injection */ - ELFSH_SELECT_INJECTION(file,writable,mode); - - if (mode == ELFSH_DATA_INJECTION) - modulo = sizeof(eresi_Addr); - else - { - /* modulo = mod; (to be uncommented one day) */ - //modulo = elfsh_get_pagesize(file); - modulo = sizeof(eresi_Addr); - } - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Mapping new section %s with data = %p \n", enew->name, data); -#endif - - if (elfsh_insert_mapped_section(file, enew, hdr, data, mode, modulo) < 0) - goto bad; - enew = elfsh_get_section_by_name(file, newname, NULL, NULL, NULL); - if (enew == NULL) - goto bad; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - bad: - XFREE(__FILE__, __FUNCTION__, __LINE__,newname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ET_REL section", -1); -} - -/** - * The intermediate pass of theglobal algorithm for ET_REL injection - * We fuze symbol tables from the ET_REL and the host binary - * - * @param file - * @param rel - * @return - */ -int elfsh_fuse_etrel_symtab(elfshobj_t *file, elfshobj_t *rel) -{ - elfshsect_t *sect; - elfsh_Sym newsym; - elfsh_Half type; - u_int index; - char sctname[BUFSIZ]; - elfsh_Sym *sym; - int symnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sym = elfsh_get_symtab(rel, &symnbr); - for (index = 0; index < symnbr; index++) - { - type = elfsh_get_symbol_type(sym + index); - - /* Avoid non-injectable symbols */ - if (type != STT_FUNC && type != STT_OBJECT) - continue; - - if (sym[index].st_shndx >= rel->hdr->e_shnum) - continue; - - /* Find target section in ET_REL */ - sect = elfsh_get_section_by_index(rel, sym[index].st_shndx, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find extracted section in ET_REL\n", -1); - - /* Filter symbols using source section */ - if (sect->shdr->sh_type != SHT_PROGBITS || !sect->shdr->sh_size || - !elfsh_get_section_allocflag(sect->shdr)) - continue; - - /* Find corresponding inserted section in ET_EXEC */ - snprintf(sctname, sizeof(sctname), "%s%s", rel->name, sect->name); - sect = elfsh_get_section_by_name(file, sctname, NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant find inserted section in ET_EXEC\n", -1); - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Injected ET_REL symbol %-20s ["XFMT"] \n", - elfsh_get_symbol_name(rel, sym + index), - (eresi_Addr) (sect->shdr->sh_addr + sym[index].st_value)); -#endif - - /* Add symbol in host file */ - newsym = elfsh_create_symbol(sect->shdr->sh_addr + sym[index].st_value, - sym[index].st_size, - elfsh_get_symbol_type(sym + index), - elfsh_get_symbol_bind(sym + index), - 0, sect->index); - - if (elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &newsym, - elfsh_get_symbol_name(rel, sym + index)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert ET_REL symbol", -1); - } - - /* Resynchronize sorted instances of symbol table */ - if (elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_SYMTAB]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to synchronize host symtab", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Inject ET_REL bss inside host BSS - * - * @param file - * @param rel - * @return - */ -int elfsh_fuse_bss(elfshobj_t *file, elfshobj_t *rel) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_insert_runtime_bss(file, rel) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert runtime BSS", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Inject a ET_REL object into a ET_EXEC object - * @param file - * @param rel - * @return - */ -int elfsh_inject_etrel(elfshobj_t *file, elfshobj_t *rel) -{ - u_int mod; - u_int pgsize; - u_int index; - elfshsect_t *sect; - elfshsect_t *hooks; - int ret = 0; - static int depth = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || file->hdr == NULL || rel == NULL || rel->hdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (rel->hdr->e_type != ET_REL || - (file->hdr->e_type != ET_EXEC && file->hdr->e_type != ET_DYN)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bad parameter types", -1); - -#if __DEBUG_RELADD__ - if (rel->pending) - { - printf("[DEBUG_RELADD] BUG BUG BUG \n"); - exit(0); - } - printf("[DEBUG_RELADD] INJECTING %s in %s (depth %d)\n", - rel->name, - file->name, - depth++); -#endif - - - /* Set pending injection flag */ - rel->pending = 1; - - /* If not already done */ - elfsh_setup_hooks(); - - /* First physically insert all BSS in the file and fuse - ** the module's BSS with the last one */ - if (elfsh_fuse_bss(file, rel) < 0) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant fuze BSS sections", -1); - } - - /* First pass : find and inject all allocatable sections */ - for (index = 0; index < rel->hdr->e_shnum; index++) - { - - /* Get the current section */ - sect = elfsh_get_section_by_index(rel, index, NULL, NULL); - if (sect == NULL) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant read section in ET_REL", -1); - } - - /* Check if the current section need to be mapped */ - if (elfsh_get_section_allocflag(sect->shdr) && - sect->shdr->sh_size && sect->shdr->sh_type == SHT_PROGBITS) - { - mod = 0; - - if (elfsh_inject_etrel_section(file, sect, mod) < 0) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ET_REL section", -1); - } - } - } - - /* compute the inject modulo */ - mod = elfsh_get_pagesize(file); - //mod = sizeof(eresi_Addr); - - /* Do a copy of the procedure linkage table for eventual redirection */ - if (!elfsh_static_file(file) && elfsh_copy_plt(file, mod) < 0) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy PLT", -1); - } - - /* Create an additional hook table for non-plt function redirection */ - hooks = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HOOKS, 0, 0, 0); - if (!hooks) - { - int mode; - - /* get injection mode */ - ELFSH_SELECT_INJECTION(file,NULL,mode); - - pgsize = elfsh_get_pagesize(file); - pgsize *= 4; /* We need a lot more than a page to trace big binaries like ssh */ - hooks = elfsh_insert_section(file, - ELFSH_SECTION_NAME_HOOKS, - NULL, - mode, - pgsize - 1, pgsize); - if (!hooks) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot inject .hooks", -1); - } - hooks->curend = 0; - } - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Entering intermediate symbol injection loop\n"); -#endif - - /* Intermediate pass 2 : Inject ET_REL symbol table into host file */ - if (elfsh_fuse_etrel_symtab(file, rel) < 0) - { - rel->pending = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to fuze symbol tables", -1); - } - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Entering final relocation loop\n"); - - elfsh_print_sectlist(file, "before relocation"); -#endif - - /* Now call the relocation on the object's sections */ - ret = elfsh_relocate_object(file, rel, ELFSH_RELOC_STAGE1); - rel->pending = 0; - depth--; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * Front end function for injection in static binaries with module dependences - * - * @param host - * @param rel - * @param listw - * @param listsh - * @return - */ -int elfsh_inject_etrel_hash(elfshobj_t *host, elfshobj_t *rel, - hash_t *listw, hash_t *listsh) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - elfsh_register_working_objects(listw, listsh); - ret = elfsh_inject_etrel(host, rel); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject ET_REL with list", ret); - else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (ret)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/reloc.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/reloc.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/reloc.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/reloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,584 +0,0 @@ -/** - * @file reloc.c - * @ingroup libelfsh -** reloc.c for elfsh -** -** Started on Tue Feb 27 14:34:50 2001 jfv -** -** -** $Id: reloc.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Contain the last requested relocation type - * This ugly flag may be sensible to race conditions if 2 users use - * it at the same time. However it is necessary for discriminating - * elfsh_Rel and elfsh_Rela pointers in scripting handlers since - * the handlers are shared with other ELF objects types, we lack - * a bit of flexibility here. - */ -static char isrel = 1; - - -/** - * Create relocation entry - * @param type - * @param sym - * @param off - * @return - */ -elfsh_Rel elfsh_create_relent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off) -{ - elfsh_Rel r; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_set_reltype(&r, type); - elfsh_set_relsym(&r, sym); - elfsh_set_reloffset(&r, off); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r)); -} - -/** - * Create relocation entry - * @param type - * @param sym - * @param off - * @param add - * @return - */ -elfsh_Rela elfsh_create_relaent(eresi_Addr type, eresi_Addr sym, - eresi_Addr off, eresi_Addr add) -{ - elfsh_Rela r; - elfsh_Rela *enta; - elfsh_Rel *ent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - enta = &r; - ent = (elfsh_Rel *) enta; - elfsh_set_reltype(ent, type); - elfsh_set_relsym(ent, sym); - elfsh_set_reloffset(ent, off); - elfsh_set_reladdend(&r, add); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r)); -} - -/** - * Return the relocation type - * @param r - * @return - */ -u_int elfsh_get_reltype(elfsh_Rel *r) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_R_TYPE(r->r_info))); -} - -/** - * Return the relocation type - * @param r - * @param type - * @return - */ -u_int elfsh_set_reltype(elfsh_Rel *r, eresi_Addr type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - r->r_info = ELFSH_R_INFO(ELFSH_R_SYM(r->r_info), type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the relocation symbol index - * @param r - * @return - */ -u_int elfsh_get_relsym(elfsh_Rel *r) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_R_SYM(r->r_info))); -} - -/** - * Change the relocation symbol index - * @param r - * @param sym - * @return - */ -u_int elfsh_set_relsym(elfsh_Rel *r, eresi_Addr sym) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - r->r_info = ELFSH_R_INFO(sym, ELFSH_R_TYPE(r->r_info)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the relocation offset - * @param r - * @return - */ -eresi_Addr elfsh_get_reloffset(elfsh_Rel *r) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r->r_offset)); -} - -/** - * Change the relocation offset for this entry - * @param r - * @param off - * @return - */ -int elfsh_set_reloffset(elfsh_Rel *r, eresi_Addr off) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - r->r_offset = off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the add-end - * @param r - * @return - */ -elfsh_Sword elfsh_get_reladdend(elfsh_Rela *r) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (r == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r->r_addend)); -} - -/** - * Change the add-end - * @param r - * @param val - * @return - */ -int elfsh_set_reladdend(elfsh_Rela *r, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (r == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - r->r_addend = (elfsh_Sword) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Change endianess of relocation tables - * @param s - * @return - */ -int elfsh_endianize_relocs(elfshsect_t *s) -{ - u_int idx; - elfsh_Rel *rel; - elfsh_Rela *rela; - u_int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - sz = s->shdr->sh_size / (IS_REL(s) ? - sizeof(elfsh_Rel) : - sizeof(elfsh_Rela));; - - /* Arrange endianess if necessary */ -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (s->parent->hdr->e_ident[EI_DATA] == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (s->parent->hdr->e_ident[EI_DATA] == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - rel = (void *) elfsh_get_raw(s); - rela = (void *) rel; - - for (idx = 0; idx < sz; idx++) - if (s->shdr->sh_type == SHT_REL) - { - rel[idx].r_offset = swaplong(rel[idx].r_offset); - rel[idx].r_info = swaplong(rel[idx].r_info); - } - else if (s->shdr->sh_type == SHT_RELA) - { - rela[idx].r_offset = swaplong(rela[idx].r_offset); - rela[idx].r_info = swaplong(rela[idx].r_info); - rela[idx].r_addend = swaplong(rela[idx].r_addend); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the 'range'th relocation table - * @param file - * @param range - * @param nbr - * @return - */ -elfshsect_t *elfsh_get_reloc(elfshobj_t *file, - eresi_Addr range, - u_int *nbr) -{ - elfshsect_t *s; - u_int type; - u_int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file->sectlist == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", NULL); - - /* Read section */ - type = (IS_REL(file->sectlist) ? SHT_REL : SHT_RELA); - s = elfsh_get_section_by_type(file, type, - range, NULL, - NULL, NULL); - if (s == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get reloc section", NULL); - - /* Return what's needed */ - sz = s->shdr->sh_size / (s->shdr->sh_type == SHT_REL ? - sizeof(elfsh_Rel) : - sizeof(elfsh_Rela));; - if (nbr != NULL) - *nbr = sz; - - /* Load section data */ - if (s->data == NULL) - { - s->data = elfsh_load_section(file, s->shdr); - if (s->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load reloc data", NULL); - elfsh_endianize_relocs(s); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); -} - - -/** - * Insert a symbol in the given symbol table - * @param sect - * @param rel - * @return - */ -int elfsh_insert_relent(elfshsect_t *sect, elfsh_Rel *rel) - -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (sect == NULL || sect->shdr == NULL || rel == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL paramater", -1); - if (sect->shdr->sh_type != SHT_REL && sect->shdr->sh_type != SHT_RELA) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Input section is not REL/RELA", -1); - - /* Insert entry in relocation table */ - if (sect->shdr->sh_type == SHT_REL) - index = elfsh_append_data_to_section(sect, rel, sizeof(elfsh_Rel)); - else - index = elfsh_append_data_to_section(sect, rel, sizeof(elfsh_Rela)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (index)); -} - - - -/** - * Return the symbol name associated with the relocation entry - * @param file - * @param r - * @return - */ -char *elfsh_get_symname_from_reloc(elfshobj_t *file, - elfsh_Rel *r) -{ - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanitize */ - sym = elfsh_get_symbol_from_reloc(file, r); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol", NULL); - - /* The object is relocatable : find symbol in .symtab */ - if (file->hdr->e_type == ET_REL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_symbol_name(file, sym))); - - /* else find symbol in .dynsym */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_dynsymbol_name(file, sym))); -} - - - -/** - * Return the Symbol associated with the relocation entry - * @param file - * @param r - * @return - */ -elfsh_Sym *elfsh_get_symbol_from_reloc(elfshobj_t *file, - elfsh_Rel *r) -{ - elfsh_Sym *sym; - u_int tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (NULL == file || NULL == r) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - tmp = ELFSH_R_SYM(r->r_info); - - /* The object is relocatable : find symbol in .symtab */ - if (file->hdr->e_type == ET_REL) - { - if (NULL == file->secthash[ELFSH_SECTION_SYMTAB]) - if (NULL == elfsh_get_symtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find SYMTAB", NULL); - - sym = (elfsh_Sym *) file->secthash[ELFSH_SECTION_SYMTAB]->data; - sym += tmp; //(tmp * ELFSH_SYMTAB_ENTRY_SIZE)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym)); - } - - /* else find symbol in .dynsym */ - if (NULL == file->secthash[ELFSH_SECTION_DYNSYM] && - NULL == elfsh_get_dynsymtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find DYNSYM", NULL); - - sym = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSYM]) + - (tmp * ELFSH_SYMTAB_ENTRY_SIZE); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym)); -} - - - -/** - * Ugly hook, but necessary for keeping track of the reloc element type - * since elfsh_get_relent_by_index cannot do it since it shares a function - * pointer with other elf objects in the scripting engine. -m - * @param b - */ -void elfsh_setrel(char b) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - isrel = b; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Used as internal handler for elfsh hashes - * @param table - * @param index - * @return - */ -elfsh_Rel *elfsh_get_relent_by_index(elfsh_Rel *table, eresi_Addr index) -{ - elfsh_Rela *atable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - atable = (elfsh_Rela *) table; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (isrel ? table + index : (elfsh_Rel*) ((elfsh_Rela*) atable + index))); -} - - - -/** - * Used as internal handler for elfsh hashes - * @param file - * @param name - * @return - */ -elfsh_Rel *elfsh_get_relent_by_name(elfshobj_t *file, char *name) -{ - elfshsect_t *sect; - elfsh_Rel *cur; - u_int range; - u_int idx; - u_int num; - char *curnam; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Find relocation entry by name */ - sect = elfsh_get_reloc(file, 0, &num); - for (range = 1; NULL != sect; range++) - { - for (idx = 0; idx < num; idx++) - { - data = elfsh_get_raw(sect); - cur = (sect->shdr->sh_type == SHT_RELA ? - (void *) ((elfsh_Rela *) data + idx) : - (void *) ((elfsh_Rel *) data + idx)); - curnam = elfsh_get_symname_from_reloc(file, cur); - if (curnam != NULL && !strcmp(curnam, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - } - sect = elfsh_get_reloc(file, range, &num); - } - - /* Not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Relentry not found", NULL); -} - - - -/** - * Create relocation table for section - * @param sect - * @return - */ -elfshrel_t *elfsh_find_rel(elfshsect_t *sect) -{ - elfshsect_t *target; - elfshrel_t *rel; - int *dword; - char *str; - eresi_Addr vaddr; - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - else if (elfsh_get_raw(sect) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section empty", NULL); - else if (sect->shdr->sh_addr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section unmapped", NULL); - else if (sect->rel) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->rel)); - - /* These sections must not be relocated, but passed to relative */ - if (sect->shdr->sh_type == SHT_DYNSYM || - sect->shdr->sh_type == SHT_REL || - sect->shdr->sh_type == SHT_RELA || - sect->shdr->sh_type == SHT_DYNAMIC || - !strcmp(sect->name, ELFSH_SECTION_NAME_GOT) || - !strcmp(sect->name, ELFSH_SECTION_NAME_CTORS) || - !strcmp(sect->name, ELFSH_SECTION_NAME_DTORS)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Use different relocation code for this section", NULL); - - /* Free existing rel[] entries if existing (section data probably changed) */ - sect->srcref = sect->dstref = 0; - - /* Read the actual section and find valid references */ - str = elfsh_get_raw(sect); - for (dword = (int *) str; - ((char *) dword + 4) <= ((char *) elfsh_get_raw(sect) + - sect->shdr->sh_size); - dword = (int *) str) - { - target = elfsh_get_parent_section(sect->parent, *dword, NULL); - if (target != NULL) - { - sect->srcref++; - target->dstref++; - } - str++; - } - - /* allocate the array */ - if (sect->srcref == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No need to relocate section", NULL); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,rel, sect->srcref * sizeof(elfshrel_t), NULL); - - /* Read the actual section again and create section rel table */ - str = elfsh_get_raw(sect); - for (index = 0, dword = (int *) str; - ((char *) dword + 4) <= ((char *) elfsh_get_raw(sect) + - sect->shdr->sh_size); - dword = (int *) str) - { - target = elfsh_get_parent_section(sect->parent, *dword, NULL); - if (target != NULL) - { - vaddr = sect->shdr->sh_addr + - (eresi_Addr) ((char *) str - (char *) elfsh_get_raw(sect)); - rel[index].idx_src = sect->index; - rel[index].off_src = vaddr - sect->shdr->sh_addr; - rel[index].idx_dst = target->index; - rel[index].off_dst = *dword - target->shdr->sh_addr; - rel[index].type = ELFSH_RELOC_SECTBASE; - index++; - } - str++; - } - - /* Return the array */ - sect->rel = rel; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->rel)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/remap.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/remap.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/remap.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/remap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,466 +0,0 @@ -/** - * @file remap.c - * @ingroup libelfsh -** remap.c for elfsh -** -** elfsh_reloc_pht/sht/symtab() are based on spacewalker's -** original modremap.c -** -** Started on Mon Mar 17 09:30:33 2003 jfv -** -** -** $Id: remap.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * Remap the Program Header Table - * @param file - * @param diff - * @return - */ -int elfsh_reloc_pht(elfshobj_t *file, eresi_Addr diff) -{ - u_int i; - u_int count; - eresi_Addr base; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - base = elfsh_get_object_baseaddr(file); - if (file == NULL || file->pht == NULL || file->hdr->e_phnum == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", 0); - - for (count = i = 0; i < file->hdr->e_phnum; i++) - { - if (file->pht[i].p_vaddr >= base) - { - file->pht[i].p_vaddr += diff; - count++; - } - if (file->pht[i].p_paddr >= base) - { - file->pht[i].p_paddr += diff; - count++; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - -/** - * Remap the Section Header Table - * @param file - * @param diff - * @return - */ -int elfsh_reloc_sht(elfshobj_t *file, eresi_Addr diff) -{ - u_int i; - u_int count; - eresi_Addr base; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || file->sht == NULL || file->hdr->e_shnum == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - base = elfsh_get_object_baseaddr(file); - for (count = i = 0; i < file->hdr->e_shnum; i++) - if (file->sht[i].sh_addr > base) - { - file->sht[i].sh_addr += diff; - count++; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - -/** - * Remap a section which type is SHT_SYMTAB or SHT_DYNSYM - * @param s - * @param diff - * @return - */ -int elfsh_reloc_symtab(elfshsect_t *s, eresi_Addr diff) -{ - elfsh_Sym *symtab; - u_int i; - eresi_Addr vaddr; - u_int count; - eresi_Addr base; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (s == NULL || s->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (s->shdr->sh_type != SHT_SYMTAB && s->shdr->sh_type != SHT_DYNSYM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section is not a symbol table", -1); - - symtab = elfsh_get_raw(s); - base = elfsh_get_object_baseaddr(s->parent); - for (count = i = 0; i < s->shdr->sh_size / sizeof(elfsh_Sym); i++) - { - vaddr = elfsh_get_symbol_value(symtab + i); - if (vaddr > base) - { - elfsh_set_symbol_value(symtab + i, vaddr + diff); - count++; - } - } - - /* Synchronize the symtab hash table */ - elfsh_sync_sorted_symtab(s); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - -/** - * Remap a section using its extra relocation entries - * @param cur - * @param diff - * @return - */ -int elfsh_reloc_raw(elfshsect_t *cur, eresi_Addr diff) -{ - u_int index; - eresi_Addr addr; - elfshsect_t *target; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (cur == NULL || cur->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (elfsh_get_raw(cur) == NULL || cur->rel == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Read the actual section and find valid references */ - for (index = 0; index < cur->srcref; index++) - switch (cur->rel[index].type) - { - - /* Relocate by : section[idx_dst].vaddr + off_dst */ - case ELFSH_RELOC_SECTBASE: - target = elfsh_get_section_by_index(cur->parent, - cur->rel[index].idx_dst, - NULL, NULL); - if (target == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid IDX_DST", -1); - - str = elfsh_get_raw(cur) + cur->rel[index].off_src; - addr = target->shdr->sh_addr + cur->rel[index].off_dst + diff; - memcpy(str, &addr, sizeof(eresi_Addr)); - - /* Do not relocate */ - case ELFSH_RELOC_FP: - default: - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur->srcref)); -} - -/** - * Remap the .dynamic section - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_dynamic(elfshsect_t *sect, eresi_Addr diff) -{ - elfshsect_t *parent; - elfsh_Dyn *dyn; - u_int index; - u_int count; - eresi_Addr val; - u_int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (sect->shdr->sh_type != SHT_DYNAMIC) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected section type", -1); - - nbr = sect->shdr->sh_size / sizeof(elfsh_Dyn); - for (dyn = elfsh_get_raw(sect), count = index = 0; index < nbr; index++) - { - val = elfsh_get_dynentry_val(dyn + index); - parent = elfsh_get_parent_section(sect->parent, val, NULL); - if (val && parent != NULL && parent->shdr->sh_addr != NULL) - { - elfsh_set_dynentry_val(dyn + index, val + diff); - count++; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - - -/** - * Remap sections of type SHT_REL and SHT_RELA - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_rel(elfshsect_t *sect, eresi_Addr diff) -{ - elfshsect_t *parent; - elfsh_Rel *rel; - u_int index; - u_int count; - u_int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (sect->shdr->sh_type != SHT_REL && sect->shdr->sh_type != SHT_RELA) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected section type", -1); - - nbr = sect->shdr->sh_size / sizeof(elfsh_Rel); - for (rel = elfsh_get_raw(sect), count = index = 0; index < nbr; index++) - { - parent = elfsh_get_parent_section(sect->parent, - rel[index].r_offset, - NULL); - if (rel[index].r_offset && parent != NULL && parent->shdr->sh_addr != NULL) - { - rel[index].r_offset += diff; - count++; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - -/** - * Remap section's whoose type is a data array (GOT, CTORS, DTORS ..) - * @param file - * @param array - * @param size - * @param diff - * @return - */ -int elfsh_reloc_array(elfshobj_t *file, - eresi_Addr *array, - u_int size, - eresi_Addr diff) -{ - elfshsect_t *parent; - u_int index; - u_int count; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || array == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL paramater", -1); - - for (count = index = 0; index < size; index++) - { - parent = elfsh_get_parent_section(file, array[index], NULL); - if (parent != NULL && parent->shdr->sh_addr != NULL && array[index] != NULL) - { - array[index] += diff; - count++; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} - -/** - * Remap Global Offset Table - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_got(elfshsect_t *sect, eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (strcmp(sect->name, ELFSH_SECTION_NAME_GOT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected section name", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), - sect->shdr->sh_size / sizeof(eresi_Addr), diff))); -} - -/** - * Remap .ctors section - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_ctors(elfshsect_t *sect, eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (strcmp(sect->name, ELFSH_SECTION_NAME_CTORS)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected section name", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), - sect->shdr->sh_size / sizeof(eresi_Addr), - diff))); -} - -/** - * Remap .dtors section - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_dtors(elfshsect_t *sect, eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (strcmp(sect->name, ELFSH_SECTION_NAME_DTORS)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected section name", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), - sect->shdr->sh_size / sizeof(eresi_Addr), - diff))); -} - - -/** - * Not used ATM since it triggers more false positives ;P - * @param sect - * @param diff - * @return - */ -int elfsh_reloc_hash(elfshsect_t *sect, eresi_Addr diff) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (sect->shdr->sh_type != SHT_HASH) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section is not HASH", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reloc_array(sect->parent, elfsh_get_raw(sect), - sect->shdr->sh_size / sizeof(eresi_Addr), diff))); -} - - -/** - * Call the type dependant remapping routine for this section - * @param sect - * @param diff - * @return - */ -int elfsh_relocate_section(elfshsect_t *sect, eresi_Addr diff) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - if (sect == NULL || elfsh_get_raw(sect) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL paramater", -1); - - if (sect->shdr->sh_addr != NULL) - elfsh_find_rel(sect); - - if (sect->shdr->sh_type == SHT_SYMTAB) - ret = elfsh_reloc_symtab(sect, diff); - else if (sect->shdr->sh_type == SHT_DYNSYM) - ret = elfsh_reloc_symtab(sect, diff); - else if (sect->shdr->sh_type == SHT_RELA || sect->shdr->sh_type == SHT_REL) - ret = elfsh_reloc_rel(sect, diff); - else if (sect->shdr->sh_type == SHT_DYNAMIC) - ret = elfsh_reloc_dynamic(sect, diff); - else if (!strcmp(sect->name, ELFSH_SECTION_NAME_CTORS)) - ret = elfsh_reloc_ctors(sect, diff); - else if (!strcmp(sect->name, ELFSH_SECTION_NAME_DTORS)) - ret = elfsh_reloc_dtors(sect, diff); - else if (!strcmp(sect->name, ELFSH_SECTION_NAME_GOT)) - ret = elfsh_reloc_got(sect, diff); - else if (sect->shdr->sh_addr != NULL) - ret = elfsh_reloc_raw(sect, diff); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Relocation recovery failed for this section", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * XXX .::. TODO for ET_EXEC to ET_DYN : - * - Insertion a new .rel section - * - Change objtype and entryp in ELF header - * - Relocate PHT and SHT - * - Change reloc section size in .dynamic * - * - * @param file - * @param new_addr - * @return - */ -int elfsh_remap(elfshobj_t *file, eresi_Addr new_addr) -{ - elfshsect_t *sect; - eresi_Addr diff; - u_int count; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - count = 0; - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (elfsh_read_obj(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to read object", -1); - - diff = elfsh_get_object_baseaddr(file); - if (diff == (eresi_Addr) -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object base address is NULL", -1); - - for (sect = file->sectlist; sect != NULL; sect = sect->next) - { - ret = elfsh_relocate_section(sect, -diff); - printf("Relocation number found for %-20s : %d \n", sect->name, ret); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to relocate section", -1); - count += ret; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (count)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/rpht.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/rpht.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/rpht.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/rpht.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,98 +0,0 @@ -/** - * @file rpht.c - * @ingroup libelfsh -** rpht.c for elfsh -** -** @brief Specific functions for Runtime Program Header Table -** -** Started on Sat Oct 01 14:37:33 2005 jfv -** -** $Id: rpht.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * @brief Return a ptr on the program header table - * @param file - * @param num - * @return - */ -void *elfsh_get_rpht(elfshobj_t *file, int *num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->rpht == NULL && elfsh_create_rpht(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Runtime PHT does not exist", NULL); - if (num != NULL) - *num = file->rhdr.rphtnbr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (file->rpht)); -} - -/** - * Create and insert the Runtime PHT - * @param file - * @return - */ -int elfsh_create_rpht(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Create and insert the new unmapped section containing it */ - if (!file->rpht) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,file->rpht, elfsh_get_pagesize(file), -1); - file->rhdr.rphtnbr = 0; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Insert a PHT entry in the RPHT (e2dbg safe) - * @param file - * @param h - * @return - */ -elfsh_Phdr *elfsh_insert_runtime_phdr(elfshobj_t *file, elfsh_Phdr *h) -{ - elfsh_Phdr *phdr; - /* - elfshsect_t *rpht; - elfshsect_t *cur; - */ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Some preliminary checks */ - phdr = elfsh_get_rpht(file, NULL); - if (!phdr) - elfsh_create_rpht(file); - - /* - if (!phdr && elfsh_create_rpht(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create Runtime PHT", NULL); - - rpht = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_RPHT, 0, 0, 0); - if (!rpht) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get Runtime PHT", NULL); - - for (cur = rpht; cur != NULL; cur = cur->next) - if (cur->shdr->sh_offset) - cur->shdr->sh_offset += file->hdr->e_phentsize; - - if (file->hdr->e_shoff >= rpht->shdr->sh_offset) - file->hdr->e_shoff += file->hdr->e_phentsize; - */ - - /* Everything OK */ - file->rpht[file->rhdr.rphtnbr++] = *h; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (file->rpht + file->rhdr.rphtnbr - 1)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/runtime.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/runtime.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/runtime.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/runtime.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,261 +0,0 @@ -/** - * @file runtime.c - * @ingroup libelfsh -** runtime.c for libelfsh -** -** -** This file contains runtime routines used for memory mapping -** in the debugger -** -** Started Sun 05 May 2005 22:29:54 mm -** -** -** $Id: runtime.c,v 1.9 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * @brief Set PHT entry rights from elfsh section mode - * @param mode - * @return - */ -int elfsh_set_phdr_prot(u_int mode) -{ - elfsh_Word flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - flags = PF_R | PF_W; - // if (mode == ELFSH_CODE_INJECTION) - flags |= PF_X; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (flags)); -} - -/** - * @brief Map a new area in memory - * @param segment - * @return - */ -eresi_Addr elfsh_runtime_map(elfsh_Phdr *segment) -{ - eresi_Addr addr; - int prot = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_segment_is_readable(segment)) - prot |= PROT_READ; - if (elfsh_segment_is_writable(segment)) - prot |= PROT_WRITE; - if (elfsh_segment_is_executable(segment)) - prot |= PROT_EXEC; - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] MMAP: " XFMT " of %d bytes \n", segment->p_vaddr, segment->p_memsz); -#endif - -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - if(kernsh_alloc(segment->p_memsz, ((unsigned long *)&addr)) == -1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot alloc memory", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (addr)); - } - -#endif - -#if defined(IRIX) -{ - int zero; - - zero = fopen("/dev/zero", O_RDWR); - if (zero < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to open /dev/zero", - ELFSH_INVALID_ADDR); - - addr = (eresi_Addr) mmap((void *) 0, segment->p_memsz, - prot, - //elfsh_get_segment_flags(segment), - MAP_PRIVATE, - zero, 0); - close(zero); -} -#else - addr = (eresi_Addr) mmap((void *) 0, segment->p_memsz, - prot, - MAP_PRIVATE | MAP_ANONYMOUS, - 0, 0); -#endif - - - if (addr == 0 && segment->p_vaddr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mmap refused the mapping", - ELFSH_INVALID_ADDR); - -#if __DEBUG_RUNTIME__ - else - printf("[DEBUG_RUNTIME] Section Mapped at addr %08X (%u) with prot %c%c%c\n", - addr, segment->p_memsz, - (elfsh_segment_is_readable(segment) ? 'R' : '-'), - (elfsh_segment_is_writable(segment) ? 'W' : '-'), - (elfsh_segment_is_executable(segment) ? 'X' : '-')); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (addr)); -} - - -/** - * @brief Unmap a previously requested area - * @param segment - * @return - */ -int elfsh_runtime_unmap(elfsh_Phdr *segment) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = munmap((void *) segment->p_vaddr, segment->p_memsz); - - //if (!ret) - //memset(segment, 0x00, sizeof(elfsh_Phdr)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * Remap an existing zone with a bigger size - * @param segment - * @param moresize - * @return - */ -int elfsh_runtime_remap(elfsh_Phdr *segment, uint32_t moresize) -{ - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_runtime_unmap(segment); - segment->p_memsz += moresize; - addr = elfsh_runtime_map(segment); - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Could not extend mmaped memory", - ELFSH_INVALID_ADDR); - - segment->p_vaddr = segment->p_paddr = addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addr); -} - -/** - * @brief Synchronize ondisk modifications in memory - * @return Always returns 0 - */ -int elfsh_runtime_sync() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Put write capability on the zone - * @param file - * @param addr - * @param sz - * @return - */ -int elfsh_munprotect(elfshobj_t *file, - eresi_Addr addr, - uint32_t sz) -{ - elfshsect_t *sect; - elfsh_Phdr *phdr; - int retval; - int prot; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - -#endif - - if (!elfsh_is_debug_mode()) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - sect = elfsh_get_parent_section(file, addr, NULL); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section", -1); - - phdr = elfsh_get_parent_segment(file, sect); - prot = 0; - - if (elfsh_segment_is_readable(phdr)) - prot |= PROT_READ; - if (elfsh_segment_is_writable(phdr)) - prot |= PROT_WRITE; - if (elfsh_segment_is_executable(phdr)) - prot |= PROT_EXEC; - - retval = mprotect((void *) (addr - addr % getpagesize()), - getpagesize(), PROT_READ | PROT_WRITE); - - if (retval != 0) - { - perror("mprotect"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed mprotect", -1); - } - /* Return the original rights */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - prot); -} - -/** - * @brief Restore original rights - * @param addr - * @param sz - * @param prot - * @return - */ -int elfsh_mprotect(eresi_Addr addr, uint32_t sz, int prot) -{ - int retval; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(KERNSH) - - if (kernsh_is_mem_mode()) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - -#endif - if (!elfsh_is_debug_mode()) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - retval = mprotect((void *) (long) addr - (long) addr % getpagesize(), - getpagesize(), prot); - - if (retval != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed munprotect", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, retval); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sanitize.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sanitize.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sanitize.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sanitize.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,172 +0,0 @@ -/** - * @file sanitize.c - * @ingroup libelfsh -** sanitize.c for elfsh -** -** Started on Sun Mar 30 04:13:03 2003 jfv -** -** -** $Id: sanitize.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/** - * @brief Update the sh_name field in the section header table entry - * @param file - * @param offset - * @param len - * @return - */ -void elfsh_update_nameidx(elfshobj_t *file, int offset, int len) -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < file->hdr->e_shnum; index++) - if (file->sht[index].sh_name > offset) - file->sht[index].sh_name -= len; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update the sh_link for all sections linked to a specific shifted one - * @param file - * @param low_index - * @param diff - * @return - */ -void elfsh_update_linkidx(elfshobj_t *file, int low_index, int diff) -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < file->hdr->e_shnum; index++) - if (file->sht[index].sh_link && file->sht[index].sh_link >= low_index) - file->sht[index].sh_link += diff; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update the sh_link for all section linked to a specific one - * @param file - * @param idx - * @param diff - * @return - */ -void elfsh_update_linkidx_equ(elfshobj_t *file, int idx, int diff) -{ - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_shstrndx == idx) - file->hdr->e_shstrndx += diff; - for (index = 0; index < file->hdr->e_shnum; index++) - if (file->sht[index].sh_link && file->sht[index].sh_link == idx) - file->sht[index].sh_link += diff; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update the sh_link for all section linked to a specific one - * @param file - * @param idx - * @param diff - * @return - */ -void elfsh_update_symlinkidx_equ(elfshobj_t *file, int idx, int diff) -{ - elfshsect_t *s; - int index; - u_int size; - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If there is no symtab, no need to fix st_shndx fields */ - s = file->secthash[ELFSH_SECTION_SYMTAB]; - if (s != NULL) - { - sym = s->data; - size = s->shdr->sh_size / ELFSH_SYMTAB_ENTRY_SIZE; - for (index = 0; index < size; index++) - if (sym[index].st_shndx && sym[index].st_shndx == idx) - sym[index].st_shndx += diff; - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update sh_link fields for the given section - * @param file - * @param tab - * @param idx - * @param diff - * @return - */ -void elfsh_update_shidx(elfshobj_t *file, elfshsect_t *tab, int idx, int diff) -{ - elfshsect_t *s; - int index; - u_int size; - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If there is no symtab, no need to fix st_shndx fields */ - s = tab; - if (s != NULL) - { - sym = s->data; - size = s->shdr->sh_size / ELFSH_SYMTAB_ENTRY_SIZE; - for (index = 0; index < size; index++) - if (sym[index].st_shndx && sym[index].st_shndx > idx) - sym[index].st_shndx += diff; - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update the sh_link for all section linked to a specific one - * @param file - * @param idx - * @param diff - * @return - */ -void elfsh_update_dynsym_shidx(elfshobj_t *file, int idx, int diff) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If there is no symtab, no need to fix st_shndx fields */ - s = file->secthash[ELFSH_SECTION_DYNSYM]; - if (s != NULL) - elfsh_update_shidx(file, s, idx, diff); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Update the sh_link for all section linked to a specific one - * @param file - * @param idx - * @param diff - */ -void elfsh_update_symtab_shidx(elfshobj_t *file, int idx, int diff) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If there is no symtab, no need to fix st_shndx fields */ - s = file->secthash[ELFSH_SECTION_SYMTAB]; - if (s != NULL) - elfsh_update_shidx(file, s, idx, diff); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/save.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/save.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/save.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/save.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,372 +0,0 @@ -/** - * @file save.c - * @ingroup libelfsh - ** save.c for elfsh - ** - ** Started on Tue Mar 4 01:14:01 2003 jfv - ** Last update Thu Mar 23 23:21:08 2006 thorkill - ** - ** $Id: save.c,v 1.18 2008-02-16 12:32:27 thor Exp $ - ** - */ -#include "libelfsh.h" -#include "libetrace.h" - - -/** - * @brief Find a string in a random buffer of size n - * @param buffer - * @param neddle - * @param n - * @return - */ -static char* elfsh_strstr(char *buffer, char *neddle, int n) -{ - int idx; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; idx < n; idx++) - { - ret = strstr(buffer + idx, neddle); - if (ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find injected names", NULL); -} - - -/** - * Find the number of removed shdr before a given index - * @param file - * @param idx - * @return - */ -static int elfsh_find_previous_rmnbr(elfshobj_t *file, u_int idx) -{ - elfshsect_t *sect; - int index; - int res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = file->sectlist; - for (res = index = 0; index < idx; index++, sect = sect->next) - if (sect->flags & ELFSH_SECTION_REMOVED) - res++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (res)); -} - - -/** - * Save SHT taking care of removed shdr if the file was cleaned up - * @param file - * @param fd - * @return - */ -static int elfsh_save_sht(elfshobj_t *file, int fd) -{ - elfsh_Shdr *newsht; - elfshsect_t *sect; - int index; - int wrindex; - uint32_t newsize; - uint32_t delsize; - char *first; - char *off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_MAP__ - printf("[DEBUG_MAP] Writing SHT \t\t\t\t (file offset %u, size %u)\n", - (u_int) file->hdr->e_shoff, - (u_int) (file->hdr->e_shentsize * file->hdr->e_shnum)); -#endif - - /* Allocate */ - newsize = (file->hdr->e_shnum - file->nbrm) * file->hdr->e_shentsize; - newsht = alloca(newsize); - memset(newsht, 0x00, newsize); - sect = file->sectlist; - first = NULL; - - /* Dump new SHT */ - for (wrindex = index = 0; index < file->hdr->e_shnum; index++, sect = sect->next) - if (!(sect->flags & ELFSH_SECTION_REMOVED)) - { - memcpy(newsht + wrindex, file->sht + index, file->hdr->e_shentsize); - newsht[wrindex].sh_link -= elfsh_find_previous_rmnbr(file, newsht[wrindex].sh_link); -#if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Comparing current end from %s (%u vs %u) ! \n", - sect->name, sect->curend, sect->shdr->sh_size); -#endif - - /* Avoid incorrect data dumping on partially filled sections */ - if (sect->curend) - { -#if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Changing %s's size for current end ! \n", sect->name); -#endif - newsht[wrindex].sh_size = sect->curend; - } - wrindex++; - } - else if (wrindex == index) - first = sect->name; - - /* Remove remaining section names in .shstrtab */ - sect = file->secthash[ELFSH_SECTION_SHSTRTAB]; - if (sect && first) - { - off = elfsh_strstr(sect->data, first, sect->shdr->sh_size); - if (off) - { - delsize = sect->shdr->sh_size - ((char *) off - (char *) sect->data); - memset(off, 0x00, delsize); - sect->shdr->sh_size -= delsize; - XSEEK(fd, elfsh_get_section_foffset(sect->shdr), SEEK_SET, -1); - XWRITE(fd, sect->data, sect->shdr->sh_size, -1); - } - } - - /* Write SHT */ - elfsh_endianize_sht((elfsh_Shdr *) newsht, - file->hdr->e_ident[EI_DATA], - file->hdr->e_shnum - file->nbrm); - XSEEK(fd, file->hdr->e_shoff, SEEK_SET, 0); - XWRITE(fd, newsht, newsize, 0); - -#if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Saved SHT -ok- \n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Relocate during save process - * @param file - * @return - */ -int elfsh_save_relocate(elfshobj_t *file) -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Force the final relocations to be done (old_* symbols) */ - for (index = 0; index < file->nbrel; index++) - { - -#if __DEBUG_MAP__ - printf("[DEBUG_MAP] Now relocating %s in second stage \n", - file->listrel[index]->name); -#endif - - if (elfsh_relocate_object(file, file->listrel[index], - ELFSH_RELOC_STAGE2) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Final stage relocation failed", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Unmap and free all ressources for this file - * @param file - * @param name - * @return - */ -int elfsh_save_obj(elfshobj_t *file, char *name) -{ - int fd; - char written_sht; - elfshsect_t *actual; - int index; - elfsh_Ehdr header; - elfsh_Phdr *pht; - unsigned int totsize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || file->sht == NULL || file->sectlist == NULL || - (file->pht == NULL && elfsh_get_objtype(file->hdr) != ET_REL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid elfshobj_t parameter", -1); - - if (elfsh_save_relocate(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Final stage relocation failed", -1); - - /* Insert a padding section to make the latest top-injected code section starting on a page bound */ - actual = file->sectlist; - while (actual && actual->shdr && !actual->shdr->sh_addr) - actual = actual->next; - - /* Only useful when we injected sections in the first PT_LOAD beforehand */ - if (actual && strstr(actual->name, ".elfsh")) - { - totsize = actual->shdr->sh_addr - sizeof(elfsh_Ehdr) - (sizeof(elfsh_Phdr) * file->hdr->e_phnum); - if (totsize % elfsh_get_pagesize(file)) - { - actual = elfsh_insert_section(file, ELFSH_SECTION_NAME_PADPAGE, - NULL, ELFSH_CODE_INJECTION, - totsize % elfsh_get_pagesize(file), 0); - if (!actual) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inject page padding section", -1); - } - } - - /* Copy the object before saving (so that we dont strip the working file) */ - file = elfsh_copy_obj(file); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy object", -1); - - /* Apply awaiting function tracing hooks */ - if (file->hdr->e_type != ET_REL && etrace_save(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Tracing failed", -1); - - /* Open the output file */ -#ifdef __BEOS__ - XOPEN(fd, name, O_CREAT | O_RDWR , 0700, -1); -#else - XOPEN(fd, name, O_CREAT | O_RDWR | O_SYNC, 0700, -1); -#endif - - /* First reset the endianess */ - if (!file->shtrb && elfsh_dynamic_file(file)) - { - if (elfsh_endianize_got(file->secthash[ELFSH_SECTION_GOT]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize got", -1); - if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_DYNSYM]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize dynsym", -1); - if (elfsh_endianize_dynamic(file->secthash[ELFSH_SECTION_DYNAMIC]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize dynamic", -1); - } - if (elfsh_endianize_symtab(file->secthash[ELFSH_SECTION_SYMTAB]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to endianize symtab", -1); - - /* Endianize multiple relocation sections */ - for (index = 0; - NULL != (actual = elfsh_get_reloc(file, index, NULL)); - index++) - elfsh_endianize_relocs(actual); - - /* Strip the SHT if requested ... */ - if (file->shtrm) - { - file->hdr->e_shoff = 0; - file->hdr->e_shstrndx = 0; - file->hdr->e_shnum = 0; - } - - /* .. or rewrite SHT if requested */ - else if (!file->hdr->e_shoff) - { - actual = elfsh_get_tail_section(file); - file->hdr->e_shoff = actual->shdr->sh_offset + actual->shdr->sh_size; - } - - /* Strip the file if requested */ - if (file->strip) - elfsh_strip(file); - - /* Write the ELF header making sure removed shdr are not written */ - memcpy(&header, file->hdr, file->hdr->e_ehsize); - header.e_shnum -= file->nbrm; - header.e_shstrndx -= elfsh_find_previous_rmnbr(file, header.e_shstrndx); - elfsh_endianize_elfhdr(&header, file->hdr->e_ident[EI_DATA]); - XWRITE(fd, &header, file->hdr->e_ehsize, -1); - - /* Write the PHT */ - if (file->pht != NULL) - { - pht = alloca(file->hdr->e_phnum * file->hdr->e_phentsize); - memcpy(pht, file->pht, file->hdr->e_phnum * file->hdr->e_phentsize); - //elfsh_cleanup_bss(file, pht); - elfsh_endianize_pht(pht, file->hdr->e_ident[EI_DATA], file->hdr->e_phnum); - XSEEK(fd, file->hdr->e_phoff, SEEK_SET, -1); - XWRITE(fd, pht, file->hdr->e_phentsize * file->hdr->e_phnum, -1); - } - - /* Nullify the first section size, so that we dont write it in the corefile */ -#if __DEBUG_MAP__ - printf("[DEBUG_SAVE] Rebuild SHT flag is set: %d\n",file->shtrb); -#endif - - if ((file->sectlist) && !file->shtrb) - file->sectlist->shdr->sh_size = 0; - - /* Write each sections in the destination file at their respective offset */ - for (written_sht = 0, actual = file->sectlist; actual; actual = actual->next) - { - - /* If SHT is not written yet and current section file offset is bigger */ - if (!written_sht && !file->shtrm && actual->shdr->sh_offset > file->hdr->e_shoff) - written_sht = elfsh_save_sht(file, fd); - - /* We do the check to avoid null sized section like .sbss to fool us */ - if (actual->data != NULL && - actual->shdr->sh_size && - !(actual->next && - actual->next->shdr->sh_offset == actual->shdr->sh_offset)) - { - -#if __DEBUG_MAP__ - printf("[DEBUG_MAP] Writing identified section %15s (hdr: %-15s " - "vaddr = " AFMT ", idx %02u, foff %08u, size %08u, data = %08X)\n", - actual->name, elfsh_get_section_name(file, actual), - (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, - (u_int) elfsh_get_section_foffset(actual->shdr), - elfsh_get_section_size(actual->shdr), - (u_int) actual->data); -#endif - - /* Write the section */ - XSEEK(fd, elfsh_get_section_foffset(actual->shdr), SEEK_SET, -1); - XWRITE(fd, actual->data, actual->shdr->sh_size, -1); - } - -#if __DEBUG_MAP__ - else - printf("[DEBUG_MAP] PASSING identified section %15s (hdr: %-15s " - "vaddr = " AFMT " , idx %02u, foff %08u, size %08u, data = %08X)\n", - actual->name, elfsh_get_section_name(file, actual), - (eresi_Addr) elfsh_get_section_addr(actual->shdr), actual->index, - (u_int) elfsh_get_section_foffset(actual->shdr), - elfsh_get_section_size(actual->shdr), - (u_int) actual->data); -#endif - - } - - /* If SHT has not been written yet and current section foffset is bigger */ - if (!written_sht && !file->shtrm) - elfsh_save_sht(file, fd); - - /* If the SHT has been rewritten, we need to rewrite the ELF header in last */ - if (file->shtrb) - { - XSEEK(fd, 0, SEEK_SET, -1); - XWRITE(fd, &header, file->hdr->e_ehsize, -1); - } - -#if __DEBUG_MAP__ - /* elfsh_print_sectlist(file); */ -#endif - - elfsh_unload_obj(file); - XCLOSE(fd, -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/search.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/search.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/search.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/search.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -/** - * @file search.c - * @ingroup libelfsh -** search.c for libelfsh -** -** This function contains the research function inside the ELF structures -** of the address space of the process or program. -** -** Started on Sat Nov 25 21:19:53 2006 jfv -** -** $Id: search.c,v 1.8 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - - -/* List of loaded objects available for the functions of those files */ -static hash_t *hash_workspace = NULL; -static hash_t *hash_shared = NULL; - - - -/** - * @brief Register list of objects to work with - * @param prvhash - * @param sharedhash - * @return - */ -int elfsh_register_working_objects(hash_t *prvhash, - hash_t *sharedhash) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash_workspace = prvhash; - hash_shared = sharedhash; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Return the strongest symbol in the object - * FIXME : we dont support symbol selection when 2 'concurrent' - * symbols are in the same object, take care - * - * @param choice - * @param candidate - * @return - */ -elfsh_Sym *elfsh_strongest_symbol(elfsh_Sym *choice, elfsh_Sym *candidate) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (elfsh_get_symbol_type(choice) == STT_NOTYPE) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (candidate)); - - if (elfsh_get_symbol_type(candidate) == STT_NOTYPE) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (choice)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_symbol_bind(choice) < - elfsh_get_symbol_bind(candidate) ? - candidate : choice)); -} - -/** - * Find in the available objects list the most important symbol with this name - * @param name - * @return - */ -elfshobj_t *elfsh_find_obj_by_symbol(char *name) -{ - elfshobj_t *curidx; - elfshobj_t *choice; - elfsh_Sym *symchoice; - elfsh_Sym *sym; - int index; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - choice = NULL; - symchoice = sym = NULL; - -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Looking for %s \n", name); -#endif - - /* Look in the user owned files */ - keys = hash_get_keys(hash_workspace, &keynbr); - for (index = 0; index < keynbr; index++) - { - curidx = hash_get(hash_workspace, keys[index]); - sym = elfsh_get_metasym_by_name(curidx, name); - if (sym && (!symchoice || (sym == elfsh_strongest_symbol(symchoice, sym)))) - { - symchoice = sym; - choice = curidx; -#if __DEBUG_STATIC__ - printf("[DEBUG_STATIC] Found stronger sym %s (" AFMT ") " - "in %s [WSLIST] \n", name, symchoice->st_value, choice->name); -#endif - } - } - - /* If the selected et_rel is beeing injected warn caller */ - if (choice->pending) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL) ; - - /* If we found something in the local list, do not search in the shared one */ - if (symchoice != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (choice)) ; - - /* Now look in the shared files */ - if (!hash_shared) - goto end; - - keys = hash_get_keys(hash_shared, &keynbr); - for (index = 0; index < keynbr; index++) - { - curidx = hash_get(hash_shared, keys[index]); - sym = elfsh_get_metasym_by_name(curidx, name); - if (sym && (!symchoice || (sym == elfsh_strongest_symbol(symchoice, sym)))) - { - symchoice = sym; - choice = curidx; -#if __DEBUG_STATIC__ - printf("Found stronger symbol %s ("AFMT") in %s [SHAREDLIST] \n", - name, symchoice->st_value, choice->name); -#endif - - } - } - - end: - - /* If the selected et_rel is beeing injected warn caller */ - if (choice->pending) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - /* If we found something in the local list, do not search in the shared one */ - if (symchoice != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (choice)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object not found", ((void *) -1)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/section.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/section.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/section.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/section.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1197 +0,0 @@ -/** - * @file section.c - * @ingroup libelfsh -** section.c for libelfsh -** -** @brief All handlers and lowlevel routines for sections management -** -** Started on Mon Feb 26 04:12:42 2001 jfv -** -** -** $Id: section.c,v 1.19 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * @brief Just used to avoid code redundancy in elfsh_add_section() - * @param sct - * @param tmp - * @param mode - * @return - */ -char elfsh_shift_section(elfshsect_t *sct, elfshsect_t *tmp, u_char mode) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Used by SHT reconstruction engine */ - if (mode >= ELFSH_SHIFTING_NONE && - tmp->shdr->sh_link && (sct->index <= tmp->shdr->sh_link)) - tmp->shdr->sh_link++; - - /* Used by MIPS/PLT reconstruction */ - /* No shifting except an incrementation of index for .plt */ - if (mode >= ELFSH_SHIFTING_MIPSPLT) - tmp->index++; - - /* File perspective section shifting */ - if (mode >= ELFSH_SHIFTING_PARTIAL) - tmp->shdr->sh_offset += sct->shdr->sh_size; - - /* Loader perspective mapped section shifting */ - if (mode >= ELFSH_SHIFTING_COMPLETE && tmp->shdr->sh_addr) - tmp->shdr->sh_addr += sct->shdr->sh_size; - - /* Return 1 */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - - -/** - * INTERNAL FUNCTION : Add a given section to the file's section list - * - * SHOULD -NOT- manipulation symbol table because we are called from - * elfsh_load_sht() which has not loaded symtab yet. - * - * This function is used for constructing the map (elfshobj_t) of a - * binary file in memory. It is called as well at each new section - * injection. - * - * See libelfsh/inject.c for the user-friendly section injection API - * - * @param file - * @param sct - * @param range - * @param dat - * @param shiftmode - * @return - */ -int elfsh_add_section(elfshobj_t *file, - elfshsect_t *sct, - u_int range, - void *dat, - int shiftmode) -{ - elfshsect_t *tmp; - char inserted; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Adding section with range = %u, file->rhdr.rshtnbr = %u, shnum = %u (%s) \n", - range, file->rhdr.rshtnbr, file->hdr->e_shnum, sct->name); -#endif - - /* Load the ELF header if not done */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - else if (file->sht == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SHT not loaded", -1); - - else if (elfsh_section_is_runtime(sct) && !file->rsht) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "RSHT not loaded", -1); - - /* Refuse to insert a section for some conditions */ - if ((elfsh_section_is_runtime(sct) && range >= file->rhdr.rshtnbr) || - range >= file->hdr->e_shnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested section slot", -1); - - else if (sct->flags & ELFSH_SECTION_INSERTED) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Already inserted", -1); - else if (sct->data != NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section is not empty", -1); - - sct->shdr = (elfsh_section_is_runtime(sct) ? file->rsht : file->sht) + range; - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Added section address = %08X \n", sct->shdr->sh_addr); -#endif - - sct->parent = file; - sct->index = range; - sct->data = dat; - inserted = 0; - - /* We cannot print the name here because some sects do not have one yet */ -#if __DEBUG_SECTS__ - printf("[DEBUG:add_section] Adding section at index = %u from file %s \n", - sct->index, file->name); -#endif - - /* Parse the section list */ - for (tmp = elfsh_section_is_runtime(sct) ? file->rsectlist : file->sectlist; - tmp != NULL && tmp->next != NULL; tmp = tmp->next) - if (tmp->index == range) - { - /* Insert the new section */ - sct->prev = tmp->prev; - sct->next = tmp; - if (sct->prev != NULL) - sct->prev->next = sct; - else if (elfsh_section_is_runtime(sct)) - file->rsectlist = sct; - else - file->sectlist = sct; - - tmp->prev = sct; - - /* Update indexes, file offset, vaddr */ - inserted = elfsh_shift_section(sct, tmp, shiftmode); - } - else if (tmp->index >= range) - inserted = elfsh_shift_section(sct, tmp, shiftmode); - - /* ==> Now the special cases <== */ - - /* The section is the first one inserted */ - if (!inserted && !tmp) - { - if (!elfsh_section_is_runtime(sct)) - { - file->sectlist = sct; - file->sectlist->prev = sct; - } - else - { - file->rsectlist = sct; - file->rsectlist->prev = sct; - } - } - - /* The section must be inserted at the last place */ - else if (!inserted && !tmp->next) - { - tmp->next = sct; - sct->prev = tmp; - if (!elfsh_section_is_runtime(sct)) - file->sectlist->prev = sct; - else - file->rsectlist->prev = sct; - } - - /* shift the last section if the insertion has already been done */ - else if (inserted && !tmp->next) - elfsh_shift_section(sct, tmp, shiftmode); - - /* Final fixes */ - sct->phdr = elfsh_get_parent_segment(file, sct); - sct->flags |= ELFSH_SECTION_INSERTED; - sct->curend = sct->shdr->sh_size; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * @brief Add a runtime section - * This function is internal, do not use it directly - * @param file - * @param sct - * @param range - * @param dat - * @return - */ -int elfsh_add_runtime_section(elfshobj_t *file, - elfshsect_t *sct, - u_int range, - void *dat) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We do not shift any file offset in runtime injection */ - sct->flags |= ELFSH_SECTION_RUNTIME; - ret = elfsh_add_section(file, sct, range, dat, ELFSH_SHIFTING_NONE); - if (!ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add runtime section", ret); -} - -/** - * @brief Internal function - * @param file - * @param name - * @param idx - * @param strindex - * @param num - * @param sectlist - * @return - */ -static -elfshsect_t *elfsh_get_section_by_name_withlist(elfshobj_t *file, - char *name, - int *idx, - int *strindex, - int *num, - elfshsect_t *sectlist) -{ - elfshsect_t *section; - char *sname; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0, section = sectlist; - section; - section = section->next, index++) - { - sname = elfsh_get_section_name(file, section); - if (sname == NULL) - continue; - if (!strcmp(name, sname)) - { - if (idx != NULL) - *idx = index; - if (num != NULL) - *num = (section->curend ? - section->curend : section->shdr->sh_size); - if (strindex != NULL) - *strindex = section->shdr->sh_link; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (section)); - } - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); -} - -/** - * @brief Return a pointer on a section giving its name - * @param file - * @param name - * @param idx - * @param strindex - * @param num - * @return - */ -elfshsect_t *elfsh_get_section_by_name(elfshobj_t *file, - char *name, - int *idx, - int *strindex, - int *num) -{ - elfshsect_t *sect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - else if (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No SHT", NULL); - - sect = elfsh_get_section_by_name_withlist(file, name, idx, strindex, num, - file->sectlist); - if (!sect && file->rsectlist) - sect = elfsh_get_section_by_name_withlist(file, name, idx, strindex, - num, file->rsectlist); - - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect)); -} - - - -/** - * Search section by type, with list parameter - * This is an internal function it should not be used directly - * @param file - * @param type - * @param range - * @param index - * @param strindex - * @param num - * @param sectlist - * @param shnum - * @return - */ -static -elfshsect_t *elfsh_get_section_by_type_withlist(elfshobj_t *file, - u_int type, - int range, - int *index, - int *strindex, - int *num, - elfshsect_t *sectlist, - uint16_t shnum) -{ - int number; - int local_index; - elfshsect_t *section; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Parse the section list */ - for (section = sectlist, local_index = number = 0; - section != NULL && local_index < shnum; - local_index++, section = section->next) - { - - if (local_index == shnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); - - if (section->shdr->sh_type == type && ++number > range) - { - if (strindex != NULL) - *strindex = section->shdr->sh_link; - if (num != NULL) - *num = (section->curend ? - section->curend : section->shdr->sh_size); - if (index != NULL) - *index = local_index; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (section)); - } - - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found ..", NULL); -} - -/** - * Return the section header for the 'range' occurence of a 'type typed section - * Return NULL if failed - * @param file - * @param type - * @param range - * @param index - * @param strindex - * @param num - * @return - */ -elfshsect_t *elfsh_get_section_by_type(elfshobj_t *file, - u_int type, - int range, - int *index, - int *strindex, - int *num) - -{ - elfshsect_t *section; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - else if (elfsh_get_sht(file, &nbr) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive SHT", NULL); - - /* Parse the section lists */ - section = elfsh_get_section_by_type_withlist(file, type, range, index, strindex, - num, file->sectlist, nbr); - if (!section && file->rsectlist) - section = elfsh_get_section_by_type_withlist(file, type, range, index, - strindex, num, file->sectlist, - nbr); - - /* Result or error */ - if (!section) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section remained unfound", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (section)); -} - -/** - * Return the section pointer giving the section index in the sht - * @param file - * @param index - * @param strindex - * @param num - * @return - */ -elfshsect_t *elfsh_get_section_by_index(elfshobj_t *file, - eresi_Addr index, - int *strindex, - int *num) -{ - elfshsect_t *section; - int local; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - else if (NULL == elfsh_get_sht(file, num)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive SHT", NULL); - - for (section = file->sectlist, local = 0; - NULL != section && local < index; local++) - section = section->next; - - if (section == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find section", NULL); - - if (strindex != NULL) - *strindex = file->sht[index].sh_link; - if (num != NULL) - *num = (section->curend ? - section->curend : section->shdr->sh_size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (section)); -} - -/** - * Same that index research but for runtime injected sections - * @param file - * @param index - * @param strindex - * @param num - * @return - */ -elfshsect_t *elfsh_get_rsection_by_index(elfshobj_t *file, - eresi_Addr index, - int *strindex, - int *num) -{ - elfshsect_t *section; - int local; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - else if (NULL == elfsh_get_runtime_sht(file, num)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive RSHT", NULL); - - for (section = file->rsectlist, local = 0; - NULL != section && local < index; local++) - section = section->next; - - if (section == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find runtime section", NULL); - - if (strindex != NULL) - *strindex = file->rsht[index].sh_link; - if (num != NULL) - *num = (section->curend ? - section->curend : section->shdr->sh_size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (section)); -} - -/** - * Load the code of a section giving its header - * Should be called after a elfsh_get_section_by_{name,type} to load the code - * @param file - * @param shdr - * @return - */ -void *elfsh_load_section(elfshobj_t *file, elfsh_Shdr *shdr) -{ - void *sct; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (shdr == NULL || !shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load NULL section", NULL); - - XSEEK(file->fd, shdr->sh_offset, SEEK_SET, NULL); - XALLOC(__FILE__, __FUNCTION__, __LINE__,sct, shdr->sh_size, NULL); - XREAD(file->fd, sct, shdr->sh_size, NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sct)); -} - -/** - * Fill an anonymous (unknown content) section - * @param file - * @param sect - * @return - */ -void *elfsh_get_anonymous_section(elfshobj_t *file, elfshsect_t *sect) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Bad parameter checking */ - if (file == NULL || sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* If the section is already loaded */ - if (sect->data != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(sect))); - - sect->data = elfsh_load_section(file, sect->shdr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_raw(sect))); -} - -/** - * Creation a new orphelin section - * @param name - * @return - */ -elfshsect_t *elfsh_create_section(char *name) -{ - elfshsect_t *enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL name", NULL); - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, sizeof(elfshsect_t), NULL); - enew->name = strdup(name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (enew)); -} - -/** - * Return the parent section for this virtual address - * @param file - * @param value - * @param offset - * @return - */ -elfshsect_t *elfsh_get_parent_section(elfshobj_t *file, - eresi_Addr value, - elfsh_SAddr *offset) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || NULL == value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - - if (NULL == file->sht && !elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", NULL); - - /* ET_DYN objects have a relative addressing inside the ELF file */ - if (elfsh_is_debug_mode()) - value -= file->rhdr.base; - - /* Look in static sections */ - for (s = file->sectlist; s; s = s->next) - if (INTERVAL(s->shdr->sh_addr, value, - (s->shdr->sh_addr + s->shdr->sh_size))) - { - if (offset) - *offset = value - s->shdr->sh_addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); - } - - /* ... but if the sections are runtime injected, their address is absolute */ - if (elfsh_is_debug_mode()) - value += file->rhdr.base; - - /* Now look in runtime sections list */ - for (s = file->rsectlist; s; s = s->next) - if (INTERVAL(s->shdr->sh_addr, value, - (s->shdr->sh_addr + s->shdr->sh_size))) - { - if (offset) - *offset = value - s->shdr->sh_addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent section", NULL); -} - -/** - * Return the parent section for this file offset, else NULL - * This function is only revelant for ondisk sections - * @param file - * @param foff - * @param offset - * @return - */ -elfshsect_t *elfsh_get_parent_section_by_foffset(elfshobj_t *file, - u_int foff, - elfsh_SAddr *offset) -{ - elfshsect_t *s; - char i; - u_int bval; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || elfsh_get_sht(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent section", NULL); - - for (s = file->sectlist; s; s = s->next) - { - bval = (s->next != NULL ? s->next->shdr->sh_offset : - s->shdr->sh_offset + s->shdr->sh_size); - i = INTERVAL(s->shdr->sh_offset, foff, bval); - if (i && elfsh_get_section_type(s->shdr) != SHT_NOBITS) - { - if (offset != NULL) - *offset = foff - s->shdr->sh_offset; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); - } - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parent section remained unfound", NULL); -} - -/** - * Retreive the section giving the section symbol from .symtab - * @param file - * @param sym - * @return - */ -elfshsect_t *elfsh_get_section_from_sym(elfshobj_t *file, - elfsh_Sym *sym) -{ - elfshsect_t *current; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - if (NULL == elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get SHT", NULL); - - /* Compare ondisk sections first */ - for (current = file->sectlist; current != NULL; current = current->next) - if (current->shdr->sh_addr == sym->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (current)); - - /* Compare runtime injected section is still unfound */ - for (current = file->rsectlist; current != NULL; current = current->next) - if (current->shdr->sh_addr == sym->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (current)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No correspondance", NULL); -} - -/** - * This function appends a single char to a section by extending it - * @param sect - * @param c - * @param size - * @return - */ -int elfsh_fill_section(elfshsect_t *sect, - char c, - u_int size) -{ - char *str; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = alloca(size); - memset(str, c, size); - ret = elfsh_append_data_to_section(sect, str, size); - if (ret <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to append data to section", NULL); - else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/* - * This function is quite context dependant and should be rewritten. - * Symbol table shifting might be avoided in some obscure - * not-yet-encountered cases. For now it works as requested quite - * correctly. - * - * Note : Section placed before non-relocatable sections should - * not use this function because all mapped following sections - * virtual addresses will change. Be sure to have decent - * (recovered) relocation tables before using it on those sections. - * - * Only strong dataflow engine seems to be the solution for those. - * - * This function is not e2dbg safe and should only be used ondisk ! - * - * @param sect - * @param input - * @param len - * @return - */ -int elfsh_append_data_to_section(elfshsect_t *sect, - void *input, - u_int len) -{ - elfshsect_t *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (sect == NULL || input == NULL || !len) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - //printf("Extending %s section from %u bytes (curend = %u) \n", - // sect->name, len, sect->curend); - //fflush(stdout); - - /* Put the data at the end of the section */ - /* XXX: need to re-mmap in the case of runtime section */ - if (sect->curend + len > sect->shdr->sh_size) - { - if (elfsh_section_is_runtime(sect) && sect->shdr->sh_addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot extend a runtime injected zone", -1); - - if (sect->data != NULL) - XREALLOC(__FILE__, __FUNCTION__, __LINE__,sect->data, sect->data, sect->shdr->sh_size + len, -1); - else - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect->data, len, -1); - - memcpy(sect->data + sect->shdr->sh_size, input, len); - sect->shdr->sh_size += len; - sect->curend += len; - } - - /* Enough room in the section to put our data */ - else - { - memcpy(sect->data + sect->curend, input, len); - sect->curend += len; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->curend - len)); - } - - /* Avoid some unwanted shifting at command line or on runtime injected sects */ - if (sect->parent->rights == O_RDONLY || - elfsh_section_is_runtime(sect)) - goto end; - - /* Modify the section header table file offset if necessary */ - if (sect->parent->hdr->e_shoff >= sect->shdr->sh_offset) - sect->parent->hdr->e_shoff += len; - - /* Update vaddr and foffset for all next sections */ - for (actual = sect; actual != NULL; actual = actual->next) - if (actual != sect) - { - - /* - printf("Shifted section %s from %08X to %08X (foff : %u -> %u) \n", - actual->name, actual->shdr->sh_addr, - actual->shdr->sh_addr + len, - actual->shdr->sh_offset, - actual->shdr->sh_offset + len); - fflush(stdout); - */ - - /* Do not shift virtual address for mapped sections located - after an unmapped section */ - if (sect->shdr->sh_addr != NULL && actual->shdr->sh_addr != NULL) - actual->shdr->sh_addr += len; - if (!elfsh_section_is_runtime(actual)) - actual->shdr->sh_offset += len; - } - - - end: - - /* Synchronize SYMTAB and all its sorted instances */ - if (sect->shdr->sh_addr != NULL) - { - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Shift symtab from append_data\n"); -#endif - - elfsh_shift_symtab(sect->parent, - sect->shdr->sh_addr + sect->shdr->sh_size - len, - len); - } - - /* Return section offset where the data has been inserted */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (sect->shdr->sh_size - len)); -} - -/** - * Remove a section - * XXX-runtime : This section should only be used for ondisk modifications - * @param obj Pointer to elfsh object. - * @param name Section name - * @return - */ -int elfsh_remove_section(elfshobj_t *obj, char *name) -{ - elfshsect_t *todel; - elfshsect_t *cur; - elfsh_Shdr shdr; - elfsh_Shdr *enew; - elfsh_Phdr *pht; - elfsh_Sym *sym; - u_int idx; - u_int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (obj == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - todel = elfsh_get_section_by_name(obj, name, NULL, NULL, NULL); - if (todel == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown section to remove", -1); - - if ((todel->prev && todel->prev->shdr->sh_addr) && - (todel->next && todel->next->shdr->sh_addr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not removable", -1); - - /* Unlink */ - if (todel->prev) - todel->prev->next = todel->next; - if (todel->next) - todel->next->prev = todel->prev; - - /* Remove SHT header */ - shdr = *todel->shdr; - size = (obj->hdr->e_shnum - todel->index - 1) * sizeof(elfsh_Shdr); - if (size) - memcpy(obj->sht + todel->index, obj->sht + todel->index + 1, size); - obj->hdr->e_shnum--; - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, obj->hdr->e_shnum * sizeof(elfsh_Shdr), -1); - memcpy(enew, obj->sht, obj->hdr->e_shnum * sizeof(elfsh_Shdr)); - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->sht); - obj->sht = enew; - elfsh_sync_sht(obj); - elfsh_sync_sectnames(obj); - - /* shift sections file offsets and sh_link */ - for (cur = obj->sectlist; cur; cur = cur->next) - { - if (cur->shdr->sh_offset > shdr.sh_offset) - cur->shdr->sh_offset -= shdr.sh_size; - if (cur->shdr->sh_link > todel->index) - cur->shdr->sh_link--; - else if (cur->shdr->sh_link == todel->index) - cur->shdr->sh_link = 0; - if (cur->shdr->sh_offset > obj->hdr->e_shoff) - cur->shdr->sh_offset -= obj->hdr->e_shentsize; - } - - /* Shift SHT file offset and .shstrtab index */ - if (obj->hdr->e_shoff > shdr.sh_offset) - obj->hdr->e_shoff -= shdr.sh_size; - if (obj->hdr->e_shstrndx > todel->index) - obj->hdr->e_shstrndx--; - - /* Modify segments if removed section was mapped */ - todel->phdr = elfsh_get_parent_segment(obj, todel); - if (todel->phdr) - { - - /* Reset PT_PHDR segment is section was pre-interp injected */ - for (idx = 0, pht = obj->pht; idx < obj->hdr->e_phnum; idx++) - if (elfsh_segment_is_executable(todel->phdr) && - (pht[idx].p_type == PT_PHDR || todel->phdr == pht + idx)) - { - pht[idx].p_vaddr += shdr.sh_size; - pht[idx].p_paddr += shdr.sh_size; - } - else if (todel->phdr != pht + idx && pht[idx].p_offset >= shdr.sh_offset) - pht[idx].p_offset -= shdr.sh_size; - - /* Truncate the removed section size to the segment size */ - todel->phdr->p_filesz -= shdr.sh_size; - todel->phdr->p_memsz -= shdr.sh_size; - - /* Delete symbols pointing on the removed section */ - cur = obj->secthash[ELFSH_SECTION_SYMTAB]; - sym = cur->data; - idx = 0; - while (idx < cur->shdr->sh_size / sizeof(elfsh_Sym)) - if (INTERVAL(shdr.sh_addr, sym[idx].st_value, shdr.sh_addr + shdr.sh_size)) - elfsh_remove_symbol(cur, elfsh_get_symbol_name(obj, sym + idx)); - else - idx++; - } - - /* Free deleted section */ - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->name); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->data); - if (todel->altdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->altdata); - if (todel->terdata) - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->terdata); - if (todel->rel) - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->rel); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Nice embedded debugging trick - * Return a pointer on the section data - * This function makes the difference between data and pdata, beeing the process data - * @param sect - */ -void *elfsh_get_raw(elfshsect_t *sect) -{ - void *dataptr = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(KERNSH) - dataptr = kernsh_elfsh_get_raw(sect); - if (dataptr != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); -#endif - - if (elfsh_is_debug_mode()) - { - - /* The address of the section */ - dataptr = (void *) sect->shdr->sh_addr; - - /* For runtime injected sections, do not add the base address of the object */ - if (!elfsh_section_is_runtime(sect)) - dataptr += sect->parent->rhdr.base; - - /* For unmapped sections */ - if (!dataptr) - dataptr = sect->data; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); - } - if (sect) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->data)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameter", NULL); -} - -/** - * Return the last section of the list - * @param file - * @return - */ -elfshsect_t *elfsh_get_tail_section(elfshobj_t *file) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || file->hdr == NULL || file->sectlist == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - s = elfsh_get_section_by_index(file, file->hdr->e_shnum - 1, NULL, NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); -} - -/** - * Return the last section of the runtime list - * @param file - * @return - */ -elfshsect_t *elfsh_get_tail_rsection(elfshobj_t *file) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || file->hdr == NULL || file->rsectlist == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - s = elfsh_get_rsection_by_index(file, file->rhdr.rshtnbr - 1, NULL, NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); -} - - -/* -******************************************************************************* -** ELFsh section objet handlers (see elfsh.h: elfshpath_t, elfshL1_t, elfshL2_t) -** -** These calls are probably only used by elfsh, it should go in vm/ maybe .. -******************************************************************************* -*/ - -/** - * Return the section list - * @param file - * @param num - * @return - */ -elfshsect_t *elfsh_get_section_list(elfshobj_t *file, int *num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (NULL == elfsh_get_sht(file, num)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", NULL); - if (file->hdr == NULL && NULL == elfsh_get_hdr(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get ELF header", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->sectlist)); -} - -/** - * Return the section list - * @param file - * @param num - * @return - */ -elfshsect_t *elfsh_get_rsection_list(elfshobj_t *file, int *num) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (NULL == elfsh_get_sht(file, num)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get SHT", NULL); - if (file->hdr == NULL && NULL == elfsh_get_hdr(file)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get ELF header", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->rsectlist)); -} - - -/** - * Return the section giving its index - * @param list - * @param index - * @return - */ -elfshsect_t *elfsh_get_section_by_idx(elfshsect_t *list, - eresi_Addr index) -{ - u_int cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (cur = 0; cur != index && list != NULL; cur++) - list = list->next; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (list)); -} - -/** - * Return the section giving its name - * @param file - * @param name - * @return - */ -elfshsect_t *elfsh_get_section_by_nam(elfshobj_t *file, char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_section_by_name(file, name, NULL, NULL, NULL))); -} - -/** - * Section objects 'raw' child read access - * @param obj - * @param off - * @param sizelem - * @return - */ -void *elfsh_get_section_data(elfshsect_t *obj, u_int off, - u_int sizelem) -{ - char *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (obj == NULL || obj->shdr == NULL || obj->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - if (sizelem == 0) - sizelem = 1; - - if (obj->shdr->sh_size <= off * sizelem) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Offset too big", NULL); - - /* Return the data */ - data = elfsh_get_raw(obj); - data += (off * sizelem); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (data)); -} - -/** - * Section objects 'raw' child write access - * @param sect - * @param off - * @param data - * @param size - * @param sizelem - * @return - */ -int elfsh_write_section_data(elfshsect_t *sect, - u_int off, - char *data, - u_int size, - u_int sizelem) -{ - void *rdata; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL || sect->data == NULL || data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (sizelem == 0) - sizelem = 1; - if ((off * sizelem) + size > sect->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section is too small", -1); - - rdata = elfsh_get_raw(sect); - memcpy(rdata + (off * sizelem), data, size); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Is it a runtime section ? - * @param sect - * @return - */ -int elfsh_section_is_runtime(elfshsect_t *sect) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect && (sect->flags & ELFSH_SECTION_RUNTIME)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sht.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sht.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sht.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sht.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1346 +0,0 @@ -/** - * @file sht.c - * @ingroup libelfsh -** sht.c for libelfsh -** -** Started on Mon Feb 26 04:16:18 2001 jfv -** -** $Id: sht.c,v 1.9 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -/** - * @brief Sort SHT by file offset on ET_REL objects - * Mandatory on gcc 2.95.2/2.96 generated bins, maybe others - * @param file - * @return - */ -int elfsh_sort_sht(elfshobj_t *file) -{ - elfshsect_t *actual; - elfshsect_t *tmpsct; - elfshsect_t *next; - elfsh_Shdr tmp; - u_int index; - u_int pass; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - else if (file->sht == NULL && NULL == elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", -1); - - /* Basic bubble sort like : O(n2) */ - for (pass = 0; pass < file->hdr->e_shnum; pass++) - { - -#if __DEBUG_SORT__ - printf(" ****** Pass %02u ******* \n", pass); - fflush(stdout); -#endif - - for (actual = file->sectlist, index = 0; - index + 1 < file->hdr->e_shnum; - index++, actual = next) - { - -#if __DEBUG_SORT__ - elfsh_print_sectlist(file, "sort_sht"); -#endif - - next = actual->next; - if (file->sht[index].sh_offset > file->sht[index + 1].sh_offset) - { - - /* Swap SHT entries */ - tmp = file->sht[index]; - file->sht[index] = file->sht[index + 1]; - file->sht[index + 1] = tmp; - actual->shdr++; - actual->next->shdr--; - - /* Change index field of current section */ - actual->index++; - actual->next->index--; - - /* Update next pointer cause sections are going to be swapped */ - next = actual; - - /* Now swap in 2 first sections in the list */ - if (index == 0) - { - file->sectlist = actual->next; - tmpsct = file->sectlist->next; - file->sectlist->next = actual; - file->sectlist->prev = file->sectlist; - file->sectlist->next->prev = file->sectlist; - file->sectlist->next->next = tmpsct; - file->sectlist->next->next->next->prev = actual; - } - - /* If not in first position */ - else - { - - actual->prev->next = actual->next; - actual->next->prev = actual->prev; - tmpsct = actual->next->next; - actual->next->next = actual; - actual->prev = actual->next; - actual->next = tmpsct; - if (tmpsct) - tmpsct->prev = actual; - - /* this is buggy, spot the difference ... - tmpsct = actual->prev; - actual->prev->next = actual->prev = actual->next; - actual->next->prev = tmpsct; - if (actual->next->next != NULL) - actual->next->next->prev = actual; - tmpsct = actual->next->next; - actual->next->next = actual; - actual->next = tmpsct; - */ - - } - - /* Update links in SHT and symlinksidx in symtab */ - /* Not optimized */ - elfsh_update_linkidx_equ(file, index, 1); - elfsh_update_linkidx_equ(file, index + 1, -1); - elfsh_update_symlinkidx_equ(file, index, 1); - elfsh_update_symlinkidx_equ(file, index + 1, -1); - } - } - -#if __DEBUG_SORT__ - puts("-------------------------------------------"); -#endif - - } - -#if __DEBUG_SORT__ - elfsh_print_sectlist(file, "final_state"); - puts("-------------------------------------------"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Synchronize duplicated names for sections - * @param file - * @return - */ -void elfsh_sync_sectnames(elfshobj_t *file) -{ - elfshsect_t *s; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (s = file->sectlist; s != NULL; s = s->next) - { - name = elfsh_get_section_name(file, s); - if (s->name != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,s->name); - s->name = (name != NULL ? strdup(name) : NULL); - - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Synchronize SHT (mostly used when removing sections) - * @param file - * @return - */ -void elfsh_sync_sht(elfshobj_t *file) -{ - u_int idx; - elfshsect_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (cur = file->sectlist, idx = 0; idx < file->hdr->e_shnum; idx++) - { - cur->shdr = file->sht + idx; - cur->index = idx; - cur = cur->next; - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Return a pointer on the runtime SHT - * @param file - * @param num - * @return - */ -void *elfsh_get_runtime_sht(elfshobj_t *file, int *num) -{ - elfshsect_t *rshstrtab; - int ret; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Build RSHT if inexistant */ - if (file->rsht == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,file->rsht, file->hdr->e_shentsize, NULL); - rshstrtab = elfsh_create_section(ELFSH_SECTION_NAME_RSHSTRTAB); - file->rhdr.rshtnbr = 1; - ret = strlen(ELFSH_SECTION_NAME_RSHSTRTAB) + 1; - file->rsht[0].sh_size = ret; - XALLOC(__FILE__, __FUNCTION__, __LINE__,str, ret, NULL); - memcpy(str, ELFSH_SECTION_NAME_RSHSTRTAB, ret); - ret = elfsh_add_runtime_section(file, rshstrtab, 0, str); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot add runtime sections strings table", NULL); - file->secthash[ELFSH_SECTION_RSHSTRTAB] = rshstrtab; - rshstrtab->curend = file->rsht[0].sh_size; - } - - - /* Everything was OK */ - if (num != NULL) - *num = file->rhdr.rshtnbr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->rsht)); -} - - -/** - * @brief Return a ptr on the section header table - * @param file - * @param num - * @return - */ -void *elfsh_get_sht(elfshobj_t *file, int *num) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (file->sht != NULL) - goto end; - - /* Load the section header table and allocate every elfshsect_t */ - else if (elfsh_load_sht(file) < 0 && elfsh_rebuild_sht(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cant load SHT", NULL); - - /* Load .shstrtab if undone in rebuild_sht() continue w/o if we cant read it */ - if (file->secthash[ELFSH_SECTION_SHSTRTAB] == NULL) - { - s = elfsh_get_section_by_index(file, file->hdr->e_shstrndx, NULL, NULL); - if (s != NULL) - { - file->secthash[ELFSH_SECTION_SHSTRTAB] = s; - if (s->data == NULL) - s->data = elfsh_load_section(file, s->shdr); - } - } - - /* Sort SHT entries and section list by their file offset */ - elfsh_sync_sectnames(file); - - /* Some final stuffs */ - end: - if (num != NULL) - *num = file->hdr->e_shnum; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->sht)); -} - - -/** - * Change endianess of SHT - * @param s - * @param byteorder - * @param shnum - * @return - */ -int elfsh_endianize_sht(elfsh_Shdr *s, - char byteorder, - uint16_t shnum) -{ - int i; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - /* Deal with cross-endianness binaries */ -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (byteorder == ELFDATA2MSB) { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (byteorder == ELFDATA2LSB) { -#else -#error Unexpected __BYTE_ORDER ! -#endif - for (i = 0; i < shnum; i++) - { - s->sh_name = swap32(s->sh_name); - s->sh_type = swap32(s->sh_type); - s->sh_flags = swaplong(s->sh_flags); - s->sh_addr = swaplong(s->sh_addr); - s->sh_offset = swaplong(s->sh_offset); - s->sh_size = swaplong(s->sh_size); - s->sh_link = swap32(s->sh_link); - s->sh_info = swap32(s->sh_info); - s->sh_addralign = swaplong(s->sh_addralign); - s->sh_entsize = swaplong(s->sh_entsize); - s++; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return an array of section header - * @param file - * @return - */ -int elfsh_load_sht(elfshobj_t *file) -{ - elfshsect_t *new; - int size; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - else if (file->sht != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Read table */ - size = file->hdr->e_shnum * file->hdr->e_shentsize; - if (!file->hdr->e_shoff) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SHT file offset is NULL", -1); - - if (file->hdr->e_shoff > file->fstat.st_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SHT file offset is larger than the file itself", -1); - - XSEEK(file->fd, file->hdr->e_shoff, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,file->sht, size, -1); - XREAD(file->fd, file->sht, size, -1); - - elfsh_endianize_sht(file->sht, - file->hdr->e_ident[EI_DATA], - file->hdr->e_shnum); - - /* - ** Allocate a elfshsect_t per section and put it - ** in the file->sectlist double linked list - */ - for (index = 0; index < file->hdr->e_shnum; index++) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(elfshsect_t), -1); - size = elfsh_add_section(file, new, index, NULL, - ELFSH_SHIFTING_COMPLETE); - if (size < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Retreive the section header giving the section symbol from .symtab - * @param file - * @param sym - * @return - */ -elfsh_Shdr *elfsh_get_shtentry_from_sym(elfshobj_t *file, - elfsh_Sym *sym) -{ - elfshsect_t *sect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = elfsh_get_section_from_sym(file, sym); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (sect == NULL ? NULL : sect->shdr)); -} - -/** - * Retreive the symbol for the section giving the section header - * @param file - * @param hdr - * @return - */ -elfsh_Sym *elfsh_get_sym_from_shtentry(elfshobj_t *file, - elfsh_Shdr *hdr) -{ - elfsh_Sym *current; - int index; - u_int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || hdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - else if (file->sht == NULL && NULL == elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", NULL); - - /* Load symtab if necessary */ - else if (file->secthash[ELFSH_SECTION_SYMTAB] == NULL && - NULL == elfsh_get_symtab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB", NULL); - - else if (!file->secthash[ELFSH_SECTION_SYMTAB]->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symtab is void", NULL); - nbr = file->secthash[ELFSH_SECTION_SYMTAB]->shdr->sh_size / - sizeof(elfsh_Sym); - - /* Find the wanted symbol */ - index = 0; - for (current = file->secthash[ELFSH_SECTION_SYMTAB]->data; - index < nbr; index++) - if (elfsh_get_symbol_type(current + index) == STT_SECTION && - current[index].st_value == hdr->sh_addr) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (current + index)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); -} - -/** - * Create a section header - * - * @param name - * @param type - * @param flags - * @param addr - * @param offset - * @param size - * @param link - * @param info - * @param align - * @param entsize - * @return - */ -elfsh_Shdr elfsh_create_shdr(elfsh_Word name, - elfsh_Word type, - elfsh_Word flags, - eresi_Addr addr, - elfsh_Off offset, - elfsh_Word size, - elfsh_Word link, - elfsh_Word info, - elfsh_Word align, - elfsh_Word entsize) -{ - elfsh_Shdr new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - new.sh_name = name; - new.sh_type = type; - new.sh_flags = flags; - new.sh_addr = addr; - new.sh_offset = offset; - new.sh_size = size; - new.sh_link = link; - new.sh_info = info; - new.sh_addralign = align; - new.sh_entsize = entsize; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * Add a section header to the object - * @param file - * @param hdr - * @param range - * @param name - * @param shiftflag - * @return - */ -int elfsh_insert_shdr(elfshobj_t *file, - elfsh_Shdr hdr, - u_int range, - char *name, - char shiftflag) -{ - elfshsect_t *tmp; - int index; - int shname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // Debug to remove - //printf("Injecting SHDR for section %s \n", name); - //fflush(stdout); - - /* Preliminary checks */ - if (file == NULL || - (file->hdr == NULL && elfsh_get_hdr(file) == NULL) || - (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get ELF header or SHT", -1); - - /* Fixup the range */ - if (range == ELFSH_SECTION_LAST) - range = file->hdr->e_shnum; - else if (range > file->hdr->e_shnum) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid range for injection", -1); - - /* Insert the name string in .shstrtab */ - shname = elfsh_insert_in_shstrtab(file, name); - if (shname < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot inject data in .shstrtab", -1); - hdr.sh_name = (u_int) shname; - - /* Keep track of what is shifted since our new shdr is not - yet in SHT */ - if (range > file->secthash[ELFSH_SECTION_SHSTRTAB]->index) - hdr.sh_offset += strlen(name) + 1; - - /* Extend the SHT and fill the new slot */ - XREALLOC(__FILE__, __FUNCTION__, __LINE__,file->sht, file->sht, - file->hdr->e_shentsize * (file->hdr->e_shnum + 1), -1); - - if (range != file->hdr->e_shnum) - memmove(file->sht + range + 1, - file->sht + range, - (file->hdr->e_shnum - range) * file->hdr->e_shentsize); - - file->sht[range] = hdr; - file->hdr->e_shnum++; - - /* Update foffset for all section header whoose section is placed after SHT */ - for (tmp = file->sectlist, index = 0; index < file->hdr->e_shnum; index++) - { - - /* - ** Since we reallocated the sht, we have to update the shdr pointer - ** since its pointing to the old chunk ! - ** Pass headers without body (this include the just inserted one) - */ - if (index != range && tmp) - { - tmp->shdr = file->sht + index; - tmp = tmp->next; - } - - /* Now update the file offset for the actual section */ - if (file->sht[index].sh_offset >= file->hdr->e_shoff) - file->sht[index].sh_offset += file->hdr->e_shentsize; - } - - /* If we have an influence on the sht file offset, update it */ - if (hdr.sh_offset <= file->hdr->e_shoff && shiftflag) - file->hdr->e_shoff += hdr.sh_size; - - /* Update the .shstrtab index in the ELF header if necessary */ - if (range <= file->hdr->e_shstrndx) - file->hdr->e_shstrndx++; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (range)); -} - -/** - * Add a section header to the object - * @param file - * @param hdr - * @param range - * @param name - * @param shiftflag - * @return - */ -int elfsh_insert_runtime_shdr(elfshobj_t *file, - elfsh_Shdr hdr, - u_int range, - char *name, - char shiftflag) -{ - elfshsect_t *tmp; - int index; - int shname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Asking runtime shdr injection on range %d \n", range); -#endif - - /* Preliminary checks */ - if (file == NULL || - (file->hdr == NULL && elfsh_get_hdr(file) == NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get ELF header or SHT", -1); - - if (!file->rsht) - range++; - - /* Runtime sections check */ - if (elfsh_get_runtime_sht(file, NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get runtime SHT", -1); - - /* Fixup the range */ - if (range == ELFSH_SECTION_LAST) - range = file->rhdr.rshtnbr; - else if (range > file->rhdr.rshtnbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid range for injection", -1); - - /* Insert the name string in .rshstrtab */ - shname = elfsh_insert_in_rshstrtab(file, name); - if (shname < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot inject data in .rshstrtab", -1); - hdr.sh_name = (u_int) shname; - - /* Extend the SHT and fill the new slot */ - XREALLOC(__FILE__, __FUNCTION__, __LINE__,file->rsht, file->rsht, - file->hdr->e_shentsize * (file->rhdr.rshtnbr + 1), -1); - - if (range != file->rhdr.rshtnbr) - memmove(file->rsht + range + 1, - file->rsht + range, - (file->rhdr.rshtnbr - range) * file->hdr->e_shentsize); - - file->rsht[range] = hdr; - file->rhdr.rshtnbr++; - - -#if __DEBUG_RUNTIME__ - printf("[DEBUG_RUNTIME] Runtime shdr injected on range %d \n", range); -#endif - - /* Update foffset for all section header whoose section is placed after SHT */ - for (tmp = file->rsectlist, index = 0; - tmp && index < file->rhdr.rshtnbr; - index++) - { - - /* - ** Since we reallocated the rsht, we have to update the shdr pointer - ** since its pointing to the old chunk ! - ** Pass headers without body (this include the just inserted one) - */ - if (index != range) - { - tmp->shdr = file->rsht + index; - tmp = tmp->next; - } - else - tmp->name = (char *) file->secthash[ELFSH_SECTION_RSHSTRTAB] + tmp->shdr->sh_name; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (range)); -} - -/** - * Get the section's name in .shstrtab - * @param file - * @param s - * @return - */ -char *elfsh_get_section_name(elfshobj_t *file, - elfshsect_t *s) -{ - volatile char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity check */ - if (file == NULL || s == NULL || - file->secthash[ELFSH_SECTION_SHSTRTAB] == NULL || - (file->sht == NULL && NULL == elfsh_get_sht(file, NULL))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHSTRTAB", NULL); - - /* Additional check for runtime sections */ - if (elfsh_section_is_runtime(s) && - (!file->rsectlist || ! file->rsht || - !file->secthash[ELFSH_SECTION_RSHSTRTAB])) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get runtime sections information", NULL); - - /* Return section's name */ - if (elfsh_section_is_runtime(s)) - str = file->secthash[ELFSH_SECTION_RSHSTRTAB]->data; - else - str = file->secthash[ELFSH_SECTION_SHSTRTAB]->data; - - /* NULL str check added for supporting binaries without shstrrtab */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (str == NULL ? NULL : (char *) str + s->shdr->sh_name)); -} - -/** - * Set the section's name in .shstrtab - * @param file - * @param s - * @param name - * @return - */ -int elfsh_set_section_name(elfshobj_t *file, - elfshsect_t *s, - char *name) -{ - char *str; - u_int len; - u_int new_len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity check */ - if (file == NULL || s == NULL || name == NULL || - file->secthash[ELFSH_SECTION_SHSTRTAB] == NULL || - (file->sht == NULL && elfsh_get_sht(file, NULL) == NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHSTRTAB", -1); - - /* Additional check for runtime sections */ - if (elfsh_section_is_runtime(s) && - (!file->rsectlist || ! file->rsht || - !file->secthash[ELFSH_SECTION_RSHSTRTAB])) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get runtime sections", NULL); - - /* Return section's name */ - if (!elfsh_section_is_runtime(s)) - str = file->secthash[ELFSH_SECTION_SHSTRTAB]->data; - else - str = file->secthash[ELFSH_SECTION_RSHSTRTAB]->data; - str += s->shdr->sh_name; - len = strlen(str); - new_len = strlen(name); - - /* Do not allocate new place if possible */ - if (len >= new_len) - strcpy(str, name); - - /* Append the name to the section string table */ - else if (!elfsh_section_is_runtime(s)) - s->shdr->sh_name = elfsh_insert_in_shstrtab(file, name); - - /* Append t he name to the runtime section string table */ - else - s->shdr->sh_name = elfsh_insert_in_rshstrtab(file, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->shdr->sh_name)); -} - -/** - * Tell elfsh that we dont want the sht in the output file - * @param file - */ -void elfsh_remove_sht(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - file->shtrm = 1; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * SET/GET the allocatable flag - * @param s - * @return - */ -char elfsh_get_section_allocflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_ALLOC))); -} - -/** - * Set the allocatable flag - * @param s - * @param f - * @return - */ -char elfsh_set_section_allocflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_ALLOC; - else - s->sh_flags &= (~SHF_ALLOC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * SET/GET the writable flag - * @param s - * @return - */ -char elfsh_get_section_writableflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_WRITE))); -} - -/** - * SET writableflag - * @param s - * @param f - * @return - */ -char elfsh_set_section_writableflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_WRITE; - else - s->sh_flags &= (~SHF_WRITE); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * SET/GET the executable flag - * @param s - * @return - */ -char elfsh_get_section_execflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_EXECINSTR))); -} - -/** - * SET executable flag - * @param s - * @param f - * @return - */ -char elfsh_set_section_execflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_EXECINSTR; - else - s->sh_flags &= (~SHF_EXECINSTR); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * SET/GET the mergeable flag - * @param s - * @return - */ -char elfsh_get_section_mergeableflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_MERGE))); -} - -/** - * SET the mergeable flag - * @param s - * @param f - * @return - */ -char elfsh_set_section_mergeableflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_MERGE; - else - s->sh_flags &= (~SHF_MERGE); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * SET/GET the string flag - * @param s - * @return - */ -char elfsh_get_section_strflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_STRINGS))); -} - -/** - * SET the string flag - * @param s - * @param f - * @return - */ -char elfsh_set_section_strflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_STRINGS; - else - s->sh_flags &= (~SHF_STRINGS); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * SET/GET the link flag - * @param s - * @return - */ -char elfsh_get_section_linkflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_INFO_LINK))); -} - -/** - * SET the link flag - * @param s - * @param f - * @return - */ - -char elfsh_set_section_linkflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_INFO_LINK; - else - s->sh_flags &= (~SHF_INFO_LINK); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * SET/GET the order flag - * @param s - * @return - */ -char elfsh_get_section_orderflag(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((s->sh_flags & SHF_LINK_ORDER))); -} - -/** - * SET the order flag - * @param s - * @param f - * @return - */ - -char elfsh_set_section_orderflag(elfsh_Shdr *s, eresi_Addr f) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - if (f) - s->sh_flags |= SHF_LINK_ORDER; - else - s->sh_flags &= (~SHF_LINK_ORDER); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * All the next functions are dumb read/write field access routine - * @param s - * @return - */ -elfsh_Word elfsh_get_section_info(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_info)); -} - -/** - * Set section info - * @param s - * @param info - * @return - */ -int elfsh_set_section_info(elfsh_Shdr *s, eresi_Addr info) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_info = (elfsh_Word) info; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section entsize - * @param s Pointer to section structure. - * @return Return section entry size or -1 on error. - */ -elfsh_Word elfsh_get_section_entsize(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_entsize)); -} - -/** - * set section entsize - * @param s - * @param entsize - * @return - */ -int elfsh_set_section_entsize(elfsh_Shdr *s, eresi_Addr entsize) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_entsize = (elfsh_Word) entsize; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section link - * @param s - * @return - */ -elfsh_Word elfsh_get_section_link(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_link)); -} - -/** - * set section link - * @param s - * @param link - * @return - */ -int elfsh_set_section_link(elfsh_Shdr *s, eresi_Addr link) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_link = (elfsh_Word) link; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section foffset - * @param s - * @return - */ -elfsh_Off elfsh_get_section_foffset(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_offset)); -} - -/** - * set section foffset - * @param s - * @param offset - * @return - */ -int elfsh_set_section_foffset(elfsh_Shdr *s, eresi_Addr offset) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_offset = (elfsh_Off) offset; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section addr - * @param s Pointer to section structure. - * @return Return section address or -1 on error. - */ -eresi_Addr elfsh_get_section_addr(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_addr)); -} - -/** - * set section addr - * @param s Pointer to section structure. - * @param addr New address of section - * @return Returns 0 on success or -1 on error. - */ -int elfsh_set_section_addr(elfsh_Shdr *s, eresi_Addr addr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_addr = addr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section align - * @param s - * @return - */ -elfsh_Word elfsh_get_section_align(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_addralign)); -} - -/** - * set section align - * @param s - * @param align - * @return - */ -int elfsh_set_section_align(elfsh_Shdr *s, eresi_Addr align) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_addralign = (elfsh_Word) align; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section size - * @param s - * @return - */ -elfsh_Word elfsh_get_section_size(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_size)); -} - -/** - * set section size - * @param s Pointer to section structure. - * @param size New size of section. - * @return Returns 0 on success or -1 on error. - */ -int elfsh_set_section_size(elfsh_Shdr *s, eresi_Addr size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_size = (elfsh_Word) size; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * get section type - * @param s - * @return Return section type or -1 on error. - */ -elfsh_Word elfsh_get_section_type(elfsh_Shdr *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->sh_type)); -} - -/** - * set section type - * @param s - * @param type - * @return Returns 0 on success or -1 on error. - */ -int elfsh_set_section_type(elfsh_Shdr *s, eresi_Addr type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter ", -1); - s->sh_type = (elfsh_Word) type; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * ELFsh handlers - * - * These functions are usually not used by something else than ELFsh - * - */ - -/** - * Get SHT or runtime SHT entry by index - * @param s - * @param index - * @return Pointer to a section structure. - */ -elfsh_Shdr *elfsh_get_sht_entry_by_index(elfsh_Shdr *s, - eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s + index)); -} - -/** - * Get SHT entry by name - * @param file - * @param name - * @return - */ -elfsh_Shdr *elfsh_get_sht_entry_by_name(elfshobj_t *file, char *name) -{ - elfshsect_t *sect; - u_int index; - char *curnam; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity check */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - else if (file->sectlist == NULL && elfsh_read_obj(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to read object", NULL); - - /* Find SHT entry */ - for (sect = file->sectlist, index = 0; sect != NULL; sect = sect->next) - { - curnam = elfsh_get_section_name(file, sect); - if (curnam != NULL && !strcmp(curnam, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->shdr)); - } - - /* Find runtime SHT entry */ - for (sect = file->rsectlist, index = 0; sect != NULL; sect = sect->next) - { - curnam = elfsh_get_section_name(file, sect); - if (curnam != NULL && !strcmp(curnam, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect->shdr)); - } - - /* Not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find SHT entry", NULL); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sht_rebuild.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sht_rebuild.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sht_rebuild.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sht_rebuild.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,956 +0,0 @@ -/** - * @file sht_rebuild.c - * @ingroup libelfsh - ** sht_rebuild.c for elfsh - ** - ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ** This code is functional as it, but it is WORK IN PROGRESS - ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - ** - ** Started on Tue Mar 26 19:07:23 2002 jfv - ** $Id: sht_rebuild.c,v 1.24 2008-02-16 12:32:27 thor Exp $ - */ -#include "libelfsh.h" -#include "libasm.h" - - - -/** - * @brief This function insert a SHT entry without shifting the address space - * I.E. it does truncate some sections for creating new ones. - * - * This is necessary when we do SHT reconstruction or when we unmerge - * the PLT section from the TEXT section on the MIPS architecture. - * - * @param file - * @param phdr_index - * @param shdr - * @param name - * @return - */ -int elfsh_merge_shtentry(elfshobj_t *file, - int phdr_index, - elfsh_Shdr shdr, - char *name) -{ - elfshsect_t *sect; - int index; - int namelen; - int len; - int off; - char buff[BUFSIZ]; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - namelen = strlen(name); - - printf("Insertion section header *%s* \n", name); - - for (index = 0; index < file->hdr->e_shnum; index++) - { - /* Used to allow a 3 bytes padding for the current section */ - len = file->sht[index].sh_size - shdr.sh_size; - - printf("SHT rebuild: len = *%d* \n", len); - - if (len < 0) - len = -len; - - /* The new section perfectly match an existing one (with an allowed padding of 3 bytes) */ - if (file->sht[index].sh_offset == shdr.sh_offset && len < 4) - { - /* In the rare case where both names have equal lenght, we can optimize a bit */ - data = elfsh_get_raw(file->secthash[ELFSH_SECTION_SHSTRTAB]); - len = (file->sht[index].sh_name ? strlen(data + file->sht[index].sh_name) : 0); - if (len == namelen) - { - printf("SHT rebuild case 1.1 \n"); - memcpy(data + file->sht[index].sh_name, name, len); - } - - /* The off variable is used just to clean the code . This case is the common one . */ - else - { - printf("SHT rebuild case 1.2 \n"); - off = file->sht[index].sh_name + len + 1; - memmove(data + file->sht[index].sh_name, - data + off, - file->secthash[ELFSH_SECTION_SHSTRTAB]->shdr->sh_size - off); - file->sht[index].sh_size -= len + 1; - elfsh_update_nameidx(file, file->sht[index].sh_name, len + 1); - file->sht[index].sh_name = elfsh_insert_in_shstrtab(file, name); - } - break; - } - - /* The new header defines a section matching the beginning area of an existing section */ - else if (file->sht[index].sh_offset == shdr.sh_offset) - { - printf("SHT rebuild case 2 \n"); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,file->sht, - file->sht, (file->hdr->e_shnum + 1) * file->hdr->e_shentsize, -1); - memmove(file->sht + index + 1, - file->sht + index, - file->hdr->e_shentsize * (file->hdr->e_shnum - index)); - - file->sht[index] = shdr; - if (strcmp(ELFSH_SECTION_NAME_BSS, name)) - { - file->sht[index + 1].sh_size -= (shdr.sh_size); - file->sht[index + 1].sh_offset += (shdr.sh_size + 1); - } - file->sht[index + 1].sh_addr += (file->sht[index + 1].sh_addr ? shdr.sh_size : 0); - - if (file->hdr->e_shstrndx >= index) - file->hdr->e_shstrndx++; - file->secthash[ELFSH_SECTION_SHSTRTAB]->shdr = file->sht + file->hdr->e_shstrndx; - file->sht[index].sh_name = elfsh_insert_in_shstrtab(file, name); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(*sect), -1); - if (elfsh_add_section(file, sect, index, NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->hdr->e_shnum++; - elfsh_update_linkidx(file, index, 1); - break; - } - - - /* The new header defines a section matching the end area of an existing section */ - else if (file->sht[index].sh_offset + file->sht[index].sh_size == shdr.sh_offset + shdr.sh_size) - { - printf("SHT rebuild case 3 \n"); - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - file->sht, file->sht, (file->hdr->e_shnum + 1) * file->hdr->e_shentsize, -1); - memmove(file->sht + index + 2, file->sht + index + 1, - file->hdr->e_shentsize * (file->hdr->e_shnum - index - 1)); - - file->sht[index + 1] = shdr; - file->sht[index].sh_size -= shdr.sh_size; - - file->hdr->e_shstrndx++; - file->secthash[ELFSH_SECTION_SHSTRTAB]->shdr = file->sht + file->hdr->e_shstrndx; - file->sht[index + 1].sh_name = elfsh_insert_in_shstrtab(file, name); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(*sect), -1); - if (elfsh_add_section(file, sect, index, NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->hdr->e_shnum++; - elfsh_update_linkidx(file, index + 1, 1); - break; - } - - - /* The new header defines a section strictly included in an already existing section */ - else if (file->sht[index].sh_offset < shdr.sh_offset && - file->sht[index].sh_offset + file->sht[index].sh_size > shdr.sh_offset + shdr.sh_size) - { - printf("SHT rebuild case 4 \n"); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - file->sht, file->sht, (file->hdr->e_shnum + 2) * file->hdr->e_shentsize, -1); - memmove(file->sht + index + 3, - file->sht + index + 1, - file->hdr->e_shentsize * (file->hdr->e_shnum - index - 1)); - - file->sht[index + 1] = shdr; - file->sht[index + 2] = elfsh_create_shdr(0, file->sht[index].sh_type, - file->sht[index].sh_flags, - shdr.sh_addr + shdr.sh_size, - shdr.sh_offset + shdr.sh_size, - file->sht[index].sh_size - - (shdr.sh_offset - file->sht[index].sh_offset) - - shdr.sh_size, - 0, 0, 0, 0); - file->sht[index].sh_size = shdr.sh_offset - file->sht[index].sh_offset; - - file->hdr->e_shstrndx += 2; - file->secthash[ELFSH_SECTION_SHSTRTAB]->shdr = file->sht + file->hdr->e_shstrndx; - - file->sht[index + 1].sh_name = elfsh_insert_in_shstrtab(file, name); - snprintf(buff, sizeof(buff), "%s_"UFMT, - (file->sht[index + 2].sh_addr ? - ELFSH_SECTION_NAME_MAPPED : ELFSH_SECTION_NAME_UNMAPPED), - file->sht[index + 2].sh_offset); - file->sht[index + 2].sh_name = elfsh_insert_in_shstrtab(file, buff); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(*sect), -1); - if (elfsh_add_section(file, sect, index, - NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(*sect), -1); - if (elfsh_add_section(file, sect, index + 2, - NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->hdr->e_shnum += 2; - elfsh_update_linkidx(file, index, 1); - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * INTERNAL FUNCTION : Rebuild an initial SHT and - * create some sections based on the pht entries - * - * @param file - * @param num - * @return - */ -static int elfsh_init_sht(elfshobj_t *file, u_int num) -{ - elfsh_Shdr shdr; - elfshsect_t *sect; - char name[256]; - unsigned int index,idx; - void *data; - unsigned int nnames,lnames,dnames; - unsigned int tlsnames,ehnames,snames; - long type, total, section_offset, base_addr = 0, dyn_addr = 0, dyn_size = 0; - int flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* count how many sections we will have */ - for (total = idx = 0; idx < num; idx++) - { - switch (file->pht[idx].p_type) - { - case PT_NOTE: - case PT_LOAD: - case PT_DYNAMIC: - case PT_INTERP: -#if !defined(sgi) && !defined(__NetBSD__) - case PT_TLS: - case PT_GNU_EH_FRAME: - //case PT_GNU_STACK: -#endif - total++; - break; - } - } - total++; - file->hdr->e_shnum = 100;//total+1; /* total, for the shstrtab */ - file->hdr->e_shentsize = sizeof(elfsh_Shdr); - - /* insert the sht at the end of the file */ - file->hdr->e_shoff = file->fstat.st_size; - section_offset = 0; - - /* Create the initial SHT */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, file->sht, - file->hdr->e_shentsize * (total + 8), -1); - - printf("SHT @ 0x%p\n", file->sht); - snames = ehnames = tlsnames = nnames = lnames = dnames = 0; - - /* rebuild the sht based on the pht entries */ - for(idx = 0, index = 0; index < num; index++) - { - /* setup the flags of this section */ - flags = SHF_ALLOC; - flags |= (elfsh_segment_is_writable(file->pht+index)?SHF_WRITE:0); - flags |= (elfsh_segment_is_executable(file->pht+index)?SHF_EXECINSTR:0); - - switch(file->pht[index].p_type) - { - case PT_INTERP: - /* .interp */ - snprintf(name, sizeof(name), ELFSH_SECTION_NAME_INTERP); - type = SHT_PROGBITS; - break; - case PT_LOAD: - /* XXX: not working */ - if(file->pht[index].p_memsz < file->pht[index].p_filesz) - { /* .bss */ - snprintf(name, sizeof(name), ELFSH_SECTION_NAME_BSS); - type = SHT_NOBITS; - } - else - { - if(file->pht[index].p_vaddr >= 0xFFFF0000) - { /* used for retrieve information from core files */ - snprintf(name, sizeof(name), ".kernel_info%d", lnames++); - type=SHT_PROGBITS; - break; - } - /* .text */ - if(file->pht[index].p_vaddr >= 0x8000000 && - elfsh_segment_is_executable(file->pht + index)) - { - snprintf(name, sizeof(name), ELFSH_SECTION_NAME_TEXT); - base_addr = file->pht[index].p_vaddr; - } - /* .data */ - else if(file->pht[index].p_vaddr >= 0x8000000 && - elfsh_segment_is_writable(file->pht + index)) - snprintf(name, sizeof(name), ELFSH_SECTION_NAME_DATA); - - type = SHT_PROGBITS; - } - break; - case PT_NOTE: - /* .note */ - if(file->coretype==ELFSH_CORE_LINUX) - { - snprintf(name, sizeof(name), ".note%d", nnames++); - type = SHT_NOTE; - } - else - { - snprintf(name, sizeof(name), ".note-ABI.tag"); - type=SHT_NOTE; - } - break; -#if !defined(sgi) && !defined(__NetBSD__) - case PT_TLS: - /* .gnu.tls */ - snprintf(name, sizeof(name), ".tls%d", tlsnames++); - type = SHT_PROGBITS; - break; -#endif - case PT_DYNAMIC: - /* .dynamic */ - snprintf(name, sizeof(name), ELFSH_SECTION_NAME_DYNAMIC); - type = SHT_DYNAMIC; - break; -#if !defined(sgi) - case PT_GNU_EH_FRAME: - snprintf(name, sizeof(name), ".eh_frame%d", ehnames++); - type = SHT_PROGBITS; - break; -#endif - default: - continue; - } - - /* create the new shdr based on the address from the pht entry */ - file->sht[idx] = elfsh_create_shdr(0, type, flags, - file->pht[index].p_vaddr, - file->pht[index].p_offset, - file->pht[index].p_filesz ? - file->pht[index].p_memsz:0, 0, 0, - file->pht[index].p_align, - sizeof(elfsh_Shdr)); - if(type==SHT_DYNAMIC) - { - dyn_addr = file->pht[index].p_vaddr; - dyn_size = file->pht[index].p_filesz; - } - if(file->pht[index].p_filesz) - { - /* duplicate the data */ - XSEEK(file->fd, file->pht[index].p_offset, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, - file->pht[index].p_filesz + 1, -1); - XREAD(file->fd, data, file->pht[index].p_filesz, -1); - } - else - { - data = NULL; - } - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name=strdup(name); - printf("IDX[%d]: %s\n", idx, sect->name); - if (elfsh_add_section(file, sect, idx++, data, ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - /* the section_offset must be the biggest offset from all sht entries */ - if(file->pht[index].p_offset) - if((file->pht[index].p_offset+file->pht[index].p_filesz)>section_offset) - section_offset = file->pht[index].p_offset + file->pht[index].p_filesz; - } - -#if 0 - /* SHSTRTAB */ - /* Insert the section header string table (.shstrtab) */ - shdr = elfsh_create_shdr(0, SHT_STRTAB, 0, 0, section_offset, - 0, 0, 0, 0, sizeof(elfsh_Shdr)); - - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(elfshsect_t), -1); - sect->name = strdup(ELFSH_SECTION_NAME_SHSTRTAB); - - if (elfsh_add_section(file, sect, idx, NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->secthash[ELFSH_SECTION_SHSTRTAB] = sect; - - file->hdr->e_shstrndx = idx; - file->hdr->e_shnum = idx+1; - - section_offset += sizeof(elfsh_Shdr); - - /* insert the names of the sections in the .shstrtab */ - for (idx= 0, sect = file->sectlist; sect; sect=sect->next, idx++) - { - sect->shdr->sh_name = elfsh_insert_in_shstrtab(file, sect->name); - printf("name[%d][%d]:%s @ 0x%08x\n", idx, sect->shdr->sh_name, - sect->name, sect->shdr->sh_addr); - section_offset += strlen(sect->name)+1; - } -#endif - /* final round for the sht reconstruction - extract data from the .dynamic section - - WORK IN PROGRESS. - */ - elfsh_Dyn *dyn; - eresi_Addr sect_addr; - elfsh_Word sect_size, ent_size; - -#if 1 - /* .dynstr */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_STRTAB)) != NULL) - { - sect_addr = dyn->d_un.d_ptr; - dyn = elfsh_get_dynamic_entry_by_type(file, DT_STRSZ); - sect_size = dyn->d_un.d_val; - printf("@" XFMT " => SECT SIZE: %x %ld bytes\n", sect_addr - base_addr, sect_size, sect_size); - - shdr = elfsh_create_shdr(0, SHT_STRTAB, SHF_ALLOC, sect_addr, - section_offset, sect_size,0,0,0, - 0); - - //elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".dynstr", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".dynstr"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - printf("READ: %d bytes\n", read(file->fd, data, sect_size)); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->secthash[ELFSH_SECTION_DYNSTR] = sect; - - section_offset += sect_size; - idx++; - } - -#endif - - /* .dynsym */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_SYMTAB)) != NULL) - { - sect_addr = dyn->d_un.d_ptr; - sect_size = elfsh_get_dynamic_entry_by_type(file, DT_STRTAB)->d_un.d_ptr - sect_addr; - - ent_size = elfsh_get_dynamic_entry_by_type(file, DT_SYMENT)->d_un.d_val; - - /* sh_link must point to the .dynstr section index */ - /* sh_info is the total number of entries in dynsym plus one */ - shdr = elfsh_create_shdr(0, SHT_DYNSYM, SHF_ALLOC, sect_addr, - section_offset, sect_size, idx-1, - (sect_size / dyn->d_un.d_val) + 1, 4, - ent_size); - - //elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".dynsym", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".dynsym"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, - ((sect_size / dyn->d_un.d_val) * ent_size)+1, -1); - XREAD(file->fd, data, (sect_size*6), -1); - - if(elfsh_add_section(file, sect, idx, data,ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - // elfsh_fixup_dynsymtab(sect); - - file->secthash[ELFSH_SECTION_DYNSYM] = sect; - section_offset += sect_size; - idx++; - } - - /* .hash */ -#if 1 - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_HASH))) - { - elfsh_Word nbucket, nchain; - sect_addr = dyn->d_un.d_ptr; - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XREAD(file->fd, &nbucket, 4, -1); - XREAD(file->fd, &nchain, 4, -1); - - sect_size = (2 + nbucket + nchain) * sizeof(elfsh_Word); - shdr = elfsh_create_shdr(0, SHT_HASH, SHF_ALLOC, sect_addr, - section_offset,sect_size,0,0,0, - sizeof(elfsh_Word)); - - //elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".hash", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".hash"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data,ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->secthash[ELFSH_SECTION_HASH] = sect; - - section_offset += sect_size; - idx++; - } -#endif -#if 1 - /* .rel.dyn */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_REL)) != NULL) - { - sect_addr = dyn->d_un.d_ptr; - sect_size = elfsh_get_dynamic_entry_by_type(file, DT_RELSZ)->d_un.d_val; - ent_size = elfsh_get_dynamic_entry_by_type(file, DT_RELENT)->d_un.d_val; - - shdr = elfsh_create_shdr(0, SHT_REL, SHF_ALLOC, sect_addr, - section_offset,sect_size,idx-2,1,0, - ent_size); - - //elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".rel.dyn", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".rel.dyn"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - section_offset += sect_size; - idx++; - } -#endif -#if 1 - /* .rel.plt */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_JMPREL)) != NULL) - { - sect_addr = dyn->d_un.d_ptr; - sect_size = elfsh_get_dynamic_entry_by_type(file, DT_PLTRELSZ)->d_un.d_val; - //ent_size = elfsh_get_dynamic_entry_by_type(file, DT_RELENT)->d_un.d_val; - - shdr = elfsh_create_shdr(0, SHT_REL, SHF_ALLOC, sect_addr, - section_offset,sect_size,idx-3,1,0, - sizeof(elfsh_Rel)); - - // elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".rel.plt", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".rel.plt"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - section_offset += sect_size; - idx++; - } -#endif -#if 1 - /* .got */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_PLTGOT)) != NULL) - { - sect_addr = dyn->d_un.d_ptr; - sect_size = sect_addr - (dyn_addr + dyn_size); //elfsh_get_dynamic_entry_by_type(file, DT_PLTRELSZ)->d_un.d_val; - //ent_size = elfsh_get_dynamic_entry_by_type(file, DT_RELENT)->d_un.d_val; - sect_addr -= sect_size; - - shdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_ALLOC|SHF_WRITE, sect_addr, - section_offset,sect_size,0,0,4, - 4); - - // elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".rel.plt", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".got"); - - printf("OFFSET: " AFMT " (size: " DFMT ")\n", sect_addr, (dyn_size)); - XSEEK(file->fd, sect_addr - (base_addr + 0x1000), SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - section_offset += sect_size; - idx++; - } -#endif -#if 1 - /* .init */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_INIT)) != NULL) - { - asm_instr instr; - asm_processor proc; - u_char temp[1024]; - //int curr; - - sect_addr = dyn->d_un.d_ptr; - - switch(elfsh_get_arch(file->hdr)) - { - case EM_SPARC32PLUS: - case EM_SPARC: - case EM_SPARCV9: - asm_init_sparc(&proc); - break; - case EM_386: - asm_init_ia32(&proc); - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - asm_init_mips(&proc); - break; - } - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XREAD(file->fd, temp, 1024, -1); - - //elfsh_read_raw(file, sect_addr - base_addr, data, 1024); - - sect_size = 0; - while(sect_size < 1024) - { - if(asm_read_instr(&instr, temp + sect_size, 1024 - sect_size, &proc) > 0) - { - if(instr.instr==ASM_RET) - { - // printf("RET RET RET: %d\n", sect_size); - sect_size += asm_instr_len(&instr); - break; - } - } - sect_size += asm_instr_len(&instr); - } - - shdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR, sect_addr, - section_offset,sect_size,0,0,4, 4); - - // elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".rel.plt", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".init"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - section_offset += sect_size; - idx++; - } -#endif -#if 1 - /* .fini */ - if((dyn = elfsh_get_dynamic_entry_by_type(file, DT_FINI)) != NULL) - { - asm_instr instr; - asm_processor proc; - u_char temp[1024]; - - sect_addr = dyn->d_un.d_ptr; - - switch(elfsh_get_arch(file->hdr)) - { - case EM_SPARC32PLUS: - case EM_SPARC: - case EM_SPARCV9: - asm_init_sparc(&proc); - break; - case EM_386: - asm_init_ia32(&proc); - break; - case EM_MIPS: - asm_init_mips(&proc); - break; - } - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XREAD(file->fd, temp, 1024, -1); - - sect_size = 0; - while(sect_size < 1024) - { - if(asm_read_instr(&instr, temp + sect_size, 1024 - sect_size, &proc) > 0) - { - if(instr.instr==ASM_RET) - { - sect_size += asm_instr_len(&instr); - break; - } - } - sect_size += asm_instr_len(&instr); - } - - shdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_ALLOC|SHF_EXECINSTR, sect_addr, - section_offset,sect_size,0,0,4, 4); - - // elfsh_insert_shdr(file, shdr, ELFSH_SECTION_LAST, ".rel.plt", ELFSH_SHIFTING_ABSENT); - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, sect, sizeof(elfshsect_t), -1); - sect->name = strdup(".fini"); - - XSEEK(file->fd, sect_addr - base_addr, SEEK_SET, -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, sect_size + 1, -1); - XREAD(file->fd, data, sect_size, -1); - - if(elfsh_add_section(file, sect, idx, data, - ELFSH_SHIFTING_ABSENT)<0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - section_offset += sect_size; - idx++; - } -#endif - -#if 1 - /* SHSTRTAB */ - /* Insert the section header string table (.shstrtab) */ - shdr = elfsh_create_shdr(0, SHT_STRTAB, 0, 0, section_offset, - 0, 0, 0, 0, sizeof(elfsh_Shdr)); - - file->sht[idx] = shdr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__,sect, sizeof(elfshsect_t), -1); - sect->name = strdup(ELFSH_SECTION_NAME_SHSTRTAB); - - if (elfsh_add_section(file, sect, idx, NULL, ELFSH_SHIFTING_ABSENT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add section", -1); - - file->secthash[ELFSH_SECTION_SHSTRTAB] = sect; - - file->hdr->e_shstrndx = idx; - file->hdr->e_shnum = idx+1; - - section_offset += sizeof(elfsh_Shdr); - - /* insert the names of the sections in the .shstrtab */ - for (idx= 0, sect = file->sectlist; sect; sect=sect->next, idx++) - { - sect->shdr->sh_name = elfsh_insert_in_shstrtab(file, sect->name); - printf("name[%d][%d]:%s @ 0x%08x\n", idx, sect->shdr->sh_name, - sect->name, sect->shdr->sh_addr); - section_offset += strlen(sect->name) + 1; - } -#endif - //elfsh_sort_sht(file); - - /* sync the sht entries and name */ - elfsh_sync_sectnames(file); - elfsh_sync_sht(file); - - // elfsh_fixup_symtab(file, &total); - - /* elfsh_Sym newent; - int symsz; - elfshsect_t *symtab = elfsh_get_symtab(file, &symsz); - - for(idx = 0; idx != (file->hdr->e_phnum * file->hdr->e_phentsize); idx++) - { - if(file->pht[idx].p_type == PT_DYNAMIC) - { - newent = elfsh_create_symbol(file->pht[idx].p_vaddr, - 0, STT_OBJECT,0,0,symsz); - elfsh_insert_symbol(symtab, &newent, "_DYNAMIC"); - } - }*/ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -#if 0 -/** - * First round : Read PHT and guess .bss, .interp, .dynamic and .notes bounds - */ -static void sht_first_round(elfshobj_t *file, u_int num) -{ - /* - elfsh_Phdr *dyn; - elfsh_Shdr shdr; - */ - u_int index; - int flags; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < num; index++) - { - flags = SHF_ALLOC; - flags |= (elfsh_segment_is_writable(file->pht + index) ? SHF_WRITE : 0); - flags |= (elfsh_segment_is_executable(file->pht + index) ? SHF_EXECINSTR : 0); - switch (file->pht[index].p_type) - { - - /* The dynamic segment */ - - case PT_DYNAMIC: - dyn = file->pht + index; - shdr = elfsh_create_section_header(0, SHT_DYNAMIC, flags , file->pht[index].p_vaddr, - file->pht[index].p_offset, file->pht[index].p_filesz, - 0, 0, 0, 0); - elfsh_merge_shtentry(file, index, shdr, ELFSH_SECTION_NAME_DYNAMIC); - break; - - - /* The interpretor segment */ - - case PT_INTERP: - shdr = elfsh_create_section_header(0, SHT_PROGBITS, flags, file->pht[index].p_vaddr, - file->pht[index].p_offset, file->pht[index].p_filesz, - 0, 0, 0, 0); - elfsh_merge_shtentry(file, index, shdr, ELFSH_SECTION_NAME_INTERP); - break; - - - /* This is the auxiliary information */ - - case PT_NOTE: - shdr = elfsh_create_section_header(0, SHT_NOTE, flags, file->pht[index].p_vaddr, - file->pht[index].p_offset, file->pht[index].p_filesz, - 0, 0, 0, 0); - elfsh_merge_shtentry(file, index, shdr, ELFSH_SECTION_NAME_NOTES_ABI); - break; - - - /* Rebuild the .bss */ - - case PT_LOAD: - if (file->pht[index].p_memsz != file->pht[index].p_filesz) - { - shdr = elfsh_create_section_header(0, SHT_NOBITS, flags, - file->pht[index].p_vaddr + file->pht[index].p_filesz, - file->pht[index].p_offset + file->pht[index].p_filesz, - file->pht[index].p_memsz - file->pht[index].p_filesz, - 0, 0, 0, 0); - elfsh_merge_shtentry(file, index, shdr, ELFSH_SECTION_NAME_BSS); - } - break; - - - default: - break; - } - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * INTERNAL FUNCTION: guess .text, .data, .init, .fini, and .bss bounds - * - * @param file - * @param num - * @return - */ -static void sht_second_round(elfshobj_t *file, u_int num) -{ - /* elfsh_Phdr *dyn; */ - elfsh_Shdr shdr; - u_int index; - int flags; - char *name; - char i; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do not remove if first_round() is entirely working with section paddings */ - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < num; index++) - { - flags = SHF_ALLOC; - flags |= (elfsh_segment_is_writable(file->pht + index) ? SHF_WRITE : 0); - flags |= (elfsh_segment_is_executable(file->pht + index)? SHF_EXECINSTR : 0); - switch (file->pht[index].p_type) - { - case PT_LOAD: - shdr = elfsh_create_shdr(0, SHT_PROGBITS, flags, - file->pht[index].p_vaddr, - file->pht[index].p_offset, - file->pht[index].p_filesz, - 0, 0, 0, 0); - i = INTERVAL(file->pht[index].p_vaddr, file->hdr->e_entry, - file->pht[index].p_vaddr + file->pht[index].p_filesz); - name = (i ? ELFSH_SECTION_NAME_TEXT : ELFSH_SECTION_NAME_DATA); - printf("MERGIN SHDR second round!\n"); - elfsh_merge_shtentry(file, index, shdr, name); - default: - break; - } - } -} -#endif - -/** - * Recreate the section header table examining the program header table - * - * @param file - * @return - */ -int elfsh_rebuild_sht(elfshobj_t *file) -{ - int num; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Some preliminary stuffs */ - if (!elfsh_get_pht(file, &num) || elfsh_init_sht(file, num) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PHT or to init SHT", -1); - - // sht_first_round(file, num); - // sht_second_round(file, num); - - file->shtrb = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sort.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sort.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sort.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sort.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -/** - * @file sort.c - * @ingroup libelfsh -** sort.c for elfsh -** -** Improved by spacewalker to use quicksort from libc -** instead of some ugly homemade bubble sort -** -** Started on Wed May 21 15:27:15 2003 jfv -** -** -** $Id: sort.c,v 1.9 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libelfsh.h" - -elfshsect_t *symstrsect = NULL; - -/** - * @brief functions called by qsort() - * @param p - * @param q - * @return - */ -int sizesort_compare(const elfsh_Sym * p, const elfsh_Sym * q) -{ - if (p->st_size < q->st_size) - return -1; - if (p->st_size > q->st_size) - return 1; - return 0; -} - -/** - * @brief Missing - * @param p - * @param q - * @return - */ -int addrsort_compare(const elfsh_Sym * p,const elfsh_Sym * q) -{ - if (p->st_value < q->st_value) - return -1; - if (p->st_value > q->st_value) - return 1; - return 0; -} - -/** - * @brief Sort the symtab given in parameter - * @param symtab - * @param size - * @param type - * @return - */ -int elfsh_sort_symtab(elfsh_Sym *symtab, int size, int type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (symtab == NULL || !size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - switch (type) - { - /* Sort by size */ - case (ELFSH_SORT_BY_SIZE): - qsort(symtab, size, sizeof(elfsh_Sym), (void *) sizesort_compare); - break; - /* Sort by address */ - case (ELFSH_SORT_BY_ADDR): - qsort(symtab, size, sizeof(elfsh_Sym), (void *) addrsort_compare); - break; - default: - /* Unknown sort mode */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown sorting mode", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Synchronize sorted instance of tables - * @param sect - * @return - */ -int elfsh_sync_sorted_symtab(elfshsect_t *sect) -{ - u_int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sect == NULL || sect->shdr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (sect->shdr->sh_type != SHT_SYMTAB && sect->shdr->sh_type != SHT_DYNSYM) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Param is not a symtab", -1); - - nbr = sect->curend / sizeof(elfsh_Sym); - - if (nbr == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Current section is empty", -1); - - /* Sort by address */ - if (sect->altdata != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->altdata); - - sect->altdata = elfsh_copy_symtab(sect->data, nbr); - elfsh_sort_symtab(sect->altdata, nbr, ELFSH_SORT_BY_ADDR); - - /* Sort by size */ - if (sect->terdata != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,sect->terdata); - - sect->terdata = elfsh_copy_symtab(sect->data, nbr); - elfsh_sort_symtab(sect->terdata, nbr, ELFSH_SORT_BY_SIZE); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sparc32.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sparc32.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sparc32.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sparc32.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,479 +0,0 @@ -/** - * @file sparc32.c - * @ingroup libelfsh - * sparc32.c for libelfsh - * - * Started on Fri Jan 11 03:05:37 2003 jfv - * - * - * $Id: sparc32.c,v 1.8 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - - - -/** - * @brief Static hooking for Sparc - * @param file - * @param name - * @param symbol - * @param addr - * @return - */ -int elfsh_cflow_sparc32(elfshobj_t *file, - char *name, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - u_int ret; - int off; - u_char buff[4]; - elfshsect_t *hooks; - char *hook; - int prot; - uint32_t *opcode; - int diff; - char bufname[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_CFLOW__ - printf("[DEBUG_CFLOW] Requesting hijack addr = %08X, sym.st_value = %08X, name = %s\n", - addr, symbol->st_value, name); -#endif - - off = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - if (!off) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid address to hijack", -1); - - /* Read two instruction */ - ret = elfsh_raw_read(file, off, buff, 8); - if (ret != 8) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read an opcode", -1); - - /* If the hook section does not exist, create it */ - hooks = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_HOOKS, - 0, 0, 0); - - if (!hooks) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get and inject .hooks", -1); - - hook = elfsh_get_raw(hooks) + hooks->curend; - opcode = (uint32_t *) hook; - -#define SPARC32_B_OPCODE(_size) 0x10000000 + (_size < 0 ? 0xb00000 : 0x800000) + (((_size - (_size % 4)) / 4) & 0xFFFFF) -#define SPARC32_NOP 0x01000000 - - /* Create the hook for this function */ - prot = elfsh_munprotect(file, (eresi_Addr) hook, 28); - - diff = addr - (hooks->shdr->sh_addr + (hook - (char *) elfsh_get_raw(hooks))); - opcode[0] = SPARC32_B_OPCODE(diff); // b - opcode[1] = SPARC32_NOP; - - /* Copy ovewrited opcode */ - memcpy((void *)&opcode[2], buff, 8); - - opcode[4] = SPARC32_NOP; - - diff = symbol->st_value - (hooks->shdr->sh_addr + hooks->curend + 20) + 8; - opcode[5] = SPARC32_B_OPCODE(diff); // b - opcode[6] = SPARC32_NOP; - - elfsh_mprotect((eresi_Addr) hook, 28, prot); - - opcode = (void *) buff; - - /* Add b instruction at function start */ - diff = (hooks->shdr->sh_addr + hooks->curend) - symbol->st_value; - opcode[0] = SPARC32_B_OPCODE(diff); - opcode[1] = SPARC32_NOP; - - ret = elfsh_raw_write(file, off, buff, 8); - if (ret != 8) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during hook installation", -1); - - /* Insert the old symbol on the original saved bytes (do the insertion AFTER all use of symbol !!) */ - snprintf(bufname, BUFSIZ, "old_%s", name); - elfsh_insert_funcsym(file, bufname, hooks->shdr->sh_addr + hooks->curend + 8, - 16, hooks->index); - snprintf(bufname, BUFSIZ, "hook_%s", name); - elfsh_insert_funcsym(file, bufname, hooks->shdr->sh_addr + hooks->curend, - 8, hooks->index); - -#if __DEBUG_CFLOW__ - printf("[DEBUG_CFLOW] hook_legit_func = %08X, old_legit_func = %08X \n", - hooks->shdr->sh_addr + hooks->curend, - hooks->shdr->sh_addr + hooks->curend + 5); -#endif - - /* Everything OK */ - hooks->curend += 28; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief PLT hijacking on SPARC - * Based on a early version by emsi, delay slot added by ELFsh crew, now it's works yes - * Slight patch by emsi to support function call when the high bit is set - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_sparc32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t addrh, addrl; - uint32_t opcode[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_SPARC && file->hdr->e_machine != EM_SPARC32PLUS) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_SPARC while the elf file is not " - "SPARC\n", -1); - - /* compute the sparc %hi(), %lo() address */ - addrh = addr & 0xfffffc00; - addrl = addr & 0x3ff; - - /* sethi %hi(addrh), %g1 */ - opcode[0] = 0x03000000 | (0x3fffff & (addrh >> 10)); - - /* jmp %g1 + addrl ! addr */ - opcode[1] = 0x81c06000 | addrl; - - /* Add a nop for delay slot */ - opcode[2] = 0x01000000; - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief PLT hijacking on SPARC - * Based on a early version by emsi, delay slot added by ELFsh crew, now it's works yes - * Slight patch by emsi to support function call when the high bit is set - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_sparc32_second(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t addrh, addrl; - uint32_t opcode[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_SPARC && - file->hdr->e_machine != EM_SPARC32PLUS) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_SPARC while the elf file is not " - "SPARC\n", -1); - - /* compute the sparc %hi(), %lo() address */ - addrh = addr & 0xfffffc00; - addrl = addr & 0x3ff; - - /* sethi %hi(addrh), %g2 */ - opcode[0] = 0x05000000 | (0x3fffff & (addrh >> 10)); - - /* jmp %g1 + addrl ! addr */ - opcode[1] = 0x81c0a000 | addrl; - - /* Add a nop for delay slot */ - opcode[2] = 0x01000000; - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* - Used for hijacking the first PLT entry, when %g1 needs to be kept. - This 16 instructions lenght code copies the first updated .plt - entry to the first not-yet-updated .alt.plt entry in runtime. This - operation needs to recompute the 'call elf_bndr' since its operand is - relative. - - This fix is necessary so that we keep a consistent relocation offset - (because first .alt.plt entry 's %i7 is used for computing the relocation - offset on solaris/sparc, I guess this is not a very standard behavior ;). - - Updated 20050311 : Alpha does it as well, not respecting the ELF reference - seems to be a normal behavior. Yeah, direct PLT patching sucks. - - If we just try to redirect .alt.plt first entry on .plt first entry, it will - work the first time, but the hook is removed after the first original (hijacked) - function call, and thats not what we want (in case we need to call the original - function from the hook function many times). That's the main reason why we - need this cool stub -mm - - Optimized by dvorak for fitting in 96 bytes (12 instrs) danke Jack ! -*/ - -/** - * @brief hijack altptl on sparc32 - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_altplt_sparc32(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t addrh, addrl; - uint32_t opcode[11]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_SPARC && file->hdr->e_machine != EM_SPARC32PLUS) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_SPARC while the elf file is not " - "SPARC\n", -1); - - { - elfsh_Sym *sym; - - sym = elfsh_get_symbol_by_value(file, addr, 0, ELFSH_EXACTSYM); - if (!sym) -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find .plt symbol .. ", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_hijack_plt_sparc32_second(file, sym, symbol->st_value))); - } - - - //Not needed anymore ? - addr += 4; - - /* save %sp, -64, %sp */ - //opcode[0] = 0x9de3bfc0; - - /* save %sp, -88, %sp */ - opcode[0] = 0x9de3bfa8; - - /* mloop: call 0x10740 */ - opcode[1] = 0x40000002; - - /* sethi %hi(0x20800), %l2 */ - addrh = addr & 0xfffffc00; - opcode[2] = 0x25000000 | addrh >> 10; - - /* x: or %l2, 0x1ac, %l2 */ - addrl = addr & 0x3ff; - opcode[3] = 0xA414a000 | addrl; - - /* sub %o7, %l2, %l3 */ - opcode[4] = 0xa623c012; - - /* sra %l3, 2, %l3 */ - opcode[5] = 0xa73ce002; - - /* ld [ %l2 ], %l4 */ - opcode[6] = 0xe804a000; - - /* sub %l4, %l3, %l4 */ - opcode[7] = 0xa8250013; - - /* st %l4, [ %o7 ] */ - opcode[8] = 0xe823e000; - - /* ld [ %l2 + 8 ], %l3 */ - opcode[9] = 0xe604a008; - - /* b 0x10738 */ - opcode[10] = 0x10bffff7; - - /* st %l3, [ %o7 + 8 ] */ - opcode[11] = 0xe623e008; - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 12 * sizeof(uint32_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Perform relocation on entry for SPARC architecture - * First version by thegrugq adapted by elfsh crew - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_sparc32(elfshsect_t *new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - int retval; - eresi_Addr result; - uint32_t *word; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#define ADD (cur->r_addend) -#define BAS (elfsh_get_object_baseaddr(new->parent)) -#define GOT 0 /* GOT isn't available ... */ -#define PLT 0 /* PLT isn't available ... */ -#define PLA (new->shdr->sh_addr + cur->r_offset) -#define SYM (addr) - -#define VERIFY8(x) (((x) & (0xFFFFFFFF << 8)) ? 1 : 0) -#define VERIFY13(x) (((x) & (0xFFFFFFFF << 13)) ? 1 : 0) -#define VERIFY16(x) (((x) & (0xFFFFFFFF << 16)) ? 1 : 0) -#define VERIFY22(x) (((x) & (0xFFFFFFFF << 22)) ? 1 : 0) -#define VERIFY30(x) (((x) & (0xFFFFFFFF << 30)) ? 1 : 0) -#define VERIFY32(x) (((x) & (0xFFFFFFFF << 0)) ? 1 : 0) - -#define TRUNCATE8(x) ((x) & ~(0xFFFFFFFF << 8)) -#define TRUNCATE13(x) ((x) & ~(0xFFFFFFFF << 13)) -#define TRUNCATE16(x) ((x) & ~(0xFFFFFFFF << 16)) -#define TRUNCATE22(x) ((x) & ~(0xFFFFFFFF << 22)) -#define TRUNCATE30(x) ((x) & ~(0xFFFFFFFF << 30)) -#define TRUNCATE32(x) (x) /* XXX just assume its 32bit */ - - retval = 0; - result = 0; - word = (uint32_t *) dword; - - switch (elfsh_get_reltype((elfsh_Rel *)cur)) - { - case R_SPARC_NONE: - break; - case R_SPARC_8: - result = SYM + ADD; - if (VERIFY8(result)) - ; // XXX error condition. - break; - case R_SPARC_16: - result = SYM + ADD; - if (VERIFY16(result)) - ; // XXX error condition - break; - case R_SPARC_32: - result = SYM + ADD; - if (VERIFY32(result)) - ; // XXX error condition - break; - case R_SPARC_DISP8: - result = SYM + ADD - PLA; - if (VERIFY8(result)) - ; // XXX error condition - break; - case R_SPARC_DISP16: - result = SYM + ADD - PLA; - if (VERIFY16(result)) - ; // XXX error condition - break; - case R_SPARC_DISP32: - result = SYM + ADD - PLA; - if (VERIFY32(result)) - ; // XXX error condition - break; - case R_SPARC_WDISP30: - result = (SYM + ADD - PLA) >> 2; - if (VERIFY30(result)) - ; // XXX error condition - break; - case R_SPARC_WDISP22: - result = (SYM + ADD - PLA) >> 10; - if (VERIFY22(result)) - ; // XXX error condition - break; - case R_SPARC_HI22: - result = TRUNCATE22(((SYM + ADD) >> 10)); - break; - case R_SPARC_22: - result = SYM + ADD; - if (VERIFY22(result)) - ; // XXX error condition - break; - case R_SPARC_13: - result = SYM + ADD; - if (VERIFY13(result)) - ; // XXX error condition - break; - case R_SPARC_LO10: - result = TRUNCATE13(((SYM + ADD) & 0x3FF)); - break; - case R_SPARC_GOT10: - case R_SPARC_GOT13: - case R_SPARC_GOT22: - // unsupported - retval = -1; - break; - case R_SPARC_PC10: - result = TRUNCATE13(((SYM + ADD - PLA) & 0x3FF)); - break; - case R_SPARC_PC22: - result = (SYM + ADD - PLA) >> 10; - if (VERIFY22(result)) - ; // XXX error condition - break; - case R_SPARC_WPLT30: - // unsupported - retval = -1; - break; - case R_SPARC_COPY: - // unsupported - retval = -1; - break; - case R_SPARC_GLOB_DAT: - result = SYM + ADD; - if (VERIFY32(result)) - ; // XXX error condition - break; - case R_SPARC_JMP_SLOT: - //unsupported - retval = -1; - break; - case R_SPARC_RELATIVE: - result = BAS + ADD; - if (VERIFY32(result)) - ; // XXX error condition - break; - case R_SPARC_UA32: - result = SYM + ADD; - if (VERIFY32(result)) - ; // XXX error condition - break; - default: -PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unsupported reloc type", - -1); - break; - } - -#undef ADD -#undef BAS -#undef GOT -#undef PLT -#undef PLA -#undef SYM - *word += (uint32_t) result; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (retval)); -} - - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sparc64.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sparc64.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sparc64.c.svn-base 2008-04-06 23:15:33.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sparc64.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,188 +0,0 @@ -/** - * @file sparc64.c - * @ingroup libelfsh - * sparc64.c for libelfsh - * - * Started on Sat Jan 15 14:25:37 2005 jfv - * Last update Sat Jan 15 14:26:39 2005 jfv - * - * Cut & Pasted from the sparc32 backend - * 64 bits backend work-in-progress - * - * - * $Id: sparc64.c,v 1.7 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -/* - Here some temporary info on openssl64 - printf : 0x100255560 (plt + 672) -*/ - -/** - * @brief Static hooking for Sparc64 - * @param null - * @param snull - * @param null2 - * @param null3 - * @return - */ -int elfsh_cflow_sparc64(elfshobj_t *null, - char *snull, - elfsh_Sym *null2, - eresi_Addr null3) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported Arch, ELF type, or OS", -1); -} - -/** - * @brief PLT hijacking on SPARC64 - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_plt_sparc64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t addrh, addrl; - uint32_t opcode[3]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_SPARCV9) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_SPARC while the elf file is not " - "SPARC\n", -1); - - /* compute the sparc %hi(), %lo() address */ - addrh = addr & 0xfffffc00; - addrl = addr & 0x3ff; - - /* sethi %hi(addrh), %g1 */ - opcode[0] = 0x03000000 | addrh >> 10; - - /* jmp %g1 + addrl ! addr */ - opcode[1] = 0x81c06000 | addrl; - - /* Add a nop for delay slot */ - opcode[2] = 0x01000000; - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 3 * sizeof(uint32_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* - - Used for hijacking the first PLT entry, when %g1 needs to be kept. - This 16 instructions lenght code copies the first updated .plt - entry to the first not-yet-updated .alt.plt entry in runtime. This - operation needs to recompute the 'call elf_bndr' since its operand is - relative. - - This fix is necessary so that we keep a consistent relocation offset - (because first .alt.plt entry 's %i7 is used for computing the relocation - offset on solaris/sparc, I guess this is not a very standard behavior ;). - If we dont do that, the hook is removed after the first original (hijacked) - function call, and thats not what we want (in case we need to call the original - function from the hook function.) -mm - - Optimized by dvorak at synnergy dot net for fitting in 64 bytes, danke Jack! - -*/ - -/** - * @brief hijack altplt on sparc64 - * @param file - * @param symbol - * @param addr - * @return - */ -int elfsh_hijack_altplt_sparc64(elfshobj_t *file, - elfsh_Sym *symbol, - eresi_Addr addr) -{ - int foffset; - uint32_t addrh, addrl; - uint32_t opcode[11]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->hdr->e_machine != EM_SPARCV9) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "requested " - "ELFSH_HIJACK_CPU_SPARC while the elf file is not " - "SPARC\n", -1); - - addr += 4; - - /* save %sp, -64, %sp */ - opcode[0] = 0x9de3bfc0; - - /* mloop: call 0x10740 */ - opcode[1] = 0x40000002; - - /* sethi %hi(0x20800), %l2 */ - addrh = addr & 0xfffffc00; - opcode[2] = 0x25000000 | addrh >> 10; - - /* x: or %l2, 0x1ac, %l2 */ - addrl = addr & 0x3ff; - opcode[3] = 0xA414a000 | addrl; - - /* sub %o7, %l2, %l3 */ - opcode[4] = 0xa623c012; - - /* sra %l3, 2, %l3 */ - opcode[5] = 0xa73ce002; - - /* ld [ %l2 ], %l4 */ - opcode[6] = 0xe804a000; - - /* sub %l4, %l3, %l4 */ - opcode[7] = 0xa8250013; - - /* st %l4, [ %o7 ] */ - opcode[8] = 0xe823e000; - - /* ld [ %l2 + 8 ], %l3 */ - opcode[9] = 0xe604a008; - - /* b 0x10738 */ - opcode[10] = 0x10bffff7; - - /* st %l3, [ %o7 + 8 ] */ - opcode[11] = 0xe623e008; - - foffset = elfsh_get_foffset_from_vaddr(file, symbol->st_value); - elfsh_raw_write(file, foffset, opcode, 12 * sizeof(uint32_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Perform relocation on entry for SPARC64 architecture. - * Shared relocation function with augmented SPARC32 - * @param new - * @param cur - * @param dword - * @param addr - * @param mod - * @return - */ -int elfsh_relocate_sparc64(elfshsect_t *new, - elfsh_Rela *cur, - eresi_Addr *dword, - eresi_Addr addr, - elfshsect_t *mod) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_relocate_sparc32(new, cur, dword, addr, mod))); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/stab.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/stab.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/stab.c.svn-base 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/stab.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,119 +0,0 @@ -/** - * @file stabs.c - * @ingroup libelfsh - * stabs.c for libelfsh - * - * Started on Mon Feb 26 04:14:06 2001 jfv - * - * - * $Id: stab.c,v 1.9 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -/** - * @brief Return the debugging symbol name giving its index in - * the stab string table. - * @param file - * @param s - * @return - */ -char *elfsh_get_stab_name(elfshobj_t *file, elfshstabent_t *s) -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL file parameter", NULL); - - if (NULL == file->secthash[ELFSH_SECTION_STABSTR] && - NULL == elfsh_get_stab(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive stabs section", NULL); - - str = (char *) elfsh_get_raw(file->secthash[ELFSH_SECTION_STABSTR]) + s->strindex; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str)); -} - -/** - * @brief Load the stab information from the file. - * @param file - * @param num - * @return - */ -void *elfsh_get_stab(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex; - int index; - int nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* Fill the stab table */ - if (file->secthash[ELFSH_SECTION_STAB] == NULL) - { - - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_STAB, - &index, &strindex, &nbr); - if (NULL == sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get STABS by name", NULL); - - file->secthash[ELFSH_SECTION_STAB] = sect; - sect->data = elfsh_load_section(file, sect->shdr); - - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load STABS", NULL); - - /* Fill the stab string table */ - sect = elfsh_get_section_by_index(file, strindex, NULL, NULL); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get STABS string table", NULL); - - file->secthash[ELFSH_SECTION_STABSTR] = sect; - sect->data = elfsh_load_section(file, sect->shdr); - - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load STABS string table", NULL); - } - - if (num != NULL) - { - nbr = file->secthash[ELFSH_SECTION_STAB]->shdr->sh_size; - *num = nbr / sizeof(elfshstabent_t); - } - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_STAB]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * @brief Return the symbol type name giving its index in the symtype array - * @param s - * @return - */ -u_int elfsh_get_stab_type(elfshstabent_t *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->type)); -} - -/** - * Not used yet - * @param s - * @return - */ -eresi_Addr elfsh_get_stab_offset(elfshstabent_t *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (((eresi_Addr) (s->value)))); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/state.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/state.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/state.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/state.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/** - * @file state.c - * @ingroup libelfsh - * @brief Provide initialization and debugger state related functions. - * - * Started on Sat Jun 2 15:20:18 2005 jfv - * - * - * $Id: state.c,v 1.17 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - - -libworld_t dbgworld; - - -void elfsh_init() __attribute__ ((constructor)); - - -/** - * @brief Initialize the elfsh world - */ -void elfsh_init() -{ - memset(&dbgworld, 0x00, sizeof(dbgworld)); - - aspect_called_ctors_inc(); - - /* Initialize the aspect library and set ondisk mode by default */ - aspect_init(); - elfsh_set_static_mode(); - - if (aspect_called_ctors_finished()) - e2dbg_presence_reset(); - -} - - -/** - * @brief The functions for simple ondisk/memory state flag - */ -u_char elfsh_is_static_mode() -{ - return (dbgworld.mode == LIBELFSH_MODE_STATIC); -} - -/** - * @brief Set static mode - */ -void elfsh_set_static_mode() -{ - elfsh_set_mode(LIBELFSH_MODE_STATIC); -} - - -/** - * @ brief check if we are running in debug mode - */ -u_char elfsh_is_debug_mode() -{ - return (dbgworld.mode == LIBELFSH_MODE_E2DBG); -} - -/** - * @brief set debug mode - */ -void elfsh_set_debug_mode() -{ - elfsh_set_mode(LIBELFSH_MODE_E2DBG); - dbgworld.indebug = 1; -} - -/** - * @brief set mode - * @param mode - */ -void elfsh_set_mode(u_char mode) -{ - //fprintf(stderr, "MODE changed for [%s] ! \n", - //(mode == LIBELFSH_MODE_STATIC ? "static" : "dynamic")); - - dbgworld.mode = mode; -} - -/** - * @brief get mode - */ -u_char elfsh_get_mode() -{ - return (dbgworld.mode); -} - -/** - * check if we are in debug - */ -u_char elfsh_debugger_present() -{ - return (dbgworld.indebug); -} - - -/** - * @brief toggle modes - */ - -void elfsh_toggle_mode() -{ - if (elfsh_is_debug_mode()) - elfsh_set_static_mode(); - else - elfsh_set_debug_mode(); -} - -/** - * @brief Print last error - */ -void elfsh_error() -{ - profiler_error(); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/strip.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/strip.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/strip.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/strip.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/** - * @file strip.c - * @ingroup libelfsh - * Made by jfv - * Login - * - * Started on Sat Mar 15 03:45:54 2003 jfv - * Last update Mon Mar 17 04:40:35 2003 jfv - * - * $Id: strip.c,v 1.7 2008-02-16 12:32:27 thor Exp $ - * - */ - -#include "libelfsh.h" - -/** - * Tell elfsh to strip all unmapped sections - * @param file - * @return - */ -int elfsh_strip(elfshobj_t *file) -{ - elfshsect_t *bss; - elfshsect_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - bss = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_BSS, - NULL, NULL, NULL); - if (file == NULL || file->sectlist == NULL || bss == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - while (bss->shdr->sh_addr) - bss = bss->next; - - while (bss) - { - next = bss->next; - if ((bss->index == 0) || - ((bss->index != file->hdr->e_shstrndx) && - elfsh_remove_section(file, bss->name))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to remove section", -1); - - bss = next; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/strtab.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/strtab.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/strtab.c.svn-base 2008-04-06 23:15:34.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/strtab.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ -/** - * @file strtab.c - * @ingroup libelfsh - * strtab.c for libelfsh - * - * Started on Sun Mar 10 03:24:23 2002 jfv - * Last update Sun May 25 17:40:19 2003 jfv - * - * $Id: strtab.c,v 1.10 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -/** - * Rebuild symbol string table if unexistant - * @param file - * @return - */ -elfshsect_t *elfsh_rebuild_strtab(elfshobj_t *file) -{ - elfshsect_t *strtab; - elfsh_Shdr hdr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Create the table if it does not exist */ - if (file->secthash[ELFSH_SECTION_STRTAB] == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,strtab, sizeof (elfshsect_t), NULL); - hdr = elfsh_create_shdr(0, SHT_STRTAB, 0, 0, 0, 0, 0, 0, 0, 0); - strtab->name = strdup(ELFSH_SECTION_NAME_STRTAB); - strtab->parent = file; - elfsh_insert_unmapped_section(file, strtab, hdr, NULL); - file->secthash[ELFSH_SECTION_STRTAB] = strtab; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (file->secthash[ELFSH_SECTION_STRTAB])); -} - -/** - * Retreive strtab - * @param file - * @param index - * @return - */ -elfshsect_t *elfsh_get_strtab(elfshobj_t *file, int index) -{ - elfshsect_t *s; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - s = file->secthash[ELFSH_SECTION_STRTAB]; - if (s) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, s); - - /* Read the string table */ - if (index > 0) - s = elfsh_get_section_by_index(file, index, NULL, NULL); - else - s = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_STRTAB, - NULL, NULL, NULL); - - /* Section is present */ - if (s != NULL) - { - file->secthash[ELFSH_SECTION_STRTAB] = s; - s->shdr->sh_link = file->secthash[ELFSH_SECTION_SYMTAB]->index; - if (s->data == NULL) - { - s->data = elfsh_load_section(file, s->shdr); - if (s->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load STRTAB", NULL); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); - } - - /* Section is not present */ - s = elfsh_rebuild_strtab(file); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s)); -} - -/** - * Add a symbol name in .strtab - * @param file - * @param name - * @return - */ -int elfsh_insert_in_strtab(elfshobj_t *file, char *name) -{ - elfshsect_t *sect; - u_int len; - u_int index; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - sect = elfsh_get_strtab(file, -1); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get STRTAB", -1); - - len = strlen(name); - if (!len) - for (index = 0; index < sect->shdr->sh_size; index++) - if (*(char *) sect->data + index == 0x00) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (index)); - - ret = elfsh_append_data_to_section(sect, name, len + 1); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to append data to strtab", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Add a symbol name in .dynstr - * @param file - * @param name - * @return - */ -int elfsh_insert_in_dynstr(elfshobj_t *file, char *name) -{ - elfshsect_t *sect; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - sect = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DYNSTR, NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find DYNSTR by name", -1); - ret = elfsh_append_data_to_section(sect, name, strlen(name) + 1); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to append data to dynstr", -1); - else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Add a section name in section string table - * @param file - * @param name - * @return - */ -int elfsh_insert_in_shstrtab(elfshobj_t *file, char *name) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (name == NULL || file == NULL || - file->secthash[ELFSH_SECTION_SHSTRTAB] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - ret = elfsh_append_data_to_section(file->secthash[ELFSH_SECTION_SHSTRTAB], - name, strlen(name) + 1); - - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to append data to shstrtab", -1); - else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Add a section name in runtime section string table - * @param file - * @param name - * @return - */ -int elfsh_insert_in_rshstrtab(elfshobj_t *file, char *name) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (name == NULL || file == NULL || - file->secthash[ELFSH_SECTION_RSHSTRTAB] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - ret = elfsh_append_data_to_section(file->secthash[ELFSH_SECTION_RSHSTRTAB], - name, strlen(name) + 1); - - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to append data to rshstrtab", -1); - else - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/symbol.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/symbol.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/symbol.c.svn-base 2008-04-06 23:15:32.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/symbol.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,746 +0,0 @@ -/** - * @file symbol.c - * @ingroup libelfsh - * symbol.c for libelfsh - * - * Started on Mon Feb 26 04:11:46 2001 jfv - * - * $Id: symbol.c,v 1.17 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -#define ELFSH_SYMTAB_HASH_NAME "elfsh_symtab_hashbyname" - -/** - * Return the symbol name giving its index in the symbol string table - * No special case for SECTION symbol because the section names strings - * have been duplicated in the symbol table. - * @param file - * @param s - * @return - */ -char *elfsh_get_symbol_name(elfshobj_t *file, elfsh_Sym *s) -{ - elfshsect_t *sect; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || s == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Load symtab if needed */ - if (file->secthash[ELFSH_SECTION_SYMTAB] == NULL && - elfsh_get_symtab(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive symbol table", NULL); - - /* Else use the symbol string table */ - sect = file->secthash[ELFSH_SECTION_STRTAB]; - if (!sect || !sect->data) - { - sect = elfsh_get_strtab(file, 0); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get STRTAB", NULL); - data = sect->data; - } - else - data = sect->data; - - /* A last check to avoid getting killed on corrupted symbol tables */ - if (!data) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ""); - else if ((unsigned int) s->st_name > - (unsigned int) file->secthash[ELFSH_SECTION_STRTAB]->shdr->sh_size) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ""); - - /* Return name */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((char *) data + s->st_name)); -} - - - -/** - * Return the used offset in .strtab or -1 if failed - * @param file - * @param s - * @param name - * @return - */ -int elfsh_set_symbol_name(elfshobj_t *file, - elfsh_Sym *s, - char *name) -{ - elfshsect_t *sct; - char *str; - u_int len; - u_int new_len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL || s == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (file->secthash[ELFSH_SECTION_SYMTAB] == NULL && - elfsh_get_symtab(file, NULL) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive symbol table", -1); - - /* Also change the section name in .shstrtab if symbol is STT_SECTION */ - if (elfsh_get_symbol_type(s) == STT_SECTION) - { - sct = elfsh_get_section_from_sym(file, s); - if (sct != NULL && elfsh_set_section_name(file, sct, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get section from its symbol", -1); - } - - - /* Else use the symbol string table */ - if (file->secthash[ELFSH_SECTION_STRTAB] == NULL || - file->secthash[ELFSH_SECTION_STRTAB]->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No STRTAB available", NULL); - - /* Change the name */ - str = file->secthash[ELFSH_SECTION_STRTAB]->data; - str += s->st_name; - len = strlen(str); - new_len = strlen(name); - - /* Do not allocate new place if possible */ - if (len >= new_len) - strcpy(str, name); - /* Append the name to .strtab */ - else - s->st_name = elfsh_insert_in_strtab(file, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->st_name)); -} - - - -/** - * Return a ptr on the symbol table - * @param file - * @param num - * @return - */ -void *elfsh_get_symtab(elfshobj_t *file, int *num) -{ - elfshsect_t *s; - int strindex; - int index; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - else if (NULL == file->sht && NULL == elfsh_get_sht(file, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SHT", NULL); - - if (file->secthash[ELFSH_SECTION_SYMTAB] == NULL) - { - //fprintf(stderr, "Loading symtab for object %s \n", file->name); - - /* If symtab is already loaded, return it */ - s = elfsh_get_section_by_type(file, SHT_SYMTAB, - 0, &index, - &strindex, &nbr); - if (s != NULL) - { - file->secthash[ELFSH_SECTION_SYMTAB] = s; - s->data = elfsh_load_section(file, s->shdr); - if (s->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load SYMTAB", NULL); - s->curend = s->shdr->sh_size; - - /* Now load the string table */ - s = elfsh_get_strtab(file, s->shdr->sh_link); - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load STRTAB", NULL); - s->parent = file; - } - - /* - ** Fix 0 lenght syms and STT_SECTION syms - ** Create a minimal .symtab if unexistant - */ - elfsh_fixup_symtab(file, &strindex); - - //fprintf(stderr, "symtab FIXED for object %s \n", file->name); - - } - - if (num != NULL) - *num = - file->secthash[ELFSH_SECTION_SYMTAB]->curend / sizeof(elfsh_Sym); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (file->secthash[ELFSH_SECTION_SYMTAB]->data)); -} - - -/** - * Return the dynamic symbol name giving its value, - * Fill 'offset' with the difference between sym->st_value and 'value' - * @param file - * @param value - * @param offset - * @return - */ -char *elfsh_reverse_symbol(elfshobj_t *file, - eresi_Addr value, - elfsh_SAddr *offset) -{ - elfshsect_t *sect; - elfsh_Sym *sorted; - int num; - int index; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (!value || value == 0xFFFFFFFF) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", NULL); - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* handle dynamic case */ - if (elfsh_is_debug_mode()) - value -= file->rhdr.base; - - /* If there is no symtab, resolve using SHT */ - if (elfsh_get_symtab(file, &num) == NULL) - { - sect = elfsh_get_parent_section(file, value, offset); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No parent section", NULL); - - *offset = (elfsh_SAddr) (sect->shdr->sh_addr - value); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_get_section_name(file, sect))); - } - - /* Else use the sorted-by-address symbol table to match what we want */ - if (file->secthash[ELFSH_SECTION_SYMTAB]->altdata == NULL) - elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_SYMTAB]); - sorted = file->secthash[ELFSH_SECTION_SYMTAB]->altdata; - - for (index = 0; index < num; index++) - if (sorted[index].st_value <= value && DUMPABLE(sorted + index) && - (index + 1 >= num || sorted[index + 1].st_value > value)) - { - *offset = (elfsh_SAddr) (value - sorted[index].st_value); - - str = elfsh_get_symbol_name(file, sorted + index); - if (!*str) - str = NULL; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No valid symbol interval", NULL); -} - -/** - * Fill symtab and dynsym hash table for _get_*_by_name functions - * @param file target file - * @return - */ -int elfsh_init_symbol_hashtables(elfshobj_t *file) -{ - elfsh_Sym *sym; - int idx; - int size; - char *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - hash_init(&file->symhash, ELFSH_SYMHASH_NAME, 100, ASPECT_TYPE_UNKNOW); - hash_init(&file->dynsymhash, ELFSH_DYNSYMHASH_NAME, 100, ASPECT_TYPE_UNKNOW); - - /* Symtab */ - if (elfsh_get_symtab(file, &size)) - { - sym = (elfsh_Sym *) file->secthash[ELFSH_SECTION_SYMTAB]->data; - - for (idx = 0; idx < size; idx++) - { - actual = elfsh_get_symbol_name(file, sym + idx); - if (actual) - hash_add(&file->symhash, strdup(actual), (void *) idx); - } - } - - sym = (elfsh_Sym *) elfsh_get_dynsymtab(file, &size); - - /* Dynsym */ - if (sym) - { - for (idx = 0; idx < size; idx++) - { - actual = elfsh_get_dynsymbol_name(file, sym + idx); - if (actual) - hash_add(&file->dynsymhash, strdup(actual), (void *) idx); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the symbol entry giving its name - * @param file target file - * @param name symbol name - * @return symbol pointer or NULL - */ -elfsh_Sym *elfsh_get_symbol_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - int idx; - int size; - char *actual; - elfshsect_t *sect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check arguments */ - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* Setup symtab pointers */ - if (elfsh_get_symtab(file, &size) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB", NULL); - - sect = file->secthash[ELFSH_SECTION_SYMTAB]; - - /* Invalid section pointer */ - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB (invalid section pointer)", NULL); - - sym = (elfsh_Sym *) sect->data; - - /* Invalid section data */ - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB data", NULL); - - if (file->symhash.ent) - { - /* idx is the symbol number in the section */ - idx = (int) hash_get(&file->symhash, name); - -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] SYM HASH Search by name for %s => %d\n", - name, idx); -#else - /* Check if idx is in the section */ - if (idx <= 0 || idx >= sect->shdr->sh_size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); -#endif - } - - - for (idx = 0; idx < size; idx++) - { - actual = elfsh_get_symbol_name(file, sym + idx); - if (actual && !strcmp(actual, name)) - { -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] SYM ITERATE Search by name for %s => %d\n", - name, idx); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); - } - } - -#if __DEBUG_HASH_BY_NAME__ - printf("[DEBUG_HASH_BY_NAME] SYM ITERATE Search by name for %s => NOT FOUND\n", name); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); -} - - - -/** - * Shift usual symbols (mandatory on solaris) - * @param sect - * @param sym - */ -void elfsh_shift_usualsyms(elfshsect_t *sect, elfsh_Sym *sym) -{ - elfsh_Sym *end; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //fprintf(stderr, "Calling shift usual syms ! \n"); - - /* Change _end in the symbol table */ - end = elfsh_get_symbol_by_name(sect->parent, "_end"); - if (end != NULL && sym->st_value + sym->st_size > end->st_value) - { - //printf("Shift _end! \n"); - end->st_value = sym->st_value + sym->st_size; - } - - /* Change _end if necessary (solaris) */ - end = elfsh_get_dynsymbol_by_name(sect->parent, "_end"); - if (end != NULL && sym->st_value + sym->st_size > end->st_value) - { - //printf("Shift _end! \n"); - end->st_value = sym->st_value + sym->st_size; - } - - /* Change _END_ if necessary (solaris) */ - end = elfsh_get_dynsymbol_by_name(sect->parent, "_END_"); - if (end != NULL && sym->st_value + sym->st_size > end->st_value) - { - //printf("Shift _END_! \n"); - end->st_value = sym->st_value + sym->st_size; - } - - /* Change _edata if necessary (solaris) */ - if (elfsh_get_ostype(sect->parent) == ELFSH_OS_SOLARIS) - { - end = elfsh_get_dynsymbol_by_name(sect->parent, "_edata"); - if (end != NULL && sym->st_value + sym->st_size > end->st_value) - { - //printf("Shift _edata! \n"); - end->st_value = sym->st_value + sym->st_size; - } - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Insert a symbol in the given symbol table - * This function is not e2dbg safe - * @param sect - * @param sym - * @param name - * @return - */ -int elfsh_insert_symbol(elfshsect_t *sect, - elfsh_Sym *sym, - char *name) -{ - elfsh_Sym *orig; - int index; - int mode; - hash_t *uptable; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //fprintf(stderr, "Adding symbol %s \n", name); - - /* Sanity checks */ - if (sect == NULL || sect->shdr == NULL || - (sect->shdr->sh_type != SHT_SYMTAB && - sect->shdr->sh_type != SHT_DYNSYM)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Input section is not SYMTAB", -1); - if (name == NULL) - name = ELFSH_NULL_STRING; - - /* Check if symbol already exists */ - orig = elfsh_get_symbol_by_name(sect->parent, name); - if (orig != NULL && sym->st_value == orig->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (((char *) orig - (char *) sect->data) / - ELFSH_SYMTAB_ENTRY_SIZE)); - - /* Shift some special symbols */ - //if (sect->shdr->sh_type == SHT_DYNSYM) - //fprintf(stderr, "Shifting usual symbols\n"); - mode = elfsh_get_mode(); - elfsh_set_static_mode(); - elfsh_shift_usualsyms(sect, sym); - elfsh_set_mode(mode); - //fprintf(stderr, "Shifted usual symbols\n"); - - /* Insert symbol name in .shstrtab */ - index = elfsh_insert_in_strtab(sect->parent, name); - if (index < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert in SHSTRTAB", -1); - -#if __DEBUG_RELADD__ - fprintf(stderr, "[DEBUG_RELADD] Injected symbol %-20s [" AFMT "] \n", - name, (eresi_Addr) sym->st_value); -#endif - - /* Insert symbol in .symtab */ - sym->st_name = index; - index = elfsh_append_data_to_section(sect, sym, sizeof(elfsh_Sym)); - - /* Update hashtable */ - switch(sect->shdr->sh_type) - { - case SHT_SYMTAB: - uptable = §->parent->symhash; - break; - case SHT_DYNSYM: - uptable = §->parent->dynsymhash; - break; - default: - uptable = NULL; - break; - } - - if (uptable && uptable->ent) - hash_add(uptable, strdup(name), (void *) (index / sizeof(elfsh_Sym))); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_name); -} - - - - -/** - * Remove a symbol - * This function is not e2dbg safe - * @param symtab - * @param name - * @return - */ -int elfsh_remove_symbol(elfshsect_t *symtab, char *name) -{ - elfsh_Sym *ret; - elfsh_Sym *tab; - elfsh_Sym *enew; - u_int off; - u_int movedsz; - hash_t *uptable = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (symtab == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - ret = elfsh_get_symbol_by_name(symtab->parent, name); - if (ret == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown symbol", -1); - - /* Do it */ - tab = symtab->data; - off = (u_long) ret - (u_long) tab; - movedsz = symtab->shdr->sh_size - off - sizeof(elfsh_Sym); - if (movedsz) - memcpy((char *) symtab->data + off, - (char *) symtab->data + off + sizeof(elfsh_Sym), - movedsz); - symtab->shdr->sh_size -= sizeof(elfsh_Sym); - symtab->curend -= sizeof(elfsh_Sym); - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, symtab->shdr->sh_size, -1); - memcpy(enew, tab, symtab->shdr->sh_size); - XFREE(__FILE__, __FUNCTION__, __LINE__,tab); - symtab->data = enew; - - /* We just cant remove the string because of ELF string table format */ - elfsh_sync_sorted_symtab(symtab); - - /* Update hashtable */ - switch(symtab->shdr->sh_type) - { - case SHT_SYMTAB: - uptable = &symtab->parent->symhash; - break; - case SHT_DYNSYM: - uptable = &symtab->parent->dynsymhash; - break; - } - - if (uptable && uptable->ent) - hash_del(uptable, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Retreive the file offset giving the virtual address - * @param file - * @param sym - * @return - */ -int elfsh_get_symbol_foffset(elfshobj_t *file, elfsh_Sym *sym) -{ - elfshsect_t *sect; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If the symbol is a section, then look at the sht instead */ - if (elfsh_get_symbol_type(sym) == STT_SECTION) - { - name = elfsh_get_symbol_name(file, sym); - sect = elfsh_get_section_by_name(file, name, NULL, NULL, NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (sect ? elfsh_get_section_foffset(sect->shdr) : 0)); - } - - /* get our parent section and compute the file offset */ - if (sym == NULL || file == NULL || NULL == sym->st_value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - sect = elfsh_get_parent_section(file, sym->st_value, NULL); - if (sect == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (sect->shdr->sh_offset + - (sym->st_value - sect->shdr->sh_addr))); -} - -/** - * Get symtab entry by vaddr - * @param file - * @param vaddr - * @param off - * @param mode - * @return - */ -elfsh_Sym *elfsh_get_symbol_by_value(elfshobj_t *file, - eresi_Addr vaddr, - int *off, - int mode) -{ - int num; - elfsh_Sym *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_symtab(file, &num); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive SYMTAB", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_get_sym_by_value(data, num, vaddr, off, mode))); -} - - - -/** - * Shift the symbol table - * @param file - * @param limit - * @param inc - * @return - */ -int elfsh_shift_symtab(elfshobj_t *file, eresi_Addr limit, int inc) -{ - elfshsect_t *actual; - int err; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - actual = elfsh_get_section_by_type(file, SHT_SYMTAB, 0, NULL, NULL, NULL); - if (actual == NULL || actual->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find SYMTAB by type", -1); - - err = elfsh_shift_syms(file, actual, limit, inc); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to shift SYMTAB", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Insert STT_SECTION symbol - * @param file - * @param sect - * @return - */ -int elfsh_insert_sectsym(elfshobj_t *file, elfshsect_t *sect) -{ - elfsh_Sym new; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - new = elfsh_create_symbol(sect->shdr->sh_addr, sect->curend, - STT_SECTION, STB_LOCAL, 0, sect->index); - ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], - &new, sect->name); - if (ret < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - ret = elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_SYMTAB]); - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Inserted STT_SECT symbol %s [" AFMT "] sz:%u cur:%u \n", - sect->name, (eresi_Addr) sect->shdr->sh_addr, - sect->shdr->sh_size, sect->curend); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * Insert STT_SECTION symbol - * @param file - * @param name - * @param vaddr - * @param sz - * @param sctidx - * @return - */ -int elfsh_insert_funcsym(elfshobj_t *file, char *name, - eresi_Addr vaddr, - uint32_t sz, uint32_t sctidx) -{ - elfsh_Sym new; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - new = elfsh_create_symbol(vaddr, sz, STT_FUNC, STB_LOCAL, 0, sctidx); - ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], - &new, name); - if (ret < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - ret = elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_SYMTAB]); - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Inserted STT_FUNC symbol %s [" AFMT - "] sz:%u sctidx:%u \n", - name, vaddr, sz, sctidx); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/sym_common.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/sym_common.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/sym_common.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/sym_common.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,589 +0,0 @@ -/** - * @file sym_common.c - * @ingroup libelfsh - * sym_common.c for elfsh - * - * Started on Tue Dec 31 10:19:01 2002 jfv - * - * - * $Id: sym_common.c,v 1.13 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" -#include "libetrace.h" - -/** - * Return the symbol size - * @param s Symbol - * @return - */ -elfsh_Word elfsh_get_symbol_size(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->st_size)); -} - -/** - * Change the symbol size - * @param s Symbol - * @param size New size of symbol - * @return 0 on success or -1 on error. - */ -int elfsh_set_symbol_size(elfsh_Sym *s, eresi_Addr size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_size = (elfsh_Word) size; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the symbol offset giving its elfsh_Sym entry - * @param s - * @return - */ -eresi_Addr elfsh_get_symbol_value(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->st_value)); -} - -/** - * Change the symbol offset giving its elfsh_Sym entry - * @param s - * @param value - * @return - */ -int elfsh_set_symbol_value(elfsh_Sym *s, eresi_Addr value) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_value = value; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the symbol binding - * @param s - * @return - */ -u_char elfsh_get_symbol_bind(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ST_BIND(s->st_info))); -} - -/** - * Change the symbol binding - * @param s - * @param opt - * @return - */ -u_char elfsh_set_symbol_bind(elfsh_Sym *s, eresi_Addr opt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_info = (s->st_info & 0x0F) + ((((char) opt) << 4) & 0xF0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the symbol type - * @param s - * @return - */ -u_char elfsh_get_symbol_type(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ST_TYPE(s->st_info))); -} - -/** - * Change the symbol type - * @param s - * @param type - * @return - */ -u_char elfsh_set_symbol_type(elfsh_Sym *s, eresi_Addr type) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_info = (s->st_info & 0xF0) + (((char) type) & 0x0F); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the symbol type - * @param s - * @return - */ -u_char elfsh_get_symbol_visibility(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ST_VISIBILITY(s->st_other))); -} - -/** - * Change the symbol type - * @param s - * @param vis - * @return - * - */ -u_int elfsh_set_symbol_visibility(elfsh_Sym *s, eresi_Addr vis) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_other = ELFSH_ST_VISIBILITY(((char) vis)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return the symbol linked section index - * @param s - * @return - */ -u_int elfsh_get_symbol_link(elfsh_Sym *s) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s->st_shndx)); -} - -/** - * Change the symbol linked section index - * @param s - * @param val - * @return - */ -u_int elfsh_set_symbol_link(elfsh_Sym *s, eresi_Addr val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (NULL == s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - s->st_shndx = (u_int) val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * High level procedure for get_sym_by_value() - * @param file - * @param vaddr - * @param off - * @param mode - * @return - */ -elfsh_Sym *elfsh_get_metasym_by_value(elfshobj_t *file, - eresi_Addr vaddr, - int *off, int mode) -{ - elfsh_Sym *dynsym; - elfsh_Sym *symtab; - elfsh_Sym *res; - int num; - int dynum; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - symtab = elfsh_get_symtab(file, &num); - dynsym = elfsh_get_dynsymtab(file, &dynum); - - /* ET_DYN objects have a relative addressing inside the ELF file */ - if (elfsh_is_debug_mode()) - vaddr -= file->rhdr.base; - - res = elfsh_get_sym_by_value(dynsym, dynum, vaddr, off, mode); - if (res == NULL) - res = elfsh_get_sym_by_value(symtab, num, vaddr, off, mode); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (res)); -} - - -/** - * Internal generic function for symbol research by value - * @param sym - * @param num - * @param vaddr - * @param off - * @param mode - * @return - */ -elfsh_Sym *elfsh_get_sym_by_value(elfsh_Sym *sym, int num, - eresi_Addr vaddr, int *off, int mode) -{ - elfsh_Sym *low; - elfsh_Sym *high; - elfsh_Sym *good; - int low_off; - int high_off; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - low_off = high_off = ELFSH_UNSET_OFFSET; - good = low = high = NULL; - - if (sym == NULL || !num) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - /* main loop */ - for (idx = 0; idx < num; idx++) - if (sym[idx].st_value < vaddr && (vaddr - sym[idx].st_value) < low_off) - { - low = sym + idx; - low_off = vaddr - sym[idx].st_value; - } - else if (sym[idx].st_value > vaddr && - (sym[idx].st_value - vaddr < high_off)) - { - high = sym + idx; - high_off = sym[idx].st_value - vaddr; - } - else if (sym[idx].st_value == vaddr) - good = sym + idx; - - /* Return what was asked */ - if (good != NULL) - { - if (off != NULL) - *off = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (good)); - } - else if (mode == ELFSH_LOWSYM) - { - if (off != NULL) - *off = low_off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (low)); - } - else if (mode == ELFSH_HIGHSYM) - { - if (off != NULL) - *off = high_off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (high)); - } - - /* ELFSH_EXACTSYM but no matching symbol */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No exact symbol matching", NULL); -} - - -/** - * Create a symbol - * @param value - * @param size - * @param type - * @param binding - * @param vis - * @param sctidx - * @return - */ -elfsh_Sym elfsh_create_symbol(eresi_Addr value, int size, int type, - int binding, int vis, int sctidx) -{ - elfsh_Sym enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - enew.st_value = value; - enew.st_size = size; - enew.st_info = ELFSH_ST_INFO(binding, type); - enew.st_other = vis; - enew.st_shndx = sctidx; - enew.st_name = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (enew)); -} - - -/** - * Just copy the symtab . The returned symbol table need to be freed. - * @param data - * @param size - * @return - */ -elfsh_Sym *elfsh_copy_symtab(void *data, int size) -{ - elfsh_Sym *enew; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!data || !size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - XALLOC(__FILE__, __FUNCTION__, __LINE__,enew, size * ELFSH_SYMTAB_ENTRY_SIZE, NULL); - memcpy(enew, data, size * ELFSH_SYMTAB_ENTRY_SIZE); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (enew)); -} - -/** - * Get symbol by index - * @param symtab - * @param index - * @return - */ -elfsh_Sym *elfsh_get_symbol_by_index(elfsh_Sym *symtab, - eresi_Addr index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (symtab + index)); -} - - -/** - * Get a symbol value by its name - * @param file - * @param name - * @return - */ -elfsh_Sym *elfsh_get_metasym_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sym = elfsh_get_dynsymbol_by_name(file, name); - if (sym != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym)); - sym = elfsh_get_symbol_by_name(file, name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym)); -} - -/** - * Reverse a symbol and give the offset of virtual address from that - * symbol virtual address. - * @param file elfsh object - * @param vaddr Virtual address to resolve - * @param off Reference to store offset from the symbol address - * @return Returns a pointer to the resolved symbol. - */ -char *elfsh_reverse_metasym(elfshobj_t *file, - eresi_Addr vaddr, elfsh_SAddr *off) -{ - elfshsect_t *parent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || vaddr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - parent = elfsh_get_parent_section(file, vaddr, NULL); - if (parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find parent section", NULL); - - if (file->secthash[ELFSH_SECTION_PLT] != NULL && - parent->index == file->secthash[ELFSH_SECTION_PLT]->index) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_reverse_dynsymbol(file, vaddr, off))); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_reverse_symbol(file, vaddr, off))); -} - -/** - * Endianize the table - * @param tab - * @return - */ -int elfsh_endianize_symtab(elfshsect_t *tab) -{ - elfsh_Sym *symtab; - u_int idx; - u_int sz; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!tab) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Arrange endianess if necessary */ -#if __BYTE_ORDER == __LITTLE_ENDIAN - if (tab->parent->hdr->e_ident[EI_DATA] == ELFDATA2MSB) - { -#elif __BYTE_ORDER == __BIG_ENDIAN - if (tab->parent->hdr->e_ident[EI_DATA] == ELFDATA2LSB) - { -#else -#error Unexpected __BYTE_ORDER ! -#endif - symtab = tab->data; - sz = tab->curend / sizeof(elfsh_Sym); - for (idx = 0; idx < sz; idx++) - { - symtab[idx].st_name = swap32(symtab[idx].st_name); - symtab[idx].st_shndx = swap16(symtab[idx].st_shndx); - symtab[idx].st_value = swaplong(symtab[idx].st_value); - symtab[idx].st_size = swaplong(symtab[idx].st_size); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Shift the symbol table - * @param file - * @param symtab - * @param limit - * @param inc - * @return - */ - int elfsh_shift_syms(elfshobj_t *file, - elfshsect_t *symtab, - eresi_Addr limit, int inc) -{ -#if __DEBUG_RELADD__ - static u_int totshift = 0; -#endif - u_int nbr; - u_int idx; - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (symtab == NULL || symtab->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid SYMTAB parameter", -1); - -#if __DEBUG_RELADD__ - totshift += inc; - printf("[DEBUG_RELADD] Shifting symtab [LIM " AFMT - " .::. INC %08u .::. TOT %08u] \n", - (eresi_Addr) limit, inc, totshift); -#endif - - - sym = (elfsh_Sym *) symtab->data; - nbr = symtab->shdr->sh_size / ELFSH_SYMTAB_ENTRY_SIZE; - for (idx = 0; idx < nbr; idx++) - if (sym[idx].st_value >= limit && limit != ELFSH_NOLIMIT) - { - -#if __DEBUG_RELADD__ - printf("[DEBUG_RELADD] Shifted symbol *%-20s* [" AFMT "-> " AFMT "]\n", - elfsh_get_symbol_name(file, sym), - (eresi_Addr) sym[idx].st_value, - (eresi_Addr) sym[idx].st_value + inc); -#endif - - sym[idx].st_value += inc; - } - - elfsh_sync_sorted_symtab(symtab); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * If submited function point into the plt, we return the file - * and its virtual address to point to remote function - * @param filein base file pointer - * @param vaddrin base virtual address - * @param fileout returned file pointer - * @param vaddrout returned virtual address - * @return - */ -int elfsh_resolv_remote_function(elfshobj_t *filein, eresi_Addr vaddrin, - elfshobj_t **fileout, eresi_Addr *vaddrout) -{ - elfshobj_t *file; - elfshsect_t *sect; - char *data; - elfsh_SAddr sfoffset; - char *sym_name; - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!filein || !fileout || !vaddrout) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Default returned values are -in */ - *fileout = filein; - *vaddrout = vaddrin; - - /* Get virtual address parent section */ - sect = elfsh_get_parent_section(filein, vaddrin, &sfoffset); - - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get section", -1); - - data = elfsh_get_section_name(filein, sect); - - if (!data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get section name", -1); - - /* Find the right function on dependencies */ - if (!strncmp(data, ".plt", 4)) - { - sym_name = elfsh_reverse_dynsymbol(filein, vaddrin, &sfoffset); - - if (!sym_name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find symbol name", -1); - - file = etrace_search_sym(filein, sym_name); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find extern function file", -1); - - sym = elfsh_get_dynsymbol_by_name(file, sym_name); - - if (!sym) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find function symbol on dependencies", -1); - - /* Update pointers */ - *fileout = file; - *vaddrout = sym->st_value; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libelfsh/.svn/text-base/version.c.svn-base eresi-0.0.20110516/libelfsh/.svn/text-base/version.c.svn-base --- eresi-0.8a25/libelfsh/.svn/text-base/version.c.svn-base 2008-04-06 23:15:36.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/.svn/text-base/version.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1501 +0,0 @@ -/** - * @defgroup libelfsh The libelfsh library - */ -/** - * @file version.c - * @ingroup libelfsh - * version.c for elfsh - * - * Started Nov 25 2003 jfv - * Last update Nov 25 2003 jfv - * Last update Sep 27 2005 mxatone - * - * - * $Id: version.c,v 1.11 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libelfsh.h" - -static int version_parent = -1; -static int version_need = -1; - -/** - * Check an equivalence between a version def entry and a version need - * entry on two different files - * @param file file for version need section - * @param deffile file for version def section - * @param need version need entry - * @param def version def entry - * @return need auxiliary entry - */ -elfsh_Vernaux *elfsh_check_defneed_eq(elfshobj_t *file, elfshobj_t *deffile, - elfsh_Verneed *need, elfsh_Verdef *def) -{ - elfsh_Vernaux *needaux; - elfsh_Verdaux *defaux; - void *data; - void *defdata; - u_int offset; - u_int defoffset; - char *needname; - char *defname; - u_int index, defndx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !deffile || !need || !def) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - data = need; - for (index = 0, offset = need->vn_aux; - index < need->vn_cnt; - index++, offset += needaux->vna_next) - { - needaux = data + offset; - - /* We find a first correc entry */ - if (needaux->vna_hash == def->vd_hash) - { - needname = elfsh_get_vernauxname(file, needaux); - - /* The definition as multiple entry, we need a correct one */ - defdata = def; - for (defndx = 0, defoffset = def->vd_aux; - defndx < def->vd_cnt; - defndx++, defoffset += defaux->vda_next) - { - defaux = defdata + defoffset; - - defname = elfsh_get_verdauxname(deffile, defaux); - - /* Check the name */ - if (!strcmp(needname, defname)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, needaux); - - if (defaux->vda_next == 0) - break; - } - } - - if (needaux->vna_next == 0) - break; - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find equivalent entries", NULL); -} - -/** - * Return a Version need entry value for a verneed aux - * @param need verneed entry - * @return aux value - */ -elfsh_Word elfsh_get_verneed_aux(elfsh_Verneed *need) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (need->vn_aux)); -} - -/** - * Set a Version need entry value for a verneed aux - * @param need verneed entry - * @param val new value - */ -int elfsh_set_verneed_aux(elfsh_Verneed *need, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - need->vn_aux = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return a Version need (aux) entry value for count (count) - * @param need verneed entry - * @return count value - */ -elfsh_Half elfsh_get_verneed_cnt(elfsh_Verneed *need) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (need->vn_cnt)); -} - -/** - * Set a Version need entry value for count - * @param need verneed entry - * @param val new value - */ -int elfsh_set_verneed_cnt(elfsh_Verneed *need, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - need->vn_cnt = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need entry vale for file - * @param need verneed entry - * @return file offset on string table - */ -elfsh_Word elfsh_get_verneed_file(elfsh_Verneed *need) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (need->vn_file)); -} - -/** - * Set a Version need entry value for file - * @param need verneed entry - * @param val new value - */ -int elfsh_set_verneed_file(elfsh_Verneed *need, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - need->vn_file = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need (aux) entry value for next (next) normal & parent - * @param p pointer on a verneed or vernaux - * @return next offset value - */ -elfsh_Word elfsh_get_verneed_next(void *p) -{ - elfsh_Verneed *need; - elfsh_Vernaux *aux; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (p == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (version_need == 1) - { - aux = p; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (aux->vna_next)); - } - - need = p; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (need->vn_next)); -} - - -/** - * Set a Version need (aux) entry value for next (next) normal & parent - * @param p pointer on a verneed or vernaux - * @param val new next value - */ -int elfsh_set_verneed_next(void *p, elfsh_Word val) -{ - elfsh_Verneed *need; - elfsh_Vernaux *aux; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (p == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (version_need == 1) - { - aux = p; - aux->vna_next = val; - } - else - { - need = p; - need->vn_next = val; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need (aux) entry value for flags - * @param naux vernaux entry - * @return flag value - */ -elfsh_Half elfsh_get_verneed_flags(elfsh_Vernaux *naux) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (naux->vna_flags)); -} - -/** - * Set a Version need (aux) entry value for flags - * @param naux vernaux entry - * @param val new flag value - */ -int elfsh_set_verneed_flags(elfsh_Vernaux *naux, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - naux->vna_flags = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need (aux) entry value for hash - * @param naux vernaux entry - * @return hash value - */ -elfsh_Word elfsh_get_verneed_hash(elfsh_Vernaux *naux) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (naux->vna_hash)); -} - -/** - * Set a Version need (aux) entry value for hash - * @param naux vernaux entry - * @param val new hash value - */ -int elfsh_set_verneed_hash(elfsh_Vernaux *naux, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - naux->vna_hash = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need (aux) entry value for name - * @param naux vernaux entry - * @return name value - */ -elfsh_Word elfsh_get_verneed_name(elfsh_Vernaux *naux) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (naux->vna_name)); -} - -/** - * Set a Version need (aux) entry value for name - * @param naux vernaux entry - * @param val new name value - */ -int elfsh_set_verneed_name(elfsh_Vernaux *naux, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - naux->vna_name = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version need (aux) entry value for other (index) - * @param naux vernaux entry - * @return index value - */ -elfsh_Half elfsh_get_verneed_ndx(elfsh_Vernaux *naux) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (naux->vna_other)); -} - - -/** - * Set a Version need (aux) entry value for other (index) - * @param naux vernaux entry - * @param val new index value - */ -int elfsh_set_verneed_ndx(elfsh_Vernaux *naux, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_need != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (naux == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - naux->vna_other = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Get Version need by name - * @param file target file - * @param name verneed entry name - * @return verneed entry - */ -elfsh_Verneed *elfsh_get_verneed_by_name(elfshobj_t *file, char *name) -{ - elfsh_Verneed *table; - char *filename; - u_int offset = 0; - int versize; - void *ps; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - ps = elfsh_get_verneedtab(file, &versize); - if (ps == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get VERNEED", NULL); - - version_need = 2; - - do - { - table = ps + offset; - - filename = elfsh_get_verneedfile(file, table); - - if (!strcmp(name, filename)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (table)); - - if (table->vn_next == NULL) - break; - - offset += table->vn_next; - } while (table != NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Get Version need by index (aux) - * @param ps verneed or vernaux pointer - * @param index index to search - * @return vernaux entry - */ -elfsh_Vernaux *elfsh_get_verneed_entry_by_index(void *ps, - elfsh_Half index) -{ - elfsh_Verneed *table; - elfsh_Vernaux *tableaux; - u_int i, offset = 0, auxset = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - version_need = 1; - - do - { - table = ps + offset; - - auxset = offset + table->vn_aux; - for(i = 0; i < table->vn_cnt; i++) - { - tableaux = ps + auxset; - - if (tableaux->vna_other == index) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (tableaux)); - - if (tableaux->vna_next == NULL) - break; - - auxset += tableaux->vna_next; - } - if (table->vn_next == NULL) - break; - - offset += table->vn_next; - } while (table != NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Return a Version def entry value for cname (name) [child] - * @param def verdef entry - * @return name value - */ -elfsh_Word elfsh_get_verdef_cname(elfsh_Verdaux *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent <= -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vda_name)); -} - -/** - * Set a Version def entry value for cname (name) [child] - * @param def verdef entry - * @param val new value - */ -int elfsh_set_verdef_cname(elfsh_Verdaux *def, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent <= -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vda_name = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return a Version def entry value for cnext (next) [child] - * @param def verdef entry - * @return next value - */ -elfsh_Word elfsh_get_verdef_cnext(elfsh_Verdaux *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent <= -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vda_next)); -} - -/** - * Set a Version def entry value for cnext (next) [child] - * @param def verdef entry - * @param val new next value - */ -int elfsh_set_verdef_cnext(elfsh_Verdaux *def, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent <= -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vda_next = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for next (next) normal & aux - * @param p verdef or verdaux pointer - * @return next value - */ -elfsh_Word elfsh_get_verdef_next(void *p) -{ - elfsh_Verdef *def; - elfsh_Verdaux *aux; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (p == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (version_parent > -1) - { - aux = p; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (aux->vda_next)); - } - - def = p; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_next)); -} - -/** - * Set a Version def entry value for next (next) normal & aux - * @param p verdef or verdaux pointer - * @param val new next value - */ -int elfsh_set_verdef_next(void *p, elfsh_Word val) -{ - elfsh_Verdef *def; - elfsh_Verdaux *aux; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (p == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - if (version_parent > -1) - { - aux = p; - aux->vda_next = val; - } - else - { - def = p; - def->vd_next = val; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for aux (aux) - * @param def verdef entry - * @return aux offset - */ -elfsh_Word elfsh_get_verdef_aux(elfsh_Verdef *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_aux)); -} - -/** - * Set a Version def entry value for aux - * @param def verdef entry - * @param val new aux value - */ -int elfsh_set_verdef_aux(elfsh_Verdef *def, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vd_aux = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for flags - * @param def verdef entry - * @return flag - */ -elfsh_Half elfsh_get_verdef_flags(elfsh_Verdef *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_flags)); -} - -/** - * Set a Version def entry value for flags (flags) - * @param def verdef entry - * @param val new flag value - */ -int elfsh_set_verdef_flags(elfsh_Verdef *def, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vd_flags = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for hash (hash) - * @param def verdef entry - * @return hash value - */ -elfsh_Word elfsh_get_verdef_hash(elfsh_Verdef *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_hash)); -} - -/** - * Set a Version def entry value for hash - * @param def verdef entry - * @parma val new hash value - */ -int elfsh_set_verdef_hash(elfsh_Verdef *def, elfsh_Word val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vd_hash = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for cnt (count) - * @param def verdef entry - * @return count value - */ -elfsh_Half elfsh_get_verdef_cnt(elfsh_Verdef *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_cnt)); -} - -/** - * Set a Version def entry value for cnt (count) - * @param def verdef entry - * @param val set count value - */ -int elfsh_set_verdef_cnt(elfsh_Verdef *def, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vd_cnt = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Return a Version def entry value for ndx (index) - * @param def verdef entry - * @return index value - */ -elfsh_Half elfsh_get_verdef_ndx(elfsh_Verdef *def) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (def->vd_ndx)); -} - - -/** - * Set a Version def entry value for ndx (index) - * @param def verdef entry - * @param val new index value - */ -int elfsh_set_verdef_ndx(elfsh_Verdef *def, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (version_parent > -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L2 request object", -1); - - if (def == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - def->vd_ndx = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Get Version def by index - * @param ps verdef or verdaux pointer - * @param index index to search - * @param return verdef or verdaux which correspond - */ -void *elfsh_get_verdef_entry_by_index(void *ps, - elfsh_Half index) -{ - elfsh_Verdef *table; - elfsh_Verdaux *tableaux; - u_int i = 0, offset = 0, auxset = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - do - { - table = ps + offset; - - if (table->vd_ndx == index && version_parent <= -1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (table)); - - if (table->vd_ndx == version_parent && version_parent > -1) - { - auxset = offset + table->vd_aux; - for(i = 0; i <= index; i++) - { - tableaux = ps + auxset; - - if (i >= index) - break; - - if (tableaux->vda_next == NULL) - break; - - auxset += tableaux->vda_next; - } - - if (i != index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Subindex not found", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (tableaux)); - } - - if (table->vd_next == NULL) - break; - - offset += table->vd_next; - } while (table != NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Get Version symbols by index - * @param s versym base - * @parma index versym index - * @return versym entry - */ -elfsh_Half *elfsh_get_versym_entry_by_index(elfsh_Half *s, - u_int index) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (s + index)); -} - - -/** - * Return a Version symbol entry value - * @param sym versym entry - * @return versym value - */ -elfsh_Half elfsh_get_versym_val(elfsh_Half *sym) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (*sym)); -} - - -/** - * Set a Version symbol entry value - * @param sym versym entry - * @param val new versym value - */ -int elfsh_set_versym_val(elfsh_Half *sym, elfsh_Half val) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - *sym = val; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Return the version symbol entry giving its name - * @param file target file - * @param name symbol name - * @return symbol entry - */ -elfsh_Half *elfsh_get_versym_by_name(elfshobj_t *file, char *name) -{ - elfsh_Sym *ret; - void *versym; - elfsh_Half *verh; - int index; - int size = 0, versize = 0; - char *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file == NULL || name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - ret = elfsh_get_dynsymtab(file, &size); - if (ret == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get DYNSYM", NULL); - - versym = elfsh_get_versymtab(file, &versize); - if (versym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get VERSSYM", NULL); - - verh = versym; - for (index = 0; index < size; index++) - { - actual = elfsh_get_dynsymbol_name(file, ret + index); - if (actual && !strcmp(actual, name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (verh + index)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found", NULL); -} - - -/** - * Build name list of verdaux entries - * @param file file target - * @param hdef a created def entry - * @param names where names will be store - * @param numnames table size - */ -int elfsh_get_verdauxnamelist(elfshobj_t *file, - hashdef_t *hdef, - char **names, - int numnames) -{ - elfsh_Verdaux *table; - void *ps; - u_int dindex; - u_int offset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ps = hdef->ps; - offset = (u_int) hdef->aux; - for (dindex = 0; dindex < numnames; dindex++) - names[dindex] = NULL; - - for (dindex = 0; dindex < hdef->def->vd_cnt; dindex++) - { - table = ps + offset; - if (dindex < numnames) - names[dindex] = elfsh_get_verdauxname(file, table); - - if (table->vda_next == NULL) - break; - - offset += table->vda_next; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Fill an hashtable for verneed index information - * @param t hash table - * @param ps verneed table pointer - * @param size verneed table size - */ -int elfsh_load_needtable(hash_t *t, void *ps, - u_int size) -{ - elfsh_Verneed *table; - elfsh_Vernaux *tableaux; - hashneed_t *pneed; - u_int offset; - u_int auxset; - u_int index; - u_int aux; - char s_temp[8]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0, offset = 0; offset < size; index++) - { - table = ps + offset; - - auxset = offset + table->vn_aux; - for (aux = 0; aux < table->vn_cnt; aux++) - { - tableaux = ps + auxset; - - snprintf(s_temp, 8, "%u", tableaux->vna_other); - XALLOC(__FILE__, __FUNCTION__, __LINE__,pneed, sizeof(hashneed_t), -1); - pneed->need = table; - pneed->aux = tableaux; - hash_add(t, strdup(s_temp), (void*) pneed); - - if (tableaux->vna_next == 0) - break; - - auxset += tableaux->vna_next; - } - - if (table->vn_next == 0) - break; - - offset += table->vn_next; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Fill an hashtable for verdef index information - * @param t hash table - * @param ps verdef table pointer - * @param size verdef table size - */ -int elfsh_load_deftable(hash_t *t, void *ps, u_int size) -{ - elfsh_Verdef *table; - hashdef_t *pdef; - u_int offset; - u_int index; - char s_temp[8]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (index = 0, offset = 0; offset < size; index++) - { - table = ps + offset; - snprintf(s_temp, 8, "%u", table->vd_ndx); - XALLOC(__FILE__, __FUNCTION__, __LINE__,pdef, sizeof(hashdef_t), -1); - pdef->ps = ps; - pdef->def = table; - pdef->aux = (elfsh_Word *) offset + table->vd_aux; - hash_add(t, strdup(s_temp), (void *) pdef); - - if (table->vd_next == NULL) - break; - offset += table->vd_next; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Get a pointer on the version string table - * @param file file which host version string table - * @return pointer on string table - */ -void *elfsh_get_verstrtable(elfshobj_t *file) -{ - elfshsect_t *dynstr; - int strindex, dnum; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_DYNSTR] == NULL) - { - - dynstr = elfsh_get_section_by_name(file, ELFSH_SECTION_NAME_DYNSTR, - NULL, &strindex, &dnum); - if (dynstr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section not found", NULL); - - if (dynstr->data == NULL) - { - dynstr->data = elfsh_load_section(file, dynstr->shdr); - if (dynstr->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Data section not found", NULL); - } - - file->secthash[ELFSH_SECTION_DYNSTR] = dynstr; - - } - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * Get verneed file string - * @param file target file - * @param n verneed entry - * @return filename string - */ -char *elfsh_get_verneedfile(elfshobj_t *file, elfsh_Verneed *n) -{ - void *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = elfsh_get_verstrtable(file); - if (str == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find STR table for verneedfile", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str + n->vn_file)); -} - -/** - * Get vernaux name string - * @param file target file - * @param a vernaux entry - * @return vernaux name string - */ -char *elfsh_get_vernauxname(elfshobj_t *file, elfsh_Vernaux *a) -{ - void *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = elfsh_get_verstrtable(file); - if (str == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find STR table for verneedfile", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str + a->vna_name)); -} - -/** - * Get verdaux name string - * @param file target file - * @param a verdaux entry - * @return verdaux name string - */ -char *elfsh_get_verdauxname(elfshobj_t *file, elfsh_Verdaux *a) -{ - void *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = elfsh_get_verstrtable(file); - if (str == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find STR table for verdeffile", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str + a->vda_name)); -} - -/** - * Preload versym section and return data pointer - * @param file target file - * @param num filled with entitiy number (optional) - * @return data pointer - */ -void *elfsh_get_versymtab(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (file->secthash[ELFSH_SECTION_GNUVERSYM] == NULL) - { - sect = elfsh_get_section_by_type(file, SHT_GNU_versym, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Symbol Version table", NULL);; - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Symbol Version table", - NULL); - } - - file->secthash[ELFSH_SECTION_GNUVERSYM] = sect; - } - - /* Search number of entry do we get here */ - nbr = file->secthash[ELFSH_SECTION_GNUVERSYM]->shdr->sh_size; - nbr /= sizeof(elfsh_Half); - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERSYM]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * We seek a versym section using a range index. - * This function was introduced after versym support implementation in EXTPLT technique. - * Because now we can have more than one versym in a binary. - * @param file target file - * @param range range index - * @param num set entitie number (optional) - * @return founded section - */ -elfshsect_t *elfsh_get_versymtab_by_range(elfshobj_t *file, eresi_Addr range, - int *num) -{ - elfshsect_t *sect; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = elfsh_get_section_by_type(file, SHT_GNU_versym, range, NULL, NULL, NULL); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Symbol Version table", NULL); - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Symbol Version table", - NULL); - } - - nbr = sect->shdr->sh_size; - nbr /= sizeof(elfsh_Half); - - if (num) - *num = nbr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sect); -} - -/** - * Preload verneed section and return data pointer - * @param file target file - * @param num filled with entitiy number (optional) - * @return data pointer - */ -void *elfsh_get_verneedtab(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - version_need = -1; - - if (file->secthash[ELFSH_SECTION_GNUVERNEED] == NULL) - { - sect = elfsh_get_section_by_type(file, SHT_GNU_verneed, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Needed Version section", NULL); - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Needed Version section", - NULL); - } - - file->secthash[ELFSH_SECTION_GNUVERNEED] = sect; - } - - nbr = file->secthash[ELFSH_SECTION_GNUVERNEED]->shdr->sh_size; - nbr /= sizeof(elfsh_Verneed); - - if (num) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERNEED]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * Preload verdef section and return data pointer - * @param file target file - * @param num filled with entitiy number (optional) - * @return data pointer - */ -void *elfsh_get_verdeftab(elfshobj_t *file, int *num) -{ - elfshsect_t *sect; - int strindex, nbr; - void *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - version_parent = -1; - - if (file->secthash[ELFSH_SECTION_GNUVERDEF] == NULL) - { - sect = elfsh_get_section_by_type(file, SHT_GNU_verdef, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Definition Version section", NULL); - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Definition " - "Version section", NULL); - } - - file->secthash[ELFSH_SECTION_GNUVERDEF] = sect; - } - - nbr = file->secthash[ELFSH_SECTION_GNUVERDEF]->shdr->sh_size; - nbr /= sizeof(elfsh_Verdef); - - if (num != NULL) - *num = nbr; - - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERDEF]); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * Get verdef table only if we found a given index - * @param file target file - * @param range searched index - * @parma set entity number (optional) - * @retrun section element - */ -elfshsect_t *elfsh_get_verdeftab_by_idx(elfshobj_t *file, eresi_Addr range, int *num) -{ - elfsh_Verdef *table; - void *ps; - elfshsect_t *sect; - int strindex, nbr; - u_int offset = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - version_parent = -1; - - sect = elfsh_get_section_by_type(file, SHT_GNU_verdef, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Definition Version section", NULL); - - if (sect->data == NULL) - { - sect->data = elfsh_load_section(file, sect->shdr); - if (sect->data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Definition " - "Version section", NULL); - } - - ps = elfsh_get_raw(sect); - - do - { - table = ps + offset; - - if (table->vd_ndx == range) - { - version_parent = range; - break; - } - - if (table->vd_next == NULL) - break; - - offset += table->vd_next; - } while(table != NULL); - - nbr = sect->shdr->sh_size; - nbr /= sizeof(elfsh_Verdef); - *num = nbr; - - if (version_parent == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data for Definition " - "Version section with index", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sect)); -} - diff -Nru eresi-0.8a25/libelfsh/symbol.c eresi-0.0.20110516/libelfsh/symbol.c --- eresi-0.8a25/libelfsh/symbol.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/symbol.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,15 +1,16 @@ /** - * @file symbol.c +* @file libelfsh/symbol.c * @ingroup libelfsh * symbol.c for libelfsh * * Started on Mon Feb 26 04:11:46 2001 jfv * - * $Id: symbol.c,v 1.17 2008-02-16 12:32:27 thor Exp $ + * $Id: symbol.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libelfsh.h" + #define ELFSH_SYMTAB_HASH_NAME "elfsh_symtab_hashbyname" /** @@ -114,8 +115,8 @@ new_len = strlen(name); /* Do not allocate new place if possible */ - if (len >= new_len) - strcpy(str, name); + if (len > new_len) + strncpy(str, name, new_len + 1); /* Append the name to .strtab */ else s->st_name = elfsh_insert_in_strtab(file, name); @@ -210,6 +211,7 @@ int num; int index; char *str; + int best; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -222,7 +224,7 @@ "Invalid NULL parameter", NULL); /* handle dynamic case */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) value -= file->rhdr.base; /* If there is no symtab, resolve using SHT */ @@ -242,19 +244,22 @@ elfsh_sync_sorted_symtab(file->secthash[ELFSH_SECTION_SYMTAB]); sorted = file->secthash[ELFSH_SECTION_SYMTAB]->altdata; - for (index = 0; index < num; index++) - if (sorted[index].st_value <= value && DUMPABLE(sorted + index) && - (index + 1 >= num || sorted[index + 1].st_value > value)) - { - *offset = (elfsh_SAddr) (value - sorted[index].st_value); - - str = elfsh_get_symbol_name(file, sorted + index); - if (!*str) - str = NULL; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (str)); - } + /* Now find the best symbol -- type is more important than offset */ + for (str = NULL, best = index = 0; index < num; index++) + if (sorted[index].st_value <= value && DUMPABLE(sorted + index)) + { + if (best && !BESTYPE(sorted + index, sorted + best)) + continue; + + *offset = (elfsh_SAddr) (value - sorted[index].st_value); + best = index; + str = elfsh_get_symbol_name(file, sorted + index); + if (!*str) + str = NULL; + } + if (str) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, str); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No valid symbol interval", NULL); } @@ -273,12 +278,17 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + // THIS FUNCTION IS DISABLED (TEST) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (file == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", -1); - hash_init(&file->symhash, ELFSH_SYMHASH_NAME, 100, ASPECT_TYPE_UNKNOW); - hash_init(&file->dynsymhash, ELFSH_DYNSYMHASH_NAME, 100, ASPECT_TYPE_UNKNOW); + printf("Init symbol hash tables ! \n"); + + hash_init(&file->symhash, ELFSH_SYMHASH_NAME, 100, ASPECT_TYPE_INT); + hash_init(&file->dynsymhash, ELFSH_DYNSYMHASH_NAME, 100, ASPECT_TYPE_INT); /* Symtab */ if (elfsh_get_symtab(file, &size)) @@ -350,16 +360,17 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get SYMTAB data", NULL); + /* if (file->symhash.ent) { - /* idx is the symbol number in the section */ + //idx is the symbol number in the section idx = (int) hash_get(&file->symhash, name); #if __DEBUG_HASH_BY_NAME__ printf("[DEBUG_HASH_BY_NAME] SYM HASH Search by name for %s => %d\n", name, idx); #else - /* Check if idx is in the section */ +//Check if idx is in the section if (idx <= 0 || idx >= sect->shdr->sh_size) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Symbol not found", NULL); @@ -367,6 +378,7 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (sym + idx)); #endif } +*/ for (idx = 0; idx < size; idx++) @@ -519,7 +531,7 @@ } if (uptable && uptable->ent) - hash_add(uptable, strdup(name), (void *) (index / sizeof(elfsh_Sym))); + hash_add(uptable, strdup(name), (void *) index); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_name); } @@ -692,7 +704,6 @@ int ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - new = elfsh_create_symbol(sect->shdr->sh_addr, sect->curend, STT_SECTION, STB_LOCAL, 0, sect->index); ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], diff -Nru eresi-0.8a25/libelfsh/sym_common.c eresi-0.0.20110516/libelfsh/sym_common.c --- eresi-0.8a25/libelfsh/sym_common.c 2008-04-06 23:15:37.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/sym_common.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,16 +1,15 @@ /** - * @file sym_common.c +* @file libelfsh/sym_common.c * @ingroup libelfsh * sym_common.c for elfsh * * Started on Tue Dec 31 10:19:01 2002 jfv * * - * $Id: sym_common.c,v 1.13 2008-02-16 12:32:27 thor Exp $ + * $Id: sym_common.c 1398 2009-09-13 07:00:08Z may $ * */ #include "libelfsh.h" -#include "libetrace.h" /** * Return the symbol size @@ -230,7 +229,7 @@ dynsym = elfsh_get_dynsymtab(file, &dynum); /* ET_DYN objects have a relative addressing inside the ELF file */ - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) vaddr -= file->rhdr.base; res = elfsh_get_sym_by_value(dynsym, dynum, vaddr, off, mode); @@ -332,7 +331,7 @@ enew.st_info = ELFSH_ST_INFO(binding, type); enew.st_other = vis; enew.st_shndx = sctidx; - enew.st_name = NULL; + enew.st_name = NULL; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (enew)); } @@ -403,6 +402,7 @@ eresi_Addr vaddr, elfsh_SAddr *off) { elfshsect_t *parent; + char *name; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -415,10 +415,17 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find parent section", NULL); - if (file->secthash[ELFSH_SECTION_PLT] != NULL && - parent->index == file->secthash[ELFSH_SECTION_PLT]->index) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_reverse_dynsymbol(file, vaddr, off))); + if ((file->secthash[ELFSH_SECTION_PLT] != NULL && + parent->index == file->secthash[ELFSH_SECTION_PLT]->index) || + (file->secthash[ELFSH_SECTION_INIT] != NULL && + parent->index == file->secthash[ELFSH_SECTION_INIT]->index) || + (file->secthash[ELFSH_SECTION_FINI] != NULL && + parent->index == file->secthash[ELFSH_SECTION_FINI]->index)) + { + name = elfsh_reverse_dynsymbol(file, vaddr, off); + if (name) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, name); + } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (elfsh_reverse_symbol(file, vaddr, off))); } @@ -518,13 +525,12 @@ } /** - * If submited function point into the plt, we return the file - * and its virtual address to point to remote function + * @brief Return the file and ivirtual address of looked up imported function. * @param filein base file pointer * @param vaddrin base virtual address * @param fileout returned file pointer * @param vaddrout returned virtual address - * @return + * @return Success (0) or Error (-1). */ int elfsh_resolv_remote_function(elfshobj_t *filein, eresi_Addr vaddrin, elfshobj_t **fileout, eresi_Addr *vaddrout) @@ -568,7 +574,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Can't find symbol name", -1); - file = etrace_search_sym(filein, sym_name); + file = elfsh_symbol_search(filein, sym_name); if (!file) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -587,3 +593,69 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + +/** + * Search a symbol on dependences file + * @param file parent file + * @param name symbol name + * @return file object that containt the symbol (on dynsym) + */ +elfshobj_t *elfsh_symbol_search(elfshobj_t *file, char *name) +{ + char **keys; + int keynbr; + u_int index; + elfshobj_t *child, *find = NULL; + elfsh_Sym *sym; + elfshsect_t *sect; + char *sect_name; + u_int bindnum; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + keys = hash_get_keys(&(file->child_hash), &keynbr); + + if (keys) + { + for (index = 0; index < keynbr; index++) + { + child = (elfshobj_t *) hash_get(&(file->child_hash), keys[index]); + + if (child) + { + sym = elfsh_get_dynsymbol_by_name(child, name); + + if (!sym) + continue; + + bindnum = elfsh_get_symbol_bind(sym); + + /* We need a global or weak symbol */ + if (bindnum == STB_GLOBAL || bindnum == STB_WEAK) + { + sect = elfsh_get_section_by_index(child, sym->st_shndx, NULL, NULL); + + /* The symbol must be local and pointing on sect_name */ + if (sect && (sect_name = elfsh_get_section_name(child, sect)) != NULL + && !strncmp(sect_name, ".text", 5)) + { + find = child; + break; + } + } + } + + /* Search deeper on this child */ + find = elfsh_symbol_search(child, name); + + if (find) + break; + } + } + + hash_free_keys(keys); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, find); +} diff -Nru eresi-0.8a25/libelfsh/vectors_call.c eresi-0.0.20110516/libelfsh/vectors_call.c --- eresi-0.8a25/libelfsh/vectors_call.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/vectors_call.c 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,633 @@ +/** +* @file libelfsh/vectors_call.c +** @ingroup libelfsh +** +** vectors_call.c for libelfsh (The ELF shell library) +** +** API for calling handlers of vectors in libelfsh +** +** $Id: vectors_call.c 1397 2009-09-13 02:19:08Z may $$ +*/ +#include "libelfsh.h" + + + + + +/** + * Call the relocation hook + * @param file + * @param s + * @param r + * @param l + * @param a + * @param m + * @return + */ +int elfsh_rel(elfshobj_t *file, elfshsect_t *s, elfsh_Rel *r, + eresi_Addr *l, eresi_Addr a, elfshsect_t *m) +{ + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + vector_t *rel; + u_int dim[3]; + int (*fct)(elfshsect_t *n, + elfsh_Rel *n2, + eresi_Addr *n3, + eresi_Addr n4, + elfshsect_t *n5); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + rel = aspect_vector_get(ELFSH_HOOK_REL); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "RELOCATION handler unexistant for this ARCH/OS", -1); + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(rel, dim); + ret = fct(s, r, l, a, m); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Relocation handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Call the relocation hook + * @param file + * @param name + * @param old + * @param new + * @return + */ +int elfsh_cflow(elfshobj_t *file, char *name, elfsh_Sym *old, + eresi_Addr new) +{ + vector_t *cflow; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshobj_t *n, char *n2, elfsh_Sym *n3, eresi_Addr n4); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "CFLOW handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(cflow, dim); + ret = fct(file, name, old, new); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Control flow redirection handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Call the PLT hook + * @param file + * @param s + * @param new + * @return + */ +int elfsh_plt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) +{ + vector_t *plt; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshobj_t *f, elfsh_Sym *s, eresi_Addr a); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + plt = aspect_vector_get(ELFSH_HOOK_PLT); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PLT handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(plt, dim); + ret = fct(file, s, new); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PLT redirection handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + +/** + * Call the ENCODEPLT hook + * + * @param file + * @param plt + * @param diff + * @param off + * @return + */ +int elfsh_encodeplt(elfshobj_t *file, elfshsect_t *plt, + eresi_Addr diff, u_int off) +{ + vector_t *encodeplt; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshobj_t *f, elfshsect_t *s, eresi_Addr a, u_int off); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "ENCODEPLT handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(encodeplt, dim); + + ret = fct(file, plt, diff, off); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PLT encoding handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + +/** + * Call the ENCODEPLT1 hook + * + * @param file + * @param plt + * @param extplt + * @param diff + * @return + */ +int elfsh_encodeplt1(elfshobj_t *file, elfshsect_t *plt, + elfshsect_t *extplt, eresi_Addr diff) +{ + vector_t *encodeplt1; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshobj_t *f, elfshsect_t *s, elfshsect_t *s2, + eresi_Addr a); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "ENCODEPLT1 handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(encodeplt1, dim); + ret = fct(file, plt, extplt, diff); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PLT1 encoding handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + +/** + * Call the ALTPLT hook + * + * @param file + * @param s + * @param new + * @return + */ +int elfsh_altplt(elfshobj_t *file, elfsh_Sym *s, eresi_Addr new) +{ + vector_t *altplt; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshobj_t *file, elfsh_Sym *s, eresi_Addr a); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "ALTPLT handler unexistant for this ARCH/OS", -1); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(altplt, dim); + ret = fct(file, s, new); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "ALTPLT redirection handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * Call the EXTPLT hook + * + * @param extplt + * @param altgot + * @param dynsym + * @param relplt + * @return + */ +int elfsh_extplt(elfshsect_t *extplt, elfshsect_t *altgot, + elfshsect_t *dynsym, elfshsect_t *relplt) +{ + vector_t *vextplt; + u_char archtype; + u_char elftype; + u_char ostype; + int ret; + int (*fct)(elfshsect_t *extplt, elfshsect_t *altgot, + elfshsect_t *dynsym, elfshsect_t *relplt); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + vextplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(extplt->parent); + elftype = elfsh_get_elftype(extplt->parent); + ostype = elfsh_get_ostype(extplt->parent); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "EXTPLT handler unexistant for this ARCH/OS", -1); + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(vextplt, dim); + ret = fct(extplt, altgot, dynsym, relplt); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "EXTPLT redirection handler failed", (-1)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * Call the arg count hook + * + * @param file + * @param off + * @param vaddr + * @return + */ +int *elfsh_args_count(elfshobj_t *file, u_int off, eresi_Addr vaddr) +{ + vector_t *argch; + u_char archtype; + u_char elftype; + u_char ostype; + int *(*fct)(elfshobj_t *file, u_int off, eresi_Addr vaddr); + u_int dim[3]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + argch = aspect_vector_get(ELFSH_HOOK_ARGC); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + elftype = elfsh_get_elftype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + elftype == ELFSH_FILE_ERROR || + ostype == ELFSH_OS_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "ARGC handler unexistant for this ARCH/OS", NULL); + + dim[0] = archtype; + dim[1] = elftype; + dim[2] = ostype; + fct = aspect_vectors_select(argch, dim); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, fct(file, off, vaddr)); +} + + + +/** + * @brief Read the analysed object memory + * @param sect Section to be analysed + * @return size on success, -1 on error + */ +void *elfsh_readmem(elfshsect_t *sect) +{ + void *ret; + u_int dim[2]; + vector_t *mem; + void *(*fct)(); + u_char archtype; + u_char iotype; + u_char ostype; + elfshobj_t *file; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!sect || !sect->parent) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", NULL); + file = sect->parent; + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + iotype = elfsh_get_iotype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + ostype == ELFSH_OS_ERROR || + iotype == ELFSH_IOTYPE_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "READMEM handler inexistant for this ARCH/OS", NULL); + mem = aspect_vector_get(ELFSH_HOOK_READMEM); + dim[0] = ostype; + dim[1] = iotype; + fct = aspect_vectors_select(mem, dim); +/* printf("dim[0]: %d, dim[1]: %d, fct: %p curobj->name: %s\n", dim[0], dim[1], fct, file->name); */ +/* fflush(stdout); */ + ret = fct(sect); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * @brief Read the analysed object memory + * @param file File to read data from. + * @param addr Virtual Address in file to read data. + * @return A pointer on the read data + */ +void *elfsh_readmema(elfshobj_t *file, eresi_Addr addr, void *buf, u_int size) +{ + void *ret; + u_int dim[2]; + vector_t *mem; + void *(*fct)(); + u_char iotype; + u_char ostype; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!file) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", NULL); + + /* Fingerprint binary */ + iotype = elfsh_get_iotype(file); + ostype = elfsh_get_ostype(file); + if (ostype == ELFSH_OS_ERROR || + iotype == ELFSH_IOTYPE_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "READMEM handler inexistant for this ARCH/OS", NULL); + mem = aspect_vector_get(ELFSH_HOOK_READMEMA); + dim[0] = ostype; + dim[1] = iotype; + fct = aspect_vectors_select(mem, dim); + ret = fct(file, addr, buf, size); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * @brief Write into analyzed object memory + * @param offset Offset to write memory + * @param buf Write buf into memory + * @param size Count bytes to write + * @return Written size on success, -1 on error. + */ +int elfsh_writemem(elfshobj_t *file, eresi_Addr addr, void *buf, u_int size) +{ + int ret; + u_int dim[2]; + vector_t *mem; + int (*fct)(); + u_char archtype; + u_char iotype; + u_char ostype; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!file || !addr || !buf || size <= 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid input parameters", -1); + + /* Fingerprint binary */ + archtype = elfsh_get_archtype(file); + iotype = elfsh_get_iotype(file); + ostype = elfsh_get_ostype(file); + if (archtype == ELFSH_ARCH_ERROR || + ostype == ELFSH_OS_ERROR || + iotype == ELFSH_IOTYPE_ERROR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "READMEM handler inexistant for this ARCH/OS", NULL); + mem = aspect_vector_get(ELFSH_HOOK_WRITEMEM); + dim[0] = ostype; + dim[1] = iotype; + fct = aspect_vectors_select(mem, dim); + ret = fct(file, addr, buf, size); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * @brief Write in raw memory at indicated file offset + * @param file The elf object + * @param foffset Offset to write memory + * @param src_buff Write buf into memoryr + * @param len Count bytes to write + * @return len on success, -1 on error + */ +int elfsh_writememf(elfshobj_t *file, u_int foffset, void *src_buff, int len) +{ + int ret; + u_int dim[2]; + vector_t *mem; + int (*fct)(); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + mem = aspect_vector_get(ELFSH_HOOK_WRITEMEMF); + dim[0] = elfsh_get_hosttype(file); + dim[1] = elfsh_get_mode(); + fct = aspect_vectors_select(mem, dim); + ret = fct(file, foffset, src_buff, len); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + +/** + * @brief Read raw memory at indicated file offset + * @param file The elf object + * @param foffset Offset to read memory + * @param dest_buff Read memory into the buf + * @param len Count bytes to read + * @return len on success, -1 on error + */ +int elfsh_readmemf(elfshobj_t *file, u_int foffset, void *dest_buff, int len) +{ + int ret; + u_int dim[2]; + vector_t *mem; + int (*fct)(); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + mem = aspect_vector_get(ELFSH_HOOK_READMEMF); + dim[0] = elfsh_get_hosttype(file); + dim[1] = elfsh_get_mode(); + fct = aspect_vectors_select(mem, dim); + ret = fct(file, foffset, dest_buff, len); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + +/** + * @brief Map a new area in memory + * @param memsz How much memory to allocate + * @param prot Which rights (in ELF format) to put on the allocated memory + * @return The address where the data has been allocated + */ +eresi_Addr elfsh_runtime_map(elfshobj_t *file, u_int memsz, int prot) +{ + eresi_Addr addr; + u_int dim[2]; + vector_t *mem; + int (*fct)(); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Wont map memory in static mode", ELFSH_INVALID_ADDR); + + mem = aspect_vector_get(ELFSH_HOOK_ALLOC); + dim[0] = elfsh_get_hosttype(file); + fct = aspect_vectors_select(mem, dim); + addr = fct(file, memsz, prot); + +#if __DEBUG_RUNTIME__ + printf("[DEBUG_RUNTIME] Section Mapped at addr "XFMT" (%u) with prot %c%c%c\n", + addr, memsz, + ((prot & PF_R) ? 'R' : '-'), + ((prot & PF_W) ? 'W' : '-'), + ((prot & PF_X) ? 'X' : '-')); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (addr)); +} + + + + +/** + * @brief Remove memory credentials. + * @param file Parent file we are working on. + * @param memsz Minimum memory size to restore protection for. + * @param prot Protection to put for memory. + * @return Success (0) or Error (-1). + */ +int elfsh_mprotect(elfshobj_t *file, eresi_Addr addr, u_int memsz, int prot) +{ + u_int dim[2]; + vector_t *mprot; + int (*fct)(); + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Wont mprotect in static mode", -1); + + mprot = aspect_vector_get(ELFSH_HOOK_MPROTECT); + dim[0] = elfsh_get_hosttype(file); + fct = aspect_vectors_select(mprot, dim); + ret = fct(file, addr, memsz, prot); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} + + + + +/** + * @brief Restore memory credentials. + * @param file Parent file we are working on. + * @param memsz Minimum memory size to restore protection for. + * @param prot Protection to put for memory. + * @return Success (0) or Error (-1). + */ +int elfsh_munprotect(elfshobj_t *file, eresi_Addr addr, u_int memsz) +{ + u_int dim[2]; + vector_t *mprot; + int (*fct)(); + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Wont munprotect in static mode", -1); + + mprot = aspect_vector_get(ELFSH_HOOK_MUNPROTECT); + dim[0] = elfsh_get_hosttype(file); + fct = aspect_vectors_select(mprot, dim); + ret = fct(file, addr, memsz); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} diff -Nru eresi-0.8a25/libelfsh/vectors_default.c eresi-0.0.20110516/libelfsh/vectors_default.c --- eresi-0.8a25/libelfsh/vectors_default.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/vectors_default.c 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,182 @@ +/** +* @file libelfsh/vectors_default.c +** @ingroup libelfsh +** +** vectors_default.c for libelfsh (The ELF shell library) +** +** Default handlers for elfsh hooked functionalities +** +** $Id: vectors_default.c 1435 2010-12-11 06:16:51Z may $$ +** +*/ +#include "libelfsh.h" + + +void *elfsh_default_readmem(elfshsect_t *sect) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", NULL); +} + +int elfsh_default_readmema(elfshobj_t *obj, eresi_Addr addr, void *buf, u_int size) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +int elfsh_default_writemem(elfshobj_t *file, eresi_Addr addr, void *buff, u_int size) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + + +int elfsh_default_writememf(elfshobj_t *file, u_int off, char *buff, int len) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +int elfsh_default_readmemf(elfshobj_t *file, u_int off, char *buff, int len) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + + +/** + * @brief Default hooks handlers + */ +int elfsh_default_plthandler(elfshobj_t *null, + elfsh_Sym *null2, + eresi_Addr null3) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +/** + * @brief Default PLT encoding handler. + */ +int elfsh_default_encodeplthandler(elfshobj_t *file, + elfshsect_t *sect, + eresi_Addr diff) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +/** + * @brief Default first entry PLT encoding handler. + */ +int elfsh_default_encodeplt1handler(elfshobj_t *file, + elfshsect_t *sect, + elfshsect_t *sect2, + eresi_Addr diff) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +/** + * @brief Default relocation handler. + */ +int elfsh_default_relhandler(elfshsect_t *null, + elfsh_Rel * null2, + eresi_Addr * null3, + eresi_Addr null4, + elfshsect_t *null5) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +/** + * @brief Default control flow redirection handler. + */ +int elfsh_default_cflowhandler(elfshobj_t *null, + char *nulls, + elfsh_Sym *null2, + eresi_Addr null3) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + + +/** + * @brief Default EXTPLT handler. + */ +int elfsh_default_extplthandler(elfshsect_t *o, elfshsect_t *d, + elfshsect_t *t, elfshsect_t *f) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", -1); +} + +/** + * @brief Default ALTPLT handler. + * Used on architectures where altplt hijack is not required, thus induces no fatal error + * DO NOT use this as a default handler, unless you know exactly what you are doing + */ +int elfsh_void_altplthandler(elfshobj_t *null, + elfsh_Sym *null2, + eresi_Addr null3) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @brief Default MPROTECT handler + * Used in kernel context where mprotect is not required, thus induces no fatal error + * DO NOT use this as a default handler, unless you know exactly what you are doing + */ +int elfsh_void_mprotecthandler(elfshobj_t *obj, eresi_Addr addr, uint32_t sz, int prot) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @brief Default MUNPROTECT handler. + * Used on architectures where altplt hijack is not required, thus induces no fatal error + * DO NOT use this as a default handler, unless you know exactly what you are doing + */ +int elfsh_void_munprotecthandler(elfshobj_t *obj, eresi_Addr addr, uint32_t sz) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @brief Default argument counting handler. + */ +int *elfsh_default_argchandler(eresi_Addr addr) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", NULL); +} + +/** + * @brief Default runtime memory mapping handler. + */ +eresi_Addr elfsh_default_rmaphandler(elfshobj_t *file, size_t size, int prot) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported Arch, ELF type, or OS", ELFSH_INVALID_ADDR); +} + diff -Nru eresi-0.8a25/libelfsh/vectors_fetch.c eresi-0.0.20110516/libelfsh/vectors_fetch.c --- eresi-0.8a25/libelfsh/vectors_fetch.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/vectors_fetch.c 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,298 @@ +/** +* @file libelfsh/vectors_fetch.c +** @ingroup libelfsh +** +** vectors_fetch.c for libelfsh (The ELF shell library) +** +** API for fetching handlers from vectors of libelfsh +** +** $Id: vectors_fetch.c 1397 2009-09-13 02:19:08Z may $$ +*/ +#include "libelfsh.h" + +static hash_t interp_hash; +static u_char elfsh_ostype[5] = { + ELFOSABI_LINUX, + ELFOSABI_FREEBSD, + ELFOSABI_NETBSD, + ELFOSABI_OPENBSD, + ELFOSABI_SOLARIS, +}; + + +/** + * Translate ELF architecture type into ELFsh architecture type + * + * @param file + * @return + */ +u_char elfsh_get_archtype(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (file == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid file argument!", (ELFSH_ARCH_ERROR)); + + switch (elfsh_get_arch(file->hdr)) + { + case EM_386: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA32)); + case EM_SPARC: + case EM_SPARC32PLUS: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC32)); + case EM_SPARCV9: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_SPARC64)); + case EM_PARISC: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PARISC)); + case EM_IA_64: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_IA64)); + case EM_PPC: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC32)); + case EM_PPC64: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_PPC64)); + case EM_ALPHA: +#if EM_ALPHA != EM_ALPHA_EXP + case EM_ALPHA_EXP: +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ALPHA64)); + case EM_MIPS: + case EM_MIPS_RS3_LE: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_MIPS32)); + case EM_ARM: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ARM)); + case EM_X86_64: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_AMD64)); + default: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_ARCH_ERROR)); + } +} + + +/** + * Translate ELF object type into ELFsh object type + * @param file + * @return + */ +u_char elfsh_get_elftype(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (elfsh_get_objtype(file->hdr)) + { + case ET_EXEC: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_FILE_EXEC)); + case ET_DYN: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_FILE_LIB)); + default: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_FILE_ERROR)); + } +} + +/** + * Return IO type associated with this file + * @param file + * @return + */ +u_char elfsh_get_iotype(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file->iotype); +} + + +/** + * Retreive ELFsh OS type from ELF header + * @param file + * @return + */ +u_char elfsh_get_real_ostype(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (file->hdr->e_ident[EI_OSABI]) + { + case ELFOSABI_LINUX: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_LINUX)); + case ELFOSABI_FREEBSD: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_FREEBSD)); + case ELFOSABI_NETBSD: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_NETBSD)); + case ELFOSABI_OPENBSD: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_OPENBSD)); + case ELFOSABI_SOLARIS: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_SOLARIS)); + case ELFOSABI_ARM: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_ARM)); + case 0: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + default: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_OS_ERROR)); + } +} + + +/** + * @brief Retreive the host type for a file + * @param file The working file. + * @return Host type for the file. + */ +u_char elfsh_get_hosttype(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, file->hostype); +} + + +/** + * Fill up ELFsh Operating System type + * + * @param file + * @return + */ +u_char elfsh_get_ostype(elfshobj_t *file) +{ + u_char *res; + char *interp; + char *end; + char r; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* First try */ + r = elfsh_get_real_ostype(file); + switch (r) + { + /* Information not present */ + case 0: + break; + default: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (r)); + } + + /* Smart intermediate way, fingerprint by .interp section */ + /* Not aware of any other software using this technique */ + if (elfsh_get_interp(file)) + { + if (!interp_hash.size) + { + hash_init(&interp_hash, "interpreters", 10, ASPECT_TYPE_STR); + hash_add(&interp_hash, + "/lib/ld-linux.so", + &elfsh_ostype[ELFSH_OS_LINUX]); + hash_add(&interp_hash, + "/usr/libexec/ld-elf.so", + &elfsh_ostype[ELFSH_OS_FREEBSD]); + hash_add(&interp_hash, + "/usr/libexec/ld-eld_so", + &elfsh_ostype[ELFSH_OS_NETBSD]); + hash_add(&interp_hash, + "??????????????", + &elfsh_ostype[ELFSH_OS_OPENBSD]); + hash_add(&interp_hash, + "/usr/lib/ld.so", + &elfsh_ostype[ELFSH_OS_SOLARIS]); + + } + + + /* Only useful for objects with .interp section */ + /* e.g. : ET_EXEC, and some special ET_DYN like libc */ + /* Cannot use elfsh_readmem / elfsh_get_raw because we might have a reentrancy problem + or even the runtime base address might not yet be filled if we are called by the debugger */ + interp = (char *) file->secthash[ELFSH_SECTION_INTERP]->data; + end = strstr(".so", interp); + if (end) + *(end + 3) = 0x00; + res = hash_get(&interp_hash, interp); + if (res) + { + file->hdr->e_ident[EI_OSABI] = *res; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (elfsh_get_real_ostype(file))); + } + } + + /* Fatalist */ +#if defined(__linux__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_LINUX); +#elif defined(__FreeBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_FREEBSD); +#elif defined(__NetBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_NETBSD); +#elif defined(__OpenBSD__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_OPENBSD); +#elif defined(sun) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_SOLARIS); +#elif defined(__BEOS__) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_BEOS); +#else + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ELFSH_OS_ERROR); +#endif +} + +/** + * Return the page size + * + * @param file + * @return + */ +int elfsh_get_pagesize(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (elfsh_get_archtype(file)) + { + case ELFSH_ARCH_IA32: + case ELFSH_ARCH_MIPS32: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4096); + case ELFSH_ARCH_SPARC32: + case ELFSH_ARCH_SPARC64: + case ELFSH_ARCH_PARISC: + case ELFSH_ARCH_IA64: + case ELFSH_ARCH_ALPHA64: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 8192); + case ELFSH_ARCH_PPC32: + case ELFSH_ARCH_PPC64: + case ELFSH_ARCH_ERROR: + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported architecture", 0); + } +} + +/** + * Return the page size + * + * @param file + * @return + */ +u_int elfsh_get_breaksize(elfshobj_t *file) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (elfsh_get_archtype(file)) + { + case ELFSH_ARCH_IA32: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); + case ELFSH_ARCH_MIPS32: + case ELFSH_ARCH_SPARC32: + case ELFSH_ARCH_SPARC64: + case ELFSH_ARCH_PARISC: + case ELFSH_ARCH_ALPHA64: + case ELFSH_ARCH_PPC32: + case ELFSH_ARCH_PPC64: + case ELFSH_ARCH_ARM: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 4); + case ELFSH_ARCH_IA64: + case ELFSH_ARCH_ERROR: + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unsupported architecture", 0); + } +} + + + + + diff -Nru eresi-0.8a25/libelfsh/vectors_register.c eresi-0.0.20110516/libelfsh/vectors_register.c --- eresi-0.8a25/libelfsh/vectors_register.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/vectors_register.c 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,483 @@ +/** +* @file libelfsh/vectors_register.c +** @ingroup libelfsh +** +** vectors_register.c for libelfsh (The ELF shell library) +** +** API for registering handlers in vectors of Libelfsh +** +** $Id: vectors_register.c 1397 2009-09-13 02:19:08Z may $$ +*/ +#include "libelfsh.h" + + +int elfsh_register_readmemf(u_int hostype, u_int exectype, void *fct) +{ + vector_t *mem; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (hostype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + if (exectype >= LIBELFSH_MODE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid execution Mode", -1); + mem = aspect_vector_get(ELFSH_HOOK_READMEMF); + dim = alloca(sizeof(u_int) * 4); + dim[0] = hostype; + dim[1] = exectype; + aspect_vectors_insert(mem, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +int elfsh_register_writememf(u_int hostype, u_int exectype, void *fct) +{ + vector_t *mem; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (hostype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + if (exectype >= LIBELFSH_MODE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid execution Mode", -1); + mem = aspect_vector_get(ELFSH_HOOK_WRITEMEMF); + dim = alloca(sizeof(u_int) * 4); + dim[0] = hostype; + dim[1] = exectype; + aspect_vectors_insert(mem, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +int elfsh_register_readmem(u_int ostype, u_int devicetype, void *fct) +{ + vector_t *mem; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (devicetype >= ELFSH_IOTYPE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + mem = aspect_vector_get(ELFSH_HOOK_READMEM); + dim = alloca(sizeof(u_int) * 3); + dim[0] = ostype; + dim[1] = devicetype; + aspect_vectors_insert(mem, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +int elfsh_register_readmema(u_int ostype, u_int devicetype, void *fct) +{ + vector_t *mem; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (devicetype >= ELFSH_IOTYPE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + mem = aspect_vector_get(ELFSH_HOOK_READMEMA); + dim = alloca(sizeof(u_int) * 3); + dim[0] = ostype; + dim[1] = devicetype; + aspect_vectors_insert(mem, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +int elfsh_register_writemem(u_int ostype, u_int devicetype, void *fct) + +{ + vector_t *mem; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (devicetype >= ELFSH_IOTYPE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + mem = aspect_vector_get(ELFSH_HOOK_WRITEMEM); + dim = alloca(sizeof(u_int) * 3); + dim[0] = ostype; + dim[1] = devicetype; + aspect_vectors_insert(mem, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Registration handlers + * + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_altplthook(u_char archtype, + u_char objtype, + u_char ostype, + void *fct) +{ + vector_t *altplt; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + altplt = aspect_vector_get(ELFSH_HOOK_ALTPLT); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(altplt, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Register an EXTPLT handler + * + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_extplthook(u_char archtype, + u_char objtype, + u_char ostype, + void *fct) +{ + vector_t *extplt; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + extplt = aspect_vector_get(ELFSH_HOOK_EXTPLT); + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(extplt, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Register an PLT handler + * + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_plthook(u_char archtype, u_char objtype, + u_char ostype, void *fct) +{ + vector_t *plt; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + plt = aspect_vector_get(ELFSH_HOOK_PLT); + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(plt, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Register an ENCODEPLT handler + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_encodeplthook(u_char archtype, u_char objtype, + u_char ostype, void *fct) +{ + vector_t *encodeplt; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + encodeplt = aspect_vector_get(ELFSH_HOOK_ENCODEPLT); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(encodeplt, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Register an ENCODEPLT1 handler + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_encodeplt1hook(u_char archtype, u_char objtype, + u_char ostype, void *fct) +{ + vector_t *encodeplt1; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + encodeplt1 = aspect_vector_get(ELFSH_HOOK_ENCODEPLT1); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(encodeplt1, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Register an ET_REL injection handler + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_relhook(u_char archtype, u_char objtype, u_char ostype, + void *fct) +{ + vector_t *rel; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + rel = aspect_vector_get(ELFSH_HOOK_REL); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(rel, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Register a control flow redirection handler + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_cflowhook(u_char archtype, u_char objtype, + u_char ostype, void *fct) +{ + vector_t *cflow; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + cflow = aspect_vector_get(ELFSH_HOOK_CFLOW); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(cflow, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Register a args counting redirection handler + * @param archtype + * @param objtype + * @param ostype + * @param fct + * @return + */ +int elfsh_register_argchook(u_char archtype, u_char objtype, + u_char ostype, void *fct) +{ + vector_t *argcp; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + argcp = aspect_vector_get(ELFSH_HOOK_ARGC); + + if (archtype >= ELFSH_ARCH_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Architecture type", -1); + if (objtype >= ELFSH_FILE_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Object type", -1); + if (ostype >= ELFSH_OS_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Operating System type", -1); + + dim = alloca(sizeof(u_int) * 4); + dim[0] = archtype; + dim[1] = objtype; + dim[2] = ostype; + aspect_vectors_insert(argcp, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * @brief Register a runtime map vector handler + * @param hostype The host type to register the handler for. + * @param fct The function pointer to register. + * @return Success (0) or Error (-1) + */ +int elfsh_register_allochook(u_char hostype, void *fct) +{ + vector_t *map; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + map = aspect_vector_get(ELFSH_HOOK_ALLOC); + if (hostype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + dim = alloca(sizeof(u_int)); + dim[0] = hostype; + aspect_vectors_insert(map, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * @brief Register a mprotect vector handler + * @param hostype The host type to register the handler for. + * @param fct The function pointer to register. + * @return Success (0) or Error (-1) + */ +int elfsh_register_mprotecthook(u_char hostype, void *fct) +{ + vector_t *mprot; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + mprot = aspect_vector_get(ELFSH_HOOK_MPROTECT); + if (hostype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + dim = alloca(sizeof(u_int)); + dim[0] = hostype; + aspect_vectors_insert(mprot, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * @brief Register a munprotect vector handler + * @param hostype The host type to register the handler for. + * @param fct The function pointer to register. + * @return Success (0) or Error (-1) + */ +int elfsh_register_munprotecthook(u_char hostype, void *fct) +{ + vector_t *munprot; + u_int *dim; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + munprot = aspect_vector_get(ELFSH_HOOK_MUNPROTECT); + if (hostype >= ELFSH_HOST_NUM) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid Host type", -1); + dim = alloca(sizeof(u_int)); + dim[0] = hostype; + aspect_vectors_insert(munprot, dim, (unsigned long) fct); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libelfsh/version.c eresi-0.0.20110516/libelfsh/version.c --- eresi-0.8a25/libelfsh/version.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/libelfsh/version.c 2011-05-16 11:34:54.000000000 +0000 @@ -1,18 +1,14 @@ /** - * @defgroup libelfsh The libelfsh library + * @defgroup libelfsh libelfsh: The ELF shell library. + * @ingroup elfsh */ /** - * @file version.c +* @file libelfsh/version.c * @ingroup libelfsh - * version.c for elfsh - * - * Started Nov 25 2003 jfv - * Last update Nov 25 2003 jfv - * Last update Sep 27 2005 mxatone - * - * - * $Id: version.c,v 1.11 2008-02-16 12:32:27 thor Exp $ + * @brief Implements API for ELF version tables. * + * Started Nov 25 2003 may + * $Id: version.c 1397 2009-09-13 02:19:08Z may $ */ #include "libelfsh.h" @@ -1183,7 +1179,7 @@ } - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_DYNSTR]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_DYNSTR]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); } @@ -1291,7 +1287,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERSYM]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_GNUVERSYM]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); } @@ -1380,7 +1376,7 @@ if (num) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERNEED]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_GNUVERNEED]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); } @@ -1429,7 +1425,7 @@ if (num != NULL) *num = nbr; - ret = elfsh_get_raw(file->secthash[ELFSH_SECTION_GNUVERDEF]); + ret = elfsh_readmem(file->secthash[ELFSH_SECTION_GNUVERDEF]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); } @@ -1469,7 +1465,7 @@ "Version section", NULL); } - ps = elfsh_get_raw(sect); + ps = elfsh_readmem(sect); do { diff -Nru eresi-0.8a25/libetrace/check.c eresi-0.0.20110516/libetrace/check.c --- eresi-0.8a25/libetrace/check.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/check.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,13 +1,13 @@ /** - * @file check.c -** check.c for libetrace +* @file libetrace/check.c +** @ingroup libetrace ** -** @brief check functions, valid faddr or is tracable ? +** @brief check functions, valid faddr or is tracable. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: check.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: check.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -90,7 +90,7 @@ * @param vaddr returned virtual address */ int etrace_valid_faddr(elfshobj_t *file, eresi_Addr addr, - eresi_Addr *vaddr, u_char *dynsym) + eresi_Addr *vaddr, u_char *dynsym) { int retvalue; @@ -112,15 +112,16 @@ /** - * Check if a function can be traced or not - * @param file target file - * @param name function name - * @param vaddr pointer where save the function virtual address - * @param external pointer where save the status internal / external of the function + * @brief Check if a function can be traced or not. + * @param file Target file. + * @param name Function name. + * @param vaddr Pointer where to save the function virtual address. + * @param external Pointer where to save function status (internal / external). + * @return Tracable (0), Untracable (-2) or Error (-1). * @see etrace_tracable_sym */ int etrace_tracable(elfshobj_t *file, char *name, - eresi_Addr *vaddr, u_char *external) + eresi_Addr *vaddr, u_char *external) { elfsh_Sym *symtab, *dynsym; int symnum = 0, dynsymnum = 0; diff -Nru eresi-0.8a25/libetrace/check_untracable.c eresi-0.0.20110516/libetrace/check_untracable.c --- eresi-0.8a25/libetrace/check_untracable.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/check_untracable.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,20 +1,27 @@ /** - * @file check_func.c -** check_func.c for libetrace +* @file libetrace/check_untracable.c +** @ingroup libetrace ** -** @brief All functions that help check, remote untracable content +** @brief All functions that help check, remote untracable content. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: check_untracable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: check_untracable.c 1397 2009-09-13 02:19:08Z may $ ** */ - -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" +/* Hash table of untracable functions */ +hash_t traces_untracable; +u_char untracable_ostype; + + +/** + * @brief Fix this doxygen tag. + * @param name + * @return + */ static int etrace_add_untracable(char *name) { NOPROFILER_IN(); @@ -24,6 +31,12 @@ NOPROFILER_ROUT(0); } +/** + * @brief Fix this doxygen tag. + * @param file + * @param name + * @return + */ int etrace_untracable(elfshobj_t *file, char *name) { u_char ostype; diff -Nru eresi-0.8a25/libetrace/delete.c eresi-0.0.20110516/libetrace/delete.c --- eresi-0.8a25/libetrace/delete.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/delete.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,13 +1,13 @@ /** - * @file delete.c -** delete.c for libetrace +* @file libetrace/delete.c +** @ingroup libetrace ** ** @brief trace deletion function ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: delete.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: delete.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libelfsh.h" @@ -26,7 +26,7 @@ etrace_funcrmall(trace); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, diff -Nru eresi-0.8a25/libetrace/errfunc.c eresi-0.0.20110516/libetrace/errfunc.c --- eresi-0.8a25/libetrace/errfunc.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/errfunc.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,16 +1,14 @@ /** - * @file errfunc.c +* @file libetrace/errfunc.c ** @ingroup libetrace ** -** @brief This file contain one function for error collection +** @brief This file contain one function for error collection. ** ** -** $Id: errfunc.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: errfunc.c 1397 2009-09-13 02:19:08Z may $ ** */ - #include "libetrace.h" -#include "libetrace-extern.h" /** * When an error occur in etrace. This function is used to show buggy function name. @@ -22,3 +20,21 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, last_parsed_function); } + + +/* Start tracing after everything has been injected */ +char *etrace_start_tracing(elfshobj_t *file) +{ + char *buggyfunc; + + profiler_error_reset(); + + + if (traces_run(file, NULL, 0) < 0) + { + buggyfunc = etrace_geterrfunc(); + profiler_error(); + return (buggyfunc); + } + return (NULL); +} diff -Nru eresi-0.8a25/libetrace/func_add.c eresi-0.0.20110516/libetrace/func_add.c --- eresi-0.8a25/libetrace/func_add.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_add.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_add.c -** func_add.c for libetrace +* @file libetrace/func_add.c +** @ingroup libetrace ** -** @brief add function to a trace table +** @brief add function to a trace table. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_add.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_add.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Add the function on the trace table @@ -22,9 +20,9 @@ * @param newtrace allocated structure that describe the trace * @return newtrace pointer or NULL in case of failure */ -elfshtraces_t *etrace_funcadd(char *trace, - char *name, - elfshtraces_t *newtrace) +trace_t *etrace_func_add(char *trace, + char *name, + trace_t *newtrace) { hash_t *table; @@ -34,7 +32,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", NULL); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -49,3 +47,193 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtrace); } + + + +/** + * Add a function on a trace (from commande line) + * @param file Target + * @param name function name + * @param optarg trace name (optional) + */ +int traces_add(elfshobj_t *file, char *name, char **optarg) +{ + trace_t *traces; + edfmtfunc_t *func = NULL; + eresi_Addr vaddr = 0; + u_char external = 0; + char **func_list; + u_int index, traced = 0; + char *trace_name; + int ret; + char *current_name; + eresi_Addr addr = 0; + u_char cont = 0; + u_char multiaddr = 0; + size_t prelen; + elfshsect_t *newsymsect; + elfsh_Sym *symbol; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!name || !name[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Try to match functions with a regex */ + if (trace_match_funcname(file, name, &func_list) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can't match a single function", -1); + + /* Address case + if the function name (always the first) will have the address in its name + else we found a symbol which correspond to the address */ + if (IS_VADDR(name) && strstr(func_list[0], name + 2) != NULL) + sscanf(name + 2, AFMT, &addr); + + trace_name = optarg ? *optarg : NULL; + + /* When we try to match everything */ + multiaddr = TRACE_MATCH_ALL(name); + prelen = strlen(TRACE_PRE_FUNC); + + if (multiaddr) + { + snprintf(buf, BUFSIZ - 1, + "\n\t[*] Start hooking all internal/external functions ...\n"); + aspectworld.profile(buf); + } + + /* Try to add every function */ + for (index = 0; func_list[index] != NULL; index++) + { + external = 0; + vaddr = 0; + cont = 0; + current_name = func_list[index]; + + /* FIXME: A function name containing "." will not be compiled right with gcc */ + if (strstr(current_name, ".") || !PRINTABLE(current_name[0])) + continue; + + /* Can we trace this function */ + if (addr > 0) + ret = etrace_valid_faddr(file, addr, &vaddr, &external); + else + { + /* Multiple address tracing */ + if (multiaddr && !strncmp(TRACE_PRE_FUNC, current_name, prelen)) + { + /* Prepare for a new address function */ + sscanf(current_name + prelen, AFMT, &vaddr); + ret = 0; + } + else + ret = etrace_tracable(file, current_name, &vaddr, &external); + } + + if (ret < 0) + { + buf[0] = 0x00; + switch(ret) + { + case -2: /* Untracable function */ + snprintf(buf, BUFSIZ - 1, + "\t[!] %s is an untracable function on this OS (context specific)\n", + current_name); + cont = 1; + break; + + case -3: /* Not called address */ + snprintf(buf, BUFSIZ - 1, + "\t[!] %s (%s) address will be traced but is never called.\n", + current_name, name); + break; + + case -4: /* Not called address */ + snprintf(buf, BUFSIZ - 1, + "\t[!] %s (%s) address can't be found on entry point section.\n", + current_name, name); + cont = 1; + break; + } + + if (buf[0] != 0x00) + aspectworld.profile(buf); + + if (cont) + continue; + } + + /* Can we trace with libedfmt informations ? */ + if (addr > 0 || vaddr > 0) + { + func = NULL; + + /* Do we need to add the symbol right before hijacking ? */ + symbol = elfsh_get_symbol_by_name(file, current_name); + + if (!symbol) + { + newsymsect = elfsh_get_parent_section(file, addr > 0 ? addr : vaddr, NULL); + + if (!newsymsect) + continue; + + /* Add a new function symbol */ + if (elfsh_insert_funcsym(file, current_name, + addr > 0 ? addr : vaddr, + 0, newsymsect->index) < 0) + continue; + } + else if (!symbol->st_value) /* Invalid symbol */ + continue; + } + + if (!addr) + func = trace_func_debug_get(file, current_name, external); + + /* Create the structure */ + traces = trace_param_create(file, current_name, func, vaddr, external); + + if (!traces) + continue; + + /* Add the function */ + if (etrace_func_add(trace_name, current_name, traces) == NULL) + continue; + + /* To avoid flood we don't display every added function for multiaddr */ + if (!multiaddr) + { + snprintf(buf, BUFSIZ - 1, "\t[*] Added function %s successfully into trace %s\n", + current_name, trace_name ? trace_name : ETRACE_TYPE_DEFAULT); + aspectworld.profile(buf); + } + + traced++; + } + + /* Free allocated table */ + if (index > 0) + XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); + + /* Do we add at least something ? */ + if (traced == 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can't add any founded functions", -1); + + /* We print the sum only */ + if (multiaddr) + { + snprintf(buf, BUFSIZ - 1, "\t[*] Added %d functions successfully into trace %s\n\n", + traced, trace_name ? trace_name : ETRACE_TYPE_DEFAULT); + aspectworld.profile(buf); + } + + /* Free function list */ + XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_disable.c eresi-0.0.20110516/libetrace/func_disable.c --- eresi-0.8a25/libetrace/func_disable.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_disable.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_disable.c -** func_disable.c for libetrace +* @file libetrace/func_disable.c +** @ingroup libetrace ** -** @brief trace table disable functions +** @brief trace table disable functions. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_disable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_disable.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Disable a functions of a trace @@ -22,12 +20,12 @@ */ int etrace_funcdisable(char *trace, char *name) { - elfshtraces_t *ret_trace; + trace_t *ret_trace; hash_t *table; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -61,9 +59,9 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; + trace = ETRACE_TYPE_DEFAULT; - etrace_inittrace(); + etrace_init_trace(); keys = hash_get_keys(&traces_table, &keynbr); @@ -82,3 +80,38 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + + +/** + * Disable a function from a trace + * @param file target + * @param name function name + * @param optarg trace name (optional) + */ +int traces_disable(elfshobj_t *file, char *name, char **optarg) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!strcmp(name, "all")) + { + if (etrace_funcdisableall(optarg ? *optarg : NULL) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Disable all functions failed", -1); + } + else + { + if (etrace_funcdisable(optarg ? *optarg : NULL, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Disable function failed", -1); + } + + snprintf(buf, BUFSIZ - 1, "\t[*] Disabled function %s successfully from trace %s\n\n", + name, optarg && *optarg ? *optarg : ETRACE_TYPE_DEFAULT); + aspectworld.profile(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_enable.c eresi-0.0.20110516/libetrace/func_enable.c --- eresi-0.8a25/libetrace/func_enable.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_enable.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_enable.c -** func_enable.c for libetrace +* @file libetrace/func_enable.c +** @ingroup libetrace ** -** @brief trace table enable functions +** @brief trace table enable functions. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_enable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_enable.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Enable the function from the trace table @@ -22,7 +20,7 @@ */ int etrace_funcenable(char *trace, char *name) { - elfshtraces_t *ret_trace; + trace_t *ret_trace; hash_t *table; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -31,7 +29,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -66,9 +64,9 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; + trace = ETRACE_TYPE_DEFAULT; - etrace_inittrace(); + etrace_init_trace(); keys = hash_get_keys(&traces_table, &keynbr); @@ -87,3 +85,38 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + + +/** + * Enable a function from a trace + * @param file target + * @param name function name + * @param optarg trace name (optional) + */ +int traces_enable(elfshobj_t *file, char *name, char **optarg) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!strcmp(name, "all")) + { + if (etrace_funcenableall(optarg ? *optarg : NULL) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Enable all functions failed", -1); + } + else + { + if (etrace_funcenable(optarg ? *optarg : NULL, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Enable function failed", -1); + } + + snprintf(buf, BUFSIZ - 1, "\t[*] Enabled function %s successfully from trace %s\n\n", + name, optarg && *optarg ? *optarg : ETRACE_TYPE_DEFAULT); + aspectworld.profile(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_exclude.c eresi-0.0.20110516/libetrace/func_exclude.c --- eresi-0.8a25/libetrace/func_exclude.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_exclude.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_exclude.c -** func_exclude.c for libetrace +* @file libetrace/func_exclude.c +** @ingroup libetrace ** ** @brief trace table exclude functions ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_exclude.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_exclude.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -//#include "libetrace-extern.h" + /** * Exclude functions by regex during the last stage @@ -33,7 +31,7 @@ /* Init table if needed */ if (exclude_table.ent == NULL) - hash_init(&exclude_table, ELFSH_TRACES_EXCLUDE_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); + hash_init(&exclude_table, ETRACE_EXCLUDE_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); len = strlen(regstr); snprintf(funcreg, 255, "%s%s%s", @@ -73,3 +71,81 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + +/** + * Exclude functions by regexec during the last stage + * @param file target + * @param freg first reg + * @param oreg others reg list + */ +int traces_exclude(elfshobj_t *file, char *freg, char **oreg) +{ + u_int index; + char buf[BUFSIZ]; + const char pattern[] = "\n\t[*] Exclude function %s successfully\n\n"; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!freg || !freg[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Exclude first argument */ + if (etrace_funcexclude(freg) < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); + + snprintf(buf, BUFSIZ - 1, pattern, freg); + aspectworld.profile(buf); + + if (oreg) + { + for (index = 0; oreg[index] != NULL; index++) + { + if (etrace_funcexclude(oreg[index]) < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); + + snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); + aspectworld.profile(buf); + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Delete excluded functions by regexec during the last stage + * @param file target + * @param freg first reg + * @param oreg others reg list + */ +int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg) +{ + u_int index; + const char pattern[] = "\n\t[*] Delete excluded function %s successfully\n\n"; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!freg || !freg[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + etrace_funcrmexclude(freg); + + snprintf(buf, BUFSIZ - 1, pattern, freg); + aspectworld.profile(buf); + + if (oreg) + { + for (index = 0; oreg[index] != NULL; index++) + { + etrace_funcrmexclude(oreg[index]); + + snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); + aspectworld.profile(buf); + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_match.c eresi-0.0.20110516/libetrace/func_match.c --- eresi-0.8a25/libetrace/func_match.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_match.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,310 @@ +/* +* @file libetrace/func_match.c +** +** Libetrace implementation in the ERESI project. +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: func_match.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libetrace.h" + +/** + * @brief Match a function in a symbol table. + * @param sect Section pointer for symbol table. + * @param num Element number. + * @param preg Reguler expression to use. + * @param func_list Function table. + * @param count Counter pointer (from the table). + * @param get_symname Function ptr to get symbol name. + * @return Success (0) or Error (-1). + */ +static int trace_match_symtab(elfshsect_t *sect, + int num, + regex_t *preg, + char ***func_list, + u_int *count, + char *(*get_symname)(elfshobj_t *f, + elfsh_Sym *s)) +{ + u_int index; + elfsh_Sym *table; + char *name; + char **f_list; + u_int cnum; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Check argument before anything */ + if (!sect || !preg || !func_list || !count || !get_symname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + f_list = *func_list; + cnum = *count; + table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_readmem(sect) : sect->data); + + /* Parse every function */ + for (index = 0; index < num; index++) + { + /* Only functions */ + if (elfsh_get_symbol_type(table + index) != STT_FUNC + || table[index].st_value == 0) + continue; + + name = get_symname(sect->parent, table + index); + + /* Check if this name is valid */ + if (name == NULL || *name == 0) + continue; + + /* We match a function */ + if (regexec(preg, name, 0, 0, 0) == 0) + { + /* Do we need to realloc ? */ + if (((cnum+1) % TRACE_MATCH_ALLOCSTEP) == 0) + { + XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, + sizeof(char*) * (cnum + 1 + TRACE_MATCH_ALLOCSTEP), -1); + + /* Blank new elements */ + memset(&f_list[cnum], 0x00, TRACE_MATCH_ALLOCSTEP*sizeof(char*)); + + /* Update the pointer, data can move during a reallocation */ + *func_list = f_list; + } + + /* Add the function in the table */ + f_list[cnum] = name; + + *count = ++cnum; + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Match functions from an addrtable + * @param func_list function list pointer + * @param count position on the list + */ +int trace_match_addrtable(elfshobj_t *curfile, char ***func_list, u_int *count) +{ + eresi_Addr *alist = NULL; + u_int index; + char **f_list; + u_int cnum; + char tmpstr[256]; + elfsh_Sym *sym; + char *toadd; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!func_list || !count) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + f_list = *func_list; + cnum = *count; + + /* Retrieve all called address in this binary */ + if (elfsh_addr_get_func_list(curfile, &alist) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can't get call function list", -1); + + for (index = 0; alist[index]; index++) + { + sym = elfsh_get_symbol_by_value(curfile, alist[index], + 0, ELFSH_EXACTSYM); + + /* Find a symbol for this address */ + if (sym) + { + toadd = elfsh_get_symbol_name(curfile, sym); + } + else + { + snprintf(tmpstr, 255, TRACE_PRE_FUNC "" AFMT, + alist[index]); + toadd = tmpstr; + } + + /* Do we need to realloc ? */ + if (((cnum+1) % TRACE_MATCH_ALLOCSTEP) == 0) + { + XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, + sizeof(char*) * (cnum + 1 + TRACE_MATCH_ALLOCSTEP), -1); + + /* Blank new elements */ + memset(&f_list[cnum], 0x00, TRACE_MATCH_ALLOCSTEP*sizeof(char*)); + + /* Update the pointer, data can move during a reallocation */ + *func_list = f_list; + } + + /* If its temp string, strdup it */ + if (toadd == tmpstr) + toadd = strdup(tmpstr); + + f_list[cnum] = toadd; + + *count = ++cnum; + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Match a list of function from symbol tables + * @param funcreg Function regex (or not ?) + * @param func_list the final function list + */ +int trace_match_funcname(elfshobj_t *curfile, char *funcname, char ***func_list) +{ + regex_t preg; + char **f_list; + u_int count = 0; + elfshsect_t *sect; + int num; + elfsh_Sym *symtab; + elfsh_Sym *sym; + char funcreg[256]; + char addrname[256]; + size_t len; + eresi_Addr addr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!funcname || !func_list) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + len = strlen(funcname); + + /* We don't want to strip some part of the submited function + but if you find a function/regex of this size (for this purpose) ... */ + if (len > 255) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Function name is too long", -1); + + /* An address ? */ + if (IS_VADDR(funcname)) + { + /* Retrieve the address */ + sscanf(funcname + 2, AFMT, &addr); + + /* Prealloc the list */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); + + sym = elfsh_get_symbol_by_value(curfile, addr, 0, ELFSH_EXACTSYM); + + /* We have a symbol for this address */ + if (sym) + { + f_list[0] = elfsh_get_symbol_name(curfile, sym); + f_list[1] = NULL; + } + else + { + sym = elfsh_get_dynsymbol_by_value(curfile, addr, 0, ELFSH_EXACTSYM); + + /* We have a dynamic symbol for this address */ + if (sym) + { + f_list[0] = elfsh_get_dynsymbol_name(curfile, sym); + f_list[1] = NULL; + } + else + { + TRACE_GET_FUNC_NAME(addrname, 255, funcname); + + f_list[0] = strdup(addrname); + f_list[1] = NULL; + } + } + + goto end; + } + + /* Add ^ and $ if needed, else we will check too many things + For example, someone wanna add "main" function, if we don't + add those symbols, it will match __libc_start_main which is very + special function and that can create problems and make the tracer + useless */ + snprintf(funcreg, 255, "%s%s%s", + funcname[0] != '^' ? "^" : "", + funcname, + funcname[len-1] != '$' ? "$" : ""); + + /* Do we have a regex ? */ + if (regcomp(&preg, funcreg, 0) != 0) + { + XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); + f_list[0] = funcname; + f_list[1] = NULL; + + goto end; + } + + /* Preallocation */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, + sizeof(char*) * TRACE_MATCH_ALLOCSTEP, -1); + + + /* Total match case */ + if (TRACE_MATCH_ALL(funcname)) + { + /* Match everything we can, symbol or not ! */ + trace_match_addrtable(curfile, &f_list, &count); + } + + /** + * Match on symbol table + */ + symtab = elfsh_get_symtab(curfile, &num); + + if (symtab != NULL) + { + sect = elfsh_get_section_by_type(curfile, + SHT_SYMTAB, 0, NULL, NULL, 0); + + /* Match function regex in the symbol table */ + trace_match_symtab(sect, num, &preg, &f_list, &count, elfsh_get_symbol_name); + } + + /** + * Match on dynamic symbol table + */ + symtab = elfsh_get_dynsymtab(curfile, &num); + + if (symtab != NULL) + { + + sect = elfsh_get_section_by_name(curfile, + ELFSH_SECTION_NAME_ALTDYNSYM, + NULL, NULL, &num); + if (!sect) + sect = elfsh_get_section_by_type(curfile, SHT_DYNSYM, 0, + NULL, NULL, &num); + + num /= sizeof(elfsh_Sym); + + /* Match function regex in the dynamic symbol table */ + trace_match_symtab(sect, num, &preg, &f_list, &count, elfsh_get_dynsymbol_name); + } + + /* Do we get something ? */ + if (count == 0) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, f_list); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can't match a single function", -1); + } + + end: + + /* Set final pointer */ + *func_list = f_list; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_remove.c eresi-0.0.20110516/libetrace/func_remove.c --- eresi-0.8a25/libetrace/func_remove.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_remove.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_remove.c -** func_remove.c for libetrace +* @file libetrace/func_remove.c +** @ingroup libetrace ** -** @brief trace table remove functions +** @brief trace table remove functions. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_remove.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_remove.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Delete the function from the trace table @@ -22,7 +20,7 @@ */ int etrace_funcrm(char *trace, char *name) { - elfshtraces_t *ret_trace; + trace_t *ret_trace; hash_t *table; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -31,7 +29,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -58,12 +56,12 @@ char **keys; u_int index; int keynbr; - elfshtraces_t *ret_trace; + trace_t *ret_trace; hash_t *table; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - table = etrace_gettrace(trace); + table = etrace_get(trace); if (!table) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -75,7 +73,7 @@ { for (index = 0; index < keynbr; index++) { - ret_trace = (elfshtraces_t *) hash_get(table, keys[index]); + ret_trace = (trace_t *) hash_get(table, keys[index]); hash_del(table, keys[index]); if (ret_trace) @@ -87,3 +85,32 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + +/** + * Delete a function from a trace + * @param file target + * @param name function name + * @param optarg trace name (optional) + */ +int traces_rm(elfshobj_t *file, char *name, char **optarg) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!name || !name[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + if (etrace_funcrm(optarg ? *optarg : NULL, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Delete function failed", -1); + + snprintf(buf, BUFSIZ - 1, "\t[*] Deleted function %s successfully from trace %s\n\n", + name, optarg && *optarg ? *optarg : ETRACE_TYPE_DEFAULT); + aspectworld.profile(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/func_run.c eresi-0.0.20110516/libetrace/func_run.c --- eresi-0.8a25/libetrace/func_run.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_run.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,33 @@ +/* +* @file libetrace/func_run.c +** +** Libetrace implementation in the ERESI project. +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: func_run.c 1397 2009-09-13 02:19:08Z may $ +** +*/ + +char **traces_lastarg = NULL; + +/** + * Add arguments for a futur traces_run + * @param argc arguments number + * @param argv arguments + * @see traces_run + */ +int trace_param_add(int argc, char **argv) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (argc < 1 || argv == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Copy arguments */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, traces_lastarg, sizeof(char *)*(argc+1), -1); + memcpy(traces_lastarg, argv, sizeof(char*)*argc); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + diff -Nru eresi-0.8a25/libetrace/func_search.c eresi-0.0.20110516/libetrace/func_search.c --- eresi-0.8a25/libetrace/func_search.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_search.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,75 @@ +/* +* @file libetrace/func_search.c +** +** Libetrace header file in the ERESI project +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: func_search.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libetrace.h" + +/** + * Research the uniform debugging format function entry on a list of files + * @param files first element of a edfmtfile_t structure + * @param name function name + * @return pointer on a edfmtfunc_t (represent function debugging information) + */ +edfmtfunc_t *trace_search_unifile(edfmtfile_t *files, char *name) +{ + edfmtfunc_t *func; + edfmtfile_t *file; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (file = files ; file != NULL; file = file->next) + { + func = hash_get(&(file->hfunc), name); + + if (func != NULL) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); + + if (file->child) + { + func = trace_search_unifile(file->child, name); + if (func != NULL) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); +} + +/** + * Research the uniform debugging format function entry + * @param file first element of a edfmtfile_t structure + * @param name function name + * @return pointer on a edfmtfunc_t (represent function debugging information) + */ +edfmtfunc_t *trace_search_uni(elfshobj_t *file, char *name) +{ + edfmtfunc_t *func; + edfmtinfo_t *uni; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + uni = edfmt_get_uniinfo(file); + + if (!uni) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No debugging informations available", NULL); + + /* Search on global scope */ + func = hash_get(&(uni->hfunc), name); + if (func == NULL) + { + /* Search on local stop if needed */ + func = trace_search_unifile(uni->files, name); + if (func == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Function not found", NULL); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); +} + diff -Nru eresi-0.8a25/libetrace/func_status.c eresi-0.0.20110516/libetrace/func_status.c --- eresi-0.8a25/libetrace/func_status.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/func_status.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,17 @@ /** - * @file func_add.c -** func_add.c for libetrace +* @file libetrace/func_status.c +** @ingroup libetrace ** -** @brief add function to a trace table +** @brief add function to a trace table. ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: func_status.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: func_status.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Change the status of a whole trace @@ -27,7 +25,7 @@ u_int index; int keynbr; char **keys; - elfshtraces_t *ret_trace; + trace_t *ret_trace; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -35,7 +33,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); - etrace_inittrace(); + etrace_init_trace(); keys = hash_get_keys(table, &keynbr); @@ -43,7 +41,7 @@ { for (index = 0; index < keynbr; index++) { - ret_trace = (elfshtraces_t *) hash_get(table, keys[index]); + ret_trace = (trace_t *) hash_get(table, keys[index]); if (ret_trace) { diff -Nru eresi-0.8a25/libetrace/include/libetrace-extern.h eresi-0.0.20110516/libetrace/include/libetrace-extern.h --- eresi-0.8a25/libetrace/include/libetrace-extern.h 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/libetrace-extern.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -#ifndef __LIBETRACE_EXTERN_H_ -#define __LIBETRACE_EXTERN_H_ - -extern char *last_parsed_function; -extern trace_used trace_functions[]; -extern int trace_enabled_count; -extern char trace_file_base[]; -#endif diff -Nru eresi-0.8a25/libetrace/include/libetrace.h eresi-0.0.20110516/libetrace/include/libetrace.h --- eresi-0.8a25/libetrace/include/libetrace.h 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/libetrace.h 2011-05-16 11:34:09.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file libetrace.h -** -** Started on Sat Nov 17 12:10:12 2007 eau +* @file libetrace/include/libetrace.h ** +** Libetrace header file in the ERESI project ** -** $Id: libetrace.h,v 1.2 2007-11-29 10:25:02 rival Exp $ +** Started on Sat Nov 17 12:10:12 2007 eau +** $Id: libetrace.h 1397 2009-09-13 02:19:08Z may $ ** */ @@ -13,6 +13,8 @@ #include "libvars.h" +#ifndef __KERNEL__ + #include #include #include @@ -25,16 +27,13 @@ #include #include -//#include "elfsh-libc.h" +#include +#include #if !defined(__OpenBSD__) #include #endif -#include "libaspect.h" -#include "libelfsh.h" -//#include - #ifdef __BEOS__ #include #endif @@ -43,25 +42,34 @@ #define __USE_GNU #endif -#if !defined(__OpenBSD__) -#include +#ifdef __BEOS__ + #include +#elif !defined(__OpenBSD__) + #include #endif -#if !defined(sgi) && !defined(__OpenBSD__) +#if !defined(sgi) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__BEOS__) #include #endif +/* #if defined(__NetBSD__) #include #elif !defined(__OpenBSD__) #include #endif +*/ -#define TRACES_CFLOW 1 -#define TRACES_PLT 2 -#define TRACES_GOT 3 +#endif /* __KERNEL__ */ -char buf[BUFSIZ]; +#include "libaspect.h" +#include "libelfsh.h" +#include "libasm.h" +#include "libedfmt.h" + +#define TRACES_CFLOW 1 +#define TRACES_PLT 2 +#define TRACES_GOT 3 #define TRACE_USED_longjmp 0 #define TRACE_USED__setjmp 1 @@ -73,23 +81,78 @@ #define TRACE_USED_exit 7 #define TRACE_USED_MAX 8 -#define TRACE_UNTRACABLE_NAME "untracable" +#define TRACE_MATCH_ALLOCSTEP 10 + +#define TRACE_UNTRACABLE_NAME "untracable" +#define TRACE_ADDR_TABLE "addrtable" +#define TRACE_PRE_FUNC "func_" +#define ETRACE_TABLE_NAME "etrace_table" +#define ETRACE_EXCLUDE_TABLE_NAME "etrace_exclude_table" +#define ETRACE_PATTERN "traces_%s" +#define REVM_TRACE_REP ".etrace" /* Traces directory */ + + +typedef struct s_trace_used +{ + char *name; + u_char exist; +} trace_used; -typedef struct _trace_used +/** + * Trace structure + */ +typedef struct s_traces_args { - char *name; - u_char exist; -} trace_used, *ptrace_used; - -/* Untracable table */ -hash_t traces_untracable; -u_char untracable_ostype; + char *name; + char *typename; + int size; +} traceargs_t; + + +/** + * Documentation missing. + */ +typedef struct s_traces +{ +#define ETRACE_TYPE_DEFAULT "global" +#define ETRACE_FUNC_SIZE 256 + char funcname[ETRACE_FUNC_SIZE]; + elfshobj_t *file; + u_char enable; + u_int offset; + +#define ELFSH_ARG_INTERN 0 +#define ELFSH_ARG_EXTERN 1 + u_char scope; + +#define ELFSH_ARG_SIZE_BASED 0 +#define ELFSH_ARG_TYPE_BASED 1 + u_char type; + + eresi_Addr vaddr; + +#define ETRACE_MAX_ARGS 20 + traceargs_t arguments[ETRACE_MAX_ARGS]; + u_int argc; +} trace_t; + + +/* Global variables for libetrace */ +extern hash_t traces_table; +extern hash_t exclude_table; +extern char *last_parsed_function; +extern trace_used trace_functions[]; +extern int trace_enabled_count; +extern char trace_file_base[]; +extern hash_t traces_cmd_hash; +extern hash_t cmd_hash; + +#define TRACE_FUNCTIONS_ADD(_name) { #_name, 0 } +#define FUNC_BEGIN(nam) (trace_functions[TRACE_USED_##nam].exist ? "old_" : "") +#define TRACE_GET_FUNC_NAME(_buf, _size, _addr) snprintf(_buf, _size, TRACE_PRE_FUNC "%s", _addr + 2) +#define TRACE_MATCH_ALL(_funcname) (!strcmp(_funcname, ".*")) -#define TRACE_FUNCTIONS_ADD(_name) \ -{ #_name, 0 } -#define FUNC_BEGIN(_name) \ -(trace_functions[TRACE_USED_##_name].exist ? "old_" : "") /* trace_used trace_functions[] = @@ -107,28 +170,19 @@ */ /** - * @brief Store every traces, this table store another hash table for each key - */ -hash_t traces_table; - -/** - * @brief Exclude hash table which contain regex - */ -hash_t exclude_table; - -/** * @brief Whole active elements */ -/* int trace_enabled_count = 0;*/ -#define ELFSH_TRACES_TABLE_NAME "etrace_table" -#define ELFSH_TRACES_EXCLUDE_TABLE_NAME "etrace_exclude_table" -#define ELFSH_TRACES_PATTERN "traces_%s" - -/* traces.c */ -int *etrace_inittrace(); -hash_t *etrace_createtrace(char *trace); -hash_t *etrace_gettrace(char *trace); +/* trace_create.c */ +int *etrace_init_trace(); +hash_t *etrace_create_trace(char *trace); +hash_t *etrace_get(char *trace); +char *etrace_start_tracing(elfshobj_t *file); +trace_t *trace_param_create(elfshobj_t *file, char *name, + edfmtfunc_t *func, eresi_Addr vaddr, + u_char external); +edfmtfunc_t *trace_func_debug_get(elfshobj_t *file, char *func_name, u_char external); + /* check.c */ int etrace_valid_faddr(elfshobj_t *file, eresi_Addr addr, eresi_Addr *vaddr, u_char *dynsym); @@ -138,7 +192,8 @@ int etrace_untracable(elfshobj_t *file, char *name); /* func_add.c */ -elfshtraces_t *etrace_funcadd(char *trace, char *name, elfshtraces_t *newtrace); +trace_t *etrace_func_add(char *trace, char *name, trace_t *newtrace); +int traces_add(elfshobj_t *file, char *name, char **optarg); /* func_remove.c */ int etrace_funcrm(char *trace, char *name); @@ -159,14 +214,23 @@ /* func_status.c */ int etrace_funcsetstatus(hash_t *table, int status); +/* func_match.c */ +int trace_match_funcname(elfshobj_t *file, char *funcname, char ***func_list); +int trace_match_addrtable(elfshobj_t *file, char ***func_list, u_int *count); + +/* func_search.c */ +edfmtfunc_t *trace_search_uni(elfshobj_t *file, char *name); +edfmtfunc_t *trace_search_unifile(edfmtfile_t *files, char *name); + /* delete.c */ int etrace_deletetrace(char *trace); /* save.c */ -int etrace_save(elfshobj_t *file); +int etrace_save_tracing(elfshobj_t *file); +int etrace_save_obj(elfshobj_t *file, char *name); /* search.c */ -elfshobj_t *etrace_search_sym(elfshobj_t *file, char *name); +elfshobj_t *elfsh_symbol_search(elfshobj_t *file, char *name); /* search_addr.c */ int elfsh_addr_get_func_list(elfshobj_t *file, eresi_Addr **addr); @@ -175,4 +239,11 @@ /* errfunc.c */ char *etrace_geterrfunc(); +/* trace_run.c */ +int traces_run(elfshobj_t *file, char **argv, int argc); +int trace_param_add(int argc, char **argv); + +/* trace_list.c */ +int traces_list_detail(hash_t *table, char *name); + #endif diff -Nru eresi-0.8a25/libetrace/include/libetrace-intvars.h eresi-0.0.20110516/libetrace/include/libetrace-intvars.h --- eresi-0.8a25/libetrace/include/libetrace-intvars.h 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/libetrace-intvars.h 2011-05-16 11:34:09.000000000 +0000 @@ -1,3 +1,7 @@ +/** + * @file libetrace/include/libetrace-intvars.h + * @ingroup libetrace + */ #ifndef __LIBETRACE_VARS_H_ #define __LIBETRACE_VARS_H_ diff -Nru eresi-0.8a25/libetrace/include/.svn/all-wcprops eresi-0.0.20110516/libetrace/include/.svn/all-wcprops --- eresi-0.8a25/libetrace/include/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libetrace/include -END -libetrace.h -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/946/trunk/libetrace/include/libetrace.h -END -libetrace-extern.h -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/825/trunk/libetrace/include/libetrace-extern.h -END -libetrace-intvars.h -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/825/trunk/libetrace/include/libetrace-intvars.h -END diff -Nru eresi-0.8a25/libetrace/include/.svn/entries eresi-0.0.20110516/libetrace/include/.svn/entries --- eresi-0.8a25/libetrace/include/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libetrace/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libetrace.h -file - - - - -2008-04-06T23:15:44.227882Z -dfbf49b67b65594339aee9f135075f67 -2008-03-27T22:53:48.747992Z -946 -may - -libetrace-extern.h -file - - - - -2008-04-06T23:15:44.236901Z -24c63524e3bb3e075139b1f07dda4503 -2007-11-28T09:32:07.000000Z -825 -rival - -libetrace-intvars.h -file - - - - -2008-04-06T23:15:44.237877Z -de091a7db4984547cb907477ab1cc6b9 -2007-11-28T09:32:07.000000Z -825 -rival - diff -Nru eresi-0.8a25/libetrace/include/.svn/format eresi-0.0.20110516/libetrace/include/.svn/format --- eresi-0.8a25/libetrace/include/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libetrace/include/.svn/text-base/libetrace-extern.h.svn-base eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace-extern.h.svn-base --- eresi-0.8a25/libetrace/include/.svn/text-base/libetrace-extern.h.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace-extern.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -#ifndef __LIBETRACE_EXTERN_H_ -#define __LIBETRACE_EXTERN_H_ - -extern char *last_parsed_function; -extern trace_used trace_functions[]; -extern int trace_enabled_count; -extern char trace_file_base[]; -#endif diff -Nru eresi-0.8a25/libetrace/include/.svn/text-base/libetrace.h.svn-base eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace.h.svn-base --- eresi-0.8a25/libetrace/include/.svn/text-base/libetrace.h.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,178 +0,0 @@ -/* -** @file libetrace.h -** -** Started on Sat Nov 17 12:10:12 2007 eau -** -** -** $Id: libetrace.h,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#ifndef __LIBETRACE_H_ -#define __LIBETRACE_H_ - -#include "libvars.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include "elfsh-libc.h" - -#if !defined(__OpenBSD__) -#include -#endif - -#include "libaspect.h" -#include "libelfsh.h" -//#include - -#ifdef __BEOS__ -#include -#endif - -#if !defined(__USE_GNU) -#define __USE_GNU -#endif - -#if !defined(__OpenBSD__) -#include -#endif - -#if !defined(sgi) && !defined(__OpenBSD__) -#include -#endif - -#if defined(__NetBSD__) -#include -#elif !defined(__OpenBSD__) -#include -#endif - -#define TRACES_CFLOW 1 -#define TRACES_PLT 2 -#define TRACES_GOT 3 - -char buf[BUFSIZ]; - -#define TRACE_USED_longjmp 0 -#define TRACE_USED__setjmp 1 -#define TRACE_USED_sigaction 2 -#define TRACE_USED_snprintf 3 -#define TRACE_USED_memset 4 -#define TRACE_USED_gettimeofday 5 -#define TRACE_USED_write 6 -#define TRACE_USED_exit 7 -#define TRACE_USED_MAX 8 - -#define TRACE_UNTRACABLE_NAME "untracable" - -typedef struct _trace_used -{ - char *name; - u_char exist; -} trace_used, *ptrace_used; - -/* Untracable table */ -hash_t traces_untracable; -u_char untracable_ostype; - -#define TRACE_FUNCTIONS_ADD(_name) \ -{ #_name, 0 } - -#define FUNC_BEGIN(_name) \ -(trace_functions[TRACE_USED_##_name].exist ? "old_" : "") - -/* -trace_used trace_functions[] = - { - TRACE_FUNCTIONS_ADD(longjmp), - TRACE_FUNCTIONS_ADD(_setjmp), - TRACE_FUNCTIONS_ADD(sigaction), - TRACE_FUNCTIONS_ADD(snprintf), - TRACE_FUNCTIONS_ADD(memset), - TRACE_FUNCTIONS_ADD(gettimeofday), - TRACE_FUNCTIONS_ADD(write), - TRACE_FUNCTIONS_ADD(exit), - { "", 0 } - }; - */ - -/** - * @brief Store every traces, this table store another hash table for each key - */ -hash_t traces_table; - -/** - * @brief Exclude hash table which contain regex - */ -hash_t exclude_table; - -/** - * @brief Whole active elements - */ -/* int trace_enabled_count = 0;*/ - -#define ELFSH_TRACES_TABLE_NAME "etrace_table" -#define ELFSH_TRACES_EXCLUDE_TABLE_NAME "etrace_exclude_table" -#define ELFSH_TRACES_PATTERN "traces_%s" - -/* traces.c */ -int *etrace_inittrace(); -hash_t *etrace_createtrace(char *trace); -hash_t *etrace_gettrace(char *trace); - -/* check.c */ -int etrace_valid_faddr(elfshobj_t *file, eresi_Addr addr, eresi_Addr *vaddr, u_char *dynsym); -int etrace_tracable(elfshobj_t *file, char *name, - eresi_Addr *vaddr, u_char *dynsym); -/* check_untracable.c */ -int etrace_untracable(elfshobj_t *file, char *name); - -/* func_add.c */ -elfshtraces_t *etrace_funcadd(char *trace, char *name, elfshtraces_t *newtrace); - -/* func_remove.c */ -int etrace_funcrm(char *trace, char *name); -int etrace_funcrmall(char *trace); - -/* func_exclude.c */ -int etrace_funcexclude(char *regstr); -int etrace_funcrmexclude(char *regstr); - -/* func_enable.c */ -int etrace_funcenable(char *trace, char *name); -int etrace_funcenableall(char *trace); - -/* func_disable.c */ -int etrace_funcdisable(char *trace, char *name); -int etrace_funcdisableall(char *trace); - -/* func_status.c */ -int etrace_funcsetstatus(hash_t *table, int status); - -/* delete.c */ -int etrace_deletetrace(char *trace); - -/* save.c */ -int etrace_save(elfshobj_t *file); - -/* search.c */ -elfshobj_t *etrace_search_sym(elfshobj_t *file, char *name); - -/* search_addr.c */ -int elfsh_addr_get_func_list(elfshobj_t *file, eresi_Addr **addr); -int elfsh_addr_is_called(elfshobj_t *file, eresi_Addr addr); - -/* errfunc.c */ -char *etrace_geterrfunc(); - -#endif diff -Nru eresi-0.8a25/libetrace/include/.svn/text-base/libetrace-intvars.h.svn-base eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace-intvars.h.svn-base --- eresi-0.8a25/libetrace/include/.svn/text-base/libetrace-intvars.h.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/include/.svn/text-base/libetrace-intvars.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,356 +0,0 @@ -#ifndef __LIBETRACE_VARS_H_ -#define __LIBETRACE_VARS_H_ - -int trace_enabled_count = 0; - -trace_used trace_functions[] = - { - TRACE_FUNCTIONS_ADD(longjmp), - TRACE_FUNCTIONS_ADD(_setjmp), - TRACE_FUNCTIONS_ADD(sigaction), - TRACE_FUNCTIONS_ADD(snprintf), - TRACE_FUNCTIONS_ADD(memset), - TRACE_FUNCTIONS_ADD(gettimeofday), - TRACE_FUNCTIONS_ADD(write), - TRACE_FUNCTIONS_ADD(exit), - { "", 0 } - }; - -/** - * Static part of the file - */ -char trace_file_base[] = "#include \n" -"#include \n" -"#include \n" -"#include \n" -"#include \n" -"#include \n" -"#include \n" -"#include \n" -"\n" -"#define T_longjmp %slongjmp\n" -"#define T_setjmp %s_setjmp\n" -"\n" -"#define T_sigaction %ssigaction\n" -"#define T_snprintf %ssnprintf\n" -"#define T_memset %smemset\n" -"#define T_gettimeofday %sgettimeofday\n" -"#define T_write %swrite\n" -"#define T_exit %sexit\n" -"\n" -"#define MAX_CHECK_CHAR 3\n" -"#define PRINTABLE(c) (c >= 32 && c <= 126)\n" -"#define STDERR 2\n" -"#define ARG(_size) trace_arg_##_size\n" -"#define WRITENOW() do { T_write(STDERR, logbuf, strlen(logbuf)+1); } while(0)\n" -"#define MAX_CHAR_STR_PRINT 40\n" -"#define STR_REPEAT_CHAR 4\n" -"jmp_buf jBuf;\n" -"#define LOGBUFSIZ 256\n" -"char logbuf[LOGBUFSIZ];\n" -"suseconds_t msec;\n" -"time_t sec;\n" -"u_char siginit = %d;\n" -"u_char no_trace = 0;\n" -"\n" -"#define INITSIGNAL() \\\ndo { if (siginit == 0) { initsignal(); siginit = 1; } } while(0)\n" -"\n" -"static void sigcrash(int signal, siginfo_t *si, void *context)\n" -"{\n" -" snprintf(logbuf, LOGBUFSIZ - 1, \" [!] The tracer received a signal %%s. \"\n" -" \"Currently, the tracer is unable to follow context dependent functions.\\n\"\n" -" \"\\t~> Please check previous functions.\\n\", \n" -" (signal == SIGILL ? \"SIGILL\" : (signal == SIGFPE ? \"SIGFPE\" : \n" -" (signal == SIGBUS ? \"SIGBUS\" : \"SIGSEGV\"))));\n" -" WRITENOW();\n" -" T_exit(-1);\n" -"}\n" -"\n" -"static void initsignal()\n" -"{\n" -" struct sigaction sa;\n" -" \n" -" sa.sa_sigaction = (void *) sigcrash;\n" -" sa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER;\n" -" \n" -" sigemptyset(&sa.sa_mask);\n" -" \n" -" T_sigaction(SIGSEGV, &sa, NULL);\n" -" T_sigaction(SIGFPE, &sa, NULL);\n" -" T_sigaction(SIGILL, &sa, NULL);\n" -" T_sigaction(SIGBUS, &sa, NULL);\n" -"}\n" -"\n" -"static unsigned char is_string(const void *ptr)\n" -"{\n" -" int count;\n" -" char *cptr = (char*) ptr;\n" -" \n" -" for (count = 0; PRINTABLE(cptr[count]) && cptr[count] != 0x00; count++)\n" -" {\n" -" if (count >= MAX_CHECK_CHAR)\n" -" return 1;\n" -" }\n" -"\n" -" return 0;\n" -"}\n" -"\n" -"static void check_ptr_failed(int nSig)\n" -"{\n" -" longjmp(jBuf, 1);\n" -"}\n" -"\n" -"static unsigned char check_read_ptr(const void *ptr, unsigned long size)\n" -"{\n" -" int index;\n" -" char elem;\n" -" struct sigaction sa, segvoldsa, busoldsa;\n" -"\n" -" if (!ptr || size <= 0 || ptr < (void*)0x5000 || ptr == (void *)-1)\n" -" return 0;\n" -"\n" -" if(T_setjmp(jBuf))\n" -" return 0;\n" -"\n" -" sa.sa_handler = (void *) check_ptr_failed;\n" -" sa.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_NODEFER;\n" -" sigemptyset(&sa.sa_mask);\n" -"\n" -" if (T_sigaction(SIGSEGV, &sa, &segvoldsa) < 0)\n" -" return 0;\n" -"\n" -" if (T_sigaction(SIGBUS, &sa, &busoldsa) < 0)\n" -" return 0;\n" -"\n" -" for (index = 0; index < size; index++)\n" -" elem = ((char *)ptr)[index];\n" -"\n" -" T_sigaction(SIGSEGV, &segvoldsa, NULL);\n" -" T_sigaction(SIGBUS, &busoldsa, NULL);\n" -"\n" -" return 1;\n" -"}\n" -"\n" -"static void hex_to_str(const void *ptr)\n" -"{\n" -" int count;\n" -" char *cptr = (char*) ptr;\n" -" unsigned int i;\n" -"\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \" = \");\n" -" WRITENOW();\n" -"\n" -" for (i = 0; i < 4; i++)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"0x%%02x\", cptr[i] & 0xFF);\n" -" WRITENOW();\n" -"\n" -" if (cptr[i] == '\\n')\n" -" {\n" -" \n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \" '\\\\n'\"); \n" -" WRITENOW();\n" -" }\n" -" else if (cptr[i] == '\\r')\n" -" {\n" -" \n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \" '\\\\r'\"); \n" -" WRITENOW();\n" -" }\n" -" else if (cptr[i] == '\\t')\n" -" {\n" -" \n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \" '\\\\t'\"); \n" -" WRITENOW();\n" -" }\n" -" else if (PRINTABLE(cptr[i]))\n" -" {\n" -" T_snprintf(logbuf, BUFSIZ - 1, \" '%%c'\", cptr[i]);\n" -" WRITENOW();\n" -" }\n" -"\n" -" if (i != 3)\n" -" {\n" -" T_snprintf(logbuf, BUFSIZ - 1, \" \");\n" -" WRITENOW();\n" -" }\n" -" }\n" -"}\n" -"\n" -"char pad_str[64];\n" -"int pad_count = 0;\n" -"static char *pad_print(int inc)\n" -"{\n" -" int i;\n" -"\n" -" if (inc == 0 && pad_count >= 2)\n" -" pad_count -= 2;\n" -"\n" -" T_memset(pad_str, ' ', pad_count);\n" -" pad_str[pad_count] = 0;\n" -"\n" -" if (inc == 1 && pad_count <= (0xFFFF - 2))\n" -" pad_count += 2;\n" -"\n" -" return pad_str;\n" -"}\n" -"\n" -"int setup = 0;\n" -"static void gettrace_time()\n" -"{\n" -" double difftime = 0;\n" -" struct timeval now;\n" -"\n" -" T_gettimeofday(&now, NULL);\n" -"\n" -" if (setup == 0)\n" -" {\n" -" msec = now.tv_usec;\n" -" sec = now.tv_sec;\n" -" }\n" -"\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"%%4d.%%06d \", now.tv_sec - sec, now.tv_usec - msec);\n" -" WRITENOW();\n" -"\n" -" if (setup)\n" -" {\n" -" msec = now.tv_usec;\n" -" sec = now.tv_sec;\n" -" }\n" -"\n" -" setup = 1;\n" -"}\n" -"static void func_prstr(char *str)\n" -"{\n" -" unsigned int i, z, count;\n" -"\n" -" for (i = 0; i < MAX_CHAR_STR_PRINT && str[i] != 0x00; i++, count = 0)\n" -" {\n" -" if (str[i+1] == str[i])\n" -" {\n" -" for (count = 0, z = i; z < MAX_CHAR_STR_PRINT && str[z] == str[i]; count++, z++);\n" -"\n" -" if (count >= STR_REPEAT_CHAR)\n" -" i = z - 1;\n" -" }\n" -"\n" -" if (str[i] == '\\n')\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\\n\");\n" -" WRITENOW();\n" -" }\n" -" else if (str[i] == '\\r')\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\\r\");\n" -" WRITENOW();\n" -" }\n" -" else if (str[i] == '\\t')\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\\t\");\n" -" WRITENOW();\n" -" }\n" -" else if (!PRINTABLE(str[i]))\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\\%%d\", (int) (str[i] & 0xFF));\n" -" WRITENOW();\n" -" }\n" -" else\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"%%c\", str[i]);\n" -" WRITENOW();\n" -" }\n" -"\n" -" if (count >= STR_REPEAT_CHAR)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"{%%d times}\", count);\n" -" WRITENOW();\n" -" }\n" -" }\n" -"\n" -" if (i >= MAX_CHAR_STR_PRINT)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"...\"); \n" -" WRITENOW();\n" -" }\n" -"}\n" -"\n" -"static void func_intro(const char *fname)\n" -"{\n" -" INITSIGNAL();\n" -" gettrace_time();\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s + %%s(\", pad_print(1), fname);\n" -" WRITENOW();\n" -"}\n" -"\n" -"static void func_fmtptr(void *ptr, unsigned char readable, unsigned char isstring)\n" -"{\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s0x%%x\", \n" -" readable ? \"*\" : \"\", ptr);\n" -" WRITENOW();\n" -"\n" -" if (isstring)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \" \\\"\");\n" -" WRITENOW(); \n" -"\n" -" func_prstr((char *)ptr);\n" -"\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\"\");\n" -" WRITENOW(); \n" -" }\n" -" else if (readable)\n" -" {\n" -" hex_to_str(ptr);\n" -" }\n" -"}\n" -" \n" -"static void func_argu(void *ptr, unsigned char first, char *tname, char *aname)\n" -"{\n" -" unsigned char readable, isstring = 0;\n" -" readable = check_read_ptr(ptr, MAX_CHECK_CHAR+1);\n" -"\n" -" if (readable)\n" -" isstring = is_string(ptr);\n" -"\n" -" if (!first)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \", \");\n" -" WRITENOW();\n" -" }\n" -" \n" -" if (tname != NULL || aname != NULL)\n" -" {\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s %%s: \", tname, aname);\n" -" WRITENOW();\n" -" }\n" -"\n" -" func_fmtptr(ptr, readable, isstring);\n" -"}\n" -"\n" -"static void func_conclu()\n" -"{\n" -" T_snprintf(logbuf, LOGBUFSIZ - 1, \")\\n%%s\", \"\");\n" -" WRITENOW(); \n" -"}\n" -"\n" -"static void func_retu(const char *fname, void *ret, int t1, int t2)\n" -"{\n" -" unsigned char readable, isstring = 0;\n" -"\n" -" readable = check_read_ptr((void *)ret, MAX_CHECK_CHAR+1);\n" -"\n" -" if (readable)\n" -" isstring = is_string(ret);\n" -"\n" -" gettrace_time();\n" -"\n" -" T_snprintf(logbuf, LOGBUFSIZ -1, \"%%s - %%s = \", pad_print(0), fname);\n" -" WRITENOW();\n" -" func_fmtptr(ret, readable, isstring);\n" -" T_snprintf(logbuf, LOGBUFSIZ -1, \" [time spent=%%d.%%06d]\\n\", t1, t2);\n" -" WRITENOW();\n" -"}\n"; - -char *last_parsed_function = NULL; - -#endif diff -Nru eresi-0.8a25/libetrace/Makefile eresi-0.0.20110516/libetrace/Makefile --- eresi-0.8a25/libetrace/Makefile 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/Makefile 2011-05-16 11:34:09.000000000 +0000 @@ -11,27 +11,32 @@ LD ?= ld RM = rm -f AR = ar rc -CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ +CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 $(EXTRACFLAGS) \ -I../libasm/include/ -I../libaspect/include/ \ - -I../libelfsh/include/ -DERESI32 $(BUILDOP) -CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ + -I../libelfsh/include/ -DERESI32 $(BUILDOP) \ + -I../libedfmt/include/ +CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 $(EXTRACFLAGS) \ -I../libasm/include/ -I../libaspect/include/ \ - -I../libelfsh/include/ -DERESI64 $(BUILDOP) -SRC = errfunc.c save.c search.c search_addr.c delete.c \ + -I../libelfsh/include/ -DERESI64 $(BUILDOP) \ + -I../libedfmt/include/ +SRC = errfunc.c save.c search_addr.c delete.c \ check.c check_untracable.c func_add.c func_remove.c \ func_exclude.c func_enable.c func_disable.c \ - func_status.c traces.c + func_status.c trace_create.c func_search.c \ + trace_list.c trace_flush.c trace_run.c func_match.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) NAME32 = libetrace32 NAME64 = libetrace64 +LDFLAGS = + all : all32 all64 all32 : $(OBJ32) @$(CC) -L../liballocproxy/ \ -lallocproxy -L../libaspect/ -laspect32 -DERESI32 \ - -lelfsh32 -L../libelfsh/ -shared $(OBJ32) -o $(NAME32).so + -L../libelfsh/ -lelfsh32 -shared $(OBJ32) -o $(NAME32).so @$(AR) $(NAME32).a $(OBJ32) @$(RANLIB) $(NAME32).a @$(LD) -r $(OBJ32) -o $(NAME32).o @@ -39,7 +44,7 @@ all64 : $(OBJ64) @$(CC) -L../liballocproxy/ \ -lallocproxy -L../libaspect/ -laspect64 -DERESI64 \ - -lelfsh64 -L../libelfsh/ -shared $(OBJ64) -o $(NAME64).so + -L../libelfsh/ -lelfsh64 -shared $(OBJ64) -o $(NAME64).so @$(AR) $(NAME64).a $(OBJ64) @$(RANLIB) $(NAME64).a @$(LD) -r $(OBJ64) -o $(NAME64).o diff -Nru eresi-0.8a25/libetrace/save.c eresi-0.0.20110516/libetrace/save.c --- eresi-0.8a25/libetrace/save.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/save.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,19 +1,14 @@ /** - * @file save.c -** save.c for libetrace +* @file libetrace/save.c +** @ingroup libetrace ** -** This file contain trace save function +** @brief This file contain trace save function. ** -** -** $Id: save.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: save.c 1397 2009-09-13 02:19:08Z may $ ** */ - #include "libetrace.h" -#include "libetrace-extern.h" -/* This buffers are used to generate the file */ -char bufex[BUFSIZ]; /** * Check if this function name is excluded @@ -81,9 +76,9 @@ } /* Queue pointers */ -elfshtraces_t **trace_queue = NULL; +trace_t **trace_queue = NULL; int queue_count = 0; -#define ELFSH_TRACES_DEFAULT_STEP 20 +#define ETRACE_DEFAULT_STEP 20 int queue_step = 0; /** @@ -91,10 +86,10 @@ * The aglorithm is two differents function then I don't wanna * recheck which function must be traced. * @param elm function to queue - * @see etrace_save_table - * @see etrace_save + * @see etrace_save_tracing_table + * @see etrace_save_tracing */ -static int etrace_queue_add(elfshtraces_t *elm) +static int etrace_queue_add(trace_t *elm) { u_int index; @@ -102,9 +97,9 @@ if (trace_queue == NULL) { - queue_step = ELFSH_TRACES_DEFAULT_STEP; + queue_step = ETRACE_DEFAULT_STEP; XALLOC(__FILE__, __FUNCTION__, __LINE__, trace_queue, - sizeof(elfshtraces_t)*queue_step, -1); + sizeof(trace_t)*queue_step, -1); } else { @@ -116,9 +111,9 @@ "Already added", -1); } - queue_step += ELFSH_TRACES_DEFAULT_STEP; + queue_step += ETRACE_DEFAULT_STEP; XREALLOC(__FILE__, __FUNCTION__, __LINE__, trace_queue, trace_queue, - sizeof(elfshtraces_t)*queue_step, -1); + sizeof(trace_t)*queue_step, -1); } trace_queue[queue_count++] = elm; @@ -149,16 +144,18 @@ * @param file object (target) * @param table a trace hash table */ -static int etrace_save_table(FILE *fp, elfshobj_t *file, hash_t *table) +static int etrace_save_tracing_table(FILE *fp, elfshobj_t *file, hash_t *table) { int z = 0; u_int index; int keynbr; char **keys; - elfshtraces_t *ret_trace; + trace_t *ret_trace; char *start; int ret; u_char typed; + char bufex[BUFSIZ]; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -194,7 +191,7 @@ /* Function arguments */ if (ret_trace->argc > 0) { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) + for (z = 0; z < ret_trace->argc && z < ETRACE_MAX_ARGS; z++) { start = z == 0 ? "" : ", "; @@ -219,7 +216,7 @@ /* Printf arguments */ if (ret_trace->argc > 0) { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) + for (z = 0; z < ret_trace->argc && z < ETRACE_MAX_ARGS; z++) { typed = (ret_trace->type == ELFSH_ARG_TYPE_BASED); @@ -248,7 +245,7 @@ /* Send arguments */ if (ret_trace->argc > 0) { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) + for (z = 0; z < ret_trace->argc && z < ETRACE_MAX_ARGS; z++) { start = z == 0 ? "" : ", "; @@ -282,7 +279,7 @@ * @param file target file that is a copy of the original * @see cmd_save */ -int etrace_save(elfshobj_t *file) +int etrace_save_tracing(elfshobj_t *file) { u_int index; int keynbr; @@ -301,6 +298,7 @@ elfsh_Sym *dst; int err; char *system[6]; + char buf[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -603,7 +601,7 @@ table = hash_get(&traces_table, keys[index]); if (table) - etrace_save_table(fp, file, table); + etrace_save_tracing_table(fp, file, table); } hash_free_keys(keys); @@ -714,3 +712,38 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + + +/** + * @brief Save a binary file on disk for tracing (interface function). + * @param file The file to be traced + * @param name Name for saved file (full path). + * @return Success (0) or Error (-1). + */ +int etrace_save_obj(elfshobj_t *file, char *name) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (file == NULL || file->sht == NULL || file->sectlist == NULL || + (file->pht == NULL && elfsh_get_objtype(file->hdr) != ET_REL)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid elfshobj_t parameter", -1); + + file = elfsh_save_preconds(file); + if (!file) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to prepare file for saving", -1); + + /* Apply awaiting function tracing hooks */ + if (file->hdr->e_type != ET_REL && etrace_save_tracing(file) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Tracing failed", -1); + + if (elfsh_store_obj(file, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to save object", -1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/search_addr.c eresi-0.0.20110516/libetrace/search_addr.c --- eresi-0.8a25/libetrace/search_addr.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/search_addr.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,22 +1,21 @@ /** - * @file func_add.c -** func_add.c for libetrace +* @file libetrace/search_addr.c +** @ingroup libetrace ** ** @brief add function to a trace table ** ** Started Jul 2 2005 00:03:44 mxatone ** ** -** $Id: search_addr.c,v 1.2 2007-11-29 10:25:02 rival Exp $ +** $Id: search_addr.c 1397 2009-09-13 02:19:08Z may $ ** */ -#include "libelfsh.h" -#include "libasm.h" #include "libetrace.h" -#include "libetrace-extern.h" + /** * Setup asm_processor structure correctly + * @param file Pointer to elfsh object. * @param proc pointer to asm_processor structure */ static int etrace_setup_proc(elfshobj_t *file, asm_processor *proc) @@ -36,15 +35,15 @@ case EM_SPARC: case EM_SPARCV9: case EM_SPARC32PLUS: - asm_init_sparc(proc); + asm_init_arch(proc, ASM_PROC_SPARC); break; case EM_386: - asm_init_ia32(proc); + asm_init_arch(proc, ASM_PROC_IA32); break; case EM_MIPS: case EM_MIPS_RS3_LE: case EM_MIPS_X: - asm_init_mips(proc); + asm_init_arch(proc, ASM_PROC_MIPS); break; default: PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -94,11 +93,11 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get an anonymous section", -1); - base = elfsh_get_raw(text); + base = elfsh_readmem(text); len = text->shdr->sh_size; /* Get the virtual address */ - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? + base_vaddr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(text) ? file->rhdr.base + elfsh_get_section_addr(text->shdr) : elfsh_get_section_addr(text->shdr)); @@ -210,11 +209,11 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get an anonymous section", -1); - base = elfsh_get_raw(text); + base = elfsh_readmem(text); len = text->shdr->sh_size; /* Get the virtual address */ - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? + base_vaddr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(text) ? file->rhdr.base + elfsh_get_section_addr(text->shdr) : elfsh_get_section_addr(text->shdr)); diff -Nru eresi-0.8a25/libetrace/search.c eresi-0.0.20110516/libetrace/search.c --- eresi-0.8a25/libetrace/search.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/search.c 2011-05-16 11:34:09.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * @file search.c -** search.c for libetrace -** -** @brief Symbol trace search function -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: search.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" - -/** - * Search a symbol on dependences file - * @param file parent file - * @param name symbol name - * @return file object that containt the symbol (on dynsym) - */ -elfshobj_t *etrace_search_sym(elfshobj_t *file, char *name) -{ - char **keys; - int keynbr; - u_int index; - elfshobj_t *child, *find = NULL; - elfsh_Sym *sym; - elfshsect_t *sect; - char *sect_name; - u_int bindnum; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&(file->child_hash), &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - child = (elfshobj_t *) hash_get(&(file->child_hash), keys[index]); - - if (child) - { - sym = elfsh_get_dynsymbol_by_name(child, name); - - if (!sym) - continue; - - bindnum = elfsh_get_symbol_bind(sym); - - /* We need a global or weak symbol */ - if (bindnum == STB_GLOBAL || bindnum == STB_WEAK) - { - sect = elfsh_get_section_by_index(child, sym->st_shndx, NULL, NULL); - - /* The symbol must be local and pointing on sect_name */ - if (sect && (sect_name = elfsh_get_section_name(child, sect)) != NULL - && !strncmp(sect_name, ".text", 5)) - { - find = child; - break; - } - } - } - - /* Search deeper on this child */ - find = etrace_search_sym(child, name); - - if (find) - break; - } - } - - hash_free_keys(keys); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, find); -} diff -Nru eresi-0.8a25/libetrace/.svn/all-wcprops eresi-0.0.20110516/libetrace/.svn/all-wcprops --- eresi-0.8a25/libetrace/.svn/all-wcprops 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 33 -/svn/!svn/ver/946/trunk/libetrace -END -func_status.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/829/trunk/libetrace/func_status.c -END -save.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libetrace/save.c -END -search_addr.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libetrace/search_addr.c -END -func_enable.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/829/trunk/libetrace/func_enable.c -END -delete.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/829/trunk/libetrace/delete.c -END -func_add.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/829/trunk/libetrace/func_add.c -END -errfunc.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/925/trunk/libetrace/errfunc.c -END -func_exclude.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/829/trunk/libetrace/func_exclude.c -END -search.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/829/trunk/libetrace/search.c -END -func_remove.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/829/trunk/libetrace/func_remove.c -END -check.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/946/trunk/libetrace/check.c -END -check_untracable.c -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/829/trunk/libetrace/check_untracable.c -END -func_disable.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/829/trunk/libetrace/func_disable.c -END -traces.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/829/trunk/libetrace/traces.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/830/trunk/libetrace/Makefile -END diff -Nru eresi-0.8a25/libetrace/.svn/entries eresi-0.0.20110516/libetrace/.svn/entries --- eresi-0.8a25/libetrace/.svn/entries 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libetrace -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -func_status.c -file - - - - -2008-04-06T23:15:44.376899Z -3ad7ff9b1a34f4605dc104a5f06b0f7f -2007-11-29T10:25:02.000000Z -829 -rival - -save.c -file - - - - -2008-04-06T23:15:44.354898Z -861dcc4df6a3c8a949012c8142ddf213 -2008-03-27T22:53:48.747992Z -946 -may - -search_addr.c -file - - - - -2008-04-06T23:15:44.388876Z -a810ca3da7b4c6c86a34bd0482d23cf2 -2008-03-27T22:53:48.747992Z -946 -may - -func_enable.c -file - - - - -2008-04-06T23:15:44.399899Z -44cbf6803dc9ac61c45c2d4a278b10ee -2007-11-29T10:25:02.000000Z -829 -rival - -delete.c -file - - - - -2008-04-06T23:15:44.411641Z -52b348a924260e2b5b43ccbd2685f37d -2007-11-29T10:25:02.000000Z -829 -rival - -include -dir - -func_add.c -file - - - - -2008-04-06T23:15:44.423099Z -43ccb326c09aba8969b4114d72cc9722 -2007-11-29T10:25:02.000000Z -829 -rival - -errfunc.c -file - - - - -2008-04-06T23:15:44.446038Z -302f8e0afa872b43b557207149e9ace3 -2008-03-24T18:25:11.790287Z -925 -enioh - -func_exclude.c -file - - - - -2008-04-06T23:15:44.433899Z -238d73d8f4cb5d3a9b9f28e5c4c3053f -2007-11-29T10:25:02.000000Z -829 -rival - -search.c -file - - - - -2008-04-06T23:15:44.456900Z -111af7dee8746e0652c2f9328e715bd5 -2007-11-29T10:25:02.000000Z -829 -rival - -func_remove.c -file - - - - -2008-04-06T23:15:44.468933Z -15187ad5606732cc439abc7a36c44bfd -2007-11-29T10:25:02.000000Z -829 -rival - -check.c -file - - - - -2008-04-06T23:15:44.491876Z -d556a8833452de76265013f80498db7d -2008-03-27T22:53:48.747992Z -946 -may - -check_untracable.c -file - - - - -2008-04-06T23:15:44.480393Z -c9089e5f451188dfcb7a5089e2ef225a -2007-11-29T10:25:02.000000Z -829 -rival - -func_disable.c -file - - - - -2008-04-06T23:15:44.503251Z -0b95f4fee25ac839db8b187850c0e9ae -2007-11-29T10:25:02.000000Z -829 -rival - -traces.c -file - - - - -2008-04-06T23:15:44.514710Z -deec24beddca7f75c74b6170de900b78 -2007-11-29T10:25:02.000000Z -829 -rival - -Makefile -file - - - - -2008-04-06T23:15:44.526110Z -57901a3e8d852f6cac0169b28ff3da49 -2007-11-29T14:01:56.000000Z -830 -may - diff -Nru eresi-0.8a25/libetrace/.svn/format eresi-0.0.20110516/libetrace/.svn/format --- eresi-0.8a25/libetrace/.svn/format 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libetrace/.svn/text-base/check.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/check.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/check.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/check.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ -/** - * @file check.c -** check.c for libetrace -** -** @brief check functions, valid faddr or is tracable ? -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: check.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" - -/** - * Can we trace this symbol ? - * @param file target file - * @param name function name - * @param symtab symbol table (symtab or dynsym) - * @param num number of symbol on the table - * @param dynsym 0 = symtab 1 = dynsym (internal/external) - * @param vaddr fill symbol virtual address - * @see etrace_tracable - */ -static int etrace_tracable_sym(elfshobj_t *file, char *name, elfsh_Sym *symtab, - int num, u_char dynsym, eresi_Addr *vaddr) -{ - u_int index; - elfshsect_t *sect; - char *sect_name; - char *func_name; - u_char bind; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < num; index++) - { - // Only function symbols - if (elfsh_get_symbol_type(symtab + index) != STT_FUNC) - continue; - - // Retrieve symbol section store into st_value - sect = elfsh_get_parent_section(file, symtab[index].st_value, NULL); - - // Try to get the section using index - if (sect == NULL && symtab[index].st_shndx) - sect = elfsh_get_section_by_index(file, symtab[index].st_shndx, NULL, NULL); - - if (sect == NULL) - continue; - - sect_name = elfsh_get_section_name(file, sect); - - // Only global, plt & text - // Make sure we look at the beginning of the name, including the . - bind = elfsh_get_symbol_bind(symtab + index); - if ((bind != STB_GLOBAL && bind != STB_LOCAL) - || (strncmp(sect_name, ".plt", 4) && strncmp(sect_name, ".text", 5))) - continue; - - // Switch between symbol table and dynamic symbol table - if (!dynsym) - func_name = elfsh_get_symbol_name(file, symtab + index); - else - func_name = elfsh_get_dynsymbol_name(file, symtab + index); - - /* Compare names */ - if (strcmp(name, func_name) != 0) - continue; - - /* Unusable symbol */ - if (symtab[index].st_value == 0) - continue; - - if (vaddr) - *vaddr = symtab[index].st_value; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Function not found", -1); -} - -/** - * Check if a function address is valid or not - * @param file target file - * @param addr function address - * @param vaddr returned virtual address - */ -int etrace_valid_faddr(elfshobj_t *file, eresi_Addr addr, - eresi_Addr *vaddr, u_char *dynsym) -{ - int retvalue; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !addr || !vaddr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Our addr must be called */ - retvalue = elfsh_addr_is_called(file, addr); - - if (retvalue >= 0) - *vaddr = addr; - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, retvalue); -} - - -/** - * Check if a function can be traced or not - * @param file target file - * @param name function name - * @param vaddr pointer where save the function virtual address - * @param external pointer where save the status internal / external of the function - * @see etrace_tracable_sym - */ -int etrace_tracable(elfshobj_t *file, char *name, - eresi_Addr *vaddr, u_char *external) -{ - elfsh_Sym *symtab, *dynsym; - int symnum = 0, dynsymnum = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !name || !vaddr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Some function can't be traced */ - if (etrace_untracable(file, name) == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Untracable function", -2); - - /* Retrieve symbol tables pointer / number */ - symtab = elfsh_get_symtab(file, &symnum); - dynsym = elfsh_get_dynsymtab(file, &dynsymnum); - - if (symnum + dynsymnum <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No symbols found", -1); - - /* sym */ - if (etrace_tracable_sym(file, name, symtab, symnum, 0, vaddr) == 0) - { - if (external) - *external = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* dynsym */ - if (etrace_tracable_sym(file, name, dynsym, dynsymnum, 1, vaddr) == 0) - { - if (external) - *external = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Not tracable", -1); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/check_untracable.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/check_untracable.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/check_untracable.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/check_untracable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/** - * @file check_func.c -** check_func.c for libetrace -** -** @brief All functions that help check, remote untracable content -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: check_untracable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" - -static int etrace_add_untracable(char *name) -{ - NOPROFILER_IN(); - - hash_add(&traces_untracable, strdup(name), (void *)1); - - NOPROFILER_ROUT(0); -} - -int etrace_untracable(elfshobj_t *file, char *name) -{ - u_char ostype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ostype = elfsh_get_ostype(file); - - /* Init the table if needed */ - if (traces_untracable.ent == NULL || ostype != untracable_ostype) - { - if (traces_untracable.ent == NULL) - hash_empty(TRACE_UNTRACABLE_NAME); - - hash_init(&traces_untracable, TRACE_UNTRACABLE_NAME, 11, ASPECT_TYPE_UNKNOW); - - /* Not support printf like functions */ - etrace_add_untracable("printf"); - etrace_add_untracable("fprintf"); - etrace_add_untracable("sprintf"); - etrace_add_untracable("snprintf"); - etrace_add_untracable("vprintf"); - etrace_add_untracable("vfprintf"); - etrace_add_untracable("vsprintf"); - etrace_add_untracable("vsnprintf"); - - /* sscanf use a printf like prototype */ - etrace_add_untracable("scanf"); - etrace_add_untracable("fscanf"); - etrace_add_untracable("sscanf"); - etrace_add_untracable("vscanf"); - etrace_add_untracable("vsscanf"); - etrace_add_untracable("vfscanf"); - - /* ioctl use a printf like prototype */ - etrace_add_untracable("ioctl"); - - if (ostype == ELFSH_OS_LINUX) - { - etrace_add_untracable("__libc_start_main"); - etrace_add_untracable("_start"); - etrace_add_untracable("_init"); - etrace_add_untracable("_fini"); - } - - if (ostype == ELFSH_OS_FREEBSD) - { - // x86 failed on this function - // TODO: correct them - etrace_add_untracable("getcwd"); - } - - untracable_ostype = ostype; - } - - if (hash_get(&traces_untracable, name) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/delete.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/delete.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/delete.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/delete.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -/** - * @file delete.c -** delete.c for libetrace -** -** @brief trace deletion function -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: delete.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" - -/** - * Delete a trace - * @param trace trace name - */ -int etrace_deletetrace(char *trace) -{ - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - etrace_funcrmall(trace); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't found this trace", -1); - - hash_destroy(table); - hash_del(&traces_table, trace); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/errfunc.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/errfunc.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/errfunc.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/errfunc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/** - * @file errfunc.c -** @ingroup libetrace -** -** @brief This file contain one function for error collection -** -** -** $Id: errfunc.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * When an error occur in etrace. This function is used to show buggy function name. - * @return function name - */ -char *etrace_geterrfunc() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, last_parsed_function); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_add.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_add.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_add.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_add.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/** - * @file func_add.c -** func_add.c for libetrace -** -** @brief add function to a trace table -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_add.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Add the function on the trace table - * @param trace trace name - * @param name function name - * @param newtrace allocated structure that describe the trace - * @return newtrace pointer or NULL in case of failure - */ -elfshtraces_t *etrace_funcadd(char *trace, - char *name, - elfshtraces_t *newtrace) -{ - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !newtrace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Trace table not found", NULL); - - if (hash_get(table, name) != NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function already exist", NULL); - - trace_enabled_count++; - hash_add(table, newtrace->funcname, (void *) newtrace); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtrace); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_disable.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_disable.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_disable.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_disable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/** - * @file func_disable.c -** func_disable.c for libetrace -** -** @brief trace table disable functions -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_disable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Disable a functions of a trace - * @param trace trace name - * @param name function name - */ -int etrace_funcdisable(char *trace, char *name) -{ - elfshtraces_t *ret_trace; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Trace table not found", -1); - - ret_trace = hash_get(table, name); - - if (!ret_trace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function not found", -1); - - if (ret_trace->enable != 0) - trace_enabled_count--; - - ret_trace->enable = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Disable all functions of a trace - * @param trace trace name - * @see etrace_funcsettatus - */ -int etrace_funcdisableall(char *trace) -{ - u_int index; - int keynbr; - char **keys; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; - - etrace_inittrace(); - - keys = hash_get_keys(&traces_table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - table = (hash_t *) hash_get(&traces_table, keys[index]); - - if (table) - etrace_funcsetstatus(table, 0); - } - - hash_free_keys(keys); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_enable.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_enable.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_enable.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_enable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -/** - * @file func_enable.c -** func_enable.c for libetrace -** -** @brief trace table enable functions -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_enable.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Enable the function from the trace table - * @param trace trace name - * @param name function name - */ -int etrace_funcenable(char *trace, char *name) -{ - elfshtraces_t *ret_trace; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!trace || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Trace table not found", -1); - - ret_trace = hash_get(table, name); - - if (!ret_trace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function not found", -1); - - if (ret_trace->enable != 1) - trace_enabled_count++; - - ret_trace->enable = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Enable all functions of a trace - * @param trace trace name - * @see etrace_funcsetstatus - */ -int etrace_funcenableall(char *trace) -{ - u_int index; - int keynbr; - char **keys; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; - - etrace_inittrace(); - - keys = hash_get_keys(&traces_table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - table = (hash_t *) hash_get(&traces_table, keys[index]); - - if (table) - etrace_funcsetstatus(table, 1); - } - - hash_free_keys(keys); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_exclude.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_exclude.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_exclude.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_exclude.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/** - * @file func_exclude.c -** func_exclude.c for libetrace -** -** @brief trace table exclude functions -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_exclude.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -//#include "libetrace-extern.h" - -/** - * Exclude functions by regex during the last stage - * @param regstr reg string - */ -int etrace_funcexclude(char *regstr) -{ - char funcreg[256]; - size_t len; - regex_t preg, *set; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!regstr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Init table if needed */ - if (exclude_table.ent == NULL) - hash_init(&exclude_table, ELFSH_TRACES_EXCLUDE_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); - - len = strlen(regstr); - snprintf(funcreg, 255, "%s%s%s", - regstr[0] != '^' ? "^" : "", - regstr, - regstr[len-1] != '$' ? "$" : ""); - - /* Check if its a valid regexec */ - if (regcomp(&preg, funcreg, 0) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid regex", -1); - - /* Alloc and copy our regex */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, set, sizeof(regex_t), -1); - memcpy(set, &preg, sizeof(regex_t)); - - /* Add it to the hash table */ - hash_add(&exclude_table, strdup(regstr), set); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Remove an exclude function by regex during the last stage - * @param regstr reg string - */ -int etrace_funcrmexclude(char *regstr) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!regstr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (exclude_table.ent) - hash_del(&exclude_table, regstr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_remove.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_remove.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_remove.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_remove.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -/** - * @file func_remove.c -** func_remove.c for libetrace -** -** @brief trace table remove functions -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_remove.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Delete the function from the trace table - * @param trace trace name - * @param name function name - */ -int etrace_funcrm(char *trace, char *name) -{ - elfshtraces_t *ret_trace; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Trace table not found", -1); - - ret_trace = hash_get(table, name); - - if (ret_trace) - { - hash_del(table, name); - XFREE(__FILE__, __FUNCTION__, __LINE__, ret_trace); - trace_enabled_count--; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete all functions of a trace - * @param trace trace name - */ -int etrace_funcrmall(char *trace) -{ - char **keys; - u_int index; - int keynbr; - elfshtraces_t *ret_trace; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - table = etrace_gettrace(trace); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Trace table not found", -1); - - keys = hash_get_keys(table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - ret_trace = (elfshtraces_t *) hash_get(table, keys[index]); - hash_del(table, keys[index]); - - if (ret_trace) - XFREE(__FILE__, __FUNCTION__, __LINE__, ret_trace); - } - - hash_free_keys(keys); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/func_status.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/func_status.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/func_status.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/func_status.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -/** - * @file func_add.c -** func_add.c for libetrace -** -** @brief add function to a trace table -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: func_status.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Change the status of a whole trace - * @param table trace hash table - * @param status new status (0 = disable, 1 = enable) - * @see etrace_funcenableall - * @see etrace_funcdisableall - */ -int etrace_funcsetstatus(hash_t *table, int status) -{ - u_int index; - int keynbr; - char **keys; - elfshtraces_t *ret_trace; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - etrace_inittrace(); - - keys = hash_get_keys(table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - ret_trace = (elfshtraces_t *) hash_get(table, keys[index]); - - if (ret_trace) - { - if (ret_trace->enable != status) - { - if (ret_trace->enable == 1) - trace_enabled_count--; - else - trace_enabled_count++; - } - ret_trace->enable = status; - } - } - - hash_free_keys(keys); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -## -## Makefile.am -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## Last update Mon Feb 23 17:22:18 2004 jfv -## - -include ../config.h - -CC ?= gcc -LD ?= ld -RM = rm -f -AR = ar rc -CFLAGS32 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libaspect/include/ \ - -I../libelfsh/include/ -DERESI32 $(BUILDOP) -CFLAGS64 += -Iinclude -Wall -fPIC -g3 -O2 -DELFSH_INTERN \ - -I../libasm/include/ -I../libaspect/include/ \ - -I../libelfsh/include/ -DERESI64 $(BUILDOP) -SRC = errfunc.c save.c search.c search_addr.c delete.c \ - check.c check_untracable.c func_add.c func_remove.c \ - func_exclude.c func_enable.c func_disable.c \ - func_status.c traces.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -NAME32 = libetrace32 -NAME64 = libetrace64 - -all : all32 all64 - -all32 : $(OBJ32) - @$(CC) -L../liballocproxy/ \ - -lallocproxy -L../libaspect/ -laspect32 -DERESI32 \ - -lelfsh32 -L../libelfsh/ -shared $(OBJ32) -o $(NAME32).so - @$(AR) $(NAME32).a $(OBJ32) - @$(RANLIB) $(NAME32).a - @$(LD) -r $(OBJ32) -o $(NAME32).o - -all64 : $(OBJ64) - @$(CC) -L../liballocproxy/ \ - -lallocproxy -L../libaspect/ -laspect64 -DERESI64 \ - -lelfsh64 -L../libelfsh/ -shared $(OBJ64) -o $(NAME64).so - @$(AR) $(NAME64).a $(OBJ64) - @$(RANLIB) $(NAME64).a - @$(LD) -r $(OBJ64) -o $(NAME64).o - -clean : - @$(RM) \#* *\# *~ *.o .\#* include/\#* include/*\# \ - include/*~ include/.\#* include/libelfsh/\#* \ - include/libelfsh/*\# include/libelfsh/*~ \ - include/libelfsh/.\#* - -fclean : clean - @$(RM) *.so *.a - - -docs: - doxygen doc/doxygen.conf - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - diff -Nru eresi-0.8a25/libetrace/.svn/text-base/save.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/save.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/save.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/save.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,716 +0,0 @@ -/** - * @file save.c -** save.c for libetrace -** -** This file contain trace save function -** -** -** $Id: save.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#include "libetrace.h" -#include "libetrace-extern.h" - -/* This buffers are used to generate the file */ -char bufex[BUFSIZ]; - -/** - * Check if this function name is excluded - * @param name function name - */ -static int etrace_check_exclude(char *name) -{ - u_int index; - int keynbr; - char **keys; - regex_t *preg; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (name && exclude_table.ent) - { - keys = hash_get_keys(&exclude_table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - preg = hash_get(&exclude_table, keys[index]); - - if (preg) - { - /* We exclude this function */ - if (regexec(preg, name, 0, 0, 0) == 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - } - - hash_free_keys(keys); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Check every function used on the new module if there already exist or not - * @param file host file - */ -static int elfsh_check_trace_functions(elfshobj_t *file) -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Each used functions */ - for (index = 0; index < TRACE_USED_MAX; index++) - { - /* Check on dynsym table */ - if (elfsh_get_dynsymbol_by_name(file, trace_functions[index].name)) - { - trace_functions[index].exist = 1; - } - else - { - trace_functions[index].exist = 0; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Queue pointers */ -elfshtraces_t **trace_queue = NULL; -int queue_count = 0; -#define ELFSH_TRACES_DEFAULT_STEP 20 -int queue_step = 0; - -/** - * The queue is used to store function that will be traced. - * The aglorithm is two differents function then I don't wanna - * recheck which function must be traced. - * @param elm function to queue - * @see etrace_save_table - * @see etrace_save - */ -static int etrace_queue_add(elfshtraces_t *elm) -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (trace_queue == NULL) - { - queue_step = ELFSH_TRACES_DEFAULT_STEP; - XALLOC(__FILE__, __FUNCTION__, __LINE__, trace_queue, - sizeof(elfshtraces_t)*queue_step, -1); - } - else - { - /* Check if we already have it */ - for (index = 0; index < queue_step && trace_queue[index]; index++) - { - if (!strcmp(elm->funcname, trace_queue[index]->funcname)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Already added", -1); - } - - queue_step += ELFSH_TRACES_DEFAULT_STEP; - XREALLOC(__FILE__, __FUNCTION__, __LINE__, trace_queue, trace_queue, - sizeof(elfshtraces_t)*queue_step, -1); - } - - trace_queue[queue_count++] = elm; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Clean the queue if we setup one - */ -static int etrace_queue_clean() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (trace_queue) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, trace_queue); - trace_queue = NULL; - queue_count = 0; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Generate each function on the file - * @param fp file pointer - * @param file object (target) - * @param table a trace hash table - */ -static int etrace_save_table(FILE *fp, elfshobj_t *file, hash_t *table) -{ - int z = 0; - u_int index; - int keynbr; - char **keys; - elfshtraces_t *ret_trace; - char *start; - int ret; - u_char typed; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(table, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - ret_trace = hash_get(table, keys[index]); - - if (ret_trace && ret_trace->enable && ret_trace->file->id == file->id) - { - /* We have an exclude hash table to check. This way, user has a total control - on traced function using etrace for example. */ - if (etrace_check_exclude(ret_trace->funcname) < 0) - continue; - - /* Add in the queue */ - ret = etrace_queue_add(ret_trace); - - /* Allocation failed */ - if (ret == -1) - break; - - /* Already handled */ - if (ret == -2) - continue; - - snprintf(bufex, BUFSIZ - 1, "int %s_trace(", ret_trace->funcname); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - - /* Function arguments */ - if (ret_trace->argc > 0) - { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) - { - start = z == 0 ? "" : ", "; - - snprintf(bufex, BUFSIZ - 1, "%sARG(%d) a%d", - start, - ret_trace->arguments[z].size, z); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - } - } - - snprintf(bufex, BUFSIZ - 1, - ")\n{\n" - "\tint ret;\n" - "\tstruct timeval before, after;\n" - "\tconst char fname[] = \"%s\";\n\n" - "\tif (!no_trace)\n\t{\n" - "\t\tno_trace = 1;\n" - "\t\tfunc_intro(fname);\n", - ret_trace->funcname); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - - /* Printf arguments */ - if (ret_trace->argc > 0) - { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) - { - typed = (ret_trace->type == ELFSH_ARG_TYPE_BASED); - - snprintf(bufex, BUFSIZ - 1, - "\t\tfunc_argu((void *) a%d.ptr, %d, %s%s%s, %s%s%s);\n", - z, (z == 0), - typed ? "\"" : "", - typed ? ret_trace->arguments[z].typename : "NULL", - typed ? "\"" : "", - typed ? "\"" : "", - typed ? ret_trace->arguments[z].name : "NULL", - typed ? "\"" : "" - ); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - } - } - - snprintf(bufex, BUFSIZ - 1, - "\t\tfunc_conclu();\n" - "\t\tT_gettimeofday(&before, NULL);\n" - "\t\tno_trace = 0;\n" - "\t}\n\tret = old_%s(", - ret_trace->funcname); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - - /* Send arguments */ - if (ret_trace->argc > 0) - { - for (z = 0; z < ret_trace->argc && z < ELFSH_TRACES_MAX_ARGS; z++) - { - start = z == 0 ? "" : ", "; - - snprintf(bufex, BUFSIZ - 1, "%sa%d", start, z); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - } - } - - snprintf(bufex, BUFSIZ - 1, - ");\n" - "\tif (!no_trace)\n\t{\n" - "\t\tno_trace = 1;\n" - "\t\tT_gettimeofday(&after, NULL);\n" - "\t\tfunc_retu(fname, (void *) ret, after.tv_sec - before.tv_sec, " - "after.tv_usec - before.tv_usec);\n" - "\t\tno_trace = 0;\n" - "\t}\n" - "\treturn ret;\n}\n"); - fwrite(bufex, strlen(bufex), sizeof(char), fp); - } - } - - hash_free_keys(keys); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Proceed tracing elements on the file during save cmd - * @param file target file that is a copy of the original - * @see cmd_save - */ -int etrace_save(elfshobj_t *file) -{ - u_int index; - int keynbr; - char **keys; - hash_t *table; - FILE *fp; - char tfname[] = "/tmp/tracingXXXXXX"; - int osize = strlen(tfname) + 3; - char rsofname[50]; - char rtfname[50]; - elfshobj_t *tobj; - int idx; - int rs = 0, fd; - struct stat s; - eresi_Addr addr; - elfsh_Sym *dst; - int err; - char *system[6]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do we will have something to trace ? */ - if (trace_enabled_count <= 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - keys = hash_get_keys(&traces_table, &keynbr); - - if (keys == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get keys and I should", -1); - - fretry: - if (rs > 30) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create temporary file (retry more than 30 times)", - NULL); - rs++; - - // Generate a random temporary name file - fd = mkstemp(tfname); - - if (fd == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create temporary file", NULL); - - fp = fdopen(fd, "w"); - - if (fp == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot read temporary file", NULL); - - // gcc needs rights extentions - snprintf(rtfname, osize, "%s.c", tfname); - snprintf(rsofname, osize, "%s.o", tfname); - - // If one of this two files exists, we retry - if (lstat(rtfname, &s) == 0 - || lstat(rsofname, &s) == 0) - goto fretry; - -#if __DEBUG_TRACES__ - printf("[DEBUG TRACE] Open trace temporary filename: %s\n", tfname); - printf("[DEBUG TRACE] Futur trace filename: %s\n", rtfname); - printf("[DEBUG TRACE] Relocatable filename: %s\n", rsofname); -#endif - - /* Check every used functions */ - elfsh_check_trace_functions(file); - - // Write basic stuff, include headers and - // pad functions (to have a tree like form) - /* - snprintf(buf, BUFSIZ - 1, - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n\n" - "#define T_longjmp %slongjmp\n" - "#define T_setjmp %s_setjmp\n" - "#define T_sigaction %ssigaction\n" - "#define T_snprintf %ssnprintf\n" - "#define T_memset %smemset\n" - "#define T_gettimeofday %sgettimeofday\n" - "#define T_write %swrite\n" - "#define T_exit %sexit\n" - "#define MAX_CHECK_CHAR 3\n" - "#define PRINTABLE(c) (c >= 32 && c <= 126)\n" - "#define STDERR 2\n" - "#define ARG(_size) trace_arg_##_size\n" - "#define WRITENOW() do { T_write(STDERR, logbuf, strlen(logbuf)+1); } while(0)\n" - "#define MAX_CHAR_STR_PRINT 256\n" - "#define STR_REPEAT_CHAR 4\n" - "jmp_buf jBuf;\n" - "#define LOGBUFSIZ 256\n" - "char logbuf[LOGBUFSIZ];\n" - "suseconds_t msec;\n" - "time_t sec;\n" - "u_char siginit = %d;\n" - "u_char no_trace = 0;\n" - "#define INITSIGNAL() \\\ndo { if (siginit == 0) { initsignal(); siginit = 1; } } while(0)\n" - "static void sigcrash(int signal, siginfo_t *si, void *context)\n{\n" - "\tsnprintf(logbuf, LOGBUFSIZ - 1, \n" - "\t\" [!] The tracer received a signal %%s. " - "Currently, the tracer is unable to follow context dependent functions.\\n\"\n" - "\t\"\t~> Please check previous functions.\\n\", " - "(signal == SIGILL ? \"SIGILL\" : (signal == SIGFPE ? \"SIGFPE\" : " - "(signal == SIGBUS ? \"SIGBUS\" : \"SIGSEGV\"))));\n" - "\tWRITENOW();\n" - "\tT_exit(-1);\n" - "}\n\n" - "static void initsignal()\n{\n" - "\tstruct sigaction sa;\n" - "\tsa.sa_sigaction = (void *) sigcrash;\n" - "\tsa.sa_flags = SA_ONSTACK | SA_SIGINFO | SA_NODEFER;\n" - "\tsigemptyset(&sa.sa_mask);\n" - "\tT_sigaction(SIGSEGV, &sa, NULL);\n" - "\tT_sigaction(SIGFPE, &sa, NULL);\n" - "\tT_sigaction(SIGILL, &sa, NULL);\n" - "\tT_sigaction(SIGBUS, &sa, NULL);\n" - "}\n\n" - "static unsigned char is_string(const void *ptr)\n{\n" - "\tint count;\n" - "\tchar *cptr = (char*) ptr;\n\n" - "\tfor (count = 0; PRINTABLE(cptr[count]) && cptr[count] != 0x00; count++)\n\t{\n" - "\t\tif (count >= MAX_CHECK_CHAR)\n" - "\t\t\treturn 1;\n" - "\t}\n\n" - "\treturn 0;\n" - "}\n\n" - "static void check_ptr_failed(int nSig)\n{\n" - "\tlongjmp(jBuf, 1);\n" - "}\n\n" - "static unsigned char check_read_ptr(const void *ptr, unsigned long size)\n{\n" - "\tint index;\n" - "\tchar elem;\n" - "\tstruct sigaction sa, segvoldsa, busoldsa;\n" - "\tif (!ptr || size <= 0 || ptr < (void*)0x5000 || ptr == (void *)-1)\n" - "\t\treturn 0;\n\n" - "\tif(T_setjmp(jBuf))\n" - "\t\treturn 0;\n\n" - "\tsa.sa_handler = (void *) check_ptr_failed;\n" - "\tsa.sa_flags = SA_ONSTACK | SA_RESETHAND | SA_NODEFER;\n" - "\tsigemptyset(&sa.sa_mask);\n" - "\tif (T_sigaction(SIGSEGV, &sa, &segvoldsa) < 0)\n" - "\t\treturn 0;\n" - "\tif (T_sigaction(SIGBUS, &sa, &busoldsa) < 0)\n" - "\t\treturn 0;\n" - "\tfor (index = 0; index < size; index++)\n" - "\t\telem = ((char *)ptr)[index];\n\n" - "\tT_sigaction(SIGSEGV, &segvoldsa, NULL);\n" - "\tT_sigaction(SIGBUS, &busoldsa, NULL);\n" - "\treturn 1;\n" - "}\n\n" - "char tmpbuf[256];\n" - "static char *hex_to_str(const void *ptr)\n{\n" - "\tint count;\n" - "\tchar *cptr = (char*) ptr;\n\n" - "\tT_snprintf(tmpbuf, 255, \"= 0x%%02x 0x%%02x 0x%%02x 0x%%02x\", " - "cptr[0] & 0xFF, cptr[1] & 0xFF, cptr[2] & 0xFF, cptr[3] & 0xFF);\n" - "\treturn tmpbuf;\n" - "}\n\n" - "char pad_str[64];\n" - "int pad_count = 0;\n\n" - "static char *pad_print(int inc)\n{\n" - "\tint i;\n" - "\tif (inc == 0 && pad_count >= 2)\n\t\tpad_count -= 2;\n" - "\t\tT_memset(pad_str, ' ', pad_count);\n" - "\t\tpad_str[pad_count] = 0;\n" - "\tif (inc == 1 && pad_count <= (0xFFFF - 2))\n\t\tpad_count += 2;\n" - "\treturn pad_str;\n}\n\n" - "int setup = 0;\n" - "static void gettrace_time()\n{\n" - "\tdouble difftime = 0;\n" - "\tstruct timeval now;\n" - "\tT_gettimeofday(&now, NULL);\n" - "\tif (setup == 0)\n\t{\n" - "\t\tmsec = now.tv_usec;\n" - "\t\tsec = now.tv_sec;\n" - "\t}\n" - "\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"%%4d.%%06d \", now.tv_sec - sec, now.tv_usec - msec);\n" - "\tWRITENOW();\n" - "\tif (setup)\n\t{\n" - "\t\tmsec = now.tv_usec;\n" - "\t\tsec = now.tv_sec;\n" - "\t}\n" - "\tsetup = 1;\n" - "}\n" - "static void func_prstr(char *str)\n{\n" - "\tunsigned int i, z, count;\n" - "\tfor (i = 0; i < MAX_CHAR_STR_PRINT && str[i] != 0x00; i++, count = 0)\n\t{\n" - "\t\tif (str[i+1] == str[i])\n\t\t{\n" - "\t\t\tfor (count = 0, z = i; z < MAX_CHAR_STR_PRINT && str[z] == str[i]; count++, z++);\n" - "\t\t\tif (count >= STR_REPEAT_CHAR)\n" - "\t\t\t\ti = z - 1;\n" - "\t\t}\n" - "\t\tif (str[i] == '\\n')\n\t\t{\n\t\t\tT_snprintf(logbuf, 255, \"\\\\n\");\n\t\t\tWRITENOW();\n\t\t}\n" - "\t\telse if (str[i] == '\\r')\n\t\t{\n\t\t\t\tT_snprintf(logbuf, 255, \"\\\\r\");\n\t\t\tWRITENOW();\n\t\t}\n" - "\t\telse if (!PRINTABLE(str[i]))\n\t\t{\n\t\t\tT_snprintf(logbuf, 255, \"\\\\%%d\", (int) (str[i] & 0xFF));\n\t\t\tWRITENOW();\n\t\t}\n" - "\t\telse\n\t\t{\n" - "\t\t\tT_snprintf(logbuf, 255, \"%%c\", str[i]);\n" - "\t\t\tWRITENOW();\n" - "\t\t}\n" - "\t\tif (count >= STR_REPEAT_CHAR)\n\t\t{\n" - "\t\t\tT_snprintf(logbuf, 255, \"{%%d times}\", count);\n" - "\t\t\tWRITENOW();\n" - "\t\t}\n" - "\t}\n" - "\tif (i >= MAX_CHAR_STR_PRINT)\n\t{\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"...\");\n" - "\t\tWRITENOW();\n" - "\t}\n" - "}\n" - "static void func_intro(const char *fname)\n{\n" - "\t\n" - "\tINITSIGNAL();\n" - "\tgettrace_time();\n" - "\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s + %%s(\", pad_print(1), fname);\n" - "\tWRITENOW();\n" - "}\n" - "static void func_fmtptr(void *ptr, unsigned char readable, unsigned char isstring)\n{\n" - "\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s0x%%x \", " - "readable ? \"*\" : \"\", " - "ptr);\n" - "\tWRITENOW();\n" - "\tif (isstring)\n\t{\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\"\");\n" - "\t\tWRITENOW();\n" - "\t\tfunc_prstr((char *)ptr);\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"\\\"\");\n" - "\t\tWRITENOW();\n" - "\t}\n" - "\telse if (readable)\n\t{\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s\", hex_to_str(ptr));\n" - "\t\tWRITENOW();\n" - "\t}\n" - "}\n" - "static void func_argu(void *ptr, unsigned char first, char *tname, char *aname)\n{\n" - "\tunsigned char readable, isstring = 0;\n" - "\treadable = check_read_ptr(ptr, MAX_CHECK_CHAR+1);\n" - "\tif (readable)\n\t\tisstring = is_string(ptr);\n" - "\tif (!first)\n\t{\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \", \");\n" - "\t\tWRITENOW();\n" - "\t}\n" - "\tif (tname != NULL || aname != NULL)\n\t{\n" - "\t\tT_snprintf(logbuf, LOGBUFSIZ - 1, \"%%s %%s: \", tname, aname);\n" - "\t\tWRITENOW();\n" - "\t}\n" - "\tfunc_fmtptr(ptr, readable, isstring);\n" - "}\n" - "static void func_conclu()\n{\n" - "\tT_snprintf(logbuf, LOGBUFSIZ - 1, \")\\n%%s\", \"\");\n" - "\tWRITENOW();\n" - "}\n" - "static void func_retu(const char *fname, void *ret, int t1, int t2)\n{\n" - "\tunsigned char readable, isstring = 0;\n" - "\treadable = check_read_ptr((void *)ret, MAX_CHECK_CHAR+1);\n" - "\tif (readable)\n\t\tisstring = is_string(ret);\n" - "\tgettrace_time();\n" - "\tT_snprintf(logbuf, LOGBUFSIZ -1, \"%%s - %%s = \", " - "pad_print(0), " - "fname);\n" - "\tWRITENOW();\n" - "\tfunc_fmtptr(ret, readable, isstring);\n" - "\tT_snprintf(logbuf, LOGBUFSIZ -1, \" [time spent=%%d.%%06d]\\n\", t1, t2);\n" - "\tWRITENOW();\n" - "}\n", - FUNC_BEGIN(longjmp), - FUNC_BEGIN(_setjmp), - FUNC_BEGIN(sigaction), - FUNC_BEGIN(snprintf), - FUNC_BEGIN(memset), - FUNC_BEGIN(gettimeofday), - FUNC_BEGIN(write), - FUNC_BEGIN(exit), - 0); - */ - snprintf(buf, BUFSIZ - 1, trace_file_base, - FUNC_BEGIN(longjmp), - FUNC_BEGIN(_setjmp), - FUNC_BEGIN(sigaction), - FUNC_BEGIN(snprintf), - FUNC_BEGIN(memset), - FUNC_BEGIN(gettimeofday), - FUNC_BEGIN(write), - FUNC_BEGIN(exit), - 0); - fwrite(buf, strlen(buf), sizeof(char), fp); - - /* Setup structures */ - for (index = sizeof(eresi_Addr); index < 512; index++) - { - if (index > sizeof(eresi_Addr)) - { - snprintf(buf, BUFSIZ - 1, - "typedef struct trace_s_%1$d { void *ptr; char elm[%2$d]; } trace_arg_%1$d;\n", - index, index - sizeof(eresi_Addr)); - } - else - { - snprintf(buf, BUFSIZ - 1, - "\ntypedef struct trace_s_%1$d { void *ptr; } trace_arg_%1$d;\n", - index); - } - fwrite(buf, strlen(buf), sizeof(char), fp); - } - - /* Add a new line */ - fwrite("\n", 1, sizeof(char), fp); - - /* Iterate */ - for (index = 0; index < keynbr; index++) - { - table = hash_get(&traces_table, keys[index]); - - if (table) - etrace_save_table(fp, file, table); - } - - hash_free_keys(keys); - fclose(fp); - - if (queue_count == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No functions found", (-1)); - - // Compile the tmp c file to create a relocatable file to inject - if (rename(tfname, rtfname) < 0) - { - etrace_queue_clean(); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Rename failed", (-1)); - } - - /* Simple array for execvp */ - system[0] = "gcc"; - system[1] = "-c"; - system[2] = rtfname; - system[3] = "-o"; - system[4] = rsofname; - system[5] = NULL; - - err = 0; - if (!fork()) - err = execvp(system[0], system); - else - wait(NULL); /* Wait gcc */ - - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Compilation failed", -1); - - /* Load the new relocatable file for ET_REL injection */ - tobj = elfsh_map_obj(rsofname); - if (!tobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to load relocatable file", -1); - - /* Inject the loaded file */ - idx = elfsh_inject_etrel(file, tobj); - - if (idx < 0) - { - etrace_queue_clean(); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to inject ET_REL with workspace", -1); - } - - last_parsed_function = NULL; - - /* Hijack functions with the new functions injected */ - for (index = 0; index < queue_count && trace_queue[index]; index++) - { - /* Keep function name for etrace */ - last_parsed_function = trace_queue[index]->funcname; - - snprintf(buf, BUFSIZ, "%s_trace", trace_queue[index]->funcname); - - /* Retrieve symbol */ - dst = elfsh_get_symbol_by_name(file, buf); - - if (dst == NULL) - { - etrace_queue_clean(); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to find trace function", -1); - } - - addr = dst->st_value; - -#if __DEBUG_TRACES__ - printf("[DEBUG TRACE] (%03u) HIJACK: %s / %s\n", index, trace_queue[index]->funcname, buf); -#endif - - /* Start to hijack the function */ - err = elfsh_hijack_function_by_name(file, - ELFSH_HIJACK_TYPE_FLOW, - trace_queue[index]->funcname, - addr, NULL); - if (err < 0) - { - etrace_queue_clean(); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to hijack a function", -1); - } - } - - last_parsed_function = NULL; - - etrace_queue_clean(); - - /* Save procedure already relocate but we made some modifications too - then we restart this procedure. - */ - if (elfsh_save_relocate(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to relocate traced binary", -1); - - /* Clean temp files */ - unlink(rtfname); - unlink(rsofname); - - /* Ask for rewrite the SHT */ - file->hdr->e_shoff = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/search_addr.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/search_addr.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/search_addr.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/search_addr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,262 +0,0 @@ -/** - * @file func_add.c -** func_add.c for libetrace -** -** @brief add function to a trace table -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: search_addr.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-extern.h" - -/** - * Setup asm_processor structure correctly - * @param proc pointer to asm_processor structure - */ -static int etrace_setup_proc(elfshobj_t *file, asm_processor *proc) -{ - u_int arch; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !proc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - arch = elfsh_get_arch(file->hdr); - - switch(arch) - { - case EM_SPARC: - case EM_SPARCV9: - case EM_SPARC32PLUS: - asm_init_sparc(proc); - break; - case EM_386: - asm_init_ia32(proc); - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - asm_init_mips(proc); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unsupported architecture for address tracing", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Get function addr list from call search basic - * @param file target file - * @param addr address list - */ -int elfsh_addr_get_func_list(elfshobj_t *file, eresi_Addr **addr) -{ - int ret; - int index; - asm_instr instr; - elfsh_SAddr foffset; - elfsh_Word len; - char *base; - asm_processor proc; - eresi_Addr base_vaddr, caddr; - u_char found = 0; - elfshsect_t *text; - eresi_Addr *vaddr; - const int astep = 20; - u_int apos = 0; - btree_t *broot = NULL; - u_int diff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file || !addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Search entrypoint section, our address must be in this section */ - text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &foffset); - - if (!text) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section from entry point", -1); - - if (!elfsh_get_anonymous_section(file, text)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get an anonymous section", -1); - - base = elfsh_get_raw(text); - len = text->shdr->sh_size; - - /* Get the virtual address */ - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? - file->rhdr.base + elfsh_get_section_addr(text->shdr) : - elfsh_get_section_addr(text->shdr)); - - /* Setup asm_processor structure */ - if (etrace_setup_proc(file, &proc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed during proc structure setup", -1); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, vaddr, sizeof(eresi_Addr)*astep, -1); - - /* Despite the fact that we choose the right architecture to init asm, - Our approach is totally architecture independant as we search using - global type ASM_TYPE_CALLPROC and we know that op[0].imm will contain a - relative value. */ - for (index = 0; index < len; index += ret) - { - /* Read an instruction */ - if ((ret = asm_read_instr(&instr, (u_char *) (base + index), len - index, &proc))) - { - /* Global assembler filter */ - if ((instr.type & ASM_TYPE_CALLPROC) - && instr.op[0].imm != 0) - { - caddr = base_vaddr + index + instr.op[0].imm + instr.len; - - /* Found a call check its local */ - if (INTERVAL(base_vaddr, caddr, base_vaddr + len)) - { - found = 1; - - diff = (u_int) caddr; - - /* Avoid double entrie */ - if (btree_get_elem(broot, diff) != NULL) - goto next; - - btree_insert(&broot, diff, (void *)0x1); - - /* Next will be the last of the current list - then realloc */ - if ((apos+1) % astep == 0) - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__, vaddr, vaddr, - sizeof(eresi_Addr)*(apos+1+astep), -1); - - /* Blank new elements */ - memset(&vaddr[apos], 0x00, astep*sizeof(eresi_Addr)); - } - - vaddr[apos++] = caddr; - } - } - } - - next: - - if (ret <= 0) - ret = 1; - } - - /* If nothing found we free allocated buffer and - return an error */ - if (!found) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, vaddr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No call internal found", -3); - } - - btree_free(broot, 0); - - *addr = vaddr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Search a call for a given address - * @param file target file - * @param addr supose to be a function - */ -int elfsh_addr_is_called(elfshobj_t *file, eresi_Addr addr) -{ - int ret; - int index; - asm_instr instr; - elfsh_SAddr foffset; - elfsh_Word len; - char *base; - asm_processor proc; - eresi_Addr base_vaddr; - u_char found = 0; - elfshsect_t *text; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", -1); - - /* Search entrypoint section, our address must be in this section */ - text = elfsh_get_parent_section(file, elfsh_get_entrypoint(file->hdr), &foffset); - - if (!text) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find parent section from entry point", -1); - - if (!elfsh_get_anonymous_section(file, text)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get an anonymous section", -1); - - base = elfsh_get_raw(text); - len = text->shdr->sh_size; - - /* Get the virtual address */ - base_vaddr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(text) ? - file->rhdr.base + elfsh_get_section_addr(text->shdr) : - elfsh_get_section_addr(text->shdr)); - - /* Our address is valid ? */ - if (!INTERVAL(base_vaddr, addr, (base_vaddr + len))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not in entrypoint section", -4); - - /* Setup asm_processor structure */ - if (etrace_setup_proc(file, &proc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed during proc structure setup", -1); - - /* Despite the fact that we choose the right architecture to init asm, - Our approach is totally architecture independant as we search using - global type ASM_TYPE_CALLPROC and we know that op[0].imm will contain a - relative value. */ - for (index = 0; index < len; index += ret) - { - /* Read an instruction */ - if ((ret = asm_read_instr(&instr, (u_char *) (base + index), len - index, &proc))) - { - /* Global assembler filter */ - if ((instr.type & ASM_TYPE_CALLPROC) - && instr.op[0].imm != 0) - { - /* Found the correct call */ - if (base_vaddr + index + instr.op[0].imm + instr.len == addr) - { - found = 1; - break; - } - } - } - - if (ret <= 0) - ret = 1; - } - - if (!found) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No call found", -3); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/search.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/search.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/search.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/search.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * @file search.c -** search.c for libetrace -** -** @brief Symbol trace search function -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: search.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ - -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" - -/** - * Search a symbol on dependences file - * @param file parent file - * @param name symbol name - * @return file object that containt the symbol (on dynsym) - */ -elfshobj_t *etrace_search_sym(elfshobj_t *file, char *name) -{ - char **keys; - int keynbr; - u_int index; - elfshobj_t *child, *find = NULL; - elfsh_Sym *sym; - elfshsect_t *sect; - char *sect_name; - u_int bindnum; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&(file->child_hash), &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - child = (elfshobj_t *) hash_get(&(file->child_hash), keys[index]); - - if (child) - { - sym = elfsh_get_dynsymbol_by_name(child, name); - - if (!sym) - continue; - - bindnum = elfsh_get_symbol_bind(sym); - - /* We need a global or weak symbol */ - if (bindnum == STB_GLOBAL || bindnum == STB_WEAK) - { - sect = elfsh_get_section_by_index(child, sym->st_shndx, NULL, NULL); - - /* The symbol must be local and pointing on sect_name */ - if (sect && (sect_name = elfsh_get_section_name(child, sect)) != NULL - && !strncmp(sect_name, ".text", 5)) - { - find = child; - break; - } - } - } - - /* Search deeper on this child */ - find = etrace_search_sym(child, name); - - if (find) - break; - } - } - - hash_free_keys(keys); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, find); -} diff -Nru eresi-0.8a25/libetrace/.svn/text-base/traces.c.svn-base eresi-0.0.20110516/libetrace/.svn/text-base/traces.c.svn-base --- eresi-0.8a25/libetrace/.svn/text-base/traces.c.svn-base 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/.svn/text-base/traces.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/** - * @file traces.c -** traces.c for libelfsh -** -** @brief All functions that help to trace content -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: traces.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-intvars.h" - -/** - * Create a new trace - * @param trace trace name - * @return trace hash table - */ -hash_t *etrace_createtrace(char *trace) -{ - hash_t *newhash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!trace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - etrace_inittrace(); - - /* Create a new trace tracename */ - snprintf(buf, BUFSIZ - 1, ELFSH_TRACES_PATTERN, trace); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newhash, sizeof(hash_t), NULL); - hash_init(newhash, strdup(buf), 30, ASPECT_TYPE_UNKNOW); - - hash_add(&traces_table, strdup(trace), (void *) newhash); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newhash); -} - -/* Init the table and add the default trace (global) */ -int *etrace_inittrace() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do we already set default table */ - if (traces_table.ent == NULL) - { - hash_init(&traces_table, ELFSH_TRACES_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); - etrace_createtrace(ELFSH_TRACES_TYPE_DEFAULT); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Retreive a trace from its name - * @param trace trace name - * @return trace hash table - */ -hash_t *etrace_gettrace(char *trace) -{ - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - etrace_inittrace(); - - /* Default trace by default */ - if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; - - table = hash_get(&traces_table, trace); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, table); -} - diff -Nru eresi-0.8a25/libetrace/trace_create.c eresi-0.0.20110516/libetrace/trace_create.c --- eresi-0.8a25/libetrace/trace_create.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/trace_create.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,280 @@ +/** + * @defgroup libetrace libetrace: The Embedded ERESI tracer library. + * @ingroup etrace + */ +/** +* @file libetrace/trace_create.c +** @ingroup libetrace +** @brief Functions for managing traces creation. +** +** Started Jul 2 2005 00:03:44 mxatone +** $Id: trace_create.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libetrace.h" +#include "libetrace-intvars.h" + +/* @brief Hash table of traces */ +hash_t traces_table; + +/** @brief Exclude hash table which contain regex */ +hash_t exclude_table; + + +/** + * @brief Create a new trace + * @param trace trace name + * @return trace hash table + */ +hash_t *etrace_create_trace(char *trace) +{ + hash_t *newhash; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!trace) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", NULL); + + etrace_init_trace(); + + /* Create a new trace tracename */ + snprintf(buf, BUFSIZ - 1, ETRACE_PATTERN, trace); + XALLOC(__FILE__, __FUNCTION__, __LINE__, newhash, sizeof(hash_t), NULL); + hash_init(newhash, strdup(buf), 30, ASPECT_TYPE_UNKNOW); + hash_add(&traces_table, strdup(trace), (void *) newhash); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newhash); +} + +/** + * @brief Init the table and add the default trace (global) . + */ +int *etrace_init_trace() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Do we already set default table */ + if (traces_table.ent == NULL) + { + hash_init(&traces_table, ETRACE_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); + etrace_create_trace(ETRACE_TYPE_DEFAULT); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @brief Retreive a trace from its name + * @param trace trace name + * @return trace hash table + */ +hash_t *etrace_get(char *trace) +{ + hash_t *table; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + etrace_init_trace(); + + /* Default trace by default */ + if (!trace) + trace = ETRACE_TYPE_DEFAULT; + + table = hash_get(&traces_table, trace); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, table); +} + + + +/** + * @brief Search the function entry on the uniform debugging format, and return it + * @param file First element of a edfmtfile_t structure. + * @param func_name Function name. + * @param external Indicate if we need internal (0) or external (1) lookup. + * @return pointer A edfmtfunc_t* representing the function debugging information. + */ +edfmtfunc_t *trace_func_debug_get(elfshobj_t *file, char *func_name, + u_char external) +{ + elfshobj_t *sym_file; + edfmtfunc_t *func = NULL; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* We have an extern symbol */ + if (external) + { + sym_file = elfsh_symbol_search(file, func_name); + + if (sym_file) + func = trace_search_uni(sym_file, func_name); + } + else + { + /* Search in this file */ + func = trace_search_uni(file, func_name); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); +} + + +/** + * @brief Construct the argument structure depending of the option we have + * @param file target file + * @param ent pointer to set + * @param func uniform debugging inforation if we got one + * @param vaddr virtual address of the function if we don't have debugging information + * @param external describe scope + * @see trace_param_create + */ +int trace_param_build(elfshobj_t *file, trace_t *ent, + edfmtfunc_t *func, eresi_Addr vaddr, + u_char external) +{ + u_int index; + int *argcount; + edfmtfuncarg_t *arg; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!ent) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + elfsh_setup_hooks(); + + ent->scope = external ? ELFSH_ARG_EXTERN : ELFSH_ARG_INTERN; + + /* Do we have uniform debugging information for this structure ? */ + if (func == NULL) + { + argcount = elfsh_args_count(file, 0, vaddr); + + ent->type = ELFSH_ARG_SIZE_BASED; + ent->argc = 0; + + /* If we found some argument, else its 0 */ + if (argcount != 0 && argcount != (int *) 0xffffffff) + { + /* Fill arguments */ + for (index = 0; argcount[index] > 0; index++) + ent->arguments[index].size = argcount[index]; + + ent->argc = index; + XFREE(__FILE__, __FUNCTION__, __LINE__, argcount); + } + else + { + snprintf(buf, BUFSIZ, "\t[*] Unable to add func at "XFMT" into trace\n", vaddr); + aspectworld.profile(buf); + } + } + else + { + ent->type = ELFSH_ARG_TYPE_BASED; + for (arg = func->arguments, index = 0; arg != NULL; arg = arg->next, index++) + { + /* We setup argument name and typename */ + ent->arguments[index].name = arg->name; + ent->arguments[index].typename = arg->type ? arg->type->name : NULL; + + /* Other information are quite the same as arg counting method */ + ent->arguments[index].size = 0; + if (arg->type->size > 0) + ent->arguments[index].size = arg->type->size; + + if (ent->arguments[index].size < sizeof(eresi_Addr)) + ent->arguments[index].size = sizeof(eresi_Addr); + } + + ent->argc = func->argc; + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Allocate the traces structure and call previous + * @param file target file + * @param func uniform debugging inforation if we got one + * @param vaddr virtual address of the function if we don't have debugging information + * @param external describe scope + * @return generate trace structure + * @see trace_param_build + */ +trace_t *trace_param_create(elfshobj_t *file, char *name, + edfmtfunc_t *func, eresi_Addr vaddr, + u_char external) +{ + trace_t *newtrace; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + // Alloc the structure + XALLOC(__FILE__, __FUNCTION__, __LINE__, newtrace, sizeof(trace_t), NULL); + snprintf(newtrace->funcname, ETRACE_FUNC_SIZE, "%s", name); + newtrace->file = file; + newtrace->enable = 1; + newtrace->vaddr = vaddr; + +#if __DEBUG_ARG_COUNT__ + printf("[DEBUG_ARG_COUNT] Builds args for %s\n", name); +#endif + + // We fill arguments part and check if we found the function + if (trace_param_build(file, newtrace, func, vaddr, external) < 0) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, newtrace); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Symbol not found or impossible to trace", NULL); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtrace); +} + + + +/** + * Create a trace + * @param file target + * @param name trace name + * @param optarg list of function to directly add + */ +int traces_create(elfshobj_t *file, char *name, char **optarg) +{ + char *strarr[2]; + int index; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!name || !name[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + if (etrace_create_trace(name) == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Create trace failed", -1); + + snprintf(buf, BUFSIZ - 1, "\t[*] Created trace %s successfully\n\n", name); + aspectworld.profile(buf); + + if (optarg && *optarg) + { + /* Add gived elements */ + for (index = 0; optarg[index]; index++) + { + strarr[0] = name; + strarr[1] = NULL; + if (traces_add(file, optarg[index], strarr) < 0) + continue; + } + + aspectworld.profile("\n"); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/trace_flush.c eresi-0.0.20110516/libetrace/trace_flush.c --- eresi-0.8a25/libetrace/trace_flush.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/trace_flush.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,63 @@ +/* +* @file libetrace/trace_flush.c +** +** Libetrace code for the ERESI project. +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: trace_flush.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libetrace.h" + + +/** + * @brief Delete a trace. + * @param file target + * @param name trace name + * @param optarg not use + */ +int traces_delete(elfshobj_t *file, char *name, char **optarg) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!name || !name[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + if (etrace_deletetrace(name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Delete trace failed", -1); + + snprintf(buf, BUFSIZ - 1, "\t[*] Deleted trace %s successfully\n\n", name); + aspectworld.profile(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Flush a whole trace + * @param name trace name + * @param optarg not use + */ +int traces_flush(elfshobj_t *file, char *name, char **optarg) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!name || !name[0]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + if (etrace_funcrmall(name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Flush trace failed", -1); + + snprintf(buf, BUFSIZ - 1, "\t[*] Flushed trace %s successfully\n\n", name); + aspectworld.profile(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + diff -Nru eresi-0.8a25/libetrace/trace_list.c eresi-0.0.20110516/libetrace/trace_list.c --- eresi-0.8a25/libetrace/trace_list.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/trace_list.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,155 @@ +/* +* @file libetrace/trace_list.c +** +** Libetrace implementation in the ERESI project. +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: trace_list.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libetrace.h" + + +/** + * Detail listing of a trace + * @param table trace hash table + * @param name trace name + * @see traces_list + */ +int traces_list_detail(hash_t *table, char *name) +{ + char **keys; + u_int index; + int keynbr; + trace_t *entrie; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + snprintf(buf, BUFSIZ - 1, " ~> %s: %s\n", + aspectworld.colorfieldstr("Trace name"), + aspectworld.colorstr(name)); + aspectworld.profile(buf); + + keys = hash_get_keys(table, &keynbr); + + if (keys && keynbr > 0) + { + aspectworld.profile("\n"); + + for (index = 0; index < keynbr; index++) + { + entrie = (trace_t *) hash_get(table, keys[index]); + + if (entrie) + { + snprintf(buf, BUFSIZ - 1, " %s: %s %s: %s\n", + aspectworld.colorfieldstr("Function name"), + aspectworld.colorstr_fmt("%-15s", entrie->funcname), + aspectworld.colorfieldstr("status"), + aspectworld.colortypestr(entrie->enable ? "enabled" : "disabled")); + aspectworld.profile(buf); + aspectworld.endline(); + } + } + + aspectworld.profile("\n"); + + hash_free_keys(keys); + } + else + { + aspectworld.profile("\n [*] No function in this trace\n\n"); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Enumerate each trace and detail every functions + * @param name not use + * @param optarg not use + * @see traces_list_detail + */ +int traces_list(elfshobj_t *file, char *name, char **optarg) +{ + char **keys = NULL; + u_int index; + int keynbr; + hash_t *subtable; + char funcreg[256]; + size_t len; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + aspectworld.profile(" .: Trace list :.\n"); + + if (traces_table.ent) + keys = hash_get_keys(&traces_table, &keynbr); + + if (keys) + { + if (keynbr > 0) + aspectworld.profile("\n"); + + for (index = 0; index < keynbr; index++) + { + subtable = hash_get(&traces_table, keys[index]); + + if (subtable) + traces_list_detail(subtable, keys[index]); + } + + hash_free_keys(keys); + } + else + { + aspectworld.profile("\n [*] No tracing table available\n\n"); + } + + aspectworld.profile(" .: Exclude list :.\n"); + + /* Reset */ + keynbr = 0; + keys = NULL; + + /* Print exclude list */ + if (exclude_table.ent) + keys = hash_get_keys(&exclude_table, &keynbr); + + if (keys) + { + if (exclude_table.ent) + aspectworld.profile("\n"); + + for (index = 0; index < keynbr; index++) + { + len = strlen(keys[index]); + snprintf(funcreg, 255, "%s%s%s", + keys[index][0] != '^' ? "^" : "", + keys[index], + keys[index][len-1] != '$' ? "$" : ""); + + snprintf(buf, BUFSIZ - 1, " %s %s %s %s %s\n", + aspectworld.colornumber("[%02u]", index+1), + aspectworld.colorfieldstr("name:"), + aspectworld.colorstr_fmt("%-15s", keys[index]), + aspectworld.colorfieldstr("regex:"), + aspectworld.colorstr(funcreg)); + aspectworld.profile(buf); + aspectworld.endline(); + } + + hash_free_keys(keys); + } + else + { + aspectworld.profile("\n [*] No exclude table available\n"); + } + + aspectworld.profile("\n"); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + diff -Nru eresi-0.8a25/libetrace/trace_run.c eresi-0.0.20110516/libetrace/trace_run.c --- eresi-0.8a25/libetrace/trace_run.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libetrace/trace_run.c 2011-05-16 11:34:09.000000000 +0000 @@ -0,0 +1,141 @@ +/* +* @file libetrace/trace_run.c +** +** Libetrace implementation in the ERESI project. +** +** Started on Sun Jun 22 12:10:12 2007 jfv +** $Id: trace_run.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libetrace.h" + + +char **traces_lastarg = NULL; + +/** + * Add arguments for a futur traces_run + * @param argc arguments number + * @param argv arguments + * @see traces_run + */ +int trace_param_add(int argc, char **argv) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (argc < 1 || argv == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Copy arguments */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, traces_lastarg, sizeof(char *)*(argc+1), -1); + memcpy(traces_lastarg, argv, sizeof(char*)*argc); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Run a trace session (used in etrace) + * @param file target + * @param argv argument list + * @param argc argument counter + */ +int traces_run(elfshobj_t *file, char **argv, int argc) +{ + char *home; + char *filename; + size_t len; + u_int index; + char *path; + char *av[argc+2]; + int ret; + struct timeval now, after; + double difftime; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + argc = 0; + if (traces_lastarg) + { + while (traces_lastarg[argc] != NULL) + argc++; + argv = traces_lastarg; + } + else + { + XALLOC(__FILE__, __FUNCTION__, __LINE__, argv, sizeof(char*), -1); + argv[0] = NULL; + } + + if (argc < 0 || !argv) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + if (elfsh_get_objtype(elfsh_get_hdr(file)) != ET_EXEC && + elfsh_get_objtype(elfsh_get_hdr(file)) != ET_DYN) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "We need a ET_EXEC binary", -1); + + home = getenv("HOME"); + + if (!home) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find home directory", -1); + + snprintf(buf, BUFSIZ - 1, "%s/%s", home, REVM_TRACE_REP); + + /* Create temp directory if needed */ + mkdir(buf, 0700); + + /* We search the filename (we have a path) */ + len = strlen(file->name); + filename = file->name; + + for (index = len; index > 0; index--) + if (file->name[index] == '/') + break; + + if (INTERVAL(0, index+1, len)) + filename = file->name + index + 1; + + /* Full path */ + snprintf(buf, BUFSIZ - 1, "%s/%s/%s", home, REVM_TRACE_REP, filename); + path = strdup(buf); + + if (etrace_save_obj(file, path) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to save object", -1); + + av[0] = path; + for (index = 0; index < argc; index++) + av[index+1] = argv[index]; + av[index+1] = NULL; + + gettimeofday(&now, NULL); + + /* Print start */ + aspectworld.profile("Start execution of "); + for (index = 0; index < argc+1; index++) + { + snprintf(buf, BUFSIZ - 1, "%s ", av[index]); + aspectworld.profile(buf); + } + aspectworld.profile("\n"); + + /* Start with arguments */ + if (!fork()) + ret = execv(av[0], av); + else + wait(NULL); + + gettimeofday(&after, NULL); + + difftime = (after.tv_sec - now.tv_sec) + ((double) (after.tv_usec - now.tv_usec)) * 0.000001; + + snprintf(buf, BUFSIZ - 1, "End execution (%.6f sec)\n\n", difftime); + aspectworld.profile(buf); + + XFREE(__FILE__, __FUNCTION__, __LINE__, path); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libetrace/traces.c eresi-0.0.20110516/libetrace/traces.c --- eresi-0.8a25/libetrace/traces.c 2008-04-06 23:15:44.000000000 +0000 +++ eresi-0.0.20110516/libetrace/traces.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,81 +0,0 @@ -/** - * @file traces.c -** traces.c for libelfsh -** -** @brief All functions that help to trace content -** -** Started Jul 2 2005 00:03:44 mxatone -** -** -** $Id: traces.c,v 1.2 2007-11-29 10:25:02 rival Exp $ -** -*/ -#include "libelfsh.h" -#include "libasm.h" -#include "libetrace.h" -#include "libetrace-intvars.h" - -/** - * Create a new trace - * @param trace trace name - * @return trace hash table - */ -hash_t *etrace_createtrace(char *trace) -{ - hash_t *newhash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!trace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", NULL); - - etrace_inittrace(); - - /* Create a new trace tracename */ - snprintf(buf, BUFSIZ - 1, ELFSH_TRACES_PATTERN, trace); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newhash, sizeof(hash_t), NULL); - hash_init(newhash, strdup(buf), 30, ASPECT_TYPE_UNKNOW); - - hash_add(&traces_table, strdup(trace), (void *) newhash); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newhash); -} - -/* Init the table and add the default trace (global) */ -int *etrace_inittrace() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Do we already set default table */ - if (traces_table.ent == NULL) - { - hash_init(&traces_table, ELFSH_TRACES_TABLE_NAME, 30, ASPECT_TYPE_UNKNOW); - etrace_createtrace(ELFSH_TRACES_TYPE_DEFAULT); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Retreive a trace from its name - * @param trace trace name - * @return trace hash table - */ -hash_t *etrace_gettrace(char *trace) -{ - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - etrace_inittrace(); - - /* Default trace by default */ - if (!trace) - trace = ELFSH_TRACES_TYPE_DEFAULT; - - table = hash_get(&traces_table, trace); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, table); -} - diff -Nru eresi-0.8a25/libgdbwrap/client.c eresi-0.0.20110516/libgdbwrap/client.c --- eresi-0.8a25/libgdbwrap/client.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/client.c 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,162 @@ +/* Basic TCP client aimed to develop of fully modular gdb wrapper. Not + part of eresi project. Took code from: + http://neworder.box.sk/newsread.php?newsid=2844. +*/ + + +#include "revm.h" +#include "gdbwrapper.h" + + +extern int errno; +extern int h_errno; + +static void dumpreg(gdbwrap_t *desc) +{ + unsigned i; + + for (i = 0; i < sizeof(gdbwrap_gdbreg32) / sizeof(ureg32); i++) + printf("Reg %d - %#x\n", i, *(&desc->reg32.eax + i)); +} + +int main( int argc, char **argv ) +{ + char buffer[4096]; + int port; + int rval; + int sd; + struct sockaddr_in socketaddr; + struct hostent *hostaddr; + struct protoent *protocol; + gdbwrap_t *desc = NULL; + + if ( argc < 3 ) + { + printf( "usage: client server port \n" ); + return (EINVAL); /* Invalid argument */ + } + + /* quick sanity check */ + + port = atoi( argv[2] ); + + if ( port < 1 || port > 65535 ) + { + printf( "client: invalid port number\n" ); + return (EINVAL); + } + + /* + * Build our socket + */ + + protocol = getprotobyname( "tcp" ); + if ( !protocol ) + { + perror( "getprotobyname()" ); + return (errno); + } + + sd = socket( PF_INET, SOCK_STREAM, protocol->p_proto ); + if ( sd == -1 ) + { + perror( "socket()" ); + return (errno); + } + /* + * Setup info about the remote host + */ + + memset( &socketaddr, 0, sizeof(socketaddr) ); + + socketaddr.sin_family = AF_INET; + socketaddr.sin_port = htons( port ); + + hostaddr = gethostbyname( argv[1] ); + if ( !hostaddr ) + { + fprintf( stderr, "gethostbyname(): %s\n", hstrerror(h_errno) ); + return (h_errno); + } + + /* copy address from hostaddr to socketaddr */ + + memcpy( &socketaddr.sin_addr, hostaddr->h_addr, hostaddr->h_length ); + + /* + * Connect to the host + */ + + rval = connect( sd, (struct sockaddr *) &socketaddr, sizeof(socketaddr) ); + if ( rval == -1 ) + { + perror( "connect()" ); + return (errno); + } + + /* Now that we're connected, we can send and receive all we want. + * I've decided to use this example as a means of simply grabbing + * whatever banner the server sends us and sending it to stdout. + */ + + desc = gdbwrap_init(sd); + do + { + char * ret; + + ret = fgets(buffer, sizeof(buffer) - 1, stdin); + assert(ret != NULL); + + if(!strncmp("hello", buffer, 5)) + gdbwrap_hello(desc); + else if(!strncmp("disconnect", buffer, 5)) + { + gdbwrap_bye(desc); + exit(0); + } + else if(!strncmp("why", buffer, 3)) + gdbwrap_reason_halted(desc); +/* else if(!strncmp("test", buffer, 4)) */ +/* gdbwrap_test(desc); */ + else if(!strncmp("gpr", buffer, 3)) + gdbwrap_readgenreg(desc); + else if(!strncmp("cont", buffer, 4)) + gdbwrap_continue(desc); + else if(!strncmp("dump", buffer, 4)) + dumpreg(desc); + else if(!strncmp("stepi", buffer, 5)) + gdbwrap_stepi(desc); + else if(!strncmp("signal", buffer, 5)) + gdbwrap_signal(0x1, desc); + else if(!strncmp("muuu", buffer, 4)) + gdbwrap_writereg2(6, 0x12345678, desc); + else if(!strncmp("ship", buffer, 4)) + gdbwrap_shipallreg(desc); + else if(!strncmp("cr0", buffer, 4)) + printf("Value: %s\n", gdbwrap_remotecmd("r cr0", desc)); + else if(!strncmp("mem", buffer, 3)) + { + char *c; + char u = 0xff; + c = gdbwrap_writememory(0xb7fe49a0, &u, 0x1, desc); + printf("Returned from memorycontent: %s\n", c); + fflush(stdout); + } +/* else if(!strncmp("own", buffer, 3)) */ +/* { */ +/* while (strncmp("quitown", buffer, 7)) */ +/* { */ +/* printf("\nCommand: "); */ +/* ret = gdbwrap_own_command(fgets(buffer, sizeof(buffer) - 1, stdin), */ +/* desc); */ +/* printf("\n%s - size: %d", ret, strlen(ret)); */ +/* } */ +/* } */ + else printf("not supported yet\n"); + + } while (strncmp("bye", buffer, 3)); + + + close(sd); + return (0); +} diff -Nru eresi-0.8a25/libgdbwrap/doc/_gdbremote.c eresi-0.0.20110516/libgdbwrap/doc/_gdbremote.c --- eresi-0.8a25/libgdbwrap/doc/_gdbremote.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/doc/_gdbremote.c 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,6739 @@ +/* Remote target communications for serial-line targets in custom GDB protocol + + Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, + 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* See the GDB User Guide for details of the GDB remote protocol. */ + +#include "defs.h" +#include "gdb_string.h" +#include +#include +#include "inferior.h" +#include "bfd.h" +#include "symfile.h" +#include "exceptions.h" +#include "target.h" +/*#include "terminal.h" */ +#include "gdbcmd.h" +#include "objfiles.h" +#include "gdb-stabs.h" +#include "gdbthread.h" +#include "remote.h" +#include "regcache.h" +#include "value.h" +#include "gdb_assert.h" +#include "observer.h" +#include "solib.h" +#include "cli/cli-decode.h" +#include "cli/cli-setshow.h" +#include "target-descriptions.h" + +#include +#include + +#include "event-loop.h" +#include "event-top.h" +#include "inf-loop.h" + +#include +#include "serial.h" + +#include "gdbcore.h" /* for exec_bfd */ + +#include "remote-fileio.h" + +#include "memory-map.h" + +/* The size to align memory write packets, when practical. The protocol + does not guarantee any alignment, and gdb will generate short + writes and unaligned writes, but even as a best-effort attempt this + can improve bulk transfers. For instance, if a write is misaligned + relative to the target's data bus, the stub may need to make an extra + round trip fetching data from the target. This doesn't make a + huge difference, but it's easy to do, so we try to be helpful. + + The alignment chosen is arbitrary; usually data bus width is + important here, not the possibly larger cache line size. */ +enum { REMOTE_ALIGN_WRITES = 16 }; + +/* Prototypes for local functions. */ +static void cleanup_sigint_signal_handler (void *dummy); +static void initialize_sigint_signal_handler (void); +static int getpkt_sane (char **buf, long *sizeof_buf, int forever); + +static void handle_remote_sigint (int); +static void handle_remote_sigint_twice (int); +static void async_remote_interrupt (gdb_client_data); +void async_remote_interrupt_twice (gdb_client_data); + +static void remote_files_info (struct target_ops *ignore); + +static void remote_prepare_to_store (struct regcache *regcache); + +static void remote_fetch_registers (struct regcache *regcache, int regno); + +static void remote_resume (ptid_t ptid, int step, + enum target_signal siggnal); +static void remote_async_resume (ptid_t ptid, int step, + enum target_signal siggnal); +static void remote_open (char *name, int from_tty); +static void remote_async_open (char *name, int from_tty); + +static void extended_remote_open (char *name, int from_tty); +static void extended_remote_async_open (char *name, int from_tty); + +static void remote_open_1 (char *, int, struct target_ops *, int extended_p, + int async_p); + +static void remote_close (int quitting); + +static void remote_store_registers (struct regcache *regcache, int regno); + +static void remote_mourn (void); +static void remote_async_mourn (void); + +static void extended_remote_restart (void); + +static void extended_remote_mourn (void); + +static void remote_mourn_1 (struct target_ops *); + +static void remote_send (char **buf, long *sizeof_buf_p); + +static int readchar (int timeout); + +static ptid_t remote_wait (ptid_t ptid, + struct target_waitstatus *status); +static ptid_t remote_async_wait (ptid_t ptid, + struct target_waitstatus *status); + +static void remote_kill (void); +static void remote_async_kill (void); + +static int tohex (int nib); + +static void remote_detach (char *args, int from_tty); + +static void remote_interrupt (int signo); + +static void remote_interrupt_twice (int signo); + +static void interrupt_query (void); + +static void set_thread (int, int); + +static int remote_thread_alive (ptid_t); + +static void get_offsets (void); + +static void skip_frame (void); + +static long read_frame (char **buf_p, long *sizeof_buf); + +static int hexnumlen (ULONGEST num); + +static void init_remote_ops (void); + +static void init_extended_remote_ops (void); + +static void remote_stop (void); + +static int ishex (int ch, int *val); + +static int stubhex (int ch); + +static int hexnumstr (char *, ULONGEST); + +static int hexnumnstr (char *, ULONGEST, int); + +static CORE_ADDR remote_address_masked (CORE_ADDR); + +static void print_packet (char *); + +static unsigned long crc32 (unsigned char *, int, unsigned int); + +static void compare_sections_command (char *, int); + +static void packet_command (char *, int); + +static int stub_unpack_int (char *buff, int fieldlength); + +static ptid_t remote_current_thread (ptid_t oldptid); + +static void remote_find_new_threads (void); + +static void record_currthread (int currthread); + +static int fromhex (int a); + +static int hex2bin (const char *hex, gdb_byte *bin, int count); + +static int bin2hex (const gdb_byte *bin, char *hex, int count); + +static int putpkt_binary (char *buf, int cnt); + +static void check_binary_download (CORE_ADDR addr); + +struct packet_config; + +static void show_packet_config_cmd (struct packet_config *config); + +static void update_packet_config (struct packet_config *config); + +static void set_remote_protocol_packet_cmd (char *args, int from_tty, + struct cmd_list_element *c); + +static void show_remote_protocol_packet_cmd (struct ui_file *file, + int from_tty, + struct cmd_list_element *c, + const char *value); + +void _initialize_remote (void); + +/* For "set remote" and "show remote". */ + +static struct cmd_list_element *remote_set_cmdlist; +static struct cmd_list_element *remote_show_cmdlist; + +/* Description of the remote protocol state for the currently + connected target. This is per-target state, and independent of the + selected architecture. */ + +struct remote_state +{ + /* A buffer to use for incoming packets, and its current size. The + buffer is grown dynamically for larger incoming packets. + Outgoing packets may also be constructed in this buffer. + BUF_SIZE is always at least REMOTE_PACKET_SIZE; + REMOTE_PACKET_SIZE should be used to limit the length of outgoing + packets. */ + char *buf; + long buf_size; + + /* If we negotiated packet size explicitly (and thus can bypass + heuristics for the largest packet size that will not overflow + a buffer in the stub), this will be set to that packet size. + Otherwise zero, meaning to use the guessed size. */ + long explicit_packet_size; +}; + +/* This data could be associated with a target, but we do not always + have access to the current target when we need it, so for now it is + static. This will be fine for as long as only one target is in use + at a time. */ +static struct remote_state remote_state; + +static struct remote_state * +get_remote_state_raw (void) +{ + return &remote_state; +} + +/* Description of the remote protocol for a given architecture. */ + +struct packet_reg +{ + long offset; /* Offset into G packet. */ + long regnum; /* GDB's internal register number. */ + LONGEST pnum; /* Remote protocol register number. */ + int in_g_packet; /* Always part of G packet. */ + /* long size in bytes; == register_size (current_gdbarch, regnum); + at present. */ + /* char *name; == gdbarch_register_name (current_gdbarch, regnum); + at present. */ +}; + +struct remote_arch_state +{ + /* Description of the remote protocol registers. */ + long sizeof_g_packet; + + /* Description of the remote protocol registers indexed by REGNUM + (making an array gdbarch_num_regs in size). */ + struct packet_reg *regs; + + /* This is the size (in chars) of the first response to the ``g'' + packet. It is used as a heuristic when determining the maximum + size of memory-read and memory-write packets. A target will + typically only reserve a buffer large enough to hold the ``g'' + packet. The size does not include packet overhead (headers and + trailers). */ + long actual_register_packet_size; + + /* This is the maximum size (in chars) of a non read/write packet. + It is also used as a cap on the size of read/write packets. */ + long remote_packet_size; +}; + + +/* Handle for retreving the remote protocol data from gdbarch. */ +static struct gdbarch_data *remote_gdbarch_data_handle; + +static struct remote_arch_state * +get_remote_arch_state (void) +{ + return gdbarch_data (current_gdbarch, remote_gdbarch_data_handle); +} + +/* Fetch the global remote target state. */ + +static struct remote_state * +get_remote_state (void) +{ + /* Make sure that the remote architecture state has been + initialized, because doing so might reallocate rs->buf. Any + function which calls getpkt also needs to be mindful of changes + to rs->buf, but this call limits the number of places which run + into trouble. */ + get_remote_arch_state (); + + return get_remote_state_raw (); +} + +static int +compare_pnums (const void *lhs_, const void *rhs_) +{ + const struct packet_reg * const *lhs = lhs_; + const struct packet_reg * const *rhs = rhs_; + + if ((*lhs)->pnum < (*rhs)->pnum) + return -1; + else if ((*lhs)->pnum == (*rhs)->pnum) + return 0; + else + return 1; +} + +static void * +init_remote_state (struct gdbarch *gdbarch) +{ + int regnum, num_remote_regs, offset; + struct remote_state *rs = get_remote_state_raw (); + struct remote_arch_state *rsa; + struct packet_reg **remote_regs; + + rsa = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_arch_state); + + /* Use the architecture to build a regnum<->pnum table, which will be + 1:1 unless a feature set specifies otherwise. */ + rsa->regs = GDBARCH_OBSTACK_CALLOC (gdbarch, + gdbarch_num_regs (current_gdbarch), + struct packet_reg); + for (regnum = 0; regnum < gdbarch_num_regs (current_gdbarch); regnum++) + { + struct packet_reg *r = &rsa->regs[regnum]; + + if (register_size (current_gdbarch, regnum) == 0) + /* Do not try to fetch zero-sized (placeholder) registers. */ + r->pnum = -1; + else + r->pnum = gdbarch_remote_register_number (gdbarch, regnum); + + r->regnum = regnum; + } + + /* Define the g/G packet format as the contents of each register + with a remote protocol number, in order of ascending protocol + number. */ + + remote_regs = alloca (gdbarch_num_regs (current_gdbarch) + * sizeof (struct packet_reg *)); + for (num_remote_regs = 0, regnum = 0; + regnum < gdbarch_num_regs (current_gdbarch); + regnum++) + if (rsa->regs[regnum].pnum != -1) + remote_regs[num_remote_regs++] = &rsa->regs[regnum]; + + qsort (remote_regs, num_remote_regs, sizeof (struct packet_reg *), + compare_pnums); + + for (regnum = 0, offset = 0; regnum < num_remote_regs; regnum++) + { + remote_regs[regnum]->in_g_packet = 1; + remote_regs[regnum]->offset = offset; + offset += register_size (current_gdbarch, remote_regs[regnum]->regnum); + } + + /* Record the maximum possible size of the g packet - it may turn out + to be smaller. */ + rsa->sizeof_g_packet = offset; + + /* Default maximum number of characters in a packet body. Many + remote stubs have a hardwired buffer size of 400 bytes + (c.f. BUFMAX in m68k-stub.c and i386-stub.c). BUFMAX-1 is used + as the maximum packet-size to ensure that the packet and an extra + NUL character can always fit in the buffer. This stops GDB + trashing stubs that try to squeeze an extra NUL into what is + already a full buffer (As of 1999-12-04 that was most stubs). */ + rsa->remote_packet_size = 400 - 1; + + /* This one is filled in when a ``g'' packet is received. */ + rsa->actual_register_packet_size = 0; + + /* Should rsa->sizeof_g_packet needs more space than the + default, adjust the size accordingly. Remember that each byte is + encoded as two characters. 32 is the overhead for the packet + header / footer. NOTE: cagney/1999-10-26: I suspect that 8 + (``$NN:G...#NN'') is a better guess, the below has been padded a + little. */ + if (rsa->sizeof_g_packet > ((rsa->remote_packet_size - 32) / 2)) + rsa->remote_packet_size = (rsa->sizeof_g_packet * 2 + 32); + + /* Make sure that the packet buffer is plenty big enough for + this architecture. */ + if (rs->buf_size < rsa->remote_packet_size) + { + rs->buf_size = 2 * rsa->remote_packet_size; + rs->buf = xrealloc (rs->buf, rs->buf_size); + } + + return rsa; +} + +/* Return the current allowed size of a remote packet. This is + inferred from the current architecture, and should be used to + limit the length of outgoing packets. */ +static long +get_remote_packet_size (void) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + + if (rs->explicit_packet_size) + return rs->explicit_packet_size; + + return rsa->remote_packet_size; +} + +static struct packet_reg * +packet_reg_from_regnum (struct remote_arch_state *rsa, long regnum) +{ + if (regnum < 0 && regnum >= gdbarch_num_regs (current_gdbarch)) + return NULL; + else + { + struct packet_reg *r = &rsa->regs[regnum]; + gdb_assert (r->regnum == regnum); + return r; + } +} + +static struct packet_reg * +packet_reg_from_pnum (struct remote_arch_state *rsa, LONGEST pnum) +{ + int i; + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + { + struct packet_reg *r = &rsa->regs[i]; + if (r->pnum == pnum) + return r; + } + return NULL; +} + +/* FIXME: graces/2002-08-08: These variables should eventually be + bound to an instance of the target object (as in gdbarch-tdep()), + when such a thing exists. */ + +/* This is set to the data address of the access causing the target + to stop for a watchpoint. */ +static CORE_ADDR remote_watch_data_address; + +/* This is non-zero if target stopped for a watchpoint. */ +static int remote_stopped_by_watchpoint_p; + +static struct target_ops remote_ops; + +static struct target_ops extended_remote_ops; + +/* Temporary target ops. Just like the remote_ops and + extended_remote_ops, but with asynchronous support. */ +static struct target_ops remote_async_ops; + +static struct target_ops extended_async_remote_ops; + +/* FIXME: cagney/1999-09-23: Even though getpkt was called with + ``forever'' still use the normal timeout mechanism. This is + currently used by the ASYNC code to guarentee that target reads + during the initial connect always time-out. Once getpkt has been + modified to return a timeout indication and, in turn + remote_wait()/wait_for_inferior() have gained a timeout parameter + this can go away. */ +static int wait_forever_enabled_p = 1; + + +/* This variable chooses whether to send a ^C or a break when the user + requests program interruption. Although ^C is usually what remote + systems expect, and that is the default here, sometimes a break is + preferable instead. */ + +static int remote_break; + +/* Descriptor for I/O to remote machine. Initialize it to NULL so that + remote_open knows that we don't have a file open when the program + starts. */ +static struct serial *remote_desc = NULL; + +/* This variable sets the number of bits in an address that are to be + sent in a memory ("M" or "m") packet. Normally, after stripping + leading zeros, the entire address would be sent. This variable + restricts the address to REMOTE_ADDRESS_SIZE bits. HISTORY: The + initial implementation of remote.c restricted the address sent in + memory packets to ``host::sizeof long'' bytes - (typically 32 + bits). Consequently, for 64 bit targets, the upper 32 bits of an + address was never sent. Since fixing this bug may cause a break in + some remote targets this variable is principly provided to + facilitate backward compatibility. */ + +static int remote_address_size; + +/* Tempoary to track who currently owns the terminal. See + target_async_terminal_* for more details. */ + +static int remote_async_terminal_ours_p; + + +/* User configurable variables for the number of characters in a + memory read/write packet. MIN (rsa->remote_packet_size, + rsa->sizeof_g_packet) is the default. Some targets need smaller + values (fifo overruns, et.al.) and some users need larger values + (speed up transfers). The variables ``preferred_*'' (the user + request), ``current_*'' (what was actually set) and ``forced_*'' + (Positive - a soft limit, negative - a hard limit). */ + +struct memory_packet_config +{ + char *name; + long size; + int fixed_p; +}; + +/* Compute the current size of a read/write packet. Since this makes + use of ``actual_register_packet_size'' the computation is dynamic. */ + +static long +get_memory_packet_size (struct memory_packet_config *config) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + + /* NOTE: The somewhat arbitrary 16k comes from the knowledge (folk + law?) that some hosts don't cope very well with large alloca() + calls. Eventually the alloca() code will be replaced by calls to + xmalloc() and make_cleanups() allowing this restriction to either + be lifted or removed. */ +#ifndef MAX_REMOTE_PACKET_SIZE +#define MAX_REMOTE_PACKET_SIZE 16384 +#endif + /* NOTE: 20 ensures we can write at least one byte. */ +#ifndef MIN_REMOTE_PACKET_SIZE +#define MIN_REMOTE_PACKET_SIZE 20 +#endif + long what_they_get; + if (config->fixed_p) + { + if (config->size <= 0) + what_they_get = MAX_REMOTE_PACKET_SIZE; + else + what_they_get = config->size; + } + else + { + what_they_get = get_remote_packet_size (); + /* Limit the packet to the size specified by the user. */ + if (config->size > 0 + && what_they_get > config->size) + what_they_get = config->size; + + /* Limit it to the size of the targets ``g'' response unless we have + permission from the stub to use a larger packet size. */ + if (rs->explicit_packet_size == 0 + && rsa->actual_register_packet_size > 0 + && what_they_get > rsa->actual_register_packet_size) + what_they_get = rsa->actual_register_packet_size; + } + if (what_they_get > MAX_REMOTE_PACKET_SIZE) + what_they_get = MAX_REMOTE_PACKET_SIZE; + if (what_they_get < MIN_REMOTE_PACKET_SIZE) + what_they_get = MIN_REMOTE_PACKET_SIZE; + + /* Make sure there is room in the global buffer for this packet + (including its trailing NUL byte). */ + if (rs->buf_size < what_they_get + 1) + { + rs->buf_size = 2 * what_they_get; + rs->buf = xrealloc (rs->buf, 2 * what_they_get); + } + + return what_they_get; +} + +/* Update the size of a read/write packet. If they user wants + something really big then do a sanity check. */ + +static void +set_memory_packet_size (char *args, struct memory_packet_config *config) +{ + int fixed_p = config->fixed_p; + long size = config->size; + if (args == NULL) + error (_("Argument required (integer, `fixed' or `limited').")); + else if (strcmp (args, "hard") == 0 + || strcmp (args, "fixed") == 0) + fixed_p = 1; + else if (strcmp (args, "soft") == 0 + || strcmp (args, "limit") == 0) + fixed_p = 0; + else + { + char *end; + size = strtoul (args, &end, 0); + if (args == end) + error (_("Invalid %s (bad syntax)."), config->name); +#if 0 + /* Instead of explicitly capping the size of a packet to + MAX_REMOTE_PACKET_SIZE or dissallowing it, the user is + instead allowed to set the size to something arbitrarily + large. */ + if (size > MAX_REMOTE_PACKET_SIZE) + error (_("Invalid %s (too large)."), config->name); +#endif + } + /* Extra checks? */ + if (fixed_p && !config->fixed_p) + { + if (! query (_("The target may not be able to correctly handle a %s\n" + "of %ld bytes. Change the packet size? "), + config->name, size)) + error (_("Packet size not changed.")); + } + /* Update the config. */ + config->fixed_p = fixed_p; + config->size = size; +} + +static void +show_memory_packet_size (struct memory_packet_config *config) +{ + printf_filtered (_("The %s is %ld. "), config->name, config->size); + if (config->fixed_p) + printf_filtered (_("Packets are fixed at %ld bytes.\n"), + get_memory_packet_size (config)); + else + printf_filtered (_("Packets are limited to %ld bytes.\n"), + get_memory_packet_size (config)); +} + +static struct memory_packet_config memory_write_packet_config = +{ + "memory-write-packet-size", +}; + +static void +set_memory_write_packet_size (char *args, int from_tty) +{ + set_memory_packet_size (args, &memory_write_packet_config); +} + +static void +show_memory_write_packet_size (char *args, int from_tty) +{ + show_memory_packet_size (&memory_write_packet_config); +} + +static long +get_memory_write_packet_size (void) +{ + return get_memory_packet_size (&memory_write_packet_config); +} + +static struct memory_packet_config memory_read_packet_config = +{ + "memory-read-packet-size", +}; + +static void +set_memory_read_packet_size (char *args, int from_tty) +{ + set_memory_packet_size (args, &memory_read_packet_config); +} + +static void +show_memory_read_packet_size (char *args, int from_tty) +{ + show_memory_packet_size (&memory_read_packet_config); +} + +static long +get_memory_read_packet_size (void) +{ + long size = get_memory_packet_size (&memory_read_packet_config); + /* FIXME: cagney/1999-11-07: Functions like getpkt() need to get an + extra buffer size argument before the memory read size can be + increased beyond this. */ + if (size > get_remote_packet_size ()) + size = get_remote_packet_size (); + return size; +} + + +/* Generic configuration support for packets the stub optionally + supports. Allows the user to specify the use of the packet as well + as allowing GDB to auto-detect support in the remote stub. */ + +enum packet_support + { + PACKET_SUPPORT_UNKNOWN = 0, + PACKET_ENABLE, + PACKET_DISABLE + }; + +struct packet_config + { + const char *name; + const char *title; + enum auto_boolean detect; + enum packet_support support; + }; + +/* Analyze a packet's return value and update the packet config + accordingly. */ + +enum packet_result +{ + PACKET_ERROR, + PACKET_OK, + PACKET_UNKNOWN +}; + +static void +update_packet_config (struct packet_config *config) +{ + switch (config->detect) + { + case AUTO_BOOLEAN_TRUE: + config->support = PACKET_ENABLE; + break; + case AUTO_BOOLEAN_FALSE: + config->support = PACKET_DISABLE; + break; + case AUTO_BOOLEAN_AUTO: + config->support = PACKET_SUPPORT_UNKNOWN; + break; + } +} + +static void +show_packet_config_cmd (struct packet_config *config) +{ + char *support = "internal-error"; + switch (config->support) + { + case PACKET_ENABLE: + support = "enabled"; + break; + case PACKET_DISABLE: + support = "disabled"; + break; + case PACKET_SUPPORT_UNKNOWN: + support = "unknown"; + break; + } + switch (config->detect) + { + case AUTO_BOOLEAN_AUTO: + printf_filtered (_("Support for the `%s' packet is auto-detected, currently %s.\n"), + config->name, support); + break; + case AUTO_BOOLEAN_TRUE: + case AUTO_BOOLEAN_FALSE: + printf_filtered (_("Support for the `%s' packet is currently %s.\n"), + config->name, support); + break; + } +} + +static void +add_packet_config_cmd (struct packet_config *config, const char *name, + const char *title, int legacy) +{ + char *set_doc; + char *show_doc; + char *cmd_name; + + config->name = name; + config->title = title; + config->detect = AUTO_BOOLEAN_AUTO; + config->support = PACKET_SUPPORT_UNKNOWN; + set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet", + name, title); + show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet", + name, title); + /* set/show TITLE-packet {auto,on,off} */ + cmd_name = xstrprintf ("%s-packet", title); + add_setshow_auto_boolean_cmd (cmd_name, class_obscure, + &config->detect, set_doc, show_doc, NULL, /* help_doc */ + set_remote_protocol_packet_cmd, + show_remote_protocol_packet_cmd, + &remote_set_cmdlist, &remote_show_cmdlist); + /* set/show remote NAME-packet {auto,on,off} -- legacy. */ + if (legacy) + { + char *legacy_name; + legacy_name = xstrprintf ("%s-packet", name); + add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, + &remote_set_cmdlist); + add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, + &remote_show_cmdlist); + } +} + +static enum packet_result +packet_check_result (const char *buf) +{ + if (buf[0] != '\0') + { + /* The stub recognized the packet request. Check that the + operation succeeded. */ + if (buf[0] == 'E' + && isxdigit (buf[1]) && isxdigit (buf[2]) + && buf[3] == '\0') + /* "Enn" - definitly an error. */ + return PACKET_ERROR; + + /* Always treat "E." as an error. This will be used for + more verbose error messages, such as E.memtypes. */ + if (buf[0] == 'E' && buf[1] == '.') + return PACKET_ERROR; + + /* The packet may or may not be OK. Just assume it is. */ + return PACKET_OK; + } + else + /* The stub does not support the packet. */ + return PACKET_UNKNOWN; +} + +static enum packet_result +packet_ok (const char *buf, struct packet_config *config) +{ + enum packet_result result; + + result = packet_check_result (buf); + switch (result) + { + case PACKET_OK: + case PACKET_ERROR: + /* The stub recognized the packet request. */ + switch (config->support) + { + case PACKET_SUPPORT_UNKNOWN: + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "Packet %s (%s) is supported\n", + config->name, config->title); + config->support = PACKET_ENABLE; + break; + case PACKET_DISABLE: + internal_error (__FILE__, __LINE__, + _("packet_ok: attempt to use a disabled packet")); + break; + case PACKET_ENABLE: + break; + } + break; + case PACKET_UNKNOWN: + /* The stub does not support the packet. */ + switch (config->support) + { + case PACKET_ENABLE: + if (config->detect == AUTO_BOOLEAN_AUTO) + /* If the stub previously indicated that the packet was + supported then there is a protocol error.. */ + error (_("Protocol error: %s (%s) conflicting enabled responses."), + config->name, config->title); + else + /* The user set it wrong. */ + error (_("Enabled packet %s (%s) not recognized by stub"), + config->name, config->title); + break; + case PACKET_SUPPORT_UNKNOWN: + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "Packet %s (%s) is NOT supported\n", + config->name, config->title); + config->support = PACKET_DISABLE; + break; + case PACKET_DISABLE: + break; + } + break; + } + + return result; +} + +enum { + PACKET_vCont = 0, + PACKET_X, + PACKET_qSymbol, + PACKET_P, + PACKET_p, + PACKET_Z0, + PACKET_Z1, + PACKET_Z2, + PACKET_Z3, + PACKET_Z4, + PACKET_qXfer_auxv, + PACKET_qXfer_features, + PACKET_qXfer_libraries, + PACKET_qXfer_memory_map, + PACKET_qXfer_spu_read, + PACKET_qXfer_spu_write, + PACKET_qGetTLSAddr, + PACKET_qSupported, + PACKET_QPassSignals, + PACKET_MAX +}; + +static struct packet_config remote_protocol_packets[PACKET_MAX]; + +static void +set_remote_protocol_packet_cmd (char *args, int from_tty, + struct cmd_list_element *c) +{ + struct packet_config *packet; + + for (packet = remote_protocol_packets; + packet < &remote_protocol_packets[PACKET_MAX]; + packet++) + { + if (&packet->detect == c->var) + { + update_packet_config (packet); + return; + } + } + internal_error (__FILE__, __LINE__, "Could not find config for %s", + c->name); +} + +static void +show_remote_protocol_packet_cmd (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + struct packet_config *packet; + + for (packet = remote_protocol_packets; + packet < &remote_protocol_packets[PACKET_MAX]; + packet++) + { + if (&packet->detect == c->var) + { + show_packet_config_cmd (packet); + return; + } + } + internal_error (__FILE__, __LINE__, "Could not find config for %s", + c->name); +} + +/* Should we try one of the 'Z' requests? */ + +enum Z_packet_type +{ + Z_PACKET_SOFTWARE_BP, + Z_PACKET_HARDWARE_BP, + Z_PACKET_WRITE_WP, + Z_PACKET_READ_WP, + Z_PACKET_ACCESS_WP, + NR_Z_PACKET_TYPES +}; + +/* For compatibility with older distributions. Provide a ``set remote + Z-packet ...'' command that updates all the Z packet types. */ + +static enum auto_boolean remote_Z_packet_detect; + +static void +set_remote_protocol_Z_packet_cmd (char *args, int from_tty, + struct cmd_list_element *c) +{ + int i; + for (i = 0; i < NR_Z_PACKET_TYPES; i++) + { + remote_protocol_packets[PACKET_Z0 + i].detect = remote_Z_packet_detect; + update_packet_config (&remote_protocol_packets[PACKET_Z0 + i]); + } +} + +static void +show_remote_protocol_Z_packet_cmd (struct ui_file *file, int from_tty, + struct cmd_list_element *c, + const char *value) +{ + int i; + for (i = 0; i < NR_Z_PACKET_TYPES; i++) + { + show_packet_config_cmd (&remote_protocol_packets[PACKET_Z0 + i]); + } +} + +/* Should we try the 'ThreadInfo' query packet? + + This variable (NOT available to the user: auto-detect only!) + determines whether GDB will use the new, simpler "ThreadInfo" + query or the older, more complex syntax for thread queries. + This is an auto-detect variable (set to true at each connect, + and set to false when the target fails to recognize it). */ + +static int use_threadinfo_query; +static int use_threadextra_query; + +/* Tokens for use by the asynchronous signal handlers for SIGINT. */ +static struct async_signal_handler *sigint_remote_twice_token; +static struct async_signal_handler *sigint_remote_token; + +/* These are pointers to hook functions that may be set in order to + modify resume/wait behavior for a particular architecture. */ + +void (*deprecated_target_resume_hook) (void); +void (*deprecated_target_wait_loop_hook) (void); + + + +/* These are the threads which we last sent to the remote system. + -1 for all or -2 for not sent yet. */ +static int general_thread; +static int continue_thread; + +/* Call this function as a result of + 1) A halt indication (T packet) containing a thread id + 2) A direct query of currthread + 3) Successful execution of set thread + */ + +static void +record_currthread (int currthread) +{ + general_thread = currthread; + + /* If this is a new thread, add it to GDB's thread list. + If we leave it up to WFI to do this, bad things will happen. */ + if (!in_thread_list (pid_to_ptid (currthread))) + { + add_thread (pid_to_ptid (currthread)); + ui_out_text (uiout, "[New "); + ui_out_text (uiout, target_pid_to_str (pid_to_ptid (currthread))); + ui_out_text (uiout, "]\n"); + } +} + +static char *last_pass_packet; + +/* If 'QPassSignals' is supported, tell the remote stub what signals + it can simply pass through to the inferior without reporting. */ + +static void +remote_pass_signals (void) +{ + if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE) + { + char *pass_packet, *p; + int numsigs = (int) TARGET_SIGNAL_LAST; + int count = 0, i; + + gdb_assert (numsigs < 256); + for (i = 0; i < numsigs; i++) + { + if (signal_stop_state (i) == 0 + && signal_print_state (i) == 0 + && signal_pass_state (i) == 1) + count++; + } + pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1); + strcpy (pass_packet, "QPassSignals:"); + p = pass_packet + strlen (pass_packet); + for (i = 0; i < numsigs; i++) + { + if (signal_stop_state (i) == 0 + && signal_print_state (i) == 0 + && signal_pass_state (i) == 1) + { + if (i >= 16) + *p++ = tohex (i >> 4); + *p++ = tohex (i & 15); + if (count) + *p++ = ';'; + else + break; + count--; + } + } + *p = 0; + if (!last_pass_packet || strcmp (last_pass_packet, pass_packet)) + { + struct remote_state *rs = get_remote_state (); + char *buf = rs->buf; + + putpkt (pass_packet); + getpkt (&rs->buf, &rs->buf_size, 0); + packet_ok (buf, &remote_protocol_packets[PACKET_QPassSignals]); + if (last_pass_packet) + xfree (last_pass_packet); + last_pass_packet = pass_packet; + } + else + xfree (pass_packet); + } +} + +#define MAGIC_NULL_PID 42000 + +static void +set_thread (int th, int gen) +{ + struct remote_state *rs = get_remote_state (); + char *buf = rs->buf; + int state = gen ? general_thread : continue_thread; + + if (state == th) + return; + + buf[0] = 'H'; + buf[1] = gen ? 'g' : 'c'; + if (th == MAGIC_NULL_PID) + { + buf[2] = '0'; + buf[3] = '\0'; + } + else if (th < 0) + xsnprintf (&buf[2], get_remote_packet_size () - 2, "-%x", -th); + else + xsnprintf (&buf[2], get_remote_packet_size () - 2, "%x", th); + putpkt (buf); + getpkt (&rs->buf, &rs->buf_size, 0); + if (gen) + general_thread = th; + else + continue_thread = th; +} + +/* Return nonzero if the thread TH is still alive on the remote system. */ + +static int +remote_thread_alive (ptid_t ptid) +{ + struct remote_state *rs = get_remote_state (); + int tid = PIDGET (ptid); + + if (tid < 0) + xsnprintf (rs->buf, get_remote_packet_size (), "T-%08x", -tid); + else + xsnprintf (rs->buf, get_remote_packet_size (), "T%08x", tid); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + return (rs->buf[0] == 'O' && rs->buf[1] == 'K'); +} + +/* About these extended threadlist and threadinfo packets. They are + variable length packets but, the fields within them are often fixed + length. They are redundent enough to send over UDP as is the + remote protocol in general. There is a matching unit test module + in libstub. */ + +#define OPAQUETHREADBYTES 8 + +/* a 64 bit opaque identifier */ +typedef unsigned char threadref[OPAQUETHREADBYTES]; + +/* WARNING: This threadref data structure comes from the remote O.S., + libstub protocol encoding, and remote.c. it is not particularly + changable. */ + +/* Right now, the internal structure is int. We want it to be bigger. + Plan to fix this. + */ + +typedef int gdb_threadref; /* Internal GDB thread reference. */ + +/* gdb_ext_thread_info is an internal GDB data structure which is + equivalent to the reply of the remote threadinfo packet. */ + +struct gdb_ext_thread_info + { + threadref threadid; /* External form of thread reference. */ + int active; /* Has state interesting to GDB? + regs, stack. */ + char display[256]; /* Brief state display, name, + blocked/suspended. */ + char shortname[32]; /* To be used to name threads. */ + char more_display[256]; /* Long info, statistics, queue depth, + whatever. */ + }; + +/* The volume of remote transfers can be limited by submitting + a mask containing bits specifying the desired information. + Use a union of these values as the 'selection' parameter to + get_thread_info. FIXME: Make these TAG names more thread specific. + */ + +#define TAG_THREADID 1 +#define TAG_EXISTS 2 +#define TAG_DISPLAY 4 +#define TAG_THREADNAME 8 +#define TAG_MOREDISPLAY 16 + +#define BUF_THREAD_ID_SIZE (OPAQUETHREADBYTES * 2) + +char *unpack_varlen_hex (char *buff, ULONGEST *result); + +static char *unpack_nibble (char *buf, int *val); + +static char *pack_nibble (char *buf, int nibble); + +static char *pack_hex_byte (char *pkt, int /* unsigned char */ byte); + +static char *unpack_byte (char *buf, int *value); + +static char *pack_int (char *buf, int value); + +static char *unpack_int (char *buf, int *value); + +static char *unpack_string (char *src, char *dest, int length); + +static char *pack_threadid (char *pkt, threadref *id); + +static char *unpack_threadid (char *inbuf, threadref *id); + +void int_to_threadref (threadref *id, int value); + +static int threadref_to_int (threadref *ref); + +static void copy_threadref (threadref *dest, threadref *src); + +static int threadmatch (threadref *dest, threadref *src); + +static char *pack_threadinfo_request (char *pkt, int mode, + threadref *id); + +static int remote_unpack_thread_info_response (char *pkt, + threadref *expectedref, + struct gdb_ext_thread_info + *info); + + +static int remote_get_threadinfo (threadref *threadid, + int fieldset, /*TAG mask */ + struct gdb_ext_thread_info *info); + +static char *pack_threadlist_request (char *pkt, int startflag, + int threadcount, + threadref *nextthread); + +static int parse_threadlist_response (char *pkt, + int result_limit, + threadref *original_echo, + threadref *resultlist, + int *doneflag); + +static int remote_get_threadlist (int startflag, + threadref *nextthread, + int result_limit, + int *done, + int *result_count, + threadref *threadlist); + +typedef int (*rmt_thread_action) (threadref *ref, void *context); + +static int remote_threadlist_iterator (rmt_thread_action stepfunction, + void *context, int looplimit); + +static int remote_newthread_step (threadref *ref, void *context); + +/* Encode 64 bits in 16 chars of hex. */ + +static const char hexchars[] = "0123456789abcdef"; + +static int +ishex (int ch, int *val) +{ + if ((ch >= 'a') && (ch <= 'f')) + { + *val = ch - 'a' + 10; + return 1; + } + if ((ch >= 'A') && (ch <= 'F')) + { + *val = ch - 'A' + 10; + return 1; + } + if ((ch >= '0') && (ch <= '9')) + { + *val = ch - '0'; + return 1; + } + return 0; +} + +static int +stubhex (int ch) +{ + if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + if (ch >= '0' && ch <= '9') + return ch - '0'; + if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + return -1; +} + +static int +stub_unpack_int (char *buff, int fieldlength) +{ + int nibble; + int retval = 0; + + while (fieldlength) + { + nibble = stubhex (*buff++); + retval |= nibble; + fieldlength--; + if (fieldlength) + retval = retval << 4; + } + return retval; +} + +char * +unpack_varlen_hex (char *buff, /* packet to parse */ + ULONGEST *result) +{ + int nibble; + ULONGEST retval = 0; + + while (ishex (*buff, &nibble)) + { + buff++; + retval = retval << 4; + retval |= nibble & 0x0f; + } + *result = retval; + return buff; +} + +static char * +unpack_nibble (char *buf, int *val) +{ + ishex (*buf++, val); + return buf; +} + +static char * +pack_nibble (char *buf, int nibble) +{ + *buf++ = hexchars[(nibble & 0x0f)]; + return buf; +} + +static char * +pack_hex_byte (char *pkt, int byte) +{ + *pkt++ = hexchars[(byte >> 4) & 0xf]; + *pkt++ = hexchars[(byte & 0xf)]; + return pkt; +} + +static char * +unpack_byte (char *buf, int *value) +{ + *value = stub_unpack_int (buf, 2); + return buf + 2; +} + +static char * +pack_int (char *buf, int value) +{ + buf = pack_hex_byte (buf, (value >> 24) & 0xff); + buf = pack_hex_byte (buf, (value >> 16) & 0xff); + buf = pack_hex_byte (buf, (value >> 8) & 0x0ff); + buf = pack_hex_byte (buf, (value & 0xff)); + return buf; +} + +static char * +unpack_int (char *buf, int *value) +{ + *value = stub_unpack_int (buf, 8); + return buf + 8; +} + +#if 0 /* Currently unused, uncomment when needed. */ +static char *pack_string (char *pkt, char *string); + +static char * +pack_string (char *pkt, char *string) +{ + char ch; + int len; + + len = strlen (string); + if (len > 200) + len = 200; /* Bigger than most GDB packets, junk??? */ + pkt = pack_hex_byte (pkt, len); + while (len-- > 0) + { + ch = *string++; + if ((ch == '\0') || (ch == '#')) + ch = '*'; /* Protect encapsulation. */ + *pkt++ = ch; + } + return pkt; +} +#endif /* 0 (unused) */ + +static char * +unpack_string (char *src, char *dest, int length) +{ + while (length--) + *dest++ = *src++; + *dest = '\0'; + return src; +} + +static char * +pack_threadid (char *pkt, threadref *id) +{ + char *limit; + unsigned char *altid; + + altid = (unsigned char *) id; + limit = pkt + BUF_THREAD_ID_SIZE; + while (pkt < limit) + pkt = pack_hex_byte (pkt, *altid++); + return pkt; +} + + +static char * +unpack_threadid (char *inbuf, threadref *id) +{ + char *altref; + char *limit = inbuf + BUF_THREAD_ID_SIZE; + int x, y; + + altref = (char *) id; + + while (inbuf < limit) + { + x = stubhex (*inbuf++); + y = stubhex (*inbuf++); + *altref++ = (x << 4) | y; + } + return inbuf; +} + +/* Externally, threadrefs are 64 bits but internally, they are still + ints. This is due to a mismatch of specifications. We would like + to use 64bit thread references internally. This is an adapter + function. */ + +void +int_to_threadref (threadref *id, int value) +{ + unsigned char *scan; + + scan = (unsigned char *) id; + { + int i = 4; + while (i--) + *scan++ = 0; + } + *scan++ = (value >> 24) & 0xff; + *scan++ = (value >> 16) & 0xff; + *scan++ = (value >> 8) & 0xff; + *scan++ = (value & 0xff); +} + +static int +threadref_to_int (threadref *ref) +{ + int i, value = 0; + unsigned char *scan; + + scan = *ref; + scan += 4; + i = 4; + while (i-- > 0) + value = (value << 8) | ((*scan++) & 0xff); + return value; +} + +static void +copy_threadref (threadref *dest, threadref *src) +{ + int i; + unsigned char *csrc, *cdest; + + csrc = (unsigned char *) src; + cdest = (unsigned char *) dest; + i = 8; + while (i--) + *cdest++ = *csrc++; +} + +static int +threadmatch (threadref *dest, threadref *src) +{ + /* Things are broken right now, so just assume we got a match. */ +#if 0 + unsigned char *srcp, *destp; + int i, result; + srcp = (char *) src; + destp = (char *) dest; + + result = 1; + while (i-- > 0) + result &= (*srcp++ == *destp++) ? 1 : 0; + return result; +#endif + return 1; +} + +/* + threadid:1, # always request threadid + context_exists:2, + display:4, + unique_name:8, + more_display:16 + */ + +/* Encoding: 'Q':8,'P':8,mask:32,threadid:64 */ + +static char * +pack_threadinfo_request (char *pkt, int mode, threadref *id) +{ + *pkt++ = 'q'; /* Info Query */ + *pkt++ = 'P'; /* process or thread info */ + pkt = pack_int (pkt, mode); /* mode */ + pkt = pack_threadid (pkt, id); /* threadid */ + *pkt = '\0'; /* terminate */ + return pkt; +} + +/* These values tag the fields in a thread info response packet. */ +/* Tagging the fields allows us to request specific fields and to + add more fields as time goes by. */ + +#define TAG_THREADID 1 /* Echo the thread identifier. */ +#define TAG_EXISTS 2 /* Is this process defined enough to + fetch registers and its stack? */ +#define TAG_DISPLAY 4 /* A short thing maybe to put on a window */ +#define TAG_THREADNAME 8 /* string, maps 1-to-1 with a thread is. */ +#define TAG_MOREDISPLAY 16 /* Whatever the kernel wants to say about + the process. */ + +static int +remote_unpack_thread_info_response (char *pkt, threadref *expectedref, + struct gdb_ext_thread_info *info) +{ + struct remote_state *rs = get_remote_state (); + int mask, length; + int tag; + threadref ref; + char *limit = pkt + rs->buf_size; /* Plausible parsing limit. */ + int retval = 1; + + /* info->threadid = 0; FIXME: implement zero_threadref. */ + info->active = 0; + info->display[0] = '\0'; + info->shortname[0] = '\0'; + info->more_display[0] = '\0'; + + /* Assume the characters indicating the packet type have been + stripped. */ + pkt = unpack_int (pkt, &mask); /* arg mask */ + pkt = unpack_threadid (pkt, &ref); + + if (mask == 0) + warning (_("Incomplete response to threadinfo request.")); + if (!threadmatch (&ref, expectedref)) + { /* This is an answer to a different request. */ + warning (_("ERROR RMT Thread info mismatch.")); + return 0; + } + copy_threadref (&info->threadid, &ref); + + /* Loop on tagged fields , try to bail if somthing goes wrong. */ + + /* Packets are terminated with nulls. */ + while ((pkt < limit) && mask && *pkt) + { + pkt = unpack_int (pkt, &tag); /* tag */ + pkt = unpack_byte (pkt, &length); /* length */ + if (!(tag & mask)) /* Tags out of synch with mask. */ + { + warning (_("ERROR RMT: threadinfo tag mismatch.")); + retval = 0; + break; + } + if (tag == TAG_THREADID) + { + if (length != 16) + { + warning (_("ERROR RMT: length of threadid is not 16.")); + retval = 0; + break; + } + pkt = unpack_threadid (pkt, &ref); + mask = mask & ~TAG_THREADID; + continue; + } + if (tag == TAG_EXISTS) + { + info->active = stub_unpack_int (pkt, length); + pkt += length; + mask = mask & ~(TAG_EXISTS); + if (length > 8) + { + warning (_("ERROR RMT: 'exists' length too long.")); + retval = 0; + break; + } + continue; + } + if (tag == TAG_THREADNAME) + { + pkt = unpack_string (pkt, &info->shortname[0], length); + mask = mask & ~TAG_THREADNAME; + continue; + } + if (tag == TAG_DISPLAY) + { + pkt = unpack_string (pkt, &info->display[0], length); + mask = mask & ~TAG_DISPLAY; + continue; + } + if (tag == TAG_MOREDISPLAY) + { + pkt = unpack_string (pkt, &info->more_display[0], length); + mask = mask & ~TAG_MOREDISPLAY; + continue; + } + warning (_("ERROR RMT: unknown thread info tag.")); + break; /* Not a tag we know about. */ + } + return retval; +} + +static int +remote_get_threadinfo (threadref *threadid, int fieldset, /* TAG mask */ + struct gdb_ext_thread_info *info) +{ + struct remote_state *rs = get_remote_state (); + int result; + + pack_threadinfo_request (rs->buf, fieldset, threadid); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + result = remote_unpack_thread_info_response (rs->buf + 2, + threadid, info); + return result; +} + +/* Format: i'Q':8,i"L":8,initflag:8,batchsize:16,lastthreadid:32 */ + +static char * +pack_threadlist_request (char *pkt, int startflag, int threadcount, + threadref *nextthread) +{ + *pkt++ = 'q'; /* info query packet */ + *pkt++ = 'L'; /* Process LIST or threadLIST request */ + pkt = pack_nibble (pkt, startflag); /* initflag 1 bytes */ + pkt = pack_hex_byte (pkt, threadcount); /* threadcount 2 bytes */ + pkt = pack_threadid (pkt, nextthread); /* 64 bit thread identifier */ + *pkt = '\0'; + return pkt; +} + +/* Encoding: 'q':8,'M':8,count:16,done:8,argthreadid:64,(threadid:64)* */ + +static int +parse_threadlist_response (char *pkt, int result_limit, + threadref *original_echo, threadref *resultlist, + int *doneflag) +{ + struct remote_state *rs = get_remote_state (); + char *limit; + int count, resultcount, done; + + resultcount = 0; + /* Assume the 'q' and 'M chars have been stripped. */ + limit = pkt + (rs->buf_size - BUF_THREAD_ID_SIZE); + /* done parse past here */ + pkt = unpack_byte (pkt, &count); /* count field */ + pkt = unpack_nibble (pkt, &done); + /* The first threadid is the argument threadid. */ + pkt = unpack_threadid (pkt, original_echo); /* should match query packet */ + while ((count-- > 0) && (pkt < limit)) + { + pkt = unpack_threadid (pkt, resultlist++); + if (resultcount++ >= result_limit) + break; + } + if (doneflag) + *doneflag = done; + return resultcount; +} + +static int +remote_get_threadlist (int startflag, threadref *nextthread, int result_limit, + int *done, int *result_count, threadref *threadlist) +{ + struct remote_state *rs = get_remote_state (); + static threadref echo_nextthread; + int result = 1; + + /* Trancate result limit to be smaller than the packet size. */ + if ((((result_limit + 1) * BUF_THREAD_ID_SIZE) + 10) >= get_remote_packet_size ()) + result_limit = (get_remote_packet_size () / BUF_THREAD_ID_SIZE) - 2; + + pack_threadlist_request (rs->buf, startflag, result_limit, nextthread); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + *result_count = + parse_threadlist_response (rs->buf + 2, result_limit, &echo_nextthread, + threadlist, done); + + if (!threadmatch (&echo_nextthread, nextthread)) + { + /* FIXME: This is a good reason to drop the packet. */ + /* Possably, there is a duplicate response. */ + /* Possabilities : + retransmit immediatly - race conditions + retransmit after timeout - yes + exit + wait for packet, then exit + */ + warning (_("HMM: threadlist did not echo arg thread, dropping it.")); + return 0; /* I choose simply exiting. */ + } + if (*result_count <= 0) + { + if (*done != 1) + { + warning (_("RMT ERROR : failed to get remote thread list.")); + result = 0; + } + return result; /* break; */ + } + if (*result_count > result_limit) + { + *result_count = 0; + warning (_("RMT ERROR: threadlist response longer than requested.")); + return 0; + } + return result; +} + +/* This is the interface between remote and threads, remotes upper + interface. */ + +/* remote_find_new_threads retrieves the thread list and for each + thread in the list, looks up the thread in GDB's internal list, + ading the thread if it does not already exist. This involves + getting partial thread lists from the remote target so, polling the + quit_flag is required. */ + + +/* About this many threadisds fit in a packet. */ + +#define MAXTHREADLISTRESULTS 32 + +static int +remote_threadlist_iterator (rmt_thread_action stepfunction, void *context, + int looplimit) +{ + int done, i, result_count; + int startflag = 1; + int result = 1; + int loopcount = 0; + static threadref nextthread; + static threadref resultthreadlist[MAXTHREADLISTRESULTS]; + + done = 0; + while (!done) + { + if (loopcount++ > looplimit) + { + result = 0; + warning (_("Remote fetch threadlist -infinite loop-.")); + break; + } + if (!remote_get_threadlist (startflag, &nextthread, MAXTHREADLISTRESULTS, + &done, &result_count, resultthreadlist)) + { + result = 0; + break; + } + /* Clear for later iterations. */ + startflag = 0; + /* Setup to resume next batch of thread references, set nextthread. */ + if (result_count >= 1) + copy_threadref (&nextthread, &resultthreadlist[result_count - 1]); + i = 0; + while (result_count--) + if (!(result = (*stepfunction) (&resultthreadlist[i++], context))) + break; + } + return result; +} + +static int +remote_newthread_step (threadref *ref, void *context) +{ + ptid_t ptid; + + ptid = pid_to_ptid (threadref_to_int (ref)); + + if (!in_thread_list (ptid)) + add_thread (ptid); + return 1; /* continue iterator */ +} + +#define CRAZY_MAX_THREADS 1000 + +static ptid_t +remote_current_thread (ptid_t oldpid) +{ + struct remote_state *rs = get_remote_state (); + + putpkt ("qC"); + getpkt (&rs->buf, &rs->buf_size, 0); + if (rs->buf[0] == 'Q' && rs->buf[1] == 'C') + /* Use strtoul here, so we'll correctly parse values whose highest + bit is set. The protocol carries them as a simple series of + hex digits; in the absence of a sign, strtol will see such + values as positive numbers out of range for signed 'long', and + return LONG_MAX to indicate an overflow. */ + return pid_to_ptid (strtoul (&rs->buf[2], NULL, 16)); + else + return oldpid; +} + +/* Find new threads for info threads command. + * Original version, using John Metzler's thread protocol. + */ + +static void +remote_find_new_threads (void) +{ + remote_threadlist_iterator (remote_newthread_step, 0, + CRAZY_MAX_THREADS); + if (PIDGET (inferior_ptid) == MAGIC_NULL_PID) /* ack ack ack */ + inferior_ptid = remote_current_thread (inferior_ptid); +} + +/* + * Find all threads for info threads command. + * Uses new thread protocol contributed by Cisco. + * Falls back and attempts to use the older method (above) + * if the target doesn't respond to the new method. + */ + +static void +remote_threads_info (void) +{ + struct remote_state *rs = get_remote_state (); + char *bufp; + int tid; + + if (remote_desc == 0) /* paranoia */ + error (_("Command can only be used when connected to the remote target.")); + + if (use_threadinfo_query) + { + putpkt ("qfThreadInfo"); + getpkt (&rs->buf, &rs->buf_size, 0); + bufp = rs->buf; + if (bufp[0] != '\0') /* q packet recognized */ + { + while (*bufp++ == 'm') /* reply contains one or more TID */ + { + do + { + /* Use strtoul here, so we'll correctly parse values + whose highest bit is set. The protocol carries + them as a simple series of hex digits; in the + absence of a sign, strtol will see such values as + positive numbers out of range for signed 'long', + and return LONG_MAX to indicate an overflow. */ + tid = strtoul (bufp, &bufp, 16); + if (tid != 0 && !in_thread_list (pid_to_ptid (tid))) + add_thread (pid_to_ptid (tid)); + } + while (*bufp++ == ','); /* comma-separated list */ + putpkt ("qsThreadInfo"); + getpkt (&rs->buf, &rs->buf_size, 0); + bufp = rs->buf; + } + return; /* done */ + } + } + + /* Else fall back to old method based on jmetzler protocol. */ + use_threadinfo_query = 0; + remote_find_new_threads (); + return; +} + +/* + * Collect a descriptive string about the given thread. + * The target may say anything it wants to about the thread + * (typically info about its blocked / runnable state, name, etc.). + * This string will appear in the info threads display. + * + * Optional: targets are not required to implement this function. + */ + +static char * +remote_threads_extra_info (struct thread_info *tp) +{ + struct remote_state *rs = get_remote_state (); + int result; + int set; + threadref id; + struct gdb_ext_thread_info threadinfo; + static char display_buf[100]; /* arbitrary... */ + int n = 0; /* position in display_buf */ + + if (remote_desc == 0) /* paranoia */ + internal_error (__FILE__, __LINE__, + _("remote_threads_extra_info")); + + if (use_threadextra_query) + { + xsnprintf (rs->buf, get_remote_packet_size (), "qThreadExtraInfo,%x", + PIDGET (tp->ptid)); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + if (rs->buf[0] != 0) + { + n = min (strlen (rs->buf) / 2, sizeof (display_buf)); + result = hex2bin (rs->buf, (gdb_byte *) display_buf, n); + display_buf [result] = '\0'; + return display_buf; + } + } + + /* If the above query fails, fall back to the old method. */ + use_threadextra_query = 0; + set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME + | TAG_MOREDISPLAY | TAG_DISPLAY; + int_to_threadref (&id, PIDGET (tp->ptid)); + if (remote_get_threadinfo (&id, set, &threadinfo)) + if (threadinfo.active) + { + if (*threadinfo.shortname) + n += xsnprintf (&display_buf[0], sizeof (display_buf) - n, + " Name: %s,", threadinfo.shortname); + if (*threadinfo.display) + n += xsnprintf (&display_buf[n], sizeof (display_buf) - n, + " State: %s,", threadinfo.display); + if (*threadinfo.more_display) + n += xsnprintf (&display_buf[n], sizeof (display_buf) - n, + " Priority: %s", threadinfo.more_display); + + if (n > 0) + { + /* For purely cosmetic reasons, clear up trailing commas. */ + if (',' == display_buf[n-1]) + display_buf[n-1] = ' '; + return display_buf; + } + } + return NULL; +} + + +/* Restart the remote side; this is an extended protocol operation. */ + +static void +extended_remote_restart (void) +{ + struct remote_state *rs = get_remote_state (); + + /* Send the restart command; for reasons I don't understand the + remote side really expects a number after the "R". */ + xsnprintf (rs->buf, get_remote_packet_size (), "R%x", 0); + putpkt (rs->buf); + + remote_fileio_reset (); + + /* Now query for status so this looks just like we restarted + gdbserver from scratch. */ + putpkt ("?"); + getpkt (&rs->buf, &rs->buf_size, 0); +} + +/* Clean up connection to a remote debugger. */ + +static void +remote_close (int quitting) +{ + if (remote_desc) + serial_close (remote_desc); + remote_desc = NULL; +} + +/* Query the remote side for the text, data and bss offsets. */ + +static void +get_offsets (void) +{ + struct remote_state *rs = get_remote_state (); + char *buf; + char *ptr; + int lose, num_segments = 0, do_sections, do_segments; + CORE_ADDR text_addr, data_addr, bss_addr, segments[2]; + struct section_offsets *offs; + struct symfile_segment_data *data; + + if (symfile_objfile == NULL) + return; + + putpkt ("qOffsets"); + getpkt (&rs->buf, &rs->buf_size, 0); + buf = rs->buf; + + if (buf[0] == '\000') + return; /* Return silently. Stub doesn't support + this command. */ + if (buf[0] == 'E') + { + warning (_("Remote failure reply: %s"), buf); + return; + } + + /* Pick up each field in turn. This used to be done with scanf, but + scanf will make trouble if CORE_ADDR size doesn't match + conversion directives correctly. The following code will work + with any size of CORE_ADDR. */ + text_addr = data_addr = bss_addr = 0; + ptr = buf; + lose = 0; + + if (strncmp (ptr, "Text=", 5) == 0) + { + ptr += 5; + /* Don't use strtol, could lose on big values. */ + while (*ptr && *ptr != ';') + text_addr = (text_addr << 4) + fromhex (*ptr++); + + if (strncmp (ptr, ";Data=", 6) == 0) + { + ptr += 6; + while (*ptr && *ptr != ';') + data_addr = (data_addr << 4) + fromhex (*ptr++); + } + else + lose = 1; + + if (!lose && strncmp (ptr, ";Bss=", 5) == 0) + { + ptr += 5; + while (*ptr && *ptr != ';') + bss_addr = (bss_addr << 4) + fromhex (*ptr++); + + if (bss_addr != data_addr) + warning (_("Target reported unsupported offsets: %s"), buf); + } + else + lose = 1; + } + else if (strncmp (ptr, "TextSeg=", 8) == 0) + { + ptr += 8; + /* Don't use strtol, could lose on big values. */ + while (*ptr && *ptr != ';') + text_addr = (text_addr << 4) + fromhex (*ptr++); + num_segments = 1; + + if (strncmp (ptr, ";DataSeg=", 9) == 0) + { + ptr += 9; + while (*ptr && *ptr != ';') + data_addr = (data_addr << 4) + fromhex (*ptr++); + num_segments++; + } + } + else + lose = 1; + + if (lose) + error (_("Malformed response to offset query, %s"), buf); + else if (*ptr != '\0') + warning (_("Target reported unsupported offsets: %s"), buf); + + offs = ((struct section_offsets *) + alloca (SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections))); + memcpy (offs, symfile_objfile->section_offsets, + SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections)); + + data = get_symfile_segment_data (symfile_objfile->obfd); + do_segments = (data != NULL); + do_sections = num_segments == 0; + + if (num_segments > 0) + { + segments[0] = text_addr; + segments[1] = data_addr; + } + /* If we have two segments, we can still try to relocate everything + by assuming that the .text and .data offsets apply to the whole + text and data segments. Convert the offsets given in the packet + to base addresses for symfile_map_offsets_to_segments. */ + else if (data && data->num_segments == 2) + { + segments[0] = data->segment_bases[0] + text_addr; + segments[1] = data->segment_bases[1] + data_addr; + num_segments = 2; + } + /* There's no way to relocate by segment. */ + else + do_segments = 0; + + if (do_segments) + { + int ret = symfile_map_offsets_to_segments (symfile_objfile->obfd, data, + offs, num_segments, segments); + + if (ret == 0 && !do_sections) + error (_("Can not handle qOffsets TextSeg response with this symbol file")); + + if (ret > 0) + do_sections = 0; + } + + if (data) + free_symfile_segment_data (data); + + if (do_sections) + { + offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr; + + /* This is a temporary kludge to force data and bss to use the same offsets + because that's what nlmconv does now. The real solution requires changes + to the stub and remote.c that I don't have time to do right now. */ + + offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr; + offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr; + } + + objfile_relocate (symfile_objfile, offs); +} + +/* Stub for catch_exception. */ + +static void +remote_start_remote (struct ui_out *uiout, void *from_tty_p) +{ + int from_tty = * (int *) from_tty_p; + + immediate_quit++; /* Allow user to interrupt it. */ + + /* Ack any packet which the remote side has already sent. */ + serial_write (remote_desc, "+", 1); + + /* Let the stub know that we want it to return the thread. */ + set_thread (-1, 0); + + inferior_ptid = remote_current_thread (inferior_ptid); + + get_offsets (); /* Get text, data & bss offsets. */ + + putpkt ("?"); /* Initiate a query from remote machine. */ + immediate_quit--; + + start_remote (from_tty); /* Initialize gdb process mechanisms. */ +} + +/* Open a connection to a remote debugger. + NAME is the filename used for communication. */ + +static void +remote_open (char *name, int from_tty) +{ + remote_open_1 (name, from_tty, &remote_ops, 0, 0); +} + +/* Just like remote_open, but with asynchronous support. */ +static void +remote_async_open (char *name, int from_tty) +{ + remote_open_1 (name, from_tty, &remote_async_ops, 0, 1); +} + +/* Open a connection to a remote debugger using the extended + remote gdb protocol. NAME is the filename used for communication. */ + +static void +extended_remote_open (char *name, int from_tty) +{ + remote_open_1 (name, from_tty, &extended_remote_ops, 1 /*extended_p */, + 0 /* async_p */); +} + +/* Just like extended_remote_open, but with asynchronous support. */ +static void +extended_remote_async_open (char *name, int from_tty) +{ + remote_open_1 (name, from_tty, &extended_async_remote_ops, + 1 /*extended_p */, 1 /* async_p */); +} + +/* Generic code for opening a connection to a remote target. */ + +static void +init_all_packet_configs (void) +{ + int i; + for (i = 0; i < PACKET_MAX; i++) + update_packet_config (&remote_protocol_packets[i]); +} + +/* Symbol look-up. */ + +static void +remote_check_symbols (struct objfile *objfile) +{ + struct remote_state *rs = get_remote_state (); + char *msg, *reply, *tmp; + struct minimal_symbol *sym; + int end; + + if (remote_protocol_packets[PACKET_qSymbol].support == PACKET_DISABLE) + return; + + /* Allocate a message buffer. We can't reuse the input buffer in RS, + because we need both at the same time. */ + msg = alloca (get_remote_packet_size ()); + + /* Invite target to request symbol lookups. */ + + putpkt ("qSymbol::"); + getpkt (&rs->buf, &rs->buf_size, 0); + packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSymbol]); + reply = rs->buf; + + while (strncmp (reply, "qSymbol:", 8) == 0) + { + tmp = &reply[8]; + end = hex2bin (tmp, (gdb_byte *) msg, strlen (tmp) / 2); + msg[end] = '\0'; + sym = lookup_minimal_symbol (msg, NULL, NULL); + if (sym == NULL) + xsnprintf (msg, get_remote_packet_size (), "qSymbol::%s", &reply[8]); + else + { + CORE_ADDR sym_addr = SYMBOL_VALUE_ADDRESS (sym); + + /* If this is a function address, return the start of code + instead of any data function descriptor. */ + sym_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch, + sym_addr, + ¤t_target); + + xsnprintf (msg, get_remote_packet_size (), "qSymbol:%s:%s", + paddr_nz (sym_addr), &reply[8]); + } + + putpkt (msg); + getpkt (&rs->buf, &rs->buf_size, 0); + reply = rs->buf; + } +} + +static struct serial * +remote_serial_open (char *name) +{ + static int udp_warning = 0; + + /* FIXME: Parsing NAME here is a hack. But we want to warn here instead + of in ser-tcp.c, because it is the remote protocol assuming that the + serial connection is reliable and not the serial connection promising + to be. */ + if (!udp_warning && strncmp (name, "udp:", 4) == 0) + { + warning (_("\ +The remote protocol may be unreliable over UDP.\n\ +Some events may be lost, rendering further debugging impossible.")); + udp_warning = 1; + } + + return serial_open (name); +} + +/* This type describes each known response to the qSupported + packet. */ +struct protocol_feature +{ + /* The name of this protocol feature. */ + const char *name; + + /* The default for this protocol feature. */ + enum packet_support default_support; + + /* The function to call when this feature is reported, or after + qSupported processing if the feature is not supported. + The first argument points to this structure. The second + argument indicates whether the packet requested support be + enabled, disabled, or probed (or the default, if this function + is being called at the end of processing and this feature was + not reported). The third argument may be NULL; if not NULL, it + is a NUL-terminated string taken from the packet following + this feature's name and an equals sign. */ + void (*func) (const struct protocol_feature *, enum packet_support, + const char *); + + /* The corresponding packet for this feature. Only used if + FUNC is remote_supported_packet. */ + int packet; +}; + +static void +remote_supported_packet (const struct protocol_feature *feature, + enum packet_support support, + const char *argument) +{ + if (argument) + { + warning (_("Remote qSupported response supplied an unexpected value for" + " \"%s\"."), feature->name); + return; + } + + if (remote_protocol_packets[feature->packet].support + == PACKET_SUPPORT_UNKNOWN) + remote_protocol_packets[feature->packet].support = support; +} + +static void +remote_packet_size (const struct protocol_feature *feature, + enum packet_support support, const char *value) +{ + struct remote_state *rs = get_remote_state (); + + int packet_size; + char *value_end; + + if (support != PACKET_ENABLE) + return; + + if (value == NULL || *value == '\0') + { + warning (_("Remote target reported \"%s\" without a size."), + feature->name); + return; + } + + errno = 0; + packet_size = strtol (value, &value_end, 16); + if (errno != 0 || *value_end != '\0' || packet_size < 0) + { + warning (_("Remote target reported \"%s\" with a bad size: \"%s\"."), + feature->name, value); + return; + } + + if (packet_size > MAX_REMOTE_PACKET_SIZE) + { + warning (_("limiting remote suggested packet size (%d bytes) to %d"), + packet_size, MAX_REMOTE_PACKET_SIZE); + packet_size = MAX_REMOTE_PACKET_SIZE; + } + + /* Record the new maximum packet size. */ + rs->explicit_packet_size = packet_size; +} + +static struct protocol_feature remote_protocol_features[] = { + { "PacketSize", PACKET_DISABLE, remote_packet_size, -1 }, + { "qXfer:auxv:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_auxv }, + { "qXfer:features:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_features }, + { "qXfer:libraries:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_libraries }, + { "qXfer:memory-map:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_memory_map }, + { "qXfer:spu:read", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_spu_read }, + { "qXfer:spu:write", PACKET_DISABLE, remote_supported_packet, + PACKET_qXfer_spu_write }, + { "QPassSignals", PACKET_DISABLE, remote_supported_packet, + PACKET_QPassSignals }, +}; + +static void +remote_query_supported (void) +{ + struct remote_state *rs = get_remote_state (); + char *next; + int i; + unsigned char seen [ARRAY_SIZE (remote_protocol_features)]; + + /* The packet support flags are handled differently for this packet + than for most others. We treat an error, a disabled packet, and + an empty response identically: any features which must be reported + to be used will be automatically disabled. An empty buffer + accomplishes this, since that is also the representation for a list + containing no features. */ + + rs->buf[0] = 0; + if (remote_protocol_packets[PACKET_qSupported].support != PACKET_DISABLE) + { + putpkt ("qSupported"); + getpkt (&rs->buf, &rs->buf_size, 0); + + /* If an error occured, warn, but do not return - just reset the + buffer to empty and go on to disable features. */ + if (packet_ok (rs->buf, &remote_protocol_packets[PACKET_qSupported]) + == PACKET_ERROR) + { + warning (_("Remote failure reply: %s"), rs->buf); + rs->buf[0] = 0; + } + } + + memset (seen, 0, sizeof (seen)); + + next = rs->buf; + while (*next) + { + enum packet_support is_supported; + char *p, *end, *name_end, *value; + + /* First separate out this item from the rest of the packet. If + there's another item after this, we overwrite the separator + (terminated strings are much easier to work with). */ + p = next; + end = strchr (p, ';'); + if (end == NULL) + { + end = p + strlen (p); + next = end; + } + else + { + *end = '\0'; + next = end + 1; + + if (end == p) + { + warning (_("empty item in \"qSupported\" response")); + continue; + } + } + + name_end = strchr (p, '='); + if (name_end) + { + /* This is a name=value entry. */ + is_supported = PACKET_ENABLE; + value = name_end + 1; + *name_end = '\0'; + } + else + { + value = NULL; + switch (end[-1]) + { + case '+': + is_supported = PACKET_ENABLE; + break; + + case '-': + is_supported = PACKET_DISABLE; + break; + + case '?': + is_supported = PACKET_SUPPORT_UNKNOWN; + break; + + default: + warning (_("unrecognized item \"%s\" in \"qSupported\" response"), p); + continue; + } + end[-1] = '\0'; + } + + for (i = 0; i < ARRAY_SIZE (remote_protocol_features); i++) + if (strcmp (remote_protocol_features[i].name, p) == 0) + { + const struct protocol_feature *feature; + + seen[i] = 1; + feature = &remote_protocol_features[i]; + feature->func (feature, is_supported, value); + break; + } + } + + /* If we increased the packet size, make sure to increase the global + buffer size also. We delay this until after parsing the entire + qSupported packet, because this is the same buffer we were + parsing. */ + if (rs->buf_size < rs->explicit_packet_size) + { + rs->buf_size = rs->explicit_packet_size; + rs->buf = xrealloc (rs->buf, rs->buf_size); + } + + /* Handle the defaults for unmentioned features. */ + for (i = 0; i < ARRAY_SIZE (remote_protocol_features); i++) + if (!seen[i]) + { + const struct protocol_feature *feature; + + feature = &remote_protocol_features[i]; + feature->func (feature, feature->default_support, NULL); + } +} + + +static void +remote_open_1 (char *name, int from_tty, struct target_ops *target, + int extended_p, int async_p) +{ + struct remote_state *rs = get_remote_state (); + if (name == 0) + error (_("To open a remote debug connection, you need to specify what\n" + "serial device is attached to the remote system\n" + "(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).")); + + /* See FIXME above. */ + if (!async_p) + wait_forever_enabled_p = 1; + + target_preopen (from_tty); + + unpush_target (target); + + /* Make sure we send the passed signals list the next time we resume. */ + xfree (last_pass_packet); + last_pass_packet = NULL; + + remote_fileio_reset (); + reopen_exec_file (); + reread_symbols (); + + remote_desc = remote_serial_open (name); + if (!remote_desc) + perror_with_name (name); + + if (baud_rate != -1) + { + if (serial_setbaudrate (remote_desc, baud_rate)) + { + /* The requested speed could not be set. Error out to + top level after closing remote_desc. Take care to + set remote_desc to NULL to avoid closing remote_desc + more than once. */ + serial_close (remote_desc); + remote_desc = NULL; + perror_with_name (name); + } + } + + serial_raw (remote_desc); + + /* If there is something sitting in the buffer we might take it as a + response to a command, which would be bad. */ + serial_flush_input (remote_desc); + + if (from_tty) + { + puts_filtered ("Remote debugging using "); + puts_filtered (name); + puts_filtered ("\n"); + } + push_target (target); /* Switch to using remote target now. */ + + /* Reset the target state; these things will be queried either by + remote_query_supported or as they are needed. */ + init_all_packet_configs (); + rs->explicit_packet_size = 0; + + general_thread = -2; + continue_thread = -2; + + /* Probe for ability to use "ThreadInfo" query, as required. */ + use_threadinfo_query = 1; + use_threadextra_query = 1; + + /* The first packet we send to the target is the optional "supported + packets" request. If the target can answer this, it will tell us + which later probes to skip. */ + remote_query_supported (); + + /* Next, if the target can specify a description, read it. We do + this before anything involving memory or registers. */ + target_find_description (); + + /* Without this, some commands which require an active target (such + as kill) won't work. This variable serves (at least) double duty + as both the pid of the target process (if it has such), and as a + flag indicating that a target is active. These functions should + be split out into seperate variables, especially since GDB will + someday have a notion of debugging several processes. */ + + inferior_ptid = pid_to_ptid (MAGIC_NULL_PID); + + if (async_p) + { + /* With this target we start out by owning the terminal. */ + remote_async_terminal_ours_p = 1; + + /* FIXME: cagney/1999-09-23: During the initial connection it is + assumed that the target is already ready and able to respond to + requests. Unfortunately remote_start_remote() eventually calls + wait_for_inferior() with no timeout. wait_forever_enabled_p gets + around this. Eventually a mechanism that allows + wait_for_inferior() to expect/get timeouts will be + implemented. */ + wait_forever_enabled_p = 0; + } + + /* First delete any symbols previously loaded from shared libraries. */ + no_shared_libraries (NULL, 0); + + /* Start the remote connection. If error() or QUIT, discard this + target (we'd otherwise be in an inconsistent state) and then + propogate the error on up the exception chain. This ensures that + the caller doesn't stumble along blindly assuming that the + function succeeded. The CLI doesn't have this problem but other + UI's, such as MI do. + + FIXME: cagney/2002-05-19: Instead of re-throwing the exception, + this function should return an error indication letting the + caller restore the previous state. Unfortunately the command + ``target remote'' is directly wired to this function making that + impossible. On a positive note, the CLI side of this problem has + been fixed - the function set_cmd_context() makes it possible for + all the ``target ....'' commands to share a common callback + function. See cli-dump.c. */ + { + struct gdb_exception ex + = catch_exception (uiout, remote_start_remote, &from_tty, + RETURN_MASK_ALL); + if (ex.reason < 0) + { + pop_target (); + if (async_p) + wait_forever_enabled_p = 1; + throw_exception (ex); + } + } + + if (async_p) + wait_forever_enabled_p = 1; + + if (extended_p) + { + /* Tell the remote that we are using the extended protocol. */ + putpkt ("!"); + getpkt (&rs->buf, &rs->buf_size, 0); + } + + if (exec_bfd) /* No use without an exec file. */ + remote_check_symbols (symfile_objfile); +} + +/* This takes a program previously attached to and detaches it. After + this is done, GDB can be used to debug some other program. We + better not have left any breakpoints in the target program or it'll + die when it hits one. */ + +static void +remote_detach (char *args, int from_tty) +{ + struct remote_state *rs = get_remote_state (); + + if (args) + error (_("Argument given to \"detach\" when remotely debugging.")); + + /* Tell the remote target to detach. */ + strcpy (rs->buf, "D"); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + if (rs->buf[0] == 'E') + error (_("Can't detach process.")); + + /* Unregister the file descriptor from the event loop. */ + if (target_is_async_p ()) + serial_async (remote_desc, NULL, 0); + + target_mourn_inferior (); + if (from_tty) + puts_filtered ("Ending remote debugging.\n"); +} + +/* Same as remote_detach, but don't send the "D" packet; just disconnect. */ + +static void +remote_disconnect (struct target_ops *target, char *args, int from_tty) +{ + if (args) + error (_("Argument given to \"detach\" when remotely debugging.")); + + /* Unregister the file descriptor from the event loop. */ + if (target_is_async_p ()) + serial_async (remote_desc, NULL, 0); + + target_mourn_inferior (); + if (from_tty) + puts_filtered ("Ending remote debugging.\n"); +} + +/* Convert hex digit A to a number. */ + +static int +fromhex (int a) +{ + if (a >= '0' && a <= '9') + return a - '0'; + else if (a >= 'a' && a <= 'f') + return a - 'a' + 10; + else if (a >= 'A' && a <= 'F') + return a - 'A' + 10; + else + error (_("Reply contains invalid hex digit %d"), a); +} + +static int +hex2bin (const char *hex, gdb_byte *bin, int count) +{ + int i; + + for (i = 0; i < count; i++) + { + if (hex[0] == 0 || hex[1] == 0) + { + /* Hex string is short, or of uneven length. + Return the count that has been converted so far. */ + return i; + } + *bin++ = fromhex (hex[0]) * 16 + fromhex (hex[1]); + hex += 2; + } + return i; +} + +/* Convert number NIB to a hex digit. */ + +static int +tohex (int nib) +{ + if (nib < 10) + return '0' + nib; + else + return 'a' + nib - 10; +} + +static int +bin2hex (const gdb_byte *bin, char *hex, int count) +{ + int i; + /* May use a length, or a nul-terminated string as input. */ + if (count == 0) + count = strlen ((char *) bin); + + for (i = 0; i < count; i++) + { + *hex++ = tohex ((*bin >> 4) & 0xf); + *hex++ = tohex (*bin++ & 0xf); + } + *hex = 0; + return i; +} + +/* Check for the availability of vCont. This function should also check + the response. */ + +static void +remote_vcont_probe (struct remote_state *rs) +{ + char *buf; + + strcpy (rs->buf, "vCont?"); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + buf = rs->buf; + + /* Make sure that the features we assume are supported. */ + if (strncmp (buf, "vCont", 5) == 0) + { + char *p = &buf[5]; + int support_s, support_S, support_c, support_C; + + support_s = 0; + support_S = 0; + support_c = 0; + support_C = 0; + while (p && *p == ';') + { + p++; + if (*p == 's' && (*(p + 1) == ';' || *(p + 1) == 0)) + support_s = 1; + else if (*p == 'S' && (*(p + 1) == ';' || *(p + 1) == 0)) + support_S = 1; + else if (*p == 'c' && (*(p + 1) == ';' || *(p + 1) == 0)) + support_c = 1; + else if (*p == 'C' && (*(p + 1) == ';' || *(p + 1) == 0)) + support_C = 1; + + p = strchr (p, ';'); + } + + /* If s, S, c, and C are not all supported, we can't use vCont. Clearing + BUF will make packet_ok disable the packet. */ + if (!support_s || !support_S || !support_c || !support_C) + buf[0] = 0; + } + + packet_ok (buf, &remote_protocol_packets[PACKET_vCont]); +} + +/* Resume the remote inferior by using a "vCont" packet. The thread + to be resumed is PTID; STEP and SIGGNAL indicate whether the + resumed thread should be single-stepped and/or signalled. If PTID's + PID is -1, then all threads are resumed; the thread to be stepped and/or + signalled is given in the global INFERIOR_PTID. This function returns + non-zero iff it resumes the inferior. + + This function issues a strict subset of all possible vCont commands at the + moment. */ + +static int +remote_vcont_resume (ptid_t ptid, int step, enum target_signal siggnal) +{ + struct remote_state *rs = get_remote_state (); + int pid = PIDGET (ptid); + char *buf = NULL, *outbuf; + struct cleanup *old_cleanup; + + if (remote_protocol_packets[PACKET_vCont].support == PACKET_SUPPORT_UNKNOWN) + remote_vcont_probe (rs); + + if (remote_protocol_packets[PACKET_vCont].support == PACKET_DISABLE) + return 0; + + /* If we could generate a wider range of packets, we'd have to worry + about overflowing BUF. Should there be a generic + "multi-part-packet" packet? */ + + if (PIDGET (inferior_ptid) == MAGIC_NULL_PID) + { + /* MAGIC_NULL_PTID means that we don't have any active threads, so we + don't have any PID numbers the inferior will understand. Make sure + to only send forms that do not specify a PID. */ + if (step && siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;S%02x", siggnal); + else if (step) + outbuf = xstrprintf ("vCont;s"); + else if (siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;C%02x", siggnal); + else + outbuf = xstrprintf ("vCont;c"); + } + else if (pid == -1) + { + /* Resume all threads, with preference for INFERIOR_PTID. */ + if (step && siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;S%02x:%x;c", siggnal, + PIDGET (inferior_ptid)); + else if (step) + outbuf = xstrprintf ("vCont;s:%x;c", PIDGET (inferior_ptid)); + else if (siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;C%02x:%x;c", siggnal, + PIDGET (inferior_ptid)); + else + outbuf = xstrprintf ("vCont;c"); + } + else + { + /* Scheduler locking; resume only PTID. */ + if (step && siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;S%02x:%x", siggnal, pid); + else if (step) + outbuf = xstrprintf ("vCont;s:%x", pid); + else if (siggnal != TARGET_SIGNAL_0) + outbuf = xstrprintf ("vCont;C%02x:%x", siggnal, pid); + else + outbuf = xstrprintf ("vCont;c:%x", pid); + } + + gdb_assert (outbuf && strlen (outbuf) < get_remote_packet_size ()); + old_cleanup = make_cleanup (xfree, outbuf); + + putpkt (outbuf); + + do_cleanups (old_cleanup); + + return 1; +} + +/* Tell the remote machine to resume. */ + +static enum target_signal last_sent_signal = TARGET_SIGNAL_0; + +static int last_sent_step; + +static void +remote_resume (ptid_t ptid, int step, enum target_signal siggnal) +{ + struct remote_state *rs = get_remote_state (); + char *buf; + int pid = PIDGET (ptid); + + last_sent_signal = siggnal; + last_sent_step = step; + + /* A hook for when we need to do something at the last moment before + resumption. */ + if (deprecated_target_resume_hook) + (*deprecated_target_resume_hook) (); + + /* Update the inferior on signals to silently pass, if they've changed. */ + remote_pass_signals (); + + /* The vCont packet doesn't need to specify threads via Hc. */ + if (remote_vcont_resume (ptid, step, siggnal)) + return; + + /* All other supported resume packets do use Hc, so call set_thread. */ + if (pid == -1) + set_thread (0, 0); /* Run any thread. */ + else + set_thread (pid, 0); /* Run this thread. */ + + buf = rs->buf; + if (siggnal != TARGET_SIGNAL_0) + { + buf[0] = step ? 'S' : 'C'; + buf[1] = tohex (((int) siggnal >> 4) & 0xf); + buf[2] = tohex (((int) siggnal) & 0xf); + buf[3] = '\0'; + } + else + strcpy (buf, step ? "s" : "c"); + + putpkt (buf); +} + +/* Same as remote_resume, but with async support. */ +static void +remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal) +{ + remote_resume (ptid, step, siggnal); + + /* We are about to start executing the inferior, let's register it + with the event loop. NOTE: this is the one place where all the + execution commands end up. We could alternatively do this in each + of the execution commands in infcmd.c. */ + /* FIXME: ezannoni 1999-09-28: We may need to move this out of here + into infcmd.c in order to allow inferior function calls to work + NOT asynchronously. */ + if (target_can_async_p ()) + target_async (inferior_event_handler, 0); + /* Tell the world that the target is now executing. */ + /* FIXME: cagney/1999-09-23: Is it the targets responsibility to set + this? Instead, should the client of target just assume (for + async targets) that the target is going to start executing? Is + this information already found in the continuation block? */ + if (target_is_async_p ()) + target_executing = 1; +} + + +/* Set up the signal handler for SIGINT, while the target is + executing, ovewriting the 'regular' SIGINT signal handler. */ +static void +initialize_sigint_signal_handler (void) +{ + sigint_remote_token = + create_async_signal_handler (async_remote_interrupt, NULL); + signal (SIGINT, handle_remote_sigint); +} + +/* Signal handler for SIGINT, while the target is executing. */ +static void +handle_remote_sigint (int sig) +{ + signal (sig, handle_remote_sigint_twice); + sigint_remote_twice_token = + create_async_signal_handler (async_remote_interrupt_twice, NULL); + mark_async_signal_handler_wrapper (sigint_remote_token); +} + +/* Signal handler for SIGINT, installed after SIGINT has already been + sent once. It will take effect the second time that the user sends + a ^C. */ +static void +handle_remote_sigint_twice (int sig) +{ + signal (sig, handle_sigint); + sigint_remote_twice_token = + create_async_signal_handler (inferior_event_handler_wrapper, NULL); + mark_async_signal_handler_wrapper (sigint_remote_twice_token); +} + +/* Perform the real interruption of the target execution, in response + to a ^C. */ +static void +async_remote_interrupt (gdb_client_data arg) +{ + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n"); + + target_stop (); +} + +/* Perform interrupt, if the first attempt did not succeed. Just give + up on the target alltogether. */ +void +async_remote_interrupt_twice (gdb_client_data arg) +{ + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "remote_interrupt_twice called\n"); + /* Do something only if the target was not killed by the previous + cntl-C. */ + if (target_executing) + { + interrupt_query (); + signal (SIGINT, handle_remote_sigint); + } +} + +/* Reinstall the usual SIGINT handlers, after the target has + stopped. */ +static void +cleanup_sigint_signal_handler (void *dummy) +{ + signal (SIGINT, handle_sigint); + if (sigint_remote_twice_token) + delete_async_signal_handler (&sigint_remote_twice_token); + if (sigint_remote_token) + delete_async_signal_handler (&sigint_remote_token); +} + +/* Send ^C to target to halt it. Target will respond, and send us a + packet. */ +static void (*ofunc) (int); + +/* The command line interface's stop routine. This function is installed + as a signal handler for SIGINT. The first time a user requests a + stop, we call remote_stop to send a break or ^C. If there is no + response from the target (it didn't stop when the user requested it), + we ask the user if he'd like to detach from the target. */ +static void +remote_interrupt (int signo) +{ + /* If this doesn't work, try more severe steps. */ + signal (signo, remote_interrupt_twice); + + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n"); + + target_stop (); +} + +/* The user typed ^C twice. */ + +static void +remote_interrupt_twice (int signo) +{ + signal (signo, ofunc); + interrupt_query (); + signal (signo, remote_interrupt); +} + +/* This is the generic stop called via the target vector. When a target + interrupt is requested, either by the command line or the GUI, we + will eventually end up here. */ +static void +remote_stop (void) +{ + /* Send a break or a ^C, depending on user preference. */ + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "remote_stop called\n"); + + if (remote_break) + serial_send_break (remote_desc); + else + serial_write (remote_desc, "\003", 1); +} + +/* Ask the user what to do when an interrupt is received. */ + +static void +interrupt_query (void) +{ + target_terminal_ours (); + + if (query ("Interrupted while waiting for the program.\n\ +Give up (and stop debugging it)? ")) + { + target_mourn_inferior (); + deprecated_throw_reason (RETURN_QUIT); + } + + target_terminal_inferior (); +} + +/* Enable/disable target terminal ownership. Most targets can use + terminal groups to control terminal ownership. Remote targets are + different in that explicit transfer of ownership to/from GDB/target + is required. */ + +static void +remote_async_terminal_inferior (void) +{ + /* FIXME: cagney/1999-09-27: Shouldn't need to test for + sync_execution here. This function should only be called when + GDB is resuming the inferior in the forground. A background + resume (``run&'') should leave GDB in control of the terminal and + consequently should not call this code. */ + if (!sync_execution) + return; + /* FIXME: cagney/1999-09-27: Closely related to the above. Make + calls target_terminal_*() idenpotent. The event-loop GDB talking + to an asynchronous target with a synchronous command calls this + function from both event-top.c and infrun.c/infcmd.c. Once GDB + stops trying to transfer the terminal to the target when it + shouldn't this guard can go away. */ + if (!remote_async_terminal_ours_p) + return; + delete_file_handler (input_fd); + remote_async_terminal_ours_p = 0; + initialize_sigint_signal_handler (); + /* NOTE: At this point we could also register our selves as the + recipient of all input. Any characters typed could then be + passed on down to the target. */ +} + +static void +remote_async_terminal_ours (void) +{ + /* See FIXME in remote_async_terminal_inferior. */ + if (!sync_execution) + return; + /* See FIXME in remote_async_terminal_inferior. */ + if (remote_async_terminal_ours_p) + return; + cleanup_sigint_signal_handler (NULL); + add_file_handler (input_fd, stdin_event_handler, 0); + remote_async_terminal_ours_p = 1; +} + +/* If nonzero, ignore the next kill. */ + +int kill_kludge; + +void +remote_console_output (char *msg) +{ + char *p; + + for (p = msg; p[0] && p[1]; p += 2) + { + char tb[2]; + char c = fromhex (p[0]) * 16 + fromhex (p[1]); + tb[0] = c; + tb[1] = 0; + fputs_unfiltered (tb, gdb_stdtarg); + } + gdb_flush (gdb_stdtarg); +} + +/* Wait until the remote machine stops, then return, + storing status in STATUS just as `wait' would. + Returns "pid", which in the case of a multi-threaded + remote OS, is the thread-id. */ + +static ptid_t +remote_wait (ptid_t ptid, struct target_waitstatus *status) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + ULONGEST thread_num = -1; + ULONGEST addr; + int solibs_changed = 0; + + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = 0; + + while (1) + { + char *buf, *p; + + ofunc = signal (SIGINT, remote_interrupt); + getpkt (&rs->buf, &rs->buf_size, 1); + signal (SIGINT, ofunc); + + buf = rs->buf; + + /* This is a hook for when we need to do something (perhaps the + collection of trace data) every time the target stops. */ + if (deprecated_target_wait_loop_hook) + (*deprecated_target_wait_loop_hook) (); + + remote_stopped_by_watchpoint_p = 0; + + switch (buf[0]) + { + case 'E': /* Error of some sort. */ + warning (_("Remote failure reply: %s"), buf); + continue; + case 'F': /* File-I/O request. */ + remote_fileio_request (buf); + continue; + case 'T': /* Status with PC, SP, FP, ... */ + { + gdb_byte regs[MAX_REGISTER_SIZE]; + + /* Expedited reply, containing Signal, {regno, reg} repeat. */ + /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where + ss = signal number + n... = register number + r... = register contents + */ + p = &buf[3]; /* after Txx */ + + while (*p) + { + char *p1; + char *p_temp; + int fieldsize; + LONGEST pnum = 0; + + /* If the packet contains a register number save it in + pnum and set p1 to point to the character following + it. Otherwise p1 points to p. */ + + /* If this packet is an awatch packet, don't parse the + 'a' as a register number. */ + + if (strncmp (p, "awatch", strlen("awatch")) != 0) + { + /* Read the ``P'' register number. */ + pnum = strtol (p, &p_temp, 16); + p1 = p_temp; + } + else + p1 = p; + + if (p1 == p) /* No register number present here. */ + { + p1 = strchr (p, ':'); + if (p1 == NULL) + error (_("Malformed packet(a) (missing colon): %s\n\ +Packet: '%s'\n"), + p, buf); + if (strncmp (p, "thread", p1 - p) == 0) + { + p_temp = unpack_varlen_hex (++p1, &thread_num); + record_currthread (thread_num); + p = p_temp; + } + else if ((strncmp (p, "watch", p1 - p) == 0) + || (strncmp (p, "rwatch", p1 - p) == 0) + || (strncmp (p, "awatch", p1 - p) == 0)) + { + remote_stopped_by_watchpoint_p = 1; + p = unpack_varlen_hex (++p1, &addr); + remote_watch_data_address = (CORE_ADDR)addr; + } + else if (strncmp (p, "library", p1 - p) == 0) + { + p1++; + p_temp = p1; + while (*p_temp && *p_temp != ';') + p_temp++; + + solibs_changed = 1; + p = p_temp; + } + else + { + /* Silently skip unknown optional info. */ + p_temp = strchr (p1 + 1, ';'); + if (p_temp) + p = p_temp; + } + } + else + { + struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum); + p = p1; + + if (*p++ != ':') + error (_("Malformed packet(b) (missing colon): %s\n\ +Packet: '%s'\n"), + p, buf); + + if (reg == NULL) + error (_("Remote sent bad register number %s: %s\n\ +Packet: '%s'\n"), + phex_nz (pnum, 0), p, buf); + + fieldsize = hex2bin (p, regs, + register_size (current_gdbarch, + reg->regnum)); + p += 2 * fieldsize; + if (fieldsize < register_size (current_gdbarch, + reg->regnum)) + warning (_("Remote reply is too short: %s"), buf); + regcache_raw_supply (get_current_regcache (), + reg->regnum, regs); + } + + if (*p++ != ';') + error (_("Remote register badly formatted: %s\nhere: %s"), + buf, p); + } + } + /* fall through */ + case 'S': /* Old style status, just signal only. */ + if (solibs_changed) + status->kind = TARGET_WAITKIND_LOADED; + else + { + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = (enum target_signal) + (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); + } + + if (buf[3] == 'p') + { + thread_num = strtol ((const char *) &buf[4], NULL, 16); + record_currthread (thread_num); + } + goto got_status; + case 'W': /* Target exited. */ + { + /* The remote process exited. */ + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]); + goto got_status; + } + case 'X': + status->kind = TARGET_WAITKIND_SIGNALLED; + status->value.sig = (enum target_signal) + (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); + kill_kludge = 1; + + goto got_status; + case 'O': /* Console output. */ + remote_console_output (buf + 1); + continue; + case '\0': + if (last_sent_signal != TARGET_SIGNAL_0) + { + /* Zero length reply means that we tried 'S' or 'C' and + the remote system doesn't support it. */ + target_terminal_ours_for_output (); + printf_filtered + ("Can't send signals to this remote system. %s not sent.\n", + target_signal_to_name (last_sent_signal)); + last_sent_signal = TARGET_SIGNAL_0; + target_terminal_inferior (); + + strcpy ((char *) buf, last_sent_step ? "s" : "c"); + putpkt ((char *) buf); + continue; + } + /* else fallthrough */ + default: + warning (_("Invalid remote reply: %s"), buf); + continue; + } + } +got_status: + if (thread_num != -1) + { + return pid_to_ptid (thread_num); + } + return inferior_ptid; +} + +/* Async version of remote_wait. */ +static ptid_t +remote_async_wait (ptid_t ptid, struct target_waitstatus *status) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + ULONGEST thread_num = -1; + ULONGEST addr; + int solibs_changed = 0; + + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = 0; + + remote_stopped_by_watchpoint_p = 0; + + while (1) + { + char *buf, *p; + + if (!target_is_async_p ()) + ofunc = signal (SIGINT, remote_interrupt); + /* FIXME: cagney/1999-09-27: If we're in async mode we should + _never_ wait for ever -> test on target_is_async_p(). + However, before we do that we need to ensure that the caller + knows how to take the target into/out of async mode. */ + getpkt (&rs->buf, &rs->buf_size, wait_forever_enabled_p); + if (!target_is_async_p ()) + signal (SIGINT, ofunc); + + buf = rs->buf; + + /* This is a hook for when we need to do something (perhaps the + collection of trace data) every time the target stops. */ + if (deprecated_target_wait_loop_hook) + (*deprecated_target_wait_loop_hook) (); + + switch (buf[0]) + { + case 'E': /* Error of some sort. */ + warning (_("Remote failure reply: %s"), buf); + continue; + case 'F': /* File-I/O request. */ + remote_fileio_request (buf); + continue; + case 'T': /* Status with PC, SP, FP, ... */ + { + gdb_byte regs[MAX_REGISTER_SIZE]; + + /* Expedited reply, containing Signal, {regno, reg} repeat. */ + /* format is: 'Tssn...:r...;n...:r...;n...:r...;#cc', where + ss = signal number + n... = register number + r... = register contents + */ + p = &buf[3]; /* after Txx */ + + while (*p) + { + char *p1; + char *p_temp; + int fieldsize; + long pnum = 0; + + /* If the packet contains a register number, save it + in pnum and set p1 to point to the character + following it. Otherwise p1 points to p. */ + + /* If this packet is an awatch packet, don't parse the 'a' + as a register number. */ + + if (strncmp (p, "awatch", strlen("awatch")) != 0) + { + /* Read the register number. */ + pnum = strtol (p, &p_temp, 16); + p1 = p_temp; + } + else + p1 = p; + + if (p1 == p) /* No register number present here. */ + { + p1 = strchr (p, ':'); + if (p1 == NULL) + error (_("Malformed packet(a) (missing colon): %s\n\ +Packet: '%s'\n"), + p, buf); + if (strncmp (p, "thread", p1 - p) == 0) + { + p_temp = unpack_varlen_hex (++p1, &thread_num); + record_currthread (thread_num); + p = p_temp; + } + else if ((strncmp (p, "watch", p1 - p) == 0) + || (strncmp (p, "rwatch", p1 - p) == 0) + || (strncmp (p, "awatch", p1 - p) == 0)) + { + remote_stopped_by_watchpoint_p = 1; + p = unpack_varlen_hex (++p1, &addr); + remote_watch_data_address = (CORE_ADDR)addr; + } + else if (strncmp (p, "library", p1 - p) == 0) + { + p1++; + p_temp = p1; + while (*p_temp && *p_temp != ';') + p_temp++; + + solibs_changed = 1; + p = p_temp; + } + else + { + /* Silently skip unknown optional info. */ + p_temp = strchr (p1 + 1, ';'); + if (p_temp) + p = p_temp; + } + } + + else + { + struct packet_reg *reg = packet_reg_from_pnum (rsa, pnum); + p = p1; + if (*p++ != ':') + error (_("Malformed packet(b) (missing colon): %s\n\ +Packet: '%s'\n"), + p, buf); + + if (reg == NULL) + error (_("Remote sent bad register number %ld: %s\n\ +Packet: '%s'\n"), + pnum, p, buf); + + fieldsize = hex2bin (p, regs, + register_size (current_gdbarch, + reg->regnum)); + p += 2 * fieldsize; + if (fieldsize < register_size (current_gdbarch, + reg->regnum)) + warning (_("Remote reply is too short: %s"), buf); + regcache_raw_supply (get_current_regcache (), + reg->regnum, regs); + } + + if (*p++ != ';') + error (_("Remote register badly formatted: %s\nhere: %s"), + buf, p); + } + } + /* fall through */ + case 'S': /* Old style status, just signal only. */ + if (solibs_changed) + status->kind = TARGET_WAITKIND_LOADED; + else + { + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = (enum target_signal) + (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); + } + + if (buf[3] == 'p') + { + thread_num = strtol ((const char *) &buf[4], NULL, 16); + record_currthread (thread_num); + } + goto got_status; + case 'W': /* Target exited. */ + { + /* The remote process exited. */ + status->kind = TARGET_WAITKIND_EXITED; + status->value.integer = (fromhex (buf[1]) << 4) + fromhex (buf[2]); + goto got_status; + } + case 'X': + status->kind = TARGET_WAITKIND_SIGNALLED; + status->value.sig = (enum target_signal) + (((fromhex (buf[1])) << 4) + (fromhex (buf[2]))); + kill_kludge = 1; + + goto got_status; + case 'O': /* Console output. */ + remote_console_output (buf + 1); + /* Return immediately to the event loop. The event loop will + still be waiting on the inferior afterwards. */ + status->kind = TARGET_WAITKIND_IGNORE; + goto got_status; + case '\0': + if (last_sent_signal != TARGET_SIGNAL_0) + { + /* Zero length reply means that we tried 'S' or 'C' and + the remote system doesn't support it. */ + target_terminal_ours_for_output (); + printf_filtered + ("Can't send signals to this remote system. %s not sent.\n", + target_signal_to_name (last_sent_signal)); + last_sent_signal = TARGET_SIGNAL_0; + target_terminal_inferior (); + + strcpy ((char *) buf, last_sent_step ? "s" : "c"); + putpkt ((char *) buf); + continue; + } + /* else fallthrough */ + default: + warning (_("Invalid remote reply: %s"), buf); + continue; + } + } +got_status: + if (thread_num != -1) + { + return pid_to_ptid (thread_num); + } + return inferior_ptid; +} + +/* Fetch a single register using a 'p' packet. */ + +static int +fetch_register_using_p (struct regcache *regcache, struct packet_reg *reg) +{ + struct remote_state *rs = get_remote_state (); + char *buf, *p; + char regp[MAX_REGISTER_SIZE]; + int i; + + if (remote_protocol_packets[PACKET_p].support == PACKET_DISABLE) + return 0; + + if (reg->pnum == -1) + return 0; + + p = rs->buf; + *p++ = 'p'; + p += hexnumstr (p, reg->pnum); + *p++ = '\0'; + remote_send (&rs->buf, &rs->buf_size); + + buf = rs->buf; + + switch (packet_ok (buf, &remote_protocol_packets[PACKET_p])) + { + case PACKET_OK: + break; + case PACKET_UNKNOWN: + return 0; + case PACKET_ERROR: + error (_("Could not fetch register \"%s\""), + gdbarch_register_name (current_gdbarch, reg->regnum)); + } + + /* If this register is unfetchable, tell the regcache. */ + if (buf[0] == 'x') + { + regcache_raw_supply (regcache, reg->regnum, NULL); + return 1; + } + + /* Otherwise, parse and supply the value. */ + p = buf; + i = 0; + while (p[0] != 0) + { + if (p[1] == 0) + error (_("fetch_register_using_p: early buf termination")); + + regp[i++] = fromhex (p[0]) * 16 + fromhex (p[1]); + p += 2; + } + regcache_raw_supply (regcache, reg->regnum, regp); + return 1; +} + +/* Fetch the registers included in the target's 'g' packet. */ + +static int +send_g_packet (void) +{ + struct remote_state *rs = get_remote_state (); + int i, buf_len; + char *p; + char *regs; + + sprintf (rs->buf, "g"); + remote_send (&rs->buf, &rs->buf_size); + + /* We can get out of synch in various cases. If the first character + in the buffer is not a hex character, assume that has happened + and try to fetch another packet to read. */ + while ((rs->buf[0] < '0' || rs->buf[0] > '9') + && (rs->buf[0] < 'A' || rs->buf[0] > 'F') + && (rs->buf[0] < 'a' || rs->buf[0] > 'f') + && rs->buf[0] != 'x') /* New: unavailable register value. */ + { + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "Bad register packet; fetching a new packet\n"); + getpkt (&rs->buf, &rs->buf_size, 0); + } + + buf_len = strlen (rs->buf); + + /* Sanity check the received packet. */ + if (buf_len % 2 != 0) + error (_("Remote 'g' packet reply is of odd length: %s"), rs->buf); + + return buf_len / 2; +} + +static void +process_g_packet (struct regcache *regcache) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + int i, buf_len; + char *p; + char *regs; + + buf_len = strlen (rs->buf); + + /* Further sanity checks, with knowledge of the architecture. */ + if (buf_len > 2 * rsa->sizeof_g_packet) + error (_("Remote 'g' packet reply is too long: %s"), rs->buf); + + /* Save the size of the packet sent to us by the target. It is used + as a heuristic when determining the max size of packets that the + target can safely receive. */ + if (rsa->actual_register_packet_size == 0) + rsa->actual_register_packet_size = buf_len; + + /* If this is smaller than we guessed the 'g' packet would be, + update our records. A 'g' reply that doesn't include a register's + value implies either that the register is not available, or that + the 'p' packet must be used. */ + if (buf_len < 2 * rsa->sizeof_g_packet) + { + rsa->sizeof_g_packet = buf_len / 2; + + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + { + if (rsa->regs[i].pnum == -1) + continue; + + if (rsa->regs[i].offset >= rsa->sizeof_g_packet) + rsa->regs[i].in_g_packet = 0; + else + rsa->regs[i].in_g_packet = 1; + } + } + + regs = alloca (rsa->sizeof_g_packet); + + /* Unimplemented registers read as all bits zero. */ + memset (regs, 0, rsa->sizeof_g_packet); + + /* Reply describes registers byte by byte, each byte encoded as two + hex characters. Suck them all up, then supply them to the + register cacheing/storage mechanism. */ + + p = rs->buf; + for (i = 0; i < rsa->sizeof_g_packet; i++) + { + if (p[0] == 0 || p[1] == 0) + /* This shouldn't happen - we adjusted sizeof_g_packet above. */ + internal_error (__FILE__, __LINE__, + "unexpected end of 'g' packet reply"); + + if (p[0] == 'x' && p[1] == 'x') + regs[i] = 0; /* 'x' */ + else + regs[i] = fromhex (p[0]) * 16 + fromhex (p[1]); + p += 2; + } + + { + int i; + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + { + struct packet_reg *r = &rsa->regs[i]; + if (r->in_g_packet) + { + if (r->offset * 2 >= strlen (rs->buf)) + /* This shouldn't happen - we adjusted in_g_packet above. */ + internal_error (__FILE__, __LINE__, + "unexpected end of 'g' packet reply"); + else if (rs->buf[r->offset * 2] == 'x') + { + gdb_assert (r->offset * 2 < strlen (rs->buf)); + /* The register isn't available, mark it as such (at + the same time setting the value to zero). */ + regcache_raw_supply (regcache, r->regnum, NULL); + } + else + regcache_raw_supply (regcache, r->regnum, + regs + r->offset); + } + } + } +} + +static void +fetch_registers_using_g (struct regcache *regcache) +{ + send_g_packet (); + process_g_packet (regcache); +} + +static void +remote_fetch_registers (struct regcache *regcache, int regnum) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + int i; + + set_thread (PIDGET (inferior_ptid), 1); + + if (regnum >= 0) + { + struct packet_reg *reg = packet_reg_from_regnum (rsa, regnum); + gdb_assert (reg != NULL); + + /* If this register might be in the 'g' packet, try that first - + we are likely to read more than one register. If this is the + first 'g' packet, we might be overly optimistic about its + contents, so fall back to 'p'. */ + if (reg->in_g_packet) + { + fetch_registers_using_g (regcache); + if (reg->in_g_packet) + return; + } + + if (fetch_register_using_p (regcache, reg)) + return; + + /* This register is not available. */ + regcache_raw_supply (regcache, reg->regnum, NULL); + + return; + } + + fetch_registers_using_g (regcache); + + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + if (!rsa->regs[i].in_g_packet) + if (!fetch_register_using_p (regcache, &rsa->regs[i])) + { + /* This register is not available. */ + regcache_raw_supply (regcache, i, NULL); + } +} + +/* Prepare to store registers. Since we may send them all (using a + 'G' request), we have to read out the ones we don't want to change + first. */ + +static void +remote_prepare_to_store (struct regcache *regcache) +{ + struct remote_arch_state *rsa = get_remote_arch_state (); + int i; + gdb_byte buf[MAX_REGISTER_SIZE]; + + /* Make sure the entire registers array is valid. */ + switch (remote_protocol_packets[PACKET_P].support) + { + case PACKET_DISABLE: + case PACKET_SUPPORT_UNKNOWN: + /* Make sure all the necessary registers are cached. */ + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + if (rsa->regs[i].in_g_packet) + regcache_raw_read (regcache, rsa->regs[i].regnum, buf); + break; + case PACKET_ENABLE: + break; + } +} + +/* Helper: Attempt to store REGNUM using the P packet. Return fail IFF + packet was not recognized. */ + +static int +store_register_using_P (const struct regcache *regcache, struct packet_reg *reg) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + /* Try storing a single register. */ + char *buf = rs->buf; + gdb_byte regp[MAX_REGISTER_SIZE]; + char *p; + + if (remote_protocol_packets[PACKET_P].support == PACKET_DISABLE) + return 0; + + if (reg->pnum == -1) + return 0; + + xsnprintf (buf, get_remote_packet_size (), "P%s=", phex_nz (reg->pnum, 0)); + p = buf + strlen (buf); + regcache_raw_collect (regcache, reg->regnum, regp); + bin2hex (regp, p, register_size (current_gdbarch, reg->regnum)); + remote_send (&rs->buf, &rs->buf_size); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_P])) + { + case PACKET_OK: + return 1; + case PACKET_ERROR: + error (_("Could not write register \"%s\""), + gdbarch_register_name (current_gdbarch, reg->regnum)); + case PACKET_UNKNOWN: + return 0; + default: + internal_error (__FILE__, __LINE__, _("Bad result from packet_ok")); + } +} + +/* Store register REGNUM, or all registers if REGNUM == -1, from the + contents of the register cache buffer. FIXME: ignores errors. */ + +static void +store_registers_using_G (const struct regcache *regcache) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + gdb_byte *regs; + char *p; + + /* Extract all the registers in the regcache copying them into a + local buffer. */ + { + int i; + regs = alloca (rsa->sizeof_g_packet); + memset (regs, 0, rsa->sizeof_g_packet); + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + { + struct packet_reg *r = &rsa->regs[i]; + if (r->in_g_packet) + regcache_raw_collect (regcache, r->regnum, regs + r->offset); + } + } + + /* Command describes registers byte by byte, + each byte encoded as two hex characters. */ + p = rs->buf; + *p++ = 'G'; + /* remote_prepare_to_store insures that rsa->sizeof_g_packet gets + updated. */ + bin2hex (regs, p, rsa->sizeof_g_packet); + remote_send (&rs->buf, &rs->buf_size); +} + +/* Store register REGNUM, or all registers if REGNUM == -1, from the contents + of the register cache buffer. FIXME: ignores errors. */ + +static void +remote_store_registers (struct regcache *regcache, int regnum) +{ + struct remote_state *rs = get_remote_state (); + struct remote_arch_state *rsa = get_remote_arch_state (); + int i; + + set_thread (PIDGET (inferior_ptid), 1); + + if (regnum >= 0) + { + struct packet_reg *reg = packet_reg_from_regnum (rsa, regnum); + gdb_assert (reg != NULL); + + /* Always prefer to store registers using the 'P' packet if + possible; we often change only a small number of registers. + Sometimes we change a larger number; we'd need help from a + higher layer to know to use 'G'. */ + if (store_register_using_P (regcache, reg)) + return; + + /* For now, don't complain if we have no way to write the + register. GDB loses track of unavailable registers too + easily. Some day, this may be an error. We don't have + any way to read the register, either... */ + if (!reg->in_g_packet) + return; + + store_registers_using_G (regcache); + return; + } + + store_registers_using_G (regcache); + + for (i = 0; i < gdbarch_num_regs (current_gdbarch); i++) + if (!rsa->regs[i].in_g_packet) + if (!store_register_using_P (regcache, &rsa->regs[i])) + /* See above for why we do not issue an error here. */ + continue; +} + + +/* Return the number of hex digits in num. */ + +static int +hexnumlen (ULONGEST num) +{ + int i; + + for (i = 0; num != 0; i++) + num >>= 4; + + return max (i, 1); +} + +/* Set BUF to the minimum number of hex digits representing NUM. */ + +static int +hexnumstr (char *buf, ULONGEST num) +{ + int len = hexnumlen (num); + return hexnumnstr (buf, num, len); +} + + +/* Set BUF to the hex digits representing NUM, padded to WIDTH characters. */ + +static int +hexnumnstr (char *buf, ULONGEST num, int width) +{ + int i; + + buf[width] = '\0'; + + for (i = width - 1; i >= 0; i--) + { + buf[i] = "0123456789abcdef"[(num & 0xf)]; + num >>= 4; + } + + return width; +} + +/* Mask all but the least significant REMOTE_ADDRESS_SIZE bits. */ + +static CORE_ADDR +remote_address_masked (CORE_ADDR addr) +{ + int address_size = remote_address_size; + /* If "remoteaddresssize" was not set, default to target address size. */ + if (!address_size) + address_size = gdbarch_addr_bit (current_gdbarch); + + if (address_size > 0 + && address_size < (sizeof (ULONGEST) * 8)) + { + /* Only create a mask when that mask can safely be constructed + in a ULONGEST variable. */ + ULONGEST mask = 1; + mask = (mask << address_size) - 1; + addr &= mask; + } + return addr; +} + +/* Convert BUFFER, binary data at least LEN bytes long, into escaped + binary data in OUT_BUF. Set *OUT_LEN to the length of the data + encoded in OUT_BUF, and return the number of bytes in OUT_BUF + (which may be more than *OUT_LEN due to escape characters). The + total number of bytes in the output buffer will be at most + OUT_MAXLEN. */ + +static int +remote_escape_output (const gdb_byte *buffer, int len, + gdb_byte *out_buf, int *out_len, + int out_maxlen) +{ + int input_index, output_index; + + output_index = 0; + for (input_index = 0; input_index < len; input_index++) + { + gdb_byte b = buffer[input_index]; + + if (b == '$' || b == '#' || b == '}') + { + /* These must be escaped. */ + if (output_index + 2 > out_maxlen) + break; + out_buf[output_index++] = '}'; + out_buf[output_index++] = b ^ 0x20; + } + else + { + if (output_index + 1 > out_maxlen) + break; + out_buf[output_index++] = b; + } + } + + *out_len = input_index; + return output_index; +} + +/* Convert BUFFER, escaped data LEN bytes long, into binary data + in OUT_BUF. Return the number of bytes written to OUT_BUF. + Raise an error if the total number of bytes exceeds OUT_MAXLEN. + + This function reverses remote_escape_output. It allows more + escaped characters than that function does, in particular because + '*' must be escaped to avoid the run-length encoding processing + in reading packets. */ + +static int +remote_unescape_input (const gdb_byte *buffer, int len, + gdb_byte *out_buf, int out_maxlen) +{ + int input_index, output_index; + int escaped; + + output_index = 0; + escaped = 0; + for (input_index = 0; input_index < len; input_index++) + { + gdb_byte b = buffer[input_index]; + + if (output_index + 1 > out_maxlen) + { + warning (_("Received too much data from remote target;" + " ignoring overflow.")); + return output_index; + } + + if (escaped) + { + out_buf[output_index++] = b ^ 0x20; + escaped = 0; + } + else if (b == '}') + escaped = 1; + else + out_buf[output_index++] = b; + } + + if (escaped) + error (_("Unmatched escape character in target response.")); + + return output_index; +} + +/* Determine whether the remote target supports binary downloading. + This is accomplished by sending a no-op memory write of zero length + to the target at the specified address. It does not suffice to send + the whole packet, since many stubs strip the eighth bit and + subsequently compute a wrong checksum, which causes real havoc with + remote_write_bytes. + + NOTE: This can still lose if the serial line is not eight-bit + clean. In cases like this, the user should clear "remote + X-packet". */ + +static void +check_binary_download (CORE_ADDR addr) +{ + struct remote_state *rs = get_remote_state (); + + switch (remote_protocol_packets[PACKET_X].support) + { + case PACKET_DISABLE: + break; + case PACKET_ENABLE: + break; + case PACKET_SUPPORT_UNKNOWN: + { + char *p; + + p = rs->buf; + *p++ = 'X'; + p += hexnumstr (p, (ULONGEST) addr); + *p++ = ','; + p += hexnumstr (p, (ULONGEST) 0); + *p++ = ':'; + *p = '\0'; + + putpkt_binary (rs->buf, (int) (p - rs->buf)); + getpkt (&rs->buf, &rs->buf_size, 0); + + if (rs->buf[0] == '\0') + { + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "binary downloading NOT suppported by target\n"); + remote_protocol_packets[PACKET_X].support = PACKET_DISABLE; + } + else + { + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "binary downloading suppported by target\n"); + remote_protocol_packets[PACKET_X].support = PACKET_ENABLE; + } + break; + } + } +} + +/* Write memory data directly to the remote machine. + This does not inform the data cache; the data cache uses this. + HEADER is the starting part of the packet. + MEMADDR is the address in the remote memory space. + MYADDR is the address of the buffer in our space. + LEN is the number of bytes. + PACKET_FORMAT should be either 'X' or 'M', and indicates if we + should send data as binary ('X'), or hex-encoded ('M'). + + The function creates packet of the form +
,: + + where encoding of is termined by PACKET_FORMAT. + + If USE_LENGTH is 0, then the field and the preceding comma + are omitted. + + Returns the number of bytes transferred, or 0 (setting errno) for + error. Only transfer a single packet. */ + +static int +remote_write_bytes_aux (const char *header, CORE_ADDR memaddr, + const gdb_byte *myaddr, int len, + char packet_format, int use_length) +{ + struct remote_state *rs = get_remote_state (); + char *p; + char *plen = NULL; + int plenlen = 0; + int todo; + int nr_bytes; + int payload_size; + int payload_length; + int header_length; + + if (packet_format != 'X' && packet_format != 'M') + internal_error (__FILE__, __LINE__, + "remote_write_bytes_aux: bad packet format"); + + if (len <= 0) + return 0; + + payload_size = get_memory_write_packet_size (); + + /* The packet buffer will be large enough for the payload; + get_memory_packet_size ensures this. */ + rs->buf[0] = '\0'; + + /* Compute the size of the actual payload by subtracting out the + packet header and footer overhead: "$M,:...#nn". + */ + payload_size -= strlen ("$,:#NN"); + if (!use_length) + /* The comma won't be used. */ + payload_size += 1; + header_length = strlen (header); + payload_size -= header_length; + payload_size -= hexnumlen (memaddr); + + /* Construct the packet excluding the data: "
,:". */ + + strcat (rs->buf, header); + p = rs->buf + strlen (header); + + /* Compute a best guess of the number of bytes actually transfered. */ + if (packet_format == 'X') + { + /* Best guess at number of bytes that will fit. */ + todo = min (len, payload_size); + if (use_length) + payload_size -= hexnumlen (todo); + todo = min (todo, payload_size); + } + else + { + /* Num bytes that will fit. */ + todo = min (len, payload_size / 2); + if (use_length) + payload_size -= hexnumlen (todo); + todo = min (todo, payload_size / 2); + } + + if (todo <= 0) + internal_error (__FILE__, __LINE__, + _("minumum packet size too small to write data")); + + /* If we already need another packet, then try to align the end + of this packet to a useful boundary. */ + if (todo > 2 * REMOTE_ALIGN_WRITES && todo < len) + todo = ((memaddr + todo) & ~(REMOTE_ALIGN_WRITES - 1)) - memaddr; + + /* Append "". */ + memaddr = remote_address_masked (memaddr); + p += hexnumstr (p, (ULONGEST) memaddr); + + if (use_length) + { + /* Append ",". */ + *p++ = ','; + + /* Append . Retain the location/size of . It may need to + be adjusted once the packet body has been created. */ + plen = p; + plenlen = hexnumstr (p, (ULONGEST) todo); + p += plenlen; + } + + /* Append ":". */ + *p++ = ':'; + *p = '\0'; + + /* Append the packet body. */ + if (packet_format == 'X') + { + /* Binary mode. Send target system values byte by byte, in + increasing byte addresses. Only escape certain critical + characters. */ + payload_length = remote_escape_output (myaddr, todo, p, &nr_bytes, + payload_size); + + /* If not all TODO bytes fit, then we'll need another packet. Make + a second try to keep the end of the packet aligned. Don't do + this if the packet is tiny. */ + if (nr_bytes < todo && nr_bytes > 2 * REMOTE_ALIGN_WRITES) + { + int new_nr_bytes; + + new_nr_bytes = (((memaddr + nr_bytes) & ~(REMOTE_ALIGN_WRITES - 1)) + - memaddr); + if (new_nr_bytes != nr_bytes) + payload_length = remote_escape_output (myaddr, new_nr_bytes, + p, &nr_bytes, + payload_size); + } + + p += payload_length; + if (use_length && nr_bytes < todo) + { + /* Escape chars have filled up the buffer prematurely, + and we have actually sent fewer bytes than planned. + Fix-up the length field of the packet. Use the same + number of characters as before. */ + plen += hexnumnstr (plen, (ULONGEST) nr_bytes, plenlen); + *plen = ':'; /* overwrite \0 from hexnumnstr() */ + } + } + else + { + /* Normal mode: Send target system values byte by byte, in + increasing byte addresses. Each byte is encoded as a two hex + value. */ + nr_bytes = bin2hex (myaddr, p, todo); + p += 2 * nr_bytes; + } + + putpkt_binary (rs->buf, (int) (p - rs->buf)); + getpkt (&rs->buf, &rs->buf_size, 0); + + if (rs->buf[0] == 'E') + { + /* There is no correspondance between what the remote protocol + uses for errors and errno codes. We would like a cleaner way + of representing errors (big enough to include errno codes, + bfd_error codes, and others). But for now just return EIO. */ + errno = EIO; + return 0; + } + + /* Return NR_BYTES, not TODO, in case escape chars caused us to send + fewer bytes than we'd planned. */ + return nr_bytes; +} + +/* Write memory data directly to the remote machine. + This does not inform the data cache; the data cache uses this. + MEMADDR is the address in the remote memory space. + MYADDR is the address of the buffer in our space. + LEN is the number of bytes. + + Returns number of bytes transferred, or 0 (setting errno) for + error. Only transfer a single packet. */ + +int +remote_write_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len) +{ + char *packet_format = 0; + + /* Check whether the target supports binary download. */ + check_binary_download (memaddr); + + switch (remote_protocol_packets[PACKET_X].support) + { + case PACKET_ENABLE: + packet_format = "X"; + break; + case PACKET_DISABLE: + packet_format = "M"; + break; + case PACKET_SUPPORT_UNKNOWN: + internal_error (__FILE__, __LINE__, + _("remote_write_bytes: bad internal state")); + default: + internal_error (__FILE__, __LINE__, _("bad switch")); + } + + return remote_write_bytes_aux (packet_format, + memaddr, myaddr, len, packet_format[0], 1); +} + +/* Read memory data directly from the remote machine. + This does not use the data cache; the data cache uses this. + MEMADDR is the address in the remote memory space. + MYADDR is the address of the buffer in our space. + LEN is the number of bytes. + + Returns number of bytes transferred, or 0 for error. */ + +/* NOTE: cagney/1999-10-18: This function (and its siblings in other + remote targets) shouldn't attempt to read the entire buffer. + Instead it should read a single packet worth of data and then + return the byte size of that packet to the caller. The caller (its + caller and its callers caller ;-) already contains code for + handling partial reads. */ + +int +remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, int len) +{ + struct remote_state *rs = get_remote_state (); + int max_buf_size; /* Max size of packet output buffer. */ + int origlen; + + if (len <= 0) + return 0; + + max_buf_size = get_memory_read_packet_size (); + /* The packet buffer will be large enough for the payload; + get_memory_packet_size ensures this. */ + + origlen = len; + while (len > 0) + { + char *p; + int todo; + int i; + + todo = min (len, max_buf_size / 2); /* num bytes that will fit */ + + /* construct "m"","" */ + /* sprintf (rs->buf, "m%lx,%x", (unsigned long) memaddr, todo); */ + memaddr = remote_address_masked (memaddr); + p = rs->buf; + *p++ = 'm'; + p += hexnumstr (p, (ULONGEST) memaddr); + *p++ = ','; + p += hexnumstr (p, (ULONGEST) todo); + *p = '\0'; + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + if (rs->buf[0] == 'E' + && isxdigit (rs->buf[1]) && isxdigit (rs->buf[2]) + && rs->buf[3] == '\0') + { + /* There is no correspondance between what the remote + protocol uses for errors and errno codes. We would like + a cleaner way of representing errors (big enough to + include errno codes, bfd_error codes, and others). But + for now just return EIO. */ + errno = EIO; + return 0; + } + + /* Reply describes memory byte by byte, + each byte encoded as two hex characters. */ + + p = rs->buf; + if ((i = hex2bin (p, myaddr, todo)) < todo) + { + /* Reply is short. This means that we were able to read + only part of what we wanted to. */ + return i + (origlen - len); + } + myaddr += todo; + memaddr += todo; + len -= todo; + } + return origlen; +} + +/* Read or write LEN bytes from inferior memory at MEMADDR, + transferring to or from debugger address BUFFER. Write to inferior + if SHOULD_WRITE is nonzero. Returns length of data written or + read; 0 for error. TARGET is unused. */ + +static int +remote_xfer_memory (CORE_ADDR mem_addr, gdb_byte *buffer, int mem_len, + int should_write, struct mem_attrib *attrib, + struct target_ops *target) +{ + int res; + + if (should_write) + res = remote_write_bytes (mem_addr, buffer, mem_len); + else + res = remote_read_bytes (mem_addr, buffer, mem_len); + + return res; +} + +/* Sends a packet with content determined by the printf format string + FORMAT and the remaining arguments, then gets the reply. Returns + whether the packet was a success, a failure, or unknown. */ + +enum packet_result +remote_send_printf (const char *format, ...) +{ + struct remote_state *rs = get_remote_state (); + int max_size = get_remote_packet_size (); + + va_list ap; + va_start (ap, format); + + rs->buf[0] = '\0'; + if (vsnprintf (rs->buf, max_size, format, ap) >= max_size) + internal_error (__FILE__, __LINE__, "Too long remote packet."); + + if (putpkt (rs->buf) < 0) + error (_("Communication problem with target.")); + + rs->buf[0] = '\0'; + getpkt (&rs->buf, &rs->buf_size, 0); + + return packet_check_result (rs->buf); +} + +static void +restore_remote_timeout (void *p) +{ + int value = *(int *)p; + remote_timeout = value; +} + +/* Flash writing can take quite some time. We'll set + effectively infinite timeout for flash operations. + In future, we'll need to decide on a better approach. */ +static const int remote_flash_timeout = 1000; + +static void +remote_flash_erase (struct target_ops *ops, + ULONGEST address, LONGEST length) +{ + int saved_remote_timeout = remote_timeout; + enum packet_result ret; + + struct cleanup *back_to = make_cleanup (restore_remote_timeout, + &saved_remote_timeout); + remote_timeout = remote_flash_timeout; + + ret = remote_send_printf ("vFlashErase:%s,%s", + paddr (address), + phex (length, 4)); + switch (ret) + { + case PACKET_UNKNOWN: + error (_("Remote target does not support flash erase")); + case PACKET_ERROR: + error (_("Error erasing flash with vFlashErase packet")); + default: + break; + } + + do_cleanups (back_to); +} + +static LONGEST +remote_flash_write (struct target_ops *ops, + ULONGEST address, LONGEST length, + const gdb_byte *data) +{ + int saved_remote_timeout = remote_timeout; + int ret; + struct cleanup *back_to = make_cleanup (restore_remote_timeout, + &saved_remote_timeout); + + remote_timeout = remote_flash_timeout; + ret = remote_write_bytes_aux ("vFlashWrite:", address, data, length, 'X', 0); + do_cleanups (back_to); + + return ret; +} + +static void +remote_flash_done (struct target_ops *ops) +{ + int saved_remote_timeout = remote_timeout; + int ret; + struct cleanup *back_to = make_cleanup (restore_remote_timeout, + &saved_remote_timeout); + + remote_timeout = remote_flash_timeout; + ret = remote_send_printf ("vFlashDone"); + do_cleanups (back_to); + + switch (ret) + { + case PACKET_UNKNOWN: + error (_("Remote target does not support vFlashDone")); + case PACKET_ERROR: + error (_("Error finishing flash operation")); + default: + break; + } +} + +static void +remote_files_info (struct target_ops *ignore) +{ + puts_filtered ("Debugging a target over a serial line.\n"); +} + +/* Stuff for dealing with the packets which are part of this protocol. + See comment at top of file for details. */ + +/* Read a single character from the remote end. */ + +static int +readchar (int timeout) +{ + int ch; + + ch = serial_readchar (remote_desc, timeout); + + if (ch >= 0) + return ch; + + switch ((enum serial_rc) ch) + { + case SERIAL_EOF: + target_mourn_inferior (); + error (_("Remote connection closed")); + /* no return */ + case SERIAL_ERROR: + perror_with_name (_("Remote communication error")); + /* no return */ + case SERIAL_TIMEOUT: + break; + } + return ch; +} + +/* Send the command in *BUF to the remote machine, and read the reply + into *BUF. Report an error if we get an error reply. Resize + *BUF using xrealloc if necessary to hold the result, and update + *SIZEOF_BUF. */ + +static void +remote_send (char **buf, + long *sizeof_buf) +{ + putpkt (*buf); + getpkt (buf, sizeof_buf, 0); + + if ((*buf)[0] == 'E') + error (_("Remote failure reply: %s"), *buf); +} + +/* Display a null-terminated packet on stdout, for debugging, using C + string notation. */ + +static void +print_packet (char *buf) +{ + puts_filtered ("\""); + fputstr_filtered (buf, '"', gdb_stdout); + puts_filtered ("\""); +} + +int +putpkt (char *buf) +{ + return putpkt_binary (buf, strlen (buf)); +} + +/* Send a packet to the remote machine, with error checking. The data + of the packet is in BUF. The string in BUF can be at most + get_remote_packet_size () - 5 to account for the $, # and checksum, + and for a possible /0 if we are debugging (remote_debug) and want + to print the sent packet as a string. */ + +static int +putpkt_binary (char *buf, int cnt) +{ + int i; + unsigned char csum = 0; + char *buf2 = alloca (cnt + 6); + + int ch; + int tcount = 0; + char *p; + + /* Copy the packet into buffer BUF2, encapsulating it + and giving it a checksum. */ + + p = buf2; + *p++ = '$'; + + for (i = 0; i < cnt; i++) + { + csum += buf[i]; + *p++ = buf[i]; + } + *p++ = '#'; + *p++ = tohex ((csum >> 4) & 0xf); + *p++ = tohex (csum & 0xf); + + /* Send it over and over until we get a positive ack. */ + + while (1) + { + int started_error_output = 0; + + if (remote_debug) + { + *p = '\0'; + fprintf_unfiltered (gdb_stdlog, "Sending packet: "); + fputstrn_unfiltered (buf2, p - buf2, 0, gdb_stdlog); + fprintf_unfiltered (gdb_stdlog, "..."); + gdb_flush (gdb_stdlog); + } + if (serial_write (remote_desc, buf2, p - buf2)) + perror_with_name (_("putpkt: write failed")); + + /* Read until either a timeout occurs (-2) or '+' is read. */ + while (1) + { + ch = readchar (remote_timeout); + + if (remote_debug) + { + switch (ch) + { + case '+': + case '-': + case SERIAL_TIMEOUT: + case '$': + if (started_error_output) + { + putchar_unfiltered ('\n'); + started_error_output = 0; + } + } + } + + switch (ch) + { + case '+': + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "Ack\n"); + return 1; + case '-': + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, "Nak\n"); + case SERIAL_TIMEOUT: + tcount++; + if (tcount > 3) + return 0; + break; /* Retransmit buffer. */ + case '$': + { + if (remote_debug) + fprintf_unfiltered (gdb_stdlog, + "Packet instead of Ack, ignoring it\n"); + /* It's probably an old response sent because an ACK + was lost. Gobble up the packet and ack it so it + doesn't get retransmitted when we resend this + packet. */ + skip_frame (); + serial_write (remote_desc, "+", 1); + continue; /* Now, go look for +. */ + } + default: + if (remote_debug) + { + if (!started_error_output) + { + started_error_output = 1; + fprintf_unfiltered (gdb_stdlog, "putpkt: Junk: "); + } + fputc_unfiltered (ch & 0177, gdb_stdlog); + } + continue; + } + break; /* Here to retransmit. */ + } + +#if 0 + /* This is wrong. If doing a long backtrace, the user should be + able to get out next time we call QUIT, without anything as + violent as interrupt_query. If we want to provide a way out of + here without getting to the next QUIT, it should be based on + hitting ^C twice as in remote_wait. */ + if (quit_flag) + { + quit_flag = 0; + interrupt_query (); + } +#endif + } +} + +/* Come here after finding the start of a frame when we expected an + ack. Do our best to discard the rest of this packet. */ + +static void +skip_frame (void) +{ + int c; + + while (1) + { + c = readchar (remote_timeout); + switch (c) + { + case SERIAL_TIMEOUT: + /* Nothing we can do. */ + return; + case '#': + /* Discard the two bytes of checksum and stop. */ + c = readchar (remote_timeout); + if (c >= 0) + c = readchar (remote_timeout); + + return; + case '*': /* Run length encoding. */ + /* Discard the repeat count. */ + c = readchar (remote_timeout); + if (c < 0) + return; + break; + default: + /* A regular character. */ + break; + } + } +} + +/* Come here after finding the start of the frame. Collect the rest + into *BUF, verifying the checksum, length, and handling run-length + compression. NUL terminate the buffer. If there is not enough room, + expand *BUF using xrealloc. + + Returns -1 on error, number of characters in buffer (ignoring the + trailing NULL) on success. (could be extended to return one of the + SERIAL status indications). */ + +static long +read_frame (char **buf_p, + long *sizeof_buf) +{ + unsigned char csum; + long bc; + int c; + char *buf = *buf_p; + + csum = 0; + bc = 0; + + while (1) + { + c = readchar (remote_timeout); + switch (c) + { + case SERIAL_TIMEOUT: + if (remote_debug) + fputs_filtered ("Timeout in mid-packet, retrying\n", gdb_stdlog); + return -1; + case '$': + if (remote_debug) + fputs_filtered ("Saw new packet start in middle of old one\n", + gdb_stdlog); + return -1; /* Start a new packet, count retries. */ + case '#': + { + unsigned char pktcsum; + int check_0 = 0; + int check_1 = 0; + + buf[bc] = '\0'; + + check_0 = readchar (remote_timeout); + if (check_0 >= 0) + check_1 = readchar (remote_timeout); + + if (check_0 == SERIAL_TIMEOUT || check_1 == SERIAL_TIMEOUT) + { + if (remote_debug) + fputs_filtered ("Timeout in checksum, retrying\n", + gdb_stdlog); + return -1; + } + else if (check_0 < 0 || check_1 < 0) + { + if (remote_debug) + fputs_filtered ("Communication error in checksum\n", + gdb_stdlog); + return -1; + } + + pktcsum = (fromhex (check_0) << 4) | fromhex (check_1); + if (csum == pktcsum) + return bc; + + if (remote_debug) + { + fprintf_filtered (gdb_stdlog, + "Bad checksum, sentsum=0x%x, csum=0x%x, buf=", + pktcsum, csum); + fputstrn_filtered (buf, bc, 0, gdb_stdlog); + fputs_filtered ("\n", gdb_stdlog); + } + /* Number of characters in buffer ignoring trailing + NULL. */ + return -1; + } + case '*': /* Run length encoding. */ + { + int repeat; + csum += c; + + c = readchar (remote_timeout); + csum += c; + repeat = c - ' ' + 3; /* Compute repeat count. */ + + /* The character before ``*'' is repeated. */ + + if (repeat > 0 && repeat <= 255 && bc > 0) + { + if (bc + repeat - 1 >= *sizeof_buf - 1) + { + /* Make some more room in the buffer. */ + *sizeof_buf += repeat; + *buf_p = xrealloc (*buf_p, *sizeof_buf); + buf = *buf_p; + } + + memset (&buf[bc], buf[bc - 1], repeat); + bc += repeat; + continue; + } + + buf[bc] = '\0'; + printf_filtered (_("Invalid run length encoding: %s\n"), buf); + return -1; + } + default: + if (bc >= *sizeof_buf - 1) + { + /* Make some more room in the buffer. */ + *sizeof_buf *= 2; + *buf_p = xrealloc (*buf_p, *sizeof_buf); + buf = *buf_p; + } + + buf[bc++] = c; + csum += c; + continue; + } + } +} + +/* Read a packet from the remote machine, with error checking, and + store it in *BUF. Resize *BUF using xrealloc if necessary to hold + the result, and update *SIZEOF_BUF. If FOREVER, wait forever + rather than timing out; this is used (in synchronous mode) to wait + for a target that is is executing user code to stop. */ +/* FIXME: ezannoni 2000-02-01 this wrapper is necessary so that we + don't have to change all the calls to getpkt to deal with the + return value, because at the moment I don't know what the right + thing to do it for those. */ +void +getpkt (char **buf, + long *sizeof_buf, + int forever) +{ + int timed_out; + + timed_out = getpkt_sane (buf, sizeof_buf, forever); +} + + +/* Read a packet from the remote machine, with error checking, and + store it in *BUF. Resize *BUF using xrealloc if necessary to hold + the result, and update *SIZEOF_BUF. If FOREVER, wait forever + rather than timing out; this is used (in synchronous mode) to wait + for a target that is is executing user code to stop. If FOREVER == + 0, this function is allowed to time out gracefully and return an + indication of this to the caller. Otherwise return the number + of bytes read. */ +static int +getpkt_sane (char **buf, long *sizeof_buf, int forever) +{ + int c; + int tries; + int timeout; + int val; + + strcpy (*buf, "timeout"); + + if (forever) + { + timeout = watchdog > 0 ? watchdog : -1; + } + + else + timeout = remote_timeout; + +#define MAX_TRIES 3 + + for (tries = 1; tries <= MAX_TRIES; tries++) + { + /* This can loop forever if the remote side sends us characters + continuously, but if it pauses, we'll get a zero from + readchar because of timeout. Then we'll count that as a + retry. */ + + /* Note that we will only wait forever prior to the start of a + packet. After that, we expect characters to arrive at a + brisk pace. They should show up within remote_timeout + intervals. */ + + do + { + c = readchar (timeout); + + if (c == SERIAL_TIMEOUT) + { + if (forever) /* Watchdog went off? Kill the target. */ + { + QUIT; + target_mourn_inferior (); + error (_("Watchdog has expired. Target detached.")); + } + if (remote_debug) + fputs_filtered ("Timed out.\n", gdb_stdlog); + goto retry; + } + } + while (c != '$'); + + /* We've found the start of a packet, now collect the data. */ + + val = read_frame (buf, sizeof_buf); + + if (val >= 0) + { + if (remote_debug) + { + fprintf_unfiltered (gdb_stdlog, "Packet received: "); + fputstrn_unfiltered (*buf, val, 0, gdb_stdlog); + fprintf_unfiltered (gdb_stdlog, "\n"); + } + serial_write (remote_desc, "+", 1); + return val; + } + + /* Try the whole thing again. */ + retry: + serial_write (remote_desc, "-", 1); + } + + /* We have tried hard enough, and just can't receive the packet. + Give up. */ + + printf_unfiltered (_("Ignoring packet error, continuing...\n")); + serial_write (remote_desc, "+", 1); + return -1; +} + +static void +remote_kill (void) +{ + /* For some mysterious reason, wait_for_inferior calls kill instead of + mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */ + if (kill_kludge) + { + kill_kludge = 0; + target_mourn_inferior (); + return; + } + + /* Use catch_errors so the user can quit from gdb even when we aren't on + speaking terms with the remote system. */ + catch_errors ((catch_errors_ftype *) putpkt, "k", "", RETURN_MASK_ERROR); + + /* Don't wait for it to die. I'm not really sure it matters whether + we do or not. For the existing stubs, kill is a noop. */ + target_mourn_inferior (); +} + +/* Async version of remote_kill. */ +static void +remote_async_kill (void) +{ + /* Unregister the file descriptor from the event loop. */ + if (target_is_async_p ()) + serial_async (remote_desc, NULL, 0); + + /* For some mysterious reason, wait_for_inferior calls kill instead of + mourn after it gets TARGET_WAITKIND_SIGNALLED. Work around it. */ + if (kill_kludge) + { + kill_kludge = 0; + target_mourn_inferior (); + return; + } + + /* Use catch_errors so the user can quit from gdb even when we + aren't on speaking terms with the remote system. */ + catch_errors ((catch_errors_ftype *) putpkt, "k", "", RETURN_MASK_ERROR); + + /* Don't wait for it to die. I'm not really sure it matters whether + we do or not. For the existing stubs, kill is a noop. */ + target_mourn_inferior (); +} + +static void +remote_mourn (void) +{ + remote_mourn_1 (&remote_ops); +} + +static void +remote_async_mourn (void) +{ + remote_mourn_1 (&remote_async_ops); +} + +static void +extended_remote_mourn (void) +{ + /* We do _not_ want to mourn the target like this; this will + remove the extended remote target from the target stack, + and the next time the user says "run" it'll fail. + + FIXME: What is the right thing to do here? */ +#if 0 + remote_mourn_1 (&extended_remote_ops); +#endif +} + +/* Worker function for remote_mourn. */ +static void +remote_mourn_1 (struct target_ops *target) +{ + unpush_target (target); + generic_mourn_inferior (); +} + +/* In the extended protocol we want to be able to do things like + "run" and have them basically work as expected. So we need + a special create_inferior function. + + FIXME: One day add support for changing the exec file + we're debugging, arguments and an environment. */ + +static void +extended_remote_create_inferior (char *exec_file, char *args, + char **env, int from_tty) +{ + /* Rip out the breakpoints; we'll reinsert them after restarting + the remote server. */ + remove_breakpoints (); + + /* Now restart the remote server. */ + extended_remote_restart (); + + /* NOTE: We don't need to recheck for a target description here; but + if we gain the ability to switch the remote executable we may + need to, if for instance we are running a process which requested + different emulated hardware from the operating system. A + concrete example of this is ARM GNU/Linux, where some binaries + will have a legacy FPA coprocessor emulated and others may have + access to a hardware VFP unit. */ + + /* Now put the breakpoints back in. This way we're safe if the + restart function works via a unix fork on the remote side. */ + insert_breakpoints (); + + /* Clean up from the last time we were running. */ + clear_proceed_status (); +} + +/* Async version of extended_remote_create_inferior. */ +static void +extended_remote_async_create_inferior (char *exec_file, char *args, + char **env, int from_tty) +{ + /* Rip out the breakpoints; we'll reinsert them after restarting + the remote server. */ + remove_breakpoints (); + + /* If running asynchronously, register the target file descriptor + with the event loop. */ + if (target_can_async_p ()) + target_async (inferior_event_handler, 0); + + /* Now restart the remote server. */ + extended_remote_restart (); + + /* NOTE: We don't need to recheck for a target description here; but + if we gain the ability to switch the remote executable we may + need to, if for instance we are running a process which requested + different emulated hardware from the operating system. A + concrete example of this is ARM GNU/Linux, where some binaries + will have a legacy FPA coprocessor emulated and others may have + access to a hardware VFP unit. */ + + /* Now put the breakpoints back in. This way we're safe if the + restart function works via a unix fork on the remote side. */ + insert_breakpoints (); + + /* Clean up from the last time we were running. */ + clear_proceed_status (); +} + + +/* Insert a breakpoint. On targets that have software breakpoint + support, we ask the remote target to do the work; on targets + which don't, we insert a traditional memory breakpoint. */ + +static int +remote_insert_breakpoint (struct bp_target_info *bp_tgt) +{ + CORE_ADDR addr = bp_tgt->placed_address; + struct remote_state *rs = get_remote_state (); + + /* Try the "Z" s/w breakpoint packet if it is not already disabled. + If it succeeds, then set the support to PACKET_ENABLE. If it + fails, and the user has explicitly requested the Z support then + report an error, otherwise, mark it disabled and go on. */ + + if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) + { + char *p = rs->buf; + + *(p++) = 'Z'; + *(p++) = '0'; + *(p++) = ','; + gdbarch_breakpoint_from_pc + (current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size); + addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address); + p += hexnumstr (p, addr); + sprintf (p, ",%d", bp_tgt->placed_size); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0])) + { + case PACKET_ERROR: + return -1; + case PACKET_OK: + return 0; + case PACKET_UNKNOWN: + break; + } + } + + return memory_insert_breakpoint (bp_tgt); +} + +static int +remote_remove_breakpoint (struct bp_target_info *bp_tgt) +{ + CORE_ADDR addr = bp_tgt->placed_address; + struct remote_state *rs = get_remote_state (); + int bp_size; + + if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE) + { + char *p = rs->buf; + + *(p++) = 'z'; + *(p++) = '0'; + *(p++) = ','; + + addr = (ULONGEST) remote_address_masked (bp_tgt->placed_address); + p += hexnumstr (p, addr); + sprintf (p, ",%d", bp_tgt->placed_size); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + return (rs->buf[0] == 'E'); + } + + return memory_remove_breakpoint (bp_tgt); +} + +static int +watchpoint_to_Z_packet (int type) +{ + switch (type) + { + case hw_write: + return Z_PACKET_WRITE_WP; + break; + case hw_read: + return Z_PACKET_READ_WP; + break; + case hw_access: + return Z_PACKET_ACCESS_WP; + break; + default: + internal_error (__FILE__, __LINE__, + _("hw_bp_to_z: bad watchpoint type %d"), type); + } +} + +static int +remote_insert_watchpoint (CORE_ADDR addr, int len, int type) +{ + struct remote_state *rs = get_remote_state (); + char *p; + enum Z_packet_type packet = watchpoint_to_Z_packet (type); + + if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE) + return -1; + + sprintf (rs->buf, "Z%x,", packet); + p = strchr (rs->buf, '\0'); + addr = remote_address_masked (addr); + p += hexnumstr (p, (ULONGEST) addr); + sprintf (p, ",%x", len); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet])) + { + case PACKET_ERROR: + case PACKET_UNKNOWN: + return -1; + case PACKET_OK: + return 0; + } + internal_error (__FILE__, __LINE__, + _("remote_insert_watchpoint: reached end of function")); +} + + +static int +remote_remove_watchpoint (CORE_ADDR addr, int len, int type) +{ + struct remote_state *rs = get_remote_state (); + char *p; + enum Z_packet_type packet = watchpoint_to_Z_packet (type); + + if (remote_protocol_packets[PACKET_Z0 + packet].support == PACKET_DISABLE) + return -1; + + sprintf (rs->buf, "z%x,", packet); + p = strchr (rs->buf, '\0'); + addr = remote_address_masked (addr); + p += hexnumstr (p, (ULONGEST) addr); + sprintf (p, ",%x", len); + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z0 + packet])) + { + case PACKET_ERROR: + case PACKET_UNKNOWN: + return -1; + case PACKET_OK: + return 0; + } + internal_error (__FILE__, __LINE__, + _("remote_remove_watchpoint: reached end of function")); +} + + +int remote_hw_watchpoint_limit = -1; +int remote_hw_breakpoint_limit = -1; + +static int +remote_check_watch_resources (int type, int cnt, int ot) +{ + if (type == bp_hardware_breakpoint) + { + if (remote_hw_breakpoint_limit == 0) + return 0; + else if (remote_hw_breakpoint_limit < 0) + return 1; + else if (cnt <= remote_hw_breakpoint_limit) + return 1; + } + else + { + if (remote_hw_watchpoint_limit == 0) + return 0; + else if (remote_hw_watchpoint_limit < 0) + return 1; + else if (ot) + return -1; + else if (cnt <= remote_hw_watchpoint_limit) + return 1; + } + return -1; +} + +static int +remote_stopped_by_watchpoint (void) +{ + return remote_stopped_by_watchpoint_p; +} + +extern int stepped_after_stopped_by_watchpoint; + +static int +remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) +{ + int rc = 0; + if (remote_stopped_by_watchpoint () + || stepped_after_stopped_by_watchpoint) + { + *addr_p = remote_watch_data_address; + rc = 1; + } + + return rc; +} + + +static int +remote_insert_hw_breakpoint (struct bp_target_info *bp_tgt) +{ + CORE_ADDR addr; + struct remote_state *rs = get_remote_state (); + char *p = rs->buf; + + /* The length field should be set to the size of a breakpoint + instruction, even though we aren't inserting one ourselves. */ + + gdbarch_breakpoint_from_pc + (current_gdbarch, &bp_tgt->placed_address, &bp_tgt->placed_size); + + if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) + return -1; + + *(p++) = 'Z'; + *(p++) = '1'; + *(p++) = ','; + + addr = remote_address_masked (bp_tgt->placed_address); + p += hexnumstr (p, (ULONGEST) addr); + sprintf (p, ",%x", bp_tgt->placed_size); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1])) + { + case PACKET_ERROR: + case PACKET_UNKNOWN: + return -1; + case PACKET_OK: + return 0; + } + internal_error (__FILE__, __LINE__, + _("remote_insert_hw_breakpoint: reached end of function")); +} + + +static int +remote_remove_hw_breakpoint (struct bp_target_info *bp_tgt) +{ + CORE_ADDR addr; + struct remote_state *rs = get_remote_state (); + char *p = rs->buf; + + if (remote_protocol_packets[PACKET_Z1].support == PACKET_DISABLE) + return -1; + + *(p++) = 'z'; + *(p++) = '1'; + *(p++) = ','; + + addr = remote_address_masked (bp_tgt->placed_address); + p += hexnumstr (p, (ULONGEST) addr); + sprintf (p, ",%x", bp_tgt->placed_size); + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + + switch (packet_ok (rs->buf, &remote_protocol_packets[PACKET_Z1])) + { + case PACKET_ERROR: + case PACKET_UNKNOWN: + return -1; + case PACKET_OK: + return 0; + } + internal_error (__FILE__, __LINE__, + _("remote_remove_hw_breakpoint: reached end of function")); +} + +/* Some targets are only capable of doing downloads, and afterwards + they switch to the remote serial protocol. This function provides + a clean way to get from the download target to the remote target. + It's basically just a wrapper so that we don't have to expose any + of the internal workings of remote.c. + + Prior to calling this routine, you should shutdown the current + target code, else you will get the "A program is being debugged + already..." message. Usually a call to pop_target() suffices. */ + +void +push_remote_target (char *name, int from_tty) +{ + printf_filtered (_("Switching to remote protocol\n")); + remote_open (name, from_tty); +} + +/* Table used by the crc32 function to calcuate the checksum. */ + +static unsigned long crc32_table[256] = +{0, 0}; + +static unsigned long +crc32 (unsigned char *buf, int len, unsigned int crc) +{ + if (!crc32_table[1]) + { + /* Initialize the CRC table and the decoding table. */ + int i, j; + unsigned int c; + + for (i = 0; i < 256; i++) + { + for (c = i << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ 0x04c11db7 : (c << 1); + crc32_table[i] = c; + } + } + + while (len--) + { + crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ *buf) & 255]; + buf++; + } + return crc; +} + +/* compare-sections command + + With no arguments, compares each loadable section in the exec bfd + with the same memory range on the target, and reports mismatches. + Useful for verifying the image on the target against the exec file. + Depends on the target understanding the new "qCRC:" request. */ + +/* FIXME: cagney/1999-10-26: This command should be broken down into a + target method (target verify memory) and generic version of the + actual command. This will allow other high-level code (especially + generic_load()) to make use of this target functionality. */ + +static void +compare_sections_command (char *args, int from_tty) +{ + struct remote_state *rs = get_remote_state (); + asection *s; + unsigned long host_crc, target_crc; + extern bfd *exec_bfd; + struct cleanup *old_chain; + char *tmp; + char *sectdata; + const char *sectname; + bfd_size_type size; + bfd_vma lma; + int matched = 0; + int mismatched = 0; + + if (!exec_bfd) + error (_("command cannot be used without an exec file")); + if (!current_target.to_shortname || + strcmp (current_target.to_shortname, "remote") != 0) + error (_("command can only be used with remote target")); + + for (s = exec_bfd->sections; s; s = s->next) + { + if (!(s->flags & SEC_LOAD)) + continue; /* skip non-loadable section */ + + size = bfd_get_section_size (s); + if (size == 0) + continue; /* skip zero-length section */ + + sectname = bfd_get_section_name (exec_bfd, s); + if (args && strcmp (args, sectname) != 0) + continue; /* not the section selected by user */ + + matched = 1; /* do this section */ + lma = s->lma; + /* FIXME: assumes lma can fit into long. */ + xsnprintf (rs->buf, get_remote_packet_size (), "qCRC:%lx,%lx", + (long) lma, (long) size); + putpkt (rs->buf); + + /* Be clever; compute the host_crc before waiting for target + reply. */ + sectdata = xmalloc (size); + old_chain = make_cleanup (xfree, sectdata); + bfd_get_section_contents (exec_bfd, s, sectdata, 0, size); + host_crc = crc32 ((unsigned char *) sectdata, size, 0xffffffff); + + getpkt (&rs->buf, &rs->buf_size, 0); + if (rs->buf[0] == 'E') + error (_("target memory fault, section %s, range 0x%s -- 0x%s"), + sectname, paddr (lma), paddr (lma + size)); + if (rs->buf[0] != 'C') + error (_("remote target does not support this operation")); + + for (target_crc = 0, tmp = &rs->buf[1]; *tmp; tmp++) + target_crc = target_crc * 16 + fromhex (*tmp); + + printf_filtered ("Section %s, range 0x%s -- 0x%s: ", + sectname, paddr (lma), paddr (lma + size)); + if (host_crc == target_crc) + printf_filtered ("matched.\n"); + else + { + printf_filtered ("MIS-MATCHED!\n"); + mismatched++; + } + + do_cleanups (old_chain); + } + if (mismatched > 0) + warning (_("One or more sections of the remote executable does not match\n\ +the loaded file\n")); + if (args && !matched) + printf_filtered (_("No loaded section named '%s'.\n"), args); +} + +/* Write LEN bytes from WRITEBUF into OBJECT_NAME/ANNEX at OFFSET + into remote target. The number of bytes written to the remote + target is returned, or -1 for error. */ + +static LONGEST +remote_write_qxfer (struct target_ops *ops, const char *object_name, + const char *annex, const gdb_byte *writebuf, + ULONGEST offset, LONGEST len, + struct packet_config *packet) +{ + int i, buf_len; + ULONGEST n; + gdb_byte *wbuf; + struct remote_state *rs = get_remote_state (); + int max_size = get_memory_write_packet_size (); + + if (packet->support == PACKET_DISABLE) + return -1; + + /* Insert header. */ + i = snprintf (rs->buf, max_size, + "qXfer:%s:write:%s:%s:", + object_name, annex ? annex : "", + phex_nz (offset, sizeof offset)); + max_size -= (i + 1); + + /* Escape as much data as fits into rs->buf. */ + buf_len = remote_escape_output + (writebuf, len, (rs->buf + i), &max_size, max_size); + + if (putpkt_binary (rs->buf, i + buf_len) < 0 + || getpkt_sane (&rs->buf, &rs->buf_size, 0) < 0 + || packet_ok (rs->buf, packet) != PACKET_OK) + return -1; + + unpack_varlen_hex (rs->buf, &n); + return n; +} + +/* Read OBJECT_NAME/ANNEX from the remote target using a qXfer packet. + Data at OFFSET, of up to LEN bytes, is read into READBUF; the + number of bytes read is returned, or 0 for EOF, or -1 for error. + The number of bytes read may be less than LEN without indicating an + EOF. PACKET is checked and updated to indicate whether the remote + target supports this object. */ + +static LONGEST +remote_read_qxfer (struct target_ops *ops, const char *object_name, + const char *annex, + gdb_byte *readbuf, ULONGEST offset, LONGEST len, + struct packet_config *packet) +{ + static char *finished_object; + static char *finished_annex; + static ULONGEST finished_offset; + + struct remote_state *rs = get_remote_state (); + unsigned int total = 0; + LONGEST i, n, packet_len; + + if (packet->support == PACKET_DISABLE) + return -1; + + /* Check whether we've cached an end-of-object packet that matches + this request. */ + if (finished_object) + { + if (strcmp (object_name, finished_object) == 0 + && strcmp (annex ? annex : "", finished_annex) == 0 + && offset == finished_offset) + return 0; + + /* Otherwise, we're now reading something different. Discard + the cache. */ + xfree (finished_object); + xfree (finished_annex); + finished_object = NULL; + finished_annex = NULL; + } + + /* Request only enough to fit in a single packet. The actual data + may not, since we don't know how much of it will need to be escaped; + the target is free to respond with slightly less data. We subtract + five to account for the response type and the protocol frame. */ + n = min (get_remote_packet_size () - 5, len); + snprintf (rs->buf, get_remote_packet_size () - 4, "qXfer:%s:read:%s:%s,%s", + object_name, annex ? annex : "", + phex_nz (offset, sizeof offset), + phex_nz (n, sizeof n)); + i = putpkt (rs->buf); + if (i < 0) + return -1; + + rs->buf[0] = '\0'; + packet_len = getpkt_sane (&rs->buf, &rs->buf_size, 0); + if (packet_len < 0 || packet_ok (rs->buf, packet) != PACKET_OK) + return -1; + + if (rs->buf[0] != 'l' && rs->buf[0] != 'm') + error (_("Unknown remote qXfer reply: %s"), rs->buf); + + /* 'm' means there is (or at least might be) more data after this + batch. That does not make sense unless there's at least one byte + of data in this reply. */ + if (rs->buf[0] == 'm' && packet_len == 1) + error (_("Remote qXfer reply contained no data.")); + + /* Got some data. */ + i = remote_unescape_input (rs->buf + 1, packet_len - 1, readbuf, n); + + /* 'l' is an EOF marker, possibly including a final block of data, + or possibly empty. If we have the final block of a non-empty + object, record this fact to bypass a subsequent partial read. */ + if (rs->buf[0] == 'l' && offset + i > 0) + { + finished_object = xstrdup (object_name); + finished_annex = xstrdup (annex ? annex : ""); + finished_offset = offset + i; + } + + return i; +} + +static LONGEST +remote_xfer_partial (struct target_ops *ops, enum target_object object, + const char *annex, gdb_byte *readbuf, + const gdb_byte *writebuf, ULONGEST offset, LONGEST len) +{ + struct remote_state *rs = get_remote_state (); + int i; + char *p2; + char query_type; + + /* Handle memory using the standard memory routines. */ + if (object == TARGET_OBJECT_MEMORY) + { + int xfered; + errno = 0; + + if (writebuf != NULL) + xfered = remote_write_bytes (offset, writebuf, len); + else + xfered = remote_read_bytes (offset, readbuf, len); + + if (xfered > 0) + return xfered; + else if (xfered == 0 && errno == 0) + return 0; + else + return -1; + } + + /* Handle SPU memory using qxfer packets. */ + if (object == TARGET_OBJECT_SPU) + { + if (readbuf) + return remote_read_qxfer (ops, "spu", annex, readbuf, offset, len, + &remote_protocol_packets + [PACKET_qXfer_spu_read]); + else + return remote_write_qxfer (ops, "spu", annex, writebuf, offset, len, + &remote_protocol_packets + [PACKET_qXfer_spu_write]); + } + + /* Only handle flash writes. */ + if (writebuf != NULL) + { + LONGEST xfered; + + switch (object) + { + case TARGET_OBJECT_FLASH: + xfered = remote_flash_write (ops, offset, len, writebuf); + + if (xfered > 0) + return xfered; + else if (xfered == 0 && errno == 0) + return 0; + else + return -1; + + default: + return -1; + } + } + + /* Map pre-existing objects onto letters. DO NOT do this for new + objects!!! Instead specify new query packets. */ + switch (object) + { + case TARGET_OBJECT_AVR: + query_type = 'R'; + break; + + case TARGET_OBJECT_AUXV: + gdb_assert (annex == NULL); + return remote_read_qxfer (ops, "auxv", annex, readbuf, offset, len, + &remote_protocol_packets[PACKET_qXfer_auxv]); + + case TARGET_OBJECT_AVAILABLE_FEATURES: + return remote_read_qxfer + (ops, "features", annex, readbuf, offset, len, + &remote_protocol_packets[PACKET_qXfer_features]); + + case TARGET_OBJECT_LIBRARIES: + return remote_read_qxfer + (ops, "libraries", annex, readbuf, offset, len, + &remote_protocol_packets[PACKET_qXfer_libraries]); + + case TARGET_OBJECT_MEMORY_MAP: + gdb_assert (annex == NULL); + return remote_read_qxfer (ops, "memory-map", annex, readbuf, offset, len, + &remote_protocol_packets[PACKET_qXfer_memory_map]); + + default: + return -1; + } + + /* Note: a zero OFFSET and LEN can be used to query the minimum + buffer size. */ + if (offset == 0 && len == 0) + return (get_remote_packet_size ()); + /* Minimum outbuf size is get_remote_packet_size (). If LEN is not + large enough let the caller deal with it. */ + if (len < get_remote_packet_size ()) + return -1; + len = get_remote_packet_size (); + + /* Except for querying the minimum buffer size, target must be open. */ + if (!remote_desc) + error (_("remote query is only available after target open")); + + gdb_assert (annex != NULL); + gdb_assert (readbuf != NULL); + + p2 = rs->buf; + *p2++ = 'q'; + *p2++ = query_type; + + /* We used one buffer char for the remote protocol q command and + another for the query type. As the remote protocol encapsulation + uses 4 chars plus one extra in case we are debugging + (remote_debug), we have PBUFZIZ - 7 left to pack the query + string. */ + i = 0; + while (annex[i] && (i < (get_remote_packet_size () - 8))) + { + /* Bad caller may have sent forbidden characters. */ + gdb_assert (isprint (annex[i]) && annex[i] != '$' && annex[i] != '#'); + *p2++ = annex[i]; + i++; + } + *p2 = '\0'; + gdb_assert (annex[i] == '\0'); + + i = putpkt (rs->buf); + if (i < 0) + return i; + + getpkt (&rs->buf, &rs->buf_size, 0); + strcpy ((char *) readbuf, rs->buf); + + return strlen ((char *) readbuf); +} + +static void +remote_rcmd (char *command, + struct ui_file *outbuf) +{ + struct remote_state *rs = get_remote_state (); + char *p = rs->buf; + + if (!remote_desc) + error (_("remote rcmd is only available after target open")); + + /* Send a NULL command across as an empty command. */ + if (command == NULL) + command = ""; + + /* The query prefix. */ + strcpy (rs->buf, "qRcmd,"); + p = strchr (rs->buf, '\0'); + + if ((strlen (rs->buf) + strlen (command) * 2 + 8/*misc*/) > get_remote_packet_size ()) + error (_("\"monitor\" command ``%s'' is too long."), command); + + /* Encode the actual command. */ + bin2hex ((gdb_byte *) command, p, 0); + + if (putpkt (rs->buf) < 0) + error (_("Communication problem with target.")); + + /* get/display the response */ + while (1) + { + char *buf; + + /* XXX - see also tracepoint.c:remote_get_noisy_reply(). */ + rs->buf[0] = '\0'; + getpkt (&rs->buf, &rs->buf_size, 0); + buf = rs->buf; + if (buf[0] == '\0') + error (_("Target does not support this command.")); + if (buf[0] == 'O' && buf[1] != 'K') + { + remote_console_output (buf + 1); /* 'O' message from stub. */ + continue; + } + if (strcmp (buf, "OK") == 0) + break; + if (strlen (buf) == 3 && buf[0] == 'E' + && isdigit (buf[1]) && isdigit (buf[2])) + { + error (_("Protocol error with Rcmd")); + } + for (p = buf; p[0] != '\0' && p[1] != '\0'; p += 2) + { + char c = (fromhex (p[0]) << 4) + fromhex (p[1]); + fputc_unfiltered (c, outbuf); + } + break; + } +} + +static VEC(mem_region_s) * +remote_memory_map (struct target_ops *ops) +{ + VEC(mem_region_s) *result = NULL; + char *text = target_read_stralloc (¤t_target, + TARGET_OBJECT_MEMORY_MAP, NULL); + + if (text) + { + struct cleanup *back_to = make_cleanup (xfree, text); + result = parse_memory_map (text); + do_cleanups (back_to); + } + + return result; +} + +static void +packet_command (char *args, int from_tty) +{ + struct remote_state *rs = get_remote_state (); + + if (!remote_desc) + error (_("command can only be used with remote target")); + + if (!args) + error (_("remote-packet command requires packet text as argument")); + + puts_filtered ("sending: "); + print_packet (args); + puts_filtered ("\n"); + putpkt (args); + + getpkt (&rs->buf, &rs->buf_size, 0); + puts_filtered ("received: "); + print_packet (rs->buf); + puts_filtered ("\n"); +} + +#if 0 +/* --------- UNIT_TEST for THREAD oriented PACKETS ------------------- */ + +static void display_thread_info (struct gdb_ext_thread_info *info); + +static void threadset_test_cmd (char *cmd, int tty); + +static void threadalive_test (char *cmd, int tty); + +static void threadlist_test_cmd (char *cmd, int tty); + +int get_and_display_threadinfo (threadref *ref); + +static void threadinfo_test_cmd (char *cmd, int tty); + +static int thread_display_step (threadref *ref, void *context); + +static void threadlist_update_test_cmd (char *cmd, int tty); + +static void init_remote_threadtests (void); + +#define SAMPLE_THREAD 0x05060708 /* Truncated 64 bit threadid. */ + +static void +threadset_test_cmd (char *cmd, int tty) +{ + int sample_thread = SAMPLE_THREAD; + + printf_filtered (_("Remote threadset test\n")); + set_thread (sample_thread, 1); +} + + +static void +threadalive_test (char *cmd, int tty) +{ + int sample_thread = SAMPLE_THREAD; + + if (remote_thread_alive (pid_to_ptid (sample_thread))) + printf_filtered ("PASS: Thread alive test\n"); + else + printf_filtered ("FAIL: Thread alive test\n"); +} + +void output_threadid (char *title, threadref *ref); + +void +output_threadid (char *title, threadref *ref) +{ + char hexid[20]; + + pack_threadid (&hexid[0], ref); /* Convert threead id into hex. */ + hexid[16] = 0; + printf_filtered ("%s %s\n", title, (&hexid[0])); +} + +static void +threadlist_test_cmd (char *cmd, int tty) +{ + int startflag = 1; + threadref nextthread; + int done, result_count; + threadref threadlist[3]; + + printf_filtered ("Remote Threadlist test\n"); + if (!remote_get_threadlist (startflag, &nextthread, 3, &done, + &result_count, &threadlist[0])) + printf_filtered ("FAIL: threadlist test\n"); + else + { + threadref *scan = threadlist; + threadref *limit = scan + result_count; + + while (scan < limit) + output_threadid (" thread ", scan++); + } +} + +void +display_thread_info (struct gdb_ext_thread_info *info) +{ + output_threadid ("Threadid: ", &info->threadid); + printf_filtered ("Name: %s\n ", info->shortname); + printf_filtered ("State: %s\n", info->display); + printf_filtered ("other: %s\n\n", info->more_display); +} + +int +get_and_display_threadinfo (threadref *ref) +{ + int result; + int set; + struct gdb_ext_thread_info threadinfo; + + set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME + | TAG_MOREDISPLAY | TAG_DISPLAY; + if (0 != (result = remote_get_threadinfo (ref, set, &threadinfo))) + display_thread_info (&threadinfo); + return result; +} + +static void +threadinfo_test_cmd (char *cmd, int tty) +{ + int athread = SAMPLE_THREAD; + threadref thread; + int set; + + int_to_threadref (&thread, athread); + printf_filtered ("Remote Threadinfo test\n"); + if (!get_and_display_threadinfo (&thread)) + printf_filtered ("FAIL cannot get thread info\n"); +} + +static int +thread_display_step (threadref *ref, void *context) +{ + /* output_threadid(" threadstep ",ref); *//* simple test */ + return get_and_display_threadinfo (ref); +} + +static void +threadlist_update_test_cmd (char *cmd, int tty) +{ + printf_filtered ("Remote Threadlist update test\n"); + remote_threadlist_iterator (thread_display_step, 0, CRAZY_MAX_THREADS); +} + +static void +init_remote_threadtests (void) +{ + add_com ("tlist", class_obscure, threadlist_test_cmd, _("\ +Fetch and print the remote list of thread identifiers, one pkt only")); + add_com ("tinfo", class_obscure, threadinfo_test_cmd, + _("Fetch and display info about one thread")); + add_com ("tset", class_obscure, threadset_test_cmd, + _("Test setting to a different thread")); + add_com ("tupd", class_obscure, threadlist_update_test_cmd, + _("Iterate through updating all remote thread info")); + add_com ("talive", class_obscure, threadalive_test, + _(" Remote thread alive test ")); +} + +#endif /* 0 */ + +/* Convert a thread ID to a string. Returns the string in a static + buffer. */ + +static char * +remote_pid_to_str (ptid_t ptid) +{ + static char buf[32]; + + xsnprintf (buf, sizeof buf, "Thread %d", ptid_get_pid (ptid)); + return buf; +} + +/* Get the address of the thread local variable in OBJFILE which is + stored at OFFSET within the thread local storage for thread PTID. */ + +static CORE_ADDR +remote_get_thread_local_address (ptid_t ptid, CORE_ADDR lm, CORE_ADDR offset) +{ + if (remote_protocol_packets[PACKET_qGetTLSAddr].support != PACKET_DISABLE) + { + struct remote_state *rs = get_remote_state (); + char *p = rs->buf; + enum packet_result result; + + strcpy (p, "qGetTLSAddr:"); + p += strlen (p); + p += hexnumstr (p, PIDGET (ptid)); + *p++ = ','; + p += hexnumstr (p, offset); + *p++ = ','; + p += hexnumstr (p, lm); + *p++ = '\0'; + + putpkt (rs->buf); + getpkt (&rs->buf, &rs->buf_size, 0); + result = packet_ok (rs->buf, &remote_protocol_packets[PACKET_qGetTLSAddr]); + if (result == PACKET_OK) + { + ULONGEST result; + + unpack_varlen_hex (rs->buf, &result); + return result; + } + else if (result == PACKET_UNKNOWN) + throw_error (TLS_GENERIC_ERROR, + _("Remote target doesn't support qGetTLSAddr packet")); + else + throw_error (TLS_GENERIC_ERROR, + _("Remote target failed to process qGetTLSAddr request")); + } + else + throw_error (TLS_GENERIC_ERROR, + _("TLS not supported or disabled on this target")); + /* Not reached. */ + return 0; +} + +/* Support for inferring a target description based on the current + architecture and the size of a 'g' packet. While the 'g' packet + can have any size (since optional registers can be left off the + end), some sizes are easily recognizable given knowledge of the + approximate architecture. */ + +struct remote_g_packet_guess +{ + int bytes; + const struct target_desc *tdesc; +}; +typedef struct remote_g_packet_guess remote_g_packet_guess_s; +DEF_VEC_O(remote_g_packet_guess_s); + +struct remote_g_packet_data +{ + VEC(remote_g_packet_guess_s) *guesses; +}; + +static struct gdbarch_data *remote_g_packet_data_handle; + +static void * +remote_g_packet_data_init (struct obstack *obstack) +{ + return OBSTACK_ZALLOC (obstack, struct remote_g_packet_data); +} + +void +register_remote_g_packet_guess (struct gdbarch *gdbarch, int bytes, + const struct target_desc *tdesc) +{ + struct remote_g_packet_data *data + = gdbarch_data (gdbarch, remote_g_packet_data_handle); + struct remote_g_packet_guess new_guess, *guess; + int ix; + + gdb_assert (tdesc != NULL); + + for (ix = 0; + VEC_iterate (remote_g_packet_guess_s, data->guesses, ix, guess); + ix++) + if (guess->bytes == bytes) + internal_error (__FILE__, __LINE__, + "Duplicate g packet description added for size %d", + bytes); + + new_guess.bytes = bytes; + new_guess.tdesc = tdesc; + VEC_safe_push (remote_g_packet_guess_s, data->guesses, &new_guess); +} + +static const struct target_desc * +remote_read_description (struct target_ops *target) +{ + struct remote_g_packet_data *data + = gdbarch_data (current_gdbarch, remote_g_packet_data_handle); + + if (!VEC_empty (remote_g_packet_guess_s, data->guesses)) + { + struct remote_g_packet_guess *guess; + int ix; + int bytes = send_g_packet (); + + for (ix = 0; + VEC_iterate (remote_g_packet_guess_s, data->guesses, ix, guess); + ix++) + if (guess->bytes == bytes) + return guess->tdesc; + + /* We discard the g packet. A minor optimization would be to + hold on to it, and fill the register cache once we have selected + an architecture, but it's too tricky to do safely. */ + } + + return NULL; +} + +static void +init_remote_ops (void) +{ + remote_ops.to_shortname = "remote"; + remote_ops.to_longname = "Remote serial target in gdb-specific protocol"; + remote_ops.to_doc = + "Use a remote computer via a serial line, using a gdb-specific protocol.\n\ +Specify the serial device it is connected to\n\ +(e.g. /dev/ttyS0, /dev/ttya, COM1, etc.)."; + remote_ops.to_open = remote_open; + remote_ops.to_close = remote_close; + remote_ops.to_detach = remote_detach; + remote_ops.to_disconnect = remote_disconnect; + remote_ops.to_resume = remote_resume; + remote_ops.to_wait = remote_wait; + remote_ops.to_fetch_registers = remote_fetch_registers; + remote_ops.to_store_registers = remote_store_registers; + remote_ops.to_prepare_to_store = remote_prepare_to_store; + remote_ops.deprecated_xfer_memory = remote_xfer_memory; + remote_ops.to_files_info = remote_files_info; + remote_ops.to_insert_breakpoint = remote_insert_breakpoint; + remote_ops.to_remove_breakpoint = remote_remove_breakpoint; + remote_ops.to_stopped_by_watchpoint = remote_stopped_by_watchpoint; + remote_ops.to_stopped_data_address = remote_stopped_data_address; + remote_ops.to_can_use_hw_breakpoint = remote_check_watch_resources; + remote_ops.to_insert_hw_breakpoint = remote_insert_hw_breakpoint; + remote_ops.to_remove_hw_breakpoint = remote_remove_hw_breakpoint; + remote_ops.to_insert_watchpoint = remote_insert_watchpoint; + remote_ops.to_remove_watchpoint = remote_remove_watchpoint; + remote_ops.to_kill = remote_kill; + remote_ops.to_load = generic_load; + remote_ops.to_mourn_inferior = remote_mourn; + remote_ops.to_thread_alive = remote_thread_alive; + remote_ops.to_find_new_threads = remote_threads_info; + remote_ops.to_pid_to_str = remote_pid_to_str; + remote_ops.to_extra_thread_info = remote_threads_extra_info; + remote_ops.to_stop = remote_stop; + remote_ops.to_xfer_partial = remote_xfer_partial; + remote_ops.to_rcmd = remote_rcmd; + remote_ops.to_get_thread_local_address = remote_get_thread_local_address; + remote_ops.to_stratum = process_stratum; + remote_ops.to_has_all_memory = 1; + remote_ops.to_has_memory = 1; + remote_ops.to_has_stack = 1; + remote_ops.to_has_registers = 1; + remote_ops.to_has_execution = 1; + remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ + remote_ops.to_magic = OPS_MAGIC; + remote_ops.to_memory_map = remote_memory_map; + remote_ops.to_flash_erase = remote_flash_erase; + remote_ops.to_flash_done = remote_flash_done; + remote_ops.to_read_description = remote_read_description; +} + +/* Set up the extended remote vector by making a copy of the standard + remote vector and adding to it. */ + +static void +init_extended_remote_ops (void) +{ + extended_remote_ops = remote_ops; + + extended_remote_ops.to_shortname = "extended-remote"; + extended_remote_ops.to_longname = + "Extended remote serial target in gdb-specific protocol"; + extended_remote_ops.to_doc = + "Use a remote computer via a serial line, using a gdb-specific protocol.\n\ +Specify the serial device it is connected to (e.g. /dev/ttya).", + extended_remote_ops.to_open = extended_remote_open; + extended_remote_ops.to_create_inferior = extended_remote_create_inferior; + extended_remote_ops.to_mourn_inferior = extended_remote_mourn; +} + +static int +remote_can_async_p (void) +{ + /* We're async whenever the serial device is. */ + return (current_target.to_async_mask_value) && serial_can_async_p (remote_desc); +} + +static int +remote_is_async_p (void) +{ + /* We're async whenever the serial device is. */ + return (current_target.to_async_mask_value) && serial_is_async_p (remote_desc); +} + +/* Pass the SERIAL event on and up to the client. One day this code + will be able to delay notifying the client of an event until the + point where an entire packet has been received. */ + +static void (*async_client_callback) (enum inferior_event_type event_type, + void *context); +static void *async_client_context; +static serial_event_ftype remote_async_serial_handler; + +static void +remote_async_serial_handler (struct serial *scb, void *context) +{ + /* Don't propogate error information up to the client. Instead let + the client find out about the error by querying the target. */ + async_client_callback (INF_REG_EVENT, async_client_context); +} + +static void +remote_async (void (*callback) (enum inferior_event_type event_type, + void *context), void *context) +{ + if (current_target.to_async_mask_value == 0) + internal_error (__FILE__, __LINE__, + _("Calling remote_async when async is masked")); + + if (callback != NULL) + { + serial_async (remote_desc, remote_async_serial_handler, NULL); + async_client_callback = callback; + async_client_context = context; + } + else + serial_async (remote_desc, NULL, NULL); +} + +/* Target async and target extended-async. + + This are temporary targets, until it is all tested. Eventually + async support will be incorporated int the usual 'remote' + target. */ + +static void +init_remote_async_ops (void) +{ + remote_async_ops.to_shortname = "async"; + remote_async_ops.to_longname = + "Remote serial target in async version of the gdb-specific protocol"; + remote_async_ops.to_doc = + "Use a remote computer via a serial line, using a gdb-specific protocol.\n\ +Specify the serial device it is connected to (e.g. /dev/ttya)."; + remote_async_ops.to_open = remote_async_open; + remote_async_ops.to_close = remote_close; + remote_async_ops.to_detach = remote_detach; + remote_async_ops.to_disconnect = remote_disconnect; + remote_async_ops.to_resume = remote_async_resume; + remote_async_ops.to_wait = remote_async_wait; + remote_async_ops.to_fetch_registers = remote_fetch_registers; + remote_async_ops.to_store_registers = remote_store_registers; + remote_async_ops.to_prepare_to_store = remote_prepare_to_store; + remote_async_ops.deprecated_xfer_memory = remote_xfer_memory; + remote_async_ops.to_files_info = remote_files_info; + remote_async_ops.to_insert_breakpoint = remote_insert_breakpoint; + remote_async_ops.to_remove_breakpoint = remote_remove_breakpoint; + remote_async_ops.to_can_use_hw_breakpoint = remote_check_watch_resources; + remote_async_ops.to_insert_hw_breakpoint = remote_insert_hw_breakpoint; + remote_async_ops.to_remove_hw_breakpoint = remote_remove_hw_breakpoint; + remote_async_ops.to_insert_watchpoint = remote_insert_watchpoint; + remote_async_ops.to_remove_watchpoint = remote_remove_watchpoint; + remote_async_ops.to_stopped_by_watchpoint = remote_stopped_by_watchpoint; + remote_async_ops.to_stopped_data_address = remote_stopped_data_address; + remote_async_ops.to_terminal_inferior = remote_async_terminal_inferior; + remote_async_ops.to_terminal_ours = remote_async_terminal_ours; + remote_async_ops.to_kill = remote_async_kill; + remote_async_ops.to_load = generic_load; + remote_async_ops.to_mourn_inferior = remote_async_mourn; + remote_async_ops.to_thread_alive = remote_thread_alive; + remote_async_ops.to_find_new_threads = remote_threads_info; + remote_async_ops.to_pid_to_str = remote_pid_to_str; + remote_async_ops.to_extra_thread_info = remote_threads_extra_info; + remote_async_ops.to_stop = remote_stop; + remote_async_ops.to_xfer_partial = remote_xfer_partial; + remote_async_ops.to_rcmd = remote_rcmd; + remote_async_ops.to_stratum = process_stratum; + remote_async_ops.to_has_all_memory = 1; + remote_async_ops.to_has_memory = 1; + remote_async_ops.to_has_stack = 1; + remote_async_ops.to_has_registers = 1; + remote_async_ops.to_has_execution = 1; + remote_async_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ + remote_async_ops.to_can_async_p = remote_can_async_p; + remote_async_ops.to_is_async_p = remote_is_async_p; + remote_async_ops.to_async = remote_async; + remote_async_ops.to_async_mask_value = 1; + remote_async_ops.to_magic = OPS_MAGIC; + remote_async_ops.to_memory_map = remote_memory_map; + remote_async_ops.to_flash_erase = remote_flash_erase; + remote_async_ops.to_flash_done = remote_flash_done; + remote_async_ops.to_read_description = remote_read_description; +} + +/* Set up the async extended remote vector by making a copy of the standard + remote vector and adding to it. */ + +static void +init_extended_async_remote_ops (void) +{ + extended_async_remote_ops = remote_async_ops; + + extended_async_remote_ops.to_shortname = "extended-async"; + extended_async_remote_ops.to_longname = + "Extended remote serial target in async gdb-specific protocol"; + extended_async_remote_ops.to_doc = + "Use a remote computer via a serial line, using an async gdb-specific protocol.\n\ +Specify the serial device it is connected to (e.g. /dev/ttya).", + extended_async_remote_ops.to_open = extended_remote_async_open; + extended_async_remote_ops.to_create_inferior = extended_remote_async_create_inferior; + extended_async_remote_ops.to_mourn_inferior = extended_remote_mourn; +} + +static void +set_remote_cmd (char *args, int from_tty) +{ + help_list (remote_set_cmdlist, "set remote ", -1, gdb_stdout); +} + +static void +show_remote_cmd (char *args, int from_tty) +{ + /* We can't just use cmd_show_list here, because we want to skip + the redundant "show remote Z-packet" and the legacy aliases. */ + struct cleanup *showlist_chain; + struct cmd_list_element *list = remote_show_cmdlist; + + showlist_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "showlist"); + for (; list != NULL; list = list->next) + if (strcmp (list->name, "Z-packet") == 0) + continue; + else if (list->type == not_set_cmd) + /* Alias commands are exactly like the original, except they + don't have the normal type. */ + continue; + else + { + struct cleanup *option_chain + = make_cleanup_ui_out_tuple_begin_end (uiout, "option"); + ui_out_field_string (uiout, "name", list->name); + ui_out_text (uiout, ": "); + if (list->type == show_cmd) + do_setshow_command ((char *) NULL, from_tty, list); + else + cmd_func (list, NULL, from_tty); + /* Close the tuple. */ + do_cleanups (option_chain); + } + + /* Close the tuple. */ + do_cleanups (showlist_chain); +} + + +/* Function to be called whenever a new objfile (shlib) is detected. */ +static void +remote_new_objfile (struct objfile *objfile) +{ + if (remote_desc != 0) /* Have a remote connection. */ + remote_check_symbols (objfile); +} + +void +_initialize_remote (void) +{ + struct remote_state *rs; + + /* architecture specific data */ + remote_gdbarch_data_handle = + gdbarch_data_register_post_init (init_remote_state); + remote_g_packet_data_handle = + gdbarch_data_register_pre_init (remote_g_packet_data_init); + + /* Initialize the per-target state. At the moment there is only one + of these, not one per target. Only one target is active at a + time. The default buffer size is unimportant; it will be expanded + whenever a larger buffer is needed. */ + rs = get_remote_state_raw (); + rs->buf_size = 400; + rs->buf = xmalloc (rs->buf_size); + + init_remote_ops (); + add_target (&remote_ops); + + init_extended_remote_ops (); + add_target (&extended_remote_ops); + + init_remote_async_ops (); + add_target (&remote_async_ops); + + init_extended_async_remote_ops (); + add_target (&extended_async_remote_ops); + + /* Hook into new objfile notification. */ + observer_attach_new_objfile (remote_new_objfile); + +#if 0 + init_remote_threadtests (); +#endif + + /* set/show remote ... */ + + add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, _("\ +Remote protocol specific variables\n\ +Configure various remote-protocol specific variables such as\n\ +the packets being used"), + &remote_set_cmdlist, "set remote ", + 0 /* allow-unknown */, &setlist); + add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\ +Remote protocol specific variables\n\ +Configure various remote-protocol specific variables such as\n\ +the packets being used"), + &remote_show_cmdlist, "show remote ", + 0 /* allow-unknown */, &showlist); + + add_cmd ("compare-sections", class_obscure, compare_sections_command, _("\ +Compare section data on target to the exec file.\n\ +Argument is a single section name (default: all loaded sections)."), + &cmdlist); + + add_cmd ("packet", class_maintenance, packet_command, _("\ +Send an arbitrary packet to a remote target.\n\ + maintenance packet TEXT\n\ +If GDB is talking to an inferior via the GDB serial protocol, then\n\ +this command sends the string TEXT to the inferior, and displays the\n\ +response packet. GDB supplies the initial `$' character, and the\n\ +terminating `#' character and checksum."), + &maintenancelist); + + add_setshow_boolean_cmd ("remotebreak", no_class, &remote_break, _("\ +Set whether to send break if interrupted."), _("\ +Show whether to send break if interrupted."), _("\ +If set, a break, instead of a cntrl-c, is sent to the remote target."), + NULL, NULL, /* FIXME: i18n: Whether to send break if interrupted is %s. */ + &setlist, &showlist); + + /* Install commands for configuring memory read/write packets. */ + + add_cmd ("remotewritesize", no_class, set_memory_write_packet_size, _("\ +Set the maximum number of bytes per memory write packet (deprecated)."), + &setlist); + add_cmd ("remotewritesize", no_class, show_memory_write_packet_size, _("\ +Show the maximum number of bytes per memory write packet (deprecated)."), + &showlist); + add_cmd ("memory-write-packet-size", no_class, + set_memory_write_packet_size, _("\ +Set the maximum number of bytes per memory-write packet.\n\ +Specify the number of bytes in a packet or 0 (zero) for the\n\ +default packet size. The actual limit is further reduced\n\ +dependent on the target. Specify ``fixed'' to disable the\n\ +further restriction and ``limit'' to enable that restriction."), + &remote_set_cmdlist); + add_cmd ("memory-read-packet-size", no_class, + set_memory_read_packet_size, _("\ +Set the maximum number of bytes per memory-read packet.\n\ +Specify the number of bytes in a packet or 0 (zero) for the\n\ +default packet size. The actual limit is further reduced\n\ +dependent on the target. Specify ``fixed'' to disable the\n\ +further restriction and ``limit'' to enable that restriction."), + &remote_set_cmdlist); + add_cmd ("memory-write-packet-size", no_class, + show_memory_write_packet_size, + _("Show the maximum number of bytes per memory-write packet."), + &remote_show_cmdlist); + add_cmd ("memory-read-packet-size", no_class, + show_memory_read_packet_size, + _("Show the maximum number of bytes per memory-read packet."), + &remote_show_cmdlist); + + add_setshow_zinteger_cmd ("hardware-watchpoint-limit", no_class, + &remote_hw_watchpoint_limit, _("\ +Set the maximum number of target hardware watchpoints."), _("\ +Show the maximum number of target hardware watchpoints."), _("\ +Specify a negative limit for unlimited."), + NULL, NULL, /* FIXME: i18n: The maximum number of target hardware watchpoints is %s. */ + &remote_set_cmdlist, &remote_show_cmdlist); + add_setshow_zinteger_cmd ("hardware-breakpoint-limit", no_class, + &remote_hw_breakpoint_limit, _("\ +Set the maximum number of target hardware breakpoints."), _("\ +Show the maximum number of target hardware breakpoints."), _("\ +Specify a negative limit for unlimited."), + NULL, NULL, /* FIXME: i18n: The maximum number of target hardware breakpoints is %s. */ + &remote_set_cmdlist, &remote_show_cmdlist); + + add_setshow_integer_cmd ("remoteaddresssize", class_obscure, + &remote_address_size, _("\ +Set the maximum size of the address (in bits) in a memory packet."), _("\ +Show the maximum size of the address (in bits) in a memory packet."), NULL, + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_X], + "X", "binary-download", 1); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_vCont], + "vCont", "verbose-resume", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_QPassSignals], + "QPassSignals", "pass-signals", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qSymbol], + "qSymbol", "symbol-lookup", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_P], + "P", "set-register", 1); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_p], + "p", "fetch-register", 1); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_Z0], + "Z0", "software-breakpoint", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_Z1], + "Z1", "hardware-breakpoint", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_Z2], + "Z2", "write-watchpoint", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_Z3], + "Z3", "read-watchpoint", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_Z4], + "Z4", "access-watchpoint", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_auxv], + "qXfer:auxv:read", "read-aux-vector", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_features], + "qXfer:features:read", "target-features", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_libraries], + "qXfer:libraries:read", "library-info", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_memory_map], + "qXfer:memory-map:read", "memory-map", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_spu_read], + "qXfer:spu:read", "read-spu-object", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qXfer_spu_write], + "qXfer:spu:write", "write-spu-object", 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qGetTLSAddr], + "qGetTLSAddr", "get-thread-local-storage-address", + 0); + + add_packet_config_cmd (&remote_protocol_packets[PACKET_qSupported], + "qSupported", "supported-packets", 0); + + /* Keep the old ``set remote Z-packet ...'' working. Each individual + Z sub-packet has its own set and show commands, but users may + have sets to this variable in their .gdbinit files (or in their + documentation). */ + add_setshow_auto_boolean_cmd ("Z-packet", class_obscure, + &remote_Z_packet_detect, _("\ +Set use of remote protocol `Z' packets"), _("\ +Show use of remote protocol `Z' packets "), _("\ +When set, GDB will attempt to use the remote breakpoint and watchpoint\n\ +packets."), + set_remote_protocol_Z_packet_cmd, + show_remote_protocol_Z_packet_cmd, /* FIXME: i18n: Use of remote protocol `Z' packets is %s. */ + &remote_set_cmdlist, &remote_show_cmdlist); + + /* Eventually initialize fileio. See fileio.c */ + initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); +} diff -Nru eresi-0.8a25/libgdbwrap/doc/gdbserialproto.txt eresi-0.0.20110516/libgdbwrap/doc/gdbserialproto.txt --- eresi-0.8a25/libgdbwrap/doc/gdbserialproto.txt 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/doc/gdbserialproto.txt 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,2885 @@ + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D. GDB Remote Serial Protocol + + D.1 Overview + D.2 Packets + D.3 Stop Reply Packets + D.4 General Query Packets + D.5 Register Packet Format + D.6 Tracepoint Packets + D.7 Host I/O Packets + D.8 Interrupts + D.9 Notification Packets + D.10 Remote Protocol Support for Non-Stop Mode + D.11 Packet Acknowledgment + D.12 Examples + D.13 File-I/O Remote Protocol Extension + D.14 Library List Format + D.15 Memory Map Format + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.1 Overview + + There may be occasions when you need to know something about the + protocol--for example, if there is only one serial port to your target + machine, you might want your program to do something special if it + recognizes a packet meant for GDB. + + In the examples below, `->' and `<-' are used to indicate transmitted + and received data, respectively. + + All GDB commands and responses (other than acknowledgments and + notifications, see D.9 Notification Packets) are sent as a packet. A + packet is introduced with the character `$', the actual packet-data, + and the terminating character `#' followed by a two-digit checksum: + + +$packet-data#checksum + + The two-digit checksum is computed as the modulo 256 sum of all + characters between the leading `$' and the trailing `#' (an eight bit + unsigned checksum). + + Implementors should note that prior to GDB 5.0 the protocol + specification also included an optional two-digit sequence-id: + + +$sequence-id:packet-data#checksum + + That sequence-id was appended to the acknowledgment. GDB has never + output sequence-ids. Stubs that handle packets added since GDB 5.0 must + not accept sequence-id. + + When either the host or the target machine receives a packet, the first + response expected is an acknowledgment: either `+' (to indicate the + package was received correctly) or `-' (to request retransmission): + + +-> $packet-data#checksum +<- + + + The `+'/`-' acknowledgments can be disabled once a connection is + established. See section D.11 Packet Acknowledgment, for details. + + The host (GDB) sends commands, and the target (the debugging stub + incorporated in your program) sends a response. In the case of step and + continue commands, the response is only sent when the operation has + completed, and the target has again stopped all threads in all attached + processes. This is the default all-stop mode behavior, but the remote + protocol also supports GDB's non-stop execution mode; see D.10 Remote + Protocol Support for Non-Stop Mode, for details. + + packet-data consists of a sequence of characters with the exception of + `#' and `$' (see `X' packet for additional exceptions). + + Fields within the packet should be separated using `,' `;' or `:'. + Except where otherwise noted all numbers are represented in HEX with + leading zeros suppressed. + + Implementors should note that prior to GDB 5.0, the character `:' could + not appear as the third character in a packet (as it would potentially + conflict with the sequence-id). + + Binary data in most packets is encoded either as two hexadecimal digits + per byte of binary data. This allowed the traditional remote protocol + to work over connections which were only seven-bit clean. Some packets + designed more recently assume an eight-bit clean connection, and use a + more efficient encoding to send and receive binary data. + + The binary data representation uses 7d (ASCII `}') as an escape + character. Any escaped byte is transmitted as the escape character + followed by the original character XORed with 0x20. For example, the + byte 0x7d would be transmitted as the two bytes 0x7d 0x5d. The bytes + 0x23 (ASCII `#'), 0x24 (ASCII `$'), and 0x7d (ASCII `}') must always be + escaped. Responses sent by the stub must also escape 0x2a (ASCII `*'), + so that it is not interpreted as the start of a run-length encoded + sequence (described next). + + Response data can be run-length encoded to save space. Run-length + encoding replaces runs of identical characters with one instance of the + repeated character, followed by a `*' and a repeat count. The repeat + count is itself sent encoded, to avoid binary characters in data: a + value of n is sent as n+29. For a repeat count greater or equal to 3, + this produces a printable ASCII character, e.g. a space (ASCII code 32) + for a repeat count of 3. (This is because run-length encoding starts to + win for counts 3 or more.) Thus, for example, `0* ' is a run-length + encoding of "0000": the space character after `*' means repeat the + leading 0 32 - 29 = 3 more times. + + The printable characters `#' and `$' or with a numeric value greater + than 126 must not be used. Runs of six repeats (`#') or seven repeats + (`$') can be expanded using a repeat count of only five (`"'). For + example, `00000000' can be encoded as `0*"00'. + + The error response returned for some packets includes a two character + error number. That number is not well defined. + + For any command not supported by the stub, an empty response (`$#00') + should be returned. That way it is possible to extend the protocol. A + newer GDB can tell if a packet is supported based on that response. + + A stub is required to support the `g', `G', `m', `M', `c', and `s' + commands. All other commands are optional. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.2 Packets + + The following table provides a complete list of all currently defined + commands and their corresponding response data. See section D.13 + File-I/O Remote Protocol Extension, for details about the File I/O + extension of the remote protocol. + + Each packet's description has a template showing the packet's overall + syntax, followed by an explanation of the packet's meaning. We include + spaces in some of the templates for clarity; these are not part of the + packet's syntax. No GDB packet uses spaces to separate its components. + For example, a template like `foo bar baz' describes a packet beginning + with the three ASCII bytes `foo', followed by a bar, followed directly + by a baz. GDB does not transmit a space character between the `foo' and + the bar, or between the bar and the baz. + + Several packets and replies include a thread-id field to identify a + thread. Normally these are positive numbers with a target-specific + interpretation, formatted as big-endian hex strings. A thread-id can + also be a literal `-1' to indicate all threads, or `0' to pick any + thread. + + In addition, the remote protocol supports a multiprocess feature in + which the thread-id syntax is extended to optionally include both + process and thread ID fields, as `ppid.tid'. The pid (process) and tid + (thread) components each have the format described above: a positive + number with target-specific interpretation formatted as a big-endian + hex string, literal `-1' to indicate all processes or threads + (respectively), or `0' to indicate an arbitrary process or thread. + Specifying just a process, as `ppid', is equivalent to `ppid.-1'. It is + an error to specify all processes but a specific thread, such as + `p-1.tid'. Note that the `p' prefix is not used for those packets and + replies explicitly documented to include a process ID, rather than a + thread-id. + + The multiprocess thread-id syntax extensions are only used if both GDB + and the stub report support for the `multiprocess' feature using + `qSupported'. See multiprocess extensions, for more information. + + Note that all packet forms beginning with an upper- or lower-case + letter, other than those described here, are reserved for future use. + + Here are the packet descriptions. + + `!' + Enable extended mode. In extended mode, the remote server is + made persistent. The `R' packet is used to restart the program + being debugged. + Reply: + `OK' + The remote target both supports and has enabled extended + mode. + `?' + Indicate the reason the target halted. The reply is the same as + for step and continue. This packet has a special interpretation + when the target is in non-stop mode; see D.10 Remote Protocol + Support for Non-Stop Mode. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `A arglen,argnum,arg,...' + Initialized argv[] array passed into program. arglen specifies + the number of bytes in the hex encoded byte stream arg. See + gdbserver for more details. + Reply: + `OK' + The arguments were set. + `E NN' + An error occurred. + `b baud' + (Don't use this packet; its behavior is not well-defined.) + Change the serial line speed to baud. + JTC: When does the transport layer state change? When it's + received, or after the ACK is transmitted. In either case, there + are problems if the command or the acknowledgment packet is + dropped. + Stan: If people really wanted to add something like this, and + get it working for the first time, they ought to modify + ser-unix.c to send some kind of out-of-band message to a + specially-setup stub and have the switch happen "in between" + packets, so that from remote protocol's point of view, nothing + actually happened. + `B addr,mode' + Set (mode is `S') or clear (mode is `C') a breakpoint at addr. + Don't use this packet. Use the `Z' and `z' packets instead (see + insert breakpoint or watchpoint packet). + `bc' + Backward continue. Execute the target system in reverse. No + parameter. See section 6. Running programs backward, for more + information. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `bs' + Backward single step. Execute one instruction in reverse. No + parameter. See section 6. Running programs backward, for more + information. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `c [addr]' + Continue. addr is address to resume. If addr is omitted, resume + at current address. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `C sig[;addr]' + Continue with signal sig (hex signal number). If `;addr' is + omitted, resume at same address. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `d' + Toggle debug flag. + Don't use this packet; instead, define a general set packet (see + section D.4 General Query Packets). + `D' + `D;pid' + The first form of the packet is used to detach GDB from the + remote system. It is sent to the remote target before GDB + disconnects via the detach command. + The second form, including a process ID, is used when + multiprocess protocol extensions are enabled (see multiprocess + extensions), to detach only a specific process. The pid is + specified as a big-endian hex string. + Reply: + `OK' + for success + `E NN' + for an error + `F RC,EE,CF;XX' + A reply from GDB to an `F' packet sent by the target. This is + part of the File-I/O protocol extension. See section D.13 + File-I/O Remote Protocol Extension, for the specification. + `g' + Read general registers. + Reply: + `XX...' + Each byte of register data is described by two hex digits. + The bytes with the register are transmitted in target byte + order. The size of each register and their position within + the `g' packet are determined by the GDB internal gdbarch + functions DEPRECATED_REGISTER_RAW_SIZE and + gdbarch_register_name. The specification of several + standard `g' packets is specified below. + `E NN' + for an error. + `G XX...' + Write general registers. See read registers packet, for a + description of the XX... data. + Reply: + `OK' + for success + `E NN' + for an error + `H c thread-id' + Set thread for subsequent operations (`m', `M', `g', `G', + et.al.). c depends on the operation to be performed: it should + be `c' for step and continue operations, `g' for other + operations. The thread designator thread-id has the format and + interpretation described in thread-id syntax. + Reply: + `OK' + for success + `E NN' + for an error + `i [addr[,nnn]]' + Step the remote target by a single clock cycle. If `,nnn' is + present, cycle step nnn cycles. If addr is present, cycle step + starting at that address. + `I' + Signal, then cycle step. See step with signal packet. See cycle + step packet. + `k' + Kill request. + FIXME: There is no description of how to operate when a specific + thread context has been selected (i.e. does 'k' kill only that + thread?). + `m addr,length' + Read length bytes of memory starting at address addr. Note that + addr may not be aligned to any particular boundary. + The stub need not use any particular size or alignment when + gathering data from memory for the response; even if addr is + word-aligned and length is a multiple of the word size, the stub + is free to use byte accesses, or not. For this reason, this + packet may not be suitable for accessing memory-mapped I/O + devices. + Reply: + `XX...' + Memory contents; each byte is transmitted as a two-digit + hexadecimal number. The reply may contain fewer bytes than + requested if the server was able to read only part of the + region of memory. + `E NN' + NN is errno + `M addr,length:XX...' + Write length bytes of memory starting at address addr. XX... is + the data; each byte is transmitted as a two-digit hexadecimal + number. + Reply: + `OK' + for success + `E NN' + for an error (this includes the case where only part of the + data was written). + `p n' + Read the value of register n; n is in hex. See read registers + packet, for a description of how the returned register value is + encoded. + Reply: + `XX...' + the register's value + `E NN' + for an error + `' + Indicating an unrecognized query. + `P n...=r...' + Write register n... with value r.... The register number n is in + hexadecimal, and r... contains two hex digits for each byte in + the register (target byte order). + Reply: + `OK' + for success + `E NN' + for an error + `q name params...' + `Q name params...' + General query (`q') and set (`Q'). These packets are described + fully in D.4 General Query Packets. + `r' + Reset the entire system. + Don't use this packet; use the `R' packet instead. + `R XX' + Restart the program being debugged. XX, while needed, is + ignored. This packet is only available in extended mode (see + extended mode). + The `R' packet has no reply. + `s [addr]' + Single step. addr is the address at which to resume. If addr is + omitted, resume at same address. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `S sig[;addr]' + Step with signal. This is analogous to the `C' packet, but + requests a single-step, rather than a normal resumption of + execution. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `t addr:PP,MM' + Search backwards starting at address addr for a match with + pattern PP and mask MM. PP and MM are 4 bytes. addr must be at + least 3 digits. + `T thread-id' + Find out if the thread thread-id is alive. See thread-id syntax. + Reply: + `OK' + thread is still alive + `E NN' + thread is dead + `v' + Packets starting with `v' are identified by a multi-letter name, + up to the first `;' or `?' (or the end of the packet). + `vAttach;pid' + Attach to a new process with the specified process ID pid. The + process ID is a hexadecimal integer identifying the process. In + all-stop mode, all threads in the attached process are stopped; + in non-stop mode, it may be attached without being stopped if + that is supported by the target. + This packet is only available in extended mode (see extended + mode). + Reply: + `E nn' + for an error + `Any stop packet' + for success in all-stop mode (see section D.3 Stop Reply + Packets) + `OK' + for success in non-stop mode (see section D.10 Remote + Protocol Support for Non-Stop Mode) + `vCont[;action[:thread-id]]...' + Resume the inferior, specifying different actions for each + thread. If an action is specified with no thread-id, then it is + applied to any threads that don't have a specific action + specified; if no default action is specified then other threads + should remain stopped in all-stop mode and in their current + state in non-stop mode. Specifying multiple default actions is + an error; specifying no actions is also an error. Thread IDs are + specified using the syntax described in thread-id syntax. + Currently supported actions are: + `c' + Continue. + `C sig' + Continue with signal sig. The signal sig should be two hex + digits. + `s' + Step. + `S sig' + Step with signal sig. The signal sig should be two hex + digits. + `t' + Stop. + `T sig' + Stop with signal sig. The signal sig should be two hex + digits. + The optional argument addr normally associated with the `c', + `C', `s', and `S' packets is not supported in `vCont'. + The `t' and `T' actions are only relevant in non-stop mode (see + section D.10 Remote Protocol Support for Non-Stop Mode) and may + be ignored by the stub otherwise. A stop reply should be + generated for any affected thread not already stopped. When a + thread is stopped by means of a `t' action, the corresponding + stop reply should indicate that the thread has stopped with + signal `0', regardless of whether the target uses some other + signal as an implementation detail. + Reply: See section D.3 Stop Reply Packets, for the reply + specifications. + `vCont?' + Request a list of actions supported by the `vCont' packet. + Reply: + `vCont[;action...]' + The `vCont' packet is supported. Each action is a supported + command in the `vCont' packet. + `' + The `vCont' packet is not supported. + `vFile:operation:parameter...' + Perform a file operation on the target system. For details, see + D.7 Host I/O Packets. + `vFlashErase:addr,length' + Direct the stub to erase length bytes of flash starting at addr. + The region may enclose any number of flash blocks, but its start + and end must fall on block boundaries, as indicated by the flash + block size appearing in the memory map (see section D.15 Memory + Map Format). GDB groups flash memory programming operations + together, and sends a `vFlashDone' request after each group; the + stub is allowed to delay erase operation until the `vFlashDone' + packet is received. + The stub must support `vCont' if it reports support for + multiprocess extensions (see multiprocess extensions). Note that + in this case `vCont' actions can be specified to apply to all + threads in a process by using the `ppid.-1' form of the + thread-id. + Reply: + `OK' + for success + `E NN' + for an error + `vFlashWrite:addr:XX...' + Direct the stub to write data to flash address addr. The data is + passed in binary form using the same encoding as for the `X' + packet (see Binary Data). The memory ranges specified by + `vFlashWrite' packets preceding a `vFlashDone' packet must not + overlap, and must appear in order of increasing addresses + (although `vFlashErase' packets for higher addresses may already + have been received; the ordering is guaranteed only between + `vFlashWrite' packets). If a packet writes to an address that + was neither erased by a preceding `vFlashErase' packet nor by + some other target-specific method, the results are + unpredictable. + Reply: + `OK' + for success + `E.memtype' + for vFlashWrite addressing non-flash memory + `E NN' + for an error + `vFlashDone' + Indicate to the stub that flash programming operation is + finished. The stub is permitted to delay or batch the effects of + a group of `vFlashErase' and `vFlashWrite' packets until a + `vFlashDone' packet is received. The contents of the affected + regions of flash memory are unpredictable until the `vFlashDone' + request is completed. + `vKill;pid' + Kill the process with the specified process ID. pid is a + hexadecimal integer identifying the process. This packet is used + in preference to `k' when multiprocess protocol extensions are + supported; see multiprocess extensions. + Reply: + `E nn' + for an error + `OK' + for success + `vRun;filename[;argument]...' + Run the program filename, passing it each argument on its + command line. The file and arguments are hex-encoded strings. If + filename is an empty string, the stub may use a default program + (e.g. the last program run). The program is created in the + stopped state. + This packet is only available in extended mode (see extended + mode). + Reply: + `E nn' + for an error + `Any stop packet' + for success (see section D.3 Stop Reply Packets) + `vStopped' + In non-stop mode (see section D.10 Remote Protocol Support for + Non-Stop Mode), acknowledge a previous stop reply and prompt for + the stub to report another one. + Reply: + `Any stop packet' + if there is another unreported stop event (see section D.3 + Stop Reply Packets) + `OK' + if there are no unreported stop events + `X addr,length:XX...' + Write data to memory, where the data is transmitted in binary. + addr is address, length is number of bytes, `XX...' is binary + data (see Binary Data). + Reply: + `OK' + for success + `E NN' + for an error + `z type,addr,length' + `Z type,addr,length' + Insert (`Z') or remove (`z') a type breakpoint or watchpoint + starting at address address and covering the next length bytes. + Each breakpoint and watchpoint packet type is documented + separately. + Implementation notes: A remote target shall return an empty + string for an unrecognized breakpoint or watchpoint packet type. + A remote target shall support either both or neither of a given + `Ztype...' and `ztype...' packet pair. To avoid potential + problems with duplicate packets, the operations should be + implemented in an idempotent way. + `z0,addr,length' + `Z0,addr,length' + Insert (`Z0') or remove (`z0') a memory breakpoint at address + addr of size length. + A memory breakpoint is implemented by replacing the instruction + at addr with a software breakpoint or trap instruction. The + length is used by targets that indicates the size of the + breakpoint (in bytes) that should be inserted (e.g., the ARM and + MIPS can insert either a 2 or 4 byte breakpoint). + Implementation note: It is possible for a target to copy or move + code that contains memory breakpoints (e.g., when implementing + overlays). The behavior of this packet, in the presence of such + a target, is not defined. + Reply: + `OK' + success + `' + not supported + `E NN' + for an error + `z1,addr,length' + `Z1,addr,length' + Insert (`Z1') or remove (`z1') a hardware breakpoint at address + addr of size length. + A hardware breakpoint is implemented using a mechanism that is + not dependant on being able to modify the target's memory. + Implementation note: A hardware breakpoint is not affected by + code movement. + Reply: + `OK' + success + `' + not supported + `E NN' + for an error + `z2,addr,length' + `Z2,addr,length' + Insert (`Z2') or remove (`z2') a write watchpoint. + Reply: + `OK' + success + `' + not supported + `E NN' + for an error + `z3,addr,length' + `Z3,addr,length' + Insert (`Z3') or remove (`z3') a read watchpoint. + Reply: + `OK' + success + `' + not supported + `E NN' + for an error + `z4,addr,length' + `Z4,addr,length' + Insert (`Z4') or remove (`z4') an access watchpoint. + Reply: + `OK' + success + `' + not supported + `E NN' + for an error + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.3 Stop Reply Packets + + The `C', `c', `S', `s', `vCont', `vAttach', `vRun', `vStopped', and `?' + packets can receive any of the below as a reply. Except for `?' and + `vStopped', that reply is only returned when the target halts. In the + below the exact meaning of signal number is defined by the header + `include/gdb/signals.h' in the GDB source code. + + As in the description of request packets, we include spaces in the + reply templates for clarity; these are not part of the reply packet's + syntax. No GDB stop reply packet uses spaces to separate its + components. + + `S AA' + The program received signal number AA (a two-digit hexadecimal + number). This is equivalent to a `T' response with no n:r pairs. + `T AA n1:r1;n2:r2;...' + The program received signal number AA (a two-digit hexadecimal + number). This is equivalent to an `S' response, except that the + `n:r' pairs can carry values of important registers and other + information directly in the stop reply packet, reducing + round-trip latency. Single-step and breakpoint traps are + reported this way. Each `n:r' pair is interpreted as follows: + + If n is a hexadecimal number, it is a register number, and the + corresponding r gives that register's value. r is a series of + bytes in target byte order, with each byte given by a + two-digit hex number. + + If n is `thread', then r is the thread-id of the stopped + thread, as specified in thread-id syntax. + + If n is a recognized stop reason, it describes a more specific + event that stopped the target. The currently defined stop + reasons are listed below. aa should be `05', the trap signal. + At most one stop reason should be present. + + Otherwise, GDB should ignore this `n:r' pair and go on to the + next; this allows us to extend the protocol in the future. + The currently defined stop reasons are: + `watch' + `rwatch' + `awatch' + The packet indicates a watchpoint hit, and r is the data + address, in hex. + `library' + The packet indicates that the loaded libraries have + changed. GDB should use `qXfer:libraries:read' to fetch a + new list of loaded libraries. r is ignored. + `replaylog' + The packet indicates that the target cannot continue + replaying logged execution events, because it has reached + the end (or the beginning when executing backward) of the + log. The value of r will be either `begin' or `end'. See + section 6. Running programs backward, for more information. + `W AA' + `W AA ; process:pid' + The process exited, and AA is the exit status. This is only + applicable to certain targets. + The second form of the response, including the process ID of the + exited process, can be used only when GDB has reported support + for multiprocess protocol extensions; see multiprocess + extensions. The pid is formatted as a big-endian hex string. + `X AA' + `X AA ; process:pid' + The process terminated with signal AA. + The second form of the response, including the process ID of the + terminated process, can be used only when GDB has reported + support for multiprocess protocol extensions; see multiprocess + extensions. The pid is formatted as a big-endian hex string. + `O XX...' + `XX...' is hex encoding of ASCII data, to be written as the + program's console output. This can happen at any time while the + program is running and the debugger should continue to wait for + `W', `T', etc. This reply is not permitted in non-stop mode. + `F call-id,parameter...' + call-id is the identifier which says which host system call + should be called. This is just the name of the function. + Translation into the correct system call is only applicable as + it's defined in GDB. See section D.13 File-I/O Remote Protocol + Extension, for a list of implemented system calls. + `parameter...' is a list of parameters as defined for this very + system call. + The target replies with this packet when it expects GDB to call + a host system call on behalf of the target. GDB replies with an + appropriate `F' packet and keeps up waiting for the next reply + packet from the target. The latest `C', `c', `S' or `s' action + is expected to be continued. See section D.13 File-I/O Remote + Protocol Extension, for more details. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.4 General Query Packets + + Packets starting with `q' are general query packets; packets starting + with `Q' are general set packets. General query and set packets are a + semi-unified form for retrieving and sending information to and from + the stub. + + The initial letter of a query or set packet is followed by a name + indicating what sort of thing the packet applies to. For example, GDB + may use a `qSymbol' packet to exchange symbol definitions with the + stub. These packet names follow some conventions: + + * The name must not contain commas, colons or semicolons. + * Most GDB query and set packets have a leading upper case letter. + * The names of custom vendor packets should use a company prefix, in + lower case, followed by a period. For example, packets designed at + the Acme Corporation might begin with `qacme.foo' (for querying + foos) or `Qacme.bar' (for setting bars). + + The name of a query or set packet should be separated from any + parameters by a `:'; the parameters themselves should be separated by + `,' or `;'. Stubs must be careful to match the full packet name, and + check for a separator or the end of the packet, in case two packet + names share a common prefix. New packets should not begin with `qC', + `qP', or `qL'(14). + + Like the descriptions of the other packets, each description here has a + template showing the packet's overall syntax, followed by an + explanation of the packet's meaning. We include spaces in some of the + templates for clarity; these are not part of the packet's syntax. No + GDB packet uses spaces to separate its components. + + Here are the currently defined query and set packets: + + `qC' + Return the current thread ID. + Reply: + `QC thread-id' + Where thread-id is a thread ID as documented in thread-id + syntax. + `(anything else)' + Any other reply implies the old thread ID. + `qCRC:addr,length' + Compute the CRC checksum of a block of memory. Reply: + `E NN' + An error (such as memory fault) + `C crc32' + The specified memory region's checksum is crc32. + `qfThreadInfo' + `qsThreadInfo' + Obtain a list of all active thread IDs from the target (OS). + Since there may be too many active threads to fit into one reply + packet, this query works iteratively: it may require more than + one query/reply sequence to obtain the entire list of threads. + The first query of the sequence will be the `qfThreadInfo' + query; subsequent queries in the sequence will be the + `qsThreadInfo' query. + NOTE: This packet replaces the `qL' query (see below). + Reply: + `m thread-id' + A single thread ID + `m thread-id,thread-id...' + a comma-separated list of thread IDs + `l' + (lower case letter `L') denotes end of list. + In response to each query, the target will reply with a list of + one or more thread IDs, separated by commas. GDB will respond to + each reply with a request for more thread ids (using the `qs' + form of the query), until the target responds with `l' + (lower-case el, for last). Refer to thread-id syntax, for the + format of the thread-id fields. + `qGetTLSAddr:thread-id,offset,lm' + Fetch the address associated with thread local storage specified + by thread-id, offset, and lm. + thread-id is the thread ID associated with the thread for which + to fetch the TLS address. See thread-id syntax. + offset is the (big endian, hex encoded) offset associated with + the thread local variable. (This offset is obtained from the + debug information associated with the variable.) + lm is the (big endian, hex encoded) OS/ABI-specific encoding of + the the load module associated with the thread local storage. + For example, a GNU/Linux system will pass the link map address + of the shared object associated with the thread local storage + under consideration. Other operating environments may choose to + represent the load module differently, so the precise meaning of + this parameter will vary. + Reply: + `XX...' + Hex encoded (big endian) bytes representing the address of + the thread local storage requested. + `E nn' + An error occurred. nn are hex digits. + `' + An empty reply indicates that `qGetTLSAddr' is not + supported by the stub. + `qL startflag threadcount nextthread' + Obtain thread information from RTOS. Where: startflag (one hex + digit) is one to indicate the first query and zero to indicate a + subsequent query; threadcount (two hex digits) is the maximum + number of threads the response packet can contain; and + nextthread (eight hex digits), for subsequent queries (startflag + is zero), is returned in the response as argthread. + Don't use this packet; use the `qfThreadInfo' query instead (see + above). + Reply: + `qM count done argthread thread...' + Where: count (two hex digits) is the number of threads + being returned; done (one hex digit) is zero to indicate + more threads and one indicates no further threads; + argthreadid (eight hex digits) is nextthread from the + request packet; thread... is a sequence of thread IDs from + the target. threadid (eight hex digits). See + remote.c:parse_threadlist_response(). + `qOffsets' + Get section offsets that the target used when relocating the + downloaded image. + Reply: + `Text=xxx;Data=yyy[;Bss=zzz]' + Relocate the Text section by xxx from its original address. + Relocate the Data section by yyy from its original address. + If the object file format provides segment information + (e.g. ELF `PT_LOAD' program headers), GDB will relocate + entire segments by the supplied offsets. + Note: while a Bss offset may be included in the response, + GDB ignores this and instead applies the Data offset to the + Bss section. + `TextSeg=xxx[;DataSeg=yyy]' + Relocate the first segment of the object file, which + conventionally contains program code, to a starting address + of xxx. If `DataSeg' is specified, relocate the second + segment, which conventionally contains modifiable data, to + a starting address of yyy. GDB will report an error if the + object file does not contain segment information, or does + not contain at least as many segments as mentioned in the + reply. Extra segments are kept at fixed offsets relative to + the last relocated segment. + `qP mode thread-id' + Returns information on thread-id. Where: mode is a hex encoded + 32 bit mode; thread-id is a thread ID (see thread-id syntax). + Don't use this packet; use the `qThreadExtraInfo' query instead + (see below). + Reply: see remote.c:remote_unpack_thread_info_response(). + `QNonStop:1' + `QNonStop:0' + Enter non-stop (`QNonStop:1') or all-stop (`QNonStop:0') mode. + See section D.10 Remote Protocol Support for Non-Stop Mode, for + more information. + Reply: + `OK' + The request succeeded. + `E nn' + An error occurred. nn are hex digits. + `' + An empty reply indicates that `QNonStop' is not supported + by the stub. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' response + (see qSupported). Use of this packet is controlled by the set + non-stop command; see section 5.4.2 Non-Stop Mode. + `QPassSignals: signal [;signal]...' + Each listed signal should be passed directly to the inferior + process. Signals are numbered identically to continue packets + and stop replies (see section D.3 Stop Reply Packets). Each + signal list item should be strictly greater than the previous + item. These signals do not need to stop the inferior, or be + reported to GDB. All other signals should be reported to GDB. + Multiple `QPassSignals' packets do not combine; any earlier + `QPassSignals' list is completely replaced by the new list. This + packet improves performance when using `handle signal nostop + noprint pass'. + Reply: + `OK' + The request succeeded. + `E nn' + An error occurred. nn are hex digits. + `' + An empty reply indicates that `QPassSignals' is not + supported by the stub. + Use of this packet is controlled by the set remote pass-signals + command (see section set remote pass-signals). This packet is + not probed by default; the remote stub must request it, by + supplying an appropriate `qSupported' response (see qSupported). + `qRcmd,command' + command (hex encoded) is passed to the local interpreter for + execution. Invalid commands should be reported using the output + string. Before the final result packet, the target may also + respond with a number of intermediate `Ooutput' console output + packets. Implementors should note that providing access to a + stubs's interpreter may have security implications. + Reply: + `OK' + A command response with no output. + `OUTPUT' + A command response with the hex encoded output string + OUTPUT. + `E NN' + Indicate a badly formed request. + `' + An empty reply indicates that `qRcmd' is not recognized. + (Note that the qRcmd packet's name is separated from the command + by a `,', not a `:', contrary to the naming conventions above. + Please don't use this packet as a model for new packets.) + `qSearch:memory:address;length;search-pattern' + Search length bytes at address for search-pattern. address and + length are encoded in hex. search-pattern is a sequence of + bytes, hex encoded. + Reply: + `0' + The pattern was not found. + `1,address' + The pattern was found at address. + `E NN' + A badly formed request or an error was encountered while + searching memory. + `' + An empty reply indicates that `qSearch:memory' is not + recognized. + `QStartNoAckMode' + Request that the remote stub disable the normal `+'/`-' protocol + acknowledgments (see section D.11 Packet Acknowledgment). + Reply: + `OK' + The stub has switched to no-acknowledgment mode. GDB + acknowledges this reponse, but neither the stub nor GDB + shall send or expect further `+'/`-' acknowledgments in the + current connection. + `' + An empty reply indicates that the stub does not support + no-acknowledgment mode. + `qSupported [:gdbfeature [;gdbfeature]... ]' + Tell the remote stub about features supported by GDB, and query + the stub for features it supports. This packet allows GDB and + the remote stub to take advantage of each others' features. + `qSupported' also consolidates multiple feature probes at + startup, to improve GDB performance--a single larger packet + performs better than multiple smaller probe packets on + high-latency links. Some features may enable behavior which must + not be on by default, e.g. because it would confuse older + clients or stubs. Other features may describe packets which + could be automatically probed for, but are not. These features + must be reported before GDB will use them. This "default + unsupported" behavior is not appropriate for all packets, but it + helps to keep the initial connection time under control with new + versions of GDB which support increasing numbers of packets. + Reply: + `stubfeature [;stubfeature]...' + The stub supports or does not support each returned + stubfeature, depending on the form of each stubfeature (see + below for the possible forms). + `' + An empty reply indicates that `qSupported' is not + recognized, or that no features needed to be reported to + GDB. + The allowed forms for each feature (either a gdbfeature in the + `qSupported' packet, or a stubfeature in the response) are: + `name=value' + The remote protocol feature name is supported, and + associated with the specified value. The format of value + depends on the feature, but it must not include a + semicolon. + `name+' + The remote protocol feature name is supported, and does not + need an associated value. + `name-' + The remote protocol feature name is not supported. + `name?' + The remote protocol feature name may be supported, and GDB + should auto-detect support in some other way when it is + needed. This form will not be used for gdbfeature + notifications, but may be used for stubfeature responses. + Whenever the stub receives a `qSupported' request, the supplied + set of GDB features should override any previous request. This + allows GDB to put the stub in a known state, even if the stub + had previously been communicating with a different version of + GDB. + The following values of gdbfeature (for the packet sent by GDB) + are defined: + `multiprocess' + This feature indicates whether GDB supports multiprocess + extensions to the remote protocol. GDB does not use such + extensions unless the stub also reports that it supports + them by including `multiprocess+' in its `qSupported' + reply. See multiprocess extensions, for details. + Stubs should ignore any unknown values for gdbfeature. Any GDB + which sends a `qSupported' packet supports receiving packets of + unlimited length (earlier versions of GDB may reject overly long + responses). Additional values for gdbfeature may be defined in + the future to let the stub take advantage of new features in + GDB, e.g. incompatible improvements in the remote protocol--the + `multiprocess' feature is an example of such a feature. The + stub's reply should be independent of the gdbfeature entries + sent by GDB; first GDB describes all the features it supports, + and then the stub replies with all the features it supports. + Similarly, GDB will silently ignore unrecognized stub feature + responses, as long as each response uses one of the standard + forms. + Some features are flags. A stub which supports a flag feature + should respond with a `+' form response. Other features require + values, and the stub should respond with an `=' form response. + Each feature has a default value, which GDB will use if + `qSupported' is not available or if the feature is not mentioned + in the `qSupported' response. The default values are fixed; a + stub is free to omit any feature responses that match the + defaults. + Not all features can be probed, but for those which can, the + probing mechanism is useful: in some cases, a stub's internal + architecture may not allow the protocol layer to know some + information about the underlying target in advance. This is + especially common in stubs which may be configured for multiple + targets. + These are the currently defined stub features and their + properties: + + Feature Name + Value Required Default Probe Allowed + `PacketSize' + Yes `-' No + `qXfer:auxv:read' + No `-' Yes + `qXfer:features:read' + No `-' Yes + `qXfer:libraries:read' + No `-' Yes + `qXfer:memory-map:read' + No `-' Yes + `qXfer:spu:read' + No `-' Yes + `qXfer:spu:write' + No `-' Yes + `qXfer:siginfo:read' + No `-' Yes + `qXfer:siginfo:write' + No `-' Yes + `QNonStop' + No `-' Yes + `QPassSignals' + No `-' Yes + `QStartNoAckMode' + No `-' Yes + `multiprocess' + No `-' No + These are the currently defined stub features, in more detail: + `PacketSize=bytes' + The remote stub can accept packets up to at least bytes in + length. GDB will send packets up to this size for bulk + transfers, and will never send larger packets. This is a + limit on the data characters in the packet, including the + frame and checksum. There is no trailing NUL byte in a + remote protocol packet; if the stub stores packets in a + NUL-terminated format, it should allow an extra byte in its + buffer for the NUL. If this stub feature is not supported, + GDB guesses based on the size of the `g' packet response. + `qXfer:auxv:read' + The remote stub understands the `qXfer:auxv:read' packet + (see qXfer auxiliary vector read). + `qXfer:features:read' + The remote stub understands the `qXfer:features:read' + packet (see qXfer target description read). + `qXfer:libraries:read' + The remote stub understands the `qXfer:libraries:read' + packet (see qXfer library list read). + `qXfer:memory-map:read' + The remote stub understands the `qXfer:memory-map:read' + packet (see qXfer memory map read). + `qXfer:spu:read' + The remote stub understands the `qXfer:spu:read' packet + (see qXfer spu read). + `qXfer:spu:write' + The remote stub understands the `qXfer:spu:write' packet + (see qXfer spu write). + `qXfer:siginfo:read' + The remote stub understands the `qXfer:siginfo:read' packet + (see qXfer siginfo read). + `qXfer:siginfo:write' + The remote stub understands the `qXfer:siginfo:write' + packet (see qXfer siginfo write). + `QNonStop' + The remote stub understands the `QNonStop' packet (see + QNonStop). + `QPassSignals' + The remote stub understands the `QPassSignals' packet (see + QPassSignals). + `QStartNoAckMode' + The remote stub understands the `QStartNoAckMode' packet + and prefers to operate in no-acknowledgment mode. See + section D.11 Packet Acknowledgment. + `multiprocess' + The remote stub understands the multiprocess extensions to + the remote protocol syntax. The multiprocess extensions + affect the syntax of thread IDs in both packets and replies + (see thread-id syntax), and add process IDs to the `D' + packet and `W' and `X' replies. Note that reporting this + feature indicates support for the syntactic extensions + only, not that the stub necessarily supports debugging of + more than one process at a time. The stub must not use + multiprocess extensions in packet replies unless GDB has + also indicated it supports them in its `qSupported' + request. + `qXfer:osdata:read' + The remote stub understands the `qXfer:osdata:read' packet + ((see qXfer osdata read). + `qSymbol::' + Notify the target that GDB is prepared to serve symbol lookup + requests. Accept requests from the target for the values of + symbols. + Reply: + `OK' + The target does not need to look up any (more) symbols. + `qSymbol:sym_name' + The target requests the value of symbol sym_name (hex + encoded). GDB may provide the value by using the + `qSymbol:sym_value:sym_name' message, described below. + `qSymbol:sym_value:sym_name' + Set the value of sym_name to sym_value. + sym_name (hex encoded) is the name of a symbol whose value the + target has previously requested. + sym_value (hex) is the value for symbol sym_name. If GDB cannot + supply a value for sym_name, then this field will be empty. + Reply: + `OK' + The target does not need to look up any (more) symbols. + `qSymbol:sym_name' + The target requests the value of a new symbol sym_name (hex + encoded). GDB will continue to supply the values of symbols + (if available), until the target ceases to request them. + `QTDP' + `QTFrame' + See section D.6 Tracepoint Packets. + `qThreadExtraInfo,thread-id' + Obtain a printable string description of a thread's attributes + from the target OS. thread-id is a thread ID; see thread-id + syntax. This string may contain anything that the target OS + thinks is interesting for GDB to tell the user about the thread. + The string is displayed in GDB's info threads display. Some + examples of possible thread extra info strings are `Runnable', + or `Blocked on Mutex'. + Reply: + `XX...' + Where `XX...' is a hex encoding of ASCII data, comprising + the printable string containing the extra information about + the thread's attributes. + (Note that the qThreadExtraInfo packet's name is separated from + the command by a `,', not a `:', contrary to the naming + conventions above. Please don't use this packet as a model for + new packets.) + `QTStart' + `QTStop' + `QTinit' + `QTro' + `qTStatus' + See section D.6 Tracepoint Packets. + `qXfer:object:read:annex:offset,length' + Read uninterpreted bytes from the target's special data area + identified by the keyword object. Request length bytes starting + at offset bytes into the data. The content and encoding of annex + is specific to object; it can supply additional details about + what data to access. + Here are the specific requests of this form defined so far. All + `qXfer:object:read:...' requests use the same reply formats, + listed below. + `qXfer:auxv:read::offset,length' + Access the target's auxiliary vector. See section auxiliary + vector. Note annex must be empty. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:features:read:annex:offset,length' + Access the target description. See section F. Target + Descriptions. The annex specifies which XML document to + access. The main description is always loaded from the + `target.xml' annex. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:libraries:read:annex:offset,length' + Access the target's list of loaded libraries. See section + D.14 Library List Format. The annex part of the generic + `qXfer' packet must be empty (see qXfer read). + Targets which maintain a list of libraries in the program's + memory do not need to implement this packet; it is designed + for platforms where the operating system manages the list + of loaded libraries. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:memory-map:read::offset,length' + Access the target's memory-map. See section D.15 Memory Map + Format. The annex part of the generic `qXfer' packet must + be empty (see qXfer read). + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:siginfo:read::offset,length' + Read contents of the extra signal information on the target + system. The annex part of the generic `qXfer' packet must + be empty (see qXfer read). + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:spu:read:annex:offset,length' + Read contents of an spufs file on the target system. The + annex specifies which file to read; it must be of the form + `id/name', where id specifies an SPU context ID in the + target process, and name identifes the spufs file in that + context to be accessed. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:osdata:read::offset,length' + Access the target's operating system information. See + section G. Operating System Information. + Reply: + `m data' + Data data (see Binary Data) has been read from the target. + There may be more data at a higher address (although it is + permitted to return `m' even for the last valid block of + data, as long as at least one byte of data was read). data + may have fewer bytes than the length in the request. + `l data' + Data data (see Binary Data) has been read from the target. + There is no more data to be read. data may have fewer bytes + than the length in the request. + `l' + The offset in the request is at the end of the data. There + is no more data to be read. + `E00' + The request was malformed, or annex was invalid. + `E nn' + The offset was invalid, or there was an error encountered + reading the data. nn is a hex-encoded errno value. + `' + An empty reply indicates the object string was not + recognized by the stub, or that the object does not support + reading. + `qXfer:object:write:annex:offset:data...' + Write uninterpreted bytes into the target's special data area + identified by the keyword object, starting at offset bytes into + the data. data... is the binary-encoded data (see Binary Data) + to be written. The content and encoding of annex is specific to + object; it can supply additional details about what data to + access. + Here are the specific requests of this form defined so far. All + `qXfer:object:write:...' requests use the same reply formats, + listed below. + `qXfer:siginfo:write::offset:data...' + Write data to the extra signal information on the target + system. The annex part of the generic `qXfer' packet must + be empty (see qXfer write). + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + `qXfer:spu:write:annex:offset:data...' + Write data to an spufs file on the target system. The annex + specifies which file to write; it must be of the form + `id/name', where id specifies an SPU context ID in the + target process, and name identifes the spufs file in that + context to be accessed. + This packet is not probed by default; the remote stub must + request it, by supplying an appropriate `qSupported' + response (see qSupported). + Reply: + `nn' + nn (hex encoded) is the number of bytes written. This may + be fewer bytes than supplied in the request. + `E00' + The request was malformed, or annex was invalid. + `E nn' + The offset was invalid, or there was an error encountered + writing the data. nn is a hex-encoded errno value. + `' + An empty reply indicates the object string was not + recognized by the stub, or that the object does not support + writing. + `qXfer:object:operation:...' + Requests of this form may be added in the future. When a stub + does not recognize the object keyword, or its support for object + does not recognize the operation keyword, the stub must respond + with an empty packet. + `qAttached:pid' + Return an indication of whether the remote server attached to an + existing process or created a new process. When the multiprocess + protocol extensions are supported (see multiprocess extensions), + pid is an integer in hexadecimal format identifying the target + process. Otherwise, GDB will omit the pid field and the query + packet will be simplified as `qAttached'. + This query is used, for example, to know whether the remote + process should be detached or killed when a GDB session is ended + with the quit command. + Reply: + `1' + The remote server attached to an existing process. + `0' + The remote server created a new process. + `E NN' + A badly formed request or an error was encountered. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.5 Register Packet Format + + The following g/G packets have previously been defined. In the below, + some thirty-two bit registers are transferred as sixty-four bits. Those + registers should be zero/sign extended (which?) to fill the space + allocated. Register bytes are transferred in target byte order. The two + nibbles within a register byte are transferred most-significant - + least-significant. + + MIPS32 + All registers are transferred as thirty-two bit quantities in + the order: 32 general-purpose; sr; lo; hi; bad; cause; pc; 32 + floating-point registers; fsr; fir; fp. + MIPS64 + All registers are transferred as sixty-four bit quantities + (including thirty-two bit registers such as sr). The ordering is + the same as MIPS32. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.6 Tracepoint Packets + + Here we describe the packets GDB uses to implement tracepoints (see + section 11. Tracepoints). + + `QTDP:n:addr:ena:step:pass[-]' + Create a new tracepoint, number n, at addr. If ena is `E', then + the tracepoint is enabled; if it is `D', then the tracepoint is + disabled. step is the tracepoint's step count, and pass is its + pass count. If the trailing `-' is present, further `QTDP' + packets will follow to specify this tracepoint's actions. + Replies: + `OK' + The packet was understood and carried out. + `' + The packet was not recognized. + `QTDP:-n:addr:[S]action...[-]' + Define actions to be taken when a tracepoint is hit. n and addr + must be the same as in the initial `QTDP' packet for this + tracepoint. This packet may only be sent immediately after + another `QTDP' packet that ended with a `-'. If the trailing `-' + is present, further `QTDP' packets will follow, specifying more + actions for this tracepoint. + In the series of action packets for a given tracepoint, at most + one can have an `S' before its first action. If such a packet is + sent, it and the following packets define "while-stepping" + actions. Any prior packets define ordinary actions -- that is, + those taken when the tracepoint is first hit. If no action + packet has an `S', then all the packets in the series specify + ordinary tracepoint actions. + The `action...' portion of the packet is a series of actions, + concatenated without separators. Each action has one of the + following forms: + `R mask' + Collect the registers whose bits are set in mask. mask is a + hexadecimal number whose i'th bit is set if register number + i should be collected. (The least significant bit is + numbered zero.) Note that mask may be any number of digits + long; it may not fit in a 32-bit word. + `M basereg,offset,len' + Collect len bytes of memory starting at the address in + register number basereg, plus offset. If basereg is `-1', + then the range has a fixed address: offset is the address + of the lowest byte to collect. The basereg, offset, and len + parameters are all unsigned hexadecimal values (the `-1' + value for basereg is a special case). + `X len,expr' + Evaluate expr, whose length is len, and collect memory as + it directs. expr is an agent expression, as described in E. + The GDB Agent Expression Mechanism. Each byte of the + expression is encoded as a two-digit hex number in the + packet; len is the number of bytes in the expression (and + thus one-half the number of hex digits in the packet). + Any number of actions may be packed together in a single `QTDP' + packet, as long as the packet does not exceed the maximum packet + length (400 bytes, for many stubs). There may be only one `R' + action per tracepoint, and it must precede any `M' or `X' + actions. Any registers referred to by `M' and `X' actions must + be collected by a preceding `R' action. (The "while-stepping" + actions are treated as if they were attached to a separate + tracepoint, as far as these restrictions are concerned.) + Replies: + `OK' + The packet was understood and carried out. + `' + The packet was not recognized. + `QTFrame:n' + Select the n'th tracepoint frame from the buffer, and use the + register and memory contents recorded there to answer subsequent + request packets from GDB. + A successful reply from the stub indicates that the stub has + found the requested frame. The response is a series of parts, + concatenated without separators, describing the frame we + selected. Each part has one of the following forms: + `F f' + The selected frame is number n in the trace frame buffer; f + is a hexadecimal number. If f is `-1', then there was no + frame matching the criteria in the request packet. + `T t' + The selected trace frame records a hit of tracepoint number + t; t is a hexadecimal number. + `QTFrame:pc:addr' + Like `QTFrame:n', but select the first tracepoint frame after + the currently selected frame whose PC is addr; addr is a + hexadecimal number. + `QTFrame:tdp:t' + Like `QTFrame:n', but select the first tracepoint frame after + the currently selected frame that is a hit of tracepoint t; t is + a hexadecimal number. + `QTFrame:range:start:end' + Like `QTFrame:n', but select the first tracepoint frame after + the currently selected frame whose PC is between start + (inclusive) and end (exclusive); start and end are hexadecimal + numbers. + `QTFrame:outside:start:end' + Like `QTFrame:range:start:end', but select the first frame + outside the given range of addresses. + `QTStart' + Begin the tracepoint experiment. Begin collecting data from + tracepoint hits in the trace frame buffer. + `QTStop' + End the tracepoint experiment. Stop collecting trace frames. + `QTinit' + Clear the table of tracepoints, and empty the trace frame + buffer. + `QTro:start1,end1:start2,end2:...' + Establish the given ranges of memory as "transparent". The stub + will answer requests for these ranges from memory's current + contents, if they were not collected as part of the tracepoint + hit. + GDB uses this to mark read-only regions of memory, like those + containing program code. Since these areas never change, they + should still have the same contents they did when the tracepoint + was hit, so there's no reason for the stub to refuse to provide + their contents. + `qTStatus' + Ask the stub if there is a trace experiment running right now. + Replies: + `T0' + There is no trace experiment running. + `T1' + There is a trace experiment running. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.7 Host I/O Packets + + The Host I/O packets allow GDB to perform I/O operations on the far + side of a remote link. For example, Host I/O is used to upload and + download files to a remote target with its own filesystem. Host I/O + uses the same constant values and data structure layout as the + target-initiated File-I/O protocol. However, the Host I/O packets are + structured differently. The target-initiated protocol relies on target + memory to store parameters and buffers. Host I/O requests are initiated + by GDB, and the target's memory is not involved. See section D.13 + File-I/O Remote Protocol Extension, for more details on the + target-initiated protocol. + + The Host I/O request packets all encode a single operation along with + its arguments. They have this format: + + `vFile:operation: parameter...' + operation is the name of the particular request; the target + should compare the entire packet name up to the second colon + when checking for a supported operation. The format of parameter + depends on the operation. Numbers are always passed in + hexadecimal. Negative numbers have an explicit minus sign (i.e. + two's complement is not used). Strings (e.g. filenames) are + encoded as a series of hexadecimal bytes. The last argument to a + system call may be a buffer of escaped binary data (see Binary + Data). + + The valid responses to Host I/O packets are: + + `F result [, errno] [; attachment]' + result is the integer value returned by this operation, usually + non-negative for success and -1 for errors. If an error has + occured, errno will be included in the result. errno will have a + value defined by the File-I/O protocol (see section Errno + Values). For operations which return data, attachment supplies + the data as a binary buffer. Binary buffers in response packets + are escaped in the normal way (see Binary Data). See the + individual packet documentation for the interpretation of result + and attachment. + `' + An empty response indicates that this operation is not + recognized. + + These are the supported Host I/O operations: + + `vFile:open: pathname, flags, mode' + Open a file at pathname and return a file descriptor for it, or + return -1 if an error occurs. pathname is a string, flags is an + integer indicating a mask of open flags (see section Open + Flags), and mode is an integer indicating a mask of mode bits to + use if the file is created (see section mode_t Values). See + section open, for details of the open flags and mode values. + `vFile:close: fd' + Close the open file corresponding to fd and return 0, or -1 if + an error occurs. + `vFile:pread: fd, count, offset' + Read data from the open file corresponding to fd. Up to count + bytes will be read from the file, starting at offset relative to + the start of the file. The target may read fewer bytes; common + reasons include packet size limits and an end-of-file condition. + The number of bytes read is returned. Zero should only be + returned for a successful read at the end of the file, or if + count was zero. + The data read should be returned as a binary attachment on + success. If zero bytes were read, the response should include an + empty binary attachment (i.e. a trailing semicolon). The return + value is the number of target bytes read; the binary attachment + may be longer if some characters were escaped. + `vFile:pwrite: fd, offset, data' + Write data (a binary buffer) to the open file corresponding to + fd. Start the write at offset from the start of the file. Unlike + many write system calls, there is no separate count argument; + the length of data in the packet is used. `vFile:write' returns + the number of bytes written, which may be shorter than the + length of data, or -1 if an error occurred. + `vFile:unlink: pathname' + Delete the file at pathname on the target. Return 0, or -1 if an + error occurs. pathname is a string. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.8 Interrupts + + When a program on the remote target is running, GDB may attempt to + interrupt it by sending a `Ctrl-C' or a BREAK, control of which is + specified via GDB's `remotebreak' setting (see set remotebreak). + + The precise meaning of BREAK is defined by the transport mechanism and + may, in fact, be undefined. GDB does not currently define a BREAK + mechanism for any of the network interfaces except for TCP, in which + case GDB sends the telnet BREAK sequence. + + `Ctrl-C', on the other hand, is defined and implemented for all + transport mechanisms. It is represented by sending the single byte 0x03 + without any of the usual packet overhead described in the Overview + section (see section D.1 Overview). When a 0x03 byte is transmitted as + part of a packet, it is considered to be packet data and does not + represent an interrupt. E.g., an `X' packet (see X packet), used for + binary downloads, may include an unescaped 0x03 as part of its packet. + + Stubs are not required to recognize these interrupt mechanisms and the + precise meaning associated with receipt of the interrupt is + implementation defined. If the target supports debugging of multiple + threads and/or processes, it should attempt to interrupt all + currently-executing threads and processes. If the stub is successful at + interrupting the running program, it should send one of the stop reply + packets (see section D.3 Stop Reply Packets) to GDB as a result of + successfully stopping the program in all-stop mode, and a stop reply + for each stopped thread in non-stop mode. Interrupts received while the + program is stopped are discarded. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.9 Notification Packets + + The GDB remote serial protocol includes notifications, packets that + require no acknowledgment. Both the GDB and the stub may send + notifications (although the only notifications defined at present are + sent by the stub). Notifications carry information without incurring + the round-trip latency of an acknowledgment, and so are useful for + low-impact communications where occasional packet loss is not a + problem. + + A notification packet has the form `% data # checksum', where data is + the content of the notification, and checksum is a checksum of data, + computed and formatted as for ordinary GDB packets. A notification's + data never contains `$', `%' or `#' characters. Upon receiving a + notification, the recipient sends no `+' or `-' to acknowledge the + notification's receipt or to report its corruption. + + Every notification's data begins with a name, which contains no colon + characters, followed by a colon character. + + Recipients should silently ignore corrupted notifications and + notifications they do not understand. Recipients should restart timeout + periods on receipt of a well-formed notification, whether or not they + understand it. + + Senders should only send the notifications described here when this + protocol description specifies that they are permitted. In the future, + we may extend the protocol to permit existing notifications in new + contexts; this rule helps older senders avoid confusing newer + recipients. + + (Older versions of GDB ignore bytes received until they see the `$' + byte that begins an ordinary packet, so new stubs may transmit + notifications without fear of confusing older clients. There are no + notifications defined for GDB to send at the moment, but we assume that + most older stubs would ignore them, as well.) + + The following notification packets from the stub to GDB are defined: + + `Stop: reply' + Report an asynchronous stop event in non-stop mode. The reply + has the form of a stop reply, as described in D.3 Stop Reply + Packets. Refer to D.10 Remote Protocol Support for Non-Stop + Mode, for information on how these notifications are + acknowledged by GDB. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.10 Remote Protocol Support for Non-Stop Mode + + GDB's remote protocol supports non-stop debugging of multi-threaded + programs, as described in 5.4.2 Non-Stop Mode. If the stub supports + non-stop mode, it should report that to GDB by including `QNonStop+' in + its `qSupported' response (see qSupported). + + GDB typically sends a `QNonStop' packet only when establishing a new + connection with the stub. Entering non-stop mode does not alter the + state of any currently-running threads, but targets must stop all + threads in any already-attached processes when entering all-stop mode. + GDB uses the `?' packet as necessary to probe the target state after a + mode change. + + In non-stop mode, when an attached process encounters an event that + would otherwise be reported with a stop reply, it uses the asynchronous + notification mechanism (see section D.9 Notification Packets) to inform + GDB. In contrast to all-stop mode, where all threads in all processes + are stopped when a stop reply is sent, in non-stop mode only the thread + reporting the stop event is stopped. That is, when reporting a `S' or + `T' response to indicate completion of a step operation, hitting a + breakpoint, or a fault, only the affected thread is stopped; any other + still-running threads continue to run. When reporting a `W' or `X' + response, all running threads belonging to other attached processes + continue to run. + + Only one stop reply notification at a time may be pending; if + additional stop events occur before GDB has acknowledged the previous + notification, they must be queued by the stub for later synchronous + transmission in response to `vStopped' packets from GDB. Because the + notification mechanism is unreliable, the stub is permitted to resend a + stop reply notification if it believes GDB may not have received it. + GDB ignores additional stop reply notifications received before it has + finished processing a previous notification and the stub has completed + sending any queued stop events. + + Otherwise, GDB must be prepared to receive a stop reply notification at + any time. Specifically, they may appear when GDB is not otherwise + reading input from the stub, or when GDB is expecting to read a normal + synchronous response or a `+'/`-' acknowledgment to a packet it has + sent. Notification packets are distinct from any other communication + from the stub so there is no ambiguity. + + After receiving a stop reply notification, GDB shall acknowledge it by + sending a `vStopped' packet (see vStopped packet) as a regular, + synchronous request to the stub. Such acknowledgment is not required to + happen immediately, as GDB is permitted to send other, unrelated + packets to the stub first, which the stub should process normally. + + Upon receiving a `vStopped' packet, if the stub has other queued stop + events to report to GDB, it shall respond by sending a normal stop + reply response. GDB shall then send another `vStopped' packet to + solicit further responses; again, it is permitted to send other, + unrelated packets as well which the stub should process normally. + + If the stub receives a `vStopped' packet and there are no additional + stop events to report, the stub shall return an `OK' response. At this + point, if further stop events occur, the stub shall send a new stop + reply notification, GDB shall accept the notification, and the process + shall be repeated. + + In non-stop mode, the target shall respond to the `?' packet as + follows. First, any incomplete stop reply notification/`vStopped' + sequence in progress is abandoned. The target must begin a new sequence + reporting stop events for all stopped threads, whether or not it has + previously reported those events to GDB. The first stop reply is sent + as a synchronous reply to the `?' packet, and subsequent stop replies + are sent as responses to `vStopped' packets using the mechanism + described above. The target must not send asynchronous stop reply + notifications until the sequence is complete. If all threads are + running when the target receives the `?' packet, or if the target is + not attached to any process, it shall respond `OK'. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.11 Packet Acknowledgment + + By default, when either the host or the target machine receives a + packet, the first response expected is an acknowledgment: either `+' + (to indicate the package was received correctly) or `-' (to request + retransmission). This mechanism allows the GDB remote protocol to + operate over unreliable transport mechanisms, such as a serial line. + + In cases where the transport mechanism is itself reliable (such as a + pipe or TCP connection), the `+'/`-' acknowledgments are redundant. It + may be desirable to disable them in that case to reduce communication + overhead, or for other reasons. This can be accomplished by means of + the `QStartNoAckMode' packet; see QStartNoAckMode. + + When in no-acknowledgment mode, neither the stub nor GDB shall send or + expect `+'/`-' protocol acknowledgments. The packet and response format + still includes the normal checksum, as described in D.1 Overview, but + the checksum may be ignored by the receiver. + + If the stub supports `QStartNoAckMode' and prefers to operate in + no-acknowledgment mode, it should report that to GDB by including + `QStartNoAckMode+' in its response to `qSupported'; see qSupported. If + GDB also supports `QStartNoAckMode' and it has not been disabled via + the set remote noack-packet off command (see section 18.4 Remote + Configuration), GDB may then send a `QStartNoAckMode' packet to the + stub. Only then may the stub actually turn off packet acknowledgments. + GDB sends a final `+' acknowledgment of the stub's `OK' response, which + can be safely ignored by the stub. + + Note that set remote noack-packet command only affects negotiation + between GDB and the stub when subsequent connections are made; it does + not affect the protocol acknowledgment state for any current + connection. Since `+'/`-' acknowledgments are enabled by default when a + new connection is established, there is also no protocol request to + re-enable the acknowledgments for the current connection, once + disabled. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.12 Examples + + Example sequence of a target being re-started. Notice how the restart + does not get any direct output: + + +-> R00 +<- + +target restarts +-> ? +<- + +<- T001:1234123412341234 +-> + + + Example sequence of a target being stepped by a single instruction: + + +-> G1445... +<- + +-> s +<- + +time passes +<- T001:1234123412341234 +-> + +-> g +<- + +<- 1455... +-> + + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.13 File-I/O Remote Protocol Extension + + D.13.1 File-I/O Overview + D.13.2 Protocol Basics + D.13.3 The F Request Packet + D.13.4 The F Reply Packet + D.13.5 The `Ctrl-C' Message + D.13.6 Console I/O + D.13.7 List of Supported Calls + D.13.8 Protocol-specific Representation of Datatypes + D.13.9 Constants + D.13.10 File-I/O Examples + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.1 File-I/O Overview + + The File I/O remote protocol extension (short: File-I/O) allows the + target to use the host's file system and console I/O to perform various + system calls. System calls on the target system are translated into a + remote protocol packet to the host system, which then performs the + needed actions and returns a response packet to the target system. This + simulates file system operations even on targets that lack file + systems. + + The protocol is defined to be independent of both the host and target + systems. It uses its own internal representation of datatypes and + values. Both GDB and the target's GDB stub are responsible for + translating the system-dependent value representations into the + internal protocol representations when data is transmitted. + + The communication is synchronous. A system call is possible only when + GDB is waiting for a response from the `C', `c', `S' or `s' packets. + While GDB handles the request for a system call, the target is stopped + to allow deterministic access to the target's memory. Therefore + File-I/O is not interruptible by target signals. On the other hand, it + is possible to interrupt File-I/O by a user interrupt (`Ctrl-C') within + GDB. + + The target's request to perform a host system call does not finish the + latest `C', `c', `S' or `s' action. That means, after finishing the + system call, the target returns to continuing the previous activity + (continue, step). No additional continue or step request from GDB is + required. + + +(gdb) continue + <- target requests 'system call X' + target is stopped, GDB executes system call + -> GDB returns result + ... target continues, GDB returns to wait for the target + <- target hits breakpoint and sends a Txx packet + + The protocol only supports I/O on the console and to regular files on + the host file system. Character or block special devices, pipes, named + pipes, sockets or any other communication method on the host system are + not supported by this protocol. + + File I/O is not supported in non-stop mode. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.2 Protocol Basics + + The File-I/O protocol uses the F packet as the request as well as reply + packet. Since a File-I/O system call can only occur when GDB is waiting + for a response from the continuing or stepping target, the File-I/O + request is a reply that GDB has to expect as a result of a previous + `C', `c', `S' or `s' packet. This F packet contains all information + needed to allow GDB to call the appropriate host system call: + + * A unique identifier for the requested system call. + * All parameters to the system call. Pointers are given as addresses + in the target memory address space. Pointers to strings are given + as pointer/length pair. Numerical values are given as they are. + Numerical control flags are given in a protocol-specific + representation. + + At this point, GDB has to perform the following actions. + + * If the parameters include pointer values to data needed as input to + a system call, GDB requests this data from the target with a + standard m packet request. This additional communication has to be + expected by the target implementation and is handled as any other m + packet. + * GDB translates all value from protocol representation to host + representation as needed. Datatypes are coerced into the host + types. + * GDB calls the system call. + * It then coerces datatypes back to protocol representation. + * If the system call is expected to return data in buffer space + specified by pointer parameters to the call, the data is + transmitted to the target using a M or X packet. This packet has to + be expected by the target implementation and is handled as any + other M or X packet. + + Eventually GDB replies with another F packet which contains all + necessary information for the target to continue. This at least + contains + + * Return value. + * errno, if has been changed by the system call. + * "Ctrl-C" flag. + + After having done the needed type and value coercion, the target + continues the latest continue or step action. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.3 The F Request Packet + + The F request packet has the following format: + + `Fcall-id,parameter...' + call-id is the identifier to indicate the host system call to be + called. This is just the name of the function. + parameter... are the parameters to the system call. Parameters + are hexadecimal integer values, either the actual values in case + of scalar datatypes, pointers to target buffer space in case of + compound datatypes and unspecified memory areas, or + pointer/length pairs in case of string parameters. These are + appended to the call-id as a comma-delimited list. All values + are transmitted in ASCII string representation, pointer/length + pairs separated by a slash. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.4 The F Reply Packet + + The F reply packet has the following format: + + `Fretcode,errno,Ctrl-C flag;call-specific attachment' + retcode is the return code of the system call as hexadecimal + value. + errno is the errno set by the call, in protocol-specific + representation. This parameter can be omitted if the call was + successful. + Ctrl-C flag is only sent if the user requested a break. In this + case, errno must be sent as well, even if the call was + successful. The Ctrl-C flag itself consists of the character + `C': + + +F0,0,C + + or, if the call was interrupted before the host call has been + performed: + + +F-1,4,C + + assuming 4 is the protocol-specific representation of EINTR. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.5 The `Ctrl-C' Message + + If the `Ctrl-C' flag is set in the GDB reply packet (see section D.13.4 + The F Reply Packet), the target should behave as if it had gotten a + break message. The meaning for the target is "system call interrupted + by SIGINT". Consequentially, the target should actually stop (as with a + break message) and return to GDB with a T02 packet. + + It's important for the target to know in which state the system call + was interrupted. There are two possible cases: + + * The system call hasn't been performed on the host yet. + * The system call on the host has been finished. + + These two states can be distinguished by the target by the value of the + returned errno. If it's the protocol representation of EINTR, the + system call hasn't been performed. This is equivalent to the EINTR + handling on POSIX systems. In any other case, the target may presume + that the system call has been finished -- successfully or not -- and + should behave as if the break message arrived right after the system + call. + + GDB must behave reliably. If the system call has not been called yet, + GDB may send the F reply immediately, setting EINTR as errno in the + packet. If the system call on the host has been finished before the + user requests a break, the full action must be finished by GDB. This + requires sending M or X packets as necessary. The F packet may only be + sent when either nothing has happened or the full action has been + completed. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.6 Console I/O + + By default and if not explicitly closed by the target system, the file + descriptors 0, 1 and 2 are connected to the GDB console. Output on the + GDB console is handled as any other file output operation (write(1, + ...) or write(2, ...)). Console input is handled by GDB so that after + the target read request from file descriptor 0 all following typing is + buffered until either one of the following conditions is met: + + * The user types Ctrl-c. The behaviour is as explained above, and the + read system call is treated as finished. + * The user presses RET. This is treated as end of input with a + trailing newline. + * The user types Ctrl-d. This is treated as end of input. No trailing + character (neither newline nor `Ctrl-D') is appended to the input. + + If the user has typed more characters than fit in the buffer given to + the read call, the trailing characters are buffered in GDB until either + another read(0, ...) is requested by the target, or debugging is + stopped at the user's request. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.7 List of Supported Calls + + open + close + read + write + lseek + rename + unlink + stat/fstat + gettimeofday + isatty + system + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + open + + Synopsis: + + +int open(const char *pathname, int flags); +int open(const char *pathname, int flags, mode_t mode); + + Request: + `Fopen,pathptr/len,flags,mode' + flags is the bitwise OR of the following values: + O_CREAT + If the file does not exist it will be created. The host + rules apply as far as file ownership and time stamps are + concerned. + O_EXCL + When used with O_CREAT, if the file already exists it is an + error and open() fails. + O_TRUNC + If the file already exists and the open mode allows writing + (O_RDWR or O_WRONLY is given) it will be truncated to zero + length. + O_APPEND + The file is opened in append mode. + O_RDONLY + The file is opened for reading only. + O_WRONLY + The file is opened for writing only. + O_RDWR + The file is opened for reading and writing. + Other bits are silently ignored. + mode is the bitwise OR of the following values: + S_IRUSR + User has read permission. + S_IWUSR + User has write permission. + S_IRGRP + Group has read permission. + S_IWGRP + Group has write permission. + S_IROTH + Others have read permission. + S_IWOTH + Others have write permission. + Other bits are silently ignored. + Return value: + open returns the new file descriptor or -1 if an error occurred. + Errors: + EEXIST + pathname already exists and O_CREAT and O_EXCL were used. + EISDIR + pathname refers to a directory. + EACCES + The requested access is not allowed. + ENAMETOOLONG + pathname was too long. + ENOENT + A directory component in pathname does not exist. + ENODEV + pathname refers to a device, pipe, named pipe or socket. + EROFS + pathname refers to a file on a read-only filesystem and + write access was requested. + EFAULT + pathname is an invalid pointer value. + ENOSPC + No space on device to create the file. + EMFILE + The process already has the maximum number of files open. + ENFILE + The limit on the total number of files open on the system + has been reached. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + close + + Synopsis: + + +int close(int fd); + + Request: + `Fclose,fd' + Return value: + close returns zero on success, or -1 if an error occurred. + Errors: + EBADF + fd isn't a valid open file descriptor. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + read + + Synopsis: + + +int read(int fd, void *buf, unsigned int count); + + Request: + `Fread,fd,bufptr,count' + Return value: + On success, the number of bytes read is returned. Zero indicates + end of file. If count is zero, read returns zero as well. On + error, -1 is returned. + Errors: + EBADF + fd is not a valid file descriptor or is not open for + reading. + EFAULT + bufptr is an invalid pointer value. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + write + + Synopsis: + + +int write(int fd, const void *buf, unsigned int count); + + Request: + `Fwrite,fd,bufptr,count' + Return value: + On success, the number of bytes written are returned. Zero + indicates nothing was written. On error, -1 is returned. + Errors: + EBADF + fd is not a valid file descriptor or is not open for + writing. + EFAULT + bufptr is an invalid pointer value. + EFBIG + An attempt was made to write a file that exceeds the + host-specific maximum file size allowed. + ENOSPC + No space on device to write the data. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + lseek + + Synopsis: + + +long lseek (int fd, long offset, int flag); + + Request: + `Flseek,fd,offset,flag' + flag is one of: + SEEK_SET + The offset is set to offset bytes. + SEEK_CUR + The offset is set to its current location plus offset + bytes. + SEEK_END + The offset is set to the size of the file plus offset + bytes. + Return value: + On success, the resulting unsigned offset in bytes from the + beginning of the file is returned. Otherwise, a value of -1 is + returned. + Errors: + EBADF + fd is not a valid open file descriptor. + ESPIPE + fd is associated with the GDB console. + EINVAL + flag is not a proper value. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + rename + + Synopsis: + + +int rename(const char *oldpath, const char *newpath); + + Request: + `Frename,oldpathptr/len,newpathptr/len' + Return value: + On success, zero is returned. On error, -1 is returned. + Errors: + EISDIR + newpath is an existing directory, but oldpath is not a + directory. + EEXIST + newpath is a non-empty directory. + EBUSY + oldpath or newpath is a directory that is in use by some + process. + EINVAL + An attempt was made to make a directory a subdirectory of + itself. + ENOTDIR + A component used as a directory in oldpath or new path is + not a directory. Or oldpath is a directory and newpath + exists but is not a directory. + EFAULT + oldpathptr or newpathptr are invalid pointer values. + EACCES + No access to the file or the path of the file. + ENAMETOOLONG + oldpath or newpath was too long. + ENOENT + A directory component in oldpath or newpath does not exist. + EROFS + The file is on a read-only filesystem. + ENOSPC + The device containing the file has no room for the new + directory entry. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + unlink + + Synopsis: + + +int unlink(const char *pathname); + + Request: + `Funlink,pathnameptr/len' + Return value: + On success, zero is returned. On error, -1 is returned. + Errors: + EACCES + No access to the file or the path of the file. + EPERM + The system does not allow unlinking of directories. + EBUSY + The file pathname cannot be unlinked because it's being + used by another process. + EFAULT + pathnameptr is an invalid pointer value. + ENAMETOOLONG + pathname was too long. + ENOENT + A directory component in pathname does not exist. + ENOTDIR + A component of the path is not a directory. + EROFS + The file is on a read-only filesystem. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + stat/fstat + + Synopsis: + + +int stat(const char *pathname, struct stat *buf); +int fstat(int fd, struct stat *buf); + + Request: + `Fstat,pathnameptr/len,bufptr' + `Ffstat,fd,bufptr' + Return value: + On success, zero is returned. On error, -1 is returned. + Errors: + EBADF + fd is not a valid open file. + ENOENT + A directory component in pathname does not exist or the + path is an empty string. + ENOTDIR + A component of the path is not a directory. + EFAULT + pathnameptr is an invalid pointer value. + EACCES + No access to the file or the path of the file. + ENAMETOOLONG + pathname was too long. + EINTR + The call was interrupted by the user. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + gettimeofday + + Synopsis: + + +int gettimeofday(struct timeval *tv, void *tz); + + Request: + `Fgettimeofday,tvptr,tzptr' + Return value: + On success, 0 is returned, -1 otherwise. + Errors: + EINVAL + tz is a non-NULL pointer. + EFAULT + tvptr and/or tzptr is an invalid pointer value. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + isatty + + Synopsis: + + +int isatty(int fd); + + Request: + `Fisatty,fd' + Return value: + Returns 1 if fd refers to the GDB console, 0 otherwise. + Errors: + EINTR + The call was interrupted by the user. + + Note that the isatty call is treated as a special case: it returns 1 to + the target if the file descriptor is attached to the GDB console, 0 + otherwise. Implementing through system calls would require implementing + ioctl and would be more complex than needed. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + system + + Synopsis: + + +int system(const char *command); + + Request: + `Fsystem,commandptr/len' + Return value: + If len is zero, the return value indicates whether a shell is + available. A zero return value indicates a shell is not + available. For non-zero len, the value returned is -1 on error + and the return status of the command otherwise. Only the exit + status of the command is returned, which is extracted from the + host's system return value by calling WEXITSTATUS(retval). In + case `/bin/sh' could not be executed, 127 is returned. + Errors: + EINTR + The call was interrupted by the user. + + GDB takes over the full task of calling the necessary host calls to + perform the system call. The return value of system on the host is + simplified before it's returned to the target. Any termination signal + information from the child process is discarded, and the return value + consists entirely of the exit status of the called command. + + Due to security concerns, the system call is by default refused by GDB. + The user has to allow this call explicitly with the set remote + system-call-allowed 1 command. + + set remote system-call-allowed + Control whether to allow the system calls in the File I/O + protocol for the remote target. The default is zero (disabled). + show remote system-call-allowed + Show whether the system calls are allowed in the File I/O + protocol. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.8 Protocol-specific Representation of Datatypes + + Integral Datatypes + Pointer Values + Memory Transfer + struct stat + struct timeval + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Integral Datatypes + + The integral datatypes used in the system calls are int, unsigned int, + long, unsigned long, mode_t, and time_t. + + int, unsigned int, mode_t and time_t are implemented as 32 bit values + in this protocol. + + long and unsigned long are implemented as 64 bit types. + + See section Limits, for corresponding MIN and MAX values (similar to + those in `limits.h') to allow range checking on host and target. + + time_t datatypes are defined as seconds since the Epoch. + + All integral datatypes transferred as part of a memory read or write of + a structured datatype e.g. a struct stat have to be given in big endian + byte order. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Pointer Values + + Pointers to target data are transmitted as they are. An exception is + made for pointers to buffers for which the length isn't transmitted as + part of the function call, namely strings. Strings are transmitted as a + pointer/length pair, both as hex values, e.g. + + +1aaf/12 + + which is a pointer to data of length 18 bytes at position 0x1aaf. The + length is defined as the full string length in bytes, including the + trailing null byte. For example, the string "hello world" at address + 0x123456 is transmitted as + + +123456/d + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Memory Transfer + + Structured data which is transferred using a memory read or write (for + example, a struct stat) is expected to be in a protocol-specific format + with all scalar multibyte datatypes being big endian. Translation to + this representation needs to be done both by the target before the F + packet is sent, and by GDB before it transfers memory to the target. + Transferred pointers to structured data should point to the + already-coerced data at any time. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + struct stat + + The buffer of type struct stat used by the target and GDB is defined as + follows: + + +struct stat { + unsigned int st_dev; /* device */ + unsigned int st_ino; /* inode */ + mode_t st_mode; /* protection */ + unsigned int st_nlink; /* number of hard links */ + unsigned int st_uid; /* user ID of owner */ + unsigned int st_gid; /* group ID of owner */ + unsigned int st_rdev; /* device type (if inode device) */ + unsigned long st_size; /* total size, in bytes */ + unsigned long st_blksize; /* blocksize for filesystem I/O */ + unsigned long st_blocks; /* number of blocks allocated */ + time_t st_atime; /* time of last access */ + time_t st_mtime; /* time of last modification */ + time_t st_ctime; /* time of last change */ +}; + + The integral datatypes conform to the definitions given in the + appropriate section (see Integral Datatypes, for details) so this + structure is of size 64 bytes. + + The values of several fields have a restricted meaning and/or range of + values. + + st_dev + A value of 0 represents a file, 1 the console. + st_ino + No valid meaning for the target. Transmitted unchanged. + st_mode + Valid mode bits are described in D.13.9 Constants. Any other + bits have currently no meaning for the target. + st_uid + st_gid + st_rdev + No valid meaning for the target. Transmitted unchanged. + st_atime + st_mtime + st_ctime + These values have a host and file system dependent accuracy. + Especially on Windows hosts, the file system may not support + exact timing values. + + The target gets a struct stat of the above representation and is + responsible for coercing it to the target representation before + continuing. + + Note that due to size differences between the host, target, and + protocol representations of struct stat members, these members could + eventually get truncated on the target. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + struct timeval + + The buffer of type struct timeval used by the File-I/O protocol is + defined as follows: + + +struct timeval { + time_t tv_sec; /* second */ + long tv_usec; /* microsecond */ +}; + + The integral datatypes conform to the definitions given in the + appropriate section (see Integral Datatypes, for details) so this + structure is of size 8 bytes. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.9 Constants + + The following values are used for the constants inside of the protocol. + GDB and target are responsible for translating these values before and + after the call as needed. + + Open Flags + mode_t Values + Errno Values + Lseek Flags + Limits + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Open Flags + + All values are given in hexadecimal representation. + + + O_RDONLY 0x0 + O_WRONLY 0x1 + O_RDWR 0x2 + O_APPEND 0x8 + O_CREAT 0x200 + O_TRUNC 0x400 + O_EXCL 0x800 + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + mode_t Values + + All values are given in octal representation. + + + S_IFREG 0100000 + S_IFDIR 040000 + S_IRUSR 0400 + S_IWUSR 0200 + S_IXUSR 0100 + S_IRGRP 040 + S_IWGRP 020 + S_IXGRP 010 + S_IROTH 04 + S_IWOTH 02 + S_IXOTH 01 + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Errno Values + + All values are given in decimal representation. + + + EPERM 1 + ENOENT 2 + EINTR 4 + EBADF 9 + EACCES 13 + EFAULT 14 + EBUSY 16 + EEXIST 17 + ENODEV 19 + ENOTDIR 20 + EISDIR 21 + EINVAL 22 + ENFILE 23 + EMFILE 24 + EFBIG 27 + ENOSPC 28 + ESPIPE 29 + EROFS 30 + ENAMETOOLONG 91 + EUNKNOWN 9999 + + EUNKNOWN is used as a fallback error value if a host system returns any + error value not in the list of supported error numbers. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Lseek Flags + + + SEEK_SET 0 + SEEK_CUR 1 + SEEK_END 2 + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + Limits + + All values are given in decimal representation. + + + INT_MIN -2147483648 + INT_MAX 2147483647 + UINT_MAX 4294967295 + LONG_MIN -9223372036854775808 + LONG_MAX 9223372036854775807 + ULONG_MAX 18446744073709551615 + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + + D.13.10 File-I/O Examples + + Example sequence of a write call, file descriptor 3, buffer is at + target address 0x1234, 6 bytes should be written: + + +<- Fwrite,3,1234,6 +request memory read from target +-> m1234,6 +<- XXXXXX +return "6 bytes written" +-> F6 + + Example sequence of a read call, file descriptor 3, buffer is at target + address 0x1234, 6 bytes should be read: + + +<- Fread,3,1234,6 +request memory write to target +-> X1234,6:XXXXXX +return "6 bytes read" +-> F6 + + Example sequence of a read call, call fails on the host due to invalid + file descriptor (EBADF): + + +<- Fread,3,1234,6 +-> F-1,9 + + Example sequence of a read call, user presses Ctrl-c before syscall on + host is called: + + +<- Fread,3,1234,6 +-> F-1,4,C +<- T02 + + Example sequence of a read call, user presses Ctrl-c after syscall on + host is called: + + +<- Fread,3,1234,6 +-> X1234,6:XXXXXX +<- T02 + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.14 Library List Format + + On some platforms, a dynamic loader (e.g. `ld.so') runs in the same + process as your application to manage libraries. In this case, GDB can + use the loader's symbol table and normal memory operations to maintain + a list of shared libraries. On other platforms, the operating system + manages loaded libraries. GDB can not retrieve the list of currently + loaded libraries through memory operations, so it uses the + `qXfer:libraries:read' packet (see qXfer library list read) instead. + The remote stub queries the target's operating system and reports which + libraries are loaded. + + The `qXfer:libraries:read' packet returns an XML document which lists + loaded libraries and their offsets. Each library has an associated name + and one or more segment or section base addresses, which report where + the library was loaded in memory. + + For the common case of libraries that are fully linked binaries, the + library should have a list of segments. If the target supports dynamic + linking of a relocatable object file, its library XML element should + instead include a list of allocated sections. The segment or section + bases are start addresses, not relocation offsets; they do not depend + on the library's link-time base addresses. + + GDB must be linked with the Expat library to support XML library lists. + See Expat. + + A simple memory map, with one loaded library relocated by a single + offset, looks like this: + + + + + + + + + Another simple memory map, with one loaded library with three allocated + sections (.text, .data, .bss), looks like this: + + + + +
+
+
+ + + + The format of a library list is described by this DTD: + + + + + + + + + + + + + In addition, segments and section descriptors cannot be mixed within a + single library element, and you must supply at least one segment or + section for each library. + __________________________________________________________________ + + [ < ] [ > ] [ << ] [ Up ] [ >> ] [Top] [Contents] [Index] [ ? + ] + +D.15 Memory Map Format + + To be able to write into flash memory, GDB needs to obtain a memory map + from the target. This section describes the format of the memory map. + + The memory map is obtained using the `qXfer:memory-map:read' (see qXfer + memory map read) packet and is an XML document that lists memory + regions. + + GDB must be linked with the Expat library to support XML memory maps. + See Expat. + + The top-level structure of the document is shown below: + + + + + + region... + + + Each region can be either: + + * A region of RAM starting at addr and extending for length bytes + from there: + + + + + * A region of read-only memory: + + + + + * A region of flash memory, with erasure blocks blocksize bytes in + length: + + + + blocksize + + + Regions must not overlap. GDB assumes that areas of memory not covered + by the memory map are RAM, and uses the ordinary `M' and `X' packets to + write to addresses in such ranges. + + The formal DTD for memory map format is given below: + + + + + + + + + + + + + + + + + __________________________________________________________________ + + [ << ] [ >> ] [Top] [Contents] [Index] [ ? ] + + + Please send FSF & GNU inquiries & questions to gnu@gnu.org. There are + also other ways to contact the FSF. + These pages are maintained by the GDB developers. + Copyright Free Software Foundation, Inc., 59 Temple Place - Suite + 330, Boston, MA 02111, USA. + Verbatim copying and distribution of this entire article is permitted + in any medium, provided this notice is preserved. + + This document was generated by GDB Administrator on April, 3 2009 using + texi2html diff -Nru eresi-0.8a25/libgdbwrap/doc/HOWTO.txt eresi-0.0.20110516/libgdbwrap/doc/HOWTO.txt --- eresi-0.8a25/libgdbwrap/doc/HOWTO.txt 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/doc/HOWTO.txt 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,215 @@ +* libgdbwrap : HOWTO * + + +This is a quick and dirty howto to test the features of libgdbwrap. + +The aim of the project is to implement a gdb capable client for +eresi, thus we'd be able to connect to different "tools", like VMWare, +qemu, etc. For now, only a 32b version is available. + +In libgdbwrap, you will find the following: + +- client.c +- gdbwrapper.c +- Makefile +- include/ + - gdbwrapper-internals.h + - gdbwrapper-stddef.h + - gdbwrapper.h + + +The gdb wrapper provides to the programmer an API, whose functions are +defined in include/gdbwrapper.h. +The available functions are: + +gdbwrap_t *gdbwrap_init(int fd); +void gdbwrap_close(gdbwrap_t *desc); +void gdbwrap_hello(gdbwrap_t *desc); +void gdbwrap_bye(gdbwrap_t *desc); +void gdbwrap_reason_halted(gdbwrap_t *desc); +char *gdbwrap_own_command(char *command, gdbwrap_t *desc); +void gdbwrap_test(gdbwrap_t *desc); +gdbwrap_gdbreg32 *gdbwrap_readgenreg(gdbwrap_t *desc); +void gdbwrap_continue(gdbwrap_t *desc); +char *gdbwrap_memorycontent(gdbwrap_t *desc, la32 linaddr, + uint8_t bytes); +void gdbwrap_writereg(ureg32 regNum, la32 val, gdbwrap_t *desc); +void gdbwrap_signal(int signal, gdbwrap_t *desc); +void gdbwrap_stepi(gdbwrap_t *desc); +void gdbwrap_vmwareinit(gdbwrap_t *desc); +void gdbwrap_writereg(ureg32 regNum, la32 val, gdbwrap_t *desc); + + +To get a gdbwrap_t "object", you must use the gdbwrap_init +function and provide a file descriptor. + +Suppose that you want to connect to a gdb client and retrieve the +state of the general purpose registers. Basically, in terms of +"functions", you will do the following: + +gdbwrap_t *gdbwrap_init(int fd); +gdbwrap_gdbreg32 *gdbwrap_readgenreg(gdbwrap_t *desc); + +From now, if you want to do some instruction stepping, just do + +void gdbwrap_stepi(gdbwrap_t *desc); + +and eventually, if you want to disconnect and free the memory, you +will do: + +void gdbwrap_bye(gdbwrap_t *desc); +void gdbwrap_close(gdbwrap_t *desc); + +Maybe I should come out with better names for these functions. + + +Now, if you want absolutely to try the functions, client.c contains some +commands: + +- hello: gdbwrap_reason_halted(desc); +- why: gdbwrap_reason_halted(desc); +- test: gdbwrap_test(desc); +- gpr: gdbwrap_readgenreg(desc); +- cont: gdbwrap_continue(desc); +- dump: dumpreg(desc); (client side) +- vm: gdbwrap_vmwareinit(desc); +- stepi: gdbwrap_stepi(desc); +- signal: gdbwrap_signal(int signal, gdbwrap_t *desc); +- own: own commands to send directly to the gdb server. + +Note that the "dump" command is dumping the value of the registers and +is implemented on the client side. This is just a way to debug the +values received by the server and will be removed when ported to +eresi. + +To try it, do the following: + +> gdbserver localhost:4444 /bin/ls +Process /bin/ls created; pid = 8556 +Listening on port 4444 + +and somewhere else: + +> make fclean && make && make client && ./client 127.0.0.1 4444 +rm -f gdbwrapper.o gdbwrapper.o *~ *\# \#* .\#* +rm -f include/*~ include/*\# include/\#* include/.\#* +rm -f libgdbwrap.a libgdbwrap.o *.o client +cc -Iinclude/ -Wall -g3 -ansi -pedantic -fprofile-generate -c -o gdbwrapper.o gdbwrapper.c +gdbwrapper.c: In function 'gdbwrap_make_message': +gdbwrapper.c:165: warning: implicit declaration of function 'snprintf' +ar rc libgdbwrap.a gdbwrapper.o +ranlib libgdbwrap.a +ld -r gdbwrapper.o -o libgdbwrap.o +cc client.c -Iinclude/ -Wall -g3 -ansi -pedantic -fprofile-generate libgdbwrap.a -o client + +[now the client is ready for the commands] + + +The warning is because it's compiling with the -pedantic -ansi +function and snprintf is a C99 function... (NB: ...that really sucks, cf +code). + +Now you're ready to play with the small client: + +-> hello (...server, how are you?) +-> dump +Reg 0 - 0 +Reg 1 - 0 +Reg 2 - 0 +Reg 3 - 0 +Reg 4 - 0 +Reg 5 - 0 +Reg 6 - 0 +Reg 7 - 0 +Reg 8 - 0 +Reg 9 - 0 +Reg 10 - 0 +Reg 11 - 0 +Reg 12 - 0 +Reg 13 - 0 +Reg 14 - 0 +Reg 15 - 0 +-> why (...did you halt ?) +-> dump +Reg 0 - 0 +Reg 1 - 0 +Reg 2 - 0 +Reg 3 - 0 +Reg 4 - 0xbfad8140 +Reg 5 - 0 +Reg 6 - 0 +Reg 7 - 0 +Reg 8 - 0xb7fc09a0 +Reg 9 - 0 +Reg 10 - 0 +Reg 11 - 0 +Reg 12 - 0 +Reg 13 - 0 +Reg 14 - 0 +Reg 15 - 0 +-> gpreg (...gimme the general purp reg state) +-> dump +Reg 0 - 0 +Reg 1 - 0 +Reg 2 - 0 +Reg 3 - 0 +Reg 4 - 0xbfad8140 +Reg 5 - 0 +Reg 6 - 0 +Reg 7 - 0 +Reg 8 - 0xb7fc09a0 +Reg 9 - 0x292 +Reg 10 - 0x73 +Reg 11 - 0x7b +Reg 12 - 0x7b +Reg 13 - 0x7b +Reg 14 - 0 +Reg 15 - 0 +-> stepi +-> dump +Reg 0 - 0 +Reg 1 - 0 +Reg 2 - 0 +Reg 3 - 0 +Reg 4 - 0xbfad8140 +Reg 5 - 0 +Reg 6 - 0 +Reg 7 - 0 +Reg 8 - 0xb7fc09a2 <--- this is the eip reg. It has been updated :) +Reg 9 - 0x292 +Reg 10 - 0x73 +Reg 11 - 0x7b +Reg 12 - 0x7b +Reg 13 - 0x7b +Reg 14 - 0 +Reg 15 - 0 + + +The correspondence between the numbers and the registers is: + + 00: eax; + 01: ecx; + 02: edx; + 03: ebx; + 04: esp; + 05: ebp; + 06: esi; + 07: edi; + 08: eip; + 09: eflags; + 10: cs; + 11: ss; + 12: ds; + 13: es; + 14: fs; + 15: gs; + + +The breakpoints are not implemented. The reason is that the gdb client +sets the breakpoint when resuming the program (ie cont) and I'm a bit afraid +that it'll cause an issue when porting it to eresi :/. + + +Thanks for trying it. + +camoroz0 diff -Nru eresi-0.8a25/libgdbwrap/gdbwrapper.c eresi-0.0.20110516/libgdbwrap/gdbwrapper.c --- eresi-0.8a25/libgdbwrap/gdbwrapper.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/gdbwrapper.c 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,1023 @@ +/** +* @file libgdbwrap/gdbwrapper.c + * @brief Implements the GDB serial protocol. + * @ingroup libgdbwrap + * + * $Id: gdbwrapper.c 1397 2009-09-13 02:19:08Z may $ + */ + +/* + * See gdb documentation, section D for more information on the + * remote serial protocol. To make it short, a packet looks like the following: + * + * $packet-data#checksum or $sequence-id:packet-data#checksum. + * + * where the checksum is the sum of all the characters modulo 256. + */ + +#include +#include "libaspect.h" +#include "gdbwrapper-internals.h" +#include "gdbwrapper.h" + +gdbwrapworld_t gdbwrapworld; + +/******************** Internal functions ********************/ + +static char *gdbwrap_lastmsg(gdbwrap_t *desc) +{ + return desc->packet; +} + + +static Bool gdbwrap_errorhandler(gdbwrap_t *desc, const char *error) +{ + ASSERT(desc != NULL && error != NULL); + + DEBUGMSG(printf("Treating error (encoded): %s\n", error)); + + if (!strncmp(GDBWRAP_REPLAY_OK, error, strlen(GDBWRAP_REPLAY_OK))) + { + desc->erroroccured = FALSE; + return FALSE; + } + + if (!strncmp(GDBWRAP_NO_SPACE, error, strlen(GDBWRAP_NO_SPACE))) + fprintf(stderr, "space was not updated.\n"); + + if (!strncmp(GDBWRAP_NO_TABLE, error, strlen(GDBWRAP_NO_TABLE))) + fprintf(stdout, "Not populating the table\n"); + + if (!strncmp(GDBWRAP_DEAD, error, strlen(GDBWRAP_DEAD))) + fprintf(stdout, "The server seems to be dead. Message not sent.\n"); + + if (error[0] == GDBWRAP_REPLAY_ERROR) + fprintf(stdout, "Error received from the server: %s\n", error); + + if (error[0] == GDBWRAP_EXIT_W_STATUS) + { + fprintf(stdout, "Exit with status: %s\n", error); + desc->is_active = FALSE; + } + + if (error[0] == GDBWRAP_EXIT_W_SIGNAL) + { + fprintf(stdout, "Exit with signal: %s\n", error); + desc->is_active = FALSE; + } + + desc->erroroccured = TRUE; + fflush(stdout); + return TRUE; +} + + +static Bool gdbwrap_is_interrupted(gdbwrap_t *desc) +{ + return desc->interrupted; +} + + +/** + * This function parses a string *strtoparse* starting at character + * *begin* and ending at character *end*. The new parsed string is + * saved in *strret*. If *begin* is not found in *strtoparse* then the + * function returns NULL. If *end* is not found in *strtoparse*, then + * the function returns NULL.. + * + * @param strtoparse: String to parse. + * @param strret : String to return without *begin* and *end*. + * @param begin : String where to start parsing. If NULL, + * we start from the beginning. + * @param end : String where to end parsing. If NULL, + * we copy the string from *begin* to then + * end of *strtoparse* (ie a NULL char is found). + * @param maxsize : The maximum size to extract. + * @return : Returns a pointer on the beginning of the new string. + */ +static char *gdbwrap_extract_from_packet(const char *strtoparse, + char *strret, + const char *begin, + const char *end, + int maxsize) +{ + const char *charbegin; + const char *charend; + unsigned strtorem; + ptrdiff_t strsize; + + ASSERT(strtoparse != NULL); + + if (begin == NULL) + { + charbegin = strtoparse; + strtorem = 0; + } + else + { + charbegin = strstr(strtoparse, begin); + strtorem = strlen(begin); + if (charbegin == NULL) + return NULL; + } + + if (end == NULL) + charend = charbegin + strlen(charbegin); + else + { + u_int off = (begin == NULL) ? 0 : strlen(begin); + + charend = strstr(charbegin + off, end); + if (charend == NULL) + return NULL; + } + + strsize = charend - charbegin - strtorem; + if (strsize > maxsize) + strsize = maxsize; + + strncpy(strret, charbegin + strtorem, strsize); + strret[strsize] = GDBWRAP_NULL_CHAR; + + return strret; +} + +static la32 gdbwrap_little_endian(la32 addr) +{ + la32 addrlittle = 0; + unsigned i; + + for (i = 0; addr > 0; i++) + { + addrlittle += (LOBYTE(addr) << (BYTE_IN_BIT * (sizeof(addr) - 1 - i))); + addr >>= BYTE_IN_BIT; + } + + return addrlittle; +} + + +static uint8_t gdbwrap_calc_checksum(gdbwrap_t *desc, const char *str) +{ + unsigned i; + uint8_t sum; + char *result; + + result = gdbwrap_extract_from_packet(str, desc->packet, GDBWRAP_BEGIN_PACKET, + GDBWRAP_END_PACKET, + desc->max_packet_size); + + /* If result == NULL, it's not a packet. */ + if (result == NULL) + result = gdbwrap_extract_from_packet(str, desc->packet, NULL, NULL, + desc->max_packet_size); + + for (i = 0, sum = 0; i < strlen(result); i++) + sum += result[i]; + + return sum; +} + + +static char *gdbwrap_make_message(gdbwrap_t *desc, const char *query) +{ + uint8_t checksum = gdbwrap_calc_checksum(desc, query); + unsigned max_query_size = (desc->max_packet_size - + strlen(GDBWRAP_BEGIN_PACKET) + - strlen(GDBWRAP_END_PACKET) + - sizeof(checksum)); + + /* Sometimes C sucks... Basic source and destination checking. We do + not check the overlapping tho.*/ + if (strlen(query) < max_query_size && query != desc->packet) + { + u_char ret; + ret = snprintf(desc->packet, desc->max_packet_size, "%s%s%s%.2x", + GDBWRAP_BEGIN_PACKET, query, GDBWRAP_END_PACKET, checksum); + ASSERT(ret > 0); + } + else + { + ASSERT(FALSE); + } + + return desc->packet; +} + + +/** + * This function performes a run-length decoding and writes back to + * *dstpacket*, but no more than *maxsize* bytes. + * + * @param srcpacket: the encoded packet. + * @param maxsize: the maximal size of the decoded packet. + */ +static char *gdbwrap_run_length_decode(char *dstpacket, const char *srcpacket, + unsigned maxsize) +{ + /* Protocol specifies to take the following value and substract 29 + and repeat by this number the previous character. Note that the + compression may be used multiple times in a packet. */ + char *encodestr; + char valuetocopy; + uint8_t numberoftimes; + unsigned iter; + unsigned strlenc; + unsigned check; + + ASSERT(dstpacket != NULL && srcpacket != NULL && + srcpacket[0] != GDBWRAP_START_ENCODC); + if (srcpacket != dstpacket) + strncpy(dstpacket, srcpacket, maxsize); + encodestr = strstr(dstpacket, GDBWRAP_START_ENCOD); + check = strlen(dstpacket); + while (encodestr != NULL) + { + /* This is OK to take encodestr[-1], since we + assert(srcpacket[0] != GDBWRAP_START_ENCODC). */ + valuetocopy = encodestr[-1]; + numberoftimes = encodestr[1] - 29; + ASSERT((check += numberoftimes) < maxsize); + strlenc = strlen(encodestr); + /* We move the string to the right, then set the bytes. We + substract 2, because we have * where * and + are filled with the value of (ie 2 chars). */ + for (iter = 0; iter < strlenc; iter++) + encodestr[strlenc + numberoftimes - iter - 2] = encodestr[strlenc - iter]; + memset(encodestr, valuetocopy, numberoftimes); + encodestr = strstr(NEXT_CHAR(encodestr), GDBWRAP_START_ENCOD); + } + + return dstpacket; +} + + +/** + * Populate the gdb registers with the values received in the + * packet. A packet has the following form: + * + * $n:r;[n:r;]#checksum + * + * where n can be a number (the register), or "thread" and r is the + * value of the thread/register. + * + * @param packet: the packet to parse. + * @param reg : the structure in which we want to write the registers. + */ +static void gdbwrap_populate_reg(gdbwrap_t *desc, char *packet) +{ + const char *nextpacket; + char *nextupacket; + char packetsemicolon[MSG_BUF]; + char packetcolon[MSG_BUF]; + unsigned packetoffset = 0; + + /* If a signal is received, we populate the registers, starting + after the signal number (ie after Tnn, where nn is the + number). */ + if (packet[0] == GDBWRAP_SIGNAL_RECV) + packetoffset = 3; + + while ((nextpacket = + gdbwrap_extract_from_packet(packet + packetoffset, + packetsemicolon, + NULL, + GDBWRAP_SEP_SEMICOLON, + sizeof(packetsemicolon))) != NULL) + { + nextupacket = gdbwrap_extract_from_packet(nextpacket, packetcolon, NULL, + GDBWRAP_SEP_COLON, + sizeof(packetcolon)); + ASSERT(nextupacket != NULL); + if (strlen(nextupacket) == 2) + { + uint8_t regnumber = gdbwrap_atoh(nextupacket, strlen(nextupacket)); + ureg32 regvalue; + + nextupacket = gdbwrap_extract_from_packet(nextpacket, packetcolon, + GDBWRAP_SEP_COLON, NULL, + sizeof(packetcolon)); + ASSERT(nextupacket != NULL); + regvalue = gdbwrap_atoh(nextupacket, strlen(nextupacket)); + regvalue = gdbwrap_little_endian(regvalue); + + *(&desc->reg32.eax + regnumber) = regvalue; + } + /* We add 1 in order not to take the right limit. In the worst + case, we should get the NULL char. */ + packetoffset += strlen(nextpacket) + 1; + } +} + + +static void gdbwrap_send_ack(gdbwrap_t *desc) +{ + send(desc->fd, GDBWRAP_COR_CHECKSUM, strlen(GDBWRAP_COR_CHECKSUM), 0x0); +} + + +static Bool gdbwrap_check_ack(gdbwrap_t *desc) +{ + int rval; + + rval = recv(desc->fd, desc->packet, 1, 0); + /* The result of the previous recv must be a "+". */ + if (!rval) + desc->is_active = FALSE; + if (desc->packet[0] == GDBWRAP_COR_CHECKSUMC && rval != -1) + return TRUE; + else + if (desc->packet[0] != GDBWRAP_BAD_CHECKSUM) + return FALSE; + else + { + fprintf(stderr, "The server has NOT sent any ACK." + "It probably does not follow exactly the gdb protocol (%s - %d).\n", + desc->packet, rval); + return FALSE; + } +} + + +static char *gdbwrap_get_packet(gdbwrap_t *desc) +{ + int rval; + int sumrval; + char checksum[3]; + + ASSERT(desc != NULL); + + desc->packet[0] = GDBWRAP_NULL_CHAR; + rval = -1; + sumrval = 0; + do + { + /* In case the packet is splitted into many others. */ + rval = recv(desc->fd, desc->packet + sumrval, desc->max_packet_size, 0); + sumrval += rval; + if (errno == EINTR) + break; + } while (sumrval >= 3 && + desc->packet[sumrval - 3] != GDBWRAP_END_PACKETC && rval); + + + /* if rval == 0, it means the host is disconnected/dead. */ + if (rval) + { + desc->packet[sumrval] = GDBWRAP_NULL_CHAR; + gdbwrap_extract_from_packet(desc->packet, checksum, GDBWRAP_END_PACKET, + NULL, sizeof(checksum)); + /* If no error, we ack the packet. */ + if (rval != -1 && + gdbwrap_atoh(checksum, strlen(checksum)) == + gdbwrap_calc_checksum(desc, desc->packet)) + { + gdbwrap_send_ack(desc); + gdbwrap_errorhandler(desc, desc->packet); + return gdbwrap_run_length_decode(desc->packet, desc->packet, + desc->max_packet_size); + } + else + { + DEBUGMSG(printf("received : %s, checksum: %#x, calulated: %#x\n", + desc->packet, + gdbwrap_atoh(checksum, strlen(checksum)), + gdbwrap_calc_checksum(desc, desc->packet))); + if (gdbwrap_is_interrupted(desc)) + { + desc->interrupted = FALSE; + gdbwrap_errorhandler(desc, desc->packet); + return gdbwrap_run_length_decode(desc->packet, desc->packet, + desc->max_packet_size); + } + else + { + fprintf(stderr, "Muh ?\n"); + return NULL; + } + } + } + else desc->is_active = FALSE; + + return NULL; +} + + +static char *gdbwrap_send_data(gdbwrap_t *desc, const char *query) +{ + int rval = 0; + char *mes; + + ASSERT(desc != NULL && query != NULL); + + DEBUGMSG(printf("Sending: %s\n", query)); + + if (gdbwrap_is_active(desc)) + { + do + { + mes = gdbwrap_make_message(desc, query); + rval = send(desc->fd, mes, strlen(mes), 0); + } while(gdbwrap_check_ack(desc) != TRUE); + + ASSERT(rval != -1); + mes = gdbwrap_get_packet(desc); + DEBUGMSG(printf("Received: %s\n", mes)); + } + else + { + gdbwrap_errorhandler(desc, GDBWRAP_DEAD); + mes = NULL; + } + + return mes; +} + + +/******************** External functions ********************/ + + +/** + * Returns the last signal. We return the signal number or 0 if no + * signal was returned. + **/ +unsigned gdbwrap_lastsignal(gdbwrap_t *desc) +{ + unsigned ret = 0; + char *lastmsg = gdbwrap_lastmsg(desc); + + /* When we receive a packet starting with GDBWRAP_SIGNAL_RECV, the + next 2 characters reprensent the signal number. */ + if (lastmsg != NULL && (lastmsg[0] == GDBWRAP_SIGNAL_RECV || + lastmsg[0] == GDBWRAP_SIGNAL_RECV2)) + ret = gdbwrap_atoh(lastmsg + 1, BYTE_IN_CHAR * sizeof(char)); + + return ret; +} + + +u_char gdbwrap_lasterror(gdbwrap_t *desc) +{ + u_char ret = 0; + char *lastmsg = gdbwrap_lastmsg(desc); + + /* When we receive a packet starting with GDBWRAP_SIGNAL_RECV, the + next 2 characters reprensent the signal number. */ + if (lastmsg != NULL && lastmsg[0] == GDBWRAP_REPLAY_ERROR) + ret = gdbwrap_atoh(lastmsg + 1, BYTE_IN_CHAR * sizeof(char)); + + return ret; +} + + +Bool gdbwrap_is_active(gdbwrap_t *desc) +{ + if (desc->is_active) + return TRUE; + else + return FALSE; +} + + +/* If the last command is not supported, we return TRUE. */ +Bool gdbwrap_cmdnotsup(gdbwrap_t *desc) +{ + char *lastmsg = gdbwrap_lastmsg(desc); + + if (lastmsg[0] == GDBWRAP_NULL_CHAR) + return TRUE; + else + return FALSE; +} + + +Bool gdbwrap_erroroccured(gdbwrap_t *desc) +{ + return desc->erroroccured; +} + + +unsigned gdbwrap_atoh(const char *str, unsigned size) +{ + unsigned i; + unsigned hex; + + for (i = 0, hex = 0; i < size; i++) + if (str != NULL && str[i] >= 'A' && str[i] <= 'F') + hex += (str[i] - 0x37) << 4 * (size - i - 1); + else if (str != NULL && str[i] >= 'a' && str[i] <= 'f') + hex += (str[i] - 0x57) << 4 * (size - i - 1); + else if (str != NULL && str[i] >= '0' && str[i] <= '9') + hex += (str[i] - 0x30) << 4 * (size - i - 1); + else + return 0; + + return hex; +} + + + + +/** + * Set/Get the gdbwrapworld variable. It's not mandatory to use the + * other functions, but sometimes a global variable is required. + */ +gdbwrapworld_t gdbwrap_current_set(gdbwrap_t *world) +{ + gdbwrapworld.gdbwrapptr = world; + + return gdbwrapworld; +} + + +gdbwrap_t *gdbwrap_current_get(void) +{ + return gdbwrapworld.gdbwrapptr; +} + + +/** + * Initialize the descriptor. We provide a default value of 1000B for + * the string that get the replies from server. + * + */ +gdbwrap_t *gdbwrap_init(int fd) +{ + gdbwrap_t *desc = malloc(sizeof(gdbwrap_t)); + + ASSERT(fd && desc != NULL); + desc->max_packet_size = 2500; + desc->packet = malloc((desc->max_packet_size + 1) * sizeof(char)); + desc->fd = fd; + desc->is_active = TRUE; + desc->interrupted = FALSE; + ASSERT(desc->packet != NULL); + + return desc; +} + + +void gdbwrap_close(gdbwrap_t *desc) +{ + ASSERT(desc != NULL && desc->packet != NULL); + free(desc->packet); + free(desc); +} + + +/** + * Initialize a connection with the gdb server and allocate more + * memory for packets if necessary. + * + */ +void gdbwrap_hello(gdbwrap_t *desc) +{ + char *received = NULL; + char *result = NULL; + unsigned previousmax = 0; + + received = gdbwrap_send_data(desc, GDBWRAP_QSUPPORTED); + + if (received != NULL) + { + result = gdbwrap_extract_from_packet(received, desc->packet, + GDBWRAP_PACKETSIZE, + GDBWRAP_SEP_SEMICOLON, + desc->max_packet_size); + + /* If we receive the info, we update gdbwrap_max_packet_size. */ + if (result != NULL) + { + char *reallocptr; + + previousmax = desc->max_packet_size; + desc->max_packet_size = gdbwrap_atoh(desc->packet, strlen(desc->packet)); + reallocptr = realloc(desc->packet, desc->max_packet_size + 1); + if (reallocptr != NULL) + desc->packet = reallocptr; + else + { + gdbwrap_errorhandler(desc, GDBWRAP_NO_SPACE); + desc->max_packet_size = previousmax; + } + } + /* We set the last bit to a NULL char to avoid getting out of the + weeds with a (unlikely) bad strlen. */ + desc->packet[desc->max_packet_size] = GDBWRAP_NULL_CHAR; + } +} + + +/** + * Send a "disconnect" command to the server and free the packet. + */ +void gdbwrap_bye(gdbwrap_t *desc) +{ + assert(desc != NULL); + gdbwrap_send_data(desc, GDBWRAP_DISCONNECT); + printf("\nThx for using gdbwrap :)\n"); +} + + +void gdbwrap_reason_halted(gdbwrap_t *desc) +{ + char *received; + + received = gdbwrap_send_data(desc, GDBWRAP_WHY_HALTED); + if (gdbwrap_is_active(desc)) + gdbwrap_populate_reg(desc, received); + else + gdbwrap_errorhandler(desc, GDBWRAP_NO_TABLE); +} + + +/** + * Great, the gdb protocol has absolutely no consistency, thus we + * cannot reuse the gdbwrap_populate_reg. We receive a poorly + * documented bulk message when sending the "g" query. + */ +gdbwrap_gdbreg32 *gdbwrap_readgenreg(gdbwrap_t *desc) +{ + char *rec; + unsigned i; + ureg32 regvalue; + + rec = gdbwrap_send_data(desc, GDBWRAP_GENPURPREG); + if (gdbwrap_is_active(desc)) + { + for (i = 0; i < sizeof(gdbwrap_gdbreg32) / sizeof(ureg32); i++) + { + /* 1B = 2 characters */ + regvalue = gdbwrap_atoh(rec, 2 * DWORD_IN_BYTE); + regvalue = gdbwrap_little_endian(regvalue); + *(&desc->reg32.eax + i) = regvalue; + rec += 2 * DWORD_IN_BYTE; + } + + return &desc->reg32; + } + else + return NULL; +} + + +void gdbwrap_continue(gdbwrap_t *desc) +{ + char *rec; + + if (gdbwrap_is_active(desc)) + { + rec = gdbwrap_send_data(desc, GDBWRAP_CONTINUE); + if (rec != NULL && gdbwrap_is_active(desc)) + gdbwrap_populate_reg(desc, rec); + } +} + + +/** + * Set a breakpoint. We read the value in memory, save it and write a + * 0xcc in replacement. The usual command to set a bp is not supported + * by the gdbserver. + */ +void gdbwrap_setbp(gdbwrap_t *desc, la32 linaddr, void *datasaved) +{ + u_char bp = 0xcc; + char *ret; + unsigned atohresult; + + ASSERT(desc != NULL && desc != datasaved); + ret = gdbwrap_readmem(desc, linaddr, 1); + /* Fix: not clean. ATOH is not clean when returning an unsigned. */ + atohresult = gdbwrap_atoh(ret, 2 * 1); + memcpy(datasaved, &atohresult, 1); + gdbwrap_writemem(desc, linaddr, &bp, sizeof(u_char)); +} + + +void gdbwrap_simplesetbp(gdbwrap_t *desc, la32 linaddr) +{ + char packet[MSG_BUF]; + + snprintf(packet, sizeof(packet), "%s%s%x%s%x", GDBWRAP_INSERTBP, + GDBWRAP_SEP_COMMA, linaddr, GDBWRAP_SEP_COMMA, 0x1); + gdbwrap_send_data(desc, packet); +} + + +void gdbwrap_delbp(gdbwrap_t *desc, la32 linaddr, void *datasaved) +{ + gdbwrap_writemem(desc, linaddr, datasaved, sizeof(u_char)); +} + + +void gdbwrap_simpledelbp(gdbwrap_t *desc, la32 linaddr) +{ + char packet[MSG_BUF]; + + snprintf(packet, sizeof(packet), "%s%s%x%s%x", GDBWRAP_REMOVEBP, + GDBWRAP_SEP_COMMA, linaddr, GDBWRAP_SEP_COMMA, 0x1); + gdbwrap_send_data(desc, packet); +} + + +char *gdbwrap_readmem(gdbwrap_t *desc, la32 linaddr, + unsigned bytes) +{ + char *rec; + char packet[MSG_BUF]; + + snprintf(packet, sizeof(packet), "%s%x%s%x", GDBWRAP_MEMCONTENT, + linaddr, GDBWRAP_SEP_COMMA, bytes); + rec = gdbwrap_send_data(desc, packet); + + return rec; +} + + +static void *gdbwrap_writememory(gdbwrap_t *desc, la32 linaddr, + void *value, unsigned bytes) +{ + uint8_t packetsize; + char *rec; + char *packet = alloca(bytes + MSG_BUF); + + ASSERT(desc != NULL && value != NULL); + snprintf(packet, MSG_BUF, "%s%x%s%x%s", GDBWRAP_MEMWRITE, + linaddr, GDBWRAP_SEP_COMMA, bytes, GDBWRAP_SEP_COLON); + packetsize = strlen(packet); + ASSERT(packetsize < MSG_BUF); + /* GDB protocol expects the value we send to be a "Binary value", ie + not converted to a char. */ + memcpy(packet + packetsize, value, bytes); + packet[packetsize + bytes] = GDBWRAP_NULL_CHAR; + rec = gdbwrap_send_data(desc, packet); + + return rec; +} + + +static void *gdbwrap_writememory2(gdbwrap_t *desc, la32 linaddr, + void *value, unsigned bytes) +{ + char *rec; + char *packet = alloca(2 * bytes + MSG_BUF); + u_char *val = value; + u_short i; + u_int len; + + snprintf(packet, MSG_BUF, "%s%x%s%x%s", GDBWRAP_MEMWRITE2, + linaddr, GDBWRAP_SEP_COMMA, bytes, GDBWRAP_SEP_COLON); + + for (i = 0; i < bytes; i++) + { + len = strlen(packet); + ASSERT(len + 1 < 2 * bytes + MSG_BUF); + snprintf(packet + len, BYTE_IN_CHAR + 1, "%02x", (unsigned)val[i]); + } + rec = gdbwrap_send_data(desc, packet); + + return rec; +} + + +void gdbwrap_writemem(gdbwrap_t *desc, la32 linaddr, + void *value, unsigned bytes) +{ + static u_char choice = 0; + + if (bytes) + { + do + { + switch (choice) + { + case 0: + gdbwrap_writememory(desc, linaddr, value, bytes); + if (gdbwrap_cmdnotsup(desc)) + choice++; + break; + + case 1: + gdbwrap_writememory2(desc, linaddr, value, bytes); + if (gdbwrap_cmdnotsup(desc)) + choice++; + break; + + default: + fprintf(stderr, "[W] Write to memory not supported.\n"); + break; + } + } while (gdbwrap_cmdnotsup(desc) && choice < 2); + } +} + + +/** + * Write a specific register. This command seems not to be supported + * by the gdbserver. See gdbwrap_writereg2. + */ +static void gdbwrap_writeregister(gdbwrap_t *desc, ureg32 regNum, + la32 val) +{ + char regpacket[MSG_BUF]; + + ASSERT(desc != NULL); + snprintf(regpacket, sizeof(regpacket), "%s%x=%x", + GDBWRAP_WRITEREG, regNum, val); + gdbwrap_send_data(desc, regpacket); +} + + +static void gdbwrap_writeregister2(gdbwrap_t *desc, ureg32 regNum, + la32 val) +{ + char *ret; + gdbwrap_gdbreg32 *reg; + unsigned offset; + char locreg[700]; + + offset = 2 * regNum * sizeof(ureg32); + + ASSERT(desc != NULL && (regNum < sizeof(gdbwrap_gdbreg32) / sizeof(ureg32)) && + offset + 2 * sizeof(ureg32) < desc->max_packet_size); + reg = gdbwrap_readgenreg(desc); + ret = gdbwrap_lastmsg(desc); + ASSERT(reg != NULL && ret != NULL); + + snprintf(locreg, sizeof(locreg), "%08x", gdbwrap_little_endian(val)); + memcpy(ret + offset, locreg, 2 * sizeof(ureg32)); + snprintf(locreg, sizeof(locreg), "%s%s", GDBWRAP_WGENPURPREG, ret); + gdbwrap_send_data(desc, locreg); +} + + +void gdbwrap_writereg(gdbwrap_t *desc, ureg32 regnum, la32 val) +{ + static u_char choice = 0; + + do + { + switch (choice) + { + case 0: + gdbwrap_writeregister(desc, regnum, val); + if (gdbwrap_cmdnotsup(desc)) + choice++; + break; + + case 1: + gdbwrap_writeregister2(desc, regnum, val); + if (gdbwrap_cmdnotsup(desc)) + choice++; + break; + + default: + fprintf(stderr, "[W] Write to registers not supported.\n"); + break; + } + } while (gdbwrap_cmdnotsup(desc) && choice < 2); + + if (choice < 2) + *(&desc->reg32.eax + regnum) = val; +} + + +/** + * Ship all the registers to the server in only 1 query. This is used + * when modifying multiple registers at once for example. + */ +char *gdbwrap_shipallreg(gdbwrap_t *desc) +{ + gdbwrap_gdbreg32 savedregs; + char *ret; + char locreg[700]; + uint8_t i; + + ASSERT(desc != NULL); + memcpy(&savedregs, &desc->reg32, sizeof(gdbwrap_gdbreg32)); + + gdbwrap_readgenreg(desc); + ret = gdbwrap_lastmsg(desc); + + /* We modify the 9 GPR only and we copy the rest from the gpr + request. */ + for (i = 0; i < 9; i++) + snprintf(locreg + i * 2 * sizeof(ureg32), 2 * sizeof(ureg32) + 1, + "%08x", gdbwrap_little_endian(*(&savedregs.eax + i))); + ASSERT(strlen(locreg) < desc->max_packet_size); + memcpy(ret, locreg, strlen(locreg)); + snprintf(locreg, sizeof(locreg), "%s%s", GDBWRAP_WGENPURPREG, ret); + + return gdbwrap_send_data(desc, locreg); +} + + +void gdbwrap_ctrl_c(gdbwrap_t *desc) +{ + u_char sended = CTRL_C; + int rval; + + ASSERT(desc != NULL); + desc->interrupted = TRUE; + send(desc->fd, &sended, sizeof(u_char), 0); + rval = recv(desc->fd, desc->packet, desc->max_packet_size, 0); + gdbwrap_populate_reg(desc, desc->packet); + rval = send(desc->fd, GDBWRAP_COR_CHECKSUM, strlen(GDBWRAP_COR_CHECKSUM), + 0x0); + ASSERT(rval); +} + + +/** + * Here's the format of a signal: + * + * $vCont;C[:process_pid]# + * + * Note that que process pid can be retrieved with a "X" command. If + * process_pid is omited, then we apply to the current process + * (default behavior). + */ +void gdbwrap_signal(gdbwrap_t *desc, int signal) +{ + char *rec; + char signalpacket[MSG_BUF]; + + ASSERT(desc != NULL); + snprintf(signalpacket, sizeof(signalpacket), "%s;C%.2x", + GDBWRAP_CONTINUEWITH, signal); + rec = gdbwrap_send_data(desc, signalpacket); +} + + +void gdbwrap_stepi(gdbwrap_t *desc) +{ + char *rec; + + ASSERT(desc != NULL); + rec = gdbwrap_send_data(desc, GDBWRAP_STEPI); + + if (gdbwrap_is_active(desc)) + gdbwrap_populate_reg(desc, rec); + else + gdbwrap_errorhandler(desc, GDBWRAP_DEAD); +} + + +/** + * Sends a custom remote command. This heavily depends on the + * server. We "transform" the char into its corresponding ASCII code + * (in char). + * @param: cmd the command to send, in clear text. + **/ +char *gdbwrap_remotecmd(gdbwrap_t *desc, char *cmd) +{ + char signalpacket[MSG_BUF]; + char cmdcpy[MSG_BUF]; + char *ret; + uint8_t i; + uint8_t rval; + + ASSERT(desc != NULL && cmd != NULL); + /* We jump 2 in 2 chars, since 1B = 2chars. */ + for (i = 0; i < sizeof(cmdcpy) && cmd[i] != GDBWRAP_NULL_CHAR; i++) + snprintf(cmdcpy + BYTE_IN_CHAR * i, BYTE_IN_CHAR + sizeof(GDBWRAP_NULL_CHAR), + "%02x", cmd[i]); + + snprintf(signalpacket, sizeof(signalpacket), "%s%s%s", + GDBWRAP_RCMD, GDBWRAP_SEP_COMMA, cmdcpy); + ret = gdbwrap_send_data(desc, signalpacket); + /* If we have a new line, it meens the packet is not finished (to + prove...), we listen to the next incoming packet, which is an + OK. */ + if (ret != NULL && gdbwrap_atoh(ret + strlen(ret) - 2, BYTE_IN_CHAR) == 0xa) + { + gdbwrap_send_ack(desc); + rval = recv(desc->fd, cmdcpy, sizeof(cmdcpy), 0); + } + + return ret; +} + +/** + * Get a memory map from the gdb server and + * and return the information parsed on a gdbmemap_t. + * + */ +gdbmemap_t gdbwrap_memorymap_get(gdbwrap_t *desc) +{ + char qXfer_msg[30]; //msg size + gdbmemap_t result; + char *received = NULL; + + snprintf(qXfer_msg, sizeof(qXfer_msg), "%s::%d,%d", + GDBWRAP_MEMORYMAP_READ, 0, 0xfff); + + received = gdbwrap_send_data(desc, qXfer_msg); + + if (received != NULL) + { + //XXX: parse it and return gdbmemap_t + } + + return result; +} diff -Nru eresi-0.8a25/libgdbwrap/include/gdbwrapper.h eresi-0.0.20110516/libgdbwrap/include/gdbwrapper.h --- eresi-0.8a25/libgdbwrap/include/gdbwrapper.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/include/gdbwrapper.h 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,102 @@ +/** +* @file libgdbwrap/include/gdbwrapper.h + * @ingroup libgdbwrap + * @brief Header file for the ERESI gdb protocol wrapper. + * + * $Id: gdbwrapper.h 1397 2009-09-13 02:19:08Z may $ + */ +#if !defined(__GDBWRAPPER_H__) + #define __GDBWRAPPER_H__ + +#include +#include +#include +#include +#include "libaspect.h" + +typedef struct gdbwrap_gdbreg32 +{ + ureg32 eax; + ureg32 ecx; + ureg32 edx; + ureg32 ebx; + ureg32 esp; + ureg32 ebp; + ureg32 esi; + ureg32 edi; + ureg32 eip; + ureg32 eflags; + ureg32 cs; + ureg32 ss; + ureg32 ds; + ureg32 es; + ureg32 fs; + ureg32 gs; +} gdbwrap_gdbreg32; + + +typedef struct gdbwrap_t +{ + char *packet; + int fd; + unsigned max_packet_size; + gdbwrap_gdbreg32 reg32; + Bool is_active; + Bool erroroccured; + Bool interrupted; + Bool pmode; +} gdbwrap_t; + +typedef struct meminfo_t +{ + char *type; + u_int start; + u_int length; + u_int blocksize; +} meminfo_t; + +typedef struct gdbmemap_t +{ + meminfo_t ram; + meminfo_t rom; + meminfo_t flash; +} gdbmemap_t; + + +typedef struct +{ + gdbwrap_t *gdbwrapptr; +} gdbwrapworld_t; + +Bool gdbwrap_erroroccured(gdbwrap_t *desc); +Bool gdbwrap_cmdnotsup(gdbwrap_t *desc); +unsigned gdbwrap_atoh(const char * str, unsigned size); +unsigned gdbwrap_lastsignal(gdbwrap_t *desc); +Bool gdbwrap_is_active(gdbwrap_t *desc); +gdbwrapworld_t gdbwrap_current_set(gdbwrap_t *world); +gdbwrap_t *gdbwrap_current_get(void); +gdbwrap_t *gdbwrap_init(int fd); +void gdbwrap_close(gdbwrap_t *desc); +void gdbwrap_hello(gdbwrap_t *desc); +void gdbwrap_bye(gdbwrap_t *desc); +void gdbwrap_reason_halted(gdbwrap_t *desc); +char *gdbwrap_own_command(gdbwrap_t *desc, char *command); +gdbwrap_gdbreg32 *gdbwrap_readgenreg(gdbwrap_t *desc); +void gdbwrap_continue(gdbwrap_t *desc); +void gdbwrap_setbp(gdbwrap_t *desc, la32 linaddr, void *datasaved); +void gdbwrap_simplesetbp(gdbwrap_t *desc, la32 linaddr); +void gdbwrap_delbp(gdbwrap_t *desc, la32 linaddr, void *datasaved); +void gdbwrap_simpledelbp(gdbwrap_t *desc, la32 linaddr); +char *gdbwrap_readmem(gdbwrap_t *desc, la32 linaddr, unsigned bytes); +void gdbwrap_writemem(gdbwrap_t *desc, la32 linaddr, void *value, + unsigned bytes); +void gdbwrap_writereg(gdbwrap_t *desc, ureg32 regnum, la32 val); +char *gdbwrap_shipallreg(gdbwrap_t *desc); +void gdbwrap_ctrl_c(gdbwrap_t *desc); +void gdbwrap_signal(gdbwrap_t *desc, int signal); +void gdbwrap_stepi(gdbwrap_t *desc); +char *gdbwrap_remotecmd(gdbwrap_t *desc, char *cmd); +u_char gdbwrap_lasterror(gdbwrap_t *desc); +gdbmemap_t gdbwrap_memorymap_get(); + +#endif diff -Nru eresi-0.8a25/libgdbwrap/include/gdbwrapper-internals.h eresi-0.0.20110516/libgdbwrap/include/gdbwrapper-internals.h --- eresi-0.8a25/libgdbwrap/include/gdbwrapper-internals.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/include/gdbwrapper-internals.h 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,67 @@ + +/* This file is for the gdb wrapper internals. It is not meant to be + included. */ + +#define GDBWRAP_PACKET_NO_BEGIN(_tocmp, _ptr) \ + assert(_tocmp); \ + _ptr = (strstr(_tocmp, GDBWRAP_BEGIN_PACKET) + 1) + +#define __DEBUG_GDBWRAP__ FALSE +#define MSG_BUF 80 + +#if __DEBUG_GDBWRAP__ +#define DEBUGMSG(_command) \ + do \ + { \ + _command; \ + } while(0) +#else +#define DEBUGMSG(_command) +#endif + +#define CONSTSTRDEC(_name, _value) const char * const _name = _value +#define CONSTCHRDEC(_name, _value) const char _name = _value +#define CTRL_C 0x3 +CONSTSTRDEC(GDBWRAP_BEGIN_PACKET, "$"); +CONSTSTRDEC(GDBWRAP_END_PACKET, "#"); +CONSTSTRDEC(GDBWRAP_QSUPPORTED, "qSupported"); +CONSTSTRDEC(GDBWRAP_DISCONNECT, "k"); +CONSTSTRDEC(GDBWRAP_CONTINUEWITH, "vCont"); +CONSTSTRDEC(GDBWRAP_CONTINUE, "c"); //"vCont;c"); +CONSTSTRDEC(GDBWRAP_SIGNAL, "C"); +CONSTSTRDEC(GDBWRAP_GENPURPREG, "g"); +CONSTSTRDEC(GDBWRAP_WGENPURPREG, "G"); +CONSTSTRDEC(GDBWRAP_MEMCONTENT, "m"); +CONSTSTRDEC(GDBWRAP_MEMWRITE, "X"); +CONSTSTRDEC(GDBWRAP_MEMWRITE2, "M"); +CONSTSTRDEC(GDBWRAP_INSERTBP, "Z0"); +CONSTSTRDEC(GDBWRAP_REMOVEBP, "z0"); +CONSTSTRDEC(GDBWRAP_STEPI, "s"); +CONSTSTRDEC(GDBWRAP_WRITEREG, "P"); +CONSTSTRDEC(GDBWRAP_ERROR, "E"); +CONSTSTRDEC(GDBWRAP_COR_CHECKSUM, "+"); +CONSTSTRDEC(GDBWRAP_WHY_HALTED, "?"); +CONSTSTRDEC(GDBWRAP_START_ENCOD, "*"); +CONSTSTRDEC(GDBWRAP_SEP_COLON, ":"); +CONSTSTRDEC(GDBWRAP_SEP_SEMICOLON, ";"); +CONSTSTRDEC(GDBWRAP_SEP_COMMA, ","); +CONSTSTRDEC(GDBWRAP_RCMD, "qRcmd"); +CONSTSTRDEC(GDBWRAP_PACKETSIZE, "PacketSize="); +CONSTSTRDEC(GDBWRAP_REPLAY_OK, "OK"); +CONSTSTRDEC(GDBWRAP_NO_SPACE, "nospace"); +CONSTSTRDEC(GDBWRAP_NO_TABLE, "notable"); +CONSTSTRDEC(GDBWRAP_DEAD, "dead"); +CONSTSTRDEC(GDBWRAP_MEMORYMAP_READ, "qXfer:memory-map:read"); + +CONSTCHRDEC(GDBWRAP_NULL_CHAR, '\0'); +CONSTCHRDEC(GDBWRAP_REPLAY_ERROR, 'E'); +CONSTCHRDEC(GDBWRAP_SIGNAL_RECV, 'T'); +CONSTCHRDEC(GDBWRAP_SIGNAL_RECV2, 'S'); +CONSTCHRDEC(GDBWRAP_EXIT_W_STATUS, 'W'); +CONSTCHRDEC(GDBWRAP_EXIT_W_SIGNAL, 'X'); +CONSTCHRDEC(GDBWRAP_END_PACKETC, '#'); +CONSTCHRDEC(GDBWRAP_START_ENCODC, '*'); +CONSTCHRDEC(GDBWRAP_COR_CHECKSUMC, '+'); +CONSTCHRDEC(GDBWRAP_BAD_CHECKSUM, '-'); + +extern int errno; diff -Nru eresi-0.8a25/libgdbwrap/interface.c eresi-0.0.20110516/libgdbwrap/interface.c --- eresi-0.8a25/libgdbwrap/interface.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/interface.c 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,56 @@ +/** + * @defgroup libgdbwrap libgdbwrap: The ERESI library implementing the GDB protocol. + * @ingroup kedbg + */ +/** +* @file libgdbwrap/interface.c + * @brief Implements initial connection to the GDB server. + * @ingroup libgdbwrap + * + * $Id: interface.c 1397 2009-09-13 02:19:08Z may $ + */ +#include "gdbwrapper.h" + + +int gdbwrap_simpleconnect(char *host, int port) +{ + int rval; + int sd; + struct sockaddr_in socketaddr; + struct hostent *hostaddr; + struct protoent *protocol; + extern int h_errno; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + hostaddr = gethostbyname(host); + protocol = getprotobyname("tcp"); + + if (!hostaddr || h_errno == HOST_NOT_FOUND) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid gethostbyname", -1); + + if (!port) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid port", -1); + + if (!protocol) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid getprotobyname()", + -1); + + sd = socket(PF_INET, SOCK_STREAM, protocol->p_proto); + + if (sd == -1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "invalid socket", -1); + + memset(&socketaddr, 0, sizeof(socketaddr)); + socketaddr.sin_family = AF_INET; + socketaddr.sin_port = htons(port); + + memcpy(&socketaddr.sin_addr, hostaddr->h_addr, hostaddr->h_length); + rval = connect(sd, (struct sockaddr *)&socketaddr, sizeof(socketaddr)); + + if (rval == -1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Problem when connecting", + -1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sd); +} diff -Nru eresi-0.8a25/libgdbwrap/Makefile eresi-0.0.20110516/libgdbwrap/Makefile --- eresi-0.8a25/libgdbwrap/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libgdbwrap/Makefile 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,49 @@ +include ../config.h + +SRC = gdbwrapper.c interface.c + +OBJ32 = $(SRC:.c=.32.o) +CFLAGS32 += -Wpointer-arith -Wextra -fPIC -g3 -Wall -Iinclude/ $(DYNOPT) $(BUILDOP) \ + -I../libgdbwrap/include/ -I../libaspect/include/ -DERESI32 +LDFLAGS32 += -L../libaspect/ -laspect32 + +OBJ64 = $(SRC:.c=.64.o) +CFLAGS64 += -Wpointer-arith -Wextra -fPIC -g3 -Wall -Iinclude/ $(DYNOPT) $(BUILDOP) \ + -I../libgdbwrap/include/ -I../libaspect/include/ -DERESI64 +LDFLAGS64 += -L../libaspect/ -laspect64 + +NAME32 = libgdbwrap32 +NAME64 = libgdbwrap64 + +CC ?= gcc +LD ?= ld +AR = ar rc + +all : all32 all64 + +all32: $(OBJ32) + $(AR) $(NAME32).a $(OBJ32) + $(RANLIB) $(NAME32).a + $(CC) -shared $(OBJ32) -o $(NAME32).so + +all64: $(OBJ64) + $(AR) $(NAME64).a $(OBJ64) + $(RANLIB) $(NAME64).a + $(CC) -shared $(OBJ64) -o $(NAME64).so + +client: + $(CC) client.c $(CFLAGS32) $(LDFLAGS32) $(NAME32).a -o client32 + $(CC) client.c $(CFLAGS64) $(LDFLAGS64) $(NAME64).a -o client64 + +clean: + rm -f $(OBJ32) $(OBJ64) *~ *\# \#* .\#* + rm -f include/*~ include/*\# include/\#* include/.\#* + +fclean: clean + rm -f $(NAME32).* $(NAME64).* $(OBJ32) $(OBJ64) client* + +%.32.o: %.c + $(CC) $(CFLAGS32) -c -o $@ $< + +%.64.o: %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libkernsh/common/autotypes.c eresi-0.0.20110516/libkernsh/common/autotypes.c --- eresi-0.8a25/libkernsh/common/autotypes.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/autotypes.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file autotypes.c -** @ingroup libkernsh_common +* @file libkernsh/common/autotypes.c +** @ingroup common ** */ #include "libkernsh.h" @@ -197,10 +197,10 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); } -int kernsh_autotask_linux_2_6() +int kernsh_autotask_linux_2_6() { - unsigned long init_task, lst_addr, current_addr; - char buffer[1024]; + eresi_Addr init_task, lst_addr, current_addr; + char buffer[1024]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -210,7 +210,7 @@ kernsh_get_addr_by_name("init_task", &init_task, strlen("init_task")); - kernsh_readmem(init_task, buffer, sizeof(buffer)); + elfsh_readmema(libkernshworld.root, init_task, buffer, sizeof(buffer)); libkernshworld.typetask.offset_name = kernsh_autotask_offsetname_linux_2_6(buffer, sizeof(buffer)); @@ -224,7 +224,7 @@ printf("OFFSET NAME %d\n", libkernshworld.typetask.offset_name); #endif - kernsh_readmem(init_task+40, buffer, 200); + elfsh_readmema(libkernshworld.root, init_task+40, buffer, 200); libkernshworld.typetask.offset_list = kernsh_autotask_offsetlist_linux_2_6(buffer, 200); @@ -236,11 +236,11 @@ printf("OFFSET LIST %d\n", libkernshworld.typetask.offset_list); #endif - kernsh_readmem(init_task + libkernshworld.typetask.offset_list, + elfsh_readmema(libkernshworld.root, init_task + libkernshworld.typetask.offset_list, &lst_addr, sizeof(unsigned long)); - kernsh_readmem(lst_addr, buffer, 256); + elfsh_readmema(libkernshworld.root, lst_addr, buffer, 256); #if __DEBUG_KERNSH__ printf("LST_ADDR 0x%lx\n", lst_addr); @@ -254,7 +254,7 @@ #endif - kernsh_readmem(lst_addr + libkernshworld.typetask.offset_next, + elfsh_readmema(libkernshworld.root, lst_addr + libkernshworld.typetask.offset_next, ¤t_addr, sizeof(unsigned long)); @@ -262,7 +262,7 @@ printf("CURRENT_ADDR 0x%lx\n", current_addr); #endif - kernsh_readmem(current_addr + libkernshworld.typetask.offset_list, + elfsh_readmema(libkernshworld.root, current_addr + libkernshworld.typetask.offset_list, buffer, sizeof(buffer)); @@ -277,7 +277,7 @@ printf("OFFSET PID %d\n", libkernshworld.typetask.offset_pid); #endif - kernsh_readmem(current_addr + libkernshworld.typetask.offset_pid, + elfsh_readmema(libkernshworld.root, current_addr + libkernshworld.typetask.offset_pid, buffer, sizeof(buffer)); diff -Nru eresi-0.8a25/libkernsh/common/dump.c eresi-0.0.20110516/libkernsh/common/dump.c --- eresi-0.8a25/libkernsh/common/dump.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/dump.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file dump.c -** @ingroup libkernsh_common +* @file libkernsh/common/dump.c +** @ingroup common ** */ @@ -9,7 +9,7 @@ /** * @brief Dump elf\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param filename The output filename * @return 0 on success, -1 on error @@ -29,7 +29,7 @@ printf("kernsh_kvirtm_dump_elf\n"); #endif - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMDUMPELF); dim[0] = libkernshworld.os; @@ -45,7 +45,7 @@ /** * @brief Get vma of a process id\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA + * LIBKERNSH_CONFIG_VMA_PREFIX, LIBKERNSH_CONFIG_VMA * @param pid The process id * @return list_t on success, NULL on error */ @@ -63,7 +63,7 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, key, BUFSIZ, NULL); memset(key, '\0', BUFSIZ); - snprintf(key, BUFSIZ, "%s_%d", (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX), pid); + snprintf(key, BUFSIZ, "%s_%d", (char *)config_get_data(LIBKERNSH_CONFIG_VMA_PREFIX), pid); XALLOC(__FILE__, __FUNCTION__, __LINE__, l, sizeof(list_t), NULL); @@ -73,7 +73,7 @@ "Failed to initialize list", NULL); } - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); + get = (int)config_get_data(LIBKERNSH_CONFIG_VMA); kgv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPGETVMA); dim[0] = libkernshworld.os; @@ -98,7 +98,7 @@ /** * @brief Get vma of a process id from userland\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX + * LIBKERNSH_CONFIG_VMA_PREFIX * @param pid The process id * @param l list_t to store vma * @return 0 on success, -1 on error @@ -155,7 +155,7 @@ memset(key, '\0', BUFSIZ); snprintf(key, BUFSIZ, "%s_%d_%d", - (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX), pid, j); + (char *)config_get_data(LIBKERNSH_CONFIG_VMA_PREFIX), pid, j); if (hash_init(h, key, 2, ASPECT_TYPE_LONG) == 1) { @@ -179,7 +179,7 @@ /** * @brief Get vma of a process id from kernelland\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX + * LIBKERNSH_CONFIG_VMA_PREFIX * @param pid The process id * @param l list_t to store vma * @return 0 on success, -1 on error @@ -194,7 +194,7 @@ /** * @brief Dump vma of a process id\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA, LIBKERNSH_VMCONFIG_STORAGE_PATH + * LIBKERNSH_CONFIG_VMA_PREFIX, LIBKERNSH_CONFIG_VMA, LIBKERNSH_CONFIG_STORAGE_PATH * @param pid The process id * @return 0 on success, -1 on error */ @@ -216,9 +216,9 @@ ret = 0; - sav_val = (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX); + sav_val = (char *)config_get_data(LIBKERNSH_CONFIG_VMA_PREFIX); - config_update_key(LIBKERNSH_VMCONFIG_VMA_PREFIX, (void *)"tmp_vma"); + config_update_key(LIBKERNSH_CONFIG_VMA_PREFIX, (void *)"tmp_vma"); l = kernsh_kdump_get_vma(pid); @@ -228,7 +228,7 @@ "Failed to get vma", -1); } - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); + get = (int)config_get_data(LIBKERNSH_CONFIG_VMA); kv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPVMA); dim[0] = libkernshworld.os; @@ -238,16 +238,16 @@ memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s%s_%d", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX), pid); mkdir(buff, 0777); memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s%s_%d/metadata_%d", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX), pid, get); @@ -287,7 +287,7 @@ hash_del(hash_lists, l->name); elist_destroy(l); - config_update_key(LIBKERNSH_VMCONFIG_VMA_PREFIX, sav_val); + config_update_key(LIBKERNSH_CONFIG_VMA_PREFIX, sav_val); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -295,7 +295,7 @@ /** * @brief Dump vma of a process id from userland\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_STORAGE_PATH + * LIBKERNSH_CONFIG_VMA_PREFIX, LIBKERNSH_CONFIG_STORAGE_PATH * @param pid The process id * @param h the hash table to store vma struct * @return 0 on success, -1 on error @@ -345,8 +345,8 @@ memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s%s_%d/dump_userland_0x%lx", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX), pid, vm_start); @@ -364,7 +364,7 @@ /** * @brief Dump vma of a process id from kernelland\n * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_STORAGE_PATH + * LIBKERNSH_CONFIG_VMA_PREFIX, LIBKERNSH_CONFIG_STORAGE_PATH * @param pid The process id * @param h the hash table to store vma struct * @return 0 on success, -1 on error @@ -400,8 +400,8 @@ memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s%s_%d/dump_kernelland_0x%lx", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX), pid, vm_start); diff -Nru eresi-0.8a25/libkernsh/common/gdt.c eresi-0.0.20110516/libkernsh/common/gdt.c --- eresi-0.8a25/libkernsh/common/gdt.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/gdt.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file idt.c -** @ingroup libkernsh_common +* @file libkernsh/common/gdt.c +** @ingroup common ** */ #include "libkernsh.h" @@ -55,7 +55,7 @@ #endif /* Interrupts is not set in static kernel ! */ - if (kernsh_is_static_mode()) + if (elfsh_is_static_mode()) { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get gdt in static mode !", -1); @@ -91,11 +91,11 @@ memset(key, '\0', BUFSIZ); sgdt->addr = libkernshworld.gdt_base+i; - kernsh_readmem(libkernshworld.gdt_base+i, + elfsh_readmema(libkernshworld.root, libkernshworld.gdt_base+i, &sgdt->deb, sizeof(unsigned long)); - kernsh_readmem(libkernshworld.gdt_base+i+4, + elfsh_readmema(libkernshworld.root, libkernshworld.gdt_base+i+4, &sgdt->fin, sizeof(unsigned long)); diff -Nru eresi-0.8a25/libkernsh/common/hash.c eresi-0.0.20110516/libkernsh/common/hash.c --- eresi-0.8a25/libkernsh/common/hash.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/hash.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file hash.c -** @ingroup libkernsh_common +* @file libkernsh/common/hash.c +** @ingroup common ** */ #include "libkernsh.h" @@ -21,15 +21,15 @@ memset(buff, '\0', size); memset(digest, '\0', LIBKERNSH_HASH_MD5_SIZE); - if (kernsh_is_mem_mode()) + if (elfsh_is_runtime_mode()) { - kernsh_readmem(addr, buff, size); + elfsh_readmema(libkernshworld.root, addr, buff, size); } else { start = elfsh_get_foffset_from_vaddr(libkernshworld.root, addr); - elfsh_raw_read(libkernshworld.root, start, buff, size); + elfsh_readmemf(libkernshworld.root, start, buff, size); } MD5_Init(&md5ctx); @@ -49,7 +49,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); buffer = NULL; - hash = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); + hash = (int)config_get_data(LIBKERNSH_CONFIG_HASH); if (size < 0) { diff -Nru eresi-0.8a25/libkernsh/common/idt.c eresi-0.0.20110516/libkernsh/common/idt.c --- eresi-0.8a25/libkernsh/common/idt.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/idt.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,5 +1,5 @@ /* -** @file idt.c +* @file libkernsh/common/idt.c ** @ingroup libkernsh ** */ @@ -54,7 +54,7 @@ #endif /* Interrupts is not set in static kernel ! */ - if (kernsh_is_static_mode()) + if (elfsh_is_static_mode()) { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to get idt in static mode !", -1); @@ -71,7 +71,7 @@ i >= 0; i--) { - kernsh_readmem(libkernshworld.idt_base+sizeof(unsigned long)*2*i, + elfsh_readmema(libkernshworld.root, libkernshworld.idt_base+sizeof(unsigned long)*2*i, &idt, sizeof(idt)); diff -Nru eresi-0.8a25/libkernsh/common/memory.c eresi-0.0.20110516/libkernsh/common/memory.c --- eresi-0.8a25/libkernsh/common/memory.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/memory.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,7 +1,7 @@ /* - * @file memory.c +* @file libkernsh/common/memory.c ** @brief memory.c for libkernsh. -** @ingroup libkernsh_common +** @ingroup common ** */ #include "libkernsh.h" @@ -9,7 +9,7 @@ /** * @brief Open kernel memory\n * Configure : \n - * LIBKERNSH_VMCONFIG_KERNEL_START, LIBKERNSH_VMCONFIG_KERNEL_END, LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_MODE, LIBKERNSH_VMCONFIG_MMAP, LIBKERNSH_VMCONFIG_MMAP_SIZE, LIBKERNSH_VMCONFIG_SYSTEMMAP, LIBKERNSH_VMCONFIG_USEVM + * LIBKERNSH_CONFIG_KERNEL_START, LIBKERNSH_CONFIG_KERNEL_END, LIBKERNSH_CONFIG_DEVICE, LIBKERNSH_CONFIG_MODE, LIBKERNSH_CONFIG_MMAP, LIBKERNSH_CONFIG_MMAP_SIZE, LIBKERNSH_CONFIG_SYSTEMMAP, LIBKERNSH_CONFIG_USEVM * * @return 0 on success, -1 on return */ @@ -28,12 +28,8 @@ printf("OPENMEM\n"); #endif - libkernshworld.kernel_start = (unsigned long) - config_get_data(LIBKERNSH_VMCONFIG_KERNEL_START); - - libkernshworld.kernel_end = (unsigned long) - config_get_data(LIBKERNSH_VMCONFIG_KERNEL_END); - + libkernshworld.kernel_start = (eresi_Addr) config_get_data(LIBKERNSH_CONFIG_KERNEL_START); + libkernshworld.kernel_end = (eresi_Addr) config_get_data(LIBKERNSH_CONFIG_KERNEL_END); #if __DEBUG_KERNSH__ printf("KERNEL_START 0x%lx\n", libkernshworld.kernel_start); @@ -45,10 +41,10 @@ { /* Check configure device, mode etc */ - device = (char *) config_get_data(LIBKERNSH_VMCONFIG_DEVICE); - mode = (char *) config_get_data(LIBKERNSH_VMCONFIG_MODE); - mmap = (int) config_get_data(LIBKERNSH_VMCONFIG_MMAP); - mmap_size = (int) config_get_data(LIBKERNSH_VMCONFIG_MMAP_SIZE); + device = (char *) config_get_data(LIBKERNSH_CONFIG_DEVICE); + mode = (char *) config_get_data(LIBKERNSH_CONFIG_MODE); + mmap = (int) config_get_data(LIBKERNSH_CONFIG_MMAP); + mmap_size = (int) config_get_data(LIBKERNSH_CONFIG_MMAP_SIZE); if (device == NULL) { @@ -103,7 +99,7 @@ libkernshworld.mmap_size = mmap_size; #if __DEBUG_KERNSH__ - printf("SYSTEM %s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP)); + printf("SYSTEM %s\n", (char *) config_get_data(LIBKERNSH_CONFIG_SYSTEMMAP)); #endif } @@ -136,31 +132,31 @@ ret = fct(); - if(ret == 0) + if (ret == 0) { libkernshworld.open = 1; - int vm = (int) config_get_data(LIBKERNSH_VMCONFIG_USEVM); + int vm = (int) config_get_data(LIBKERNSH_CONFIG_USEVM); if (vm == 0) kernsh_info(); else { - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_IDTBASE); libkernshworld.idt_base = strtoull(value, NULL, 16); - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_IDTLIMIT); libkernshworld.idt_limit = strtoull(value, NULL, 16); - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_GDTBASE); libkernshworld.gdt_base = strtoull(value, NULL, 16); - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_GDTLIMIT); libkernshworld.gdt_limit = strtoull(value, NULL, 16); #if defined(__linux__) - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_SYSTEMCALL); libkernshworld.system_call = strtoull(value, NULL, 16); #endif - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_SCT); + value = (char *) config_get_data(LIBKERNSH_CONFIG_SPECIFY_SCT); libkernshworld.sct = strtoull(value, NULL, 16); } } @@ -203,83 +199,3 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } - -/** - * @brief Read kernel memory - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem(unsigned long offset, void *buf, int size) -{ - int ret; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - if (size < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Size is negative", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_READMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(offset, buf, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Write into kernel memory - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem(unsigned long offset, void *buf, int size) -{ - int ret; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - if (size < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Size is negative", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_WRITEMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(offset, buf, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libkernsh/common/sct.c eresi-0.0.20110516/libkernsh/common/sct.c --- eresi-0.8a25/libkernsh/common/sct.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/sct.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file sct.c -** @ingroup libkernsh_common +* @file libkernsh/common/sct.c +** @ingroup common ** */ #include "libkernsh.h" @@ -39,7 +39,7 @@ /** * @brief Get the sct on Linux\n * Configure :\n - * LIBKERNSH_VMCONFIG_NB_SYSCALLS + * LIBKERNSH_CONFIG_NB_SYSCALLS * @param lsct List to store the sct * @return 0 on success, -1 on return */ @@ -58,10 +58,10 @@ #endif /* Get syscalls in the static kernel */ - if (kernsh_is_static_mode()) + if (elfsh_is_static_mode()) { offset = 0; - for (i = (int) config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS) - 1; + for (i = (int) config_get_data(LIBKERNSH_CONFIG_NB_SYSCALLS) - 1; i >= 0; i--) { @@ -89,7 +89,7 @@ start = elfsh_get_foffset_from_vaddr(libkernshworld.root, libkernshworld.sct + sizeof(unsigned long)*i); - elfsh_raw_read(libkernshworld.root, + elfsh_readmemf(libkernshworld.root, start, &syscall->addr, sizeof(unsigned long)); @@ -112,7 +112,7 @@ "Memory not open !", -1); } - for (i = (int) config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS) - 1; + for (i = (int) config_get_data(LIBKERNSH_CONFIG_NB_SYSCALLS) - 1; i >= 0; i--) { @@ -137,7 +137,7 @@ "%d", i); - kernsh_readmem(libkernshworld.sct + sizeof(unsigned long) * i, + elfsh_readmema(libkernshworld.root, libkernshworld.sct + sizeof(unsigned long) * i, &syscall->addr, sizeof(unsigned long)); @@ -214,6 +214,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if defined(ERESI32) if (argc > 5 || argc < 0) { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -241,7 +242,11 @@ SYSCALL5 (num, argv[0], argv[1], argv[2], argv[3], argv[4] ); break; } - +#else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to execute syscalls on 64bits machine", -1); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, __ret); } diff -Nru eresi-0.8a25/libkernsh/common/.svn/all-wcprops eresi-0.0.20110516/libkernsh/common/.svn/all-wcprops --- eresi-0.8a25/libkernsh/common/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/946/trunk/libkernsh/common -END -gdt.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/933/trunk/libkernsh/common/gdt.c -END -idt.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/933/trunk/libkernsh/common/idt.c -END -hash.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/933/trunk/libkernsh/common/hash.c -END -dump.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/943/trunk/libkernsh/common/dump.c -END -vectors.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/933/trunk/libkernsh/common/vectors.c -END -memory.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/933/trunk/libkernsh/common/memory.c -END -sct.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libkernsh/common/sct.c -END -vectors_default.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/933/trunk/libkernsh/common/vectors_default.c -END -vectors_register.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/933/trunk/libkernsh/common/vectors_register.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/930/trunk/libkernsh/common/Makefile -END -autotypes.c -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/933/trunk/libkernsh/common/autotypes.c -END diff -Nru eresi-0.8a25/libkernsh/common/.svn/entries eresi-0.0.20110516/libkernsh/common/.svn/entries --- eresi-0.8a25/libkernsh/common/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/common -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -gdt.c -file - - - - -2008-04-06T23:15:27.598876Z -cb65afd4a5df4a8eac46b98e14ec60d8 -2008-03-25T12:19:53.725666Z -933 -pouik - -idt.c -file - - - - -2008-04-06T23:15:27.607133Z -5e9d935c21eae9109054b7b0d1c4a98a -2008-03-25T12:19:53.725666Z -933 -pouik - -hash.c -file - - - - -2008-04-06T23:15:27.618146Z -e68f212ffa1967f5ffb379abb5b2a5cc -2008-03-25T12:19:53.725666Z -933 -pouik - -dump.c -file - - - - -2008-04-06T23:15:27.628900Z -fcafdec1ccde99a2bba592ea2d25adf8 -2008-03-27T17:59:55.343182Z -943 -pouik - -vectors.c -file - - - - -2008-04-06T23:15:27.640876Z -317803c96a7be2f6a012a20f605ea15e -2008-03-25T12:19:53.725666Z -933 -pouik - -memory.c -file - - - - -2008-04-06T23:15:27.652121Z -8e3da83bce1c82a5aa0e03ada11854de -2008-03-25T12:19:53.725666Z -933 -pouik - -sct.c -file - - - - -2008-04-06T23:15:27.663463Z -beb9250d945250f6e65a9e701eee2e53 -2008-03-27T22:53:48.747992Z -946 -may - -vectors_default.c -file - - - - -2008-04-06T23:15:27.676425Z -460d278b0b4da354ceb46750a96faa13 -2008-03-25T12:19:53.725666Z -933 -pouik - -vectors_register.c -file - - - - -2008-04-06T23:15:27.687712Z -a833bfb784b73d4ac291f72f194ae6bd -2008-03-25T12:19:53.725666Z -933 -pouik - -Makefile -file - - - - -2008-04-06T23:15:27.698882Z -61f54b92808bc4e5cb7964ef75311497 -2008-03-25T08:32:13.270742Z -930 -pouik - -autotypes.c -file - - - - -2008-04-06T23:15:27.710396Z -2c5980bb935f8cf20b8925b4ce58189d -2008-03-25T12:19:53.725666Z -933 -pouik - diff -Nru eresi-0.8a25/libkernsh/common/.svn/format eresi-0.0.20110516/libkernsh/common/.svn/format --- eresi-0.8a25/libkernsh/common/.svn/format 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/autotypes.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/autotypes.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/autotypes.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/autotypes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,336 +0,0 @@ -/* -** @file autotypes.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -int kernsh_autotypes() -{ - int ret; - u_int dim[3]; - vector_t *autotypes; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - autotypes = aspect_vector_get(LIBKERNSH_VECTOR_NAME_AUTOTYPES); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(autotypes, dim); - - ret = fct(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int kernsh_autotypes_linux_2_6() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = kernsh_autotask_linux_2_6(); - if (ret) - { - - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotask_offsetname_linux_2_6(char *buffer, size_t size) -{ - char *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - p = kernsh_find_pattern(buffer, - size, - "\x73\x77\x61\x70\x70\x65\x72", - 7); - - if (p == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find pattern !", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (int)p - (int)buffer); -} - -int kernsh_autotask_offsetlist_linux_2_6(char *buffer, size_t size) -{ - int i, count, offset; - unsigned long first_addr, second_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - count = 0; - offset = -1; - first_addr = second_addr = -1; - - for (i = 0; i < size && offset == -1; i += 4) - { - first_addr = *(unsigned long *)(buffer+i); - - if (first_addr == second_addr) - { - count++; - } - - if (count == 2) - { - offset = i; - } - - if (first_addr > libkernshworld.kernel_start && - first_addr < libkernshworld.kernel_end) - { - second_addr = first_addr; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); -} - -int kernsh_autotask_offsetnext_linux_2_6(char *buffer, size_t size) -{ - int i, offset, find1, find2, diffaddr, jmpfiveaddr; - unsigned long first_addr,second_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - diffaddr = 0x10; - jmpfiveaddr = 0x14; - offset = find1 = find2 = second_addr = first_addr = 0; - - for(i = 0; i < size; i += 4) - { - second_addr = first_addr; - first_addr = *(unsigned long *)(buffer+i); - - if ((first_addr == second_addr) && - (first_addr > libkernshworld.kernel_start)) - { - find2 = find1; - find1 = i; - - if((find1-find2) == diffaddr) - { -#if __DEBUG_KERNSH__ - printf("[+] POS = 0x%x\n",find2+jmpfiveaddr); -#endif - offset = find2+jmpfiveaddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); -} - -int kernsh_autotask_offsetpid_linux_2_6(char *buffer, size_t size) -{ - int i, offset; - unsigned long first_addr, second_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - offset = first_addr = second_addr = -1; - - for (i = 0; i < size && offset == -1 ; i += 4) - { - first_addr = *(unsigned long *)(buffer + i); - - - if(first_addr == 0x1) - second_addr = first_addr; - - if(first_addr == second_addr) - offset = i; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); -} - -int kernsh_autotask_offsetuid_linux_2_6(char *buffer, size_t size) -{ - unsigned long first_addr, second_addr; - int i, offset, count; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - offset = -1; - count = first_addr = second_addr = 0; - - for(i = 0; i < size && offset == -1; i += 4) - { - if(first_addr != 0) - second_addr = first_addr; - - first_addr = *(unsigned long *)(buffer + i); - if(first_addr == second_addr) - { -#if __DEBUG_KERNSH__ - printf("EGAL %d %d\n", i, count); -#endif - count++; - } - - if(count == 6) - { -#if __DEBUG_KERNSH__ - printf("COUNT %d\n", i); -#endif - offset = i; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); -} - -int kernsh_autotask_linux_2_6() -{ - unsigned long init_task, lst_addr, current_addr; - char buffer[1024]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - libkernshworld.typetask.dectask.dec_list = 28; - libkernshworld.typetask.dectask.dec_pid = 4; - libkernshworld.typetask.dectask.dec_uid = 16; - - kernsh_get_addr_by_name("init_task", &init_task, strlen("init_task")); - - kernsh_readmem(init_task, buffer, sizeof(buffer)); - - libkernshworld.typetask.offset_name = - kernsh_autotask_offsetname_linux_2_6(buffer, sizeof(buffer)); - - if (libkernshworld.typetask.offset_name == -1) - { - - } - -#if __DEBUG_KERNSH__ - printf("OFFSET NAME %d\n", libkernshworld.typetask.offset_name); -#endif - - kernsh_readmem(init_task+40, buffer, 200); - - libkernshworld.typetask.offset_list = - kernsh_autotask_offsetlist_linux_2_6(buffer, 200); - - libkernshworld.typetask.offset_list += - libkernshworld.typetask.dectask.dec_list; - -#if __DEBUG_KERNSH__ - printf("OFFSET LIST %d\n", libkernshworld.typetask.offset_list); -#endif - - kernsh_readmem(init_task + libkernshworld.typetask.offset_list, - &lst_addr, - sizeof(unsigned long)); - - kernsh_readmem(lst_addr, buffer, 256); - -#if __DEBUG_KERNSH__ - printf("LST_ADDR 0x%lx\n", lst_addr); -#endif - - libkernshworld.typetask.offset_next = - kernsh_autotask_offsetnext_linux_2_6(buffer, 200); - -#if __DEBUG_KERNSH__ - printf("OFFSET_NEXT %d\n", libkernshworld.typetask.offset_next); -#endif - - - kernsh_readmem(lst_addr + libkernshworld.typetask.offset_next, - ¤t_addr, - sizeof(unsigned long)); - -#if __DEBUG_KERNSH__ - printf("CURRENT_ADDR 0x%lx\n", current_addr); -#endif - - kernsh_readmem(current_addr + libkernshworld.typetask.offset_list, - buffer, - sizeof(buffer)); - - libkernshworld.typetask.offset_pid = - kernsh_autotask_offsetpid_linux_2_6(buffer, 200); - - libkernshworld.typetask.offset_pid += - libkernshworld.typetask.offset_list + - libkernshworld.typetask.dectask.dec_pid; - -#if __DEBUG_KERNSH__ - printf("OFFSET PID %d\n", libkernshworld.typetask.offset_pid); -#endif - - kernsh_readmem(current_addr + libkernshworld.typetask.offset_pid, - buffer, - sizeof(buffer)); - - libkernshworld.typetask.offset_uid = - kernsh_autotask_offsetuid_linux_2_6(buffer, 500); - - libkernshworld.typetask.offset_uid += - libkernshworld.typetask.offset_pid + libkernshworld.typetask.dectask.dec_uid; -#if __DEBUG_KERNSH__ - printf("OFFSET UID %d\n", libkernshworld.typetask.offset_uid); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotypes_linux_2_4() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotask_linux_2_4() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotypes_netbsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotask_netbsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotypes_freebsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_autotask_freebsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/dump.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/dump.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/dump.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/dump.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,418 +0,0 @@ -/* -** @file dump.c -** @ingroup libkernsh_common -** -*/ - -#include "libkernsh.h" - -/** - * @brief Dump elf\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param filename The output filename - * @return 0 on success, -1 on error - */ -int kernsh_dump_kvirtm_elf(pid_t pid, char *filename) -{ - int ret, get; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_dump_elf\n"); -#endif - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMDUMPELF); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - ret = fct(pid, filename); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get vma of a process id\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA - * @param pid The process id - * @return list_t on success, NULL on error - */ -list_t *kernsh_kdump_get_vma(pid_t pid) -{ - int ret, get; - char *key; - u_int dim[3]; - list_t *l; - vector_t *kgv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, key, BUFSIZ, NULL); - memset(key, '\0', BUFSIZ); - - snprintf(key, BUFSIZ, "%s_%d", (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX), pid); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, l, sizeof(list_t), NULL); - - if (elist_init(l, key, ASPECT_TYPE_HASH) == 1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to initialize list", NULL); - } - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); - - kgv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPGETVMA); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(kgv, dim); - - // ret = fct(pid, l); - ret = kernsh_kdump_get_vma_userland_linux(pid, l); - - if (ret < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get vma", NULL); - } - - l = elist_reverse(l); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, l); -} - -/** - * @brief Get vma of a process id from userland\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX - * @param pid The process id - * @param l list_t to store vma - * @return 0 on success, -1 on error - */ -int kernsh_kdump_get_vma_userland_linux(pid_t pid, list_t *l) -{ - int ret, fd, i, j; - char buff[BUFSIZ]; - char line[BUFSIZ]; - char *tok, *subtok, *brk, *subbrk, *subsubtok, *subsubbrk, *key; - libkernshvma_struct_t *vst; - hash_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - tok = subtok = subsubtok = brk = subbrk = subsubbrk = key = NULL; - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "/proc/%d/maps", pid); - - XOPEN(fd, buff, O_RDONLY, 0,-1); - - ret = read(fd, line, sizeof(line)); - - if (ret <= 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read /proc", -1); - } - - for (tok = strtok_r(line, "\n", &brk), j = 0; - tok; - tok = strtok_r(NULL, "\n", &brk), j++) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, vst, sizeof(libkernshvma_struct_t), -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, h, sizeof(hash_t), -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, key, BUFSIZ, -1); - - for (subtok = strtok_r(tok, " ", &subbrk), i = 0; - subtok; - subtok = strtok_r(NULL, " ", &subbrk), i++) - { - switch (i) - { - case 0 : - subsubtok = strtok_r(subtok, "-", &subsubbrk); - vst->vm_start = strtoul(subsubtok, NULL, 16); - subsubtok = strtok_r(NULL, "-", &subsubbrk); - vst->vm_end = strtoul(subsubtok, NULL, 16); - break; - } - } - - memset(key, '\0', BUFSIZ); - snprintf(key, BUFSIZ, "%s_%d_%d", - (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX), pid, j); - - if (hash_init(h, key, 2, ASPECT_TYPE_LONG) == 1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to initialize hash", -1); - } - - hash_add(h, LIBKERNSH_STRING_VM_START, (void *)vst->vm_start); - hash_add(h, LIBKERNSH_STRING_VM_END, (void *)vst->vm_end); - - XFREE(__FILE__, __FUNCTION__, __LINE__, vst); - - elist_add(l, key, (void *)h); - } - - XCLOSE(fd, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get vma of a process id from kernelland\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX - * @param pid The process id - * @param l list_t to store vma - * @return 0 on success, -1 on error - */ -int kernsh_kdump_get_vma_kernelland_linux(pid_t pid, list_t *l) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); -} - -/** - * @brief Dump vma of a process id\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_VMA, LIBKERNSH_VMCONFIG_STORAGE_PATH - * @param pid The process id - * @return 0 on success, -1 on error - */ -int kernsh_kdump_vma(pid_t pid) -{ - int ret, tret, fd, index, get; - listent_t *actual; - list_t *l; - hash_t *h; - char *sav_val; - char buff[BUFSIZ]; - char meta[BUFSIZ]; - u_int dim[3]; - vector_t *kv; - int (*fct)(); - unsigned long meta_start, meta_end, meta_size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - - sav_val = (char *)config_get_data(LIBKERNSH_VMCONFIG_VMA_PREFIX); - - config_update_key(LIBKERNSH_VMCONFIG_VMA_PREFIX, (void *)"tmp_vma"); - - l = kernsh_kdump_get_vma(pid); - - if (l == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get vma", -1); - } - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VMA); - - kv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPVMA); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(kv, dim); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "%s%s_%d", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), - pid); - - mkdir(buff, 0777); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "%s%s_%d/metadata_%d", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), - pid, - get); - - XOPEN(fd, buff, O_RDWR|O_CREAT, 0777, -1); - - for (index = 0, actual = l->head; - index < l->elmnbr; - index++, actual = actual->next) - { - h = (hash_t *) actual->data; - printf("%s[%d]", l->name, index); - if (h) - { - memset(meta, '\0', sizeof(meta)); - - tret = fct(pid, h); - ret += tret; - - meta_start = (int)hash_get(h, LIBKERNSH_STRING_VM_START); - meta_end = (int)hash_get(h, LIBKERNSH_STRING_VM_END); - meta_size = meta_end - meta_start; - - snprintf(meta, sizeof(meta), "%s[%d] 0x%lx ... 0x%lx strlen(0x%lx) ==> [0x%lx]\n", - l->name, - index, - meta_start, - meta_end, - meta_size, - (unsigned long)tret); - XWRITE(fd, meta, strlen(meta), -1); - } - printf("\n"); - } - - XCLOSE(fd, -1); - - hash_del(hash_lists, l->name); - elist_destroy(l); - - config_update_key(LIBKERNSH_VMCONFIG_VMA_PREFIX, sav_val); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Dump vma of a process id from userland\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_STORAGE_PATH - * @param pid The process id - * @param h the hash table to store vma struct - * @return 0 on success, -1 on error - */ -int kernsh_kdump_vma_userland_linux(pid_t pid, hash_t *h) -{ - int ret, fd, i; - unsigned long vm_start, vm_end, size; - char buff[BUFSIZ]; - char *new_vma; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - -#if defined(__linux__) - if (ptrace(PTRACE_ATTACH, pid, 0, 0) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to attach pid", -1); - } - waitpid(pid, NULL, WUNTRACED); -#endif - - vm_start = (int)hash_get(h, LIBKERNSH_STRING_VM_START); - vm_end = (int)hash_get(h, LIBKERNSH_STRING_VM_END); - - size = vm_end - vm_start; - - printf("VM_* 0x%lx -> 0x%lx ==> strlen(0x%lx)\n", vm_start, vm_end, size); - XALLOC(__FILE__, __FUNCTION__, __LINE__, new_vma, size + 1, -1); - - memset(new_vma, '\0', size); - -#if defined(__linux__) - for (i=0; i < size; i++) - { - new_vma[i]=(char)ptrace(PTRACE_PEEKTEXT, pid, vm_start+i, 0); - if (errno == 0) - ret++; - } -#endif - -#if defined(__linux__) - ptrace(PTRACE_DETACH, pid, 0, 0); -#endif - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "%s%s_%d/dump_userland_0x%lx", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), - pid, - vm_start); - - printf("DUMP USERLAND 0x%lx into %s\n", vm_start, buff); - - XOPEN(fd, buff, O_RDWR|O_CREAT, 0777, -1); - XWRITE(fd, new_vma, size, -1); - XCLOSE(fd, -1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_vma); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Dump vma of a process id from kernelland\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VMA_PREFIX, LIBKERNSH_VMCONFIG_STORAGE_PATH - * @param pid The process id - * @param h the hash table to store vma struct - * @return 0 on success, -1 on error - */ -int kernsh_kdump_vma_kernelland_linux(pid_t pid, hash_t *h) -{ - int ret, fd; - unsigned long vm_start, vm_end, size; - char buff[BUFSIZ]; - char *new_vma; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - - vm_start = (int)hash_get(h, LIBKERNSH_STRING_VM_START); - vm_end = (int)hash_get(h, LIBKERNSH_STRING_VM_END); - - size = vm_end - vm_start; - - printf("VM_* 0x%lx -> 0x%lx ==> strlen(0x%lx)\n", vm_start, vm_end, size); - XALLOC(__FILE__, __FUNCTION__, __LINE__, new_vma, size + 1, -1); - - memset(new_vma, '\0', size); - - ret = kernsh_kvirtm_read_virtm(pid, vm_start, new_vma, (int)size); - if (ret <= 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, new_vma); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to dump vma", -1); - } - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "%s%s_%d/dump_kernelland_0x%lx", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX), - pid, - vm_start); - - printf("DUMP KERNELLAND 0x%lx into %s\n", vm_start, buff); - - XOPEN(fd, buff, O_RDWR|O_CREAT, 0777, -1); - XWRITE(fd, new_vma, size, -1); - XCLOSE(fd, -1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, new_vma); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/gdt.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/gdt.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/gdt.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/gdt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* -** @file idt.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -/** - * @brief Get the gdt - * @param lgdt List to store the gdt - * @return 0 on success, -1 on return - */ -/* Put interrupts inside the list lgdt */ -int kernsh_gdt(list_t *lgdt) -{ - int ret; - u_int dim[3]; - vector_t *gdt; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if(lgdt == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "List is NULL !", -1); - } - - gdt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_GDT); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(gdt, dim); - - ret = fct(lgdt); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get the gdt on Linux - * @param lgdt List to store the gdt - * @return 0 on success, -1 on return - */ -int kernsh_gdt_linux(list_t *lgdt) -{ - int i; - char *key; - libkernshsgdt_t *sgdt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("GDT LINUX\n"); -#endif - - /* Interrupts is not set in static kernel ! */ - if (kernsh_is_static_mode()) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get gdt in static mode !", -1); - } - else - { - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - for (i = 0; - i < libkernshworld.gdt_limit; - i = i + 8) - { - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - sgdt, - sizeof(libkernshsgdt_t), - -1); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - key, - BUFSIZ, - -1); - - memset(sgdt, '\0', sizeof(libkernshsgdt_t)); - memset(key, '\0', BUFSIZ); - - sgdt->addr = libkernshworld.gdt_base+i; - kernsh_readmem(libkernshworld.gdt_base+i, - &sgdt->deb, - sizeof(unsigned long)); - - kernsh_readmem(libkernshworld.gdt_base+i+4, - &sgdt->fin, - sizeof(unsigned long)); - - snprintf(key, - BUFSIZ, - "%d", - i); - - - /* Add the segment in the list */ - elist_add(lgdt, key, (void *) sgdt); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the gdt on Netbsd - * @param lgdt List to store the gdt - * @return 0 on success, -1 on return - */ -int kernsh_gdt_netbsd(list_t *lgdt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the gdt on Freebsd - * @param lgdt List to store the gdt - * @return 0 on success, -1 on return - */ -int kernsh_gdt_freebsd(list_t *lgdt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/hash.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/hash.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/hash.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/hash.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -/* -** @file hash.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" -#include - -unsigned char *kernsh_hash_md5(unsigned long addr, int size) -{ - MD5_CTX md5ctx; - unsigned char *buff; - unsigned char *digest; - unsigned long start; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, buff, size + 1, NULL); - XALLOC(__FILE__, __FUNCTION__, __LINE__, digest, LIBKERNSH_HASH_MD5_SIZE, NULL); - - memset(buff, '\0', size); - memset(digest, '\0', LIBKERNSH_HASH_MD5_SIZE); - - if (kernsh_is_mem_mode()) - { - kernsh_readmem(addr, buff, size); - } - else - { - start = elfsh_get_foffset_from_vaddr(libkernshworld.root, - addr); - elfsh_raw_read(libkernshworld.root, start, buff, size); - } - - MD5_Init(&md5ctx); - MD5_Update(&md5ctx, buff, size); - MD5_Final(digest, &md5ctx); - - XFREE(__FILE__, __FUNCTION__, __LINE__, buff); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, digest); -} - -unsigned char *kernsh_hash(unsigned long addr, int size, int *new_size) -{ - int hash; - unsigned char *buffer; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - buffer = NULL; - hash = (int)config_get_data(LIBKERNSH_VMCONFIG_HASH); - - if (size < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Size is negative", NULL); - } - - /* We must find ret */ - if (size == 0) - { - size = kernsh_find_end(addr); - if (!size) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't find the size", NULL); - } - } - - *new_size = size; - - switch (hash) - { - case LIBKERNSH_HASH_MD5 : - buffer = kernsh_hash_md5(addr, size); - break; - case LIBKERNSH_HASH_SHA1 : - break; - - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buffer); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/idt.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/idt.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/idt.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/idt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,134 +0,0 @@ -/* -** @file idt.c -** @ingroup libkernsh -** -*/ -#include "libkernsh.h" - -/** - * @brief Get the idt - * @param lidt List to store the idt - * @return 0 on success, -1 on return - */ -int kernsh_idt(list_t *lidt) -{ - int ret; - u_int dim[3]; - vector_t *idt; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if(lidt == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "List is NULL !", -1); - } - - idt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_IDT); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(idt, dim); - - ret = fct(lidt); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get the idt on Linux - * @param lidt List to store the idt - * @return 0 on success, -1 on return - */ -int kernsh_idt_linux(list_t *lidt) -{ - int i; - char *key; - libkernshint_t *dint; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("IDT LINUX\n"); -#endif - - /* Interrupts is not set in static kernel ! */ - if (kernsh_is_static_mode()) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get idt in static mode !", -1); - } - else - { - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - for (i = (libkernshworld.idt_limit + 1) / (sizeof(unsigned long) * 2) - 1; - i >= 0; - i--) - { - kernsh_readmem(libkernshworld.idt_base+sizeof(unsigned long)*2*i, - &idt, - sizeof(idt)); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - dint, - sizeof(libkernshint_t), - -1); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - key, - BUFSIZ, - -1); - - memset(dint, '\0', sizeof(libkernshint_t)); - memset(key, '\0', BUFSIZ); - snprintf(key, - BUFSIZ, - "%d", - i); - - dint->addr = (unsigned long)(idt.off2 << 16) + idt.off1; - kernsh_resolve_systemmap(dint->addr, - dint->name, - sizeof(dint->name)); - - /* Add the interrupt in the list */ - elist_add(lidt, key, (void *) dint); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the idt on Netbsd - * @param lidt List to store the idt - * @return 0 on success, -1 on return - */ -int kernsh_idt_netbsd(list_t *lidt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the idt on Freebsd - * @param lidt List to store the idt - * @return 0 on success, -1 on return - */ -int kernsh_idt_freebsd(list_t *lidt) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -include ../../config.h -# -# Architecture source files -# -SRCS = autotypes.c dump.c hash.c memory.c vectors.c vectors_register.c gdt.c idt.c sct.c vectors_default.c - -OBJS32 = ${SRCS:.c=.32.o} -OBJS64 = ${SRCS:.c=.64.o} - -CFLAGS32 = -I../include -Wall -g3 -DERESI32 \ - -I../../libaspect/include -I../../libasm/include \ - -I../../libelfsh/include -I../../libedfmt/include \ - -I../../libmjollnir/include -O2 -CFLAGS64 = -I../include -Wall -g3 -fPIC -DERESI64 \ - -I../../libaspect/include -I../../libasm/include \ - -I../../libelfsh/include -I../../libedfmt/include \ - -I../../libmjollnir/include -O2 -RM = rm -f -ETAGS = etags -CC ?= gcc -LD ?= ld -CP = cp - -all: all32 all64 - -symbs : - @cd symbols && $(MAKE) - -all32: $(OBJS32) - -all64: $(OBJS64) - -clean: - @$(RM) $(OBJS32) $(OBJS64) *~ \#* *\# .\#* - -fclean: clean - -#tags: -# @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c -# @echo TAGS generated succesfully - -%.32.o: %.c - @$(CC) $(CFLAGS32) ${DBGFLAGS} -c $*.c -o $*.32.o - @echo "[CC] $*.32.o" - -%.64.o: %.c - @$(CC) $(CFLAGS64) ${DBGFLAGS} -c $*.c -o $*.64.o - @echo "[CC] $*.64.o" diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/memory.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/memory.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/memory.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/memory.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,285 +0,0 @@ -/* - * @file memory.c -** @brief memory.c for libkernsh. -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -/** - * @brief Open kernel memory\n - * Configure : \n - * LIBKERNSH_VMCONFIG_KERNEL_START, LIBKERNSH_VMCONFIG_KERNEL_END, LIBKERNSH_VMCONFIG_DEVICE, LIBKERNSH_VMCONFIG_MODE, LIBKERNSH_VMCONFIG_MMAP, LIBKERNSH_VMCONFIG_MMAP_SIZE, LIBKERNSH_VMCONFIG_SYSTEMMAP, LIBKERNSH_VMCONFIG_USEVM - * - * @return 0 on success, -1 on return - */ -int kernsh_openmem() -{ - int ret, mmap, mmap_size; - - char *device, *mode, *value; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPENMEM\n"); -#endif - - libkernshworld.kernel_start = (unsigned long) - config_get_data(LIBKERNSH_VMCONFIG_KERNEL_START); - - libkernshworld.kernel_end = (unsigned long) - config_get_data(LIBKERNSH_VMCONFIG_KERNEL_END); - - -#if __DEBUG_KERNSH__ - printf("KERNEL_START 0x%lx\n", libkernshworld.kernel_start); - printf("KERNEL_END 0x%lx\n", libkernshworld.kernel_end); -#endif - - if (libkernshworld.os == LIBKERNSH_OS_LINUX_2_6 || - libkernshworld.os == LIBKERNSH_OS_LINUX_2_4) - { - /* Check configure device, mode etc */ - - device = (char *) config_get_data(LIBKERNSH_VMCONFIG_DEVICE); - mode = (char *) config_get_data(LIBKERNSH_VMCONFIG_MODE); - mmap = (int) config_get_data(LIBKERNSH_VMCONFIG_MMAP); - mmap_size = (int) config_get_data(LIBKERNSH_VMCONFIG_MMAP_SIZE); - - if (device == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Device is NULL", -1); - } - - if (mode == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Mode is NULL", -1); - } - - /* check device and mode */ - if (!strcmp(device, LIBKERNSH_STRING_DEVICE_KMEM)) - { - libkernshworld.device = LIBKERNSH_DEVICE_KMEM; - } - else if (!strcmp(device, LIBKERNSH_STRING_DEVICE_MEM)) - { - libkernshworld.device = LIBKERNSH_DEVICE_MEM; - } - else if (!strcmp(device, LIBKERNSH_STRING_DEVICE_KCORE)) - { - libkernshworld.device = LIBKERNSH_DEVICE_KCORE; - } - else if (!strcmp(device, LIBKERNSH_STRING_DEVICE_KVIRTM)) - { - libkernshworld.device = LIBKERNSH_DEVICE_KVIRTM; - } - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid device", -1); - } - - if (!strcmp(mode, "read")) - { - libkernshworld.fdmode = O_RDONLY; - libkernshworld.protmode = PROT_READ; - libkernshworld.flagsmode = MAP_PRIVATE; - } - else if (!strcmp(mode, "write")) - { - libkernshworld.fdmode = O_RDWR; - libkernshworld.protmode = PROT_WRITE; - libkernshworld.flagsmode = MAP_SHARED; - } - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid mode", -1); - } - - libkernshworld.mmap = mmap; - libkernshworld.mmap_size = mmap_size; - -#if __DEBUG_KERNSH__ - printf("SYSTEM %s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP)); -#endif - - } - else if (libkernshworld.os == LIBKERNSH_OS_NETBSD) - { - - } - else if (libkernshworld.os == LIBKERNSH_OS_FREEBSD) - { - - } - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "OS not supported", -1); - } - - if (libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory already open, you must close it !", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_OPENMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(); - - if(ret == 0) - { - libkernshworld.open = 1; - int vm = (int) config_get_data(LIBKERNSH_VMCONFIG_USEVM); - if (vm == 0) - kernsh_info(); - else - { - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE); - libkernshworld.idt_base = strtoull(value, NULL, 16); - - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT); - libkernshworld.idt_limit = strtoull(value, NULL, 16); - - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE); - libkernshworld.gdt_base = strtoull(value, NULL, 16); - - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT); - libkernshworld.gdt_limit = strtoull(value, NULL, 16); - -#if defined(__linux__) - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL); - libkernshworld.system_call = strtoull(value, NULL, 16); -#endif - value = (char *) config_get_data(LIBKERNSH_VMCONFIG_SPECIFY_SCT); - libkernshworld.sct = strtoull(value, NULL, 16); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Close kernel memory - * @return 0 on success, -1 on error - */ -int kernsh_closemem() -{ - int ret; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CLOSEMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(); - - libkernshworld.open = 0; - libkernshworld.idt_base = 0; - libkernshworld.idt_limit = 0; - libkernshworld.sct = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Read kernel memory - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem(unsigned long offset, void *buf, int size) -{ - int ret; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - if (size < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Size is negative", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_READMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(offset, buf, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Write into kernel memory - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem(unsigned long offset, void *buf, int size) -{ - int ret; - u_int dim[4]; - vector_t *mem; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - if (size < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Size is negative", -1); - } - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_WRITEMEM); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - dim[2] = libkernshworld.device; - - fct = aspect_vectors_select(mem, dim); - - ret = fct(offset, buf, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/sct.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/sct.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/sct.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/sct.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,247 +0,0 @@ -/* -** @file sct.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -/** - * @brief Get the sct - * @param lsct List to store the sct - * @return 0 on success, -1 on return - */ -int kernsh_sct(list_t *lsct) -{ - int ret; - u_int dim[3]; - vector_t *sct; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if(lsct == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "List is NULL !", -1); - } - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_SCT); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(sct, dim); - - ret = fct(lsct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get the sct on Linux\n - * Configure :\n - * LIBKERNSH_VMCONFIG_NB_SYSCALLS - * @param lsct List to store the sct - * @return 0 on success, -1 on return - */ -int kernsh_sct_linux(list_t *lsct) -{ - int i; - char *key; - libkernshsyscall_t *syscall; - elfsh_SAddr offset; - unsigned long start; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("SCT LINUX\n"); -#endif - - /* Get syscalls in the static kernel */ - if (kernsh_is_static_mode()) - { - offset = 0; - for (i = (int) config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS) - 1; - i >= 0; - i--) - { - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - syscall, - sizeof(libkernshsyscall_t), - -1); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - key, - BUFSIZ, - -1); - - memset(syscall, '\0', sizeof(libkernshsyscall_t)); - memset(key, '\0', BUFSIZ); - snprintf(key, - BUFSIZ, - "%d", - i); - - start = elfsh_get_foffset_from_vaddr(libkernshworld.root, - libkernshworld.sct + sizeof(unsigned long)*i); - - elfsh_raw_read(libkernshworld.root, - start, - &syscall->addr, - sizeof(unsigned long)); - - memcpy(syscall->name, - elfsh_reverse_symbol(libkernshworld.root, - (eresi_Addr) syscall->addr, - &offset), - sizeof(syscall->name)); - - /* Add syscall to the list */ - elist_add(lsct, key, (void *) syscall); - } - } - /* Get syscalls in the memory */ - else { - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - for (i = (int) config_get_data(LIBKERNSH_VMCONFIG_NB_SYSCALLS) - 1; - i >= 0; - i--) - { - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - syscall, - sizeof(libkernshsyscall_t), - -1); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - key, - BUFSIZ, - -1); - - memset(syscall, '\0', sizeof(libkernshsyscall_t)); - memset(key, '\0', BUFSIZ); - snprintf(key, - BUFSIZ, - "%d", - i); - - kernsh_readmem(libkernshworld.sct + sizeof(unsigned long) * i, - &syscall->addr, - sizeof(unsigned long)); - - kernsh_resolve_systemmap(syscall->addr, - syscall->name, - sizeof(syscall->name)); - - /* Add syscall in the list */ - elist_add(lsct, key, (void *) syscall); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the sct on Netbsd - * @param lsct List to store the sct - * @return 0 on success, -1 on return - */ -int kernsh_sct_netbsd(list_t *lsct) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get the sct on Freebsd - * @param lsct List to store the sct - * @return 0 on success, -1 on return - */ -int kernsh_sct_freebsd(list_t *lsct) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Call a system call - * @param num Number of the syscall - * @param argc Number of arguments - * @param argv Arguments - * @return return syscall value - */ -int kernsh_syscall(int num, int argc, unsigned int argv[]) -{ - int ret; - u_int dim[2]; - vector_t *csct; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - csct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CALLSC); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(csct, dim); - - ret = fct(num, argc, argv); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Call a system call on Linux - * @param num Number of the syscall - * @param argc Number of arguments - * @param argv Arguments - * @return return syscall value - */ -int kernsh_syscall_linux(int num, int argc, unsigned int argv[]) -{ - int __ret = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (argc > 5 || argc < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "invalid number of arguments", -1); - } - - switch(argc) - { - case 0 : - SYSCALL0(num); - break; - case 1 : - SYSCALL1(num, argv[0]); - break; - case 2: - SYSCALL2( num, argv[0], argv[1] ); - break; - case 3: - SYSCALL3 (num, argv[0], argv[1], argv[2] ); - break; - case 4: - SYSCALL4 (num, argv[0], argv[1], argv[2], argv[3] ); - break; - case 5: - SYSCALL5 (num, argv[0], argv[1], argv[2], argv[3], argv[4] ); - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, __ret); -} - diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/vectors.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/vectors.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,637 +0,0 @@ -/** - * @defgroup libkernsh_common libkernsh_common - */ -/* -** @file vectors.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -libkernshworld_t libkernshworld; - -/** - * @brief Initialise kernsh's vectors - * @return 0 on success, -1 on return - */ -int kernsh_init_vectors() -{ - u_int *dims; - char **strdims; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - aspect_init(); - - /* Memory ARCH, OS, DEVICE */ -#if __DEBUG_KERNSH__ - printf("INIT MEMORY VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 4 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 4 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - dims[2] = LIBKERNSH_DEVICENUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - strdims[2] = "DEVICETYPE"; - - /* Register memory default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_OPENMEM, - kernsh_openmem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_CLOSEMEM, - kernsh_closemem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_READMEM, - kernsh_readmem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_WRITEMEM, - kernsh_writemem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - - /* Syscalls ARCH, OS */ -#if __DEBUG_KERNSH__ - printf("INIT SCT VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register sct default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_SCT, - kernsh_sct_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - /* Call syscall OS */ -#if __DEBUG_KERNSH__ - printf("INIT CALL SYSCALL VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 2 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 2 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - - strdims[0] = "OSTYPE"; - - /* Register call syscall default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_CALLSC, - kernsh_callsc_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - - /* IDT ARCH, OS */ -#if __DEBUG_KERNSH__ - printf("INIT IDT VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register idt default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_IDT, - kernsh_idt_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - /* GDT ARCH, OS */ -#if __DEBUG_KERNSH__ - printf("INIT GDT VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register gdt default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_GDT, - kernsh_gdt_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - /* Info ARCH, OS */ -#if __DEBUG_KERNSH__ - printf("INIT INFO VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register info default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_INFO, - kernsh_info_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); -#if __DEBUG_KERNSH__ - printf("INIT KERNEL DECOMP VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 2 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 2 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - - strdims[0] = "OSTYPE"; - - /* Register kernel default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_DECOMPKERNEL, - kernsh_decompkernel_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("INIT SYMBS VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register symbs default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_ADDRBYNAME, - kernsh_symbs_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_NAMEBYADDR, - kernsh_symbs_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("INIT ALLOC CONTIGUOUS VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 2 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 2 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - - strdims[0] = "OSTYPE"; - - /* Register alloc/free default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS, - kernsh_alloc_contiguous_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS, - kernsh_alloc_noncontiguous_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS, - kernsh_free_contiguous_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS, - kernsh_free_noncontiguous_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - /* autotypes ARCH, OS, DEVICE */ -#if __DEBUG_KERNSH__ - printf("INIT AUTOTYPES VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_ARCHNUM; - dims[1] = LIBKERNSH_OSNUM; - - strdims[0] = "ARCHTYPE"; - strdims[1] = "OSTYPE"; - - /* Register memory default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_AUTOTYPES, - kernsh_autotypes_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("INIT RELINK MODULE VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 2 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 2 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - - strdims[0] = "OSTYPE"; - - /* Register relink module vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_RELINKMODULE, - kernsh_relink_module_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("INIT INFECT MODULE VECTORS\n"); -#endif - - /* Register infect module vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_INFECTMODULE, - kernsh_infect_module_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KLOADMODULE, - kernsh_kload_module_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KUNLOADMODULE, - kernsh_kunload_module_default, - dims, strdims, 1, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("KVIRTM READ * VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - dims[1] = LIBKERNSH_VIRTMNUM; - - strdims[0] = "OSTYPE"; - strdims[1] = "VIRTMTYPE"; - - /* Register kvirtm read * default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KVIRTMREADVIRTM, - kernsh_kvirtm_read_virtm_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM, - kernsh_kvirtm_read_mem_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - /* Register kvirtm write * default vectors */ - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEVIRTM, - kernsh_kvirtm_write_virtm_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEMEM, - kernsh_kvirtm_write_mem_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID, - kernsh_kvirtm_task_pid_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - -#if __DEBUG_KERNSH__ - printf("KDUMP VMA VECTORS\n"); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,dims , 3 * sizeof(u_int) , -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,strdims, 3 * sizeof(char *), -1); - - dims[0] = LIBKERNSH_OSNUM; - dims[1] = LIBKERNSH_VMANUM; - - strdims[0] = "OSTYPE"; - strdims[1] = "VMATYPE"; - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KDUMPGETVMA, - kernsh_kdump_get_vma_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_KDUMPVMA, - kernsh_kdump_vma_default, - dims, strdims, 2, ASPECT_TYPE_CADDR); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Register kernsh's vectors - * @return 0 on success, -1 on return - */ -int kernsh_register_vectors() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_openmem_kmem_linux_2_6); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_openmem_kmem_linux_2_4); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_openmem_mem_linux); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_openmem_mem_linux); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_openmem_kcore_linux_2_6); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, - kernsh_openmem_netbsd); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_openmem); - kernsh_register_openmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_openmem); - - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_closemem_kmem_linux_2_6); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_closemem_kmem_linux_2_4); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_closemem_mem_linux); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_closemem_mem_linux); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_closemem_kcore_linux_2_6); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, - kernsh_closemem_netbsd); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_closemem); - kernsh_register_closemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_closemem); - - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_readmem_kmem_linux_2_6); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_readmem_kmem_linux_2_4); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_mem_linux); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_mem_linux); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_readmem_kcore_linux_2_6); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_netbsd); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_readmem); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_readmem); - - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_writemem_kmem_linux_2_6); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_writemem_kmem_linux_2_4); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_writemem_mem_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_writemem_mem_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_writemem_kcore_linux_2_6); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, kernsh_writemem_netbsd); - - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_writemem); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_writemem); - - kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_sct_linux); - kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_sct_linux); - - kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_6, - kernsh_syscall_linux); - kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_4, - kernsh_syscall_linux); - - kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_idt_linux); - kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_idt_linux); - - kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_gdt_linux); - kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_gdt_linux); - - kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_info_linux); - kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_info_linux); - - kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_6, - kernsh_decompkernel_linux); - kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_4, - kernsh_decompkernel_linux); - - kernsh_register_symbs_abn(LIBKERNSH_ARCH_I386, - LIBKERNSH_OS_LINUX_2_6, - kernsh_get_addr_by_name_linux_2_6); - kernsh_register_symbs_abn(LIBKERNSH_ARCH_I386, - LIBKERNSH_OS_LINUX_2_4, - kernsh_get_addr_by_name_linux_2_4); - kernsh_register_symbs_nba(LIBKERNSH_ARCH_I386, - LIBKERNSH_OS_LINUX_2_6, - kernsh_get_name_by_addr_linux_2_6); - kernsh_register_symbs_nba(LIBKERNSH_ARCH_I386, - LIBKERNSH_OS_LINUX_2_4, - kernsh_get_name_by_addr_linux_2_4); - - kernsh_register_alloc_contiguous(LIBKERNSH_OS_LINUX_2_6, - kernsh_alloc_contiguous_linux); - kernsh_register_alloc_contiguous(LIBKERNSH_OS_LINUX_2_4, - kernsh_alloc_contiguous_linux); - - kernsh_register_alloc_noncontiguous(LIBKERNSH_OS_LINUX_2_6, - kernsh_alloc_noncontiguous_linux); - kernsh_register_alloc_noncontiguous(LIBKERNSH_OS_LINUX_2_4, - kernsh_alloc_noncontiguous_linux); - - kernsh_register_free_contiguous(LIBKERNSH_OS_LINUX_2_6, - kernsh_free_contiguous_linux); - kernsh_register_free_contiguous(LIBKERNSH_OS_LINUX_2_4, - kernsh_free_contiguous_linux); - - kernsh_register_free_noncontiguous(LIBKERNSH_OS_LINUX_2_6, - kernsh_free_noncontiguous_linux); - kernsh_register_free_noncontiguous(LIBKERNSH_OS_LINUX_2_4, - kernsh_free_noncontiguous_linux); - - kernsh_register_autotypes(LIBKERNSH_ARCH_I386, - LIBKERNSH_OS_LINUX_2_6, - kernsh_autotypes_linux_2_6); - - - kernsh_register_relink(LIBKERNSH_OS_LINUX_2_4, - kernsh_relink_module_linux); - kernsh_register_relink(LIBKERNSH_OS_LINUX_2_6, - kernsh_relink_module_linux); - - kernsh_register_infect(LIBKERNSH_OS_LINUX_2_6, - kernsh_infect_module_linux_2_6); - kernsh_register_infect(LIBKERNSH_OS_LINUX_2_4, - kernsh_infect_module_linux_2_4); - - kernsh_register_kload(LIBKERNSH_OS_LINUX_2_6, - kernsh_kload_module_linux); - kernsh_register_kload(LIBKERNSH_OS_LINUX_2_4, - kernsh_kload_module_linux); - - kernsh_register_kunload(LIBKERNSH_OS_LINUX_2_6, - kernsh_kunload_module_linux); - kernsh_register_kunload(LIBKERNSH_OS_LINUX_2_4, - kernsh_kunload_module_linux); - - /* kvirtm read/write virtm */ - kernsh_register_kvirtm_read_virtm(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_read_virtm_proc_linux); - - kernsh_register_kvirtm_read_virtm(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_read_virtm_proc_linux); - - kernsh_register_kvirtm_read_virtm(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_read_virtm_syscall_linux); - - kernsh_register_kvirtm_read_virtm(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_read_virtm_syscall_linux); - - kernsh_register_kvirtm_read_virtm(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_read_virtm_syscall_linux); - - kernsh_register_kvirtm_write_virtm(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_write_virtm_proc_linux); - - kernsh_register_kvirtm_write_virtm(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_write_virtm_proc_linux); - - kernsh_register_kvirtm_write_virtm(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_write_virtm_syscall_linux); - - kernsh_register_kvirtm_write_virtm(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_write_virtm_syscall_linux); - - /* kvirtm read/write mem */ - kernsh_register_kvirtm_read_mem(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_readmem_proc_linux); - - kernsh_register_kvirtm_read_mem(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_readmem_proc_linux); - - kernsh_register_kvirtm_read_mem(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_readmem_syscall_linux); - - kernsh_register_kvirtm_read_mem(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_readmem_syscall_linux); - - kernsh_register_kvirtm_write_mem(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_writemem_proc_linux); - - kernsh_register_kvirtm_write_mem(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_writemem_proc_linux); - - kernsh_register_kvirtm_write_mem(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_writemem_syscall_linux); - - kernsh_register_kvirtm_write_mem(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_writemem_syscall_linux); - - kernsh_register_kvirtm_task_pid(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_task_pid_proc_linux); - - kernsh_register_kvirtm_task_pid(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_KERNEL_MODE, - kernsh_kvirtm_task_pid_proc_linux); - - kernsh_register_kvirtm_task_pid(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_task_pid_syscall_linux); - - kernsh_register_kvirtm_task_pid(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_USER_MODE, - kernsh_kvirtm_task_pid_syscall_linux); - - kernsh_register_kdump_get_vma(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_VMA_USERLAND, - kernsh_kdump_get_vma_userland_linux); - - kernsh_register_kdump_get_vma(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_VMA_USERLAND, - kernsh_kdump_get_vma_userland_linux); - - kernsh_register_kdump_vma(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_VMA_USERLAND, - kernsh_kdump_vma_userland_linux); - - kernsh_register_kdump_vma(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_VMA_USERLAND, - kernsh_kdump_vma_userland_linux); - - kernsh_register_kdump_vma(LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_VMA_KERNELLAND, - kernsh_kdump_vma_kernelland_linux); - - kernsh_register_kdump_vma(LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_VMA_KERNELLAND, - kernsh_kdump_vma_kernelland_linux); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/vectors_default.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors_default.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/vectors_default.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors_default.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,344 +0,0 @@ -/* -** @file vectors_default.c -** @ingroup libkernsh_common -** -*/ - -#include "libkernsh.h" - - -int kernsh_openmem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("OPENMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "openmem default !", -1); -} - -int kernsh_closemem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("CLOSEMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "closemem default !", -1); -} - -int kernsh_readmem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("READMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "readmem default !", -1); -} - -int kernsh_writemem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("WRITEMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "writemem default !", -1); -} - -int kernsh_sct_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("SCT DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "sct default !", -1); -} - -int kernsh_callsc_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("CALL SC DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "call sc default !", -1); -} - -int kernsh_idt_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("IDT DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "idt default !", -1); -} - -int kernsh_gdt_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("GDT DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "gdt default !", -1); -} - -int kernsh_info_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("INFO DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "info default !", -1); -} - -int kernsh_decompkernel_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("DECOMPKERNEL DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "decompkernel default !", -1); -} - -int kernsh_loadkernel_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("LOADKERNEL DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "loadkernel default !", -1); -} - -int kernsh_autotypes_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("AUTOTYPES DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "autotypes default !", -1); -} - -int kernsh_symbs_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("SYMBS DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "symbs default !", -1); -} - -int kernsh_alloc_contiguous_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("ALLOC CONTIGUOUS DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "alloc contiguous default !", -1); -} - -int kernsh_alloc_noncontiguous_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("ALLOC NON CONTIGUOUS DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "alloc non contiguous default !", -1); -} - -int kernsh_free_contiguous_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("FREE CONTIGUOUS DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "free contiguous default !", -1); -} - -int kernsh_free_noncontiguous_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("FREE NON CONTIGUOUS DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "free non contiguous default !", -1); -} - -int kernsh_relink_module_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("RELINK MODULE DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "relink module default !", -1); -} - -int kernsh_infect_module_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("INFECT MODULE DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "infect module default !", -1); -} - -int kernsh_kload_module_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KLOAD MODULE DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kload module default !", -1); -} - -int kernsh_kunload_module_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KUNLOAD MODULE DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kunload module default !", -1); -} - -int kernsh_kvirtm_read_virtm_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KVIRTM READ VIRTM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kvirtm read virtm default !", -1); -} - -int kernsh_kvirtm_read_mem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KVIRTM READ MEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kvirtm read mem default !", -1); -} - -int kernsh_kvirtm_write_virtm_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KVIRTM WRITE VIRTM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kvirtm write virtm default !", -1); -} - -int kernsh_kvirtm_write_mem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KVIRTM WRITE MEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kvirtm write mem default !", -1); -} - -int kernsh_kvirtm_task_pid_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KVIRTM TASK PID DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kvirtm task pid default !", -1); -} - -int kernsh_kdump_get_vma_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KDUMP GET VMA DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kdump get vma default !", -1); -} - -int kernsh_kdump_vma_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("KDUMP VMA DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "kdump vma default !", -1); -} diff -Nru eresi-0.8a25/libkernsh/common/.svn/text-base/vectors_register.c.svn-base eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors_register.c.svn-base --- eresi-0.8a25/libkernsh/common/.svn/text-base/vectors_register.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/.svn/text-base/vectors_register.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,633 +0,0 @@ -/* -** @file vectors_register.c -** @ingroup libkernsh_common -** -*/ -#include "libkernsh.h" - -int kernsh_register_openmem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_OPENMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER OPENMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_closemem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CLOSEMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER CLOSEMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -int kernsh_register_readmem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_READMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER READMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -int kernsh_register_writemem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_WRITEMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER WRITEMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_sct(u_int archtype, u_int ostype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_SCT); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER SCT\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_callsc(u_int ostype, void *fct) -{ - - vector_t *csc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - csc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_CALLSC); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER CALLSC CONTIGUOUS\n"); -#endif - - aspect_vectors_insert(csc, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_idt(u_int archtype, u_int ostype, void *fct) -{ - vector_t *idt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - idt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_IDT); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER IDT\n"); -#endif - - aspect_vectors_insert(idt, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_gdt(u_int archtype, u_int ostype, void *fct) -{ - vector_t *gdt; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - gdt = aspect_vector_get(LIBKERNSH_VECTOR_NAME_GDT); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER GDT\n"); -#endif - - aspect_vectors_insert(gdt, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_info(u_int archtype, u_int ostype, void *fct) -{ - vector_t *info; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - info = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFO); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER INFO\n"); -#endif - - aspect_vectors_insert(info, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_decompkernel(u_int ostype, void *fct) -{ - - vector_t *decomp; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - decomp = aspect_vector_get(LIBKERNSH_VECTOR_NAME_DECOMPKERNEL); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER DECOMP KERNEL\n"); -#endif - - aspect_vectors_insert(decomp, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_symbs_abn(u_int archtype, u_int ostype, void *fct) -{ - vector_t *abn; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - abn = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ADDRBYNAME); - - dim = alloca(sizeof(u_int) * 2); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER SYMBS ABN\n"); -#endif - - aspect_vectors_insert(abn, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_symbs_nba(u_int archtype, u_int ostype, void *fct) -{ - vector_t *nba; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - nba = aspect_vector_get(LIBKERNSH_VECTOR_NAME_NAMEBYADDR); - - dim = alloca(sizeof(u_int) * 2); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER SYMBS NBA\n"); -#endif - - aspect_vectors_insert(nba, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_alloc_contiguous(u_int ostype, void *fct) -{ - - vector_t *alloc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER ALLOC CONTIGUOUS\n"); -#endif - - aspect_vectors_insert(alloc, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_alloc_noncontiguous(u_int ostype, void *fct) -{ - - vector_t *alloc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER ALLOC NON CONTIGUOUS\n"); -#endif - - aspect_vectors_insert(alloc, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_free_contiguous(u_int ostype, void *fct) -{ - - vector_t *alloc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER FREE CONTIGUOUS\n"); -#endif - - aspect_vectors_insert(alloc, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_free_noncontiguous(u_int ostype, void *fct) -{ - - vector_t *alloc; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER FREE NON CONTIGUOUS\n"); -#endif - - aspect_vectors_insert(alloc, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_autotypes(u_int archtype, u_int ostype, void *fct) -{ - vector_t *autotypes; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - autotypes = aspect_vector_get(LIBKERNSH_VECTOR_NAME_AUTOTYPES); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = archtype; - dim[1] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER AUTOTYPES\n"); -#endif - - aspect_vectors_insert(autotypes, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_relink(u_int ostype, void *fct) -{ - - vector_t *rel; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - rel = aspect_vector_get(LIBKERNSH_VECTOR_NAME_RELINKMODULE); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER RELINK MODULE\n"); -#endif - - aspect_vectors_insert(rel, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_infect(u_int ostype, void *fct) -{ - - vector_t *inf; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - inf = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFECTMODULE); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER INFECT MODULE\n"); -#endif - - aspect_vectors_insert(inf, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kload(u_int ostype, void *fct) -{ - - vector_t *kload; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - kload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KLOADMODULE); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KLOAD MODULE\n"); -#endif - - aspect_vectors_insert(kload, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kunload(u_int ostype, void *fct) -{ - - vector_t *kunload; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - kunload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KUNLOADMODULE); - - dim = alloca(sizeof(u_int) * 1); - dim[0] = ostype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KUNLOAD MODULE\n"); -#endif - - aspect_vectors_insert(kunload, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kvirtm_read_virtm(u_int ostype, u_int virtmtype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADVIRTM); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = virtmtype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KVIRTM READ VIRTM\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kvirtm_read_mem(u_int ostype, u_int virtmtype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = virtmtype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KVIRTM READ MEM\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -int kernsh_register_kvirtm_write_virtm(u_int ostype, u_int virtmtype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEVIRTM); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = virtmtype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KVIRTM WRITE VIRTM\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kvirtm_write_mem(u_int ostype, u_int virtmtype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEMEM); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = virtmtype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KVIRTM WRITE MEM\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kvirtm_task_pid(u_int ostype, u_int virtmtype, void *fct) -{ - vector_t *sct; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = virtmtype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KVIRTM TASK PID\n"); -#endif - - aspect_vectors_insert(sct, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kdump_get_vma(u_int ostype, u_int vmatype, void *fct) -{ - vector_t *vma; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - vma = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPGETVMA); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = vmatype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KDUMP GET VMA\n"); -#endif - - aspect_vectors_insert(vma, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_register_kdump_vma(u_int ostype, u_int vmatype, void *fct) -{ - vector_t *vma; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - vma = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KDUMPVMA); - - dim = alloca(sizeof(u_int) * 3); - dim[0] = ostype; - dim[1] = vmatype; - -#if __DEBUG_KERNSH__ - printf("REGISTER KDUMP VMA\n"); -#endif - - aspect_vectors_insert(vma, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/common/vectors.c eresi-0.0.20110516/libkernsh/common/vectors.c --- eresi-0.8a25/libkernsh/common/vectors.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/vectors.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @defgroup libkernsh_common libkernsh_common + * @defgroup common Common code between user and kernel land. + * @ingroup libkernsh */ /* -** @file vectors.c -** @ingroup libkernsh_common +* @file libkernsh/common/vectors.c +** @ingroup common ** */ #include "libkernsh.h" @@ -48,14 +49,6 @@ kernsh_closemem_default, dims, strdims, 3, ASPECT_TYPE_CADDR); - aspect_register_vector(LIBKERNSH_VECTOR_NAME_READMEM, - kernsh_readmem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - - aspect_register_vector(LIBKERNSH_VECTOR_NAME_WRITEMEM, - kernsh_writemem_default, - dims, strdims, 3, ASPECT_TYPE_CADDR); - /* Syscalls ARCH, OS */ #if __DEBUG_KERNSH__ @@ -385,85 +378,48 @@ LIBKERNSH_DEVICE_KVIRTM, kernsh_kvirtm_closemem); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_readmem_kmem_linux_2_6); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_readmem_kmem_linux_2_4); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_mem_linux); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_mem_linux); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_readmem_kcore_linux_2_6); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, - kernsh_readmem_netbsd); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_readmem); - kernsh_register_readmem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_readmem); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVKMEM26, kernsh_readmema_kmem_linux_2_6); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVKMEM24, kernsh_readmema_kmem_linux_2_4); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVMEM26, kernsh_readmema_mem_linux); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVMEM24, kernsh_readmema_mem_linux); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_KCORE, kernsh_readmema_kcore_linux_2_6); + elfsh_register_readmema(ELFSH_OS_NETBSD, ELFSH_IOTYPE_DEVMEM24, kernsh_readmema_netbsd); + elfsh_register_readmema(ELFSH_OS_NETBSD, ELFSH_IOTYPE_DEVMEM26, kernsh_readmema_netbsd); + elfsh_register_readmema(ELFSH_OS_LINUX, ELFSH_IOTYPE_KVIRTM, kernsh_kvirtm_readmema); + + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVKMEM26, kernsh_writemem_kmem_linux_2_6); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVKMEM24, kernsh_writemem_kmem_linux_2_4); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVMEM24, kernsh_writemem_mem_linux); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_DEVMEM26, kernsh_writemem_mem_linux); + elfsh_register_writemem(ELFSH_OS_LINUX, ELFSH_IOTYPE_KCORE, kernsh_writemem_kcore_linux_2_6); + elfsh_register_writemem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_DEVMEM26, kernsh_writemem_netbsd); + elfsh_register_writemem(ELFSH_OS_NETBSD, ELFSH_IOTYPE_DEVMEM26, kernsh_writemem_netbsd); + + elfsh_register_writememf(ELFSH_HOST_KERN, LIBELFSH_MODE_STATIC, kernsh_raw_write); + elfsh_register_writememf(ELFSH_HOST_KERN, LIBELFSH_MODE_RUNTIME, kernsh_raw_write); + + elfsh_register_readmemf(ELFSH_HOST_KERN, LIBELFSH_MODE_STATIC, kernsh_raw_read); + elfsh_register_readmemf(ELFSH_HOST_KERN, LIBELFSH_MODE_RUNTIME, kernsh_raw_read); + + elfsh_register_allochook(ELFSH_HOST_KERN, kernsh_alloc); + + kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, kernsh_sct_linux); + kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, kernsh_sct_linux); + + kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_6, kernsh_syscall_linux); + kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_4, kernsh_syscall_linux); + + kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, kernsh_idt_linux); + kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, kernsh_idt_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KMEM, - kernsh_writemem_kmem_linux_2_6); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KMEM, - kernsh_writemem_kmem_linux_2_4); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_MEM, - kernsh_writemem_mem_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_MEM, - kernsh_writemem_mem_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KCORE, - kernsh_writemem_kcore_linux_2_6); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_NETBSD, - LIBKERNSH_DEVICE_MEM, kernsh_writemem_netbsd); + kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, kernsh_gdt_linux); + kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, kernsh_gdt_linux); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_writemem); - kernsh_register_writemem(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_DEVICE_KVIRTM, - kernsh_kvirtm_writemem); + kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, kernsh_info_linux); + kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, kernsh_info_linux); - kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_sct_linux); - kernsh_register_sct(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_sct_linux); - - kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_6, - kernsh_syscall_linux); - kernsh_register_callsc(LIBKERNSH_OS_LINUX_2_4, - kernsh_syscall_linux); - - kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_idt_linux); - kernsh_register_idt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_idt_linux); - - kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_gdt_linux); - kernsh_register_gdt(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_gdt_linux); - - kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, - kernsh_info_linux); - kernsh_register_info(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_4, - kernsh_info_linux); - - kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_6, - kernsh_decompkernel_linux); - kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_4, - kernsh_decompkernel_linux); + kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_6, kernsh_decompkernel_linux); + kernsh_register_decompkernel(LIBKERNSH_OS_LINUX_2_4, kernsh_decompkernel_linux); kernsh_register_symbs_abn(LIBKERNSH_ARCH_I386, LIBKERNSH_OS_LINUX_2_6, diff -Nru eresi-0.8a25/libkernsh/common/vectors_default.c eresi-0.0.20110516/libkernsh/common/vectors_default.c --- eresi-0.8a25/libkernsh/common/vectors_default.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/vectors_default.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file vectors_default.c -** @ingroup libkernsh_common +* @file libkernsh/common/vectors_default.c +** @ingroup common ** */ @@ -31,30 +31,6 @@ "closemem default !", -1); } -int kernsh_readmem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("READMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "readmem default !", -1); -} - -int kernsh_writemem_default() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNEL__ - printf("WRITEMEM DEFAULT!!!\n"); -#endif - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "writemem default !", -1); -} - int kernsh_sct_default() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/libkernsh/common/vectors_register.c eresi-0.0.20110516/libkernsh/common/vectors_register.c --- eresi-0.8a25/libkernsh/common/vectors_register.c 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/common/vectors_register.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file vectors_register.c -** @ingroup libkernsh_common +* @file libkernsh/common/vectors_register.c +** @ingroup common ** */ #include "libkernsh.h" @@ -54,55 +54,6 @@ } -int kernsh_register_readmem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_READMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER READMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -int kernsh_register_writemem(u_int archtype, u_int ostype, u_int devicetype, - void *fct) -{ - vector_t *mem; - u_int *dim; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mem = aspect_vector_get(LIBKERNSH_VECTOR_NAME_WRITEMEM); - - dim = alloca(sizeof(u_int) * 4); - dim[0] = archtype; - dim[1] = ostype; - dim[2] = devicetype; - -#if __DEBUG_KERNSH__ - printf("REGISTER WRITEMEM\n"); -#endif - - aspect_vectors_insert(mem, dim, (int)fct); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - int kernsh_register_sct(u_int archtype, u_int ostype, void *fct) { vector_t *sct; @@ -499,13 +450,12 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -int kernsh_register_kvirtm_read_mem(u_int ostype, u_int virtmtype, void *fct) +int kernsh_register_kvirtm_read_mem(u_int ostype, u_int virtmtype, void *fct) { - vector_t *sct; - u_int *dim; + vector_t *sct; + u_int *dim; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - sct = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM); dim = alloca(sizeof(u_int) * 3); @@ -516,8 +466,7 @@ printf("REGISTER KVIRTM READ MEM\n"); #endif - aspect_vectors_insert(sct, dim, (int)fct); - + aspect_vectors_insert(sct, dim, (u_long) fct); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libkernsh/doc/.svn/all-wcprops eresi-0.0.20110516/libkernsh/doc/.svn/all-wcprops --- eresi-0.8a25/libkernsh/doc/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/903/trunk/libkernsh/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/903/trunk/libkernsh/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libkernsh/doc/.svn/entries eresi-0.0.20110516/libkernsh/doc/.svn/entries --- eresi-0.8a25/libkernsh/doc/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/doc -http://svn.eresi-project.org/svn - - - -2008-03-09T15:27:32.066882Z -903 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:27.255886Z -65cb25ea69b00d90477144d026d0e5ea -2008-03-09T15:27:32.066882Z -903 -pouik - diff -Nru eresi-0.8a25/libkernsh/doc/.svn/format eresi-0.0.20110516/libkernsh/doc/.svn/format --- eresi-0.8a25/libkernsh/doc/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libkernsh/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libkernsh/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libkernsh - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = YES - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./ include - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libkernsh - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = LATEX - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = libkernsh-latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = YES - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = YES - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = YES - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = YES diff -Nru eresi-0.8a25/libkernsh/include/libkernsh.h eresi-0.0.20110516/libkernsh/include/libkernsh.h --- eresi-0.8a25/libkernsh/include/libkernsh.h 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/libkernsh.h 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,10 @@ -/* -** libkernsh.h for libkernsh -** +/** + * @defgroup libkernsh + * @ingroup kernsh + */ +/** +* @file libkernsh/include/libkernsh.h +** @ingroup libkernsh ** */ #ifndef __LIBKERNSH_H__ @@ -113,41 +117,41 @@ #define __DEBUG_KERNSH__ 0 -#define LIBKERNSH_VMCONFIG_WITHOUT_KERNEL "libkernsh.without_kernel" -#define LIBKERNSH_VMCONFIG_DEVICE "libkernsh.device" -#define LIBKERNSH_VMCONFIG_MODE "libkernsh.mode" -#define LIBKERNSH_VMCONFIG_SYSTEMMAP "libkernsh.systemmap" -#define LIBKERNSH_VMCONFIG_MMAP "libkernsh.mmap" -#define LIBKERNSH_VMCONFIG_MMAP_SIZE "libkernsh.mmapsize" -#define LIBKERNSH_VMCONFIG_KERNEL "libkernsh.kernel" -#define LIBKERNSH_VMCONFIG_GZIP "libkernsh.gzipcmd" -#define LIBKERNSH_VMCONFIG_OBJCOPY "libkernsh.objcopycmd" -#define LIBKERNSH_VMCONFIG_LD "libkernsh.ldcmd" -#define LIBKERNSH_VMCONFIG_KERNELGZ "libkernsh.kernelgz" -#define LIBKERNSH_VMCONFIG_KERNELELF "libkernsh.kernelelf" -#define LIBKERNSH_VMCONFIG_USE_KERNEL "libkernsh.use_kernel" -#define LIBKERNSH_VMCONFIG_STORAGE_PATH "libkernsh.storagepath" -#define LIBKERNSH_VMCONFIG_NB_SYSCALLS "libkernsh.nbsyscalls" -#define LIBKERNSH_VMCONFIG_NIL_SYSCALL "libkernsh.nilsyscall" -#define LIBKERNSH_VMCONFIG_KERNEL_START "libkernsh.kernel_start" -#define LIBKERNSH_VMCONFIG_KERNEL_END "libkernsh.kernel_end" -#define LIBKERNSH_VMCONFIG_ALLOC "libkernsh.alloc" -#define LIBKERNSH_VMCONFIG_KLOAD "libkernsh.kload" -#define LIBKERNSH_VMCONFIG_KUNLOAD "libkernsh.kunload" -#define LIBKERNSH_VMCONFIG_FENDSIZE "libkernsh.fendsize" -#define LIBKERNSH_VMCONFIG_USEVM "libkernsh.usevm" -#define LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE "libkernsh.specify_idtbase" -#define LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT "libkernsh.specify_idtlimit" -#define LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE "libkernsh.specify_gdtbase" -#define LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT "libkernsh.specify_gdtlimit" -#define LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL "libkernsh.specify_systemcall" -#define LIBKERNSH_VMCONFIG_SPECIFY_SCT "libkernsh.specify_sct" -#define LIBKERNSH_VMCONFIG_VIRTM "libkernsh.virtm" -#define LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL "libkernsh.virtm_nil_syscall" -#define LIBKERNSH_VMCONFIG_HASH "libkernsh.hash" -#define LIBKERNSH_VMCONFIG_VMA "libkernsh.vma" -#define LIBKERNSH_VMCONFIG_VMA_PREFIX "libkernsh.vma_prefix" -#define LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX "libkernsh.dump_vma_prefix" +#define LIBKERNSH_CONFIG_WITHOUT_KERNEL "libkernsh.without_kernel" +#define LIBKERNSH_CONFIG_DEVICE "libkernsh.device" +#define LIBKERNSH_CONFIG_MODE "libkernsh.mode" +#define LIBKERNSH_CONFIG_SYSTEMMAP "libkernsh.systemmap" +#define LIBKERNSH_CONFIG_MMAP "libkernsh.mmap" +#define LIBKERNSH_CONFIG_MMAP_SIZE "libkernsh.mmapsize" +#define LIBKERNSH_CONFIG_KERNEL "libkernsh.kernel" +#define LIBKERNSH_CONFIG_GZIP "libkernsh.gzipcmd" +#define LIBKERNSH_CONFIG_OBJCOPY "libkernsh.objcopycmd" +#define LIBKERNSH_CONFIG_LD "libkernsh.ldcmd" +#define LIBKERNSH_CONFIG_KERNELGZ "libkernsh.kernelgz" +#define LIBKERNSH_CONFIG_KERNELELF "libkernsh.kernelelf" +#define LIBKERNSH_CONFIG_USE_KERNEL "libkernsh.use_kernel" +#define LIBKERNSH_CONFIG_STORAGE_PATH "libkernsh.storagepath" +#define LIBKERNSH_CONFIG_NB_SYSCALLS "libkernsh.nbsyscalls" +#define LIBKERNSH_CONFIG_NIL_SYSCALL "libkernsh.nilsyscall" +#define LIBKERNSH_CONFIG_KERNEL_START "libkernsh.kernel_start" +#define LIBKERNSH_CONFIG_KERNEL_END "libkernsh.kernel_end" +#define LIBKERNSH_CONFIG_ALLOC "libkernsh.alloc" +#define LIBKERNSH_CONFIG_KLOAD "libkernsh.kload" +#define LIBKERNSH_CONFIG_KUNLOAD "libkernsh.kunload" +#define LIBKERNSH_CONFIG_FENDSIZE "libkernsh.fendsize" +#define LIBKERNSH_CONFIG_USEVM "libkernsh.usevm" +#define LIBKERNSH_CONFIG_SPECIFY_IDTBASE "libkernsh.specify_idtbase" +#define LIBKERNSH_CONFIG_SPECIFY_IDTLIMIT "libkernsh.specify_idtlimit" +#define LIBKERNSH_CONFIG_SPECIFY_GDTBASE "libkernsh.specify_gdtbase" +#define LIBKERNSH_CONFIG_SPECIFY_GDTLIMIT "libkernsh.specify_gdtlimit" +#define LIBKERNSH_CONFIG_SPECIFY_SYSTEMCALL "libkernsh.specify_systemcall" +#define LIBKERNSH_CONFIG_SPECIFY_SCT "libkernsh.specify_sct" +#define LIBKERNSH_CONFIG_VIRTM "libkernsh.virtm" +#define LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL "libkernsh.virtm_nil_syscall" +#define LIBKERNSH_CONFIG_HASH "libkernsh.hash" +#define LIBKERNSH_CONFIG_VMA "libkernsh.vma" +#define LIBKERNSH_CONFIG_VMA_PREFIX "libkernsh.vma_prefix" +#define LIBKERNSH_CONFIG_DUMP_VMA_PREFIX "libkernsh.dump_vma_prefix" #define LIBKERNSH_DEFAULT_LINUX_KERNEL "/boot/vmlinuz" @@ -187,8 +191,6 @@ #define LIBKERNSH_VECTOR_NAME_OPENMEM "openmem" #define LIBKERNSH_VECTOR_NAME_CLOSEMEM "closemem" -#define LIBKERNSH_VECTOR_NAME_READMEM "readmem" -#define LIBKERNSH_VECTOR_NAME_WRITEMEM "writemem" #define LIBKERNSH_VECTOR_NAME_SCT "sct" #define LIBKERNSH_VECTOR_NAME_IDT "idt" #define LIBKERNSH_VECTOR_NAME_GDT "gdt" @@ -219,92 +221,96 @@ /* Idtr segment struct */ struct { - unsigned short limit; - unsigned long base; + unsigned short limit; + unsigned long base; } __attribute__((packed)) idtr; /* Interrupt descriptor */ struct { - unsigned short off1; - unsigned short sel; - unsigned char none,flags; - unsigned short off2; + unsigned short off1; + unsigned short sel; + unsigned char none,flags; + unsigned short off2; } __attribute__ ((packed)) idt; /* gdtr */ struct { - unsigned short limit; - unsigned long base; -} __attribute__ ((packed))gdtr; + unsigned short limit; + unsigned long base; +} __attribute__ ((packed)) gdtr; + /** * @brief Kmalloc struct */ -typedef struct s_libkernshkma +typedef struct s_libkernshkma { - unsigned long ( *kexec )( size_t, int ); /* Execution of kmalloc */ - int size; /* Size to alloc */ - int flags; /* Flags, by default GFP_KERNEL */ - unsigned long mem; /* The address where the allocation has been done */ -} libkernshkma_t ; + eresi_Addr (*kexec)(size_t, int); /* Execution of kmalloc */ + int size; /* Size to alloc */ + int flags; /* Flags, by default GFP_KERNEL */ + unsigned long mem; /* The address where the allocation has been done */ +} libkernshkma_t; + /** * @brief Kfree struct */ -typedef struct s_libkernshkfr +typedef struct s_libkernshkfr { - unsigned long ( *kexec )( const void * ); /* Execution of kfree */ - const void * address; /* Address to be free */ -} libkernshkfr_t; + unsigned long (*kexec)(const void *); /* Execution of kfree */ + const void *address; /* Address to be free */ +} libkernshkfr_t; + /** * @brief Vmalloc struct */ -typedef struct s_libkernshvma +typedef struct s_libkernshvma { - unsigned long ( *kexec )( size_t ); /* Execution of vmalloc */ - int size; /* Size to alloc */ - unsigned long mem; /* The address where the allocation has been done */ -} libkernshvma_t; + unsigned long (*kexec)(size_t); /* Execution of vmalloc */ + int size; /* Size to alloc */ + unsigned long mem; /* The address where the allocation has been done */ +} libkernshvma_t; + /** * @brief Vfree struct */ -typedef struct s_libkernshvfr +typedef struct s_libkernshvfr { - unsigned long ( *kexec )( void * ); /* Execution of vfree */ - void * address; /* Address to be free */ -} libkernshvfr_t; + unsigned long (*kexec)(void *); /* Execution of vfree */ + void *address; /* Address to be free */ +} libkernshvfr_t; /** * @brief Syscall struct */ -typedef struct s_libkernshsyscall +typedef struct s_libkernshsyscall { - unsigned long addr; - char name[NAMESIZ]; -} libkernshsyscall_t; + eresi_Addr addr; + char name[NAMESIZ]; +} libkernshsyscall_t; /** * @brief Interrupt struct */ -typedef struct s_libkernshint +typedef struct s_libkernshint { - unsigned long addr; - char name[NAMESIZ]; -} libkernshint_t; + eresi_Addr addr; + char name[NAMESIZ]; +} libkernshint_t; /** * @brief Gdt segment struct */ -typedef struct s_libkernshsgdt +typedef struct s_libkernshsgdt { - unsigned long addr; - unsigned long deb; - unsigned long fin; -} libkernshsgdt_t; + eresi_Addr addr; + eresi_Addr deb; + eresi_Addr fin; +} libkernshsgdt_t; /** * @brief md5 context @@ -314,125 +320,89 @@ unsigned long buf[4]; unsigned long bits[2]; unsigned char in[64]; -} libkernshmd5context_t; +} libkernshmd5context_t; /** * @brief dec task */ -typedef struct s_dectask +typedef struct s_dectask { - int dec_list; - int dec_pid; - int dec_uid; -} dectask_t; + int dec_list; + int dec_pid; + int dec_uid; +} dectask_t; /** * @brief auto task */ -typedef struct s_autotask +typedef struct s_autotask { - int offset_name; - int offset_list; - int offset_next; - int offset_pid; - int offset_uid; - - dectask_t dectask; -} autotask_t; + int offset_name; + int offset_list; + int offset_next; + int offset_pid; + int offset_uid; + dectask_t dectask; +} autotask_t; /** * @brief World kernsh struct */ -typedef struct s_libkernshworld +typedef struct s_libkernshworld { - u_int arch; /* Arch type */ - u_int os; /* Os type */ - u_int device; /* Device type */ - - int present; /* Flag to test kernsh's present */ - int open; /* 0 => memory close, 1 => memory open */ - int open_static; /* 0 => static kernel close, - 1 => static kernel open */ - - char *release; /* Release name */ - - int fd; /* !< @brief File descriptor for the memory */ - int fdmode; /* Mode to open memory (read/write) */ - int protmode; /* Protection mode to mmap */ - int flagsmode; /* Flags mode to mmap */ - - int mmap; /* 0 => memory not mmap - 1 => memory mmap */ - int mmap_size; /* Size of the mmap */ - void *ptr; /* Pointer of the mmap*/ - - unsigned long kernel_start; /* Address of kernel start */ - unsigned long kernel_end; /* Address of kernel end */ - - int mem; /* Static/Mem mode */ - - int physical; /* 0 => virtual memory address - 1 => physical memory address */ - - unsigned long idt_base; /* Address of idt table */ - unsigned short idt_limit; /* Length */ + u_int arch; /* Arch type */ + u_int os; /* Os type */ + u_int device; /* Device type */ + int open; /* 0 => memory close, 1 => memory open */ + int open_static; /* 0 => static kernel close, 1 => open */ + char *release; /* Release name */ + int fd; /* !< @brief File descriptor for the memory */ + int fdmode; /* Mode to open memory (read/write) */ + int protmode; /* Protection mode to mmap */ + int flagsmode; /* Flags mode to mmap */ + int mmap; /* 0 => memory not mmap, 1 => memory mmap */ + int mmap_size; /* Size of the mmap */ + void *ptr; /* Pointer of the mmap */ + eresi_Addr kernel_start; /* Address of kernel start */ + eresi_Addr kernel_end; /* Address of kernel end */ + int mem; /* Static/Mem mode */ + int physical; /* 0 => virtual memory address, 1 => physical memory addr */ + eresi_Addr idt_base; /* Address of idt table */ + u_short idt_limit; /* Length */ + eresi_Addr sct; /* Address of syscall table */ + eresi_Addr system_call; + eresi_Addr gdt_base; /* Address of the gdt table */ + u_short gdt_limit; /* Lenght */ + autotask_t typetask; /* Make type for task_struct */ + asm_processor proc; /* To play with libasm of course */ + elfshobj_t *root; /* Pointer to the kernel's elfshobj_t*/ +} libkernshworld_t; - unsigned long sct; /* Address of syscall table */ - -#if defined(__linux__) - unsigned long system_call; -#endif - unsigned long gdt_base; /* Address of the gdt table */ - unsigned short gdt_limit; /* Lenght */ +extern libkernshworld_t libkernshworld; /* Global libkernsh struct */ - autotask_t typetask; /* Make type for task_struct */ - - asm_processor proc; /* To play with libasm of course */ - elfshobj_t *root; /* Pointer to the kernel's elfshobj_t*/ -} libkernshworld_t; - -extern libkernshworld_t libkernshworld; /* Global libkernsh struct - W00t W00t use it please !*/ /* Init lib */ -int kernsh_init_ia32(char *, char *); -int kernsh_del_ia32(); - -/* Get raw */ -void *kernsh_elfsh_get_raw(elfshsect_t *); -void *kernsh_revm_get_raw(void *); +int kernsh_init_ia32(char *, char *); +int kernsh_del_ia32(); /* Information about kernel */ -int kernsh_info(); -int kernsh_info_linux(); -int kernsh_info_netbsd(); -int kernsh_info_freebsd(); - +int kernsh_info(); +int kernsh_info_linux(); +int kernsh_info_netbsd(); +int kernsh_info_freebsd(); elfshobj_t *kernsh_load_file(char *); void kernsh_unload_file(elfshobj_t *); -/* Memory or Static mode */ -int kernsh_is_mem_mode(); -int kernsh_set_mem_mode(); -int kernsh_is_static_mode(); -int kernsh_set_static_mode(); -int kernsh_get_mode(); -int kernsh_set_mode(int); - -void kernsh_present_set(); -int kernsh_is_present(); - /* Raw mode */ -int kernsh_raw_write(elfshobj_t *, u_int, void *, int); -int kernsh_raw_read(elfshobj_t *, u_int, void *, int); - -/* Default vectors */ +int kernsh_raw_write(elfshobj_t *, u_int, void *, int); +int kernsh_raw_read(elfshobj_t *, u_int, void *, int); +void *kernsh_get_raw(elfshsect_t *); +void *kernsh_get_raw_by_addr(elfshobj_t *, eresi_Addr, void*, u_int); +/* Default vector handlers */ int kernsh_openmem_default(); int kernsh_closemem_default(); -int kernsh_readmem_default(); -int kernsh_writemem_default(); int kernsh_sct_default(); int kernsh_callsc_default(); int kernsh_idt_default(); @@ -463,8 +433,6 @@ int kernsh_register_vectors(); int kernsh_register_openmem(u_int, u_int, u_int, void *); int kernsh_register_closemem(u_int, u_int, u_int, void *); -int kernsh_register_readmem(u_int, u_int, u_int, void *); -int kernsh_register_writemem(u_int, u_int, u_int, void *); int kernsh_register_sct(u_int, u_int, void *); int kernsh_register_callsc(u_int, void *); int kernsh_register_idt(u_int, u_int, void *); @@ -505,19 +473,17 @@ int kernsh_closemem_kcore_linux_2_6(); int kernsh_closemem_netbsd(); -int kernsh_readmem(unsigned long, void *, int); -int kernsh_readmem_kmem_linux_2_6(unsigned long, void *, int); -int kernsh_readmem_kmem_linux_2_4(unsigned long, void *, int); -int kernsh_readmem_mem_linux(unsigned long, void *, int); -int kernsh_readmem_kcore_linux_2_6(unsigned long, void *, int); -int kernsh_readmem_netbsd(unsigned long, void *, int); - -int kernsh_writemem(unsigned long, void *, int); -int kernsh_writemem_kmem_linux_2_6(unsigned long, void *, int); -int kernsh_writemem_kmem_linux_2_4(unsigned long, void *, int); -int kernsh_writemem_mem_linux(unsigned long, void *, int); -int kernsh_writemem_kcore_linux_2_6(unsigned long, void *, int); -int kernsh_writemem_netbsd(unsigned long, void *, int); +void *kernsh_readmema_kmem_linux_2_6(elfshobj_t *file, eresi_Addr, void *, int); +void *kernsh_readmema_kmem_linux_2_4(elfshobj_t *file, eresi_Addr, void *, int); +void *kernsh_readmema_mem_linux(elfshobj_t *file, eresi_Addr, void *, int); +void *kernsh_readmema_kcore_linux_2_6(elfshobj_t *file, eresi_Addr, void *, int); +void *kernsh_readmema_netbsd(elfshobj_t *file, eresi_Addr, void *, int); + +int kernsh_writemem_kmem_linux_2_6(elfshobj_t *file, eresi_Addr, void *, int); +int kernsh_writemem_kmem_linux_2_4(elfshobj_t *file, eresi_Addr, void *, int); +int kernsh_writemem_mem_linux(elfshobj_t *file, eresi_Addr, void *, int); +int kernsh_writemem_kcore_linux_2_6(elfshobj_t *file, eresi_Addr, void *, int); +int kernsh_writemem_netbsd(elfshobj_t *file, eresi_Addr, void *, int); /* Syscalls table */ int kernsh_sct(list_t *); @@ -541,33 +507,30 @@ int kernsh_gdt_freebsd(list_t *); /* Symbols */ -int kernsh_get_addr_by_name(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr(unsigned long, char *, size_t); - -int kernsh_get_addr_by_name_linux_2_6(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr_linux_2_6(unsigned long, char *, size_t); -int kernsh_get_addr_by_name_linux_2_4(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr_linux_2_4(unsigned long, char *, size_t); +int kernsh_get_addr_by_name(char *, eresi_Addr*, size_t); +int kernsh_get_name_by_addr(eresi_Addr, char *, size_t); -int kernsh_walk_kstrtab(const char *, unsigned long *, size_t); -int kernsh_get_kernel_syms(char *, unsigned long *, size_t); - -/* Tasks */ +int kernsh_get_addr_by_name_linux_2_6(char *, eresi_Addr*, size_t); +int kernsh_get_name_by_addr_linux_2_6(eresi_Addr, char *, size_t); +int kernsh_get_addr_by_name_linux_2_4(char *, eresi_Addr*, size_t); +int kernsh_get_name_by_addr_linux_2_4(eresi_Addr, char *, size_t); +int kernsh_walk_kstrtab(const char *, eresi_Addr*, size_t); +int kernsh_get_kernel_syms(char *, eresi_Addr*, size_t); /* Alloc-Free */ -int kernsh_alloc(size_t, unsigned long *); -int kernsh_free(unsigned long); +eresi_Addr kernsh_alloc(elfshobj_t *file, size_t size, int prot); +int kernsh_free(eresi_Addr); -int kernsh_alloc_contiguous(size_t, unsigned long *); -int kernsh_free_contiguous(unsigned long); -int kernsh_alloc_noncontiguous(size_t, unsigned long *); -int kernsh_free_noncontiguous(unsigned long); - -int kernsh_alloc_contiguous_linux(size_t, unsigned long *); -int kernsh_free_contiguous_linux(unsigned long); -int kernsh_alloc_noncontiguous_linux(size_t, unsigned long *); -int kernsh_free_noncontiguous_linux(unsigned long); +int kernsh_alloc_contiguous(size_t, eresi_Addr*); +int kernsh_free_contiguous(eresi_Addr); +int kernsh_alloc_noncontiguous(size_t, eresi_Addr*); +int kernsh_free_noncontiguous(eresi_Addr); + +int kernsh_alloc_contiguous_linux(size_t, eresi_Addr*); +int kernsh_free_contiguous_linux(eresi_Addr); +int kernsh_alloc_noncontiguous_linux(size_t, eresi_Addr*); +int kernsh_free_noncontiguous_linux(eresi_Addr); /* Module */ int kernsh_kload_module(char *); @@ -583,23 +546,14 @@ int kernsh_infect_module_linux_2_6(char *, elfshobj_t *, char *, char *); int kernsh_infect_module_linux_2_4(char *, elfshobj_t *, char *, char *); -/* Hijack */ - /* MD5 */ unsigned char *kernsh_hash(unsigned long, int, int *); - int kernsh_md5init(libkernshmd5context_t *); -int kernsh_md5update(libkernshmd5context_t *, - unsigned char *, - unsigned); +int kernsh_md5update(libkernshmd5context_t *, unsigned char *, unsigned); int kernsh_md5final(unsigned char [16], libkernshmd5context_t *); -int kernsh_md5transform(unsigned long [4], - const unsigned char [64]); -int kernsh_md5dump(unsigned char *, - int, - unsigned char [BUFSIZ]); - -int kernsh_md5(unsigned long, int, unsigned char [BUFSIZ]); +int kernsh_md5transform(unsigned long [4], const unsigned char [64]); +int kernsh_md5dump(unsigned char *, int, unsigned char [BUFSIZ]); +int kernsh_md5(eresi_Addr, int, unsigned char [BUFSIZ]); /* Auto Types */ int kernsh_autotypes(); @@ -617,48 +571,46 @@ int kernsh_autotask_offsetlist_linux_2_6(char *, size_t); /* Kernel Decompression */ -int kernsh_decompkernel(); -int kernsh_decompkernel_linux(); +int kernsh_decompkernel(); +int kernsh_decompkernel_linux(); /* Kvirtm */ - -int kernsh_kvirtm_read_virtm(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_read_virtm_proc_linux(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_read_virtm_syscall_linux(pid_t, unsigned long, char *, int); - -int kernsh_kvirtm_write_virtm(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_write_virtm_proc_linux(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_write_virtm_syscall_linux(pid_t, unsigned long, char *, int); +int kernsh_kvirtm_read_virtm(pid_t, eresi_Addr, char *, int); +int kernsh_kvirtm_read_virtm_proc_linux(pid_t, eresi_Addr, char *, int); +int kernsh_kvirtm_read_virtm_syscall_linux(pid_t, eresi_Addr, char *, int); + +int kernsh_kvirtm_write_virtm(pid_t, eresi_Addr, char *, int); +int kernsh_kvirtm_write_virtm_proc_linux(pid_t, eresi_Addr, char *, int); +int kernsh_kvirtm_write_virtm_syscall_linux(pid_t, eresi_Addr, char *, int); int kernsh_kvirtm_openmem(); int kernsh_kvirtm_closemem(); -int kernsh_kvirtm_readmem(unsigned long, char *, int); -int kernsh_kvirtm_readmem_proc_linux(unsigned long, char *, int); -int kernsh_kvirtm_readmem_syscall_linux(unsigned long, char *, int); - -int kernsh_kvirtm_writemem(unsigned long, char *, int); -int kernsh_kvirtm_writemem_proc_linux(unsigned long, char *, int); -int kernsh_kvirtm_writemem_syscall_linux(unsigned long, char *, int); +void *kernsh_kvirtm_readmema(elfshobj_t *kern, eresi_Addr, char *, int); +int kernsh_kvirtm_readmem_proc_linux(eresi_Addr, char *, int); +int kernsh_kvirtm_readmem_syscall_linux(eresi_Addr, char *, int); + +int kernsh_kvirtm_writemem(elfshobj_t *kern, eresi_Addr, char *, int); +int kernsh_kvirtm_writemem_proc_linux(eresi_Addr, char *, int); +int kernsh_kvirtm_writemem_syscall_linux(eresi_Addr, char *, int); int kernsh_kvirtm_task_pid(pid_t, list_t *); int kernsh_kvirtm_task_pid_proc_linux(pid_t, list_t *); int kernsh_kvirtm_task_pid_syscall_linux(pid_t, list_t *); /* Dump */ - -int kernsh_dump_kvirtm_elf(pid_t, char *); +int kernsh_dump_kvirtm_elf(pid_t, char *); list_t *kernsh_kdump_get_vma(pid_t); -int kernsh_kdump_get_vma_userland_linux(pid_t, list_t *); +int kernsh_kdump_get_vma_userland_linux(pid_t, list_t *); -int kernsh_kdump_vma(pid_t); -int kernsh_kdump_vma_userland_linux(pid_t, hash_t *); -int kernsh_kdump_vma_kernelland_linux(pid_t, hash_t *); +int kernsh_kdump_vma(pid_t); +int kernsh_kdump_vma_userland_linux(pid_t, hash_t *); +int kernsh_kdump_vma_kernelland_linux(pid_t, hash_t *); /* Misc */ void *kernsh_find_pattern(const void *, int, const void *, int); -int kernsh_resolve_systemmap(unsigned long, char *, size_t); -int kernsh_rresolve_systemmap(const char *,unsigned long *, size_t); -int kernsh_find_end(unsigned long); +int kernsh_resolve_systemmap(eresi_Addr, char *, size_t); +int kernsh_rresolve_systemmap(const char *, eresi_Addr*, size_t); +int kernsh_find_end(eresi_Addr); #endif diff -Nru eresi-0.8a25/libkernsh/include/libkernsh-virtm.h eresi-0.0.20110516/libkernsh/include/libkernsh-virtm.h --- eresi-0.8a25/libkernsh/include/libkernsh-virtm.h 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/libkernsh-virtm.h 2011-05-16 11:34:48.000000000 +0000 @@ -1,3 +1,7 @@ +/** +* @file libkernsh/include/libkernsh-virtm.h +** @ingroup libkernsh +*/ #ifndef __LIBKERNSH_VIRTM_H__ #define __LIBKERNSH_VIRTM_H__ diff -Nru eresi-0.8a25/libkernsh/include/.svn/all-wcprops eresi-0.0.20110516/libkernsh/include/.svn/all-wcprops --- eresi-0.8a25/libkernsh/include/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/943/trunk/libkernsh/include -END -libkernsh-virtm.h -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/943/trunk/libkernsh/include/libkernsh-virtm.h -END -libkernsh.h -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/933/trunk/libkernsh/include/libkernsh.h -END diff -Nru eresi-0.8a25/libkernsh/include/.svn/entries eresi-0.0.20110516/libkernsh/include/.svn/entries --- eresi-0.8a25/libkernsh/include/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/include -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libkernsh-virtm.h -file - - - - -2008-04-06T23:15:26.857892Z -082d3b647c5ffc1b7a9adb404468a173 -2008-03-27T17:59:55.343182Z -943 -pouik - -libkernsh.h -file - - - - -2008-04-06T23:15:26.880137Z -0b2e1cee841e6ec68e92acb551cb7700 -2008-03-25T12:19:53.725666Z -933 -pouik - diff -Nru eresi-0.8a25/libkernsh/include/.svn/format eresi-0.0.20110516/libkernsh/include/.svn/format --- eresi-0.8a25/libkernsh/include/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/include/.svn/text-base/libkernsh.h.svn-base eresi-0.0.20110516/libkernsh/include/.svn/text-base/libkernsh.h.svn-base --- eresi-0.8a25/libkernsh/include/.svn/text-base/libkernsh.h.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/.svn/text-base/libkernsh.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,664 +0,0 @@ -/* -** libkernsh.h for libkernsh -** -** -*/ -#ifndef __LIBKERNSH_H__ - #define __LIBKERNSH_H__ - -#include "libaspect.h" -#include "libelfsh.h" -#include "libasm.h" - -#include "libkernsh-virtm.h" - -#if defined(__NetBSD__) -#include -#include -#include -#include -#include -#endif - -#if defined(__linux__) - -#include - -#define SYSCALL0(num) asm volatile \ -( "\n\tint $0x80" : "=a"(__ret) : "0"(num) ); - -#define SYSCALL1(num,arg0) asm volatile \ -( "\n\tint $0x80": "=a"(__ret) : "0"(num), "b" (arg0) ); - -#define SYSCALL2(num,arg0,arg1) asm volatile \ -( "\n\tint $0x80": "=a"(__ret) : "0"(num),"b" (arg0),"c"(arg1) ); - -#define SYSCALL3(num,arg0,arg1,arg2) asm volatile \ -( "\n\tint $0x80": "=a"(__ret) : "0"(num),"b" (arg0),"c"(arg1),"d"(arg2) ); - -#define SYSCALL4(num,arg0,arg1,arg2,arg3) asm volatile \ -( "\n\tint $0x80": "=a"(__ret) : "0"(num),"b" (arg0),"c"(arg1),"d"(arg2),"S"(arg3) ); - -#define SYSCALL5(num,arg0,arg1,arg2,arg3,arg4) asm volatile \ -( "\n\tint $0x80": "=a"(__ret) : "0"(num),"b" (arg0),"c"(arg1),"d"(arg2),"S"(arg3),"D"(arg4) ); - -#endif - -#define GET_32BIT_LSB_FIRST(cp) \ - (((unsigned long)(unsigned char)(cp)[0]) | \ - ((unsigned long)(unsigned char)(cp)[1] << 8) | \ - ((unsigned long)(unsigned char)(cp)[2] << 16) | \ - ((unsigned long)(unsigned char)(cp)[3] << 24)) - -#define PUT_32BIT_LSB_FIRST(cp, value) do { \ - (cp)[0] = (value); \ - (cp)[1] = (value) >> 8; \ - (cp)[2] = (value) >> 16; \ - (cp)[3] = (value) >> 24; } while (0) - -/* The four core functions - F1 is optimized somewhat */ - -#define F1(x, y, z) (z ^ (x & (y ^ z))) -#define F2(x, y, z) F1(z, x, y) -#define F3(x, y, z) (x ^ y ^ z) -#define F4(x, y, z) (y ^ (x | ~z)) - -/* This is the central step in the MD5 algorithm. */ -#define MD5STEP(f, w, x, y, z, data, s) \ - ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) - -enum - { - LIBKERNSH_ARCH_I386, - LIBKERNSH_ARCH_X86_64, - LIBKERNSH_ARCHNUM - } libkernsh_e_arch_type; - -enum - { - LIBKERNSH_OS_LINUX_2_6, - LIBKERNSH_OS_LINUX_2_4, - LIBKERNSH_OS_NETBSD, - LIBKERNSH_OS_FREEBSD, - LIBKERNSH_OSNUM - } libkernsh_e_os_type; - -enum - { - LIBKERNSH_HASH_MD5, - LIBKERNSH_HASH_SHA1 - } libkernsh_e_hash_type; - -enum - { - LIBKERNSH_DEVICE_KMEM, - LIBKERNSH_DEVICE_MEM, - LIBKERNSH_DEVICE_KCORE, - LIBKERNSH_DEVICE_KVIRTM, - LIBKERNSH_DEVICENUM - } libkernsh_e_device_type; - -enum - { - LIBKERNSH_MEM_MODE, - LIBKERNSH_STATIC_MODE - } libkernsh_e_debug_type; - -enum - { - LIBKERNSH_VMA_USERLAND, - LIBKERNSH_VMA_KERNELLAND, - LIBKERNSH_VMANUM - } libkernsh_e_vma_type; - -#define __DEBUG_KERNSH__ 0 - -#define LIBKERNSH_VMCONFIG_WITHOUT_KERNEL "libkernsh.without_kernel" -#define LIBKERNSH_VMCONFIG_DEVICE "libkernsh.device" -#define LIBKERNSH_VMCONFIG_MODE "libkernsh.mode" -#define LIBKERNSH_VMCONFIG_SYSTEMMAP "libkernsh.systemmap" -#define LIBKERNSH_VMCONFIG_MMAP "libkernsh.mmap" -#define LIBKERNSH_VMCONFIG_MMAP_SIZE "libkernsh.mmapsize" -#define LIBKERNSH_VMCONFIG_KERNEL "libkernsh.kernel" -#define LIBKERNSH_VMCONFIG_GZIP "libkernsh.gzipcmd" -#define LIBKERNSH_VMCONFIG_OBJCOPY "libkernsh.objcopycmd" -#define LIBKERNSH_VMCONFIG_LD "libkernsh.ldcmd" -#define LIBKERNSH_VMCONFIG_KERNELGZ "libkernsh.kernelgz" -#define LIBKERNSH_VMCONFIG_KERNELELF "libkernsh.kernelelf" -#define LIBKERNSH_VMCONFIG_USE_KERNEL "libkernsh.use_kernel" -#define LIBKERNSH_VMCONFIG_STORAGE_PATH "libkernsh.storagepath" -#define LIBKERNSH_VMCONFIG_NB_SYSCALLS "libkernsh.nbsyscalls" -#define LIBKERNSH_VMCONFIG_NIL_SYSCALL "libkernsh.nilsyscall" -#define LIBKERNSH_VMCONFIG_KERNEL_START "libkernsh.kernel_start" -#define LIBKERNSH_VMCONFIG_KERNEL_END "libkernsh.kernel_end" -#define LIBKERNSH_VMCONFIG_ALLOC "libkernsh.alloc" -#define LIBKERNSH_VMCONFIG_KLOAD "libkernsh.kload" -#define LIBKERNSH_VMCONFIG_KUNLOAD "libkernsh.kunload" -#define LIBKERNSH_VMCONFIG_FENDSIZE "libkernsh.fendsize" -#define LIBKERNSH_VMCONFIG_USEVM "libkernsh.usevm" -#define LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE "libkernsh.specify_idtbase" -#define LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT "libkernsh.specify_idtlimit" -#define LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE "libkernsh.specify_gdtbase" -#define LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT "libkernsh.specify_gdtlimit" -#define LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL "libkernsh.specify_systemcall" -#define LIBKERNSH_VMCONFIG_SPECIFY_SCT "libkernsh.specify_sct" -#define LIBKERNSH_VMCONFIG_VIRTM "libkernsh.virtm" -#define LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL "libkernsh.virtm_nil_syscall" -#define LIBKERNSH_VMCONFIG_HASH "libkernsh.hash" -#define LIBKERNSH_VMCONFIG_VMA "libkernsh.vma" -#define LIBKERNSH_VMCONFIG_VMA_PREFIX "libkernsh.vma_prefix" -#define LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX "libkernsh.dump_vma_prefix" - - -#define LIBKERNSH_DEFAULT_LINUX_KERNEL "/boot/vmlinuz" -#define LIBKERNSH_DEFAULT_LINUX_MAP "/boot/System.map" -#define LIBKERNSH_DEFAULT_LINUX_KERNELGZ "vmlinuz.gz" -#define LIBKERNSH_DEFAULT_LINUX_KERNELELF "vmlinux" -#define LIBKERNSH_DEFAULT_LINUX_NB_SYSCALLS 320 -#define LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL 17 -#define LIBKERNSH_DEFAULT_LINUX_VIRTM_NIL_SYSCALL 31 -#define LIBKERNSH_DEFAULT_LINUX_MMAP_SIZE 0x3e800000 -#define LIBKERNSH_DEFAULT_LINUX_INSMOD "/sbin/insmod" -#define LIBKERNSH_DEFAULT_LINUX_RMMOD "/sbin/rmmod" -#define LIBKERNSH_DEFAULT_STORAGE_PATH "/tmp/" -#define LIBKERNSH_DEFAULT_GZIP "/bin/gzip" -#define LIBKERNSH_DEFAULT_OBJCOPY "/usr/bin/objcopy" -#define LIBKERNSH_DEFAULT_LD "/usr/bin/ld" -#define LIBKERNSH_DEFAULT_FENDSIZE 0x1000 -#define LIBKERNSH_STRING_DEVICE_MEM "/dev/mem" -#define LIBKERNSH_STRING_DEVICE_KMEM "/dev/kmem" -#define LIBKERNSH_STRING_DEVICE_KCORE "/proc/kcore" -#define LIBKERNSH_STRING_DEVICE_KVIRTM "kvirtm" -#define LIBKERNSH_STRING_REL_GNU ".rel.gnu.linkonce.this_module" -#define LIBKERNSH_DEFAULT_VMA_PREFIX "vma" -#define LIBKERNSH_DEFAULT_DUMP_VMA_PREFIX "kernsh_dump" - -#define LIBKERNSH_HASH_MD5_SIZE 16 - -#define LIBKERNSH_I386_LINUX_START 0xc0000000 -#define LIBKERNSH_I386_LINUX_END 0xc1000000 - -#define LIBKERNSH_PROC_ENTRY_SIZE 1024 - -#define LIBKERNSH_PAGE_I386_LINUX_OFFSET 0xc0000000 - -#define GFP_KERNEL 208 -#define NAMESIZ 64 - -#define LIBKERNSH_VECTOR_NAME_OPENMEM "openmem" -#define LIBKERNSH_VECTOR_NAME_CLOSEMEM "closemem" -#define LIBKERNSH_VECTOR_NAME_READMEM "readmem" -#define LIBKERNSH_VECTOR_NAME_WRITEMEM "writemem" -#define LIBKERNSH_VECTOR_NAME_SCT "sct" -#define LIBKERNSH_VECTOR_NAME_IDT "idt" -#define LIBKERNSH_VECTOR_NAME_GDT "gdt" -#define LIBKERNSH_VECTOR_NAME_INFO "info" -#define LIBKERNSH_VECTOR_NAME_DECOMPKERNEL "decompkernel" -#define LIBKERNSH_VECTOR_NAME_ADDRBYNAME "addr_by_name" -#define LIBKERNSH_VECTOR_NAME_NAMEBYADDR "name_by_addr" -#define LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS "alloc_contiguous" -#define LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS "alloc_noncontiguous" -#define LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS "free_contiguous" -#define LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS "free_noncontiguous" -#define LIBKERNSH_VECTOR_NAME_AUTOTYPES "autotypes" -#define LIBKERNSH_VECTOR_NAME_RELINKMODULE "relink_module" -#define LIBKERNSH_VECTOR_NAME_INFECTMODULE "infect_module" -#define LIBKERNSH_VECTOR_NAME_KLOADMODULE "kload_module" -#define LIBKERNSH_VECTOR_NAME_KUNLOADMODULE "kunload_module" -#define LIBKERNSH_VECTOR_NAME_CALLSC "call_syscall" -#define LIBKERNSH_VECTOR_NAME_KVIRTMREADVIRTM "kvirtm_read_virtm" -#define LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM "kvirtm_read_mem" -#define LIBKERNSH_VECTOR_NAME_KVIRTMWRITEVIRTM "kvirtm_write_virtm" -#define LIBKERNSH_VECTOR_NAME_KVIRTMWRITEMEM "kvirtm_write_mem" -#define LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID "kvirtm_task_pid" -#define LIBKERNSH_VECTOR_NAME_KVIRTMDUMPELF "kvirtm_dump_elf" -#define LIBKERNSH_VECTOR_NAME_KDUMPGETVMA "kdump_get_vma" -#define LIBKERNSH_VECTOR_NAME_KDUMPVMA "kdump_vma" - - -/* Idtr segment struct */ -struct -{ - unsigned short limit; - unsigned long base; -} __attribute__((packed)) idtr; - -/* Interrupt descriptor */ -struct -{ - unsigned short off1; - unsigned short sel; - unsigned char none,flags; - unsigned short off2; -} __attribute__ ((packed)) idt; - -/* gdtr */ -struct -{ - unsigned short limit; - unsigned long base; -} __attribute__ ((packed))gdtr; - -/** - * @brief Kmalloc struct - */ -typedef struct s_libkernshkma -{ - unsigned long ( *kexec )( size_t, int ); /* Execution of kmalloc */ - int size; /* Size to alloc */ - int flags; /* Flags, by default GFP_KERNEL */ - unsigned long mem; /* The address where the allocation has been done */ -} libkernshkma_t ; - -/** - * @brief Kfree struct - */ -typedef struct s_libkernshkfr -{ - unsigned long ( *kexec )( const void * ); /* Execution of kfree */ - const void * address; /* Address to be free */ -} libkernshkfr_t; - -/** - * @brief Vmalloc struct - */ -typedef struct s_libkernshvma -{ - unsigned long ( *kexec )( size_t ); /* Execution of vmalloc */ - int size; /* Size to alloc */ - unsigned long mem; /* The address where the allocation has been done */ -} libkernshvma_t; - -/** - * @brief Vfree struct - */ -typedef struct s_libkernshvfr -{ - unsigned long ( *kexec )( void * ); /* Execution of vfree */ - void * address; /* Address to be free */ -} libkernshvfr_t; - -/** - * @brief Syscall struct - */ -typedef struct s_libkernshsyscall -{ - unsigned long addr; - char name[NAMESIZ]; -} libkernshsyscall_t; - -/** - * @brief Interrupt struct - */ -typedef struct s_libkernshint -{ - unsigned long addr; - char name[NAMESIZ]; -} libkernshint_t; - -/** - * @brief Gdt segment struct - */ -typedef struct s_libkernshsgdt -{ - unsigned long addr; - unsigned long deb; - unsigned long fin; -} libkernshsgdt_t; - -/** - * @brief md5 context - */ -typedef struct s_libkernshmd5context -{ - unsigned long buf[4]; - unsigned long bits[2]; - unsigned char in[64]; -} libkernshmd5context_t; - - -/** - * @brief dec task - */ -typedef struct s_dectask -{ - int dec_list; - int dec_pid; - int dec_uid; -} dectask_t; - -/** - * @brief auto task - */ -typedef struct s_autotask -{ - int offset_name; - int offset_list; - int offset_next; - int offset_pid; - int offset_uid; - - dectask_t dectask; -} autotask_t; - -/** - * @brief World kernsh struct - */ -typedef struct s_libkernshworld -{ - u_int arch; /* Arch type */ - u_int os; /* Os type */ - u_int device; /* Device type */ - - int present; /* Flag to test kernsh's present */ - int open; /* 0 => memory close, 1 => memory open */ - int open_static; /* 0 => static kernel close, - 1 => static kernel open */ - - char *release; /* Release name */ - - int fd; /* !< @brief File descriptor for the memory */ - int fdmode; /* Mode to open memory (read/write) */ - int protmode; /* Protection mode to mmap */ - int flagsmode; /* Flags mode to mmap */ - - int mmap; /* 0 => memory not mmap - 1 => memory mmap */ - int mmap_size; /* Size of the mmap */ - void *ptr; /* Pointer of the mmap*/ - - unsigned long kernel_start; /* Address of kernel start */ - unsigned long kernel_end; /* Address of kernel end */ - - int mem; /* Static/Mem mode */ - - int physical; /* 0 => virtual memory address - 1 => physical memory address */ - - unsigned long idt_base; /* Address of idt table */ - unsigned short idt_limit; /* Length */ - - unsigned long sct; /* Address of syscall table */ - -#if defined(__linux__) - unsigned long system_call; -#endif - unsigned long gdt_base; /* Address of the gdt table */ - unsigned short gdt_limit; /* Lenght */ - - autotask_t typetask; /* Make type for task_struct */ - - asm_processor proc; /* To play with libasm of course */ - elfshobj_t *root; /* Pointer to the kernel's elfshobj_t*/ -} libkernshworld_t; - -extern libkernshworld_t libkernshworld; /* Global libkernsh struct - W00t W00t use it please !*/ - -/* Init lib */ -int kernsh_init_ia32(char *, char *); -int kernsh_del_ia32(); - -/* Get raw */ -void *kernsh_elfsh_get_raw(elfshsect_t *); -void *kernsh_revm_get_raw(void *); - -/* Information about kernel */ -int kernsh_info(); -int kernsh_info_linux(); -int kernsh_info_netbsd(); -int kernsh_info_freebsd(); - -elfshobj_t *kernsh_load_file(char *); -void kernsh_unload_file(elfshobj_t *); - -/* Memory or Static mode */ -int kernsh_is_mem_mode(); -int kernsh_set_mem_mode(); -int kernsh_is_static_mode(); -int kernsh_set_static_mode(); -int kernsh_get_mode(); -int kernsh_set_mode(int); - -void kernsh_present_set(); -int kernsh_is_present(); - -/* Raw mode */ -int kernsh_raw_write(elfshobj_t *, u_int, void *, int); -int kernsh_raw_read(elfshobj_t *, u_int, void *, int); - -/* Default vectors */ - -int kernsh_openmem_default(); -int kernsh_closemem_default(); -int kernsh_readmem_default(); -int kernsh_writemem_default(); -int kernsh_sct_default(); -int kernsh_callsc_default(); -int kernsh_idt_default(); -int kernsh_gdt_default(); -int kernsh_info_default(); -int kernsh_decompkernel_default(); -int kernsh_loadkernel_default(); -int kernsh_autotypes_default(); -int kernsh_symbs_default(); -int kernsh_alloc_contiguous_default(); -int kernsh_alloc_noncontiguous_default(); -int kernsh_free_contiguous_default(); -int kernsh_free_noncontiguous_default(); -int kernsh_relink_module_default(); -int kernsh_infect_module_default(); -int kernsh_kload_module_default(); -int kernsh_kunload_module_default(); -int kernsh_kvirtm_read_virtm_default(); -int kernsh_kvirtm_read_mem_default(); -int kernsh_kvirtm_write_virtm_default(); -int kernsh_kvirtm_write_mem_default(); -int kernsh_kvirtm_task_pid_default(); -int kernsh_kdump_get_vma_default(); -int kernsh_kdump_vma_default(); - -/* Init vectors */ -int kernsh_init_vectors(); -int kernsh_register_vectors(); -int kernsh_register_openmem(u_int, u_int, u_int, void *); -int kernsh_register_closemem(u_int, u_int, u_int, void *); -int kernsh_register_readmem(u_int, u_int, u_int, void *); -int kernsh_register_writemem(u_int, u_int, u_int, void *); -int kernsh_register_sct(u_int, u_int, void *); -int kernsh_register_callsc(u_int, void *); -int kernsh_register_idt(u_int, u_int, void *); -int kernsh_register_gdt(u_int, u_int, void *); -int kernsh_register_info(u_int, u_int, void *); -int kernsh_register_decompkernel(u_int, void *); -int kernsh_register_symbs_abn(u_int, u_int, void *); -int kernsh_register_symbs_nba(u_int, u_int, void *); -int kernsh_register_alloc_contiguous(u_int, void *); -int kernsh_register_alloc_noncontiguous(u_int, void *); -int kernsh_register_free_contiguous(u_int, void *); -int kernsh_register_free_noncontiguous(u_int, void *); -int kernsh_register_autotypes(u_int, u_int, void *); -int kernsh_register_relink(u_int, void *); -int kernsh_register_infect(u_int, void *); -int kernsh_register_kload(u_int, void *); -int kernsh_register_kunload(u_int, void *); -int kernsh_register_kvirtm_read_virtm(u_int, u_int, void *); -int kernsh_register_kvirtm_read_mem(u_int, u_int, void *); -int kernsh_register_kvirtm_write_virtm(u_int, u_int, void *); -int kernsh_register_kvirtm_write_mem(u_int, u_int, void *); -int kernsh_register_kvirtm_task_pid(u_int, u_int, void *); -int kernsh_register_kdump_get_vma(u_int, u_int, void *); -int kernsh_register_kdump_vma(u_int, u_int, void *); - -/* Memory */ -int kernsh_openmem(); -int kernsh_openmem_kmem_linux_2_6(); -int kernsh_openmem_kmem_linux_2_4(); -int kernsh_openmem_mem_linux(); -int kernsh_openmem_kcore_linux_2_6(); -int kernsh_openmem_netbsd(); - -int kernsh_closemem(); -int kernsh_closemem_kmem_linux_2_6(); -int kernsh_closemem_kmem_linux_2_4(); -int kernsh_closemem_mem_linux(); -int kernsh_closemem_kcore_linux_2_6(); -int kernsh_closemem_netbsd(); - -int kernsh_readmem(unsigned long, void *, int); -int kernsh_readmem_kmem_linux_2_6(unsigned long, void *, int); -int kernsh_readmem_kmem_linux_2_4(unsigned long, void *, int); -int kernsh_readmem_mem_linux(unsigned long, void *, int); -int kernsh_readmem_kcore_linux_2_6(unsigned long, void *, int); -int kernsh_readmem_netbsd(unsigned long, void *, int); - -int kernsh_writemem(unsigned long, void *, int); -int kernsh_writemem_kmem_linux_2_6(unsigned long, void *, int); -int kernsh_writemem_kmem_linux_2_4(unsigned long, void *, int); -int kernsh_writemem_mem_linux(unsigned long, void *, int); -int kernsh_writemem_kcore_linux_2_6(unsigned long, void *, int); -int kernsh_writemem_netbsd(unsigned long, void *, int); - -/* Syscalls table */ -int kernsh_sct(list_t *); -int kernsh_sct_linux(list_t *); -int kernsh_sct_netbsd(list_t *); -int kernsh_sct_freebsd(list_t *); - -int kernsh_syscall(int, int, unsigned int []); -int kernsh_syscall_linux(int, int, unsigned int []); - -/* IDT */ -int kernsh_idt(list_t *); -int kernsh_idt_linux(list_t *); -int kernsh_idt_netbsd(list_t *); -int kernsh_idt_freebsd(list_t *); - -/* GDT */ -int kernsh_gdt(list_t *); -int kernsh_gdt_linux(list_t *); -int kernsh_gdt_netbsd(list_t *); -int kernsh_gdt_freebsd(list_t *); - -/* Symbols */ -int kernsh_get_addr_by_name(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr(unsigned long, char *, size_t); - -int kernsh_get_addr_by_name_linux_2_6(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr_linux_2_6(unsigned long, char *, size_t); -int kernsh_get_addr_by_name_linux_2_4(char *, unsigned long *, size_t); -int kernsh_get_name_by_addr_linux_2_4(unsigned long, char *, size_t); - -int kernsh_walk_kstrtab(const char *, unsigned long *, size_t); -int kernsh_get_kernel_syms(char *, unsigned long *, size_t); - -/* Tasks */ - - -/* Alloc-Free */ -int kernsh_alloc(size_t, unsigned long *); -int kernsh_free(unsigned long); - -int kernsh_alloc_contiguous(size_t, unsigned long *); -int kernsh_free_contiguous(unsigned long); -int kernsh_alloc_noncontiguous(size_t, unsigned long *); -int kernsh_free_noncontiguous(unsigned long); - -int kernsh_alloc_contiguous_linux(size_t, unsigned long *); -int kernsh_free_contiguous_linux(unsigned long); -int kernsh_alloc_noncontiguous_linux(size_t, unsigned long *); -int kernsh_free_noncontiguous_linux(unsigned long); - -/* Module */ -int kernsh_kload_module(char *); -int kernsh_kload_module_linux(char *); - -int kernsh_kunload_module(char *); -int kernsh_kunload_module_linux(char *); - -int kernsh_relink_module(char *, char *, char *); -int kernsh_relink_module_linux(char *, char *, char *); - -int kernsh_infect_module(char *, char *, char *); -int kernsh_infect_module_linux_2_6(char *, elfshobj_t *, char *, char *); -int kernsh_infect_module_linux_2_4(char *, elfshobj_t *, char *, char *); - -/* Hijack */ - -/* MD5 */ -unsigned char *kernsh_hash(unsigned long, int, int *); - -int kernsh_md5init(libkernshmd5context_t *); -int kernsh_md5update(libkernshmd5context_t *, - unsigned char *, - unsigned); -int kernsh_md5final(unsigned char [16], libkernshmd5context_t *); -int kernsh_md5transform(unsigned long [4], - const unsigned char [64]); -int kernsh_md5dump(unsigned char *, - int, - unsigned char [BUFSIZ]); - -int kernsh_md5(unsigned long, int, unsigned char [BUFSIZ]); - -/* Auto Types */ -int kernsh_autotypes(); -int kernsh_autotypes_linux_2_6(); -int kernsh_autotypes_linux_2_4(); -int kernsh_autotypes_netbsd(); -int kernsh_autotypes_freebsd(); - -int kernsh_autotask_linux_2_6(); -int kernsh_autotask_linux_2_4(); -int kernsh_autotask_netbsd(); -int kernsh_autotask_freebsd(); - -int kernsh_autotask_offsetname_linux_2_6(char *, size_t); -int kernsh_autotask_offsetlist_linux_2_6(char *, size_t); - -/* Kernel Decompression */ -int kernsh_decompkernel(); -int kernsh_decompkernel_linux(); - -/* Kvirtm */ - -int kernsh_kvirtm_read_virtm(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_read_virtm_proc_linux(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_read_virtm_syscall_linux(pid_t, unsigned long, char *, int); - -int kernsh_kvirtm_write_virtm(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_write_virtm_proc_linux(pid_t, unsigned long, char *, int); -int kernsh_kvirtm_write_virtm_syscall_linux(pid_t, unsigned long, char *, int); - -int kernsh_kvirtm_openmem(); -int kernsh_kvirtm_closemem(); - -int kernsh_kvirtm_readmem(unsigned long, char *, int); -int kernsh_kvirtm_readmem_proc_linux(unsigned long, char *, int); -int kernsh_kvirtm_readmem_syscall_linux(unsigned long, char *, int); - -int kernsh_kvirtm_writemem(unsigned long, char *, int); -int kernsh_kvirtm_writemem_proc_linux(unsigned long, char *, int); -int kernsh_kvirtm_writemem_syscall_linux(unsigned long, char *, int); - -int kernsh_kvirtm_task_pid(pid_t, list_t *); -int kernsh_kvirtm_task_pid_proc_linux(pid_t, list_t *); -int kernsh_kvirtm_task_pid_syscall_linux(pid_t, list_t *); - -/* Dump */ - -int kernsh_dump_kvirtm_elf(pid_t, char *); -list_t *kernsh_kdump_get_vma(pid_t); -int kernsh_kdump_get_vma_userland_linux(pid_t, list_t *); - -int kernsh_kdump_vma(pid_t); -int kernsh_kdump_vma_userland_linux(pid_t, hash_t *); -int kernsh_kdump_vma_kernelland_linux(pid_t, hash_t *); - -/* Misc */ -void *kernsh_find_pattern(const void *, int, const void *, int); -int kernsh_resolve_systemmap(unsigned long, char *, size_t); -int kernsh_rresolve_systemmap(const char *,unsigned long *, size_t); -int kernsh_find_end(unsigned long); - -#endif diff -Nru eresi-0.8a25/libkernsh/include/.svn/text-base/libkernsh-virtm.h.svn-base eresi-0.0.20110516/libkernsh/include/.svn/text-base/libkernsh-virtm.h.svn-base --- eresi-0.8a25/libkernsh/include/.svn/text-base/libkernsh-virtm.h.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/include/.svn/text-base/libkernsh-virtm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,66 +0,0 @@ -#ifndef __LIBKERNSH_VIRTM_H__ - #define __LIBKERNSH_VIRTM_H__ - -#define PROC_ENTRY_ROOT "/proc/" -#define PROC_ENTRY_KERNSH_VIRTM "kernsh_virtm" -#define PROC_ENTRY_KERNSH_VIRTM_DUMP_ELF "dump_elf" -#define PROC_ENTRY_KERNSH_VIRTM_VIO_INFO "vio_info" -#define PROC_ENTRY_KERNSH_VIRTM_VIO "vio" -#define PROC_ENTRY_KERNSH_VIRTM_INFO "info" - -#define PROC_ENTRY_KERNSH_VIRTM_MAX PROC_ENTRY_KERNSH_VIRTM - -#define LIBKERNSH_STRING_VM_START "vm_start" -#define LIBKERNSH_STRING_VM_END "vm_end" - -enum libkernsh_e_virtm_action_type - { - LIBKERNSH_VIRTM_READ_MEM, - LIBKERNSH_VIRTM_WRITE_MEM, - LIBKERNSH_VIRTM_READ_MEM_PID, - LIBKERNSH_VIRTM_WRITE_MEM_PID, - LIBKERNSH_VIRTM_TASK_PID, - LIBKERNSH_VIRTM_DUMP_ELF_PID - }; - -enum libkernsh_e_virtm_type - { - LIBKERNSH_KERNEL_MODE, - LIBKERNSH_USER_MODE, - LIBKERNSH_VIRTMNUM - }; - -typedef struct s_kvirtm_virtual_task_struct -{ - unsigned long state; - unsigned long flags; - unsigned long ptrace; - - - /* struct mm_struct *mm */ - unsigned long mmap_base; - unsigned long task_size; - - unsigned long start_code, end_code, start_data, end_data; - -} kvirtm_virtual_task_struct_t; - -typedef struct s_libkernshvma_struct -{ - - unsigned long vm_start; - unsigned long vm_end; - -} libkernshvma_struct_t; - -typedef struct s_kvirtm_action -{ - int action; - unsigned long addr; - int len; - int pid; - char filename[256]; - -} kvirtm_action_t; - -#endif /* __LIBKERNSH_VIRTM_H_ */ diff -Nru eresi-0.8a25/libkernsh/kernel/arch/.svn/all-wcprops eresi-0.0.20110516/libkernsh/kernel/arch/.svn/all-wcprops --- eresi-0.8a25/libkernsh/kernel/arch/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/944/trunk/libkernsh/kernel/arch -END diff -Nru eresi-0.8a25/libkernsh/kernel/arch/.svn/entries eresi-0.0.20110516/libkernsh/kernel/arch/.svn/entries --- eresi-0.8a25/libkernsh/kernel/arch/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/kernel/arch -http://svn.eresi-project.org/svn - - - -2008-03-27T21:39:30.403274Z -944 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -x86 -dir - diff -Nru eresi-0.8a25/libkernsh/kernel/arch/.svn/format eresi-0.0.20110516/libkernsh/kernel/arch/.svn/format --- eresi-0.8a25/libkernsh/kernel/arch/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/mem.c eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/mem.c --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/mem.c 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/mem.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file mem.c -** @ingroup libkernsh_kernel +/** +* @file libkernsh/kernel/arch/x86/linux/mem.c +** @ingroup kernelmode ** */ #include "libkernsh-kernel.h" diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/misc.c eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/misc.c --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/misc.c 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/misc.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @defgroup libkernsh_kernel libkernsh_kernel + * @defgroup kernelmode Kernel mode code. + * @ingroup libkernsh */ -/* -** @file misc.c -** @ingroup libkernsh_kernel +/** +* @file libkernsh/kernel/arch/x86/linux/misc.c +** @ingroup kernelmode ** */ #include "libkernsh-kernel.h" diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/page.c eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/page.c --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/page.c 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/page.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file page.c -** @ingroup libkernsh_kernel +/** +* @file libkernsh/kernel/arch/x86/linux/page.c +** @ingroup kernelmode ** */ #include "libkernsh-kernel.h" diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/all-wcprops eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/all-wcprops --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/944/trunk/libkernsh/kernel/arch/x86/linux -END -mem.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/944/trunk/libkernsh/kernel/arch/x86/linux/mem.c -END -virtm.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/943/trunk/libkernsh/kernel/arch/x86/linux/virtm.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/940/trunk/libkernsh/kernel/arch/x86/linux/misc.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/940/trunk/libkernsh/kernel/arch/x86/linux/Makefile -END -page.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/943/trunk/libkernsh/kernel/arch/x86/linux/page.c -END diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/entries eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/entries --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/kernel/arch/x86/linux -http://svn.eresi-project.org/svn - - - -2008-03-27T21:39:30.403274Z -944 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -mem.c -file - - - - -2008-04-06T23:15:26.670126Z -513c9c22f75c718a1289ce475eae6db9 -2008-03-27T21:39:30.403274Z -944 -pouik - -virtm.c -file - - - - -2008-04-06T23:15:26.676155Z -5eaa0a825f66607d11da410fd203f1cd -2008-03-27T17:59:55.343182Z -943 -pouik - -misc.c -file - - - - -2008-04-06T23:15:26.686901Z -01c1d82e8747badc0a48d2eafe4ab2ae -2008-03-27T10:28:40.877770Z -940 -pouik - -Makefile -file - - - - -2008-04-06T23:15:26.698132Z -bf121bc4cb42139ecde185d5f8a5eec0 -2008-03-27T10:28:40.877770Z -940 -pouik - -page.c -file - - - - -2008-04-06T23:15:26.709876Z -4a4bf4869e128ccdde9b6e366036c473 -2008-03-27T17:59:55.343182Z -943 -pouik - diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/format eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/format --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -RELEASE := $(shell uname -r | sed -e s/2.6.*/2.6/ -e s/2.4.*/2.4/) -CP = cp - -ifeq ($(RELEASE),2.6) - -EXTRA_CFLAGS := -g3 -Wall -I/usr/include -I$(src)/../../../include \ - -I$(src)/../../../../include \ - -DERESI32 -Wno-strict-prototypes - - -libkernsh-kernel-y := page.o virtm.o mem.o misc.o - -obj-m := libkernsh-kernel.o - -all: - $(MAKE) -C /lib/modules/`uname -r`/build M=`pwd`/ - $(CP) libkernsh-kernel.o ../../../ - -clean: - @$(RM) *.o *~ \#* *\# .\#* *.mod.c Module.* .*.o.cmd .*.ko.cmd - @$(RM) include/*~ include/\#* include/*\# include/.\#* - @$(RM) -fr .tmp_versions* - -fclean: clean - @$(RM) *.ko -endif diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/mem.c.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/mem.c.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/mem.c.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/mem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,147 +0,0 @@ -/* -** @file mem.c -** @ingroup libkernsh_kernel -** -*/ -#include "libkernsh-kernel.h" -#include "libkernsh-kernel-linux.h" - -/** - * @brief Read kernel memory - * @param addr Address to read memory - * @param buffer Read memory into the buffer - * @param len Count bytes to read - * @param mode The mode to write into the buffer - * @return len on success, -1 on error - */ -asmlinkage int kernsh_read_mem(unsigned long addr, char *buffer, int len, int mode) -{ - ssize_t read, sz; - char *ptr; - unsigned long p = addr; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_read_mem ENTER !!\n"); -#endif - - if (!valid_phys_addr_range(p, len)) - return -EFAULT; - - read = 0; - while (len > 0) - { - /* - * Handle first page in case it's not aligned - */ - if (-p & (PAGE_SIZE - 1)) - sz = -p & (PAGE_SIZE - 1); - else - sz = PAGE_SIZE; - - sz = min_t(unsigned long, sz, len); - - ptr = __va(p); - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "SZ %d PTR 0x%lx\n", sz, (unsigned long)ptr); -#endif - - switch(mode) - { - case LIBKERNSH_KERNEL_MODE : - memcpy(buffer, ptr, sz); - break; - case LIBKERNSH_USER_MODE : - if (copy_to_user(buffer, ptr, sz)) - return -EFAULT; - break; - } - - buffer += sz; - p += sz; - len -= sz; - read += sz; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_read_mem EXIT !!\n"); -#endif - - return read; -} - -/** - * @brief Write into kernel memory - * @param addr Address to write buffer - * @param buffer Write buffer into memory - * @param len Count bytes to write - * @param mode The mode to write into the buffer - * @return len on success, -1 on error - */ -asmlinkage int kernsh_write_mem(unsigned long addr, const char *buffer, int len, int mode) -{ - unsigned long p = addr; - ssize_t written, sz; - unsigned long copied; - void *ptr; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_write_mem ENTER !!\n"); -#endif - - if (!valid_phys_addr_range(p, len)) - return -EFAULT; - - written = 0; - - while (len > 0) - { - /* - * Handle first page in case it's not aligned - */ - if (-p & (PAGE_SIZE - 1)) - sz = -p & (PAGE_SIZE - 1); - else - sz = PAGE_SIZE; - - sz = min_t(unsigned long, sz, len); - - /* - * On ia64 if a page has been mapped somewhere as - * uncached, then it must also be accessed uncached - * by the kernel or data corruption may occur - */ - ptr = __va(p); - - switch(mode) - { - case LIBKERNSH_KERNEL_MODE : - memcpy(ptr, buffer, sz); - copied = sz; - break; - case LIBKERNSH_USER_MODE : - copied = copy_from_user(ptr, buffer, sz); - break; - } - - if (copied) - { - written += sz - copied; - if (written) - break; - - return -EFAULT; - } - - buffer += sz; - p += sz; - len -= sz; - written += sz; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_write_mem EXIT !!\n"); -#endif - - return written; -} diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -/** - * @defgroup libkernsh_kernel libkernsh_kernel - */ -/* -** @file misc.c -** @ingroup libkernsh_kernel -** -*/ -#include "libkernsh-kernel.h" -#include "libkernsh-kernel-linux.h" - -/** - * @brief Convert a string to an integer - * @param name The string - * @return value - */ -int kernsh_atoi(const char *name) -{ - int val = 0; - - for (;; name++) - { - switch (*name) - { - case '0' ... '9': - val = 10*val+(*name-'0'); - break; - default: - return val; - } - } -} - -/** - * @brief Get task_struct from userland - * @param pid task_struct of the process id - * @param buffer Store the task_struct in a buffer - * @param len Count bytes of the buffer - * @param mode The mode to write into the buffer - * @return 0 on success, -1 on error - */ -asmlinkage int kernsh_task_pid(int pid, char *buffer, int len, int mode) -{ - kvirtm_virtual_task_struct_t kvtst; - int write, cur_write; - struct task_struct *task; - struct mm_struct *mm; - unsigned long *tmp; - unsigned long size; - char *ptr; - - task = find_task_by_pid(pid); - if (task == NULL) - { - printk(KERN_ALERT "Couldn't find pid %d\n", pid); - return -EFAULT; - } - - if (task->mm == NULL) - { - printk(KERN_ALERT "Couldn't find mm_struct %d\n", pid); - return -EFAULT; - } - - mm = task->mm; - memset(&kvtst, '\0', sizeof(kvirtm_virtual_task_struct_t)); - - kvtst.state = task->state; - kvtst.flags = task->flags; - kvtst.ptrace = task->ptrace; - kvtst.mmap_base = mm->mmap_base; - kvtst.task_size = mm->task_size; - - kvtst.start_code = mm->start_code; - kvtst.end_code = mm->end_code; - kvtst.start_data = mm->start_data; - kvtst.end_data = mm->end_data; - - write = 0; - - tmp = (unsigned long *)&kvtst; - ptr = buffer; - size = write = cur_write = 0; - - while (write < len && size < sizeof(kvirtm_virtual_task_struct_t)) - { - cur_write = sprintf(ptr, "0x%lx:", *tmp); - size += sizeof(unsigned long); - tmp++; - ptr += cur_write; - write += cur_write; - } - - return write; -} - -/** - * @brief Display vma of a process id - * @param pid the process id - * @return 0 on success, -1 on error - */ -int kernsh_view_vmaps(pid_t pid) -{ - struct task_struct *task; - struct mm_struct *mm; - struct vm_area_struct *vma; - - task = find_task_by_pid(pid); - if (task == NULL) - { - printk(KERN_ALERT "Couldn't find pid %d\n", pid); - return -1; - } - - if (task->mm == NULL) - return -1; - - mm = task->mm; - - printk(KERN_ALERT "START CODE 0x%lx START END 0x%lx\n", mm->start_code, mm->end_code); - printk(KERN_ALERT "DATA CODE 0x%lx DATA END 0x%lx\n", mm->start_data, mm->end_data); - - if (mm) - { - for(vma = mm->mmap; vma; vma = vma->vm_next) - { - printk(KERN_ALERT "VM_START @ 0x%lx VM_END @ 0x%lx VM_FLAGS 0x%lx VM_FILE 0x%lx\n", - vma->vm_start, - vma->vm_end, - vma->vm_flags, - (unsigned long)vma->vm_file); - } - } - - return 0; -} - -/** - * @brief Valid a physical address range - * @param addr - * @param count - * @return 0 on success, -1 on error - */ -int valid_phys_addr_range(unsigned long addr, int count) -{ - if (addr + count > __pa(high_memory)) - return 0; - - return 1; -} diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/page.c.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/page.c.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/page.c.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/page.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* -** @file page.c -** @ingroup libkernsh_kernel -** -*/ -#include "libkernsh-kernel.h" -#include "libkernsh-kernel-linux.h" - -/** - * @brief Get a page of a process id - * @param task The task_struct - * @param addr The addr to get the page - * @return page on success, NULL on error - */ -struct page *kernsh_get_page_from_pid(int pid, unsigned long addr) -{ - struct task_struct *task; - struct mm_struct *mm; - struct page *page_at_addr; - pgd_t * pgd; - pmd_t * pmd; - pte_t * pte; - pud_t *pud; - - page_at_addr = NULL; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_get_page_from_task ENTER !!\n"); -#endif - - task = find_task_by_pid(pid); - - if (task == NULL) - { - printk(KERN_ALERT "[-] task_struct is null !!\n"); - return NULL; - } - - if (addr <= 0) - { - printk(KERN_ALERT "[-] Addr isn't valid => 0x%lx!\n", addr); - return NULL; - } - - mm = task->mm; - - task_lock(task); - if (mm == NULL) - { - printk(KERN_ALERT "[-] mm_struct is null !!\n"); - task_unlock(task); - return NULL; - } - - atomic_inc(&mm->mm_users); - spin_lock(&mm->page_table_lock); - task_unlock(task); - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] PGD ENTER\n"); -#endif - - pgd = pgd_offset(mm, addr); - if (pgd_none(*pgd)) - { - printk(KERN_ALERT "[-] PGD_NONE\n"); - goto kernsh_get_page_from_task_error; - } - if (pgd_bad(*pgd)) - { - printk(KERN_ALERT "[-] PGD_BAD\n"); - pgd_clear(pgd); - goto kernsh_get_page_from_task_error; - } -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] PGD EXIT\n"); - - printk(KERN_ALERT "[+] PUD ENTER\n"); -#endif - - pud = pud_offset(pgd, addr); - if (pud_none(*pud)) - { - printk(KERN_ALERT "[-] PUD_NONE\n"); - goto kernsh_get_page_from_task_error; - } - if (pud_bad(*pud)) - { - printk(KERN_ALERT "[-] PUD_BAD\n"); - pud_clear(pud); - goto kernsh_get_page_from_task_error; - } -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] PUD EXIT\n"); - - printk(KERN_ALERT "[+] PMD ENTER\n"); -#endif - - pmd = pmd_offset(pud, addr); - if (pmd_none(*pmd)) - { - printk(KERN_ALERT "[-] PMD_NONE\n"); - goto kernsh_get_page_from_task_error; - } - if (pmd_bad(*pmd)) - { - pmd_clear(pmd); - goto kernsh_get_page_from_task_error; - } -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] PMD EXIT\n"); - - printk(KERN_ALERT "[+] PTE ENTER\n"); -#endif - - pte = pte_offset_kernel(pmd, addr); - if (!pte_present(*pte)) - { - printk(KERN_ALERT "[-] PTE_PRESENT\n"); - goto kernsh_get_page_from_task_error; - } -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] PTE EXIT\n"); -#endif - - page_at_addr = (struct page *)pte_page(*pte); - - kernsh_get_page_from_task_error : - task_lock(task); - spin_unlock(&mm->page_table_lock); - atomic_dec(&mm->mm_users); - task_unlock(task); - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_get_page_from_task EXIT !!\n"); -#endif - - return page_at_addr; -} diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/virtm.c.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/virtm.c.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/.svn/text-base/virtm.c.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/.svn/text-base/virtm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,277 +0,0 @@ -/* -** @file virtm.c -** @ingroup libkernsh_kernel -** -*/ - -#include "libkernsh-kernel.h" -#include "libkernsh-kernel-linux.h" - -/* - * Dictracy Loadable Kernel Module - * by - twiz - twiz@email.it - * thefly - thefly@acaro.org - * - * That module let you investigate, read, search, dump and write the virtual - * address space of a process running. - * - * From the idea exposed by vecna in rmfbd : - * http://www.s0ftpj.org/bfi/dev/BFi11-dev-06 - * - * Thanks : silvio, Liv Tyler (by thefly) - */ - -/** - * @brief Dump elf binary of a pid into a file - * @param pid The process id - * @param filename The filename to write elf binary - * @return 0 on success, -1 on error - */ -int kernsh_dump_elf_pid(int pid, const char *filename) -{ - struct task_struct *task; - struct file *file; - struct mm_struct *mm; - struct vm_area_struct *vma; - unsigned char c; - ssize_t ssize; - int i; - mm_segment_t fs; - - if (filename == NULL || strlen(filename) == 0) - return -1; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "DUMP pid %d @ %s\n", pid, filename); -#endif - - task = find_task_by_pid(pid); - if (task == NULL) - { - printk(KERN_ALERT "Couldn't find pid %d\n", pid); - return -1; - } - - if (task->mm == NULL) - return -1; - - file = filp_open(filename, O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO ); - if (file == NULL) - { - printk(KERN_ALERT "Couldn't create %s\n", filename); - return -1; - } - - get_file(file); - - fs = get_fs(); - set_fs(KERNEL_DS); - - mm = task->mm; - - if (mm) - { - for(vma = mm->mmap; vma; vma = vma->vm_next) - { -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "VM_START @ 0x%lx VM_END @ 0x%lx VM_FLAGS 0x%lx VM_FILE 0x%lx\n", - vma->vm_start, - vma->vm_end, - vma->vm_flags, - (unsigned long)vma->vm_file); -#endif - - if((vma->vm_flags & VM_EXECUTABLE) && - (vma->vm_flags & VM_EXEC) && - (vma->vm_file)) - { - vma->vm_file->f_pos = 0; - ssize = vma->vm_file->f_op->read(vma->vm_file, &c, sizeof(c), - &vma->vm_file->f_pos); - if(ssize > 0) - { - while(ssize != 0) - { - i = file->f_op->write(file, &c, sizeof(c), &file->f_pos ); - if (i != ssize) - { - set_fs(fs); - atomic_dec(&file->f_count); - filp_close(file, 0); - return -1; - } - ssize = vma->vm_file->f_op->read(vma->vm_file, &c, sizeof(c), - &vma->vm_file->f_pos ); - } - } - } - } - - } - - set_fs(fs); - atomic_dec(&file->f_count); - filp_close(file, 0); - - return 0; -} - -/** - * @brief Read virtual memory of a pid - * @param pid The process id - * @param addr The address to read - * @param buffer Read virtual memory into the buffer - * @param len Count bytes to read - * @param mode The mode to write into the buffer - * @return 0 on success, -1 on error - */ -asmlinkage int kernsh_read_virtm(int pid, unsigned long addr, char *buffer, int len, int mode) -{ - struct task_struct *task; - struct page *mypage; - void *kaddr; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_read_virtm ENTER !!\n"); - - printk(KERN_ALERT "Kernsh Read Virtm PID %d @ 0x%lx strlen(%d) in 0x%lx\n", - pid, - addr, - len, - (unsigned long)buffer); -#endif - - if (addr <= 0) - { - printk(KERN_ALERT "[-] Addr isn't valid => 0x%lx!\n", addr); - return -1; - } - - task = find_task_by_pid(pid); - - if (task == NULL) - { - printk(KERN_ALERT "[-] Couldn't find pid %d\n", pid); - return -1; - } - - mypage = kernsh_get_page_from_pid(pid, addr); - if (mypage == NULL) - { - printk(KERN_ALERT "[-] PAGE NULL\n"); - return -EFAULT; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] KMAP_ATOMIC\n"); -#endif - - kaddr = kmap_atomic(mypage, smp_processor_id()); - - switch(mode) - { - case LIBKERNSH_KERNEL_MODE : - memcpy(buffer, kaddr + (addr & ~PAGE_MASK), len); - break; - case LIBKERNSH_USER_MODE : - if(copy_to_user(buffer, kaddr + (addr & ~PAGE_MASK), len)) - { - printk(KERN_ALERT "[-] copy_to_user error\n"); - kunmap_atomic(kaddr, smp_processor_id()); - return -EFAULT; - } - break; - } - - kunmap_atomic(kaddr, smp_processor_id()); -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] KUNMAP_ATOMIC\n"); - - printk(KERN_ALERT "[+] kernsh_read_virtm EXIT !!\n"); -#endif - - return len; -} - -/** - * @brief Write virtual memory of a pid - * @param pid The process id - * @param addr The address to write - * @param buffer Write buffer into virtual memory - * @param len Count bytes to write - * @param mode The mode to write into the buffer - * @return len on success, -1 on error - */ -asmlinkage int kernsh_write_virtm(int pid, unsigned long addr, const char *buffer, int len, int mode) -{ - struct task_struct *task; - struct page *mypage; - void *kaddr; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_write_virtm ENTER !!\n"); - - printk(KERN_ALERT "Kernsh Write Virtm PID %d @ 0x%lx strlen(%d) to 0x%lx\n", - pid, - addr, - len, - (unsigned long)buffer); -#endif - - if (addr <= 0) - { - printk(KERN_ALERT "[-] Addr isn't valid => 0x%lx!\n", addr); - return -1; - } - - task = find_task_by_pid(pid); - - if (task == NULL) - { - printk(KERN_ALERT "[-] Couldn't find pid %d\n", pid); - return -1; - } - - mypage = kernsh_get_page_from_pid(pid, addr); - if (mypage == NULL) - { - printk(KERN_ALERT "[-] PAGE NULL\n"); - return -EFAULT; - } - - if (PageReserved(mypage)) - { - printk(KERN_ALERT "[-] PAGE RESERVED\n"); - return -EFAULT; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] KMAP_ATOMIC\n"); -#endif - - kaddr = kmap_atomic(mypage, smp_processor_id()); - - switch(mode) - { - case LIBKERNSH_KERNEL_MODE : - memcpy(kaddr + (addr & ~PAGE_MASK), buffer, len); - break; - case LIBKERNSH_USER_MODE : - if(copy_from_user(kaddr + (addr & ~PAGE_MASK), buffer, len)) - { - printk(KERN_ALERT "[-] copy_from_user error\n"); - kunmap_atomic(kaddr, smp_processor_id()); - return -EFAULT; - } - break; - } - - kunmap_atomic(kaddr, smp_processor_id()); -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] KUNMAP_ATOMIC\n"); - - printk(KERN_ALERT "[+] kernsh_write_virtm EXIT !!\n"); -#endif - - return len; -} diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/linux/virtm.c eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/virtm.c --- eresi-0.8a25/libkernsh/kernel/arch/x86/linux/virtm.c 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/linux/virtm.c 2011-05-16 11:34:48.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file virtm.c -** @ingroup libkernsh_kernel +/** +* @file libkernsh/kernel/arch/x86/linux/virtm.c +** @ingroup kernelmode ** */ diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/all-wcprops eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/all-wcprops --- eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/944/trunk/libkernsh/kernel/arch/x86 -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/940/trunk/libkernsh/kernel/arch/x86/Makefile -END diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/entries eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/entries --- eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/kernel/arch/x86 -http://svn.eresi-project.org/svn - - - -2008-03-27T21:39:30.403274Z -944 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -linux -dir - -Makefile -file - - - - -2008-04-06T23:15:26.743912Z -659f305c3dc8f6f04a8c833b822fa13d -2008-03-27T10:28:40.877770Z -940 -pouik - diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/format eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/format --- eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/kernel/arch/x86/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/arch/x86/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -OS := $(shell uname -s | sed -e s/Linux*/Linux/) - -ifeq ($(OS),Linux) -all: - $(MAKE) -C linux - -clean: - $(MAKE) -C linux clean - -fclean: - $(MAKE) -C linux fclean -endif diff -Nru eresi-0.8a25/libkernsh/kernel/include/.svn/all-wcprops eresi-0.0.20110516/libkernsh/kernel/include/.svn/all-wcprops --- eresi-0.8a25/libkernsh/kernel/include/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/943/trunk/libkernsh/kernel/include -END -libkernsh-kernel-linux.h -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/943/trunk/libkernsh/kernel/include/libkernsh-kernel-linux.h -END -libkernsh-kernel.h -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/943/trunk/libkernsh/kernel/include/libkernsh-kernel.h -END diff -Nru eresi-0.8a25/libkernsh/kernel/include/.svn/entries eresi-0.0.20110516/libkernsh/kernel/include/.svn/entries --- eresi-0.8a25/libkernsh/kernel/include/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/kernel/include -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libkernsh-kernel-linux.h -file - - - - -2008-04-06T23:15:26.526897Z -4fe4b730dc63dfe97371dedcc2006bf0 -2008-03-27T17:59:55.343182Z -943 -pouik - -libkernsh-kernel.h -file - - - - -2008-04-06T23:15:26.536876Z -454a6aff0f62434b0535efb4638a7e80 -2008-03-27T17:59:55.343182Z -943 -pouik - diff -Nru eresi-0.8a25/libkernsh/kernel/include/.svn/format eresi-0.0.20110516/libkernsh/kernel/include/.svn/format --- eresi-0.8a25/libkernsh/kernel/include/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel.h.svn-base eresi-0.0.20110516/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel.h.svn-base --- eresi-0.8a25/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel.h.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -#ifndef LIBKERNSH_KERNEL_H - #define LIBKERNSH_KERNEL_H - -#include "libkernsh-virtm.h" - -#define __DEBUG_LIBKERNSH_KERNEL__ 1 - -#if defined(__linux__) -#include -#endif - -/* page.c */ -struct page *kernsh_get_page_from_pid(int pid, unsigned long); - -/* virtm.c */ -int kernsh_dump_elf_pid(int, const char *); -asmlinkage int kernsh_read_virtm(int, unsigned long, char *, int, int); -asmlinkage int kernsh_write_virtm(int, unsigned long, const char *, int, int); - -/* mem.c */ -asmlinkage int kernsh_read_mem(unsigned long, char *, int, int); -asmlinkage int kernsh_write_mem(unsigned long, const char *, int, int); - -/* misc.c */ -int kernsh_atoi(const char *); -int kernsh_view_vmaps(int); -asmlinkage int kernsh_task_pid(int, char *, int, int); -int valid_phys_addr_range(unsigned long, int); - -#endif /* __LIBKERNSH_KERNEL_H_ */ diff -Nru eresi-0.8a25/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel-linux.h.svn-base eresi-0.0.20110516/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel-linux.h.svn-base --- eresi-0.8a25/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel-linux.h.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/include/.svn/text-base/libkernsh-kernel-linux.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#ifndef LIBKERNSH_KERNEL_LINUX_H - #define LIBKERNSH_KERNEL_LINUX_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#endif /* __LIBKERNSH_KERNEL_LINUX_H_ */ diff -Nru eresi-0.8a25/libkernsh/kernel/.svn/all-wcprops eresi-0.0.20110516/libkernsh/kernel/.svn/all-wcprops --- eresi-0.8a25/libkernsh/kernel/.svn/all-wcprops 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/950/trunk/libkernsh/kernel -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/950/trunk/libkernsh/kernel/Makefile -END diff -Nru eresi-0.8a25/libkernsh/kernel/.svn/entries eresi-0.0.20110516/libkernsh/kernel/.svn/entries --- eresi-0.8a25/libkernsh/kernel/.svn/entries 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/kernel -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -include -dir - -arch -dir - -Makefile -file - - - - -2008-04-06T23:15:26.800884Z -39b6d2177374b87a91c015e0e3746c57 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/libkernsh/kernel/.svn/format eresi-0.0.20110516/libkernsh/kernel/.svn/format --- eresi-0.8a25/libkernsh/kernel/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/kernel/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/kernel/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/kernel/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/kernel/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -ARCH := $(shell uname -m | sed -e s/i.86/x86/) -OS := $(shell uname -s | sed -e s/Linux*/Linux/) -RELEASE := $(shell uname -r | sed -e s/2.6.*/2.6/ -e s/2.4.*/2.4/) -NAME = libkernsh-kernel.o - -ifeq ($(ARCH),x86) -$(NAME): - $(MAKE) -C arch/x86 - -all: $(NAME) - -clean: - @$(RM) *.o *.ko - $(MAKE) -C arch/x86 clean - -fclean: - @$(RM) *.o *.ko - $(MAKE) -C arch/x86 fclean - -endif diff -Nru eresi-0.8a25/libkernsh/Makefile eresi-0.0.20110516/libkernsh/Makefile --- eresi-0.8a25/libkernsh/Makefile 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/Makefile 2011-05-16 11:34:50.000000000 +0000 @@ -1,7 +1,13 @@ +## +## Makefile for libkernsh in the ERESI project +## +## Created by the ERESI team +## + include ../config.h -NAME32_libkernsh = libkernsh32 -NAME64_libkernsh = libkernsh64 +NAME32_libkernsh = libkernsh32 +NAME64_libkernsh = libkernsh64 LDFLAGS32 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) LDFLAGS64 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) @@ -14,12 +20,12 @@ ../libelfsh/libelfsh64.o ../libedfmt/libedfmt64.o \ ../libaspect/libaspect64.o -RM = rm -f -ETAGS = etags -CC ?= gcc -LD ?= ld -CP = cp -AR = ar rc +RM = rm -f +ETAGS = etags +CC ?= gcc +LD ?= ld +CP = cp +AR = ar rc COBJ32 = common/*.32.o COBJ64 = common/*.64.o @@ -41,6 +47,7 @@ @$(CC) -shared -lcrypto $(COBJ32) $(UOBJ32) $(LDFLAGS32) -o $(NAME32_libkernsh).so @${AR} ${NAME32_libkernsh}.a ${COBJ32} $(UOBJ32) @${RANLIB} ${NAME32_libkernsh}.a + @$(LD) -r $(COBJ32) $(UOBJ32) -o $(NAME32_libkernsh).o all64: mod64 lib64 @@ -53,6 +60,7 @@ $(CC) -shared -lcrypto $(COBJ64) $(UOBJ64) $(LDFLAGS64) -o $(NAME64_libkernsh).so @${AR} ${NAME64_libkernsh}.a ${COBJ4} $(UOBJ64) @${RANLIB} ${NAME64_libkernsh}.a + @$(LD) -r $(COBJ64) $(UOBJ64) -o $(NAME64_libkernsh).o clean: @$(MAKE) -C common clean @@ -64,7 +72,7 @@ @$(MAKE) -C common fclean @$(MAKE) -C kernel fclean @$(MAKE) -C user fclean - @$(RM) *.a *.so + @$(RM) *.a *.so *.o #tags: # @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c diff -Nru eresi-0.8a25/libkernsh/modules/arch/.svn/all-wcprops eresi-0.0.20110516/libkernsh/modules/arch/.svn/all-wcprops --- eresi-0.8a25/libkernsh/modules/arch/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/943/trunk/libkernsh/modules/arch -END diff -Nru eresi-0.8a25/libkernsh/modules/arch/.svn/entries eresi-0.0.20110516/libkernsh/modules/arch/.svn/entries --- eresi-0.8a25/libkernsh/modules/arch/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/modules/arch -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -x86 -dir - diff -Nru eresi-0.8a25/libkernsh/modules/arch/.svn/format eresi-0.0.20110516/libkernsh/modules/arch/.svn/format --- eresi-0.8a25/libkernsh/modules/arch/.svn/format 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/all-wcprops eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/all-wcprops --- eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/943/trunk/libkernsh/modules/arch/x86/linux -END -kernsh-virtm.c -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/943/trunk/libkernsh/modules/arch/x86/linux/kernsh-virtm.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/941/trunk/libkernsh/modules/arch/x86/linux/Makefile -END diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/entries eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/entries --- eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/modules/arch/x86/linux -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kernsh-virtm.c -file - - - - -2008-04-06T23:15:27.860127Z -c9fa303de7ffe9b9529d155191bc41df -2008-03-27T17:59:55.343182Z -943 -pouik - -Makefile -file - - - - -2008-04-06T23:15:27.870136Z -88fa1f48ede17ad46163cc2dacaaa076 -2008-03-27T10:41:19.554616Z -941 -pouik - diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/format eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/format --- eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/format 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/text-base/kernsh-virtm.c.svn-base eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/text-base/kernsh-virtm.c.svn-base --- eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/text-base/kernsh-virtm.c.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/text-base/kernsh-virtm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,388 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libkernsh-kernel.h" - -MODULE_DESCRIPTION("Kernsh Virtual Memory !"); -MODULE_AUTHOR("pouik@kernsh.org"); -MODULE_LICENSE("GPL"); - -#define FREE_SYSCALL_DEFAULT 31 -#define SYS_CALL_TABLE_DEFAULT 0xc02aa440 - -static int hijack_sct; -static unsigned long sct_value; -static int free_syscall; - -module_param(hijack_sct, int, 0); -MODULE_PARM_DESC(hijack_sct, "Hijack sct"); - -module_param(sct_value, long, 0); -MODULE_PARM_DESC(sct_value, "sct_value"); - -module_param(free_syscall, int, 0); -MODULE_PARM_DESC(free_syscall, "free_syscall"); - -static struct proc_dir_entry *proc_entry_kernsh_virtm; -static struct proc_dir_entry *proc_entry_kernsh_virtm_vio; -static struct proc_dir_entry *proc_entry_kernsh_virtm_vio_info; - -static kvirtm_action_t current_kvirtm; - -static void **sys_call_table; - -asmlinkage int (*o_syscallnill)(void); - -asmlinkage int kernsh_read_virtm_syscall(pid_t, unsigned long, char *, int); -asmlinkage int kernsh_read_mem_syscall(unsigned long, char *, int); -asmlinkage int kernsh_write_virtm_syscall(pid_t, unsigned long, const char *, int); -asmlinkage int kernsh_write_mem_syscall(unsigned long, const char *, int); - -ssize_t kernsh_virtm_vio_info_input(struct file *filp, - const char __user *buff, - unsigned long len, - void *data) -{ - char *token; - char *new_buff; - int i; - pid_t new_pid; - - printk(KERN_ALERT "kernsh_virtm_vio_info_input ENTER !!\n"); - - new_buff = kmalloc(len, GFP_KERNEL); - if (copy_from_user(new_buff, buff, len)) - return -EFAULT; - - i = 0; - while((token = strsep(&new_buff, ":")) != NULL) - { - switch(i) - { - /* Action */ - case 0 : - current_kvirtm.action = kernsh_atoi(token); - break; - - /* Addr */ - case 1 : - current_kvirtm.addr = simple_strtoul(token, NULL, 16); - break; - - /* Len */ - case 2 : - current_kvirtm.len = kernsh_atoi(token); - break; - - /* Additional flags */ - case 3 : - new_pid = kernsh_atoi(token); - if (new_pid > 0 && new_pid <= PID_MAX_DEFAULT) - { - current_kvirtm.pid = new_pid; - } - break; - case 4 : - if (strlen(token) > 0 && strlen(token) <= sizeof(current_kvirtm.filename)) - { - memset(current_kvirtm.filename, '\0', sizeof(current_kvirtm.filename)); - memcpy(current_kvirtm.filename, token, strlen(token)); - } - break; - default : - break; - } - i++; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "KVIRTM %d 0x%lx %d %d %s\n", - current_kvirtm.action, - current_kvirtm.addr, - current_kvirtm.len, - current_kvirtm.pid, - current_kvirtm.filename); -#endif - - kfree(new_buff); - return len; -} - -int kernsh_virtm_vio_info_output(char *page, char **start, off_t off, int count, int *eof, void *data) -{ - - return 0; -} - -ssize_t kernsh_virtm_vio_input(struct file *filp, - const char __user *buff, - unsigned long len, - void *data) -{ - - printk(KERN_ALERT "kernsh_virtm_vio_input buff 0x%lx COUNT 0x%lx\n", (unsigned long)buff, len); - - switch (current_kvirtm.action) - { - case LIBKERNSH_VIRTM_WRITE_MEM_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kvvo -> kernsh_write_virtm\n"); -#endif - kernsh_write_virtm(current_kvirtm.pid, - current_kvirtm.addr, - buff, - current_kvirtm.len, - LIBKERNSH_KERNEL_MODE); - break; - case LIBKERNSH_VIRTM_WRITE_MEM : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kvvo -> kernsh_write_mem\n"); -#endif - kernsh_write_mem(current_kvirtm.addr, - buff, - current_kvirtm.len, - LIBKERNSH_KERNEL_MODE); - break; - } - - - return len; -} - -int kernsh_virtm_vio_output(char *page, char **start, off_t off, int count, int *eof, void *data) -{ - char *new_buff; - int len; - - len = 0; - - new_buff = NULL; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kernsh_virtm_vio_output PAGE 0x%lx COUNT %d\n", (unsigned long)page, count); -#endif - - switch (current_kvirtm.action) - { - case LIBKERNSH_VIRTM_READ_MEM : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kvvo -> kernsh_read_mem\n"); -#endif - new_buff = kmalloc(current_kvirtm.len, GFP_KERNEL); - kernsh_read_mem(current_kvirtm.addr, - new_buff, - current_kvirtm.len, - LIBKERNSH_KERNEL_MODE); - len = current_kvirtm.len; - break; - case LIBKERNSH_VIRTM_READ_MEM_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kvvo -> kernsh_read_virtm\n"); -#endif - new_buff = kmalloc(current_kvirtm.len, GFP_KERNEL); - len = kernsh_read_virtm(current_kvirtm.pid, - current_kvirtm.addr, - new_buff, - current_kvirtm.len, - LIBKERNSH_KERNEL_MODE); - break; - case LIBKERNSH_VIRTM_TASK_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "kvvo -> kernsh_task_pid\n"); -#endif - new_buff = kmalloc(current_kvirtm.len, GFP_KERNEL); - len = kernsh_task_pid(current_kvirtm.pid, new_buff, current_kvirtm.len, LIBKERNSH_KERNEL_MODE); - break; - case LIBKERNSH_VIRTM_DUMP_ELF_PID : - len = kernsh_dump_elf_pid(current_kvirtm.pid, current_kvirtm.filename); - break; - default : - return -EFAULT; - break; - } - - if (len > 0) - memcpy(page, new_buff, len); - - kfree(new_buff); - - return len; -} - -asmlinkage int kernsh_read_virtm_syscall(pid_t pid, unsigned long addr, char *buffer, int len) -{ - return kernsh_read_virtm(pid, addr, buffer, len, LIBKERNSH_USER_MODE); -} - -asmlinkage int kernsh_write_virtm_syscall(pid_t pid, unsigned long addr, const char *buffer, int len) -{ - return kernsh_write_virtm(pid, addr, buffer, len, LIBKERNSH_USER_MODE); -} - -asmlinkage int kernsh_read_mem_syscall(unsigned long addr, char *buffer, int len) -{ - return kernsh_read_mem(addr, buffer, len, LIBKERNSH_USER_MODE); -} - -asmlinkage int kernsh_write_mem_syscall(unsigned long addr, const char *buffer, int len) -{ - return kernsh_write_mem(addr, buffer, len, LIBKERNSH_USER_MODE); -} - -asmlinkage int kernsh_task_pid_syscall(pid_t pid, char *buffer, int len) -{ - return kernsh_task_pid(pid, buffer, len, LIBKERNSH_USER_MODE); -} - -asmlinkage int kernsh_dump_elf_pid_syscall(pid_t pid, const char *filename) -{ - return kernsh_dump_elf_pid(pid, filename); -} - -int asmlinkage kernsh_kvirtm_syscall_wrapper(pid_t pid, - unsigned long addr, - char *buffer, - int len, - int type) -{ -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kernsh_kvirtm_syscall_wrapper\n"); -#endif - - switch (type) - { - case LIBKERNSH_VIRTM_READ_MEM : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_read_mem_syscall\n"); -#endif - return kernsh_read_mem_syscall(addr, buffer, len); - break; - case LIBKERNSH_VIRTM_WRITE_MEM : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_write_mem_syscall\n"); -#endif - return kernsh_write_mem_syscall(addr, buffer, len); - break; - case LIBKERNSH_VIRTM_READ_MEM_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_read_virtm_syscall\n"); -#endif - return kernsh_read_virtm_syscall(pid, addr, buffer, len); - break; - case LIBKERNSH_VIRTM_WRITE_MEM_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_write_virtm_syscall\n"); -#endif - return kernsh_write_virtm_syscall(pid, addr, buffer, len); - break; - case LIBKERNSH_VIRTM_TASK_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_task_pid_syscall\n"); -#endif - return kernsh_task_pid_syscall(pid, buffer, len); - break; - case LIBKERNSH_VIRTM_DUMP_ELF_PID : -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "[+] kksw -> kernsh_dump_pid_syscall\n"); -#endif - return kernsh_dump_elf_pid_syscall(pid, buffer); - break; - default : - break; - } - - return -1; -} - -static int kernsh_virtm_init(void) -{ -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "Kernsh Virtm Init\n"); -#endif - - memset(¤t_kvirtm, '\0', sizeof(current_kvirtm)); - - proc_entry_kernsh_virtm = proc_mkdir(PROC_ENTRY_KERNSH_VIRTM, &proc_root); - - if (proc_entry_kernsh_virtm == NULL) - { - printk(KERN_ALERT "Couldn't create kernsh virtm proc entry\n"); - return -1; - } - - proc_entry_kernsh_virtm_vio = - create_proc_entry(PROC_ENTRY_KERNSH_VIRTM_VIO, 0644, proc_entry_kernsh_virtm); - proc_entry_kernsh_virtm_vio_info = - create_proc_entry(PROC_ENTRY_KERNSH_VIRTM_VIO_INFO, 0644, proc_entry_kernsh_virtm); - - if (proc_entry_kernsh_virtm_vio_info == NULL || - proc_entry_kernsh_virtm_vio == NULL) - { - printk(KERN_ALERT "Couldn't create sub proc entry\n"); - return -1; - } - - proc_entry_kernsh_virtm_vio_info->read_proc = kernsh_virtm_vio_info_output; - proc_entry_kernsh_virtm_vio_info->write_proc = kernsh_virtm_vio_info_input; - proc_entry_kernsh_virtm_vio_info->owner = THIS_MODULE; - - proc_entry_kernsh_virtm_vio->read_proc = kernsh_virtm_vio_output; - proc_entry_kernsh_virtm_vio->write_proc = kernsh_virtm_vio_input; - proc_entry_kernsh_virtm_vio->owner = THIS_MODULE; - - if (hijack_sct) - { - if (!sct_value) - sct_value = SYS_CALL_TABLE_DEFAULT; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "HIJACK sys_call_table @ 0x%lx ", sct_value); -#endif - - sys_call_table = (void **)sct_value; - - if (!free_syscall) - free_syscall = FREE_SYSCALL_DEFAULT; - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "and use syscall %d\n", free_syscall); -#endif - - o_syscallnill = sys_call_table[free_syscall]; - sys_call_table[free_syscall] = &kernsh_kvirtm_syscall_wrapper; - } - - return 0; -} - -static void kernsh_virtm_exit(void) -{ - remove_proc_entry(PROC_ENTRY_KERNSH_VIRTM_VIO_INFO, proc_entry_kernsh_virtm); - remove_proc_entry(PROC_ENTRY_KERNSH_VIRTM_VIO, proc_entry_kernsh_virtm); - - remove_proc_entry(PROC_ENTRY_KERNSH_VIRTM, &proc_root); - - if (hijack_sct) - { -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "UNHIJACK sys_call_table @ 0x%lx\n", sct_value); -#endif - sys_call_table[free_syscall] = o_syscallnill; - } - -#if __DEBUG_LIBKERNSH_KERNEL__ - printk(KERN_ALERT "Kernsh Virtm Exit\n"); -#endif -} - -module_init(kernsh_virtm_init); -module_exit(kernsh_virtm_exit); diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/modules/arch/x86/linux/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/linux/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -RELEASE := $(shell uname -r | sed -e s/2.6.*/2.6/ -e s/2.4.*/2.4/) -CP := cp - -ifeq ($(RELEASE),2.6) - -EXTRA_CFLAGS := -g3 -Wall -I/usr/include -I$(src)/../../../../include \ - -I$(src)/../include -I$(src)/../../../../kernel/include \ - -DERESI32 -Wno-strict-prototypes - -EXTRAOBJ := ../../../../kernel/libkernsh-kernel.o - -kernsh-virtm-linux-y := kernsh-virtm.o $(EXTRAOBJ) - -obj-m := kernsh-virtm-linux.o - -all: - $(MAKE) -C /lib/modules/`uname -r`/build M=`pwd`/ - $(CP) kernsh-virtm-linux.ko ../../../ - -clean: - @$(RM) *.o *~ \#* *\# .\#* *.symvers *.mod.c Module.* .*.o.cmd .*.ko.cmd - @$(RM) include/*~ include/\#* include/*\# include/.\#* - @$(RM) -fr .tmp_versions* - -fclean: clean - @$(RM) *.ko -endif diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/.svn/all-wcprops eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/all-wcprops --- eresi-0.8a25/libkernsh/modules/arch/x86/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/943/trunk/libkernsh/modules/arch/x86 -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/941/trunk/libkernsh/modules/arch/x86/Makefile -END diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/.svn/entries eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/entries --- eresi-0.8a25/libkernsh/modules/arch/x86/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/modules/arch/x86 -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -linux -dir - -Makefile -file - - - - -2008-04-06T23:15:27.905133Z -659f305c3dc8f6f04a8c833b822fa13d -2008-03-27T10:41:19.554616Z -941 -pouik - diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/.svn/format eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/format --- eresi-0.8a25/libkernsh/modules/arch/x86/.svn/format 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/modules/arch/x86/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/modules/arch/x86/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/arch/x86/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -OS := $(shell uname -s | sed -e s/Linux*/Linux/) - -ifeq ($(OS),Linux) -all: - $(MAKE) -C linux - -clean: - $(MAKE) -C linux clean - -fclean: - $(MAKE) -C linux fclean -endif diff -Nru eresi-0.8a25/libkernsh/modules/.svn/all-wcprops eresi-0.0.20110516/libkernsh/modules/.svn/all-wcprops --- eresi-0.8a25/libkernsh/modules/.svn/all-wcprops 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/943/trunk/libkernsh/modules -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/941/trunk/libkernsh/modules/Makefile -END diff -Nru eresi-0.8a25/libkernsh/modules/.svn/entries eresi-0.0.20110516/libkernsh/modules/.svn/entries --- eresi-0.8a25/libkernsh/modules/.svn/entries 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/modules -http://svn.eresi-project.org/svn - - - -2008-03-27T17:59:55.343182Z -943 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -arch -dir - -Makefile -file - - - - -2008-04-06T23:15:27.961886Z -1df73b446c6c0fcfde8677cfa25f7bee -2008-03-27T10:41:19.554616Z -941 -pouik - diff -Nru eresi-0.8a25/libkernsh/modules/.svn/format eresi-0.0.20110516/libkernsh/modules/.svn/format --- eresi-0.8a25/libkernsh/modules/.svn/format 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/modules/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/modules/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/modules/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/modules/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -ARCH := $(shell uname -m | sed -e s/i.86/x86/) -OS := $(shell uname -s | sed -e s/Linux*/Linux/) -RELEASE := $(shell uname -r | sed -e s/2.6.*/2.6/ -e s/2.4.*/2.4/) - -ifeq ($(ARCH),x86) -all: - $(MAKE) -C arch/x86 - -clean: - @$(RM) *.o *.ko - $(MAKE) -C arch/x86 clean - -fclean: - @$(RM) *.o *.ko - $(MAKE) -C arch/x86 fclean - -endif diff -Nru eresi-0.8a25/libkernsh/.svn/all-wcprops eresi-0.0.20110516/libkernsh/.svn/all-wcprops --- eresi-0.8a25/libkernsh/.svn/all-wcprops 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 33 -/svn/!svn/ver/952/trunk/libkernsh -END -TODO -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/952/trunk/libkernsh/TODO -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/932/trunk/libkernsh/Makefile -END diff -Nru eresi-0.8a25/libkernsh/.svn/entries eresi-0.0.20110516/libkernsh/.svn/entries --- eresi-0.8a25/libkernsh/.svn/entries 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh -http://svn.eresi-project.org/svn - - - -2008-03-29T16:01:15.895002Z -952 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kernel -dir - -include -dir - -doc -dir - -TODO -file - - - - -2008-04-06T23:15:28.494207Z -459b7d67739f51d4675ba080a743ef0d -2008-03-29T16:01:15.895002Z -952 -pouik - -common -dir - -modules -dir - -Makefile -file - - - - -2008-04-06T23:15:28.505665Z -5fb96f5c4dc7311cb7d187447a4c1054 -2008-03-25T08:39:03.629041Z -932 -pouik - -user -dir - diff -Nru eresi-0.8a25/libkernsh/.svn/format eresi-0.0.20110516/libkernsh/.svn/format --- eresi-0.8a25/libkernsh/.svn/format 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:27.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,82 +0,0 @@ -include ../config.h - -NAME32_libkernsh = libkernsh32 -NAME64_libkernsh = libkernsh64 - -LDFLAGS32 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) -LDFLAGS64 += $(DLOPT) $(DYNOPT) $(EXTRAOPT) - -EXTRAOBJ32 = ../libasm/libasm.o ../libmjollnir/libmjollnir32.o \ - ../libelfsh/libelfsh32.o ../libedfmt/libedfmt32.o \ - ../libaspect/libaspect32.o - -EXTRAOBJ64 = ../libasm/libasm.o ../libmjollnir/libmjollnir64.o \ - ../libelfsh/libelfsh64.o ../libedfmt/libedfmt64.o \ - ../libaspect/libaspect64.o - -RM = rm -f -ETAGS = etags -CC ?= gcc -LD ?= ld -CP = cp -AR = ar rc - -COBJ32 = common/*.32.o -COBJ64 = common/*.64.o -KOBJ32 = kernel/*.32.o -KOBJ64 = kernel/*.64.o -UOBJ32 = user/*.32.o -UOBJ64 = user/*.64.o - -all: all32 all64 - -all32: mod32 lib32 - -mod32: - $(MAKE) -C common all32 - $(MAKE) -C user all32 - $(MAKE) -C kernel - -lib32: - @$(CC) -shared -lcrypto $(COBJ32) $(UOBJ32) $(LDFLAGS32) -o $(NAME32_libkernsh).so - @${AR} ${NAME32_libkernsh}.a ${COBJ32} $(UOBJ32) - @${RANLIB} ${NAME32_libkernsh}.a - -all64: mod64 lib64 - -mod64: - $(MAKE) -C common all64 - $(MAKE) -C user all64 - $(MAKE) -C kernel - -lib64: - $(CC) -shared -lcrypto $(COBJ64) $(UOBJ64) $(LDFLAGS64) -o $(NAME64_libkernsh).so - @${AR} ${NAME64_libkernsh}.a ${COBJ4} $(UOBJ64) - @${RANLIB} ${NAME64_libkernsh}.a - -clean: - @$(MAKE) -C common clean - @$(MAKE) -C kernel clean - @$(MAKE) -C user clean - @$(RM) *~ \#* *\# .\#* - -fclean: clean - @$(MAKE) -C common fclean - @$(MAKE) -C kernel fclean - @$(MAKE) -C user fclean - @$(RM) *.a *.so - -#tags: -# @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c -# @echo TAGS generated succesfully - -%.32.o: %.c - @$(CC) $(CFLAGS32) ${DBGFLAGS} -c $*.c -o $*.32.o - @echo "[CC] $*.32.o" - -%.64.o: %.c - @$(CC) $(CFLAGS64) ${DBGFLAGS} -c $*.c -o $*.64.o - @echo "[CC] $*.64.o" -docs: - doxygen doc/doxygen.conf - diff -Nru eresi-0.8a25/libkernsh/.svn/text-base/TODO.svn-base eresi-0.0.20110516/libkernsh/.svn/text-base/TODO.svn-base --- eresi-0.8a25/libkernsh/.svn/text-base/TODO.svn-base 2008-04-06 23:15:26.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/.svn/text-base/TODO.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - -----[ Libkernsh TODO (not ordered) ]----- - - -- Finish kernsh_get_vma and kernsh_task_pid -- Fix len at PAGE_SIZE to read/write in process virtual memory with syscall -- Fix Dump -- Socket -- Use libmjollnir -- Handle compressed kernel -- Finish autotypes -- Handle process -- Add SHA-1 -- support *BSD -- ... -- ... - - -A new feature ? see kernsh README diff -Nru eresi-0.8a25/libkernsh/user/alloc.c eresi-0.0.20110516/libkernsh/user/alloc.c --- eresi-0.8a25/libkernsh/user/alloc.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/alloc.c 2011-05-16 11:34:50.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file alloc.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/alloc.c +** @ingroup usermode ** @brief allocation contiguous/non contiguous. ** */ @@ -11,45 +11,49 @@ /** * @brief Allocate contiguous/non contiguous kernel memory\n * Configure :\n - * LIBKERNSH_VMCONFIG_ALLOC + * LIBKERNSH_CONFIG_ALLOC * @param size Allocate size bytes * @param addr Address of the new allocation * @return 0 on success, -1 on return */ -int kernsh_alloc(size_t size, unsigned long *addr) +eresi_Addr kernsh_alloc(elfshobj_t *file, size_t size, int prot) { - int mode, ret; + int mode; + int ret; + eresi_Addr raddr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - mode = (int) config_get_data(LIBKERNSH_VMCONFIG_ALLOC); + mode = (int) config_get_data(LIBKERNSH_CONFIG_ALLOC); if (mode == 0) - ret = kernsh_alloc_contiguous(size, addr); + ret = kernsh_alloc_contiguous(size, &raddr); else - ret = kernsh_alloc_noncontiguous(size, addr); + ret = kernsh_alloc_noncontiguous(size, &raddr); + + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to allocate kernel memory", ELFSH_INVALID_ADDR); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, raddr); } /** * @brief Free contiguous/non contiguous kernel memory\n * Configure :\n - * LIBKERNSH_VMCONFIG_ALLOC + * LIBKERNSH_CONFIG_ALLOC * @param addr Address of the allocation * @return 0 on success, -1 on return */ -int kernsh_free(unsigned long addr) +int kernsh_free(eresi_Addr addr) { - int mode, ret; + int mode, ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mode = (int) config_get_data(LIBKERNSH_VMCONFIG_ALLOC); + mode = (int) config_get_data(LIBKERNSH_CONFIG_ALLOC); if (mode == 0) ret = kernsh_free_contiguous(addr); else ret = kernsh_free_noncontiguous(addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -59,9 +63,9 @@ * @param addr Address of the new allocation * @return 0 on success, -1 on return */ -int kernsh_alloc_contiguous(size_t size, unsigned long *addr) +int kernsh_alloc_contiguous(size_t size, eresi_Addr *addr) { - int ret; + int ret; u_int dim[2]; vector_t *alloc; int (*fct)(); @@ -69,18 +73,13 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not open !", -1); alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS); dim[0] = libkernshworld.os; - fct = aspect_vectors_select(alloc, dim); - ret = fct(size, addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -90,28 +89,21 @@ * @param addr Address of the new allocation * @return 0 on success, -1 on return */ -int kernsh_alloc_noncontiguous(size_t size, unsigned long *addr) +int kernsh_alloc_noncontiguous(size_t size, eresi_Addr *addr) { - int ret; + int ret; u_int dim[2]; vector_t *alloc; int (*fct)(); PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not open !", -1); alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS); dim[0] = libkernshworld.os; - fct = aspect_vectors_select(alloc, dim); - ret = fct(size, addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -120,28 +112,21 @@ * @param addr Address of the allocation * @return 0 on success, -1 on return */ -int kernsh_free_contiguous(unsigned long addr) +int kernsh_free_contiguous(eresi_Addr addr) { - int ret; + int ret; u_int dim[2]; vector_t *alloc; int (*fct)(); PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not open !", -1); alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS); dim[0] = libkernshworld.os; - fct = aspect_vectors_select(alloc, dim); - ret = fct(addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -150,47 +135,40 @@ * @param addr Address of the allocation * @return 0 on success, -1 on return */ -int kernsh_free_noncontiguous(unsigned long addr) +int kernsh_free_noncontiguous(eresi_Addr addr) { - int ret; + int ret; u_int dim[2]; vector_t *alloc; int (*fct)(); PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not open !", -1); alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS); dim[0] = libkernshworld.os; - fct = aspect_vectors_select(alloc, dim); - ret = fct(addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } /** * @brief Allocate contiguous kernel memory on Linux\n * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL + * LIBKERNSH_CONFIG_NIL_SYSCALL * @param size Allocate size bytes * @param addr Address of the new allocation * @return 0 on success, -1 on return */ -int kernsh_alloc_contiguous_linux(size_t size, unsigned long *addr) +int kernsh_alloc_contiguous_linux(size_t size, eresi_Addr *addr) { - int ret; - char buf[sizeof(KMALLOC)]; - unsigned long kaddr; - unsigned long nil_syscall; + int ret; + char buf[sizeof(KMALLOC)]; + eresi_Addr kaddr; + eresi_Addr nil_syscall; libkernshkma_t kmalloc; - unsigned int arg[1]; + unsigned int arg[1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -202,245 +180,221 @@ #endif if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol kmalloc", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find symbol kmalloc", -1); - kmalloc.kexec = (void *)kaddr; - kmalloc.size = size; + kmalloc.kexec = (void *) kaddr; + kmalloc.size = size; kmalloc.flags = GFP_KERNEL; - kmalloc.mem = 0; + kmalloc.mem = 0; - arg[0] = (unsigned int)&kmalloc; + /* XXX: NOT 64 BITS COMPATIBLE */ + arg[0] = (unsigned int) &kmalloc; /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); + elfsh_readmema(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); /* Write kmalloc's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, KMALLOC, sizeof(KMALLOC)); + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, KMALLOC, sizeof(KMALLOC)); /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_readmema(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &libkernshworld.kernel_start, sizeof(eresi_Addr)); + /* Exec nil syscall which is now kmalloc */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - + kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), 1, arg); *addr = kmalloc.mem; /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** * @brief Free contiguous kernel memory on Linux\n * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL + * LIBKERNSH_CONFIG_NIL_SYSCALL * @param addr Address of the allocation * @return 0 on success, -1 on return */ -int kernsh_free_contiguous_linux(unsigned long addr) +int kernsh_free_contiguous_linux(eresi_Addr addr) { - int ret; - char buf[sizeof(KFREE)]; - unsigned long kaddr; - unsigned long nil_syscall; + int ret; + char buf[sizeof(KFREE)]; + eresi_Addr kaddr; + eresi_Addr nil_syscall; libkernshkfr_t kfree; - unsigned int arg[1]; + unsigned int arg[1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Get kfree's addr */ ret = kernsh_get_addr_by_name("kfree", &kaddr, strlen("kfree")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol kfree", -1); - } + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find symbol kfree", -1); - kfree.kexec = (void *)kaddr; + /* FIXME: not 64 bits compatible */ + kfree.kexec = (void *) kaddr; kfree.address = (const void *) addr; - - arg[0] = (unsigned int)&kfree; + arg[0] = (unsigned int) &kfree; /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); + elfsh_readmema(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); /* Write kfree's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, KFREE, sizeof(KFREE)); + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, KFREE, sizeof(KFREE)); /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_readmema(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &libkernshworld.kernel_start, sizeof(eresi_Addr)); + /* Exec nil syscall which is now kfree */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); + kernsh_syscall((int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), 1, arg); /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** * @brief Allocate non contiguous kernel memory on Linux\n * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL + * LIBKERNSH_CONFIG_NIL_SYSCALL * @param size Allocate size bytes * @param addr Address of the new allocation * @return 0 on success, -1 on return */ -int kernsh_alloc_noncontiguous_linux(size_t size, unsigned long *addr) +int kernsh_alloc_noncontiguous_linux(size_t size, eresi_Addr *addr) { - int ret; - char buf[sizeof(VMALLOC)]; - unsigned long kaddr; - unsigned long nil_syscall; + int ret; + char buf[sizeof(VMALLOC)]; + eresi_Addr kaddr; + eresi_Addr nil_syscall; libkernshvma_t vmalloc; - unsigned int arg[1]; + unsigned int arg[1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Get vmalloc's addr */ ret = kernsh_get_addr_by_name("vmalloc", &kaddr, strlen("vmalloc")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol vmalloc", -1); - } - - vmalloc.kexec = (void *)kaddr; - vmalloc.size = size; - vmalloc.mem = 0; - - arg[0] = (unsigned int)&vmalloc; + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find symbol vmalloc", -1); + + /* XXX: Not 64 bits compatible ? */ + vmalloc.kexec = (void *) kaddr; + vmalloc.size = size; + vmalloc.mem = 0; + arg[0] = (unsigned int) &vmalloc; /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); + elfsh_readmema(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); /* Write vmalloc's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, VMALLOC, sizeof(VMALLOC)); + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, VMALLOC, sizeof(VMALLOC)); /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_readmema(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &libkernshworld.kernel_start, sizeof(eresi_Addr)); /* Exec nil syscall which is now vmlloc */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - + kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), 1, arg); *addr = vmalloc.mem; /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** * @brief Free non contiguous kernel memory on Linux\n * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL + * LIBKERNSH_CONFIG_NIL_SYSCALL * @param addr Address of the allocation * @return 0 on success, -1 on return */ -int kernsh_free_noncontiguous_linux(unsigned long addr) +int kernsh_free_noncontiguous_linux(eresi_Addr addr) { - int ret; - char buf[sizeof(VFREE)]; - unsigned long kaddr; - unsigned long nil_syscall; - libkernshvfr_t vfree; - unsigned int arg[1]; + int ret; + char buf[sizeof(VFREE)]; + eresi_Addr kaddr; + eresi_Addr nil_syscall; + libkernshvfr_t vfree; + unsigned int arg[1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Get vfree's addr */ ret = kernsh_get_addr_by_name("vfree", &kaddr, strlen("vfree")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol vfree", -1); - } + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find symbol vfree", -1); - vfree.kexec = (void *)kaddr; + /* XXX: not 64 bits compatible ? */ + vfree.kexec = (void *) kaddr; vfree.address = (void *) addr; - - arg[0] = (unsigned int)&vfree; + arg[0] = (unsigned int) &vfree; /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); + elfsh_readmema(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); /* Write vfree's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, VFREE, sizeof(VFREE)); + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, VFREE, sizeof(VFREE)); /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_readmema(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &libkernshworld.kernel_start, + sizeof(eresi_Addr)); + /* Exec nil syscall which is now vfree */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); + kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), 1, arg); /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); + elfsh_writemem(libkernshworld.root, libkernshworld.sct + + sizeof(eresi_Addr) * (int) config_get_data(LIBKERNSH_CONFIG_NIL_SYSCALL), + &nil_syscall, sizeof(eresi_Addr)); /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - + elfsh_writemem(libkernshworld.root, libkernshworld.kernel_start, &buf, sizeof(buf)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libkernsh/user/kcore.c eresi-0.0.20110516/libkernsh/user/kcore.c --- eresi-0.8a25/libkernsh/user/kcore.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/kcore.c 2011-05-16 11:34:49.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file kcore.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/kcore.c +** @ingroup usermode ** */ #define _LARGEFILE64_SOURCE @@ -38,6 +38,7 @@ } libkernshworld.open = 1; + libkernshworld.root->iotype = ELFSH_IOTYPE_KCORE; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -75,31 +76,36 @@ * @param size Count bytes to read * @return size on success, -1 on error */ -int kernsh_readmem_kcore_linux_2_6(unsigned long offset, void *buf, int size) +void *kernsh_readmema_kcore_linux_2_6(elfshobj_t *unused, eresi_Addr addr, + void *buf, int size) { - unsigned long roffset; + eresi_Addr realaddr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read kcore in static mode", NULL); - roffset = offset - libkernshworld.kernel_start + 0x1000; + realaddr = addr - libkernshworld.kernel_start + 0x1000; if (libkernshworld.mmap) { - if (memcpy(buf, libkernshworld.ptr+roffset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } + if (memcpy(buf, libkernshworld.ptr + realaddr, size) == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memcpy failed !", NULL); } else { #if defined(__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); + XLSEEK64(libkernshworld.fd, realaddr, SEEK_SET, NULL); #endif - XREAD(libkernshworld.fd, buf, size, -1); + XREAD(libkernshworld.fd, buf, size, NULL); } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } /** @@ -109,11 +115,15 @@ * @param size Count bytes to write * @return size on success, -1 on error */ -int kernsh_writemem_kcore_linux_2_6(unsigned long offset, void *buf, int size) +int kernsh_writemem_kcore_linux_2_6(elfshobj_t *unused, eresi_Addr offset, void *buf, + int size) { - unsigned long roffset; + eresi_Addr roffset; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); roffset = offset - libkernshworld.kernel_start + 0x1000; diff -Nru eresi-0.8a25/libkernsh/user/kernimage.c eresi-0.0.20110516/libkernsh/user/kernimage.c --- eresi-0.8a25/libkernsh/user/kernimage.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/kernimage.c 2011-05-16 11:34:49.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file kernimage.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/kernimage.c +** @ingroup usermode ** */ #include "libkernsh.h" @@ -36,7 +36,7 @@ /** * @brief Extract and gunzip the linux kernel\n * Configure :\n - * LIBKERNSH_VMCONFIG_KERNEL, LIBKERNSH_VMCONFIG_STORAGE_PATH, LIBKERNSH_VMCONFIG_KERNELGZ, LIBKERNSH_VMCONFIG_KERNELELF, LIBKERNSH_VMCONFIG_OBJCOPY, LIBKERNSH_VMCONFIG_GZIP + * LIBKERNSH_CONFIG_KERNEL, LIBKERNSH_CONFIG_STORAGE_PATH, LIBKERNSH_CONFIG_KERNELGZ, LIBKERNSH_CONFIG_KERNELELF, LIBKERNSH_CONFIG_OBJCOPY, LIBKERNSH_CONFIG_GZIP * @return 0 on success, -1 on error */ int kernsh_decompkernel_linux() @@ -59,13 +59,13 @@ XOPEN(fd, - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNEL), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNEL), O_RDONLY, 0, -1); #if __DEBUG_KERNSH__ - printf("OPEN KERNEL @ %s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNEL)); + printf("OPEN KERNEL @ %s\n", (char *) config_get_data(LIBKERNSH_CONFIG_KERNEL)); #endif if(fstat(fd, &st) == -1) @@ -91,8 +91,8 @@ memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNELGZ)); XOPEN(fz, buf, O_CREAT|O_RDWR, 0777, -1); @@ -111,9 +111,9 @@ memset(decomp, '\0', sizeof(decomp)); snprintf(decomp, sizeof(decomp), "%s -d -f %s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_GZIP), - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); + (char *) config_get_data(LIBKERNSH_CONFIG_GZIP), + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNELGZ)); #if __DEBUG_KERNSH__ printf("DECOMP %s\n", decomp); @@ -123,25 +123,25 @@ memset(bufgz, '\0', sizeof(bufgz)); snprintf(bufgz, sizeof(bufgz), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNELGZ)); bufgz[strlen(bufgz) - 3] = '\0'; memset(bufelf, '\0', sizeof(bufelf)); snprintf(bufelf, sizeof(bufelf), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); + (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), + (char *) config_get_data(LIBKERNSH_CONFIG_KERNELELF)); memset(buf, '\0', sizeof(buf)); snprintf(buf, sizeof(buf) , "%s -B i386 -I binary -O elf32-i386 %s %s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_OBJCOPY), + (char *) config_get_data(LIBKERNSH_CONFIG_OBJCOPY), bufgz, bufelf); #if __DEBUG_KERNSH__ - printf("EXTRACT ELF FROM DATA @ %s%s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); + printf("EXTRACT ELF FROM DATA @ %s%s\n", (char *) config_get_data(LIBKERNSH_CONFIG_STORAGE_PATH), (char *) config_get_data(LIBKERNSH_CONFIG_KERNELELF)); #endif system(buf); diff -Nru eresi-0.8a25/libkernsh/user/kernsh.c eresi-0.0.20110516/libkernsh/user/kernsh.c --- eresi-0.8a25/libkernsh/user/kernsh.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/kernsh.c 2011-05-16 11:34:50.000000000 +0000 @@ -1,9 +1,10 @@ /** - * @defgroup libkernsh_user libkernsh_user + * @defgroup usermode Usermode running code. + * @ingroup libkernsh */ /* -** @file kernsh.c -* @ingroup libkernsh_user +* @file libkernsh/user/kernsh.c +* @ingroup usermode * @brief initialisation, get_raw and mode switch ** */ @@ -28,101 +29,101 @@ libkernshworld.arch = LIBKERNSH_ARCH_I386; /* By default we use static kernel */ - kernsh_set_static_mode(); + elfsh_set_static_mode(); - config_add_item(LIBKERNSH_VMCONFIG_WITHOUT_KERNEL, + config_add_item(LIBKERNSH_CONFIG_WITHOUT_KERNEL, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 0); - config_add_item(LIBKERNSH_VMCONFIG_USE_KERNEL, + config_add_item(LIBKERNSH_CONFIG_USE_KERNEL, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 0); - config_add_item(LIBKERNSH_VMCONFIG_ALLOC, + config_add_item(LIBKERNSH_CONFIG_ALLOC, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 0); - config_add_item(LIBKERNSH_VMCONFIG_GZIP, + config_add_item(LIBKERNSH_CONFIG_GZIP, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_DEFAULT_GZIP); - config_add_item(LIBKERNSH_VMCONFIG_OBJCOPY, + config_add_item(LIBKERNSH_CONFIG_OBJCOPY, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_DEFAULT_OBJCOPY); - config_add_item(LIBKERNSH_VMCONFIG_LD, + config_add_item(LIBKERNSH_CONFIG_LD, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_DEFAULT_LD); - config_add_item(LIBKERNSH_VMCONFIG_FENDSIZE, + config_add_item(LIBKERNSH_CONFIG_FENDSIZE, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_FENDSIZE); - - config_add_item(LIBKERNSH_VMCONFIG_USEVM, + + config_add_item(LIBKERNSH_CONFIG_USEVM, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 0); - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_IDTBASE, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_IDTLIMIT, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_GDTBASE, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_GDTLIMIT, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); #if defined(__linux__) - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_SYSTEMCALL, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); #endif - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_SCT, + config_add_item(LIBKERNSH_CONFIG_SPECIFY_SCT, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) "0x0"); - config_add_item(LIBKERNSH_VMCONFIG_VIRTM, + config_add_item(LIBKERNSH_CONFIG_VIRTM, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_KERNEL_MODE); - config_add_item(LIBKERNSH_VMCONFIG_HASH, + config_add_item(LIBKERNSH_CONFIG_HASH, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_HASH_MD5); - config_add_item(LIBKERNSH_VMCONFIG_VMA, + config_add_item(LIBKERNSH_CONFIG_VMA, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_VMA_USERLAND); - config_add_item(LIBKERNSH_VMCONFIG_VMA_PREFIX, + config_add_item(LIBKERNSH_CONFIG_VMA_PREFIX, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_DEFAULT_VMA_PREFIX); - config_add_item(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX, + config_add_item(LIBKERNSH_CONFIG_DUMP_VMA_PREFIX, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_DEFAULT_DUMP_VMA_PREFIX); @@ -144,22 +145,22 @@ "Release not supported", -1); } - config_add_item(LIBKERNSH_VMCONFIG_DEVICE, + config_add_item(LIBKERNSH_CONFIG_DEVICE, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) LIBKERNSH_STRING_DEVICE_MEM); - config_add_item(LIBKERNSH_VMCONFIG_MODE, + config_add_item(LIBKERNSH_CONFIG_MODE, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *)"write"); - config_add_item(LIBKERNSH_VMCONFIG_MMAP, + config_add_item(LIBKERNSH_CONFIG_MMAP, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 1); - config_add_item(LIBKERNSH_VMCONFIG_MMAP_SIZE, + config_add_item(LIBKERNSH_CONFIG_MMAP_SIZE, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_MMAP_SIZE); @@ -167,22 +168,22 @@ memset(buffer, '\0', sizeof(buffer)); snprintf(buffer, sizeof(buffer), "%s-%s", LIBKERNSH_DEFAULT_LINUX_KERNEL, release); - config_add_item(LIBKERNSH_VMCONFIG_KERNEL, + config_add_item(LIBKERNSH_CONFIG_KERNEL, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) buffer); - config_add_item(LIBKERNSH_VMCONFIG_KERNELGZ, + config_add_item(LIBKERNSH_CONFIG_KERNELGZ, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_KERNELGZ); - config_add_item(LIBKERNSH_VMCONFIG_KERNELELF, + config_add_item(LIBKERNSH_CONFIG_KERNELELF, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_KERNELELF); - config_add_item(LIBKERNSH_VMCONFIG_STORAGE_PATH, + config_add_item(LIBKERNSH_CONFIG_STORAGE_PATH, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_STORAGE_PATH); @@ -190,42 +191,42 @@ memset(buffer, '\0', sizeof(buffer)); snprintf(buffer, sizeof(buffer), "%s-%s", LIBKERNSH_DEFAULT_LINUX_MAP, release); - config_add_item(LIBKERNSH_VMCONFIG_SYSTEMMAP, + config_add_item(LIBKERNSH_CONFIG_SYSTEMMAP, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *) buffer); - config_add_item(LIBKERNSH_VMCONFIG_NB_SYSCALLS, + config_add_item(LIBKERNSH_CONFIG_NB_SYSCALLS, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_NB_SYSCALLS); - config_add_item(LIBKERNSH_VMCONFIG_NIL_SYSCALL, + config_add_item(LIBKERNSH_CONFIG_NIL_SYSCALL, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL); - - config_add_item(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_VIRTM_NIL_SYSCALL); - - config_add_item(LIBKERNSH_VMCONFIG_KERNEL_START, + + config_add_item(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL, + CONFIG_TYPE_INT, + CONFIG_MODE_RW, + (void *) LIBKERNSH_DEFAULT_LINUX_VIRTM_NIL_SYSCALL); + + config_add_item(LIBKERNSH_CONFIG_KERNEL_START, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_I386_LINUX_START); - config_add_item(LIBKERNSH_VMCONFIG_KERNEL_END, + config_add_item(LIBKERNSH_CONFIG_KERNEL_END, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) LIBKERNSH_I386_LINUX_END); - config_add_item(LIBKERNSH_VMCONFIG_KLOAD, + config_add_item(LIBKERNSH_CONFIG_KLOAD, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_INSMOD); - config_add_item(LIBKERNSH_VMCONFIG_KUNLOAD, + config_add_item(LIBKERNSH_CONFIG_KUNLOAD, CONFIG_TYPE_STR, CONFIG_MODE_RW, (void *) LIBKERNSH_DEFAULT_LINUX_RMMOD); @@ -256,10 +257,9 @@ kernsh_init_vectors(); kernsh_register_vectors(); + asm_init_arch(&libkernshworld.proc, ASM_PROC_IA32); kernsh_present_set(); - asm_init_ia32(&libkernshworld.proc); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -276,114 +276,22 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * @brief Kernsh is in memory mode ? - * @return 1 on memory mode, 0 on error - */ -int kernsh_is_mem_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.mem == LIBKERNSH_MEM_MODE)); -} - -/** - * @brief Set kernsh in memory mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_mem_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - libkernshworld.mem= LIBKERNSH_MEM_MODE; - - elfsh_set_debug_mode(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Kernsh is in static mode ? - * @return 1 on static mode, 0 on error - */ -int kernsh_is_static_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.mem == LIBKERNSH_STATIC_MODE)); -} - -/** - * @brief Set kernsh in static mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_static_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - libkernshworld.mem= LIBKERNSH_STATIC_MODE; - - elfsh_set_static_mode(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get kernsh mode - * @return return the mode - */ -int kernsh_get_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, libkernshworld.mem); -} - -/** - * @brief Set kernsh mode - * @param mode The mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_mode(int mode) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (mode) - { - case LIBKERNSH_MEM_MODE : - libkernshworld.mem = LIBKERNSH_MEM_MODE; - elfsh_set_debug_mode(); - break; - case LIBKERNSH_STATIC_MODE : - libkernshworld.mem = LIBKERNSH_STATIC_MODE; - elfsh_set_static_mode(); - break; - default : - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalide mode", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} /** - * @brief Called in elfsh_get_raw to interact with the memory + * @brief Called in elfsh_readmem to interact with the memory * @param sect The section */ -void *kernsh_elfsh_get_raw(elfshsect_t *sect) +void *kernsh_get_raw(elfshsect_t *sect) { void *dataptr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); #if __DEBUG_KERNSH__ - printf("kernsh_elfsh_get_raw\n"); + printf("kernsh_get_raw\n"); #endif - if (libkernshworld.open && kernsh_is_mem_mode() && libkernshworld.mmap) + if (libkernshworld.open && elfsh_is_runtime_mode() && libkernshworld.mmap) { /* We use physical memory ? */ if (libkernshworld.physical) @@ -424,27 +332,28 @@ } /** - * @brief Called in revm_get_raw to interact with the memory + * @brief Called in elfsh_readmema to interact with the memory * @param addr The address */ -void *kernsh_revm_get_raw(void *addr) +void *kernsh_get_raw_by_addr(elfshobj_t *null, eresi_Addr addr, void *buf, u_int size) { - void *dataptr; + void *dataptr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); #if __DEBUG_KERNSH__ - printf("kernsh_revm_get_raw\n"); + printf("kernsh_get_raw_by_addr\n"); #endif - if (libkernshworld.open && kernsh_is_mem_mode() && libkernshworld.mmap) + if (libkernshworld.open && elfsh_is_runtime_mode() && libkernshworld.mmap) { /* We use physical memory ? */ if (libkernshworld.physical) - dataptr = libkernshworld.ptr + ((eresi_Addr) addr - libkernshworld.kernel_start); + dataptr = libkernshworld.ptr + addr - libkernshworld.kernel_start; else - dataptr = libkernshworld.ptr + (eresi_Addr) addr; - + dataptr = libkernshworld.ptr + addr; + if (buf && size) + memcpy(buf, dataptr, size); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); @@ -497,7 +406,7 @@ printf("IDTR BASE 0x%lx LIMIT 0x%x\n", idtr.base,idtr.limit); #endif - kernsh_readmem(idtr.base+(2*sizeof(unsigned long))*0x80, + elfsh_readmema(libkernshworld.root, idtr.base+(2*sizeof(unsigned long))*0x80, &idt, sizeof(idt)); system_call = (idt.off2 << 16) | idt.off1; @@ -513,7 +422,7 @@ printf("SYSTEM_CALL : 0x%lx\n", system_call); #endif - kernsh_readmem(system_call, buffer, 255); + elfsh_readmema(libkernshworld.root, system_call, buffer, 255); p = (char *)kernsh_find_pattern(buffer, 255, "\xff\x14\x85", 3); if (p == NULL) @@ -575,9 +484,7 @@ elfshobj_t *ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = elfsh_load_obj(name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -588,9 +495,7 @@ void kernsh_unload_file(elfshobj_t *file) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - elfsh_unload_obj(file); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } @@ -605,18 +510,12 @@ int kernsh_raw_write(elfshobj_t *file, u_int foffset, void *src_buff, int len) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (kernsh_is_mem_mode()) + if (elfsh_is_runtime_mode()) { - kernsh_writemem(elfsh_get_vaddr_from_foffset(file, foffset), - src_buff, - len); - + elfsh_writemem(file, elfsh_get_vaddr_from_foffset(file, foffset), src_buff, len); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (len)); } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mode is wrong", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Mode is wrong", -1); } /** @@ -630,40 +529,10 @@ int kernsh_raw_read(elfshobj_t *file, u_int foffset, void *dest_buff, int len) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (kernsh_is_mem_mode()) + if (elfsh_is_runtime_mode()) { - kernsh_readmem(elfsh_get_vaddr_from_foffset(file, foffset), - dest_buff, - len); - + elfsh_readmema(file, elfsh_get_vaddr_from_foffset(file, foffset), dest_buff, len); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mode is wrong", -1); -} - -/** - * @brief Set kernsh's present - */ -void kernsh_present_set() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - libkernshworld.present = 1; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Get kernsh's present - * @return 1 on success, 0 on error - */ -int kernsh_is_present() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.present == 1)); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Mode is wrong", -1); } diff -Nru eresi-0.8a25/libkernsh/user/kmem.c eresi-0.0.20110516/libkernsh/user/kmem.c --- eresi-0.8a25/libkernsh/user/kmem.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/kmem.c 2011-05-16 11:34:49.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file kmem.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/kmem.c +** @ingroup usermode ** */ #if defined(__linux__) @@ -30,8 +30,9 @@ XOPEN(libkernshworld.fd, LIBKERNSH_STRING_DEVICE_KMEM, libkernshworld.fdmode, - 0, - -1); + 0, -1); + + libkernshworld.root->iotype = ELFSH_IOTYPE_DEVKMEM26; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -60,17 +61,22 @@ * @param size Count bytes to read * @return size on success, -1 on error */ -int kernsh_readmem_kmem_linux_2_6(unsigned long offset, void *buf, int size) +void *kernsh_readmema_kmem_linux_2_6(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read kmem in static mode", NULL); #if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); + XLSEEK64(libkernshworld.fd, offset, SEEK_SET, NULL); #endif - XREAD(libkernshworld.fd, buf, size, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); + XREAD(libkernshworld.fd, buf, size, NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } /** @@ -80,9 +86,12 @@ * @param size Count bytes to write * @return size on success, -1 on error */ -int kernsh_writemem_kmem_linux_2_6(unsigned long offset, void *buf, int size) +int kernsh_writemem_kmem_linux_2_6(elfshobj_t *file, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); #if defined(__linux__) XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); @@ -125,6 +134,8 @@ #endif } + libkernshworld.root->iotype = ELFSH_IOTYPE_DEVKMEM24; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -159,27 +170,31 @@ * @param size Count bytes to read * @return size on success, -1 on error */ -int kernsh_readmem_kmem_linux_2_4(unsigned long offset, void *buf, int size) +void *kernsh_readmema_kmem_linux_2_4(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read kmem in static mode", NULL); if (libkernshworld.mmap) { if (memcpy(buf, libkernshworld.ptr+offset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memcpy failed !", NULL); } else { #if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); + XLSEEK64(libkernshworld.fd, offset, SEEK_SET, NULL); #endif - XREAD(libkernshworld.fd, buf, size, -1); + XREAD(libkernshworld.fd, buf, size, NULL); } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } /** @@ -189,9 +204,12 @@ * @param size Count bytes to write * @return size on success, -1 on error */ -int kernsh_writemem_kmem_linux_2_4(unsigned long offset, void *buf, int size) +int kernsh_writemem_kmem_linux_2_4(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); if (libkernshworld.mmap) { diff -Nru eresi-0.8a25/libkernsh/user/kvirtm.c eresi-0.0.20110516/libkernsh/user/kvirtm.c --- eresi-0.8a25/libkernsh/user/kvirtm.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/kvirtm.c 2011-05-16 11:34:50.000000000 +0000 @@ -1,22 +1,21 @@ -/* -** @file kvirtm.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/kvirtm.c +** @ingroup usermode ** */ - #include "libkernsh.h" /** * @brief Read virtual memory of a pid\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param addr The address to read * @param buffer Read virtual memory into the buffer * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_read_virtm(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_read_virtm(pid_t pid, eresi_Addr addr, char *buffer, int len) { int ret, get, i, j, max_size; u_int dim[3]; @@ -25,7 +24,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); max_size = LIBKERNSH_PROC_ENTRY_SIZE; krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADVIRTM); @@ -63,7 +62,7 @@ * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_read_virtm_proc_linux(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_read_virtm_proc_linux(pid_t pid, eresi_Addr addr, char *buffer, int len) { int fd, ret, nlen; char *proc_entry_root_tmp; @@ -89,26 +88,20 @@ -1); memset(proc_entry_root_tmp, '\0', nlen); - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", PROC_ENTRY_ROOT, PROC_ENTRY_KERNSH_VIRTM, PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:%d", + snprintf(buff, sizeof(buff), "%d:"XFMT":%d:%d", LIBKERNSH_VIRTM_READ_MEM_PID, - addr, - len, - pid); + addr, len, pid); ret = write(fd, buff, strlen(buff)); if (ret != strlen(buff)) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Impossible to set vio", -1); XCLOSE(fd, -1); @@ -135,7 +128,7 @@ * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_read_virtm_syscall_linux(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_read_virtm_syscall_linux(pid_t pid, eresi_Addr addr, char *buffer, int len) { int ret; unsigned int arg[5]; @@ -155,7 +148,7 @@ arg[3] = (unsigned int)len; arg[4] = (unsigned int)LIBKERNSH_VIRTM_READ_MEM_PID; - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); + rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL), 5, arg); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); } @@ -163,14 +156,14 @@ /** * @brief Write virtual memory of a pid\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param addr The address to write * @param buffer Write buffer into virtual memory * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_write_virtm(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_write_virtm(pid_t pid, eresi_Addr addr, char *buffer, int len) { int ret, get, i, j, max_size;; u_int dim[3]; @@ -179,7 +172,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); max_size = LIBKERNSH_PROC_ENTRY_SIZE; krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEVIRTM); @@ -217,7 +210,7 @@ * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_write_virtm_proc_linux(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_write_virtm_proc_linux(pid_t pid, eresi_Addr addr, char *buffer, int len) { int fd, ret, nlen; char *proc_entry_root_tmp; @@ -243,27 +236,20 @@ -1); memset(proc_entry_root_tmp, '\0', nlen); - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", PROC_ENTRY_ROOT, PROC_ENTRY_KERNSH_VIRTM, PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:%d", + snprintf(buff, sizeof(buff), "%d:"XFMT":%d:%d", LIBKERNSH_VIRTM_WRITE_MEM_PID, - addr, - len, - pid); + addr, len, pid); ret = write(fd, buff, strlen(buff)); if (ret != strlen(buff)) - { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - + "Impossible to set vio", -1); XCLOSE(fd, -1); snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", @@ -288,7 +274,7 @@ * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_write_virtm_syscall_linux(pid_t pid, unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_write_virtm_syscall_linux(pid_t pid, eresi_Addr addr, char *buffer, int len) { int ret; unsigned int arg[5]; @@ -308,7 +294,7 @@ arg[3] = (unsigned int)len; arg[4] = (unsigned int)LIBKERNSH_VIRTM_WRITE_MEM_PID; - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); + rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL), 5, arg); if (rlen != len) ret = -1; @@ -328,6 +314,7 @@ printf("OPEN KVIRTM OPEN MEM\n"); #endif + libkernshworld.root->iotype = ELFSH_IOTYPE_KVIRTM; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -353,7 +340,7 @@ * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_readmem(unsigned long addr, char *buffer, int len) +void *kernsh_kvirtm_readmema(elfshobj_t *kern, eresi_Addr addr, char *buffer, int len) { int ret, get, i, j, max_size; u_int dim[3]; @@ -361,6 +348,12 @@ int (*fct)(); PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read userland virtual memory in static mode", NULL); ret = 0; max_size = LIBKERNSH_PROC_ENTRY_SIZE; @@ -369,12 +362,11 @@ printf("kernsh_kvirtm_read_mem\n"); #endif - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int) config_get_data(LIBKERNSH_CONFIG_VIRTM); krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM); dim[0] = libkernshworld.os; dim[1] = get; - fct = aspect_vectors_select(krv, dim); if (len > max_size && get == LIBKERNSH_KERNEL_MODE) @@ -393,7 +385,7 @@ else ret = fct(addr, buffer, len); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buffer); } /** @@ -403,7 +395,7 @@ * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_readmem_syscall_linux(unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_readmem_syscall_linux(eresi_Addr addr, char *buffer, int len) { int ret; unsigned int arg[5]; @@ -423,7 +415,7 @@ arg[3] = (unsigned int)len; arg[4] = (unsigned int)LIBKERNSH_VIRTM_READ_MEM; - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); + rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL), 5, arg); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); } @@ -435,10 +427,10 @@ * @param len Count bytes to read * @return len on success, -1 on error */ -int kernsh_kvirtm_readmem_proc_linux(unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_readmem_proc_linux(eresi_Addr addr, char *buffer, int len) { - int fd, ret, nlen; - char *proc_entry_root_tmp; + int fd, ret, nlen; + char *proc_entry_root_tmp; char buff[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -472,7 +464,7 @@ PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:", + snprintf(buff, sizeof(buff), "%d:"XFMT":%d:", LIBKERNSH_VIRTM_READ_MEM, (addr - libkernshworld.kernel_start), len); @@ -482,8 +474,7 @@ { XCLOSE(fd, -1); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); + "Impossible to set vio", -1); } XCLOSE(fd, -1); @@ -510,7 +501,7 @@ * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_writemem(unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_writemem(elfshobj_t *kern, eresi_Addr addr, char *buffer, int len) { int ret, get, i, j, max_size; u_int dim[3]; @@ -518,6 +509,9 @@ int (*fct)(); PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); ret = 0; max_size = LIBKERNSH_PROC_ENTRY_SIZE; @@ -526,7 +520,7 @@ printf("kernsh_kvirtm_read_mem\n"); #endif - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEMEM); dim[0] = libkernshworld.os; @@ -560,7 +554,7 @@ * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_writemem_syscall_linux(unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_writemem_syscall_linux(eresi_Addr addr, char *buffer, int len) { int ret; unsigned int arg[5]; @@ -580,7 +574,7 @@ arg[3] = (unsigned int)len; arg[4] = (unsigned int)LIBKERNSH_VIRTM_WRITE_MEM; - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); + rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_CONFIG_VIRTM_NIL_SYSCALL), 5, arg); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); } @@ -592,7 +586,7 @@ * @param len Count bytes to write * @return len on success, -1 on error */ -int kernsh_kvirtm_writemem_proc_linux(unsigned long addr, char *buffer, int len) +int kernsh_kvirtm_writemem_proc_linux(eresi_Addr addr, char *buffer, int len) { int fd, ret, nlen; char *proc_entry_root_tmp; @@ -629,7 +623,7 @@ PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:", + snprintf(buff, sizeof(buff), "%d:"XFMT":%d:", LIBKERNSH_VIRTM_WRITE_MEM, (addr - libkernshworld.kernel_start), len); @@ -661,7 +655,7 @@ /** * @brief Task pid\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param h The list * @return 0 on success, -1 on error @@ -681,7 +675,7 @@ printf("kernsh_kvirtm_task_pid\n"); #endif - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); + get = (int)config_get_data(LIBKERNSH_CONFIG_VIRTM); krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID); dim[0] = libkernshworld.os; @@ -697,7 +691,7 @@ /** * @brief Task pid thought /proc\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param h The list * @return 0 on success, -1 on error @@ -801,7 +795,7 @@ /** * @brief Task pid thought syscall\n * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM + * LIBKERNSH_CONFIG_VIRTM * @param pid The process id * @param h The list * @return 0 on success, -1 on error diff -Nru eresi-0.8a25/libkernsh/user/mem.c eresi-0.0.20110516/libkernsh/user/mem.c --- eresi-0.8a25/libkernsh/user/mem.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/mem.c 2011-05-16 11:34:49.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file mem.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/mem.c +** @ingroup usermode ** */ #if defined(__linux__) @@ -43,7 +43,7 @@ } libkernshworld.physical = 1; - + libkernshworld.root->iotype = ELFSH_IOTYPE_DEVMEM26; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -78,32 +78,35 @@ * @param size Count bytes to read * @return size on success, -1 on error */ -int kernsh_readmem_mem_linux(unsigned long offset, void *buf, int size) +void *kernsh_readmema_mem_linux(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { - unsigned long roffset; + eresi_Addr roffset; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read /dev/mem in static mode", NULL); - /* We must subtrack kernel_start(page_offset) to get the physical address */ + /* We must substract kernel_start(page_offset) to get the physical address */ roffset = offset - libkernshworld.kernel_start; - if (libkernshworld.mmap) { - if (memcpy(buf, libkernshworld.ptr+roffset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } + if (memcpy(buf, libkernshworld.ptr + roffset, size) == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memcpy failed !", NULL); } else { #if defined(__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); + XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, NULL); #endif - XREAD(libkernshworld.fd, buf, size, -1); + XREAD(libkernshworld.fd, buf, size, NULL); } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } /** @@ -113,11 +116,14 @@ * @param size Count bytes to write * @return size on success, -1 on error */ -int kernsh_writemem_mem_linux(unsigned long offset, void *buf, int size) +int kernsh_writemem_mem_linux(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { - unsigned long roffset; + eresi_Addr roffset; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); /* We must subtrack kernel_start (page_offset) to get the physical address */ roffset = offset - libkernshworld.kernel_start; @@ -195,26 +201,33 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -int kernsh_readmem_netbsd(unsigned long offset, void *buf, int size) +void *kernsh_readmema_netbsd(elfshobj_t *file, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", NULL); + if (elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot read /dev/mem in static mode", NULL); // printf("READ MEM NETBSD\n"); #if defined(__NetBSD__) if (krevm_read(libkernshworld.kd, offset, buf, size) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - krevm_geterr(libkernshworld.kd), -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + krevm_geterr(libkernshworld.kd), NULL); #endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf); } -int kernsh_writemem_netbsd(unsigned long offset, void *buf, int size) +int kernsh_writemem_netbsd(elfshobj_t *unused, eresi_Addr offset, void *buf, int size) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!libkernshworld.open) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not opened !", -1); // printf("WRITE MEM NETBSD\n"); diff -Nru eresi-0.8a25/libkernsh/user/misc.c eresi-0.0.20110516/libkernsh/user/misc.c --- eresi-0.8a25/libkernsh/user/misc.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/misc.c 2011-05-16 11:34:50.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file misc.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/misc.c +** @ingroup usermode ** */ #include "libkernsh.h" @@ -30,7 +30,7 @@ } /* Resolve name with addr */ -int kernsh_resolve_systemmap(unsigned long addr, char *name, size_t size) +int kernsh_resolve_systemmap(eresi_Addr addr, char *name, size_t size) { FILE *input; char line[256]; @@ -45,7 +45,7 @@ memset(caddr, '\0', sizeof(caddr)); snprintf(caddr, sizeof(caddr) - 1, "0x%lx", (unsigned long)addr); - if ((input = fopen((char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP), + if ((input = fopen((char *) config_get_data(LIBKERNSH_CONFIG_SYSTEMMAP), "r")) == NULL) { memcpy(name, "UNKNOWN_NAME", size - 1); @@ -78,7 +78,7 @@ } /* Resolve add with name */ -int kernsh_rresolve_systemmap(const char *name, unsigned long *addr, size_t size) +int kernsh_rresolve_systemmap(const char *name, eresi_Addr *addr, size_t size) { FILE *input; char *paddr, *pname; @@ -86,7 +86,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if ((input = fopen((char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP), + if ((input = fopen((char *) config_get_data(LIBKERNSH_CONFIG_SYSTEMMAP), "r")) == NULL) { PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to open systemmap", -1); @@ -111,31 +111,27 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get addr", -1); } -int kernsh_find_end(unsigned long addr) +int kernsh_find_end(eresi_Addr addr) { unsigned char buff[BUFSIZ]; int curr, sizemax; - unsigned long addrcur, addrfinal, start; + eresi_Addr addrcur, addrfinal, start; asm_instr instr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - addrcur = addr; - sizemax = (int) config_get_data(LIBKERNSH_VMCONFIG_FENDSIZE); - addrfinal = addr+sizemax; - + addrcur = addr; + sizemax = (int) config_get_data(LIBKERNSH_CONFIG_FENDSIZE); + addrfinal = addr + sizemax; while (addrcur < addrfinal) { - if (kernsh_is_mem_mode()) + if (elfsh_is_runtime_mode()) { - kernsh_readmem(addrcur, buff, sizeof(buff)); + elfsh_readmema(libkernshworld.root, addrcur, buff, sizeof(buff)); } else { - start = elfsh_get_foffset_from_vaddr(libkernshworld.root, - addrcur); - elfsh_raw_read(libkernshworld.root, start, buff, sizeof(buff)); - + start = elfsh_get_foffset_from_vaddr(libkernshworld.root, addrcur); + elfsh_readmemf(libkernshworld.root, start, buff, sizeof(buff)); } curr = 0; while(curr < sizeof(buff)) diff -Nru eresi-0.8a25/libkernsh/user/module.c eresi-0.0.20110516/libkernsh/user/module.c --- eresi-0.8a25/libkernsh/user/module.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/module.c 2011-05-16 11:34:49.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file module.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/module.c +** @ingroup usermode ** */ #include "libkernsh.h" @@ -57,7 +57,7 @@ /** * @brief Load a linux loadable kernel module\n * Configure :\n - * LIBKERNSH_VMCONFIG_KLOAD + * LIBKERNSH_CONFIG_KLOAD * @param name Module's pathname * @return 0 on success, -1 on return */ @@ -74,7 +74,7 @@ #endif if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_KLOAD), params, environ); + ret = execve((char *) config_get_data(LIBKERNSH_CONFIG_KLOAD), params, environ); else wait(NULL); @@ -121,7 +121,7 @@ /** * @brief Unload a linux loadable kernel module\n * Configure :\n - * LIBKERNSH_VMCONFIG_KUNLOAD + * LIBKERNSH_CONFIG_KUNLOAD * @param name Module's name * @return 0 on success, -1 on return */ @@ -138,7 +138,7 @@ #endif if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_KUNLOAD), params, environ); + ret = execve((char *) config_get_data(LIBKERNSH_CONFIG_KUNLOAD), params, environ); else wait(NULL); @@ -230,7 +230,7 @@ #endif if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_LD), params, environ); + ret = execve((char *) config_get_data(LIBKERNSH_CONFIG_LD), params, environ); else wait(NULL); @@ -407,7 +407,7 @@ for (idx = 0; idx < size && !end; idx++) { - data = elfsh_get_raw(gnu); + data = elfsh_readmem(gnu); cur = (void *) ((elfsh_Rel *) data + idx); if (elfsh_get_relsym(cur) == idx_init) { @@ -470,7 +470,7 @@ "Unable to find original function name", -1); } - elfsh_raw_write(mod, strtab->shdr->sh_offset + so->st_name, evil_fname, strlen(evil_fname)); + elfsh_writememf(mod, strtab->shdr->sh_offset + so->st_name, evil_fname, strlen(evil_fname)); elfsh_save_obj(mod, mod->name); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); diff -Nru eresi-0.8a25/libkernsh/user/.svn/all-wcprops eresi-0.0.20110516/libkernsh/user/.svn/all-wcprops --- eresi-0.8a25/libkernsh/user/.svn/all-wcprops 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/946/trunk/libkernsh/user -END -mem.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/933/trunk/libkernsh/user/mem.c -END -kernimage.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/936/trunk/libkernsh/user/kernimage.c -END -kcore.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/933/trunk/libkernsh/user/kcore.c -END -module.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/933/trunk/libkernsh/user/module.c -END -kmem.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/933/trunk/libkernsh/user/kmem.c -END -alloc.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/933/trunk/libkernsh/user/alloc.c -END -kernsh.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libkernsh/user/kernsh.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/933/trunk/libkernsh/user/misc.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/930/trunk/libkernsh/user/Makefile -END -kvirtm.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/933/trunk/libkernsh/user/kvirtm.c -END -symbs.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/933/trunk/libkernsh/user/symbs.c -END diff -Nru eresi-0.8a25/libkernsh/user/.svn/entries eresi-0.0.20110516/libkernsh/user/.svn/entries --- eresi-0.8a25/libkernsh/user/.svn/entries 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,163 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/user -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -mem.c -file - - - - -2008-04-06T23:15:28.302882Z -20bfad174b9398b29603bd13b5836c0e -2008-03-25T12:19:53.725666Z -933 -pouik - -kernimage.c -file - - - - -2008-04-06T23:15:28.312894Z -f1a3c399da7d51f44d6555bdc828ba79 -2008-03-26T07:36:43.917920Z -936 -pouik - -kcore.c -file - - - - -2008-04-06T23:15:28.324136Z -5f274a664455fdba0ade48b177c09602 -2008-03-25T12:19:53.725666Z -933 -pouik - -module.c -file - - - - -2008-04-06T23:15:28.335143Z -176487563808a7b6be216bfe3a0e190c -2008-03-25T12:19:53.725666Z -933 -pouik - -symbols -dir - -kmem.c -file - - - - -2008-04-06T23:15:28.365079Z -605570ba531ad2909b63cf6584483f5e -2008-03-25T12:19:53.725666Z -933 -pouik - -alloc.c -file - - - - -2008-04-06T23:15:28.391543Z -c55b474d2001640801463d46af538ed9 -2008-03-25T12:19:53.725666Z -933 -pouik - -kernsh.c -file - - - - -2008-04-06T23:15:28.402886Z -2ae23f9eb2d021642aee6d3660266e48 -2008-03-27T22:53:48.747992Z -946 -may - -misc.c -file - - - - -2008-04-06T23:15:28.414074Z -140da0180a69b5ac84e2a440f71bb8f9 -2008-03-25T12:19:53.725666Z -933 -pouik - -Makefile -file - - - - -2008-04-06T23:15:28.425572Z -aca60677120e5c1ce29c1c07040ce4a5 -2008-03-25T08:32:13.270742Z -930 -pouik - -kvirtm.c -file - - - - -2008-04-06T23:15:28.436972Z -33196074045601517c4bf9562e86ddc0 -2008-03-25T12:19:53.725666Z -933 -pouik - -symbs.c -file - - - - -2008-04-06T23:15:28.448315Z -8ec407c39e97cf6233be38f1eb547e22 -2008-03-25T12:19:53.725666Z -933 -pouik - diff -Nru eresi-0.8a25/libkernsh/user/.svn/format eresi-0.0.20110516/libkernsh/user/.svn/format --- eresi-0.8a25/libkernsh/user/.svn/format 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/alloc.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/alloc.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/alloc.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/alloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,446 +0,0 @@ -/* -** @file alloc.c -** @ingroup libkernsh_user -** @brief allocation contiguous/non contiguous. -** -*/ -#include "libkernsh.h" -#include "libkernsh-symbols.h" -#include "libkernsh-info.h" - -/** - * @brief Allocate contiguous/non contiguous kernel memory\n - * Configure :\n - * LIBKERNSH_VMCONFIG_ALLOC - * @param size Allocate size bytes - * @param addr Address of the new allocation - * @return 0 on success, -1 on return - */ -int kernsh_alloc(size_t size, unsigned long *addr) -{ - int mode, ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mode = (int) config_get_data(LIBKERNSH_VMCONFIG_ALLOC); - if (mode == 0) - ret = kernsh_alloc_contiguous(size, addr); - else - ret = kernsh_alloc_noncontiguous(size, addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Free contiguous/non contiguous kernel memory\n - * Configure :\n - * LIBKERNSH_VMCONFIG_ALLOC - * @param addr Address of the allocation - * @return 0 on success, -1 on return - */ -int kernsh_free(unsigned long addr) -{ - int mode, ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mode = (int) config_get_data(LIBKERNSH_VMCONFIG_ALLOC); - if (mode == 0) - ret = kernsh_free_contiguous(addr); - else - ret = kernsh_free_noncontiguous(addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Allocate contiguous kernel memory - * @param size Allocate size bytes - * @param addr Address of the new allocation - * @return 0 on success, -1 on return - */ -int kernsh_alloc_contiguous(size_t size, unsigned long *addr) -{ - int ret; - u_int dim[2]; - vector_t *alloc; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCCONTIGUOUS); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(alloc, dim); - - ret = fct(size, addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Allocate non contiguous kernel memory - * @param size Allocate size bytes - * @param addr Address of the new allocation - * @return 0 on success, -1 on return - */ -int kernsh_alloc_noncontiguous(size_t size, unsigned long *addr) -{ - int ret; - u_int dim[2]; - vector_t *alloc; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ALLOCNONCONTIGUOUS); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(alloc, dim); - - ret = fct(size, addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Free contiguous kernel memory - * @param addr Address of the allocation - * @return 0 on success, -1 on return - */ -int kernsh_free_contiguous(unsigned long addr) -{ - int ret; - u_int dim[2]; - vector_t *alloc; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREECONTIGUOUS); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(alloc, dim); - - ret = fct(addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Free non contiguous kernel memory - * @param addr Address of the allocation - * @return 0 on success, -1 on return - */ -int kernsh_free_noncontiguous(unsigned long addr) -{ - int ret; - u_int dim[2]; - vector_t *alloc; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - alloc = aspect_vector_get(LIBKERNSH_VECTOR_NAME_FREENONCONTIGUOUS); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(alloc, dim); - - ret = fct(addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Allocate contiguous kernel memory on Linux\n - * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL - * @param size Allocate size bytes - * @param addr Address of the new allocation - * @return 0 on success, -1 on return - */ -int kernsh_alloc_contiguous_linux(size_t size, unsigned long *addr) -{ - int ret; - char buf[sizeof(KMALLOC)]; - unsigned long kaddr; - unsigned long nil_syscall; - libkernshkma_t kmalloc; - unsigned int arg[1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get kmalloc's addr */ -#if __LINUX_2_4__ - ret = kernsh_get_addr_by_name("kmalloc", &kaddr, strlen("kmalloc")); -#else - ret = kernsh_get_addr_by_name("__kmalloc", &kaddr, strlen("__kmalloc")); -#endif - - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol kmalloc", -1); - } - - kmalloc.kexec = (void *)kaddr; - kmalloc.size = size; - kmalloc.flags = GFP_KERNEL; - kmalloc.mem = 0; - - arg[0] = (unsigned int)&kmalloc; - - /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - /* Write kmalloc's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, KMALLOC, sizeof(KMALLOC)); - - /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - - /* Exec nil syscall which is now kmalloc */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - - *addr = kmalloc.mem; - - /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Free contiguous kernel memory on Linux\n - * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL - * @param addr Address of the allocation - * @return 0 on success, -1 on return - */ -int kernsh_free_contiguous_linux(unsigned long addr) -{ - int ret; - char buf[sizeof(KFREE)]; - unsigned long kaddr; - unsigned long nil_syscall; - libkernshkfr_t kfree; - unsigned int arg[1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get kfree's addr */ - ret = kernsh_get_addr_by_name("kfree", &kaddr, strlen("kfree")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol kfree", -1); - } - - kfree.kexec = (void *)kaddr; - kfree.address = (const void *) addr; - - arg[0] = (unsigned int)&kfree; - - /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - /* Write kfree's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, KFREE, sizeof(KFREE)); - - /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - - /* Exec nil syscall which is now kfree */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - - /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Allocate non contiguous kernel memory on Linux\n - * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL - * @param size Allocate size bytes - * @param addr Address of the new allocation - * @return 0 on success, -1 on return - */ -int kernsh_alloc_noncontiguous_linux(size_t size, unsigned long *addr) -{ - int ret; - char buf[sizeof(VMALLOC)]; - unsigned long kaddr; - unsigned long nil_syscall; - libkernshvma_t vmalloc; - unsigned int arg[1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get vmalloc's addr */ - ret = kernsh_get_addr_by_name("vmalloc", &kaddr, strlen("vmalloc")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol vmalloc", -1); - } - - vmalloc.kexec = (void *)kaddr; - vmalloc.size = size; - vmalloc.mem = 0; - - arg[0] = (unsigned int)&vmalloc; - - /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - /* Write vmalloc's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, VMALLOC, sizeof(VMALLOC)); - - /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - - /* Exec nil syscall which is now vmlloc */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - - *addr = vmalloc.mem; - - /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Free non contiguous kernel memory on Linux\n - * Configure :\n - * LIBKERNSH_VMCONFIG_NIL_SYSCALL - * @param addr Address of the allocation - * @return 0 on success, -1 on return - */ -int kernsh_free_noncontiguous_linux(unsigned long addr) -{ - int ret; - char buf[sizeof(VFREE)]; - unsigned long kaddr; - unsigned long nil_syscall; - libkernshvfr_t vfree; - unsigned int arg[1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get vfree's addr */ - ret = kernsh_get_addr_by_name("vfree", &kaddr, strlen("vfree")); - if(ret) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol vfree", -1); - } - - vfree.kexec = (void *)kaddr; - vfree.address = (void *) addr; - - arg[0] = (unsigned int)&vfree; - - /* Save the first byte */ - kernsh_readmem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - /* Write vfree's opcodes */ - kernsh_writemem(libkernshworld.kernel_start, VFREE, sizeof(VFREE)); - - /* Get the nil syscall */ - kernsh_readmem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Write the new addr */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &libkernshworld.kernel_start, - sizeof(unsigned long)); - - /* Exec nil syscall which is now vfree */ - kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), 1, arg); - - /* Restore nil syscall */ - kernsh_writemem(libkernshworld.sct + - sizeof(unsigned long) * (int) config_get_data(LIBKERNSH_VMCONFIG_NIL_SYSCALL), - &nil_syscall, - sizeof(unsigned long)); - - /* Restore save bytes */ - kernsh_writemem(libkernshworld.kernel_start, &buf, sizeof(buf)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/kcore.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/kcore.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/kcore.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/kcore.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* -** @file kcore.c -** @ingroup libkernsh_user -** -*/ -#define _LARGEFILE64_SOURCE -#include "libkernsh.h" - -/** - * @brief Open /proc/kcore on Linux - * @return 0 on success, -1 on return - */ -int kernsh_openmem_kcore_linux_2_6() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN KCORE 2.6\n"); -#endif - - XOPEN(libkernshworld.fd, - LIBKERNSH_STRING_DEVICE_KCORE, - libkernshworld.fdmode, - 0, - -1); - - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMMAP(libkernshworld.ptr, - 0, libkernshworld.mmap_size, - libkernshworld.protmode, - libkernshworld.flagsmode, - libkernshworld.fd, - 0, - -1); -#endif - } - - libkernshworld.open = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Close /proc/kcore on Linux - * @return 0 on success, -1 on return - */ -int kernsh_closemem_kcore_linux_2_6() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("CLOSE KCORE 2.6\n"); -#endif - - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMUNMAP(libkernshworld.ptr, libkernshworld.mmap_size, -1); -#endif - } - - XCLOSE(libkernshworld.fd, -1); - - libkernshworld.open = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Read /proc/kcore on Linux - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem_kcore_linux_2_6(unsigned long offset, void *buf, int size) -{ - unsigned long roffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - roffset = offset - libkernshworld.kernel_start + 0x1000; - - if (libkernshworld.mmap) - { - if (memcpy(buf, libkernshworld.ptr+roffset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } - } - else - { -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); -#endif - XREAD(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Write into /proc/kcore - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem_kcore_linux_2_6(unsigned long offset, void *buf, int size) -{ - unsigned long roffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - roffset = offset - libkernshworld.kernel_start + 0x1000; - - if (libkernshworld.mmap) - { - if (memcpy(libkernshworld.ptr+roffset, buf, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } -#if defined(__linux__) - XMSYNC(libkernshworld.ptr, libkernshworld.mmap_size, MS_SYNC, -1); -#endif - } - else - { -#if defined (__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); -#endif - XWRITE(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/kernimage.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/kernimage.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/kernimage.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/kernimage.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -/* -** @file kernimage.c -** @ingroup libkernsh_user -** -*/ -#include "libkernsh.h" - -/** - * @brief Extract and gunzip the kernel - * @return 0 on success, -1 on error - */ -int kernsh_decompkernel() -{ - int ret; - u_int dim[1]; - vector_t *decomp; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("DECOMP KERNEL\n"); -#endif - - decomp = aspect_vector_get(LIBKERNSH_VECTOR_NAME_DECOMPKERNEL); - - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(decomp, dim); - - ret = fct(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Extract and gunzip the linux kernel\n - * Configure :\n - * LIBKERNSH_VMCONFIG_KERNEL, LIBKERNSH_VMCONFIG_STORAGE_PATH, LIBKERNSH_VMCONFIG_KERNELGZ, LIBKERNSH_VMCONFIG_KERNELELF, LIBKERNSH_VMCONFIG_OBJCOPY, LIBKERNSH_VMCONFIG_GZIP - * @return 0 on success, -1 on error - */ -int kernsh_decompkernel_linux() -{ - char magic[] = { 0x1f, 0x8b, 0x08 }; - char buf[256]; - char bufgz[256]; - char bufelf[256]; - char decomp[256]; - struct stat st; - int fd, fz; - int size; - char *begin, *zone; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("DECOMP KERNEL LINUX\n"); -#endif - - - XOPEN(fd, - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNEL), - O_RDONLY, - 0, - -1); - -#if __DEBUG_KERNSH__ - printf("OPEN KERNEL @ %s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNEL)); -#endif - - if(fstat(fd, &st) == -1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "fd error", -1); - } - -#if defined(__linux__) - XMMAP(zone, NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0, -1); -#endif - -#if __DEBUG_KERNSH__ - printf("MMAP size %d @ 0x%lx\n", (int)st.st_size, (unsigned long) zone); -#endif - - begin = kernsh_find_pattern(zone, st.st_size, magic, 3); - -#if __DEBUG_KERNSH__ - printf("FIND MAGIC GZIP PATTERN @ 0x%lx\n", (unsigned long) begin); -#endif - - size = st.st_size - ((int)begin - (int)zone); - - memset(buf, '\0', sizeof(buf)); - snprintf(buf, sizeof(buf), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); - - XOPEN(fz, buf, O_CREAT|O_RDWR, 0777, -1); - -#if __DEBUG_KERNSH__ - printf("OPEN GZ KERNEL @ %s\n", buf); -#endif - - XWRITE(fz, begin, size, -1); - XCLOSE(fz, -1); - -#if defined(__linux__) - XMUNMAP(zone, st.st_size, -1); -#endif - - XCLOSE(fd, -1); - - memset(decomp, '\0', sizeof(decomp)); - snprintf(decomp, sizeof(decomp), "%s -d -f %s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_GZIP), - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); - -#if __DEBUG_KERNSH__ - printf("DECOMP %s\n", decomp); -#endif - - system(decomp); - - memset(bufgz, '\0', sizeof(bufgz)); - snprintf(bufgz, sizeof(bufgz), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELGZ)); - - bufgz[strlen(bufgz) - 3] = '\0'; - - - memset(bufelf, '\0', sizeof(bufelf)); - snprintf(bufelf, sizeof(bufelf), "%s%s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), - (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); - - memset(buf, '\0', sizeof(buf)); - snprintf(buf, sizeof(buf) , "%s -B i386 -I binary -O elf32-i386 %s %s", - (char *) config_get_data(LIBKERNSH_VMCONFIG_OBJCOPY), - bufgz, - bufelf); - -#if __DEBUG_KERNSH__ - printf("EXTRACT ELF FROM DATA @ %s%s\n", (char *) config_get_data(LIBKERNSH_VMCONFIG_STORAGE_PATH), (char *) config_get_data(LIBKERNSH_VMCONFIG_KERNELELF)); -#endif - - system(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/kernsh.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/kernsh.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/kernsh.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/kernsh.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,669 +0,0 @@ -/** - * @defgroup libkernsh_user libkernsh_user - */ -/* -** @file kernsh.c -* @ingroup libkernsh_user -* @brief initialisation, get_raw and mode switch -** -*/ -#include "libkernsh.h" - -libkernshworld_t libkernshworld; - -/** - * @brief Initialise kernsh for ia32 - * @param os Operating System - * @param release Release of the OS - * @return 0 on success, -1 on error - */ -int kernsh_init_ia32(char *os, char *release) -{ - char buffer[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(&libkernshworld, '\0', sizeof(libkernshworld_t)); - - libkernshworld.arch = LIBKERNSH_ARCH_I386; - - /* By default we use static kernel */ - kernsh_set_static_mode(); - - config_add_item(LIBKERNSH_VMCONFIG_WITHOUT_KERNEL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 0); - - config_add_item(LIBKERNSH_VMCONFIG_USE_KERNEL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 0); - - config_add_item(LIBKERNSH_VMCONFIG_ALLOC, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 0); - - config_add_item(LIBKERNSH_VMCONFIG_GZIP, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_DEFAULT_GZIP); - - config_add_item(LIBKERNSH_VMCONFIG_OBJCOPY, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_DEFAULT_OBJCOPY); - - config_add_item(LIBKERNSH_VMCONFIG_LD, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_DEFAULT_LD); - - config_add_item(LIBKERNSH_VMCONFIG_FENDSIZE, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_FENDSIZE); - - config_add_item(LIBKERNSH_VMCONFIG_USEVM, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 0); - - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_IDTBASE, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); - - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_IDTLIMIT, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); - - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_GDTBASE, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); - - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_GDTLIMIT, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); - -#if defined(__linux__) - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_SYSTEMCALL, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); -#endif - - config_add_item(LIBKERNSH_VMCONFIG_SPECIFY_SCT, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) "0x0"); - - config_add_item(LIBKERNSH_VMCONFIG_VIRTM, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_KERNEL_MODE); - - config_add_item(LIBKERNSH_VMCONFIG_HASH, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_HASH_MD5); - - config_add_item(LIBKERNSH_VMCONFIG_VMA, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_VMA_USERLAND); - - config_add_item(LIBKERNSH_VMCONFIG_VMA_PREFIX, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_DEFAULT_VMA_PREFIX); - - config_add_item(LIBKERNSH_VMCONFIG_DUMP_VMA_PREFIX, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_DEFAULT_DUMP_VMA_PREFIX); - - /* We are on Linux ! */ - if (!strcmp(os, "Linux")) - { - if (!strncmp(release, "2.6", 3)) - { - libkernshworld.os = LIBKERNSH_OS_LINUX_2_6; - } - else if (!strncmp(release, "2.4", 3)) - { - libkernshworld.os = LIBKERNSH_OS_LINUX_2_4; - } - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Release not supported", -1); - } - - config_add_item(LIBKERNSH_VMCONFIG_DEVICE, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) LIBKERNSH_STRING_DEVICE_MEM); - - config_add_item(LIBKERNSH_VMCONFIG_MODE, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *)"write"); - - config_add_item(LIBKERNSH_VMCONFIG_MMAP, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 1); - - config_add_item(LIBKERNSH_VMCONFIG_MMAP_SIZE, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_MMAP_SIZE); - - memset(buffer, '\0', sizeof(buffer)); - snprintf(buffer, sizeof(buffer), "%s-%s", LIBKERNSH_DEFAULT_LINUX_KERNEL, release); - - config_add_item(LIBKERNSH_VMCONFIG_KERNEL, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) buffer); - - config_add_item(LIBKERNSH_VMCONFIG_KERNELGZ, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_KERNELGZ); - - config_add_item(LIBKERNSH_VMCONFIG_KERNELELF, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_KERNELELF); - - config_add_item(LIBKERNSH_VMCONFIG_STORAGE_PATH, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_STORAGE_PATH); - - memset(buffer, '\0', sizeof(buffer)); - snprintf(buffer, sizeof(buffer), "%s-%s", LIBKERNSH_DEFAULT_LINUX_MAP, release); - - config_add_item(LIBKERNSH_VMCONFIG_SYSTEMMAP, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *) buffer); - - config_add_item(LIBKERNSH_VMCONFIG_NB_SYSCALLS, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_NB_SYSCALLS); - - config_add_item(LIBKERNSH_VMCONFIG_NIL_SYSCALL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_NIL_SYSCALL); - - config_add_item(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_VIRTM_NIL_SYSCALL); - - config_add_item(LIBKERNSH_VMCONFIG_KERNEL_START, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_I386_LINUX_START); - - config_add_item(LIBKERNSH_VMCONFIG_KERNEL_END, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) LIBKERNSH_I386_LINUX_END); - - config_add_item(LIBKERNSH_VMCONFIG_KLOAD, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_INSMOD); - - config_add_item(LIBKERNSH_VMCONFIG_KUNLOAD, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (void *) LIBKERNSH_DEFAULT_LINUX_RMMOD); - - } - else - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Os not supported", -1); - } - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - libkernshworld.release, - strlen(release) + 1, - -1); - - if (memcpy(libkernshworld.release, release, strlen(release)) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed", -1); - } - -#if __DEBUG_KERNSH__ - printf("RELEASE %s\n", libkernshworld.release); -#endif - - kernsh_init_vectors(); - kernsh_register_vectors(); - kernsh_present_set(); - - asm_init_ia32(&libkernshworld.proc); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Delete kernsh for ia32 - * @return 0 on success, -1 on error - */ -int kernsh_del_ia32() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XFREE(__FILE__, __FUNCTION__, __LINE__, libkernshworld.release); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Kernsh is in memory mode ? - * @return 1 on memory mode, 0 on error - */ -int kernsh_is_mem_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.mem == LIBKERNSH_MEM_MODE)); -} - -/** - * @brief Set kernsh in memory mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_mem_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - libkernshworld.mem= LIBKERNSH_MEM_MODE; - - elfsh_set_debug_mode(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Kernsh is in static mode ? - * @return 1 on static mode, 0 on error - */ -int kernsh_is_static_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.mem == LIBKERNSH_STATIC_MODE)); -} - -/** - * @brief Set kernsh in static mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_static_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - - libkernshworld.mem= LIBKERNSH_STATIC_MODE; - - elfsh_set_static_mode(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get kernsh mode - * @return return the mode - */ -int kernsh_get_mode() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, libkernshworld.mem); -} - -/** - * @brief Set kernsh mode - * @param mode The mode - * @return 0 on sucess, -1 on error - */ -int kernsh_set_mode(int mode) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (mode) - { - case LIBKERNSH_MEM_MODE : - libkernshworld.mem = LIBKERNSH_MEM_MODE; - elfsh_set_debug_mode(); - break; - case LIBKERNSH_STATIC_MODE : - libkernshworld.mem = LIBKERNSH_STATIC_MODE; - elfsh_set_static_mode(); - break; - default : - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalide mode", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Called in elfsh_get_raw to interact with the memory - * @param sect The section - */ -void *kernsh_elfsh_get_raw(elfshsect_t *sect) -{ - void *dataptr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_elfsh_get_raw\n"); -#endif - - if (libkernshworld.open && kernsh_is_mem_mode() && libkernshworld.mmap) - { - /* We use physical memory ? */ - if (libkernshworld.physical) - { -#if __DEBUG_KERNSH__ - printf("PTR 0x%lx RHDR BASE 0x%lx KERNEL_START 0x%lx SH_ADDR 0x%lx DATA 0x%lx 0x%lx\n", - (unsigned long) libkernshworld.ptr, - (unsigned long) sect->parent->rhdr.base, - (unsigned long) libkernshworld.kernel_start, - (unsigned long) sect->shdr->sh_addr, - (unsigned long) sect->data, - (unsigned long) sect->phdr); -#endif - - dataptr = libkernshworld.ptr; - - if(elfsh_section_is_runtime(sect)) - { - sect->parent->rhdr.base = 0; - dataptr += sect->shdr->sh_addr - libkernshworld.kernel_start; - } - else - { - sect->parent->rhdr.base = - libkernshworld.kernel_start - sect->shdr->sh_addr; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); - } - } - else - { - if (libkernshworld.open) - sect->parent->rhdr.base = 0; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * @brief Called in revm_get_raw to interact with the memory - * @param addr The address - */ -void *kernsh_revm_get_raw(void *addr) -{ - void *dataptr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_revm_get_raw\n"); -#endif - - if (libkernshworld.open && kernsh_is_mem_mode() && libkernshworld.mmap) - { - /* We use physical memory ? */ - if (libkernshworld.physical) - dataptr = libkernshworld.ptr + ((eresi_Addr) addr - libkernshworld.kernel_start); - else - dataptr = libkernshworld.ptr + (eresi_Addr) addr; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dataptr); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * @brief Get some information about the kernel - * @return 0 on sucess, -1 on error - */ -int kernsh_info() -{ - int ret; - u_int dim[3]; - vector_t *info; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - info = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFO); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(info, dim); - - ret = fct(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get some information about the linux kernel - * @return 0 on sucess, -1 on error - */ -int kernsh_info_linux() -{ - unsigned long system_call; - char buffer[256]; - char *p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(__linux__) - asm("sidt %0" : "=m" (idtr)); -#endif - - libkernshworld.idt_base = idtr.base; - libkernshworld.idt_limit = idtr.limit; - -#if __DEBUG_KERNSH__ - printf("IDTR BASE 0x%lx LIMIT 0x%x\n", idtr.base,idtr.limit); -#endif - - kernsh_readmem(idtr.base+(2*sizeof(unsigned long))*0x80, - &idt, - sizeof(idt)); - system_call = (idt.off2 << 16) | idt.off1; - -#if defined(__linux__) - libkernshworld.system_call = system_call; -#endif - -#if __DEBUG_KERNSH__ - printf("idt80: flags = %d flags=%X sel=%X off1=%x off2=%X\n", - idt.flags,(unsigned)idt.flags,(unsigned)idt.sel,(unsigned)idt.off1, - (unsigned)idt.off2); - printf("SYSTEM_CALL : 0x%lx\n", system_call); -#endif - - kernsh_readmem(system_call, buffer, 255); - p = (char *)kernsh_find_pattern(buffer, 255, "\xff\x14\x85", 3); - - if (p == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get sct", -1); - } - - libkernshworld.sct = *(unsigned long *)(p + 3); - -#if __DEBUG_KERNSH__ - printf("Sys Call Table 0x%lx\n", libkernshworld.sct); -#endif - - -#if defined(__linux__) - asm("sgdt %0" : "=m" (gdtr)); -#endif - -#if __DEBUG_KERNSH__ - printf("GDTR BASE 0x%lx LIMIT 0x%x\n", gdtr.base,gdtr.limit); -#endif - - libkernshworld.gdt_base = gdtr.base; - libkernshworld.gdt_limit = gdtr.limit; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get some information about the netbsd kernel - * @return 0 on sucess, -1 on error - */ -int kernsh_info_netbsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Get some information about the freebsd kernel - * @return 0 on sucess, -1 on error - */ -int kernsh_info_freebsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Load elf file - * @param name The path of the file to load - * @return 0 on sucess, -1 on error - */ -elfshobj_t *kernsh_load_file(char *name) -{ - elfshobj_t *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = elfsh_load_obj(name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Unload elf file - * @param file The elf object - */ -void kernsh_unload_file(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - elfsh_unload_obj(file); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Write raw in the kernel memory - * @param file The elf object - * @param foffset Offset to write memory - * @param src_buff Write buf into memoryr - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_raw_write(elfshobj_t *file, u_int foffset, void *src_buff, int len) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (kernsh_is_mem_mode()) - { - kernsh_writemem(elfsh_get_vaddr_from_foffset(file, foffset), - src_buff, - len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (len)); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mode is wrong", -1); -} - -/** - * @brief Read raw kernel memory - * @param file The elf object - * @param foffset Offset to read memory - * @param dest_buff Read memory into the buf - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_raw_read(elfshobj_t *file, u_int foffset, void *dest_buff, int len) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (kernsh_is_mem_mode()) - { - kernsh_readmem(elfsh_get_vaddr_from_foffset(file, foffset), - dest_buff, - len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, len); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mode is wrong", -1); -} - -/** - * @brief Set kernsh's present - */ -void kernsh_present_set() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - libkernshworld.present = 1; - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Get kernsh's present - * @return 1 on success, 0 on error - */ -int kernsh_is_present() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (libkernshworld.present == 1)); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/kmem.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/kmem.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/kmem.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/kmem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,213 +0,0 @@ -/* -** @file kmem.c -** @ingroup libkernsh_user -** -*/ -#if defined(__linux__) -#define _LARGEFILE64_SOURCE -#endif - -#include "libkernsh.h" - -/** - * @brief Open /dev/kmem on Linux 2.6.X - * @return 0 on success, -1 on return - */ -int kernsh_openmem_kmem_linux_2_6() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN KMEM 2.6\n"); -#endif - - if (libkernshworld.mmap) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Mmap not supported with /dev/kmem", -1); - } - - XOPEN(libkernshworld.fd, - LIBKERNSH_STRING_DEVICE_KMEM, - libkernshworld.fdmode, - 0, - -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Close /dev/kmem on Linux 2.6.X - * @return 0 on success, -1 on return - */ -int kernsh_closemem_kmem_linux_2_6() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("CLOSE KMEM 2.6\n"); -#endif - - XCLOSE(libkernshworld.fd, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Read /dev/kmem on Linux 2.6.X - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem_kmem_linux_2_6(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); -#endif - - XREAD(libkernshworld.fd, buf, size, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} - -/** - * @brief Write in /dev/kmem on Linux 2.6.X - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem_kmem_linux_2_6(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); -#endif - - XWRITE(libkernshworld.fd, buf, size, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} - -/** - * @brief Open /dev/kmem on Linux 2.4.X - * @return 0 on success, -1 on return - */ -int kernsh_openmem_kmem_linux_2_4() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN KMEM 2.4\n"); -#endif - - XOPEN(libkernshworld.fd, - LIBKERNSH_STRING_DEVICE_KMEM, - libkernshworld.fdmode, - 0, - -1); - - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMMAP(libkernshworld.ptr, - 0, - libkernshworld.mmap_size, - libkernshworld.protmode, - libkernshworld.flagsmode, - libkernshworld.fd, - 0, - -1); -#endif - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Close /dev/kmem on Linux 2.4.X - * @return 0 on success, -1 on return - */ -int kernsh_closemem_kmem_linux_2_4() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("CLOSE KMEM 2.4\n"); -#endif - - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMUNMAP(libkernshworld.ptr, libkernshworld.mmap_size, -1); -#endif - } - - XCLOSE(libkernshworld.fd, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Read /dev/kmem on Linux 2.4.X - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem_kmem_linux_2_4(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (libkernshworld.mmap) - { - if (memcpy(buf, libkernshworld.ptr+offset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } - } - else - { -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); -#endif - XREAD(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} - -/** - * @brief Write in /dev/kmem on Linux 2.4.X - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem_kmem_linux_2_4(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (libkernshworld.mmap) - { - if (memcpy(libkernshworld.ptr+offset, buf, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } - } - else - { -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, offset, SEEK_SET, -1); -#endif - XWRITE(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/kvirtm.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/kvirtm.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/kvirtm.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/kvirtm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,819 +0,0 @@ -/* -** @file kvirtm.c -** @ingroup libkernsh_user -** -*/ - -#include "libkernsh.h" - -/** - * @brief Read virtual memory of a pid\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param addr The address to read - * @param buffer Read virtual memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_read_virtm(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int ret, get, i, j, max_size; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - max_size = LIBKERNSH_PROC_ENTRY_SIZE; - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADVIRTM); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - ret = 0; - - if (len > max_size && get == LIBKERNSH_KERNEL_MODE) - { - i = len / max_size; - for (j = 0; j < i; j++) - { - ret += fct(pid, addr+(max_size*j), buffer+(max_size*j), max_size); - } - - if ((max_size*i) < len) - { - ret += fct(pid, addr+(max_size*i), buffer+(max_size*i), (len - (max_size*i))); - } - } - else - ret = fct(pid, addr, buffer, len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Read virtual memory of a pid in /proc - * @param pid The process id - * @param addr The address to read - * @param buffer Read virtual memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_read_virtm_proc_linux(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int fd, ret, nlen; - char *proc_entry_root_tmp; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - if (len > 1024) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Len is too long > 1024", - -1); - - nlen = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - nlen, - -1); - - memset(proc_entry_root_tmp, '\0', nlen); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:%d", - LIBKERNSH_VIRTM_READ_MEM_PID, - addr, - len, - pid); - - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - - XCLOSE(fd, -1); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - ret = read(fd, buffer, len); - XCLOSE(fd, -1); - - - XFREE(__FILE__, __FUNCTION__, __LINE__, proc_entry_root_tmp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Read virtual memory of a pid with syscall - * @param pid The process id - * @param addr The address to read - * @param buffer Read virtual memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_read_virtm_syscall_linux(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int ret; - unsigned int arg[5]; - int rlen; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_virtm_syscall_linux\n"); -#endif - - ret = 0; - - arg[0] = (unsigned int)pid; - arg[1] = (unsigned int)(addr - libkernshworld.kernel_start); - arg[2] = (unsigned int)buffer; - arg[3] = (unsigned int)len; - arg[4] = (unsigned int)LIBKERNSH_VIRTM_READ_MEM_PID; - - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); -} - -/** - * @brief Write virtual memory of a pid\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param addr The address to write - * @param buffer Write buffer into virtual memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_write_virtm(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int ret, get, i, j, max_size;; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - max_size = LIBKERNSH_PROC_ENTRY_SIZE; - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEVIRTM); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - ret = 0; - - if (len > max_size && get == LIBKERNSH_KERNEL_MODE) - { - i = len / max_size; - for (j = 0; j < i; j++) - { - ret += fct(pid, addr+(max_size*j), buffer+(max_size*j), max_size); - } - - if ((max_size*i) < len) - { - ret += fct(pid, addr+(max_size*i), buffer+(max_size*i), (len - (max_size*i))); - } - } - else - ret = fct(pid, addr, buffer, len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Write virtual memory of a pid in /proc - * @param pid The process id - * @param addr The address to write - * @param buffer Write buffer into virtual memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_write_virtm_proc_linux(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int fd, ret, nlen; - char *proc_entry_root_tmp; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - memset(buff, '\0', sizeof(buff)); - - if (len > 1024) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Len is too long > 1024", - -1); - - nlen = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - nlen, - -1); - - memset(proc_entry_root_tmp, '\0', nlen); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:%d", - LIBKERNSH_VIRTM_WRITE_MEM_PID, - addr, - len, - pid); - - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - - XCLOSE(fd, -1); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - ret = write(fd, buffer, len); - XCLOSE(fd, -1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, proc_entry_root_tmp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Write virtual memory of a pid with syscall - * @param pid The process id - * @param addr The address to write - * @param buffer Write buffer into virtual memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_write_virtm_syscall_linux(pid_t pid, unsigned long addr, char *buffer, int len) -{ - int ret; - unsigned int arg[5]; - int rlen; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_write_virtm_syscall_linux\n"); -#endif - - ret = 0; - - arg[0] = (unsigned int)pid; - arg[1] = (unsigned int)(addr - libkernshworld.kernel_start); - arg[2] = (unsigned int)buffer; - arg[3] = (unsigned int)len; - arg[4] = (unsigned int)LIBKERNSH_VIRTM_WRITE_MEM_PID; - - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); - - if (rlen != len) - ret = -1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Open kernsh-virtm module - * @return 0 on success, -1 on error - */ -int kernsh_kvirtm_openmem() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN KVIRTM OPEN MEM\n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Close kernsh-virtm module - * @return 0 on success, -1 on error - */ -int kernsh_kvirtm_closemem() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN KVIRTM CLOSE MEM\n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Read kernel memory with kernsh-virtm module - * @param addr Address to read memory - * @param buffer Read memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_readmem(unsigned long addr, char *buffer, int len) -{ - int ret, get, i, j, max_size; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - max_size = LIBKERNSH_PROC_ENTRY_SIZE; - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem\n"); -#endif - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMREADMEM); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - if (len > max_size && get == LIBKERNSH_KERNEL_MODE) - { - i = len / max_size; - for (j = 0; j < i; j++) - { - ret += fct(addr+(max_size*j), buffer+(max_size*j), max_size); - } - - if ((max_size*i) < len) - { - ret += fct(addr+(max_size*i), buffer+(max_size*i), (len - (max_size*i))); - } - } - else - ret = fct(addr, buffer, len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Read kernel memory with kernsh-virtm module thought syscall - * @param addr Address to read memory - * @param buffer Read memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_readmem_syscall_linux(unsigned long addr, char *buffer, int len) -{ - int ret; - unsigned int arg[5]; - int rlen; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem_syscall_linux\n"); -#endif - - ret = 0; - - arg[0] = (unsigned int)0; - arg[1] = (unsigned int)(addr - libkernshworld.kernel_start); - arg[2] = (unsigned int)buffer; - arg[3] = (unsigned int)len; - arg[4] = (unsigned int)LIBKERNSH_VIRTM_READ_MEM; - - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); -} - -/** - * @brief Read kernel memory with kernsh-virtm module thought /proc - * @param addr Address to read memory - * @param buffer Read memory into the buffer - * @param len Count bytes to read - * @return len on success, -1 on error - */ -int kernsh_kvirtm_readmem_proc_linux(unsigned long addr, char *buffer, int len) -{ - int fd, ret, nlen; - char *proc_entry_root_tmp; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem_proc\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (len > 1024) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Len is too long > 1024", - -1); - - nlen = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - nlen, - -1); - - memset(proc_entry_root_tmp, '\0', nlen); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:", - LIBKERNSH_VIRTM_READ_MEM, - (addr - libkernshworld.kernel_start), - len); - - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - XCLOSE(fd, -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - XCLOSE(fd, -1); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - ret = read(fd, buffer, len); - XCLOSE(fd, -1); - - - XFREE(__FILE__, __FUNCTION__, __LINE__, proc_entry_root_tmp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * @brief Write into kernel memory with kernsh-virtm module - * @param addr Address to write buffer - * @param buffer Write buffer into memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_writemem(unsigned long addr, char *buffer, int len) -{ - int ret, get, i, j, max_size; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - max_size = LIBKERNSH_PROC_ENTRY_SIZE; - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem\n"); -#endif - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMWRITEMEM); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - if (len > max_size && get == LIBKERNSH_KERNEL_MODE) - { - i = len / max_size; - for (j = 0; j < i; j++) - { - ret += fct(addr+(max_size*j), buffer+(max_size*j), max_size); - } - - if ((max_size*i) < len) - { - ret += fct(addr+(max_size*i), buffer+(max_size*i), (len - (max_size*i))); - } - } - else - ret = fct(addr, buffer, len); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Write into kernel memory with kernsh-virtm module thought syscall - * @param addr Address to write buffer - * @param buffer Write buffer into memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_writemem_syscall_linux(unsigned long addr, char *buffer, int len) -{ - int ret; - unsigned int arg[5]; - int rlen; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem_syscall_linux\n"); -#endif - - ret = 0; - - arg[0] = (unsigned int)0; - arg[1] = (unsigned int)(addr - libkernshworld.kernel_start); - arg[2] = (unsigned int)buffer; - arg[3] = (unsigned int)len; - arg[4] = (unsigned int)LIBKERNSH_VIRTM_WRITE_MEM; - - rlen = kernsh_syscall((int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM_NIL_SYSCALL), 5, arg); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rlen); -} - -/** - * @brief Write kernel memory with kernsh-virtm module thought /proc - * @param addr Address to write buffer - * @param buffer Write buffer into memory - * @param len Count bytes to write - * @return len on success, -1 on error - */ -int kernsh_kvirtm_writemem_proc_linux(unsigned long addr, char *buffer, int len) -{ - int fd, ret, nlen; - char *proc_entry_root_tmp; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_read_mem_proc\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (len > 1024) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Len is too long > 1024", - -1); - - nlen = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - nlen, - -1); - - memset(proc_entry_root_tmp, '\0', nlen); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x%lx:%d:", - LIBKERNSH_VIRTM_WRITE_MEM, - (addr - libkernshworld.kernel_start), - len); - - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - XCLOSE(fd, -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - XCLOSE(fd, -1); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - ret = write(fd, buffer, len); - XCLOSE(fd, -1); - - XFREE(__FILE__, __FUNCTION__, __LINE__, proc_entry_root_tmp); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Task pid\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param h The list - * @return 0 on success, -1 on error - */ -int kernsh_kvirtm_task_pid(pid_t pid, list_t *h) -{ - int ret, get; - u_int dim[3]; - vector_t *krv; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - -#if __DEBUG_KERNSH__ - printf("kernsh_kvirtm_task_pid\n"); -#endif - - get = (int)config_get_data(LIBKERNSH_VMCONFIG_VIRTM); - - krv = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KVIRTMTASKPID); - dim[0] = libkernshworld.os; - dim[1] = get; - - fct = aspect_vectors_select(krv, dim); - - ret = fct(pid, h); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Task pid thought /proc\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param h The list - * @return 0 on success, -1 on error - */ -int kernsh_kvirtm_task_pid_proc_linux(pid_t pid, list_t *h) -{ - int fd, ret, nlen, blen; - kvirtm_virtual_task_struct_t *kvtst; - char *key, *proc_entry_root_tmp, *buffer, *p; - char buff[BUFSIZ]; - unsigned long *pkvtst; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - kvtst, - sizeof(kvirtm_virtual_task_struct_t), - -1); - - XALLOC(__FILE__, - __FUNCTION__, - __LINE__, - key, - BUFSIZ, - -1); - - memset(kvtst, '\0', sizeof(kvirtm_virtual_task_struct_t)); - memset(key, '\0', BUFSIZ); - snprintf(key, BUFSIZ, "%d", pid); - - memset(buff, '\0', sizeof(buff)); - - nlen = strlen(PROC_ENTRY_ROOT) + - strlen(PROC_ENTRY_KERNSH_VIRTM) + - strlen(PROC_ENTRY_KERNSH_VIRTM_MAX) + - 2; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - proc_entry_root_tmp, - nlen, - -1); - - memset(proc_entry_root_tmp, '\0', nlen); - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO_INFO); - - - blen = sizeof(kvirtm_virtual_task_struct_t) * 2 + - (sizeof(kvirtm_virtual_task_struct_t) / sizeof(unsigned long)) * 3; - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - snprintf(buff, sizeof(buff), "%d:0x0:%d:%d:", - LIBKERNSH_VIRTM_TASK_PID, - blen, - pid); - - ret = write(fd, buff, strlen(buff)); - if (ret != strlen(buff)) - { - XCLOSE(fd, -1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Impossible to set vio", - -1); - } - XCLOSE(fd, -1); - - - snprintf(proc_entry_root_tmp, nlen, "%s%s/%s", - PROC_ENTRY_ROOT, - PROC_ENTRY_KERNSH_VIRTM, - PROC_ENTRY_KERNSH_VIRTM_VIO); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - buffer, - blen + 1, - -1); - - XOPEN(fd, proc_entry_root_tmp, O_RDWR, 0777, -1); - ret = read(fd, buffer, blen); - XCLOSE(fd, -1); - - for (p = (char *)strtok(buffer, ":"), pkvtst = (unsigned long *)kvtst; - p; - p = (char *)strtok(NULL, ":"), pkvtst++) - { - *pkvtst = strtoul(p, NULL, 16); - } - - elist_add(h, key, (void *) kvtst); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Task pid thought syscall\n - * Configure :\n - * LIBKERNSH_VMCONFIG_VIRTM - * @param pid The process id - * @param h The list - * @return 0 on success, -1 on error - */ -int kernsh_kvirtm_task_pid_syscall_linux(pid_t pid, list_t *h) -{ - int ret; - // kvirtm_virtual_task_struct_t *kvtst; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -include ../../config.h -# -# Architecture source files -# -SRCS = kernsh.c kernimage.c alloc.c kvirtm.c misc.c symbs.c kcore.c kmem.c mem.c module.c - -OBJS32 = ${SRCS:.c=.32.o} -OBJS64 = ${SRCS:.c=.64.o} - -CFLAGS32 = -I../include -Wall -g3 -DERESI32 \ - -I../../libaspect/include -I../../libasm/include \ - -I../../libelfsh/include -I../../libedfmt/include \ - -I../../libmjollnir/include -O2 -CFLAGS64 = -I../include -Wall -g3 -fPIC -DERESI64 \ - -I../../libaspect/include -I../../libasm/include \ - -I../../libelfsh/include -I../../libedfmt/include \ - -I../../libmjollnir/include -O2 -RM = rm -f -ETAGS = etags -CC ?= gcc -LD ?= ld -CP = cp - -all: all32 all64 - -symbs : - @cd symbols && $(MAKE) - -all32: symbs $(OBJS32) - -all64: symbs $(OBJS64) - -clean: - @$(RM) $(OBJS32) $(OBJS64) *~ \#* *\# .\#* - @cd symbols && $(MAKE) clean - -fclean: clean - -#tags: -# @$(ETAGS) -a arch/i386/*.c include/*.h engine/*.c sample/*.c -# @echo TAGS generated succesfully - -%.32.o: %.c - @$(CC) $(CFLAGS32) ${DBGFLAGS} -c $*.c -o $*.32.o - @echo "[CC] $*.32.o" - -%.64.o: %.c - @$(CC) $(CFLAGS64) ${DBGFLAGS} -c $*.c -o $*.64.o - @echo "[CC] $*.64.o" diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/mem.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/mem.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/mem.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/mem.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,230 +0,0 @@ -/* -** @file mem.c -** @ingroup libkernsh_user -** -*/ -#if defined(__linux__) -#define _LARGEFILE64_SOURCE -#endif - -#include "libkernsh.h" - -/** - * @brief Open /dev/mem on Linux 2.X - * @return 0 on success, -1 on return - */ -int kernsh_openmem_mem_linux() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN MEM 2.X\n"); -#endif - - XOPEN(libkernshworld.fd, - LIBKERNSH_STRING_DEVICE_MEM, - libkernshworld.fdmode, - 0, - -1); - - /* If mmap is specified */ - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMMAP(libkernshworld.ptr, - 0, - libkernshworld.mmap_size, - libkernshworld.protmode, - libkernshworld.flagsmode, - libkernshworld.fd, - 0, - -1); -#endif - } - - libkernshworld.physical = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Close /dev/mem on Linux 2.X - * @return 0 on success, -1 on return - */ -int kernsh_closemem_mem_linux() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("CLOSE MEM 2.X\n"); -#endif - - if (libkernshworld.mmap) - { -#if defined(__linux__) - XMUNMAP(libkernshworld.ptr, libkernshworld.mmap_size, -1); -#endif - } - - XCLOSE(libkernshworld.fd, -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Read /dev/mem on Linux 2.X - * @param offset Offset to read memory - * @param buf Read memory into the buf - * @param size Count bytes to read - * @return size on success, -1 on error - */ -int kernsh_readmem_mem_linux(unsigned long offset, void *buf, int size) -{ - unsigned long roffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We must subtrack kernel_start(page_offset) to get the physical address */ - roffset = offset - libkernshworld.kernel_start; - - if (libkernshworld.mmap) - { - if (memcpy(buf, libkernshworld.ptr+roffset, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } - } - else - { -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); -#endif - XREAD(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} - -/** - * @brief Write into /dev/mem on Linux 2.X - * @param offset Offset to write memory - * @param buf Write buf into memoryr - * @param size Count bytes to write - * @return size on success, -1 on error - */ -int kernsh_writemem_mem_linux(unsigned long offset, void *buf, int size) -{ - unsigned long roffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We must subtrack kernel_start (page_offset) to get the physical address */ - roffset = offset - libkernshworld.kernel_start; - - if (libkernshworld.mmap) - { - if (memcpy(libkernshworld.ptr+roffset, buf, size) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memcpy failed !", -1); - } - } - else - { -#if defined(__linux__) - XLSEEK64(libkernshworld.fd, roffset, SEEK_SET, -1); -#endif - XWRITE(libkernshworld.fd, buf, size, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, size); -} - -int kernsh_openmem_netbsd() -{ -#if defined(__NetBSD__) - char errbuf[_POSIX2_LINE_MAX]; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("OPEN MEM NETBSD\n"); -#endif - -#if defined(__NetBSD__) - libkernshworld.kd = krevm_openfiles(NULL, - NULL, - NULL, - libkernshworld.fdmode, - errbuf); - - if(libkernshworld.kd == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - errbuf, -1); - - } - -#endif - - libkernshworld.open = 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_closemem_netbsd() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("CLOSE MEM NETBSD\n"); -#endif - -#if defined(__NetBSD__) - if(krevm_close(libkernshworld.kd) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to close memory", -1); - } -#endif - - libkernshworld.open = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_readmem_netbsd(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // printf("READ MEM NETBSD\n"); - -#if defined(__NetBSD__) - if (krevm_read(libkernshworld.kd, offset, buf, size) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - krevm_geterr(libkernshworld.kd), -1); - } -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int kernsh_writemem_netbsd(unsigned long offset, void *buf, int size) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // printf("WRITE MEM NETBSD\n"); - -#if defined(__NetBSD__) - if (krevm_write(libkernshworld.kd, offset, buf, size) < 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - krevm_geterr(libkernshworld.kd), -1); - } -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,175 +0,0 @@ -/* -** @file misc.c -** @ingroup libkernsh_user -** -*/ -#include "libkernsh.h" - -/* This function find a needle inside a haystack */ -void *kernsh_find_pattern(const void *haystack, int haystack_len, - const void *needle, int needle_len) -{ - const char *begin; - const char *const last_possible - = (const char *) haystack+ haystack_len - needle_len; - - if (needle_len == 0) - return (void *) haystack; - - if (haystack_len < needle_len) - return NULL; - - for (begin = (const char *) haystack; begin <= last_possible; ++begin) - if (begin[0] == ((const char *) needle)[0] && - !memcmp ((const void *) &begin[1], - (const void *) ((const char *) needle + 1), - needle_len - 1)) - return (void *) begin; - - return NULL; -} - -/* Resolve name with addr */ -int kernsh_resolve_systemmap(unsigned long addr, char *name, size_t size) -{ - FILE *input; - char line[256]; - char caddr[32]; - char *paddr, *pname, *end; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if(addr != 0) - { - memset(name, '\0', size); - memset(caddr, '\0', sizeof(caddr)); - - snprintf(caddr, sizeof(caddr) - 1, "0x%lx", (unsigned long)addr); - if ((input = fopen((char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP), - "r")) == NULL) - { - memcpy(name, "UNKNOWN_NAME", size - 1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to open systemmap", -1); - } - - while (fgets(line, sizeof(line) - 1, input) != NULL) - { - paddr = strtok(line, " "); - if(strstr(caddr, paddr)) - { - pname = strtok(NULL, " "); - pname = strtok(NULL, " "); - end = strstr(pname, "\n"); - if (pname[0] != '_') - { - memcpy(name, pname, size - 1); - name[end - pname] = '\0'; - fclose(input); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - } - fclose(input); - } - - memcpy(name, "UNKNOWN_NAME", size - 1); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get name", -1); -} - -/* Resolve add with name */ -int kernsh_rresolve_systemmap(const char *name, unsigned long *addr, size_t size) -{ - FILE *input; - char *paddr, *pname; - char line[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if ((input = fopen((char *) config_get_data(LIBKERNSH_VMCONFIG_SYSTEMMAP), - "r")) == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to open systemmap", -1); - } - - while (fgets(line, sizeof(line) - 1, input) != NULL) - { - paddr = strtok(line, " "); - pname = strtok(NULL, " "); - pname = strtok(NULL, " "); - pname[strlen(pname) - 1] = '\0'; - - if (!strcmp(pname, name)) - { - *addr = strtoull(paddr, NULL, 16); - fclose(input); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - fclose(input); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot get addr", -1); -} - -int kernsh_find_end(unsigned long addr) -{ - unsigned char buff[BUFSIZ]; - int curr, sizemax; - unsigned long addrcur, addrfinal, start; - asm_instr instr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - addrcur = addr; - sizemax = (int) config_get_data(LIBKERNSH_VMCONFIG_FENDSIZE); - addrfinal = addr+sizemax; - - while (addrcur < addrfinal) - { - if (kernsh_is_mem_mode()) - { - kernsh_readmem(addrcur, buff, sizeof(buff)); - } - else - { - start = elfsh_get_foffset_from_vaddr(libkernshworld.root, - addrcur); - elfsh_raw_read(libkernshworld.root, start, buff, sizeof(buff)); - - } - curr = 0; - while(curr < sizeof(buff)) - { - if (asm_read_instr(&instr, - buff + curr, sizeof(buff) - curr, - &libkernshworld.proc) > 0) - { -#if __DEBUG_KERNSH__ - printf("CURR %d INSTR %d TYPE %d => ", - curr, instr.instr, instr.type); - int i; - for (i = 0; i < instr.len; i++) - printf("%02x ", *(buff + curr + i)); - printf("\n"); -#endif - curr += asm_instr_len(&instr); - - if (instr.instr == ASM_RET || instr.instr == ASM_IRET) - { - PROFILER_ROUT(__FILE__, - __FUNCTION__, - __LINE__, - curr + (addrcur - addr)); - } - } - else - { - curr++; - } - } - - addrcur += sizeof(buff); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find the end", 0); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/module.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/module.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/module.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/module.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,477 +0,0 @@ -/* -** @file module.c -** @ingroup libkernsh_user -** -*/ -#include "libkernsh.h" - -/** - * @brief Load a loadable kernel module - * @param name Module's pathname - * @return 0 on success, -1 on return - */ -int kernsh_kload_module(char *name) -{ - int ret; - u_int dim[2]; - vector_t *kload; - int (*fct)(); - char buff[BUFSIZ]; - struct stat binary; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("KLOAD MODULE\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (name == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Paramater must be not null", -1); - } - - if (stat(name, &binary)) - { - snprintf(buff, - sizeof(buff), - "Unable to open %s", - name); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - buff, -1); - } - - kload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KLOADMODULE); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(kload, dim); - - ret = fct(name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Load a linux loadable kernel module\n - * Configure :\n - * LIBKERNSH_VMCONFIG_KLOAD - * @param name Module's pathname - * @return 0 on success, -1 on return - */ -int kernsh_kload_module_linux(char *name) -{ - int ret = 0; - extern char **environ; - char *params[] = { "insmod", name, NULL }; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("KLOAD MODULE LINUX\n"); -#endif - - if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_KLOAD), params, environ); - else - wait(NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Unload a loadable kernel module - * @param name Module's name - * @return 0 on success, -1 on return - */ -int kernsh_kunload_module(char *name) -{ - int ret; - u_int dim[2]; - vector_t *kunload; - int (*fct)(); - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("KUNLOAD MODULE\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (name == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Paramater must be not null", -1); - } - - kunload = aspect_vector_get(LIBKERNSH_VECTOR_NAME_KUNLOADMODULE); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(kunload, dim); - - ret = fct(name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Unload a linux loadable kernel module\n - * Configure :\n - * LIBKERNSH_VMCONFIG_KUNLOAD - * @param name Module's name - * @return 0 on success, -1 on return - */ -int kernsh_kunload_module_linux(char *name) -{ - int ret = 0; - extern char **environ; - char *params[] = { "rmmod", name, NULL }; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("KUNLOAD MODULE LINUX\n"); -#endif - - if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_KUNLOAD), params, environ); - else - wait(NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Relink a loadable kernel module - * @param orig Original module's pathname - * @param injec Injected module's pathname - * @param evil New module's pathname - * @return 0 on success, -1 on return - */ -int kernsh_relink_module(char *orig, char *injec, char *evil) -{ - int ret; - u_int dim[2]; - vector_t *rel; - int (*fct)(); - char buff[BUFSIZ]; - struct stat binary; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("RELINK MODULE\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (orig == NULL || injec == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Paramater must be not null", -1); - } - - if (stat(orig, &binary)) - { - snprintf(buff, - sizeof(buff), - "Unable to open %s", - orig); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - buff, -1); - } - - if (stat(injec, &binary)) - { - snprintf(buff, - sizeof(buff), - "Unable to open %s", - injec); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - buff, -1); - } - - rel = aspect_vector_get(LIBKERNSH_VECTOR_NAME_RELINKMODULE); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(rel, dim); - - if (evil == NULL) - ret = fct(orig, injec, orig); - else - ret = fct(orig, injec, evil); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Relink a linux loadable kernel module - * @param orig Original module's pathname - * @param injec Injected module's pathname - * @param evil New module's pathname - * @return 0 on success, -1 on return - */ -int kernsh_relink_module_linux(char *orig, char *injec, char *evil) -{ - int ret = 0; - extern char **environ; - char *params[] = { "ld", "-r", orig, injec, "-o", evil, NULL}; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("RELINK MODULE LINUX\n"); -#endif - - if(fork() == 0) - ret = execve((char *) config_get_data(LIBKERNSH_VMCONFIG_LD), params, environ); - else - wait(NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Replace a function in a loadable kernel module - * @param module Module's pathname - * @param original_fname Original function's name - * @param evil_fname New function's name - * @return 0 on success, -1 on return - */ -int kernsh_infect_module(char *module, - char *original_fname, char *evil_fname) -{ - int ret; - u_int dim[2]; - vector_t *inf; - int (*fct)(); - char buff[BUFSIZ]; - struct stat binary; - elfshobj_t *mod; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("INFECT MODULE\n"); -#endif - - memset(buff, '\0', sizeof(buff)); - - if (module == NULL || original_fname == NULL || evil_fname == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Paramater must be not null", -1); - } - - if (stat(module, &binary)) - { - snprintf(buff, - sizeof(buff), - "Unable to open %s", - module); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - buff, -1); - } - - mod = kernsh_load_file(module); - if (mod == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load module", -1); - } - - inf = aspect_vector_get(LIBKERNSH_VECTOR_NAME_INFECTMODULE); - dim[0] = libkernshworld.os; - - fct = aspect_vectors_select(inf, dim); - - ret = fct(module, mod, original_fname, evil_fname); - - kernsh_unload_file(mod); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -int get_symbol_idx(elfshobj_t *file, elfsh_Sym *table, int num, char *symbol) -{ - int idx, index; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - idx = -1; - - for (index = 0; index < num; index++) - { - name = elfsh_get_symbol_name(file, table + index); - if (!strcmp(name, symbol)) - idx = index; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); -} - -/** - * @brief Replace a function in a linux 2.6.X loadable kernel module - * @param module Module's pathname - * @param mod Module's elf object - * @param original_fname Original function's name - * @param evil_fname New function's name - * @return 0 on success, -1 on return - */ -int kernsh_infect_module_linux_2_6(char *module, elfshobj_t *mod, - char *original_fname, char *evil_fname) -{ - int ret, num, index, strindex, nbr, idx_init, idx_ninit, end, size; - elfshsect_t *sct, *gnu; - elfsh_Sym *table; - elfsh_Rel *rel, *cur; - u_int idx; - void *data; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = -1; - num = end = 0; - idx_init = idx_ninit = -1; - - memset(buff, '\0', sizeof(buff)); - -#if __DEBUG_KERNSH__ - printf("INFECT MODULE LINUX 2.6\n"); -#endif - - sct = elfsh_get_section_by_type(mod, - SHT_SYMTAB, 0, NULL, NULL, 0); - - if (sct == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get SYMTAB", -1); - } - - elfsh_get_symtab(mod, &num); - table = (elfsh_Sym *) (sct->data); - - if (table == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find data", -1); - } - - idx_init = get_symbol_idx(mod, table, num, original_fname); - - idx_ninit = get_symbol_idx(mod, table, num, evil_fname); - -#if __DEBUG_KERNSH__ - printf("idx_init %d\n", idx_init); - printf("idx_ninit %d\n", idx_ninit); -#endif - - if (idx_init == -1 || idx_ninit == -1) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol doesn't exist", -1); - } - - rel = elfsh_get_relent_by_name(mod, original_fname); - - gnu = elfsh_get_section_by_name(mod, - LIBKERNSH_STRING_REL_GNU, - &index, - &strindex, - &nbr); - if (gnu == NULL) - { - snprintf(buff, - sizeof(buff), - "Unable to open %s", - LIBKERNSH_STRING_REL_GNU); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - buff, -1); - } - - if (gnu->data == NULL) - gnu->data = elfsh_load_section(mod, gnu->shdr); - - size = gnu->shdr->sh_size / sizeof(elfsh_Rel); - - for (idx = 0; idx < size && !end; idx++) - { - data = elfsh_get_raw(gnu); - cur = (void *) ((elfsh_Rel *) data + idx); - if (elfsh_get_relsym(cur) == idx_init) - { - elfsh_set_relsym(cur, idx_ninit); - end = 1; - } - } - - if (end == 0) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol is not in reloc section", -1); - } - - elfsh_save_obj(mod, mod->name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Replace a function in a linux 2.4.X loadable kernel module - * @param module Module's pathname - * @param mod Module's elf object - * @param original_fname Original function's name - * @param evil_fname New function's name - * @return 0 on success, -1 on return - */ -int kernsh_infect_module_linux_2_4(char *module, elfshobj_t *mod, - char *original_fname, char *evil_fname) -{ - elfshsect_t *strtab; - elfsh_Sym *so; - int strindex; - int index; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_KERNSH__ - printf("INFECT MODULE LINUX 2.4\n"); -#endif - - if (strlen(original_fname) != strlen(evil_fname)) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Argument 2 has not the same lenght as arguement 3", -1); - } - - strtab = elfsh_get_section_by_name(mod, ".strtab", &index, &strindex, &nbr); - if (strtab == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find .strtab", -1); - } - - so = elfsh_get_symbol_by_name(mod, original_fname); - if (so == NULL) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find original function name", -1); - } - - elfsh_raw_write(mod, strtab->shdr->sh_offset + so->st_name, evil_fname, strlen(evil_fname)); - elfsh_save_obj(mod, mod->name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libkernsh/user/.svn/text-base/symbs.c.svn-base eresi-0.0.20110516/libkernsh/user/.svn/text-base/symbs.c.svn-base --- eresi-0.8a25/libkernsh/user/.svn/text-base/symbs.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/.svn/text-base/symbs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,307 +0,0 @@ -/* -** @file symbs.c -** @ingroup libkernsh_user -** -*/ -#include "libkernsh.h" -#include "libkernsh-info.h" - -#if __LINUX_2_4__ -#include -#endif - -/** - * @brief Get a symbol's address - * @param name Symbol's name - * @param addr Symbol's address - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_addr_by_name(char *name, unsigned long *addr, size_t size) -{ - int ret; - u_int dim[2]; - vector_t *symbs; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - symbs = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ADDRBYNAME); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(symbs, dim); - - ret = fct(name, addr, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get a symbol's name - * @param addr Symbol's address - * @param name Symbol's name - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_name_by_addr(unsigned long addr, char *name, size_t size) -{ - int ret; - u_int dim[2]; - vector_t *symbs; - int (*fct)(); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } - - symbs = aspect_vector_get(LIBKERNSH_VECTOR_NAME_NAMEBYADDR); - dim[0] = libkernshworld.arch; - dim[1] = libkernshworld.os; - - fct = aspect_vectors_select(symbs, dim); - - ret = fct(addr, name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get a symbol's address with kstrtab method, based on phalanx rootkit :) - * @param symbol Symbol's name - * @param addr Symbol's address - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_walk_kstrtab(const char *symbol, unsigned long *addr, size_t size) -{ - char srch[512]; - char tab[] = { '\0', '\xff' }; - unsigned long kstrtab, x, i; - int j; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - kstrtab = x = i = j = 0; - size += 2; - - memset(srch, '\0', sizeof(srch)); - memcpy (srch + 1, symbol, size); - srch[size] = '\0'; - - *addr = 0; - while(j < 2) - { - srch[0] = tab[j]; - for (x = 0, i = 0; - x < libkernshworld.kernel_end - libkernshworld.kernel_start; - x++, i++) - { - -#if __DEBUG_KERNSH__ - if (i % 500000 == 0) - write (1, "?", 1); - else if (i == 4000001) - { - write (1, "\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b", 24); - i = 0; - } -#endif - /* Ok we have find kstrtab_name */ - if(memcmp ((unsigned char *) (libkernshworld.ptr + x), - srch, - size) == 0) - { - kstrtab = libkernshworld.kernel_start + x + 1; - break; - } - } - j++; - srch[0] = tab[j]; - -#if __DEBUG_KERNSH__ - printf("kstrtab = 0x%.8lx\n", (unsigned long)kstrtab); -#endif - - if(kstrtab != 0) - { - /* Now we search ksymtab, paper street is not so far */ - for (x = 0, i = 0; - x < libkernshworld.kernel_end - libkernshworld.kernel_start; - x++, i++) - { -#if __DEBUG_KERNSH__ - if (i % 500000 == 0) - write (1, "?", 1); - else if(i == 4000001) - { - write (1, "\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b", 24); - i = 0; - } -#endif - /* We find ksymtab_name, uhm on some kernel the kstrtab - is present twice, so we keep the last */ - if (*(unsigned long *) (libkernshworld.ptr + x) == kstrtab) - { -#if __DEBUG_KERNSH__ - printf("ksymtab 0x%lx\n", (libkernshworld.kernel_start + x - sizeof(unsigned long))); -#endif - *addr = *(unsigned long *) (libkernshworld.ptr + x - sizeof(unsigned long)); - } - } - } - kstrtab = 0; - j++; - srch[0] = tab[j]; - } - - if (*addr != 0) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find symbol", -1); -} - -/** - * @brief Get a symbol's address on Linux 2.6.X - * @param name Symbol's name - * @param addr Symbol's address - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_addr_by_name_linux_2_6(char *name, unsigned long *addr, size_t size) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First, check if mmap is active, find a symbol by kstrtab */ - if(libkernshworld.mmap) - { - ret = kernsh_walk_kstrtab(name, addr, size); - /* We didn't find it, use lame system map:( */ - if(ret) - { - ret = kernsh_rresolve_systemmap(name, addr, size); - } - } - /* Else we use lame system map :( */ - else - { - ret = kernsh_rresolve_systemmap(name, addr, size); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get a symbol's name on Linux 2.6.X - * @param addr Symbol's address - * @param name Symbol's name - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_name_by_addr_linux_2_6(unsigned long addr, char *name, size_t size) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = kernsh_resolve_systemmap(addr, name, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get a symbol's address with kernel syms - * @param name Symbol's name - * @param addr Symbol's address - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_kernel_syms(char *name, unsigned long *addr, size_t size) -{ -#if defined(__linux__) -#if __LINUX_2_4__ - int i, numsyms; - struct kernel_sym tab_kernel_sym[8192]; -#endif -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(__linux__) -#if __LINUX_2_4__ - numsyms = get_kernel_syms(NULL); - if (numsyms < 0 || numsyms > 8192) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get symbol by get_kernel_syms", -1); - } - - get_kernel_syms(tab_kernel_sym); - - for (i = 0; i < numsyms; i++) - { - if (!strncmp(name, tab_kernel_sym[i].name, size)) - { - *addr = tab_kernel_sym[i].value; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } -#endif -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); -} - -/** - * @brief Get a symbol's address on Linux 2.4.X - * @param name Symbol's name - * @param addr Symbol's address - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_addr_by_name_linux_2_4(char *name, unsigned long *addr, size_t size) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = kernsh_get_kernel_syms(name, addr, size); - - if (ret) - ret = kernsh_rresolve_systemmap(name, addr, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * @brief Get a symbol's name on Linux 2.4.X - * @param addr Symbol's address - * @param name Symbol's name - * @param size Symbol's name size - * @return 0 on success, -1 on return - */ -int kernsh_get_name_by_addr_linux_2_4(unsigned long addr, char *name, size_t size) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = kernsh_resolve_systemmap(addr, name, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libkernsh/user/symbols/bin2hex.pl eresi-0.0.20110516/libkernsh/user/symbols/bin2hex.pl --- eresi-0.8a25/libkernsh/user/symbols/bin2hex.pl 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/bin2hex.pl 2011-05-16 11:34:49.000000000 +0000 @@ -25,27 +25,52 @@ open(FP , $ARGV[0]); # skip the 6 lines of information and get the function name while () { - $i++; - if ($i >= 6) { - ($function_name) = ($_ =~ /<([a-zA-Z0-9_]+)>/); - last; - } + + #print "BEG Zero loop \n"; + if ($_ =~ /<([a-zA-Z0-9_]+)>/) + { + ($function_name) = $1; + last; + } + + #print "Zero loop \n"; + } # get the opcodes -while () { +ITER: while () { + + #print "BEG First loop \n"; + ($op) = ($_ =~ /.*:\t([^\t]+)/); $op =~ s/[^a-z0-9]+$//g; + + #print "OP before: $op \n"; + + if ($op eq "") { next ITER; } + $op =~ s/ /\\x/g; + + #print "OP middle: $op \n"; + $op = "\\x".$op; + + #print "OP after: $op \n"; + $hex .= $op; -} + #print "First loop \n"; +} + # build the string $i = 0; $code = "#define ".uc($function_name)." \\\n"; $code .= " \""; + while ($hex) { + +# print "BEG Second loop with hex = $hex\n"; + ($op) = ($hex =~ /^(\\x[a-z0-9]+)/); $code .= $op; $hex =~ s/^(\\x[a-z0-9]+)//g; @@ -55,6 +80,9 @@ $i = 0; $code .= "\" \\\n \""; } + + # print "Second loop \n"; + } $code .= "\"\n\n"; print($code); diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/all-wcprops eresi-0.0.20110516/libkernsh/user/symbols/.svn/all-wcprops --- eresi-0.8a25/libkernsh/user/symbols/.svn/all-wcprops 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols -END -kmalloc.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/kmalloc.c -END -vfree.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/vfree.c -END -bin2hex.pl -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/bin2hex.pl -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/Makefile -END -kfree.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/kfree.c -END -vmalloc.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/930/trunk/libkernsh/user/symbols/vmalloc.c -END diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/entries eresi-0.0.20110516/libkernsh/user/symbols/.svn/entries --- eresi-0.8a25/libkernsh/user/symbols/.svn/entries 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libkernsh/user/symbols -http://svn.eresi-project.org/svn - - - -2008-03-25T08:32:13.270742Z -930 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -kmalloc.c -file - - - - -2008-04-06T23:15:28.069908Z -bb943185a373ba968f71eeab0c89db93 -2008-03-25T08:32:13.270742Z -930 -pouik - -vfree.c -file - - - - -2008-04-06T23:15:28.119877Z -ccc55b370ce421b012879d317d79659c -2008-03-25T08:32:13.270742Z -930 -pouik - -bin2hex.pl -file - - - - -2008-04-06T23:15:28.130175Z -1a80a308cdb51780e78925bd5e1088bb -2008-03-25T08:32:13.270742Z -930 -pouik -has-props - -Makefile -file - - - - -2008-04-06T23:15:28.142083Z -66c2a3e4c50873922f0f53320a8eb758 -2008-03-25T08:32:13.270742Z -930 -pouik - -kfree.c -file - - - - -2008-04-06T23:15:28.153276Z -a62774e3f540ce7116684190cf69f2cf -2008-03-25T08:32:13.270742Z -930 -pouik - -vmalloc.c -file - - - - -2008-04-06T23:15:28.164876Z -45c9c090b3188fa8e979af2276298cf4 -2008-03-25T08:32:13.270742Z -930 -pouik - diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/format eresi-0.0.20110516/libkernsh/user/symbols/.svn/format --- eresi-0.8a25/libkernsh/user/symbols/.svn/format 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/prop-base/bin2hex.pl.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/prop-base/bin2hex.pl.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/prop-base/bin2hex.pl.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/prop-base/bin2hex.pl.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/bin2hex.pl.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/bin2hex.pl.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/bin2hex.pl.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/bin2hex.pl.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -#!/usr/bin/perl - - -use strict; - - - -my $code = ""; -my $hex = ""; -my $i = 0; -my $op = ""; -my $function_name = ""; - - - -if ($#ARGV != 0) { - die("usage : ./bin2hex.pl \n"); -} - - - -if (! -e $ARGV[0]) { - die("[-] $!."); -} -open(FP , $ARGV[0]); -# skip the 6 lines of information and get the function name -while () { - $i++; - if ($i >= 6) { - ($function_name) = ($_ =~ /<([a-zA-Z0-9_]+)>/); - last; - } -} - -# get the opcodes -while () { - ($op) = ($_ =~ /.*:\t([^\t]+)/); - $op =~ s/[^a-z0-9]+$//g; - $op =~ s/ /\\x/g; - $op = "\\x".$op; - $hex .= $op; -} - -# build the string -$i = 0; -$code = "#define ".uc($function_name)." \\\n"; -$code .= " \""; -while ($hex) { - ($op) = ($hex =~ /^(\\x[a-z0-9]+)/); - $code .= $op; - $hex =~ s/^(\\x[a-z0-9]+)//g; - - $i++; - if ($i == 16) { - $i = 0; - $code .= "\" \\\n \""; - } -} -$code .= "\"\n\n"; -print($code); - - - diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/kfree.c.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/kfree.c.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/kfree.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/kfree.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -struct kfr_struct -{ - unsigned long ( * kfree )( const void * ); - const void * obj; -}; - -/* This function is called by syscall() */ -void kfree( struct kfr_struct * k ) -{ - /* kfr_struct.kfree contains the address of kfree symbol */ - /* kfr_struct.obj contains the address to be free */ - k->kfree( k->obj ); -} diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/kmalloc.c.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/kmalloc.c.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/kmalloc.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/kmalloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -struct kma_struct -{ - unsigned long ( * kmalloc )( unsigned int, int ); - int size; - int flags; - unsigned long mem; -}; - -/* This function is called by syscall() */ -void kmalloc( struct kma_struct * k ) -{ - /* kma_struct.kmalloc contains the address of kmalloc symbol */ - /* kma_struct.size contains the size to alloc (first arg) */ - /* kma_struct.flags contains the flags (twict arg ) */ - /* kma_struct.mem contains the return address of kmalloc */ - k->mem = ( unsigned long )k->kmalloc( k->size, k->flags ); -} diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -CC = gcc -CFLAGS = -Wall -LDFLAGS = -Wall -SRC_SYMBOLS = $(wildcard *.c) -ASM_SYMBOLS = $(wildcard *.s) -OBJ_SYMBOLS = $(SRC_SYMBOLS:.c=.o) $(ASM_SYMBOLS:.s=.o) -DIS_SYMBOLS = $(OBJ_SYMBOLS:.o=.dis) - -INCLUDE_SYMBOLS = "../../include/libkernsh-symbols.h" - -all: $(DIS_SYMBOLS) - @echo "" > $(INCLUDE_SYMBOLS) - @echo "#ifndef __LIBKERNSH_SYMBOLS_H__" >> $(INCLUDE_SYMBOLS) - @echo "#define __LIBKERNSH_SYMBOLS_H__" >> $(INCLUDE_SYMBOLS) - @echo "" >> $(INCLUDE_SYMBOLS) - @for file in $^; do ./bin2hex.pl $$file >> $(INCLUDE_SYMBOLS); done - @echo "#endif" >> $(INCLUDE_SYMBOLS) - -%.dis: %.o - @objdump -d $< > $@ - @rm $< - -%.o: %.s - @nasm -f elf -g $< - -%.o: %.c - @$(CC) -c $< -o $@ $(CFLAGS) - -clean: - rm -rf *.o *.dis diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/vfree.c.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/vfree.c.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/vfree.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/vfree.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -struct vfr_struct -{ - unsigned long ( * vfree )( void * ); - void * obj; -}; - -/* This function is called by syscall() */ -void vfree( struct vfr_struct * v ) -{ - /* vfr_struct.vfree contains the address of vfree symbol */ - /* vfr_struct.obj contains the address to be free */ - v->vfree( v->obj ); -} diff -Nru eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/vmalloc.c.svn-base eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/vmalloc.c.svn-base --- eresi-0.8a25/libkernsh/user/symbols/.svn/text-base/vmalloc.c.svn-base 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbols/.svn/text-base/vmalloc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,15 +0,0 @@ -struct vma_struct -{ - unsigned long ( * vmalloc )( unsigned int ); - int size; - unsigned long mem; -}; - -/* This function is called by syscall() */ -void vmalloc( struct vma_struct * v ) -{ - /* vma_struct.vmalloc contains the address of vmalloc symbol */ - /* vma_struct.size contains the size to alloc (first arg) */ - /* vma_struct.mem contains the return address of vmalloc */ - v->mem = ( unsigned long )v->vmalloc( v->size ); -} diff -Nru eresi-0.8a25/libkernsh/user/symbs.c eresi-0.0.20110516/libkernsh/user/symbs.c --- eresi-0.8a25/libkernsh/user/symbs.c 2008-04-06 23:15:28.000000000 +0000 +++ eresi-0.0.20110516/libkernsh/user/symbs.c 2011-05-16 11:34:50.000000000 +0000 @@ -1,6 +1,6 @@ -/* -** @file symbs.c -** @ingroup libkernsh_user +/** +* @file libkernsh/user/symbs.c +** @ingroup usermode ** */ #include "libkernsh.h" @@ -17,9 +17,9 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_addr_by_name(char *name, unsigned long *addr, size_t size) +int kernsh_get_addr_by_name(char *name, eresi_Addr *addr, size_t size) { - int ret; + int ret; u_int dim[2]; vector_t *symbs; int (*fct)(); @@ -27,19 +27,15 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!libkernshworld.open) - { - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Memory not open !", -1); - } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Memory not open !", -1); symbs = aspect_vector_get(LIBKERNSH_VECTOR_NAME_ADDRBYNAME); dim[0] = libkernshworld.arch; dim[1] = libkernshworld.os; fct = aspect_vectors_select(symbs, dim); - ret = fct(name, addr, size); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -50,9 +46,9 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_name_by_addr(unsigned long addr, char *name, size_t size) +int kernsh_get_name_by_addr(eresi_Addr addr, char *name, size_t size) { - int ret; + int ret; u_int dim[2]; vector_t *symbs; int (*fct)(); @@ -83,7 +79,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_walk_kstrtab(const char *symbol, unsigned long *addr, size_t size) +int kernsh_walk_kstrtab(const char *symbol, eresi_Addr *addr, size_t size) { char srch[512]; char tab[] = { '\0', '\xff' }; @@ -181,7 +177,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_addr_by_name_linux_2_6(char *name, unsigned long *addr, size_t size) +int kernsh_get_addr_by_name_linux_2_6(char *name, eresi_Addr *addr, size_t size) { int ret; @@ -213,7 +209,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_name_by_addr_linux_2_6(unsigned long addr, char *name, size_t size) +int kernsh_get_name_by_addr_linux_2_6(eresi_Addr addr, char *name, size_t size) { int ret; @@ -231,7 +227,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_kernel_syms(char *name, unsigned long *addr, size_t size) +int kernsh_get_kernel_syms(char *name, eresi_Addr *addr, size_t size) { #if defined(__linux__) #if __LINUX_2_4__ @@ -274,7 +270,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_addr_by_name_linux_2_4(char *name, unsigned long *addr, size_t size) +int kernsh_get_addr_by_name_linux_2_4(char *name, eresi_Addr *addr, size_t size) { int ret; @@ -295,7 +291,7 @@ * @param size Symbol's name size * @return 0 on success, -1 on return */ -int kernsh_get_name_by_addr_linux_2_4(unsigned long addr, char *name, size_t size) +int kernsh_get_name_by_addr_linux_2_4(eresi_Addr addr, char *name, size_t size) { int ret; diff -Nru eresi-0.8a25/libmjollnir/bin/elfThor.c eresi-0.0.20110516/libmjollnir/bin/elfThor.c --- eresi-0.8a25/libmjollnir/bin/elfThor.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/elfThor.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,7 +1,7 @@ /* * (C) 2006-2007 Asgard Labs, thorolf * BSD License - * $Id: elfThor.c,v 1.8 2007-02-26 17:47:15 thor Exp $ + * $Id: elfThor.c 1311 2009-01-14 20:36:48Z may $ * */ #include @@ -78,11 +78,11 @@ } */ - mjr_setup_processor(&sess); + mjr_setup_processor(&sess, NULL); if (opt_A) { - mjr_analyse(&sess,NULL); + mjr_analyse(&sess,NULL, 0); printf("seen: %d found %d\n", sess.cur->calls_seen, sess.cur->calls_found); diff -Nru eresi-0.8a25/libmjollnir/bin/Makefile eresi-0.0.20110516/libmjollnir/bin/Makefile --- eresi-0.8a25/libmjollnir/bin/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/Makefile 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,8 @@ +SRCS = elfThor.c +OBJS =$(SRCS:.c=.o) +NAME = elfThor +CFLAGS=`eresi-config libmjollnir --cflags` +LDFLAGS=`eresi-config libmjollnir --libs` + +all: $(OBJS) + $(CC) -o $(NAME) $(OBJS) $(LDFLAGS) diff -Nru eresi-0.8a25/libmjollnir/bin/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/bin/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/bin/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/460/trunk/libmjollnir/bin -END -elfThor.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/460/trunk/libmjollnir/bin/elfThor.c -END diff -Nru eresi-0.8a25/libmjollnir/bin/.svn/entries eresi-0.0.20110516/libmjollnir/bin/.svn/entries --- eresi-0.8a25/libmjollnir/bin/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/bin -http://svn.eresi-project.org/svn - - - -2007-02-26T17:47:15.000000Z -460 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -elfThor.c -file - - - - -2008-04-06T23:16:30.777888Z -e05d2697f3c4e084f80183baff69cdfa -2007-02-26T17:47:15.000000Z -460 -thor - diff -Nru eresi-0.8a25/libmjollnir/bin/.svn/format eresi-0.0.20110516/libmjollnir/bin/.svn/format --- eresi-0.8a25/libmjollnir/bin/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/bin/.svn/text-base/elfThor.c.svn-base eresi-0.0.20110516/libmjollnir/bin/.svn/text-base/elfThor.c.svn-base --- eresi-0.8a25/libmjollnir/bin/.svn/text-base/elfThor.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/bin/.svn/text-base/elfThor.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,111 +0,0 @@ -/* - * (C) 2006-2007 Asgard Labs, thorolf - * BSD License - * $Id: elfThor.c,v 1.8 2007-02-26 17:47:15 thor Exp $ - * - */ -#include - -void usage() -{ - printf("./elfThor [-AR -o -d " - "-r ] -i \n\n" - "\t -A \t - perform analyse \n" - "\t -R \t - rebuild symtab \n" - "\t -d \t - delete symbol \n" - "\t -r \t - rename symbol \n" - "\t -o \t - output file \n"); -} - - -int main(int ac, char **av) -{ - mjrsession_t sess; - char *infile,*outfile, *delsym, *rensym; - int opt_R, opt_A, nr; - - opt_R = opt_A = 0; - infile = outfile = delsym = rensym = NULL; - - while ((nr = getopt(ac, av, "i:o:ARd:r:")) != -1) - { - switch(nr) - { - case 'i': - infile = optarg; - break; - case 'A': - opt_A = 1; - break; - case 'R': - opt_R = 1; - opt_A = 1; - break; - case 'o': - outfile = optarg; - break; - case 'd': - delsym = optarg; - break; - case 'r': - rensym = optarg; - break; - default: - usage(); - return 1; - break; - } - } - - if (!infile) - { - usage(); - return 1; - } - - if (!mjr_init_session(&sess)) - { - printf("mjrInitSession faild.\n"); - exit(1); - } - - mjr_create_context_as_current(&sess, elfsh_map_obj(infile)); - - /* - if (sess->cur->obj == NULL) { - printf("elfsh_map_obj faild.\n"); - exit(1); - } - */ - - mjr_setup_processor(&sess); - - if (opt_A) - { - mjr_analyse(&sess,NULL); - printf("seen: %d found %d\n", - sess.cur->calls_seen, - sess.cur->calls_found); - } - - if (opt_R) - mjr_symtab_rebuild(&sess); - - /* just for tests */ - if (delsym && mjr_symbol_delete_by_name(&sess,delsym)) - printf("deleted %s\n",delsym); - - if (rensym) - { - char *o,*n,*brk; - o = strtok_r(rensym, ":", &brk); - n = strtok_r(NULL, ":", &brk); - printf("Rename %s -> %s\n", o, n); - mjr_symbol_rename(&sess,o,n); - } - - if (outfile) - elfsh_save_obj(sess.cur->obj,outfile); - - return 0; -} diff -Nru eresi-0.8a25/libmjollnir/doc/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/doc/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/doc/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/896/trunk/libmjollnir/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/896/trunk/libmjollnir/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libmjollnir/doc/.svn/entries eresi-0.0.20110516/libmjollnir/doc/.svn/entries --- eresi-0.8a25/libmjollnir/doc/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/doc -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:16:30.470137Z -b9ab3533ee227635a902a1b7d288493d -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/libmjollnir/doc/.svn/format eresi-0.0.20110516/libmjollnir/doc/.svn/format --- eresi-0.8a25/libmjollnir/doc/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libmjollnir/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libmjollnir/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libmjollnir - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = src/ include/ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libmjollnir/ - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/libmjollnir/include/libmjollnir.h eresi-0.0.20110516/libmjollnir/include/libmjollnir.h --- eresi-0.8a25/libmjollnir/include/libmjollnir.h 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/libmjollnir.h 2011-05-16 11:34:47.000000000 +0000 @@ -1,13 +1,14 @@ /** - * @file libmjollnir.h + * @defgroup libmjollnir libmjollnir: The control-flow analysis and fingerprinting library. + */ +/** + * @file libmjollnir/include/libmjollnir.h + * @ingroup libmjollnir + * @brief The libmjollnir header file. * - * (C) Devhell Labs / Asgard Labs 2001-2007 - * - * $id: Libmjollnir.H,V 1.8 2006/07/27 16:50:48 thor Exp $ - * - * December 2006 : Merged the modflow API and the mjollnir API to make a - * unified component. Adapted the data structures. Unified prefixing. -may + * The ERESI project (c) Devhell / Asgard labs * + * $Id: libmjollnir.h 1440 2010-12-29 02:22:03Z may $ */ #if !defined(__MJOLLNIR__) @@ -31,6 +32,11 @@ #define MJR_MAX_INCREMENTS 200 /** + * @brief How much bytes will we recursively read at once during analysis ? + */ +#define MJR_MAX_BLOCK_SIZE 200 + +/** * @brief Input and Output links */ #define CONTAINER_LINK_IN 0 @@ -47,13 +53,16 @@ */ #define MJR_CONFIG_BLOC_PREFIX "mjr.bloc_prefix" #define MJR_CONFIG_FUNC_PREFIX "mjr.func_prefix" +#define MJR_CONFIG_LINK_PREFIX "mjr.link_prefix" + #define MJR_CONFIG_BLOC_POSTFIX "mjr.bloc_postfix" /** * @brief Default subroutines prefix in symbol recovery */ -#define MJR_FUNC_PREFIX "sub_" +#define MJR_FUNC_PREFIX "func_" #define MJR_BLOC_PREFIX "bloc_" +#define MJR_LINK_PREFIX "link_" #define MJR_BLOC_POSTFIX "_unseen" /** @@ -68,29 +77,36 @@ #define MJR_FPRINT_TYPE_MD5 0 /** - * @brief The hash declared in VM for gotos + * @brief Analysis of unlimited depth */ -extern hash_t goto_hash; +#define MJR_MAX_DEPTH 1 +#define MJR_BLOCK_INVALID ((eresi_Addr) -1) +#define MJR_BLOCK_EXIST ((eresi_Addr) -2) +#define MJR_MIN(x, y) ((x > y ? y : x)) /* init.c */ int mjr_init_session(mjrsession_t *); int mjr_create_context_as_current(mjrsession_t *, elfshobj_t *); mjrcontext_t *mjr_create_context(elfshobj_t *); -int mjr_setup_processor(mjrsession_t *); +int mjr_setup_processor(mjrsession_t *, asm_processor *proc); +int mjr_set_current_context(mjrsession_t *sess, char *name); +int mjr_del_context(mjrsession_t *sess, char *name); /* core.c */ -int mjr_analyse(mjrsession_t *sess, eresi_Addr addr, int flags); -int mjr_analyse_section(mjrsession_t *s, char *sectname); -int mjr_analyse_finished(mjrsession_t *sess); +int mjr_analyse(mjrsession_t *sess, eresi_Addr addr, int maxdepth, int flags); +int mjr_analyse_rec(mjrsession_t *sess, eresi_Addr vaddr, int curd, int maxd); +int mjr_analyse_finished(mjrsession_t *sess); +int mjr_analysed(mjrsession_t *sess, eresi_Addr addr); +void mjr_analyse_destroy(mjrcontext_t *ctx); /* blocks.c */ int mjr_blocks_get(mjrcontext_t *ctxt); -container_t* mjr_block_get_by_vaddr(mjrcontext_t *ctxt, eresi_Addr, int); +container_t* mjr_block_get_by_vaddr(mjrcontext_t *ctxt, eresi_Addr, int); int mjr_block_point(mjrcontext_t*, asm_instr*, eresi_Addr, eresi_Addr); char *_vaddr2str(eresi_Addr); int mjr_block_relink_cond_always(container_t *, container_t *, int); int mjr_block_dump(mjrcontext_t*, container_t *); -int mjr_block_symbol(mjrcontext_t*, container_t*, eresi_Addr curaddr, u_char resize); +int mjr_block_symbol(mjrcontext_t*, container_t*); /* fingerprint.c */ int mjr_block_funcstart(container_t *cntnr); @@ -104,8 +120,9 @@ void mjr_funcs_display(mjrcontext_t *c); /* cfg.c */ -int mjr_trace_control(mjrcontext_t *c, elfshobj_t *, - asm_instr *, eresi_Addr a); +int mjr_trace_control(mjrcontext_t *context, container_t *curblock, + elfshobj_t *obj, asm_instr *curins, eresi_Addr curvaddr, + eresi_Addr *dstaddr, eresi_Addr *retaddr); eresi_Addr mjr_compute_fctptr(mjrcontext_t *context); eresi_Addr mjr_get_jmp_destaddr(mjrcontext_t *context); eresi_Addr mjr_get_call_destaddr(mjrcontext_t *context); @@ -133,7 +150,7 @@ int mjr_link_block_call(mjrcontext_t *, eresi_Addr, eresi_Addr, eresi_Addr); int mjr_link_block_jump(mjrcontext_t *, eresi_Addr, eresi_Addr, eresi_Addr); int mjr_link_func_call(mjrcontext_t *ctxt, eresi_Addr src, eresi_Addr dst, eresi_Addr ret); -container_t *mjr_block_split(mjrcontext_t *ctxt, eresi_Addr dst, u_int link_with); +container_t *mjr_block_split(mjrcontext_t *ctxt, eresi_Addr dst, u_char link_with); /* history.c */ void mjr_history_shift(mjrcontext_t *cur, asm_instr i, eresi_Addr a); @@ -160,7 +177,8 @@ mjrlink_t *mjr_container_add_link(mjrcontext_t *ctxt, container_t *cntnr, u_int id, - int link_type, + u_char link_type, + u_char link_scope, int link_direction); /* findentry.c */ diff -Nru eresi-0.8a25/libmjollnir/include/libmjollnir-int.h eresi-0.0.20110516/libmjollnir/include/libmjollnir-int.h --- eresi-0.8a25/libmjollnir/include/libmjollnir-int.h 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/libmjollnir-int.h 2011-05-16 11:34:47.000000000 +0000 @@ -1,7 +1,9 @@ /** - * @file libmjollnir-int.h + * @file libmjollnir/include/libmjollnir-int.h + * @ingroup libmjollnir + * @{ * (C) 2006-2008 Asgard Labs, thorolf - * BSD License + * 2008-2010 ERESI Team * */ @@ -25,10 +27,11 @@ #define D_DESC stderr #define mjrHashVerySmall 64 -#define mjrHashSmall 1024 -#define mjrHashMedium 10240 -#define mjrHashLarge 102400 -#define mjrHahsXXL 1024000 +#define mjrHashSmall 1024 +#define mjrHashMedium 10240 +#define mjrHashLarge 102400 +#define mjrHahsXXL 1024000 #define MJR_MAX_FUNCTION_LEN 1024000 +/** @} */ diff -Nru eresi-0.8a25/libmjollnir/include/libmjollnir-objects.h eresi-0.0.20110516/libmjollnir/include/libmjollnir-objects.h --- eresi-0.8a25/libmjollnir/include/libmjollnir-objects.h 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/libmjollnir-objects.h 2011-05-16 11:34:47.000000000 +0000 @@ -1,11 +1,12 @@ -/** - * @file libmjollnir-objects.h - * +/** +* @file libmjollnir/include/libmjollnir-objects.h + * @ingroup libmjollnir + * @{ * 2001-2007 Devhell Labs, Asgardlabs * * @brief All structures of libmjollnir * - * $Id: libmjollnir-objects.h,v 1.4 2008-02-16 12:32:27 thor Exp $ + * $Id: libmjollnir-objects.h 1397 2009-09-13 02:19:08Z may $ * */ #if !defined(__MJR_BLOCKS__) @@ -27,7 +28,7 @@ eresi_Addr vaddr; /* !< @brief block starting virtual address */ u_int size; /* !< @brief block code size */ u_int symoff; /* !< @brief block name offset in string table */ - u_char seen; /* !< @brief block live status (0 means dead) */ + u_char seen; /* !< @brief block live status (0 or 1) */ } mjrblock_t; /** @@ -57,15 +58,20 @@ we hope to do any shape analysis in ERESI */ typedef struct s_link { -#define MJR_LINK_FUNC_CALL 0 /* !< @brief a call between functions */ -#define MJR_LINK_FUNC_RET 1 /* !< @brief a function returning control */ -#define MJR_LINK_BLOCK_COND_TRUE 2 /* !< @brief 'true' condition of a branch */ -#define MJR_LINK_BLOCK_COND_FALSE 3 /* !< @brief 'false' condition of a branch */ -#define MJR_LINK_BLOCK_COND_ALWAYS 4 /* !< @brief uncoditional branch */ -#define MJR_LINK_TYPE_DELAY 5 /* !< @brief generally ignored but useful */ -#define MJR_LINK_UNKNOWN 6 /* !< @brief unknown type */ unsigned int id; - int type; +#define MJR_LINK_FUNC_CALL 0 /* !< @brief A call between functions */ +#define MJR_LINK_FUNC_RET 1 /* !< @brief A returning control */ +#define MJR_LINK_FUNC_SLIDE 2 /* !< @brief A new stack frame happening in the middle */ +#define MJR_LINK_BLOCK_COND_TRUE 3 /* !< @brief 'true' condition of a branch */ +#define MJR_LINK_BLOCK_COND_FALSE 4 /* !< @brief 'false' condition of a branch */ +#define MJR_LINK_BLOCK_COND_ALWAYS 5 /* !< @brief uncoditional branch */ +#define MJR_LINK_TYPE_DELAY 6 /* !< @brief generally ignored but useful */ +#define MJR_LINK_UNKNOWN 7 /* !< @brief unknown type */ + u_char type; +#define MJR_LINK_SCOPE_UNKNOWN 0 /* !< @brief Link type is unknown */ +#define MJR_LINK_SCOPE_LOCAL 1 /* !< @brief Link within the current parent object */ +#define MJR_LINK_SCOPE_GLOBAL 2 /* !< @brief Link outside the current parent object */ + u_char scope; } mjrlink_t; @@ -85,16 +91,19 @@ typedef struct _mjrContext { elfshobj_t *obj; /* !< @brief ELF binary object */ - elfshsect_t *cursct; /* !< @brief Current analysed section */ asm_processor proc; /* !< @brief ASM processor */ + container_t *curblock; /* !< @brief Current working block */ container_t *curfunc; /* !< @brief Current working function */ + list_t *func_stack; /* !< @brief Stack of analyzed functions */ + container_t **reg_containers; /* !< @brief Registered containers */ btree_t *block_btree; /* !< @brief Blocks Binary tree (speedup parent search) */ u_int cntnrs_size; /* !< @brief Size of current containers */ u_int next_id; /* !< @brief Next free container id */ #define MJR_HISTORY_LEN 5 +#define MJR_HISTORY_PPPREV (MJR_HISTORY_LEN - 4) #define MJR_HISTORY_PPREV (MJR_HISTORY_LEN - 3) #define MJR_HISTORY_PREV (MJR_HISTORY_LEN - 2) #define MJR_HISTORY_CUR (MJR_HISTORY_LEN - 1) @@ -102,7 +111,10 @@ hash_t funchash; /* !< @brief functions hash table */ hash_t blkhash; /* !< @brief blocks hash table for this obj */ - unsigned char analysed; /* !< @brief do we analysed it */ + hash_t linkhash; /* !< @brief links hash table */ + hash_t goto_hash; /* !< @brief manual gotos hash table */ + + //unsigned char analysed; /* !< @brief do we analysed it */ u_int calls_seen; /* !< @brief how many CALL we have seen */ u_int calls_found; /* !< @brief how many dest has beed resolved */ } mjrcontext_t; @@ -153,3 +165,5 @@ #endif + +/** @} */ diff -Nru eresi-0.8a25/libmjollnir/include/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/include/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/include/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/946/trunk/libmjollnir/include -END -libmjollnir.h -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/946/trunk/libmjollnir/include/libmjollnir.h -END -libmjollnir-objects.h -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/946/trunk/libmjollnir/include/libmjollnir-objects.h -END -libmjollnir-int.h -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/900/trunk/libmjollnir/include/libmjollnir-int.h -END diff -Nru eresi-0.8a25/libmjollnir/include/.svn/entries eresi-0.0.20110516/libmjollnir/include/.svn/entries --- eresi-0.8a25/libmjollnir/include/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libmjollnir.h -file - - - - -2008-04-06T23:16:30.363147Z -49c5b841ca2361b76f825bd831ad24f4 -2008-03-27T22:53:48.747992Z -946 -may - -libmjollnir-objects.h -file - - - - -2008-04-06T23:16:30.384151Z -e1254687cc287bf14f57fad469189688 -2008-03-27T22:53:48.747992Z -946 -may - -libmjollnir-int.h -file - - - - -2008-04-06T23:16:30.395152Z -bf52bb6b7a76b6bc10969c043de0d06f -2008-03-09T02:28:00.261745Z -900 -thorkill - diff -Nru eresi-0.8a25/libmjollnir/include/.svn/format eresi-0.0.20110516/libmjollnir/include/.svn/format --- eresi-0.8a25/libmjollnir/include/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir.h.svn-base eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir.h.svn-base --- eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir.h.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -/** - * @file libmjollnir.h - * - * (C) Devhell Labs / Asgard Labs 2001-2007 - * - * $id: Libmjollnir.H,V 1.8 2006/07/27 16:50:48 thor Exp $ - * - * December 2006 : Merged the modflow API and the mjollnir API to make a - * unified component. Adapted the data structures. Unified prefixing. -may - * - */ - -#if !defined(__MJOLLNIR__) - #define __MJOLLNIR__ 1 - -#ifndef __KERNEL__ -#include -#include -#include -#endif - -#include "libelfsh.h" -#include "libasm.h" -#include "libmjollnir-objects.h" -#include "libmjollnir-int.h" - -/** - * @brief Some defined values for containers array - */ -#define MJR_CNTNRS_INCREMENT 200 -#define MJR_MAX_INCREMENTS 200 - -/** - * @brief Input and Output links - */ -#define CONTAINER_LINK_IN 0 -#define CONTAINER_LINK_OUT 1 - -/** - * @brief Size of temp buffers - */ -#define BSIZE_SMALL 32 -#define BSIZE 4096 - -/** - * @brief Names used in config hash - */ -#define MJR_CONFIG_BLOC_PREFIX "mjr.bloc_prefix" -#define MJR_CONFIG_FUNC_PREFIX "mjr.func_prefix" -#define MJR_CONFIG_BLOC_POSTFIX "mjr.bloc_postfix" - -/** - * @brief Default subroutines prefix in symbol recovery - */ -#define MJR_FUNC_PREFIX "sub_" -#define MJR_BLOC_PREFIX "bloc_" -#define MJR_BLOC_POSTFIX "_unseen" - -/** - * @brief OS for which we are able to match the entry point - */ -#define MJR_BIN_LINUX 0 -#define MJR_BIN_FREEBSD 1 - -/** - * @brief Fingerprinting types - */ -#define MJR_FPRINT_TYPE_MD5 0 - -/** - * @brief The hash declared in VM for gotos - */ -extern hash_t goto_hash; - -/* init.c */ -int mjr_init_session(mjrsession_t *); -int mjr_create_context_as_current(mjrsession_t *, elfshobj_t *); -mjrcontext_t *mjr_create_context(elfshobj_t *); -int mjr_setup_processor(mjrsession_t *); - -/* core.c */ -int mjr_analyse(mjrsession_t *sess, eresi_Addr addr, int flags); -int mjr_analyse_section(mjrsession_t *s, char *sectname); -int mjr_analyse_finished(mjrsession_t *sess); - -/* blocks.c */ -int mjr_blocks_get(mjrcontext_t *ctxt); -container_t* mjr_block_get_by_vaddr(mjrcontext_t *ctxt, eresi_Addr, int); -int mjr_block_point(mjrcontext_t*, asm_instr*, eresi_Addr, eresi_Addr); -char *_vaddr2str(eresi_Addr); -int mjr_block_relink_cond_always(container_t *, container_t *, int); -int mjr_block_dump(mjrcontext_t*, container_t *); -int mjr_block_symbol(mjrcontext_t*, container_t*, eresi_Addr curaddr, u_char resize); - -/* fingerprint.c */ -int mjr_block_funcstart(container_t *cntnr); -int mjr_fingerprint(mjrcontext_t*, container_t*, int, int, - int, int, int, int (*fprint)(container_t*)); - -/* display.c */ -int mjr_blocks_display(mjrcontext_t *c, int); -int mjr_block_display(mjrcontext_t *, container_t *c, mjropt_t *opt); -void mjr_function_display(mjrfunc_t *func); -void mjr_funcs_display(mjrcontext_t *c); - -/* cfg.c */ -int mjr_trace_control(mjrcontext_t *c, elfshobj_t *, - asm_instr *, eresi_Addr a); -eresi_Addr mjr_compute_fctptr(mjrcontext_t *context); -eresi_Addr mjr_get_jmp_destaddr(mjrcontext_t *context); -eresi_Addr mjr_get_call_destaddr(mjrcontext_t *context); -int mjr_asm_check_function_start(mjrcontext_t *ctxt); - -/* symtab.c */ -int mjr_symtab_rebuild(mjrsession_t *); -int mjr_symbol_add(mjrsession_t *, eresi_Addr, char *); -int mjr_symbol_delete_by_name(mjrsession_t *, char *); -int mjr_symbol_rename(mjrsession_t *,char *,char *); - -/* function.c */ -void *mjr_fingerprint_function(mjrcontext_t *, eresi_Addr addr, int); -void mjr_function_dump(mjrcontext_t*, char *,container_t *); -int mjr_functions_get(mjrcontext_t *); -int mjr_function_register(mjrcontext_t *, u_int, container_t *); -container_t *mjr_function_get_by_vaddr(mjrcontext_t *, u_int); -int mjr_function_symbol(mjrcontext_t*, container_t *); - -/* ondisk.c */ -int mjr_flow_load(mjrcontext_t *c, u_int datatypeid); -int mjr_flow_store(mjrcontext_t *c, u_int datatypeid); - -/* link.c */ -int mjr_link_block_call(mjrcontext_t *, eresi_Addr, eresi_Addr, eresi_Addr); -int mjr_link_block_jump(mjrcontext_t *, eresi_Addr, eresi_Addr, eresi_Addr); -int mjr_link_func_call(mjrcontext_t *ctxt, eresi_Addr src, eresi_Addr dst, eresi_Addr ret); -container_t *mjr_block_split(mjrcontext_t *ctxt, eresi_Addr dst, u_int link_with); - -/* history.c */ -void mjr_history_shift(mjrcontext_t *cur, asm_instr i, eresi_Addr a); -void mjr_history_write(mjrcontext_t*, asm_instr*, eresi_Addr a, int i); - -/* container.c */ -int mjr_init_containers(mjrcontext_t*); -int mjr_resize_containers(mjrcontext_t*, u_int resize); -unsigned int mjr_register_container (mjrcontext_t*, container_t *cntnr); -unsigned int mjr_register_container_id (mjrcontext_t*, container_t *cntnr); -void mjr_unregister_container(mjrcontext_t*, u_int id); -container_t *mjr_lookup_container (mjrcontext_t*,u_int id); -container_t *mjr_get_container_by_vaddr(mjrcontext_t*, eresi_Addr vaddr, int type); -list_t *mjr_link_get_by_direction(container_t *c, int dir); -mjrlink_t *mjr_get_link_by_type(list_t *listlink, int link_type); -int mjr_create_container_linklist(container_t *cur, u_int linktype); -container_t *mjr_create_block_container(mjrcontext_t*, u_int symoff, eresi_Addr v, u_int s, u_char); -container_t *mjr_create_function_container(mjrcontext_t*, - eresi_Addr vaddr, - u_int size, - char *name, - mjrblock_t *first, - char *md5); -mjrlink_t *mjr_container_add_link(mjrcontext_t *ctxt, - container_t *cntnr, - u_int id, - int link_type, - int link_direction); - -/* findentry.c */ -eresi_Addr mjr_trace_start(mjrcontext_t *c, u_char *, u_int, eresi_Addr); -eresi_Addr mjr_find_main(elfshobj_t *obj, - asm_processor *proc, - u_char *buf, - u_int len, - eresi_Addr vaddr, - u_int *dis); - - -#endif diff -Nru eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir-int.h.svn-base eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir-int.h.svn-base --- eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir-int.h.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir-int.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * @file libmjollnir-int.h - * (C) 2006-2008 Asgard Labs, thorolf - * BSD License - * - */ - -#define __DEBUG_MJOLLNIR__ 0 -#define __DEBUG_CALLS__ 0 -#define __DEBUG_READ__ 0 -#define __DEBUG_PTR__ 0 -#define __DEBUG_OPERAND__ 0 -#define __DEBUG_BLOCKS__ 0 -#define __DEBUG_BLK_LOOKUP__ 0 -#define __DEBUG_FLOW__ 0 -#define __DEBUG_CNTNR__ 0 -#define __DEBUG_CNTNR_LOOKUP__ 0 -#define __DEBUG_FUNCS__ 0 -#define __DEBUG_FUCNS_LOOKUP__ 0 -#define __DEBUG_FNG__ 0 -#define __DEBUG_ONDISK__ 0 -#define __DEBUG_LINKS__ 0 - -/* Debug descriptor */ -#define D_DESC stderr - -#define mjrHashVerySmall 64 -#define mjrHashSmall 1024 -#define mjrHashMedium 10240 -#define mjrHashLarge 102400 -#define mjrHahsXXL 1024000 - -#define MJR_MAX_FUNCTION_LEN 1024000 - diff -Nru eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir-objects.h.svn-base eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir-objects.h.svn-base --- eresi-0.8a25/libmjollnir/include/.svn/text-base/libmjollnir-objects.h.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/include/.svn/text-base/libmjollnir-objects.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,155 +0,0 @@ -/** - * @file libmjollnir-objects.h - * - * 2001-2007 Devhell Labs, Asgardlabs - * - * @brief All structures of libmjollnir - * - * $Id: libmjollnir-objects.h,v 1.4 2008-02-16 12:32:27 thor Exp $ - * - */ -#if !defined(__MJR_BLOCKS__) - #define __MJR_BLOCKS__ 1 - -#include "libelfsh.h" - -#define MJR_BLOCK_GET_STRICT 0 -#define MJR_BLOCK_GET_FUZZY 1 - -/* XXX: Change size in libaspect/types.c if this struct is changed */ -/* XXX: Always let the vaddr and size field in first for the next 2 structures !!!! */ - -/** - * @brief Structure used to describe blocks in memory - */ -typedef struct s_iblock -{ - eresi_Addr vaddr; /* !< @brief block starting virtual address */ - u_int size; /* !< @brief block code size */ - u_int symoff; /* !< @brief block name offset in string table */ - u_char seen; /* !< @brief block live status (0 means dead) */ -} mjrblock_t; - -/** - * @brief Structure used to described functions in memory - */ -typedef struct s_function -{ - eresi_Addr vaddr; /* !< @brief Function virtual address */ - u_int size; /* !< @brief Function size */ - char name[64]; /* !< @brief Function name */ - mjrblock_t *first; /* !< @brief First function block */ - char md5[34]; /* !< @brief MD5 Checksum */ -} mjrfunc_t; - - -/* - * struct s_link is to reference links between functions or blocks - * field type may help us to analyse blocks to build higher - * logical structures. It contains : - * - * - a type field specifying which kind of link this is - * - an id field to reference the destination container of this link - * - a pointer to the next link in this list of links - */ - -/* XXX: the type field has to be changed for a real eresi type id if - we hope to do any shape analysis in ERESI */ -typedef struct s_link -{ -#define MJR_LINK_FUNC_CALL 0 /* !< @brief a call between functions */ -#define MJR_LINK_FUNC_RET 1 /* !< @brief a function returning control */ -#define MJR_LINK_BLOCK_COND_TRUE 2 /* !< @brief 'true' condition of a branch */ -#define MJR_LINK_BLOCK_COND_FALSE 3 /* !< @brief 'false' condition of a branch */ -#define MJR_LINK_BLOCK_COND_ALWAYS 4 /* !< @brief uncoditional branch */ -#define MJR_LINK_TYPE_DELAY 5 /* !< @brief generally ignored but useful */ -#define MJR_LINK_UNKNOWN 6 /* !< @brief unknown type */ - unsigned int id; - int type; -} mjrlink_t; - - - -/** - * @brief An history entry - */ -typedef struct s_history -{ - eresi_Addr vaddr; - asm_instr instr; -} mjrhistory_t; - -/** - * @brief The context of a single session -*/ -typedef struct _mjrContext -{ - elfshobj_t *obj; /* !< @brief ELF binary object */ - elfshsect_t *cursct; /* !< @brief Current analysed section */ - asm_processor proc; /* !< @brief ASM processor */ - container_t *curblock; /* !< @brief Current working block */ - container_t *curfunc; /* !< @brief Current working function */ - container_t **reg_containers; /* !< @brief Registered containers */ - btree_t *block_btree; /* !< @brief Blocks Binary tree (speedup parent search) */ - u_int cntnrs_size; /* !< @brief Size of current containers */ - u_int next_id; /* !< @brief Next free container id */ - -#define MJR_HISTORY_LEN 5 -#define MJR_HISTORY_PPREV (MJR_HISTORY_LEN - 3) -#define MJR_HISTORY_PREV (MJR_HISTORY_LEN - 2) -#define MJR_HISTORY_CUR (MJR_HISTORY_LEN - 1) - mjrhistory_t hist[MJR_HISTORY_LEN]; /* !< @brief History of instructions */ - - hash_t funchash; /* !< @brief functions hash table */ - hash_t blkhash; /* !< @brief blocks hash table for this obj */ - unsigned char analysed; /* !< @brief do we analysed it */ - u_int calls_seen; /* !< @brief how many CALL we have seen */ - u_int calls_found; /* !< @brief how many dest has beed resolved */ -} mjrcontext_t; - - -/** - * @brief The session structure. Yes, libmjollnir is multisession - */ -typedef struct s_session -{ - mjrcontext_t *cur; - hash_t ctx; -} mjrsession_t; - - -/** - * @brief Control flow dump options - */ -typedef struct s_disopt -{ - elfshobj_t *file; - u_int counter; - int level; -} mjropt_t; - -/* Mjollnir buffer */ -typedef struct s_buf -{ - char *data; - u_int maxlen; - u_int allocated; - u_int counter; - elfshobj_t *obj; -} mjrbuf_t; - - -/***** That structure is not used yet ******/ -/* Abstract representation for a condition */ -typedef struct s_condition -{ -#define CONDITION_SIGNED -#define CONDITION_UNSIGNED - int sign; - char *dst; - char *src; - char *cmp; -} mjrcond_t; - - -#endif diff -Nru eresi-0.8a25/libmjollnir/Makefile eresi-0.0.20110516/libmjollnir/Makefile --- eresi-0.8a25/libmjollnir/Makefile 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/Makefile 2011-05-16 11:34:47.000000000 +0000 @@ -3,13 +3,12 @@ # # (C) 2001-2006 - Devhell Labs / Asgard Labs (sk, jfv, thorolf) # -# BSD License -# + include ../config.h SRC = src/blocks.c src/core.c src/history.c src/init.c src/symtab.c \ src/findentry.c src/cfg.c src/fingerprint.c src/display.c src/links.c \ - src/ondisk.c src/function.c src/container.c + src/ondisk.c src/function.c src/container.c src/destroy.c OBJ = ${SRC:.c=.o} OBJ32 = ${SRC:.c=.32.o} @@ -24,19 +23,17 @@ NAME32 = libmjollnir32 NAME64 = libmjollnir64 -CFLAGS32 = -fPIC -I./include/ -I../libasm/include/ \ - -I../libelfsh/include/ -I../libhash/include/ -I../libaspect/include \ - -Wall -DERESI32 -DELFSH_INTERN -g3 - -CFLAGS64 = -fPIC -I./include/ -I../libasm/include/ \ - -I../libelfsh/include/ -I../libhash/include/ -I../libaspect/include \ - -Wall -DERESI64 -DELFSH_INTERN -g3 +CFLAGS32 = -fPIC -I./include/ -I../libasm/include/ -I../libelfsh/include/ \ + -I../libaspect/include -Wall -DERESI32 -g3 $(EXTRACFLAGS) + +CFLAGS64 = -fPIC -I./include/ -I../libasm/include/ -I../libelfsh/include/ \ + -I../libaspect/include -Wall -DERESI64 -g3 $(EXTRACFLAGS) LDFLAGS32 = -L. -L../libasm/ -L../libelfsh/ -L../liballocproxy \ - -L../libaspect/ -lelfsh32 -laspect32 -lasm -lallocproxy $(LPTHREAD) + -L../libaspect/ -lelfsh32 -laspect32 -lasm32 -lallocproxy $(LPTHREAD) LDFLAGS64 = -L. -L../libasm/ -L../libelfsh/ -L../liballocproxy \ - -L../libaspect/ -lelfsh64 -laspect64 -lasm -lallocproxy $(LPTHREAD) + -L../libaspect/ -lelfsh64 -laspect64 -lasm64 -lallocproxy $(LPTHREAD) all : all32 all64 diff -Nru eresi-0.8a25/libmjollnir/src/blocks.c eresi-0.0.20110516/libmjollnir/src/blocks.c --- eresi-0.8a25/libmjollnir/src/blocks.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/blocks.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,17 +1,12 @@ -/* -** @file libmjollnir/src/blocks.c -** -** Authors : sk, jfv, thorkill, strauss -** -** Started : Thu May 29 20:39:14 2003 sk -** Updated : Fri Dec 15 01:09:47 2006 jfv -** -*/ +/** +* @file libmjollnir/src/blocks.c + * @ingroup libmjollnir + * @{ + * Authors : sk, jfv, thorkill, strauss + * + */ #include "libmjollnir.h" -/* Goto hash */ -hash_t goto_hash; - /** * @brief Retreive control flow section content if any @@ -22,14 +17,14 @@ { elfshsect_t *sect; int cnt; - + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Parse arguments, load binary and resolve symbol */ + + /* Parse arguments, load binary and resolve symbol */ sect = elfsh_get_section_by_name(ctxt->obj, ELFSH_SECTION_NAME_EDFMT_BLOCKS, 0, 0, 0); if (!sect) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow section : use analyse command", 0); + "No control flow section : use analyse command", 0); /* Retreive information */ cnt = hash_size(&ctxt->blkhash); @@ -40,8 +35,9 @@ /* Return result */ if (cnt != 0) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flow analysis failed", -1); + "Flow analysis failed", -1); } @@ -100,7 +96,7 @@ ret->id); #endif - if ((tmpblock->vaddr <= vaddr) && (vaddr <= tmpblock->vaddr + tmpblock->size)) + if ((tmpblock->vaddr <= vaddr) && (vaddr < tmpblock->vaddr + tmpblock->size)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); if (tmpblock->vaddr < vaddr) @@ -156,29 +152,38 @@ * @param resize 1 if current block size has to be computed from the value of curaddr * @return Always 0 */ -int mjr_block_symbol(mjrcontext_t *ctxt, container_t *csrc, - eresi_Addr curaddr, u_char resize) +int mjr_block_symbol(mjrcontext_t *ctxt, container_t *csrc) { mjrblock_t *block; elfsh_Sym bsym; elfsh_Sym *sym; char *prefix; char buffer[BUFSIZ]; + int off; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Insert new block symbol */ + off = 0; block = (mjrblock_t *) csrc->data; prefix = (char *) config_get_data(MJR_CONFIG_BLOC_PREFIX); - if (resize) - block->size = curaddr - block->vaddr + asm_instr_len(&ctxt->hist[MJR_HISTORY_CUR].instr); - snprintf(buffer, sizeof(buffer), "%s"AFMT, prefix, block->vaddr); sym = elfsh_get_symbol_by_name(ctxt->obj, buffer); if (!sym) { + off = ctxt->obj->secthash[ELFSH_SECTION_SYMTAB]->shdr->sh_size; bsym = elfsh_create_symbol(block->vaddr, block->size, STT_BLOCK, 0, 0, 0); elfsh_insert_symbol(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, buffer); + elfsh_sync_sorted_symtab(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB]); } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +#if __DEBUG_BLOCKS__ + else + printf(" [D] Block symbol %s was already inserted ! \n", + elfsh_get_symbol_name(ctxt->obj, sym)); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, off); } + +/** @} */ + diff -Nru eresi-0.8a25/libmjollnir/src/cfg.c eresi-0.0.20110516/libmjollnir/src/cfg.c --- eresi-0.8a25/libmjollnir/src/cfg.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/cfg.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,16 +1,14 @@ -/* -** (C) 2006-2008 Devhell Labs / Asgard Labs -** - sk, jfv, thorolf, strauss -** -** @file libmjollnir/types.c -** -** @brief Functions that use the typed instructions information in libasm -** -*/ +/** + * @file libmjollnir/src/cfg.c + * (C) 2006-2010 The ERESI team + * @ingroup libmjollnir + * + * @brief Top-level functions for control-flow analysis + * + */ #include "libmjollnir.h" - -/** +/** * @brief This function trace execution flow and creates block depending on instruction. * * If instruction break execution flow, block is considerated finished and added @@ -22,22 +20,27 @@ * ASM_TYPE_CALLPROC: calls break instruction flow but CAN restore it * ASM_TYPE_IMPBRANCH, ASM_TYPE_RETPROC: jmp and ret break execution flow * + * UPDATE: ASM_TYPE_IMPBRANCH and ASM_TYPE_CONDBRANCH are now ASM_TYPE_BRANCH and + * (ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL) + * * The last two types reset g_prevaddr as execution flow won't be restored * to following instruction. * * FIXME : this function must be tested on other architectures - * + * @ingroup libmjollnir */ -int mjr_trace_control(mjrcontext_t *context, +int mjr_trace_control(mjrcontext_t *context, + container_t *curblock, elfshobj_t *obj, asm_instr *curins, - eresi_Addr curvaddr) + eresi_Addr curvaddr, + eresi_Addr *dstaddr, + eresi_Addr *retaddr) { int ilen; - container_t *fun; - eresi_Addr dstaddr; - eresi_Addr retaddr; + container_t *bloc; u_int addend; + elfshsect_t *sect; /* Initialize stuffs */ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -45,107 +48,139 @@ mjr_history_write(context, curins, curvaddr, MJR_HISTORY_CUR); mjr_history_write(context, curins, curvaddr, 0); ilen = asm_instr_len(curins); - fun = mjr_function_get_by_vaddr(context, curvaddr); - if (fun) - context->curfunc = fun; - else - mjr_asm_check_function_start(context); - fun = NULL; + + /* It might be that we are reaching the beginning of an existing bloc */ + bloc = mjr_block_get_by_vaddr(context, curvaddr, MJR_BLOCK_GET_STRICT); + if (bloc && bloc->id != curblock->id) + { + *dstaddr = MJR_BLOCK_EXIST; + *retaddr = MJR_BLOCK_INVALID; + mjr_container_add_link(context, curblock, bloc->id, MJR_LINK_BLOCK_COND_ALWAYS, + MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(context, bloc, curblock->id, MJR_LINK_BLOCK_COND_ALWAYS, + MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); + +#if __DEBUG_FLOW__ + fprintf(stderr, " [D] Found contiguous block ! stopping this recursion branch ******** \n"); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + //mjr_asm_check_function_start(context); /* Switch on instruction types provided by libasm */ - if (curins->type & ASM_TYPE_CONDBRANCH) + if ((curins->type & ASM_TYPE_BRANCH) && (curins->type & ASM_TYPE_CONDCONTROL)) { - dstaddr = mjr_get_jmp_destaddr(context); + /* Conditional branch */ + /* MIPS use delay slots for jump instructions too */ + addend = (context->proc.type == ASM_PROC_MIPS || + context->proc.type == ASM_PROC_SPARC ? 4 : 0); + + *dstaddr = mjr_get_jmp_destaddr(context); #if __DEBUG_FLOW__ - fprintf(D_DESC, - "[D] %s: " XFMT " ASM_TYPE_CONDBRANCH T:" XFMT - " F:" XFMT"\n", __FUNCTION__, curvaddr, dstaddr, curvaddr + ilen); + fprintf(D_DESC, + "[D] %s:%d " XFMT " ASM_TYPE_BRANCH | ASM_TYPE_CONDCONTROL T:" XFMT + " F:" XFMT"\n", __FUNCTION__, __LINE__, + curvaddr, *dstaddr, curvaddr + ilen + addend); #endif - if (dstaddr != -1) - mjr_link_block_jump(context, curvaddr, dstaddr, curvaddr + ilen); - + *retaddr = curvaddr + ilen + addend; + mjr_link_block_jump(context, curvaddr, *dstaddr, *retaddr); } - else if (curins->type == ASM_TYPE_IMPBRANCH) + else if ((curins->type & ASM_TYPE_BRANCH) && !(curins->type & ASM_TYPE_CONDCONTROL)) { - dstaddr = mjr_get_jmp_destaddr(context); + /* Imperative branch */ + *dstaddr = mjr_get_jmp_destaddr(context); #if __DEBUG_FLOW__ fprintf(D_DESC, - "[D] mjr_asm_flow: " XFMT " ASM_TYPE_IMPBRANCH T:" XFMT - " F: NULL \n", curvaddr, dstaddr); + "[D] mjr_asm_flow: " XFMT " ASM_TYPE_BRANCH T:" XFMT + " F: NULL \n", curvaddr, *dstaddr); #endif - - if (dstaddr != (eresi_Addr) -1) - mjr_link_block_jump(context, curvaddr, dstaddr, 0); - + + if (*dstaddr != MJR_BLOCK_INVALID) + mjr_link_block_jump(context, curvaddr, *dstaddr, MJR_BLOCK_INVALID); } + else if (curins->type & ASM_TYPE_CALLPROC) { - dstaddr = mjr_get_call_destaddr(context); + *dstaddr = mjr_get_call_destaddr(context); #if __DEBUG_FLOW__ fprintf(D_DESC, - "[D] %s: " XFMT " ASM_TYPE_CALLPROC T:" XFMT - " F:" XFMT "\n", __FUNCTION__, curvaddr, dstaddr, curvaddr + ilen); + "[D] %s:%d " XFMT " ASM_TYPE_CALLPROC T:" XFMT + " F:" XFMT "\n", __FUNCTION__, __LINE__, + curvaddr, *dstaddr, curvaddr + ilen); #endif context->calls_seen++; - - /* For delay slot */ - addend = (context->proc.type == ASM_PROC_SPARC ? 4 : 0); - + + /* SPARC and MIPS use delay slots */ + addend = (context->proc.type == ASM_PROC_SPARC || context->proc.type == ASM_PROC_MIPS ? 4 : 0); + /* If call occured at the end of a section */ - if (curvaddr + ilen + addend >= context->cursct->shdr->sh_size + context->cursct->shdr->sh_addr) + sect = elfsh_get_parent_section(context->obj, curvaddr + ilen + addend, NULL); + if (!sect) { + #if __DEBUG_FLOW__ - fprintf(D_DESC,"[W] %s: unusual retaddr found - expected ret:%x section end:%x\n", - __FUNCTION__, curvaddr + ilen + addend, context->cursct->shdr->sh_size + context->cursct->shdr->sh_addr); + fprintf(D_DESC,"[W] *** %s: unusual retaddr found - expected ret: " + XFMT" section end is below this address. ***\n", + __FUNCTION__, curvaddr + ilen + addend); #endif - - retaddr = NULL; + + *retaddr = MJR_BLOCK_INVALID; } else - retaddr = curvaddr + ilen + addend; + *retaddr = curvaddr + ilen + addend; - /* 20070102 - * FIXME: we should be able to resolve CALL 0x0 (dstaddr == 0), - * Possible libasm or mjollnir bug. - */ - if (dstaddr && dstaddr != (eresi_Addr) -1) - { - /* Link block layer */ - mjr_link_block_call(context, curvaddr, dstaddr, retaddr); + /* Link block layer */ + mjr_link_block_call(context, curvaddr, *dstaddr, *retaddr); - /* Link function layer */ - mjr_link_func_call(context, curvaddr, dstaddr, retaddr); + /* Link function layer */ + if (*dstaddr != MJR_BLOCK_INVALID) + { + mjr_link_func_call(context, curvaddr, *dstaddr, *retaddr); context->calls_found++; - } + } } - else if (curins->type == ASM_TYPE_RETPROC) + else if (curins->type & ASM_TYPE_RETPROC) { - + if (context->func_stack->elmnbr > 1) + { + context->curfunc = elist_pop(context->func_stack); + #if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: " XFMT " ASM_TYPE_RETPROC\n", - __FUNCTION__, curvaddr); + fprintf(D_DESC, " *********** CURFUNC RET @ " XFMT " : to %s ******** \n", + curvaddr, (context->curfunc && context->curfunc->data ? + ((mjrfunc_t *) context->curfunc->data)->name : "NULL")); #endif + } + +#if __DEBUG_FLOW__ + else + fprintf(D_DESC, " *********** RET @ " XFMT " : NO RET FROM %s ******** \n", + curvaddr, (context->curfunc && context->curfunc->data ? + ((mjrfunc_t *) context->curfunc->data)->name : "NULL")); +#endif + } + +#if __DEBUG_FLOW__ else { -#if __DEBUG_FLOW__ fprintf(D_DESC,"[D] %s: CUR: %x DEFAULT %d\n", __FUNCTION__, curvaddr, curins->type); -#endif } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - +#endif + /* Return the delay slot size if any */ + addend = (context->proc.type == ASM_PROC_MIPS || + context->proc.type == ASM_PROC_SPARC ? 4 : 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, addend); +} /** * @brief Support function pointers computations @@ -167,7 +202,8 @@ * ... * 804936c: ff d2 call *%edx * - * FIXME : this function must be ported to the SPARC architecture + * FIXME : this function must be ported to other architectures + * @ingroup libmjollnir */ eresi_Addr mjr_compute_fctptr(mjrcontext_t *context) { @@ -185,8 +221,8 @@ /* Specific pattern (simple one) */ /* As we dont do any real dataflow analysis yet, we dont handle automatically - complex case where addresses are constructed in a complex way */ - + cases where target addresses are constructed in a complex way */ + /* TOO NAIVE EVEN FOR THE SIMPLEST CASE. -- DISABLE if (context->hist[MJR_HISTORY_CUR].instr.instr == ASM_CALL && context->hist[MJR_HISTORY_PREV].instr.instr == ASM_MOV && context->hist[MJR_HISTORY_PPREV].instr.instr == ASM_MOV) @@ -200,7 +236,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid target vaddr for function pointer", - (eresi_Addr) -1); + MJR_BLOCK_INVALID); } #if __DEBUG_MJOLLNIR__ @@ -208,31 +244,31 @@ (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, (unsigned long) dest, (unsigned long) dest); #endif - + printf(" [*] RESOLVED function pointer called from 0x%08lx -> 0x%08lx \n", (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, (unsigned long) dest); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); } + */ /* Instead we have a hash table that we can add element to using the 'addgoto' command of elfsh. That allow to tell which is the target address manually - and make the graph continuous even with complex address construction */ - + and connect two graphs even with complex address construction */ /* Happens when an address was manually inserted in the routing table */ /* This allow to avoid the control flow graph to be broken if elfsh is not capable to recompute the target address */ /* So the keys for this hash tables are the vaddr of the instruction that does the complex function pointer call */ - ret = (char *) hash_get(&goto_hash, tmp); + ret = (char *) hash_get(&context->goto_hash, tmp); if (!ret) { printf(" [*] UNABLE to resolve function pointer called from 0x%08lx\n", (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to compute function pointer target", (eresi_Addr) -1); + "Unable to compute function pointer target", MJR_BLOCK_INVALID); } dest = strtol(ret, (char **) NULL, 16); @@ -255,150 +291,300 @@ /** * @brief Resolve the destination address of current call * @param context mjorllnir context strucutre + * @ingroup libmjollnir */ -eresi_Addr mjr_get_call_destaddr(mjrcontext_t *context) +eresi_Addr mjr_get_call_destaddr(mjrcontext_t *context) { - int ilen; - eresi_Addr dest; - asm_instr *ins; + int ilen; + eresi_Addr dest; + asm_instr *ins; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); dest = 0; ins = &context->hist[MJR_HISTORY_CUR].instr; - - if (context->proc.type == ASM_PROC_IA32) - { - /* The target block is called directly */ - if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) - { - ilen = asm_instr_len(ins); - asm_operand_get_immediate(ins, 1, 0, &dest); - dest += ilen + context->hist[MJR_HISTORY_CUR].vaddr; - } - /* The target block is called indirectly : if we find a pattern that correspond - to an easy to predict function pointer, then we compute it */ - else if (ins->op[0].content & ASM_OP_BASE) - dest = mjr_compute_fctptr(context); - else - dest = -1; - } - else if (context->proc.type == ASM_PROC_SPARC) - { - if (ins->instr == ASM_SP_CALL) - { - if (ins->op[0].content & ASM_SP_OTYPE_DISP30) - { - dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; - } - else /* Indirect call (special case of JMPL) */ - dest = -1; + + switch (context->proc.type) + { + + /* INTEL architecture */ + case ASM_PROC_IA32: + + /* The target block is called directly */ + if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) + { + ilen = asm_instr_len(ins); + asm_operand_get_immediate(ins, 1, 0, &dest); + dest = asm_dest_resolve(&context->proc, context->hist[MJR_HISTORY_CUR].vaddr, (dest + ilen)); + } + /* The target block is called indirectly : if we find a pattern that correspond + to an easy to predict function pointer, then we compute it */ + else if (ins->op[0].content & ASM_OP_BASE) + dest = mjr_compute_fctptr(context); + else + dest = MJR_BLOCK_INVALID; + break; + + /* SPARC architecture */ + case ASM_PROC_SPARC: + if (ins->instr == ASM_SP_CALL) + { + if (ins->op[0].content & ASM_SP_OTYPE_DISP30) + dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; + else /* Indirect call (special case of JMPL) */ + dest = MJR_BLOCK_INVALID; + } + break; + + /* MIPS architecture */ + case ASM_PROC_MIPS: + switch (ins->instr) + { + case ASM_MIPS_JAL: + dest = (ins->op[0].imm << 2) | + ((((context->hist[MJR_HISTORY_CUR].vaddr + 8) >> 28) & 0xF) << 28); + break; + case ASM_MIPS_JALR: + dest = MJR_BLOCK_INVALID; + break; + case ASM_MIPS_BAL: + dest = (context->hist[MJR_HISTORY_CUR].vaddr + (((short) ins->op[0].imm + 1) * 4)); + break; + default: + dest = (context->hist[MJR_HISTORY_CUR].vaddr + (((short) ins->op[1].imm + 1) * 4)); + break; + } + break; + + /* ARM architecture */ + case ASM_PROC_ARM: + if (!(ins->type & ASM_TYPE_INDCONTROL)) + /* BLX(1) & BL */ + dest = asm_dest_resolve_arm(context->hist[MJR_HISTORY_CUR].vaddr, ins->op[0].imm, + (ins->op[0].content == ASM_ARM_OTYPE_DISP_HALF) ? 1 : 0); + else + /* Call to register */ + /* BLX(2) */ + dest = MJR_BLOCK_INVALID; + break; + + /* Unknown architecture */ + default: + dest = MJR_BLOCK_INVALID; } - } - else - dest = -1; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); } + /** * @brief Resolve the destination address of current jmp instruction * @param context mjollnir context structure + * @ingroup libmjollnir */ eresi_Addr mjr_get_jmp_destaddr(mjrcontext_t *context) { int ilen; eresi_Addr dest; asm_instr *ins; + unsigned int i; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); dest = 0; ins = &context->hist[MJR_HISTORY_CUR].instr; - if (context->proc.type == ASM_PROC_IA32) - { - /* The target block is called directly */ - if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) - { - ilen = asm_instr_len(ins); - asm_operand_get_immediate(ins, 1, 0, &dest); - dest += ilen + context->hist[MJR_HISTORY_CUR].vaddr; - } - - /* The target block is called indirectly : if we find a pattern that correspond + switch (context->proc.type) + { + + /* INTEL architecture */ + case ASM_PROC_IA32: + + /* The target block is called directly */ + if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) + { + ilen = asm_instr_len(ins); + asm_operand_get_immediate(ins, 1, 0, &dest); + dest = asm_dest_resolve(&context->proc, context->hist[MJR_HISTORY_CUR].vaddr, (dest + ilen)); + } + + /* The target block is called indirectly : if we find a pattern that correspond to an easy to predict function pointer, then we compute it */ - else if (ins->op[0].content & ASM_OP_BASE) - dest = mjr_compute_fctptr(context); - else - dest = -1; - } - else if (context->proc.type == ASM_PROC_SPARC) - { - if (ins->instr & ASM_SP_JMPL) /* Indirect jump */ - { - dest = -1; - } - else if (ins->type & ASM_TYPE_CONDBRANCH) - { - dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; - } - } - else - dest = -1; + else if (ins->op[0].content & ASM_OP_BASE) + dest = mjr_compute_fctptr(context); + else + dest = MJR_BLOCK_INVALID; + break; + + /* SPARC architecture */ + case ASM_PROC_SPARC: + /* + if (ins->instr & ASM_SP_JMPL) //Indirect jump + { + printf("INDIRECT BRANCH TYPE FOR SPARC at addr "XFMT" ! \n", + context->hist[MJR_HISTORY_CUR].vaddr); + dest = MJR_BLOCK_INVALID; + } + */ + if (ins->type & ASM_TYPE_BRANCH) + /* Imperative or conditional branch */ + dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; + else + { + fprintf(stderr, " [D] UNKNOWN BRANCH FOR SPARC at addr "XFMT" ! \n", + context->hist[MJR_HISTORY_CUR].vaddr); + dest = MJR_BLOCK_INVALID; + } + break; + + /* MIPS architecture */ + case ASM_PROC_MIPS: + i = 0; + if ( (ins->instr & ASM_MIPS_BEQ) || (ins->instr & ASM_MIPS_BEQL) + || (ins->instr & ASM_MIPS_BNE) || (ins->instr & ASM_MIPS_BNEL) ) + i = 2; + else if ( (ins->instr & ASM_MIPS_BGEZAL) || (ins->instr & ASM_MIPS_BGEZALL) + || (ins->instr & ASM_MIPS_BGEZ) || (ins->instr & ASM_MIPS_BGEZL) + || (ins->instr & ASM_MIPS_BGTZ) || (ins->instr & ASM_MIPS_BGTZL) + || (ins->instr & ASM_MIPS_BLEZ) || (ins->instr & ASM_MIPS_BLEZL) + || (ins->instr & ASM_MIPS_BLTZAL) || (ins->instr & ASM_MIPS_BLTZALL) + || (ins->instr & ASM_MIPS_BLTZ) || (ins->instr & ASM_MIPS_BLTZL) ) + i = 1; + if (ins->op[i].type & ASM_MIPS_OTYPE_BRANCH) + dest = (context->hist[MJR_HISTORY_CUR].vaddr + (((short)ins->op[i].imm+1) * 4)); + else if (ins->op[i].type & ASM_MIPS_OTYPE_JUMP) + dest = (ins->op[i].imm << 2) | + ((((context->hist[MJR_HISTORY_CUR].vaddr + 8) >> 28) & 0xF) << 28); + else + dest = MJR_BLOCK_INVALID; /* Jump to register - not yet */ + break; + + /* ARM architecture */ + case ASM_PROC_ARM: + if (!(ins->type & ASM_TYPE_INDCONTROL)) + { + if (ins->op[0].content == ASM_ARM_OTYPE_REGISTER) + { + if ((ins->instr >= ASM_ARM_MVNEQ && ins->instr <= ASM_ARM_MVNS)) + /* MVN */ + dest = ~ins->op[1].imm; + else + /* MOV */ + dest = ins->op[1].imm; + } + else + /* B */ + dest = asm_dest_resolve_arm(context->hist[MJR_HISTORY_CUR].vaddr, ins->op[0].imm, 0); + } + else + /* Jump to register */ + dest = MJR_BLOCK_INVALID; + + break; + + /* Unknown architecture */ + default: + dest = MJR_BLOCK_INVALID; + } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); } + + /** * @brief Check if we missed some function start * @param ctxt mjollnir context structure + * @todo to remove ? + * @ingroup libmjollnir */ + +/** @} */ + +/* int mjr_asm_check_function_start(mjrcontext_t *ctxt) { char *tmpstr; - u_int tmpaddr; - container_t *fun; + eresi_Addr tmpaddr; + container_t *fun; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* check function prologue */ - if (ctxt->proc.type == ASM_PROC_IA32) - { - if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SUB && - ctxt->hist[MJR_HISTORY_PREV].instr.instr == ASM_MOV && - ctxt->hist[MJR_HISTORY_PPREV].instr.instr == ASM_PUSH) - { - tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_PPREV].vaddr); - tmpaddr = ctxt->hist[MJR_HISTORY_PPREV].vaddr; - -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: function start found at %x for %x\n", - __FUNCTION__, ctxt->hist[MJR_HISTORY_CUR].vaddr, tmpaddr); -#endif - fun = mjr_create_function_container(ctxt, tmpaddr, 0, tmpstr, NULL, NULL); - mjr_function_register(ctxt, tmpaddr, fun); - ctxt->curfunc = mjr_function_get_by_vaddr(ctxt, tmpaddr); - } - } - else if (ctxt->proc.type == ASM_PROC_SPARC) - { - if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SP_SAVE && - ctxt->hist[MJR_HISTORY_CUR].instr.op[0].baser == ASM_REG_O6 && - ctxt->hist[MJR_HISTORY_CUR].instr.op[1].type == ASM_SP_OTYPE_IMMEDIATE && - ctxt->hist[MJR_HISTORY_CUR].instr.op[2].baser == ASM_REG_O6) + //check function prologue + //FIXME: does not support function without frame pointer or without local variables, + //- check func-without-fp signature + //- check if history contains a call to us (to detect small functions) + switch (ctxt->proc.type) + { + + //IA32 architecture + case ASM_PROC_IA32: + if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SUB && + ctxt->hist[MJR_HISTORY_PREV].instr.instr == ASM_MOV && + ctxt->hist[MJR_HISTORY_PPREV].instr.instr == ASM_PUSH) + { + tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_PPREV].vaddr); + tmpaddr = ctxt->hist[MJR_HISTORY_PPREV].vaddr; + goto finish; + } + break; + + //SPARC architecture + case ASM_PROC_SPARC: + if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SP_SAVE && + ctxt->hist[MJR_HISTORY_CUR].instr.op[0].baser == ASM_REG_O6 && + ctxt->hist[MJR_HISTORY_CUR].instr.op[1].type == ASM_SP_OTYPE_IMMEDIATE && + ctxt->hist[MJR_HISTORY_CUR].instr.op[2].baser == ASM_REG_O6) { tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_CUR].vaddr); tmpaddr = ctxt->hist[MJR_HISTORY_CUR].vaddr; + goto finish; + } + break; + + //MIPS architecture + case ASM_PROC_MIPS: + if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_MIPS_SD && + ctxt->hist[MJR_HISTORY_PREV].instr.instr == ASM_MIPS_ADDIU && + ctxt->hist[MJR_HISTORY_PREV].instr.op[0].baser == ASM_MIPS_REG_SP) + { + tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_PREV].vaddr); + tmpaddr = ctxt->hist[MJR_HISTORY_PREV].vaddr; + //goto finish; + + } + break; + + default: + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Unsupported architecture in libmjollnir", -1); + } + + //Nothing to declare + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + //We found a prolog + finish: #if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: function start found at %x for %x\n", - __FUNCTION__, ctxt->hist[MJR_HISTORY_CUR].vaddr, tmpaddr); + fprintf(D_DESC," [D] FUNCTION START FOUND at "XFMT" for "XFMT" \n", + ctxt->hist[MJR_HISTORY_CUR].vaddr, tmpaddr); #endif + + fun = mjr_function_get_by_vaddr(ctxt, tmpaddr); + if (!fun) + { + fun = mjr_create_function_container(ctxt, tmpaddr, 0, tmpstr, NULL, NULL); + mjr_function_register(ctxt, tmpaddr, fun); + mjr_function_symbol(ctxt, fun); + mjr_container_add_link(ctxt, ctxt->curfunc, fun->id, + MJR_LINK_FUNC_SLIDE, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + elist_push(ctxt->func_stack, fun); + ctxt->curfunc = fun; + fprintf(stderr, " ******* ALLOCATED STACKFRAME IN MIDDLE OF FUNC at "XFMT" \n", tmpaddr); + fprintf(stderr, " **** -> NOW NEW CURFUNC @ %s \n", ((mjrfunc_t *) fun->data)->name); + } - fun = mjr_create_function_container(ctxt, tmpaddr, 0, tmpstr, NULL, NULL); - mjr_function_register(ctxt, tmpaddr, fun); - ctxt->curfunc = mjr_function_get_by_vaddr(ctxt, tmpaddr); - } - } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } +*/ + diff -Nru eresi-0.8a25/libmjollnir/src/container.c eresi-0.0.20110516/libmjollnir/src/container.c --- eresi-0.8a25/libmjollnir/src/container.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/container.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,7 +1,8 @@ /** - * 2001-2007 Devhell Labs, Rfdslabs, Asgardlabs + * 2001-2008 Devhell Labs, Rfdslabs, Asgardlabs * - * @file container.c +* @file libmjollnir/src/container.c + * @ingroup libmjollnir * @brief An API for generic containers data structures * */ @@ -118,14 +119,15 @@ mjrlink_t *mjr_container_add_link(mjrcontext_t *ctx, container_t *cntnr, unsigned int id, - int link_type, + u_char link_type, + u_char link_scope, int link_direction) { list_t *linklist; listent_t *listent; listent_t *savednext; mjrlink_t *link; - container_t *cnt; + container_t *cnt; char linkname[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -168,8 +170,8 @@ { #if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: removing old link id:%d from type:%d to %d\n", - __FUNCTION__,id, link->type,link_type); + fprintf(D_DESC,"[D] %s: removing old unconditional link id:%d for condlink type %d\n", + __FUNCTION__, id, link_type); #endif elist_del(linklist, listent->key); @@ -186,8 +188,10 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__, link, sizeof(mjrlink_t), NULL); link->id = id; link->type = link_type; - snprintf(linkname, sizeof(linkname), "link_%u", id); + link->scope = link_scope; + snprintf(linkname, sizeof(linkname), "%u_%u", cntnr->id, id); elist_add(linklist, strdup(linkname), link); + hash_add(&ctx->linkhash, strdup(linkname), link); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, link); } @@ -259,7 +263,7 @@ newblock->vaddr = vaddr; newblock->size = size; newblock->seen = seen; - newcntnr = container_create(ASPECT_TYPE_BLOC, newblock, NULL, NULL); + newcntnr = container_create(ASPECT_TYPE_BLOC, newblock, NULL, NULL, ctx->obj->id); if (!newcntnr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to create block container", NULL); @@ -318,7 +322,7 @@ __FUNCTION__, vaddr, name, size, md5); #endif - newcntnr = container_create(ASPECT_TYPE_FUNC, newfunction, NULL, NULL); + newcntnr = container_create(ASPECT_TYPE_FUNC, newfunction, NULL, NULL, ctx->obj->id); if (!newcntnr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to create function container", NULL); @@ -338,7 +342,8 @@ PROFILER_IN(__FILE__,__FUNCTION__,__LINE__); - for (idx = 1, cur = ctx->reg_containers[idx]; cur; cur = ctx->reg_containers[++idx]) + for (idx = 1, cur = ctx->reg_containers[idx]; cur && idx < ctx->next_id; + cur = ctx->reg_containers[++idx]) if (cur->type == type && *(eresi_Addr *) cur->data == vaddr) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cur); diff -Nru eresi-0.8a25/libmjollnir/src/core.c eresi-0.0.20110516/libmjollnir/src/core.c --- eresi-0.8a25/libmjollnir/src/core.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/core.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,339 +1,340 @@ -/* -** (C) 2006-2008 The ERESI team -** -** @file core.c -** @brief Implement low-level functions of the libmjollnir library -** -*/ - +/** + * @file libmjollnir/src/core.c + * @ingroup libmjollnir + * @brief Implement low-level functions of the libmjollnir library + * + */ #include "libmjollnir.h" /** * @brief Core control flow analysis function at a given address * @param sess Mjollnir session - * @param ptr Code buffer pointer to analyse * @param vaddr Entry point address for analysis - * @param len Size of code to analyse + * @param curdepth current depth of cfg being analyzed + * @param maxdepth depth limit of analysis (== MJR_MAX_DEPTH for limitless) + * @return Success (0) or error (-1). + * + * @ingroup libmjollnir */ -static int mjr_analyse_code(mjrsession_t *sess, unsigned char *ptr, eresi_Addr vaddr, int len) +int mjr_analyse_rec(mjrsession_t *sess, eresi_Addr vaddr, int curdepth, int maxdepth) { - asm_instr instr; - unsigned int curr, ilen; + asm_instr instr; + unsigned int curr; + int ilen; + eresi_Addr trueaddr, falseaddr; + container_t *curblock; + mjrblock_t *block; + u_int delayslotsize; + u_char *ptr, *argptr; + u_int curlen; + u_int restlen; + elfshsect_t *sect; + elfsh_SAddr off; + u_char eos; + u_int depthinc; + u_int curoff; + u_int totlen; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if __DEBUG_READ__ + fprintf(stderr, " [D] ENTERING ANALYSE-REC: curdepth=%u maxdepth=%u \n", curdepth, maxdepth); +#endif + /* Check if we have reached the limit bound */ - //limit = (u_int) config_get_data(CONFIG_CFGDEPTH); - // Please use this config variable when doing CFG recursive analysis + if (maxdepth > 0 && curdepth >= maxdepth) + { + if (sess->cur->func_stack->elmnbr > 1) + { + sess->cur->curfunc = elist_pop(sess->cur->func_stack); +#if __DEBUG_FLOW__ + fprintf(stderr, " [*] New CURFUNC @ %s \n", ((mjrfunc_t*)sess->cur->curfunc->data)->name); +#endif + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + trueaddr = falseaddr = MJR_BLOCK_INVALID; + delayslotsize = 0; + + /* Create a new block if current address is out of all existing ones */ + curblock = (container_t *) hash_get(&sess->cur->blkhash, _vaddr2str(vaddr)); + +#if __DEBUG_MJOLLNIR__ + fprintf(D_DESC, "[D] core.c:analyse_code: bloc requested at vaddr " XFMT " \n", + vaddr); +#endif + + assert(curblock != NULL); - /* Read all instructions of the section */ - for (curr = 0; curr < len; curr += ilen) + block = (mjrblock_t *) curblock->data; + +#if __DEBUG_MJOLLNIR__ + fprintf(D_DESC, "[D] %s: bloc " XFMT ": seen %hhd\n", + __FUNCTION__, block->vaddr, block->seen); +#endif + + /* Avoid loops */ + if (block->seen == 1) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + block->seen = 1; + + /* Verify that we have a parent section to read data from */ + sect = elfsh_get_parent_section(sess->cur->obj, vaddr, &off); + +#if __DEBUG_MJOLLNIR__ + fprintf(stderr, " [D] analyse_rec: parent section of vaddr "AFMT" = %s (off %u) \n", + vaddr, (sect ? sect->name : "UNKNOW"), (u_int) off); +#endif + + if (!sect) + { + fprintf(stderr, " [*] Early finishing of CFG analysis at addr "AFMT" \n", vaddr); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* In many cases we dont need to do a malloc, since we will read from the section's cache */ + totlen = curlen = MJR_MIN(sect->shdr->sh_size - off, MJR_MAX_BLOCK_SIZE); + eos = (curlen != MJR_MAX_BLOCK_SIZE ? 1 : 0); + argptr = NULL; + if (elfsh_is_runtime_mode() && (kernsh_is_present() || kedbg_is_present())) { - ilen = asm_read_instr(&instr, ptr + curr, len - curr, &sess->cur->proc); - + XALLOC(__FILE__, __FUNCTION__, __LINE__, ptr, curlen, -1); + argptr = ptr; + } + ptr = elfsh_readmema(sess->cur->obj, vaddr, argptr, curlen); + + /* Read all instructions, making sure we never override section's boundaries */ + for (curr = 0; vaddr + curr < sect->shdr->sh_addr + sect->shdr->sh_size; curr += ilen) + { + + /* Reallocate the buffer if necessary (runtime kernsh or kedbg mode) */ + /* If we are in elfsh, e2dbg or evarista, never reallocate */ + /* since we read from static cache */ + /* The use of readmema is a bit subtle here, dont modify unless */ + /* you know what you are doing */ + if (!eos && curr + 15 >= curlen) + { + sect = elfsh_get_parent_section(sess->cur->obj, vaddr + curr, &off); + restlen = MJR_MIN(sect->shdr->sh_size - off, MJR_MAX_BLOCK_SIZE); + eos = (restlen != MJR_MAX_BLOCK_SIZE ? 1 : 0); + if (elfsh_is_runtime_mode() && (kernsh_is_present() || kedbg_is_present())) + { + curoff = (u_int) (ptr - argptr); + totlen += restlen; + XREALLOC(__FILE__, __FUNCTION__, __LINE__, argptr, argptr, totlen, -1); + ptr = argptr + curoff; + } + curlen += restlen; + ptr = elfsh_readmema(sess->cur->obj, vaddr + curr, ptr + curr, curlen - curr); + vaddr += curr; + curlen -= curr; + curr = 0; + } + + /* Analyse current instruction */ + ilen = asm_read_instr(&instr, ptr + curr, curlen - curr, &sess->cur->proc); + + /* This is an error that should never happen, or we have a serious libasm bug */ + if (ilen <= 0) + { + fprintf(stderr, + " [D] asm_read_instr returned -1 (opcode %02X %02X %02X %02X %02X %02X) at "XFMT"\n", + *(ptr + curr), *(ptr + curr + 1), *(ptr + curr + 2), + *(ptr + curr + 3), *(ptr + curr + 4), *(ptr + curr + 5), + vaddr + curr); + goto end; + } + + mjr_history_shift(sess->cur, instr, vaddr + curr); + block->size += ilen; + #if __DEBUG_READ__ - fprintf(D_DESC,"[D] %s/%s,%d: ilen=%d\n", __FUNCTION__, __FILE__, __LINE__, ilen); + fprintf(stderr, " [D] curaddr WILL BE analyzed: "XFMT" (curr = %d, ilen = %d) \n", + vaddr + curr, curr, ilen); #endif - - if (ilen > 0) - { - mjr_history_shift(sess->cur, instr, vaddr + curr); - mjr_trace_control(sess->cur, sess->cur->obj, &instr, vaddr + curr); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "asm_read_instr returned <= 0 lenght", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Analyse control flow at a given address - * @param sess Mjollnir session - * @param addr Entry point address for analysis - * @param flags - */ -static int mjr_analyse_addr(mjrsession_t *sess, eresi_Addr addr, int flags) -{ - elfshsect_t *parent; - elfsh_SAddr offset; - container_t *block; - unsigned char *ptr; - unsigned long len; - + /* Increase block size for delay slot if any */ + delayslotsize = mjr_trace_control(sess->cur, curblock, sess->cur->obj, &instr, + vaddr + curr, &trueaddr, &falseaddr); - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); +#if __DEBUG_READ__ + fprintf(stderr, " [D] curaddr analyzed: "XFMT" (trueaddr = "XFMT", falseaddr = "XFMT")\n", + vaddr + curr, trueaddr, falseaddr); +#endif - ptr = elfsh_get_raw(sess->cur->cursct); - len = sess->cur->cursct->shdr->sh_size; - - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to analyse control flow", -1); + /* If we have found a contiguous block, stop this recursion now */ + if (trueaddr == MJR_BLOCK_EXIST) + { - parent = elfsh_get_parent_section(sess->cur->obj, addr, &offset); - if (!parent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find parent section", -1); +#if __DEBUG_READ__ + fprintf(stderr, " [D] FOUND contiguous block at "XFMT" - breaking\n", trueaddr); +#endif + block->size -= ilen; + break; + } + + /* Recurse on next blocks -- might be the beginning of a new func */ + if (trueaddr != MJR_BLOCK_INVALID) + { + depthinc = (instr.type & ASM_TYPE_CALLPROC ? 1 : 0); + mjr_analyse_rec(sess, trueaddr, curdepth + depthinc, maxdepth); + } - block = mjr_create_block_container(sess->cur, 0, addr, - parent->shdr->sh_size - offset, 1); - if (!block) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create parent container", -1); - - hash_add(&sess->cur->blkhash, _vaddr2str(addr), block); + /* Recurse on false block -- might be the return block for a function */ + if (falseaddr != MJR_BLOCK_INVALID) + mjr_analyse_rec(sess, falseaddr, curdepth, maxdepth); + + /* If we have recursed, the current block is over */ + if (falseaddr != MJR_BLOCK_INVALID || trueaddr != MJR_BLOCK_INVALID || + (instr.type & ASM_TYPE_RETPROC) || (instr.type & ASM_TYPE_STOP)) + { +#if __DEBUG_MJOLLNIR__ + fprintf(D_DESC, + "[D] core.c:analyse_code: bloc at vaddr " XFMT " with delayslot size %u\n", + block->vaddr, + delayslotsize); +#endif - ptr = elfsh_get_raw(sess->cur->cursct); - len = parent->shdr->sh_size - offset ; - - if (mjr_analyse_code(sess, ptr + offset, addr, len) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during code analysis", -1); + block->size += delayslotsize; + break; + } + } - if (mjr_analyse_finished(sess) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during storage of analysis info", -1); + end: + if (elfsh_is_runtime_mode() && (kernsh_is_present() || kedbg_is_present())) + XFREE(__FILE__, __FUNCTION__, __LINE__, argptr); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - /** - * @brief This function will find calls including calls trought a pointer + * @brief Analyse control flow at a given address * @param sess Mjollnir session - * @param section_name The name of the section we want to analyse + * @param addr Entry point address for analysis + * @param maxdepth Maximum depth of the analysis in the CFG + * @param flags + * @return Success (0) or Error (-1). + * + * @ingroup libmjollnir */ -int mjr_analyse_section(mjrsession_t *sess, char *section_name) +int mjr_analyse(mjrsession_t *sess, eresi_Addr addr, int maxdepth, int flags) { - container_t *cntnr; - unsigned char *ptr; - unsigned long len; - eresi_Addr e_point, vaddr; + elfshsect_t *parent; + elfsh_SAddr offset; + eresi_Addr e_entry; eresi_Addr main_addr; + u_char *ptr; + container_t *cont; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* load section */ -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG_MJOLLNIR__] %s: loading %s\n", - __FUNCTION__, section_name); -#endif + if (!addr || !sess) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid null parameters", -1); - /* We just started here so we can clear the current section in context */ - sess->cur->cursct = NULL; + if (sess->cur->proc.fetch == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No valid fetch-hook for this architecture", -1); - if (!section_name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section name empty", -1); - - sess->cur->cursct = elfsh_get_section_by_name(sess->cur->obj, section_name, NULL, NULL, NULL); - if (!sess->cur->cursct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section not found", -1); - -#if __DEBUG_CALLS__ - fprintf(D_DESC, "[__DEBUG_CALLS__] %s: vaddr:%x size:%d foff:%d\n", - __FUNCTION__, sess->cur->cursct->shdr->sh_addr, - sess->cur->cursct->shdr->sh_size, - sess->cur->cursct->shdr->sh_offset); -#endif - - /* Setup initial conditions */ - ptr = elfsh_get_raw(sess->cur->cursct); - len = sess->cur->cursct->shdr->sh_size; - vaddr = sess->cur->cursct->shdr->sh_addr; - e_point = elfsh_get_entrypoint(elfsh_get_hdr(sess->cur->obj)); + /* Make sure the input address is mapped somewhere */ + parent = elfsh_get_parent_section(sess->cur->obj, addr, &offset); + if (!parent) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find parent section", -1); + + /* Create a container for the starting block */ + cont = mjr_create_block_container(sess->cur, 0, addr, 0, 0); + if (!cont) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Can't create initial block", -1); + hash_add(&sess->cur->blkhash, _vaddr2str(addr), cont); - /* Create block pointing to this section */ - if (sess->cur->cursct->shdr->sh_addr == e_point) + /* Check if we are starting at the entry point -- if yes, special treatment is to be done */ + e_entry = elfsh_get_entrypoint(elfsh_get_hdr(sess->cur->obj)); + if (addr == e_entry) { - printf(" [*] Entry point: " AFMT "\n", e_point); - main_addr = mjr_trace_start(sess->cur, ptr, - sess->cur->cursct->shdr->sh_size, e_point); + printf(" [*] Entry point: " AFMT "\n", e_entry); + XALLOC(__FILE__, __FUNCTION__, __LINE__, ptr, MJR_MAX_BLOCK_SIZE * 2, -1); + elfsh_readmema(sess->cur->obj, addr, ptr, MJR_MAX_BLOCK_SIZE * 2); + main_addr = mjr_trace_start(sess->cur, ptr, MJR_MAX_BLOCK_SIZE * 2, e_entry); + XFREE(__FILE__, __FUNCTION__, __LINE__, ptr); printf(" [*] main located at " AFMT "\n", main_addr); } + + /* We are not analyzing the entry point */ else { - cntnr = mjr_create_function_container(sess->cur, vaddr, 0, _vaddr2str(vaddr), 0, NULL); - sess->cur->curfunc = cntnr; - mjr_function_register(sess->cur,vaddr, cntnr); + main_addr = 0; + sess->cur->func_stack = elist_empty(sess->cur->func_stack->name); + cont = mjr_create_function_container(sess->cur, addr, 0, _vaddr2str(addr), 0, NULL); + sess->cur->curfunc = cont; + mjr_function_register(sess->cur, addr, cont); + elist_push(sess->cur->func_stack, cont); } + /* Analyse recursively, starting at requested address */ + if (mjr_analyse_rec(sess, addr, 0, maxdepth) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during code analysis", -1); + + /* If requested address was the entry point, also analyse the infered main() address */ + if (main_addr) + { + sess->cur->func_stack = elist_empty(sess->cur->func_stack->name); + cont = mjr_function_get_by_vaddr(sess->cur, main_addr); + sess->cur->curfunc = cont; + elist_push(sess->cur->func_stack, cont); + if (mjr_analyse_rec(sess, main_addr, 0, maxdepth) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during code analysis", -1); + } - /* Read all instructions of the section */ - if (mjr_analyse_code(sess, ptr, vaddr, len) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during code analysis", -1); + /* Store analysis on disk */ + if (mjr_analyse_finished(sess) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during storage of analysis info", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - -int mjr_analyse_finished(mjrsession_t *sess) -{ +/** + * @breif Store control-flow analysis information on disk + * @param sess Mjollnir session + * @ingroup libmjollnir + */ +int mjr_analyse_finished(mjrsession_t *sess) +{ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Store analyzed functions in file */ if (mjr_flow_store(sess->cur, ASPECT_TYPE_FUNC) <= 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to store functions in file", -1); - + /* Store analyzed blocks in file */ if (mjr_flow_store(sess->cur, ASPECT_TYPE_BLOC) <= 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to store blocks in file", -1); - + /* Set the flag and return */ - sess->cur->analysed = 1; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - /** - * @brief Main analysis function - * @param sess Mjollnir session strucutre - * @param flags + * Indicate if a given address has already been analyzed + * @param sess Mjollnir session + * @param addr current address + * @ingroup libmjollnir */ -int mjr_analyse(mjrsession_t *sess, eresi_Addr entry, int flags) +int mjr_analysed(mjrsession_t *sess, eresi_Addr addr) { - char *shtName; - elfsh_Shdr *shtlist, *shdr; - elfsh_Sym *sym, *lastsym; - elfshsect_t *sct; - container_t *fcnt; - int num_sht, idx_sht; - int index, blocksize; - eresi_Addr addr; - char c; - int ret; + int analysed; + container_t *cont; + char *str; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if ((NULL == sess) || (NULL == sess->cur)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - - /* Get section table */ - shtlist = elfsh_get_sht(sess->cur->obj, &num_sht); - if (!shtlist) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get SHT", -1); - - /* Make sure we do what the user desires (remove previously stored analysis) */ - /* FIXME: should go in libstderesi/cmd_analyse command and use revm_output */ - if (sess->cur->analysed) - { - printf(" [*] %s section present ! \n" - " Analysis will remove currently stored information. " - "continue ? [N/y]", ELFSH_SECTION_NAME_EDFMT_BLOCKS); - - c = getchar(); - puts(""); - - if (c != 'y') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flow analysis aborted", 0); - - elfsh_remove_section(sess->cur->obj, ELFSH_SECTION_NAME_EDFMT_BLOCKS); - } - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC,"[__DEBUG__] mjr_analize: Found %d sections.\n",num_sht); -#endif - - /* In case we are provided an entry point */ - if (entry) - { - ret = mjr_analyse_addr(sess, entry, flags); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to analyse control flow by addr", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* - ** First run, create blocks starting at section vaddr - ** and in size of the section - */ - for (idx_sht = 0; idx_sht < num_sht; idx_sht++) - { - shdr = (shtlist + idx_sht); - sym = elfsh_get_sym_from_shtentry(sess->cur->obj, shdr); - - if (!elfsh_get_section_execflag(shdr) || - !elfsh_get_section_allocflag(shdr) || - !sym) - continue; - - shtName = elfsh_get_symbol_name(sess->cur->obj, sym); - sct = elfsh_get_section_by_name(sess->cur->obj, shtName, NULL, NULL, NULL); - - if (!sct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get section", -1); - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG__] %s: 1st run - Executable section name=(%14s) " - "index=(%02i) vaddr=(%x) size=(%d)\n", - __FUNCTION__, shtName, idx_sht, sct->shdr->sh_addr, sct->shdr->sh_size); -#endif - - fcnt = mjr_create_block_container(sess->cur, 0, sct->shdr->sh_addr, - sct->shdr->sh_size, 1); - if (!fcnt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't create initial blocks", -1); - - hash_add(&sess->cur->blkhash, _vaddr2str(sct->shdr->sh_addr), fcnt); - } - - - /* Analyse all executable sections */ - for (idx_sht = 0; idx_sht < num_sht; idx_sht++) - { - shdr = (shtlist + idx_sht); - sym = elfsh_get_sym_from_shtentry(sess->cur->obj, shdr); - shtName = elfsh_get_symbol_name(sess->cur->obj, sym); - - if (!elfsh_get_section_execflag(shdr) || - !elfsh_get_section_allocflag(shdr)) - continue; - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG__] mjr_analize: Executable section name=(%14s) " - "index=(%02i)\n", shtName, idx_sht); -#endif - - mjr_analyse_section(sess, shtName); - } - - /* Find all unseen blocks (may be dead code) */ - for (lastsym = NULL, index = 0, sym = sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB]->altdata; - index < sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB]->shdr->sh_size / sizeof(elfsh_Sym); - index++) - { - if (elfsh_get_symbol_type(sym + index) != STT_BLOCK) - continue; - if (!lastsym) - { - lastsym = sym; - continue; - } - if (lastsym->st_value + lastsym->st_size != sym->st_value) - { - addr = lastsym->st_value + lastsym->st_size; - blocksize = sym->st_value - addr; - mjr_create_block_container(sess->cur, 0, addr, blocksize, 0); - lastsym = sym; - - fprintf(stderr, " [D] Adding UNLINKED block at " XFMT " ! \n", addr); - - } - } - - if (mjr_analyse_finished(sess) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during storage of analysis info", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + str = _vaddr2str(addr); + cont = (container_t *) hash_get(&sess->cur->blkhash, str); + XFREE(__FILE__, __FUNCTION__, __LINE__, str); + analysed = (cont ? 1 : 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, analysed); } diff -Nru eresi-0.8a25/libmjollnir/src/destroy.c eresi-0.0.20110516/libmjollnir/src/destroy.c --- eresi-0.8a25/libmjollnir/src/destroy.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/destroy.c 2011-05-16 11:34:47.000000000 +0000 @@ -0,0 +1,61 @@ +/** + * (C) 2006-2008 The ERESI team + * +* @file libmjollnir/src/destroy.c + * @ingroup libmjollnir + * @brief Cleaning API for removing previously saved analysis. + */ +#include "libmjollnir.h" + + +/** Remove the whole content of as hash table of containers */ +void mjr_hash_destroy(hash_t *hash, u_char haslists) +{ + char **keys; + int nbr; + u_int index; + container_t *data; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + keys = hash_get_keys(hash, &nbr); + for (index = 0; index < nbr; index++) + { + data = (container_t *) hash_get(hash, keys[index]); + if (haslists) + { + elist_destroy(data->inlinks); + elist_destroy(data->outlinks); + } + hash_del(hash, keys[index]); + XFREE(__FILE__, __FUNCTION__, __LINE__, data); + XFREE(__FILE__, __FUNCTION__, __LINE__, keys[index]); + } + hash->elmnbr = 0; + XFREE(__FILE__, __FUNCTION__, __LINE__, keys); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** Remove existing control flow analysis stored information */ +void mjr_analyse_destroy(mjrcontext_t *ctx) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + elfsh_remove_section(ctx->obj, ELFSH_SECTION_NAME_EDFMT_BLOCKS); + elfsh_remove_section(ctx->obj, ELFSH_SECTION_NAME_EDFMT_BCONTROL); + elfsh_remove_section(ctx->obj, ELFSH_SECTION_NAME_EDFMT_FUNCTIONS); + elfsh_remove_section(ctx->obj, ELFSH_SECTION_NAME_EDFMT_FCONTROL); + ctx->func_stack = elist_empty(ctx->func_stack->name); + ctx->next_id = 1; + ctx->block_btree = NULL; + ctx->curfunc = NULL; + ctx->curblock = NULL; + ctx->cntnrs_size = MJR_CNTNRS_INCREMENT; + ctx->calls_seen = ctx->calls_found = 0; + bzero(&ctx->hist, sizeof(mjrhistory_t) * MJR_HISTORY_LEN); + mjr_hash_destroy(&ctx->funchash, 1); + mjr_hash_destroy(&ctx->blkhash, 1); + mjr_hash_destroy(&ctx->linkhash, 0); + XFREE(__FILE__, __FUNCTION__, __LINE__, ctx->reg_containers); + mjr_init_containers(ctx); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} diff -Nru eresi-0.8a25/libmjollnir/src/display.c eresi-0.0.20110516/libmjollnir/src/display.c --- eresi-0.8a25/libmjollnir/src/display.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/display.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,13 +1,13 @@ -/* -** @file display.c -** -** @brief Contain printing functions for debug purpose only -** -** FIXME: needs to use revm_output() and not printf inside elfsh. -** -** Started on Tue Jan 02 04:04:18 2006 jfv -** -*/ +/** +* @file libmjollnir/src/display.c + * @ingroup libmjollnir + * @brief Contain printing functions for debug purpose only + * + * FIXME: needs to use revm_output() and not printf inside elfsh. + * + * Started on Tue Jan 02 04:04:18 2006 jfv + * + */ #include "libmjollnir.h" diff -Nru eresi-0.8a25/libmjollnir/src/findentry.c eresi-0.0.20110516/libmjollnir/src/findentry.c --- eresi-0.8a25/libmjollnir/src/findentry.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/findentry.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,10 +1,11 @@ -/* -** @file control.c -** -** Started : Thu May 29 20:44:39 2003 sk -** Updated : Sun Dec 30 16:45:48 2006 jfv -** -*/ +/** +* @file libmjollnir/src/findentry.c + * @ingroup libmjollnir + * + * Started : Thu May 29 20:44:39 2003 sk + * Updated : Sun Dec 30 16:45:48 2006 jfv + * + */ #include "libmjollnir.h" @@ -14,7 +15,7 @@ * * This function inspect the code at entry point and inject the resolved * symbol for the main function. This is a separate function so that it - * can be called frmo the tracer and benefit from the main symbol presence + * can be called from the tracer and benefit from the main symbol presence */ eresi_Addr mjr_find_main(elfshobj_t *obj, asm_processor *proc, @@ -25,7 +26,7 @@ { int stop; elfsh_Sym *sym; - u_int ilen; + u_int ilen,done; eresi_Addr init_addr; asm_instr ins; int arch_bin; @@ -34,6 +35,8 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + done = 0; + for (*dis = stop = 0; !stop; *dis += ilen) { ilen = asm_read_instr(&ins, (u_char *) buf + *dis, @@ -140,12 +143,19 @@ else PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Architecture not supported", -1); - - } + + done += ilen; + /* If we reached this point it probably means that we analyse + self made software, written in asm and compiled with nasm */ + if (done >= len) + { + main_addr = vaddr; + stop = 1; + } + } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, main_addr); } - /** * This function traces the entry point and save the last push argument until * a call is found. This allow to fetch the main address in an OS-dependent @@ -162,7 +172,7 @@ u_int dis; elfsh_Sym *sym; elfsh_Sym bsym; - + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!context || !buf) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -170,43 +180,52 @@ if (!(elfsh_get_objtype(elfsh_get_hdr(context->obj)) == ET_EXEC)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object is not ET_EXEC", 0); + "Object is not ET_EXEC", 0); #if defined(__DEBUG_MJOLLNIR__) printf(" [*] _start found at 0x%lx\n", (unsigned long) vaddr); #endif - sym = elfsh_get_symbol_by_name(context->obj, "main"); + // sym = elfsh_get_symbol_by_name(context->obj, "main"); + sym = elfsh_get_metasym_by_name(context->obj, "main"); if (sym && sym->st_value) - main_addr = sym->st_value; + { + main_addr = sym->st_value; + dis = 0; + } else main_addr = mjr_find_main(context->obj, &context->proc, buf, len, vaddr, &dis); if (main_addr == -1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Could not find address of main", -1); - - tmpcntnr = mjr_create_function_container(context, vaddr, 0, "_start", 0, NULL); - mjr_function_register(context, vaddr, tmpcntnr); - - fprintf(stderr, "CREATING MAIN FUNC at %llX\n", main_addr); - - main_container = mjr_create_function_container(context, main_addr, 0, "main", 0, NULL); - mjr_function_register(context, main_addr, main_container); + "Could not find address of main", 0); - mjr_container_add_link(context, tmpcntnr, main_container->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); - mjr_container_add_link(context, main_container, tmpcntnr->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_IN); - mjr_link_block_call(context, vaddr, main_addr, vaddr + dis); - - /* Create symbols for main */ - /* Then we create the symbol for the bloc and returns */ - if (!sym || !sym->st_value) + if (main_addr != vaddr) { - bsym = elfsh_create_symbol(main_addr, 0, STT_FUNC, 0, 0, 0); - elfsh_insert_symbol(context->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, "main"); + tmpcntnr = mjr_create_function_container(context, vaddr, 0, "_start", 0, NULL); + mjr_function_register(context, vaddr, tmpcntnr); + +#if defined(__DEBUG_MJOLLNIR__) + fprintf(stderr, " [D] Creating MAIN Func at " XFMT "\n", main_addr); +#endif + + main_container = mjr_create_function_container(context, main_addr, 0, "main", 0, NULL); + mjr_function_register(context, main_addr, main_container); + + mjr_container_add_link(context, tmpcntnr, main_container->id, + MJR_LINK_FUNC_CALL, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(context, main_container, tmpcntnr->id, + MJR_LINK_FUNC_RET, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); + mjr_link_block_call(context, vaddr, main_addr, vaddr + dis); + + /* Create symbols for main */ + /* Then we create the symbol for the bloc and returns */ + if (!sym || !sym->st_value) + { + bsym = elfsh_create_symbol(main_addr, 0, STT_FUNC, 0, 0, 0); + elfsh_insert_symbol(context->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, "main"); + elfsh_sync_sorted_symtab(context->obj->secthash[ELFSH_SECTION_SYMTAB]); + } } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, main_addr); } diff -Nru eresi-0.8a25/libmjollnir/src/fingerprint.c eresi-0.0.20110516/libmjollnir/src/fingerprint.c --- eresi-0.8a25/libmjollnir/src/fingerprint.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/fingerprint.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,11 +1,12 @@ -/* -** @file fingerprint.c -** -** @brief Functions for fingerprinting inside libmjollnir -** -** Started : Mon Jan 02 01:18:14 2007 jfv -** -*/ +/** +* @file libmjollnir/src/fingerprint.c + * @ingroup libmjollnir + * + * @brief Functions for fingerprinting inside libmjollnir + * + * Started : Mon Jan 02 01:18:14 2007 jfv + * + */ #include "libmjollnir.h" diff -Nru eresi-0.8a25/libmjollnir/src/function.c eresi-0.0.20110516/libmjollnir/src/function.c --- eresi-0.8a25/libmjollnir/src/function.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/function.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,5 +1,6 @@ /** - * @file function.c +* @file libmjollnir/src/function.c + * @ingroup libmjollnir * * @brief funtion containers related api * @@ -145,8 +146,8 @@ */ void *mjr_fingerprint_function(mjrcontext_t *ctx, eresi_Addr addr, - int type) { - + int type) +{ MD5_CTX md5ctx; unsigned char fbuf[MJR_MAX_FUNCTION_LEN] = {0x00}; unsigned char digest[16]; @@ -167,7 +168,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown parent section", NULL); - buff = elfsh_get_raw(sect); + buff = elfsh_readmem(sect); buff += off; /* Select the desired fingerprinting function */ @@ -216,15 +217,16 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if 1 //__DEBUG_FUNCS__ +#if __DEBUG_FUNCS__ fprintf(D_DESC, "[D] %s: vaddr:%x ID:%d\n", __FUNCTION__, vaddr, fun->id); #endif if (!mjr_function_get_by_vaddr(ctx, vaddr)) { +#if __DEBUG_FUNCS__ fprintf(stderr, " [*] Registered new function starting at 0x%08X \n", vaddr); - +#endif tmpstr = _vaddr2str(vaddr); hash_add(&ctx->funchash, tmpstr, fun); } @@ -268,14 +270,23 @@ elfsh_Sym bsym; char *prefix; char buffer[BUFSIZ]; + char *name; + elfsh_SAddr off; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Insert new function symbol */ func = (mjrfunc_t *) csrc->data; + + /* Check if symbol already exists */ + name = elfsh_reverse_metasym(ctxt->obj, func->vaddr, &off); + prefix = (char *) config_get_data(MJR_CONFIG_BLOC_PREFIX); + if (!off && !strstr(name, prefix)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + /* If not, inject it */ prefix = (char *) config_get_data(MJR_CONFIG_FUNC_PREFIX); snprintf(buffer, sizeof(buffer), "%s"AFMT, prefix, func->vaddr); bsym = elfsh_create_symbol(func->vaddr, func->size, STT_FUNC, 0, 0, 0); elfsh_insert_symbol(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, buffer); + elfsh_sync_sorted_symtab(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB]); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libmjollnir/src/history.c eresi-0.0.20110516/libmjollnir/src/history.c --- eresi-0.8a25/libmjollnir/src/history.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/history.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,8 +1,10 @@ -/* -** (C) 2001-2008 Devhell Labs / Asgard Labs : thorolf / sk / jfv -** @file history.c -** -*/ +/** +* @file libmjollnir/src/history.c + * @ingroup libmjollnir + * + * (C) 2001-2008 Devhell Labs / Asgard Labs : thorolf / sk / jfv + * + */ #include "libmjollnir.h" diff -Nru eresi-0.8a25/libmjollnir/src/init.c eresi-0.0.20110516/libmjollnir/src/init.c --- eresi-0.8a25/libmjollnir/src/init.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/init.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,10 +1,9 @@ /** - * (C) 2006-2008 Asgard Labs, thorolf - * BSD License - * - * @file init.c + * @file libmjollnir/src/init.c * @brief Initialization functions + * @ingroup libmjollnir * + * (C) 2006-2010 Eresi Project */ #include "libmjollnir.h" @@ -12,12 +11,12 @@ /** * @brief Initialize the world for libmjollnir * @param sess The session structure + * @ingroup libmjollnir */ int mjr_init_session(mjrsession_t *sess) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash_init(&goto_hash, "gotos" , 100 , ASPECT_TYPE_STR); hash_init(&sess->ctx, "mjrcontexts", mjrHashSmall, ASPECT_TYPE_UNKNOW); /* register configurable parameters */ @@ -33,6 +32,10 @@ CONFIG_TYPE_STR, CONFIG_MODE_RW, MJR_FUNC_PREFIX); + config_add_item(MJR_CONFIG_LINK_PREFIX, + CONFIG_TYPE_STR, + CONFIG_MODE_RW, + MJR_LINK_PREFIX); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } @@ -41,11 +44,12 @@ * @brief Change the current analysis context * @param sess The session structure * @param name The name of the session + * @ingroup libmjollnir */ int mjr_set_current_context(mjrsession_t *sess, char *name) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if ((sess->cur = hash_get(&sess->ctx,name)) == NULL) + if ((sess->cur = hash_get(&sess->ctx, name)) == NULL) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } @@ -54,6 +58,7 @@ * @brief Create a new analysis context * @param sess The session structure * @param ctx The context structure + * @ingroup libmjollnir */ int mjr_add_context(mjrsession_t *sess, mjrcontext_t *ctx) { @@ -63,9 +68,38 @@ } /** + * @brief Delete an analysis context + * @param sess The session structure + * @param name Object Name + * @ingroup libmjollnir + */ +int mjr_del_context(mjrsession_t *sess, char *name) +{ + mjrcontext_t *ctx; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + ctx = hash_get(&sess->ctx, name); + elist_destroy(ctx->func_stack); + + /* Check if current context is the same we want to remove + if yes set cur to NULL + */ + if (sess && sess->cur && (!strcmp(sess->cur->obj->name, + name))) + { + sess->cur = NULL; + } + + hash_del(&sess->ctx, name); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); +} + +/** * @brief Create a context and set it as the current one * @param sess The session strucutre * @param obj elfshell obj + * @ingroup libmjollnir */ int mjr_create_context_as_current(mjrsession_t *sess, elfshobj_t *obj) { @@ -82,45 +116,73 @@ /** * @brief Create a new context * @param obj elf shell object + * @ingroup libmjollnir */ mjrcontext_t *mjr_create_context(elfshobj_t *obj) { mjrcontext_t *ctx; + char *lname; + char buff[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,ctx, sizeof(mjrcontext_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, lname, BSIZE_SMALL, NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, ctx, sizeof(mjrcontext_t), NULL); bzero(ctx, sizeof(mjrcontext_t)); ctx->obj = obj; - hash_init(&ctx->funchash, "functions", mjrHashVerySmall, ASPECT_TYPE_FUNC); - hash_init(&ctx->blkhash , "blocks" , mjrHashLarge , ASPECT_TYPE_BLOC); + + snprintf(buff, sizeof(buff), "%s_functions", obj->name); + hash_init(&ctx->funchash , strdup(buff), mjrHashVerySmall, ASPECT_TYPE_FUNC); + snprintf(buff, sizeof(buff), "%s_blocks", obj->name); + hash_init(&ctx->blkhash , strdup(buff) , mjrHashMedium, ASPECT_TYPE_BLOC); + snprintf(buff, sizeof(buff), "%s_links", obj->name); + hash_init(&ctx->linkhash , strdup(buff), mjrHashMedium, ASPECT_TYPE_LINK); + + snprintf(buff, sizeof(buff), "%s_gotos", obj->name); + hash_init(&ctx->goto_hash, strdup(buff), mjrHashVerySmall, ASPECT_TYPE_STR); + + XALLOC(__FILE__, __FUNCTION__, __LINE__, ctx->func_stack, sizeof(list_t), NULL); + + snprintf(lname, BSIZE_SMALL, "%s"AFMT, (char *) "funcpath_", obj->id); + elist_init(ctx->func_stack, lname, ASPECT_TYPE_FUNC); ctx->cntnrs_size = MJR_CNTNRS_INCREMENT; ctx->next_id = 1; - ctx->block_btree=NULL; + ctx->block_btree = NULL; + ctx->curfunc = NULL; mjr_init_containers(ctx); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ctx)); } /** - * Virtualisation of the libasm initialization depending on the architecture + * @brief Virtualisation of the libasm initialization depending on the architecture * @param sess Mjollnir session strucutre + * @param existing current processor + * @ingroup libmjollnir */ -int mjr_setup_processor(mjrsession_t *sess) +int mjr_setup_processor(mjrsession_t *sess, asm_processor *existing) { u_int arch; + if (existing) + { + memcpy(&sess->cur->proc, existing, sizeof(asm_processor)); + return (1); + } arch = elfsh_get_arch(sess->cur->obj->hdr); switch(arch) { case EM_SPARC: case EM_SPARCV9: case EM_SPARC32PLUS: - asm_init_sparc(&sess->cur->proc); + asm_init_arch(&sess->cur->proc, ASM_PROC_SPARC); break; case EM_386: - asm_init_ia32(&sess->cur->proc); + asm_init_arch(&sess->cur->proc, ASM_PROC_IA32); break; case EM_MIPS: - asm_init_mips(&sess->cur->proc); + asm_init_arch(&sess->cur->proc, ASM_PROC_MIPS); + break; + case EM_ARM: + asm_init_arch(&sess->cur->proc, ASM_PROC_ARM); break; default: fprintf(D_DESC," [E] Libmjollnir unsupported architecture\n"); @@ -128,3 +190,4 @@ } return 1; } + diff -Nru eresi-0.8a25/libmjollnir/src/links.c eresi-0.0.20110516/libmjollnir/src/links.c --- eresi-0.8a25/libmjollnir/src/links.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/links.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,5 +1,6 @@ /** - * @file links.c +* @file libmjollnir/src/links.c + * @ingroup libmjollnir * * @brief All the functions that deal with linking other objects, such * as functions, blocks, or others. @@ -18,122 +19,169 @@ * @param dst destination address * @param ret return address */ -int mjr_link_func_call(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) +int mjr_link_func_call(mjrcontext_t *ctxt, + eresi_Addr src, + eresi_Addr dst, + eresi_Addr ret) { - container_t *fun; - mjrfunc_t *tmpfunc; - char *tmpstr; - char *md5; - eresi_Addr tmpaddr; - elfshsect_t *dstsect; + container_t *fun; + char *tmpstr; + eresi_Addr tmpaddr; + elfshsect_t *dstsect; + u_char scope; + u_char isnew; + +#if __DEBUG_FLOW__ + mjrfunc_t *tmpfunc; + mjrfunc_t *tmpfunc2; + //char *md5; +#endif PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); #if __DEBUG_LINKS__ - fprintf(D_DESC, "[D] %s: src:%x dst:%x ret:%x\n", - __FUNCTION__, src, dst, ret); + fprintf(D_DESC, "[D] %s: src:"XFMT" dst:"XFMT" ret:"XFMT"\n", + __FUNCTION__, src, dst, ret); #endif /* Check if we are not pointing into BSS */ dstsect = elfsh_get_parent_section(ctxt->obj, dst, NULL); if (!dstsect || !dstsect->data) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + scope = (!dstsect || !strcmp(dstsect->name, ELFSH_SECTION_NAME_PLT) ? + MJR_LINK_SCOPE_GLOBAL : MJR_LINK_SCOPE_LOCAL); /* Link/Prepare function layer. We use an intermediate variable, else - the compiler optimize too hard and that make segfault (bug in gcc ?) */ + the compiler optimize too hard and that make segfault (bug in gcc ?) */ tmpaddr = dst; fun = mjr_function_get_by_vaddr(ctxt, tmpaddr); if (!fun) { tmpstr = _vaddr2str(tmpaddr); - fun = mjr_create_function_container(ctxt, tmpaddr, 0, - tmpstr, NULL, NULL); + fun = mjr_create_function_container(ctxt, tmpaddr, 0, + tmpstr, NULL, NULL); mjr_function_register(ctxt, tmpaddr, fun); mjr_function_symbol(ctxt, fun); + isnew = 1; } + else + isnew = 0; /* Add links between functions */ if (ctxt->curfunc) { - mjr_container_add_link(ctxt, fun, ctxt->curfunc->id, - MJR_LINK_FUNC_RET, CONTAINER_LINK_IN); - mjr_container_add_link(ctxt, ctxt->curfunc, fun->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); +#if __DEBUG_FLOW__ + tmpfunc = (mjrfunc_t *) ctxt->curfunc->data; + tmpfunc2 = (mjrfunc_t *) fun->data; + fprintf(stderr, " [*] Linking function " XFMT " to func " XFMT "\n", + tmpfunc->vaddr, tmpfunc2->vaddr); +#endif + mjr_container_add_link(ctxt, fun, ctxt->curfunc->id, + MJR_LINK_FUNC_RET, scope, CONTAINER_LINK_IN); + mjr_container_add_link(ctxt, ctxt->curfunc, fun->id, + MJR_LINK_FUNC_CALL, scope, CONTAINER_LINK_OUT); } /* Fingerprint function */ + /* + ** XXX: this segfaults on 64bits architecture - MAX_FUNC_LEN should + ** not be used. Instead, we should fingerprint all functions with + ** their infered size at the moment of saving debug sections. + ** md5 = mjr_fingerprint_function(ctxt, tmpaddr, MJR_FPRINT_TYPE_MD5); tmpfunc = (mjrfunc_t *) fun->data; if (md5) memcpy(tmpfunc->md5, md5, sizeof(tmpfunc->md5)); + */ + +#if __DEBUG_FLOW__ + tmpfunc = fun->data; +#endif + + if (scope == MJR_LINK_SCOPE_LOCAL && isnew) + { + elist_push(ctxt->func_stack, fun); + ctxt->curfunc = fun; +#if __DEBUG_FLOW__ + fprintf(stderr, " [*] New CURFUNC @ %s \n", tmpfunc->name); + } + else if (!isnew) + fprintf(stderr, " ******** ALREADY SEEN FUNCTION : NOT CHANGING CURFUNC @ %s \n", tmpfunc->name); + else + fprintf(stderr, " ******** GLOBAL FUNCTION CALL : NOT CHANGING CURFUNC @ %s \n", tmpfunc->name); +#else + } +#endif PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * @brief Create a link between blocks on a call +/** + * @brief Create a link between blocks on a call */ -int mjr_link_block_call(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) +int mjr_link_block_call(mjrcontext_t *ctxt, + eresi_Addr src, + eresi_Addr dst, + eresi_Addr ret) { - container_t *csrc,*cdst,*cret; - elfshsect_t *dstsect; + container_t *csrc,*cdst,*cret; + elfshsect_t *dstsect; + elfshsect_t *retsect; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); #if __DEBUG_LINKS__ fprintf(D_DESC,"[D] %s: linking " AFMT " CALL " AFMT " RET " AFMT "\n", - __FUNCTION__, src, dst, ret); + __FUNCTION__, src, dst, ret); #endif /* Check if we are not pointing into BSS */ dstsect = elfsh_get_parent_section(ctxt->obj, dst, NULL); - if (!dstsect || !dstsect->data) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + retsect = elfsh_get_parent_section(ctxt->obj, ret, NULL); /* at this point we must have src block */ csrc = mjr_block_get_by_vaddr(ctxt, src, MJR_BLOCK_GET_FUZZY); - fprintf(stderr, "Calling location source " XFMT "\n", src); - assert(csrc != NULL); - mjr_block_symbol(ctxt, csrc, src, 0); - /* search and/or split destination block */ - if (!(cdst = mjr_block_split(ctxt, dst, 0))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the dst",0); +#if __DEBUG_LINKS__ + fprintf(stderr, "[D] Calling location source " XFMT "\n", src); +#endif - if (ret) - /* search and/or split - return block */ - if (!(cret = mjr_block_split(ctxt, ret, 0))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the ret", 0); + assert(csrc != NULL); + mjr_block_symbol(ctxt, csrc); /* link src and dst */ - mjr_container_add_link(ctxt, csrc, cdst->id, MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cdst, csrc->id, MJR_LINK_FUNC_CALL, CONTAINER_LINK_IN); - - if (ret) + if (dst != MJR_BLOCK_INVALID && dstsect && dstsect->data) { - /* link dst and ret */ - mjr_container_add_link(ctxt, cdst, cret->id, MJR_LINK_FUNC_RET, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, cdst->id, MJR_LINK_FUNC_RET, CONTAINER_LINK_IN); - - // mjr_block_relink_cond_always(csrc,cret,CONTAINER_LINK_OUT); - // mjr_block_relink_cond_always(cret,csrc,CONTAINER_LINK_IN); + cdst = mjr_block_split(ctxt, dst, MJR_LINK_FUNC_CALL); + if (!cdst) + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Could not split the dst", 0); + + mjr_container_add_link(ctxt, csrc, cdst->id, + MJR_LINK_FUNC_CALL, MJR_LINK_SCOPE_GLOBAL, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, cdst, csrc->id, + MJR_LINK_FUNC_CALL, MJR_LINK_SCOPE_GLOBAL, CONTAINER_LINK_IN); + } - mjr_container_add_link(ctxt, csrc, cret->id, MJR_LINK_TYPE_DELAY, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, csrc->id, MJR_LINK_TYPE_DELAY, CONTAINER_LINK_IN); + /* Link src and ret at the block level */ + if (ret != MJR_BLOCK_INVALID && retsect && retsect->data) + { + cret = mjr_block_split(ctxt, ret, MJR_LINK_FUNC_RET); + if (!cret) + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Could not split the ret", 0); + + mjr_container_add_link(ctxt, csrc, cret->id, + MJR_LINK_TYPE_DELAY, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, cret, csrc->id, + MJR_LINK_TYPE_DELAY, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); } #if __DEBUG_BLOCKS__ mjr_block_dump(ctxt,csrc); - mjr_block_dump(ctxt,cdst); + if (dst != MJR_BLOCK_INVALID) + mjr_block_dump(ctxt,cdst); mjr_block_dump(ctxt,cret); #endif @@ -141,45 +189,77 @@ } -/** +/** * @brief This function does prepare linking of blocks on conditional jumps */ -int mjr_link_block_jump(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) +int mjr_link_block_jump(mjrcontext_t *ctxt, + eresi_Addr src, + eresi_Addr dst, + eresi_Addr ret) { - container_t *csrc, *cdst, *cret; - + container_t *csrc, *cdst, *cret; + mjrblock_t *bsrc; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - + #if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s: linking JMP %x TRUE %x FALSE %x\n", - __FUNCTION__, - src,dst,ret); + fprintf(D_DESC,"[D] %s: linking JMP "XFMT" TRUE "XFMT" FALSE "XFMT"\n", + __FUNCTION__, src, dst, ret); #endif /* Insert symbol on terminated block */ csrc = mjr_block_get_by_vaddr(ctxt, src, MJR_BLOCK_GET_FUZZY); - assert(csrc != NULL); - mjr_block_symbol(ctxt, csrc, src, 0); + + /* Get block data */ + bsrc = (mjrblock_t *) csrc->data; + + /* If TRUE < SRC: split it and set the new one as csrc */ + if (dst > bsrc->vaddr && dst <= src) + { + csrc = mjr_block_split(ctxt, src, MJR_LINK_BLOCK_COND_ALWAYS); + } + + if (!csrc) + { + printf("missing block at address " XFMT "\n", src); + assert(csrc != NULL); + } + + mjr_block_symbol(ctxt, csrc); /* Now split destination blocks */ - if (!(cdst = mjr_block_split(ctxt,dst,MJR_LINK_BLOCK_COND_ALWAYS))) + cdst = mjr_block_split(ctxt, dst, MJR_LINK_BLOCK_COND_ALWAYS); + if (!cdst) PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the dst",0); - cret = NULL; - if (ret) - if (!(cret = mjr_block_split(ctxt,ret,MJR_LINK_BLOCK_COND_ALWAYS))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the ret",0); - - mjr_container_add_link(ctxt, csrc, cdst->id, MJR_LINK_BLOCK_COND_TRUE, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cdst, csrc->id, MJR_LINK_BLOCK_COND_TRUE, CONTAINER_LINK_IN); + "Could not split destination block", 0); + + if (ret != MJR_BLOCK_INVALID) + { + cret = mjr_block_split(ctxt, ret, MJR_LINK_BLOCK_COND_ALWAYS); + if (!cret) + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Could not split return block", 0); + } + else + cret = NULL; + + mjr_container_add_link(ctxt, csrc, cdst->id, + MJR_LINK_BLOCK_COND_TRUE, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, cdst, csrc->id, + MJR_LINK_BLOCK_COND_TRUE, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); + + +#if __DEBUG_LINKS__ + fprintf(D_DESC,"[D] %s: cret: "XFMT"\n", + __FUNCTION__, ret); +#endif + if (cret) { - mjr_container_add_link(ctxt, csrc, cret->id, MJR_LINK_BLOCK_COND_FALSE, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, csrc->id, MJR_LINK_BLOCK_COND_FALSE, CONTAINER_LINK_IN); + mjr_container_add_link(ctxt, csrc, cret->id, + MJR_LINK_BLOCK_COND_FALSE, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, cret, csrc->id, + MJR_LINK_BLOCK_COND_FALSE, MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); @@ -191,25 +271,25 @@ -/** - * @brief Update link information when splitting a block +/** + * @brief Update link information when splitting a block */ -static int mjr_block_relink(mjrcontext_t *ctx, - container_t *src, - container_t *dst, - int direction) +static int mjr_block_relink(mjrcontext_t *ctx, + container_t *src, + container_t *dst, + int direction) { - list_t *linklist; - listent_t *curent; - listent_t *savednext; - mjrlink_t *lnk; + list_t *linklist; + listent_t *curent; + listent_t *savednext; + mjrlink_t *lnk; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); linklist = mjr_link_get_by_direction(src, direction); #if __DEBUG_LINKS__ fprintf(D_DESC, "[D] Relinking blocks %s: src:%d dst:%d dir:%d\n", - __FUNCTION__, src->id, dst->id, direction); + __FUNCTION__, src->id, dst->id, direction); #endif /* First same links to dest, then remove links from source */ @@ -217,7 +297,7 @@ { savednext = curent->next; lnk = (mjrlink_t *) curent->data; - mjr_container_add_link(ctx, dst, lnk->id, lnk->type, direction); + mjr_container_add_link(ctx, dst, lnk->id, lnk->type, lnk->scope, direction); elist_del(linklist, curent->key); } @@ -235,64 +315,66 @@ * @param dst destination address of wanted block * @param link_with link splitted blocks with specified link type */ -container_t *mjr_block_split(mjrcontext_t *ctxt, - eresi_Addr dst, - u_int link_with) +container_t *mjr_block_split(mjrcontext_t *ctxt, + eresi_Addr dst, + u_char link_with) { - container_t *tmpdst,*dstend; - mjrblock_t *blkdst; - int new_size; - elfsh_Sym *sym; + container_t *tmpdst,*dstend; + mjrblock_t *blkdst; + int new_size; + elfsh_Sym *sym; + int symoff; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* Check if we need to split a bloc */ + /* Check if we need to create a new bloc for destination addr */ tmpdst = mjr_block_get_by_vaddr(ctxt, dst, MJR_BLOCK_GET_FUZZY); if (!tmpdst) { - tmpdst = mjr_create_block_container(ctxt, 0, dst, 1, 1); + tmpdst = mjr_create_block_container(ctxt, 0, dst, 0, 0); hash_add(&ctxt->blkhash, _vaddr2str(dst), tmpdst); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (tmpdst)); + symoff = mjr_block_symbol(ctxt, tmpdst); + ((mjrblock_t *) tmpdst->data)->symoff = symoff; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, tmpdst); } - /* Find existing symbol for split bloc */ + /* Or we might find an existing symbol and split existing bloc */ blkdst = (mjrblock_t *) tmpdst->data; sym = elfsh_get_symbol_by_value(ctxt->obj, blkdst->vaddr, NULL, ELFSH_EXACTSYM); assert(sym != NULL); #if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s:%d: wanted dst:%x got:%x\n", __FUNCTION__, __LINE__, dst, blkdst->vaddr); + fprintf(D_DESC,"[D] %s:%d: wanted dst:"XFMT" got:"XFMT"\n", + __FUNCTION__, __LINE__, dst, blkdst->vaddr); #endif /* Recompute sizes */ if (blkdst->vaddr != dst) { - new_size = blkdst->size - (dst - blkdst->vaddr); + new_size = blkdst->size - (dst - blkdst->vaddr); #if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s:%d: new_size %d for %x\n", __FUNCTION__, __LINE__, new_size, dst); - fprintf(D_DESC,"[D] %s:%d: turncate %x to %d\n", __FUNCTION__, __LINE__, blkdst->vaddr, blkdst->size); + fprintf(D_DESC,"[D] %s:%d: new_size %d for "XFMT"\n", __FUNCTION__, __LINE__, new_size, dst); + fprintf(D_DESC,"[D] %s:%d: turncate "XFMT" to %d\n", + __FUNCTION__, __LINE__, blkdst->vaddr, blkdst->size); #endif + blkdst->size -= new_size; + sym->st_size = blkdst->size; - assert(new_size > 0); assert(blkdst->size > 0); - - dstend = mjr_create_block_container(ctxt, 0, dst, new_size, 1); - hash_add(&ctxt->blkhash, _vaddr2str(dst), dstend); - - /* Correct existing symbol size and add new symbol */ - sym->st_size = blkdst->size; - mjr_block_symbol(ctxt, dstend, NULL, 0); - if (link_with) - { - mjr_block_relink(ctxt, tmpdst, dstend, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, tmpdst, dstend->id, link_with, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, dstend, tmpdst->id, link_with, CONTAINER_LINK_IN); - } - } - else + /* Correct existing symbol size and add new symbol pointing on new split block */ + dstend = mjr_create_block_container(ctxt, 0, dst, new_size, (new_size ? 1 : 0)); + hash_add(&ctxt->blkhash, _vaddr2str(dst), dstend); + mjr_block_symbol(ctxt, dstend); + mjr_block_relink(ctxt, tmpdst, dstend, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, tmpdst, dstend->id, MJR_LINK_BLOCK_COND_ALWAYS, + MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_OUT); + mjr_container_add_link(ctxt, dstend, tmpdst->id, MJR_LINK_BLOCK_COND_ALWAYS, + MJR_LINK_SCOPE_LOCAL, CONTAINER_LINK_IN); + } + else dstend = tmpdst; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dstend)); diff -Nru eresi-0.8a25/libmjollnir/src/ondisk.c eresi-0.0.20110516/libmjollnir/src/ondisk.c --- eresi-0.8a25/libmjollnir/src/ondisk.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/ondisk.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,16 +1,15 @@ -/* -** @file ondisk.c -** -** @brief Implement routines to store and load analysis data on disk -** -** Started : Thu Jul 28 02:39:14 2003 jfv -** -*/ - +/** +* @file libmjollnir/src/ondisk.c + * @ingroup libmjollnir + * + * @brief Implement routines to store and load analysis data on disk + * + * Started : Thu Jul 28 02:39:14 2003 jfv + * + */ #include "libmjollnir.h" - /** * @brief Save and prepare a buffer which will be saved into the elfshobj. * @@ -68,8 +67,10 @@ memcpy(buf->data + buf->maxlen, (char *) &curlink->id , sizeof(unsigned int)); buf->maxlen += sizeof(unsigned int); - memcpy(buf->data + buf->maxlen, (char *) &curlink->type , sizeof(unsigned int)); - buf->maxlen += sizeof(unsigned int); + memcpy(buf->data + buf->maxlen, (char *) &curlink->type, sizeof(unsigned char)); + buf->maxlen++; + memcpy(buf->data + buf->maxlen, (char *) &curlink->scope, sizeof(unsigned char)); + buf->maxlen++; cur = cur->next; } @@ -92,7 +93,8 @@ { u_int off; u_int tmpid; - u_int tmptype; + u_char tmptype; + u_char tmpscope; u_int tmpnbr; u_int findex; @@ -104,12 +106,12 @@ case CONTAINER_LINK_IN: off = (u_int) container->inlinks; tmpnbr = container->nbrinlinks; - container_linklists_create(container, CONTAINER_LINK_IN); + container_linklists_create(container, CONTAINER_LINK_IN, ctxt->obj->id); break; case CONTAINER_LINK_OUT: off = (u_int) container->outlinks; tmpnbr = container->nbroutlinks; - container_linklists_create(container, CONTAINER_LINK_OUT); + container_linklists_create(container, CONTAINER_LINK_OUT, ctxt->obj->id); break; default: PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -121,17 +123,19 @@ { tmpid = *(unsigned int *) ((char *) sectdata + off + *curoff); *curoff += sizeof (unsigned int); - tmptype = *(unsigned int *) ((char *) sectdata + off + *curoff); - *curoff += sizeof (unsigned int); + tmptype = *(unsigned char *) sectdata + off + *curoff; + *curoff += sizeof (unsigned char); + tmpscope = *(unsigned char *) sectdata + off + *curoff; + *curoff += sizeof (unsigned char); #if __DEBUG_ONDISK__ - fprintf(D_DESC," [__DEBUG_ONDISK__] Restored link: (%d/%d) sid:%u did:%u type:%u\n", - findex, tmpnbr, container->id, tmpid, tmptype); + fprintf(D_DESC," [__DEBUG_ONDISK__] Restored link: (%d/%d) sid:%u did:%u type:%u scope:%u\n", + findex, tmpnbr, container->id, tmpid, tmptype, tmpscope); #endif /* This function increments linklist->elmnbr */ if (tmpid) - mjr_container_add_link(ctxt, container, tmpid, tmptype, linktype); + mjr_container_add_link(ctxt, container, tmpid, tmptype, tmpscope, linktype); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -319,8 +323,6 @@ } /* Prevent double analysis */ - if (typeid == ASPECT_TYPE_BLOC) - ctxt->analysed = 1; cnt = hash_size(table); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); } diff -Nru eresi-0.8a25/libmjollnir/src/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/src/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/src/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/libmjollnir/src -END -cfg.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libmjollnir/src/cfg.c -END -symtab.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/946/trunk/libmjollnir/src/symtab.c -END -links.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libmjollnir/src/links.c -END -history.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/946/trunk/libmjollnir/src/history.c -END -container.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libmjollnir/src/container.c -END -findentry.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/946/trunk/libmjollnir/src/findentry.c -END -init.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/913/trunk/libmjollnir/src/init.c -END -display.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/946/trunk/libmjollnir/src/display.c -END -function.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/libmjollnir/src/function.c -END -fingerprint.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/913/trunk/libmjollnir/src/fingerprint.c -END -ondisk.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/946/trunk/libmjollnir/src/ondisk.c -END -core.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libmjollnir/src/core.c -END -blocks.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/946/trunk/libmjollnir/src/blocks.c -END diff -Nru eresi-0.8a25/libmjollnir/src/.svn/entries eresi-0.0.20110516/libmjollnir/src/.svn/entries --- eresi-0.8a25/libmjollnir/src/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/src -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -cfg.c -file - - - - -2008-04-06T23:16:30.533133Z -b354b3a9fa9e51a8740794fc714d8e7c -2008-03-27T22:53:48.747992Z -946 -may - -symtab.c -file - - - - -2008-04-06T23:16:30.570013Z -9442d7e335f1e571f1616cf78b7660b9 -2008-03-27T22:53:48.747992Z -946 -may - -links.c -file - - - - -2008-04-06T23:16:30.581356Z -12859d3f9ce12dc3ff91ea376f177b88 -2008-03-27T22:53:48.747992Z -946 -may - -history.c -file - - - - -2008-04-06T23:16:30.592697Z -8b25c7cdbcdf00249a0c8e0672eb6f4f -2008-03-27T22:53:48.747992Z -946 -may - -container.c -file - - - - -2008-04-06T23:16:30.603899Z -e5b1a0e37a41513aea3d02ddec8e1d4e -2008-03-27T22:53:48.747992Z -946 -may - -findentry.c -file - - - - -2008-04-06T23:16:30.615353Z -9e442c3e9f66c2561942266b586e1225 -2008-03-27T22:53:48.747992Z -946 -may - -init.c -file - - - - -2008-04-06T23:16:30.626610Z -d01098abe891aa83f2f764bf7dd9da91 -2008-03-17T23:26:05.201308Z -913 -thorkill - -display.c -file - - - - -2008-04-06T23:16:30.637901Z -5201e25594e53bbe21c09ad718406bfb -2008-03-27T22:53:48.747992Z -946 -may - -function.c -file - - - - -2008-04-06T23:16:30.649586Z -a4fb89f317759a432fac5ba40d10aaff -2008-03-27T22:53:48.747992Z -946 -may - -fingerprint.c -file - - - - -2008-04-06T23:16:30.660890Z -edb0da802d42a8f25526e37ba1195668 -2008-03-17T23:26:05.201308Z -913 -thorkill - -ondisk.c -file - - - - -2008-04-06T23:16:30.671981Z -72e9d8e751639faf3e118557f0bd61fa -2008-03-27T22:53:48.747992Z -946 -may - -core.c -file - - - - -2008-04-06T23:16:30.683556Z -c25fac49ae519a42059e422321e92a64 -2008-03-27T22:53:48.747992Z -946 -may - -blocks.c -file - - - - -2008-04-06T23:16:30.694918Z -2d116d8d2338501b854889c3ec002a8f -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/format eresi-0.0.20110516/libmjollnir/src/.svn/format --- eresi-0.8a25/libmjollnir/src/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/blocks.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/blocks.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/blocks.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/blocks.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,184 +0,0 @@ -/* -** @file libmjollnir/src/blocks.c -** -** Authors : sk, jfv, thorkill, strauss -** -** Started : Thu May 29 20:39:14 2003 sk -** Updated : Fri Dec 15 01:09:47 2006 jfv -** -*/ -#include "libmjollnir.h" - -/* Goto hash */ -hash_t goto_hash; - - -/** - * @brief Retreive control flow section content if any - * - * @return returns the number of blocks (0 probably means something is wrong) - */ -int mjr_blocks_get(mjrcontext_t *ctxt) -{ - elfshsect_t *sect; - int cnt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Parse arguments, load binary and resolve symbol */ - sect = elfsh_get_section_by_name(ctxt->obj, ELFSH_SECTION_NAME_EDFMT_BLOCKS, 0, 0, 0); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow section : use analyse command", 0); - - /* Retreive information */ - cnt = hash_size(&ctxt->blkhash); - if (cnt != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); - cnt = mjr_flow_load(ctxt, ASPECT_TYPE_BLOC); - - /* Return result */ - if (cnt != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flow analysis failed", -1); -} - - - - -/** - * @brief Get a block by vaddr - * - * If mode = 0, return block only if vaddr is equal to block starting address - * else return block if vaddr belong to block - */ -container_t *mjr_block_get_by_vaddr(mjrcontext_t *ctxt, - eresi_Addr vaddr, - int mode) -{ - container_t *ret; - btree_t *retbtree; - mjrblock_t *tmpblock; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!ctxt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "missing context", (NULL)); - -#if __DEBUG_BLOCKS__ - fprintf(D_DESC,"[D] %s: get %x (%d)\n", __FUNCTION__, vaddr, mode); -#endif - - /* Exact match */ - ret = hash_get(&ctxt->blkhash, _vaddr2str(vaddr)); - -#if __DEBUG_BLK_LOOKUP__ - if (ret) - fprintf(D_DESC,"[D] %s: found %x in hash\n", - __FUNCTION__, vaddr); -#endif - - if ((mode == MJR_BLOCK_GET_STRICT) || ((mode == MJR_BLOCK_GET_FUZZY) && (ret))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - - retbtree = ctxt->block_btree; - while (retbtree) - { - - /* Parent match */ - ret = (container_t *)retbtree->elem; - tmpblock = (mjrblock_t *)ret->data; - -#if __DEBUG_BLK_LOOKUP__ - fprintf(D_DESC,"[D] %s: checking block: %x:%x s:%d id:%d\n", - __FUNCTION__, - tmpblock->vaddr, - tmpblock->vaddr+tmpblock->size, - tmpblock->size, - ret->id); -#endif - - if ((tmpblock->vaddr <= vaddr) && (vaddr <= tmpblock->vaddr + tmpblock->size)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - - if (tmpblock->vaddr < vaddr) - retbtree = retbtree->right; - else - retbtree = retbtree->left; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); -} - - - - -/** - * @brief Simple debug function for block containers - */ -int mjr_block_dump(mjrcontext_t* ctxt, container_t *c) -{ - mjrblock_t *blk; - mjrblock_t *tblk; - listent_t *llnk; - mjrlink_t *lnk; - - blk = (mjrblock_t *) c->data; - fprintf(D_DESC,"[D] %s: vaddr:" AFMT " size:%d in container ID:%d OUT:%d IN:%d\n", - __FUNCTION__, blk->vaddr, blk->size, c->id, c->outlinks->elmnbr, c->inlinks->elmnbr); - - for (llnk = c->inlinks->head; llnk; llnk = llnk->next) - { - lnk = (mjrlink_t *) llnk->data; - tblk = (mjrblock_t *) mjr_lookup_container(ctxt, lnk->id)->data; - fprintf(D_DESC,"[D] %s: " AFMT " linked IN from vaddr:" AFMT " size:%d type:%d\n", - __FUNCTION__, blk->vaddr, tblk->vaddr, tblk->size, lnk->type); - } - for (llnk = c->outlinks->head; llnk; llnk = llnk->next) - { - lnk = (mjrlink_t *) llnk->data; - tblk = (mjrblock_t *) mjr_lookup_container(ctxt, lnk->id)->data; - fprintf(D_DESC,"[D] %s: " AFMT " linked OUT to vaddr:" AFMT " size:%d type:%d\n", - __FUNCTION__, blk->vaddr, tblk->vaddr, tblk->size, lnk->type); - } - return 0; -} - - - - -/** - * @brief Inject a symbol associated to a block container - * @param csrc Container for which a symbol has to be injected - * @param curaddr Address of currently analyzed instruction - * @param resize 1 if current block size has to be computed from the value of curaddr - * @return Always 0 - */ -int mjr_block_symbol(mjrcontext_t *ctxt, container_t *csrc, - eresi_Addr curaddr, u_char resize) -{ - mjrblock_t *block; - elfsh_Sym bsym; - elfsh_Sym *sym; - char *prefix; - char buffer[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Insert new block symbol */ - block = (mjrblock_t *) csrc->data; - prefix = (char *) config_get_data(MJR_CONFIG_BLOC_PREFIX); - if (resize) - block->size = curaddr - block->vaddr + asm_instr_len(&ctxt->hist[MJR_HISTORY_CUR].instr); - - snprintf(buffer, sizeof(buffer), "%s"AFMT, prefix, block->vaddr); - sym = elfsh_get_symbol_by_name(ctxt->obj, buffer); - if (!sym) - { - bsym = elfsh_create_symbol(block->vaddr, block->size, STT_BLOCK, 0, 0, 0); - elfsh_insert_symbol(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, buffer); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/cfg.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/cfg.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/cfg.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/cfg.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,404 +0,0 @@ -/* -** (C) 2006-2008 Devhell Labs / Asgard Labs -** - sk, jfv, thorolf, strauss -** -** @file libmjollnir/types.c -** -** @brief Functions that use the typed instructions information in libasm -** -*/ -#include "libmjollnir.h" - - -/** - * @brief This function trace execution flow and creates block depending on instruction. - * - * If instruction break execution flow, block is considerated finished and added - * to linked list of blocks (that is the content of the .edfmt.blocks section) - * - * Depending on instruction type -based on IA32 instruction set- - * - * ASM_TYPE_CONDBRANCH: jcc, loop, MAY NOT break execution flow - * ASM_TYPE_CALLPROC: calls break instruction flow but CAN restore it - * ASM_TYPE_IMPBRANCH, ASM_TYPE_RETPROC: jmp and ret break execution flow - * - * The last two types reset g_prevaddr as execution flow won't be restored - * to following instruction. - * - * FIXME : this function must be tested on other architectures - * - */ -int mjr_trace_control(mjrcontext_t *context, - elfshobj_t *obj, - asm_instr *curins, - eresi_Addr curvaddr) -{ - int ilen; - container_t *fun; - eresi_Addr dstaddr; - eresi_Addr retaddr; - u_int addend; - - /* Initialize stuffs */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - context->obj = obj; - mjr_history_write(context, curins, curvaddr, MJR_HISTORY_CUR); - mjr_history_write(context, curins, curvaddr, 0); - ilen = asm_instr_len(curins); - fun = mjr_function_get_by_vaddr(context, curvaddr); - if (fun) - context->curfunc = fun; - else - mjr_asm_check_function_start(context); - fun = NULL; - - /* Switch on instruction types provided by libasm */ - if (curins->type & ASM_TYPE_CONDBRANCH) - { - dstaddr = mjr_get_jmp_destaddr(context); - -#if __DEBUG_FLOW__ - fprintf(D_DESC, - "[D] %s: " XFMT " ASM_TYPE_CONDBRANCH T:" XFMT - " F:" XFMT"\n", __FUNCTION__, curvaddr, dstaddr, curvaddr + ilen); -#endif - - if (dstaddr != -1) - mjr_link_block_jump(context, curvaddr, dstaddr, curvaddr + ilen); - - } - else if (curins->type == ASM_TYPE_IMPBRANCH) - { - dstaddr = mjr_get_jmp_destaddr(context); - -#if __DEBUG_FLOW__ - fprintf(D_DESC, - "[D] mjr_asm_flow: " XFMT " ASM_TYPE_IMPBRANCH T:" XFMT - " F: NULL \n", curvaddr, dstaddr); -#endif - - if (dstaddr != (eresi_Addr) -1) - mjr_link_block_jump(context, curvaddr, dstaddr, 0); - - } - else if (curins->type & ASM_TYPE_CALLPROC) - { - dstaddr = mjr_get_call_destaddr(context); - -#if __DEBUG_FLOW__ - fprintf(D_DESC, - "[D] %s: " XFMT " ASM_TYPE_CALLPROC T:" XFMT - " F:" XFMT "\n", __FUNCTION__, curvaddr, dstaddr, curvaddr + ilen); -#endif - - context->calls_seen++; - - /* For delay slot */ - addend = (context->proc.type == ASM_PROC_SPARC ? 4 : 0); - - /* If call occured at the end of a section */ - if (curvaddr + ilen + addend >= context->cursct->shdr->sh_size + context->cursct->shdr->sh_addr) - { -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[W] %s: unusual retaddr found - expected ret:%x section end:%x\n", - __FUNCTION__, curvaddr + ilen + addend, context->cursct->shdr->sh_size + context->cursct->shdr->sh_addr); -#endif - - retaddr = NULL; - } - else - retaddr = curvaddr + ilen + addend; - - /* 20070102 - * FIXME: we should be able to resolve CALL 0x0 (dstaddr == 0), - * Possible libasm or mjollnir bug. - */ - if (dstaddr && dstaddr != (eresi_Addr) -1) - { - /* Link block layer */ - mjr_link_block_call(context, curvaddr, dstaddr, retaddr); - - /* Link function layer */ - mjr_link_func_call(context, curvaddr, dstaddr, retaddr); - context->calls_found++; - } - } - else if (curins->type == ASM_TYPE_RETPROC) - { - -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: " XFMT " ASM_TYPE_RETPROC\n", - __FUNCTION__, curvaddr); -#endif - } - else - { -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: CUR: %x DEFAULT %d\n", - __FUNCTION__, curvaddr, curins->type); -#endif - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - -/** - * @brief Support function pointers computations - * - * Handle something like this : call *%reg - * - * -> Check goto table and fixup destination - * - * - start gdb, set breakpoint on a known pointer function, run the prog - * - check register value at breakpoint - * - start elfsh - * - addgoto - * - * TODO: - * history of mov to reg when second operand was an address ;-) - * - * 804933c: 89 d1 mov %edx,%ecx - * 804933e: 89 15 c0 e2 04 08 mov %edx,0x804e2c0 - * ... - * 804936c: ff d2 call *%edx - * - * FIXME : this function must be ported to the SPARC architecture - */ -eresi_Addr mjr_compute_fctptr(mjrcontext_t *context) -{ - char tmp[255]; - char *ret; - eresi_Addr dest; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - printf(" [*] Found function pointer called from " XFMT "\n", - context->hist[MJR_HISTORY_CUR].vaddr); - snprintf(tmp, sizeof(tmp), AFMT, context->hist[MJR_HISTORY_CUR].vaddr); - - /* We deal with a constructed address */ - - /* Specific pattern (simple one) */ - /* As we dont do any real dataflow analysis yet, we dont handle automatically - complex case where addresses are constructed in a complex way */ - - if (context->hist[MJR_HISTORY_CUR].instr.instr == ASM_CALL && - context->hist[MJR_HISTORY_PREV].instr.instr == ASM_MOV && - context->hist[MJR_HISTORY_PPREV].instr.instr == ASM_MOV) - { - dest = context->hist[MJR_HISTORY_PPREV].instr.op[1].imm; - - if (dest < elfsh_get_entrypoint(context->obj->hdr)) - { - printf(" [*] FAILED to resolve function pointer called from " XFMT "\n", - context->hist[MJR_HISTORY_CUR].vaddr); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid target vaddr for function pointer", - (eresi_Addr) -1); - } - -#if __DEBUG_MJOLLNIR__ - printf(" [*] 0x%lx Detected possible FUNCPTR at [%lx/%ld] \n", - (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, - (unsigned long) dest, (unsigned long) dest); -#endif - - printf(" [*] RESOLVED function pointer called from 0x%08lx -> 0x%08lx \n", - (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, - (unsigned long) dest); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); - } - - /* Instead we have a hash table that we can add element to using the 'addgoto' - command of elfsh. That allow to tell which is the target address manually - and make the graph continuous even with complex address construction */ - - /* Happens when an address was manually inserted in the routing table */ - /* This allow to avoid the control flow graph to be broken if elfsh - is not capable to recompute the target address */ - /* So the keys for this hash tables are the vaddr of the instruction that does - the complex function pointer call */ - - ret = (char *) hash_get(&goto_hash, tmp); - if (!ret) - { - printf(" [*] UNABLE to resolve function pointer called from 0x%08lx\n", - (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to compute function pointer target", (eresi_Addr) -1); - } - - dest = strtol(ret, (char **) NULL, 16); - if (dest) - { -#if __DEBUG_MJOLLNIR__ - printf(" [*] Extended routing table found 0x%lx -> 0x%lx\n", - (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, - (unsigned long) dest); -#endif - } - - printf(" [*] RESOLVED function pointer called from 0x%08lx -> 0x%08lx \n", - (unsigned long) context->hist[MJR_HISTORY_CUR].vaddr, - (unsigned long) dest); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); -} - -/** - * @brief Resolve the destination address of current call - * @param context mjorllnir context strucutre - */ -eresi_Addr mjr_get_call_destaddr(mjrcontext_t *context) -{ - int ilen; - eresi_Addr dest; - asm_instr *ins; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dest = 0; - ins = &context->hist[MJR_HISTORY_CUR].instr; - - if (context->proc.type == ASM_PROC_IA32) - { - /* The target block is called directly */ - if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) - { - ilen = asm_instr_len(ins); - asm_operand_get_immediate(ins, 1, 0, &dest); - dest += ilen + context->hist[MJR_HISTORY_CUR].vaddr; - } - /* The target block is called indirectly : if we find a pattern that correspond - to an easy to predict function pointer, then we compute it */ - else if (ins->op[0].content & ASM_OP_BASE) - dest = mjr_compute_fctptr(context); - else - dest = -1; - } - else if (context->proc.type == ASM_PROC_SPARC) - { - if (ins->instr == ASM_SP_CALL) - { - if (ins->op[0].content & ASM_SP_OTYPE_DISP30) - { - dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; - } - else /* Indirect call (special case of JMPL) */ - dest = -1; - } - } - else - dest = -1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); -} - -/** - * @brief Resolve the destination address of current jmp instruction - * @param context mjollnir context structure - */ -eresi_Addr mjr_get_jmp_destaddr(mjrcontext_t *context) -{ - int ilen; - eresi_Addr dest; - asm_instr *ins; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dest = 0; - ins = &context->hist[MJR_HISTORY_CUR].instr; - - if (context->proc.type == ASM_PROC_IA32) - { - /* The target block is called directly */ - if ((ins->op[0].content & ASM_OP_VALUE) && !(ins->op[0].content & ASM_OP_REFERENCE)) - { - ilen = asm_instr_len(ins); - asm_operand_get_immediate(ins, 1, 0, &dest); - dest += ilen + context->hist[MJR_HISTORY_CUR].vaddr; - } - - /* The target block is called indirectly : if we find a pattern that correspond - to an easy to predict function pointer, then we compute it */ - else if (ins->op[0].content & ASM_OP_BASE) - dest = mjr_compute_fctptr(context); - else - dest = -1; - } - else if (context->proc.type == ASM_PROC_SPARC) - { - if (ins->instr & ASM_SP_JMPL) /* Indirect jump */ - { - dest = -1; - } - else if (ins->type & ASM_TYPE_CONDBRANCH) - { - dest = (ins->op[0].imm * 4) + context->hist[MJR_HISTORY_CUR].vaddr; - } - } - else - dest = -1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); -} - -/** - * @brief Check if we missed some function start - * @param ctxt mjollnir context structure - */ -int mjr_asm_check_function_start(mjrcontext_t *ctxt) -{ - char *tmpstr; - u_int tmpaddr; - container_t *fun; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* check function prologue */ - if (ctxt->proc.type == ASM_PROC_IA32) - { - if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SUB && - ctxt->hist[MJR_HISTORY_PREV].instr.instr == ASM_MOV && - ctxt->hist[MJR_HISTORY_PPREV].instr.instr == ASM_PUSH) - { - tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_PPREV].vaddr); - tmpaddr = ctxt->hist[MJR_HISTORY_PPREV].vaddr; - -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: function start found at %x for %x\n", - __FUNCTION__, ctxt->hist[MJR_HISTORY_CUR].vaddr, tmpaddr); -#endif - fun = mjr_create_function_container(ctxt, tmpaddr, 0, tmpstr, NULL, NULL); - mjr_function_register(ctxt, tmpaddr, fun); - ctxt->curfunc = mjr_function_get_by_vaddr(ctxt, tmpaddr); - } - } - else if (ctxt->proc.type == ASM_PROC_SPARC) - { - if (ctxt->hist[MJR_HISTORY_CUR].instr.instr == ASM_SP_SAVE && - ctxt->hist[MJR_HISTORY_CUR].instr.op[0].baser == ASM_REG_O6 && - ctxt->hist[MJR_HISTORY_CUR].instr.op[1].type == ASM_SP_OTYPE_IMMEDIATE && - ctxt->hist[MJR_HISTORY_CUR].instr.op[2].baser == ASM_REG_O6) - { - tmpstr = _vaddr2str(ctxt->hist[MJR_HISTORY_CUR].vaddr); - tmpaddr = ctxt->hist[MJR_HISTORY_CUR].vaddr; - -#if __DEBUG_FLOW__ - fprintf(D_DESC,"[D] %s: function start found at %x for %x\n", - __FUNCTION__, ctxt->hist[MJR_HISTORY_CUR].vaddr, tmpaddr); -#endif - - fun = mjr_create_function_container(ctxt, tmpaddr, 0, tmpstr, NULL, NULL); - mjr_function_register(ctxt, tmpaddr, fun); - ctxt->curfunc = mjr_function_get_by_vaddr(ctxt, tmpaddr); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/container.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/container.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/container.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/container.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,397 +0,0 @@ -/** - * 2001-2007 Devhell Labs, Rfdslabs, Asgardlabs - * - * @file container.c - * @brief An API for generic containers data structures - * - */ - -#include "libmjollnir.h" - -/** - * @brief Initialize containers for context - * @param ctx mjollnir context - */ -int mjr_init_containers(mjrcontext_t *ctx) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, ctx->reg_containers, - sizeof(container_t*) * ctx->cntnrs_size, -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Resize containers for given context - * @param ctx mjollnir context - */ -int mjr_resize_containers(mjrcontext_t *ctx, unsigned int resize) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ctx->cntnrs_size += (resize ? resize + 1 : MJR_CNTNRS_INCREMENT); - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - ctx->reg_containers, ctx->reg_containers, - sizeof(container_t*) * ctx->cntnrs_size, -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Register new container for given context - * @param ctx mjollnir context - * @param cntnr container - */ -unsigned int mjr_register_container(mjrcontext_t *ctx, container_t *cntnr) -{ - - /* Allocate more memory if we lack some */ - if (ctx->next_id >= ctx->cntnrs_size) - { - if (ctx->cntnrs_size < MJR_CNTNRS_INCREMENT * MJR_MAX_INCREMENTS) - mjr_resize_containers(ctx, 0); - else - return 0; - } - - ctx->reg_containers[ctx->next_id] = cntnr; - cntnr->id = ctx->next_id; - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: %x registred id: %d type: %d\n", - __FUNCTION__, *(eresi_Addr *) cntnr->data, cntnr->id, cntnr->type); -#endif - - return ctx->next_id++; -} - -/** - * Register container in context by id - * @param ctx mjollnir context - */ -unsigned int mjr_register_container_id(mjrcontext_t *ctx, container_t *cntnr) -{ - - /* When reloading containers from on-disk, containers can be stored in any ID order, thus - we need to make sure we allocate sufficiently room, not just an atomic alloc increment */ - if (cntnr->id >= ctx->cntnrs_size) - { - if (ctx->cntnrs_size < MJR_CNTNRS_INCREMENT * MJR_MAX_INCREMENTS) - mjr_resize_containers(ctx, (cntnr->id - ctx->cntnrs_size)); - else - return 0; - } - - ctx->reg_containers[cntnr->id] = cntnr; - if (cntnr->id >= ctx->next_id) - ctx->next_id = cntnr->id + 1; - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: %x registred id: %d\n", - __FUNCTION__, *(eresi_Addr *) cntnr->data, cntnr->id); -#endif - - return cntnr->id; -} - -/** - * @brief Unregister container by id - * @param ctx mjollnir context - * @param id container id - */ -void mjr_unregister_container(mjrcontext_t *ctx, unsigned int id) -{ - ctx->reg_containers[id] = NULL; -} - -/** - * Lookup container by id - * @param ctx mjollnir context - * @param id container id - */ -container_t *mjr_lookup_container(mjrcontext_t *ctx, unsigned int id) -{ - return ctx->reg_containers[id]; -} - - -/** - * Add a generic link (input or output) to a container - */ -mjrlink_t *mjr_container_add_link(mjrcontext_t *ctx, - container_t *cntnr, - unsigned int id, - int link_type, - int link_direction) -{ - list_t *linklist; - listent_t *listent; - listent_t *savednext; - mjrlink_t *link; - container_t *cnt; - char linkname[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_CNTNR__ - if (cntnr->id == id) - fprintf(D_DESC, "[D] %s: linking the same container id:%d\n", - __FUNCTION__, id); -#endif - - /* Check if we are linked with container id by other link type */ - linklist = mjr_link_get_by_direction(cntnr, link_direction); - for (listent = linklist->head; listent; listent = savednext) - { - link = (mjrlink_t *) listent->data; - cnt = ctx->reg_containers[link->id]; - savednext = listent->next; - - if (cnt->type == cntnr->type && link->id == id) - { - -#if __DEBUG_CNTNR__ - fprintf(D_DESC, "[D] %s: already linked with id:%d type:%d/%d\n", - __FUNCTION__, id, link->type, link_type); -#endif - - if (link->type == link_type) - { - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: return existing link id:%d\n", __FUNCTION__, id); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, link); - } - - else if ((link->type == MJR_LINK_BLOCK_COND_ALWAYS) && - ((link_type == MJR_LINK_BLOCK_COND_TRUE) || - (link_type == MJR_LINK_BLOCK_COND_FALSE))) - { - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: removing old link id:%d from type:%d to %d\n", - __FUNCTION__,id, link->type,link_type); -#endif - - elist_del(linklist, listent->key); - } - } - } - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: link id:%d -> id:%d type:%d dir:%d\n", - __FUNCTION__, cntnr->id, id, link_type, link_direction); -#endif - - /* Create and add the new link */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, link, sizeof(mjrlink_t), NULL); - link->id = id; - link->type = link_type; - snprintf(linkname, sizeof(linkname), "link_%u", id); - elist_add(linklist, strdup(linkname), link); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, link); -} - - - -/** - * Return a link giving its type - */ -mjrlink_t *mjr_get_link_by_type(list_t *listlink, int link_type) -{ - listent_t *ent; - mjrlink_t *curlink; - - if (!listlink || !listlink->head) - return (NULL); - for (ent = listlink->head; ent; ent = ent->next) - { - curlink = (mjrlink_t *) ent->data; - if (curlink->type == link_type) - return curlink; - } - return (NULL); -} - - -/** - * - */ -int match_block(void *elem, void *match) -{ - mjrblock_t *blk_elem, *blk_match; - - blk_elem = (mjrblock_t *)((container_t *)elem)->data; - blk_match = (mjrblock_t *)((container_t *)match)->data; - - return (blk_match->vaddr - blk_elem->vaddr); -} - - - - -/** - * @brief Creates a block container - */ -container_t *mjr_create_block_container(mjrcontext_t *ctx, - u_int symoff, - eresi_Addr vaddr, - u_int size, - u_char seen) -{ - mjrblock_t *newblock; - container_t *newcntnr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_CNTNR__ - newcntnr = mjr_get_container_by_vaddr(ctx, vaddr, ASPECT_TYPE_BLOC); - if (newcntnr) - { - fprintf(D_DESC,"[D] %s: block container %x id:%d is there ALREADY\n", - __FUNCTION__, vaddr, newcntnr->id); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); - } -#endif - - newblock = alloca(sizeof(mjrblock_t)); - bzero(newblock, sizeof(mjrblock_t)); - newblock->symoff = symoff; - newblock->vaddr = vaddr; - newblock->size = size; - newblock->seen = seen; - newcntnr = container_create(ASPECT_TYPE_BLOC, newblock, NULL, NULL); - if (!newcntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create block container", NULL); - -#if __DEBUG_CNTNR__ - fprintf(D_DESC, "[D] %s: create block addr " XFMT " (sz %d)\n", __FUNCTION__, vaddr, size); -#endif - - mjr_register_container(ctx, newcntnr); - - /* fill the btree */ - btree_insert_sort(&ctx->block_btree, match_block, newcntnr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); -} - - -/** - * Creates function container - */ -container_t *mjr_create_function_container(mjrcontext_t *ctx, - eresi_Addr vaddr, - u_int size, - char *name, - mjrblock_t *first, - char *md5) -{ - mjrfunc_t *newfunction; - container_t *newcntnr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_CNTNR__ - newcntnr = mjr_get_container_by_vaddr(ctx, vaddr, ASPECT_TYPE_FUNC); - if (newcntnr) - { - fprintf(D_DESC,"[D] %s: func container addr %x id:%d is there ALREADY\n", - __FUNCTION__, vaddr, newcntnr->id); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); - } -#endif - - /* Allocate the new container and its links lists */ - newfunction = alloca(sizeof(mjrfunc_t)); - bzero(newfunction, sizeof(mjrfunc_t)); - newfunction->vaddr = vaddr; - newfunction->size = size; - - /* Create name and md5 string for function */ - if (name) - strncpy(newfunction->name, (char *) name, sizeof(newfunction->name) - 1); - if (md5) - memcpy(newfunction->md5, md5, sizeof(newfunction->md5)); - -#if __DEBUG_CNTNR__ - fprintf(D_DESC,"[D] %s: create func addr: %x name: <%s> (sz %d) (md5 %s)\n", - __FUNCTION__, vaddr, name, size, md5); -#endif - - newcntnr = container_create(ASPECT_TYPE_FUNC, newfunction, NULL, NULL); - if (!newcntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create function container", NULL); - mjr_register_container(ctx, newcntnr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newcntnr); -} - - -/** - * @brief This function should be used only for debug - * It is O(n) since this api doesn't know about hashes in the mjr context - */ -container_t *mjr_get_container_by_vaddr(mjrcontext_t *ctx, eresi_Addr vaddr, int type) -{ - container_t *cur; - u_int idx; - - PROFILER_IN(__FILE__,__FUNCTION__,__LINE__); - - for (idx = 1, cur = ctx->reg_containers[idx]; cur; cur = ctx->reg_containers[++idx]) - if (cur->type == type && *(eresi_Addr *) cur->data == vaddr) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cur); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - -/* Debug output help function for containers */ -void mjr_container_dump(mjrcontext_t *ctx, int what) -{ - container_t *cur; - mjrfunc_t *tf; - u_int idx; - - for (idx = 1, cur = ctx->reg_containers[idx]; cur; cur = ctx->reg_containers[++idx]) - { - if (cur->type == what) - { - if (cur->type == ASPECT_TYPE_FUNC) - { - tf = cur->data; - printf("FOUND: FUNC T:%d V:" AFMT " I:%d O:%d\n", - what, tf->vaddr, cur->inlinks->elmnbr, cur->outlinks->elmnbr); - } - else if (cur->type == ASPECT_TYPE_BLOC) - { - mjr_block_dump(ctx, cur); - } - } - } -} - - -/** - * @brief Get the list of links for the desired direction (input or output) - */ -list_t *mjr_link_get_by_direction(container_t *c, int dir) -{ - list_t *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = NULL; - if (dir == CONTAINER_LINK_IN) - ret = c->inlinks; - else if (dir == CONTAINER_LINK_OUT) - ret = c->outlinks; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - - - - - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/core.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/core.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/core.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/core.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,339 +0,0 @@ -/* -** (C) 2006-2008 The ERESI team -** -** @file core.c -** @brief Implement low-level functions of the libmjollnir library -** -*/ - -#include "libmjollnir.h" - -/** - * @brief Core control flow analysis function at a given address - * @param sess Mjollnir session - * @param ptr Code buffer pointer to analyse - * @param vaddr Entry point address for analysis - * @param len Size of code to analyse - */ -static int mjr_analyse_code(mjrsession_t *sess, unsigned char *ptr, eresi_Addr vaddr, int len) -{ - asm_instr instr; - unsigned int curr, ilen; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if we have reached the limit bound */ - //limit = (u_int) config_get_data(CONFIG_CFGDEPTH); - // Please use this config variable when doing CFG recursive analysis - - /* Read all instructions of the section */ - for (curr = 0; curr < len; curr += ilen) - { - ilen = asm_read_instr(&instr, ptr + curr, len - curr, &sess->cur->proc); - -#if __DEBUG_READ__ - fprintf(D_DESC,"[D] %s/%s,%d: ilen=%d\n", __FUNCTION__, __FILE__, __LINE__, ilen); -#endif - - if (ilen > 0) - { - mjr_history_shift(sess->cur, instr, vaddr + curr); - mjr_trace_control(sess->cur, sess->cur->obj, &instr, vaddr + curr); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "asm_read_instr returned <= 0 lenght", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Analyse control flow at a given address - * @param sess Mjollnir session - * @param addr Entry point address for analysis - * @param flags - */ -static int mjr_analyse_addr(mjrsession_t *sess, eresi_Addr addr, int flags) -{ - elfshsect_t *parent; - elfsh_SAddr offset; - container_t *block; - unsigned char *ptr; - unsigned long len; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ptr = elfsh_get_raw(sess->cur->cursct); - len = sess->cur->cursct->shdr->sh_size; - - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to analyse control flow", -1); - - parent = elfsh_get_parent_section(sess->cur->obj, addr, &offset); - if (!parent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to find parent section", -1); - - block = mjr_create_block_container(sess->cur, 0, addr, - parent->shdr->sh_size - offset, 1); - if (!block) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create parent container", -1); - - hash_add(&sess->cur->blkhash, _vaddr2str(addr), block); - - - ptr = elfsh_get_raw(sess->cur->cursct); - len = parent->shdr->sh_size - offset ; - - if (mjr_analyse_code(sess, ptr + offset, addr, len) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during code analysis", -1); - - if (mjr_analyse_finished(sess) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during storage of analysis info", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief This function will find calls including calls trought a pointer - * @param sess Mjollnir session - * @param section_name The name of the section we want to analyse - */ -int mjr_analyse_section(mjrsession_t *sess, char *section_name) -{ - container_t *cntnr; - unsigned char *ptr; - unsigned long len; - eresi_Addr e_point, vaddr; - eresi_Addr main_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* load section */ -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG_MJOLLNIR__] %s: loading %s\n", - __FUNCTION__, section_name); -#endif - - /* We just started here so we can clear the current section in context */ - sess->cur->cursct = NULL; - - if (!section_name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section name empty", -1); - - sess->cur->cursct = elfsh_get_section_by_name(sess->cur->obj, section_name, NULL, NULL, NULL); - if (!sess->cur->cursct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section not found", -1); - -#if __DEBUG_CALLS__ - fprintf(D_DESC, "[__DEBUG_CALLS__] %s: vaddr:%x size:%d foff:%d\n", - __FUNCTION__, sess->cur->cursct->shdr->sh_addr, - sess->cur->cursct->shdr->sh_size, - sess->cur->cursct->shdr->sh_offset); -#endif - - /* Setup initial conditions */ - ptr = elfsh_get_raw(sess->cur->cursct); - len = sess->cur->cursct->shdr->sh_size; - vaddr = sess->cur->cursct->shdr->sh_addr; - e_point = elfsh_get_entrypoint(elfsh_get_hdr(sess->cur->obj)); - - /* Create block pointing to this section */ - if (sess->cur->cursct->shdr->sh_addr == e_point) - { - printf(" [*] Entry point: " AFMT "\n", e_point); - main_addr = mjr_trace_start(sess->cur, ptr, - sess->cur->cursct->shdr->sh_size, e_point); - printf(" [*] main located at " AFMT "\n", main_addr); - } - else - { - cntnr = mjr_create_function_container(sess->cur, vaddr, 0, _vaddr2str(vaddr), 0, NULL); - sess->cur->curfunc = cntnr; - mjr_function_register(sess->cur,vaddr, cntnr); - } - - - /* Read all instructions of the section */ - if (mjr_analyse_code(sess, ptr, vaddr, len) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during code analysis", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -int mjr_analyse_finished(mjrsession_t *sess) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Store analyzed functions in file */ - if (mjr_flow_store(sess->cur, ASPECT_TYPE_FUNC) <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to store functions in file", -1); - - /* Store analyzed blocks in file */ - if (mjr_flow_store(sess->cur, ASPECT_TYPE_BLOC) <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to store blocks in file", -1); - - /* Set the flag and return */ - sess->cur->analysed = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Main analysis function - * @param sess Mjollnir session strucutre - * @param flags - */ -int mjr_analyse(mjrsession_t *sess, eresi_Addr entry, int flags) -{ - char *shtName; - elfsh_Shdr *shtlist, *shdr; - elfsh_Sym *sym, *lastsym; - elfshsect_t *sct; - container_t *fcnt; - int num_sht, idx_sht; - int index, blocksize; - eresi_Addr addr; - char c; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if ((NULL == sess) || (NULL == sess->cur)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - - /* Get section table */ - shtlist = elfsh_get_sht(sess->cur->obj, &num_sht); - if (!shtlist) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to get SHT", -1); - - /* Make sure we do what the user desires (remove previously stored analysis) */ - /* FIXME: should go in libstderesi/cmd_analyse command and use revm_output */ - if (sess->cur->analysed) - { - printf(" [*] %s section present ! \n" - " Analysis will remove currently stored information. " - "continue ? [N/y]", ELFSH_SECTION_NAME_EDFMT_BLOCKS); - - c = getchar(); - puts(""); - - if (c != 'y') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flow analysis aborted", 0); - - elfsh_remove_section(sess->cur->obj, ELFSH_SECTION_NAME_EDFMT_BLOCKS); - } - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC,"[__DEBUG__] mjr_analize: Found %d sections.\n",num_sht); -#endif - - /* In case we are provided an entry point */ - if (entry) - { - ret = mjr_analyse_addr(sess, entry, flags); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to analyse control flow by addr", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* - ** First run, create blocks starting at section vaddr - ** and in size of the section - */ - for (idx_sht = 0; idx_sht < num_sht; idx_sht++) - { - shdr = (shtlist + idx_sht); - sym = elfsh_get_sym_from_shtentry(sess->cur->obj, shdr); - - if (!elfsh_get_section_execflag(shdr) || - !elfsh_get_section_allocflag(shdr) || - !sym) - continue; - - shtName = elfsh_get_symbol_name(sess->cur->obj, sym); - sct = elfsh_get_section_by_name(sess->cur->obj, shtName, NULL, NULL, NULL); - - if (!sct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get section", -1); - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG__] %s: 1st run - Executable section name=(%14s) " - "index=(%02i) vaddr=(%x) size=(%d)\n", - __FUNCTION__, shtName, idx_sht, sct->shdr->sh_addr, sct->shdr->sh_size); -#endif - - fcnt = mjr_create_block_container(sess->cur, 0, sct->shdr->sh_addr, - sct->shdr->sh_size, 1); - if (!fcnt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't create initial blocks", -1); - - hash_add(&sess->cur->blkhash, _vaddr2str(sct->shdr->sh_addr), fcnt); - } - - - /* Analyse all executable sections */ - for (idx_sht = 0; idx_sht < num_sht; idx_sht++) - { - shdr = (shtlist + idx_sht); - sym = elfsh_get_sym_from_shtentry(sess->cur->obj, shdr); - shtName = elfsh_get_symbol_name(sess->cur->obj, sym); - - if (!elfsh_get_section_execflag(shdr) || - !elfsh_get_section_allocflag(shdr)) - continue; - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, "[__DEBUG__] mjr_analize: Executable section name=(%14s) " - "index=(%02i)\n", shtName, idx_sht); -#endif - - mjr_analyse_section(sess, shtName); - } - - /* Find all unseen blocks (may be dead code) */ - for (lastsym = NULL, index = 0, sym = sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB]->altdata; - index < sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB]->shdr->sh_size / sizeof(elfsh_Sym); - index++) - { - if (elfsh_get_symbol_type(sym + index) != STT_BLOCK) - continue; - if (!lastsym) - { - lastsym = sym; - continue; - } - if (lastsym->st_value + lastsym->st_size != sym->st_value) - { - addr = lastsym->st_value + lastsym->st_size; - blocksize = sym->st_value - addr; - mjr_create_block_container(sess->cur, 0, addr, blocksize, 0); - lastsym = sym; - - fprintf(stderr, " [D] Adding UNLINKED block at " XFMT " ! \n", addr); - - } - } - - if (mjr_analyse_finished(sess) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during storage of analysis info", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/display.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/display.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/display.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/display.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,154 +0,0 @@ -/* -** @file display.c -** -** @brief Contain printing functions for debug purpose only -** -** FIXME: needs to use revm_output() and not printf inside elfsh. -** -** Started on Tue Jan 02 04:04:18 2006 jfv -** -*/ - -#include "libmjollnir.h" - -///** -// * Block dump for debug purposes -// * @param b mjrblock strucutre -// */ -//void mjr_block_dump(mjrblock_t *b) -//{ -// printf("[B]=(%lX) [V]=(%lX) sz=(%04u) \n", -// (unsigned long) b, (unsigned long) b->vaddr, b->size); -//} - - -/** - * @brief Display all information about a block - */ -int mjr_block_display(mjrcontext_t *ctxt, container_t *cur, mjropt_t *disopt) -{ - listent_t *curent; - mjrlink_t *ccal; - char *str; - char *end_str; - elfsh_SAddr offset; - elfsh_SAddr end_offset; - char buf1[30]; - char buf2[30]; - mjrblock_t *block; - mjrblock_t *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - block = cur->data; - str = elfsh_reverse_metasym(disopt->file, block->vaddr, &offset); - - end_str = elfsh_reverse_metasym(disopt->file, - block->vaddr + block->size, &end_offset); - - if (str == NULL) - *buf1 = 0x00; - else - snprintf(buf1, sizeof (buf1), "<%s + " UFMT ">", str, offset); - - if (end_str == NULL || !(mjr_get_link_by_type(cur->outlinks, MJR_LINK_BLOCK_COND_TRUE))) - *buf2 = 0x00; - else - snprintf(buf2, sizeof (buf2), "<%s + " UFMT ">", end_str, end_offset); - - printf("[%8lx:%05i] %-30s --> %-30s ", - (unsigned long) block->vaddr, block->size, buf1, buf2); - - /* - if (cur->false == 0xFFFFFFFF) - printf(" [?]"); - else if (cur->false != NULL) - { - str = elfsh_reverse_metasym(disopt->file, cur->false, &offset); - printf(" [%s + " UFMT "]", (str ? str : ""), offset); - } - */ - - printf("\n"); - if (disopt->level > 0) - for (curent = cur->inlinks->head; curent; curent = curent->next) - { - ccal = (mjrlink_t *) curent->data; - tmp = mjr_lookup_container(ctxt, ccal->id)->data; - str = elfsh_reverse_metasym(disopt->file, tmp->vaddr, &offset); - printf("\texecuted from: (" AFMT ") <%s + " UFMT ">\n", - tmp->vaddr, (str ? str : ""), (elfsh_SAddr) offset); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ++disopt->counter); -} - - -/** - * @brief Print the content of the control flow section - */ -int mjr_blocks_display(mjrcontext_t *c, int level) -{ - mjropt_t opt; - container_t *block; - char **keys; - int index; - int blocnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - opt.counter = 0; - opt.level = level; - opt.file = c->obj; - keys = hash_get_keys(&c->blkhash, &blocnbr); - - for (index = 0; index < blocnbr; index++) - { - block = hash_get(&c->blkhash, keys[index]); - mjr_block_display(c, block, &opt); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, opt.counter); -} - -/** - * @brief Print information for functions - */ -void mjr_function_display(mjrfunc_t *func) -{ - printf(" - FUNC ["AFMT"] %30s MD5: %s \n", func->vaddr, func->name, func->md5); -} - -/** - * @brief Print the functions in the function hash for the current context - */ -void mjr_funcs_display(mjrcontext_t *c) -{ - char **keys; - int keynbr; - int index; - mjrfunc_t *current; - container_t *cntnr; - - keys = hash_get_keys(&c->funchash, &keynbr); - for (index = 0; index < keynbr; index++) - { - cntnr = hash_get(&c->funchash, keys[index]); - current = cntnr->data; - mjr_function_display(current); - } - hash_free_keys(keys); -} - - -/** - * @brief Shortcut for vaddr 2 string with allocation .. - */ -char *_vaddr2str(eresi_Addr addr) -{ - char *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, tmp, BSIZE_SMALL, NULL); - snprintf(tmp, BSIZE_SMALL, AFMT, addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, tmp); -} - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/findentry.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/findentry.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/findentry.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/findentry.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,212 +0,0 @@ -/* -** @file control.c -** -** Started : Thu May 29 20:44:39 2003 sk -** Updated : Sun Dec 30 16:45:48 2006 jfv -** -*/ - -#include "libmjollnir.h" - - -/** - * @brief Search main function from binary entry point. - * - * This function inspect the code at entry point and inject the resolved - * symbol for the main function. This is a separate function so that it - * can be called frmo the tracer and benefit from the main symbol presence - */ -eresi_Addr mjr_find_main(elfshobj_t *obj, - asm_processor *proc, - u_char *buf, - u_int len, - eresi_Addr vaddr, - u_int *dis) -{ - int stop; - elfsh_Sym *sym; - u_int ilen; - eresi_Addr init_addr; - asm_instr ins; - int arch_bin; - int fetch_next = 0; - eresi_Addr main_addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (*dis = stop = 0; !stop; *dis += ilen) - { - ilen = asm_read_instr(&ins, (u_char *) buf + *dis, - len - *dis, proc); - - if (!*dis) - { - if (proc->type == ASM_PROC_IA32) - { - switch (ins.instr) - { - case ASM_XOR: - arch_bin = MJR_BIN_LINUX; - break; - case ASM_PUSH: - arch_bin = MJR_BIN_FREEBSD; - sym = elfsh_get_metasym_by_name(obj, ELFSH_SECTION_NAME_INIT); - init_addr = sym->st_value; - fprintf(stderr, - " [*] locating call to .init: %lx\n", - (unsigned long) init_addr); - break; - - } - } - else if (proc->type == ASM_PROC_SPARC) - { - switch (ins.instr) - { - case ASM_SP_MOV: - arch_bin = MJR_BIN_LINUX; - break; - } - } - else if (proc->type == ASM_PROC_MIPS) - { - // FIXME: this should be expanded - arch_bin = MJR_BIN_LINUX; - } - - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Architecture not supported", -1); - - // FIXME: This should go to librevm - fprintf(stderr, " [*] %s-like start\n", arch_bin ? "FreeBSD" : "Linux"); - } - - /* Now fingerprint depending on the architecture */ - if (proc->type == ASM_PROC_IA32) - { - switch (ins.instr) - { - case ASM_PUSH: - if (*dis && (arch_bin == MJR_BIN_LINUX) && - ins.op[0].type == ASM_OTYPE_IMMEDIATE) - asm_operand_get_immediate(&ins, 1, 0, &main_addr); - break; - case ASM_CALL: - if (arch_bin == MJR_BIN_FREEBSD) - { - asm_operand_get_immediate(&ins, 1, 0, &main_addr); - if (fetch_next) - stop = 1; - - main_addr += vaddr + *dis + ilen; - if (main_addr == init_addr) - fetch_next = 1; - - break; - } - else if ((arch_bin == MJR_BIN_LINUX)) - { - stop = 1; - break; - } - } - } - else if (proc->type == ASM_PROC_SPARC) - { - switch (ins.instr) - { - case ASM_SP_SETHI: - if (ins.op[0].baser == ASM_REG_O0) - main_addr = ins.op[1].imm << 10; - break; - case ASM_SP_OR: - if (ins.op[0].baser == ASM_REG_O0 && - ins.op[2].baser == ASM_REG_O0 && - ins.op[1].type == ASM_SP_OTYPE_IMMEDIATE) - main_addr |= ins.op[1].imm; - break; - case ASM_SP_CALL: - stop = 1; - break; - } - } - else if (proc->type == ASM_PROC_MIPS) - { - // FIXME: this should be expanded (WIP) - main_addr = vaddr; - stop = 1; - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Architecture not supported", -1); - - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, main_addr); -} - - -/** - * This function traces the entry point and save the last push argument until - * a call is found. This allow to fetch the main address in an OS-dependent - * manner - */ -eresi_Addr mjr_trace_start(mjrcontext_t *context, - u_char *buf, - u_int len, - eresi_Addr vaddr) -{ - eresi_Addr main_addr; - container_t *main_container; - container_t *tmpcntnr; - u_int dis; - elfsh_Sym *sym; - elfsh_Sym bsym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!context || !buf) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", 0); - - if (!(elfsh_get_objtype(elfsh_get_hdr(context->obj)) == ET_EXEC)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object is not ET_EXEC", 0); - -#if defined(__DEBUG_MJOLLNIR__) - printf(" [*] _start found at 0x%lx\n", (unsigned long) vaddr); -#endif - - sym = elfsh_get_symbol_by_name(context->obj, "main"); - if (sym && sym->st_value) - main_addr = sym->st_value; - else - main_addr = mjr_find_main(context->obj, &context->proc, buf, len, vaddr, &dis); - - if (main_addr == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Could not find address of main", -1); - - tmpcntnr = mjr_create_function_container(context, vaddr, 0, "_start", 0, NULL); - mjr_function_register(context, vaddr, tmpcntnr); - - fprintf(stderr, "CREATING MAIN FUNC at %llX\n", main_addr); - - main_container = mjr_create_function_container(context, main_addr, 0, "main", 0, NULL); - mjr_function_register(context, main_addr, main_container); - - mjr_container_add_link(context, tmpcntnr, main_container->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); - mjr_container_add_link(context, main_container, tmpcntnr->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_IN); - mjr_link_block_call(context, vaddr, main_addr, vaddr + dis); - - /* Create symbols for main */ - /* Then we create the symbol for the bloc and returns */ - if (!sym || !sym->st_value) - { - bsym = elfsh_create_symbol(main_addr, 0, STT_FUNC, 0, 0, 0); - elfsh_insert_symbol(context->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, "main"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, main_addr); -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/fingerprint.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/fingerprint.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/fingerprint.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/fingerprint.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* -** @file fingerprint.c -** -** @brief Functions for fingerprinting inside libmjollnir -** -** Started : Mon Jan 02 01:18:14 2007 jfv -** -*/ - -#include "libmjollnir.h" - - -/** - * @brief Say if a block is the start of a function or not - */ -int mjr_block_funcstart(container_t *cntnr) -{ - listent_t *cur; - mjrlink_t *curlink; - mjrblock_t *blk; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!cntnr || cntnr->type != ASPECT_TYPE_BLOC) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - blk = cntnr->data; - -#if __DEBUG_BLOCK__ - fprintf(D_DESC,"[D] mjr_block_funcstart: blk:"XFMT"\n", blk->vaddr); -#endif - - for (cur = cntnr->inlinks->head; cur; cur = cur->next) - { - curlink = (mjrlink_t *) cur->data; - -#if __DEBUG_BLOCK__ - fprintf(D_DESC,"[D] mjr_block_funcstart: clr:"XFMT"/%d\n", - curlink->vaddr, curlink->type); -#endif - - if (curlink->type == MJR_LINK_FUNC_RET) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Depth First Search: distance fingerprinting algorithm - * @param c mjollnir context - * @param start mjollnir container - * @param type 0 for forward-fingerprinting, 1 for backwards - * @param curd current depth, Mind: minimum depth to search for, Maxd: Maximum depth - * @param weight : allow finer fingerprint by counting hits (should start with 0) - * @param mind min depth to match - * @param maxd max depth to match - * @param fprint : any intrabloc fingerprinting function that you like - */ -int mjr_fingerprint(mjrcontext_t *c, - container_t *start, - int type, - int weight, - int curd, // cur depth - int mind, // min depth to match - int maxd, // max depth to match - int (*fprint)(container_t *)) -{ - container_t *tmp; - list_t *listlink; - listent_t *cur; - mjrlink_t *curlink; - - if (type == CONTAINER_LINK_OUT) - listlink = start->outlinks; - else if (type == CONTAINER_LINK_IN) - listlink = start->inlinks; - else - return 0; - - /* We are not yet in the depth range of fingerprint, just recurse */ - if (curd < mind) - curd++; - - /* We are in the range. Fingerprint and recurse */ - else if (curd >= mind && maxd >= curd) - { - weight += fprint(start); - curd++; - } - - /* We passed the max distance. Stop recursing */ - else - return (weight); - - /* Now recursing ! */ - for (cur = listlink->head; cur; cur = cur->next) - { - curlink = (mjrlink_t *) cur->data; - tmp = mjr_lookup_container(c, curlink->id); - weight += mjr_fingerprint(c, tmp, type, weight, curd, mind, maxd, fprint); - } - - return weight; -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/function.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/function.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/function.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/function.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,281 +0,0 @@ -/** - * @file function.c - * - * @brief funtion containers related api - * - * (C) 2006-2008 Asgard Labs, thorolf - * 2006-2007 devhell, jfv - * 2007 rfd labs, strauss - * - */ - -#include - - -/** - * @brief Retrieve control flow section content if any - * @param ctxt mjorllnir context - * @return returns the number of functions (0 probably means something is wrong) - */ -int mjr_functions_get(mjrcontext_t *ctxt) -{ - elfshsect_t *sect; - int cnt; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Parse arguments, load binary and resolve symbol */ - sect = elfsh_get_section_by_name(ctxt->obj, - ELFSH_SECTION_NAME_EDFMT_FUNCTIONS, 0, 0, 0); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No functions section : use analyse command", 0); - - /* Retreive information */ - cnt = hash_size(&ctxt->funchash); - if (cnt != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); - - /* Return result */ - cnt = mjr_flow_load(ctxt, ASPECT_TYPE_FUNC); - if (cnt != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flow analysis failed", -1); -} - - - -/** - * @brief Function dumping procedure for debug purposes - */ -void mjr_function_dump(mjrcontext_t *ctxt, char *where, container_t *c) -{ - mjrfunc_t *f, *tmp; - listent_t *ent; - mjrlink_t *cur; - - f = (mjrfunc_t *) c->data; - fprintf(D_DESC," [D] FUNC DUMP in {%s}: " AFMT "/<%s>[%s] ID:%d No. Children: %d, No. Parents: %d\n", - where, f->vaddr, (f->name) ? f->name : NULL , - (f->md5) ? f->md5 : NULL , c->id, c->outlinks->elmnbr, c->inlinks->elmnbr); - - if (c->outlinks->head) - { - fprintf(D_DESC," [D] Child functions:\n [x] "); - for (ent = c->outlinks->head; ent; ent = ent->next) - { - cur = (mjrlink_t *) ent->data; - tmp = (mjrfunc_t *) mjr_lookup_container(ctxt,cur->id)->data; - fprintf(D_DESC, AFMT" ", tmp->vaddr); - } - fprintf(D_DESC,"\n"); - } - - if (c->inlinks->head) - { - fprintf(D_DESC," [D] Parent functions:\n [x] "); - for (ent = c->inlinks->head; ent; ent = ent->next) - { - cur = (mjrlink_t *) ent->data; - tmp = (mjrfunc_t *) mjr_lookup_container(ctxt,cur->id)->data; - fprintf(D_DESC, AFMT" ", tmp->vaddr); - } - fprintf(D_DESC,"\n"); - } -} - - -/** - * @brief Copy the function in a special buffer to fingerprint it - */ -int mjr_function_copy(mjrcontext_t *ctx, - unsigned char *src, - unsigned char *dst, - int mlen) -{ - int n, ilen, p; - asm_instr instr, hist[2]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (p = ilen = n = 0; n < mlen; n += ilen) - { - ilen = asm_read_instr(&instr, src + n, mlen - n, &ctx->proc); - if (ilen <= 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, p); - - /* Filter this out */ - if ((ctx->proc.type == ASM_PROC_IA32 && instr.instr != ASM_NOP) || - (ctx->proc.type == ASM_PROC_SPARC && instr.instr != ASM_SP_NOP)) - { - memcpy(dst + p, src, ilen); - p += ilen; - } - - /* epilog */ - if (ctx->proc.type == ASM_PROC_IA32) - { - if ((instr.instr == ASM_RET) && (hist[0].instr == ASM_LEAVE || - hist[0].instr == ASM_POP || - hist[0].instr == ASM_MOV)) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, p); - } - } - else if (ctx->proc.type == ASM_PROC_SPARC) - { - if ((instr.instr == ASM_SP_RESTORE && hist[0].instr == ASM_SP_RET) || - hist[0].instr == ASM_SP_RETL) - { - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, p); - } - } - hist[1] = hist[0]; - hist[0] = instr; - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy function", 0); -} - - - -/** - * @brief Finger print a function using X method - */ -void *mjr_fingerprint_function(mjrcontext_t *ctx, - eresi_Addr addr, - int type) { - - MD5_CTX md5ctx; - unsigned char fbuf[MJR_MAX_FUNCTION_LEN] = {0x00}; - unsigned char digest[16]; - char *pt; - void *ret; - u_int i; - int mlen; - elfsh_SAddr off; - elfshsect_t *sect; - unsigned char *buff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = NULL; - - /* Get function data */ - sect = elfsh_get_parent_section(ctx->obj, addr, &off); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown parent section", NULL); - - buff = elfsh_get_raw(sect); - buff += off; - - /* Select the desired fingerprinting function */ - switch (type) - { - case MJR_FPRINT_TYPE_MD5: - //memset(fbuf, 0, MJR_MAX_FUNCTION_LEN); - mlen = mjr_function_copy(ctx, buff, fbuf, MJR_MAX_FUNCTION_LEN); - - if (mlen <= 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - - MD5_Init(&md5ctx); - MD5_Update(&md5ctx, fbuf, mlen); - MD5_Final(digest, &md5ctx); - XALLOC(__FILE__, __FUNCTION__, __LINE__, ret, 34, NULL); - - if (!ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (NULL)); - - memset(ret, 0, 34); - pt = ret; - - for (i = 0; i < 16; i++, pt += 2) - sprintf(pt, "%02x", digest[i]); - - break; - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown fingerprint type", NULL); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * @brief Register function container in the context - * @param ctx mjollnir context structure - * @param vaddr virtual address of the function - * @param fun function container - */ -int mjr_function_register(mjrcontext_t *ctx, u_int vaddr, container_t *fun) -{ - char *tmpstr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if 1 //__DEBUG_FUNCS__ - fprintf(D_DESC, "[D] %s: vaddr:%x ID:%d\n", - __FUNCTION__, vaddr, fun->id); -#endif - - if (!mjr_function_get_by_vaddr(ctx, vaddr)) - { - fprintf(stderr, " [*] Registered new function starting at 0x%08X \n", vaddr); - - tmpstr = _vaddr2str(vaddr); - hash_add(&ctx->funchash, tmpstr, fun); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Get function container by vaddr - * @param ctx mjollnir context structure - * @param vaddr virtual address of requested function - */ -container_t *mjr_function_get_by_vaddr(mjrcontext_t *ctx, u_int vaddr) -{ - container_t *container; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_FUCNS_LOOKUP__ - fprintf(D_DESC,"[D] %s: vaddr:%x\n",__FUNCTION__,vaddr); -#endif - - container = (container_t *) hash_get(&ctx->funchash, _vaddr2str(vaddr)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, container); -} - - - - -/** - * @brief Inject a symbol associated to a function container - * @param csrc Container for which a symbol has to be injected - * @param curaddr Address of currently analyzed instruction - * @return Always 0 - */ -int mjr_function_symbol(mjrcontext_t *ctxt, container_t *csrc) -{ - mjrfunc_t *func; - elfsh_Sym bsym; - char *prefix; - char buffer[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Insert new function symbol */ - func = (mjrfunc_t *) csrc->data; - prefix = (char *) config_get_data(MJR_CONFIG_FUNC_PREFIX); - snprintf(buffer, sizeof(buffer), "%s"AFMT, prefix, func->vaddr); - bsym = elfsh_create_symbol(func->vaddr, func->size, STT_FUNC, 0, 0, 0); - elfsh_insert_symbol(ctxt->obj->secthash[ELFSH_SECTION_SYMTAB], &bsym, buffer); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/history.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/history.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/history.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/history.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** (C) 2001-2008 Devhell Labs / Asgard Labs : thorolf / sk / jfv -** @file history.c -** -*/ - -#include "libmjollnir.h" - -/* Oldest entry is entry 0 */ -/* It is the good way to do it */ -void mjr_history_shift(mjrcontext_t *cur, asm_instr inst, eresi_Addr addr) -{ - int i; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if ((cur->proc.type == ASM_PROC_IA32 && inst.instr == ASM_NOP) || - (cur->proc.type == ASM_PROC_SPARC && inst.instr == ASM_SP_NOP)) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - for (i = 0; i < MJR_HISTORY_LEN - 1; i++) - memcpy(&cur->hist[i], &cur->hist[i + 1], sizeof(mjrhistory_t)); - mjr_history_write(cur, &inst, addr, MJR_HISTORY_CUR); - -#if __DEBUG_OPERAND__ - fprintf(D_DESC,"[__DEBUG_OPERAND__] mjr_history_shift: %x/%x/%x\n", - cur->hist[MJR_HISTORY_CUR].vaddr, - cur->hist[MJR_HISTORY_PREV].vaddr, - cur->hist[MJR_HISTORY_PPREV].vaddr); -#endif - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Write an entry of history */ -void mjr_history_write(mjrcontext_t *cur, asm_instr *i, eresi_Addr a, int idx) -{ - if (idx >= MJR_HISTORY_LEN) - return; - - memcpy(&cur->hist[idx].instr, i, sizeof(asm_instr)); - cur->hist[idx].vaddr = a; -} - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/init.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/init.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/init.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/init.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -/** - * (C) 2006-2008 Asgard Labs, thorolf - * BSD License - * - * @file init.c - * @brief Initialization functions - * - */ - -#include "libmjollnir.h" - -/** - * @brief Initialize the world for libmjollnir - * @param sess The session structure - */ -int mjr_init_session(mjrsession_t *sess) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_init(&goto_hash, "gotos" , 100 , ASPECT_TYPE_STR); - hash_init(&sess->ctx, "mjrcontexts", mjrHashSmall, ASPECT_TYPE_UNKNOW); - - /* register configurable parameters */ - config_add_item(MJR_CONFIG_BLOC_PREFIX, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - MJR_BLOC_PREFIX); - config_add_item(MJR_CONFIG_BLOC_POSTFIX, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - MJR_BLOC_POSTFIX); - config_add_item(MJR_CONFIG_FUNC_PREFIX, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - MJR_FUNC_PREFIX); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * @brief Change the current analysis context - * @param sess The session structure - * @param name The name of the session - */ -int mjr_set_current_context(mjrsession_t *sess, char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if ((sess->cur = hash_get(&sess->ctx,name)) == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * @brief Create a new analysis context - * @param sess The session structure - * @param ctx The context structure - */ -int mjr_add_context(mjrsession_t *sess, mjrcontext_t *ctx) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash_add(&sess->ctx, ctx->obj->name, ctx); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * @brief Create a context and set it as the current one - * @param sess The session strucutre - * @param obj elfshell obj - */ -int mjr_create_context_as_current(mjrsession_t *sess, elfshobj_t *obj) -{ - mjrcontext_t *ctx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ctx = mjr_create_context(obj); - mjr_add_context(sess, ctx); - mjr_set_current_context(sess, obj->name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - - -/** - * @brief Create a new context - * @param obj elf shell object - */ -mjrcontext_t *mjr_create_context(elfshobj_t *obj) -{ - mjrcontext_t *ctx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,ctx, sizeof(mjrcontext_t), NULL); - bzero(ctx, sizeof(mjrcontext_t)); - ctx->obj = obj; - hash_init(&ctx->funchash, "functions", mjrHashVerySmall, ASPECT_TYPE_FUNC); - hash_init(&ctx->blkhash , "blocks" , mjrHashLarge , ASPECT_TYPE_BLOC); - ctx->cntnrs_size = MJR_CNTNRS_INCREMENT; - ctx->next_id = 1; - ctx->block_btree=NULL; - mjr_init_containers(ctx); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ctx)); -} - -/** - * Virtualisation of the libasm initialization depending on the architecture - * @param sess Mjollnir session strucutre - */ -int mjr_setup_processor(mjrsession_t *sess) -{ - u_int arch; - - arch = elfsh_get_arch(sess->cur->obj->hdr); - switch(arch) - { - case EM_SPARC: - case EM_SPARCV9: - case EM_SPARC32PLUS: - asm_init_sparc(&sess->cur->proc); - break; - case EM_386: - asm_init_ia32(&sess->cur->proc); - break; - case EM_MIPS: - asm_init_mips(&sess->cur->proc); - break; - default: - fprintf(D_DESC," [E] Libmjollnir unsupported architecture\n"); - return (-1); - } - return 1; -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/links.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/links.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/links.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/links.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,299 +0,0 @@ -/** - * @file links.c - * - * @brief All the functions that deal with linking other objects, such - * as functions, blocks, or others. - * - * Started on Fri Jun 22 2007 jfv - */ - -#include - - - -/** - * @brief Link function layer - * @param ctxt mjollnir context structure - * @param str source address - * @param dst destination address - * @param ret return address - */ -int mjr_link_func_call(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) -{ - container_t *fun; - mjrfunc_t *tmpfunc; - char *tmpstr; - char *md5; - eresi_Addr tmpaddr; - elfshsect_t *dstsect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_LINKS__ - fprintf(D_DESC, "[D] %s: src:%x dst:%x ret:%x\n", - __FUNCTION__, src, dst, ret); -#endif - - /* Check if we are not pointing into BSS */ - dstsect = elfsh_get_parent_section(ctxt->obj, dst, NULL); - if (!dstsect || !dstsect->data) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Link/Prepare function layer. We use an intermediate variable, else - the compiler optimize too hard and that make segfault (bug in gcc ?) */ - tmpaddr = dst; - fun = mjr_function_get_by_vaddr(ctxt, tmpaddr); - if (!fun) - { - tmpstr = _vaddr2str(tmpaddr); - fun = mjr_create_function_container(ctxt, tmpaddr, 0, - tmpstr, NULL, NULL); - mjr_function_register(ctxt, tmpaddr, fun); - mjr_function_symbol(ctxt, fun); - } - - /* Add links between functions */ - if (ctxt->curfunc) - { - mjr_container_add_link(ctxt, fun, ctxt->curfunc->id, - MJR_LINK_FUNC_RET, CONTAINER_LINK_IN); - mjr_container_add_link(ctxt, ctxt->curfunc, fun->id, - MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); - } - - /* Fingerprint function */ - md5 = mjr_fingerprint_function(ctxt, tmpaddr, MJR_FPRINT_TYPE_MD5); - tmpfunc = (mjrfunc_t *) fun->data; - if (md5) - memcpy(tmpfunc->md5, md5, sizeof(tmpfunc->md5)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Create a link between blocks on a call - */ -int mjr_link_block_call(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) -{ - container_t *csrc,*cdst,*cret; - elfshsect_t *dstsect; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s: linking " AFMT " CALL " AFMT " RET " AFMT "\n", - __FUNCTION__, src, dst, ret); -#endif - - /* Check if we are not pointing into BSS */ - dstsect = elfsh_get_parent_section(ctxt->obj, dst, NULL); - if (!dstsect || !dstsect->data) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* at this point we must have src block */ - csrc = mjr_block_get_by_vaddr(ctxt, src, MJR_BLOCK_GET_FUZZY); - fprintf(stderr, "Calling location source " XFMT "\n", src); - assert(csrc != NULL); - mjr_block_symbol(ctxt, csrc, src, 0); - - /* search and/or split destination block */ - if (!(cdst = mjr_block_split(ctxt, dst, 0))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the dst",0); - - if (ret) - /* search and/or split - return block */ - if (!(cret = mjr_block_split(ctxt, ret, 0))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the ret", 0); - - /* link src and dst */ - mjr_container_add_link(ctxt, csrc, cdst->id, MJR_LINK_FUNC_CALL, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cdst, csrc->id, MJR_LINK_FUNC_CALL, CONTAINER_LINK_IN); - - if (ret) - { - /* link dst and ret */ - mjr_container_add_link(ctxt, cdst, cret->id, MJR_LINK_FUNC_RET, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, cdst->id, MJR_LINK_FUNC_RET, CONTAINER_LINK_IN); - - // mjr_block_relink_cond_always(csrc,cret,CONTAINER_LINK_OUT); - // mjr_block_relink_cond_always(cret,csrc,CONTAINER_LINK_IN); - - mjr_container_add_link(ctxt, csrc, cret->id, MJR_LINK_TYPE_DELAY, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, csrc->id, MJR_LINK_TYPE_DELAY, CONTAINER_LINK_IN); - } - -#if __DEBUG_BLOCKS__ - mjr_block_dump(ctxt,csrc); - mjr_block_dump(ctxt,cdst); - mjr_block_dump(ctxt,cret); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - - -/** - * @brief This function does prepare linking of blocks on conditional jumps - */ -int mjr_link_block_jump(mjrcontext_t *ctxt, - eresi_Addr src, - eresi_Addr dst, - eresi_Addr ret) -{ - container_t *csrc, *cdst, *cret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s: linking JMP %x TRUE %x FALSE %x\n", - __FUNCTION__, - src,dst,ret); -#endif - - /* Insert symbol on terminated block */ - csrc = mjr_block_get_by_vaddr(ctxt, src, MJR_BLOCK_GET_FUZZY); - assert(csrc != NULL); - mjr_block_symbol(ctxt, csrc, src, 0); - - /* Now split destination blocks */ - if (!(cdst = mjr_block_split(ctxt,dst,MJR_LINK_BLOCK_COND_ALWAYS))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the dst",0); - cret = NULL; - if (ret) - if (!(cret = mjr_block_split(ctxt,ret,MJR_LINK_BLOCK_COND_ALWAYS))) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Could not split the ret",0); - - mjr_container_add_link(ctxt, csrc, cdst->id, MJR_LINK_BLOCK_COND_TRUE, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cdst, csrc->id, MJR_LINK_BLOCK_COND_TRUE, CONTAINER_LINK_IN); - if (cret) - { - mjr_container_add_link(ctxt, csrc, cret->id, MJR_LINK_BLOCK_COND_FALSE, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, cret, csrc->id, MJR_LINK_BLOCK_COND_FALSE, CONTAINER_LINK_IN); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - - - -/* Those functions are static and should not be used by external API */ - - - -/** - * @brief Update link information when splitting a block - */ -static int mjr_block_relink(mjrcontext_t *ctx, - container_t *src, - container_t *dst, - int direction) -{ - list_t *linklist; - listent_t *curent; - listent_t *savednext; - mjrlink_t *lnk; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - linklist = mjr_link_get_by_direction(src, direction); - -#if __DEBUG_LINKS__ - fprintf(D_DESC, "[D] Relinking blocks %s: src:%d dst:%d dir:%d\n", - __FUNCTION__, src->id, dst->id, direction); -#endif - - /* First same links to dest, then remove links from source */ - for (curent = linklist->head; curent; curent = savednext) - { - savednext = curent->next; - lnk = (mjrlink_t *) curent->data; - mjr_container_add_link(ctx, dst, lnk->id, lnk->type, direction); - elist_del(linklist, curent->key); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - - - - -/** - * @brief This function does split a block carried by given container - * to 2 pieces, a new container will be added by vaddr dst - * - * @param ctxt mjollnir context strucutre - * @param dst destination address of wanted block - * @param link_with link splitted blocks with specified link type - */ -container_t *mjr_block_split(mjrcontext_t *ctxt, - eresi_Addr dst, - u_int link_with) -{ - container_t *tmpdst,*dstend; - mjrblock_t *blkdst; - int new_size; - elfsh_Sym *sym; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check if we need to split a bloc */ - tmpdst = mjr_block_get_by_vaddr(ctxt, dst, MJR_BLOCK_GET_FUZZY); - if (!tmpdst) - { - tmpdst = mjr_create_block_container(ctxt, 0, dst, 1, 1); - hash_add(&ctxt->blkhash, _vaddr2str(dst), tmpdst); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (tmpdst)); - } - - /* Find existing symbol for split bloc */ - blkdst = (mjrblock_t *) tmpdst->data; - sym = elfsh_get_symbol_by_value(ctxt->obj, blkdst->vaddr, NULL, ELFSH_EXACTSYM); - assert(sym != NULL); - -#if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s:%d: wanted dst:%x got:%x\n", __FUNCTION__, __LINE__, dst, blkdst->vaddr); -#endif - - /* Recompute sizes */ - if (blkdst->vaddr != dst) - { - new_size = blkdst->size - (dst - blkdst->vaddr); - -#if __DEBUG_LINKS__ - fprintf(D_DESC,"[D] %s:%d: new_size %d for %x\n", __FUNCTION__, __LINE__, new_size, dst); - fprintf(D_DESC,"[D] %s:%d: turncate %x to %d\n", __FUNCTION__, __LINE__, blkdst->vaddr, blkdst->size); -#endif - blkdst->size -= new_size; - - assert(new_size > 0); - assert(blkdst->size > 0); - - dstend = mjr_create_block_container(ctxt, 0, dst, new_size, 1); - hash_add(&ctxt->blkhash, _vaddr2str(dst), dstend); - - /* Correct existing symbol size and add new symbol */ - sym->st_size = blkdst->size; - mjr_block_symbol(ctxt, dstend, NULL, 0); - - if (link_with) - { - mjr_block_relink(ctxt, tmpdst, dstend, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, tmpdst, dstend->id, link_with, CONTAINER_LINK_OUT); - mjr_container_add_link(ctxt, dstend, tmpdst->id, link_with, CONTAINER_LINK_IN); - } - } - else - dstend = tmpdst; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dstend)); -} diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/ondisk.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/ondisk.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/ondisk.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/ondisk.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,493 +0,0 @@ -/* -** @file ondisk.c -** -** @brief Implement routines to store and load analysis data on disk -** -** Started : Thu Jul 28 02:39:14 2003 jfv -** -*/ - -#include "libmjollnir.h" - - - -/** - * @brief Save and prepare a buffer which will be saved into the elfshobj. - * - * @param c a block container containing links to be stores - * @param type 0 for inout/1 for output - * @param buf buffer which contains the data - * @return an offset where the data has been saved - */ -static int mjr_flow_store_links(container_t *c, u_int type, mjrbuf_t *buf) -{ - u_int nbr; - listent_t *cur; - mjrlink_t *curlink; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Make sure we have correct parameters */ - switch (type) - { - case CONTAINER_LINK_IN: - cur = c->inlinks->head; - nbr = c->nbrinlinks; - break; - case CONTAINER_LINK_OUT: - cur = c->outlinks->head; - nbr = c->nbroutlinks; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown link type", -1); - } - - /* Allocate the good size for ondisk buffer */ - if (!buf->data || !buf->allocated) - { - buf->allocated = nbr * sizeof(unsigned int) * 2; - XALLOC(__FILE__, __FUNCTION__, __LINE__, buf->data, buf->allocated, -1); - } - else if (buf->allocated) - { - buf->allocated += nbr * sizeof(unsigned int) * 2; - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - buf->data, buf->data, buf->allocated, -1); - } - - /* Iterate over all links */ - while (cur) - { - curlink = (mjrlink_t *) cur->data; - -#if __DEBUG_ONDISK__ - fprintf(D_DESC,"[D] %s.%d: stored dep id:%d dir:%d cid:%d type:%d\n", - __FUNCTION__, __LINE__, c->id, type, curlink->id, curlink->type); -#endif - - memcpy(buf->data + buf->maxlen, (char *) &curlink->id , sizeof(unsigned int)); - buf->maxlen += sizeof(unsigned int); - memcpy(buf->data + buf->maxlen, (char *) &curlink->type , sizeof(unsigned int)); - buf->maxlen += sizeof(unsigned int); - - cur = cur->next; - } - - buf->counter++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf->maxlen); -} - - - - -/** - * @brief Link containers in the control flow graph - */ -static int mjr_flow_load_links(mjrcontext_t *ctxt, - container_t *container, - u_int linktype, - char *sectdata, - u_int *curoff) -{ - u_int off; - u_int tmpid; - u_int tmptype; - u_int tmpnbr; - u_int findex; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Make sure we deal with the right list of links */ - switch (linktype) - { - case CONTAINER_LINK_IN: - off = (u_int) container->inlinks; - tmpnbr = container->nbrinlinks; - container_linklists_create(container, CONTAINER_LINK_IN); - break; - case CONTAINER_LINK_OUT: - off = (u_int) container->outlinks; - tmpnbr = container->nbroutlinks; - container_linklists_create(container, CONTAINER_LINK_OUT); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid link type", -1); - } - - /* Recreate each link */ - for (findex = 0; findex < tmpnbr; findex++) - { - tmpid = *(unsigned int *) ((char *) sectdata + off + *curoff); - *curoff += sizeof (unsigned int); - tmptype = *(unsigned int *) ((char *) sectdata + off + *curoff); - *curoff += sizeof (unsigned int); - -#if __DEBUG_ONDISK__ - fprintf(D_DESC," [__DEBUG_ONDISK__] Restored link: (%d/%d) sid:%u did:%u type:%u\n", - findex, tmpnbr, container->id, tmpid, tmptype); -#endif - - /* This function increments linklist->elmnbr */ - if (tmpid) - mjr_container_add_link(ctxt, container, tmpid, tmptype, linktype); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - -/** - * @brief Create the data dump to be saved in file - */ -static int mjr_unit_save(container_t *cur, mjrbuf_t *buf, u_int typeid) -{ - void *curunit; - container_t *container; - u_int unitsize; - eresi_Addr addr; - u_int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Here check what kind of structures we are saving */ - switch (typeid) - { - case ASPECT_TYPE_BLOC: - unitsize = sizeof(mjrblock_t); - break; - case ASPECT_TYPE_FUNC: - unitsize = sizeof(mjrfunc_t); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input type id", 0); - } - - /* At this points, no new unit allocation should be done */ - curunit = cur->data; - - /* This is why addr and size fields should always be in first in mjrblock/mjrfunc */ - addr = *(eresi_Addr *) curunit; - size = *(u_int *) ((char *) curunit + sizeof(eresi_Addr)); - -#if __DEBUG_ONDISK__ - fprintf(D_DESC," [*] Saving data unit %s\n", buf); -#endif - - /* Else insert the block in the global buffer for the .control section */ - if (!buf->data) - { - buf->allocated = getpagesize(); - XALLOC(__FILE__, __FUNCTION__, __LINE__, buf->data, buf->allocated, -1); - buf->maxlen = 0; - } - else if (buf->allocated < (buf->maxlen + unitsize + sizeof(container_t))) - { - buf->allocated += getpagesize(); - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - buf->data, buf->data, buf->allocated, -1); - } - - /* Unit copy in the buffer */ - container = (container_t *) ((char *) buf->data + buf->maxlen); - curunit = (char *) buf->data + buf->maxlen + sizeof(container_t); - - memcpy(container, cur, sizeof(container_t)); - memcpy(curunit, cur->data, unitsize); - - /* Return result */ - buf->maxlen += sizeof(container_t); - buf->maxlen += unitsize; - buf->counter++; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - - - -/** - * @brief Create the control flow graph using the information stored in .elfsh.control - * - * @return Returns the number of saved data units (0 probably means something is wrong) - */ -int mjr_flow_load(mjrcontext_t *ctxt, u_int typeid) -{ - int index, cnt, done; - elfshsect_t *sect, *flowsect; - char name[20]; - char **keys; - container_t *container; - container_t *tmpcntnr; - u_int flowdone; - u_int unitsize; - u_int unitnbr; - hash_t *table; - void *curunit; - void *tmpunit; - char *debugsect1; - char *debugsect2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Here check what kind of structures we are saving */ - switch (typeid) - { - case ASPECT_TYPE_BLOC: - unitsize = sizeof(mjrblock_t); - table = &ctxt->blkhash; - debugsect1 = ELFSH_SECTION_NAME_EDFMT_BLOCKS; - debugsect2 = ELFSH_SECTION_NAME_EDFMT_BCONTROL; - break; - case ASPECT_TYPE_FUNC: - unitsize = sizeof(mjrfunc_t); - table = &ctxt->funchash; - debugsect1 = ELFSH_SECTION_NAME_EDFMT_FUNCTIONS; - debugsect2 = ELFSH_SECTION_NAME_EDFMT_FCONTROL; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input type id", 0); - } - - /* If mjr_flow_load() was already called, just return now */ - cnt = hash_size(table); - if (cnt != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); - - /* Preliminary checks */ - sect = elfsh_get_section_by_name(ctxt->obj, debugsect1, 0, 0, 0); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow section : use analyse command", 0); - if (sect->shdr->sh_size % (unitsize + sizeof(container_t))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Corrupted edfmt section : modulo-test failed", 0); - flowsect = elfsh_get_section_by_name(ctxt->obj, debugsect2, 0, 0, 0); - if (!flowsect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow analysis section found (use analyse command)", 0); - - /* First pass : Iterate on the control flow section to find blocks */ - /* We do not create new data units but use the data from the section */ - unitnbr = sect->shdr->sh_size / (sizeof(container_t) + unitsize); - for (done = index = 0; index < unitnbr; index++) - { - - /* Ondisk format ondisk is the exact same format that we manipulate - in this lib. So its very practical to reload/store the info ondisk */ - container = (container_t *) ((char *) sect->data + done); - done += sizeof(container_t); - curunit = (char *) sect->data + done; - done += unitsize; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, tmpunit, unitsize, 0); - XALLOC(__FILE__, __FUNCTION__, __LINE__, tmpcntnr, sizeof(container_t), 0); - - memcpy(tmpcntnr, container, sizeof(container_t)); - memcpy(tmpunit, curunit, unitsize); - tmpcntnr->data = tmpunit; - - /* Because of this line, we need to make sure the addr is always in first in all structs */ - snprintf(name, sizeof(name), AFMT, *(eresi_Addr *) tmpunit); - -#if __DEBUG_ONDISK__ - fprintf(D_DESC,"[__DEBUG_ONDISK__] %s: add new unit name: %s \n", __FUNCTION__, name); -#endif - - mjr_register_container_id(ctxt, tmpcntnr); - hash_add(table, _vaddr2str(*(eresi_Addr *) tmpunit), tmpcntnr); - } - - /* Relink containers in this second run */ - keys = hash_get_keys(table, &done); - for (index = 0; index < done; index++) - { - container = hash_get(table, keys[index]); - flowdone = 0; - mjr_flow_load_links(ctxt, container, CONTAINER_LINK_IN , flowsect->data, &flowdone); - mjr_flow_load_links(ctxt, container, CONTAINER_LINK_OUT, flowsect->data, &flowdone); - } - - /* Prevent double analysis */ - if (typeid == ASPECT_TYPE_BLOC) - ctxt->analysed = 1; - cnt = hash_size(table); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, cnt); -} - - - -/** - * @brief Store the blocks and functions on disk - * - * This loops on all block/func, and call mjr_unit_save() on each element - * - */ -int mjr_flow_store(mjrcontext_t *ctxt, u_int typeid) -{ - elfsh_Shdr shdr; - elfshsect_t *sect; - mjrbuf_t buf, cfbuf; - container_t *container; - int err; - char **keys; - int keynbr; - int index; - int flow_off_in, flow_off_out; - list_t *tmpin, *tmpout; - hash_t *table; - char *debugsect1; - char *debugsect2; - void *curunit; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Here check what kind of structures we are saving */ - switch (typeid) - { - case ASPECT_TYPE_BLOC: - table = &ctxt->blkhash; - debugsect1 = ELFSH_SECTION_NAME_EDFMT_BLOCKS; - debugsect2 = ELFSH_SECTION_NAME_EDFMT_BCONTROL; - break; - case ASPECT_TYPE_FUNC: - table = &ctxt->funchash; - debugsect1 = ELFSH_SECTION_NAME_EDFMT_FUNCTIONS; - debugsect2 = ELFSH_SECTION_NAME_EDFMT_FCONTROL; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input type id", 0); - } - - /* Remove previous control sections if any */ - sect = elfsh_get_section_by_name(ctxt->obj, debugsect1, 0, 0, 0); - if (sect) - elfsh_remove_section(ctxt->obj, debugsect1); - sect = elfsh_get_section_by_name(ctxt->obj, debugsect2, 0, 0, 0); - if (sect) - elfsh_remove_section(ctxt->obj, debugsect2); - - /* Initialize data buffer */ - buf.allocated = 0; - buf.maxlen = 0; - buf.counter = 0; - buf.data = 0; - buf.obj = ctxt->obj; - - /* Initialize data buffer */ - cfbuf.allocated = 0; - cfbuf.maxlen = 0; - cfbuf.counter = 0; - cfbuf.data = 0; - cfbuf.obj = ctxt->obj; - - flow_off_in = flow_off_out = 0; - - /* Iteratively save all data units */ - keys = hash_get_keys(table, &keynbr); - for (index = 0; index < keynbr; index++) - { - tmpin = tmpout = NULL; - container = hash_get(table, keys[index]); - -#if __DEBUG_ONDISK__ - switch (typeid) - { - case ASPECT_TYPE_BLOC: - mjr_block_dump(ctxt, container); - break; - case ASPECT_TYPE_FUNC: - mjr_function_dump(ctxt, (char *) __FUNCTION__, container); - break; - default: - break; - } -#endif - - /* We update the number of links stored ondisk */ - container->nbrinlinks = container->inlinks->elmnbr; - container->nbroutlinks = container->outlinks->elmnbr; - - /* Setting references to link information inside the file */ - tmpin = container->inlinks; - tmpout = container->outlinks; - container->inlinks = (list_t *) flow_off_in; - container->outlinks = (list_t *) flow_off_out; - mjr_unit_save(container, &buf, typeid); - - /* Restore list pointers */ - container->inlinks = tmpin; - container->outlinks = tmpout; - -#if __DEBUG_ONDISK__ - fprintf(D_DESC, " [D] %s: IN Offset: %d\n", __FUNCTION__, flow_off_in); - fprintf(D_DESC, " [D] %s: OUT Offset: %d\n", __FUNCTION__, flow_off_out); -#endif - - /* Store block flow and get new offsets */ - flow_off_in = mjr_flow_store_links(container, CONTAINER_LINK_IN, &cfbuf); - flow_off_out = mjr_flow_store_links(container, CONTAINER_LINK_OUT, &cfbuf); - if (flow_off_in < 0 || flow_off_out < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to save flow analysis information", 0); - curunit = container->data; - - /* This is just a help code, it does not do really - anything and it kept for intelligence purpose */ - if (typeid == ASPECT_TYPE_BLOC && mjr_block_funcstart(container)) - { - container = mjr_function_get_by_vaddr(ctxt, *(eresi_Addr *) curunit); - - /* Can happens rarely - should not be fatal */ - if (container == NULL || container->data == NULL) - { -#if __DEBUG_ONDISK__ - fprintf(stderr, " [*] Failed to find parent function at 0x%08lx \n", - (unsigned long) *(eresi_Addr *) curunit); -#endif - continue; - } - -#if __DEBUG_ONDISK__ - fprintf(stderr, " [*] Found block start for function 0x%08lx \n", - (unsigned long) *(eresi_Addr *) curunit); -#endif - - } - } - - /* Create control section */ - sect = elfsh_create_section(debugsect1); - shdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, buf.maxlen, 0, 0, 0, 0); - - fprintf(stderr, " [*] Saving %s section of %u bytes \n", debugsect1, buf.maxlen); - - err = elfsh_insert_unmapped_section(ctxt->obj, sect, shdr, buf.data); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to save edfmt section1", -1); - - sect = elfsh_create_section(debugsect2); - shdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, cfbuf.maxlen, 0, 0, 0, 0); - - fprintf(stderr, " [*] Saving %s section of %u bytes\n", debugsect2, cfbuf.maxlen); - - err = elfsh_insert_unmapped_section(ctxt->obj, sect, shdr, cfbuf.data); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to save edfmt section2", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, buf.counter); -} - diff -Nru eresi-0.8a25/libmjollnir/src/.svn/text-base/symtab.c.svn-base eresi-0.0.20110516/libmjollnir/src/.svn/text-base/symtab.c.svn-base --- eresi-0.8a25/libmjollnir/src/.svn/text-base/symtab.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/.svn/text-base/symtab.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -/** - * @file symtab.c - * - * (C) 2006-2008 Asgard Labs, thorolf - * BSD License - * - */ - -#include - - - -/** - * Rebuild the symtab with original names when possible - */ -int mjr_symtab_rebuild(mjrsession_t *sess) -{ - int cn; - int x; - char **tab; - container_t *tmp; - mjrblock_t *n; - char s[BSIZE]; - - tab = hash_get_keys(&sess->cur->blkhash, &cn); - for (x = 0; x < cn; x++) - { - tmp = hash_get(&sess->cur->blkhash, tab[x]); - n = tmp->data; - - fprintf(D_DESC,"[__DEBUG_MJOLLNIR__] mjr_symtab_rebuild: "XFMT" \n", - n->vaddr); - - if (!mjr_block_funcstart(tmp)) - continue; - snprintf(s, BSIZE, "%s"AFMT, - (char *) config_get_data(MJR_CONFIG_FUNC_PREFIX), n->vaddr); - mjr_symbol_add(sess, n->vaddr, s); - } - return 1; -} - -/** - * @brief This function inserts new symbol as a function. Shortcut for insert/set - */ -int mjr_symbol_add(mjrsession_t *sess, - eresi_Addr vaddr, - char *fname) -{ - elfshsect_t *sect; - elfsh_Sym sym; - - if (elfsh_get_symbol_by_value(sess->cur->obj, vaddr, 0, ELFSH_EXACTSYM)) - return 0; - - sect = elfsh_get_parent_section(sess->cur->obj, vaddr, NULL); - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC,"[__DEBUG_MJOLLNIR__] mjrSymbolAdd: [%10s] 0x%08x <%s>\n", - "SECNAME", vaddr, fname); -#endif - - if (!sect) - return 0; - - sym = elfsh_create_symbol(vaddr, 0, STT_FUNC, 0, 0, sect->index); - elfsh_insert_symbol(sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB], &sym, fname); - return 1; -} - - -/** - * @brief Remove symbol by name - */ -int mjr_symbol_delete_by_name(mjrsession_t *sess, char *symbol) -{ -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC,"[__DEBUG_MJOLLNIR__] mjr_symbol_deleteByName: <%s>\n", symbol); -#endif - - elfsh_remove_symbol(sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB], symbol); - return 1; -} - -/** - * @brief Rename symbol FIXME - */ -int mjr_symbol_rename(mjrsession_t *sess, - char *old_name, - char *new_name) -{ - elfsh_Sym *sm; - - sm = elfsh_get_symbol_by_name(sess->cur->obj, old_name); - if (!sm) - return 0; - -#if __DEBUG_MJOLLNIR__ - fprintf(D_DESC, - "[__DEBUG_MJOLLNIR__] mjr_symbol_rename: %s (st_value: 0x%08x) -> %s \n", - old_name, sm->st_value, new_name); -#endif - - mjr_symbol_add(sess, sm->st_value, new_name); - mjr_symbol_delete_by_name(sess, old_name); - return 1; -} diff -Nru eresi-0.8a25/libmjollnir/src/symtab.c eresi-0.0.20110516/libmjollnir/src/symtab.c --- eresi-0.8a25/libmjollnir/src/symtab.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/src/symtab.c 2011-05-16 11:34:47.000000000 +0000 @@ -1,8 +1,8 @@ /** - * @file symtab.c +* @file libmjollnir/src/symtab.c + * @ingroup libmjollnir * * (C) 2006-2008 Asgard Labs, thorolf - * BSD License * */ @@ -56,7 +56,7 @@ sect = elfsh_get_parent_section(sess->cur->obj, vaddr, NULL); #if __DEBUG_MJOLLNIR__ - fprintf(D_DESC,"[__DEBUG_MJOLLNIR__] mjrSymbolAdd: [%10s] 0x%08x <%s>\n", + fprintf(D_DESC,"[__DEBUG_MJOLLNIR__] mjrSymbolAdd: [%10s] 0x"XFMT" <%s>\n", "SECNAME", vaddr, fname); #endif @@ -97,11 +97,12 @@ #if __DEBUG_MJOLLNIR__ fprintf(D_DESC, - "[__DEBUG_MJOLLNIR__] mjr_symbol_rename: %s (st_value: 0x%08x) -> %s \n", + "[__DEBUG_MJOLLNIR__] mjr_symbol_rename: %s (st_value: 0x"XFMT") -> %s \n", old_name, sm->st_value, new_name); #endif mjr_symbol_add(sess, sm->st_value, new_name); mjr_symbol_delete_by_name(sess, old_name); + elfsh_sync_sorted_symtab(sess->cur->obj->secthash[ELFSH_SECTION_SYMTAB]); return 1; } diff -Nru eresi-0.8a25/libmjollnir/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/950/trunk/libmjollnir -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/950/trunk/libmjollnir/Makefile -END diff -Nru eresi-0.8a25/libmjollnir/.svn/entries eresi-0.0.20110516/libmjollnir/.svn/entries --- eresi-0.8a25/libmjollnir/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -tools -dir - -include -dir - -doc -dir - -src -dir - -bin -dir - -Makefile -file - - - - -2008-04-06T23:16:30.812878Z -acf5f297739e2475bb8ef8d36b4c814a -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/libmjollnir/.svn/format eresi-0.0.20110516/libmjollnir/.svn/format --- eresi-0.8a25/libmjollnir/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libmjollnir/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libmjollnir/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -# -# LibMjollnir Makefile -# -# (C) 2001-2006 - Devhell Labs / Asgard Labs (sk, jfv, thorolf) -# -# BSD License -# -include ../config.h - -SRC = src/blocks.c src/core.c src/history.c src/init.c src/symtab.c \ - src/findentry.c src/cfg.c src/fingerprint.c src/display.c src/links.c \ - src/ondisk.c src/function.c src/container.c - -OBJ = ${SRC:.c=.o} -OBJ32 = ${SRC:.c=.32.o} -OBJ64 = ${SRC:.c=.64.o} -SRCT = bin/elfThor.c -OBJT = elfThor -SRCUT = tools/mjollnirUnitTest.c -OBJUT = mjollnirUnitTest - -CC ?= gcc -LD ?= ld -NAME32 = libmjollnir32 -NAME64 = libmjollnir64 - -CFLAGS32 = -fPIC -I./include/ -I../libasm/include/ \ - -I../libelfsh/include/ -I../libhash/include/ -I../libaspect/include \ - -Wall -DERESI32 -DELFSH_INTERN -g3 - -CFLAGS64 = -fPIC -I./include/ -I../libasm/include/ \ - -I../libelfsh/include/ -I../libhash/include/ -I../libaspect/include \ - -Wall -DERESI64 -DELFSH_INTERN -g3 - -LDFLAGS32 = -L. -L../libasm/ -L../libelfsh/ -L../liballocproxy \ - -L../libaspect/ -lelfsh32 -laspect32 -lasm -lallocproxy $(LPTHREAD) - -LDFLAGS64 = -L. -L../libasm/ -L../libelfsh/ -L../liballocproxy \ - -L../libaspect/ -lelfsh64 -laspect64 -lasm -lallocproxy $(LPTHREAD) - -all : all32 all64 - -$(NAME32).so : $(OBJ32) - @$(CC) $(BITS) -shared $(OBJ32) -o $(NAME32).so -lcrypto $(LDFLAGS32) - @ar rc ${NAME32}.a ${OBJ32} - @${RANLIB} ${NAME32}.a -# $(CC) $(CFLAGS32) $(LDFLAGS32) $(SRCT) -o $(OBJT) $(STATOPT) -lmjollnir32 - @$(LD) -r $(OBJ32) -o $(NAME32).o - -all32: $(NAME32).so - -$(NAME64).so : $(OBJ64) - @$(CC) $(BITS) -shared $(OBJ64) -o $(NAME64).so -lcrypto $(LDFLAGS64) - @ar rc ${NAME64}.a ${OBJ64} - @${RANLIB} ${NAME64}.a - @$(LD) -r $(OBJ64) -o $(NAME64).o - -all64: $(NAME64).so - -docs: - doxygen doc/doxygen.conf - -clean: - rm -f $(OBJ) $(OBJ32) $(OBJ64) src/*~ src/\#* \ - include/\#* include/*~ $(OBJT) $(OBJM) - -fclean: clean - rm -f bin/elfThor mjollnirUnitTest *.a *.so *~ $(NAME64).o $(NAME32).o - -.c.o: - $(CC) $(CFLAGS) -c $*.c -o $*.o - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< - diff -Nru eresi-0.8a25/libmjollnir/tools/desDiff.pl eresi-0.0.20110516/libmjollnir/tools/desDiff.pl --- eresi-0.8a25/libmjollnir/tools/desDiff.pl 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/desDiff.pl 2011-05-16 11:34:46.000000000 +0000 @@ -1,8 +1,6 @@ #!/usr/bin/perl # (C) 2006-2007 Asgard Labs, thorolf -# BSD License -# $Id: desDiff.pl,v 1.8 2007-06-09 22:35:16 thor Exp $ # the objects should be striped libraries # this script was 'designed' to search for differences in diff -Nru eresi-0.8a25/libmjollnir/tools/mjollnirUnitTest.c eresi-0.0.20110516/libmjollnir/tools/mjollnirUnitTest.c --- eresi-0.8a25/libmjollnir/tools/mjollnirUnitTest.c 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/mjollnirUnitTest.c 2011-05-16 11:34:46.000000000 +0000 @@ -1,8 +1,6 @@ /* * (C) 2006 Asgard Labs, thorolf - * BSD License - * $Id: mjollnirUnitTest.c,v 1.4 2006-07-15 17:06:08 thor Exp $ * */ @@ -17,7 +15,7 @@ fail_unless(mjr_init_session(&sess) == 1,"mjrInitSession faild."); sess.obj = elfsh_map_obj(infile); fail_unless(sess.obj != NULL, "elfsh_map_obj faild."); - fail_unless(mjr_setup_processor(&sess) == 1, "mjrSetupProcessor faild."); + fail_unless(mjr_setup_processor(&sess, NULL) == 1, "mjrSetupProcessor faild."); // fail_unless(mjrFindCalls(&sess,".abstractSection") != NULL, "mjrFindCalls on abstract section returned without error."); fail_unless(mjr_find_calls(&sess,".text") == NULL, "mjrFindCalls on .text section faild."); fail_unless(mjr_analize(&sess,NULL) == 1, "mjrAnalize faild."); diff -Nru eresi-0.8a25/libmjollnir/tools/mkDb.sh eresi-0.0.20110516/libmjollnir/tools/mkDb.sh --- eresi-0.8a25/libmjollnir/tools/mkDb.sh 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/mkDb.sh 2011-05-16 11:34:46.000000000 +0000 @@ -1,7 +1,6 @@ #!/bin/sh # (C) 2006 Asgard Labs, thorolf -# BSD License # $Id: mkDb.sh,v 1.3 2006-07-08 21:24:27 thor Exp $ for x in `ls -1 /usr/lib/*.a` diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/tools/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/tools/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/855/trunk/libmjollnir/tools -END -mkDb.sh -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/202/trunk/libmjollnir/tools/mkDb.sh -END -mjollnirUnitTest.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/210/trunk/libmjollnir/tools/mjollnirUnitTest.c -END -desDiff.pl -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/690/trunk/libmjollnir/tools/desDiff.pl -END diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/entries eresi-0.0.20110516/libmjollnir/tools/.svn/entries --- eresi-0.8a25/libmjollnir/tools/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/tools -http://svn.eresi-project.org/svn - - - -2008-02-19T23:47:44.265264Z -855 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -tests -dir - -mkDb.sh -file - - - - -2008-04-06T23:16:30.271142Z -afc646636c8aec21665185e21fae6b9b -2006-07-08T21:24:27.000000Z -202 -thor -has-props - -mjollnirUnitTest.c -file - - - - -2008-04-06T23:16:30.292691Z -f1f031cd32302cafa7c4d3e89b79b499 -2006-07-15T17:06:08.000000Z -210 -thor - -desDiff.pl -file - - - - -2008-04-06T23:16:30.304127Z -9d9d02f5d21fecb644e33900b9556ed2 -2007-06-09T22:35:16.000000Z -690 -thor -has-props - diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/format eresi-0.0.20110516/libmjollnir/tools/.svn/format --- eresi-0.8a25/libmjollnir/tools/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/prop-base/desDiff.pl.svn-base eresi-0.0.20110516/libmjollnir/tools/.svn/prop-base/desDiff.pl.svn-base --- eresi-0.8a25/libmjollnir/tools/.svn/prop-base/desDiff.pl.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/prop-base/desDiff.pl.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/prop-base/mkDb.sh.svn-base eresi-0.0.20110516/libmjollnir/tools/.svn/prop-base/mkDb.sh.svn-base --- eresi-0.8a25/libmjollnir/tools/.svn/prop-base/mkDb.sh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/prop-base/mkDb.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/text-base/desDiff.pl.svn-base eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/desDiff.pl.svn-base --- eresi-0.8a25/libmjollnir/tools/.svn/text-base/desDiff.pl.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/desDiff.pl.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,131 +0,0 @@ -#!/usr/bin/perl - -# (C) 2006-2007 Asgard Labs, thorolf -# BSD License -# $Id: desDiff.pl,v 1.8 2007-06-09 22:35:16 thor Exp $ - -# the objects should be striped libraries -# this script was 'designed' to search for differences in -# disassembly between objdump and mydisasm/libasm - -$sparcObjDump = "sparc-rtems-objdump"; -$intelObjDump = "objdump"; - -# overwrite default objdump -if ($ENV{'ERESI_OBJDUMP'}) { - $sparcObjDump = $ENV{'ERESI_OBJDUMP'}; - $intelObjDump = $ENV{'ERESI_OBJDUMP'}; -} - -if (!$ARGV[0]) {print "usage: ./desDiff.pl test.so\n";exit();} - -$b = $ARGV[0]; - -open(SI,"file $b |"); -$tmp = ; -@fileInfo = split(',',$tmp); -close(SI); - -$arch = $fileInfo[1]; -$arch =~ s/^ //; -$arch =~ s/,//; - -if ($arch =~ /^Intel/) { - $objDump = $intelObjDump; -} elsif ($arch =~ /SPARC$/) { - $objDump = $sparcObjDump; -} else { - print "[E] Architecture [$arch] is not supported\n"; - exit(1); -} - -$tmpFile = $b; -$tmpFile =~ s/\//\###/g; -$tmpFile = $$.".$tmpFile"; - -print STDERR "[i] Checking: $b [$arch] - ... "; -print STDERR "Objdump, "; -system("$objDump -w -d -j .text $b > $tmpFile.objdump"); -print STDERR "Mydisasm, "; -system("./mydisasm $b .text > $tmpFile.mydisasm"); - -open(X1, "$tmpFile.mydisasm"); -open(X2, "$tmpFile.objdump"); - -print STDERR "Analysis started...\n"; - -$waitFlag = 0; - -while($myDisasmInput = ) { - chomp($myDisasmInput); - @myDisasmLine = split("\t",$myDisasmInput); - $mdAddr = $myDisasmLine[0]; - $mdAddr =~ s/ //g; - $mdAddr =~ s/://; - $mdInstr = $myDisasmLine[1]; - $mdInstr =~ s/ //g; - $mdOpcode = $myDisasmLine[2]; - $mdOpcode =~ s/ //g; - - if (!$waitFlag) { - # objdump opcodes - @objDumpLine = x2(); - } - - $obAddr = $objDumpLine[0]; - $obAddr =~ s/ //g; - $obAddr =~ s/://g; - $obAddr = "0x".$obAddr; - $obOpcode = $objDumpLine[1]; - $obOpcode =~ s/ //g; - $obInstr = $objDumpLine[2]; - -## debug -# print "MD: ". $mdAddr . " " .$mdInstr . " " . $mdOpcode . "\n"; -# print "OD: ". $obAddr . " " .$obInstr . " " . $obOpcode . "\n"; - - if (oct($mdAddr) < oct($obAddr)) - { - $waitFlag = 1; - next; - } - - if ($mdOpcode ne $obOpcode) { - if (($obOpcode ne "...") && ($mdInstr ne "illtrap")) - { - $tmp = "[!] opcodes: ". $mdOpcode . " :: " . $obOpcode ." in $b\n"; - $tmp .= "[X] LIBASM: ". $myDisasmInput . "\n"; - $tmp .= "[X] OBJDUMP: ". $objDumpInput . "\n[o] ======\n"; - $x = $mdOpcode; - $x =~ s/$obOpcode//g; - x2(); - if ($x ne $obOpcode) { - print $tmp; - print STDERR "[o] diffs found\n"; - exit(1); - } - } - } - - $waitFlag = 0; - -} - -close(X1); -close(X2); - -unlink("$tmpFile.objdump"); -unlink("$tmpFile.mydisasm"); - - -### Read objdump output -sub x2 { - - $objDumpInput = ; - if (!$objDumpInput) {exit();} - chomp($objDumpInput); - if ($objDumpInput !~ /^\s+/) {x2();} - @objDumpLine = split("\t",$objDumpInput); - - return (@objDumpLine); -} diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/text-base/mjollnirUnitTest.c.svn-base eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/mjollnirUnitTest.c.svn-base --- eresi-0.8a25/libmjollnir/tools/.svn/text-base/mjollnirUnitTest.c.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/mjollnirUnitTest.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ - -/* - * (C) 2006 Asgard Labs, thorolf - * BSD License - * $Id: mjollnirUnitTest.c,v 1.4 2006-07-15 17:06:08 thor Exp $ - * - */ - -#include -#include -#include - -START_TEST (test_create) -{ - char *infile = "ptrfnc"; - mjrSession sess; - fail_unless(mjr_init_session(&sess) == 1,"mjrInitSession faild."); - sess.obj = elfsh_map_obj(infile); - fail_unless(sess.obj != NULL, "elfsh_map_obj faild."); - fail_unless(mjr_setup_processor(&sess) == 1, "mjrSetupProcessor faild."); -// fail_unless(mjrFindCalls(&sess,".abstractSection") != NULL, "mjrFindCalls on abstract section returned without error."); - fail_unless(mjr_find_calls(&sess,".text") == NULL, "mjrFindCalls on .text section faild."); - fail_unless(mjr_analize(&sess,NULL) == 1, "mjrAnalize faild."); -} -END_TEST - -Suite *mjollnir_suite(void) -{ - Suite *s = suite_create("Mjollnir"); - TCase *tc_core = tcase_create("Core"); - - suite_add_tcase (s, tc_core); - tcase_add_test(tc_core, test_create); - return s; -} - -int main(void) -{ - int nf; - Suite *s = mjollnir_suite(); - SRunner *sr = srunner_create(s); - srunner_run_all(sr, CK_NORMAL); - nf = srunner_ntests_failed(sr); - srunner_free(sr); - return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE; -} - diff -Nru eresi-0.8a25/libmjollnir/tools/.svn/text-base/mkDb.sh.svn-base eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/mkDb.sh.svn-base --- eresi-0.8a25/libmjollnir/tools/.svn/text-base/mkDb.sh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/.svn/text-base/mkDb.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -#!/bin/sh - -# (C) 2006 Asgard Labs, thorolf -# BSD License -# $Id: mkDb.sh,v 1.3 2006-07-08 21:24:27 thor Exp $ - -for x in `ls -1 /usr/lib/*.a` -do -echo $x - for f in `ar t $x` - do - echo "--->" $f - ar x $x $f - ./thor -i $f -O FreeBSD -A i386 -R 5.4-RELEASE-p7 -F $f -c >> tmp.db - rm -f $f - done -done diff -Nru eresi-0.8a25/libmjollnir/tools/tests/makeit.sh eresi-0.0.20110516/libmjollnir/tools/tests/makeit.sh --- eresi-0.8a25/libmjollnir/tools/tests/makeit.sh 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/makeit.sh 2011-05-16 11:34:46.000000000 +0000 @@ -1,5 +1,9 @@ #!/bin/sh -nasm -f elf test-1.asm -ld -s -o test-1 test-1.o +# ERESI (c) 2008 +for i in *.asm; do + ofile=`echo $i | sed 's/.asm//g'` + nasm -f elf $i + ld -s -o $ofile $ofile.o +done diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/all-wcprops eresi-0.0.20110516/libmjollnir/tools/tests/.svn/all-wcprops --- eresi-0.8a25/libmjollnir/tools/tests/.svn/all-wcprops 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/855/trunk/libmjollnir/tools/tests -END -makeit.sh -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/855/trunk/libmjollnir/tools/tests/makeit.sh -END -system.inc -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/855/trunk/libmjollnir/tools/tests/system.inc -END -test-1.asm -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/855/trunk/libmjollnir/tools/tests/test-1.asm -END diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/entries eresi-0.0.20110516/libmjollnir/tools/tests/.svn/entries --- eresi-0.8a25/libmjollnir/tools/tests/.svn/entries 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libmjollnir/tools/tests -http://svn.eresi-project.org/svn - - - -2008-02-19T23:47:44.265264Z -855 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -makeit.sh -file - - - - -2008-04-06T23:16:30.191128Z -dcbe47eabb39706c76947f7fd8834dd0 -2008-02-19T23:47:44.265264Z -855 -thorkill -has-props - -system.inc -file - - - - -2008-04-06T23:16:30.212311Z -259c9295a154789d248424d8cbf40db3 -2008-02-19T23:47:44.265264Z -855 -thorkill - -test-1.asm -file - - - - -2008-04-06T23:16:30.223149Z -3864d54f374c35509003bd9457e11528 -2008-02-19T23:47:44.265264Z -855 -thorkill - diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/format eresi-0.0.20110516/libmjollnir/tools/tests/.svn/format --- eresi-0.8a25/libmjollnir/tools/tests/.svn/format 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/prop-base/makeit.sh.svn-base eresi-0.0.20110516/libmjollnir/tools/tests/.svn/prop-base/makeit.sh.svn-base --- eresi-0.8a25/libmjollnir/tools/tests/.svn/prop-base/makeit.sh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/prop-base/makeit.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/makeit.sh.svn-base eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/makeit.sh.svn-base --- eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/makeit.sh.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/makeit.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -#!/bin/sh - -nasm -f elf test-1.asm -ld -s -o test-1 test-1.o - diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/system.inc.svn-base eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/system.inc.svn-base --- eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/system.inc.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/system.inc.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -; -; 2008 (C) ERESI Project -; -; Taken from http://www.int80h.org/bsdasm/ -; This is an include file for our unit test - -%define stdin 0 -%define stdout 1 -%define stderr 2 - -%define SYS_nosys 0 -%define SYS_exit 1 -%define SYS_fork 2 -%define SYS_read 3 -%define SYS_write 4 - -section .text -align 4 -access.the.bsd.kernel: - int 80h - ret - -%macro system 1 - mov eax, %1 - call access.the.bsd.kernel - -%endmacro - -%macro sys.exit 0 - system SYS_exit -%endmacro - -%macro sys.fork 0 - system SYS_fork -%endmacro - -%macro sys.read 0 - system SYS_read -%endmacro - -%macro sys.write 0 - system SYS_write -%endmacro diff -Nru eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/test-1.asm.svn-base eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/test-1.asm.svn-base --- eresi-0.8a25/libmjollnir/tools/tests/.svn/text-base/test-1.asm.svn-base 2008-04-06 23:16:30.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/.svn/text-base/test-1.asm.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -; -; 2008 (C) ERESI Project -; -; Taken from http://www.int80h.org/bsdasm/ - -; First simple 'hello world' test - -%include 'system.inc' - -section .data -hello db 'Hello, World!', 0Ah -hbytes equ hello - -section .text -global _start -_start: - push dword hbytes - push dword hello - push dword stdout -sys.write - push dword 0 -sys.exit diff -Nru eresi-0.8a25/libmjollnir/tools/tests/test-calls.asm eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.asm --- eresi-0.8a25/libmjollnir/tools/tests/test-calls.asm 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.asm 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,31 @@ +; +; 2008 (C) ERESI Project +; +; Taken from http://www.int80h.org/bsdasm/ + +; First simple 'hello world' test + +section .text +global _start +_start: + call function1 + mov eax, 0x1 + int 0x80 + ret + + +function1: + mov eax,0x1 + mov ebx,0x2 + add eax,ebx + call function2 + ret + +function2: + test eax,eax + call function3 + ret + +function3: + test ebx,ebx + ret diff -Nru eresi-0.8a25/libmjollnir/tools/tests/test-calls.esh eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.esh --- eresi-0.8a25/libmjollnir/tools/tests/test-calls.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.esh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,8 @@ +#!/usr/local/bin/elfsh32 + +load test-calls +analyse +graph + +graph bloc .text + diff -Nru eresi-0.8a25/libmjollnir/tools/tests/test-calls.gdb eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.gdb --- eresi-0.8a25/libmjollnir/tools/tests/test-calls.gdb 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/test-calls.gdb 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,9 @@ + +file elfsh32 +run +b mjr_analyse_section +b mjr_trace_start +b mjr_find_main +run test-calls.esh +c + diff -Nru eresi-0.8a25/libmjollnir/tools/tests/test-jumps.asm eresi-0.0.20110516/libmjollnir/tools/tests/test-jumps.asm --- eresi-0.8a25/libmjollnir/tools/tests/test-jumps.asm 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/test-jumps.asm 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,30 @@ +; +; 2008 (C) ERESI Project +; +; Taken from http://www.int80h.org/bsdasm/ + +; First simple 'hello world' test + +section .text +global _start +_start: + align 4 + mov eax,0x4 +.bkwjump: + mov ecx,0x1 + sub eax,ecx + cmp eax,0x0 + jne .bkwjump + mov eax,0x5 +.loop: + cmp eax,0x0 + jne .fwdjump + jmp .exit +.fwdjump: + mov ecx,0x1 + sub eax,ecx + jmp .loop +.exit: + mov eax,0x1 + int 0x80 + ret diff -Nru eresi-0.8a25/libmjollnir/tools/tests/test-jumps.esh eresi-0.0.20110516/libmjollnir/tools/tests/test-jumps.esh --- eresi-0.8a25/libmjollnir/tools/tests/test-jumps.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libmjollnir/tools/tests/test-jumps.esh 2011-05-16 11:34:46.000000000 +0000 @@ -0,0 +1,7 @@ +#!/usr/bin/elfsh32 + +load test-jumps +analyse +graph + + diff -Nru eresi-0.8a25/libregex/Makefile eresi-0.0.20110516/libregex/Makefile --- eresi-0.8a25/libregex/Makefile 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libregex/Makefile 2011-05-16 11:34:12.000000000 +0000 @@ -10,7 +10,7 @@ LD = ld RM = rm -f AR = ar rc -CFLAGS += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI32 +CFLAGS += -Iinclude -fPIC -g3 -O2 -DERESI32 SRC = regex.c OBJ = $(SRC:.c=.o) NAME = libregex diff -Nru eresi-0.8a25/libregex/.svn/all-wcprops eresi-0.0.20110516/libregex/.svn/all-wcprops --- eresi-0.8a25/libregex/.svn/all-wcprops 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 32 -/svn/!svn/ver/843/trunk/libregex -END -regex.h -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/843/trunk/libregex/regex.h -END -regexec.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/843/trunk/libregex/regexec.c -END -regex_internal.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libregex/regex_internal.c -END -regex.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/843/trunk/libregex/regex.c -END -regex_internal.h -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libregex/regex_internal.h -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/843/trunk/libregex/Makefile -END -regcomp.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/843/trunk/libregex/regcomp.c -END diff -Nru eresi-0.8a25/libregex/.svn/entries eresi-0.0.20110516/libregex/.svn/entries --- eresi-0.8a25/libregex/.svn/entries 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,112 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libregex -http://svn.eresi-project.org/svn - - - -2008-02-16T12:32:28.000000Z -843 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -regex.h -file - - - - -2008-04-06T23:15:48.481886Z -d9c0523896a78d08a557077a6857d090 -2008-02-16T12:32:28.000000Z -843 -thor - -regexec.c -file - - - - -2008-04-06T23:15:48.527106Z -ea146bc1a22049b285821bfc3c73c4e8 -2008-02-16T12:32:28.000000Z -843 -thor - -regex_internal.c -file - - - - -2008-04-06T23:15:48.538876Z -59118a34de0290857c34a4849c57dbb9 -2008-02-16T12:32:28.000000Z -843 -thor - -regex.c -file - - - - -2008-04-06T23:15:48.550131Z -45679b7cfbb2a5c61c4cff0b8bbf1758 -2008-02-16T12:32:28.000000Z -843 -thor - -regex_internal.h -file - - - - -2008-04-06T23:15:48.561531Z -da11879a29e1898634d31dc789a1433a -2008-02-16T12:32:28.000000Z -843 -thor - -Makefile -file - - - - -2008-04-06T23:15:48.572931Z -01b210a2123bfe4a52006750d405369c -2008-02-16T12:32:28.000000Z -843 -thor - -regcomp.c -file - - - - -2008-04-06T23:15:48.584390Z -6a38eef0d18ed3b969de3094a90cd75c -2008-02-16T12:32:28.000000Z -843 -thor - diff -Nru eresi-0.8a25/libregex/.svn/format eresi-0.0.20110516/libregex/.svn/format --- eresi-0.8a25/libregex/.svn/format 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libregex/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libregex/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libregex/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:47.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -## -## Makefile.am for libaspect in elfsh -## -## Started on Fri Dec 22 16:32:29 2006 jfv -## - -include ../config.h - -CC ?= gcc -LD = ld -RM = rm -f -AR = ar rc -CFLAGS += -Iinclude -fPIC -g3 -O2 -DASPECT_ELFSH_INTERN -DERESI32 -SRC = regex.c -OBJ = $(SRC:.c=.o) -NAME = libregex - -all : $(OBJ) - @$(AR) $(NAME).a $(OBJ) - @$(RANLIB) $(NAME).a - -clean : - @$(RM) \#* *\# *~ $(OBJ) .\#* include/\#* \ - include/*\# include/*~ include/.\#* - -fclean : clean - @$(RM) *.a diff -Nru eresi-0.8a25/libregex/.svn/text-base/regcomp.c.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regcomp.c.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regcomp.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regcomp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,3800 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, - size_t length, reg_syntax_t syntax); -static void re_compile_fastmap_iter (regex_t *bufp, - const re_dfastate_t *init_state, - char *fastmap); -static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); -#ifdef RE_ENABLE_I18N -static void free_charset (re_charset_t *cset); -#endif /* RE_ENABLE_I18N */ -static void free_workarea_compile (regex_t *preg); -static reg_errcode_t create_initial_state (re_dfa_t *dfa); -#ifdef RE_ENABLE_I18N -static void optimize_utf8 (re_dfa_t *dfa); -#endif -static reg_errcode_t analyze (regex_t *preg); -static reg_errcode_t preorder (bin_tree_t *root, - reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra); -static reg_errcode_t postorder (bin_tree_t *root, - reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra); -static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node); -static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node); -static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg, - bin_tree_t *node); -static reg_errcode_t calc_first (void *extra, bin_tree_t *node); -static reg_errcode_t calc_next (void *extra, bin_tree_t *node); -static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); -static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint); -static int search_duplicated_node (const re_dfa_t *dfa, int org_node, - unsigned int constraint); -static reg_errcode_t calc_eclosure (re_dfa_t *dfa); -static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, - int node, int root); -static reg_errcode_t calc_inveclosure (re_dfa_t *dfa); -static int fetch_number (re_string_t *input, re_token_t *token, - reg_syntax_t syntax); -static int peek_token (re_token_t *token, re_string_t *input, - reg_syntax_t syntax) internal_function; -static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, - reg_syntax_t syntax, reg_errcode_t *err); -static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - int nest, reg_errcode_t *err); -static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - int nest, reg_errcode_t *err); -static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - int nest, reg_errcode_t *err); -static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg, - re_token_t *token, reg_syntax_t syntax, - int nest, reg_errcode_t *err); -static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp, - re_dfa_t *dfa, re_token_t *token, - reg_syntax_t syntax, reg_errcode_t *err); -static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, - re_token_t *token, reg_syntax_t syntax, - reg_errcode_t *err); -static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, - re_string_t *regexp, - re_token_t *token, int token_len, - re_dfa_t *dfa, - reg_syntax_t syntax, - int accept_hyphen); -static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, - re_string_t *regexp, - re_token_t *token); -#ifdef RE_ENABLE_I18N -static reg_errcode_t build_equiv_class (bitset_t sbcset, - re_charset_t *mbcset, - int *equiv_class_alloc, - const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, - bitset_t sbcset, - re_charset_t *mbcset, - int *char_class_alloc, - const unsigned char *class_name, - reg_syntax_t syntax); -#else /* not RE_ENABLE_I18N */ -static reg_errcode_t build_equiv_class (bitset_t sbcset, - const unsigned char *name); -static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, - bitset_t sbcset, - const unsigned char *class_name, - reg_syntax_t syntax); -#endif /* not RE_ENABLE_I18N */ -static bin_tree_t *build_charclass_op (re_dfa_t *dfa, - RE_TRANSLATE_TYPE trans, - const unsigned char *class_name, - const unsigned char *extra, - int non_match, reg_errcode_t *err); -static bin_tree_t *create_tree (re_dfa_t *dfa, - bin_tree_t *left, bin_tree_t *right, - re_token_type_t type); -static bin_tree_t *create_token_tree (re_dfa_t *dfa, - bin_tree_t *left, bin_tree_t *right, - const re_token_t *token); -static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); -static void free_token (re_token_t *node); -static reg_errcode_t free_tree (void *extra, bin_tree_t *node); -static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); - -/* This table gives an error message for each of the error codes listed - in regex.h. Obviously the order here has to be same as there. - POSIX doesn't require that we do anything for REG_NOERROR, - but why not be nice? */ - -const char __re_error_msgid[] attribute_hidden = - { -#define REG_NOERROR_IDX 0 - gettext_noop ("Success") /* REG_NOERROR */ - "\0" -#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") - gettext_noop ("No match") /* REG_NOMATCH */ - "\0" -#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") - gettext_noop ("Invalid regular expression") /* REG_BADPAT */ - "\0" -#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") - gettext_noop ("Invalid collation character") /* REG_ECOLLATE */ - "\0" -#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") - gettext_noop ("Invalid character class name") /* REG_ECTYPE */ - "\0" -#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") - gettext_noop ("Trailing backslash") /* REG_EESCAPE */ - "\0" -#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") - gettext_noop ("Invalid back reference") /* REG_ESUBREG */ - "\0" -#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") - gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ - "\0" -#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") - gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ - "\0" -#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") - gettext_noop ("Unmatched \\{") /* REG_EBRACE */ - "\0" -#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") - gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ - "\0" -#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") - gettext_noop ("Invalid range end") /* REG_ERANGE */ - "\0" -#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") - gettext_noop ("Memory exhausted") /* REG_ESPACE */ - "\0" -#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") - gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ - "\0" -#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") - gettext_noop ("Premature end of regular expression") /* REG_EEND */ - "\0" -#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") - gettext_noop ("Regular expression too big") /* REG_ESIZE */ - "\0" -#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") - gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */ - }; - -const size_t __re_error_msgid_idx[] attribute_hidden = - { - REG_NOERROR_IDX, - REG_NOMATCH_IDX, - REG_BADPAT_IDX, - REG_ECOLLATE_IDX, - REG_ECTYPE_IDX, - REG_EESCAPE_IDX, - REG_ESUBREG_IDX, - REG_EBRACK_IDX, - REG_EPAREN_IDX, - REG_EBRACE_IDX, - REG_BADBR_IDX, - REG_ERANGE_IDX, - REG_ESPACE_IDX, - REG_BADRPT_IDX, - REG_EEND_IDX, - REG_ESIZE_IDX, - REG_ERPAREN_IDX - }; - -/* Entry points for GNU code. */ - -/* re_compile_pattern is the GNU regular expression compiler: it - compiles PATTERN (of length LENGTH) and puts the result in BUFP. - Returns 0 if the pattern was valid, otherwise an error string. - - Assumes the `allocated' (and perhaps `buffer') and `translate' fields - are set in BUFP on entry. */ - -const char * -re_compile_pattern (pattern, length, bufp) - const char *pattern; - size_t length; - struct re_pattern_buffer *bufp; -{ - reg_errcode_t ret; - - /* And GNU code determines whether or not to get register information - by passing null for the REGS argument to re_match, etc., not by - setting no_sub, unless RE_NO_SUB is set. */ - bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); - - /* Match anchors at newline. */ - bufp->newline_anchor = 1; - - ret = re_compile_internal (bufp, pattern, length, re_syntax_options); - - if (!ret) - return NULL; - return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); -} -#ifdef _LIBC -weak_alias (__re_compile_pattern, re_compile_pattern) -#endif - -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -/* This has no initializer because initialized variables in Emacs - become read-only after dumping. */ -reg_syntax_t re_syntax_options; - - -/* Specify the precise syntax of regexps for compilation. This provides - for compatibility for various utilities which historically have - different, incompatible syntaxes. - - The argument SYNTAX is a bit mask comprised of the various bits - defined in regex.h. We return the old syntax. */ - -reg_syntax_t -re_set_syntax (syntax) - reg_syntax_t syntax; -{ - reg_syntax_t ret = re_syntax_options; - - re_syntax_options = syntax; - return ret; -} -#ifdef _LIBC -weak_alias (__re_set_syntax, re_set_syntax) -#endif - -int -re_compile_fastmap (bufp) - struct re_pattern_buffer *bufp; -{ - re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; - char *fastmap = bufp->fastmap; - - memset (fastmap, '\0', sizeof (char) * SBC_MAX); - re_compile_fastmap_iter (bufp, dfa->init_state, fastmap); - if (dfa->init_state != dfa->init_state_word) - re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap); - if (dfa->init_state != dfa->init_state_nl) - re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap); - if (dfa->init_state != dfa->init_state_begbuf) - re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap); - bufp->fastmap_accurate = 1; - return 0; -} -#ifdef _LIBC -weak_alias (__re_compile_fastmap, re_compile_fastmap) -#endif - -static inline void -__attribute ((always_inline)) -re_set_fastmap (char *fastmap, int icase, int ch) -{ - fastmap[ch] = 1; - if (icase) - fastmap[tolower (ch)] = 1; -} - -/* Helper function for re_compile_fastmap. - Compile fastmap for the initial_state INIT_STATE. */ - -static void -re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, - char *fastmap) -{ - re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; - int node_cnt; - int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); - for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) - { - int node = init_state->nodes.elems[node_cnt]; - re_token_type_t type = dfa->nodes[node].type; - - if (type == CHARACTER) - { - re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); -#ifdef RE_ENABLE_I18N - if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) - { - unsigned char *buf = alloca (dfa->mb_cur_max), *p; - wchar_t wc; - mbstate_t state; - - p = buf; - *p++ = dfa->nodes[node].opr.c; - while (++node < dfa->nodes_len - && dfa->nodes[node].type == CHARACTER - && dfa->nodes[node].mb_partial) - *p++ = dfa->nodes[node].opr.c; - memset (&state, '\0', sizeof (state)); - if (mbrtowc (&wc, (const char *) buf, p - buf, - &state) == p - buf - && (__wcrtomb ((char *) buf, towlower (wc), &state) - != (size_t) -1)) - re_set_fastmap (fastmap, 0, buf[0]); - } -#endif - } - else if (type == SIMPLE_BRACKET) - { - int i, ch; - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - { - int j; - bitset_word_t w = dfa->nodes[node].opr.sbcset[i]; - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - if (w & ((bitset_word_t) 1 << j)) - re_set_fastmap (fastmap, icase, ch); - } - } -#ifdef RE_ENABLE_I18N - else if (type == COMPLEX_BRACKET) - { - int i; - re_charset_t *cset = dfa->nodes[node].opr.mbcset; - if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes - || cset->nranges || cset->nchar_classes) - { -# ifdef _LIBC - if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0) - { - /* In this case we want to catch the bytes which are - the first byte of any collation elements. - e.g. In da_DK, we want to catch 'a' since "aa" - is a valid collation element, and don't catch - 'b' since 'b' is the only collation element - which starts from 'b'. */ - const int32_t *table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - for (i = 0; i < SBC_MAX; ++i) - if (table[i] < 0) - re_set_fastmap (fastmap, icase, i); - } -# else - if (dfa->mb_cur_max > 1) - for (i = 0; i < SBC_MAX; ++i) - if (__btowc (i) == WEOF) - re_set_fastmap (fastmap, icase, i); -# endif /* not _LIBC */ - } - for (i = 0; i < cset->nmbchars; ++i) - { - char buf[256]; - mbstate_t state; - memset (&state, '\0', sizeof (state)); - if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1) - re_set_fastmap (fastmap, icase, *(unsigned char *) buf); - if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) - { - if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) - != (size_t) -1) - re_set_fastmap (fastmap, 0, *(unsigned char *) buf); - } - } - } -#endif /* RE_ENABLE_I18N */ - else if (type == OP_PERIOD -#ifdef RE_ENABLE_I18N - || type == OP_UTF8_PERIOD -#endif /* RE_ENABLE_I18N */ - || type == END_OF_RE) - { - memset (fastmap, '\1', sizeof (char) * SBC_MAX); - if (type == END_OF_RE) - bufp->can_be_null = 1; - return; - } - } -} - -/* Entry point for POSIX code. */ -/* regcomp takes a regular expression as a string and compiles it. - - PREG is a regex_t *. We do not expect any fields to be initialized, - since POSIX says we shouldn't. Thus, we set - - `buffer' to the compiled pattern; - `used' to the length of the compiled pattern; - `syntax' to RE_SYNTAX_POSIX_EXTENDED if the - REG_EXTENDED bit in CFLAGS is set; otherwise, to - RE_SYNTAX_POSIX_BASIC; - `newline_anchor' to REG_NEWLINE being set in CFLAGS; - `fastmap' to an allocated space for the fastmap; - `fastmap_accurate' to zero; - `re_nsub' to the number of subexpressions in PATTERN. - - PATTERN is the address of the pattern string. - - CFLAGS is a series of bits which affect compilation. - - If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we - use POSIX basic syntax. - - If REG_NEWLINE is set, then . and [^...] don't match newline. - Also, regexec will try a match beginning after every newline. - - If REG_ICASE is set, then we considers upper- and lowercase - versions of letters to be equivalent when matching. - - If REG_NOSUB is set, then when PREG is passed to regexec, that - routine will report only success or failure, and nothing about the - registers. - - It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for - the return codes and their meanings.) */ - -int -regcomp (preg, pattern, cflags) - regex_t *__restrict preg; - const char *__restrict pattern; - int cflags; -{ - reg_errcode_t ret; - reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED - : RE_SYNTAX_POSIX_BASIC); - - preg->buffer = NULL; - preg->allocated = 0; - preg->used = 0; - - /* Try to allocate space for the fastmap. */ - preg->fastmap = re_malloc (char, SBC_MAX); - if (BE (preg->fastmap == NULL, 0)) - return REG_ESPACE; - - syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; - - /* If REG_NEWLINE is set, newlines are treated differently. */ - if (cflags & REG_NEWLINE) - { /* REG_NEWLINE implies neither . nor [^...] match newline. */ - syntax &= ~RE_DOT_NEWLINE; - syntax |= RE_HAT_LISTS_NOT_NEWLINE; - /* It also changes the matching behavior. */ - preg->newline_anchor = 1; - } - else - preg->newline_anchor = 0; - preg->no_sub = !!(cflags & REG_NOSUB); - preg->translate = NULL; - - ret = re_compile_internal (preg, pattern, strlen (pattern), syntax); - - /* POSIX doesn't distinguish between an unmatched open-group and an - unmatched close-group: both are REG_EPAREN. */ - if (ret == REG_ERPAREN) - ret = REG_EPAREN; - - /* We have already checked preg->fastmap != NULL. */ - if (BE (ret == REG_NOERROR, 1)) - /* Compute the fastmap now, since regexec cannot modify the pattern - buffer. This function never fails in this implementation. */ - (void) re_compile_fastmap (preg); - else - { - /* Some error occurred while compiling the expression. */ - re_free (preg->fastmap); - preg->fastmap = NULL; - } - - return (int) ret; -} -#ifdef _LIBC -weak_alias (__regcomp, regcomp) -#endif - -/* Returns a message corresponding to an error code, ERRCODE, returned - from either regcomp or regexec. We don't use PREG here. */ - -size_t -regerror (errcode, preg, errbuf, errbuf_size) - int errcode; - const regex_t *__restrict preg; - char *__restrict errbuf; - size_t errbuf_size; -{ - const char *msg; - size_t msg_size; - - if (BE (errcode < 0 - || errcode >= (int) (sizeof (__re_error_msgid_idx) - / sizeof (__re_error_msgid_idx[0])), 0)) - /* Only error codes returned by the rest of the code should be passed - to this routine. If we are given anything else, or if other regex - code generates an invalid error code, then the program has a bug. - Dump core so we can fix it. */ - abort (); - - msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); - - msg_size = strlen (msg) + 1; /* Includes the null. */ - - if (BE (errbuf_size != 0, 1)) - { - if (BE (msg_size > errbuf_size, 0)) - { -#if defined HAVE_MEMPCPY || defined _LIBC - *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; -#else - memcpy (errbuf, msg, errbuf_size - 1); - errbuf[errbuf_size - 1] = 0; -#endif - } - else - memcpy (errbuf, msg, msg_size); - } - - return msg_size; -} -#ifdef _LIBC -weak_alias (__regerror, regerror) -#endif - - -#ifdef RE_ENABLE_I18N -/* This static array is used for the map to single-byte characters when - UTF-8 is used. Otherwise we would allocate memory just to initialize - it the same all the time. UTF-8 is the preferred encoding so this is - a worthwhile optimization. */ -static const bitset_t utf8_sb_map = -{ - /* Set the first 128 bits. */ - [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX -}; -#endif - - -static void -free_dfa_content (re_dfa_t *dfa) -{ - int i, j; - - if (dfa->nodes) - for (i = 0; i < dfa->nodes_len; ++i) - free_token (dfa->nodes + i); - re_free (dfa->nexts); - for (i = 0; i < dfa->nodes_len; ++i) - { - if (dfa->eclosures != NULL) - re_node_set_free (dfa->eclosures + i); - if (dfa->inveclosures != NULL) - re_node_set_free (dfa->inveclosures + i); - if (dfa->edests != NULL) - re_node_set_free (dfa->edests + i); - } - re_free (dfa->edests); - re_free (dfa->eclosures); - re_free (dfa->inveclosures); - re_free (dfa->nodes); - - if (dfa->state_table) - for (i = 0; i <= dfa->state_hash_mask; ++i) - { - struct re_state_table_entry *entry = dfa->state_table + i; - for (j = 0; j < entry->num; ++j) - { - re_dfastate_t *state = entry->array[j]; - free_state (state); - } - re_free (entry->array); - } - re_free (dfa->state_table); -#ifdef RE_ENABLE_I18N - if (dfa->sb_char != utf8_sb_map) - re_free (dfa->sb_char); -#endif - re_free (dfa->subexp_map); -#ifdef DEBUG - re_free (dfa->re_str); -#endif - - re_free (dfa); -} - - -/* Free dynamically allocated space used by PREG. */ - -void -regfree (preg) - regex_t *preg; -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - if (BE (dfa != NULL, 1)) - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - - re_free (preg->fastmap); - preg->fastmap = NULL; - - re_free (preg->translate); - preg->translate = NULL; -} -#ifdef _LIBC -weak_alias (__regfree, regfree) -#endif - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them unless specifically requested. */ - -#if defined _REGEX_RE_COMP || defined _LIBC - -/* BSD has one and only one pattern buffer. */ -static struct re_pattern_buffer re_comp_buf; - -char * -# ifdef _LIBC -/* Make these definitions weak in libc, so POSIX programs can redefine - these names if they don't use our functions, and still use - regcomp/regexec above without link errors. */ -weak_function -# endif -re_comp (s) - const char *s; -{ - reg_errcode_t ret; - char *fastmap; - - if (!s) - { - if (!re_comp_buf.buffer) - return gettext ("No previous regular expression"); - return 0; - } - - if (re_comp_buf.buffer) - { - fastmap = re_comp_buf.fastmap; - re_comp_buf.fastmap = NULL; - __regfree (&re_comp_buf); - memset (&re_comp_buf, '\0', sizeof (re_comp_buf)); - re_comp_buf.fastmap = fastmap; - } - - if (re_comp_buf.fastmap == NULL) - { - re_comp_buf.fastmap = (char *) malloc (SBC_MAX); - if (re_comp_buf.fastmap == NULL) - return (char *) gettext (__re_error_msgid - + __re_error_msgid_idx[(int) REG_ESPACE]); - } - - /* Since `re_exec' always passes NULL for the `regs' argument, we - don't need to initialize the pattern buffer fields which affect it. */ - - /* Match anchors at newlines. */ - re_comp_buf.newline_anchor = 1; - - ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); - - if (!ret) - return NULL; - - /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ - return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); -} - -#ifdef _LIBC -libc_freeres_fn (free_mem) -{ - __regfree (&re_comp_buf); -} -#endif - -#endif /* _REGEX_RE_COMP */ - -/* Internal entry point. - Compile the regular expression PATTERN, whose length is LENGTH. - SYNTAX indicate regular expression's syntax. */ - -static reg_errcode_t -re_compile_internal (regex_t *preg, const char * pattern, size_t length, - reg_syntax_t syntax) -{ - reg_errcode_t err = REG_NOERROR; - re_dfa_t *dfa; - re_string_t regexp; - - /* Initialize the pattern buffer. */ - preg->fastmap_accurate = 0; - preg->syntax = syntax; - preg->not_bol = preg->not_eol = 0; - preg->used = 0; - preg->re_nsub = 0; - preg->can_be_null = 0; - preg->regs_allocated = REGS_UNALLOCATED; - - /* Initialize the dfa. */ - dfa = (re_dfa_t *) preg->buffer; - if (BE (preg->allocated < sizeof (re_dfa_t), 0)) - { - /* If zero allocated, but buffer is non-null, try to realloc - enough space. This loses if buffer's address is bogus, but - that is the user's responsibility. If ->buffer is NULL this - is a simple allocation. */ - dfa = re_realloc (preg->buffer, re_dfa_t, 1); - if (dfa == NULL) - return REG_ESPACE; - preg->allocated = sizeof (re_dfa_t); - preg->buffer = (unsigned char *) dfa; - } - preg->used = sizeof (re_dfa_t); - - err = init_dfa (dfa, length); - if (BE (err != REG_NOERROR, 0)) - { - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - return err; - } -#ifdef DEBUG - /* Note: length+1 will not overflow since it is checked in init_dfa. */ - dfa->re_str = re_malloc (char, length + 1); - strncpy (dfa->re_str, pattern, length + 1); -#endif - - __libc_lock_init (dfa->lock); - - err = re_string_construct (®exp, pattern, length, preg->translate, - syntax & RE_ICASE, dfa); - if (BE (err != REG_NOERROR, 0)) - { - re_compile_internal_free_return: - free_workarea_compile (preg); - re_string_destruct (®exp); - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - return err; - } - - /* Parse the regular expression, and build a structure tree. */ - preg->re_nsub = 0; - dfa->str_tree = parse (®exp, preg, syntax, &err); - if (BE (dfa->str_tree == NULL, 0)) - goto re_compile_internal_free_return; - - /* Analyze the tree and create the nfa. */ - err = analyze (preg); - if (BE (err != REG_NOERROR, 0)) - goto re_compile_internal_free_return; - -#ifdef RE_ENABLE_I18N - /* If possible, do searching in single byte encoding to speed things up. */ - if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) - optimize_utf8 (dfa); -#endif - - /* Then create the initial state of the dfa. */ - err = create_initial_state (dfa); - - /* Release work areas. */ - free_workarea_compile (preg); - re_string_destruct (®exp); - - if (BE (err != REG_NOERROR, 0)) - { - free_dfa_content (dfa); - preg->buffer = NULL; - preg->allocated = 0; - } - - return err; -} - -/* Initialize DFA. We use the length of the regular expression PAT_LEN - as the initial length of some arrays. */ - -static reg_errcode_t -init_dfa (re_dfa_t *dfa, size_t pat_len) -{ - unsigned int table_size; -#ifndef _LIBC - char *codeset_name; -#endif - - memset (dfa, '\0', sizeof (re_dfa_t)); - - /* Force allocation of str_tree_storage the first time. */ - dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; - - /* Avoid overflows. */ - if (pat_len == SIZE_MAX) - return REG_ESPACE; - - dfa->nodes_alloc = pat_len + 1; - dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); - - /* table_size = 2 ^ ceil(log pat_len) */ - for (table_size = 1; ; table_size <<= 1) - if (table_size > pat_len) - break; - - dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); - dfa->state_hash_mask = table_size - 1; - - dfa->mb_cur_max = MB_CUR_MAX; -#ifdef _LIBC - if (dfa->mb_cur_max == 6 - && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) - dfa->is_utf8 = 1; - dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) - != 0); -#else -# ifdef HAVE_LANGINFO_CODESET - codeset_name = nl_langinfo (CODESET); -# else - codeset_name = getenv ("LC_ALL"); - if (codeset_name == NULL || codeset_name[0] == '\0') - codeset_name = getenv ("LC_CTYPE"); - if (codeset_name == NULL || codeset_name[0] == '\0') - codeset_name = getenv ("LANG"); - if (codeset_name == NULL) - codeset_name = ""; - else if (strchr (codeset_name, '.') != NULL) - codeset_name = strchr (codeset_name, '.') + 1; -# endif - - if (strcasecmp (codeset_name, "UTF-8") == 0 - || strcasecmp (codeset_name, "UTF8") == 0) - dfa->is_utf8 = 1; - - /* We check exhaustively in the loop below if this charset is a - superset of ASCII. */ - dfa->map_notascii = 0; -#endif - -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - if (dfa->is_utf8) - dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map; - else - { - int i, j, ch; - - dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); - if (BE (dfa->sb_char == NULL, 0)) - return REG_ESPACE; - - /* Set the bits corresponding to single byte chars. */ - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - { - wint_t wch = __btowc (ch); - if (wch != WEOF) - dfa->sb_char[i] |= (bitset_word_t) 1 << j; -# ifndef _LIBC - if (isascii (ch) && wch != ch) - dfa->map_notascii = 1; -# endif - } - } - } -#endif - - if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) - return REG_ESPACE; - return REG_NOERROR; -} - -/* Initialize WORD_CHAR table, which indicate which character is - "word". In this case "word" means that it is the word construction - character used by some operators like "\<", "\>", etc. */ - -static void -internal_function -init_word_char (re_dfa_t *dfa) -{ - int i, j, ch; - dfa->word_ops_used = 1; - for (i = 0, ch = 0; i < BITSET_WORDS; ++i) - for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) - if (isalnum (ch) || ch == '_') - dfa->word_char[i] |= (bitset_word_t) 1 << j; -} - -/* Free the work area which are only used while compiling. */ - -static void -free_workarea_compile (regex_t *preg) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_storage_t *storage, *next; - for (storage = dfa->str_tree_storage; storage; storage = next) - { - next = storage->next; - re_free (storage); - } - dfa->str_tree_storage = NULL; - dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; - dfa->str_tree = NULL; - re_free (dfa->org_indices); - dfa->org_indices = NULL; -} - -/* Create initial states for all contexts. */ - -static reg_errcode_t -create_initial_state (re_dfa_t *dfa) -{ - int first, i; - reg_errcode_t err; - re_node_set init_nodes; - - /* Initial states have the epsilon closure of the node which is - the first node of the regular expression. */ - first = dfa->str_tree->first->node_idx; - dfa->init_node = first; - err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* The back-references which are in initial states can epsilon transit, - since in this case all of the subexpressions can be null. - Then we add epsilon closures of the nodes which are the next nodes of - the back-references. */ - if (dfa->nbackref > 0) - for (i = 0; i < init_nodes.nelem; ++i) - { - int node_idx = init_nodes.elems[i]; - re_token_type_t type = dfa->nodes[node_idx].type; - - int clexp_idx; - if (type != OP_BACK_REF) - continue; - for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx) - { - re_token_t *clexp_node; - clexp_node = dfa->nodes + init_nodes.elems[clexp_idx]; - if (clexp_node->type == OP_CLOSE_SUBEXP - && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx) - break; - } - if (clexp_idx == init_nodes.nelem) - continue; - - if (type == OP_BACK_REF) - { - int dest_idx = dfa->edests[node_idx].elems[0]; - if (!re_node_set_contains (&init_nodes, dest_idx)) - { - re_node_set_merge (&init_nodes, dfa->eclosures + dest_idx); - i = 0; - } - } - } - - /* It must be the first time to invoke acquire_state. */ - dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); - /* We don't check ERR here, since the initial state must not be NULL. */ - if (BE (dfa->init_state == NULL, 0)) - return err; - if (dfa->init_state->has_constraint) - { - dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, - CONTEXT_WORD); - dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes, - CONTEXT_NEWLINE); - dfa->init_state_begbuf = re_acquire_state_context (&err, dfa, - &init_nodes, - CONTEXT_NEWLINE - | CONTEXT_BEGBUF); - if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL - || dfa->init_state_begbuf == NULL, 0)) - return err; - } - else - dfa->init_state_word = dfa->init_state_nl - = dfa->init_state_begbuf = dfa->init_state; - - re_node_set_free (&init_nodes); - return REG_NOERROR; -} - -#ifdef RE_ENABLE_I18N -/* If it is possible to do searching in single byte encoding instead of UTF-8 - to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change - DFA nodes where needed. */ - -static void -optimize_utf8 (re_dfa_t *dfa) -{ - int node, i, mb_chars = 0, has_period = 0; - - for (node = 0; node < dfa->nodes_len; ++node) - switch (dfa->nodes[node].type) - { - case CHARACTER: - if (dfa->nodes[node].opr.c >= 0x80) - mb_chars = 1; - break; - case ANCHOR: - switch (dfa->nodes[node].opr.idx) - { - case LINE_FIRST: - case LINE_LAST: - case BUF_FIRST: - case BUF_LAST: - break; - default: - /* Word anchors etc. cannot be handled. */ - return; - } - break; - case OP_PERIOD: - has_period = 1; - break; - case OP_BACK_REF: - case OP_ALT: - case END_OF_RE: - case OP_DUP_ASTERISK: - case OP_OPEN_SUBEXP: - case OP_CLOSE_SUBEXP: - break; - case COMPLEX_BRACKET: - return; - case SIMPLE_BRACKET: - /* Just double check. The non-ASCII range starts at 0x80. */ - assert (0x80 % BITSET_WORD_BITS == 0); - for (i = 0x80 / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) - if (dfa->nodes[node].opr.sbcset[i]) - return; - break; - default: - abort (); - } - - if (mb_chars || has_period) - for (node = 0; node < dfa->nodes_len; ++node) - { - if (dfa->nodes[node].type == CHARACTER - && dfa->nodes[node].opr.c >= 0x80) - dfa->nodes[node].mb_partial = 0; - else if (dfa->nodes[node].type == OP_PERIOD) - dfa->nodes[node].type = OP_UTF8_PERIOD; - } - - /* The search can be in single byte locale. */ - dfa->mb_cur_max = 1; - dfa->is_utf8 = 0; - dfa->has_mb_node = dfa->nbackref > 0 || has_period; -} -#endif - -/* Analyze the structure tree, and calculate "first", "next", "edest", - "eclosure", and "inveclosure". */ - -static reg_errcode_t -analyze (regex_t *preg) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - reg_errcode_t ret; - - /* Allocate arrays. */ - dfa->nexts = re_malloc (int, dfa->nodes_alloc); - dfa->org_indices = re_malloc (int, dfa->nodes_alloc); - dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); - dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); - if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL - || dfa->eclosures == NULL, 0)) - return REG_ESPACE; - - dfa->subexp_map = re_malloc (int, preg->re_nsub); - if (dfa->subexp_map != NULL) - { - int i; - for (i = 0; i < preg->re_nsub; i++) - dfa->subexp_map[i] = i; - preorder (dfa->str_tree, optimize_subexps, dfa); - for (i = 0; i < preg->re_nsub; i++) - if (dfa->subexp_map[i] != i) - break; - if (i == preg->re_nsub) - { - free (dfa->subexp_map); - dfa->subexp_map = NULL; - } - } - - ret = postorder (dfa->str_tree, lower_subexps, preg); - if (BE (ret != REG_NOERROR, 0)) - return ret; - ret = postorder (dfa->str_tree, calc_first, dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - preorder (dfa->str_tree, calc_next, dfa); - ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - ret = calc_eclosure (dfa); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - /* We only need this during the prune_impossible_nodes pass in regexec.c; - skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */ - if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match) - || dfa->nbackref) - { - dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); - if (BE (dfa->inveclosures == NULL, 0)) - return REG_ESPACE; - ret = calc_inveclosure (dfa); - } - - return ret; -} - -/* Our parse trees are very unbalanced, so we cannot use a stack to - implement parse tree visits. Instead, we use parent pointers and - some hairy code in these two functions. */ -static reg_errcode_t -postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra) -{ - bin_tree_t *node, *prev; - - for (node = root; ; ) - { - /* Descend down the tree, preferably to the left (or to the right - if that's the only child). */ - while (node->left || node->right) - if (node->left) - node = node->left; - else - node = node->right; - - do - { - reg_errcode_t err = fn (extra, node); - if (BE (err != REG_NOERROR, 0)) - return err; - if (node->parent == NULL) - return REG_NOERROR; - prev = node; - node = node->parent; - } - /* Go up while we have a node that is reached from the right. */ - while (node->right == prev || node->right == NULL); - node = node->right; - } -} - -static reg_errcode_t -preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), - void *extra) -{ - bin_tree_t *node; - - for (node = root; ; ) - { - reg_errcode_t err = fn (extra, node); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* Go to the left node, or up and to the right. */ - if (node->left) - node = node->left; - else - { - bin_tree_t *prev = NULL; - while (node->right == prev || node->right == NULL) - { - prev = node; - node = node->parent; - if (!node) - return REG_NOERROR; - } - node = node->right; - } - } -} - -/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell - re_search_internal to map the inner one's opr.idx to this one's. Adjust - backreferences as well. Requires a preorder visit. */ -static reg_errcode_t -optimize_subexps (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - - if (node->token.type == OP_BACK_REF && dfa->subexp_map) - { - int idx = node->token.opr.idx; - node->token.opr.idx = dfa->subexp_map[idx]; - dfa->used_bkref_map |= 1 << node->token.opr.idx; - } - - else if (node->token.type == SUBEXP - && node->left && node->left->token.type == SUBEXP) - { - int other_idx = node->left->token.opr.idx; - - node->left = node->left->left; - if (node->left) - node->left->parent = node; - - dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; - if (other_idx < BITSET_WORD_BITS) - dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx); - } - - return REG_NOERROR; -} - -/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation - of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */ -static reg_errcode_t -lower_subexps (void *extra, bin_tree_t *node) -{ - regex_t *preg = (regex_t *) extra; - reg_errcode_t err = REG_NOERROR; - - if (node->left && node->left->token.type == SUBEXP) - { - node->left = lower_subexp (&err, preg, node->left); - if (node->left) - node->left->parent = node; - } - if (node->right && node->right->token.type == SUBEXP) - { - node->right = lower_subexp (&err, preg, node->right); - if (node->right) - node->right->parent = node; - } - - return err; -} - -static bin_tree_t * -lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_t *body = node->left; - bin_tree_t *op, *cls, *tree1, *tree; - - if (preg->no_sub - /* We do not optimize empty subexpressions, because otherwise we may - have bad CONCAT nodes with NULL children. This is obviously not - very common, so we do not lose much. An example that triggers - this case is the sed "script" /\(\)/x. */ - && node->left != NULL - && (node->token.opr.idx >= BITSET_WORD_BITS - || !(dfa->used_bkref_map - & ((bitset_word_t) 1 << node->token.opr.idx)))) - return node->left; - - /* Convert the SUBEXP node to the concatenation of an - OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */ - op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP); - cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); - tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; - tree = create_tree (dfa, op, tree1, CONCAT); - if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - - op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; - op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; - return tree; -} - -/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton - nodes. Requires a postorder visit. */ -static reg_errcode_t -calc_first (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - if (node->token.type == CONCAT) - { - node->first = node->left->first; - node->node_idx = node->left->node_idx; - } - else - { - node->first = node; - node->node_idx = re_dfa_add_node (dfa, node->token); - if (BE (node->node_idx == -1, 0)) - return REG_ESPACE; - } - return REG_NOERROR; -} - -/* Pass 2: compute NEXT on the tree. Preorder visit. */ -static reg_errcode_t -calc_next (void *extra, bin_tree_t *node) -{ - switch (node->token.type) - { - case OP_DUP_ASTERISK: - node->left->next = node; - break; - case CONCAT: - node->left->next = node->right->first; - node->right->next = node->next; - break; - default: - if (node->left) - node->left->next = node->next; - if (node->right) - node->right->next = node->next; - break; - } - return REG_NOERROR; -} - -/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */ -static reg_errcode_t -link_nfa_nodes (void *extra, bin_tree_t *node) -{ - re_dfa_t *dfa = (re_dfa_t *) extra; - int idx = node->node_idx; - reg_errcode_t err = REG_NOERROR; - - switch (node->token.type) - { - case CONCAT: - break; - - case END_OF_RE: - assert (node->next == NULL); - break; - - case OP_DUP_ASTERISK: - case OP_ALT: - { - int left, right; - dfa->has_plural_match = 1; - if (node->left != NULL) - left = node->left->first->node_idx; - else - left = node->next->node_idx; - if (node->right != NULL) - right = node->right->first->node_idx; - else - right = node->next->node_idx; - assert (left > -1); - assert (right > -1); - err = re_node_set_init_2 (dfa->edests + idx, left, right); - } - break; - - case ANCHOR: - case OP_OPEN_SUBEXP: - case OP_CLOSE_SUBEXP: - err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx); - break; - - case OP_BACK_REF: - dfa->nexts[idx] = node->next->node_idx; - if (node->token.type == OP_BACK_REF) - re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]); - break; - - default: - assert (!IS_EPSILON_NODE (node->token.type)); - dfa->nexts[idx] = node->next->node_idx; - break; - } - - return err; -} - -/* Duplicate the epsilon closure of the node ROOT_NODE. - Note that duplicated nodes have constraint INIT_CONSTRAINT in addition - to their own constraint. */ - -static reg_errcode_t -internal_function -duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node, - int root_node, unsigned int init_constraint) -{ - int org_node, clone_node, ret; - unsigned int constraint = init_constraint; - for (org_node = top_org_node, clone_node = top_clone_node;;) - { - int org_dest, clone_dest; - if (dfa->nodes[org_node].type == OP_BACK_REF) - { - /* If the back reference epsilon-transit, its destination must - also have the constraint. Then duplicate the epsilon closure - of the destination of the back reference, and store it in - edests of the back reference. */ - org_dest = dfa->nexts[org_node]; - re_node_set_empty (dfa->edests + clone_node); - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == -1, 0)) - return REG_ESPACE; - dfa->nexts[clone_node] = dfa->nexts[org_node]; - ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - } - else if (dfa->edests[org_node].nelem == 0) - { - /* In case of the node can't epsilon-transit, don't duplicate the - destination and store the original destination as the - destination of the node. */ - dfa->nexts[clone_node] = dfa->nexts[org_node]; - break; - } - else if (dfa->edests[org_node].nelem == 1) - { - /* In case of the node can epsilon-transit, and it has only one - destination. */ - org_dest = dfa->edests[org_node].elems[0]; - re_node_set_empty (dfa->edests + clone_node); - if (dfa->nodes[org_node].type == ANCHOR) - { - /* In case of the node has another constraint, append it. */ - if (org_node == root_node && clone_node != org_node) - { - /* ...but if the node is root_node itself, it means the - epsilon closure have a loop, then tie it to the - destination of the root_node. */ - ret = re_node_set_insert (dfa->edests + clone_node, - org_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - break; - } - constraint |= dfa->nodes[org_node].opr.ctx_type; - } - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == -1, 0)) - return REG_ESPACE; - ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - } - else /* dfa->edests[org_node].nelem == 2 */ - { - /* In case of the node can epsilon-transit, and it has two - destinations. In the bin_tree_t and DFA, that's '|' and '*'. */ - org_dest = dfa->edests[org_node].elems[0]; - re_node_set_empty (dfa->edests + clone_node); - /* Search for a duplicated node which satisfies the constraint. */ - clone_dest = search_duplicated_node (dfa, org_dest, constraint); - if (clone_dest == -1) - { - /* There are no such a duplicated node, create a new one. */ - reg_errcode_t err; - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == -1, 0)) - return REG_ESPACE; - ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - err = duplicate_node_closure (dfa, org_dest, clone_dest, - root_node, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - { - /* There are a duplicated node which satisfy the constraint, - use it to avoid infinite loop. */ - ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - } - - org_dest = dfa->edests[org_node].elems[1]; - clone_dest = duplicate_node (dfa, org_dest, constraint); - if (BE (clone_dest == -1, 0)) - return REG_ESPACE; - ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); - if (BE (ret < 0, 0)) - return REG_ESPACE; - } - org_node = org_dest; - clone_node = clone_dest; - } - return REG_NOERROR; -} - -/* Search for a node which is duplicated from the node ORG_NODE, and - satisfies the constraint CONSTRAINT. */ - -static int -search_duplicated_node (const re_dfa_t *dfa, int org_node, - unsigned int constraint) -{ - int idx; - for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) - { - if (org_node == dfa->org_indices[idx] - && constraint == dfa->nodes[idx].constraint) - return idx; /* Found. */ - } - return -1; /* Not found. */ -} - -/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. - Return the index of the new node, or -1 if insufficient storage is - available. */ - -static int -duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint) -{ - int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); - if (BE (dup_idx != -1, 1)) - { - dfa->nodes[dup_idx].constraint = constraint; - if (dfa->nodes[org_idx].type == ANCHOR) - dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type; - dfa->nodes[dup_idx].duplicated = 1; - - /* Store the index of the original node. */ - dfa->org_indices[dup_idx] = org_idx; - } - return dup_idx; -} - -static reg_errcode_t -calc_inveclosure (re_dfa_t *dfa) -{ - int src, idx, ret; - for (idx = 0; idx < dfa->nodes_len; ++idx) - re_node_set_init_empty (dfa->inveclosures + idx); - - for (src = 0; src < dfa->nodes_len; ++src) - { - int *elems = dfa->eclosures[src].elems; - for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) - { - ret = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); - if (BE (ret == -1, 0)) - return REG_ESPACE; - } - } - - return REG_NOERROR; -} - -/* Calculate "eclosure" for all the node in DFA. */ - -static reg_errcode_t -calc_eclosure (re_dfa_t *dfa) -{ - int node_idx, incomplete; -#ifdef DEBUG - assert (dfa->nodes_len > 0); -#endif - incomplete = 0; - /* For each nodes, calculate epsilon closure. */ - for (node_idx = 0; ; ++node_idx) - { - reg_errcode_t err; - re_node_set eclosure_elem; - if (node_idx == dfa->nodes_len) - { - if (!incomplete) - break; - incomplete = 0; - node_idx = 0; - } - -#ifdef DEBUG - assert (dfa->eclosures[node_idx].nelem != -1); -#endif - - /* If we have already calculated, skip it. */ - if (dfa->eclosures[node_idx].nelem != 0) - continue; - /* Calculate epsilon closure of `node_idx'. */ - err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (dfa->eclosures[node_idx].nelem == 0) - { - incomplete = 1; - re_node_set_free (&eclosure_elem); - } - } - return REG_NOERROR; -} - -/* Calculate epsilon closure of NODE. */ - -static reg_errcode_t -calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root) -{ - reg_errcode_t err; - unsigned int constraint; - int i, incomplete; - re_node_set eclosure; - incomplete = 0; - err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* This indicates that we are calculating this node now. - We reference this value to avoid infinite loop. */ - dfa->eclosures[node].nelem = -1; - - constraint = ((dfa->nodes[node].type == ANCHOR) - ? dfa->nodes[node].opr.ctx_type : 0); - /* If the current node has constraints, duplicate all nodes. - Since they must inherit the constraints. */ - if (constraint - && dfa->edests[node].nelem - && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) - { - err = duplicate_node_closure (dfa, node, node, node, constraint); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - /* Expand each epsilon destination nodes. */ - if (IS_EPSILON_NODE(dfa->nodes[node].type)) - for (i = 0; i < dfa->edests[node].nelem; ++i) - { - re_node_set eclosure_elem; - int edest = dfa->edests[node].elems[i]; - /* If calculating the epsilon closure of `edest' is in progress, - return intermediate result. */ - if (dfa->eclosures[edest].nelem == -1) - { - incomplete = 1; - continue; - } - /* If we haven't calculated the epsilon closure of `edest' yet, - calculate now. Otherwise use calculated epsilon closure. */ - if (dfa->eclosures[edest].nelem == 0) - { - err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - eclosure_elem = dfa->eclosures[edest]; - /* Merge the epsilon closure of `edest'. */ - re_node_set_merge (&eclosure, &eclosure_elem); - /* If the epsilon closure of `edest' is incomplete, - the epsilon closure of this node is also incomplete. */ - if (dfa->eclosures[edest].nelem == 0) - { - incomplete = 1; - re_node_set_free (&eclosure_elem); - } - } - - /* Epsilon closures include itself. */ - re_node_set_insert (&eclosure, node); - if (incomplete && !root) - dfa->eclosures[node].nelem = 0; - else - dfa->eclosures[node] = eclosure; - *new_set = eclosure; - return REG_NOERROR; -} - -/* Functions for token which are used in the parser. */ - -/* Fetch a token from INPUT. - We must not use this function inside bracket expressions. */ - -static void -internal_function -fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) -{ - re_string_skip_bytes (input, peek_token (result, input, syntax)); -} - -/* Peek a token from INPUT, and return the length of the token. - We must not use this function inside bracket expressions. */ - -static int -internal_function -peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) -{ - unsigned char c; - - if (re_string_eoi (input)) - { - token->type = END_OF_RE; - return 0; - } - - c = re_string_peek_byte (input, 0); - token->opr.c = c; - - token->word_char = 0; -#ifdef RE_ENABLE_I18N - token->mb_partial = 0; - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) - { - token->type = CHARACTER; - token->mb_partial = 1; - return 1; - } -#endif - if (c == '\\') - { - unsigned char c2; - if (re_string_cur_idx (input) + 1 >= re_string_length (input)) - { - token->type = BACK_SLASH; - return 1; - } - - c2 = re_string_peek_byte_case (input, 1); - token->opr.c = c2; - token->type = CHARACTER; -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc = re_string_wchar_at (input, - re_string_cur_idx (input) + 1); - token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; - } - else -#endif - token->word_char = IS_WORD_CHAR (c2) != 0; - - switch (c2) - { - case '|': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR)) - token->type = OP_ALT; - break; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - if (!(syntax & RE_NO_BK_REFS)) - { - token->type = OP_BACK_REF; - token->opr.idx = c2 - '1'; - } - break; - case '<': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_FIRST; - } - break; - case '>': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_LAST; - } - break; - case 'b': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = WORD_DELIM; - } - break; - case 'B': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = NOT_WORD_DELIM; - } - break; - case 'w': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_WORD; - break; - case 'W': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_NOTWORD; - break; - case 's': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_SPACE; - break; - case 'S': - if (!(syntax & RE_NO_GNU_OPS)) - token->type = OP_NOTSPACE; - break; - case '`': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = BUF_FIRST; - } - break; - case '\'': - if (!(syntax & RE_NO_GNU_OPS)) - { - token->type = ANCHOR; - token->opr.ctx_type = BUF_LAST; - } - break; - case '(': - if (!(syntax & RE_NO_BK_PARENS)) - token->type = OP_OPEN_SUBEXP; - break; - case ')': - if (!(syntax & RE_NO_BK_PARENS)) - token->type = OP_CLOSE_SUBEXP; - break; - case '+': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_PLUS; - break; - case '?': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_QUESTION; - break; - case '{': - if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) - token->type = OP_OPEN_DUP_NUM; - break; - case '}': - if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) - token->type = OP_CLOSE_DUP_NUM; - break; - default: - break; - } - return 2; - } - - token->type = CHARACTER; -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); - token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; - } - else -#endif - token->word_char = IS_WORD_CHAR (token->opr.c); - - switch (c) - { - case '\n': - if (syntax & RE_NEWLINE_ALT) - token->type = OP_ALT; - break; - case '|': - if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR)) - token->type = OP_ALT; - break; - case '*': - token->type = OP_DUP_ASTERISK; - break; - case '+': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_PLUS; - break; - case '?': - if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) - token->type = OP_DUP_QUESTION; - break; - case '{': - if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - token->type = OP_OPEN_DUP_NUM; - break; - case '}': - if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) - token->type = OP_CLOSE_DUP_NUM; - break; - case '(': - if (syntax & RE_NO_BK_PARENS) - token->type = OP_OPEN_SUBEXP; - break; - case ')': - if (syntax & RE_NO_BK_PARENS) - token->type = OP_CLOSE_SUBEXP; - break; - case '[': - token->type = OP_OPEN_BRACKET; - break; - case '.': - token->type = OP_PERIOD; - break; - case '^': - if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && - re_string_cur_idx (input) != 0) - { - char prev = re_string_peek_byte (input, -1); - if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') - break; - } - token->type = ANCHOR; - token->opr.ctx_type = LINE_FIRST; - break; - case '$': - if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && - re_string_cur_idx (input) + 1 != re_string_length (input)) - { - re_token_t next; - re_string_skip_bytes (input, 1); - peek_token (&next, input, syntax); - re_string_skip_bytes (input, -1); - if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP) - break; - } - token->type = ANCHOR; - token->opr.ctx_type = LINE_LAST; - break; - default: - break; - } - return 1; -} - -/* Peek a token from INPUT, and return the length of the token. - We must not use this function out of bracket expressions. */ - -static int -internal_function -peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) -{ - unsigned char c; - if (re_string_eoi (input)) - { - token->type = END_OF_RE; - return 0; - } - c = re_string_peek_byte (input, 0); - token->opr.c = c; - -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1 && - !re_string_first_byte (input, re_string_cur_idx (input))) - { - token->type = CHARACTER; - return 1; - } -#endif /* RE_ENABLE_I18N */ - - if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) - && re_string_cur_idx (input) + 1 < re_string_length (input)) - { - /* In this case, '\' escape a character. */ - unsigned char c2; - re_string_skip_bytes (input, 1); - c2 = re_string_peek_byte (input, 0); - token->opr.c = c2; - token->type = CHARACTER; - return 1; - } - if (c == '[') /* '[' is a special char in a bracket exps. */ - { - unsigned char c2; - int token_len; - if (re_string_cur_idx (input) + 1 < re_string_length (input)) - c2 = re_string_peek_byte (input, 1); - else - c2 = 0; - token->opr.c = c2; - token_len = 2; - switch (c2) - { - case '.': - token->type = OP_OPEN_COLL_ELEM; - break; - case '=': - token->type = OP_OPEN_EQUIV_CLASS; - break; - case ':': - if (syntax & RE_CHAR_CLASSES) - { - token->type = OP_OPEN_CHAR_CLASS; - break; - } - /* else fall through. */ - default: - token->type = CHARACTER; - token->opr.c = c; - token_len = 1; - break; - } - return token_len; - } - switch (c) - { - case '-': - token->type = OP_CHARSET_RANGE; - break; - case ']': - token->type = OP_CLOSE_BRACKET; - break; - case '^': - token->type = OP_NON_MATCH_LIST; - break; - default: - token->type = CHARACTER; - } - return 1; -} - -/* Functions for parser. */ - -/* Entry point of the parser. - Parse the regular expression REGEXP and return the structure tree. - If an error is occured, ERR is set by error code, and return NULL. - This function build the following tree, from regular expression : - CAT - / \ - / \ - EOR - - CAT means concatenation. - EOR means end of regular expression. */ - -static bin_tree_t * -parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, - reg_errcode_t *err) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_t *tree, *eor, *root; - re_token_t current_token; - dfa->syntax = syntax; - fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); - tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - eor = create_tree (dfa, NULL, NULL, END_OF_RE); - if (tree != NULL) - root = create_tree (dfa, tree, eor, CONCAT); - else - root = eor; - if (BE (eor == NULL || root == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - return root; -} - -/* This function build the following tree, from regular expression - |: - ALT - / \ - / \ - - - ALT means alternative, which represents the operator `|'. */ - -static bin_tree_t * -parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, int nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_t *tree, *branch = NULL; - tree = parse_branch (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - - while (token->type == OP_ALT) - { - fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); - if (token->type != OP_ALT && token->type != END_OF_RE - && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) - { - branch = parse_branch (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && branch == NULL, 0)) - return NULL; - } - else - branch = NULL; - tree = create_tree (dfa, tree, branch, OP_ALT); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - return tree; -} - -/* This function build the following tree, from regular expression - : - CAT - / \ - / \ - - - CAT means concatenation. */ - -static bin_tree_t * -parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, int nest, reg_errcode_t *err) -{ - bin_tree_t *tree, *exp; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - tree = parse_expression (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - - while (token->type != OP_ALT && token->type != END_OF_RE - && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) - { - exp = parse_expression (regexp, preg, token, syntax, nest, err); - if (BE (*err != REG_NOERROR && exp == NULL, 0)) - { - return NULL; - } - if (tree != NULL && exp != NULL) - { - tree = create_tree (dfa, tree, exp, CONCAT); - if (tree == NULL) - { - *err = REG_ESPACE; - return NULL; - } - } - else if (tree == NULL) - tree = exp; - /* Otherwise exp == NULL, we don't need to create new tree. */ - } - return tree; -} - -/* This function build the following tree, from regular expression a*: - * - | - a -*/ - -static bin_tree_t * -parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, int nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_t *tree; - switch (token->type) - { - case CHARACTER: - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - while (!re_string_eoi (regexp) - && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) - { - bin_tree_t *mbc_remain; - fetch_token (token, regexp, syntax); - mbc_remain = create_token_tree (dfa, NULL, NULL, token); - tree = create_tree (dfa, tree, mbc_remain, CONCAT); - if (BE (mbc_remain == NULL || tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - } -#endif - break; - case OP_OPEN_SUBEXP: - tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_OPEN_BRACKET: - tree = parse_bracket_exp (regexp, dfa, token, syntax, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_BACK_REF: - if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) - { - *err = REG_ESUBREG; - return NULL; - } - dfa->used_bkref_map |= 1 << token->opr.idx; - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - ++dfa->nbackref; - dfa->has_mb_node = 1; - break; - case OP_OPEN_DUP_NUM: - if (syntax & RE_CONTEXT_INVALID_DUP) - { - *err = REG_BADRPT; - return NULL; - } - /* FALLTHROUGH */ - case OP_DUP_ASTERISK: - case OP_DUP_PLUS: - case OP_DUP_QUESTION: - if (syntax & RE_CONTEXT_INVALID_OPS) - { - *err = REG_BADRPT; - return NULL; - } - else if (syntax & RE_CONTEXT_INDEP_OPS) - { - fetch_token (token, regexp, syntax); - return parse_expression (regexp, preg, token, syntax, nest, err); - } - /* else fall through */ - case OP_CLOSE_SUBEXP: - if ((token->type == OP_CLOSE_SUBEXP) && - !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) - { - *err = REG_ERPAREN; - return NULL; - } - /* else fall through */ - case OP_CLOSE_DUP_NUM: - /* We treat it as a normal character. */ - - /* Then we can these characters as normal characters. */ - token->type = CHARACTER; - /* mb_partial and word_char bits should be initialized already - by peek_token. */ - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - break; - case ANCHOR: - if ((token->opr.ctx_type - & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) - && dfa->word_ops_used == 0) - init_word_char (dfa); - if (token->opr.ctx_type == WORD_DELIM - || token->opr.ctx_type == NOT_WORD_DELIM) - { - bin_tree_t *tree_first, *tree_last; - if (token->opr.ctx_type == WORD_DELIM) - { - token->opr.ctx_type = WORD_FIRST; - tree_first = create_token_tree (dfa, NULL, NULL, token); - token->opr.ctx_type = WORD_LAST; - } - else - { - token->opr.ctx_type = INSIDE_WORD; - tree_first = create_token_tree (dfa, NULL, NULL, token); - token->opr.ctx_type = INSIDE_NOTWORD; - } - tree_last = create_token_tree (dfa, NULL, NULL, token); - tree = create_tree (dfa, tree_first, tree_last, OP_ALT); - if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - else - { - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - } - /* We must return here, since ANCHORs can't be followed - by repetition operators. - eg. RE"^*" is invalid or "", - it must not be "". */ - fetch_token (token, regexp, syntax); - return tree; - case OP_PERIOD: - tree = create_token_tree (dfa, NULL, NULL, token); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - if (dfa->mb_cur_max > 1) - dfa->has_mb_node = 1; - break; - case OP_WORD: - case OP_NOTWORD: - tree = build_charclass_op (dfa, regexp->trans, - (const unsigned char *) "alnum", - (const unsigned char *) "_", - token->type == OP_NOTWORD, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_SPACE: - case OP_NOTSPACE: - tree = build_charclass_op (dfa, regexp->trans, - (const unsigned char *) "space", - (const unsigned char *) "", - token->type == OP_NOTSPACE, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - break; - case OP_ALT: - case END_OF_RE: - return NULL; - case BACK_SLASH: - *err = REG_EESCAPE; - return NULL; - default: - /* Must not happen? */ -#ifdef DEBUG - assert (0); -#endif - return NULL; - } - fetch_token (token, regexp, syntax); - - while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS - || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) - { - tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); - if (BE (*err != REG_NOERROR && tree == NULL, 0)) - return NULL; - /* In BRE consecutive duplications are not allowed. */ - if ((syntax & RE_CONTEXT_INVALID_DUP) - && (token->type == OP_DUP_ASTERISK - || token->type == OP_OPEN_DUP_NUM)) - { - *err = REG_BADRPT; - return NULL; - } - } - - return tree; -} - -/* This function build the following tree, from regular expression - (): - SUBEXP - | - -*/ - -static bin_tree_t * -parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, - reg_syntax_t syntax, int nest, reg_errcode_t *err) -{ - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - bin_tree_t *tree; - size_t cur_nsub; - cur_nsub = preg->re_nsub++; - - fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); - - /* The subexpression may be a null string. */ - if (token->type == OP_CLOSE_SUBEXP) - tree = NULL; - else - { - tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); - if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) - *err = REG_EPAREN; - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } - - if (cur_nsub <= '9' - '1') - dfa->completed_bkref_map |= 1 << cur_nsub; - - tree = create_tree (dfa, tree, NULL, SUBEXP); - if (BE (tree == NULL, 0)) - { - *err = REG_ESPACE; - return NULL; - } - tree->token.opr.idx = cur_nsub; - return tree; -} - -/* This function parse repetition operators like "*", "+", "{1,3}" etc. */ - -static bin_tree_t * -parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, - re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) -{ - bin_tree_t *tree = NULL, *old_tree = NULL; - int i, start, end, start_idx = re_string_cur_idx (regexp); - re_token_t start_token = *token; - - if (token->type == OP_OPEN_DUP_NUM) - { - end = 0; - start = fetch_number (regexp, token, syntax); - if (start == -1) - { - if (token->type == CHARACTER && token->opr.c == ',') - start = 0; /* We treat "{,m}" as "{0,m}". */ - else - { - *err = REG_BADBR; /* {} is invalid. */ - return NULL; - } - } - if (BE (start != -2, 1)) - { - /* We treat "{n}" as "{n,n}". */ - end = ((token->type == OP_CLOSE_DUP_NUM) ? start - : ((token->type == CHARACTER && token->opr.c == ',') - ? fetch_number (regexp, token, syntax) : -2)); - } - if (BE (start == -2 || end == -2, 0)) - { - /* Invalid sequence. */ - if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) - { - if (token->type == END_OF_RE) - *err = REG_EBRACE; - else - *err = REG_BADBR; - - return NULL; - } - - /* If the syntax bit is set, rollback. */ - re_string_set_index (regexp, start_idx); - *token = start_token; - token->type = CHARACTER; - /* mb_partial and word_char bits should be already initialized by - peek_token. */ - return elem; - } - - if (BE (end != -1 && start > end, 0)) - { - /* First number greater than second. */ - *err = REG_BADBR; - return NULL; - } - } - else - { - start = (token->type == OP_DUP_PLUS) ? 1 : 0; - end = (token->type == OP_DUP_QUESTION) ? 1 : -1; - } - - fetch_token (token, regexp, syntax); - - if (BE (elem == NULL, 0)) - return NULL; - if (BE (start == 0 && end == 0, 0)) - { - postorder (elem, free_tree, NULL); - return NULL; - } - - /* Extract "{n,m}" to "...{0,}". */ - if (BE (start > 0, 0)) - { - tree = elem; - for (i = 2; i <= start; ++i) - { - elem = duplicate_tree (elem, dfa); - tree = create_tree (dfa, tree, elem, CONCAT); - if (BE (elem == NULL || tree == NULL, 0)) - goto parse_dup_op_espace; - } - - if (start == end) - return tree; - - /* Duplicate ELEM before it is marked optional. */ - elem = duplicate_tree (elem, dfa); - old_tree = tree; - } - else - old_tree = NULL; - - if (elem->token.type == SUBEXP) - postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); - - tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); - if (BE (tree == NULL, 0)) - goto parse_dup_op_espace; - - /* This loop is actually executed only when end != -1, - to rewrite {0,n} as ((...?)?)?... We have - already created the start+1-th copy. */ - for (i = start + 2; i <= end; ++i) - { - elem = duplicate_tree (elem, dfa); - tree = create_tree (dfa, tree, elem, CONCAT); - if (BE (elem == NULL || tree == NULL, 0)) - goto parse_dup_op_espace; - - tree = create_tree (dfa, tree, NULL, OP_ALT); - if (BE (tree == NULL, 0)) - goto parse_dup_op_espace; - } - - if (old_tree) - tree = create_tree (dfa, old_tree, tree, CONCAT); - - return tree; - - parse_dup_op_espace: - *err = REG_ESPACE; - return NULL; -} - -/* Size of the names for collating symbol/equivalence_class/character_class. - I'm not sure, but maybe enough. */ -#define BRACKET_NAME_BUF_SIZE 32 - -#ifndef _LIBC - /* Local function for parse_bracket_exp only used in case of NOT _LIBC. - Build the range expression which starts from START_ELEM, and ends - at END_ELEM. The result are written to MBCSET and SBCSET. - RANGE_ALLOC is the allocated size of mbcset->range_starts, and - mbcset->range_ends, is a pointer argument sinse we may - update it. */ - -static reg_errcode_t -internal_function -# ifdef RE_ENABLE_I18N -build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, - bracket_elem_t *start_elem, bracket_elem_t *end_elem) -# else /* not RE_ENABLE_I18N */ -build_range_exp (bitset_t sbcset, bracket_elem_t *start_elem, - bracket_elem_t *end_elem) -# endif /* not RE_ENABLE_I18N */ -{ - unsigned int start_ch, end_ch; - /* Equivalence Classes and Character Classes can't be a range start/end. */ - if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS - || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, - 0)) - return REG_ERANGE; - - /* We can handle no multi character collating elements without libc - support. */ - if (BE ((start_elem->type == COLL_SYM - && strlen ((char *) start_elem->opr.name) > 1) - || (end_elem->type == COLL_SYM - && strlen ((char *) end_elem->opr.name) > 1), 0)) - return REG_ECOLLATE; - -# ifdef RE_ENABLE_I18N - { - wchar_t wc; - wint_t start_wc; - wint_t end_wc; - wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; - - start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch - : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] - : 0)); - end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch - : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] - : 0)); - start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) - ? __btowc (start_ch) : start_elem->opr.wch); - end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) - ? __btowc (end_ch) : end_elem->opr.wch); - if (start_wc == WEOF || end_wc == WEOF) - return REG_ECOLLATE; - cmp_buf[0] = start_wc; - cmp_buf[4] = end_wc; - if (wcscoll (cmp_buf, cmp_buf + 4) > 0) - return REG_ERANGE; - - /* Got valid collation sequence values, add them as a new entry. - However, for !_LIBC we have no collation elements: if the - character set is single byte, the single byte character set - that we build below suffices. parse_bracket_exp passes - no MBCSET if dfa->mb_cur_max == 1. */ - if (mbcset) - { - /* Check the space of the arrays. */ - if (BE (*range_alloc == mbcset->nranges, 0)) - { - /* There is not enough space, need realloc. */ - wchar_t *new_array_start, *new_array_end; - int new_nranges; - - /* +1 in case of mbcset->nranges is 0. */ - new_nranges = 2 * mbcset->nranges + 1; - /* Use realloc since mbcset->range_starts and mbcset->range_ends - are NULL if *range_alloc == 0. */ - new_array_start = re_realloc (mbcset->range_starts, wchar_t, - new_nranges); - new_array_end = re_realloc (mbcset->range_ends, wchar_t, - new_nranges); - - if (BE (new_array_start == NULL || new_array_end == NULL, 0)) - return REG_ESPACE; - - mbcset->range_starts = new_array_start; - mbcset->range_ends = new_array_end; - *range_alloc = new_nranges; - } - - mbcset->range_starts[mbcset->nranges] = start_wc; - mbcset->range_ends[mbcset->nranges++] = end_wc; - } - - /* Build the table for single byte characters. */ - for (wc = 0; wc < SBC_MAX; ++wc) - { - cmp_buf[2] = wc; - if (wcscoll (cmp_buf, cmp_buf + 2) <= 0 - && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0) - bitset_set (sbcset, wc); - } - } -# else /* not RE_ENABLE_I18N */ - { - unsigned int ch; - start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch - : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] - : 0)); - end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch - : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] - : 0)); - if (start_ch > end_ch) - return REG_ERANGE; - /* Build the table for single byte characters. */ - for (ch = 0; ch < SBC_MAX; ++ch) - if (start_ch <= ch && ch <= end_ch) - bitset_set (sbcset, ch); - } -# endif /* not RE_ENABLE_I18N */ - return REG_NOERROR; -} -#endif /* not _LIBC */ - -#ifndef _LIBC -/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. - Build the collating element which is represented by NAME. - The result are written to MBCSET and SBCSET. - COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a - pointer argument since we may update it. */ - -static reg_errcode_t -internal_function -# ifdef RE_ENABLE_I18N -build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, - int *coll_sym_alloc, const unsigned char *name) -# else /* not RE_ENABLE_I18N */ -build_collating_symbol (bitset_t sbcset, const unsigned char *name) -# endif /* not RE_ENABLE_I18N */ -{ - size_t name_len = strlen ((const char *) name); - if (BE (name_len != 1, 0)) - return REG_ECOLLATE; - else - { - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } -} -#endif /* not _LIBC */ - -/* This function parse bracket expression like "[abc]", "[a-c]", - "[[.a-a.]]" etc. */ - -static bin_tree_t * -parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, - reg_syntax_t syntax, reg_errcode_t *err) -{ -#ifdef _LIBC - const unsigned char *collseqmb; - const char *collseqwc; - uint32_t nrules; - int32_t table_size; - const int32_t *symb_table; - const unsigned char *extra; - - /* Local function for parse_bracket_exp used in _LIBC environement. - Seek the collating symbol entry correspondings to NAME. - Return the index of the symbol in the SYMB_TABLE. */ - - auto inline int32_t - __attribute ((always_inline)) - seek_collating_symbol_entry (name, name_len) - const unsigned char *name; - size_t name_len; - { - int32_t hash = elem_hash ((const char *) name, name_len); - int32_t elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - int32_t second = hash % (table_size - 2) + 1; - - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - /* Compare the length of the name. */ - && name_len == extra[symb_table[2 * elem + 1]] - /* Compare the name. */ - && memcmp (name, &extra[symb_table[2 * elem + 1] + 1], - name_len) == 0) - { - /* Yep, this is the entry. */ - break; - } - - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } - return elem; - } - - /* Local function for parse_bracket_exp used in _LIBC environement. - Look up the collation sequence value of BR_ELEM. - Return the value if succeeded, UINT_MAX otherwise. */ - - auto inline unsigned int - __attribute ((always_inline)) - lookup_collation_sequence_value (br_elem) - bracket_elem_t *br_elem; - { - if (br_elem->type == SB_CHAR) - { - /* - if (MB_CUR_MAX == 1) - */ - if (nrules == 0) - return collseqmb[br_elem->opr.ch]; - else - { - wint_t wc = __btowc (br_elem->opr.ch); - return __collseq_table_lookup (collseqwc, wc); - } - } - else if (br_elem->type == MB_CHAR) - { - return __collseq_table_lookup (collseqwc, br_elem->opr.wch); - } - else if (br_elem->type == COLL_SYM) - { - size_t sym_name_len = strlen ((char *) br_elem->opr.name); - if (nrules != 0) - { - int32_t elem, idx; - elem = seek_collating_symbol_entry (br_elem->opr.name, - sym_name_len); - if (symb_table[2 * elem] != 0) - { - /* We found the entry. */ - idx = symb_table[2 * elem + 1]; - /* Skip the name of collating element name. */ - idx += 1 + extra[idx]; - /* Skip the byte sequence of the collating element. */ - idx += 1 + extra[idx]; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; - /* Skip the multibyte collation sequence value. */ - idx += sizeof (unsigned int); - /* Skip the wide char sequence of the collating element. */ - idx += sizeof (unsigned int) * - (1 + *(unsigned int *) (extra + idx)); - /* Return the collation sequence value. */ - return *(unsigned int *) (extra + idx); - } - else if (symb_table[2 * elem] == 0 && sym_name_len == 1) - { - /* No valid character. Match it as a single byte - character. */ - return collseqmb[br_elem->opr.name[0]]; - } - } - else if (sym_name_len == 1) - return collseqmb[br_elem->opr.name[0]]; - } - return UINT_MAX; - } - - /* Local function for parse_bracket_exp used in _LIBC environement. - Build the range expression which starts from START_ELEM, and ends - at END_ELEM. The result are written to MBCSET and SBCSET. - RANGE_ALLOC is the allocated size of mbcset->range_starts, and - mbcset->range_ends, is a pointer argument sinse we may - update it. */ - - auto inline reg_errcode_t - __attribute ((always_inline)) - build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) - re_charset_t *mbcset; - int *range_alloc; - bitset_t sbcset; - bracket_elem_t *start_elem, *end_elem; - { - unsigned int ch; - uint32_t start_collseq; - uint32_t end_collseq; - - /* Equivalence Classes and Character Classes can't be a range - start/end. */ - if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS - || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, - 0)) - return REG_ERANGE; - - start_collseq = lookup_collation_sequence_value (start_elem); - end_collseq = lookup_collation_sequence_value (end_elem); - /* Check start/end collation sequence values. */ - if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) - return REG_ECOLLATE; - if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) - return REG_ERANGE; - - /* Got valid collation sequence values, add them as a new entry. - However, if we have no collation elements, and the character set - is single byte, the single byte character set that we - build below suffices. */ - if (nrules > 0 || dfa->mb_cur_max > 1) - { - /* Check the space of the arrays. */ - if (BE (*range_alloc == mbcset->nranges, 0)) - { - /* There is not enough space, need realloc. */ - uint32_t *new_array_start; - uint32_t *new_array_end; - int new_nranges; - - /* +1 in case of mbcset->nranges is 0. */ - new_nranges = 2 * mbcset->nranges + 1; - new_array_start = re_realloc (mbcset->range_starts, uint32_t, - new_nranges); - new_array_end = re_realloc (mbcset->range_ends, uint32_t, - new_nranges); - - if (BE (new_array_start == NULL || new_array_end == NULL, 0)) - return REG_ESPACE; - - mbcset->range_starts = new_array_start; - mbcset->range_ends = new_array_end; - *range_alloc = new_nranges; - } - - mbcset->range_starts[mbcset->nranges] = start_collseq; - mbcset->range_ends[mbcset->nranges++] = end_collseq; - } - - /* Build the table for single byte characters. */ - for (ch = 0; ch < SBC_MAX; ch++) - { - uint32_t ch_collseq; - /* - if (MB_CUR_MAX == 1) - */ - if (nrules == 0) - ch_collseq = collseqmb[ch]; - else - ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch)); - if (start_collseq <= ch_collseq && ch_collseq <= end_collseq) - bitset_set (sbcset, ch); - } - return REG_NOERROR; - } - - /* Local function for parse_bracket_exp used in _LIBC environement. - Build the collating element which is represented by NAME. - The result are written to MBCSET and SBCSET. - COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a - pointer argument sinse we may update it. */ - - auto inline reg_errcode_t - __attribute ((always_inline)) - build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name) - re_charset_t *mbcset; - int *coll_sym_alloc; - bitset_t sbcset; - const unsigned char *name; - { - int32_t elem, idx; - size_t name_len = strlen ((const char *) name); - if (nrules != 0) - { - elem = seek_collating_symbol_entry (name, name_len); - if (symb_table[2 * elem] != 0) - { - /* We found the entry. */ - idx = symb_table[2 * elem + 1]; - /* Skip the name of collating element name. */ - idx += 1 + extra[idx]; - } - else if (symb_table[2 * elem] == 0 && name_len == 1) - { - /* No valid character, treat it as a normal - character. */ - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } - else - return REG_ECOLLATE; - - /* Got valid collation sequence, add it as a new entry. */ - /* Check the space of the arrays. */ - if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->ncoll_syms is 0. */ - int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1; - /* Use realloc since mbcset->coll_syms is NULL - if *alloc == 0. */ - int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, - new_coll_sym_alloc); - if (BE (new_coll_syms == NULL, 0)) - return REG_ESPACE; - mbcset->coll_syms = new_coll_syms; - *coll_sym_alloc = new_coll_sym_alloc; - } - mbcset->coll_syms[mbcset->ncoll_syms++] = idx; - return REG_NOERROR; - } - else - { - if (BE (name_len != 1, 0)) - return REG_ECOLLATE; - else - { - bitset_set (sbcset, name[0]); - return REG_NOERROR; - } - } - } -#endif - - re_token_t br_token; - re_bitset_ptr_t sbcset; -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; - int coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; - int equiv_class_alloc = 0, char_class_alloc = 0; -#endif /* not RE_ENABLE_I18N */ - int non_match = 0; - bin_tree_t *work_tree; - int token_len; - int first_round = 1; -#ifdef _LIBC - collseqmb = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); - nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules) - { - /* - if (MB_CUR_MAX > 1) - */ - collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); - table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); - symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_TABLEMB); - extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_SYMB_EXTRAMB); - } -#endif - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); -#ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); -#endif /* RE_ENABLE_I18N */ -#ifdef RE_ENABLE_I18N - if (BE (sbcset == NULL || mbcset == NULL, 0)) -#else - if (BE (sbcset == NULL, 0)) -#endif /* RE_ENABLE_I18N */ - { - *err = REG_ESPACE; - return NULL; - } - - token_len = peek_token_bracket (token, regexp, syntax); - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_BADPAT; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_NON_MATCH_LIST) - { -#ifdef RE_ENABLE_I18N - mbcset->non_match = 1; -#endif /* not RE_ENABLE_I18N */ - non_match = 1; - if (syntax & RE_HAT_LISTS_NOT_NEWLINE) - bitset_set (sbcset, '\0'); - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - token_len = peek_token_bracket (token, regexp, syntax); - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_BADPAT; - goto parse_bracket_exp_free_return; - } - } - - /* We treat the first ']' as a normal character. */ - if (token->type == OP_CLOSE_BRACKET) - token->type = CHARACTER; - - while (1) - { - bracket_elem_t start_elem, end_elem; - unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; - unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; - reg_errcode_t ret; - int token_len2 = 0, is_range_exp = 0; - re_token_t token2; - - start_elem.opr.name = start_name_buf; - ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, - syntax, first_round); - if (BE (ret != REG_NOERROR, 0)) - { - *err = ret; - goto parse_bracket_exp_free_return; - } - first_round = 0; - - /* Get information about the next token. We need it in any case. */ - token_len = peek_token_bracket (token, regexp, syntax); - - /* Do not check for ranges if we know they are not allowed. */ - if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) - { - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_CHARSET_RANGE) - { - re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ - token_len2 = peek_token_bracket (&token2, regexp, syntax); - if (BE (token2.type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token2.type == OP_CLOSE_BRACKET) - { - /* We treat the last '-' as a normal character. */ - re_string_skip_bytes (regexp, -token_len); - token->type = CHARACTER; - } - else - is_range_exp = 1; - } - } - - if (is_range_exp == 1) - { - end_elem.opr.name = end_name_buf; - ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, - dfa, syntax, 1); - if (BE (ret != REG_NOERROR, 0)) - { - *err = ret; - goto parse_bracket_exp_free_return; - } - - token_len = peek_token_bracket (token, regexp, syntax); - -#ifdef _LIBC - *err = build_range_exp (sbcset, mbcset, &range_alloc, - &start_elem, &end_elem); -#else -# ifdef RE_ENABLE_I18N - *err = build_range_exp (sbcset, - dfa->mb_cur_max > 1 ? mbcset : NULL, - &range_alloc, &start_elem, &end_elem); -# else - *err = build_range_exp (sbcset, &start_elem, &end_elem); -# endif -#endif /* RE_ENABLE_I18N */ - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - } - else - { - switch (start_elem.type) - { - case SB_CHAR: - bitset_set (sbcset, start_elem.opr.ch); - break; -#ifdef RE_ENABLE_I18N - case MB_CHAR: - /* Check whether the array has enough space. */ - if (BE (mbchar_alloc == mbcset->nmbchars, 0)) - { - wchar_t *new_mbchars; - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nmbchars is 0. */ - mbchar_alloc = 2 * mbcset->nmbchars + 1; - /* Use realloc since array is NULL if *alloc == 0. */ - new_mbchars = re_realloc (mbcset->mbchars, wchar_t, - mbchar_alloc); - if (BE (new_mbchars == NULL, 0)) - goto parse_bracket_exp_espace; - mbcset->mbchars = new_mbchars; - } - mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; - break; -#endif /* RE_ENABLE_I18N */ - case EQUIV_CLASS: - *err = build_equiv_class (sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &equiv_class_alloc, -#endif /* RE_ENABLE_I18N */ - start_elem.opr.name); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - case COLL_SYM: - *err = build_collating_symbol (sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &coll_sym_alloc, -#endif /* RE_ENABLE_I18N */ - start_elem.opr.name); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - case CHAR_CLASS: - *err = build_charclass (regexp->trans, sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &char_class_alloc, -#endif /* RE_ENABLE_I18N */ - start_elem.opr.name, syntax); - if (BE (*err != REG_NOERROR, 0)) - goto parse_bracket_exp_free_return; - break; - default: - assert (0); - break; - } - } - if (BE (token->type == END_OF_RE, 0)) - { - *err = REG_EBRACK; - goto parse_bracket_exp_free_return; - } - if (token->type == OP_CLOSE_BRACKET) - break; - } - - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - - /* If it is non-matching list. */ - if (non_match) - bitset_not (sbcset); - -#ifdef RE_ENABLE_I18N - /* Ensure only single byte characters are set. */ - if (dfa->mb_cur_max > 1) - bitset_mask (sbcset, dfa->sb_char); - - if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes - || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes - || mbcset->non_match))) - { - bin_tree_t *mbc_tree; - int sbc_idx; - /* Build a tree for complex bracket. */ - dfa->has_mb_node = 1; - br_token.type = COMPLEX_BRACKET; - br_token.opr.mbcset = mbcset; - mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (mbc_tree == NULL, 0)) - goto parse_bracket_exp_espace; - for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) - if (sbcset[sbc_idx]) - break; - /* If there are no bits set in sbcset, there is no point - of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */ - if (sbc_idx < BITSET_WORDS) - { - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - work_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - - /* Then join them by ALT node. */ - work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - } - else - { - re_free (sbcset); - work_tree = mbc_tree; - } - } - else -#endif /* not RE_ENABLE_I18N */ - { -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - work_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (work_tree == NULL, 0)) - goto parse_bracket_exp_espace; - } - return work_tree; - - parse_bracket_exp_espace: - *err = REG_ESPACE; - parse_bracket_exp_free_return: - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - return NULL; -} - -/* Parse an element in the bracket expression. */ - -static reg_errcode_t -parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, - re_token_t *token, int token_len, re_dfa_t *dfa, - reg_syntax_t syntax, int accept_hyphen) -{ -#ifdef RE_ENABLE_I18N - int cur_char_size; - cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); - if (cur_char_size > 1) - { - elem->type = MB_CHAR; - elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp)); - re_string_skip_bytes (regexp, cur_char_size); - return REG_NOERROR; - } -#endif /* RE_ENABLE_I18N */ - re_string_skip_bytes (regexp, token_len); /* Skip a token. */ - if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS - || token->type == OP_OPEN_EQUIV_CLASS) - return parse_bracket_symbol (elem, regexp, token); - if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) - { - /* A '-' must only appear as anything but a range indicator before - the closing bracket. Everything else is an error. */ - re_token_t token2; - (void) peek_token_bracket (&token2, regexp, syntax); - if (token2.type != OP_CLOSE_BRACKET) - /* The actual error value is not standardized since this whole - case is undefined. But ERANGE makes good sense. */ - return REG_ERANGE; - } - elem->type = SB_CHAR; - elem->opr.ch = token->opr.c; - return REG_NOERROR; -} - -/* Parse a bracket symbol in the bracket expression. Bracket symbols are - such as [::], [..], and - [==]. */ - -static reg_errcode_t -parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, - re_token_t *token) -{ - unsigned char ch, delim = token->opr.c; - int i = 0; - if (re_string_eoi(regexp)) - return REG_EBRACK; - for (;; ++i) - { - if (i >= BRACKET_NAME_BUF_SIZE) - return REG_EBRACK; - if (token->type == OP_OPEN_CHAR_CLASS) - ch = re_string_fetch_byte_case (regexp); - else - ch = re_string_fetch_byte (regexp); - if (re_string_eoi(regexp)) - return REG_EBRACK; - if (ch == delim && re_string_peek_byte (regexp, 0) == ']') - break; - elem->opr.name[i] = ch; - } - re_string_skip_bytes (regexp, 1); - elem->opr.name[i] = '\0'; - switch (token->type) - { - case OP_OPEN_COLL_ELEM: - elem->type = COLL_SYM; - break; - case OP_OPEN_EQUIV_CLASS: - elem->type = EQUIV_CLASS; - break; - case OP_OPEN_CHAR_CLASS: - elem->type = CHAR_CLASS; - break; - default: - break; - } - return REG_NOERROR; -} - - /* Helper function for parse_bracket_exp. - Build the equivalence class which is represented by NAME. - The result are written to MBCSET and SBCSET. - EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, - is a pointer argument sinse we may update it. */ - -static reg_errcode_t -#ifdef RE_ENABLE_I18N -build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, - int *equiv_class_alloc, const unsigned char *name) -#else /* not RE_ENABLE_I18N */ -build_equiv_class (bitset_t sbcset, const unsigned char *name) -#endif /* not RE_ENABLE_I18N */ -{ -#ifdef _LIBC - uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules != 0) - { - const int32_t *table, *indirect; - const unsigned char *weights, *extra, *cp; - unsigned char char_buf[2]; - int32_t idx1, idx2; - unsigned int ch; - size_t len; - /* This #include defines a local function! */ -# include - /* Calculate the index for equivalence class. */ - cp = name; - table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_INDIRECTMB); - idx1 = findidx (&cp); - if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0)) - /* This isn't a valid character. */ - return REG_ECOLLATE; - - /* Build single byte matcing table for this equivalence class. */ - char_buf[1] = (unsigned char) '\0'; - len = weights[idx1]; - for (ch = 0; ch < SBC_MAX; ++ch) - { - char_buf[0] = ch; - cp = char_buf; - idx2 = findidx (&cp); -/* - idx2 = table[ch]; -*/ - if (idx2 == 0) - /* This isn't a valid character. */ - continue; - if (len == weights[idx2]) - { - int cnt = 0; - while (cnt <= len && - weights[idx1 + 1 + cnt] == weights[idx2 + 1 + cnt]) - ++cnt; - - if (cnt > len) - bitset_set (sbcset, ch); - } - } - /* Check whether the array has enough space. */ - if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nequiv_classes is 0. */ - int new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1; - /* Use realloc since the array is NULL if *alloc == 0. */ - int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, - int32_t, - new_equiv_class_alloc); - if (BE (new_equiv_classes == NULL, 0)) - return REG_ESPACE; - mbcset->equiv_classes = new_equiv_classes; - *equiv_class_alloc = new_equiv_class_alloc; - } - mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1; - } - else -#endif /* _LIBC */ - { - if (BE (strlen ((const char *) name) != 1, 0)) - return REG_ECOLLATE; - bitset_set (sbcset, *name); - } - return REG_NOERROR; -} - - /* Helper function for parse_bracket_exp. - Build the character class which is represented by NAME. - The result are written to MBCSET and SBCSET. - CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, - is a pointer argument sinse we may update it. */ - -static reg_errcode_t -#ifdef RE_ENABLE_I18N -build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, - re_charset_t *mbcset, int *char_class_alloc, - const unsigned char *class_name, reg_syntax_t syntax) -#else /* not RE_ENABLE_I18N */ -build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, - const unsigned char *class_name, reg_syntax_t syntax) -#endif /* not RE_ENABLE_I18N */ -{ - int i; - const char *name = (const char *) class_name; - - /* In case of REG_ICASE "upper" and "lower" match the both of - upper and lower cases. */ - if ((syntax & RE_ICASE) - && (strcmp (name, "upper") == 0 || strcmp (name, "lower") == 0)) - name = "alpha"; - -#ifdef RE_ENABLE_I18N - /* Check the space of the arrays. */ - if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) - { - /* Not enough, realloc it. */ - /* +1 in case of mbcset->nchar_classes is 0. */ - int new_char_class_alloc = 2 * mbcset->nchar_classes + 1; - /* Use realloc since array is NULL if *alloc == 0. */ - wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, - new_char_class_alloc); - if (BE (new_char_classes == NULL, 0)) - return REG_ESPACE; - mbcset->char_classes = new_char_classes; - *char_class_alloc = new_char_class_alloc; - } - mbcset->char_classes[mbcset->nchar_classes++] = __wctype (name); -#endif /* RE_ENABLE_I18N */ - -#define BUILD_CHARCLASS_LOOP(ctype_func) \ - do { \ - if (BE (trans != NULL, 0)) \ - { \ - for (i = 0; i < SBC_MAX; ++i) \ - if (ctype_func (i)) \ - bitset_set (sbcset, trans[i]); \ - } \ - else \ - { \ - for (i = 0; i < SBC_MAX; ++i) \ - if (ctype_func (i)) \ - bitset_set (sbcset, i); \ - } \ - } while (0) - - if (strcmp (name, "alnum") == 0) - BUILD_CHARCLASS_LOOP (isalnum); - else if (strcmp (name, "cntrl") == 0) - BUILD_CHARCLASS_LOOP (iscntrl); - else if (strcmp (name, "lower") == 0) - BUILD_CHARCLASS_LOOP (islower); - else if (strcmp (name, "space") == 0) - BUILD_CHARCLASS_LOOP (isspace); - else if (strcmp (name, "alpha") == 0) - BUILD_CHARCLASS_LOOP (isalpha); - else if (strcmp (name, "digit") == 0) - BUILD_CHARCLASS_LOOP (isdigit); - else if (strcmp (name, "print") == 0) - BUILD_CHARCLASS_LOOP (isprint); - else if (strcmp (name, "upper") == 0) - BUILD_CHARCLASS_LOOP (isupper); - else if (strcmp (name, "blank") == 0) - BUILD_CHARCLASS_LOOP (isblank); - else if (strcmp (name, "graph") == 0) - BUILD_CHARCLASS_LOOP (isgraph); - else if (strcmp (name, "punct") == 0) - BUILD_CHARCLASS_LOOP (ispunct); - else if (strcmp (name, "xdigit") == 0) - BUILD_CHARCLASS_LOOP (isxdigit); - else - return REG_ECTYPE; - - return REG_NOERROR; -} - -static bin_tree_t * -build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, - const unsigned char *class_name, - const unsigned char *extra, int non_match, - reg_errcode_t *err) -{ - re_bitset_ptr_t sbcset; -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; - int alloc = 0; -#endif /* not RE_ENABLE_I18N */ - reg_errcode_t ret; - re_token_t br_token; - bin_tree_t *tree; - - sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); -#ifdef RE_ENABLE_I18N - mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); -#endif /* RE_ENABLE_I18N */ - -#ifdef RE_ENABLE_I18N - if (BE (sbcset == NULL || mbcset == NULL, 0)) -#else /* not RE_ENABLE_I18N */ - if (BE (sbcset == NULL, 0)) -#endif /* not RE_ENABLE_I18N */ - { - *err = REG_ESPACE; - return NULL; - } - - if (non_match) - { -#ifdef RE_ENABLE_I18N - /* - if (syntax & RE_HAT_LISTS_NOT_NEWLINE) - bitset_set(cset->sbcset, '\0'); - */ - mbcset->non_match = 1; -#endif /* not RE_ENABLE_I18N */ - } - - /* We don't care the syntax in this case. */ - ret = build_charclass (trans, sbcset, -#ifdef RE_ENABLE_I18N - mbcset, &alloc, -#endif /* RE_ENABLE_I18N */ - class_name, 0); - - if (BE (ret != REG_NOERROR, 0)) - { - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - *err = ret; - return NULL; - } - /* \w match '_' also. */ - for (; *extra; extra++) - bitset_set (sbcset, *extra); - - /* If it is non-matching list. */ - if (non_match) - bitset_not (sbcset); - -#ifdef RE_ENABLE_I18N - /* Ensure only single byte characters are set. */ - if (dfa->mb_cur_max > 1) - bitset_mask (sbcset, dfa->sb_char); -#endif - - /* Build a tree for simple bracket. */ - br_token.type = SIMPLE_BRACKET; - br_token.opr.sbcset = sbcset; - tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (tree == NULL, 0)) - goto build_word_op_espace; - -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - bin_tree_t *mbc_tree; - /* Build a tree for complex bracket. */ - br_token.type = COMPLEX_BRACKET; - br_token.opr.mbcset = mbcset; - dfa->has_mb_node = 1; - mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); - if (BE (mbc_tree == NULL, 0)) - goto build_word_op_espace; - /* Then join them by ALT node. */ - tree = create_tree (dfa, tree, mbc_tree, OP_ALT); - if (BE (mbc_tree != NULL, 1)) - return tree; - } - else - { - free_charset (mbcset); - return tree; - } -#else /* not RE_ENABLE_I18N */ - return tree; -#endif /* not RE_ENABLE_I18N */ - - build_word_op_espace: - re_free (sbcset); -#ifdef RE_ENABLE_I18N - free_charset (mbcset); -#endif /* RE_ENABLE_I18N */ - *err = REG_ESPACE; - return NULL; -} - -/* This is intended for the expressions like "a{1,3}". - Fetch a number from `input', and return the number. - Return -1, if the number field is empty like "{,1}". - Return -2, If an error is occured. */ - -static int -fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) -{ - int num = -1; - unsigned char c; - while (1) - { - fetch_token (token, input, syntax); - c = token->opr.c; - if (BE (token->type == END_OF_RE, 0)) - return -2; - if (token->type == OP_CLOSE_DUP_NUM || c == ',') - break; - num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) - ? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0')); - num = (num > RE_DUP_MAX) ? -2 : num; - } - return num; -} - -#ifdef RE_ENABLE_I18N -static void -free_charset (re_charset_t *cset) -{ - re_free (cset->mbchars); -# ifdef _LIBC - re_free (cset->coll_syms); - re_free (cset->equiv_classes); - re_free (cset->range_starts); - re_free (cset->range_ends); -# endif - re_free (cset->char_classes); - re_free (cset); -} -#endif /* RE_ENABLE_I18N */ - -/* Functions for binary tree operation. */ - -/* Create a tree node. */ - -static bin_tree_t * -create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, - re_token_type_t type) -{ - re_token_t t; - t.type = type; - return create_token_tree (dfa, left, right, &t); -} - -static bin_tree_t * -create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, - const re_token_t *token) -{ - bin_tree_t *tree; - if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) - { - bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); - - if (storage == NULL) - return NULL; - storage->next = dfa->str_tree_storage; - dfa->str_tree_storage = storage; - dfa->str_tree_storage_idx = 0; - } - tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++]; - - tree->parent = NULL; - tree->left = left; - tree->right = right; - tree->token = *token; - tree->token.duplicated = 0; - tree->token.opt_subexp = 0; - tree->first = NULL; - tree->next = NULL; - tree->node_idx = -1; - - if (left != NULL) - left->parent = tree; - if (right != NULL) - right->parent = tree; - return tree; -} - -/* Mark the tree SRC as an optional subexpression. - To be called from preorder or postorder. */ - -static reg_errcode_t -mark_opt_subexp (void *extra, bin_tree_t *node) -{ - int idx = (int) (long) extra; - if (node->token.type == SUBEXP && node->token.opr.idx == idx) - node->token.opt_subexp = 1; - - return REG_NOERROR; -} - -/* Free the allocated memory inside NODE. */ - -static void -free_token (re_token_t *node) -{ -#ifdef RE_ENABLE_I18N - if (node->type == COMPLEX_BRACKET && node->duplicated == 0) - free_charset (node->opr.mbcset); - else -#endif /* RE_ENABLE_I18N */ - if (node->type == SIMPLE_BRACKET && node->duplicated == 0) - re_free (node->opr.sbcset); -} - -/* Worker function for tree walking. Free the allocated memory inside NODE - and its children. */ - -static reg_errcode_t -free_tree (void *extra, bin_tree_t *node) -{ - free_token (&node->token); - return REG_NOERROR; -} - - -/* Duplicate the node SRC, and return new node. This is a preorder - visit similar to the one implemented by the generic visitor, but - we need more infrastructure to maintain two parallel trees --- so, - it's easier to duplicate. */ - -static bin_tree_t * -duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa) -{ - const bin_tree_t *node; - bin_tree_t *dup_root; - bin_tree_t **p_new = &dup_root, *dup_node = root->parent; - - for (node = root; ; ) - { - /* Create a new tree and link it back to the current parent. */ - *p_new = create_token_tree (dfa, NULL, NULL, &node->token); - if (*p_new == NULL) - return NULL; - (*p_new)->parent = dup_node; - (*p_new)->token.duplicated = 1; - dup_node = *p_new; - - /* Go to the left node, or up and to the right. */ - if (node->left) - { - node = node->left; - p_new = &dup_node->left; - } - else - { - const bin_tree_t *prev = NULL; - while (node->right == prev || node->right == NULL) - { - prev = node; - node = node->parent; - dup_node = dup_node->parent; - if (!node) - return dup_root; - } - node = node->right; - p_new = &dup_node->right; - } - } -} diff -Nru eresi-0.8a25/libregex/.svn/text-base/regex.c.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regex.c.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regex.c.svn-base 2008-04-06 23:15:47.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regex.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* Make sure noone compiles this code with a C++ compiler. */ -#ifdef __cplusplus -# error "This is C code, use a C compiler" -#endif - -#ifdef _LIBC -/* We have to keep the namespace clean. */ -# define regfree(preg) __regfree (preg) -# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) -# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) -# define regerror(errcode, preg, errbuf, errbuf_size) \ - __regerror(errcode, preg, errbuf, errbuf_size) -# define re_set_registers(bu, re, nu, st, en) \ - __re_set_registers (bu, re, nu, st, en) -# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ - __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) -# define re_match(bufp, string, size, pos, regs) \ - __re_match (bufp, string, size, pos, regs) -# define re_search(bufp, string, size, startpos, range, regs) \ - __re_search (bufp, string, size, startpos, range, regs) -# define re_compile_pattern(pattern, length, bufp) \ - __re_compile_pattern (pattern, length, bufp) -# define re_set_syntax(syntax) __re_set_syntax (syntax) -# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ - __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) -# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) - -# include "../locale/localeinfo.h" -#endif - -/* On some systems, limits.h sets RE_DUP_MAX to a lower value than - GNU regex allows. Include it before , which correctly - #undefs RE_DUP_MAX and sets it to the right value. */ -#include - -#include -#include "regex_internal.h" - -#include "regex_internal.c" -#include "regcomp.c" -#include "regexec.c" - -/* Binary backward compatibility. */ -#if _LIBC -# include -# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) -link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") -int re_max_failures = 2000; -# endif -#endif diff -Nru eresi-0.8a25/libregex/.svn/text-base/regexec.c.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regexec.c.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regexec.c.svn-base 2008-04-06 23:15:47.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regexec.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,4334 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -typedef u_char bool; - -#define true 1 -#define false 0 - -static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, - int n) internal_function; -static void match_ctx_clean (re_match_context_t *mctx) internal_function; -static void match_ctx_free (re_match_context_t *cache) internal_function; -static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node, - int str_idx, int from, int to) - internal_function; -static int search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx) - internal_function; -static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node, - int str_idx) internal_function; -static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, - int node, int str_idx) - internal_function; -static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, - re_dfastate_t **limited_sts, int last_node, - int last_str_idx) - internal_function; -static reg_errcode_t re_search_internal (const regex_t *preg, - const char *string, int length, - int start, int range, int stop, - size_t nmatch, regmatch_t pmatch[], - int eflags) internal_function; -static int re_search_2_stub (struct re_pattern_buffer *bufp, - const char *string1, int length1, - const char *string2, int length2, - int start, int range, struct re_registers *regs, - int stop, int ret_len) internal_function; -static int re_search_stub (struct re_pattern_buffer *bufp, - const char *string, int length, int start, - int range, int stop, struct re_registers *regs, - int ret_len) internal_function; -static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, - int nregs, int regs_allocated) internal_function; -static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) - internal_function; -static int check_matching (re_match_context_t *mctx, int fl_longest_match, - int *p_match_first) internal_function; -static int check_halt_state_context (const re_match_context_t *mctx, - const re_dfastate_t *state, int idx) - internal_function; -static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, - regmatch_t *prev_idx_match, int cur_node, - int cur_idx, int nmatch) internal_function; -static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, - int str_idx, int dest_node, int nregs, - regmatch_t *regs, - re_node_set *eps_via_nodes) - internal_function; -static reg_errcode_t set_regs (const regex_t *preg, - const re_match_context_t *mctx, - size_t nmatch, regmatch_t *pmatch, - int fl_backtrack) internal_function; -static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) - internal_function; - -#ifdef RE_ENABLE_I18N -static int sift_states_iter_mb (const re_match_context_t *mctx, - re_sift_context_t *sctx, - int node_idx, int str_idx, int max_str_idx) - internal_function; -#endif /* RE_ENABLE_I18N */ -static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, - re_sift_context_t *sctx) - internal_function; -static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, - re_sift_context_t *sctx, int str_idx, - re_node_set *cur_dest) - internal_function; -static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, - re_sift_context_t *sctx, - int str_idx, - re_node_set *dest_nodes) - internal_function; -static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, - re_node_set *dest_nodes, - const re_node_set *candidates) - internal_function; -static int check_dst_limits (const re_match_context_t *mctx, - re_node_set *limits, - int dst_node, int dst_idx, int src_node, - int src_idx) internal_function; -static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, - int boundaries, int subexp_idx, - int from_node, int bkref_idx) - internal_function; -static int check_dst_limits_calc_pos (const re_match_context_t *mctx, - int limit, int subexp_idx, - int node, int str_idx, - int bkref_idx) internal_function; -static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, - re_node_set *dest_nodes, - const re_node_set *candidates, - re_node_set *limits, - struct re_backref_cache_entry *bkref_ents, - int str_idx) internal_function; -static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, - re_sift_context_t *sctx, - int str_idx, const re_node_set *candidates) - internal_function; -static reg_errcode_t merge_state_array (const re_dfa_t *dfa, - re_dfastate_t **dst, - re_dfastate_t **src, int num) - internal_function; -static re_dfastate_t *find_recover_state (reg_errcode_t *err, - re_match_context_t *mctx) internal_function; -static re_dfastate_t *transit_state (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *state) internal_function; -static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *next_state) - internal_function; -static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, - re_node_set *cur_nodes, - int str_idx) internal_function; -#if 0 -static re_dfastate_t *transit_state_sb (reg_errcode_t *err, - re_match_context_t *mctx, - re_dfastate_t *pstate) - internal_function; -#endif -#ifdef RE_ENABLE_I18N -static reg_errcode_t transit_state_mb (re_match_context_t *mctx, - re_dfastate_t *pstate) - internal_function; -#endif /* RE_ENABLE_I18N */ -static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, - const re_node_set *nodes) - internal_function; -static reg_errcode_t get_subexp (re_match_context_t *mctx, - int bkref_node, int bkref_str_idx) - internal_function; -static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, - const re_sub_match_top_t *sub_top, - re_sub_match_last_t *sub_last, - int bkref_node, int bkref_str) - internal_function; -static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, - int subexp_idx, int type) internal_function; -static reg_errcode_t check_arrival (re_match_context_t *mctx, - state_array_t *path, int top_node, - int top_str, int last_node, int last_str, - int type) internal_function; -static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, - int str_idx, - re_node_set *cur_nodes, - re_node_set *next_nodes) - internal_function; -static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, - re_node_set *cur_nodes, - int ex_subexp, int type) - internal_function; -static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, - re_node_set *dst_nodes, - int target, int ex_subexp, - int type) internal_function; -static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, - re_node_set *cur_nodes, int cur_str, - int subexp_num, int type) - internal_function; -static int build_trtable (const re_dfa_t *dfa, - re_dfastate_t *state) internal_function; -#ifdef RE_ENABLE_I18N -static int check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, - const re_string_t *input, int idx) - internal_function; -# ifdef _LIBC -static unsigned int find_collation_sequence_value (const unsigned char *mbs, - size_t name_len) - internal_function; -# endif /* _LIBC */ -#endif /* RE_ENABLE_I18N */ -static int group_nodes_into_DFAstates (const re_dfa_t *dfa, - const re_dfastate_t *state, - re_node_set *states_node, - bitset_t *states_ch) internal_function; -static int check_node_accept (const re_match_context_t *mctx, - const re_token_t *node, int idx) - internal_function; -static reg_errcode_t extend_buffers (re_match_context_t *mctx) - internal_function; - -/* Entry point for POSIX code. */ - -/* regexec searches for a given pattern, specified by PREG, in the - string STRING. - - If NMATCH is zero or REG_NOSUB was set in the cflags argument to - `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at - least NMATCH elements, and we set them to the offsets of the - corresponding matched substrings. - - EFLAGS specifies `execution flags' which affect matching: if - REG_NOTBOL is set, then ^ does not match at the beginning of the - string; if REG_NOTEOL is set, then $ does not match at the end. - - We return 0 if we find a match and REG_NOMATCH if not. */ - -int -regexec (preg, string, nmatch, pmatch, eflags) - const regex_t *__restrict preg; - const char *__restrict string; - size_t nmatch; - regmatch_t pmatch[]; - int eflags; -{ - reg_errcode_t err; - int start, length; - re_dfa_t *dfa = (re_dfa_t *) preg->buffer; - - if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) - return REG_BADPAT; - - if (eflags & REG_STARTEND) - { - start = pmatch[0].rm_so; - length = pmatch[0].rm_eo; - } - else - { - start = 0; - length = strlen (string); - } - - __libc_lock_lock (dfa->lock); - if (preg->no_sub) - err = re_search_internal (preg, string, length, start, length - start, - length, 0, NULL, eflags); - else - err = re_search_internal (preg, string, length, start, length - start, - length, nmatch, pmatch, eflags); - __libc_lock_unlock (dfa->lock); - return err != REG_NOERROR; -} - -#ifdef _LIBC -# include -versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); - -# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) -__typeof__ (__regexec) __compat_regexec; - -int -attribute_compat_text_section -__compat_regexec (const regex_t *__restrict preg, - const char *__restrict string, size_t nmatch, - regmatch_t pmatch[], int eflags) -{ - return regexec (preg, string, nmatch, pmatch, - eflags & (REG_NOTBOL | REG_NOTEOL)); -} -compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0); -# endif -#endif - -/* Entry points for GNU code. */ - -/* re_match, re_search, re_match_2, re_search_2 - - The former two functions operate on STRING with length LENGTH, - while the later two operate on concatenation of STRING1 and STRING2 - with lengths LENGTH1 and LENGTH2, respectively. - - re_match() matches the compiled pattern in BUFP against the string, - starting at index START. - - re_search() first tries matching at index START, then it tries to match - starting from index START + 1, and so on. The last start position tried - is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same - way as re_match().) - - The parameter STOP of re_{match,search}_2 specifies that no match exceeding - the first STOP characters of the concatenation of the strings should be - concerned. - - If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match - and all groups is stroed in REGS. (For the "_2" variants, the offsets are - computed relative to the concatenation, not relative to the individual - strings.) - - On success, re_match* functions return the length of the match, re_search* - return the position of the start of the match. Return value -1 means no - match was found and -2 indicates an internal error. */ - -int -re_match (bufp, string, length, start, regs) - struct re_pattern_buffer *bufp; - const char *string; - int length, start; - struct re_registers *regs; -{ - return re_search_stub (bufp, string, length, start, 0, length, regs, 1); -} -#ifdef _LIBC -weak_alias (__re_match, re_match) -#endif - -int -re_search (bufp, string, length, start, range, regs) - struct re_pattern_buffer *bufp; - const char *string; - int length, start, range; - struct re_registers *regs; -{ - return re_search_stub (bufp, string, length, start, range, length, regs, 0); -} -#ifdef _LIBC -weak_alias (__re_search, re_search) -#endif - -int -re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int length1, length2, start, stop; - struct re_registers *regs; -{ - return re_search_2_stub (bufp, string1, length1, string2, length2, - start, 0, regs, stop, 1); -} -#ifdef _LIBC -weak_alias (__re_match_2, re_match_2) -#endif - -int -re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int length1, length2, start, range, stop; - struct re_registers *regs; -{ - return re_search_2_stub (bufp, string1, length1, string2, length2, - start, range, regs, stop, 0); -} -#ifdef _LIBC -weak_alias (__re_search_2, re_search_2) -#endif - -static int -re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, - stop, ret_len) - struct re_pattern_buffer *bufp; - const char *string1, *string2; - int length1, length2, start, range, stop, ret_len; - struct re_registers *regs; -{ - const char *str; - int rval; - int len = length1 + length2; - int free_str = 0; - - if (BE (length1 < 0 || length2 < 0 || stop < 0, 0)) - return -2; - - /* Concatenate the strings. */ - if (length2 > 0) - if (length1 > 0) - { - char *s = re_malloc (char, len); - - if (BE (s == NULL, 0)) - return -2; -#ifdef _LIBC - memcpy (__mempcpy (s, string1, length1), string2, length2); -#else - memcpy (s, string1, length1); - memcpy (s + length1, string2, length2); -#endif - str = s; - free_str = 1; - } - else - str = string2; - else - str = string1; - - rval = re_search_stub (bufp, str, len, start, range, stop, regs, - ret_len); - if (free_str) - re_free ((char *) str); - return rval; -} - -/* The parameters have the same meaning as those of re_search. - Additional parameters: - If RET_LEN is nonzero the length of the match is returned (re_match style); - otherwise the position of the match is returned. */ - -static int -re_search_stub (bufp, string, length, start, range, stop, regs, ret_len) - struct re_pattern_buffer *bufp; - const char *string; - int length, start, range, stop, ret_len; - struct re_registers *regs; -{ - reg_errcode_t result; - regmatch_t *pmatch; - int nregs, rval; - int eflags = 0; - re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; - - /* Check for out-of-range. */ - if (BE (start < 0 || start > length, 0)) - return -1; - if (BE (start + range > length, 0)) - range = length - start; - else if (BE (start + range < 0, 0)) - range = -start; - - __libc_lock_lock (dfa->lock); - - eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; - eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; - - /* Compile fastmap if we haven't yet. */ - if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate) - re_compile_fastmap (bufp); - - if (BE (bufp->no_sub, 0)) - regs = NULL; - - /* We need at least 1 register. */ - if (regs == NULL) - nregs = 1; - else if (BE (bufp->regs_allocated == REGS_FIXED && - regs->num_regs < bufp->re_nsub + 1, 0)) - { - nregs = regs->num_regs; - if (BE (nregs < 1, 0)) - { - /* Nothing can be copied to regs. */ - regs = NULL; - nregs = 1; - } - } - else - nregs = bufp->re_nsub + 1; - pmatch = re_malloc (regmatch_t, nregs); - if (BE (pmatch == NULL, 0)) - { - rval = -2; - goto out; - } - - result = re_search_internal (bufp, string, length, start, range, stop, - nregs, pmatch, eflags); - - rval = 0; - - /* I hope we needn't fill ther regs with -1's when no match was found. */ - if (result != REG_NOERROR) - rval = -1; - else if (regs != NULL) - { - /* If caller wants register contents data back, copy them. */ - bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, - bufp->regs_allocated); - if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) - rval = -2; - } - - if (BE (rval == 0, 1)) - { - if (ret_len) - { - assert (pmatch[0].rm_so == start); - rval = pmatch[0].rm_eo - start; - } - else - rval = pmatch[0].rm_so; - } - re_free (pmatch); - out: - __libc_lock_unlock (dfa->lock); - return rval; -} - -static unsigned -re_copy_regs (regs, pmatch, nregs, regs_allocated) - struct re_registers *regs; - regmatch_t *pmatch; - int nregs, regs_allocated; -{ - int rval = REGS_REALLOCATE; - int i; - int need_regs = nregs + 1; - /* We need one extra element beyond `num_regs' for the `-1' marker GNU code - uses. */ - - /* Have the register data arrays been allocated? */ - if (regs_allocated == REGS_UNALLOCATED) - { /* No. So allocate them with malloc. */ - regs->start = re_malloc (regoff_t, need_regs); - regs->end = re_malloc (regoff_t, need_regs); - if (BE (regs->start == NULL, 0) || BE (regs->end == NULL, 0)) - return REGS_UNALLOCATED; - regs->num_regs = need_regs; - } - else if (regs_allocated == REGS_REALLOCATE) - { /* Yes. If we need more elements than were already - allocated, reallocate them. If we need fewer, just - leave it alone. */ - if (BE (need_regs > regs->num_regs, 0)) - { - regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); - regoff_t *new_end = re_realloc (regs->end, regoff_t, need_regs); - if (BE (new_start == NULL, 0) || BE (new_end == NULL, 0)) - return REGS_UNALLOCATED; - regs->start = new_start; - regs->end = new_end; - regs->num_regs = need_regs; - } - } - else - { - assert (regs_allocated == REGS_FIXED); - /* This function may not be called with REGS_FIXED and nregs too big. */ - assert (regs->num_regs >= nregs); - rval = REGS_FIXED; - } - - /* Copy the regs. */ - for (i = 0; i < nregs; ++i) - { - regs->start[i] = pmatch[i].rm_so; - regs->end[i] = pmatch[i].rm_eo; - } - for ( ; i < regs->num_regs; ++i) - regs->start[i] = regs->end[i] = -1; - - return rval; -} - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use - this memory for recording register information. STARTS and ENDS - must be allocated using the malloc library routine, and must each - be at least NUM_REGS * sizeof (regoff_t) bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ - -void -re_set_registers (bufp, regs, num_regs, starts, ends) - struct re_pattern_buffer *bufp; - struct re_registers *regs; - unsigned num_regs; - regoff_t *starts, *ends; -{ - if (num_regs) - { - bufp->regs_allocated = REGS_REALLOCATE; - regs->num_regs = num_regs; - regs->start = starts; - regs->end = ends; - } - else - { - bufp->regs_allocated = REGS_UNALLOCATED; - regs->num_regs = 0; - regs->start = regs->end = (regoff_t *) 0; - } -} -#ifdef _LIBC -weak_alias (__re_set_registers, re_set_registers) -#endif - -/* Entry points compatible with 4.2 BSD regex library. We don't define - them unless specifically requested. */ - -#if defined _REGEX_RE_COMP || defined _LIBC -int -# ifdef _LIBC -weak_function -# endif -re_exec (s) - const char *s; -{ - return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); -} -#endif /* _REGEX_RE_COMP */ - -/* Internal entry point. */ - -/* Searches for a compiled pattern PREG in the string STRING, whose - length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same - mingings with regexec. START, and RANGE have the same meanings - with re_search. - Return REG_NOERROR if we find a match, and REG_NOMATCH if not, - otherwise return the error code. - Note: We assume front end functions already check ranges. - (START + RANGE >= 0 && START + RANGE <= LENGTH) */ - -static reg_errcode_t -re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch, - eflags) - const regex_t *preg; - const char *string; - int length, start, range, stop, eflags; - size_t nmatch; - regmatch_t pmatch[]; -{ - reg_errcode_t err; - const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; - int left_lim, right_lim, incr; - int fl_longest_match, match_first, match_kind, match_last = -1; - int extra_nmatch; - int sb, ch; -#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) - re_match_context_t mctx = { .dfa = dfa }; -#else - re_match_context_t mctx; -#endif - char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate - && range && !preg->can_be_null) ? preg->fastmap : NULL; - RE_TRANSLATE_TYPE t = preg->translate; - -#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) - memset (&mctx, '\0', sizeof (re_match_context_t)); - mctx.dfa = dfa; -#endif - - extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; - nmatch -= extra_nmatch; - - /* Check if the DFA haven't been compiled. */ - if (BE (preg->used == 0 || dfa->init_state == NULL - || dfa->init_state_word == NULL || dfa->init_state_nl == NULL - || dfa->init_state_begbuf == NULL, 0)) - return REG_NOMATCH; - -#ifdef DEBUG - /* We assume front-end functions already check them. */ - assert (start + range >= 0 && start + range <= length); -#endif - - /* If initial states with non-begbuf contexts have no elements, - the regex must be anchored. If preg->newline_anchor is set, - we'll never use init_state_nl, so do not check it. */ - if (dfa->init_state->nodes.nelem == 0 - && dfa->init_state_word->nodes.nelem == 0 - && (dfa->init_state_nl->nodes.nelem == 0 - || !preg->newline_anchor)) - { - if (start != 0 && start + range != 0) - return REG_NOMATCH; - start = range = 0; - } - - /* We must check the longest matching, if nmatch > 0. */ - fl_longest_match = (nmatch != 0 || dfa->nbackref); - - err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, - preg->translate, preg->syntax & RE_ICASE, dfa); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - mctx.input.stop = stop; - mctx.input.raw_stop = stop; - mctx.input.newline_anchor = preg->newline_anchor; - - err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* We will log all the DFA states through which the dfa pass, - if nmatch > 1, or this dfa has "multibyte node", which is a - back-reference or a node which can accept multibyte character or - multi character collating element. */ - if (nmatch > 1 || dfa->has_mb_node) - { - mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); - if (BE (mctx.state_log == NULL, 0)) - { - err = REG_ESPACE; - goto free_return; - } - } - else - mctx.state_log = NULL; - - match_first = start; - mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF - : CONTEXT_NEWLINE | CONTEXT_BEGBUF; - - /* Check incrementally whether of not the input string match. */ - incr = (range < 0) ? -1 : 1; - left_lim = (range < 0) ? start + range : start; - right_lim = (range < 0) ? start : start + range; - sb = dfa->mb_cur_max == 1; - match_kind = - (fastmap - ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0) - | (range >= 0 ? 2 : 0) - | (t != NULL ? 1 : 0)) - : 8); - - for (;; match_first += incr) - { - err = REG_NOMATCH; - if (match_first < left_lim || right_lim < match_first) - goto free_return; - - /* Advance as rapidly as possible through the string, until we - find a plausible place to start matching. This may be done - with varying efficiency, so there are various possibilities: - only the most common of them are specialized, in order to - save on code size. We use a switch statement for speed. */ - switch (match_kind) - { - case 8: - /* No fastmap. */ - break; - - case 7: - /* Fastmap with single-byte translation, match forward. */ - while (BE (match_first < right_lim, 1) - && !fastmap[t[(unsigned char) string[match_first]]]) - ++match_first; - goto forward_match_found_start_or_reached_end; - - case 6: - /* Fastmap without translation, match forward. */ - while (BE (match_first < right_lim, 1) - && !fastmap[(unsigned char) string[match_first]]) - ++match_first; - - forward_match_found_start_or_reached_end: - if (BE (match_first == right_lim, 0)) - { - ch = match_first >= length - ? 0 : (unsigned char) string[match_first]; - if (!fastmap[t ? t[ch] : ch]) - goto free_return; - } - break; - - case 4: - case 5: - /* Fastmap without multi-byte translation, match backwards. */ - while (match_first >= left_lim) - { - ch = match_first >= length - ? 0 : (unsigned char) string[match_first]; - if (fastmap[t ? t[ch] : ch]) - break; - --match_first; - } - if (match_first < left_lim) - goto free_return; - break; - - default: - /* In this case, we can't determine easily the current byte, - since it might be a component byte of a multibyte - character. Then we use the constructed buffer instead. */ - for (;;) - { - /* If MATCH_FIRST is out of the valid range, reconstruct the - buffers. */ - unsigned int offset = match_first - mctx.input.raw_mbs_idx; - if (BE (offset >= (unsigned int) mctx.input.valid_raw_len, 0)) - { - err = re_string_reconstruct (&mctx.input, match_first, - eflags); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - offset = match_first - mctx.input.raw_mbs_idx; - } - /* If MATCH_FIRST is out of the buffer, leave it as '\0'. - Note that MATCH_FIRST must not be smaller than 0. */ - ch = (match_first >= length - ? 0 : re_string_byte_at (&mctx.input, offset)); - if (fastmap[ch]) - break; - match_first += incr; - if (match_first < left_lim || match_first > right_lim) - { - err = REG_NOMATCH; - goto free_return; - } - } - break; - } - - /* Reconstruct the buffers so that the matcher can assume that - the matching starts from the beginning of the buffer. */ - err = re_string_reconstruct (&mctx.input, match_first, eflags); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - -#ifdef RE_ENABLE_I18N - /* Don't consider this char as a possible match start if it part, - yet isn't the head, of a multibyte character. */ - if (!sb && !re_string_first_byte (&mctx.input, 0)) - continue; -#endif - - /* It seems to be appropriate one, then use the matcher. */ - /* We assume that the matching starts from 0. */ - mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; - match_last = check_matching (&mctx, fl_longest_match, - range >= 0 ? &match_first : NULL); - if (match_last != -1) - { - if (BE (match_last == -2, 0)) - { - err = REG_ESPACE; - goto free_return; - } - else - { - mctx.match_last = match_last; - if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) - { - re_dfastate_t *pstate = mctx.state_log[match_last]; - mctx.last_node = check_halt_state_context (&mctx, pstate, - match_last); - } - if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) - || dfa->nbackref) - { - err = prune_impossible_nodes (&mctx); - if (err == REG_NOERROR) - break; - if (BE (err != REG_NOMATCH, 0)) - goto free_return; - match_last = -1; - } - else - break; /* We found a match. */ - } - } - - match_ctx_clean (&mctx); - } - -#ifdef DEBUG - assert (match_last != -1); - assert (err == REG_NOERROR); -#endif - - /* Set pmatch[] if we need. */ - if (nmatch > 0) - { - int reg_idx; - - /* Initialize registers. */ - for (reg_idx = 1; reg_idx < nmatch; ++reg_idx) - pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1; - - /* Set the points where matching start/end. */ - pmatch[0].rm_so = 0; - pmatch[0].rm_eo = mctx.match_last; - - if (!preg->no_sub && nmatch > 1) - { - err = set_regs (preg, &mctx, nmatch, pmatch, - dfa->has_plural_match && dfa->nbackref > 0); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - - /* At last, add the offset to the each registers, since we slided - the buffers so that we could assume that the matching starts - from 0. */ - for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) - if (pmatch[reg_idx].rm_so != -1) - { -#ifdef RE_ENABLE_I18N - if (BE (mctx.input.offsets_needed != 0, 0)) - { - pmatch[reg_idx].rm_so = - (pmatch[reg_idx].rm_so == mctx.input.valid_len - ? mctx.input.valid_raw_len - : mctx.input.offsets[pmatch[reg_idx].rm_so]); - pmatch[reg_idx].rm_eo = - (pmatch[reg_idx].rm_eo == mctx.input.valid_len - ? mctx.input.valid_raw_len - : mctx.input.offsets[pmatch[reg_idx].rm_eo]); - } -#else - assert (mctx.input.offsets_needed == 0); -#endif - pmatch[reg_idx].rm_so += match_first; - pmatch[reg_idx].rm_eo += match_first; - } - for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx) - { - pmatch[nmatch + reg_idx].rm_so = -1; - pmatch[nmatch + reg_idx].rm_eo = -1; - } - - if (dfa->subexp_map) - for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++) - if (dfa->subexp_map[reg_idx] != reg_idx) - { - pmatch[reg_idx + 1].rm_so - = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so; - pmatch[reg_idx + 1].rm_eo - = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo; - } - } - - free_return: - re_free (mctx.state_log); - if (dfa->nbackref) - match_ctx_free (&mctx); - re_string_destruct (&mctx.input); - return err; -} - -static reg_errcode_t -prune_impossible_nodes (mctx) - re_match_context_t *mctx; -{ - const re_dfa_t *const dfa = mctx->dfa; - int halt_node, match_last; - reg_errcode_t ret; - re_dfastate_t **sifted_states; - re_dfastate_t **lim_states = NULL; - re_sift_context_t sctx; -#ifdef DEBUG - assert (mctx->state_log != NULL); -#endif - match_last = mctx->match_last; - halt_node = mctx->last_node; - sifted_states = re_malloc (re_dfastate_t *, match_last + 1); - if (BE (sifted_states == NULL, 0)) - { - ret = REG_ESPACE; - goto free_return; - } - if (dfa->nbackref) - { - lim_states = re_malloc (re_dfastate_t *, match_last + 1); - if (BE (lim_states == NULL, 0)) - { - ret = REG_ESPACE; - goto free_return; - } - while (1) - { - memset (lim_states, '\0', - sizeof (re_dfastate_t *) * (match_last + 1)); - sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, - match_last); - ret = sift_states_backward (mctx, &sctx); - re_node_set_free (&sctx.limits); - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - if (sifted_states[0] != NULL || lim_states[0] != NULL) - break; - do - { - --match_last; - if (match_last < 0) - { - ret = REG_NOMATCH; - goto free_return; - } - } while (mctx->state_log[match_last] == NULL - || !mctx->state_log[match_last]->halt); - halt_node = check_halt_state_context (mctx, - mctx->state_log[match_last], - match_last); - } - ret = merge_state_array (dfa, sifted_states, lim_states, - match_last + 1); - re_free (lim_states); - lim_states = NULL; - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - } - else - { - sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); - ret = sift_states_backward (mctx, &sctx); - re_node_set_free (&sctx.limits); - if (BE (ret != REG_NOERROR, 0)) - goto free_return; - } - re_free (mctx->state_log); - mctx->state_log = sifted_states; - sifted_states = NULL; - mctx->last_node = halt_node; - mctx->match_last = match_last; - ret = REG_NOERROR; - free_return: - re_free (sifted_states); - re_free (lim_states); - return ret; -} - -/* Acquire an initial state and return it. - We must select appropriate initial state depending on the context, - since initial states may have constraints like "\<", "^", etc.. */ - -static inline re_dfastate_t * -__attribute ((always_inline)) internal_function -acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, - int idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - if (dfa->init_state->has_constraint) - { - unsigned int context; - context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); - if (IS_WORD_CONTEXT (context)) - return dfa->init_state_word; - else if (IS_ORDINARY_CONTEXT (context)) - return dfa->init_state; - else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) - return dfa->init_state_begbuf; - else if (IS_NEWLINE_CONTEXT (context)) - return dfa->init_state_nl; - else if (IS_BEGBUF_CONTEXT (context)) - { - /* It is relatively rare case, then calculate on demand. */ - return re_acquire_state_context (err, dfa, - dfa->init_state->entrance_nodes, - context); - } - else - /* Must not happen? */ - return dfa->init_state; - } - else - return dfa->init_state; -} - -/* Check whether the regular expression match input string INPUT or not, - and return the index where the matching end, return -1 if not match, - or return -2 in case of an error. - FL_LONGEST_MATCH means we want the POSIX longest matching. - If P_MATCH_FIRST is not NULL, and the match fails, it is set to the - next place where we may want to try matching. - Note that the matcher assume that the maching starts from the current - index of the buffer. */ - -static int -internal_function -check_matching (re_match_context_t *mctx, int fl_longest_match, - int *p_match_first) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - int match = 0; - int match_last = -1; - int cur_str_idx = re_string_cur_idx (&mctx->input); - re_dfastate_t *cur_state; - int at_init_state = p_match_first != NULL; - int next_start_idx = cur_str_idx; - - err = REG_NOERROR; - cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); - /* An initial state must not be NULL (invalid). */ - if (BE (cur_state == NULL, 0)) - { - assert (err == REG_ESPACE); - return -2; - } - - if (mctx->state_log != NULL) - { - mctx->state_log[cur_str_idx] = cur_state; - - /* Check OP_OPEN_SUBEXP in the initial state in case that we use them - later. E.g. Processing back references. */ - if (BE (dfa->nbackref, 0)) - { - at_init_state = 0; - err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (cur_state->has_backref) - { - err = transit_state_bkref (mctx, &cur_state->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - } - - /* If the RE accepts NULL string. */ - if (BE (cur_state->halt, 0)) - { - if (!cur_state->has_constraint - || check_halt_state_context (mctx, cur_state, cur_str_idx)) - { - if (!fl_longest_match) - return cur_str_idx; - else - { - match_last = cur_str_idx; - match = 1; - } - } - } - - while (!re_string_eoi (&mctx->input)) - { - re_dfastate_t *old_state = cur_state; - int next_char_idx = re_string_cur_idx (&mctx->input) + 1; - - if (BE (next_char_idx >= mctx->input.bufs_len, 0) - || (BE (next_char_idx >= mctx->input.valid_len, 0) - && mctx->input.valid_len < mctx->input.len)) - { - err = extend_buffers (mctx); - if (BE (err != REG_NOERROR, 0)) - { - assert (err == REG_ESPACE); - return -2; - } - } - - cur_state = transit_state (&err, mctx, cur_state); - if (mctx->state_log != NULL) - cur_state = merge_state_with_log (&err, mctx, cur_state); - - if (cur_state == NULL) - { - /* Reached the invalid state or an error. Try to recover a valid - state using the state log, if available and if we have not - already found a valid (even if not the longest) match. */ - if (BE (err != REG_NOERROR, 0)) - return -2; - - if (mctx->state_log == NULL - || (match && !fl_longest_match) - || (cur_state = find_recover_state (&err, mctx)) == NULL) - break; - } - - if (BE (at_init_state, 0)) - { - if (old_state == cur_state) - next_start_idx = next_char_idx; - else - at_init_state = 0; - } - - if (cur_state->halt) - { - /* Reached a halt state. - Check the halt state can satisfy the current context. */ - if (!cur_state->has_constraint - || check_halt_state_context (mctx, cur_state, - re_string_cur_idx (&mctx->input))) - { - /* We found an appropriate halt state. */ - match_last = re_string_cur_idx (&mctx->input); - match = 1; - - /* We found a match, do not modify match_first below. */ - p_match_first = NULL; - if (!fl_longest_match) - break; - } - } - } - - if (p_match_first) - *p_match_first += next_start_idx; - - return match_last; -} - -/* Check NODE match the current context. */ - -static int -internal_function -check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context) -{ - re_token_type_t type = dfa->nodes[node].type; - unsigned int constraint = dfa->nodes[node].constraint; - if (type != END_OF_RE) - return 0; - if (!constraint) - return 1; - if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context)) - return 0; - return 1; -} - -/* Check the halt state STATE match the current context. - Return 0 if not match, if the node, STATE has, is a halt node and - match the context, return the node. */ - -static int -internal_function -check_halt_state_context (const re_match_context_t *mctx, - const re_dfastate_t *state, int idx) -{ - int i; - unsigned int context; -#ifdef DEBUG - assert (state->halt); -#endif - context = re_string_context_at (&mctx->input, idx, mctx->eflags); - for (i = 0; i < state->nodes.nelem; ++i) - if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) - return state->nodes.elems[i]; - return 0; -} - -/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA - corresponding to the DFA). - Return the destination node, and update EPS_VIA_NODES, return -1 in case - of errors. */ - -static int -internal_function -proceed_next_node (const re_match_context_t *mctx, int nregs, regmatch_t *regs, - int *pidx, int node, re_node_set *eps_via_nodes, - struct re_fail_stack_t *fs) -{ - const re_dfa_t *const dfa = mctx->dfa; - int i, err; - if (IS_EPSILON_NODE (dfa->nodes[node].type)) - { - re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; - re_node_set *edests = &dfa->edests[node]; - int dest_node; - err = re_node_set_insert (eps_via_nodes, node); - if (BE (err < 0, 0)) - return -2; - /* Pick up a valid destination, or return -1 if none is found. */ - for (dest_node = -1, i = 0; i < edests->nelem; ++i) - { - int candidate = edests->elems[i]; - if (!re_node_set_contains (cur_nodes, candidate)) - continue; - if (dest_node == -1) - dest_node = candidate; - - else - { - /* In order to avoid infinite loop like "(a*)*", return the second - epsilon-transition if the first was already considered. */ - if (re_node_set_contains (eps_via_nodes, dest_node)) - return candidate; - - /* Otherwise, push the second epsilon-transition on the fail stack. */ - else if (fs != NULL - && push_fail_stack (fs, *pidx, candidate, nregs, regs, - eps_via_nodes)) - return -2; - - /* We know we are going to exit. */ - break; - } - } - return dest_node; - } - else - { - int naccepted = 0; - re_token_type_t type = dfa->nodes[node].type; - -#ifdef RE_ENABLE_I18N - if (dfa->nodes[node].accept_mb) - naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); - else -#endif /* RE_ENABLE_I18N */ - if (type == OP_BACK_REF) - { - int subexp_idx = dfa->nodes[node].opr.idx + 1; - naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; - if (fs != NULL) - { - if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) - return -1; - else if (naccepted) - { - char *buf = (char *) re_string_get_buffer (&mctx->input); - if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, - naccepted) != 0) - return -1; - } - } - - if (naccepted == 0) - { - int dest_node; - err = re_node_set_insert (eps_via_nodes, node); - if (BE (err < 0, 0)) - return -2; - dest_node = dfa->edests[node].elems[0]; - if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, - dest_node)) - return dest_node; - } - } - - if (naccepted != 0 - || check_node_accept (mctx, dfa->nodes + node, *pidx)) - { - int dest_node = dfa->nexts[node]; - *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; - if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL - || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, - dest_node))) - return -1; - re_node_set_empty (eps_via_nodes); - return dest_node; - } - } - return -1; -} - -static reg_errcode_t -internal_function -push_fail_stack (struct re_fail_stack_t *fs, int str_idx, int dest_node, - int nregs, regmatch_t *regs, re_node_set *eps_via_nodes) -{ - reg_errcode_t err; - int num = fs->num++; - if (fs->num == fs->alloc) - { - struct re_fail_stack_ent_t *new_array; - new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) - * fs->alloc * 2)); - if (new_array == NULL) - return REG_ESPACE; - fs->alloc *= 2; - fs->stack = new_array; - } - fs->stack[num].idx = str_idx; - fs->stack[num].node = dest_node; - fs->stack[num].regs = re_malloc (regmatch_t, nregs); - if (fs->stack[num].regs == NULL) - return REG_ESPACE; - memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); - err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); - return err; -} - -static int -internal_function -pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs, - regmatch_t *regs, re_node_set *eps_via_nodes) -{ - int num = --fs->num; - assert (num >= 0); - *pidx = fs->stack[num].idx; - memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); - re_node_set_free (eps_via_nodes); - re_free (fs->stack[num].regs); - *eps_via_nodes = fs->stack[num].eps_via_nodes; - return fs->stack[num].node; -} - -/* Set the positions where the subexpressions are starts/ends to registers - PMATCH. - Note: We assume that pmatch[0] is already set, and - pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ - -static reg_errcode_t -internal_function -set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, - regmatch_t *pmatch, int fl_backtrack) -{ - const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; - int idx, cur_node; - re_node_set eps_via_nodes; - struct re_fail_stack_t *fs; - struct re_fail_stack_t fs_body = { 0, 2, NULL }; - regmatch_t *prev_idx_match; - int prev_idx_match_malloced = 0; - -#ifdef DEBUG - assert (nmatch > 1); - assert (mctx->state_log != NULL); -#endif - if (fl_backtrack) - { - fs = &fs_body; - fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc); - if (fs->stack == NULL) - return REG_ESPACE; - } - else - fs = NULL; - - cur_node = dfa->init_node; - re_node_set_init_empty (&eps_via_nodes); - - if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) - prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t)); - else - { - prev_idx_match = re_malloc (regmatch_t, nmatch); - if (prev_idx_match == NULL) - { - free_fail_stack_return (fs); - return REG_ESPACE; - } - prev_idx_match_malloced = 1; - } - memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); - - for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) - { - update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); - - if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) - { - int reg_idx; - if (fs) - { - for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) - if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) - break; - if (reg_idx == nmatch) - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return free_fail_stack_return (fs); - } - cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, - &eps_via_nodes); - } - else - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return REG_NOERROR; - } - } - - /* Proceed to next node. */ - cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, - &eps_via_nodes, fs); - - if (BE (cur_node < 0, 0)) - { - if (BE (cur_node == -2, 0)) - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - free_fail_stack_return (fs); - return REG_ESPACE; - } - if (fs) - cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, - &eps_via_nodes); - else - { - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return REG_NOMATCH; - } - } - } - re_node_set_free (&eps_via_nodes); - if (prev_idx_match_malloced) - re_free (prev_idx_match); - return free_fail_stack_return (fs); -} - -static reg_errcode_t -internal_function -free_fail_stack_return (struct re_fail_stack_t *fs) -{ - if (fs) - { - int fs_idx; - for (fs_idx = 0; fs_idx < fs->num; ++fs_idx) - { - re_node_set_free (&fs->stack[fs_idx].eps_via_nodes); - re_free (fs->stack[fs_idx].regs); - } - re_free (fs->stack); - } - return REG_NOERROR; -} - -static void -internal_function -update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, - regmatch_t *prev_idx_match, int cur_node, int cur_idx, int nmatch) -{ - int type = dfa->nodes[cur_node].type; - if (type == OP_OPEN_SUBEXP) - { - int reg_num = dfa->nodes[cur_node].opr.idx + 1; - - /* We are at the first node of this sub expression. */ - if (reg_num < nmatch) - { - pmatch[reg_num].rm_so = cur_idx; - pmatch[reg_num].rm_eo = -1; - } - } - else if (type == OP_CLOSE_SUBEXP) - { - int reg_num = dfa->nodes[cur_node].opr.idx + 1; - if (reg_num < nmatch) - { - /* We are at the last node of this sub expression. */ - if (pmatch[reg_num].rm_so < cur_idx) - { - pmatch[reg_num].rm_eo = cur_idx; - /* This is a non-empty match or we are not inside an optional - subexpression. Accept this right away. */ - memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); - } - else - { - if (dfa->nodes[cur_node].opt_subexp - && prev_idx_match[reg_num].rm_so != -1) - /* We transited through an empty match for an optional - subexpression, like (a?)*, and this is not the subexp's - first match. Copy back the old content of the registers - so that matches of an inner subexpression are undone as - well, like in ((a?))*. */ - memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch); - else - /* We completed a subexpression, but it may be part of - an optional one, so do not update PREV_IDX_MATCH. */ - pmatch[reg_num].rm_eo = cur_idx; - } - } - } -} - -/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0 - and sift the nodes in each states according to the following rules. - Updated state_log will be wrote to STATE_LOG. - - Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if... - 1. When STR_IDX == MATCH_LAST(the last index in the state_log): - If `a' isn't the LAST_NODE and `a' can't epsilon transit to - the LAST_NODE, we throw away the node `a'. - 2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts - string `s' and transit to `b': - i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw - away the node `a'. - ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is - thrown away, we throw away the node `a'. - 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': - i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the - node `a'. - ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, - we throw away the node `a'. */ - -#define STATE_NODE_CONTAINS(state,node) \ - ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) - -static reg_errcode_t -internal_function -sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) -{ - reg_errcode_t err; - int null_cnt = 0; - int str_idx = sctx->last_str_idx; - re_node_set cur_dest; - -#ifdef DEBUG - assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL); -#endif - - /* Build sifted state_log[str_idx]. It has the nodes which can epsilon - transit to the last_node and the last_node itself. */ - err = re_node_set_init_1 (&cur_dest, sctx->last_node); - if (BE (err != REG_NOERROR, 0)) - return err; - err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* Then check each states in the state_log. */ - while (str_idx > 0) - { - /* Update counters. */ - null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0; - if (null_cnt > mctx->max_mb_elem_len) - { - memset (sctx->sifted_states, '\0', - sizeof (re_dfastate_t *) * str_idx); - re_node_set_free (&cur_dest); - return REG_NOERROR; - } - re_node_set_empty (&cur_dest); - --str_idx; - - if (mctx->state_log[str_idx]) - { - err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - - /* Add all the nodes which satisfy the following conditions: - - It can epsilon transit to a node in CUR_DEST. - - It is in CUR_SRC. - And update state_log. */ - err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - err = REG_NOERROR; - free_return: - re_node_set_free (&cur_dest); - return err; -} - -static reg_errcode_t -internal_function -build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, - int str_idx, re_node_set *cur_dest) -{ - const re_dfa_t *const dfa = mctx->dfa; - const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; - int i; - - /* Then build the next sifted state. - We build the next sifted state on `cur_dest', and update - `sifted_states[str_idx]' with `cur_dest'. - Note: - `cur_dest' is the sifted state from `state_log[str_idx + 1]'. - `cur_src' points the node_set of the old `state_log[str_idx]' - (with the epsilon nodes pre-filtered out). */ - for (i = 0; i < cur_src->nelem; i++) - { - int prev_node = cur_src->elems[i]; - int naccepted = 0; - int ret; - -#ifdef DEBUG - re_token_type_t type = dfa->nodes[prev_node].type; - assert (!IS_EPSILON_NODE (type)); -#endif -#ifdef RE_ENABLE_I18N - /* If the node may accept `multi byte'. */ - if (dfa->nodes[prev_node].accept_mb) - naccepted = sift_states_iter_mb (mctx, sctx, prev_node, - str_idx, sctx->last_str_idx); -#endif /* RE_ENABLE_I18N */ - - /* We don't check backreferences here. - See update_cur_sifted_state(). */ - if (!naccepted - && check_node_accept (mctx, dfa->nodes + prev_node, str_idx) - && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], - dfa->nexts[prev_node])) - naccepted = 1; - - if (naccepted == 0) - continue; - - if (sctx->limits.nelem) - { - int to_idx = str_idx + naccepted; - if (check_dst_limits (mctx, &sctx->limits, - dfa->nexts[prev_node], to_idx, - prev_node, str_idx)) - continue; - } - ret = re_node_set_insert (cur_dest, prev_node); - if (BE (ret == -1, 0)) - return REG_ESPACE; - } - - return REG_NOERROR; -} - -/* Helper functions. */ - -static reg_errcode_t -internal_function -clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx) -{ - int top = mctx->state_log_top; - - if (next_state_log_idx >= mctx->input.bufs_len - || (next_state_log_idx >= mctx->input.valid_len - && mctx->input.valid_len < mctx->input.len)) - { - reg_errcode_t err; - err = extend_buffers (mctx); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (top < next_state_log_idx) - { - memset (mctx->state_log + top + 1, '\0', - sizeof (re_dfastate_t *) * (next_state_log_idx - top)); - mctx->state_log_top = next_state_log_idx; - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, - re_dfastate_t **src, int num) -{ - int st_idx; - reg_errcode_t err; - for (st_idx = 0; st_idx < num; ++st_idx) - { - if (dst[st_idx] == NULL) - dst[st_idx] = src[st_idx]; - else if (src[st_idx] != NULL) - { - re_node_set merged_set; - err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, - &src[st_idx]->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); - re_node_set_free (&merged_set); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -update_cur_sifted_state (const re_match_context_t *mctx, - re_sift_context_t *sctx, int str_idx, - re_node_set *dest_nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err = REG_NOERROR; - const re_node_set *candidates; - candidates = ((mctx->state_log[str_idx] == NULL) ? NULL - : &mctx->state_log[str_idx]->nodes); - - if (dest_nodes->nelem == 0) - sctx->sifted_states[str_idx] = NULL; - else - { - if (candidates) - { - /* At first, add the nodes which can epsilon transit to a node in - DEST_NODE. */ - err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - - /* Then, check the limitations in the current sift_context. */ - if (sctx->limits.nelem) - { - err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, - mctx->bkref_ents, str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - - sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (candidates && mctx->state_log[str_idx]->has_backref) - { - err = sift_states_bkref (mctx, sctx, str_idx, candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, - const re_node_set *candidates) -{ - reg_errcode_t err = REG_NOERROR; - int i; - - re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - - if (!state->inveclosure.alloc) - { - err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); - if (BE (err != REG_NOERROR, 0)) - return REG_ESPACE; - for (i = 0; i < dest_nodes->nelem; i++) - re_node_set_merge (&state->inveclosure, - dfa->inveclosures + dest_nodes->elems[i]); - } - return re_node_set_add_intersect (dest_nodes, candidates, - &state->inveclosure); -} - -static reg_errcode_t -internal_function -sub_epsilon_src_nodes (const re_dfa_t *dfa, int node, re_node_set *dest_nodes, - const re_node_set *candidates) -{ - int ecl_idx; - reg_errcode_t err; - re_node_set *inv_eclosure = dfa->inveclosures + node; - re_node_set except_nodes; - re_node_set_init_empty (&except_nodes); - for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) - { - int cur_node = inv_eclosure->elems[ecl_idx]; - if (cur_node == node) - continue; - if (IS_EPSILON_NODE (dfa->nodes[cur_node].type)) - { - int edst1 = dfa->edests[cur_node].elems[0]; - int edst2 = ((dfa->edests[cur_node].nelem > 1) - ? dfa->edests[cur_node].elems[1] : -1); - if ((!re_node_set_contains (inv_eclosure, edst1) - && re_node_set_contains (dest_nodes, edst1)) - || (edst2 > 0 - && !re_node_set_contains (inv_eclosure, edst2) - && re_node_set_contains (dest_nodes, edst2))) - { - err = re_node_set_add_intersect (&except_nodes, candidates, - dfa->inveclosures + cur_node); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&except_nodes); - return err; - } - } - } - } - for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) - { - int cur_node = inv_eclosure->elems[ecl_idx]; - if (!re_node_set_contains (&except_nodes, cur_node)) - { - int idx = re_node_set_contains (dest_nodes, cur_node) - 1; - re_node_set_remove_at (dest_nodes, idx); - } - } - re_node_set_free (&except_nodes); - return REG_NOERROR; -} - -static int -internal_function -check_dst_limits (const re_match_context_t *mctx, re_node_set *limits, - int dst_node, int dst_idx, int src_node, int src_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - int lim_idx, src_pos, dst_pos; - - int dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); - int src_bkref_idx = search_cur_bkref_entry (mctx, src_idx); - for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) - { - int subexp_idx; - struct re_backref_cache_entry *ent; - ent = mctx->bkref_ents + limits->elems[lim_idx]; - subexp_idx = dfa->nodes[ent->node].opr.idx; - - dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], - subexp_idx, dst_node, dst_idx, - dst_bkref_idx); - src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], - subexp_idx, src_node, src_idx, - src_bkref_idx); - - /* In case of: - ( ) - ( ) - ( ) */ - if (src_pos == dst_pos) - continue; /* This is unrelated limitation. */ - else - return 1; - } - return 0; -} - -static int -internal_function -check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, - int subexp_idx, int from_node, int bkref_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - const re_node_set *eclosures = dfa->eclosures + from_node; - int node_idx; - - /* Else, we are on the boundary: examine the nodes on the epsilon - closure. */ - for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx) - { - int node = eclosures->elems[node_idx]; - switch (dfa->nodes[node].type) - { - case OP_BACK_REF: - if (bkref_idx != -1) - { - struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; - do - { - int dst, cpos; - - if (ent->node != node) - continue; - - if (subexp_idx < BITSET_WORD_BITS - && !(ent->eps_reachable_subexps_map - & ((bitset_word_t) 1 << subexp_idx))) - continue; - - /* Recurse trying to reach the OP_OPEN_SUBEXP and - OP_CLOSE_SUBEXP cases below. But, if the - destination node is the same node as the source - node, don't recurse because it would cause an - infinite loop: a regex that exhibits this behavior - is ()\1*\1* */ - dst = dfa->edests[node].elems[0]; - if (dst == from_node) - { - if (boundaries & 1) - return -1; - else /* if (boundaries & 2) */ - return 0; - } - - cpos = - check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, - dst, bkref_idx); - if (cpos == -1 /* && (boundaries & 1) */) - return -1; - if (cpos == 0 && (boundaries & 2)) - return 0; - - if (subexp_idx < BITSET_WORD_BITS) - ent->eps_reachable_subexps_map - &= ~((bitset_word_t) 1 << subexp_idx); - } - while (ent++->more); - } - break; - - case OP_OPEN_SUBEXP: - if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx) - return -1; - break; - - case OP_CLOSE_SUBEXP: - if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx) - return 0; - break; - - default: - break; - } - } - - return (boundaries & 2) ? 1 : 0; -} - -static int -internal_function -check_dst_limits_calc_pos (const re_match_context_t *mctx, int limit, - int subexp_idx, int from_node, int str_idx, - int bkref_idx) -{ - struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; - int boundaries; - - /* If we are outside the range of the subexpression, return -1 or 1. */ - if (str_idx < lim->subexp_from) - return -1; - - if (lim->subexp_to < str_idx) - return 1; - - /* If we are within the subexpression, return 0. */ - boundaries = (str_idx == lim->subexp_from); - boundaries |= (str_idx == lim->subexp_to) << 1; - if (boundaries == 0) - return 0; - - /* Else, examine epsilon closure. */ - return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, - from_node, bkref_idx); -} - -/* Check the limitations of sub expressions LIMITS, and remove the nodes - which are against limitations from DEST_NODES. */ - -static reg_errcode_t -internal_function -check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, - const re_node_set *candidates, re_node_set *limits, - struct re_backref_cache_entry *bkref_ents, int str_idx) -{ - reg_errcode_t err; - int node_idx, lim_idx; - - for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) - { - int subexp_idx; - struct re_backref_cache_entry *ent; - ent = bkref_ents + limits->elems[lim_idx]; - - if (str_idx <= ent->subexp_from || ent->str_idx < str_idx) - continue; /* This is unrelated limitation. */ - - subexp_idx = dfa->nodes[ent->node].opr.idx; - if (ent->subexp_to == str_idx) - { - int ops_node = -1; - int cls_node = -1; - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - int node = dest_nodes->elems[node_idx]; - re_token_type_t type = dfa->nodes[node].type; - if (type == OP_OPEN_SUBEXP - && subexp_idx == dfa->nodes[node].opr.idx) - ops_node = node; - else if (type == OP_CLOSE_SUBEXP - && subexp_idx == dfa->nodes[node].opr.idx) - cls_node = node; - } - - /* Check the limitation of the open subexpression. */ - /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ - if (ops_node >= 0) - { - err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - - /* Check the limitation of the close subexpression. */ - if (cls_node >= 0) - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - int node = dest_nodes->elems[node_idx]; - if (!re_node_set_contains (dfa->inveclosures + node, - cls_node) - && !re_node_set_contains (dfa->eclosures + node, - cls_node)) - { - /* It is against this limitation. - Remove it form the current sifted state. */ - err = sub_epsilon_src_nodes (dfa, node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - --node_idx; - } - } - } - else /* (ent->subexp_to != str_idx) */ - { - for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) - { - int node = dest_nodes->elems[node_idx]; - re_token_type_t type = dfa->nodes[node].type; - if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP) - { - if (subexp_idx != dfa->nodes[node].opr.idx) - continue; - /* It is against this limitation. - Remove it form the current sifted state. */ - err = sub_epsilon_src_nodes (dfa, node, dest_nodes, - candidates); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, - int str_idx, const re_node_set *candidates) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - int node_idx, node; - re_sift_context_t local_sctx; - int first_idx = search_cur_bkref_entry (mctx, str_idx); - - if (first_idx == -1) - return REG_NOERROR; - - local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ - - for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) - { - int enabled_idx; - re_token_type_t type; - struct re_backref_cache_entry *entry; - node = candidates->elems[node_idx]; - type = dfa->nodes[node].type; - /* Avoid infinite loop for the REs like "()\1+". */ - if (node == sctx->last_node && str_idx == sctx->last_str_idx) - continue; - if (type != OP_BACK_REF) - continue; - - entry = mctx->bkref_ents + first_idx; - enabled_idx = first_idx; - do - { - int subexp_len; - int to_idx; - int dst_node; - int ret; - re_dfastate_t *cur_state; - - if (entry->node != node) - continue; - subexp_len = entry->subexp_to - entry->subexp_from; - to_idx = str_idx + subexp_len; - dst_node = (subexp_len ? dfa->nexts[node] - : dfa->edests[node].elems[0]); - - if (to_idx > sctx->last_str_idx - || sctx->sifted_states[to_idx] == NULL - || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node) - || check_dst_limits (mctx, &sctx->limits, node, - str_idx, dst_node, to_idx)) - continue; - - if (local_sctx.sifted_states == NULL) - { - local_sctx = *sctx; - err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - local_sctx.last_node = node; - local_sctx.last_str_idx = str_idx; - ret = re_node_set_insert (&local_sctx.limits, enabled_idx); - if (BE (ret < 0, 0)) - { - err = REG_ESPACE; - goto free_return; - } - cur_state = local_sctx.sifted_states[str_idx]; - err = sift_states_backward (mctx, &local_sctx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - if (sctx->limited_states != NULL) - { - err = merge_state_array (dfa, sctx->limited_states, - local_sctx.sifted_states, - str_idx + 1); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - local_sctx.sifted_states[str_idx] = cur_state; - re_node_set_remove (&local_sctx.limits, enabled_idx); - - /* mctx->bkref_ents may have changed, reload the pointer. */ - entry = mctx->bkref_ents + enabled_idx; - } - while (enabled_idx++, entry++->more); - } - err = REG_NOERROR; - free_return: - if (local_sctx.sifted_states != NULL) - { - re_node_set_free (&local_sctx.limits); - } - - return err; -} - - -#ifdef RE_ENABLE_I18N -static int -internal_function -sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, - int node_idx, int str_idx, int max_str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - int naccepted; - /* Check the node can accept `multi byte'. */ - naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); - if (naccepted > 0 && str_idx + naccepted <= max_str_idx && - !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], - dfa->nexts[node_idx])) - /* The node can't accept the `multi byte', or the - destination was already thrown away, then the node - could't accept the current input `multi byte'. */ - naccepted = 0; - /* Otherwise, it is sure that the node could accept - `naccepted' bytes input. */ - return naccepted; -} -#endif /* RE_ENABLE_I18N */ - - -/* Functions for state transition. */ - -/* Return the next state to which the current state STATE will transit by - accepting the current input byte, and update STATE_LOG if necessary. - If STATE can accept a multibyte char/collating element/back reference - update the destination of STATE_LOG. */ - -static re_dfastate_t * -internal_function -transit_state (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *state) -{ - re_dfastate_t **trtable; - unsigned char ch; - -#ifdef RE_ENABLE_I18N - /* If the current state can accept multibyte. */ - if (BE (state->accept_mb, 0)) - { - *err = transit_state_mb (mctx, state); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } -#endif /* RE_ENABLE_I18N */ - - /* Then decide the next state with the single byte. */ -#if 0 - if (0) - /* don't use transition table */ - return transit_state_sb (err, mctx, state); -#endif - - /* Use transition table */ - ch = re_string_fetch_byte (&mctx->input); - for (;;) - { - trtable = state->trtable; - if (BE (trtable != NULL, 1)) - return trtable[ch]; - - trtable = state->word_trtable; - if (BE (trtable != NULL, 1)) - { - unsigned int context; - context - = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input) - 1, - mctx->eflags); - if (IS_WORD_CONTEXT (context)) - return trtable[ch + SBC_MAX]; - else - return trtable[ch]; - } - - if (!build_trtable (mctx->dfa, state)) - { - *err = REG_ESPACE; - return NULL; - } - - /* Retry, we now have a transition table. */ - } -} - -/* Update the state_log if we need */ -re_dfastate_t * -internal_function -merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *next_state) -{ - const re_dfa_t *const dfa = mctx->dfa; - int cur_idx = re_string_cur_idx (&mctx->input); - - if (cur_idx > mctx->state_log_top) - { - mctx->state_log[cur_idx] = next_state; - mctx->state_log_top = cur_idx; - } - else if (mctx->state_log[cur_idx] == 0) - { - mctx->state_log[cur_idx] = next_state; - } - else - { - re_dfastate_t *pstate; - unsigned int context; - re_node_set next_nodes, *log_nodes, *table_nodes = NULL; - /* If (state_log[cur_idx] != 0), it implies that cur_idx is - the destination of a multibyte char/collating element/ - back reference. Then the next state is the union set of - these destinations and the results of the transition table. */ - pstate = mctx->state_log[cur_idx]; - log_nodes = pstate->entrance_nodes; - if (next_state != NULL) - { - table_nodes = next_state->entrance_nodes; - *err = re_node_set_init_union (&next_nodes, table_nodes, - log_nodes); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - } - else - next_nodes = *log_nodes; - /* Note: We already add the nodes of the initial state, - then we don't need to add them here. */ - - context = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input) - 1, - mctx->eflags); - next_state = mctx->state_log[cur_idx] - = re_acquire_state_context (err, dfa, &next_nodes, context); - /* We don't need to check errors here, since the return value of - this function is next_state and ERR is already set. */ - - if (table_nodes != NULL) - re_node_set_free (&next_nodes); - } - - if (BE (dfa->nbackref, 0) && next_state != NULL) - { - /* Check OP_OPEN_SUBEXP in the current state in case that we use them - later. We must check them here, since the back references in the - next state might use them. */ - *err = check_subexp_matching_top (mctx, &next_state->nodes, - cur_idx); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - - /* If the next state has back references. */ - if (next_state->has_backref) - { - *err = transit_state_bkref (mctx, &next_state->nodes); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - next_state = mctx->state_log[cur_idx]; - } - } - - return next_state; -} - -/* Skip bytes in the input that correspond to part of a - multi-byte match, then look in the log for a state - from which to restart matching. */ -re_dfastate_t * -internal_function -find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) -{ - re_dfastate_t *cur_state; - do - { - int max = mctx->state_log_top; - int cur_str_idx = re_string_cur_idx (&mctx->input); - - do - { - if (++cur_str_idx > max) - return NULL; - re_string_skip_bytes (&mctx->input, 1); - } - while (mctx->state_log[cur_str_idx] == NULL); - - cur_state = merge_state_with_log (err, mctx, NULL); - } - while (*err == REG_NOERROR && cur_state == NULL); - return cur_state; -} - -/* Helper functions for transit_state. */ - -/* From the node set CUR_NODES, pick up the nodes whose types are - OP_OPEN_SUBEXP and which have corresponding back references in the regular - expression. And register them to use them later for evaluating the - correspoding back references. */ - -static reg_errcode_t -internal_function -check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, - int str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - int node_idx; - reg_errcode_t err; - - /* TODO: This isn't efficient. - Because there might be more than one nodes whose types are - OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all - nodes. - E.g. RE: (a){2} */ - for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx) - { - int node = cur_nodes->elems[node_idx]; - if (dfa->nodes[node].type == OP_OPEN_SUBEXP - && dfa->nodes[node].opr.idx < BITSET_WORD_BITS - && (dfa->used_bkref_map - & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) - { - err = match_ctx_add_subtop (mctx, node, str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - } - } - return REG_NOERROR; -} - -#if 0 -/* Return the next state to which the current state STATE will transit by - accepting the current input byte. */ - -static re_dfastate_t * -transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, - re_dfastate_t *state) -{ - const re_dfa_t *const dfa = mctx->dfa; - re_node_set next_nodes; - re_dfastate_t *next_state; - int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); - unsigned int context; - - *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); - if (BE (*err != REG_NOERROR, 0)) - return NULL; - for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) - { - int cur_node = state->nodes.elems[node_cnt]; - if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx)) - { - *err = re_node_set_merge (&next_nodes, - dfa->eclosures + dfa->nexts[cur_node]); - if (BE (*err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return NULL; - } - } - } - context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); - next_state = re_acquire_state_context (err, dfa, &next_nodes, context); - /* We don't need to check errors here, since the return value of - this function is next_state and ERR is already set. */ - - re_node_set_free (&next_nodes); - re_string_skip_bytes (&mctx->input, 1); - return next_state; -} -#endif - -#ifdef RE_ENABLE_I18N -static reg_errcode_t -internal_function -transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - int i; - - for (i = 0; i < pstate->nodes.nelem; ++i) - { - re_node_set dest_nodes, *new_nodes; - int cur_node_idx = pstate->nodes.elems[i]; - int naccepted, dest_idx; - unsigned int context; - re_dfastate_t *dest_state; - - if (!dfa->nodes[cur_node_idx].accept_mb) - continue; - - if (dfa->nodes[cur_node_idx].constraint) - { - context = re_string_context_at (&mctx->input, - re_string_cur_idx (&mctx->input), - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, - context)) - continue; - } - - /* How many bytes the node can accept? */ - naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, - re_string_cur_idx (&mctx->input)); - if (naccepted == 0) - continue; - - /* The node can accepts `naccepted' bytes. */ - dest_idx = re_string_cur_idx (&mctx->input) + naccepted; - mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted - : mctx->max_mb_elem_len); - err = clean_state_log_if_needed (mctx, dest_idx); - if (BE (err != REG_NOERROR, 0)) - return err; -#ifdef DEBUG - assert (dfa->nexts[cur_node_idx] != -1); -#endif - new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; - - dest_state = mctx->state_log[dest_idx]; - if (dest_state == NULL) - dest_nodes = *new_nodes; - else - { - err = re_node_set_init_union (&dest_nodes, - dest_state->entrance_nodes, new_nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - context = re_string_context_at (&mctx->input, dest_idx - 1, - mctx->eflags); - mctx->state_log[dest_idx] - = re_acquire_state_context (&err, dfa, &dest_nodes, context); - if (dest_state != NULL) - re_node_set_free (&dest_nodes); - if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) - return err; - } - return REG_NOERROR; -} -#endif /* RE_ENABLE_I18N */ - -static reg_errcode_t -internal_function -transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - int i; - int cur_str_idx = re_string_cur_idx (&mctx->input); - - for (i = 0; i < nodes->nelem; ++i) - { - int dest_str_idx, prev_nelem, bkc_idx; - int node_idx = nodes->elems[i]; - unsigned int context; - const re_token_t *node = dfa->nodes + node_idx; - re_node_set *new_dest_nodes; - - /* Check whether `node' is a backreference or not. */ - if (node->type != OP_BACK_REF) - continue; - - if (node->constraint) - { - context = re_string_context_at (&mctx->input, cur_str_idx, - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) - continue; - } - - /* `node' is a backreference. - Check the substring which the substring matched. */ - bkc_idx = mctx->nbkref_ents; - err = get_subexp (mctx, node_idx, cur_str_idx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - - /* And add the epsilon closures (which is `new_dest_nodes') of - the backreference to appropriate state_log. */ -#ifdef DEBUG - assert (dfa->nexts[node_idx] != -1); -#endif - for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) - { - int subexp_len; - re_dfastate_t *dest_state; - struct re_backref_cache_entry *bkref_ent; - bkref_ent = mctx->bkref_ents + bkc_idx; - if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx) - continue; - subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from; - new_dest_nodes = (subexp_len == 0 - ? dfa->eclosures + dfa->edests[node_idx].elems[0] - : dfa->eclosures + dfa->nexts[node_idx]); - dest_str_idx = (cur_str_idx + bkref_ent->subexp_to - - bkref_ent->subexp_from); - context = re_string_context_at (&mctx->input, dest_str_idx - 1, - mctx->eflags); - dest_state = mctx->state_log[dest_str_idx]; - prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 - : mctx->state_log[cur_str_idx]->nodes.nelem); - /* Add `new_dest_node' to state_log. */ - if (dest_state == NULL) - { - mctx->state_log[dest_str_idx] - = re_acquire_state_context (&err, dfa, new_dest_nodes, - context); - if (BE (mctx->state_log[dest_str_idx] == NULL - && err != REG_NOERROR, 0)) - goto free_return; - } - else - { - re_node_set dest_nodes; - err = re_node_set_init_union (&dest_nodes, - dest_state->entrance_nodes, - new_dest_nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&dest_nodes); - goto free_return; - } - mctx->state_log[dest_str_idx] - = re_acquire_state_context (&err, dfa, &dest_nodes, context); - re_node_set_free (&dest_nodes); - if (BE (mctx->state_log[dest_str_idx] == NULL - && err != REG_NOERROR, 0)) - goto free_return; - } - /* We need to check recursively if the backreference can epsilon - transit. */ - if (subexp_len == 0 - && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem) - { - err = check_subexp_matching_top (mctx, new_dest_nodes, - cur_str_idx); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - err = transit_state_bkref (mctx, new_dest_nodes); - if (BE (err != REG_NOERROR, 0)) - goto free_return; - } - } - } - err = REG_NOERROR; - free_return: - return err; -} - -/* Enumerate all the candidates which the backreference BKREF_NODE can match - at BKREF_STR_IDX, and register them by match_ctx_add_entry(). - Note that we might collect inappropriate candidates here. - However, the cost of checking them strictly here is too high, then we - delay these checking for prune_impossible_nodes(). */ - -static reg_errcode_t -internal_function -get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx) -{ - const re_dfa_t *const dfa = mctx->dfa; - int subexp_num, sub_top_idx; - const char *buf = (const char *) re_string_get_buffer (&mctx->input); - /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ - int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); - if (cache_idx != -1) - { - const struct re_backref_cache_entry *entry - = mctx->bkref_ents + cache_idx; - do - if (entry->node == bkref_node) - return REG_NOERROR; /* We already checked it. */ - while (entry++->more); - } - - subexp_num = dfa->nodes[bkref_node].opr.idx; - - /* For each sub expression */ - for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx) - { - reg_errcode_t err; - re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; - re_sub_match_last_t *sub_last; - int sub_last_idx, sl_str, bkref_str_off; - - if (dfa->nodes[sub_top->node].opr.idx != subexp_num) - continue; /* It isn't related. */ - - sl_str = sub_top->str_idx; - bkref_str_off = bkref_str_idx; - /* At first, check the last node of sub expressions we already - evaluated. */ - for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx) - { - int sl_str_diff; - sub_last = sub_top->lasts[sub_last_idx]; - sl_str_diff = sub_last->str_idx - sl_str; - /* The matched string by the sub expression match with the substring - at the back reference? */ - if (sl_str_diff > 0) - { - if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) - { - /* Not enough chars for a successful match. */ - if (bkref_str_off + sl_str_diff > mctx->input.len) - break; - - err = clean_state_log_if_needed (mctx, - bkref_str_off - + sl_str_diff); - if (BE (err != REG_NOERROR, 0)) - return err; - buf = (const char *) re_string_get_buffer (&mctx->input); - } - if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) - /* We don't need to search this sub expression any more. */ - break; - } - bkref_str_off += sl_str_diff; - sl_str += sl_str_diff; - err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, - bkref_str_idx); - - /* Reload buf, since the preceding call might have reallocated - the buffer. */ - buf = (const char *) re_string_get_buffer (&mctx->input); - - if (err == REG_NOMATCH) - continue; - if (BE (err != REG_NOERROR, 0)) - return err; - } - - if (sub_last_idx < sub_top->nlasts) - continue; - if (sub_last_idx > 0) - ++sl_str; - /* Then, search for the other last nodes of the sub expression. */ - for (; sl_str <= bkref_str_idx; ++sl_str) - { - int cls_node, sl_str_off; - const re_node_set *nodes; - sl_str_off = sl_str - sub_top->str_idx; - /* The matched string by the sub expression match with the substring - at the back reference? */ - if (sl_str_off > 0) - { - if (BE (bkref_str_off >= mctx->input.valid_len, 0)) - { - /* If we are at the end of the input, we cannot match. */ - if (bkref_str_off >= mctx->input.len) - break; - - err = extend_buffers (mctx); - if (BE (err != REG_NOERROR, 0)) - return err; - - buf = (const char *) re_string_get_buffer (&mctx->input); - } - if (buf [bkref_str_off++] != buf[sl_str - 1]) - break; /* We don't need to search this sub expression - any more. */ - } - if (mctx->state_log[sl_str] == NULL) - continue; - /* Does this state have a ')' of the sub expression? */ - nodes = &mctx->state_log[sl_str]->nodes; - cls_node = find_subexp_node (dfa, nodes, subexp_num, - OP_CLOSE_SUBEXP); - if (cls_node == -1) - continue; /* No. */ - if (sub_top->path == NULL) - { - sub_top->path = calloc (sizeof (state_array_t), - sl_str - sub_top->str_idx + 1); - if (sub_top->path == NULL) - return REG_ESPACE; - } - /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node - in the current context? */ - err = check_arrival (mctx, sub_top->path, sub_top->node, - sub_top->str_idx, cls_node, sl_str, - OP_CLOSE_SUBEXP); - if (err == REG_NOMATCH) - continue; - if (BE (err != REG_NOERROR, 0)) - return err; - sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); - if (BE (sub_last == NULL, 0)) - return REG_ESPACE; - err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, - bkref_str_idx); - if (err == REG_NOMATCH) - continue; - } - } - return REG_NOERROR; -} - -/* Helper functions for get_subexp(). */ - -/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR. - If it can arrive, register the sub expression expressed with SUB_TOP - and SUB_LAST. */ - -static reg_errcode_t -internal_function -get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, - re_sub_match_last_t *sub_last, int bkref_node, int bkref_str) -{ - reg_errcode_t err; - int to_idx; - /* Can the subexpression arrive the back reference? */ - err = check_arrival (mctx, &sub_last->path, sub_last->node, - sub_last->str_idx, bkref_node, bkref_str, - OP_OPEN_SUBEXP); - if (err != REG_NOERROR) - return err; - err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, - sub_last->str_idx); - if (BE (err != REG_NOERROR, 0)) - return err; - to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; - return clean_state_log_if_needed (mctx, to_idx); -} - -/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. - Search '(' if FL_OPEN, or search ')' otherwise. - TODO: This function isn't efficient... - Because there might be more than one nodes whose types are - OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all - nodes. - E.g. RE: (a){2} */ - -static int -internal_function -find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, - int subexp_idx, int type) -{ - int cls_idx; - for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx) - { - int cls_node = nodes->elems[cls_idx]; - const re_token_t *node = dfa->nodes + cls_node; - if (node->type == type - && node->opr.idx == subexp_idx) - return cls_node; - } - return -1; -} - -/* Check whether the node TOP_NODE at TOP_STR can arrive to the node - LAST_NODE at LAST_STR. We record the path onto PATH since it will be - heavily reused. - Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ - -static reg_errcode_t -internal_function -check_arrival (re_match_context_t *mctx, state_array_t *path, int top_node, - int top_str, int last_node, int last_str, int type) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err = REG_NOERROR; - int subexp_num, backup_cur_idx, str_idx, null_cnt; - re_dfastate_t *cur_state = NULL; - re_node_set *cur_nodes, next_nodes; - re_dfastate_t **backup_state_log; - unsigned int context; - - subexp_num = dfa->nodes[top_node].opr.idx; - /* Extend the buffer if we need. */ - if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) - { - re_dfastate_t **new_array; - int old_alloc = path->alloc; - path->alloc += last_str + mctx->max_mb_elem_len + 1; - new_array = re_realloc (path->array, re_dfastate_t *, path->alloc); - if (BE (new_array == NULL, 0)) - { - path->alloc = old_alloc; - return REG_ESPACE; - } - path->array = new_array; - memset (new_array + old_alloc, '\0', - sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); - } - - str_idx = path->next_idx ?: top_str; - - /* Temporary modify MCTX. */ - backup_state_log = mctx->state_log; - backup_cur_idx = mctx->input.cur_idx; - mctx->state_log = path->array; - mctx->input.cur_idx = str_idx; - - /* Setup initial node set. */ - context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); - if (str_idx == top_str) - { - err = re_node_set_init_1 (&next_nodes, top_node); - if (BE (err != REG_NOERROR, 0)) - return err; - err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - else - { - cur_state = mctx->state_log[str_idx]; - if (cur_state && cur_state->has_backref) - { - err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); - if (BE (err != REG_NOERROR, 0)) - return err; - } - else - re_node_set_init_empty (&next_nodes); - } - if (str_idx == top_str || (cur_state && cur_state->has_backref)) - { - if (next_nodes.nelem) - { - err = expand_bkref_cache (mctx, &next_nodes, str_idx, - subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); - if (BE (cur_state == NULL && err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - mctx->state_log[str_idx] = cur_state; - } - - for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) - { - re_node_set_empty (&next_nodes); - if (mctx->state_log[str_idx + 1]) - { - err = re_node_set_merge (&next_nodes, - &mctx->state_log[str_idx + 1]->nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - if (cur_state) - { - err = check_arrival_add_next_nodes (mctx, str_idx, - &cur_state->non_eps_nodes, - &next_nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - ++str_idx; - if (next_nodes.nelem) - { - err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - err = expand_bkref_cache (mctx, &next_nodes, str_idx, - subexp_num, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - } - context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); - cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); - if (BE (cur_state == NULL && err != REG_NOERROR, 0)) - { - re_node_set_free (&next_nodes); - return err; - } - mctx->state_log[str_idx] = cur_state; - null_cnt = cur_state == NULL ? null_cnt + 1 : 0; - } - re_node_set_free (&next_nodes); - cur_nodes = (mctx->state_log[last_str] == NULL ? NULL - : &mctx->state_log[last_str]->nodes); - path->next_idx = str_idx; - - /* Fix MCTX. */ - mctx->state_log = backup_state_log; - mctx->input.cur_idx = backup_cur_idx; - - /* Then check the current node set has the node LAST_NODE. */ - if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) - return REG_NOERROR; - - return REG_NOMATCH; -} - -/* Helper functions for check_arrival. */ - -/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them - to NEXT_NODES. - TODO: This function is similar to the functions transit_state*(), - however this function has many additional works. - Can't we unify them? */ - -static reg_errcode_t -internal_function -check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx, - re_node_set *cur_nodes, re_node_set *next_nodes) -{ - const re_dfa_t *const dfa = mctx->dfa; - int result; - int cur_idx; - reg_errcode_t err = REG_NOERROR; - re_node_set union_set; - re_node_set_init_empty (&union_set); - for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) - { - int naccepted = 0; - int cur_node = cur_nodes->elems[cur_idx]; -#ifdef DEBUG - re_token_type_t type = dfa->nodes[cur_node].type; - assert (!IS_EPSILON_NODE (type)); -#endif -#ifdef RE_ENABLE_I18N - /* If the node may accept `multi byte'. */ - if (dfa->nodes[cur_node].accept_mb) - { - naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, - str_idx); - if (naccepted > 1) - { - re_dfastate_t *dest_state; - int next_node = dfa->nexts[cur_node]; - int next_idx = str_idx + naccepted; - dest_state = mctx->state_log[next_idx]; - re_node_set_empty (&union_set); - if (dest_state) - { - err = re_node_set_merge (&union_set, &dest_state->nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&union_set); - return err; - } - } - result = re_node_set_insert (&union_set, next_node); - if (BE (result < 0, 0)) - { - re_node_set_free (&union_set); - return REG_ESPACE; - } - mctx->state_log[next_idx] = re_acquire_state (&err, dfa, - &union_set); - if (BE (mctx->state_log[next_idx] == NULL - && err != REG_NOERROR, 0)) - { - re_node_set_free (&union_set); - return err; - } - } - } -#endif /* RE_ENABLE_I18N */ - if (naccepted - || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) - { - result = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); - if (BE (result < 0, 0)) - { - re_node_set_free (&union_set); - return REG_ESPACE; - } - } - } - re_node_set_free (&union_set); - return REG_NOERROR; -} - -/* For all the nodes in CUR_NODES, add the epsilon closures of them to - CUR_NODES, however exclude the nodes which are: - - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN. - - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN. -*/ - -static reg_errcode_t -internal_function -check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, - int ex_subexp, int type) -{ - reg_errcode_t err; - int idx, outside_node; - re_node_set new_nodes; -#ifdef DEBUG - assert (cur_nodes->nelem); -#endif - err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); - if (BE (err != REG_NOERROR, 0)) - return err; - /* Create a new node set NEW_NODES with the nodes which are epsilon - closures of the node in CUR_NODES. */ - - for (idx = 0; idx < cur_nodes->nelem; ++idx) - { - int cur_node = cur_nodes->elems[idx]; - const re_node_set *eclosure = dfa->eclosures + cur_node; - outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); - if (outside_node == -1) - { - /* There are no problematic nodes, just merge them. */ - err = re_node_set_merge (&new_nodes, eclosure); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&new_nodes); - return err; - } - } - else - { - /* There are problematic nodes, re-calculate incrementally. */ - err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, - ex_subexp, type); - if (BE (err != REG_NOERROR, 0)) - { - re_node_set_free (&new_nodes); - return err; - } - } - } - re_node_set_free (cur_nodes); - *cur_nodes = new_nodes; - return REG_NOERROR; -} - -/* Helper function for check_arrival_expand_ecl. - Check incrementally the epsilon closure of TARGET, and if it isn't - problematic append it to DST_NODES. */ - -static reg_errcode_t -internal_function -check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, - int target, int ex_subexp, int type) -{ - int cur_node; - for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);) - { - int err; - - if (dfa->nodes[cur_node].type == type - && dfa->nodes[cur_node].opr.idx == ex_subexp) - { - if (type == OP_CLOSE_SUBEXP) - { - err = re_node_set_insert (dst_nodes, cur_node); - if (BE (err == -1, 0)) - return REG_ESPACE; - } - break; - } - err = re_node_set_insert (dst_nodes, cur_node); - if (BE (err == -1, 0)) - return REG_ESPACE; - if (dfa->edests[cur_node].nelem == 0) - break; - if (dfa->edests[cur_node].nelem == 2) - { - err = check_arrival_expand_ecl_sub (dfa, dst_nodes, - dfa->edests[cur_node].elems[1], - ex_subexp, type); - if (BE (err != REG_NOERROR, 0)) - return err; - } - cur_node = dfa->edests[cur_node].elems[0]; - } - return REG_NOERROR; -} - - -/* For all the back references in the current state, calculate the - destination of the back references by the appropriate entry - in MCTX->BKREF_ENTS. */ - -static reg_errcode_t -internal_function -expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, - int cur_str, int subexp_num, int type) -{ - const re_dfa_t *const dfa = mctx->dfa; - reg_errcode_t err; - int cache_idx_start = search_cur_bkref_entry (mctx, cur_str); - struct re_backref_cache_entry *ent; - - if (cache_idx_start == -1) - return REG_NOERROR; - - restart: - ent = mctx->bkref_ents + cache_idx_start; - do - { - int to_idx, next_node; - - /* Is this entry ENT is appropriate? */ - if (!re_node_set_contains (cur_nodes, ent->node)) - continue; /* No. */ - - to_idx = cur_str + ent->subexp_to - ent->subexp_from; - /* Calculate the destination of the back reference, and append it - to MCTX->STATE_LOG. */ - if (to_idx == cur_str) - { - /* The backreference did epsilon transit, we must re-check all the - node in the current state. */ - re_node_set new_dests; - reg_errcode_t err2, err3; - next_node = dfa->edests[ent->node].elems[0]; - if (re_node_set_contains (cur_nodes, next_node)) - continue; - err = re_node_set_init_1 (&new_dests, next_node); - err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); - err3 = re_node_set_merge (cur_nodes, &new_dests); - re_node_set_free (&new_dests); - if (BE (err != REG_NOERROR || err2 != REG_NOERROR - || err3 != REG_NOERROR, 0)) - { - err = (err != REG_NOERROR ? err - : (err2 != REG_NOERROR ? err2 : err3)); - return err; - } - /* TODO: It is still inefficient... */ - goto restart; - } - else - { - re_node_set union_set; - next_node = dfa->nexts[ent->node]; - if (mctx->state_log[to_idx]) - { - int ret; - if (re_node_set_contains (&mctx->state_log[to_idx]->nodes, - next_node)) - continue; - err = re_node_set_init_copy (&union_set, - &mctx->state_log[to_idx]->nodes); - ret = re_node_set_insert (&union_set, next_node); - if (BE (err != REG_NOERROR || ret < 0, 0)) - { - re_node_set_free (&union_set); - err = err != REG_NOERROR ? err : REG_ESPACE; - return err; - } - } - else - { - err = re_node_set_init_1 (&union_set, next_node); - if (BE (err != REG_NOERROR, 0)) - return err; - } - mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); - re_node_set_free (&union_set); - if (BE (mctx->state_log[to_idx] == NULL - && err != REG_NOERROR, 0)) - return err; - } - } - while (ent++->more); - return REG_NOERROR; -} - -/* Build transition table for the state. - Return 1 if succeeded, otherwise return NULL. */ - -static int -internal_function -build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) -{ - reg_errcode_t err; - int i, j, ch, need_word_trtable = 0; - bitset_word_t elem, mask; - bool dests_node_malloced = false; - bool dest_states_malloced = false; - int ndests; /* Number of the destination states from `state'. */ - re_dfastate_t **trtable; - re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; - re_node_set follows, *dests_node; - bitset_t *dests_ch; - bitset_t acceptable; - - struct dests_alloc - { - re_node_set dests_node[SBC_MAX]; - bitset_t dests_ch[SBC_MAX]; - } *dests_alloc; - - /* We build DFA states which corresponds to the destination nodes - from `state'. `dests_node[i]' represents the nodes which i-th - destination state contains, and `dests_ch[i]' represents the - characters which i-th destination state accepts. */ - if (__libc_use_alloca (sizeof (struct dests_alloc))) - dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); - else - { - dests_alloc = re_malloc (struct dests_alloc, 1); - if (BE (dests_alloc == NULL, 0)) - return 0; - dests_node_malloced = true; - } - dests_node = dests_alloc->dests_node; - dests_ch = dests_alloc->dests_ch; - - /* Initialize transiton table. */ - state->word_trtable = state->trtable = NULL; - - /* At first, group all nodes belonging to `state' into several - destinations. */ - ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); - if (BE (ndests <= 0, 0)) - { - if (dests_node_malloced) - free (dests_alloc); - /* Return 0 in case of an error, 1 otherwise. */ - if (ndests == 0) - { - state->trtable = (re_dfastate_t **) - calloc (sizeof (re_dfastate_t *), SBC_MAX); - return 1; - } - return 0; - } - - err = re_node_set_alloc (&follows, ndests + 1); - if (BE (err != REG_NOERROR, 0)) - goto out_free; - - if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX - + ndests * 3 * sizeof (re_dfastate_t *))) - dest_states = (re_dfastate_t **) - alloca (ndests * 3 * sizeof (re_dfastate_t *)); - else - { - dest_states = (re_dfastate_t **) - malloc (ndests * 3 * sizeof (re_dfastate_t *)); - if (BE (dest_states == NULL, 0)) - { -out_free: - if (dest_states_malloced) - free (dest_states); - re_node_set_free (&follows); - for (i = 0; i < ndests; ++i) - re_node_set_free (dests_node + i); - if (dests_node_malloced) - free (dests_alloc); - return 0; - } - dest_states_malloced = true; - } - dest_states_word = dest_states + ndests; - dest_states_nl = dest_states_word + ndests; - bitset_empty (acceptable); - - /* Then build the states for all destinations. */ - for (i = 0; i < ndests; ++i) - { - int next_node; - re_node_set_empty (&follows); - /* Merge the follows of this destination states. */ - for (j = 0; j < dests_node[i].nelem; ++j) - { - next_node = dfa->nexts[dests_node[i].elems[j]]; - if (next_node != -1) - { - err = re_node_set_merge (&follows, dfa->eclosures + next_node); - if (BE (err != REG_NOERROR, 0)) - goto out_free; - } - } - dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); - if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - /* If the new state has context constraint, - build appropriate states for these contexts. */ - if (dest_states[i]->has_constraint) - { - dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, - CONTEXT_WORD); - if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - - if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) - need_word_trtable = 1; - - dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, - CONTEXT_NEWLINE); - if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) - goto out_free; - } - else - { - dest_states_word[i] = dest_states[i]; - dest_states_nl[i] = dest_states[i]; - } - bitset_merge (acceptable, dests_ch[i]); - } - - if (!BE (need_word_trtable, 0)) - { - /* We don't care about whether the following character is a word - character, or we are in a single-byte character set so we can - discern by looking at the character code: allocate a - 256-entry transition table. */ - trtable = state->trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); - if (BE (trtable == NULL, 0)) - goto out_free; - - /* For all characters ch...: */ - for (i = 0; i < BITSET_WORDS; ++i) - for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; - elem; - mask <<= 1, elem >>= 1, ++ch) - if (BE (elem & 1, 0)) - { - /* There must be exactly one destination which accepts - character ch. See group_nodes_into_DFAstates. */ - for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) - ; - - /* j-th destination accepts the word character ch. */ - if (dfa->word_char[i] & mask) - trtable[ch] = dest_states_word[j]; - else - trtable[ch] = dest_states[j]; - } - } - else - { - /* We care about whether the following character is a word - character, and we are in a multi-byte character set: discern - by looking at the character code: build two 256-entry - transition tables, one starting at trtable[0] and one - starting at trtable[SBC_MAX]. */ - trtable = state->word_trtable = - (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); - if (BE (trtable == NULL, 0)) - goto out_free; - - /* For all characters ch...: */ - for (i = 0; i < BITSET_WORDS; ++i) - for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; - elem; - mask <<= 1, elem >>= 1, ++ch) - if (BE (elem & 1, 0)) - { - /* There must be exactly one destination which accepts - character ch. See group_nodes_into_DFAstates. */ - for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) - ; - - /* j-th destination accepts the word character ch. */ - trtable[ch] = dest_states[j]; - trtable[ch + SBC_MAX] = dest_states_word[j]; - } - } - - /* new line */ - if (bitset_contain (acceptable, NEWLINE_CHAR)) - { - /* The current state accepts newline character. */ - for (j = 0; j < ndests; ++j) - if (bitset_contain (dests_ch[j], NEWLINE_CHAR)) - { - /* k-th destination accepts newline character. */ - trtable[NEWLINE_CHAR] = dest_states_nl[j]; - if (need_word_trtable) - trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j]; - /* There must be only one destination which accepts - newline. See group_nodes_into_DFAstates. */ - break; - } - } - - if (dest_states_malloced) - free (dest_states); - - re_node_set_free (&follows); - for (i = 0; i < ndests; ++i) - re_node_set_free (dests_node + i); - - if (dests_node_malloced) - free (dests_alloc); - - return 1; -} - -/* Group all nodes belonging to STATE into several destinations. - Then for all destinations, set the nodes belonging to the destination - to DESTS_NODE[i] and set the characters accepted by the destination - to DEST_CH[i]. This function return the number of destinations. */ - -static int -internal_function -group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, - re_node_set *dests_node, bitset_t *dests_ch) -{ - reg_errcode_t err; - int result; - int i, j, k; - int ndests; /* Number of the destinations from `state'. */ - bitset_t accepts; /* Characters a node can accept. */ - const re_node_set *cur_nodes = &state->nodes; - bitset_empty (accepts); - ndests = 0; - - /* For all the nodes belonging to `state', */ - for (i = 0; i < cur_nodes->nelem; ++i) - { - re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; - re_token_type_t type = node->type; - unsigned int constraint = node->constraint; - - /* Enumerate all single byte character this node can accept. */ - if (type == CHARACTER) - bitset_set (accepts, node->opr.c); - else if (type == SIMPLE_BRACKET) - { - bitset_merge (accepts, node->opr.sbcset); - } - else if (type == OP_PERIOD) - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - bitset_merge (accepts, dfa->sb_char); - else -#endif - bitset_set_all (accepts); - if (!(dfa->syntax & RE_DOT_NEWLINE)) - bitset_clear (accepts, '\n'); - if (dfa->syntax & RE_DOT_NOT_NULL) - bitset_clear (accepts, '\0'); - } -#ifdef RE_ENABLE_I18N - else if (type == OP_UTF8_PERIOD) - { - memset (accepts, '\xff', sizeof (bitset_t) / 2); - if (!(dfa->syntax & RE_DOT_NEWLINE)) - bitset_clear (accepts, '\n'); - if (dfa->syntax & RE_DOT_NOT_NULL) - bitset_clear (accepts, '\0'); - } -#endif - else - continue; - - /* Check the `accepts' and sift the characters which are not - match it the context. */ - if (constraint) - { - if (constraint & NEXT_NEWLINE_CONSTRAINT) - { - bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR); - bitset_empty (accepts); - if (accepts_newline) - bitset_set (accepts, NEWLINE_CHAR); - else - continue; - } - if (constraint & NEXT_ENDBUF_CONSTRAINT) - { - bitset_empty (accepts); - continue; - } - - if (constraint & NEXT_WORD_CONSTRAINT) - { - bitset_word_t any_set = 0; - if (type == CHARACTER && !node->word_char) - { - bitset_empty (accepts); - continue; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); - else -#endif - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= dfa->word_char[j]); - if (!any_set) - continue; - } - if (constraint & NEXT_NOTWORD_CONSTRAINT) - { - bitset_word_t any_set = 0; - if (type == CHARACTER && node->word_char) - { - bitset_empty (accepts); - continue; - } -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); - else -#endif - for (j = 0; j < BITSET_WORDS; ++j) - any_set |= (accepts[j] &= ~dfa->word_char[j]); - if (!any_set) - continue; - } - } - - /* Then divide `accepts' into DFA states, or create a new - state. Above, we make sure that accepts is not empty. */ - for (j = 0; j < ndests; ++j) - { - bitset_t intersec; /* Intersection sets, see below. */ - bitset_t remains; - /* Flags, see below. */ - bitset_word_t has_intersec, not_subset, not_consumed; - - /* Optimization, skip if this state doesn't accept the character. */ - if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) - continue; - - /* Enumerate the intersection set of this state and `accepts'. */ - has_intersec = 0; - for (k = 0; k < BITSET_WORDS; ++k) - has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; - /* And skip if the intersection set is empty. */ - if (!has_intersec) - continue; - - /* Then check if this state is a subset of `accepts'. */ - not_subset = not_consumed = 0; - for (k = 0; k < BITSET_WORDS; ++k) - { - not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k]; - not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; - } - - /* If this state isn't a subset of `accepts', create a - new group state, which has the `remains'. */ - if (not_subset) - { - bitset_copy (dests_ch[ndests], remains); - bitset_copy (dests_ch[j], intersec); - err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); - if (BE (err != REG_NOERROR, 0)) - goto error_return; - ++ndests; - } - - /* Put the position in the current group. */ - result = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); - if (BE (result < 0, 0)) - goto error_return; - - /* If all characters are consumed, go to next node. */ - if (!not_consumed) - break; - } - /* Some characters remain, create a new group. */ - if (j == ndests) - { - bitset_copy (dests_ch[ndests], accepts); - err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); - if (BE (err != REG_NOERROR, 0)) - goto error_return; - ++ndests; - bitset_empty (accepts); - } - } - return ndests; - error_return: - for (j = 0; j < ndests; ++j) - re_node_set_free (dests_node + j); - return -1; -} - -#ifdef RE_ENABLE_I18N -/* Check how many bytes the node `dfa->nodes[node_idx]' accepts. - Return the number of the bytes the node accepts. - STR_IDX is the current index of the input string. - - This function handles the nodes which can accept one character, or - one collating element like '.', '[a-z]', opposite to the other nodes - can only accept one byte. */ - -static int -internal_function -check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, - const re_string_t *input, int str_idx) -{ - const re_token_t *node = dfa->nodes + node_idx; - int char_len, elem_len; - int i; - - if (BE (node->type == OP_UTF8_PERIOD, 0)) - { - unsigned char c = re_string_byte_at (input, str_idx), d; - if (BE (c < 0xc2, 1)) - return 0; - - if (str_idx + 2 > input->len) - return 0; - - d = re_string_byte_at (input, str_idx + 1); - if (c < 0xe0) - return (d < 0x80 || d > 0xbf) ? 0 : 2; - else if (c < 0xf0) - { - char_len = 3; - if (c == 0xe0 && d < 0xa0) - return 0; - } - else if (c < 0xf8) - { - char_len = 4; - if (c == 0xf0 && d < 0x90) - return 0; - } - else if (c < 0xfc) - { - char_len = 5; - if (c == 0xf8 && d < 0x88) - return 0; - } - else if (c < 0xfe) - { - char_len = 6; - if (c == 0xfc && d < 0x84) - return 0; - } - else - return 0; - - if (str_idx + char_len > input->len) - return 0; - - for (i = 1; i < char_len; ++i) - { - d = re_string_byte_at (input, str_idx + i); - if (d < 0x80 || d > 0xbf) - return 0; - } - return char_len; - } - - char_len = re_string_char_size_at (input, str_idx); - if (node->type == OP_PERIOD) - { - if (char_len <= 1) - return 0; - /* FIXME: I don't think this if is needed, as both '\n' - and '\0' are char_len == 1. */ - /* '.' accepts any one character except the following two cases. */ - if ((!(dfa->syntax & RE_DOT_NEWLINE) && - re_string_byte_at (input, str_idx) == '\n') || - ((dfa->syntax & RE_DOT_NOT_NULL) && - re_string_byte_at (input, str_idx) == '\0')) - return 0; - return char_len; - } - - elem_len = re_string_elem_size_at (input, str_idx); - if ((elem_len <= 1 && char_len <= 1) || char_len == 0) - return 0; - - if (node->type == COMPLEX_BRACKET) - { - const re_charset_t *cset = node->opr.mbcset; -# ifdef _LIBC - const unsigned char *pin - = ((const unsigned char *) re_string_get_buffer (input) + str_idx); - int j; - uint32_t nrules; -# endif /* _LIBC */ - int match_len = 0; - wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) - ? re_string_wchar_at (input, str_idx) : 0); - - /* match with multibyte character? */ - for (i = 0; i < cset->nmbchars; ++i) - if (wc == cset->mbchars[i]) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - /* match with character_class? */ - for (i = 0; i < cset->nchar_classes; ++i) - { - wctype_t wt = cset->char_classes[i]; - if (__iswctype (wc, wt)) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - } - -# ifdef _LIBC - nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules != 0) - { - unsigned int in_collseq = 0; - const int32_t *table, *indirect; - const unsigned char *weights, *extra; - const char *collseqwc; - int32_t idx; - /* This #include defines a local function! */ -# include - - /* match with collating_symbol? */ - if (cset->ncoll_syms) - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); - for (i = 0; i < cset->ncoll_syms; ++i) - { - const unsigned char *coll_sym = extra + cset->coll_syms[i]; - /* Compare the length of input collating element and - the length of current collating element. */ - if (*coll_sym != elem_len) - continue; - /* Compare each bytes. */ - for (j = 0; j < *coll_sym; j++) - if (pin[j] != coll_sym[1 + j]) - break; - if (j == *coll_sym) - { - /* Match if every bytes is equal. */ - match_len = j; - goto check_node_accept_bytes_match; - } - } - - if (cset->nranges) - { - if (elem_len <= char_len) - { - collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); - in_collseq = __collseq_table_lookup (collseqwc, wc); - } - else - in_collseq = find_collation_sequence_value (pin, elem_len); - } - /* match with range expression? */ - for (i = 0; i < cset->nranges; ++i) - if (cset->range_starts[i] <= in_collseq - && in_collseq <= cset->range_ends[i]) - { - match_len = elem_len; - goto check_node_accept_bytes_match; - } - - /* match with equivalence_class? */ - if (cset->nequiv_classes) - { - const unsigned char *cp = pin; - table = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - weights = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); - idx = findidx (&cp); - if (idx > 0) - for (i = 0; i < cset->nequiv_classes; ++i) - { - int32_t equiv_class_idx = cset->equiv_classes[i]; - size_t weight_len = weights[idx]; - if (weight_len == weights[equiv_class_idx]) - { - int cnt = 0; - while (cnt <= weight_len - && (weights[equiv_class_idx + 1 + cnt] - == weights[idx + 1 + cnt])) - ++cnt; - if (cnt > weight_len) - { - match_len = elem_len; - goto check_node_accept_bytes_match; - } - } - } - } - } - else -# endif /* _LIBC */ - { - /* match with range expression? */ -#if __GNUC__ >= 2 - wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'}; -#else - wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'}; - cmp_buf[2] = wc; -#endif - for (i = 0; i < cset->nranges; ++i) - { - cmp_buf[0] = cset->range_starts[i]; - cmp_buf[4] = cset->range_ends[i]; - if (wcscoll (cmp_buf, cmp_buf + 2) <= 0 - && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0) - { - match_len = char_len; - goto check_node_accept_bytes_match; - } - } - } - check_node_accept_bytes_match: - if (!cset->non_match) - return match_len; - else - { - if (match_len > 0) - return 0; - else - return (elem_len > char_len) ? elem_len : char_len; - } - } - return 0; -} - -# ifdef _LIBC -static unsigned int -internal_function -find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) -{ - uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - if (nrules == 0) - { - if (mbs_len == 1) - { - /* No valid character. Match it as a single byte character. */ - const unsigned char *collseq = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); - return collseq[mbs[0]]; - } - return UINT_MAX; - } - else - { - int32_t idx; - const unsigned char *extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); - int32_t extrasize = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; - - for (idx = 0; idx < extrasize;) - { - int mbs_cnt, found = 0; - int32_t elem_mbs_len; - /* Skip the name of collating element name. */ - idx = idx + extra[idx] + 1; - elem_mbs_len = extra[idx++]; - if (mbs_len == elem_mbs_len) - { - for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) - if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) - break; - if (mbs_cnt == elem_mbs_len) - /* Found the entry. */ - found = 1; - } - /* Skip the byte sequence of the collating element. */ - idx += elem_mbs_len; - /* Adjust for the alignment. */ - idx = (idx + 3) & ~3; - /* Skip the collation sequence value. */ - idx += sizeof (uint32_t); - /* Skip the wide char sequence of the collating element. */ - idx = idx + sizeof (uint32_t) * (extra[idx] + 1); - /* If we found the entry, return the sequence value. */ - if (found) - return *(uint32_t *) (extra + idx); - /* Skip the collation sequence value. */ - idx += sizeof (uint32_t); - } - return UINT_MAX; - } -} -# endif /* _LIBC */ -#endif /* RE_ENABLE_I18N */ - -/* Check whether the node accepts the byte which is IDX-th - byte of the INPUT. */ - -static int -internal_function -check_node_accept (const re_match_context_t *mctx, const re_token_t *node, - int idx) -{ - unsigned char ch; - ch = re_string_byte_at (&mctx->input, idx); - switch (node->type) - { - case CHARACTER: - if (node->opr.c != ch) - return 0; - break; - - case SIMPLE_BRACKET: - if (!bitset_contain (node->opr.sbcset, ch)) - return 0; - break; - -#ifdef RE_ENABLE_I18N - case OP_UTF8_PERIOD: - if (ch >= 0x80) - return 0; - /* FALLTHROUGH */ -#endif - case OP_PERIOD: - if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) - || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) - return 0; - break; - - default: - return 0; - } - - if (node->constraint) - { - /* The node has constraints. Check whether the current context - satisfies the constraints. */ - unsigned int context = re_string_context_at (&mctx->input, idx, - mctx->eflags); - if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) - return 0; - } - - return 1; -} - -/* Extend the buffers, if the buffers have run out. */ - -static reg_errcode_t -internal_function -extend_buffers (re_match_context_t *mctx) -{ - reg_errcode_t ret; - re_string_t *pstr = &mctx->input; - - /* Double the lengthes of the buffers. */ - ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - if (mctx->state_log != NULL) - { - /* And double the length of state_log. */ - /* XXX We have no indication of the size of this buffer. If this - allocation fail we have no indication that the state_log array - does not have the right size. */ - re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, - pstr->bufs_len + 1); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - mctx->state_log = new_array; - } - - /* Then reconstruct the buffers. */ - if (pstr->icase) - { -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - else -#endif /* RE_ENABLE_I18N */ - build_upper_buffer (pstr); - } - else - { -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - build_wcs_buffer (pstr); - else -#endif /* RE_ENABLE_I18N */ - { - if (pstr->trans != NULL) - re_string_translate_buffer (pstr); - } - } - return REG_NOERROR; -} - - -/* Functions for matching context. */ - -/* Initialize MCTX. */ - -static reg_errcode_t -internal_function -match_ctx_init (re_match_context_t *mctx, int eflags, int n) -{ - mctx->eflags = eflags; - mctx->match_last = -1; - if (n > 0) - { - mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); - mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); - if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) - return REG_ESPACE; - } - /* Already zero-ed by the caller. - else - mctx->bkref_ents = NULL; - mctx->nbkref_ents = 0; - mctx->nsub_tops = 0; */ - mctx->abkref_ents = n; - mctx->max_mb_elem_len = 1; - mctx->asub_tops = n; - return REG_NOERROR; -} - -/* Clean the entries which depend on the current input in MCTX. - This function must be invoked when the matcher changes the start index - of the input, or changes the input string. */ - -static void -internal_function -match_ctx_clean (re_match_context_t *mctx) -{ - int st_idx; - for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) - { - int sl_idx; - re_sub_match_top_t *top = mctx->sub_tops[st_idx]; - for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) - { - re_sub_match_last_t *last = top->lasts[sl_idx]; - re_free (last->path.array); - re_free (last); - } - re_free (top->lasts); - if (top->path) - { - re_free (top->path->array); - re_free (top->path); - } - free (top); - } - - mctx->nsub_tops = 0; - mctx->nbkref_ents = 0; -} - -/* Free all the memory associated with MCTX. */ - -static void -internal_function -match_ctx_free (re_match_context_t *mctx) -{ - /* First, free all the memory associated with MCTX->SUB_TOPS. */ - match_ctx_clean (mctx); - re_free (mctx->sub_tops); - re_free (mctx->bkref_ents); -} - -/* Add a new backreference entry to MCTX. - Note that we assume that caller never call this function with duplicate - entry, and call with STR_IDX which isn't smaller than any existing entry. -*/ - -static reg_errcode_t -internal_function -match_ctx_add_entry (re_match_context_t *mctx, int node, int str_idx, int from, - int to) -{ - if (mctx->nbkref_ents >= mctx->abkref_ents) - { - struct re_backref_cache_entry* new_entry; - new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, - mctx->abkref_ents * 2); - if (BE (new_entry == NULL, 0)) - { - re_free (mctx->bkref_ents); - return REG_ESPACE; - } - mctx->bkref_ents = new_entry; - memset (mctx->bkref_ents + mctx->nbkref_ents, '\0', - sizeof (struct re_backref_cache_entry) * mctx->abkref_ents); - mctx->abkref_ents *= 2; - } - if (mctx->nbkref_ents > 0 - && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx) - mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1; - - mctx->bkref_ents[mctx->nbkref_ents].node = node; - mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx; - mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from; - mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to; - - /* This is a cache that saves negative results of check_dst_limits_calc_pos. - If bit N is clear, means that this entry won't epsilon-transition to - an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If - it is set, check_dst_limits_calc_pos_1 will recurse and try to find one - such node. - - A backreference does not epsilon-transition unless it is empty, so set - to all zeros if FROM != TO. */ - mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map - = (from == to ? ~0 : 0); - - mctx->bkref_ents[mctx->nbkref_ents++].more = 0; - if (mctx->max_mb_elem_len < to - from) - mctx->max_mb_elem_len = to - from; - return REG_NOERROR; -} - -/* Search for the first entry which has the same str_idx, or -1 if none is - found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ - -static int -internal_function -search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx) -{ - int left, right, mid, last; - last = right = mctx->nbkref_ents; - for (left = 0; left < right;) - { - mid = (left + right) / 2; - if (mctx->bkref_ents[mid].str_idx < str_idx) - left = mid + 1; - else - right = mid; - } - if (left < last && mctx->bkref_ents[left].str_idx == str_idx) - return left; - else - return -1; -} - -/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches - at STR_IDX. */ - -static reg_errcode_t -internal_function -match_ctx_add_subtop (re_match_context_t *mctx, int node, int str_idx) -{ -#ifdef DEBUG - assert (mctx->sub_tops != NULL); - assert (mctx->asub_tops > 0); -#endif - if (BE (mctx->nsub_tops == mctx->asub_tops, 0)) - { - int new_asub_tops = mctx->asub_tops * 2; - re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, - re_sub_match_top_t *, - new_asub_tops); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - mctx->sub_tops = new_array; - mctx->asub_tops = new_asub_tops; - } - mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); - if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) - return REG_ESPACE; - mctx->sub_tops[mctx->nsub_tops]->node = node; - mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; - return REG_NOERROR; -} - -/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches - at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ - -static re_sub_match_last_t * -internal_function -match_ctx_add_sublast (re_sub_match_top_t *subtop, int node, int str_idx) -{ - re_sub_match_last_t *new_entry; - if (BE (subtop->nlasts == subtop->alasts, 0)) - { - int new_alasts = 2 * subtop->alasts + 1; - re_sub_match_last_t **new_array = re_realloc (subtop->lasts, - re_sub_match_last_t *, - new_alasts); - if (BE (new_array == NULL, 0)) - return NULL; - subtop->lasts = new_array; - subtop->alasts = new_alasts; - } - new_entry = calloc (1, sizeof (re_sub_match_last_t)); - if (BE (new_entry != NULL, 1)) - { - subtop->lasts[subtop->nlasts] = new_entry; - new_entry->node = node; - new_entry->str_idx = str_idx; - ++subtop->nlasts; - } - return new_entry; -} - -static void -internal_function -sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, - re_dfastate_t **limited_sts, int last_node, int last_str_idx) -{ - sctx->sifted_states = sifted_sts; - sctx->limited_states = limited_sts; - sctx->last_node = last_node; - sctx->last_str_idx = last_str_idx; - re_node_set_init_empty (&sctx->limits); -} diff -Nru eresi-0.8a25/libregex/.svn/text-base/regex.h.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regex.h.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regex.h.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regex.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,558 +0,0 @@ -/* Definitions for data structures and routines for the regular - expression library. - Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006 - Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _REGEX_H -#define _REGEX_H 1 - -#ifndef __KERNEL__ -#include -#endif - -/* Allow the use in C++ code. */ -#ifdef __cplusplus -extern "C" { -#endif - -/* The following two types have to be signed and unsigned integer type - wide enough to hold a value of a pointer. For most ANSI compilers - ptrdiff_t and size_t should be likely OK. Still size of these two - types is 2 for Microsoft C. Ugh... */ -typedef long int s_reg_t; -typedef unsigned long int active_reg_t; - -/* The following bits are used to determine the regexp syntax we - recognize. The set/not-set meanings are chosen so that Emacs syntax - remains the value 0. The bits are given in alphabetical order, and - the definitions shifted by one from the previous bit; thus, when we - add or remove a bit, only one other definition need change. */ -typedef unsigned long int reg_syntax_t; - -/* If this bit is not set, then \ inside a bracket expression is literal. - If set, then such a \ quotes the following character. */ -#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) - -/* If this bit is not set, then + and ? are operators, and \+ and \? are - literals. - If set, then \+ and \? are operators and + and ? are literals. */ -#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) - -/* If this bit is set, then character classes are supported. They are: - [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], - [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. - If not set, then character classes are not supported. */ -#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) - -/* If this bit is set, then ^ and $ are always anchors (outside bracket - expressions, of course). - If this bit is not set, then it depends: - ^ is an anchor if it is at the beginning of a regular - expression or after an open-group or an alternation operator; - $ is an anchor if it is at the end of a regular expression, or - before a close-group or an alternation operator. - - This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because - POSIX draft 11.2 says that * etc. in leading positions is undefined. - We already implemented a previous draft which made those constructs - invalid, though, so we haven't changed the code back. */ -#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) - -/* If this bit is set, then special characters are always special - regardless of where they are in the pattern. - If this bit is not set, then special characters are special only in - some contexts; otherwise they are ordinary. Specifically, - * + ? and intervals are only special when not after the beginning, - open-group, or alternation operator. */ -#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) - -/* If this bit is set, then *, +, ?, and { cannot be first in an re or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) - -/* If this bit is set, then . matches newline. - If not set, then it doesn't. */ -#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) - -/* If this bit is set, then . doesn't match NUL. - If not set, then it does. */ -#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) - -/* If this bit is set, nonmatching lists [^...] do not match newline. - If not set, they do. */ -#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) - -/* If this bit is set, either \{...\} or {...} defines an - interval, depending on RE_NO_BK_BRACES. - If not set, \{, \}, {, and } are literals. */ -#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) - -/* If this bit is set, +, ? and | aren't recognized as operators. - If not set, they are. */ -#define RE_LIMITED_OPS (RE_INTERVALS << 1) - -/* If this bit is set, newline is an alternation operator. - If not set, newline is literal. */ -#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) - -/* If this bit is set, then `{...}' defines an interval, and \{ and \} - are literals. - If not set, then `\{...\}' defines an interval. */ -#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) - -/* If this bit is set, (...) defines a group, and \( and \) are literals. - If not set, \(...\) defines a group, and ( and ) are literals. */ -#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) - -/* If this bit is set, then \ matches . - If not set, then \ is a back-reference. */ -#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) - -/* If this bit is set, then | is an alternation operator, and \| is literal. - If not set, then \| is an alternation operator, and | is literal. */ -#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) - -/* If this bit is set, then an ending range point collating higher - than the starting range point, as in [z-a], is invalid. - If not set, then when ending range point collates higher than the - starting range point, the range is ignored. */ -#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) - -/* If this bit is set, then an unmatched ) is ordinary. - If not set, then an unmatched ) is invalid. */ -#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) - -/* If this bit is set, succeed as soon as we match the whole pattern, - without further backtracking. */ -#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) - -/* If this bit is set, do not process the GNU regex operators. - If not set, then the GNU regex operators are recognized. */ -#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) - -/* If this bit is set, turn on internal regex debugging. - If not set, and debugging was on, turn it off. - This only works if regex.c is compiled -DDEBUG. - We define this bit always, so that all that's needed to turn on - debugging is to recompile regex.c; the calling code can always have - this bit set, and it won't affect anything in the normal case. */ -#define RE_DEBUG (RE_NO_GNU_OPS << 1) - -/* If this bit is set, a syntactically invalid interval is treated as - a string of ordinary characters. For example, the ERE 'a{1' is - treated as 'a\{1'. */ -#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) - -/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only - for ^, because it is difficult to scan the regex backwards to find - whether ^ should be special. */ -#define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) - -/* If this bit is set, then \{ cannot be first in an bre or - immediately after an alternation or begin-group operator. */ -#define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) - -/* If this bit is set, then no_sub will be set to 1 during - re_compile_pattern. */ -#define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) - -/* This global variable defines the particular regexp syntax to use (for - some interfaces). When a regexp is compiled, the syntax used is - stored in the pattern buffer, so changing this does not affect - already-compiled regexps. */ -extern reg_syntax_t re_syntax_options; - -/* Define combinations of the above bits for the standard possibilities. - (The [[[ comments delimit what gets put into the Texinfo file, so - don't delete them!) */ -/* [[[begin syntaxes]]] */ -#define RE_SYNTAX_EMACS 0 - -#define RE_SYNTAX_AWK \ - (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ - | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ - | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) - -#define RE_SYNTAX_GNU_AWK \ - ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \ - & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ - | RE_CONTEXT_INVALID_OPS )) - -#define RE_SYNTAX_POSIX_AWK \ - (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ - | RE_INTERVALS | RE_NO_GNU_OPS) - -#define RE_SYNTAX_GREP \ - (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ - | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ - | RE_NEWLINE_ALT) - -#define RE_SYNTAX_EGREP \ - (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ - | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ - | RE_NO_BK_VBAR) - -#define RE_SYNTAX_POSIX_EGREP \ - (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ - | RE_INVALID_INTERVAL_ORD) - -/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ -#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC - -#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC - -/* Syntax bits common to both basic and extended POSIX regex syntax. */ -#define _RE_SYNTAX_POSIX_COMMON \ - (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ - | RE_INTERVALS | RE_NO_EMPTY_RANGES) - -#define RE_SYNTAX_POSIX_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) - -/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes - RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this - isn't minimal, since other operators, such as \`, aren't disabled. */ -#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ - (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) - -#define RE_SYNTAX_POSIX_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ - | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) - -/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is - removed and RE_NO_BK_REFS is added. */ -#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ - (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ - | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ - | RE_NO_BK_PARENS | RE_NO_BK_REFS \ - | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) -/* [[[end syntaxes]]] */ - -/* Maximum number of duplicates an interval can allow. Some systems - (erroneously) define this in other header files, but we want our - value, so remove any previous define. */ -#ifdef RE_DUP_MAX -# undef RE_DUP_MAX -#endif -/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ -#define RE_DUP_MAX (0x7fff) - - -/* POSIX `cflags' bits (i.e., information for `regcomp'). */ - -/* If this bit is set, then use extended regular expression syntax. - If not set, then use basic regular expression syntax. */ -#define REG_EXTENDED 1 - -/* If this bit is set, then ignore case when matching. - If not set, then case is significant. */ -#define REG_ICASE (REG_EXTENDED << 1) - -/* If this bit is set, then anchors do not match at newline - characters in the string. - If not set, then anchors do match at newlines. */ -#define REG_NEWLINE (REG_ICASE << 1) - -/* If this bit is set, then report only success or fail in regexec. - If not set, then returns differ between not matching and errors. */ -#define REG_NOSUB (REG_NEWLINE << 1) - - -/* POSIX `eflags' bits (i.e., information for regexec). */ - -/* If this bit is set, then the beginning-of-line operator doesn't match - the beginning of the string (presumably because it's not the - beginning of a line). - If not set, then the beginning-of-line operator does match the - beginning of the string. */ -#define REG_NOTBOL 1 - -/* Like REG_NOTBOL, except for the end-of-line. */ -#define REG_NOTEOL (1 << 1) - -/* Use PMATCH[0] to delimit the start and end of the search in the - buffer. */ -#define REG_STARTEND (1 << 2) - - -/* If any error codes are removed, changed, or added, update the - `re_error_msg' table in regex.c. */ -typedef enum -{ -#ifdef _XOPEN_SOURCE - REG_ENOSYS = -1, /* This will never happen for this implementation. */ -#endif - - REG_NOERROR = 0, /* Success. */ - REG_NOMATCH, /* Didn't find a match (for regexec). */ - - /* POSIX regcomp return error codes. (In the order listed in the - standard.) */ - REG_BADPAT, /* Invalid pattern. */ - REG_ECOLLATE, /* Inalid collating element. */ - REG_ECTYPE, /* Invalid character class name. */ - REG_EESCAPE, /* Trailing backslash. */ - REG_ESUBREG, /* Invalid back reference. */ - REG_EBRACK, /* Unmatched left bracket. */ - REG_EPAREN, /* Parenthesis imbalance. */ - REG_EBRACE, /* Unmatched \{. */ - REG_BADBR, /* Invalid contents of \{\}. */ - REG_ERANGE, /* Invalid range end. */ - REG_ESPACE, /* Ran out of memory. */ - REG_BADRPT, /* No preceding re for repetition op. */ - - /* Error codes we've added. */ - REG_EEND, /* Premature end. */ - REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ - REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ -} reg_errcode_t; - -/* This data structure represents a compiled pattern. Before calling - the pattern compiler, the fields `buffer', `allocated', `fastmap', - `translate', and `no_sub' can be set. After the pattern has been - compiled, the `re_nsub' field is available. All other fields are - private to the regex routines. */ - -#ifndef RE_TRANSLATE_TYPE -# define RE_TRANSLATE_TYPE unsigned char * -#endif - -struct re_pattern_buffer -{ - /* Space that holds the compiled pattern. It is declared as - `unsigned char *' because its elements are sometimes used as - array indexes. */ - unsigned char *buffer; - - /* Number of bytes to which `buffer' points. */ - unsigned long int allocated; - - /* Number of bytes actually used in `buffer'. */ - unsigned long int used; - - /* Syntax setting with which the pattern was compiled. */ - reg_syntax_t syntax; - - /* Pointer to a fastmap, if any, otherwise zero. re_search uses the - fastmap, if there is one, to skip over impossible starting points - for matches. */ - char *fastmap; - - /* Either a translate table to apply to all characters before - comparing them, or zero for no translation. The translation is - applied to a pattern when it is compiled and to a string when it - is matched. */ - RE_TRANSLATE_TYPE translate; - - /* Number of subexpressions found by the compiler. */ - size_t re_nsub; - - /* Zero if this pattern cannot match the empty string, one else. - Well, in truth it's used only in `re_search_2', to see whether or - not we should use the fastmap, so we don't set this absolutely - perfectly; see `re_compile_fastmap' (the `duplicate' case). */ - unsigned can_be_null : 1; - - /* If REGS_UNALLOCATED, allocate space in the `regs' structure - for `max (RE_NREGS, re_nsub + 1)' groups. - If REGS_REALLOCATE, reallocate space if necessary. - If REGS_FIXED, use what's there. */ -#define REGS_UNALLOCATED 0 -#define REGS_REALLOCATE 1 -#define REGS_FIXED 2 - unsigned regs_allocated : 2; - - /* Set to zero when `regex_compile' compiles a pattern; set to one - by `re_compile_fastmap' if it updates the fastmap. */ - unsigned fastmap_accurate : 1; - - /* If set, `re_match_2' does not return information about - subexpressions. */ - unsigned no_sub : 1; - - /* If set, a beginning-of-line anchor doesn't match at the beginning - of the string. */ - unsigned not_bol : 1; - - /* Similarly for an end-of-line anchor. */ - unsigned not_eol : 1; - - /* If true, an anchor at a newline matches. */ - unsigned newline_anchor : 1; -}; - -typedef struct re_pattern_buffer regex_t; - -/* Type for byte offsets within the string. POSIX mandates this. */ -typedef int regoff_t; - - -/* This is the structure we store register match data in. See - regex.texinfo for a full description of what registers match. */ -struct re_registers -{ - unsigned num_regs; - regoff_t *start; - regoff_t *end; -}; - - -/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, - `re_match_2' returns information about at least this many registers - the first time a `regs' structure is passed. */ -#ifndef RE_NREGS -# define RE_NREGS 30 -#endif - - -/* POSIX specification for registers. Aside from the different names than - `re_registers', POSIX uses an array of structures, instead of a - structure of arrays. */ -typedef struct -{ - regoff_t rm_so; /* Byte offset from string's start to substring's start. */ - regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ -} regmatch_t; - -/* Declarations for routines. */ - -/* Sets the current default syntax to SYNTAX, and return the old syntax. - You can also simply assign to the `re_syntax_options' variable. */ -extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); - -/* Compile the regular expression PATTERN, with length LENGTH - and syntax given by the global `re_syntax_options', into the buffer - BUFFER. Return NULL if successful, and an error string if not. */ -extern const char *re_compile_pattern (const char *__pattern, size_t __length, - struct re_pattern_buffer *__buffer); - - -/* Compile a fastmap for the compiled pattern in BUFFER; used to - accelerate searches. Return 0 if successful and -2 if was an - internal error. */ -extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); - - -/* Search in the string STRING (with length LENGTH) for the pattern - compiled into BUFFER. Start searching at position START, for RANGE - characters. Return the starting position of the match, -1 for no - match, or -2 for an internal error. Also return register - information in REGS (if REGS and BUFFER->no_sub are nonzero). */ -extern int re_search (struct re_pattern_buffer *__buffer, const char *__string, - int __length, int __start, int __range, - struct re_registers *__regs); - - -/* Like `re_search', but search in the concatenation of STRING1 and - STRING2. Also, stop searching at index START + STOP. */ -extern int re_search_2 (struct re_pattern_buffer *__buffer, - const char *__string1, int __length1, - const char *__string2, int __length2, int __start, - int __range, struct re_registers *__regs, int __stop); - - -/* Like `re_search', but return how many characters in STRING the regexp - in BUFFER matched, starting at position START. */ -extern int re_match (struct re_pattern_buffer *__buffer, const char *__string, - int __length, int __start, struct re_registers *__regs); - - -/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ -extern int re_match_2 (struct re_pattern_buffer *__buffer, - const char *__string1, int __length1, - const char *__string2, int __length2, int __start, - struct re_registers *__regs, int __stop); - - -/* Set REGS to hold NUM_REGS registers, storing them in STARTS and - ENDS. Subsequent matches using BUFFER and REGS will use this memory - for recording register information. STARTS and ENDS must be - allocated with malloc, and must each be at least `NUM_REGS * sizeof - (regoff_t)' bytes long. - - If NUM_REGS == 0, then subsequent matches should allocate their own - register data. - - Unless this function is called, the first search or match using - PATTERN_BUFFER will allocate its own register data, without - freeing the old data. */ -extern void re_set_registers (struct re_pattern_buffer *__buffer, - struct re_registers *__regs, - unsigned int __num_regs, - regoff_t *__starts, regoff_t *__ends); - -#if defined _REGEX_RE_COMP || defined _LIBC -# ifndef _CRAY -/* 4.2 bsd compatibility. */ -extern char *re_comp (const char *); -extern int re_exec (const char *); -# endif -#endif - -/* GCC 2.95 and later have "__restrict"; C99 compilers have - "restrict", and "configure" may have defined "restrict". */ -#ifndef __restrict -# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) -# if defined restrict || 199901L <= __STDC_VERSION__ -# define __restrict restrict -# else -# define __restrict -# endif -# endif -#endif -/* gcc 3.1 and up support the [restrict] syntax. */ -#ifndef __restrict_arr -# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \ - && !defined __GNUG__ -# define __restrict_arr __restrict -# else -# define __restrict_arr -# endif -#endif - -/* POSIX compatibility. */ -extern int regcomp (regex_t *__restrict __preg, - const char *__restrict __pattern, - int __cflags); - -extern int regexec (const regex_t *__restrict __preg, - const char *__restrict __string, size_t __nmatch, - regmatch_t __pmatch[__restrict_arr], - int __eflags); - -extern size_t regerror (int __errcode, const regex_t *__restrict __preg, - char *__restrict __errbuf, size_t __errbuf_size); - -extern void regfree (regex_t *__preg); - - -#ifdef __cplusplus -} -#endif /* C++ */ - -#endif /* regex.h */ diff -Nru eresi-0.8a25/libregex/.svn/text-base/regex_internal.c.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regex_internal.c.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regex_internal.c.svn-base 2008-04-06 23:15:47.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regex_internal.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1717 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -static void re_string_construct_common (const char *str, int len, - re_string_t *pstr, - RE_TRANSLATE_TYPE trans, int icase, - const re_dfa_t *dfa) internal_function; -static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, - const re_node_set *nodes, - unsigned int hash) internal_function; -static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, - const re_node_set *nodes, - unsigned int context, - unsigned int hash) internal_function; - -/* Functions for string operation. */ - -/* This function allocate the buffers. It is necessary to call - re_string_reconstruct before using the object. */ - -static reg_errcode_t -internal_function -re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len, - RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) -{ - reg_errcode_t ret; - int init_buf_len; - - /* Ensure at least one character fits into the buffers. */ - if (init_len < dfa->mb_cur_max) - init_len = dfa->mb_cur_max; - init_buf_len = (len + 1 < init_len) ? len + 1: init_len; - re_string_construct_common (str, len, pstr, trans, icase, dfa); - - ret = re_string_realloc_buffers (pstr, init_buf_len); - if (BE (ret != REG_NOERROR, 0)) - return ret; - - pstr->word_char = dfa->word_char; - pstr->word_ops_used = dfa->word_ops_used; - pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; - pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; - pstr->valid_raw_len = pstr->valid_len; - return REG_NOERROR; -} - -/* This function allocate the buffers, and initialize them. */ - -static reg_errcode_t -internal_function -re_string_construct (re_string_t *pstr, const char *str, int len, - RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) -{ - reg_errcode_t ret; - memset (pstr, '\0', sizeof (re_string_t)); - re_string_construct_common (str, len, pstr, trans, icase, dfa); - - if (len > 0) - { - ret = re_string_realloc_buffers (pstr, len + 1); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; - - if (icase) - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - { - while (1) - { - ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - if (pstr->valid_raw_len >= len) - break; - if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) - break; - ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - } - else -#endif /* RE_ENABLE_I18N */ - build_upper_buffer (pstr); - } - else - { -#ifdef RE_ENABLE_I18N - if (dfa->mb_cur_max > 1) - build_wcs_buffer (pstr); - else -#endif /* RE_ENABLE_I18N */ - { - if (trans != NULL) - re_string_translate_buffer (pstr); - else - { - pstr->valid_len = pstr->bufs_len; - pstr->valid_raw_len = pstr->bufs_len; - } - } - } - - return REG_NOERROR; -} - -/* Helper functions for re_string_allocate, and re_string_construct. */ - -static reg_errcode_t -internal_function -re_string_realloc_buffers (re_string_t *pstr, int new_buf_len) -{ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - wint_t *new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); - if (BE (new_wcs == NULL, 0)) - return REG_ESPACE; - pstr->wcs = new_wcs; - if (pstr->offsets != NULL) - { - int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len); - if (BE (new_offsets == NULL, 0)) - return REG_ESPACE; - pstr->offsets = new_offsets; - } - } -#endif /* RE_ENABLE_I18N */ - if (pstr->mbs_allocated) - { - unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, - new_buf_len); - if (BE (new_mbs == NULL, 0)) - return REG_ESPACE; - pstr->mbs = new_mbs; - } - pstr->bufs_len = new_buf_len; - return REG_NOERROR; -} - - -static void -internal_function -re_string_construct_common (const char *str, int len, re_string_t *pstr, - RE_TRANSLATE_TYPE trans, int icase, - const re_dfa_t *dfa) -{ - pstr->raw_mbs = (const unsigned char *) str; - pstr->len = len; - pstr->raw_len = len; - pstr->trans = trans; - pstr->icase = icase ? 1 : 0; - pstr->mbs_allocated = (trans != NULL || icase); - pstr->mb_cur_max = dfa->mb_cur_max; - pstr->is_utf8 = dfa->is_utf8; - pstr->map_notascii = dfa->map_notascii; - pstr->stop = pstr->len; - pstr->raw_stop = pstr->stop; -} - -#ifdef RE_ENABLE_I18N - -/* Build wide character buffer PSTR->WCS. - If the byte sequence of the string are: - (0), (1), (0), (1), - Then wide character buffer will be: - , WEOF , , WEOF , - We use WEOF for padding, they indicate that the position isn't - a first byte of a multibyte character. - - Note that this function assumes PSTR->VALID_LEN elements are already - built and starts from PSTR->VALID_LEN. */ - -static void -internal_function -build_wcs_buffer (re_string_t *pstr) -{ -#ifdef _LIBC - unsigned char buf[MB_LEN_MAX]; - assert (MB_LEN_MAX >= pstr->mb_cur_max); -#else - unsigned char buf[64]; -#endif - mbstate_t prev_st; - int byte_idx, end_idx, remain_len; - size_t mbclen; - - /* Build the buffers from pstr->valid_len to either pstr->len or - pstr->bufs_len. */ - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - for (byte_idx = pstr->valid_len; byte_idx < end_idx;) - { - wchar_t wc; - const char *p; - - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - /* Apply the translation if we need. */ - if (BE (pstr->trans != NULL, 0)) - { - int i, ch; - - for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) - { - ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i]; - buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch]; - } - p = (const char *) buf; - } - else - p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; - mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state); - if (BE (mbclen == (size_t) -2, 0)) - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0)) - { - /* We treat these cases as a singlebyte character. */ - mbclen = 1; - wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; - if (BE (pstr->trans != NULL, 0)) - wc = pstr->trans[wc]; - pstr->cur_state = prev_st; - } - - /* Write wide character and padding. */ - pstr->wcs[byte_idx++] = wc; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = byte_idx; -} - -/* Build wide character buffer PSTR->WCS like build_wcs_buffer, - but for REG_ICASE. */ - -static reg_errcode_t -internal_function -build_wcs_upper_buffer (re_string_t *pstr) -{ - mbstate_t prev_st; - int src_idx, byte_idx, end_idx, remain_len; - size_t mbclen; -#ifdef _LIBC - char buf[MB_LEN_MAX]; - assert (MB_LEN_MAX >= pstr->mb_cur_max); -#else - char buf[64]; -#endif - - byte_idx = pstr->valid_len; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - /* The following optimization assumes that ASCII characters can be - mapped to wide characters with a simple cast. */ - if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed) - { - while (byte_idx < end_idx) - { - wchar_t wc; - - if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) - && mbsinit (&pstr->cur_state)) - { - /* In case of a singlebyte character. */ - pstr->mbs[byte_idx] - = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]); - /* The next step uses the assumption that wchar_t is encoded - ASCII-safe: all ASCII values can be converted like this. */ - pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; - ++byte_idx; - continue; - } - - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - mbclen = mbrtowc (&wc, - ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx - + byte_idx), remain_len, &pstr->cur_state); - if (BE (mbclen + 2 > 2, 1)) - { - wchar_t wcu = wc; - if (iswlower (wc)) - { - size_t mbcdlen; - - wcu = towupper (wc); - mbcdlen = wcrtomb (buf, wcu, &prev_st); - if (BE (mbclen == mbcdlen, 1)) - memcpy (pstr->mbs + byte_idx, buf, mbclen); - else - { - src_idx = byte_idx; - goto offsets_needed; - } - } - else - memcpy (pstr->mbs + byte_idx, - pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen); - pstr->wcs[byte_idx++] = wcu; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - else if (mbclen == (size_t) -1 || mbclen == 0) - { - /* It is an invalid character or '\0'. Just use the byte. */ - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; - pstr->mbs[byte_idx] = ch; - /* And also cast it to wide char. */ - pstr->wcs[byte_idx++] = (wchar_t) ch; - if (BE (mbclen == (size_t) -1, 0)) - pstr->cur_state = prev_st; - } - else - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = byte_idx; - return REG_NOERROR; - } - else - for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;) - { - wchar_t wc; - const char *p; - offsets_needed: - remain_len = end_idx - byte_idx; - prev_st = pstr->cur_state; - if (BE (pstr->trans != NULL, 0)) - { - int i, ch; - - for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) - { - ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i]; - buf[i] = pstr->trans[ch]; - } - p = (const char *) buf; - } - else - p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; - mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state); - if (BE (mbclen + 2 > 2, 1)) - { - wchar_t wcu = wc; - if (iswlower (wc)) - { - size_t mbcdlen; - - wcu = towupper (wc); - mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); - if (BE (mbclen == mbcdlen, 1)) - memcpy (pstr->mbs + byte_idx, buf, mbclen); - else if (mbcdlen != (size_t) -1) - { - size_t i; - - if (byte_idx + mbcdlen > pstr->bufs_len) - { - pstr->cur_state = prev_st; - break; - } - - if (pstr->offsets == NULL) - { - pstr->offsets = re_malloc (int, pstr->bufs_len); - - if (pstr->offsets == NULL) - return REG_ESPACE; - } - if (!pstr->offsets_needed) - { - for (i = 0; i < (size_t) byte_idx; ++i) - pstr->offsets[i] = i; - pstr->offsets_needed = 1; - } - - memcpy (pstr->mbs + byte_idx, buf, mbcdlen); - pstr->wcs[byte_idx] = wcu; - pstr->offsets[byte_idx] = src_idx; - for (i = 1; i < mbcdlen; ++i) - { - pstr->offsets[byte_idx + i] - = src_idx + (i < mbclen ? i : mbclen - 1); - pstr->wcs[byte_idx + i] = WEOF; - } - pstr->len += mbcdlen - mbclen; - if (pstr->raw_stop > src_idx) - pstr->stop += mbcdlen - mbclen; - end_idx = (pstr->bufs_len > pstr->len) - ? pstr->len : pstr->bufs_len; - byte_idx += mbcdlen; - src_idx += mbclen; - continue; - } - else - memcpy (pstr->mbs + byte_idx, p, mbclen); - } - else - memcpy (pstr->mbs + byte_idx, p, mbclen); - - if (BE (pstr->offsets_needed != 0, 0)) - { - size_t i; - for (i = 0; i < mbclen; ++i) - pstr->offsets[byte_idx + i] = src_idx + i; - } - src_idx += mbclen; - - pstr->wcs[byte_idx++] = wcu; - /* Write paddings. */ - for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) - pstr->wcs[byte_idx++] = WEOF; - } - else if (mbclen == (size_t) -1 || mbclen == 0) - { - /* It is an invalid character or '\0'. Just use the byte. */ - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; - - if (BE (pstr->trans != NULL, 0)) - ch = pstr->trans [ch]; - pstr->mbs[byte_idx] = ch; - - if (BE (pstr->offsets_needed != 0, 0)) - pstr->offsets[byte_idx] = src_idx; - ++src_idx; - - /* And also cast it to wide char. */ - pstr->wcs[byte_idx++] = (wchar_t) ch; - if (BE (mbclen == (size_t) -1, 0)) - pstr->cur_state = prev_st; - } - else - { - /* The buffer doesn't have enough space, finish to build. */ - pstr->cur_state = prev_st; - break; - } - } - pstr->valid_len = byte_idx; - pstr->valid_raw_len = src_idx; - return REG_NOERROR; -} - -/* Skip characters until the index becomes greater than NEW_RAW_IDX. - Return the index. */ - -static int -internal_function -re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc) -{ - mbstate_t prev_st; - int rawbuf_idx; - size_t mbclen; - wchar_t wc = WEOF; - - /* Skip the characters which are not necessary to check. */ - for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; - rawbuf_idx < new_raw_idx;) - { - int remain_len; - remain_len = pstr->len - rawbuf_idx; - prev_st = pstr->cur_state; - mbclen = mbrtowc (&wc, (const char *) pstr->raw_mbs + rawbuf_idx, - remain_len, &pstr->cur_state); - if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) - { - /* We treat these cases as a single byte character. */ - if (mbclen == 0 || remain_len == 0) - wc = L'\0'; - else - wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); - mbclen = 1; - pstr->cur_state = prev_st; - } - /* Then proceed the next character. */ - rawbuf_idx += mbclen; - } - *last_wc = (wint_t) wc; - return rawbuf_idx; -} -#endif /* RE_ENABLE_I18N */ - -/* Build the buffer PSTR->MBS, and apply the translation if we need. - This function is used in case of REG_ICASE. */ - -static void -internal_function -build_upper_buffer (re_string_t *pstr) -{ - int char_idx, end_idx; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) - { - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; - if (BE (pstr->trans != NULL, 0)) - ch = pstr->trans[ch]; - if (islower (ch)) - pstr->mbs[char_idx] = toupper (ch); - else - pstr->mbs[char_idx] = ch; - } - pstr->valid_len = char_idx; - pstr->valid_raw_len = char_idx; -} - -/* Apply TRANS to the buffer in PSTR. */ - -static void -internal_function -re_string_translate_buffer (re_string_t *pstr) -{ - int buf_idx, end_idx; - end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; - - for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx) - { - int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx]; - pstr->mbs[buf_idx] = pstr->trans[ch]; - } - - pstr->valid_len = buf_idx; - pstr->valid_raw_len = buf_idx; -} - -/* This function re-construct the buffers. - Concretely, convert to wide character in case of pstr->mb_cur_max > 1, - convert to upper case in case of REG_ICASE, apply translation. */ - -static reg_errcode_t -internal_function -re_string_reconstruct (re_string_t *pstr, int idx, int eflags) -{ - int offset = idx - pstr->raw_mbs_idx; - if (BE (offset < 0, 0)) - { - /* Reset buffer. */ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); -#endif /* RE_ENABLE_I18N */ - pstr->len = pstr->raw_len; - pstr->stop = pstr->raw_stop; - pstr->valid_len = 0; - pstr->raw_mbs_idx = 0; - pstr->valid_raw_len = 0; - pstr->offsets_needed = 0; - pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF - : CONTEXT_NEWLINE | CONTEXT_BEGBUF); - if (!pstr->mbs_allocated) - pstr->mbs = (unsigned char *) pstr->raw_mbs; - offset = idx; - } - - if (BE (offset != 0, 1)) - { - /* Should the already checked characters be kept? */ - if (BE (offset < pstr->valid_raw_len, 1)) - { - /* Yes, move them to the front of the buffer. */ -#ifdef RE_ENABLE_I18N - if (BE (pstr->offsets_needed, 0)) - { - int low = 0, high = pstr->valid_len, mid; - do - { - mid = (high + low) / 2; - if (pstr->offsets[mid] > offset) - high = mid; - else if (pstr->offsets[mid] < offset) - low = mid + 1; - else - break; - } - while (low < high); - if (pstr->offsets[mid] < offset) - ++mid; - pstr->tip_context = re_string_context_at (pstr, mid - 1, - eflags); - /* This can be quite complicated, so handle specially - only the common and easy case where the character with - different length representation of lower and upper - case is present at or after offset. */ - if (pstr->valid_len > offset - && mid == offset && pstr->offsets[mid] == offset) - { - memmove (pstr->wcs, pstr->wcs + offset, - (pstr->valid_len - offset) * sizeof (wint_t)); - memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); - pstr->valid_len -= offset; - pstr->valid_raw_len -= offset; - for (low = 0; low < pstr->valid_len; low++) - pstr->offsets[low] = pstr->offsets[low + offset] - offset; - } - else - { - /* Otherwise, just find out how long the partial multibyte - character at offset is and fill it with WEOF/255. */ - pstr->len = pstr->raw_len - idx + offset; - pstr->stop = pstr->raw_stop - idx + offset; - pstr->offsets_needed = 0; - while (mid > 0 && pstr->offsets[mid - 1] == offset) - --mid; - while (mid < pstr->valid_len) - if (pstr->wcs[mid] != WEOF) - break; - else - ++mid; - if (mid == pstr->valid_len) - pstr->valid_len = 0; - else - { - pstr->valid_len = pstr->offsets[mid] - offset; - if (pstr->valid_len) - { - for (low = 0; low < pstr->valid_len; ++low) - pstr->wcs[low] = WEOF; - memset (pstr->mbs, 255, pstr->valid_len); - } - } - pstr->valid_raw_len = pstr->valid_len; - } - } - else -#endif - { - pstr->tip_context = re_string_context_at (pstr, offset - 1, - eflags); -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - memmove (pstr->wcs, pstr->wcs + offset, - (pstr->valid_len - offset) * sizeof (wint_t)); -#endif /* RE_ENABLE_I18N */ - if (BE (pstr->mbs_allocated, 0)) - memmove (pstr->mbs, pstr->mbs + offset, - pstr->valid_len - offset); - pstr->valid_len -= offset; - pstr->valid_raw_len -= offset; -#if DEBUG - assert (pstr->valid_len > 0); -#endif - } - } - else - { - /* No, skip all characters until IDX. */ - int prev_valid_len = pstr->valid_len; - -#ifdef RE_ENABLE_I18N - if (BE (pstr->offsets_needed, 0)) - { - pstr->len = pstr->raw_len - idx + offset; - pstr->stop = pstr->raw_stop - idx + offset; - pstr->offsets_needed = 0; - } -#endif - pstr->valid_len = 0; -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - int wcs_idx; - wint_t wc = WEOF; - - if (pstr->is_utf8) - { - const unsigned char *raw, *p, *q, *end; - - /* Special case UTF-8. Multi-byte chars start with any - byte other than 0x80 - 0xbf. */ - raw = pstr->raw_mbs + pstr->raw_mbs_idx; - end = raw + (offset - pstr->mb_cur_max); - if (end < pstr->raw_mbs) - end = pstr->raw_mbs; - p = raw + offset - 1; -#ifdef _LIBC - /* We know the wchar_t encoding is UCS4, so for the simple - case, ASCII characters, skip the conversion step. */ - if (isascii (*p) && BE (pstr->trans == NULL, 1)) - { - memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); - /* pstr->valid_len = 0; */ - wc = (wchar_t) *p; - } - else -#endif - for (; p >= end; --p) - if ((*p & 0xc0) != 0x80) - { - mbstate_t cur_state; - wchar_t wc2; - int mlen = raw + pstr->len - p; - unsigned char buf[6]; - size_t mbclen; - - q = p; - if (BE (pstr->trans != NULL, 0)) - { - int i = mlen < 6 ? mlen : 6; - while (--i >= 0) - buf[i] = pstr->trans[p[i]]; - q = buf; - } - /* XXX Don't use mbrtowc, we know which conversion - to use (UTF-8 -> UCS4). */ - memset (&cur_state, 0, sizeof (cur_state)); - mbclen = mbrtowc (&wc2, (const char *) p, mlen, - &cur_state); - if (raw + offset - p <= mbclen - && mbclen < (size_t) -2) - { - memset (&pstr->cur_state, '\0', - sizeof (mbstate_t)); - pstr->valid_len = mbclen - (raw + offset - p); - wc = wc2; - } - break; - } - } - - if (wc == WEOF) - pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; - if (wc == WEOF) - pstr->tip_context - = re_string_context_at (pstr, prev_valid_len - 1, eflags); - else - pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) - && IS_WIDE_WORD_CHAR (wc)) - ? CONTEXT_WORD - : ((IS_WIDE_NEWLINE (wc) - && pstr->newline_anchor) - ? CONTEXT_NEWLINE : 0)); - if (BE (pstr->valid_len, 0)) - { - for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) - pstr->wcs[wcs_idx] = WEOF; - if (pstr->mbs_allocated) - memset (pstr->mbs, 255, pstr->valid_len); - } - pstr->valid_raw_len = pstr->valid_len; - } - else -#endif /* RE_ENABLE_I18N */ - { - int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; - pstr->valid_raw_len = 0; - if (pstr->trans) - c = pstr->trans[c]; - pstr->tip_context = (bitset_contain (pstr->word_char, c) - ? CONTEXT_WORD - : ((IS_NEWLINE (c) && pstr->newline_anchor) - ? CONTEXT_NEWLINE : 0)); - } - } - if (!BE (pstr->mbs_allocated, 0)) - pstr->mbs += offset; - } - pstr->raw_mbs_idx = idx; - pstr->len -= offset; - pstr->stop -= offset; - - /* Then build the buffers. */ -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1) - { - if (pstr->icase) - { - reg_errcode_t ret = build_wcs_upper_buffer (pstr); - if (BE (ret != REG_NOERROR, 0)) - return ret; - } - else - build_wcs_buffer (pstr); - } - else -#endif /* RE_ENABLE_I18N */ - if (BE (pstr->mbs_allocated, 0)) - { - if (pstr->icase) - build_upper_buffer (pstr); - else if (pstr->trans != NULL) - re_string_translate_buffer (pstr); - } - else - pstr->valid_len = pstr->len; - - pstr->cur_idx = 0; - return REG_NOERROR; -} - -static unsigned char -internal_function __attribute ((pure)) -re_string_peek_byte_case (const re_string_t *pstr, int idx) -{ - int ch, off; - - /* Handle the common (easiest) cases first. */ - if (BE (!pstr->mbs_allocated, 1)) - return re_string_peek_byte (pstr, idx); - -#ifdef RE_ENABLE_I18N - if (pstr->mb_cur_max > 1 - && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) - return re_string_peek_byte (pstr, idx); -#endif - - off = pstr->cur_idx + idx; -#ifdef RE_ENABLE_I18N - if (pstr->offsets_needed) - off = pstr->offsets[off]; -#endif - - ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - -#ifdef RE_ENABLE_I18N - /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I - this function returns CAPITAL LETTER I instead of first byte of - DOTLESS SMALL LETTER I. The latter would confuse the parser, - since peek_byte_case doesn't advance cur_idx in any way. */ - if (pstr->offsets_needed && !isascii (ch)) - return re_string_peek_byte (pstr, idx); -#endif - - return ch; -} - -static unsigned char -internal_function __attribute ((pure)) -re_string_fetch_byte_case (re_string_t *pstr) -{ - if (BE (!pstr->mbs_allocated, 1)) - return re_string_fetch_byte (pstr); - -#ifdef RE_ENABLE_I18N - if (pstr->offsets_needed) - { - int off, ch; - - /* For tr_TR.UTF-8 [[:islower:]] there is - [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip - in that case the whole multi-byte character and return - the original letter. On the other side, with - [[: DOTLESS SMALL LETTER I return [[:I, as doing - anything else would complicate things too much. */ - - if (!re_string_first_byte (pstr, pstr->cur_idx)) - return re_string_fetch_byte (pstr); - - off = pstr->offsets[pstr->cur_idx]; - ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; - - if (! isascii (ch)) - return re_string_fetch_byte (pstr); - - re_string_skip_bytes (pstr, - re_string_char_size_at (pstr, pstr->cur_idx)); - return ch; - } -#endif - - return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; -} - -static void -internal_function -re_string_destruct (re_string_t *pstr) -{ -#ifdef RE_ENABLE_I18N - re_free (pstr->wcs); - re_free (pstr->offsets); -#endif /* RE_ENABLE_I18N */ - if (pstr->mbs_allocated) - re_free (pstr->mbs); -} - -/* Return the context at IDX in INPUT. */ - -static unsigned int -internal_function -re_string_context_at (const re_string_t *input, int idx, int eflags) -{ - int c; - if (BE (idx < 0, 0)) - /* In this case, we use the value stored in input->tip_context, - since we can't know the character in input->mbs[-1] here. */ - return input->tip_context; - if (BE (idx == input->len, 0)) - return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF - : CONTEXT_NEWLINE | CONTEXT_ENDBUF); -#ifdef RE_ENABLE_I18N - if (input->mb_cur_max > 1) - { - wint_t wc; - int wc_idx = idx; - while(input->wcs[wc_idx] == WEOF) - { -#ifdef DEBUG - /* It must not happen. */ - assert (wc_idx >= 0); -#endif - --wc_idx; - if (wc_idx < 0) - return input->tip_context; - } - wc = input->wcs[wc_idx]; - if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) - return CONTEXT_WORD; - return (IS_WIDE_NEWLINE (wc) && input->newline_anchor - ? CONTEXT_NEWLINE : 0); - } - else -#endif - { - c = re_string_byte_at (input, idx); - if (bitset_contain (input->word_char, c)) - return CONTEXT_WORD; - return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; - } -} - -/* Functions for set operation. */ - -static reg_errcode_t -internal_function -re_node_set_alloc (re_node_set *set, int size) -{ - set->alloc = size; - set->nelem = 0; - set->elems = re_malloc (int, size); - if (BE (set->elems == NULL, 0)) - return REG_ESPACE; - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -re_node_set_init_1 (re_node_set *set, int elem) -{ - set->alloc = 1; - set->nelem = 1; - set->elems = re_malloc (int, 1); - if (BE (set->elems == NULL, 0)) - { - set->alloc = set->nelem = 0; - return REG_ESPACE; - } - set->elems[0] = elem; - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -re_node_set_init_2 (re_node_set *set, int elem1, int elem2) -{ - set->alloc = 2; - set->elems = re_malloc (int, 2); - if (BE (set->elems == NULL, 0)) - return REG_ESPACE; - if (elem1 == elem2) - { - set->nelem = 1; - set->elems[0] = elem1; - } - else - { - set->nelem = 2; - if (elem1 < elem2) - { - set->elems[0] = elem1; - set->elems[1] = elem2; - } - else - { - set->elems[0] = elem2; - set->elems[1] = elem1; - } - } - return REG_NOERROR; -} - -static reg_errcode_t -internal_function -re_node_set_init_copy (re_node_set *dest, const re_node_set *src) -{ - dest->nelem = src->nelem; - if (src->nelem > 0) - { - dest->alloc = dest->nelem; - dest->elems = re_malloc (int, dest->alloc); - if (BE (dest->elems == NULL, 0)) - { - dest->alloc = dest->nelem = 0; - return REG_ESPACE; - } - memcpy (dest->elems, src->elems, src->nelem * sizeof (int)); - } - else - re_node_set_init_empty (dest); - return REG_NOERROR; -} - -/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. - Note: We assume dest->elems is NULL, when dest->alloc is 0. */ - -static reg_errcode_t -internal_function -re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, - const re_node_set *src2) -{ - int i1, i2, is, id, delta, sbase; - if (src1->nelem == 0 || src2->nelem == 0) - return REG_NOERROR; - - /* We need dest->nelem + 2 * elems_in_intersection; this is a - conservative estimate. */ - if (src1->nelem + src2->nelem + dest->nelem > dest->alloc) - { - int new_alloc = src1->nelem + src2->nelem + dest->alloc; - int *new_elems = re_realloc (dest->elems, int, new_alloc); - if (BE (new_elems == NULL, 0)) - return REG_ESPACE; - dest->elems = new_elems; - dest->alloc = new_alloc; - } - - /* Find the items in the intersection of SRC1 and SRC2, and copy - into the top of DEST those that are not already in DEST itself. */ - sbase = dest->nelem + src1->nelem + src2->nelem; - i1 = src1->nelem - 1; - i2 = src2->nelem - 1; - id = dest->nelem - 1; - for (;;) - { - if (src1->elems[i1] == src2->elems[i2]) - { - /* Try to find the item in DEST. Maybe we could binary search? */ - while (id >= 0 && dest->elems[id] > src1->elems[i1]) - --id; - - if (id < 0 || dest->elems[id] != src1->elems[i1]) - dest->elems[--sbase] = src1->elems[i1]; - - if (--i1 < 0 || --i2 < 0) - break; - } - - /* Lower the highest of the two items. */ - else if (src1->elems[i1] < src2->elems[i2]) - { - if (--i2 < 0) - break; - } - else - { - if (--i1 < 0) - break; - } - } - - id = dest->nelem - 1; - is = dest->nelem + src1->nelem + src2->nelem - 1; - delta = is - sbase + 1; - - /* Now copy. When DELTA becomes zero, the remaining - DEST elements are already in place; this is more or - less the same loop that is in re_node_set_merge. */ - dest->nelem += delta; - if (delta > 0 && id >= 0) - for (;;) - { - if (dest->elems[is] > dest->elems[id]) - { - /* Copy from the top. */ - dest->elems[id + delta--] = dest->elems[is--]; - if (delta == 0) - break; - } - else - { - /* Slide from the bottom. */ - dest->elems[id + delta] = dest->elems[id]; - if (--id < 0) - break; - } - } - - /* Copy remaining SRC elements. */ - memcpy (dest->elems, dest->elems + sbase, delta * sizeof (int)); - - return REG_NOERROR; -} - -/* Calculate the union set of the sets SRC1 and SRC2. And store it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ - -static reg_errcode_t -internal_function -re_node_set_init_union (re_node_set *dest, const re_node_set *src1, - const re_node_set *src2) -{ - int i1, i2, id; - if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0) - { - dest->alloc = src1->nelem + src2->nelem; - dest->elems = re_malloc (int, dest->alloc); - if (BE (dest->elems == NULL, 0)) - return REG_ESPACE; - } - else - { - if (src1 != NULL && src1->nelem > 0) - return re_node_set_init_copy (dest, src1); - else if (src2 != NULL && src2->nelem > 0) - return re_node_set_init_copy (dest, src2); - else - re_node_set_init_empty (dest); - return REG_NOERROR; - } - for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;) - { - if (src1->elems[i1] > src2->elems[i2]) - { - dest->elems[id++] = src2->elems[i2++]; - continue; - } - if (src1->elems[i1] == src2->elems[i2]) - ++i2; - dest->elems[id++] = src1->elems[i1++]; - } - if (i1 < src1->nelem) - { - memcpy (dest->elems + id, src1->elems + i1, - (src1->nelem - i1) * sizeof (int)); - id += src1->nelem - i1; - } - else if (i2 < src2->nelem) - { - memcpy (dest->elems + id, src2->elems + i2, - (src2->nelem - i2) * sizeof (int)); - id += src2->nelem - i2; - } - dest->nelem = id; - return REG_NOERROR; -} - -/* Calculate the union set of the sets DEST and SRC. And store it to - DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ - -static reg_errcode_t -internal_function -re_node_set_merge (re_node_set *dest, const re_node_set *src) -{ - int is, id, sbase, delta; - if (src == NULL || src->nelem == 0) - return REG_NOERROR; - if (dest->alloc < 2 * src->nelem + dest->nelem) - { - int new_alloc = 2 * (src->nelem + dest->alloc); - int *new_buffer = re_realloc (dest->elems, int, new_alloc); - if (BE (new_buffer == NULL, 0)) - return REG_ESPACE; - dest->elems = new_buffer; - dest->alloc = new_alloc; - } - - if (BE (dest->nelem == 0, 0)) - { - dest->nelem = src->nelem; - memcpy (dest->elems, src->elems, src->nelem * sizeof (int)); - return REG_NOERROR; - } - - /* Copy into the top of DEST the items of SRC that are not - found in DEST. Maybe we could binary search in DEST? */ - for (sbase = dest->nelem + 2 * src->nelem, - is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; ) - { - if (dest->elems[id] == src->elems[is]) - is--, id--; - else if (dest->elems[id] < src->elems[is]) - dest->elems[--sbase] = src->elems[is--]; - else /* if (dest->elems[id] > src->elems[is]) */ - --id; - } - - if (is >= 0) - { - /* If DEST is exhausted, the remaining items of SRC must be unique. */ - sbase -= is + 1; - memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (int)); - } - - id = dest->nelem - 1; - is = dest->nelem + 2 * src->nelem - 1; - delta = is - sbase + 1; - if (delta == 0) - return REG_NOERROR; - - /* Now copy. When DELTA becomes zero, the remaining - DEST elements are already in place. */ - dest->nelem += delta; - for (;;) - { - if (dest->elems[is] > dest->elems[id]) - { - /* Copy from the top. */ - dest->elems[id + delta--] = dest->elems[is--]; - if (delta == 0) - break; - } - else - { - /* Slide from the bottom. */ - dest->elems[id + delta] = dest->elems[id]; - if (--id < 0) - { - /* Copy remaining SRC elements. */ - memcpy (dest->elems, dest->elems + sbase, - delta * sizeof (int)); - break; - } - } - } - - return REG_NOERROR; -} - -/* Insert the new element ELEM to the re_node_set* SET. - SET should not already have ELEM. - return -1 if an error is occured, return 1 otherwise. */ - -static int -internal_function -re_node_set_insert (re_node_set *set, int elem) -{ - int idx; - /* In case the set is empty. */ - if (set->alloc == 0) - { - if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1)) - return 1; - else - return -1; - } - - if (BE (set->nelem, 0) == 0) - { - /* We already guaranteed above that set->alloc != 0. */ - set->elems[0] = elem; - ++set->nelem; - return 1; - } - - /* Realloc if we need. */ - if (set->alloc == set->nelem) - { - int *new_elems; - set->alloc = set->alloc * 2; - new_elems = re_realloc (set->elems, int, set->alloc); - if (BE (new_elems == NULL, 0)) - return -1; - set->elems = new_elems; - } - - /* Move the elements which follows the new element. Test the - first element separately to skip a check in the inner loop. */ - if (elem < set->elems[0]) - { - idx = 0; - for (idx = set->nelem; idx > 0; idx--) - set->elems[idx] = set->elems[idx - 1]; - } - else - { - for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) - set->elems[idx] = set->elems[idx - 1]; - } - - /* Insert the new element. */ - set->elems[idx] = elem; - ++set->nelem; - return 1; -} - -/* Insert the new element ELEM to the re_node_set* SET. - SET should not already have any element greater than or equal to ELEM. - Return -1 if an error is occured, return 1 otherwise. */ - -static int -internal_function -re_node_set_insert_last (re_node_set *set, int elem) -{ - /* Realloc if we need. */ - if (set->alloc == set->nelem) - { - int *new_elems; - set->alloc = (set->alloc + 1) * 2; - new_elems = re_realloc (set->elems, int, set->alloc); - if (BE (new_elems == NULL, 0)) - return -1; - set->elems = new_elems; - } - - /* Insert the new element. */ - set->elems[set->nelem++] = elem; - return 1; -} - -/* Compare two node sets SET1 and SET2. - return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */ - -static int -internal_function __attribute ((pure)) -re_node_set_compare (const re_node_set *set1, const re_node_set *set2) -{ - int i; - if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) - return 0; - for (i = set1->nelem ; --i >= 0 ; ) - if (set1->elems[i] != set2->elems[i]) - return 0; - return 1; -} - -/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ - -static int -internal_function __attribute ((pure)) -re_node_set_contains (const re_node_set *set, int elem) -{ - unsigned int idx, right, mid; - if (set->nelem <= 0) - return 0; - - /* Binary search the element. */ - idx = 0; - right = set->nelem - 1; - while (idx < right) - { - mid = (idx + right) / 2; - if (set->elems[mid] < elem) - idx = mid + 1; - else - right = mid; - } - return set->elems[idx] == elem ? idx + 1 : 0; -} - -static void -internal_function -re_node_set_remove_at (re_node_set *set, int idx) -{ - if (idx < 0 || idx >= set->nelem) - return; - --set->nelem; - for (; idx < set->nelem; idx++) - set->elems[idx] = set->elems[idx + 1]; -} - - -/* Add the token TOKEN to dfa->nodes, and return the index of the token. - Or return -1, if an error will be occured. */ - -static int -internal_function -re_dfa_add_node (re_dfa_t *dfa, re_token_t token) -{ - int type = token.type; - if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) - { - size_t new_nodes_alloc = dfa->nodes_alloc * 2; - int *new_nexts, *new_indices; - re_node_set *new_edests, *new_eclosures; - re_token_t *new_nodes; - - /* Avoid overflows. */ - if (BE (new_nodes_alloc < dfa->nodes_alloc, 0)) - return -1; - - new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); - if (BE (new_nodes == NULL, 0)) - return -1; - dfa->nodes = new_nodes; - new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc); - new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc); - new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); - new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); - if (BE (new_nexts == NULL || new_indices == NULL - || new_edests == NULL || new_eclosures == NULL, 0)) - return -1; - dfa->nexts = new_nexts; - dfa->org_indices = new_indices; - dfa->edests = new_edests; - dfa->eclosures = new_eclosures; - dfa->nodes_alloc = new_nodes_alloc; - } - dfa->nodes[dfa->nodes_len] = token; - dfa->nodes[dfa->nodes_len].constraint = 0; -#ifdef RE_ENABLE_I18N - dfa->nodes[dfa->nodes_len].accept_mb = - (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET; -#endif - dfa->nexts[dfa->nodes_len] = -1; - re_node_set_init_empty (dfa->edests + dfa->nodes_len); - re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); - return dfa->nodes_len++; -} - -static inline unsigned int -internal_function -calc_state_hash (const re_node_set *nodes, unsigned int context) -{ - unsigned int hash = nodes->nelem + context; - int i; - for (i = 0 ; i < nodes->nelem ; i++) - hash += nodes->elems[i]; - return hash; -} - -/* Search for the state whose node_set is equivalent to NODES. - Return the pointer to the state, if we found it in the DFA. - Otherwise create the new one and return it. In case of an error - return NULL and set the error code in ERR. - Note: - We assume NULL as the invalid state, then it is possible that - return value is NULL and ERR is REG_NOERROR. - - We never return non-NULL value in case of any errors, it is for - optimization. */ - -static re_dfastate_t * -internal_function -re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, - const re_node_set *nodes) -{ - unsigned int hash; - re_dfastate_t *new_state; - struct re_state_table_entry *spot; - int i; - if (BE (nodes->nelem == 0, 0)) - { - *err = REG_NOERROR; - return NULL; - } - hash = calc_state_hash (nodes, 0); - spot = dfa->state_table + (hash & dfa->state_hash_mask); - - for (i = 0 ; i < spot->num ; i++) - { - re_dfastate_t *state = spot->array[i]; - if (hash != state->hash) - continue; - if (re_node_set_compare (&state->nodes, nodes)) - return state; - } - - /* There are no appropriate state in the dfa, create the new one. */ - new_state = create_ci_newstate (dfa, nodes, hash); - if (BE (new_state == NULL, 0)) - *err = REG_ESPACE; - - return new_state; -} - -/* Search for the state whose node_set is equivalent to NODES and - whose context is equivalent to CONTEXT. - Return the pointer to the state, if we found it in the DFA. - Otherwise create the new one and return it. In case of an error - return NULL and set the error code in ERR. - Note: - We assume NULL as the invalid state, then it is possible that - return value is NULL and ERR is REG_NOERROR. - - We never return non-NULL value in case of any errors, it is for - optimization. */ - -static re_dfastate_t * -internal_function -re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, - const re_node_set *nodes, unsigned int context) -{ - unsigned int hash; - re_dfastate_t *new_state; - struct re_state_table_entry *spot; - int i; - if (nodes->nelem == 0) - { - *err = REG_NOERROR; - return NULL; - } - hash = calc_state_hash (nodes, context); - spot = dfa->state_table + (hash & dfa->state_hash_mask); - - for (i = 0 ; i < spot->num ; i++) - { - re_dfastate_t *state = spot->array[i]; - if (state->hash == hash - && state->context == context - && re_node_set_compare (state->entrance_nodes, nodes)) - return state; - } - /* There are no appropriate state in `dfa', create the new one. */ - new_state = create_cd_newstate (dfa, nodes, context, hash); - if (BE (new_state == NULL, 0)) - *err = REG_ESPACE; - - return new_state; -} - -/* Finish initialization of the new state NEWSTATE, and using its hash value - HASH put in the appropriate bucket of DFA's state table. Return value - indicates the error code if failed. */ - -static reg_errcode_t -register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, - unsigned int hash) -{ - struct re_state_table_entry *spot; - reg_errcode_t err; - int i; - - newstate->hash = hash; - err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); - if (BE (err != REG_NOERROR, 0)) - return REG_ESPACE; - for (i = 0; i < newstate->nodes.nelem; i++) - { - int elem = newstate->nodes.elems[i]; - if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) - re_node_set_insert_last (&newstate->non_eps_nodes, elem); - } - - spot = dfa->state_table + (hash & dfa->state_hash_mask); - if (BE (spot->alloc <= spot->num, 0)) - { - int new_alloc = 2 * spot->num + 2; - re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, - new_alloc); - if (BE (new_array == NULL, 0)) - return REG_ESPACE; - spot->array = new_array; - spot->alloc = new_alloc; - } - spot->array[spot->num++] = newstate; - return REG_NOERROR; -} - -static void -free_state (re_dfastate_t *state) -{ - re_node_set_free (&state->non_eps_nodes); - re_node_set_free (&state->inveclosure); - if (state->entrance_nodes != &state->nodes) - { - re_node_set_free (state->entrance_nodes); - re_free (state->entrance_nodes); - } - re_node_set_free (&state->nodes); - re_free (state->word_trtable); - re_free (state->trtable); - re_free (state); -} - -/* Create the new state which is independ of contexts. - Return the new state if succeeded, otherwise return NULL. */ - -static re_dfastate_t * -internal_function -create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, - unsigned int hash) -{ - int i; - reg_errcode_t err; - re_dfastate_t *newstate; - - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); - if (BE (newstate == NULL, 0)) - return NULL; - err = re_node_set_init_copy (&newstate->nodes, nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_free (newstate); - return NULL; - } - - newstate->entrance_nodes = &newstate->nodes; - for (i = 0 ; i < nodes->nelem ; i++) - { - re_token_t *node = dfa->nodes + nodes->elems[i]; - re_token_type_t type = node->type; - if (type == CHARACTER && !node->constraint) - continue; -#ifdef RE_ENABLE_I18N - newstate->accept_mb |= node->accept_mb; -#endif /* RE_ENABLE_I18N */ - - /* If the state has the halt node, the state is a halt state. */ - if (type == END_OF_RE) - newstate->halt = 1; - else if (type == OP_BACK_REF) - newstate->has_backref = 1; - else if (type == ANCHOR || node->constraint) - newstate->has_constraint = 1; - } - err = register_state (dfa, newstate, hash); - if (BE (err != REG_NOERROR, 0)) - { - free_state (newstate); - newstate = NULL; - } - return newstate; -} - -/* Create the new state which is depend on the context CONTEXT. - Return the new state if succeeded, otherwise return NULL. */ - -static re_dfastate_t * -internal_function -create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, - unsigned int context, unsigned int hash) -{ - int i, nctx_nodes = 0; - reg_errcode_t err; - re_dfastate_t *newstate; - - newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); - if (BE (newstate == NULL, 0)) - return NULL; - err = re_node_set_init_copy (&newstate->nodes, nodes); - if (BE (err != REG_NOERROR, 0)) - { - re_free (newstate); - return NULL; - } - - newstate->context = context; - newstate->entrance_nodes = &newstate->nodes; - - for (i = 0 ; i < nodes->nelem ; i++) - { - unsigned int constraint = 0; - re_token_t *node = dfa->nodes + nodes->elems[i]; - re_token_type_t type = node->type; - if (node->constraint) - constraint = node->constraint; - - if (type == CHARACTER && !constraint) - continue; -#ifdef RE_ENABLE_I18N - newstate->accept_mb |= node->accept_mb; -#endif /* RE_ENABLE_I18N */ - - /* If the state has the halt node, the state is a halt state. */ - if (type == END_OF_RE) - newstate->halt = 1; - else if (type == OP_BACK_REF) - newstate->has_backref = 1; - else if (type == ANCHOR) - constraint = node->opr.ctx_type; - - if (constraint) - { - if (newstate->entrance_nodes == &newstate->nodes) - { - newstate->entrance_nodes = re_malloc (re_node_set, 1); - if (BE (newstate->entrance_nodes == NULL, 0)) - { - free_state (newstate); - return NULL; - } - re_node_set_init_copy (newstate->entrance_nodes, nodes); - nctx_nodes = 0; - newstate->has_constraint = 1; - } - - if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context)) - { - re_node_set_remove_at (&newstate->nodes, i - nctx_nodes); - ++nctx_nodes; - } - } - } - err = register_state (dfa, newstate, hash); - if (BE (err != REG_NOERROR, 0)) - { - free_state (newstate); - newstate = NULL; - } - return newstate; -} diff -Nru eresi-0.8a25/libregex/.svn/text-base/regex_internal.h.svn-base eresi-0.0.20110516/libregex/.svn/text-base/regex_internal.h.svn-base --- eresi-0.8a25/libregex/.svn/text-base/regex_internal.h.svn-base 2008-04-06 23:15:47.000000000 +0000 +++ eresi-0.0.20110516/libregex/.svn/text-base/regex_internal.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,763 +0,0 @@ -/* Extended regular expression matching and search library. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Isamu Hasegawa . - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#ifndef _REGEX_INTERNAL_H -#define _REGEX_INTERNAL_H 1 - -#include -#include -#include -#include -#include - -#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC -# include -#endif -#if defined HAVE_LOCALE_H || defined _LIBC -# include -#endif -#if defined HAVE_WCHAR_H || defined _LIBC -# include -#endif /* HAVE_WCHAR_H || _LIBC */ -#if defined HAVE_WCTYPE_H || defined _LIBC -# include -#endif /* HAVE_WCTYPE_H || _LIBC */ -#if defined HAVE_STDBOOL_H || defined _LIBC -# include -#endif /* HAVE_STDBOOL_H || _LIBC */ -#if defined HAVE_STDINT_H || defined _LIBC -# include -#endif /* HAVE_STDINT_H || _LIBC */ -#if defined _LIBC -# include -#else -# define __libc_lock_define(CLASS,NAME) -# define __libc_lock_init(NAME) do { } while (0) -# define __libc_lock_lock(NAME) do { } while (0) -# define __libc_lock_unlock(NAME) do { } while (0) -#endif - -/* In case that the system doesn't have isblank(). */ -#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank -# define isblank(ch) ((ch) == ' ' || (ch) == '\t') -#endif - -#ifdef _LIBC -# ifndef _RE_DEFINE_LOCALE_FUNCTIONS -# define _RE_DEFINE_LOCALE_FUNCTIONS 1 -# include -# include -# include -# endif -#endif - -/* This is for other GNU distributions with internationalized messages. */ -#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC -# include -# ifdef _LIBC -# undef gettext -# define gettext(msgid) \ - INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES) -# endif -#else -# define gettext(msgid) (msgid) -#endif - -#ifndef gettext_noop -/* This define is so xgettext can find the internationalizable - strings. */ -# define gettext_noop(String) String -#endif - -/* For loser systems without the definition. */ -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t) -1) -#endif - -#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC -# define RE_ENABLE_I18N -#endif - -#if __GNUC__ >= 3 -# define BE(expr, val) __builtin_expect (expr, val) -#else -# define BE(expr, val) (expr) -# define inline -#endif - -/* Number of single byte character. */ -#define SBC_MAX 256 - -#define COLL_ELEM_LEN_MAX 8 - -/* The character which represents newline. */ -#define NEWLINE_CHAR '\n' -#define WIDE_NEWLINE_CHAR L'\n' - -/* Rename to standard API for using out of glibc. */ -#ifndef _LIBC -# define __wctype wctype -# define __iswctype iswctype -# define __btowc btowc -# define __mempcpy mempcpy -# define __wcrtomb wcrtomb -# define __regfree regfree -# define attribute_hidden -#endif /* not _LIBC */ - -#ifdef __GNUC__ -# define __attribute(arg) __attribute__ (arg) -#else -# define __attribute(arg) -#endif - -extern const char __re_error_msgid[] attribute_hidden; -extern const size_t __re_error_msgid_idx[] attribute_hidden; - -/* An integer used to represent a set of bits. It must be unsigned, - and must be at least as wide as unsigned int. */ -typedef unsigned long int bitset_word_t; -/* All bits set in a bitset_word_t. */ -#define BITSET_WORD_MAX ULONG_MAX -/* Number of bits in a bitset_word_t. */ -#define BITSET_WORD_BITS (sizeof (bitset_word_t) * CHAR_BIT) -/* Number of bitset_word_t in a bit_set. */ -#define BITSET_WORDS (SBC_MAX / BITSET_WORD_BITS) -typedef bitset_word_t bitset_t[BITSET_WORDS]; -typedef bitset_word_t *re_bitset_ptr_t; -typedef const bitset_word_t *re_const_bitset_ptr_t; - -#define bitset_set(set,i) \ - (set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS) -#define bitset_clear(set,i) \ - (set[i / BITSET_WORD_BITS] &= ~((bitset_word_t) 1 << i % BITSET_WORD_BITS)) -#define bitset_contain(set,i) \ - (set[i / BITSET_WORD_BITS] & ((bitset_word_t) 1 << i % BITSET_WORD_BITS)) -#define bitset_empty(set) memset (set, '\0', sizeof (bitset_t)) -#define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t)) -#define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t)) - -#define PREV_WORD_CONSTRAINT 0x0001 -#define PREV_NOTWORD_CONSTRAINT 0x0002 -#define NEXT_WORD_CONSTRAINT 0x0004 -#define NEXT_NOTWORD_CONSTRAINT 0x0008 -#define PREV_NEWLINE_CONSTRAINT 0x0010 -#define NEXT_NEWLINE_CONSTRAINT 0x0020 -#define PREV_BEGBUF_CONSTRAINT 0x0040 -#define NEXT_ENDBUF_CONSTRAINT 0x0080 -#define WORD_DELIM_CONSTRAINT 0x0100 -#define NOT_WORD_DELIM_CONSTRAINT 0x0200 - -typedef enum -{ - INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, - WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, - WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, - INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, - LINE_FIRST = PREV_NEWLINE_CONSTRAINT, - LINE_LAST = NEXT_NEWLINE_CONSTRAINT, - BUF_FIRST = PREV_BEGBUF_CONSTRAINT, - BUF_LAST = NEXT_ENDBUF_CONSTRAINT, - WORD_DELIM = WORD_DELIM_CONSTRAINT, - NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT -} re_context_type; - -typedef struct -{ - int alloc; - int nelem; - int *elems; -} re_node_set; - -typedef enum -{ - NON_TYPE = 0, - - /* Node type, These are used by token, node, tree. */ - CHARACTER = 1, - END_OF_RE = 2, - SIMPLE_BRACKET = 3, - OP_BACK_REF = 4, - OP_PERIOD = 5, -#ifdef RE_ENABLE_I18N - COMPLEX_BRACKET = 6, - OP_UTF8_PERIOD = 7, -#endif /* RE_ENABLE_I18N */ - - /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used - when the debugger shows values of this enum type. */ -#define EPSILON_BIT 8 - OP_OPEN_SUBEXP = EPSILON_BIT | 0, - OP_CLOSE_SUBEXP = EPSILON_BIT | 1, - OP_ALT = EPSILON_BIT | 2, - OP_DUP_ASTERISK = EPSILON_BIT | 3, - ANCHOR = EPSILON_BIT | 4, - - /* Tree type, these are used only by tree. */ - CONCAT = 16, - SUBEXP = 17, - - /* Token type, these are used only by token. */ - OP_DUP_PLUS = 18, - OP_DUP_QUESTION, - OP_OPEN_BRACKET, - OP_CLOSE_BRACKET, - OP_CHARSET_RANGE, - OP_OPEN_DUP_NUM, - OP_CLOSE_DUP_NUM, - OP_NON_MATCH_LIST, - OP_OPEN_COLL_ELEM, - OP_CLOSE_COLL_ELEM, - OP_OPEN_EQUIV_CLASS, - OP_CLOSE_EQUIV_CLASS, - OP_OPEN_CHAR_CLASS, - OP_CLOSE_CHAR_CLASS, - OP_WORD, - OP_NOTWORD, - OP_SPACE, - OP_NOTSPACE, - BACK_SLASH - -} re_token_type_t; - -#ifdef RE_ENABLE_I18N -typedef struct -{ - /* Multibyte characters. */ - wchar_t *mbchars; - - /* Collating symbols. */ -# ifdef _LIBC - int32_t *coll_syms; -# endif - - /* Equivalence classes. */ -# ifdef _LIBC - int32_t *equiv_classes; -# endif - - /* Range expressions. */ -# ifdef _LIBC - uint32_t *range_starts; - uint32_t *range_ends; -# else /* not _LIBC */ - wchar_t *range_starts; - wchar_t *range_ends; -# endif /* not _LIBC */ - - /* Character classes. */ - wctype_t *char_classes; - - /* If this character set is the non-matching list. */ - unsigned int non_match : 1; - - /* # of multibyte characters. */ - int nmbchars; - - /* # of collating symbols. */ - int ncoll_syms; - - /* # of equivalence classes. */ - int nequiv_classes; - - /* # of range expressions. */ - int nranges; - - /* # of character classes. */ - int nchar_classes; -} re_charset_t; -#endif /* RE_ENABLE_I18N */ - -typedef struct -{ - union - { - unsigned char c; /* for CHARACTER */ - re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ -#ifdef RE_ENABLE_I18N - re_charset_t *mbcset; /* for COMPLEX_BRACKET */ -#endif /* RE_ENABLE_I18N */ - int idx; /* for BACK_REF */ - re_context_type ctx_type; /* for ANCHOR */ - } opr; -#if __GNUC__ >= 2 - re_token_type_t type : 8; -#else - re_token_type_t type; -#endif - unsigned int constraint : 10; /* context constraint */ - unsigned int duplicated : 1; - unsigned int opt_subexp : 1; -#ifdef RE_ENABLE_I18N - unsigned int accept_mb : 1; - /* These 2 bits can be moved into the union if needed (e.g. if running out - of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ - unsigned int mb_partial : 1; -#endif - unsigned int word_char : 1; -} re_token_t; - -#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) - -struct re_string_t -{ - /* Indicate the raw buffer which is the original string passed as an - argument of regexec(), re_search(), etc.. */ - const unsigned char *raw_mbs; - /* Store the multibyte string. In case of "case insensitive mode" like - REG_ICASE, upper cases of the string are stored, otherwise MBS points - the same address that RAW_MBS points. */ - unsigned char *mbs; -#ifdef RE_ENABLE_I18N - /* Store the wide character string which is corresponding to MBS. */ - wint_t *wcs; - int *offsets; - mbstate_t cur_state; -#endif - /* Index in RAW_MBS. Each character mbs[i] corresponds to - raw_mbs[raw_mbs_idx + i]. */ - int raw_mbs_idx; - /* The length of the valid characters in the buffers. */ - int valid_len; - /* The corresponding number of bytes in raw_mbs array. */ - int valid_raw_len; - /* The length of the buffers MBS and WCS. */ - int bufs_len; - /* The index in MBS, which is updated by re_string_fetch_byte. */ - int cur_idx; - /* length of RAW_MBS array. */ - int raw_len; - /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ - int len; - /* End of the buffer may be shorter than its length in the cases such - as re_match_2, re_search_2. Then, we use STOP for end of the buffer - instead of LEN. */ - int raw_stop; - /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ - int stop; - - /* The context of mbs[0]. We store the context independently, since - the context of mbs[0] may be different from raw_mbs[0], which is - the beginning of the input string. */ - unsigned int tip_context; - /* The translation passed as a part of an argument of re_compile_pattern. */ - RE_TRANSLATE_TYPE trans; - /* Copy of re_dfa_t's word_char. */ - re_const_bitset_ptr_t word_char; - /* 1 if REG_ICASE. */ - unsigned char icase; - unsigned char is_utf8; - unsigned char map_notascii; - unsigned char mbs_allocated; - unsigned char offsets_needed; - unsigned char newline_anchor; - unsigned char word_ops_used; - int mb_cur_max; -}; -typedef struct re_string_t re_string_t; - - -struct re_dfa_t; -typedef struct re_dfa_t re_dfa_t; - -#ifndef _LIBC -# ifdef __i386__ -# define internal_function __attribute ((regparm (3), stdcall)) -# else -# define internal_function -# endif -#endif - -static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, - int new_buf_len) - internal_function; -#ifdef RE_ENABLE_I18N -static void build_wcs_buffer (re_string_t *pstr) internal_function; -static int build_wcs_upper_buffer (re_string_t *pstr) internal_function; -#endif /* RE_ENABLE_I18N */ -static void build_upper_buffer (re_string_t *pstr) internal_function; -static void re_string_translate_buffer (re_string_t *pstr) internal_function; -static unsigned int re_string_context_at (const re_string_t *input, int idx, - int eflags) - internal_function __attribute ((pure)); -#define re_string_peek_byte(pstr, offset) \ - ((pstr)->mbs[(pstr)->cur_idx + offset]) -#define re_string_fetch_byte(pstr) \ - ((pstr)->mbs[(pstr)->cur_idx++]) -#define re_string_first_byte(pstr, idx) \ - ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) -#define re_string_is_single_byte_char(pstr, idx) \ - ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ - || (pstr)->wcs[(idx) + 1] != WEOF)) -#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) -#define re_string_cur_idx(pstr) ((pstr)->cur_idx) -#define re_string_get_buffer(pstr) ((pstr)->mbs) -#define re_string_length(pstr) ((pstr)->len) -#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) -#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) -#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) - -#include - -#ifndef _LIBC -# if HAVE_ALLOCA -/* The OS usually guarantees only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - allocate anything larger than 4096 bytes. Also care for the possibility - of a few compiler-allocated temporary stack slots. */ -# define __libc_use_alloca(n) ((n) < 4032) -# else -/* alloca is implemented with malloc, so just use malloc. */ -# define __libc_use_alloca(n) 0 -# endif -#endif - -#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) -#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) -#define re_free(p) free (p) - -struct bin_tree_t -{ - struct bin_tree_t *parent; - struct bin_tree_t *left; - struct bin_tree_t *right; - struct bin_tree_t *first; - struct bin_tree_t *next; - - re_token_t token; - - /* `node_idx' is the index in dfa->nodes, if `type' == 0. - Otherwise `type' indicate the type of this node. */ - int node_idx; -}; -typedef struct bin_tree_t bin_tree_t; - -#define BIN_TREE_STORAGE_SIZE \ - ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) - -struct bin_tree_storage_t -{ - struct bin_tree_storage_t *next; - bin_tree_t data[BIN_TREE_STORAGE_SIZE]; -}; -typedef struct bin_tree_storage_t bin_tree_storage_t; - -#define CONTEXT_WORD 1 -#define CONTEXT_NEWLINE (CONTEXT_WORD << 1) -#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) -#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) - -#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) -#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) -#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) -#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) -#define IS_ORDINARY_CONTEXT(c) ((c) == 0) - -#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') -#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) -#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') -#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) - -#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ - ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ - || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ - || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ - || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) - -#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ - ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ - || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ - || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ - || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) - -struct re_dfastate_t -{ - unsigned int hash; - re_node_set nodes; - re_node_set non_eps_nodes; - re_node_set inveclosure; - re_node_set *entrance_nodes; - struct re_dfastate_t **trtable, **word_trtable; - unsigned int context : 4; - unsigned int halt : 1; - /* If this state can accept `multi byte'. - Note that we refer to multibyte characters, and multi character - collating elements as `multi byte'. */ - unsigned int accept_mb : 1; - /* If this state has backreference node(s). */ - unsigned int has_backref : 1; - unsigned int has_constraint : 1; -}; -typedef struct re_dfastate_t re_dfastate_t; - -struct re_state_table_entry -{ - int num; - int alloc; - re_dfastate_t **array; -}; - -/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ - -typedef struct -{ - int next_idx; - int alloc; - re_dfastate_t **array; -} state_array_t; - -/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ - -typedef struct -{ - int node; - int str_idx; /* The position NODE match at. */ - state_array_t path; -} re_sub_match_last_t; - -/* Store information about the node NODE whose type is OP_OPEN_SUBEXP. - And information about the node, whose type is OP_CLOSE_SUBEXP, - corresponding to NODE is stored in LASTS. */ - -typedef struct -{ - int str_idx; - int node; - state_array_t *path; - int alasts; /* Allocation size of LASTS. */ - int nlasts; /* The number of LASTS. */ - re_sub_match_last_t **lasts; -} re_sub_match_top_t; - -struct re_backref_cache_entry -{ - int node; - int str_idx; - int subexp_from; - int subexp_to; - char more; - char unused; - unsigned short int eps_reachable_subexps_map; -}; - -typedef struct -{ - /* The string object corresponding to the input string. */ - re_string_t input; -#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) - const re_dfa_t *const dfa; -#else - const re_dfa_t *dfa; -#endif - /* EFLAGS of the argument of regexec. */ - int eflags; - /* Where the matching ends. */ - int match_last; - int last_node; - /* The state log used by the matcher. */ - re_dfastate_t **state_log; - int state_log_top; - /* Back reference cache. */ - int nbkref_ents; - int abkref_ents; - struct re_backref_cache_entry *bkref_ents; - int max_mb_elem_len; - int nsub_tops; - int asub_tops; - re_sub_match_top_t **sub_tops; -} re_match_context_t; - -typedef struct -{ - re_dfastate_t **sifted_states; - re_dfastate_t **limited_states; - int last_node; - int last_str_idx; - re_node_set limits; -} re_sift_context_t; - -struct re_fail_stack_ent_t -{ - int idx; - int node; - regmatch_t *regs; - re_node_set eps_via_nodes; -}; - -struct re_fail_stack_t -{ - int num; - int alloc; - struct re_fail_stack_ent_t *stack; -}; - -struct re_dfa_t -{ - re_token_t *nodes; - size_t nodes_alloc; - size_t nodes_len; - int *nexts; - int *org_indices; - re_node_set *edests; - re_node_set *eclosures; - re_node_set *inveclosures; - struct re_state_table_entry *state_table; - re_dfastate_t *init_state; - re_dfastate_t *init_state_word; - re_dfastate_t *init_state_nl; - re_dfastate_t *init_state_begbuf; - bin_tree_t *str_tree; - bin_tree_storage_t *str_tree_storage; - re_bitset_ptr_t sb_char; - int str_tree_storage_idx; - - /* number of subexpressions `re_nsub' is in regex_t. */ - unsigned int state_hash_mask; - int init_node; - int nbackref; /* The number of backreference in this dfa. */ - - /* Bitmap expressing which backreference is used. */ - bitset_word_t used_bkref_map; - bitset_word_t completed_bkref_map; - - unsigned int has_plural_match : 1; - /* If this dfa has "multibyte node", which is a backreference or - a node which can accept multibyte character or multi character - collating element. */ - unsigned int has_mb_node : 1; - unsigned int is_utf8 : 1; - unsigned int map_notascii : 1; - unsigned int word_ops_used : 1; - int mb_cur_max; - bitset_t word_char; - reg_syntax_t syntax; - int *subexp_map; -#ifdef DEBUG - char* re_str; -#endif - __libc_lock_define (, lock) -}; - -#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) -#define re_node_set_remove(set,id) \ - (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) -#define re_node_set_empty(p) ((p)->nelem = 0) -#define re_node_set_free(set) re_free ((set)->elems) - - -typedef enum -{ - SB_CHAR, - MB_CHAR, - EQUIV_CLASS, - COLL_SYM, - CHAR_CLASS -} bracket_elem_type; - -typedef struct -{ - bracket_elem_type type; - union - { - unsigned char ch; - unsigned char *name; - wchar_t wch; - } opr; -} bracket_elem_t; - - -/* Inline functions for bitset operation. */ -static inline void -bitset_not (bitset_t set) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) - set[bitset_i] = ~set[bitset_i]; -} - -static inline void -bitset_merge (bitset_t dest, const bitset_t src) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) - dest[bitset_i] |= src[bitset_i]; -} - -static inline void -bitset_mask (bitset_t dest, const bitset_t src) -{ - int bitset_i; - for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) - dest[bitset_i] &= src[bitset_i]; -} - -#ifdef RE_ENABLE_I18N -/* Inline functions for re_string. */ -static inline int -internal_function __attribute ((pure)) -re_string_char_size_at (const re_string_t *pstr, int idx) -{ - int byte_idx; - if (pstr->mb_cur_max == 1) - return 1; - for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) - if (pstr->wcs[idx + byte_idx] != WEOF) - break; - return byte_idx; -} - -static inline wint_t -internal_function __attribute ((pure)) -re_string_wchar_at (const re_string_t *pstr, int idx) -{ - if (pstr->mb_cur_max == 1) - return (wint_t) pstr->mbs[idx]; - return (wint_t) pstr->wcs[idx]; -} - -static int -internal_function __attribute ((pure)) -re_string_elem_size_at (const re_string_t *pstr, int idx) -{ -# ifdef _LIBC - const unsigned char *p, *extra; - const int32_t *table, *indirect; - int32_t tmp; -# include - uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); - - if (nrules != 0) - { - table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); - extra = (const unsigned char *) - _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); - indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, - _NL_COLLATE_INDIRECTMB); - p = pstr->mbs + idx; - tmp = findidx (&p); - return p - pstr->mbs - idx; - } - else -# endif /* _LIBC */ - return 1; -} -#endif /* RE_ENABLE_I18N */ - -#endif /* _REGEX_INTERNAL_H */ diff -Nru eresi-0.8a25/librevm/api/asmproc.c eresi-0.0.20110516/librevm/api/asmproc.c --- eresi-0.8a25/librevm/api/asmproc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/asmproc.c 2011-05-16 11:34:12.000000000 +0000 @@ -0,0 +1,55 @@ +/** +* @file librevm/api/asmproc.c + * @ingroup librevm + * Author: jfv + * + * $Id: asmproc.c 1397 2009-09-13 02:19:08Z may $ + * + */ +#include "revm.h" + +/** + * Synchronise the job asm_processor with the good architecture + * @ingroup librevm + */ +void revm_proc_init() +{ + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->curfile) + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); + + /* Init proc */ + if (!world.curjob->proc) + { + switch (elfsh_get_arch(world.curjob->curfile->hdr)) + { + case EM_386: + world.curjob->proc = &world.proc_ia32; + break; + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + world.curjob->proc = &world.proc_sparc; + break; + case EM_MIPS: + case EM_MIPS_RS3_LE: + case EM_MIPS_X: + world.curjob->proc = &world.proc_mips; + break; + case EM_ARM: + world.curjob->proc = &world.proc_arm; + break; + default: + snprintf(logbuf, sizeof (logbuf), + "Architecture %s not supported. No flowjack available.\n", + elfsh_get_machine_string(elfsh_get_arch(world.curjob->curfile->hdr))); + revm_output(logbuf); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); + } + } + + asm_set_resolve_handler(world.curjob->proc, asm_do_resolve, world.curjob->curfile); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} diff -Nru eresi-0.8a25/librevm/api/atomic.c eresi-0.0.20110516/librevm/api/atomic.c --- eresi-0.8a25/librevm/api/atomic.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/atomic.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,16 +1,15 @@ /** - * @defgroup librevm_api librevm API - */ -/* -** @file atomic.c -** @ingroup librevm_api +** @defgroup api Librevm external API. +** @ingroup librevm +*/ +/** +* @file librevm/api/atomic.c +** @ingroup api ** @brief Implement the API for atomic arithmetic and logic ERESI commands. ** ** Started on Sun Feb 9 22:43:34 2003 jfv -** -** $Id: atomic.c,v 1.18 2008-02-16 12:32:27 thor Exp $ -** -*/ +** $Id: atomic.c 1444 2011-01-31 07:41:29Z may $ +**/ #include "revm.h" @@ -46,8 +45,8 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Sanity checks */ - *o1 = revm_lookup_param(world.curjob->curcmd->param[0]); - *o2 = revm_lookup_param(world.curjob->curcmd->param[1]); + *o1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + *o2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); if (!*o1 || !*o2) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to lookup a parameter", -1); @@ -59,7 +58,7 @@ /* Preconditions on arithmetic operations */ /* Used by add, sub, mul, div, mod */ -int revm_arithmetics(revmexpr_t *e1, revmexpr_t *e2, u_char op) +int revm_arithmetics(revmexpr_t *dest, revmexpr_t *e1, revmexpr_t *e2, u_char op) { eresi_Addr src; eresi_Addr dst; @@ -68,7 +67,7 @@ revmobj_t *o1; revmobj_t *o2; revmexpr_t *last; - int oldtype; + u_int oldtype; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!e1 || !e2) @@ -81,9 +80,12 @@ "Incompatible parameter type", -1); /* First check if we write in a constant */ - if (o1->immed && !o1->perm) + if (!dest && o1->immed && !o1->perm) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Destination parameter must not be a constant", -1); + else if (dest && (!dest->value || !dest->value->perm)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Destination parameter must not be a constant", -1); + "Invalid destination parameter", -1); /* Preliminary checks */ oldtype = o1->otype->type; @@ -128,19 +130,43 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot divide by 0", -1); dst %= src; + break; + case REVM_OP_SHL: + dst = dst << src; + break; + case REVM_OP_SHR: + dst = dst >> src; break; + case REVM_OP_OR: + dst = dst | src; + break; + default: PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown requested operation", -1); } /* Store result */ - if (o1->immed) - o1->immed_val.ent = dst; + if (!dest) + { + if (o1->immed) + o1->immed_val.ent = dst; + else + o1->set_obj(o1->parent, dst); + } else - o1->set_obj(o1->parent, dst); + { + if (dest->value->immed) + dest->value->immed_val.ent = dst; + else + dest->value->set_obj(dest->value->parent, dst); + } /* Store last-result variable */ + if (o1->otype->type == ASPECT_TYPE_HASH || + o1->otype->type == ASPECT_TYPE_LIST) + goto end; + last = revm_expr_get(REVM_VAR_RESULT); res = last->value; res->otype = o1->otype; @@ -153,6 +179,8 @@ revm_output(buf); } + end: + /* If the object was a string, translate it back */ if (o1->otype->type != oldtype) revm_convert_object(e1, oldtype); @@ -169,6 +197,7 @@ u_char *key; hash_t *src; revmobj_t *o; + revmobj_t *copy; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!h || !e) @@ -190,10 +219,13 @@ /* Some checks */ if (!o->kname && !o->hname && !o->get_name) { + copy = revm_copy_object(o); if (revm_convert_object(e, ASPECT_TYPE_STR) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown key for source object", -1); - key = (u_char *) (h->type != o->otype->type ? strdup(o->immed_val.str) : o->immed_val.str); + key = o->immed_val.str; + revm_destroy_object(e->value, 0); + o = e->value = copy; } else key = (u_char *) (o->kname ? o->kname : (o->hname ? o->hname : o->get_name(o->root, o->parent))); @@ -213,7 +245,9 @@ /* Add it to the hash table */ elem = (eresi_Addr) (o->immed ? o->immed_val.ent : o->get_obj(o->parent)); - hash_add(h, (char *) key, (void *) elem); + if (o->otype->type == ASPECT_TYPE_STR) + elem = (eresi_Addr) strdup((char *) elem); + hash_add(h, strdup((char *) key), (void *) elem); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -252,8 +286,8 @@ if (revm_convert_object(e, ASPECT_TYPE_STR) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown key for source object", -1); - key = strdup(e->value->immed_val.str); - revm_destroy_object(e->value); + key = e->value->immed_val.str; + revm_destroy_object(e->value, 0); o = e->value = copy; } else @@ -276,6 +310,8 @@ /* Add it to the hash table */ elem = (eresi_Addr) (o->immed ? o->immed_val.ent : o->get_obj(o->parent)); + if (o->otype->type == ASPECT_TYPE_STR) + elem = (eresi_Addr) strdup((char *) elem); elist_add(h, key, (void *) elem); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -469,11 +505,15 @@ } else if (o1->parent == str || !o1->parent) o1->parent = (str ? strdup(str) : NULL); - else if (o1->set_name(o1->root, o1->parent, str) < 0) + else { - XFREE(__FILE__, __FUNCTION__, __LINE__, str); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set string variable", -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, o1->parent, strlen(str), -1); + if (o1->set_name(o1->root, o1->parent, str) < 0) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, str); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set string variable", -1); + } } break; @@ -487,7 +527,7 @@ { if (o1->contype == CONT_HASH) revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val8, ASPECT_TYPE_BYTE); + (void *) (eresi_Addr) val8, ASPECT_TYPE_BYTE); else if (o1->contype == CONT_LIST) revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, str, ASPECT_TYPE_STR); @@ -505,11 +545,11 @@ { if (o1->contype == CONT_HASH) revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); + (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); else if (o1->contype == CONT_LIST) revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); - + (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); + } else if (o1->set_obj(o1->parent, val16) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -525,11 +565,11 @@ { if (o1->contype == CONT_HASH) revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); + (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); else if (o1->contype == CONT_LIST) revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); - + (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); + } else if (o1->set_obj(o1->parent, val32) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -537,8 +577,11 @@ break; case ASPECT_TYPE_LONG: - if (sizeof(u_long) == 4) - goto intcopy; + if (sizeof(u_long) == 4 && o1->set_obj == revm_long_setobj) + { + o1->set_obj = revm_int_setobj; + goto intcopy; + } case ASPECT_TYPE_CADDR: case ASPECT_TYPE_DADDR: ptrcopy: @@ -608,7 +651,7 @@ u_int ival2; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e2 || !e2) + if (!e1 || !e2) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); o1 = e1->value; @@ -696,16 +739,10 @@ /* Set the last result variable */ last = revm_expr_get(REVM_VAR_RESULT); - if (!last) - { - if (!o2->perm && o2->immed && o2->otype->type == ASPECT_TYPE_STR && str != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,str); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get last result variable", -1); - } - revm_expr_destroy(REVM_VAR_RESULT); + if (last) + revm_expr_destroy_by_name(REVM_VAR_RESULT); res = revm_create_IMMED(ASPECT_TYPE_INT, 1, *val); - last = revm_expr_create_from_object(res, REVM_VAR_RESULT); + last = revm_expr_create_from_object(res, REVM_VAR_RESULT, 1); if (!last) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to set result expression", (-1)); diff -Nru eresi-0.8a25/librevm/api/commands.c eresi-0.0.20110516/librevm/api/commands.c --- eresi-0.8a25/librevm/api/commands.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/commands.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,11 +1,11 @@ /* -** @file cmdapi.c -** @ingroup librevm_api +* @file librevm/api/commands.c +** @ingroup api ** @brief Commands functions. ** Started on Mon Feb 24 15:52:06 2003 jfv ** Last update Thu Mar 11 14:39:06 2004 jfv ** -** $Id: commands.c,v 1.6 2007-08-03 18:05:03 may Exp $ +** $Id: commands.c 1440 2010-12-29 02:22:03Z may $ ** */ #include "revm.h" @@ -50,18 +50,18 @@ "Supplied handler invalid", (-1)); } act = ent->data; - if (reg != ELFSH_ORIG) + if (reg != ERESI_ORIG) act->reg = reg; - if (exec != ELFSH_ORIG) + if (exec != ERESI_ORIG) act->exec = exec; - if (needcur != (u_int) ELFSH_ORIG) + if (needcur != (u_int) ERESI_ORIG) act->wflags = needcur; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /* Add a command */ -int revm_command_add(char *cmd, void *exec, void *reg, u_int needfile, - char *help) +int revm_command_add(char *cmd, int (*exec)(void), void *reg, + u_int needfile, char *help) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); hash_add(&cmd_hash, cmd , (void *) revm_create_CMDENT(exec, reg, needfile, help)); diff -Nru eresi-0.8a25/librevm/api/doswitch.c eresi-0.0.20110516/librevm/api/doswitch.c --- eresi-0.8a25/librevm/api/doswitch.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/doswitch.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file doswitch.c -** @ingroup librevm_api +* @file librevm/api/doswitch.c +** @ingroup api ** @brief Do the switch. ** Started on Sat Jan 25 11:20:49 2003 jfv ** -** $Id: doswitch.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: doswitch.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -26,7 +26,7 @@ world.curjob->curfile = actual; /* Switch to static mode if current file is not mapped */ - if (elfsh_is_debug_mode() && !actual->linkmap) + if (elfsh_is_runtime_mode() && !actual->linkmap) elfsh_set_static_mode(); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); diff -Nru eresi-0.8a25/librevm/api/edfmt.c eresi-0.0.20110516/librevm/api/edfmt.c --- eresi-0.8a25/librevm/api/edfmt.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/edfmt.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,10 @@ /* -** @file edfmt.c -** @ingroup librevm_api +* @file librevm/api/edfmt.c +** @ingroup api ** @brief All functions dealing with libedfmt. ** ** Started on Fev 25 2007 mxatone -** -** $Id: edfmt.c,v 1.15 2008-02-16 12:32:27 thor Exp $ -** +** $Id: edfmt.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" @@ -227,7 +225,7 @@ else str = var->type->name; - revm_inform_type(str, buf, buf, NULL, 0, 0); + revm_inform_toplevel(str, buf, buf, NULL, 0, 0); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/librevm/api/filter.c eresi-0.0.20110516/librevm/api/filter.c --- eresi-0.8a25/librevm/api/filter.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/filter.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,16 +1,15 @@ -/* -** @file filter.c -** @ingroup librevm_api -** @brief Filter 0x00 in the OBJ_TYPESTR object. -** Started on Thu Mar 13 23:27:58 2003 jfv -** Last update Sat Mar 15 07:00:38 2003 jfv -** -** $Id: filter.c,v 1.5 2007-08-03 11:51:00 heroine Exp $ -** -*/ +/** + * @file librevm/api/filter.c + * @ingroup api + * @brief Filter 0x00 in the OBJ_TYPESTR object. + * Started on Thu Mar 13 23:27:58 2003 jfv + * Last update Sat Mar 15 07:00:38 2003 jfv + * + * $Id: filter.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "libui.h" - /* Filter \x00 in the OBJ_TYPESTR object */ void revm_filter_zero(char *buf) { @@ -24,22 +23,22 @@ { ptr = strstr(buf, "\\x00"); if (ptr != NULL) - { - *ptr = 0x00; - memmove(ptr + 1, ptr + 4, (u_int) buf + size - (u_int) (ptr + 4)); - buf = ptr + 1; - size -= 3; - } - else - { - ptr = strstr(buf, "\\x0"); - if (ptr == NULL) - break; - *ptr = 0x00; - memmove(ptr + 1, ptr + 3, (u_int) buf + size - (u_int) (ptr + 3)); - buf = ptr + 1; - size -= 2; - } + { + *ptr = 0x00; + memmove(ptr + 1, ptr + 4, (u_int) buf + size - (u_int) (ptr + 4)); + buf = ptr + 1; + size -= 3; + } + else + { + ptr = strstr(buf, "\\x0"); + if (ptr == NULL) + break; + *ptr = 0x00; + memmove(ptr + 1, ptr + 3, (u_int) buf + size - (u_int) (ptr + 3)); + buf = ptr + 1; + size -= 2; + } } while (ptr != NULL); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); @@ -49,39 +48,69 @@ /* Replace \xNUM taking care of the \x00 in a string */ +/* char *revm_filter_param(char *buf, char *ptr) { u_int nbr; char c; char d; + u_int len; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* if string ends with '\x', its over for this entry */ + //if string ends with '\x', its over for this entry if (*(ptr + 2) == 0x00) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); - /* Do exception for \x00 which must not be resolved */ + //Do exception for \x00 which must not be resolved c = *(ptr + 2); d = *(ptr + 3); if (c == '0' && !((d >= 'A' && d <= 'F') || (d >= '1' && d <= '9'))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (buf + (d == '0' ? 4 : 3))); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ptr + 4); - /* else read the hexadecimal value */ - else - { - sscanf(ptr + 2, "%X", &nbr); - *ptr = (char) nbr; - buf = ptr + 4; + //else read the hexadecimal value + sscanf(ptr + 2, "%X", &nbr); + *ptr = (char) nbr; + buf = ptr + 4; - /* and copy the data, strcpy put NUL at the end */ - strcpy(ptr + 1, buf); + //If we are ending the search buffer + if (*buf == 0x00) + { + *(ptr + 1) = 0x00; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ptr + 1)); } - assert(1); + //Copy the remaining data + len = strlen(buf); + memmove(ptr + 1, buf, len); + *(ptr + 1 + len) = 0x00; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ptr + 1)); } +*/ +char *revm_filter_param(char *buf, char *ptr) +{ + u_int nbr; + char c; + char d; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + //if string ends with '\x', its over for this entry + if (*(ptr + 2) == 0x00) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); + //Do exception for \x00 which must not be resolved + c = *(ptr + 2); + d = *(ptr + 3); + if (c == '0' && !((d >= 'A' && d <= 'F') || (d >= '1' && d <= '9'))) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ptr + 4); + sscanf(ptr + 2, "%X", &nbr); + *ptr = (char) nbr; + buf = ptr + 4; + + /* and copy the data, strcpy put NUL at the end */ + strcpy(ptr + 1, buf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ptr + 1)); +} diff -Nru eresi-0.8a25/librevm/api/helping.c eresi-0.0.20110516/librevm/api/helping.c --- eresi-0.8a25/librevm/api/helping.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/helping.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,9 +1,9 @@ /* -** @file help.c -** @ingroup librevm_api +* @file librevm/api/helping.c +** @ingroup api ** @brief The help command. ** Started on Sat Jan 25 11:19:18 2003 jfv -** $Id: helping.c,v 1.1 2007-11-29 14:08:47 may Exp $ +** $Id: helping.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/api/implicit.c eresi-0.0.20110516/librevm/api/implicit.c --- eresi-0.8a25/librevm/api/implicit.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/implicit.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file implicit.c +* @file librevm/api/implicit.c ** @brief Load the working files. -** @ingroup librevm_api +** @ingroup api ** Started on Tue Feb 18 06:45:35 2003 jfv ** -** $Id: implicit.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: implicit.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -97,10 +97,10 @@ /* Do all implicit operation when calling elfsh from a script */ int revm_implicit(revmcmd_t *actual) { - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* If the requested command does not need a current pointer */ + revm_proc_init(); if (actual && !actual->wflags) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -124,7 +124,8 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No file loaded", -1); /* We need to set it here since the CURRENT object can change */ - asm_set_resolve_handler(&world.proc, asm_do_resolve, world.curjob->curfile); + if (world.curjob->proc && world.curjob->curfile) + asm_set_resolve_handler(world.curjob->proc, asm_do_resolve, world.curjob->curfile); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/librevm/api/inform.c eresi-0.0.20110516/librevm/api/inform.c --- eresi-0.8a25/librevm/api/inform.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/inform.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file inform.c -** @ingroup librevm_api +* @file librevm/api/inform.c +** @ingroup api ** @brief API for annotating program objects. ** ** Started Jan 21 2007 12:57:03 jfv -** $Id: inform.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: inform.c 1435 2010-12-11 06:16:51Z may $ ** */ #include "revm.h" @@ -39,7 +39,7 @@ /* We are at the first iteration : create root expression */ pathsize = snprintf(pathbuf, sizeof(pathbuf), "%s", curpath); -#if __DEBUG_EXPRS__ +#if __DEBUG_INFORM__ fprintf(stderr, " [I] Current expr path before loop (%s) \n", pathbuf); #endif @@ -58,11 +58,11 @@ { len = snprintf(pathbuf + pathsize, BUFSIZ - pathsize, ".%s", curtype->fieldname); -#if __DEBUG_EXPRS__ +#if __DEBUG_INFORM__ fprintf(stderr, " [I] Curchild expr path will be informed recursively (%s) \n", pathbuf); #endif - revm_inform_type_addr(curtype->name, pathbuf, childaddr, newexpr, 0, 0); + revm_inform_type(curtype->name, pathbuf, childaddr, newexpr, 0, 0); pathsize += len; revm_inform_subtype(pathbuf, newexpr, curtype, childaddr, translateaddr); pathsize -= len; @@ -73,7 +73,7 @@ else { -#if __DEBUG_EXPRS__ +#if __DEBUG_INFORM__ fprintf(stderr, " [I] Current TERMINAL path inside loop (%s::%s) \n", pathbuf, curtype->fieldname); #endif @@ -82,8 +82,9 @@ if (!newexpr->value) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to lookup terminal object", NULL); + len = snprintf(pathbuf + pathsize, BUFSIZ - pathsize, ".%s", curtype->fieldname); - revm_inform_type_addr(curtype->name, pathbuf, childaddr, newexpr, 0, 0); + revm_inform_type(curtype->name, pathbuf, childaddr, newexpr, 0, 0); bzero(pathbuf + pathsize, len); } @@ -172,14 +173,14 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); for (index = 0, phdr = obj->pht; index < obj->hdr->e_phnum; index++) if (phdr[index].p_type == PT_LOAD && - phdr[index].p_vaddr < addr && + phdr[index].p_vaddr <= addr && addr < phdr[index].p_vaddr + phdr[index].p_memsz) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/* Add an elemnt to the inform table for a given type, by real address */ +/** Add an element to the inform table for a given type, by real address */ revmexpr_t *revm_inform_type_addr(char *type, char *varname, eresi_Addr addr, @@ -192,8 +193,8 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); XALLOC(__FILE__, __FUNCTION__, __LINE__, addrbuf, 20, NULL); - snprintf(addrbuf, 20, "0x%08lX", (unsigned long) addr); - ret = revm_inform_type(type, varname, addrbuf, expr, print, rec); + snprintf(addrbuf, 20, XFMT, (eresi_Addr) addr); + ret = revm_inform_toplevel(type, varname, addrbuf, expr, print, rec); if (ret) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, @@ -204,79 +205,100 @@ /** * @brief Add an element to the inform table for a given type */ -revmexpr_t *revm_inform_type(char *type, char *varname, - char *straddr, revmexpr_t *expr, - u_char print, u_char rec) +revmexpr_t *revm_inform_toplevel(char *type, char *varname, + char *straddr, revmexpr_t *expr, + u_char print, u_char rec) { - hash_t *hash; - char buf[BUFSIZ]; - eresi_Addr addr; eresi_Addr oaddr; char *realname; char *symname; - revmannot_t *annot; elfsh_SAddr off; - aspectype_t *rtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - /* Add element in the good hash table */ - rtype = aspect_type_get_by_name(type); - snprintf(buf, sizeof(buf), "type_%s", type); - hash = hash_find(buf); - if (!hash || !rtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested type", NULL); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* The address is not precised, to to find it from the varname */ if (!straddr) straddr = varname; -#if __DEBUG_EXPRS__ - fprintf(stderr, "\n [D] Variable %40s LOOKED UP\n", varname); +#if __DEBUG_INFORM__ + fprintf(stderr, "\n [D] Variable %40s TOPLEVEL INFORM ENTER \n", varname); #endif - /* The address is given, lookup it */ - if (!hash_get(&exprs_hash, varname)) + /* The address is given, look it up */ + if (!revm_expr_get(varname)) realname = revm_lookup_string(varname); else realname = varname; oaddr = revm_lookup_addr(straddr); /* Adding expression and its type to hash tables */ -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Variable %40s TO BE added to exprs_hash with type %s \n", realname, rtype->name); +#if __DEBUG_INFORM__ + fprintf(stderr, " [D] Variable %40s TO BE added to local exprs table with type %s \n", + realname, type); #endif /* Only check for addr range if print flag (manual inform) is on */ - if (print && (!oaddr || !revm_check_addr(world.curjob->curfile, oaddr))) + if (print && !revm_check_addr(world.curjob->curfile, oaddr)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable address", NULL); + "Invalid variable address", NULL); if (!realname) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid variable name", NULL); - if (hash_get(&exprs_hash, realname)) - hash_del(&exprs_hash, realname); - /* If just the address was given, lookup or create a name for the variable */ if (IS_VADDR(realname)) { - sscanf(realname + 2, AFMT, &addr); - symname = elfsh_reverse_symbol(world.curjob->curfile, addr, &off); + sscanf(realname + 2, AFMT, &oaddr); + symname = elfsh_reverse_symbol(world.curjob->curfile, oaddr, &off); if (symname && !off) realname = strdup(symname); else { XALLOC(__FILE__, __FUNCTION__, __LINE__, realname, strlen(type) + 20, NULL); - snprintf(realname, sizeof(realname), "%s_"AFMT, type, addr); + snprintf(realname, sizeof(realname), "%s_"AFMT, type, oaddr); } } - addr = oaddr; - XALLOC(__FILE__, __FUNCTION__, __LINE__, annot, sizeof(revmannot_t), NULL); + /* It can happens that the realname lacks a variable prefix, in that case add it now */ + if (*realname != REVM_VAR_PREFIX) + { + varname = alloca(strlen(realname) + 2); + *varname = REVM_VAR_PREFIX; + strcpy(varname + 1, realname); + realname = varname; + } + + /* Now do the real job */ + expr = revm_inform_type(type, realname, oaddr, expr, print, rec); + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to inform type", NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); +} + + +/** Add type information for a memory address */ +revmexpr_t *revm_inform_type(char *type, char *realname, + eresi_Addr addr, revmexpr_t *expr, + u_char print, u_char rec) +{ + hash_t *hash; + char buf[BUFSIZ]; + revmannot_t *annot; + aspectype_t *rtype; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Add element in the good hash table */ + rtype = aspect_type_get_by_name(type); + snprintf(buf, sizeof(buf), "type_%s", type); + hash = hash_find(buf); + if (!hash || !rtype) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown requested type", NULL); /* Setup current string table offset, type, scope, and representation */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, annot, sizeof(revmannot_t), NULL); annot->nameoff = revm_strtable_add(realname); annot->typenum = rtype->type; annot->scope = EDFMT_SCOPE_GLOBAL; @@ -295,11 +317,9 @@ { XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, sizeof(revmexpr_t), NULL); expr->strval = NULL; - expr->label = realname; + expr->label = strdup(realname); expr->type = rtype; - - // XXX: changed NULL for expr (testing) - expr->childs = revm_inform_subtype(realname, NULL, rtype, oaddr, print); + expr->childs = revm_inform_subtype(realname, NULL, rtype, addr, print); } else if (!rtype->childs) expr = revm_simple_expr_create(rtype, realname, NULL); @@ -307,15 +327,20 @@ /* Else if recursion is asked on an existing expression (set $expr $existingexpr) */ else if (rec && rtype->childs) - revm_inform_subtype(realname, expr, rtype, oaddr, print); + revm_inform_subtype(realname, expr, rtype, addr, print); /* Register the expression */ annot->expr = expr; - hash_set(&exprs_hash, (char *) strdup(realname), (void *) expr); + if (expr) + expr->annot = annot; + + hash_set(&world.curjob->recur[world.curjob->curscope].exprs, + (char *) strdup(realname), (void *) expr); /* Adding expression and its type to hash tables */ -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Variable %40s ADDED to exprs_hash with type %s \n", realname, rtype->name); +#if __DEBUG_INFORM__ + fprintf(stderr, " [D] Variable %40s ADDED to local exprs hash with type %s \n", + realname, rtype->name); #endif /* Success message and exit */ diff -Nru eresi-0.8a25/librevm/api/job.c eresi-0.0.20110516/librevm/api/job.c --- eresi-0.8a25/librevm/api/job.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/job.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,12 @@ -/* -** @file job.c -** @ingroup librevm_api -** @brief Create a new job structure. -** Started on Wed Jul 20 22:22:35 2005 yann_malcom -** -** $Id: job.c,v 1.5 2007-11-29 14:01:55 may Exp $ -** -*/ +/** + * @file librevm/api/job.c + * @ingroup api + * @brief Create a new job structure. + * Started on Wed Jul 20 22:22:35 2005 yann_malcom + * + * $Id: job.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "revm.h" @@ -16,31 +16,47 @@ revmjob_t *new; int i; char logbuf[BUFSIZ]; + static int lastid = 1; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmjob_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, new, sizeof(revmjob_t), NULL); memcpy(new, job, sizeof(revmjob_t)); bzero(&new->loaded, sizeof(hash_t)); bzero(&new->dbgloaded, sizeof(hash_t)); - + bzero(&new->iter, sizeof(revmiter_t) * REVM_MAXSRCNEST); + bzero(&new->recur, sizeof(revmrecur_t) * REVM_MAXSRCNEST); + new->id = lastid++; + snprintf(logbuf, sizeof(logbuf), "%s_loaded", newname); hash_init(&new->loaded, strdup(logbuf), 51, ASPECT_TYPE_UNKNOW); snprintf(logbuf, sizeof(logbuf), "%s_dbgloaded", newname); - hash_init(&new->dbgloaded, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); + hash_init(&new->dbgloaded, strdup(logbuf), 23, ASPECT_TYPE_UNKNOW); + + snprintf(logbuf, sizeof(logbuf), "job%u_rec%u_exprs", new->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].exprs, + strdup(logbuf), 23, ASPECT_TYPE_EXPR); + + snprintf(logbuf, sizeof(logbuf), "job%u_rec%u_labels", new->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].labels, + strdup(logbuf), 11, ASPECT_TYPE_STR); - /* empty new job */ + /* Empty new job */ new->curcmd = NULL; - new->sourced = 0; + new->curloop = 0; + new->curscope = 0; new->ws.active = 0; new->ws.oldline = NULL; new->ws.screen.buf = new->ws.screen.tail = new->ws.screen.head = NULL; - for (i = 0; i < REVM_MAXSRCNEST; i++) { - new->script[i] = NULL; - new->lstcmd[i] = NULL; + new->recur[i].script = NULL; + new->recur[i].lstcmd = NULL; + new->recur[i].funcname = NULL; + new->iter[i].listidx = REVM_IDX_UNINIT; } + + new->recur[0].funcname = "top-level"; new->ws.createtime = time(&new->ws.createtime); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); } diff -Nru eresi-0.8a25/librevm/api/Makefile eresi-0.0.20110516/librevm/api/Makefile --- eresi-0.8a25/librevm/api/Makefile 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/Makefile 2011-05-16 11:34:12.000000000 +0000 @@ -7,7 +7,8 @@ SRC = atomic.c commands.c doswitch.c edfmt.c filter.c job.c \ implicit.c misc.c modlist.c screen.c stringtable.c \ - inform.c sourcing.c helping.c printing.c typing.c + inform.c sourcing.c helping.c printing.c typing.c \ + asmproc.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) @@ -18,21 +19,21 @@ NAME64 = ../revm-api.64.o CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ + $(STATOPT2) $(ASMOPT) -DERESI32 $(EXTRACFLAGS) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libaspect/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ + -I../../libedfmt/include/ $(EXTRACFLAGS) \ + $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/librevm/api/misc.c eresi-0.0.20110516/librevm/api/misc.c --- eresi-0.8a25/librevm/api/misc.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/misc.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file misc.c -** @ingroup librevm_api +* @file librevm/api/misc.c +** @ingroup api ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Fri Sep 11 17:26:11 2005 jfv ** -** $Id: misc.c,v 1.15 2008-02-16 12:32:27 thor Exp $ +** $Id: misc.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -20,7 +20,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (world.state.revm_mode == REVM_STATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_EMBEDDED) mode = E2DBG_NAME; else mode = REVM_NAME; @@ -73,6 +73,8 @@ void revm_exit(int err) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + revm_callback_handler_remove(); + revm_cleanup(); _exit(err); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } @@ -153,11 +155,11 @@ { snprintf(actual, sizeof(actual), "$%u", idx); new = revm_create_IMMEDSTR(1, strdup(av[idx])); - expr = revm_expr_create_from_object(new, actual); + expr = revm_expr_create_from_object(new, actual, 0); } new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - expr = revm_expr_create_from_object(new, REVM_VAR_ARGC); + expr = revm_expr_create_from_object(new, REVM_VAR_ARGC, 0); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -189,6 +191,8 @@ !strstr(buff, "elfsh") && !strstr(buff, "etrace") && !strstr(buff, "e2dbg") && + !strstr(buff, "kernsh") && + !strstr(buff, "kedbg") && !strstr(buff, "evarista")) { XCLOSE(fd, 0); @@ -234,7 +238,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buf, ELFSH_MEANING, "%s %08X", str, (u_int) type); + snprintf(buf, ERESI_MEANING, "%s %08X", str, (u_int) type); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); } @@ -344,9 +348,7 @@ char *ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = NULL; - cur = str; + ret = cur = str; while ((cur = strchr(cur, '/'))) if (!*(cur + 1)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No basename", (NULL)); @@ -394,3 +396,24 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Empty parameter", NULL); } + + +/** + * Get and Set fields of structures + */ +uint8_t revm_get_argc(void) +{ + return world.curjob->curcmd->argc; +} + + +char *revm_get_cur_job_parameter(uint8_t p) +{ + return world.curjob->curcmd->param[p]; +} + + +char *revm_get_cur_job_parameter_with_job(revmjob_t *job, uint8_t p) +{ + return job->curcmd->param[p]; +} diff -Nru eresi-0.8a25/librevm/api/modlist.c eresi-0.0.20110516/librevm/api/modlist.c --- eresi-0.8a25/librevm/api/modlist.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/modlist.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file modlist.c -** @ingroup librevm_api +* @file librevm/api/modlist.c +** @ingroup api ** @brief List the loaded eresi module. ** Started on Wed Feb 19 04:42:47 2003 jfv ** -** $Id: modlist.c,v 1.6 2008-02-16 12:32:27 thor Exp $ +** $Id: modlist.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/api/printing.c eresi-0.0.20110516/librevm/api/printing.c --- eresi-0.8a25/librevm/api/printing.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/printing.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /* - * @file printing.c - * @ingroup librevm_api +* @file librevm/api/printing.c + * @ingroup api * @brief This file contains various printing facilities API. * * Started on Wed Dec 05 23:02:04 2003 jfv - * $Id: printing.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: printing.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" @@ -29,7 +29,7 @@ if (start) list = start; else - list = world.curjob->script[world.curjob->sourced]; + list = world.curjob->recur[world.curjob->curscope].script; for (index = 0; list; list = list->next, index++) { diff -Nru eresi-0.8a25/librevm/api/screen.c eresi-0.0.20110516/librevm/api/screen.c --- eresi-0.8a25/librevm/api/screen.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/screen.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,12 @@ /* -** @file screen.c -** @ingroup librevm_api +* @file librevm/api/screen.c +** @ingroup api */ /* ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Thu Jan 04 11:22:11 2007 jfv ** -** $Id: screen.c,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: screen.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/api/sourcing.c eresi-0.0.20110516/librevm/api/sourcing.c --- eresi-0.8a25/librevm/api/sourcing.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/sourcing.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,20 +1,19 @@ /** -** @file sourcing.c +* @file librevm/api/sourcing.c ** -** @ingroup librevm_api +** @ingroup api */ /* ** Started on Fri May 16 15:18:35 2005 jfv -** $Id: sourcing.c,v 1.4 2008-02-16 12:32:27 thor Exp $ +** $Id: sourcing.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" /** - * @brief Command interface for ERESI script sourcing - * - * @param params - * @return + * @brief Command interface for ERESI script sourcing. + * @param params NULL terminated array of script parameters. + * @return Success (0) or Error (-1). */ int revm_source(char **params) { @@ -28,18 +27,20 @@ char **av; int ac; int idx; - char actual[26]; - char framename[26]; + char actual[40]; int argc; int ret; revmobj_t *new; - revmexpr_t *prevargc; revmexpr_t *expr; - revmexpr_t *param; - list_t *newframe; + revmexpr_t *eparam[10] = {NULL}; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + /* Make sure we still can recurse */ + if (world.curjob->curscope + 1 >= REVM_MAXSRCNEST) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot recurse anymore", (-1)); + /* build argc */ for (argc = idx = 0; params[idx] != NULL; idx++) argc++; @@ -55,7 +56,7 @@ /* Switch to debugger script mode when sourcing */ /* This does not include execution of .eresirc in the debugger */ - if (!strstr(str, REVM_CONFIG) && world.state.revm_mode == REVM_STATE_DEBUGGER) + if (!strstr(str, REVM_CONFIG) && world.state.revm_mode == REVM_STATE_EMBEDDED) world.state.revm_sourcing = 1; /* Open the script file and pass its parameters */ @@ -66,62 +67,46 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid script file", -1); - /* Copy all procedure parameters as new objects arguments */ - snprintf(framename, sizeof(framename), "%u", world.curjob->sourced); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newframe, sizeof(list_t), -1); - elist_init(newframe, strdup(framename), ASPECT_TYPE_EXPR); + /* Prepare the interpreter for executing a new script */ + XOPEN(fd, str, O_RDONLY, 0, -1); + world.curjob->curscope++; + snprintf(actual, sizeof(actual), "job%u_rec%u_labels", world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].labels, strdup(actual), 23, ASPECT_TYPE_STR); + snprintf(actual, sizeof(actual), "job%u_rec%u_exprs", world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].exprs, strdup(actual), 23, ASPECT_TYPE_EXPR); + world.curjob->recur[world.curjob->curscope].funcname = str; - /* Create new parameters and store the old ones in a frame */ + /* Lookup script parameters */ for (ac = 1; params[ac]; ac++) { + expr = revm_lookup_param(params[ac], 1); + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid script parameter", -1); + eparam[ac - 1] = expr; + } - /* Get the parameter value. Can be a previous function parameter ($Num) itself - -> lookup has to be done before creating the new parameter */ - expr = revm_lookup_param(params[ac]); - - /* Then save the previous $1...N variables */ - argv[ac + 1] = params[ac]; - snprintf(actual, sizeof(actual), "$%u", ac); - param = revm_expr_get(actual); - if (param) - { - elist_add(newframe, strdup(actual), (void *) param); - hash_del(&exprs_hash, (char *) actual); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s stacked with type = %s \n", - actual, (param->type ? param->type->name : "UNKNOWN TYPE")); -#endif - } - - /* Then install the new ones */ - /* This will copy the parameter expression under the name "$N" - and name it in the expression hash table */ + /* Create new parameters and store them in new scope */ + for (ac = 0; eparam[ac]; ac++) + { + snprintf(actual, sizeof(actual), "$%u", ac + 1); #if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s added with type = %s \n", - actual, (expr->type ? expr->type->name : "UNKNOWN TYPE")); + fprintf(stderr, " [D] Parameter %s added with type = %s \n", + actual, (eparam[ac]->type ? eparam[ac]->type->name : "UNKNOWN TYPE")); #endif - - expr = revm_expr_copy(expr, actual, 0); + + revm_expr_copy(eparam[ac], actual, 0); } - argv[ac + 1] = NULL; - /* Create new argc variable and add the new frame to the list */ - prevargc = revm_expr_get(REVM_VAR_ARGC); - if (prevargc) - hash_del(&exprs_hash, (char *) REVM_VAR_ARGC); + /* Change ARGC variable */ + argv[ac + 1] = NULL; new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - revm_expr_create_from_object(new, REVM_VAR_ARGC); - elist_add(&frames_list, strdup(framename), (void *) newframe); + revm_expr_create_from_object(new, REVM_VAR_ARGC, 0); - /* Prepare the interpreter for executing a new script */ - XOPEN(fd, str, O_RDONLY, 0, -1); - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 251, ASPECT_TYPE_STR); + /* Update current recursion variable */ expr = revm_expr_get(REVM_VAR_ESHLEVEL); - expr->value->immed_val.ent = world.curjob->sourced; + expr->value->immed_val.ent = world.curjob->curscope; /* Save state for restoring on "continue" */ savedfd = world.curjob->ws.io.input_fd; @@ -132,7 +117,7 @@ /* Temporary takes input from the script file */ revm_setinput(&world.curjob->ws, fd); world.curjob->ws.io.input_fd = fd; - world.state.revm_mode = REVM_STATE_SCRIPT; + world.state.revm_mode = REVM_STATE_SCRIPT; world.curjob->ws.io.input = revm_stdinput; /* First we parse the script file */ @@ -154,7 +139,7 @@ } while (1); /* We then execute the parsed script */ - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; + world.curjob->curcmd = world.curjob->recur[world.curjob->curscope].script; /* If we are executing a debugger script, do not clear everything yet */ switch (revm_execscript()) @@ -174,9 +159,7 @@ /* Restore the context immediately if no continue is met */ default: ret = revm_context_restore(savedfd, savedmode, savedcmd, savedinput, argv, str); - if (prevargc) - hash_set(&exprs_hash, strdup((char *) REVM_VAR_ARGC), prevargc); - expr->value->immed_val.ent = world.curjob->sourced; + expr->value->immed_val.ent = world.curjob->curscope; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -203,12 +186,12 @@ char **argv, char *savedname) { - list_t *lastframe; char buf[BUFSIZ]; - u_int idx; + int idx; char **keys; int keynbr; - revmexpr_t *expr; + revmexpr_t *res; + revmexpr_t *oldres; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -223,32 +206,41 @@ revm_output(buf); } - /* Link back all parameters and their types */ - snprintf(buf, BUFSIZ, "%u", world.curjob->sourced - 1); - lastframe = elist_get(&frames_list, buf); - if (!lastframe) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - keys = elist_get_keys(lastframe, &keynbr); + /* Destroy current frame */ + keys = hash_get_keys(&world.curjob->recur[world.curjob->curscope].exprs, &keynbr); for (idx = 0; idx < keynbr; idx++) { - expr = elist_get(lastframe, keys[idx]); - hash_set(&exprs_hash , keys[idx], expr); + + /* Only free top-level expressions, the rest will be freed recursively by revm_expr_destroy_by_name() */ + if (strstr(keys[idx], REVM_SEP)) + continue; + + /* Special treatment for the return value that needs to move to the inner scope */ + if (!strcmp(keys[idx], REVM_VAR_RESULT) && world.curjob->curscope) + { + res = revm_expr_get(keys[idx]); + oldres = hash_get(&world.curjob->recur[world.curjob->curscope - 1].exprs, REVM_VAR_RESULT); + if (oldres) + revm_expr_destroy(oldres); + hash_add(&world.curjob->recur[world.curjob->curscope - 1].exprs, strdup(keys[idx]), res); + revm_expr_print(res, 0); + continue; + } #if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s restored with type = %s \n", - keys[idx], expr->type->name); + fprintf(stderr, " [D] Expression %s will be destroyed from ending scope \n", keys[idx]); #endif + revm_expr_destroy_by_name(keys[idx]); + } + hash_free_keys(keys); /* Destroy frame */ - elist_destroy(lastframe); - elist_del(&frames_list, buf); - elist_free_keys(keys); - - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; + hash_destroy(&world.curjob->recur[world.curjob->curscope].labels); + hash_destroy(&world.curjob->recur[world.curjob->curscope].exprs); + world.curjob->recur[world.curjob->curscope].script = NULL; + world.curjob->curscope--; /* Return OK */ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); diff -Nru eresi-0.8a25/librevm/api/stringtable.c eresi-0.0.20110516/librevm/api/stringtable.c --- eresi-0.8a25/librevm/api/stringtable.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/stringtable.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,6 +1,6 @@ /* -** @file stringtable.c -** @ingroup librevm_api +* @file librevm/api/stringtable.c +** @ingroup api ** @brief All functions about string table management ** ** Started on Sept 11 2005 mxatone diff -Nru eresi-0.8a25/librevm/api/.svn/all-wcprops eresi-0.0.20110516/librevm/api/.svn/all-wcprops --- eresi-0.8a25/librevm/api/.svn/all-wcprops 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/950/trunk/librevm/api -END -edfmt.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/906/trunk/librevm/api/edfmt.c -END -commands.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/api/commands.c -END -typing.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/935/trunk/librevm/api/typing.c -END -implicit.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/api/implicit.c -END -job.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/906/trunk/librevm/api/job.c -END -modlist.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/906/trunk/librevm/api/modlist.c -END -atomic.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/946/trunk/librevm/api/atomic.c -END -stringtable.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/912/trunk/librevm/api/stringtable.c -END -screen.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/906/trunk/librevm/api/screen.c -END -doswitch.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/api/doswitch.c -END -filter.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/906/trunk/librevm/api/filter.c -END -helping.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/907/trunk/librevm/api/helping.c -END -sourcing.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/911/trunk/librevm/api/sourcing.c -END -inform.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/946/trunk/librevm/api/inform.c -END -printing.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/api/printing.c -END -misc.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/906/trunk/librevm/api/misc.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/950/trunk/librevm/api/Makefile -END diff -Nru eresi-0.8a25/librevm/api/.svn/entries eresi-0.0.20110516/librevm/api/.svn/entries --- eresi-0.8a25/librevm/api/.svn/entries 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,232 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/api -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -edfmt.c -file - - - - -2008-04-06T23:15:46.295892Z -013c38c77e1a80f0a61e5ef7e396582e -2008-03-14T00:57:20.622435Z -906 -enioh - -commands.c -file - - - - -2008-04-06T23:15:46.302315Z -fdedf61d303c0763f63984af6a6bbbbc -2008-03-14T00:57:20.622435Z -906 -enioh - -typing.c -file - - - - -2008-04-06T23:15:46.336911Z -56f76b8170c84524fe5e6ccd70864f0b -2008-03-25T17:24:54.084701Z -935 -may - -implicit.c -file - - - - -2008-04-06T23:15:46.327152Z -c9b7c391a770bdf77df0a5d141c2ab02 -2008-03-14T00:57:20.622435Z -906 -enioh - -job.c -file - - - - -2008-04-06T23:15:46.313983Z -faee0da2819fce008f9f2ff923a47e81 -2008-03-14T00:57:20.622435Z -906 -enioh - -modlist.c -file - - - - -2008-04-06T23:15:46.349001Z -08253df30cc5c6a0d166bd02c89ce198 -2008-03-14T00:57:20.622435Z -906 -enioh - -atomic.c -file - - - - -2008-04-06T23:15:46.360944Z -bcc3ba2e1396684da86fc8cce57dd761 -2008-03-27T22:53:48.747992Z -946 -may - -stringtable.c -file - - - - -2008-04-06T23:15:46.372318Z -913520b8c1507c069fc40b90ff127c5e -2008-03-14T16:16:54.448934Z -912 -may - -screen.c -file - - - - -2008-04-06T23:15:46.383660Z -d0108e54cbff9316c4c7049ba5c97c07 -2008-03-14T00:57:20.622435Z -906 -enioh - -doswitch.c -file - - - - -2008-04-06T23:15:46.395059Z -b29b8d32d943dfb23d33b707ff6ed4e0 -2008-03-14T00:57:20.622435Z -906 -enioh - -filter.c -file - - - - -2008-04-06T23:15:46.406404Z -440fbb30d55f6274e88a6a6a1d597942 -2008-03-14T00:57:20.622435Z -906 -enioh - -helping.c -file - - - - -2008-04-06T23:15:46.417920Z -eb11e54f0804ca604b0f4ca9df9e50b5 -2008-03-14T01:01:17.818585Z -907 -enioh - -sourcing.c -file - - - - -2008-04-06T23:15:46.429263Z -e2df1bb15c14185587e99b7be634842f -2008-03-14T10:03:51.600980Z -911 -may - -inform.c -file - - - - -2008-04-06T23:15:46.451948Z -a2efdb18e81aa0789259eec0fb9aea99 -2008-03-27T22:53:48.747992Z -946 -may - -printing.c -file - - - - -2008-04-06T23:15:46.440605Z -392ae378017976b6a95f90276e271261 -2008-03-14T00:57:20.622435Z -906 -enioh - -misc.c -file - - - - -2008-04-06T23:15:46.463291Z -b5e0f6532602e9e92494348a38db9940 -2008-03-14T00:57:20.622435Z -906 -enioh - -Makefile -file - - - - -2008-04-06T23:15:46.474691Z -f943f10d19b237e4ded09001c6fedd6e -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/librevm/api/.svn/format eresi-0.0.20110516/librevm/api/.svn/format --- eresi-0.8a25/librevm/api/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/atomic.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/atomic.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/atomic.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/atomic.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,768 +0,0 @@ -/** - * @defgroup librevm_api librevm API - */ -/* -** @file atomic.c -** @ingroup librevm_api -** @brief Implement the API for atomic arithmetic and logic ERESI commands. -** -** Started on Sun Feb 9 22:43:34 2003 jfv -** -** $Id: atomic.c,v 1.18 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/* Convert and see if interaction is possible between two expressions */ -int revm_nextconds_atomics(revmexpr_t *o1, revmexpr_t *o2) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lazy typing in action */ - if (!o2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source parameter undefined", -1); - - if (!o1->type) - revm_convert_object(o1, o2->type->type); - else if (o1->type->type != o2->type->type) - if (revm_convert_object(o2, o1->type->type) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "SET parameters type are not compatible", -1); - - /* Make sure we dont want to write in a constant */ - if (o1->value && o1->value->immed && !o1->value->perm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Destination parameter must not be a constant", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Preconditions on atomic operations set (only called by cmd_set) */ -int revm_preconds_atomics(revmexpr_t **o1, revmexpr_t **o2) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - *o1 = revm_lookup_param(world.curjob->curcmd->param[0]); - *o2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!*o1 || !*o2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup a parameter", -1); - if (revm_nextconds_atomics(*o1, *o2) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Will not be able to compute with such types", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Preconditions on arithmetic operations */ -/* Used by add, sub, mul, div, mod */ -int revm_arithmetics(revmexpr_t *e1, revmexpr_t *e2, u_char op) -{ - eresi_Addr src; - eresi_Addr dst; - char buf[BUFSIZ]; - revmobj_t *res; - revmobj_t *o1; - revmobj_t *o2; - revmexpr_t *last; - int oldtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup a parameter", -1); - o1 = e1->value; - o2 = e2->value; - if (!o1 || !o2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incompatible parameter type", -1); - - /* First check if we write in a constant */ - if (o1->immed && !o1->perm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Destination parameter must not be a constant", -1); - - /* Preliminary checks */ - oldtype = o1->otype->type; - if (o1->otype->type == ASPECT_TYPE_UNKNOW && o1->perm) - o1->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - else if (o1->otype->type == ASPECT_TYPE_STR) - revm_convert_object(e1, ASPECT_TYPE_INT); - if ((o1->otype->type != ASPECT_TYPE_INT && - o1->otype->type != ASPECT_TYPE_BYTE && - o1->otype->type != ASPECT_TYPE_SHORT && - o1->otype->type != ASPECT_TYPE_CADDR && - o1->otype->type != ASPECT_TYPE_DADDR && - o1->otype->type != ASPECT_TYPE_LONG) || - (o1->otype->type != o2->otype->type && revm_convert_object(e2, o1->otype->type))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter has not INTEGER type", -1); - - /* Get the objects */ - dst = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - src = (o2->immed ? o2->immed_val.ent : o2->get_obj(o2->parent)); - - /* Compute */ - switch (op) - { - case REVM_OP_ADD: - dst += src; - break; - case REVM_OP_SUB: - dst -= src; - break; - case REVM_OP_MUL: - dst *= src; - break; - case REVM_OP_DIV: - if (src == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot divide by 0", -1); - dst /= src; - break; - case REVM_OP_MOD: - if (src == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot divide by 0", -1); - dst %= src; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested operation", -1); - } - - /* Store result */ - if (o1->immed) - o1->immed_val.ent = dst; - else - o1->set_obj(o1->parent, dst); - - /* Store last-result variable */ - last = revm_expr_get(REVM_VAR_RESULT); - res = last->value; - res->otype = o1->otype; - last->type = o1->otype; - res->immed_val.ent = dst; - res->immed = 1; - if (!world.state.revm_quiet) - { - snprintf(buf, sizeof(buf), " $_ = 0x" XFMT "\n\n", dst); - revm_output(buf); - } - - /* If the object was a string, translate it back */ - if (o1->otype->type != oldtype) - revm_convert_object(e1, oldtype); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* API for adding in hash */ -int revm_hash_add(hash_t *h, revmexpr_t *e) -{ - eresi_Addr elem; - u_char *key; - hash_t *src; - revmobj_t *o; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o = e->value; - if (!o) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", -1); - - /* If the source object is a hash, then we need to do a merge operation ! */ - if (o->otype->type == ASPECT_TYPE_HASH) - { - src = (hash_t *) o->get_obj(o->parent); - hash_merge(h, src); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Some checks */ - if (!o->kname && !o->hname && !o->get_name) - { - if (revm_convert_object(e, ASPECT_TYPE_STR) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", -1); - key = (u_char *) (h->type != o->otype->type ? strdup(o->immed_val.str) : o->immed_val.str); - } - else - key = (u_char *) (o->kname ? o->kname : (o->hname ? o->hname : o->get_name(o->root, o->parent))); - - if (!key) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", -1); - - /* In case the hash table was freshly created, assign its element type now */ - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = o->otype->type; - - /* Make sure we insert an element of the same type */ - if (h->type != o->otype->type && revm_convert_object(e, h->type)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incompatible types between objects", -1); - - /* Add it to the hash table */ - elem = (eresi_Addr) (o->immed ? o->immed_val.ent : o->get_obj(o->parent)); - hash_add(h, (char *) key, (void *) elem); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* API for adding in hash */ -int revm_elist_add(list_t *h, revmexpr_t *e) -{ - eresi_Addr elem; - char *key; - list_t *src; - revmobj_t *copy; - revmobj_t *o; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o = e->value; - if (!o) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", -1); - - /* If the source object is a hash, then we need to do a merge operation ! */ - if (o->otype->type == ASPECT_TYPE_LIST) - { - src = (list_t *) o->get_obj(o->parent); - elist_merge(h, src); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Some checks */ - if (!o->kname && !o->hname && !o->get_name) - { - copy = revm_copy_object(o); - if (revm_convert_object(e, ASPECT_TYPE_STR) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", -1); - key = strdup(e->value->immed_val.str); - revm_destroy_object(e->value); - o = e->value = copy; - } - else - { - key = (o->kname ? o->kname : o->hname ? o->hname : o->get_name(o->root, o->parent)); - key = strdup(key); - } - if (!key) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", -1); - - /* In case the hash table was freshly created, assign its element type now */ - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = o->otype->type; - - /* Make sure we insert an element of the same type */ - if (h->type != o->otype->type && revm_convert_object(e, h->type)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incompatible types between objects", -1); - - /* Add it to the hash table */ - elem = (eresi_Addr) (o->immed ? o->immed_val.ent : o->get_obj(o->parent)); - elist_add(h, key, (void *) elem); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* API for deleting in hash */ -int revm_hash_del(hash_t *h, revmexpr_t *e) -{ - char *name; - hash_t *src; - revmobj_t *o; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o = e->value; - if (!o) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", -1); - - /* If the source object is a hash, then we need to do a merge operation ! */ - if (o->otype->type == ASPECT_TYPE_HASH) - { - src = (hash_t *) o->get_obj(o->parent); - hash_unmerge(h, src); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* If second parameter was a string */ - if (o->otype->type == ASPECT_TYPE_STR) - { - if (o->get_name) - name = o->get_name(o->root, o->parent); - else - name = (o->immed ? o->immed_val.str : (char *) o->get_obj(o->parent)); - if (hash_get(h, name)) - hash_del(h, name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Else if it was a hash element */ - if ((h->type != o->otype->type && revm_convert_object(e, h->type)) || !o->kname || - !hash_get(h, o->kname)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown hash element to remove", -1); - hash_del(h, o->kname); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* REVM API for deleting in lists */ -int revm_elist_del(list_t *h, revmexpr_t *e) -{ - char *name; - list_t *src; - revmobj_t *o; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!h || !e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o = e->value; - if (!o) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", -1); - - /* If the source object is a hash, then we need to do a merge operation ! */ - if (o->otype->type == ASPECT_TYPE_LIST) - { - src = (list_t *) o->get_obj(o->parent); - elist_unmerge(h, src); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* If second parameter was a string */ - if (o->otype->type == ASPECT_TYPE_STR) - { - if (o->get_name) - name = o->get_name(o->root, o->parent); - else - name = (o->immed ? o->immed_val.str : (char *) o->get_obj(o->parent)); - if (elist_get(h, name)) - elist_del(h, name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Else if it was a hash element */ - if ((h->type != o->otype->type && revm_convert_object(e, h->type)) || !o->kname || - !elist_get(h, o->kname)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown hash element to remove", -1); - elist_del(h, o->kname); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* API for setting elements inside hash */ -int revm_hash_set(char *table, char *elmname, void *obj, u_int type) -{ - hash_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!table) - hash_register((hash_t *) obj, elmname); - else - { - h = hash_find(table); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown destination hash table", -1); - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = type; - hash_add(h, elmname, obj); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* API for setting elements inside lists */ -int revm_elist_set(char *table, char *elmname, void *obj, u_int type) -{ - list_t *h; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!table) - elist_register((list_t *) obj, elmname); - else - { - h = elist_find(table); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown destination list", -1); - if (h->type == ASPECT_TYPE_UNKNOW) - h->type = type; - elist_add(h, elmname, obj); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * @brief Copy a simply typed object into another one - * @param o1 Destination object - * @param o2 Source object - * @return Success:0 Error:-1 - */ -/* o1 = destination, o2 = source */ -int revm_object_set(revmexpr_t *e1, revmexpr_t *e2) -{ - revmobj_t *o1; - revmobj_t *o2; - char *str; - eresi_Addr val64; - u_int val32; - u_char val8; - u_short val16; - hash_t *hash; - list_t *list; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - o1 = e1->value; - o2 = e2->value; - - /* Do the real assignation */ - switch (o1->otype->type) - { - case ASPECT_TYPE_STR: - str = (o2->immed ? o2->immed_val.str : o2->get_name(o2->root, o2->parent)); - if (o1->immed) - { - o1->immed_val.str = strdup(str); - o1->size = o2->size; - } - else if (o1->hname && (o1->kname || o2->kname)) - { - if (o1->contype == CONT_HASH) - revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, str, - ASPECT_TYPE_STR); - else if (o1->contype == CONT_LIST) - revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, str, - ASPECT_TYPE_STR); - } - else if (o1->parent == str || !o1->parent) - o1->parent = (str ? strdup(str) : NULL); - else if (o1->set_name(o1->root, o1->parent, str) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, str); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set string variable", -1); - } - break; - - case ASPECT_TYPE_BYTE: - if (o1->otype->isptr) - goto ptrcopy; - val8 = (o2->immed ? o2->immed_val.byte : o2->get_obj(o2->parent)); - if (o1->immed) - o1->immed_val.byte = val8; - else if (o1->hname && (o1->kname || o2->kname)) - { - if (o1->contype == CONT_HASH) - revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val8, ASPECT_TYPE_BYTE); - else if (o1->contype == CONT_LIST) - revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, str, - ASPECT_TYPE_STR); - } - else if (o1->set_obj(o1->parent, val8) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set byte variable", -1); - break; - - case ASPECT_TYPE_SHORT: - val16 = (o2->immed ? o2->immed_val.half : o2->get_obj(o2->parent)); - if (o1->immed) - o1->immed_val.half = val16; - else if (o1->hname && (o1->kname || o2->kname)) - { - if (o1->contype == CONT_HASH) - revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); - else if (o1->contype == CONT_LIST) - revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val16, ASPECT_TYPE_SHORT); - - } - else if (o1->set_obj(o1->parent, val16) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set short variable", -1); - break; - - case ASPECT_TYPE_INT: - intcopy: - val32 = (o2->immed ? o2->immed_val.word : o2->get_obj(o2->parent)); - if (o1->immed) - o1->immed_val.word = val32; - else if (o1->hname && (o1->kname || o2->kname)) - { - if (o1->contype == CONT_HASH) - revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); - else if (o1->contype == CONT_LIST) - revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) (eresi_Addr) val32, ASPECT_TYPE_INT); - - } - else if (o1->set_obj(o1->parent, val32) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set integer variable", -1); - break; - - case ASPECT_TYPE_LONG: - if (sizeof(u_long) == 4) - goto intcopy; - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - ptrcopy: - val64 = (o2->immed ? o2->immed_val.ent : o2->get_obj(o2->parent)); - if (o1->immed) - o1->immed_val.ent = val64; - else if (o1->hname && (o1->kname || o2->kname)) - { - if (o1->contype == CONT_HASH) - revm_hash_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) val64, o1->otype->type); - else if (o1->contype == CONT_LIST) - revm_elist_set(o1->hname, o1->kname ? o1->kname : o2->kname, - (void *) val64, o1->otype->type); - - } - else if (o1->set_obj(o1->parent, val64) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set long variable", -1); - break; - - case ASPECT_TYPE_HASH: - hash = (hash_t *) o2->get_obj(o2->parent); - if (!o1->otype->isptr) - { - if (revm_hash_set(NULL, o1->hname, (void *) hash, o1->otype->type)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set hash table variable", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - o1->immed = 1; - goto ptrcopy; - case ASPECT_TYPE_LIST: - list = (list_t *) o2->get_obj(o2->parent); - if (!o1->otype->isptr) - { - if (revm_elist_set(NULL, o1->hname, (void *) list, o1->otype->type)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set list variable", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - o1->immed = 1; - goto ptrcopy; - default: - *o1 = *o2; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Comparison function */ -int revm_object_compare(revmexpr_t *e1, revmexpr_t *e2, eresi_Addr *val) -{ - revmexpr_t *last; - revmobj_t *res; - revmobj_t *o1; - revmobj_t *o2; - char *str; - char *str2; - eresi_Addr val2; - u_char bval2; - u_short hval2; - u_int ival2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e2 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o1 = e1->value; - o2 = e2->value; - if (!o1 || !o2 || !o1->otype || !o2->otype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", -1); - - /* Lazy typing in action */ - if ((o1->otype->type != ASPECT_TYPE_INT && - o1->otype->type != ASPECT_TYPE_BYTE && - o1->otype->type != ASPECT_TYPE_SHORT && - o1->otype->type != ASPECT_TYPE_CADDR && - o1->otype->type != ASPECT_TYPE_DADDR && - o1->otype->type != ASPECT_TYPE_LONG && - o1->otype->type != ASPECT_TYPE_STR) || - o1->otype->type != o2->otype->type) - { - revm_convert_object(e2, o1->otype->type); - if (o2->otype->type != o1->otype->type) - { - if (!o2->perm && o2->immed && - o2->otype->type == ASPECT_TYPE_STR && str != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,str); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - } - } - str = NULL; - - /* Do the real assignation */ - switch (o1->otype->type) - { - case ASPECT_TYPE_STR: - str2 = (o2->immed ? o2->immed_val.str : o2->get_name(o2->root, o2->parent)); - str = (o1->immed ? o1->immed_val.str : o1->get_name(o1->root, o1->parent)); - if (!str || !str2) - *val = 1; - else - *val = strcmp(str, str2); - break; - case ASPECT_TYPE_BYTE: - bval2 = (o2->immed ? o2->immed_val.byte : o2->get_obj(o2->parent)); - *val = (o1->immed ? o1->immed_val.byte : o1->get_obj(o1->parent)); - *val = *val & 0x000000FF; - *val -= bval2; - break; - - case ASPECT_TYPE_SHORT: - hval2 = (o2->immed ? o2->immed_val.half : o2->get_obj(o2->parent)); - *val = (o1->immed ? o1->immed_val.half : o1->get_obj(o1->parent)); - *val = *val & 0x0000FFFF; - *val -= hval2; - break; - - case ASPECT_TYPE_INT: - ival2 = (o2->immed ? o2->immed_val.word : o2->get_obj(o2->parent)); - *val = (o1->immed ? o1->immed_val.word : o1->get_obj(o1->parent)); - *val = *val & 0xFFFFFFFF; - *val -= ival2; - break; - - case ASPECT_TYPE_LONG: - val2 = (o2->immed ? o2->immed_val.ent : o2->get_obj(o2->parent)); - *val = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - if (sizeof(u_long) == 4) - { - val2 = val2 & 0xFFFFFFFF; - *val = *val & 0xFFFFFFFF; - } - *val -= val2; - break; - - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val2 = (o2->immed ? o2->immed_val.ent : o2->get_obj(o2->parent)); - *val = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - *val -= val2; - break; - - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Uncomparable parameter type", -1); - } - - /* Set the last result variable */ - last = revm_expr_get(REVM_VAR_RESULT); - if (!last) - { - if (!o2->perm && o2->immed && o2->otype->type == ASPECT_TYPE_STR && str != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,str); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get last result variable", -1); - } - revm_expr_destroy(REVM_VAR_RESULT); - res = revm_create_IMMED(ASPECT_TYPE_INT, 1, *val); - last = revm_expr_create_from_object(res, REVM_VAR_RESULT); - if (!last) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set result expression", (-1)); - - /* Success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Test a bit in a bitfield */ -int revm_testbit(revmexpr_t *e1, revmexpr_t *e2, u_int *result) -{ - revmobj_t *o1; - revmobj_t *o2; - revmobj_t *res; - revmexpr_t *last; - eresi_Addr val; - eresi_Addr val2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - o1 = e1->value; - o2 = e2->value; - if (!o1 || !o2 || o1->otype || !o2->otype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters types", -1); - - /* Lazy typing in action */ - if ((o1->otype->type != ASPECT_TYPE_INT && - o1->otype->type != ASPECT_TYPE_BYTE && - o1->otype->type != ASPECT_TYPE_SHORT && - o1->otype->type != ASPECT_TYPE_CADDR && - o1->otype->type != ASPECT_TYPE_DADDR && - o1->otype->type != ASPECT_TYPE_LONG) || - o1->otype->type != o2->otype->type) - { - revm_convert_object(e2, o1->otype->type); - if (o2->otype->type != o1->otype->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - } - - /* Set the last result variable */ - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get last result variable", -1); - res = last->value; - res->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - last->type = res->otype; - - /* Do the real assignation */ - val = (o1->immed ? o1->immed_val.ent : o1->get_obj(o1->parent)); - val2 = (o2->immed ? o2->immed_val.ent : o2->get_obj(o2->parent)); - res->immed_val.ent = *result = ((val & (1 << val2)) >> val2); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/commands.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/commands.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/commands.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/commands.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/* -** @file cmdapi.c -** @ingroup librevm_api -** @brief Commands functions. -** Started on Mon Feb 24 15:52:06 2003 jfv -** Last update Thu Mar 11 14:39:06 2004 jfv -** -** $Id: commands.c,v 1.6 2007-08-03 18:05:03 may Exp $ -** -*/ -#include "revm.h" - - - -/* Create the cmdhandler passed to hash_add() */ -revmcmd_t *revm_create_CMDENT(int (*exec)(void *file, void *av), - int (*reg)(u_int index, u_int argc, char **argv), - int flags, - char *help) -{ - revmcmd_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmcmd_t), NULL); - new->exec = exec; - new->reg = reg; - new->wflags = flags; - new->help = help; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/* Change the handler for an ELFsh command */ -int revm_command_set(char *cmd, void *exec, void *reg, u_int needcur) -{ - listent_t *ent; - revmcmd_t *act; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ent = hash_get_ent(&cmd_hash, cmd); - if (!ent) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [!] Unknown command %s \n\n", world.curjob->curcmd->param[0]); - revm_output(logbuf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Supplied handler invalid", (-1)); - } - act = ent->data; - if (reg != ELFSH_ORIG) - act->reg = reg; - if (exec != ELFSH_ORIG) - act->exec = exec; - if (needcur != (u_int) ELFSH_ORIG) - act->wflags = needcur; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Add a command */ -int revm_command_add(char *cmd, void *exec, void *reg, u_int needfile, - char *help) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - hash_add(&cmd_hash, cmd , (void *) revm_create_CMDENT(exec, reg, needfile, help)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Delete a command */ -int revm_command_del(char *cmd) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_del(&cmd_hash, cmd); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/doswitch.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/doswitch.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/doswitch.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/doswitch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** @file doswitch.c -** @ingroup librevm_api -** @brief Do the switch. -** Started on Sat Jan 25 11:20:49 2003 jfv -** -** $Id: doswitch.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - -/* Do the switch */ -int revm_doswitch(int nbr) -{ - elfshobj_t *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - actual = (nbr ? revm_getfile(nbr) : - hash_get(&file_hash, world.curjob->curcmd->param[0])); - - if (actual == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested object", (-1)); - - world.curjob->curfile = actual; - - /* Switch to static mode if current file is not mapped */ - if (elfsh_is_debug_mode() && !actual->linkmap) - elfsh_set_static_mode(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/edfmt.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/edfmt.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/edfmt.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/edfmt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,338 +0,0 @@ -/* -** @file edfmt.c -** @ingroup librevm_api -** @brief All functions dealing with libedfmt. -** -** Started on Fev 25 2007 mxatone -** -** $Id: edfmt.c,v 1.15 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - -#define VM_EDFMT_VAR_QUEUE_NAME "revm_edfmt_varqueue" -#define TYPE_MAX_ATTR 500 -#define TYPE_ATTR_LEN 256 - -char *tmp_arr[TYPE_MAX_ATTR]; -char arr_pool[TYPE_ATTR_LEN]; - -#define VM_EDFMT_PARSED(_type) \ -_type->parsed = 1 - -hash_t var_queue; - -/* Register a type (and transform its name if needed) */ -static int revm_edfmt_register_type(char isunion, - char *label, - char **fields, - u_int fieldnbr) -{ - - char buf[BUFSIZ]; - int index = 0, len; - int ret = 0; - char *nlabel; - aspectype_t *cur, *new, *inew, *icur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buf, BUFSIZ - 1, "%s", label); - len = strlen(buf); - for (index = 0; index < len && buf[index] == '*'; index++) - buf[index] = 'p'; - nlabel = (char *) strdup(label); - - /* We create the type right now to compare to an existing - type in case of double entry */ - new = aspect_type_create(isunion, nlabel, fields, fieldnbr); - if (!new) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type declaration", -1); - - /* Check if this type already exist */ - cur = hash_get(&types_hash, nlabel); - if (cur) - { - /* Same types ? Compare field names & type names */ - for (inew = new->childs, icur = cur->childs; - inew && icur; inew = inew->next, icur = icur->next) - if (strcmp(inew->fieldname, icur->fieldname) != 0 - || strcmp(inew->name, icur->name) != 0) - goto diff; - - /* Are we okay ? */ - if (icur == inew) - goto add; - - diff: - snprintf(buf, BUFSIZ - 1, " [!] %s has 2 different versions \n", - nlabel); - revm_output(buf); - revm_output(" [!] New type has been discarded \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - add: - ret = aspect_type_register_real(nlabel, new); - if (ret == 0) - revm_type_hashcreate(nlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/* Analyze a given uniform type and add it into ERESI type engine */ -static int revm_edfmt_type_parse(edfmttype_t *type) -{ - edfmttype_t *child = NULL; - int index = 0; - int typeid; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!type || type->parsed) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - VM_EDFMT_PARSED(type); - - typeid = type->type; - - start: - - switch(typeid) - { - case EDFMT_TYPE_UNK: - break; - case EDFMT_TYPE_ARRAY: - if (type->parent) - { - revm_edfmt_type_parse(type->parent); - - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "elm:%s[%d]", type->parent->name, type->size+1); - tmp_arr[index] = strdup(arr_pool); - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "array%d%s", type->size+1, type->parent->name); - - revm_edfmt_register_type(0, arr_pool, tmp_arr, 1); - } - break; - case EDFMT_TYPE_PTR: - if (type->parent) - { - revm_edfmt_type_parse(type->parent); - - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "elm:%s", type->parent->name); - tmp_arr[index] = strdup(arr_pool); - revm_edfmt_register_type(0, type->name, tmp_arr, 1); - } - break; - case EDFMT_TYPE_VOID: - case EDFMT_TYPE_BASIC: - aspect_basetype_register(type->name, type->size); - break; - case EDFMT_TYPE_UNION: - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "elm%%%d", type->size); - tmp_arr[index] = strdup(arr_pool); - revm_edfmt_register_type(1, type->name, tmp_arr, 1); - break; - case EDFMT_TYPE_STRUCT: - /* Resolve all dependencies before */ - for (child = type->child, index = 0; child != NULL; child = child->next, index++) - { - /* We try to avoid infinite loops */ - if (child->child && child->child != type) - revm_edfmt_type_parse(child->child); - } - - for (child = type->child, index = 0; - child != NULL && index < TYPE_MAX_ATTR; - child = child->next, index++) - { - if (child->parent == NULL || child->child == NULL) - continue; - - VM_EDFMT_PARSED(child); - - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "%s:%s", child->name, child->child->name); - tmp_arr[index] = strdup(arr_pool); - } - - revm_edfmt_register_type(0, type->name, tmp_arr, index); - break; - case EDFMT_TYPE_LINK: - if (type->parent) - { - revm_edfmt_type_parse(type->parent); - if (type->name[0] == '*') - { - typeid = EDFMT_TYPE_PTR; - goto start; - } - else - { - if (revm_type_copy(type->parent->name, type->name) == 0) - revm_type_hashcreate(type->name); - } - } - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Add global type into ERESI engine */ -static int revm_edfmt_types(edfmttype_t *types) -{ - edfmttype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (type = types; type != NULL; type = type->next) - if (type->valid) - revm_edfmt_type_parse(type); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Add global variable into ERESI engine */ -static int revm_edfmt_inform(edfmtvar_t *var) -{ - int index = 0, len; - char *str; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!var) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - snprintf(buf, BUFSIZ - 1, "%s", var->name); - len = strlen(buf); - - for (index = 0; index < len && buf[index] == '*'; index++) - buf[index] = 'p'; - - snprintf(buf, BUFSIZ - 1, XFMT, var->addr); - if (var->type->type == EDFMT_TYPE_ARRAY) - { - snprintf(arr_pool, TYPE_ATTR_LEN - 1, - "array%d%s", var->type->size+1, var->type->parent->name); - str = arr_pool; - } - else - str = var->type->name; - - revm_inform_type(str, buf, buf, NULL, 0, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Add some global variable waiting to be added at the end */ -static int revm_edfmt_add_var_queue(edfmtvar_t *vars) -{ - edfmtvar_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!vars) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (var_queue.ent == NULL) - hash_init(&var_queue, VM_EDFMT_VAR_QUEUE_NAME, 50, ASPECT_TYPE_UNKNOW); - - for (var = vars; var != NULL; var = var->next) - { - /* We add the variable only if we don't already have it ! */ - if (hash_get(&var_queue, var->name) == NULL) - hash_add(&var_queue, strdup(var->name), (void *) var); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Proceed variable waiting to be added, then clean the hash table */ -static int revm_edfmt_proceed_var_queue() -{ - char **keys; - u_int index; - int keynbr = 0; - edfmtvar_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&var_queue, &keynbr); - - if (keys) - { - for (index = 0; index < keynbr; index++) - { - var = hash_get(&var_queue, keys[index]); - - if (var) - revm_edfmt_inform(var); - } - - hash_free_keys(keys); - - hash_empty(VM_EDFMT_VAR_QUEUE_NAME); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Iterate each file */ -static int revm_edfmt_file(edfmtfile_t *files) -{ - edfmtfile_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (file = files; file != NULL; file = file->next) - { - revm_edfmt_types(file->types); - revm_edfmt_add_var_queue(file->vars); - - if (file->child) - revm_edfmt_file(file->child); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/* Manage libedfmt and fill inform / types from debuggin informations */ -int revm_edfmt_parse(elfshobj_t *file) -{ - edfmtinfo_t *info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Parse all debugging information */ - edfmt_format(file); - - /* Retrieve uni format ptr */ - info = edfmt_get_uniinfo(file); - - /* This pointer should be NULL only if there's not "parsable" deubgging - informations */ - if (info) - { - /* Global elements */ - revm_edfmt_types(info->types); - - revm_edfmt_add_var_queue(info->vars); - - /* Then local file elements */ - revm_edfmt_file(info->files); - - /* Add register variables */ - revm_edfmt_proceed_var_queue(); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/filter.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/filter.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/filter.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/filter.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/* -** @file filter.c -** @ingroup librevm_api -** @brief Filter 0x00 in the OBJ_TYPESTR object. -** Started on Thu Mar 13 23:27:58 2003 jfv -** Last update Sat Mar 15 07:00:38 2003 jfv -** -** $Id: filter.c,v 1.5 2007-08-03 11:51:00 heroine Exp $ -** -*/ -#include "libui.h" - - -/* Filter \x00 in the OBJ_TYPESTR object */ -void revm_filter_zero(char *buf) -{ - char *ptr; - u_int size; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - size = strlen(buf); - do - { - ptr = strstr(buf, "\\x00"); - if (ptr != NULL) - { - *ptr = 0x00; - memmove(ptr + 1, ptr + 4, (u_int) buf + size - (u_int) (ptr + 4)); - buf = ptr + 1; - size -= 3; - } - else - { - ptr = strstr(buf, "\\x0"); - if (ptr == NULL) - break; - *ptr = 0x00; - memmove(ptr + 1, ptr + 3, (u_int) buf + size - (u_int) (ptr + 3)); - buf = ptr + 1; - size -= 2; - } - } - while (ptr != NULL); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - - -/* Replace \xNUM taking care of the \x00 in a string */ -char *revm_filter_param(char *buf, char *ptr) -{ - u_int nbr; - char c; - char d; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* if string ends with '\x', its over for this entry */ - if (*(ptr + 2) == 0x00) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); - - /* Do exception for \x00 which must not be resolved */ - c = *(ptr + 2); - d = *(ptr + 3); - if (c == '0' && !((d >= 'A' && d <= 'F') || (d >= '1' && d <= '9'))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (buf + (d == '0' ? 4 : 3))); - - /* else read the hexadecimal value */ - else - { - sscanf(ptr + 2, "%X", &nbr); - *ptr = (char) nbr; - buf = ptr + 4; - - /* and copy the data, strcpy put NUL at the end */ - strcpy(ptr + 1, buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ptr + 1)); - } - - assert(1); -} - - - diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/helping.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/helping.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/helping.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/helping.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* -** @file help.c -** @ingroup librevm_api -** @brief The help command. -** Started on Sat Jan 25 11:19:18 2003 jfv -** $Id: helping.c,v 1.1 2007-11-29 14:08:47 may Exp $ -** -*/ -#include "revm.h" - -/* The Help command */ -int revm_help(char *command) -{ - revmcmd_t *cmd; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* The general message */ - if (!command) - { - snprintf(logbuf, BUFSIZ - 1, - "\n The Reverse Engineering Vector Machine (REVM Version %s compiled for %s objects)\n\n\n" - " General purpose commands .::. help, info, cat, exec, edit, sdir, lscripts, profile \n" - " quit, exit, load, unload, switch, list, workspace \n" - " setcolor, nocolor, configure, add, sub, mul, div, \n" - " mod, cmp, print, stop \n" - " Ondisk/Memory ELF commands .::. elf, interp, pht, got, sht, rel, notes, dyn, dynsym \n" - " findrel, ctors, write, set, reladd, coreinfo, \n" - " verneed, verdef \n" - " Ondisk only ELF commands .::. flush, save, sym, stab, append, extend, insert, \n" - " remove, rename, unstrip \n" - " Function redirect commands .::. redir, flowjack \n" - " Debugging commands .::. break, delete, continue, dumpregs, stack, dbgstack \n" - " backtrace, linkmap, step, display, itrace, threads \n" - " Tracing commands .::. traces, traceadd, tracerun \n" - " Assembly level commands .::. disasm, hexa, inspect \n" - " Code analysis commands .::. analyse, graph, addgoto, setgvl \n" - " Types related commands .::. type, typedef, inform, uninform \n" - " Transformation commands .::. rewrite, case, default \n" - " Reflection commands .::. vectors, tables, lists, reflect \n" - " ELF objects flags .::. fixup, shtrm, sstrip \n" - " REVM modules commands .::. modload, modunload, modhelp \n" - " Network commands .::. net, netlist, netkill, connect, disconnect, peerslist, rcmd \n" - " Available prefixes .::. all, sort, quiet, verb, alert \n" - " Available Script jumps .::. jmp, je, jne, jg, jl, jge, jle \n" - " Available modules .::. modtest, modremap \n\n" - - " Type 'help command' for specific information\n\n", - - REVM_VERSION, -#if defined(ERESI32) - "32 bits" -#elif defined(ERESI64) - "64 bits" -#else - "Unknown built" -#endif - ); - revm_output(logbuf); - } - - /* Command specific help */ - else - { - cmd = hash_get(&cmd_hash, command); - if (!cmd) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown command", -1); - revm_output("\t"); - revm_output(command); - revm_output(" : "); - revm_output(cmd->help); - revm_output("\n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/implicit.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/implicit.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/implicit.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/implicit.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -/* -** @file implicit.c -** @brief Load the working files. -** @ingroup librevm_api -** Started on Tue Feb 18 06:45:35 2003 jfv -** -** $Id: implicit.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - - -/* Load the working files */ -void revm_workfiles_load() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.input == NULL) - { - revm_help(NULL); - revm_exit(-1); - } - world.curjob->curfile = (world.state.output != NULL ? - elfsh_map_obj(world.state.input) : - elfsh_load_obj(world.state.input)); - if (world.curjob->curfile == NULL) - { - perror(world.state.input); - revm_exit(-1); - } - - hash_add(&world.curjob->loaded, world.curjob->curfile->name, - world.curjob->curfile); - hash_add(&file_hash, world.curjob->curfile->name, - (void *) world.curjob->curfile); - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, "\n [*] Object %s has been loaded (%s) \n\n", - world.state.input, - (world.state.output != NULL ? "O_RDWR" : "O_RDONLY")); - revm_output(logbuf); - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - - -/* Unload (and save if asked) files */ -int revm_workfiles_unload() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.output) - switch (elfsh_save_obj(world.curjob->curfile, world.state.output)) - { - case 0: - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Object %s saved successfully \n\n", - world.state.output); - revm_output(logbuf); - } - break; - default: - snprintf(logbuf, BUFSIZ - 1, - " [*] Unable to save modified object in %s \n\n", - world.state.output); - revm_output(logbuf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to save object", (-1)); - } - else - { - elfsh_unload_obj(world.curjob->curfile); - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Object %s unloaded \n\n", world.state.input); - revm_output(logbuf); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* Do all implicit operation when calling elfsh from a script */ -int revm_implicit(revmcmd_t *actual) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If the requested command does not need a current pointer */ - if (actual && !actual->wflags) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Load implicit current file */ - else if (world.state.revm_mode == REVM_STATE_CMDLINE && - world.curjob->curfile == NULL) - { - if (!world.state.revm_sourcing) - revm_workfiles_load(); - if (!world.curjob->curfile) - { - revm_help(NULL); - revm_exit(-1); - } - } - - /* Do error in imode if current is NULL */ - else if (((world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_SCRIPT) && - !world.curjob->curfile)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No file loaded", -1); - - /* We need to set it here since the CURRENT object can change */ - asm_set_resolve_handler(&world.proc, asm_do_resolve, world.curjob->curfile); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/inform.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/inform.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/inform.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/inform.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,383 +0,0 @@ -/* -** @file inform.c -** @ingroup librevm_api -** @brief API for annotating program objects. -** -** Started Jan 21 2007 12:57:03 jfv -** $Id: inform.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/** - * @brief Create an expression tree ad-hoc, recursively, and without initialization - * @param curpath Current path for constructed object - * @param curexpr Currently constructed expression - * @param type Type of the root node - * @param addr Address of currently constructed object - * @param translateaddr Translate pointers between analyzed and analyzer address space - * @return - */ -static revmexpr_t *revm_inform_subtype(char *curpath, - revmexpr_t *curexpr, - aspectype_t *type, - eresi_Addr addr, - char translateaddr) -{ - char pathbuf[BUFSIZ]; - aspectype_t *curtype; - revmexpr_t *newexpr, *rootexpr, *prevexpr; - eresi_Addr childaddr; - u_int len; - static u_int pathsize = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - newexpr = rootexpr = prevexpr = NULL; - - /* We are at the first iteration : create root expression */ - pathsize = snprintf(pathbuf, sizeof(pathbuf), "%s", curpath); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [I] Current expr path before loop (%s) \n", pathbuf); -#endif - - /* Iterate over all fields */ - for (curtype = type->childs; curtype; curtype = curtype->next) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, newexpr, sizeof(revmexpr_t), NULL); - newexpr->type = curtype; - childaddr = addr + curtype->off; - newexpr->label = curtype->fieldname; - newexpr->parent = curexpr; - - /* Recurse over record children. */ - /* Do not recurse on pointers else we get infinite loops ! */ - if (curtype->childs && !curtype->isptr) - { - len = snprintf(pathbuf + pathsize, BUFSIZ - pathsize, ".%s", curtype->fieldname); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [I] Curchild expr path will be informed recursively (%s) \n", pathbuf); -#endif - - revm_inform_type_addr(curtype->name, pathbuf, childaddr, newexpr, 0, 0); - pathsize += len; - revm_inform_subtype(pathbuf, newexpr, curtype, childaddr, translateaddr); - pathsize -= len; - bzero(pathbuf + pathsize, len); - } - - /* Simply lookup terminal fields */ - else - { - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [I] Current TERMINAL path inside loop (%s::%s) \n", - pathbuf, curtype->fieldname); -#endif - - newexpr->value = revm_object_lookup_real(type, pathbuf, curtype->fieldname, translateaddr); - if (!newexpr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup terminal object", NULL); - len = snprintf(pathbuf + pathsize, BUFSIZ - pathsize, ".%s", curtype->fieldname); - revm_inform_type_addr(curtype->name, pathbuf, childaddr, newexpr, 0, 0); - bzero(pathbuf + pathsize, len); - } - - /* Link fields and children in the constructed expression */ - if (curexpr) - { - rootexpr = curexpr; - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - { - curexpr->childs = newexpr; - prevexpr = newexpr; - } - } - else - { - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - rootexpr = prevexpr = newexpr; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rootexpr); -} - - - -/* Print registered variables for a given type */ -int revm_informed_print(char *name) -{ - hash_t *hash; - char buf[BUFSIZ]; - revmannot_t *annot; - char **keys; - int index; - int keynbr; - - /* Preliminary checks */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buf, sizeof(buf), "type_%s", name); - hash = hash_find(buf); - if (!hash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown informed type", -1); - - /* Retreive hash table content and print it */ - keys = hash_get_keys(hash, &keynbr); - if (keynbr) - revm_output(" .:: Registered variables for this type \n\n"); - for (index = 0; index < keynbr; index++) - { - annot = hash_get(hash, keys[index]); - snprintf(buf, sizeof(buf), " + ["AFMT"] %-30s \n", annot->addr, keys[index]); - revm_output(buf); - } - - /* End message */ - if (!keynbr) - revm_output(" .:: No registered variables for this type \n\n"); - else - { - snprintf(buf, sizeof(buf), - "\n .:: Displayed %u registered variables for type %s \n\n", - keynbr, name); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Check the validity of an address - */ -int revm_check_addr(elfshobj_t *obj, eresi_Addr addr) -{ - elfsh_Phdr *phdr; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (index = 0, phdr = obj->pht; index < obj->hdr->e_phnum; index++) - if (phdr[index].p_type == PT_LOAD && - phdr[index].p_vaddr < addr && - addr < phdr[index].p_vaddr + phdr[index].p_memsz) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Add an elemnt to the inform table for a given type, by real address */ -revmexpr_t *revm_inform_type_addr(char *type, - char *varname, - eresi_Addr addr, - revmexpr_t *expr, - u_char print, - u_char rec) -{ - revmexpr_t *ret; - char *addrbuf; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, addrbuf, 20, NULL); - snprintf(addrbuf, 20, "0x%08lX", (unsigned long) addr); - ret = revm_inform_type(type, varname, addrbuf, expr, print, rec); - if (ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inform type by address", NULL); -} - - -/** - * @brief Add an element to the inform table for a given type - */ -revmexpr_t *revm_inform_type(char *type, char *varname, - char *straddr, revmexpr_t *expr, - u_char print, u_char rec) -{ - hash_t *hash; - char buf[BUFSIZ]; - eresi_Addr addr; - eresi_Addr oaddr; - char *realname; - char *symname; - revmannot_t *annot; - elfsh_SAddr off; - aspectype_t *rtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Add element in the good hash table */ - rtype = aspect_type_get_by_name(type); - snprintf(buf, sizeof(buf), "type_%s", type); - hash = hash_find(buf); - if (!hash || !rtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested type", NULL); - - /* The address is not precised, to to find it from the varname */ - if (!straddr) - straddr = varname; - -#if __DEBUG_EXPRS__ - fprintf(stderr, "\n [D] Variable %40s LOOKED UP\n", varname); -#endif - - /* The address is given, lookup it */ - if (!hash_get(&exprs_hash, varname)) - realname = revm_lookup_string(varname); - else - realname = varname; - oaddr = revm_lookup_addr(straddr); - - /* Adding expression and its type to hash tables */ -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Variable %40s TO BE added to exprs_hash with type %s \n", realname, rtype->name); -#endif - - /* Only check for addr range if print flag (manual inform) is on */ - if (print && (!oaddr || !revm_check_addr(world.curjob->curfile, oaddr))) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable address", NULL); - if (!realname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable name", NULL); - - if (hash_get(&exprs_hash, realname)) - hash_del(&exprs_hash, realname); - - /* If just the address was given, lookup or create a name for the variable */ - if (IS_VADDR(realname)) - { - sscanf(realname + 2, AFMT, &addr); - symname = elfsh_reverse_symbol(world.curjob->curfile, addr, &off); - if (symname && !off) - realname = strdup(symname); - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, realname, strlen(type) + 20, NULL); - snprintf(realname, sizeof(realname), "%s_"AFMT, type, addr); - } - } - addr = oaddr; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, annot, sizeof(revmannot_t), NULL); - - /* Setup current string table offset, type, scope, and representation */ - annot->nameoff = revm_strtable_add(realname); - annot->typenum = rtype->type; - annot->scope = EDFMT_SCOPE_GLOBAL; - annot->addr = addr; - - /* This must be done before informing subtypes, as we will need - the annotation to create subfields of pointed expressions (e.g. hash/list elems) */ - hash_set(hash, strdup(realname), (void *) annot); - - /* If no expression was given (manual inform) we need to create one ad-hoc */ - if (!expr) - { - - /* FIXME: Note that expr can remain NULL if rec == 0 and childs != NULL (arrays) */ - if (rtype->childs && rec) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, sizeof(revmexpr_t), NULL); - expr->strval = NULL; - expr->label = realname; - expr->type = rtype; - - // XXX: changed NULL for expr (testing) - expr->childs = revm_inform_subtype(realname, NULL, rtype, oaddr, print); - } - else if (!rtype->childs) - expr = revm_simple_expr_create(rtype, realname, NULL); - } - - /* Else if recursion is asked on an existing expression (set $expr $existingexpr) */ - else if (rec && rtype->childs) - revm_inform_subtype(realname, expr, rtype, oaddr, print); - - /* Register the expression */ - annot->expr = expr; - hash_set(&exprs_hash, (char *) strdup(realname), (void *) expr); - - /* Adding expression and its type to hash tables */ -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Variable %40s ADDED to exprs_hash with type %s \n", realname, rtype->name); -#endif - - /* Success message and exit */ - if (print) - { - snprintf(buf, sizeof(buf), - " [*] Type %s succesfully informed of variable %s [" XFMT "]\n\n", - type, realname, annot->addr); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); -} - - - -/* Add an element to the inform table for a given type */ -int revm_uninform_type(char *type, char *varname, u_char print) -{ - hash_t *hash; - char buf[BUFSIZ]; - char *realname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Grab element in the good hash table */ - snprintf(buf, sizeof(buf), "type_%s", type); - hash = hash_find(buf); - if (!hash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested type", -1); - - /* In case we have to remove everything at once */ - if (!varname) - { - hash_empty(buf); - if (print) - { - snprintf(buf, sizeof(buf), - " [*] Hash information for type %s succesfully reset \n\n", type); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* In case we just have to remove one variable */ - realname = revm_lookup_string(varname); - if (!realname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable name", -1); - - if (!hash_get(hash, realname)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown typed variable", -1); - - if (print) - { - snprintf(buf, sizeof(buf), - " [*] Type %s succesfully uninformed of object %s \n\n", - type, realname); - revm_output(buf); - } - hash_del(hash, realname); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/job.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/job.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/job.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/job.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,101 +0,0 @@ -/* -** @file job.c -** @ingroup librevm_api -** @brief Create a new job structure. -** Started on Wed Jul 20 22:22:35 2005 yann_malcom -** -** $Id: job.c,v 1.5 2007-11-29 14:01:55 may Exp $ -** -*/ -#include "revm.h" - - -/* Create a new job structure */ -revmjob_t *revm_clone_job(char *newname, revmjob_t *job) -{ - revmjob_t *new; - int i; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmjob_t), NULL); - memcpy(new, job, sizeof(revmjob_t)); - bzero(&new->loaded, sizeof(hash_t)); - bzero(&new->dbgloaded, sizeof(hash_t)); - - snprintf(logbuf, sizeof(logbuf), "%s_loaded", newname); - hash_init(&new->loaded, strdup(logbuf), 51, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_dbgloaded", newname); - hash_init(&new->dbgloaded, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - - /* empty new job */ - new->curcmd = NULL; - new->sourced = 0; - new->ws.active = 0; - new->ws.oldline = NULL; - new->ws.screen.buf = new->ws.screen.tail = new->ws.screen.head = NULL; - - for (i = 0; i < REVM_MAXSRCNEST; i++) - { - new->script[i] = NULL; - new->lstcmd[i] = NULL; - } - new->ws.createtime = time(&new->ws.createtime); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/* Switch of current job */ -void revm_switch_job(revmjob_t *job) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Save the active buffer line */ - revm_job_preswitch(); - world.curjob->ws.active = 0; - world.curjob = job; - job->ws.active = 1; - revm_job_postswitch(); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/* Is this workspace valid for switching ? */ -int revm_valid_workspace(char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (!name[0]) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (!strncmp(name, "net_init", 5)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (isdigit(name[0])) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - - -/* Is this workspace the current one ? */ -int revm_own_job(revmjob_t *job) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!job) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (job->ws.io.type != world.curjob->ws.io.type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (job->ws.io.input_fd != world.curjob->ws.io.input_fd) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (job->ws.io.output_fd != world.curjob->ws.io.output_fd) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -## -## Makefile for vm in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = atomic.c commands.c doswitch.c edfmt.c filter.c job.c \ - implicit.c misc.c modlist.c screen.c stringtable.c \ - inform.c sourcing.c helping.c printing.c typing.c - -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME32 = ../revm-api.32.o -NAME64 = ../revm-api.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libaspect/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -all32: $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) - -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -fclean : clean - @$(RM) $(NAME32) $(NAME64) - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/misc.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/misc.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/misc.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/misc.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,396 +0,0 @@ -/* -** @file misc.c -** @ingroup librevm_api -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Fri Sep 11 17:26:11 2005 jfv -** -** $Id: misc.c,v 1.15 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/** - * return the project name accordingly to mode - * @return - */ -char *revm_modename_get() -{ - char *mode; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - mode = E2DBG_NAME; - else - mode = REVM_NAME; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (mode)); -} - - -/** - * Our system implementation - * @param cmd - */ -int revm_system(char *cmd) -{ - char buf[BUFSIZ]; - int ret; - char **av; - int nbr; - int argc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->ws.io.type == REVM_IO_NET) - snprintf(buf, BUFSIZ, "%s <&%u >&0 2>&0 ", cmd, world.curjob->ws.io.output_fd); - else - snprintf(buf, BUFSIZ, "%s ", cmd); - - /* If the user shell is unspecified we use system */ - nbr = revm_findblanks(cmd); - av = revm_doargv(nbr, (u_int *)&argc, cmd); - av++; - if (!fork()) - ret = execvp(av[0], av); - else - wait(NULL); - - /* Report result */ - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Shell not found", 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Decide what to do for exiting depending on the current input - * @param err - * @return - */ -void revm_exit(int err) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - _exit(err); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Bad parameter handler - * @param str - * @return - */ -void revm_badparam(char *str) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, - "\n [!] Invalid parameters for command %s .::. " - "type 'help' for command list \n\n", str); - revm_output(buf); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Unknow command handler - * @param str - */ -void revm_unknown(char *str) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, "\n [!] Unknown command %s .::. " - "type 'help' for command list \n\n", str); - revm_output(buf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Generic error message handler - * - * @param label - * @param param - */ - -void revm_error(char *label, char *param) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, " [!] %s [%s] \n\n", label, param); - revm_output(buf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Open the script file - */ -int revm_openscript(char **av) -{ - int fd; - int idx; - char actual[16]; - revmobj_t *new; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Open script file */ - XOPEN(fd, av[0], O_RDONLY, 0, -1); - world.curjob->ws.io.input_fd = fd; - - /* Add argument variables */ - for (idx = 1; av[idx]; idx++) - { - snprintf(actual, sizeof(actual), "$%u", idx); - new = revm_create_IMMEDSTR(1, strdup(av[idx])); - expr = revm_expr_create_from_object(new, actual); - } - - new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - expr = revm_expr_create_from_object(new, REVM_VAR_ARGC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Say if we are in script mode - */ -int revm_testscript(int ac, char **av) -{ - int fd; - char buff[30]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (ac < 2 || (av[1] && av[1][0] == REVM_DASH)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - XOPEN(fd, av[1], O_RDONLY, 0, 0); - XREAD(fd, buff, 30, 0); - buff[29] = 0x00; - if (strncmp(buff, "#!", 2)) - { - XCLOSE(fd, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid script interpreter", 0); - } - - /* FIXME-XXX: Make it possible to register its interpreter name */ - if (!strstr(buff, av[0]) && - !strstr(buff, "elfsh") && - !strstr(buff, "etrace") && - !strstr(buff, "e2dbg") && - !strstr(buff, "evarista")) - { - XCLOSE(fd, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not an ERESI script", 0); - } - XCLOSE(fd, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Print the banner - */ -void revm_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - revm_modename_get(), - REVM_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - - revm_output(logbuf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Print the Unknown buffer - */ -char *revm_build_unknown(char *buf, const char *str, u_long type) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, ELFSH_MEANING, "%s %08X", str, (u_int) type); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); -} - - -/** - * Retreive a file object giving its unique ID - */ -elfshobj_t *revm_getfile(u_int id) -{ - elfshobj_t *cur; - elfshobj_t *subcur; - char **keys; - int idx; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check in private objects of the workspace */ - if (hash_size(&world.curjob->loaded)) - { - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (idx = 0; idx < keynbr; idx++) - { - cur = hash_get(&world.curjob->loaded, keys[idx]); - if (cur->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - - if ((subcur = revm_is_depid(cur, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (subcur)); - } - } - - /* Check in shared objects */ - if (hash_size(&world.shared_hash)) - { - keys = hash_get_keys(&world.shared_hash, &keynbr); - for (idx = 0; idx < keynbr; idx++) - { - cur = hash_get(&world.shared_hash, keys[idx]); - if (cur->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - - if ((subcur = revm_is_depid(cur, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (subcur)); - } - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find file", (NULL)); -} - -/** - * Retreive a module object giving its unique ID - */ -revmmod_t *revm_getmod(u_int index) -{ - revmmod_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (cur = world.modlist; cur; cur = cur->next) - if (cur->id == index) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find module", (NULL)); -} - -/** - * Print error depending on the state of the machine - */ -int revm_doerror(void (*fct)(char *str), char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_mode != REVM_STATE_CMDLINE || world.state.revm_net) - fct(str); - else - { - revm_help(NULL); - exit(-1); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bypassed error printing", (-1)); -} - - -/** - * Change the shell variable - */ -int revm_setshell(char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_setvar_str(REVM_VAR_SHELL, str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot modify shell var", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * The internal basename function - */ -char *revm_basename(char *str) -{ - char *cur; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = NULL; - cur = str; - while ((cur = strchr(cur, '/'))) - if (!*(cur + 1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No basename", (NULL)); - else - ret = ++cur; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * Useful to differentiate 0 and a string - */ -int revm_isnbr(char *string) -{ - size_t len = strlen(string); - size_t ii; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (ii=0; ii < len; ii++) - if (!isdigit((int) string[ii])) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - - - -/** - * Concatenate all parameters and return a single string - */ -char *revm_string_get(char **params) -{ - char buff[BUFSIZ]; - int idx; - int len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (len = idx = 0; params[idx]; idx++) - len += snprintf(buff + len, BUFSIZ - len, "%s%s", - (idx ? " " : ""), params[idx]); - if (len) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - strdup(buff)); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Empty parameter", NULL); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/modlist.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/modlist.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/modlist.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/modlist.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** @file modlist.c -** @ingroup librevm_api -** @brief List the loaded eresi module. -** Started on Wed Feb 19 04:42:47 2003 jfv -** -** $Id: modlist.c,v 1.6 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/** - * List the loaded ERESI modules - * - * @return - */ -int revm_modlist() -{ - revmmod_t *actual; - u_int index; - char *time; - char *nl; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output(" .::. ELFsh modules .::. \n"); - index = 1; - for (actual = world.modlist; actual != NULL; actual = actual->next, index++) - { - time = ctime(&actual->loadtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - snprintf(logbuf, BUFSIZ - 1, " [%03u] %s ID: %u [%s] \n", - index, time, actual->id, actual->path); - revm_output(logbuf); - } - if (world.modlist == NULL) - revm_output(" [*] No loaded module\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/printing.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/printing.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/printing.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/printing.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* - * @file printing.c - * @ingroup librevm_api - * @brief This file contains various printing facilities API. - * - * Started on Wed Dec 05 23:02:04 2003 jfv - * $Id: printing.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - */ -#include "revm.h" - - - -/** - * Debug purpose - * - * @param start - * @return - */ -int revm_printscript(revmargv_t *start) -{ - revmargv_t *list; - u_int index; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output(" .:: Printing Script: \n"); - - if (start) - list = start; - else - list = world.curjob->script[world.curjob->sourced]; - - for (index = 0; list; list = list->next, index++) - { - snprintf(logbuf, BUFSIZ - 1, "[%03u] ~%s %p \n", - index, list->name, list); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Scripting report purpose - * @param cur - * @return - */ -void revm_print_actual(revmargv_t *cur) -{ - int idx; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, "~%s ", cur->name); - revm_output(logbuf); - for (idx = 0; cur->param[idx] && idx < 10; idx++) - { - snprintf(logbuf, BUFSIZ - 1, "%s ", cur->param[idx]); - revm_output(logbuf); - } - putchar('\n'); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/screen.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/screen.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/screen.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/screen.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,122 +0,0 @@ -/* -** @file screen.c -** @ingroup librevm_api -*/ -/* -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Thu Jan 04 11:22:11 2007 jfv -** -** $Id: screen.c,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/** - * Clear the content of the current screen - * @param i - * @param c - * @return - */ -int revm_screen_clear(int i, char c) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XFREE(__FILE__, __FUNCTION__, __LINE__,world.curjob->ws.screen.buf); - world.curjob->ws.screen.head = world.curjob->ws.screen.tail = NULL; - world.curjob->ws.screen.buf = NULL; - revm_ctrl_set(i, c); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Update the screen depending of the actual job - * - * @param isnew - * @param prompt_display - * @return - */ -int revm_screen_update(u_short isnew, u_short prompt_display) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* clear screen */ - revm_output_nolog("\033[2J"); - revm_output_nolog("\033[0;0H"); - revm_buffer_reset(isnew); - revm_flush(); - - /* Rebuild the current screen */ - if (world.curjob->ws.screen.buf != NULL) - { - revm_output_nolog(world.curjob->ws.screen.head); - if (world.curjob->ws.screen.head >= world.curjob->ws.screen.tail) - { - revm_output_nolog(world.curjob->ws.screen.head); - revm_output_nolog(world.curjob->ws.screen.buf); - } - } - - revm_screen_change(isnew, prompt_display); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Switch screen with switching workspace - * - */ -int revm_screen_switch() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_workspace_next() <= 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_screen_update(0, 1)); -} - - -/** - * Switch to the next workspace - * - */ -int revm_workspace_next() -{ - u_int index, entrie; - char **keys; - int keynbr; - revmjob_t *curjob; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.jobs, &keynbr); - if (keynbr <= 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Search the current index */ - for (index = 0; index < keynbr; index++) - { - curjob = hash_get(&world.jobs, keys[index]); - if (revm_own_job(curjob) && curjob == world.curjob) - { - entrie = index; - break; - } - } - - /* Search the next entrie */ - for (entrie = (entrie+1) % keynbr; entrie < keynbr; entrie = (entrie+1) % keynbr) - { - curjob = hash_get(&world.jobs, keys[entrie]); - if (revm_own_job(curjob)) - { - /* If we found the current job, we made a loop, so we break */ - if (curjob == world.curjob) - break; - revm_switch_job(curjob); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - } - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find workspace to switch on", -1); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/sourcing.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/sourcing.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/sourcing.c.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/sourcing.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ -/** -** @file sourcing.c -** -** @ingroup librevm_api -*/ -/* -** Started on Fri May 16 15:18:35 2005 jfv -** $Id: sourcing.c,v 1.4 2008-02-16 12:32:27 thor Exp $ -*/ -#include "revm.h" - - -/** - * @brief Command interface for ERESI script sourcing - * - * @param params - * @return - */ -int revm_source(char **params) -{ - char *str; - int fd; - int savedfd; - char savedmode; - revmargv_t *savedcmd; - char *(*savedinput)(); - char **argv; - char **av; - int ac; - int idx; - char actual[26]; - char framename[26]; - int argc; - int ret; - revmobj_t *new; - revmexpr_t *prevargc; - revmexpr_t *expr; - revmexpr_t *param; - list_t *newframe; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* build argc */ - for (argc = idx = 0; params[idx] != NULL; idx++) - argc++; - if (!idx) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", (-1)); - - /* Resolve the parameter */ - str = revm_lookup_string(params[0]); - if (!str) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", (-1)); - - /* Switch to debugger script mode when sourcing */ - /* This does not include execution of .eresirc in the debugger */ - if (!strstr(str, REVM_CONFIG) && world.state.revm_mode == REVM_STATE_DEBUGGER) - world.state.revm_sourcing = 1; - - /* Open the script file and pass its parameters */ - argv = alloca((2 + argc) * sizeof(char *)); - argv[0] = "#!elfsh"; - argv[1] = str; - if (!revm_testscript(2, argv)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid script file", -1); - - /* Copy all procedure parameters as new objects arguments */ - snprintf(framename, sizeof(framename), "%u", world.curjob->sourced); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newframe, sizeof(list_t), -1); - elist_init(newframe, strdup(framename), ASPECT_TYPE_EXPR); - - /* Create new parameters and store the old ones in a frame */ - for (ac = 1; params[ac]; ac++) - { - - /* Get the parameter value. Can be a previous function parameter ($Num) itself - -> lookup has to be done before creating the new parameter */ - expr = revm_lookup_param(params[ac]); - - /* Then save the previous $1...N variables */ - argv[ac + 1] = params[ac]; - snprintf(actual, sizeof(actual), "$%u", ac); - param = revm_expr_get(actual); - if (param) - { - elist_add(newframe, strdup(actual), (void *) param); - hash_del(&exprs_hash, (char *) actual); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s stacked with type = %s \n", - actual, (param->type ? param->type->name : "UNKNOWN TYPE")); -#endif - } - - /* Then install the new ones */ - /* This will copy the parameter expression under the name "$N" - and name it in the expression hash table */ - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s added with type = %s \n", - actual, (expr->type ? expr->type->name : "UNKNOWN TYPE")); -#endif - - expr = revm_expr_copy(expr, actual, 0); - } - argv[ac + 1] = NULL; - - /* Create new argc variable and add the new frame to the list */ - prevargc = revm_expr_get(REVM_VAR_ARGC); - if (prevargc) - hash_del(&exprs_hash, (char *) REVM_VAR_ARGC); - new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - revm_expr_create_from_object(new, REVM_VAR_ARGC); - elist_add(&frames_list, strdup(framename), (void *) newframe); - - /* Prepare the interpreter for executing a new script */ - XOPEN(fd, str, O_RDONLY, 0, -1); - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 251, ASPECT_TYPE_STR); - expr = revm_expr_get(REVM_VAR_ESHLEVEL); - expr->value->immed_val.ent = world.curjob->sourced; - - /* Save state for restoring on "continue" */ - savedfd = world.curjob->ws.io.input_fd; - savedinput = world.curjob->ws.io.input; - savedmode = world.state.revm_mode; - savedcmd = world.curjob->curcmd; - - /* Temporary takes input from the script file */ - revm_setinput(&world.curjob->ws, fd); - world.curjob->ws.io.input_fd = fd; - world.state.revm_mode = REVM_STATE_SCRIPT; - world.curjob->ws.io.input = revm_stdinput; - - /* First we parse the script file */ - do { - av = revm_input(&ac, NULL); - if (av == ((char **) REVM_INPUT_VOID)) - continue; - else if (!av || !world.curjob->curcmd) - { - world.state.revm_sourcing = 0; - break; - } - if (revm_parseopt(ac, av) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,av); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid script", (-1)); - } - } while (1); - - /* We then execute the parsed script */ - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - - /* If we are executing a debugger script, do not clear everything yet */ - switch (revm_execscript()) - { - case REVM_SCRIPT_CONTINUE: - world.context.savedfd = savedfd; - world.context.savedmode = savedmode; - world.context.savedcmd = savedcmd; - world.context.savedinput = savedinput; - world.context.savedargv = argv; - world.context.savedname = str; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); - case (-1): - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to execute script", (-1)); - - /* Restore the context immediately if no continue is met */ - default: - ret = revm_context_restore(savedfd, savedmode, savedcmd, savedinput, argv, str); - if (prevargc) - hash_set(&exprs_hash, strdup((char *) REVM_VAR_ARGC), prevargc); - expr->value->immed_val.ent = world.curjob->sourced; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - } - -} - - - -/** - * Restore the previous debugger control context. - * Mostly useful when using 'continue' command from a debugger script - * - * @param savedfd - * @param savedmode - * @param savedcmd - * @param savedinput - * @param argv - * @param savedname - * @return - */ -int revm_context_restore(int savedfd, - char savedmode, - revmargv_t *savedcmd, - void *savedinput, - char **argv, - char *savedname) -{ - list_t *lastframe; - char buf[BUFSIZ]; - u_int idx; - char **keys; - int keynbr; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Restore modified control context */ - world.curjob->ws.io.input_fd = savedfd; - world.state.revm_mode = savedmode; - world.curjob->curcmd = savedcmd; - world.curjob->ws.io.input = savedinput; - if (!world.state.revm_quiet) - { - snprintf(buf, BUFSIZ, "\n [*] %s sourcing -OK- \n", savedname); - revm_output(buf); - } - - /* Link back all parameters and their types */ - snprintf(buf, BUFSIZ, "%u", world.curjob->sourced - 1); - lastframe = elist_get(&frames_list, buf); - if (!lastframe) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - keys = elist_get_keys(lastframe, &keynbr); - for (idx = 0; idx < keynbr; idx++) - { - expr = elist_get(lastframe, keys[idx]); - hash_set(&exprs_hash , keys[idx], expr); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Parameter %s restored with type = %s \n", - keys[idx], expr->type->name); -#endif - - } - - /* Destroy frame */ - elist_destroy(lastframe); - elist_del(&frames_list, buf); - elist_free_keys(keys); - - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; - - /* Return OK */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Execute a command given by a string in the current job - * - * @param str - * @return - */ -int revm_exec_str(char *str) -{ - int nbr; - char **av; - int ac; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - nbr = revm_findblanks(str); - av = revm_doargv(nbr, (u_int *)&ac, str); - if (revm_parseopt(ac, av) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,av); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command failed", (-1)); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/stringtable.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/stringtable.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/stringtable.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/stringtable.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* -** @file stringtable.c -** @ingroup librevm_api -** @brief All functions about string table management -** -** Started on Sept 11 2005 mxatone -** -*/ -#include "revm.h" - -#define STRTABLE_IT 256 - -/* Table pointers */ -char *strtable = NULL; -u_int strtable_current = 0; -u_int strtable_max = 0; - -/** - * Add a new element to the string table - * - * @param string - * @return - */ -int revm_strtable_add(char *string) -{ - u_int string_len; - int off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!string || !string[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid string", -1); - - string_len = strlen(string); - - if (strtable == NULL) - { - strtable_max = STRTABLE_IT; - XALLOC(__FILE__, __FUNCTION__, __LINE__,strtable, strtable_max * sizeof(char), -1); - } - else if (strtable_max <= strtable_current + string_len) - { - /* Find the correct value */ - do { - strtable_max += STRTABLE_IT; - } while (strtable_max <= strtable_current + string_len); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__,strtable, strtable, strtable_max * sizeof(char), -1); - } - - /* Copy string */ - strcpy(strtable + strtable_current, string); - strtable[strtable_current + string_len] = 0x00; - - /* Update positions */ - off = strtable_current; - strtable_current += string_len + 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, off); -} diff -Nru eresi-0.8a25/librevm/api/.svn/text-base/typing.c.svn-base eresi-0.0.20110516/librevm/api/.svn/text-base/typing.c.svn-base --- eresi-0.8a25/librevm/api/.svn/text-base/typing.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/.svn/text-base/typing.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,249 +0,0 @@ -/** -* @file typing.c -* @ingroup librevm_api -* @brief Various API for manipulating types. -* -* Started on Sun Jan 9 07:23:58 2007 jfv -* $Id: typing.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - - -/** - * Do a copy meta-representation of a datatype - * @param from Source type name to copy from - * @param to Destination type name to copy into - * @return 0 on success, or < 0 on error. - */ -int revm_type_copy(char *from, char *to) -{ - aspectype_t *tocopy, *newtype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - tocopy = (aspectype_t *) hash_get(&types_hash, from); - if (!tocopy) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Type not found", -1); - newtype = (aspectype_t *) hash_get(&types_hash, to); - if (newtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Type destination already exist", -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newtype, sizeof(aspectype_t), -1); - memcpy(newtype, tocopy, sizeof(aspectype_t)); - newtype->name = strdup(to); - aspect_type_register_real(newtype->name, newtype); - revm_type_hashcreate(newtype->name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Init the global type table - * - * @param name - * @return - */ -int revm_type_hashcreate(char *name) -{ - char hashname[BUFSIZ]; - hash_t *newhash; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Create the hash table for objects of that type */ - type = aspect_type_get_by_name(name); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Type subject does not exist", -1); - snprintf(hashname, sizeof(hashname), "type_%s", name); - XALLOC(__FILE__, __FUNCTION__, __LINE__, newhash, sizeof(hash_t), -1); - hash_init(newhash, strdup(hashname), 11, type->type); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Print a specific type - * - * @param type - * @param mode - * @return - */ -int revm_type_print(char *type, char mode) -{ - aspectype_t *cur; - aspectype_t *child; - char buf[BUFSIZ]; - char prefix[128]; - int len; - char *size; - char offset[128]; - int idx; - int sz; - char *pad; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cur = hash_get(&types_hash, type); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown type", 0); - - /* Set up things */ - revm_endline(); - - /* Setup first part of the line */ - snprintf(prefix, sizeof(prefix), "%s%s%s", - revm_colorfieldstr("{"), - revm_colornumber("%u", cur->size), - revm_colorfieldstr("}")); - len = snprintf(buf, sizeof(buf), " %s %s %-20s %s %-10s", - revm_colornumber("id:%-10u", cur->type), - revm_colorfieldstr("Type"), - revm_colortypestr_fmt("%-20s", type), - revm_colorfieldstr("size"), - prefix); - size = alloca(20); - - /* If the type is a structure */ - if (cur->childs) - { - len += snprintf(buf + len, sizeof(buf) - len, "%s", - revm_colorfieldstr(" = {")); - - /* Prepare the padding after each field name */ - sz = len - revm_color_size(buf) - 16; /* -16 is dirty: some bug in colors */ - pad = alloca(sz + 1); - memset(pad, ' ', sz); - pad[sz] = 0x00; - - /* For each child field type */ - for (child = cur->childs; child; child = child->next) - { - - /* Compute the size field */ - if (child->type == ASPECT_TYPE_RAW) - snprintf(size, sizeof(size), "%s%s%s", - revm_colorfieldstr("["), - revm_colornumber("%u", child->size), - revm_colorfieldstr("]")); - else if (child->dimnbr && child->elemnbr) - { - for (sz = idx = 0; idx < child->dimnbr; idx++) - sz += 20; - size = alloca(sz); - for (sz = idx = 0; idx < child->dimnbr; idx++) - sz += sprintf(size + sz, "%s%s%s", - revm_colorfieldstr("["), - revm_colornumber("%u", child->elemnbr[idx]), - revm_colorfieldstr("]")); - } - else - *size = 0x00; - - /* Format the whole thing */ - if (mode) - *offset = 0x00; - else - snprintf(offset, sizeof(offset), "%s%s", - revm_colornumber("%u", child->off), - revm_colorfieldstr(":")); - len += snprintf(buf + len, sizeof(buf) - len, - "%s%s%s%s%s%s%s", - offset, - revm_colorstr(child->fieldname), - revm_colorfieldstr(":"), - revm_colortypestr((child->isptr ? "*" : "")), - revm_colortypestr(child->name), - size, - revm_colorfieldstr((child->next ? ",\n" : "}\n\n"))); - - /* Print field and next padding */ - revm_output(buf); - revm_endline(); - if (child->next) - revm_output(pad); - *buf = 0x00; - len = 0; - } - } - - /* Print non-structures types */ - else - { - revm_output(buf); - revm_output("\n"); - } - - /* Return success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - - -/** - * Print types matching a regular expression - * - * @param regex - * @return - */ -int revm_type_print_regex(char *regex) -{ - regex_t rx; - int keynbr; - char **keys; - int index; - int match; - char buf[50]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (regcomp(&rx, regex, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - keys = hash_get_keys(&types_hash, &keynbr); - for (match = index = 0; index < keynbr; index++) - { - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - revm_type_print(keys[index], 0); - match++; - } - } - - snprintf(buf, sizeof(buf), " [*] Matched %u types \n\n", match); - revm_output(buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Print available types - * - * @return - */ -int revm_type_prints() -{ - int keynbr; - char **keys; - int index; - int total; - char buf[BUFSIZ]; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!types_hash.elmnbr) - { - revm_output("\n .:: No registered types\n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - revm_output("\n .:: Available meta-language types \n\n"); - keys = hash_get_keys(&types_hash, &keynbr); - for (total = index = 0; index < keynbr; index++) - total += revm_type_print(keys[index], 1); - snprintf(buf, sizeof(buf), "\n .:: Found %u registered types\n\n", total); - revm_output(buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/api/typing.c eresi-0.0.20110516/librevm/api/typing.c --- eresi-0.8a25/librevm/api/typing.c 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/api/typing.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /** -* @file typing.c -* @ingroup librevm_api +* @file librevm/api/typing.c +* @ingroup api * @brief Various API for manipulating types. * * Started on Sun Jan 9 07:23:58 2007 jfv -* $Id: typing.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +* $Id: typing.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -134,7 +134,7 @@ sz += 20; size = alloca(sz); for (sz = idx = 0; idx < child->dimnbr; idx++) - sz += sprintf(size + sz, "%s%s%s", + sz += snprintf(size + sz, sz, "%s%s%s", revm_colorfieldstr("["), revm_colornumber("%u", child->elemnbr[idx]), revm_colorfieldstr("]")); @@ -247,3 +247,45 @@ revm_output(buf); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + +/* This function reflect a data structure */ +int revm_type_reflect(hash_t *hash, char *typename) +{ + char **keys; + int index; + int nbr; + void *data; + char logbuf[BUFSIZ]; + revmexpr_t *result; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + keys = hash_get_keys(hash, &nbr); + for (index = 0; index < nbr; index++) + { + data = hash_get(hash, keys[index]); + snprintf(logbuf, sizeof(logbuf), "%c%s_%s", + REVM_VAR_PREFIX, typename, keys[index]); + + //if (!strcmp(typename, "func")) + //sleep(10); + + result = revm_inform_type_addr(typename, logbuf, (eresi_Addr) data, NULL, 0, 1); + + /* + if (!result) + { + fprintf(stderr, "FAILED TO REFLECT %s OBJECT OF KEY %s \n", typename, keys[index]); + sleep(10); + } + else + { + fprintf(stderr, "SUCCESS TO REFLECT %s OBJECT OF KEY %s \n", typename, keys[index]); + revm_expr_print(result, 0); + } + */ + + } + hash_free_keys(keys); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/librevm/doc/.svn/all-wcprops eresi-0.0.20110516/librevm/doc/.svn/all-wcprops --- eresi-0.8a25/librevm/doc/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/896/trunk/librevm/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/896/trunk/librevm/doc/doxygen.conf -END diff -Nru eresi-0.8a25/librevm/doc/.svn/entries eresi-0.0.20110516/librevm/doc/.svn/entries --- eresi-0.8a25/librevm/doc/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/doc -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:45.571877Z -9a6aa846902ca0284177027559b999dc -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/librevm/doc/.svn/format eresi-0.0.20110516/librevm/doc/.svn/format --- eresi-0.8a25/librevm/doc/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/librevm/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/librevm/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = librevm - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = api/ include/ io/ lang/ vm/ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = librevm - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = NO - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/librevm/include/librevm-color.h eresi-0.0.20110516/librevm/include/librevm-color.h --- eresi-0.8a25/librevm/include/librevm-color.h 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/librevm-color.h 2011-05-16 11:34:11.000000000 +0000 @@ -1,9 +1,9 @@ /* -** @file libui-color.h -** @ingroup librevm_hdr +* @file librevm/include/librevm-color.h +** @ingroup librevm ** Started on Sun Nov 26 22:13:54 2006 mxatone ** -** $Id: librevm-color.h,v 1.7 2008-02-16 12:32:27 thor Exp $ +** $Id: librevm-color.h 1397 2009-09-13 02:19:08Z may $ ** */ @@ -77,7 +77,7 @@ char *revm_coloradv(char *ty, char *p, char *te); char *revm_colorinstr_fmt(char* p, char *t); char *revm_coloraddress(char *p, eresi_Addr a); -char *revm_colornumber(char *p, elfsh_Off n); +char *revm_colornumber(char *p, eresi_Off n); char *revm_colorstr_fmt(char *p, char *t); char *revm_colorfieldstr_fmt(char *p, char *t); char *revm_colortypestr_fmt(char *p, char *t); diff -Nru eresi-0.8a25/librevm/include/revm-debug.h eresi-0.0.20110516/librevm/include/revm-debug.h --- eresi-0.8a25/librevm/include/revm-debug.h 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/revm-debug.h 2011-05-16 11:34:11.000000000 +0000 @@ -0,0 +1,27 @@ +/** + * @defgroup ERESI The ERESI runtime environment + */ + +/** + * @file librevm/include/revm-debug.h + * @ingroup librevm + * + * Started on Thu Dec 09 07:19:04 2010 may + * $Id$ + */ +#ifndef __REVM_DEBUG_H_ + #define __REVM_DEBUG_H_ + +/* Now come INTERNAL DEBUGGING VARIABLES for various part of the ERESI code */ +#define __DEBUG_SIGHANDLER__ 0 +#define __DEBUG_LANG__ 0 +#define __DEBUG_SCANNER__ 0 +#define __DEBUG_ASLR__ 0 +#define __DEBUG_NETWORK__ 0 +#define __DEBUG_RESOLVE__ 0 +#define __DEBUG_TEST__ 0 +#define __DEBUG_EXPRS__ 0 +#define __DEBUG_EXPRS_MORE__ 0 +#define __DEBUG_INFORM__ 0 + +#endif diff -Nru eresi-0.8a25/librevm/include/revm.h eresi-0.0.20110516/librevm/include/revm.h --- eresi-0.8a25/librevm/include/revm.h 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/revm.h 2011-05-16 11:34:11.000000000 +0000 @@ -1,21 +1,30 @@ /** -** @file revm.h -** @ingroup librevm_hdr -** Started on Thu Feb 22 07:19:04 2001 jfv -** Moved from elfsh to librevm on January 2007 -may -** -** $Id: revm.h,v 1.97 2008-02-16 12:32:27 thor Exp $ -*/ + * @defgroup ERESI The ERESI runtime environment + */ + +/** + * @file librevm/include/revm.h + * @ingroup librevm + * + * Started on Thu Feb 22 07:19:04 2001 jfv + * $Id: revm.h 1444 2011-01-31 07:41:29Z may $ + */ #ifndef __REVM_H_ #define __REVM_H_ +/* Debug variables */ +#include "revm-debug.h" + /* User defined configuration */ #include "revm-vars.h" /* Do not put all those headers when compiling for kernel */ #ifndef __KERNEL__ +#define _GNU_SOURCE -#define __USE_ISOC99 +#if defined(__linux__) +#include +#endif #include #include @@ -37,10 +46,13 @@ #include #include #include -#define __USE_GNU -#if !defined(__OpenBSD__) -#include + +#if defined(__BEOS__) + #include +#elif !defined(__OpenBSD__) + #include #endif + #include #include #include @@ -49,11 +61,10 @@ #endif #include "libelfsh.h" -//#include "libetrace.h" #include "libedfmt.h" #include "libaspect.h" -#if defined(ELFSHNET) +#if defined(ERESI_NET) #include #endif @@ -68,31 +79,11 @@ extern char **environ; #endif -#if defined(KERNSH) -#include "libkernsh.h" -#endif - /* Disassembling engine */ #include extern asm_processor proc; -/* Now come INTERNAL DEBUGGING VARIABLES for various part of the ERESI code */ -#define __DEBUG_DISASM__ 0 -#define __DEBUG_SIGHANDLER__ 0 -#define __DEBUG_LANG__ 0 -#define __DEBUG_SCANNER__ 0 -#define __DEBUG_ASLR__ 0 -#define __DEBUG_NETWORK__ 0 -#define __DEBUG_RESOLVE__ 0 -#define __DEBUG_HIJACK__ 0 -#define __DEBUG_TEST__ 0 -#define __DEBUG_TRACE__ 0 -#define __DEBUG_GRAPH__ 0 -#define __DEBUG_ARG_COUNT__ 0 -#define __DEBUG_EXPRS__ 0 -#define __DEBUG_EXPRS_MORE__ 0 - /* Parsing related defines */ #define REVM_MAXNEST_LOOP 10 @@ -128,9 +119,7 @@ #define RET(a) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, a) #define RETERR(a) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, a, -1) #define PERROR_RET(a, b) { perror(a); RETERR (b); } -#define PRINTABLE(c) (c >= 32 && c <= 126) #define REGX_IS_USED(a) a -#define IS_VADDR(s) (s[0] == '0' && (s[1] == 'X' || s[1] == 'x')) #define IS_BLANK(c) (c == ' ' || c == '\t') #define REVM_VAR_ARGC "$#" @@ -160,6 +149,9 @@ #define REVM_OP_CMP 7 #define REVM_OP_MATCH 8 #define REVM_OP_COPY 9 +#define REVM_OP_SHL 10 +#define REVM_OP_SHR 11 +#define REVM_OP_OR 12 /* Some useful macros */ #define CHOOSE_REGX(r, idx) r = (world.curjob->curcmd->use_regx[idx] ? \ @@ -182,35 +174,8 @@ #define ELFSH_VERTYPE_DEF 3 #define ELFSH_VERENTRY_MAX 4 -/* Used to store ascii description for different structures types in data.c */ -#define ELFSH_INSTRTYPE_MAX 24 -#define ELFSH_OPTYPE_MAX 4 -#define ELFSH_SEGTYPE_MAX 7 -#define ELFSH_SHTYPE_MAX 16 -#define ELFSH_OBJTYPE_MAX 5 -#define ELFSH_SYMBIND_MAX 3 -#define ELFSH_SYMTYPE_MAX STT_NUM + 1 -#define ELFSH_ENCODING_MAX 3 -#define ELFSH_DYNAMIC_MAX 35 -#define ELFSH_EXTDYN_MAX 19 -#define ELFSH_MIPSDYN_MAX 43 -#define ELFSH_ARCHTYPE_MAX 56 -#define ELFSH_EXTSEG_MAX 5 -#define ELFSH_RELOC_i386_MAX 11 -#define ELFSH_RELOC_IA64_MAX 81 -#define ELFSH_RELOC_SPARC_MAX 55 -#define ELFSH_RELOC_SPARC64_MAX 55 -#define ELFSH_RELOC_ALPHA_MAX 43 -#define ELFSH_RELOC_MIPS_MAX 35 - #define ELFSH_RELOC_MAX(file) revm_getmaxrelnbr(file) -#define ELFSH_FEATURE_MAX 2 -#define ELFSH_POSFLAG_MAX 2 -#define ELFSH_FLAGS_MAX 4 -#define ELFSH_FLAGS1_MAX 15 -#define ELFSH_MIPSFLAGS_MAX 16 - /* REVM general parameters */ #define REVM_MAXARGC 128 #define REVM_SEP "." @@ -229,15 +194,12 @@ #define REVM_FIFO_C2S "/tmp/.revm.io.c2s" #define REVM_FIFO_S2C "/tmp/.revm.io.s2c" -/* Traces directory */ -#define REVM_TRACE_REP ".etrace" - /* For revm_object_display() */ #define REVM_VIEW_HEX 0 #define REVM_VIEW_DISASM 1 /* For elfsh/elfsh/modules.c:revm_change_handler() */ -#define ELFSH_ORIG ((void *) -1) +#define ERESI_ORIG ((void *) -1) /* For lang/access.c */ #define REVM_INVALID_FIELD ((u_int) -1) @@ -248,14 +210,14 @@ #define REVM_CREATE_NEWID (1 << 2) /* config strings */ -#define ERESI_VMCONFIG_ONLOAD_RCONTROL "onload.restore_control" -#define ERESI_VMCONFIG_GRAPH_STORAGEPATH "graph.storagepath" -#define ERESI_VMCONFIG_GRAPH_VIEWCMD "graph.viewcmd" -#define ERESI_VMCONFIG_GRAPH_AUTOVIEW "graph.autoview" -#define ERESI_VMCONFIG_GRAPH_AUTOBUILD "graph.autobuild" -#define ERESI_VMCONFIG_USE_MORE "vm.use_more" -#define ERESI_VMCONFIG_USE_ASMDEBUG "asm.debug" -#define ERESI_VMCONFIG_HISTORY "history" +#define ERESI_CONFIG_ONLOAD_RCONTROL "onload.restore_control" +#define ERESI_CONFIG_GRAPH_STORAGEPATH "graph.storagepath" +#define ERESI_CONFIG_GRAPH_VIEWCMD "graph.viewcmd" +#define ERESI_CONFIG_GRAPH_AUTOVIEW "graph.autoview" +#define ERESI_CONFIG_GRAPH_AUTOBUILD "graph.autobuild" +#define REVM_CONFIG_USEMORE "vm.use_more" +#define ERESI_CONFIG_ASMVERB "asm.debug" +#define ERESI_CONFIG_HISTORY "history" #define ERESI_DEFAULT_HISTORY ".eresi_history" @@ -324,30 +286,15 @@ char argc; /* Number of args in param[] */ revmcmd_t *cmd; /* Command descriptor */ char *name; /* Command name */ + char *endlabel; /* Co-Label for foreach/forend */ -#define REVM_IDX_UNINIT ((unsigned int) (-1)) - u_int listidx; /* Iteration index for this foreach */ + struct s_args *next; struct s_args *prev; } revmargv_t; - -/* Trace structures, used by the tracer */ -typedef struct s_revmtraces -{ - int (*exec)(elfshobj_t*, char *, char **); /* Function used */ - - /* Unexistant (0), optional (1), needed (2) */ - char flagName; /* Need a first argument */ - char flagArg; /* Need a second argument */ -} revmtraces_t; - - - #include - - /* REVM module structure */ typedef struct s_module { @@ -384,16 +331,16 @@ /* We use a separate header for defnition of object structures */ #include "revm-objects.h" - - /* This structure stores the current FOREACH iteration state for a job */ -typedef struct s_revmiteration +typedef struct s_revmiter { -#define REVM_IDX_UNINIT ((unsigned int) (-1)) - u_int *curindex; /* Current iteration index (most-nested foreach) */ - char *curkey; /* Name (key) of matchme expression in list */ - char *curname; /* Name (bound) of induction variable if any */ - list_t *list; /* Current list being iterated */ + char *curkey; /* Key of currently processed variable */ +#define REVM_IDX_UNINIT ((unsigned int) (-1)) + u_int listidx; /* Index of currently processed variable */ + revmexpr_t *curind; /* Induction variable if any */ + void *list; /* Current list (or hash) being iterated */ + u_int reclevel; /* Current recursion level on loop start */ + char *end; /* END loop label */ } revmiter_t; /* This structure stores the current REWRITE transformation state for a job */ @@ -404,30 +351,39 @@ u_char replaced; /* Indicate if we have already transformed */ } revmrewrite_t; +/* This structure stores the current function recursion state for a job */ +typedef struct s_revmrecur +{ + char *funcname; /* Names of call-stack functions */ + revmargv_t *script; /* Script commands at this depth */ + revmargv_t *lstcmd; /* Last command at this depth */ + hash_t labels; /* Defined labels */ + hash_t exprs; /* Expressions */ + revmrewrite_t rwrt; /* "rewrite" matching context */ +} revmrecur_t; + /* REVM job structure, one per client */ typedef struct s_job { - revmworkspace_t ws; /* The job workspace */ + u_int id; /* Job identifier */ + revmworkspace_t ws; /* The job workspace */ - /* Scripting machine job context */ -#define REVM_MAXSRCNEST 10 - revmargv_t *script[REVM_MAXSRCNEST]; /* List of script commands */ - revmargv_t *lstcmd[REVM_MAXSRCNEST]; /* Last command for each depth */ - u_int sourced; /* script depth (if beeing sourced) */ - - /* File job context */ - revmargv_t *curcmd; /* Next command to be executed */ - hash_t loaded; /* List of loaded ELF objects */ - elfshobj_t *curfile; /* Current working ELF object */ - asm_processor* proc; /* Processor structure */ - - /* Debugger job context */ - hash_t dbgloaded; /* List of objects loaded into e2dbg */ - elfshobj_t *dbgcurrent; /* Current working e2dbg file */ - - /* Job iteration and rewritten expression name if any */ - revmiter_t iter; /* Iteration context */ - revmrewrite_t rwrt; /* Rewrite context */ + /* Job recursion and iteration contexts */ +#define REVM_MAXSRCNEST 50 + revmrecur_t recur[REVM_MAXSRCNEST]; /* Recursion contexts */ + u_int curscope; /* Current recursion depth */ + revmiter_t iter[REVM_MAXSRCNEST]; /* "foreach" iteration context */ + u_int curloop; /* Current iteration depth */ + + /* Job files context */ + revmargv_t *curcmd; /* Next command to be executed */ + hash_t loaded; /* List of loaded ELF objects */ + elfshobj_t *curfile; /* Current working ELF object */ + asm_processor *proc; /* Processor structure */ + + /* Job debugger context */ + hash_t dbgloaded; /* List of objects loaded into e2dbg */ + elfshobj_t *dbgcurrent; /* Current working e2dbg file */ } revmjob_t; @@ -442,9 +398,10 @@ revmjob_t *curjob; /* Current job */ hash_t shared_hash; /* Hash of shared descriptors */ char *scriptsdir; /* Directory which contains script commands */ - asm_processor proc; /* Libasm world */ + asm_processor proc_ia32; /* Libasm Intel */ asm_processor proc_sparc; /* Libasm Sparc */ asm_processor proc_mips; /* Libasm Mips */ + asm_processor proc_arm; /* Libasm ARM */ mjrsession_t mjr_session; /* Session holding contexts for mjollnir */ int fifo_s2c; /* Fd for the debugger IO FIFO */ int fifo_c2s; /* Fd for the debugger IO FIFO */ @@ -464,8 +421,6 @@ extern hash_t const_hash; /* elf.h picked up constants values */ extern hash_t redir_hash; /* Function redirections hash table */ extern hash_t mod_hash; /* Modules name hash table */ -extern hash_t exprs_hash; /* ERESI expressions types hash */ -extern hash_t labels_hash[10]; /* Scripting labels hash table */ /* The Level 1 object hash table : hash the object name and returns a L1handler_t* */ extern hash_t L1_hash; /* For HDR, SHT, PHT, GOT, DTORS, CTORS, DYNAMIC, SECTIONS */ @@ -493,40 +448,13 @@ extern hash_t fg_color_hash; /* colors def */ extern hash_t t_color_hash; /* colors type */ -extern hash_t traces_cmd_hash;/* trace cmd table */ +//extern hash_t traces_cmd_hash;/* trace cmd table */ extern hash_t goto_hash; /* goto hash */ /* Lattice for I/O */ extern char *(*hooks_input[REVM_IO_NUM])(); extern int (*hooks_output[REVM_IO_NUM])(char *buf); -/* Data value/string/description arrays */ -extern revmconst_t asm_instr_type[ELFSH_INSTRTYPE_MAX]; -extern revmconst_t asm_operand_type[ELFSH_OPTYPE_MAX]; - -extern revmconst_t elfsh_extseg_type[ELFSH_EXTSEG_MAX]; -extern revmconst_t elfsh_seg_type[ELFSH_SEGTYPE_MAX]; -extern revmconst_t elfsh_sh_type[ELFSH_SHTYPE_MAX]; -extern revmconst_t elfsh_obj_type[ELFSH_OBJTYPE_MAX]; -extern revmconst_t elfsh_sym_bind[ELFSH_SYMBIND_MAX]; -extern revmconst_t elfsh_sym_type[ELFSH_SYMTYPE_MAX]; -extern revmconst_t elfsh_dynentry_type[ELFSH_DYNAMIC_MAX]; -extern revmconst_t elfsh_encoding[ELFSH_ENCODING_MAX]; -extern revmconst_t elfsh_extdyn_type[ELFSH_EXTDYN_MAX]; -extern revmconst_t elfsh_mipsdyn_type[ELFSH_MIPSDYN_MAX]; -extern char *elfsh_arch_type[ELFSH_ARCHTYPE_MAX]; -extern revmconst_t elfsh_feature1[ELFSH_FEATURE_MAX]; -extern revmconst_t elfsh_posflag1[ELFSH_POSFLAG_MAX]; -extern revmconst_t elfsh_flags[ELFSH_FLAGS_MAX]; -extern revmconst_t elfsh_flags1[ELFSH_FLAGS1_MAX]; -extern revmconst_t elfsh_mipsflags[ELFSH_MIPSFLAGS_MAX]; -extern revmconst_t elfsh_rel_type_i386[ELFSH_RELOC_i386_MAX]; -extern revmconst_t elfsh_rel_type_ia64[ELFSH_RELOC_IA64_MAX]; -extern revmconst_t elfsh_rel_type_sparc[ELFSH_RELOC_SPARC64_MAX]; -extern revmconst_t elfsh_rel_type_alpha[ELFSH_RELOC_ALPHA_MAX]; -extern revmconst_t elfsh_rel_type_mips[ELFSH_RELOC_MIPS_MAX]; -extern revmconst_t elfsh_verentry_type[ELFSH_VERENTRY_MAX]; - /* This has to be prototyped in libelfsh and not put in extern ! */ extern int elfsh_load_core_info(elfshobj_t *); @@ -566,18 +494,18 @@ char *revm_resolve(elfshobj_t *file, eresi_Addr addr, elfsh_SAddr *roff); /* General VM functions */ -revmexpr_t *revm_lookup_param(char *param); +revmexpr_t *revm_lookup_param(char *param, u_char existing); revmobj_t *revm_check_object(revmobj_t *pobj); -void revm_destroy_object(revmobj_t *pobj); +void revm_destroy_object(revmobj_t *pobj, u_char datafree); revmobj_t *revm_copy_object(revmobj_t *pobj); elfshobj_t *revm_getfile(u_int index); revmmod_t *revm_getmod(u_int index); char *revm_reverse(elfshobj_t *file, u_int vaddr); /* Lookup functions */ -revmobj_t *revm_lookup_immed(char *param); +revmobj_t *revm_lookup_immed(char *param, u_char existing); revmexpr_t *revm_lookup_var(char *param); - +char *revm_lookup_key(char *param); elfshobj_t *revm_lookup_file(char *param); u_int revm_lookup_index(char *param); char *revm_lookup_string(char *param); @@ -595,8 +523,8 @@ /* Command API */ int revm_command_set(char *cmd, void *exec, void *reg, u_int needcur); -int revm_command_add(char *cmd, void *exec, void *reg, - u_int needfile, char *help); +int revm_command_add(char *cmd, int (*exec)(void), void *reg, + u_int needfile, char *help); int revm_command_del(char *cmd); /* Default grammar handlers */ @@ -617,16 +545,19 @@ int revm_version_unk(u_int ai, u_int i, char *id, char *n, char *t); /* Disassembling and hexadecimal view functions */ -u_int revm_instr_display(int, u_int, eresi_Addr, u_int, u_int, - char *, u_int, char *); +int revm_array_display(elfshsect_t *parent, elfsh_Sym *sym, char *buf, eresi_Addr vaddr, + char *name, u_int foffset); +int revm_instr_display(int, eresi_Addr, u_int, u_int, char *, u_int, char *); int revm_section_display(elfshsect_t *s, char *name, revmlist_t *re); -int revm_match_sht(elfshobj_t *file, elfshsect_t *l, revmlist_t *actual); +int revm_match_sht(elfshsect_t *l, revmlist_t *actual); int revm_match_symtab(elfshobj_t *file, elfshsect_t *symtab, revmlist_t *actual, int flag); int revm_match_special(elfshobj_t *file, eresi_Addr vaddr, revmlist_t*); int revm_object_display(elfshsect_t *parent, elfsh_Sym *sym, int size, - u_int off, u_int foffset, eresi_Addr vaddr, - char *name, char otype); + u_int off, u_int symoff, u_int foffset, eresi_Addr vaddr, + char *name, char otype, u_char addbase); +int revm_hexa_display(elfshsect_t *parent, char *name, eresi_Addr vaddr, + u_int size, u_int symoff, char *buff, u_int fileoff); /* Parsing / Scanning functions */ char *revm_filter_param(char *buf, char *ptr); @@ -642,25 +573,8 @@ /* String functions */ int revm_strtable_add(char *string); -/* Trace functions */ -int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg); -int traces_add(elfshobj_t *file, char *name, char **optarg); -int traces_rm(elfshobj_t *file, char *name, char **optarg); -int traces_exclude(elfshobj_t *file, char *freg, char **oreg); -int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg); -int traces_enable(elfshobj_t *file, char *name, char **optarg); -int traces_disable(elfshobj_t *file, char *name, char **optarg); -int traces_create(elfshobj_t *file, char *name, char **optarg); -int traces_delete(elfshobj_t *file, char *name, char **optarg); -int traces_flush(elfshobj_t *file, char *name, char **optarg); -int traces_list(elfshobj_t *file, char *name, char **optarg); -int traces_run(elfshobj_t *file, char **argv, int argc); - int revm_traces_add_arguments(int argc, char **argv); edfmtfunc_t *revm_traces_tracable_with_type(elfshobj_t *file, char *func_name, u_char external); -elfshtraces_t *revm_traces_createargs(elfshobj_t *file, char *name, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external); /* Hash functions */ int revm_hashunk(int i); @@ -668,6 +582,7 @@ int revm_hashchain_print(int i, int s, char *n, int r, int h); /* Internal functions */ +void revm_proc_init(); revmmod_t *revm_modprobe(); void revm_tables_setup(); int revm_doerror(void (*fct)(char *str), char *str); @@ -683,7 +598,7 @@ void revm_workfiles_load(); int revm_implicit(revmcmd_t *actual); int revm_workfiles_unload(); -int dprintf(int fd, char *format, ...); +int dprintf(int fd, const char *format, ...); void revm_pht_print(elfsh_Phdr *phdr, uint16_t num, eresi_Addr base); char *revm_fetch_sht_typedesc(elfsh_Word typenum); int revm_sht_print(elfsh_Shdr *shdr, u_int num, char rtflag); @@ -703,6 +618,10 @@ int revm_help(char *command); void revm_print_actual(revmargv_t *cur); int revm_printscript(revmargv_t *start); +char *revm_get_cur_job_parameter(uint8_t p); +char *revm_get_cur_job_parameter_with_job(revmjob_t *job, uint8_t p); +uint8_t revm_get_argc(void); +int revm_create_new_workspace(char *ws_name); /* Vector related functions */ int revm_vectors_getdims(char *str, unsigned int *dims); @@ -723,10 +642,12 @@ int revm_init() __attribute__((constructor)); int revm_loop(int argc, char **argv); int revm_setup(int ac, char **av, char mode, char side); -int revm_run(int ac, char **av); +elfshobj_t *revm_run(int ac, char **av); +elfshobj_t *revm_run_no_handler(int ac, char **av); int revm_config(char *config); void revm_postexec(int retval); void revm_cleanup(); +void revm_clean(); /* Scripting flow functions */ int revm_execscript(); @@ -752,22 +673,27 @@ int revm_type_print_regex(char *regex); int revm_type_copy(char *from, char *to); int revm_type_hashcreate(char *name); +int revm_type_reflect(hash_t *hash, char *typename); /* Data access related functions */ -aspectype_t *revm_fieldoff_get(aspectype_t *par, char *fld, u_int *off); revmobj_t *revm_object_lookup_real(aspectype_t *type, char *objname, char *objpath, char trans); revmobj_t *revm_object_lookup(char *str); -revmobj_t *revm_object_create(aspectype_t *type, void *data, char transaddr); +revmobj_t *revm_object_create(aspectype_t *type, void *data, char transaddr, u_char perm); /* Generic handlers for data accesses */ char *revm_generic_getname(void *type, void *data); int revm_generic_setname(void *type, void *data, void *newdata); -eresi_Addr revm_generic_getobj(void *data); +int revm_addr_setobj(void *data, eresi_Addr value); +eresi_Addr revm_addr_getobj(void *data); eresi_Addr revm_hash_getobj(void *data); +eresi_Addr revm_byte_getobj(void *data); int revm_byte_setobj(void *data, eresi_Addr value); +eresi_Addr revm_short_getobj(void *data); int revm_short_setobj(void *data, eresi_Addr value); +eresi_Addr revm_int_getobj(void *data); int revm_int_setobj(void *data, eresi_Addr value); int revm_long_setobj(void *data, eresi_Addr value); +eresi_Addr revm_long_getobj(void *data); char *revm_generic_getdata(void *data, int off, int sizelm); int revm_generic_setdata(void *d, int off, void *ndat, int sz, int szlm); @@ -798,6 +724,7 @@ revmobj_t *revm_create_LONG(char perm, eresi_Addr val); revmobj_t *revm_create_CADDR(char perm, eresi_Addr val); revmobj_t *revm_create_DADDR(char perm, eresi_Addr val); +revmobj_t *revm_create_ptr(char perm, eresi_Addr val, u_int type); /* Interface related functions */ int revm_system(char *cmd); @@ -807,7 +734,7 @@ /* Atomic operations */ int revm_preconds_atomics(revmexpr_t **o1, revmexpr_t **o2); int revm_nextconds_atomics(revmexpr_t *o1, revmexpr_t *o2); -int revm_arithmetics(revmexpr_t *e1, revmexpr_t *e2, u_char op); +int revm_arithmetics(revmexpr_t *dst, revmexpr_t *e1, revmexpr_t *e2, u_char op); int revm_hash_add(hash_t *h, revmexpr_t *e); int revm_hash_del(hash_t *h, revmexpr_t *e); int revm_elist_add(list_t *h, revmexpr_t *e); @@ -835,14 +762,17 @@ int revm_screen_switch(); int revm_screen_clear(int i, char c); int revm_screen_update(u_short isnew, u_short prompt_display); -int revm_workspace_next(); +int revm_workspace_next(); /* libedfmt related functions */ int revm_edfmt_parse(elfshobj_t *file); int revm_edfmt_uni_print(elfshobj_t *file); /* Type/Inform related functions */ -revmexpr_t *revm_inform_type(char *type, char *name, char *addr, revmexpr_t *e, u_char p, u_char r); +revmexpr_t *revm_inform_type(char *type, char *name, eresi_Addr, revmexpr_t *e, u_char p, u_char r); +revmexpr_t *revm_inform_toplevel(char *type, char *varname, + char *straddr, revmexpr_t *expr, + u_char print, u_char rec); revmexpr_t *revm_inform_type_addr(char *t, char *n, eresi_Addr a, revmexpr_t *, u_char p, u_char r); int revm_check_addr(elfshobj_t *obj, eresi_Addr add); int revm_informed_print(char *name); @@ -859,14 +789,21 @@ int revm_expr_compare(revmexpr_t *orig, revmexpr_t *candid, eresi_Addr *val); int revm_expr_match(revmexpr_t *candid, revmexpr_t *orig); int revm_expr_set(revmexpr_t *adst, revmexpr_t *asrc); -int revm_expr_print(char *pathname); +int revm_expr_print(revmexpr_t *expr, u_char quiet); +int revm_expr_print_by_name(char *pathname, u_char quiet); int revm_expr_match_by_name(char *original, char *candidate); int revm_expr_compare_by_name(char *original, char *candidate, eresi_Addr *val); int revm_expr_set_by_name(char *dest, char *source); aspectype_t *revm_exprtype_get(char *exprvalue); -revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name); +int revm_expr_unlink_by_name(char *e, u_char exprfree, u_char datafree); +revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name, u_char force); revmexpr_t *revm_expr_copy(revmexpr_t *source, char *dstname, u_char isfield); -int revm_expr_destroy(char *e); +int revm_expr_destroy_by_name(char *ename); +int revm_expr_destroy(revmexpr_t *expr); +int revm_expr_hide(char *ename); +int revm_expr_clean(char *ename); +revmexpr_t *revm_expr_lookup(u_int oid); +revmexpr_t *revm_compute(char *str); /* May not be defined */ #ifndef __KERNEL__ diff -Nru eresi-0.8a25/librevm/include/revm-io.h eresi-0.0.20110516/librevm/include/revm-io.h --- eresi-0.8a25/librevm/include/revm-io.h 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/revm-io.h 2011-05-16 11:34:11.000000000 +0000 @@ -1,9 +1,9 @@ /** -** @file revm.h for librevm in ERESI -** @ingroup librevm_hdr +* @file librevm/include/revm-io.h +** @ingroup librevm +** ** Started on Thu Feb 22 07:19:04 2001 jfv -** Moved from elfsh to librevm on January 2007 jfv -** $Id: revm-io.h,v 1.56 2008-02-16 12:32:27 thor Exp $ +** $Id: revm-io.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef __REVM_IO_H_ #define __REVM_IO_H_ @@ -19,7 +19,7 @@ #include "librevm-color.h" -#if defined(ELFSHNET) +#if defined(ERESI_NET) #include #endif @@ -34,8 +34,8 @@ #define REVM_DUMP_MSG 2 #define REVM_NAME "revm" -#define REVM_VERSION "0.81" -#define REVM_RELEASE "a8" +#define REVM_VERSION "0.82" +#define REVM_RELEASE "b2" #define REVM_EDITION "dev" /* Unused, feel free to try it, its awesome */ @@ -48,7 +48,7 @@ "\033[00;01;35mh" \ "\033[00;01;36m-" \ "\033[00;01;30m" \ - ELFSH_VERSION \ + ERESI_VERSION \ "\033[00;01;35m-" \ "\033[05;01;35mcircus" \ "\033[00;01;35m-edition" \ @@ -61,18 +61,18 @@ "\033[00;01;31melfsh" \ "\033[00;01;30m-" \ "\033[00;01;33m" \ - ELFSH_VERSION \ + ERESI_VERSION \ "\033[00;01;30m-" \ "\033[00;01;33m" \ - ELFSH_RELEASE \ + ERESI_RELEASE \ "\033[00;01;30m-" \ "\033[00;01;32mdevhell" \ "\033[00;01;30m)" \ "\033[00m " /* Be original, do your own */ -#define ELFSH_PROMPT ELFSH_CREW_PROMPT -//#define ELFSH_PROMPT ELFSH_CIRCUS_PROMPT +#define ERESI_PROMPT ELFSH_CREW_PROMPT +//#define ERESI_PROMPT ELFSH_CIRCUS_PROMPT /* Now some strings for graphviz/dot */ #define GVZ_COLOR_BLUE "\"blue\"" @@ -119,9 +119,7 @@ #define REVM_INPUT_EXIT (-2) #define REVM_INPUT_TRANSFERED (-3) -/** - * Elfsh Output Caching structure - */ +/** ERESI outut caching structure */ typedef struct s_outbuf { int nblines; @@ -130,16 +128,35 @@ char ignore; } revmoutbuf_t; +/** REVM socket structure */ +typedef struct s_socket +{ + int socket; /*! The socket */ + char **recvd; /*! List of received buffer */ + + /* XXX: NEW/OLD is not explicit enough, rename ... */ +#define NEW 1 +#define OLD 0 + int recvd_f; /*! NEW if the buffer was not passed to the parser yet */ +#define YES 1 +#define NO 0 + int ready_f; /*! Have we received the trailing \n ? */ -/** - * Input / Output template for ELFsh - */ +#ifndef __KERNEL__ + struct sockaddr_in addr; /*! sockaddr_in struct */ +#endif + +} revmsock_t; + + +/** ERESI INPUT/OUTPUT abstraction */ typedef struct s_io { #define REVM_IO_STD 1 #define REVM_IO_NET 2 #define REVM_IO_DUMP 3 -#define REVM_IO_NUM 4 +#define REVM_IO_GDB 4 +#define REVM_IO_NUM 5 char type; /*! IO type */ int input_fd; /*! Input file */ int output_fd; /*! Output file */ @@ -157,41 +174,16 @@ /* DUMP IO specific */ int new; /*! 0 if already used */ -#if defined(ELFSHNET) +#if defined(ERESI_NET) pkt_t *pkt; /*! Last received dump */ #else void *pkt; /*! Unused else */ #endif + revmsock_t sock; /* Socket information */ } revmio_t; - - -/** - * REVM socket structure - */ -typedef struct s_socket -{ - int socket; /*! The socket */ - char **recvd; /*! List of received buffer */ - - /* XXX: NEW/OLD is not explicit enough, rename ... */ -#define NEW 1 -#define OLD 0 - int recvd_f; /*! NEW if the buffer was not passed to the parser yet */ -#define YES 1 -#define NO 0 - int ready_f; /*! Have we received the trailing \n ? */ - -#ifndef __KERNEL__ - struct sockaddr_in addr; /*! sockaddr_in struct */ -#endif - -} revmsock_t; - - - /** * Screen cache for each workspace */ @@ -211,7 +203,6 @@ typedef struct s_workspace { char *name; /*! Name of the job */ - revmsock_t sock; /*! Unused in initial job */ u_char active; /*! Is the workspace active ? */ time_t createtime; /*! Workspace creation time */ int logfd; /*! Log file descriptor */ @@ -242,13 +233,13 @@ char revm_use_alert; /*! Is an alert regx available ? */ regex_t revm_alert; /*! Alert regx */ char *revm_salert; /*! ALert regx in string format */ - char *sort; /*! Actual sorting choice */ - char *input; /*! Implicit File input (-f option) */ - char *output; /*! Implicit File output (-w option) */ + char *sort; /*! Actual sorting choice */ + char *input; /*! Implicit File input (-f option) */ + char *output; /*! Implicit File output (-w option) */ #define REVM_STATE_CMDLINE 0 #define REVM_STATE_SCRIPT 1 #define REVM_STATE_INTERACTIVE 2 -#define REVM_STATE_DEBUGGER 3 +#define REVM_STATE_EMBEDDED 3 #define REVM_STATE_TRACER 4 char revm_mode; /*! Command line, scripting, interactive, debugger ? */ #define REVM_SIDE_CLIENT 0 @@ -257,14 +248,13 @@ char revm_sourcing; /*! Are we sourcing a script ? */ char revm_stopped; /*! We are in a signal handler */ char revm_shared; /*! Next opened object must be shared */ - char revm_net; /*! We are a node connected to the elf network */ - u_int lastid; /*! Last Object ID */ + char revm_net; /*! We are a node connected to the ERESI network */ + u_int lastid; /*! Last Object ID */ } revmstate_t; /* Extern variables */ extern int elfsh_net_client_count; - /* Parsing, Scanning, I/O functions */ char *revm_getln(); int revm_initio(); @@ -280,6 +270,8 @@ int revm_display_prompt(); void revm_setinput(revmworkspace_t *j, int fd); void revm_setoutput(revmworkspace_t *j, int fd); +void revm_setoutput_handler(revmworkspace_t *ws, void *hdl); +int revm_output_get(revmworkspace_t *ws); void revm_log(char *str); int revm_closelog(); char *revm_get_prompt(); @@ -287,7 +279,7 @@ /* Network related functions */ int revm_net_init(); -void revm_check_net_select(fd_set *sel_sockets, int sock); +int revm_check_net_select(fd_set *sel_sockets, int sock); int revm_select(); char* revm_net_input(); int revm_net_output(char *buf); @@ -301,6 +293,9 @@ int revm_getmaxfd(); int revm_clean_jobs(); +char *revm_netgdb_input(void); +int revm_netgdb_output(void); + /* Readline interface */ int revm_init_history(int mode); int revm_quit(int mode); diff -Nru eresi-0.8a25/librevm/include/revm-objects.h eresi-0.0.20110516/librevm/include/revm-objects.h --- eresi-0.8a25/librevm/include/revm-objects.h 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/revm-objects.h 2011-05-16 11:34:11.000000000 +0000 @@ -1,21 +1,17 @@ /** - * @defgroup librevm_hdr librevm Headers + * @defgroup librevm librevm: The Reverse Engineering Vector Machine. + * @ingroup ERESI */ /** -** @file revm.h -** @ingroup librevm_hdr -** Started on Thu Feb 22 07:19:04 2001 jfv -** -** Moved from elfsh to librevm on January 2007 -may -** -** -** $Id: revm-objects.h,v 1.9 2007-11-30 10:13:54 may Exp $ +* @file librevm/include/revm-objects.h +** @ingroup librevm ** +** Started on Thu Feb 22 07:19:04 2001 jfv +** $Id: revm-objects.h 1397 2009-09-13 02:19:08Z may $ */ #ifndef __REVM_OBJECTS_H_ #define __REVM_OBJECTS_H_ - /** * Meta-object : Abstract object description when reflected */ @@ -60,6 +56,8 @@ } revmobj_t; +typedef struct s_revm_annotation revmannot_t; + /** * @brief Structure for an expression in ERESI : A tree of revmobj_t */ @@ -69,6 +67,7 @@ char *strval; /*! ASCII form of current expression object */ aspectype_t *type; /*! Expression type */ revmobj_t *value; /*! Expression field value */ + revmannot_t *annot; /*! Annotation on this expression */ struct s_revm_expr *parent; /*! Parent expression */ struct s_revm_expr *childs; /*! Child expressions list, if non-terminal */ struct s_revm_expr *next; /*! Next expression if curexpr is in record */ @@ -78,8 +77,9 @@ /** * @brief Generic structure for objects program annotations in ERESI */ -typedef struct s_revm_annotation +struct s_revm_annotation { + u_char inhash; /*! Is this expression somewhere in hash or list ? */ #define EDFMT_SCOPE_UNK 0 #define EDFMT_SCOPE_GLOBAL 1 #define EDFMT_SCOPE_FUNC 2 @@ -91,7 +91,7 @@ int nameoff; /*! Name offset in string table */ /* XXX: should be a symbol instead */ revmexpr_t *expr; /* Annotated expression, if already constructed */ -} revmannot_t; +}; /**********************************************************************************/ diff -Nru eresi-0.8a25/librevm/include/.svn/all-wcprops eresi-0.0.20110516/librevm/include/.svn/all-wcprops --- eresi-0.8a25/librevm/include/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/946/trunk/librevm/include -END -revm.h -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/librevm/include/revm.h -END -librevm-color.h -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/946/trunk/librevm/include/librevm-color.h -END -revm-io.h -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/946/trunk/librevm/include/revm-io.h -END -revm-objects.h -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/946/trunk/librevm/include/revm-objects.h -END diff -Nru eresi-0.8a25/librevm/include/.svn/entries eresi-0.0.20110516/librevm/include/.svn/entries --- eresi-0.8a25/librevm/include/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:53:48.747992Z -946 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -revm.h -file - - - - -2008-04-06T23:15:45.455147Z -6f9989429c0116fa0a195de943bbb74a -2008-03-27T22:53:48.747992Z -946 -may - -librevm-color.h -file - - - - -2008-04-06T23:15:45.472900Z -7f713c5b7859996d9ac1bd6d42d846a2 -2008-03-27T22:53:48.747992Z -946 -may - -revm-io.h -file - - - - -2008-04-06T23:15:45.484898Z -2aaecadfd008671320c8c538a7f965d8 -2008-03-27T22:53:48.747992Z -946 -may - -revm-objects.h -file - - - - -2008-04-06T23:15:45.495972Z -9358b64b62abb556ac2bc9274ca88476 -2008-03-27T22:53:48.747992Z -946 -may - diff -Nru eresi-0.8a25/librevm/include/.svn/format eresi-0.0.20110516/librevm/include/.svn/format --- eresi-0.8a25/librevm/include/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/include/.svn/text-base/librevm-color.h.svn-base eresi-0.0.20110516/librevm/include/.svn/text-base/librevm-color.h.svn-base --- eresi-0.8a25/librevm/include/.svn/text-base/librevm-color.h.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/text-base/librevm-color.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,90 +0,0 @@ -/* -** @file libui-color.h -** @ingroup librevm_hdr -** Started on Sun Nov 26 22:13:54 2006 mxatone -** -** $Id: librevm-color.h,v 1.7 2008-02-16 12:32:27 thor Exp $ -** -*/ - -#ifndef __LIBUI_COLOR_H__ - #define __LIBUI_COLOR_H__ - -#include "libelfsh.h" - -#define S_STARTCOLOR "\033[" -#define C_STARTCOLOR '\033' - -#define COLOR_TOKENS 50 -#define COLOR_TOKEN_LEN 256 - -/** - * ELFsh color structure - */ -typedef struct s_color -{ - -#define COLOR_NONE 0 -#define COLOR_BOLD 1 -#define COLOR_UNDERLINE 4 -#define COLOR_RESET 160 -#define COLOR_SEPARE ";" - -#define COLOR_FG_BLACK 30 -#define COLOR_FG_RED 31 -#define COLOR_FG_GREEN 32 -#define COLOR_FG_YELLOW 33 -#define COLOR_FG_BLUE 34 -#define COLOR_FG_MAGENTA 35 -#define COLOR_FG_CYAN 36 -#define COLOR_FG_WHITE 37 - -#define COLOR_BG_BLACK 40 -#define COLOR_BG_RED 41 -#define COLOR_BG_GREEN 42 -#define COLOR_BG_YELLOW 43 -#define COLOR_BG_BLUE 44 -#define COLOR_BG_MAGENTA 45 -#define COLOR_BG_CYAN 46 -#define COLOR_BG_WHITE 47 - u_int fground; - u_int bground; - u_int bold; - u_int underline; - -} color_t; - -extern u_int nocolor; - -/* Color functions */ -color_t *revm_colortable(char *t, char *te); -int revm_colorpattern(color_t *t, char *te, char *p); -color_t *revm_colorblank(); -char *revm_colorget(char *p, char *ty, void *o); -void revm_endline(); - -/* Simple */ -char *revm_colorinstr(char *text); -char *revm_colorstr(char *t); -char *revm_colorfieldstr(char *t); -char *revm_colortypestr(char *t); -char *revm_colorend(char *text); -char *revm_colorwarn(char *text); -char *revm_colorfunction(char *text); -char *revm_colorfilename(char *text); - -/* Advanced */ -char *revm_coloradv(char *ty, char *p, char *te); -char *revm_colorinstr_fmt(char* p, char *t); -char *revm_coloraddress(char *p, eresi_Addr a); -char *revm_colornumber(char *p, elfsh_Off n); -char *revm_colorstr_fmt(char *p, char *t); -char *revm_colorfieldstr_fmt(char *p, char *t); -char *revm_colortypestr_fmt(char *p, char *t); -char *revm_colorwarn_fmt(char *pattern, char *text); - -/* Misc */ -int revm_color_count(char *string); -int revm_color_size(char *string); - -#endif diff -Nru eresi-0.8a25/librevm/include/.svn/text-base/revm.h.svn-base eresi-0.0.20110516/librevm/include/.svn/text-base/revm.h.svn-base --- eresi-0.8a25/librevm/include/.svn/text-base/revm.h.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/text-base/revm.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,887 +0,0 @@ -/** -** @file revm.h -** @ingroup librevm_hdr -** Started on Thu Feb 22 07:19:04 2001 jfv -** Moved from elfsh to librevm on January 2007 -may -** -** $Id: revm.h,v 1.97 2008-02-16 12:32:27 thor Exp $ -*/ -#ifndef __REVM_H_ - #define __REVM_H_ - -/* User defined configuration */ -#include "revm-vars.h" - -/* Do not put all those headers when compiling for kernel */ -#ifndef __KERNEL__ - -#define __USE_ISOC99 - -#include -#include -#include - -#ifdef __BSD__ -#include -#elif defined(__linux__) -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define __USE_GNU -#if !defined(__OpenBSD__) -#include -#endif -#include -#include -#include -#else - #include "../../libregex/regex.h" -#endif - -#include "libelfsh.h" -//#include "libetrace.h" -#include "libedfmt.h" -#include "libaspect.h" - -#if defined(ELFSHNET) - #include -#endif - -#if defined(USE_READLN) - #include -#else - #define RL_PROMPT_START_IGNORE '\001' - #define RL_PROMPT_END_IGNORE '\002' -#endif - -#if defined(__FreeBSD__) - extern char **environ; -#endif - -#if defined(KERNSH) -#include "libkernsh.h" -#endif - -/* Disassembling engine */ -#include - -extern asm_processor proc; - -/* Now come INTERNAL DEBUGGING VARIABLES for various part of the ERESI code */ -#define __DEBUG_DISASM__ 0 -#define __DEBUG_SIGHANDLER__ 0 -#define __DEBUG_LANG__ 0 -#define __DEBUG_SCANNER__ 0 -#define __DEBUG_ASLR__ 0 -#define __DEBUG_NETWORK__ 0 -#define __DEBUG_RESOLVE__ 0 -#define __DEBUG_HIJACK__ 0 -#define __DEBUG_TEST__ 0 -#define __DEBUG_TRACE__ 0 -#define __DEBUG_GRAPH__ 0 -#define __DEBUG_ARG_COUNT__ 0 -#define __DEBUG_EXPRS__ 0 -#define __DEBUG_EXPRS_MORE__ 0 - -/* Parsing related defines */ -#define REVM_MAXNEST_LOOP 10 - -/* XXX: REVM still needs those definition somewhere ... modularity weaknesses w/ libstderesi */ -#define E2DBG_NAME "Embedded ELF Debugger" -#define E2DBG_ARGV0 "e2dbg" -#define CMD_CONTINUE "continue" -#define CMD_CONTINUE2 "cont" -#define CMD_QUIT "quit" -#define CMD_QUIT2 "exit" -#define CMD_RETURN "return" -#define CMD_RETURN2 "ret" -#define CMD_PARAM_INTO "into" -#define CMD_FOREACH "foreach" -#define CMD_FOREND "forend" -#define CMD_MATCH "rewrite" -#define CMD_MATCHEND "rwtend" -#define CMD_DEFAULT "default" -#define CMD_CASE "case" -#define CMD_PRE "pre" -#define CMD_POST "post" - -/* Special cmd_ return values that indicate special events */ -#define REVM_SCRIPT_ERROR (-1) -#define REVM_SCRIPT_OK (0) -#define REVM_SCRIPT_CONTINUE (1) -#define REVM_SCRIPT_STOP (2) -#define REVM_SCRIPT_QUIT (3) - -/* General usage macros */ -#define FATAL(a) { perror(a); revm_exit(-1); } -#define QUIT_ERROR(a) { revm_exit(a); } -#define RET(a) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, a) -#define RETERR(a) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, a, -1) -#define PERROR_RET(a, b) { perror(a); RETERR (b); } -#define PRINTABLE(c) (c >= 32 && c <= 126) -#define REGX_IS_USED(a) a -#define IS_VADDR(s) (s[0] == '0' && (s[1] == 'X' || s[1] == 'x')) -#define IS_BLANK(c) (c == ' ' || c == '\t') - -#define REVM_VAR_ARGC "$#" -#define REVM_VAR_RESULT "$_" -#define REVM_VAR_LOAD "$!" -#define REVM_VAR_ERROR "$ERR" -#define REVM_VAR_SHELL "$SHELL" -#define REVM_VAR_EDITOR "$EDITOR" -#define REVM_VAR_LIBPATH "$LPATH" -#define REVM_VAR_STRIPLOG "$SLOG" -#define REVM_TMPVAR_PREFIX "$TMPVAR" -#define REVM_VAR_ESHLEVEL "$ESHLVL" -#define REVM_VAR_PREFIX '$' - -/* Some constant tokens for case command */ -#define REVM_CASE_ARROW "->" -#define REVM_CASE_QMARK "?" - -/* REVM atomic operations */ -#define REVM_OP_UNKNOW 0 -#define REVM_OP_ADD 1 -#define REVM_OP_SUB 2 -#define REVM_OP_MUL 3 -#define REVM_OP_DIV 4 -#define REVM_OP_MOD 5 -#define REVM_OP_SET 6 -#define REVM_OP_CMP 7 -#define REVM_OP_MATCH 8 -#define REVM_OP_COPY 9 - -/* Some useful macros */ -#define CHOOSE_REGX(r, idx) r = (world.curjob->curcmd->use_regx[idx] ? \ - &world.curjob->curcmd->regx[idx] : \ - world.state.revm_use_regx ? &world.state.revm_regx : \ - NULL) -#define FIRSTREGX(r) CHOOSE_REGX(r, 0) -#define SECONDREGX(r) CHOOSE_REGX(r, 1) - -/** Macros for declaring commands inside modules - ** Necessary for beeing able to use module commands - ** in script without loading the module during the - ** entire script */ -#define REVM_COMMAND_DECLARE(name) char modcmd_##name = name - -/* ELF Versions */ -#define ELFSH_VERTYPE_NONE 0 -#define ELFSH_VERTYPE_UNK 1 -#define ELFSH_VERTYPE_NEED 2 -#define ELFSH_VERTYPE_DEF 3 -#define ELFSH_VERENTRY_MAX 4 - -/* Used to store ascii description for different structures types in data.c */ -#define ELFSH_INSTRTYPE_MAX 24 -#define ELFSH_OPTYPE_MAX 4 -#define ELFSH_SEGTYPE_MAX 7 -#define ELFSH_SHTYPE_MAX 16 -#define ELFSH_OBJTYPE_MAX 5 -#define ELFSH_SYMBIND_MAX 3 -#define ELFSH_SYMTYPE_MAX STT_NUM + 1 -#define ELFSH_ENCODING_MAX 3 -#define ELFSH_DYNAMIC_MAX 35 -#define ELFSH_EXTDYN_MAX 19 -#define ELFSH_MIPSDYN_MAX 43 -#define ELFSH_ARCHTYPE_MAX 56 -#define ELFSH_EXTSEG_MAX 5 -#define ELFSH_RELOC_i386_MAX 11 -#define ELFSH_RELOC_IA64_MAX 81 -#define ELFSH_RELOC_SPARC_MAX 55 -#define ELFSH_RELOC_SPARC64_MAX 55 -#define ELFSH_RELOC_ALPHA_MAX 43 -#define ELFSH_RELOC_MIPS_MAX 35 - -#define ELFSH_RELOC_MAX(file) revm_getmaxrelnbr(file) - -#define ELFSH_FEATURE_MAX 2 -#define ELFSH_POSFLAG_MAX 2 -#define ELFSH_FLAGS_MAX 4 -#define ELFSH_FLAGS1_MAX 15 -#define ELFSH_MIPSFLAGS_MAX 16 - -/* REVM general parameters */ -#define REVM_MAXARGC 128 -#define REVM_SEP "." -#define REVM_COMMENT_START '#' -#define REVM_DASH '-' -#define REVM_SLASH '/' -#define REVM_SPACE ' ' - -#define ELFSH_NAME "ELF shell" -#define ELFSH_INIT "elfsh_init" -#define ELFSH_FINI "elfsh_fini" -#define ELFSH_HELP "elfsh_help" - -/* REVM files */ -#define REVM_CONFIG ".eresirc" -#define REVM_FIFO_C2S "/tmp/.revm.io.c2s" -#define REVM_FIFO_S2C "/tmp/.revm.io.s2c" - -/* Traces directory */ -#define REVM_TRACE_REP ".etrace" - -/* For revm_object_display() */ -#define REVM_VIEW_HEX 0 -#define REVM_VIEW_DISASM 1 - -/* For elfsh/elfsh/modules.c:revm_change_handler() */ -#define ELFSH_ORIG ((void *) -1) - -/* For lang/access.c */ -#define REVM_INVALID_FIELD ((u_int) -1) - -/* ELFsh actions, for parametrizing some function behaviors */ -#define REVM_HASH_MERGE (1 << 0) -#define REVM_HASH_UNMERGE (1 << 1) -#define REVM_CREATE_NEWID (1 << 2) - -/* config strings */ -#define ERESI_VMCONFIG_ONLOAD_RCONTROL "onload.restore_control" -#define ERESI_VMCONFIG_GRAPH_STORAGEPATH "graph.storagepath" -#define ERESI_VMCONFIG_GRAPH_VIEWCMD "graph.viewcmd" -#define ERESI_VMCONFIG_GRAPH_AUTOVIEW "graph.autoview" -#define ERESI_VMCONFIG_GRAPH_AUTOBUILD "graph.autobuild" -#define ERESI_VMCONFIG_USE_MORE "vm.use_more" -#define ERESI_VMCONFIG_USE_ASMDEBUG "asm.debug" -#define ERESI_VMCONFIG_HISTORY "history" - -#define ERESI_DEFAULT_HISTORY ".eresi_history" - -/* Manage string table */ -#define REVM_STRTABLE_GET(_out, _in) \ -do { \ - if (_in > strtable_current) \ - _out = NULL; \ - else \ - _out = strtable + _in; \ -} while(0) - - -/* Take a revmargv_t and fill its argc field */ -/* Only used when the command is unknown (module) and tries to be determined */ -#define REVM_CMDARGS_COUNT(cmd) \ -do \ -{ \ - int len; \ - for (len = 0; cmd->param[len] != 0; len++) \ - cmd->argc++; \ -} \ -while (0) - - -/* Regx option, a module of struct s_args */ -typedef struct s_list -{ - regex_t name; - char *rname; - u_int off; - u_int size; - char otype; -} revmlist_t; - - -/* Structure for constants */ -typedef struct s_const -{ - const char *desc; - const char *name; - eresi_Addr val; -} revmconst_t; - - -/* ELFsh command handlers */ -typedef struct s_cmdhandler -{ - int (*reg)(u_int i, u_int s, char **a); /* Registration handler */ - int (*exec)(); /* Execution handler */ - char *arg1; /* Option activation variable ptr */ - void *arg2; /* Option regex ptr */ - char *arg3; /* Regex switch ptr */ - char wflags; /* 1 if the cmd need a valid curfile */ - char *help; /* Help string */ -} revmcmd_t; - - -/* Thats the command line options registering structure */ -typedef struct s_args -{ - char *param[REVM_MAXARGC]; /* Parameters */ - char use_regx[2]; /* 1 if the option use a regx */ - regex_t regx[2]; /* Regx */ - revmlist_t disasm[2]; /* D/X parameters */ - char argc; /* Number of args in param[] */ - revmcmd_t *cmd; /* Command descriptor */ - char *name; /* Command name */ - char *endlabel; /* Co-Label for foreach/forend */ -#define REVM_IDX_UNINIT ((unsigned int) (-1)) - u_int listidx; /* Iteration index for this foreach */ - struct s_args *next; - struct s_args *prev; -} revmargv_t; - - -/* Trace structures, used by the tracer */ -typedef struct s_revmtraces -{ - int (*exec)(elfshobj_t*, char *, char **); /* Function used */ - - /* Unexistant (0), optional (1), needed (2) */ - char flagName; /* Need a first argument */ - char flagArg; /* Need a second argument */ -} revmtraces_t; - - - -#include - - - -/* REVM module structure */ -typedef struct s_module -{ - char *path; /* Name */ -#ifdef __BEOS__ - image_id handler; /* Object handler */ -#else - void *handler; /* Object handler */ -#endif - void (*help)(); /* Help wrapper */ - void (*init)(); /* Constructor pointer */ - void (*fini)(); /* Destructor pointer */ - u_int id; /* Object ID */ - time_t loadtime; /* Load time stamp */ - struct s_module *next; /* Next module of the list */ -} revmmod_t; - - -/* This structure contains the control flow context for e2dbg scripts */ -typedef struct s_revmcontext -{ - int savedfd; - char savedmode; - revmargv_t *savedcmd; - char *(*savedinput)(); - char **savedargv; - char *savedname; - revmargv_t *curcmd; -} revmcontext_t; - -/* We use a separate header for the generic IO sublib */ -#include "revm-io.h" - -/* We use a separate header for defnition of object structures */ -#include "revm-objects.h" - - - -/* This structure stores the current FOREACH iteration state for a job */ -typedef struct s_revmiteration -{ -#define REVM_IDX_UNINIT ((unsigned int) (-1)) - u_int *curindex; /* Current iteration index (most-nested foreach) */ - char *curkey; /* Name (key) of matchme expression in list */ - char *curname; /* Name (bound) of induction variable if any */ - list_t *list; /* Current list being iterated */ -} revmiter_t; - -/* This structure stores the current REWRITE transformation state for a job */ -typedef struct s_revmrewrite -{ - revmexpr_t *matchexpr; /* Expression to rewrite */ - u_char matched; /* Matched flag : just 0 or 1 depending on last try */ - u_char replaced; /* Indicate if we have already transformed */ -} revmrewrite_t; - -/* REVM job structure, one per client */ -typedef struct s_job -{ - revmworkspace_t ws; /* The job workspace */ - - /* Scripting machine job context */ -#define REVM_MAXSRCNEST 10 - revmargv_t *script[REVM_MAXSRCNEST]; /* List of script commands */ - revmargv_t *lstcmd[REVM_MAXSRCNEST]; /* Last command for each depth */ - u_int sourced; /* script depth (if beeing sourced) */ - - /* File job context */ - revmargv_t *curcmd; /* Next command to be executed */ - hash_t loaded; /* List of loaded ELF objects */ - elfshobj_t *curfile; /* Current working ELF object */ - asm_processor* proc; /* Processor structure */ - - /* Debugger job context */ - hash_t dbgloaded; /* List of objects loaded into e2dbg */ - elfshobj_t *dbgcurrent; /* Current working e2dbg file */ - - /* Job iteration and rewritten expression name if any */ - revmiter_t iter; /* Iteration context */ - revmrewrite_t rwrt; /* Rewrite context */ -} revmjob_t; - - -/* The REVM world */ -typedef struct s_world -{ - revmstate_t state; /* Flags structure */ - revmcontext_t context; /* Save the VM context before sourcing */ - revmmod_t *modlist; /* ELFsh loaded modules list */ - hash_t jobs; /* Hash table of jobs */ - revmjob_t *initial; /* Main initial job */ - revmjob_t *curjob; /* Current job */ - hash_t shared_hash; /* Hash of shared descriptors */ - char *scriptsdir; /* Directory which contains script commands */ - asm_processor proc; /* Libasm world */ - asm_processor proc_sparc; /* Libasm Sparc */ - asm_processor proc_mips; /* Libasm Mips */ - mjrsession_t mjr_session; /* Session holding contexts for mjollnir */ - int fifo_s2c; /* Fd for the debugger IO FIFO */ - int fifo_c2s; /* Fd for the debugger IO FIFO */ - void (*cmd_init)(); /* Command constructor from libstderesi */ -} revmworld_t; - - -/* The world */ -extern revmworld_t world; - -/* All the StandAlone hashtables */ -extern list_t frames_list; /* List of frames for the ERESI interpreter */ -extern hash_t instrlists_hash; /* Tables of expression lists */ -extern hash_t cmd_hash; /* commands handlers */ -extern hash_t parser_hash; /* parsers handlers */ -extern hash_t file_hash; /* elfshobj_t pointers */ -extern hash_t const_hash; /* elf.h picked up constants values */ -extern hash_t redir_hash; /* Function redirections hash table */ -extern hash_t mod_hash; /* Modules name hash table */ -extern hash_t exprs_hash; /* ERESI expressions types hash */ -extern hash_t labels_hash[10]; /* Scripting labels hash table */ - -/* The Level 1 object hash table : hash the object name and returns a L1handler_t* */ -extern hash_t L1_hash; /* For HDR, SHT, PHT, GOT, DTORS, CTORS, DYNAMIC, SECTIONS */ - -/* The Level 2 object hash table list : hash the object name and returns a L2handler_t* */ -extern hash_t elf_L2_hash; /* For the ELF header fields */ -extern hash_t sht_L2_hash; /* For the Section header table fields */ -extern hash_t pht_L2_hash; /* For the Program header table fields */ -extern hash_t got_L2_hash; /* For the Global offset table fields */ -extern hash_t crs_L2_hash; /* For the .ctors fields */ -extern hash_t drs_L2_hash; /* For the .dtors fields */ -extern hash_t sym_L2_hash; /* For symbol fields */ -extern hash_t rel_L2_hash; /* For Relocation table fields */ -extern hash_t sct_L2_hash; /* For Section data access */ -extern hash_t dynsym_L2_hash; /* For .dynsym */ -extern hash_t dyn_L2_hash; /* For .dynamic */ - -extern hash_t vers_L2_hash; /* For .gnu.version */ -extern hash_t verd_L2_hash; /* For .gnu.version_d */ -extern hash_t vern_L2_hash; /* For .gnu.version_r */ -extern hash_t hashb_L2_hash; /* For .hash (bucket) */ -extern hash_t hashc_L2_hash; /* For .hash (chain) */ - -extern hash_t bg_color_hash; /* colors def */ -extern hash_t fg_color_hash; /* colors def */ -extern hash_t t_color_hash; /* colors type */ - -extern hash_t traces_cmd_hash;/* trace cmd table */ -extern hash_t goto_hash; /* goto hash */ - -/* Lattice for I/O */ -extern char *(*hooks_input[REVM_IO_NUM])(); -extern int (*hooks_output[REVM_IO_NUM])(char *buf); - -/* Data value/string/description arrays */ -extern revmconst_t asm_instr_type[ELFSH_INSTRTYPE_MAX]; -extern revmconst_t asm_operand_type[ELFSH_OPTYPE_MAX]; - -extern revmconst_t elfsh_extseg_type[ELFSH_EXTSEG_MAX]; -extern revmconst_t elfsh_seg_type[ELFSH_SEGTYPE_MAX]; -extern revmconst_t elfsh_sh_type[ELFSH_SHTYPE_MAX]; -extern revmconst_t elfsh_obj_type[ELFSH_OBJTYPE_MAX]; -extern revmconst_t elfsh_sym_bind[ELFSH_SYMBIND_MAX]; -extern revmconst_t elfsh_sym_type[ELFSH_SYMTYPE_MAX]; -extern revmconst_t elfsh_dynentry_type[ELFSH_DYNAMIC_MAX]; -extern revmconst_t elfsh_encoding[ELFSH_ENCODING_MAX]; -extern revmconst_t elfsh_extdyn_type[ELFSH_EXTDYN_MAX]; -extern revmconst_t elfsh_mipsdyn_type[ELFSH_MIPSDYN_MAX]; -extern char *elfsh_arch_type[ELFSH_ARCHTYPE_MAX]; -extern revmconst_t elfsh_feature1[ELFSH_FEATURE_MAX]; -extern revmconst_t elfsh_posflag1[ELFSH_POSFLAG_MAX]; -extern revmconst_t elfsh_flags[ELFSH_FLAGS_MAX]; -extern revmconst_t elfsh_flags1[ELFSH_FLAGS1_MAX]; -extern revmconst_t elfsh_mipsflags[ELFSH_MIPSFLAGS_MAX]; -extern revmconst_t elfsh_rel_type_i386[ELFSH_RELOC_i386_MAX]; -extern revmconst_t elfsh_rel_type_ia64[ELFSH_RELOC_IA64_MAX]; -extern revmconst_t elfsh_rel_type_sparc[ELFSH_RELOC_SPARC64_MAX]; -extern revmconst_t elfsh_rel_type_alpha[ELFSH_RELOC_ALPHA_MAX]; -extern revmconst_t elfsh_rel_type_mips[ELFSH_RELOC_MIPS_MAX]; -extern revmconst_t elfsh_verentry_type[ELFSH_VERENTRY_MAX]; - -/* This has to be prototyped in libelfsh and not put in extern ! */ -extern int elfsh_load_core_info(elfshobj_t *); - -/* Network related variables */ -//extern hash_t elfsh_net_client_list; /* The client socket's list */ -extern int elfsh_net_client_count; /* Number of clients connected */ -//extern revmsock_t elfsh_net_serv_sock; /* The main socket structur */ - -/* Lib path */ -extern char elfsh_libpath[BUFSIZ]; - -/* String table for .elfsh.strings */ -extern char *strtable; -extern u_int strtable_current; -extern u_int strtable_max; - -/* Prompt storage */ -extern void (*prompt_token_setup)(char *name, u_int size); -extern char prompt_token[512]; - -/* Registration handlers for options from opt.c */ -int revm_getoption(u_int index, u_int argc, char **argv); -int revm_getoption2(u_int index, u_int argc, char **argv); -int revm_getoption3(u_int index, u_int argc, char **argv); -int revm_getregxoption(u_int index, u_int argc, char **argv); -int revm_getinput(u_int index, u_int argc, char **argv); -int revm_getoutput(u_int index, u_int argc, char **argv); -int revm_getdisasm(u_int index, u_int argc, char **argv); -int revm_gethexa(u_int index, u_int argc, char **argv); -int revm_getvarparams(u_int index, u_int argc, char **argv); -int revm_getforparams(u_int index, u_int argc, char **argv); -int revm_getmatchparams(u_int index, u_int argc, char **argv); -int revm_getcaseparams(u_int index, u_int argc, char **argv); - -/* Libasm resolve handlers */ -void asm_do_resolve(void *data, eresi_Addr vaddr, char *, u_int); -char *revm_resolve(elfshobj_t *file, eresi_Addr addr, elfsh_SAddr *roff); - -/* General VM functions */ -revmexpr_t *revm_lookup_param(char *param); -revmobj_t *revm_check_object(revmobj_t *pobj); -void revm_destroy_object(revmobj_t *pobj); -revmobj_t *revm_copy_object(revmobj_t *pobj); -elfshobj_t *revm_getfile(u_int index); -revmmod_t *revm_getmod(u_int index); -char *revm_reverse(elfshobj_t *file, u_int vaddr); - -/* Lookup functions */ -revmobj_t *revm_lookup_immed(char *param); -revmexpr_t *revm_lookup_var(char *param); - -elfshobj_t *revm_lookup_file(char *param); -u_int revm_lookup_index(char *param); -char *revm_lookup_string(char *param); -eresi_Addr revm_lookup_addr(char *param); - -/* Lazy Abstract Type system functions */ -int revm_convert2str(revmobj_t *obj); -int revm_convert2int(revmobj_t *obj); -int revm_convert2long(revmobj_t *obj); -int revm_convert2raw(revmobj_t *obj); -int revm_convert2byte(revmobj_t *obj); -int revm_convert2short(revmobj_t *obj); -int revm_convert2daddr(revmobj_t *obj); -int revm_convert2caddr(revmobj_t *obj); - -/* Command API */ -int revm_command_set(char *cmd, void *exec, void *reg, u_int needcur); -int revm_command_add(char *cmd, void *exec, void *reg, - u_int needfile, char *help); -int revm_command_del(char *cmd); - -/* Default grammar handlers */ -revmobj_t *parse_lookup3_index(char *param, char *fmt, u_int sepnbr); -revmobj_t *parse_lookup3(char *param, char *fmt, u_int sepnbr); -revmobj_t *parse_lookup4(char *param, char *fmt, u_int sepnbr); -revmobj_t *parse_lookup5_index(char *param, char *fmt, u_int sepnbr); -revmobj_t *parse_vector(char *param, char *fmt); -revmobj_t *parse_hash(char *param, char *fmt); -revmobj_t *parse_hash_field(char *param, char *fmt); -revmobj_t *parse_list(char *param, char *fmt); - -/* Versions functions */ -int revm_version_pdef(hashdef_t *p, u_int ai, u_int i, char *id, - char *n, char *t, regex_t *r); -int revm_version_pneed(hashneed_t *p, u_int ai, u_int i, char *id, - char *n, char *t, regex_t *r); -int revm_version_unk(u_int ai, u_int i, char *id, char *n, char *t); - -/* Disassembling and hexadecimal view functions */ -u_int revm_instr_display(int, u_int, eresi_Addr, u_int, u_int, - char *, u_int, char *); -int revm_section_display(elfshsect_t *s, char *name, revmlist_t *re); -int revm_match_sht(elfshobj_t *file, elfshsect_t *l, revmlist_t *actual); -int revm_match_symtab(elfshobj_t *file, elfshsect_t *symtab, - revmlist_t *actual, int flag); -int revm_match_special(elfshobj_t *file, eresi_Addr vaddr, revmlist_t*); -int revm_object_display(elfshsect_t *parent, elfsh_Sym *sym, int size, - u_int off, u_int foffset, eresi_Addr vaddr, - char *name, char otype); - -/* Parsing / Scanning functions */ -char *revm_filter_param(char *buf, char *ptr); -char *revm_build_unknown(char *buf, const char *str, u_long type); -void revm_filter_zero(char *str); -int revm_parseopt(int argc, char **argv); -void revm_findhex(u_int argc, char **argv); -int revm_trans_speblank(const char *in, char ***av, u_int *ac); -void revm_replace_speblanks(u_int argc, char **argv); -u_int revm_findblanks(char *buf); -char **revm_doargv(u_int nbr, u_int *argc, char *buf); - -/* String functions */ -int revm_strtable_add(char *string); - -/* Trace functions */ -int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg); -int traces_add(elfshobj_t *file, char *name, char **optarg); -int traces_rm(elfshobj_t *file, char *name, char **optarg); -int traces_exclude(elfshobj_t *file, char *freg, char **oreg); -int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg); -int traces_enable(elfshobj_t *file, char *name, char **optarg); -int traces_disable(elfshobj_t *file, char *name, char **optarg); -int traces_create(elfshobj_t *file, char *name, char **optarg); -int traces_delete(elfshobj_t *file, char *name, char **optarg); -int traces_flush(elfshobj_t *file, char *name, char **optarg); -int traces_list(elfshobj_t *file, char *name, char **optarg); -int traces_run(elfshobj_t *file, char **argv, int argc); - -int revm_traces_add_arguments(int argc, char **argv); -edfmtfunc_t *revm_traces_tracable_with_type(elfshobj_t *file, char *func_name, u_char external); -elfshtraces_t *revm_traces_createargs(elfshobj_t *file, char *name, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external); - -/* Hash functions */ -int revm_hashunk(int i); -int revm_hashbucket_print(int, int, int, char *, int, int, int); -int revm_hashchain_print(int i, int s, char *n, int r, int h); - -/* Internal functions */ -revmmod_t *revm_modprobe(); -void revm_tables_setup(); -int revm_doerror(void (*fct)(char *str), char *str); -void revm_error(char *label, char *param); -void revm_badparam(char *str); -void revm_unknown(char *str); -void revm_exit(int err); -void revm_banner_print(); -void revm_dynentinfo(elfshobj_t *f, elfsh_Dyn *ent, char *info); -int revm_usage(char *str); -int revm_modlist(); -int revm_isnbr(char *string); -void revm_workfiles_load(); -int revm_implicit(revmcmd_t *actual); -int revm_workfiles_unload(); -int dprintf(int fd, char *format, ...); -void revm_pht_print(elfsh_Phdr *phdr, uint16_t num, eresi_Addr base); -char *revm_fetch_sht_typedesc(elfsh_Word typenum); -int revm_sht_print(elfsh_Shdr *shdr, u_int num, char rtflag); -int revm_load_init_dephash(elfshobj_t *file, char *name); -int revm_file_load(char *name, eresi_Addr base, elfshlinkmap_t *lm); -int revm_is_loaded(char *name); -int revm_doswitch(int nbr); -char *revm_ascii_type(hash_t *cur); -char *revm_ascii_ltype(list_t *cur); -char *revm_modename_get(); -char *revm_basename(char *str); -void revm_quitmsg_set(char *msg); -int revm_fifo_io(revmjob_t *job); -void revm_object_print(revmobj_t *obj); -char *revm_string_get(char **params); -int revm_source(char **params); -int revm_help(char *command); -void revm_print_actual(revmargv_t *cur); -int revm_printscript(revmargv_t *start); - -/* Vector related functions */ -int revm_vectors_getdims(char *str, unsigned int *dims); -char *revm_ascii_vtype(vector_t *cur); -int revm_vectors_getdimnbr(char *str); -int revm_vector_bad_dims(vector_t *v, unsigned int *dims, u_int dimnbr); - -/* Dependences related information : deps.c */ -int revm_load_enumdep(elfshobj_t *obj); -int revm_load_dep(elfshobj_t *p, char *n, eresi_Addr b, elfshlinkmap_t *, hash_t*); -int revm_unload_dep(elfshobj_t *obj, elfshobj_t *root); -char *revm_load_searchlib(char *name); -elfshobj_t *revm_is_dep(elfshobj_t *obj, char *path); -elfshobj_t *revm_is_depid(elfshobj_t *obj, int id); - - -/* Top skeleton functions */ -int revm_init() __attribute__((constructor)); -int revm_loop(int argc, char **argv); -int revm_setup(int ac, char **av, char mode, char side); -int revm_run(int ac, char **av); -int revm_config(char *config); -void revm_postexec(int retval); -void revm_cleanup(); - -/* Scripting flow functions */ -int revm_execscript(); -int revm_execmd(); -int revm_move_pc(char *idx); -int revm_openscript(char **av); -int revm_testscript(int ac, char **av); -int revm_exec_str(char *str); -int revm_context_restore(int, char, revmargv_t*, void*, char**, char*); - -/* ERESI variables related functions */ -int revm_setvar_str(char *varname, char *value); -int revm_setvar_raw(char *varname, char *value, u_int len); -int revm_setvar_byte(char *varname, u_char byte); -int revm_setvar_short(char *varname, u_short val); -int revm_setvar_int(char *varname, u_int val); -int revm_setvar_long(char *varname, u_long val); -char *revm_tmpvar_create(); -int revm_variable_istemp(revmexpr_t *e); - -/* ERESI types related functions */ -int revm_type_prints(); -int revm_type_print_regex(char *regex); -int revm_type_copy(char *from, char *to); -int revm_type_hashcreate(char *name); - -/* Data access related functions */ -aspectype_t *revm_fieldoff_get(aspectype_t *par, char *fld, u_int *off); -revmobj_t *revm_object_lookup_real(aspectype_t *type, char *objname, char *objpath, char trans); -revmobj_t *revm_object_lookup(char *str); -revmobj_t *revm_object_create(aspectype_t *type, void *data, char transaddr); - -/* Generic handlers for data accesses */ -char *revm_generic_getname(void *type, void *data); -int revm_generic_setname(void *type, void *data, void *newdata); -eresi_Addr revm_generic_getobj(void *data); -eresi_Addr revm_hash_getobj(void *data); -int revm_byte_setobj(void *data, eresi_Addr value); -int revm_short_setobj(void *data, eresi_Addr value); -int revm_int_setobj(void *data, eresi_Addr value); -int revm_long_setobj(void *data, eresi_Addr value); -char *revm_generic_getdata(void *data, int off, int sizelm); -int revm_generic_setdata(void *d, int off, void *ndat, int sz, int szlm); - -/* Object creation/verification functions */ -int revm_convert_object(revmexpr_t *e, u_int objtype); -revmL1_t *revm_create_L1ENT(void *get_obj, - void *get_obj_idx, - void *get_obj_nam, - hash_t *l2_hash, - void *get_entptr, - void *get_entval, - void *set_entval, - u_int elem_size); -revmL2_t *revm_create_L2ENT(void *get_obj, - void *set_obj, - char type, - void *get_name, - void *set_name, - void *get_data, - void *set_data); -revmcmd_t *revm_create_CMDENT(int (*exec)(void *file, void *av), - int (*reg)(u_int i, u_int ac, char **av), - int flags, char *help); -elfshredir_t *revm_create_REDIR(u_char type, char *sname, char *dname, - eresi_Addr saddr, eresi_Addr daddr); -revmobj_t *revm_create_IMMED(char type, char perm, u_int val); -revmobj_t *revm_create_IMMEDSTR(char perm, char *str); -revmobj_t *revm_create_LONG(char perm, eresi_Addr val); -revmobj_t *revm_create_CADDR(char perm, eresi_Addr val); -revmobj_t *revm_create_DADDR(char perm, eresi_Addr val); - -/* Interface related functions */ -int revm_system(char *cmd); -void revm_dbgid_set(u_int pid); -u_int revm_dbgid_get(); - -/* Atomic operations */ -int revm_preconds_atomics(revmexpr_t **o1, revmexpr_t **o2); -int revm_nextconds_atomics(revmexpr_t *o1, revmexpr_t *o2); -int revm_arithmetics(revmexpr_t *e1, revmexpr_t *e2, u_char op); -int revm_hash_add(hash_t *h, revmexpr_t *e); -int revm_hash_del(hash_t *h, revmexpr_t *e); -int revm_elist_add(list_t *h, revmexpr_t *e); -int revm_elist_del(list_t *h, revmexpr_t *e); -int revm_hash_set(char *tab, char *elm, void *obj, u_int type); -int revm_elist_set(char *tab, char *elm, void *obj, u_int type); -int revm_testbit(revmexpr_t *o1, revmexpr_t *o2, u_int *result); -int revm_object_compare(revmexpr_t *e1, revmexpr_t *e2, eresi_Addr *val); -int revm_object_set(revmexpr_t *e1, revmexpr_t *e2); - -/* Job related functions */ -int revm_own_job(revmjob_t *job); -int revm_valid_workspace(char *name); -void revm_switch_job(revmjob_t *job); -revmjob_t *revm_clone_job(char *name, revmjob_t *job); -int revm_add_script_cmd(char *dirstr); -revmjob_t *revm_localjob_get(); - -#ifdef __KERNEL__ -revmjob_t *revm_socket_add(int socket, void *addr); -#else -revmjob_t *revm_socket_add(int socket, struct sockaddr_in *addr); -#endif - -int revm_screen_switch(); -int revm_screen_clear(int i, char c); -int revm_screen_update(u_short isnew, u_short prompt_display); -int revm_workspace_next(); - -/* libedfmt related functions */ -int revm_edfmt_parse(elfshobj_t *file); -int revm_edfmt_uni_print(elfshobj_t *file); - -/* Type/Inform related functions */ -revmexpr_t *revm_inform_type(char *type, char *name, char *addr, revmexpr_t *e, u_char p, u_char r); -revmexpr_t *revm_inform_type_addr(char *t, char *n, eresi_Addr a, revmexpr_t *, u_char p, u_char r); -int revm_check_addr(elfshobj_t *obj, eresi_Addr add); -int revm_informed_print(char *name); -int revm_uninform_type(char *type, char *varname, u_char print); -int revm_type_copy(char *from, char *to); -int revm_type_hashcreate(char *name); -int revm_type_print(char *type, char mode); -revmannot_t *revm_annot_get(char *name); - -/* Expression related functions */ -revmexpr_t *revm_simple_expr_create(aspectype_t *datatype, char *name, char *value); -revmexpr_t *revm_expr_create(aspectype_t *type, char *name, char *val); -revmexpr_t *revm_expr_get(char *pathname); -int revm_expr_compare(revmexpr_t *orig, revmexpr_t *candid, eresi_Addr *val); -int revm_expr_match(revmexpr_t *candid, revmexpr_t *orig); -int revm_expr_set(revmexpr_t *adst, revmexpr_t *asrc); -int revm_expr_print(char *pathname); -int revm_expr_match_by_name(char *original, char *candidate); -int revm_expr_compare_by_name(char *original, char *candidate, eresi_Addr *val); -int revm_expr_set_by_name(char *dest, char *source); -aspectype_t *revm_exprtype_get(char *exprvalue); -revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name); -revmexpr_t *revm_expr_copy(revmexpr_t *source, char *dstname, u_char isfield); -int revm_expr_destroy(char *e); - -/* May not be defined */ -#ifndef __KERNEL__ - -#ifdef __BSD__ -extern int vsscanf(const char * restrict str, const char * restrict format, - va_list ap); -#elif defined(__linux__) -extern int vsscanf (__const char *__restrict __s, - __const char *__restrict __format, _G_va_list __arg); -#endif - -void wait4exit(void *); - -#endif /* __KERNEL__ */ - -#endif /* __ELFSH_H_ */ - diff -Nru eresi-0.8a25/librevm/include/.svn/text-base/revm-io.h.svn-base eresi-0.0.20110516/librevm/include/.svn/text-base/revm-io.h.svn-base --- eresi-0.8a25/librevm/include/.svn/text-base/revm-io.h.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/text-base/revm-io.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,336 +0,0 @@ -/** -** @file revm.h for librevm in ERESI -** @ingroup librevm_hdr -** Started on Thu Feb 22 07:19:04 2001 jfv -** Moved from elfsh to librevm on January 2007 jfv -** $Id: revm-io.h,v 1.56 2008-02-16 12:32:27 thor Exp $ -*/ -#ifndef __REVM_IO_H_ - #define __REVM_IO_H_ - -#ifndef __KERNEL__ - #include - #include - #include - #include - #include - #include -#endif - -#include "librevm-color.h" - -#if defined(ELFSHNET) - #include -#endif - -/* Network related defines */ -#define REVM_PORT 4444 -#define REVM_DUMP_PORT 4445 -#define REVM_MAX_CLIENTS 4 -#define REVM_MAX_SEND_SIZE 2048 - -/* DUMP related defines */ -#define REVM_DUMP_CMD 1 -#define REVM_DUMP_MSG 2 - -#define REVM_NAME "revm" -#define REVM_VERSION "0.81" -#define REVM_RELEASE "a8" -#define REVM_EDITION "dev" - -/* Unused, feel free to try it, its awesome */ -#define ELFSH_CIRCUS_PROMPT \ -"\033[00;01;30m(" \ -"\033[00;01;31me" \ -"\033[00;01;32ml" \ -"\033[00;01;33mf" \ -"\033[00;01;34ms" \ -"\033[00;01;35mh" \ -"\033[00;01;36m-" \ -"\033[00;01;30m" \ - ELFSH_VERSION \ -"\033[00;01;35m-" \ -"\033[05;01;35mcircus" \ -"\033[00;01;35m-edition" \ -"\033[00;01;30m)" \ -"\033[00m " - -/* The ERESI team crew prompt */ -#define ELFSH_CREW_PROMPT \ -"\033[00;01;30m(" \ - "\033[00;01;31melfsh" \ - "\033[00;01;30m-" \ - "\033[00;01;33m" \ - ELFSH_VERSION \ - "\033[00;01;30m-" \ - "\033[00;01;33m" \ - ELFSH_RELEASE \ - "\033[00;01;30m-" \ - "\033[00;01;32mdevhell" \ - "\033[00;01;30m)" \ - "\033[00m " - -/* Be original, do your own */ -#define ELFSH_PROMPT ELFSH_CREW_PROMPT -//#define ELFSH_PROMPT ELFSH_CIRCUS_PROMPT - -/* Now some strings for graphviz/dot */ -#define GVZ_COLOR_BLUE "\"blue\"" -#define GVZ_COLOR_CORAL "\"coral\"" -#define GVZ_COLOR_CYAN "\"cyan\"" -#define GVZ_COLOR_RED "\"red\"" -#define GVZ_COLOR_GREEN "\"green\"" -#define GVZ_COLOR_BLACK "\"black\"" -#define GVZ_COLOR_GREY "\"grey\"" -#define GVZ_COLOR_BROWN "\"brown\"" -#define GVZ_COLOR_PINK "\"pink\"" -#define GVZ_COLOR_YELLOW "\"yellow\"" - -#define GVZ_NODE_EPOINT 0 -#define GVZ_NODE_MAIN 1 -#define GVZ_NODE_INTERN 2 -#define GVZ_NODE_EXTERN 3 -#define GVZ_NODE_UNKNOWN 4 - -/* XXX: Deprecated? */ -#define BLK_COLOR_FUNC GVZ_COLOR_GREEN -#define BLK_COLOR_NORM GVZ_COLOR_CYAN -#define BLK_COLOR_RET GVZ_COLOR_CORAL -#define BLK_COLOR_TRUE GVZ_COLOR_GREEN -#define BLK_COLOR_FALSE GVZ_COLOR_RED -#define BLK_COLOR_CONT GVZ_COLOR_BLACK -#define BLK_COLOR_CALL GVZ_COLOR_BLUE -#define BLK_COLOR_JUMP GVZ_COLOR_BLACK - -#define LNK_COLOR_CALL GVZ_COLOR_BROWN -#define LNK_COLOR_RET GVZ_COLOR_YELLOW -#define LNK_COLOR_TRUE GVZ_COLOR_GREEN -#define LNK_COLOR_FALSE GVZ_COLOR_RED -#define LNK_COLOR_DELAY GVZ_COLOR_PINK - -#define FNC_COLOR_INTERN GVZ_COLOR_GREY -#define FNC_COLOR_EPOINT GVZ_COLOR_GREEN -#define FNC_COLOR_EXTERN GVZ_COLOR_CYAN -#define FNC_COLOR_MAIN GVZ_COLOR_BLUE -#define FNC_COLOR_DEFAULT GVZ_COLOR_GREY - -/* Return of an input function in case of ignorable input */ -#define REVM_INPUT_VOID (-1) -#define REVM_INPUT_EXIT (-2) -#define REVM_INPUT_TRANSFERED (-3) - -/** - * Elfsh Output Caching structure - */ -typedef struct s_outbuf -{ - int nblines; - unsigned int cols; - unsigned int lines; - char ignore; -} revmoutbuf_t; - - -/** - * Input / Output template for ELFsh - */ -typedef struct s_io -{ -#define REVM_IO_STD 1 -#define REVM_IO_NET 2 -#define REVM_IO_DUMP 3 -#define REVM_IO_NUM 4 - char type; /*! IO type */ - int input_fd; /*! Input file */ - int output_fd; /*! Output file */ - char *(*input)(); /*! Read Input data */ - char *(*old_input)(); /*! Old Input handler */ - int (*output)(char *buf); /*! Write output data */ - revmoutbuf_t outcache; - - /* Readline IO specific */ - char *buf; /*! readline line */ - char *savebuf; - int rl_point; - int rl_end; - - /* DUMP IO specific */ - int new; /*! 0 if already used */ - -#if defined(ELFSHNET) - pkt_t *pkt; /*! Last received dump */ -#else - void *pkt; /*! Unused else */ -#endif - -} revmio_t; - - - - -/** - * REVM socket structure - */ -typedef struct s_socket -{ - int socket; /*! The socket */ - char **recvd; /*! List of received buffer */ - - /* XXX: NEW/OLD is not explicit enough, rename ... */ -#define NEW 1 -#define OLD 0 - int recvd_f; /*! NEW if the buffer was not passed to the parser yet */ -#define YES 1 -#define NO 0 - int ready_f; /*! Have we received the trailing \n ? */ - -#ifndef __KERNEL__ - struct sockaddr_in addr; /*! sockaddr_in struct */ -#endif - -} revmsock_t; - - - -/** - * Screen cache for each workspace - */ -typedef struct s_screen -{ - unsigned int x; /*! Screen height */ - unsigned int y; /*! Screen width */ - char *buf; /*! Screen buffer */ - char *head; /*! Buffer's beginning */ - char *tail; /*! Buffer's end */ -} revmscreen_t; - - -/** - * @brief REVM job structure, one per client - */ -typedef struct s_workspace -{ - char *name; /*! Name of the job */ - revmsock_t sock; /*! Unused in initial job */ - u_char active; /*! Is the workspace active ? */ - time_t createtime; /*! Workspace creation time */ - int logfd; /*! Log file descriptor */ - revmscreen_t screen; /*! Last printed screen */ - char *oldline; /*! Previous command line */ - -#define REVM_JOB_LOGGED (1 << 0) - u_char state; /*! Job state flags */ - -#define REVM_INPUT 0 -#define REVM_OUTPUT 1 - revmio_t io; /*! Current IO for this job */ - -} revmworkspace_t; - - -/** - * @brief Hold all the VM flags, sort of global context - */ -typedef struct s_state -{ - char revm_quiet; /*! Quiet mode : 0 or 1 */ - char revm_gvl; /*! Graph verbose level : 0 or 1 */ - char revm_force; /*! Force mode : 0 or 1 */ - char revm_use_regx; /*! Is a global regx available ? */ - regex_t revm_regx; /*! Global regx */ - char *revm_sregx; /*! Global regx in string format */ - char revm_use_alert; /*! Is an alert regx available ? */ - regex_t revm_alert; /*! Alert regx */ - char *revm_salert; /*! ALert regx in string format */ - char *sort; /*! Actual sorting choice */ - char *input; /*! Implicit File input (-f option) */ - char *output; /*! Implicit File output (-w option) */ -#define REVM_STATE_CMDLINE 0 -#define REVM_STATE_SCRIPT 1 -#define REVM_STATE_INTERACTIVE 2 -#define REVM_STATE_DEBUGGER 3 -#define REVM_STATE_TRACER 4 - char revm_mode; /*! Command line, scripting, interactive, debugger ? */ -#define REVM_SIDE_CLIENT 0 -#define REVM_SIDE_SERVER 1 - char revm_side; /*! Useful for the bi-partite debugger */ - char revm_sourcing; /*! Are we sourcing a script ? */ - char revm_stopped; /*! We are in a signal handler */ - char revm_shared; /*! Next opened object must be shared */ - char revm_net; /*! We are a node connected to the elf network */ - u_int lastid; /*! Last Object ID */ -} revmstate_t; - -/* Extern variables */ -extern int elfsh_net_client_count; - - -/* Parsing, Scanning, I/O functions */ -char *revm_getln(); -int revm_initio(); -char **revm_input(int *argc, char *mayhavealine); -char *revm_stdinput(); -char *revm_fifoinput(); -int revm_flush(); -int revm_output(char *str); -int revm_output_nolog(char *str); -int revm_outerr(char *str); -int revm_output_bcast(char *str); -int revm_stdoutput(char *str); -int revm_display_prompt(); -void revm_setinput(revmworkspace_t *j, int fd); -void revm_setoutput(revmworkspace_t *j, int fd); -void revm_log(char *str); -int revm_closelog(); -char *revm_get_prompt(); -void revm_set_prompt(void (*func) (char *name, u_int size)); - -/* Network related functions */ -int revm_net_init(); -void revm_check_net_select(fd_set *sel_sockets, int sock); -int revm_select(); -char* revm_net_input(); -int revm_net_output(char *buf); -int revm_net_recvd(); -int revm_net_accept(); -int revm_dump_accept(); -int revm_socket_del(char *inet_addr); -int revm_socket_get_nb_recvd(char *inet); -int revm_update_recvd(revmsock_t *socket); -char* revm_socket_merge_recvd(revmsock_t *socket); -int revm_getmaxfd(); -int revm_clean_jobs(); - -/* Readline interface */ -int revm_init_history(int mode); -int revm_quit(int mode); -void revm_ctrl_set(int i, char c); -void revm_completion_install(char mode, char side); -void revm_completion_commands(hash_t *cmd_hash); -char **revm_completion(const char* text, int start, int end); -int revm_column_update(); -int revm_prompt_update(char *ptr, int size); -int revm_prompt_restore(); -void revm_prompt_log(); -void revm_prompt_postselect_restore(fd_set *sel_sockets); -char *revm_input_check(); -void revm_input_log(char *str); -void revm_input_prelog(char *buf); -void revm_screen_change(u_short isnew, char promptdisplay); -void revm_terminal_prepare(char mode); -void revm_terminal_unprepare(char mode); -void revm_buffer_reset(u_short isnew); -void revm_job_preswitch(); -void revm_job_postswitch(); -void revm_screen_getsize(int *lines, int *cols); -void revm_buffer_free(char *buf); -void revm_strip_char(char *str, char c); -void revm_callback_handler_remove(); -void revm_conditional_rlquit(); -void revm_rlfifo_write(); -int revm_is_enabled(); -int revm_is_stdinput(); -void revm_callback_handler_install(char *prompt, void (*fct)(char *str)); -void revm_line_handler(char *c); - -#endif diff -Nru eresi-0.8a25/librevm/include/.svn/text-base/revm-objects.h.svn-base eresi-0.0.20110516/librevm/include/.svn/text-base/revm-objects.h.svn-base --- eresi-0.8a25/librevm/include/.svn/text-base/revm-objects.h.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/include/.svn/text-base/revm-objects.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,146 +0,0 @@ -/** - * @defgroup librevm_hdr librevm Headers - */ -/** -** @file revm.h -** @ingroup librevm_hdr -** Started on Thu Feb 22 07:19:04 2001 jfv -** -** Moved from elfsh to librevm on January 2007 -may -** -** -** $Id: revm-objects.h,v 1.9 2007-11-30 10:13:54 may Exp $ -** -*/ -#ifndef __REVM_OBJECTS_H_ - #define __REVM_OBJECTS_H_ - - -/** - * Meta-object : Abstract object description when reflected - */ -typedef struct s_revm_object -{ - - /* Access handlers */ - eresi_Addr (*get_obj)(void *parent); - int (*set_obj)(void *parent, eresi_Addr value); - char *(*get_name)(void*, void *obj); - int (*set_name)(void*, void *, char *); - char *(*get_data)(void*, u_int off, u_int); - int (*set_data)(void*, u_int, char *, u_int, u_int); - - /* Attributes */ - elfshobj_t *root; /* Root parent */ - void *parent; /* Direct parent */ - u_int off; /* Optional byte offset */ - u_int size; /* Size of the immediate string */ - u_int sizelem; /* Size of element for OBJRAW */ - u_char immed; /* Immediate binary flag */ - u_char perm; /* TRUE if obj is a script variable */ - aspectype_t *otype; /* The object type identifier */ - - /* Only when describing elements of hash tables or list */ -#define CONT_UNKNOW 0 -#define CONT_HASH 1 -#define CONT_LIST 2 - u_char contype; /* Container type */ - char *hname; /* Name of parent container */ - char *kname; /* Name of element in container */ - - /* Immediate value if immed flag is set */ - union immval - { - u_char byte; - u_short half; - u_int word; - eresi_Addr ent; - char *str; - } immed_val; -} revmobj_t; - - -/** - * @brief Structure for an expression in ERESI : A tree of revmobj_t - */ -typedef struct s_revm_expr -{ - char *label; /*! Relative current field name */ - char *strval; /*! ASCII form of current expression object */ - aspectype_t *type; /*! Expression type */ - revmobj_t *value; /*! Expression field value */ - struct s_revm_expr *parent; /*! Parent expression */ - struct s_revm_expr *childs; /*! Child expressions list, if non-terminal */ - struct s_revm_expr *next; /*! Next expression if curexpr is in record */ -} revmexpr_t; - - -/** - * @brief Generic structure for objects program annotations in ERESI - */ -typedef struct s_revm_annotation -{ -#define EDFMT_SCOPE_UNK 0 -#define EDFMT_SCOPE_GLOBAL 1 -#define EDFMT_SCOPE_FUNC 2 - u_char scope; /*! XXX: Unused for now ? */ - eresi_Addr addr; /*! Global address */ - u_int typenum; /*! Type id associated to this annotation */ - u_int reg; /*! Function reg id base (stack) */ - int relvalue; /*! Relative value based on reg */ - int nameoff; /*! Name offset in string table */ - /* XXX: should be a symbol instead */ - revmexpr_t *expr; /* Annotated expression, if already constructed */ -} revmannot_t; - - -/**********************************************************************************/ -/****** Those 2 objects are reminicescence of the old object system of elfsh ******/ -/**** Need to disapear to use only revmannot/revmobj/aspectype instead of those *****/ -/**************** This only affects ERESI types of ELF structures ******************/ -/**********************************************************************************/ - - -/** - * @brief REVM Level 2 (= child of L1) object structure - */ -typedef struct s_L2handler -{ - - /* For fields */ - eresi_Addr (*get_obj)(void *obj); /*! Read object */ - int (*set_obj)(void *par, eresi_Addr arg); /*! Write object */ - - /* For names */ - char *(*get_name)(elfshobj_t *, void *obj); /*! Get name */ - int (*set_name)(elfshobj_t *, void *, char *); /*! Set name */ - - /* For sections data */ - char *(*get_data)(elfshsect_t *, u_int, u_int); /*! Read data */ - int (*set_data)(elfshsect_t*, u_int, char*, u_int, u_int); /* Write data */ - - u_char type; /*! Object type */ -} revmL2_t; - - - -/** - * @brief ELFsh Level 1 object (= parent object) structure - */ -typedef struct s_L1handler -{ - hash_t *l2list; /*! A ptr on the child L2 hashtable */ - u_int elem_size; /*! Size of one element of this object */ - - /* Handlers */ - void *(*get_obj)(void *container, void *retarg); /*! Read object and return size */ - void *(*get_obj_idx)(void *f, eresi_Addr i, void *a); /*! Read handler for arrays objects */ - void *(*get_obj_nam)(void *f, char *name); /*! Read handler by name */ - void *(*get_entptr)(void *f, eresi_Addr idx); /*! Get address */ - eresi_Addr (*get_entval)(void *ptr); /*! Get value */ - eresi_Addr (*set_entval)(void *ptr, eresi_Addr vaddr); /*! Set value */ -} revmL1_t; - - - -#endif diff -Nru eresi-0.8a25/librevm/io/color.c eresi-0.0.20110516/librevm/io/color.c --- eresi-0.8a25/librevm/io/color.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/color.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file color.c +* @file librevm/io/color.c * @ingroup io * @brief All functions about colors. * * Started on Sept 11 2005 mxatone * - * $Id: color.c,v 1.7 2008-02-16 12:32:27 thor Exp $ + * $Id: color.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -33,14 +33,11 @@ color_t *c; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,c, sizeof(color_t), NULL); - c->fground = COLOR_NONE; c->bground = COLOR_NONE; c->bold = COLOR_NONE; c->underline = COLOR_NONE; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (c)); } @@ -252,11 +249,11 @@ /* Simple functions */ char *revm_colorinstr(char *text) { return revm_colorget("%s", "instr" , text); } -char *revm_colorstr(char *text) { return revm_colorget("%s", "string" , text); } +char *revm_colorstr(char *text) { return revm_colorget("%s", "string" , text); } char *revm_colorfieldstr(char *text) { return revm_colorget("%s", "fieldstring", text); } char *revm_colortypestr(char *text) { return revm_colorget("%s", "typestring" , text); } -char *revm_colorend(char *text) { return revm_colorget("%s", "endstring" , text); } -char *revm_colorwarn(char *text) { return revm_colorget("%s", "warnstring" , text); } +char *revm_colorend(char *text) { return revm_colorget("%s", "endstring" , text); } +char *revm_colorwarn(char *text) { return revm_colorget("%s", "warnstring" , text); } char *revm_colorfunction(char *text) { return revm_colorget("%s", "function" , text); } char *revm_colorfilename(char *text) { return revm_colorget("%s", "filename" , text); } @@ -266,13 +263,10 @@ char *p; NOPROFILER_IN(); - p = revm_colorget(pattern, type, text); - strncpy(text, p, BUFSIZ); text[BUFSIZ-1] = 0; curtok--; - NOPROFILER_ROUT(text); } @@ -313,7 +307,7 @@ return revm_colorget(pattern, "address", &addr); } -char *revm_colornumber(char *pattern, elfsh_Off numb) +char *revm_colornumber(char *pattern, eresi_Off numb) { return revm_colorget(pattern, "number", &numb); } @@ -360,7 +354,6 @@ { if (string[i] == C_STARTCOLOR) { - //size++; while (i < len && string[i] != 'm') { size++; diff -Nru eresi-0.8a25/librevm/io/curjob.c eresi-0.0.20110516/librevm/io/curjob.c --- eresi-0.8a25/librevm/io/curjob.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/curjob.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file curjob.c +* @file librevm/io/curjob.c * @ingroup io * @brief Implement job API necessary for revm-io. * * Started September 16 03:11:04 2005 jfv * - * $Id: curjob.c,v 1.6 2007-08-03 11:51:00 heroine Exp $ + * $Id: curjob.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/io/input.c eresi-0.0.20110516/librevm/io/input.c --- eresi-0.8a25/librevm/io/input.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/input.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file input.c +* @file librevm/io/input.c * @ingroup io * @brief Input related functions. * * Started on Fri Feb 7 20:53:25 2003 jfv - * $Id: input.c,v 1.13 2008-02-16 12:32:27 thor Exp $ + * $Id: input.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -43,7 +43,7 @@ revm_log("\n"); revm_buffer_free(buf); if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER) + world.state.revm_mode == REVM_STATE_EMBEDDED) NOPROFILER_ROUT((char*) REVM_INPUT_VOID); buf = NULL; @@ -69,17 +69,18 @@ /** - * @brief Read input from the file descriptor + * @brief Read input from the current IO file descriptor */ char *revm_read_input() { char tmpbuf[BUFSIZ + 1]; int len; + u_char wantmore; NOPROFILER_IN(); /* In case we are scripting, even readline will use a read */ - for (len = 0; len < BUFSIZ; len++) + for (wantmore = len = 0; len < BUFSIZ; len++) switch (read(world.curjob->ws.io.input_fd, tmpbuf + len, 1)) { case 1: @@ -90,13 +91,23 @@ //fprintf(stderr, "Read length 0 ... \n"); NOPROFILER_ROUT((char *) REVM_INPUT_VOID); } - if (world.state.revm_mode == REVM_STATE_DEBUGGER && + if (wantmore) + { + len--; + wantmore = 0; + continue; + } + if (world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_CLIENT) tmpbuf[len + 1] = 0x00; else tmpbuf[len] = 0x00; goto end; } + else if ((len > 2 && tmpbuf[len - 1] == ':' && tmpbuf[len] == ':') || tmpbuf[len] == ',') + wantmore = 1; + else + wantmore = 0; continue; default: *tmpbuf = 0x00; @@ -110,7 +121,7 @@ /** - * Input handler for the FIFO + * IO Input handler for the debugger */ char *revm_fifoinput() { @@ -131,28 +142,28 @@ world.curjob->ws.io.input_fd = world.fifo_c2s; break; } - - ret = revm_read_input(); - world.curjob->ws.io.input_fd = fd; - world.curjob->ws.io.input = world.curjob->ws.io.old_input; - - /* Just debugging */ - switch (world.state.revm_side) - { + + ret = revm_read_input(); + world.curjob->ws.io.input_fd = fd; + world.curjob->ws.io.input = world.curjob->ws.io.old_input; + + /* Just debugging */ + switch (world.state.revm_side) + { case REVM_SIDE_CLIENT: //fprintf(stderr, "BACK from reading fifo (client legit) ... (%s)\n"); break; - case REVM_SIDE_SERVER: - //fprintf(stderr, "BACK from reading fifo (server legit) ... \n"); - break; - } - + case REVM_SIDE_SERVER: + //fprintf(stderr, "BACK from reading fifo (server legit) ... \n"); + break; + } + return (ret); } /** - * INPUT handler for stdin + * INPUT IO handler for stdin */ char *revm_stdinput() { @@ -174,7 +185,7 @@ /** - * Change the Input file + * Change the Input IO file descriptor */ void revm_setinput(revmworkspace_t *ws, int fd) { diff -Nru eresi-0.8a25/librevm/io/io.c eresi-0.0.20110516/librevm/io/io.c --- eresi-0.8a25/librevm/io/io.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/io.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,19 +1,19 @@ /** - * @file io.c + * @defgroup io Librevm IO API. + * @ingroup librevm + */ +/** +* @file librevm/io/io.c * @ingroup io * @brief Initialize the IO system. * * Started on Fri Mar 5 00:55:40 2004 jfv - * $Id: io.c,v 1.14 2008-02-16 12:32:27 thor Exp $ + * $Id: io.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" /** - * @defgroup io librevm Input/output - */ - -/** * Reset lines counters and ignore output state */ int revm_flush() @@ -25,7 +25,7 @@ /* Cache output only in IMODE/DEBUGGER mode */ if (world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) + world.state.revm_mode != REVM_STATE_EMBEDDED) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); revm_screen_getsize(&lines, &cols); @@ -125,6 +125,7 @@ { static int done = 0; revmjob_t *initial; + u_int i; NOPROFILER_IN(); if (done) @@ -134,6 +135,9 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__,initial, sizeof(revmjob_t), -1); memset(initial, 0, sizeof(revmjob_t)); + hash_init(&initial->recur[0].exprs , "job0_rec0_exprs" , 23, ASPECT_TYPE_EXPR); + hash_init(&initial->recur[0].labels, "job0_rec0_labels", 23, ASPECT_TYPE_STR); + revm_std_io(initial); initial->ws.active = 1; initial->ws.createtime = time(&initial->ws.createtime); @@ -150,6 +154,15 @@ "initial_dbgloaded_files", 11, ASPECT_TYPE_UNKNOW); + for (i = 0; i < REVM_MAXSRCNEST; i++) + { + initial->recur[i].script = NULL; + initial->recur[i].lstcmd = NULL; + initial->iter[i].listidx = REVM_IDX_UNINIT; + } + + initial->recur[0].funcname = "top-level"; + profiler_setcolor(revm_endline, revm_colorinstr, revm_colorstr, revm_colorfieldstr, revm_colortypestr, revm_colorend, revm_colorwarn, revm_colorfunction, revm_colorfilename); diff -Nru eresi-0.8a25/librevm/io/log.c eresi-0.0.20110516/librevm/io/log.c --- eresi-0.8a25/librevm/io/log.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/log.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file log.c +* @file librevm/io/log.c * @ingroup io * @brief Implement logging facilities. * * Started September 16 03:11:04 2005 jfv * - * $Id: log.c,v 1.10 2007-11-29 14:01:56 may Exp $ + * $Id: log.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/io/Makefile eresi-0.0.20110516/librevm/io/Makefile --- eresi-0.8a25/librevm/io/Makefile 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/Makefile 2011-05-16 11:34:12.000000000 +0000 @@ -17,18 +17,16 @@ CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ -I../../libelfsh/include/ -I../../libedfmt/include/ \ - -I../../elibc/include/ \ -I../../libui/include/ -I../../libasm/include/ \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libdump/include/ $(BUILDOP) -DELFSH_INTERN \ + -I../../libdump/include/ $(BUILDOP) $(EXTRACFLAGS) \ $(STATOPT2) $(ASMOPT) $(BITS) -DERESI32 $(READLNOPT) CFLAGS64 += -fPIC -g3 -Wall -I../include -Iinclude $(DYNOPT) \ -I../../libelfsh/include/ -I../../libedfmt/include/ \ - -I../../elibc/include/ \ -I../../libui/include/ -I../../libasm/include/ \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libdump/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../../libdump/include/ $(STATOPT2) $(EXTRACFLAGS) \ $(ASMOPT) $(BITS) -DERESI64 $(BUILDOP) $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/librevm/io/network.c eresi-0.0.20110516/librevm/io/network.c --- eresi-0.8a25/librevm/io/network.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/network.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,24 +1,38 @@ /** - * @file network.c +* @file librevm/io/network.c * @ingroup io * @brief The high-level network interface. * * Started Wed Feb 25 22:22:35 2004 yann_malcom * Updated Mon Mar 05 04:37:10 2007 jfv * - * $Id: network.c,v 1.10 2007-08-17 15:38:52 heroine Exp $ + * $Id: network.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" /* Number of clients connected */ -int elfsh_net_client_count = 0; +int elfsh_net_client_count = 0; + +int revm_netgdb_output(void) +{ + fprintf(stderr, "output called :) - output.\n" + "Info: job->ws.io.type: %d", world.curjob->ws.io.type); + + return 0; +} +char *revm_netgdb_input(void) +{ + fprintf(stderr, "input called :) - input \n"); + return "\n"; +} + /* Is net support enable ? */ -#if defined(ELFSHNET) +#if defined(ERESI_NET) /** * @brief Add a client socket to the elfsh_net_client_list. * @ingroup io @@ -46,10 +60,10 @@ XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (revmjob_t), NULL); - new->ws.sock.addr = *addr; - new->ws.sock.socket = socket; - new->ws.sock.recvd = NULL; - new->ws.sock.recvd_f = OLD; + new->ws.io.sock.addr = *addr; + new->ws.io.sock.socket = socket; + new->ws.io.sock.recvd = NULL; + new->ws.io.sock.recvd_f = OLD; elfsh_net_client_count++; new->ws.io.type = REVM_IO_NET; @@ -114,20 +128,20 @@ } } - if (tmp->ws.sock.recvd_f == OLD) + if (tmp->ws.io.sock.recvd_f == OLD) { /* recvd data have already been read so we forget them */ - tmp->ws.sock.recvd = NULL; + tmp->ws.io.sock.recvd = NULL; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } else { /* we have to count them */ - if (tmp->ws.sock.recvd != NULL) + if (tmp->ws.io.sock.recvd != NULL) { /* There might be data */ i = 0; - while (tmp->ws.sock.recvd[i] != NULL) + while (tmp->ws.io.sock.recvd[i] != NULL) { i++; } @@ -216,17 +230,17 @@ } } - if (revm_socket_close(tmp->ws.sock.socket) < 0) + if (revm_socket_close(tmp->ws.io.sock.socket) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to close socket", (-1)); //elfsh_net_client_count--; - if (tmp->ws.sock.recvd_f == NEW) + if (tmp->ws.io.sock.recvd_f == NEW) { /* We assume that buffer are not referenced, and so won't be used */ - nbargc = revm_socket_get_nb_recvd(inet_ntoa(tmp->ws.sock.addr.sin_addr)); + nbargc = revm_socket_get_nb_recvd(inet_ntoa(tmp->ws.io.sock.addr.sin_addr)); for (i = 0 ; i < nbargc ; i++) - XFREE (__FILE__, __FUNCTION__, __LINE__, tmp->ws.sock.recvd[i]); + XFREE (__FILE__, __FUNCTION__, __LINE__, tmp->ws.io.sock.recvd[i]); #if __DEBUG_NETWORK__ fprintf(stderr, "[DEBUG NETWORK] We are deleting a socket struct which has" @@ -234,7 +248,7 @@ #endif } - XFREE(__FILE__, __FUNCTION__, __LINE__,tmp->ws.sock.recvd); + XFREE(__FILE__, __FUNCTION__, __LINE__,tmp->ws.io.sock.recvd); hash_del(&world.jobs, inet_addr); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -618,15 +632,14 @@ temp_addr_len = sizeof (struct sockaddr_in); XALLOC(__FILE__, __FUNCTION__, __LINE__, temp_addr, temp_addr_len, -1); - temp_sock = accept(init->ws.sock.socket, + temp_sock = accept(init->ws.io.sock.socket, (struct sockaddr *) temp_addr, &temp_addr_len); if (temp_sock >= 0) { // Somebody want to join us. We are so "attractive" ... #if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Client " - "accepted on socket %d.\n",temp_sock); + fprintf(stderr, "[DEBUG NETWORK] Client accepted on socket %d.\n",temp_sock); #endif curjob = revm_socket_add(temp_sock, temp_addr); @@ -656,7 +669,7 @@ { oldjob = world.curjob; world.curjob = curjob; - revm_output("\n [*] Connection granted to ELFsh daemon\n\n"); + revm_output("\n [*] Connection granted to ERESI server\n\n"); revm_display_prompt(); world.curjob = oldjob; } @@ -697,12 +710,12 @@ if (!((revmjob_t *) actual->data)->ws.active) continue; - temp_socket = &((revmjob_t *) actual->data)->ws.sock; + temp_socket = &((revmjob_t *) actual->data)->ws.io.sock; - if (((revmjob_t *) actual->data)->ws.io.type != REVM_IO_NET) - continue; + if (((revmjob_t *) actual->data)->ws.io.type != REVM_IO_NET) + continue; - if (temp_socket->socket == init->ws.sock.socket || + if (temp_socket->socket == init->ws.io.sock.socket || temp_socket->socket == 0) continue; @@ -917,11 +930,11 @@ if (!((revmjob_t *) actual->data)->ws.active) continue; - temp_socket = & ((revmjob_t *) actual->data)->ws.sock; + temp_socket = & ((revmjob_t *) actual->data)->ws.io.sock; - if (temp_socket->recvd_f == NEW && - temp_socket->ready_f == YES) + if (temp_socket->recvd_f == NEW && + temp_socket->ready_f == YES) { #if __DEBUG_NETWORK__ fprintf(stderr, "[DEBUG NETWORK] revm_network_input " @@ -972,8 +985,8 @@ "Cannot find initial net job", (-1)); /* remote client main socket */ - if (revm_create_server(&(init->ws.sock.socket), - &(init->ws.sock.addr), REVM_PORT) < 0) + if (revm_create_server(&(init->ws.io.sock.socket), + &(init->ws.io.sock.addr), REVM_PORT) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to create net server", (-1)); @@ -1015,7 +1028,7 @@ actual != NULL && actual->key != NULL; actual = actual->next) { - temp_socket = &((revmjob_t *) actual->data)->ws.sock; + temp_socket = &((revmjob_t *) actual->data)->ws.io.sock; #if __DEBUG_NETWORK__ fprintf(stderr, "[DEBUG NETWORK] Closing " @@ -1036,7 +1049,7 @@ #if __DEBUG_NETWORK__ fprintf(stderr, "[DEBUG NETWORK] Closing socket : %d \n", - serv->ws.sock.socket); + serv->ws.io.sock.socket); #endif /* Closing DUMP connections */ @@ -1052,7 +1065,7 @@ /* Closing DUMP main socket */ close(dump_world.sock); - if (serv == NULL || revm_socket_close(serv->ws.sock.socket) < 0) + if (serv == NULL || revm_socket_close(serv->ws.io.sock.socket) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to close socket", (-1)); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -1117,7 +1130,7 @@ */ int revm_getmaxfd() { - if (world.state.revm_mode != REVM_STATE_DEBUGGER) + if (world.state.revm_mode != REVM_STATE_EMBEDDED) return (0); if (world.state.revm_side == REVM_SIDE_CLIENT) return (world.fifo_s2c); diff -Nru eresi-0.8a25/librevm/io/output.c eresi-0.0.20110516/librevm/io/output.c --- eresi-0.8a25/librevm/io/output.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/output.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file output.c +* @file librevm/io/output.c * @ingroup io * @brief The output vector interface. * * Started on Fri Mar 5 00:55:40 2004 jfv * Updated on Mon Mar 5 18:47:41 2007 jfv * - * $Id: output.c,v 1.8 2007-08-17 15:38:52 heroine Exp $ + * $Id: output.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -76,11 +76,11 @@ /* No -- more -- in some modes */ if ((world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) + world.state.revm_mode != REVM_STATE_EMBEDDED) || world.curjob->ws.io.type == REVM_IO_DUMP || !world.curjob->ws.io.outcache.lines - || world.curjob->sourced - || !(int)config_get_data(ERESI_VMCONFIG_USE_MORE)) + || world.curjob->curscope + || !(int)config_get_data(REVM_CONFIG_USEMORE)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (world.curjob->ws.io.output(str))); @@ -165,8 +165,18 @@ } + +/** + * @brief Change the Output handler + * @ingroup io + */ +void revm_setoutput_handler(revmworkspace_t *ws, void *hdl) +{ + ws->io.output = hdl; +} + /** - * @bief Change the Output file + * @brief Change the Output file * @ingroup io */ void revm_setoutput(revmworkspace_t *ws, int fd) @@ -174,3 +184,12 @@ ws->io.output_fd = fd; } +/** + * @brief Retreive the output fd of a workspace + * @ingroup io + */ +int revm_output_get(revmworkspace_t *ws) +{ + return (ws->io.output_fd); +} + diff -Nru eresi-0.8a25/librevm/io/prompt.c eresi-0.0.20110516/librevm/io/prompt.c --- eresi-0.8a25/librevm/io/prompt.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/prompt.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file prompt.c +* @file librevm/io/prompt.c * @ingroup io * @brief Interface for prompt management. * @ingroup io * Started on Fri Nov 2 15:21:56 2001 jfv * Updated on Mon Mar 5 17:26:11 2007 jfv * - * $Id: prompt.c,v 1.11 2008-02-16 12:32:27 thor Exp $ + * $Id: prompt.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -35,7 +35,7 @@ snprintf(name, size - 1, "%s%s%s%s%s%s%s%s%s%s%s ", revm_colorget("%s", "pspecial", "("), - (world.state.revm_mode == REVM_STATE_DEBUGGER ? + (world.state.revm_mode == REVM_STATE_EMBEDDED ? revm_colorget("%s", "psname" , E2DBG_ARGV0) : revm_colorget("%s", "psname" , REVM_NAME)), revm_colorget("%s", "pspecial", "-"), @@ -57,7 +57,7 @@ char* revm_get_prompt() { if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER) + world.state.revm_mode == REVM_STATE_EMBEDDED) { /* Setup prompt only once */ if (prompt_token_setup == NULL) @@ -91,7 +91,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); buf = ((world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER || + world.state.revm_mode == REVM_STATE_EMBEDDED || (world.state.revm_net && world.curjob->ws.io.type != REVM_IO_STD)) ? revm_get_prompt() : ""); revm_output(buf); diff -Nru eresi-0.8a25/librevm/io/readln.c eresi-0.0.20110516/librevm/io/readln.c --- eresi-0.8a25/librevm/io/readln.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/readln.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,5 +1,5 @@ /** - * @file readln.c +* @file librevm/io/readln.c * @ingroup io * @brief Interface readline with librevm. * @@ -7,7 +7,7 @@ * when the user recompiles enabling/disabling readline. * * Started on Fri Mar 5 00:55:40 2004 jfv - * $Id: readln.c,v 1.2 2007-11-29 15:33:39 may Exp $ + * $Id: readln.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" @@ -67,7 +67,7 @@ int revm_init_history(int mode) { #if defined(USE_READLN) - return (readln_init(mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY))); + return (readln_init(mode, (char *)config_get_data(ERESI_CONFIG_HISTORY))); #else return (0); #endif @@ -76,7 +76,7 @@ int revm_quit(int mode) { #if defined(USE_READLN) - return (readln_quit(mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY))); + return (readln_quit(mode, (char *)config_get_data(ERESI_CONFIG_HISTORY))); #else return (0); #endif @@ -210,7 +210,6 @@ } - void revm_prompt_log() { #if defined (USE_READLN) @@ -222,9 +221,9 @@ void revm_conditional_rlquit() { #if defined(USE_READLN) - if (!(world.state.revm_mode == REVM_STATE_DEBUGGER + if (!(world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_SERVER)) - readln_quit(world.state.revm_mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY)); + readln_quit(world.state.revm_mode, (char *)config_get_data(ERESI_CONFIG_HISTORY)); #endif } @@ -264,7 +263,7 @@ { /* On the client side, we consider that the prompt is already returned by the server */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && + if (world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_CLIENT) { rl_on_new_line_with_prompt(); diff -Nru eresi-0.8a25/librevm/io/select.c eresi-0.0.20110516/librevm/io/select.c --- eresi-0.8a25/librevm/io/select.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/select.c 2011-05-16 11:34:12.000000000 +0000 @@ -1,12 +1,12 @@ /** - * @file select.c +* @file librevm/io/select.c ** @ingroup io ** @brief The interface for I/O based on select(). ** ** Started on Fri Mar 5 00:55:40 2004 jfv ** Updated on Mon Mar 5 18:47:41 2007 jfv ** -** $Id: select.c,v 1.15 2007-11-29 14:01:56 may Exp $ +** $Id: select.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -17,7 +17,7 @@ * @brief Return the greatest socket from the elfsh_net_client_list and sock. * @ingroup io */ -#if defined(ELFSHNET) +#if defined(ERESI_NET) int revm_getmaxfd() { int index; @@ -26,13 +26,14 @@ u_long port; int ret; revmjob_t *serv; + int fd; /* If the network is not UP, the biggest fd is 0 */ ret = 0; serv = hash_get(&world.jobs, "net_init"); if (serv == NULL) return (ret); - ret = serv->ws.sock.socket; + ret = serv->ws.io.sock.socket; ret = (ret > dump_world.sock) ? ret : dump_world.sock; keys = hash_get_keys(&dump_world.ports, &keynbr); @@ -42,7 +43,7 @@ if (port > ret) ret = port; #if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Socket (DUMP) [%u] \n", port); + fprintf(stderr, "[DEBUG NETWORK] Socket (DUMP) ["DFMT"] \n", port); #endif } @@ -55,17 +56,28 @@ serv = hash_get(&world.jobs, keys[index]); if (!serv->ws.active) continue; - if (serv->ws.sock.socket > ret) - ret = serv->ws.sock.socket; + if (serv->ws.io.sock.socket > ret) + ret = serv->ws.io.sock.socket; #if __DEBUG_NETWORK__ fprintf(stderr, "[DEBUG NETWORK] Socket [%u] key = %10s \n", - serv->sock.socket, keys[index]); + serv->ws.io.sock.socket, keys[index]); #endif } hash_free_keys(keys); - if (world.state.revm_mode == REVM_STATE_DEBUGGER && world.fifofd > ret) - ret = world.fifofd; + + switch (world.state.revm_side) + { + case REVM_SIDE_CLIENT: + fd = world.fifo_s2c; + break; + case REVM_SIDE_SERVER: + fd = world.fifo_c2s; + break; + } + + if (world.state.revm_mode == REVM_STATE_EMBEDDED && fd > ret) + return (fd); return (ret); } #endif @@ -86,7 +98,7 @@ char **keys; int keynbr; revmjob_t *job; -#if defined(ELFSHNET) +#if defined(ERESI_NET) u_long port; keys = hash_get_keys(&dump_world.ports, &keynbr); @@ -95,7 +107,7 @@ port = (u_long) hash_get(&dump_world.ports, keys[index]); #if __DEBUG_NETWORK__ fprintf(stderr, - "[DEBUG NETWORK] prepare_4_select : (DUMP) socket : %d \n", + "[DEBUG NETWORK] prepare_4_select : (DUMP) socket : "DFMT" \n", port); #endif FD_SET(port, sel_sockets); @@ -118,11 +130,11 @@ job->ws.sock.socket); #endif -#if defined(ELFSHNET) +#if defined(ERESI_NET) if (job->ws.io.type == REVM_IO_DUMP) continue; if (job->ws.io.type == REVM_IO_NET) - FD_SET(job->ws.sock.socket, sel_sockets); + FD_SET(job->ws.io.sock.socket, sel_sockets); #endif if (job->ws.io.type == REVM_IO_STD) @@ -130,7 +142,7 @@ } /* Also set the debugger fifo if we are in debugger mode */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_EMBEDDED) { if (world.state.revm_side == REVM_SIDE_CLIENT) FD_SET(world.fifo_s2c, sel_sockets); @@ -148,19 +160,22 @@ * @brief Check if we had any network event * @ingroup io */ -void revm_check_net_select(fd_set *sel_sockets, - int cursock) +int revm_check_net_select(fd_set *sel_sockets, int cursock) { -#if defined(ELFSHNET) +#if defined(ERESI_NET) // Read net command if any. if (revm_net_recvd(sel_sockets) < 0) - fprintf(stderr, "vmnet_select : revm_net_recvd() failed\n"); - + { + fprintf(stderr, "vmnet_select : revm_net_recvd() failed\n"); + return (1); + } + /* Check remote clients */ if (FD_ISSET(cursock, sel_sockets)) { if (revm_net_accept() < 0) fprintf(stderr, "Connection rejected\n"); + return (1); } /* Check the DUMP connection */ @@ -168,8 +183,11 @@ { if (revm_dump_accept() < 0) fprintf(stderr, "Connection rejected\n"); + return (1); } #endif + + return (0); } @@ -199,7 +217,8 @@ return (1); } if (cur->ws.io.type == REVM_IO_NET && - cur->ws.sock.recvd_f == NEW && cur->ws.sock.ready_f == YES) + cur->ws.io.sock.recvd_f == NEW && + cur->ws.io.sock.ready_f == YES) { world.curjob = cur; return (1); @@ -223,7 +242,7 @@ /* Do not display the prompt for the client side This part can't use any READLN stuff because we always be on server */ - if (!(world.state.revm_mode == REVM_STATE_DEBUGGER && + if (!(world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_CLIENT)) revm_display_prompt(); } @@ -264,10 +283,10 @@ { FD_ZERO(&sel_sockets); -#if defined(ELFSHNET) +#if defined(ERESI_NET) if (world.state.revm_net && init) { - FD_SET(init->ws.sock.socket, &sel_sockets); + FD_SET(init->ws.io.sock.socket, &sel_sockets); FD_SET(dump_world.sock, &sel_sockets); } #endif @@ -285,22 +304,23 @@ if (err < 1 && errno == EINTR) goto retry; - /* Select which command will be proceded */ -#if defined(ELFSHNET) +#if defined(ERESI_NET) if (world.state.revm_net) { if (init) - revm_check_net_select(&sel_sockets, init->ws.sock.socket); - - if (revm_socket_getnew()) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(0)); - + err = revm_check_net_select(&sel_sockets, init->ws.io.sock.socket); + if (err) + { + if (revm_socket_getnew()) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(0)); + #if __DEBUG_NETWORK__ - fprintf(stderr, - "[DEBUG NETWORK] Select broken by a new connexion.\n"); + fprintf(stderr, + "[DEBUG NETWORK] Select broken by a new connexion.\n"); #endif - continue; + continue; + } } #endif @@ -318,7 +338,7 @@ /* If the event appeared on the debugger FIFO, change the input file descriptor for it */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_EMBEDDED) { fifofd = (world.state.revm_side == REVM_SIDE_CLIENT ? world.fifo_s2c : world.fifo_c2s); @@ -329,10 +349,10 @@ world.curjob->ws.io.input = revm_fifoinput; #if __DEBUG_NETWORK__ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && + if (world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_CLIENT) fprintf(stderr, "(client) Event appeared on fifo \n"); - else if (world.state.revm_mode == REVM_STATE_DEBUGGER && + else if (world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_SERVER) fprintf(stderr, "(server) Event appeared on fifo \n"); #endif diff -Nru eresi-0.8a25/librevm/io/.svn/all-wcprops eresi-0.0.20110516/librevm/io/.svn/all-wcprops --- eresi-0.8a25/librevm/io/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/950/trunk/librevm/io -END -color.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/946/trunk/librevm/io/color.c -END -input.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/906/trunk/librevm/io/input.c -END -select.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/906/trunk/librevm/io/select.c -END -output.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/916/trunk/librevm/io/output.c -END -log.c -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/906/trunk/librevm/io/log.c -END -prompt.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/906/trunk/librevm/io/prompt.c -END -curjob.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/906/trunk/librevm/io/curjob.c -END -readln.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/916/trunk/librevm/io/readln.c -END -io.c -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/906/trunk/librevm/io/io.c -END -network.c -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/906/trunk/librevm/io/network.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/950/trunk/librevm/io/Makefile -END diff -Nru eresi-0.8a25/librevm/io/.svn/entries eresi-0.0.20110516/librevm/io/.svn/entries --- eresi-0.8a25/librevm/io/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/io -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -color.c -file - - - - -2008-04-06T23:15:45.696892Z -ee7c3a0b286ef97b65e8cd062819389d -2008-03-27T22:53:48.747992Z -946 -may - -input.c -file - - - - -2008-04-06T23:15:45.726137Z -ec80eec124b6741ab167add67e9fe504 -2008-03-14T00:57:20.622435Z -906 -enioh - -select.c -file - - - - -2008-04-06T23:15:45.737645Z -bf681502ebc839e22053fff07b6fa120 -2008-03-14T00:57:20.622435Z -906 -enioh - -output.c -file - - - - -2008-04-06T23:15:45.748988Z -e6cd3196b55ca423be6c11ce9ed15a8a -2008-03-18T18:43:08.635419Z -916 -pouik - -log.c -file - - - - -2008-04-06T23:15:45.760388Z -b41bcddd1a4d52bcbe144da1633730b9 -2008-03-14T00:57:20.622435Z -906 -enioh - -prompt.c -file - - - - -2008-04-06T23:15:45.771876Z -11cea4929052b2e6b9230f272dd7e377 -2008-03-14T00:57:20.622435Z -906 -enioh - -curjob.c -file - - - - -2008-04-06T23:15:45.783149Z -e071ef0bf65a6d891675d783d8275824 -2008-03-14T00:57:20.622435Z -906 -enioh - -readln.c -file - - - - -2008-04-06T23:15:45.794705Z -abddcf736a98d310e00a62c93b446b65 -2008-03-18T18:43:08.635419Z -916 -pouik - -io.c -file - - - - -2008-04-06T23:15:45.806047Z -4b6a200f5895aa40922f0cc9ea881b79 -2008-03-14T00:57:20.622435Z -906 -enioh - -network.c -file - - - - -2008-04-06T23:15:45.817391Z -d7afa8f69ec5b694c0558a9157151eaf -2008-03-14T00:57:20.622435Z -906 -enioh - -Makefile -file - - - - -2008-04-06T23:15:45.828876Z -ce5801671fead62ac797213533d55e79 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/librevm/io/.svn/format eresi-0.0.20110516/librevm/io/.svn/format --- eresi-0.8a25/librevm/io/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/color.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/color.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/color.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/color.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,373 +0,0 @@ -/** - * @file color.c - * @ingroup io - * @brief All functions about colors. - * - * Started on Sept 11 2005 mxatone - * - * $Id: color.c,v 1.7 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "revm.h" - - -/** - * Token system - */ -static char tokens[COLOR_TOKENS][COLOR_TOKEN_LEN]; -static u_int curtok = 0; - -/** - * Indicate if we print color - * 0 = color, 1 = without color - */ -u_int nocolor = 1; - - -/** - * Init color structure - * @return an allocated color structure - */ -color_t *revm_colorblank() -{ - color_t *c; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,c, sizeof(color_t), NULL); - - c->fground = COLOR_NONE; - c->bground = COLOR_NONE; - c->bold = COLOR_NONE; - c->underline = COLOR_NONE; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (c)); -} - -/** - * Retrieve a color information structure from a color type - * @param type color type - * @param text text to color to filter for warnstring type - * @return color structure - */ -color_t *revm_colortable(char *type, char *text) -{ - NOPROFILER_IN(); - - /* Override color by warning color if we match the alert regex */ - if (world.state.revm_use_alert && - !regexec(&world.state.revm_alert, text, 0, 0, 0)) - NOPROFILER_ROUT(hash_get(&t_color_hash, "warnstring")); - - NOPROFILER_ROUT(hash_get(&t_color_hash, type)); -} - -/* Speed setup code*/ -#define COLOR_SET_ELEMENT(_c, _v, _z) \ -do { \ -if (_c > 0) { \ -snprintf(_v, 15, "%s%u", (!set ? S_STARTCOLOR : COLOR_SEPARE), _z); \ -set = 1; } \ -} while(0) - - -/** - * Generate the color pattern for a given color structure - * @param t color structure - * @param text text to color (not used on this function) - * @param pattern pattern will be save on this buffer - */ -int revm_colorpattern(color_t *t, char *text, char *pattern) -{ - char bo[16], ul[16], fg[16], bg[16]; - u_short set = 0; - - NOPROFILER_IN(); - - if (t == NULL || (!t->bground && !t->fground && !t->bold && !t->underline)) - NOPROFILER_ROUT(-1); - - /* Set every element */ - COLOR_SET_ELEMENT(t->bold, bo, COLOR_BOLD); - COLOR_SET_ELEMENT(t->underline, ul, COLOR_UNDERLINE); - COLOR_SET_ELEMENT(t->fground, fg, t->fground); - COLOR_SET_ELEMENT(t->bground, bg, t->bground); - - snprintf(pattern, COLOR_TOKEN_LEN - 1, - "%%s%s%s%s%sm%%s%s%um%%s", - (t->bold > 0 ? bo : ""), - (t->underline > 0 ? ul : ""), - (t->fground > 0 ? fg : ""), - (t->bground > 0 ? bg : ""), - S_STARTCOLOR, - COLOR_NONE); - - NOPROFILER_ROUT(0); -} - -/** - * Return without color - * @param sp given string (pattern like %s or %d etc ..) - * @param object objet to print using the string - * @return generate string - */ -static char *revm_colornothing(char *sp, void *object) -{ - NOPROFILER_IN(); - - if (!strcmp(sp, "%s")) - NOPROFILER_ROUT((char *) object); - - if (strchr(sp, 's') == NULL) - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, sp, *(eresi_Addr *) object); - else - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, sp, object); - - NOPROFILER_ROUT(tokens[curtok++]); -} - - - -/** - * Trim a string from blank char and copy it on to argument - * @param from source - * @param to destination - * @param size buffer size - * @param start saved starting blank chars (for replace in another place) - * @param end saved ending blank chars (for replace in another place) - */ -static int trim(char *from, char *to, u_int size, char *start, char *end) -{ - u_int len, istart, iend; - - NOPROFILER_IN(); - - if (size == 0 || size > COLOR_TOKEN_LEN || from == NULL || to == NULL) - NOPROFILER_ROUT(-1); - - len = strlen(from); - - /* Speed check */ - if (!IS_BLANK(from[0]) && !IS_BLANK(from[len])) - NOPROFILER_ROUT(-1); - - /* Before */ - for (istart = 0; istart < len && IS_BLANK(from[istart]); istart++); - - /* All blank, no modifications */ - if (istart == len) - NOPROFILER_ROUT(-1); - - /* After */ - for (iend = len; iend > 0 && IS_BLANK(from[iend]); iend--); - - iend = len - iend; - - /* Copy the right char on to argument */ - strncpy(to, from + istart, len - istart - iend); - to[len - istart - iend] = 0x00; - - if (start) - { - strncpy(start, from, istart); - start[istart] = 0x00; - } - - if (end) - { - strncpy(end, from + len - iend, iend); - end[iend] = 0x00; - } - - NOPROFILER_ROUT(0); -} - -/** - * Build color text - * - */ -char *revm_colorget(char *sp, char *type, void *object) -{ - color_t *t; - char pattern[COLOR_TOKEN_LEN]; - char text[COLOR_TOKEN_LEN]; - char trim_text[COLOR_TOKEN_LEN]; - char white_s[COLOR_TOKEN_LEN]; - char white_e[COLOR_TOKEN_LEN]; - char *pText; - - NOPROFILER_IN(); - - if (curtok >= COLOR_TOKENS) - { - printf("[E] %s:%d %s: WARNING !!!! Token overflow (val:%u)\n", - __FILE__, __LINE__, __FUNCTION__, curtok); - NOPROFILER_ROUT(NULL); - } - - //printf("Before token = %016llX \n", (eresi_Addr *) object); - - //snprintf(text, COLOR_TOKEN_LEN - 1, sp, object); - if (strchr(sp, 's') == NULL) - snprintf(text, COLOR_TOKEN_LEN - 1, sp, *(eresi_Addr *) object); - else - snprintf(text, COLOR_TOKEN_LEN - 1, sp, object); - - /* Color isn't activated */ - if (!nocolor) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - t = revm_colortable(type, text); - - /* Color not found */ - if (t == NULL) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - /* Invalid pattern */ - if (revm_colorpattern(t, text, pattern) != 0) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - pText = text; - - memset(white_s, 0x00, COLOR_TOKEN_LEN); - memset(white_e, 0x00, COLOR_TOKEN_LEN); - - /* Trim the string from blank char */ - if (!trim(text, trim_text, COLOR_TOKEN_LEN, white_s, white_e)) - pText = trim_text; - - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, - pattern, white_s, pText, white_e); - - NOPROFILER_ROUT(tokens[curtok++]); -} - -/** - * Reset token - */ -void revm_endline() -{ - curtok = 0; -} - -/* Simple functions */ -char *revm_colorinstr(char *text) { return revm_colorget("%s", "instr" , text); } -char *revm_colorstr(char *text) { return revm_colorget("%s", "string" , text); } -char *revm_colorfieldstr(char *text) { return revm_colorget("%s", "fieldstring", text); } -char *revm_colortypestr(char *text) { return revm_colorget("%s", "typestring" , text); } -char *revm_colorend(char *text) { return revm_colorget("%s", "endstring" , text); } -char *revm_colorwarn(char *text) { return revm_colorget("%s", "warnstring" , text); } -char *revm_colorfunction(char *text) { return revm_colorget("%s", "function" , text); } -char *revm_colorfilename(char *text) { return revm_colorget("%s", "filename" , text); } - -/* Special functions */ -char *revm_coloradv(char *type, char *pattern, char *text) -{ - char *p; - - NOPROFILER_IN(); - - p = revm_colorget(pattern, type, text); - - strncpy(text, p, BUFSIZ); - text[BUFSIZ-1] = 0; - curtok--; - - NOPROFILER_ROUT(text); -} - -/** - * Advanced functions - */ -char *revm_colorinstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "instr", text); -} - -char *revm_colorstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "string", text); -} -char *revm_colorfieldstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "fieldstring", text); -} - -char *revm_colortypestr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "typestring", text); -} - -char *revm_colorend_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "endstring", text); -} - -char *revm_colorwarn_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "warnstring", text); -} - -char *revm_coloraddress(char *pattern, eresi_Addr addr) -{ - return revm_colorget(pattern, "address", &addr); -} - -char *revm_colornumber(char *pattern, elfsh_Off numb) -{ - return revm_colorget(pattern, "number", &numb); -} - - -/* Misc functions */ - -/* Return number of color chars (not total size) */ -int revm_color_count(char *string) -{ - int count = 0; - int len; - int i; - - NOPROFILER_IN(); - - len = strlen(string); - for (i = 0; i < len; i++) - { - if (string[i] == C_STARTCOLOR) - { - count++; - while (i < len && string[i] != 'm') - i++; - } - } - - NOPROFILER_ROUT(count); -} - -/** - * Return total size of colors on a string - */ -int revm_color_size(char *string) -{ - int size = 0; - int len; - int i; - - NOPROFILER_IN(); - - len = strlen(string); - for (i = 0; i < len; i++) - { - if (string[i] == C_STARTCOLOR) - { - //size++; - while (i < len && string[i] != 'm') - { - size++; - i++; - } - } - } - - NOPROFILER_ROUT(size); -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/curjob.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/curjob.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/curjob.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/curjob.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -/** - * @file curjob.c - * @ingroup io - * @brief Implement job API necessary for revm-io. - * - * Started September 16 03:11:04 2005 jfv - * - * $Id: curjob.c,v 1.6 2007-08-03 11:51:00 heroine Exp $ - * - */ -#include "revm.h" - - -/** - * @brief Return the current local job - */ -revmjob_t *revm_localjob_get() -{ - revmjob_t *job; - int index; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - keys = hash_get_keys(&world.jobs, &keynbr); - for (index = 0; index < keynbr; index++) - { - job = hash_get(&world.jobs, keys[index]); - if (!job->ws.active) - continue; - if (job->ws.io.type == REVM_IO_STD) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, job); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(NULL)); -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/input.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/input.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/input.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/input.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,182 +0,0 @@ -/** - * @file input.c - * @ingroup io - * @brief Input related functions. - * - * Started on Fri Feb 7 20:53:25 2003 jfv - * $Id: input.c,v 1.13 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "revm.h" - - - -/** - * @brief Read a new line, avoiding comments and void lines - */ -char *revm_getln() -{ - char *buf; - char *sav; - - NOPROFILER_IN(); - do - { - buf = world.curjob->ws.io.input(); - if (buf == ((char *) REVM_INPUT_VOID)) - NOPROFILER_ROUT((char *) REVM_INPUT_VOID); - if (buf == NULL) - NOPROFILER_ROUT(NULL); - if (!*buf) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,buf); - NOPROFILER_ROUT(NULL); - } - - sav = buf; - while (IS_BLANK(*sav)) - sav++; - - if (!*sav || *sav == REVM_COMMENT_START) - { - revm_log(sav); - revm_log("\n"); - revm_buffer_free(buf); - if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER) - NOPROFILER_ROUT((char*) REVM_INPUT_VOID); - - buf = NULL; - if (*sav) - continue; - } - - if (world.state.revm_mode != REVM_STATE_SCRIPT) - { - revm_output_nolog("\n"); - - /* avoid looping with readline */ - if (revm_is_enabled() && buf == NULL) - NOPROFILER_ROUT((char *) REVM_INPUT_VOID); - if (revm_is_enabled()) - break; - } - } - while (buf == NULL); - - NOPROFILER_ROUT(buf); -} - - -/** - * @brief Read input from the file descriptor - */ -char *revm_read_input() -{ - char tmpbuf[BUFSIZ + 1]; - int len; - - NOPROFILER_IN(); - - /* In case we are scripting, even readline will use a read */ - for (len = 0; len < BUFSIZ; len++) - switch (read(world.curjob->ws.io.input_fd, tmpbuf + len, 1)) - { - case 1: - if (tmpbuf[len] == '\n') - { - if (len == 0) - { - //fprintf(stderr, "Read length 0 ... \n"); - NOPROFILER_ROUT((char *) REVM_INPUT_VOID); - } - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_CLIENT) - tmpbuf[len + 1] = 0x00; - else - tmpbuf[len] = 0x00; - goto end; - } - continue; - default: - *tmpbuf = 0x00; - goto end; - } - - end: - //fprintf(stderr, "[pid = %u] Read on fd = *%s*\n", getpid(), tmpbuf); - NOPROFILER_ROUT((*tmpbuf ? strdup(tmpbuf) : NULL)); -} - - -/** - * Input handler for the FIFO - */ -char *revm_fifoinput() -{ - int fd; - char *ret; - - fd = world.curjob->ws.io.input_fd; - - /* Just debugging */ - switch (world.state.revm_side) - { - case REVM_SIDE_CLIENT: - //fprintf(stderr, "Goto read fifo (client legit) ... \n"); - world.curjob->ws.io.input_fd = world.fifo_s2c; - break; - case REVM_SIDE_SERVER: - //fprintf(stderr, "Goto read fifo (server legit) ... \n"); - world.curjob->ws.io.input_fd = world.fifo_c2s; - break; - } - - ret = revm_read_input(); - world.curjob->ws.io.input_fd = fd; - world.curjob->ws.io.input = world.curjob->ws.io.old_input; - - /* Just debugging */ - switch (world.state.revm_side) - { - case REVM_SIDE_CLIENT: - //fprintf(stderr, "BACK from reading fifo (client legit) ... (%s)\n"); - break; - case REVM_SIDE_SERVER: - //fprintf(stderr, "BACK from reading fifo (server legit) ... \n"); - break; - } - - return (ret); -} - - -/** - * INPUT handler for stdin - */ -char *revm_stdinput() -{ - char *str; - - NOPROFILER_IN(); - str = NULL; - - /* Case if we are using readline */ - if (revm_is_enabled() && world.state.revm_mode != REVM_STATE_SCRIPT) - { - str = revm_input_check(); - NOPROFILER_ROUT(str); - } - - /* If not, read the stdin file descriptor */ - NOPROFILER_ROUT(revm_read_input()); -} - - -/** - * Change the Input file - */ -void revm_setinput(revmworkspace_t *ws, int fd) -{ - ws->io.input_fd = fd; -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/io.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/io.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/io.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/io.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,161 +0,0 @@ -/** - * @file io.c - * @ingroup io - * @brief Initialize the IO system. - * - * Started on Fri Mar 5 00:55:40 2004 jfv - * $Id: io.c,v 1.14 2008-02-16 12:32:27 thor Exp $ - */ -#include "revm.h" - - -/** - * @defgroup io librevm Input/output - */ - -/** - * Reset lines counters and ignore output state - */ -int revm_flush() -{ - int lines = 80; - int cols = 200; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Cache output only in IMODE/DEBUGGER mode */ - if (world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - revm_screen_getsize(&lines, &cols); - - /* We * 2 because color take a lot of place !!! */ - world.curjob->ws.io.outcache.lines = lines * 2; - world.curjob->ws.io.outcache.cols = cols * 2; - world.curjob->ws.io.outcache.nblines = lines; - world.curjob->ws.io.outcache.ignore = 0; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -} - -/** - * Set workspace configuration to standard I/O - */ -int revm_std_io(revmjob_t *job) -{ - NOPROFILER_IN(); - if (!job) - NOPROFILER_ROUT(0); - job->ws.io.type = REVM_IO_STD; - job->ws.io.input_fd = 0; - job->ws.io.input = revm_stdinput; - job->ws.io.output_fd = 1; - job->ws.io.output = revm_stdoutput; - NOPROFILER_ROUT(0); -} - -/** - * Set workspace configuration to standard I/O - */ -int revm_fifo_io(revmjob_t *job) -{ - int fd; - int fd2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!job) - { - fprintf(stderr, "error: input job is NULL in fifo_io \n"); - NOPROFILER_ROUT(0); - } - - /* Remove the FIFO is already existing */ - if (world.state.revm_side == REVM_SIDE_CLIENT) - { - if (!access(REVM_FIFO_C2S, F_OK)) - unlink(REVM_FIFO_C2S); - if (!access(REVM_FIFO_S2C, F_OK)) - unlink(REVM_FIFO_S2C); - - /* Create the 2 FIFO */ - mkfifo(REVM_FIFO_S2C, 0600); - mkfifo(REVM_FIFO_C2S, 0600); - } - - /* Register the FIFO as an I/O */ - if (!e2dbg_kpresence_get()) - { - XOPEN(fd, REVM_FIFO_S2C, O_RDWR, 0600, -1); - world.fifo_s2c = fd; - XOPEN(fd2, REVM_FIFO_C2S, O_RDWR, 0600, -1); - world.fifo_c2s = fd2; - - /* If we are in the embedded server part of the debugger, - do all I/O on the FIFO */ - if (world.state.revm_side == REVM_SIDE_SERVER) - { - job->ws.io.input_fd = fd2; - job->ws.io.input = revm_stdinput; - job->ws.io.output_fd = fd; - job->ws.io.output = revm_stdoutput; - dup2(fd, 0); - } - } - - /* We dont let this between #ifdef's KERNEL to avoid recompiling - this code multiple times for the userland and kernel debuggers */ - else - { - job->ws.io.input = NULL; - // FIXME: need IO vector ? - //job->ws.io.output = ke2dbg_output; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Initialize Input/Output hooks - */ -int revm_initio() -{ - static int done = 0; - revmjob_t *initial; - - NOPROFILER_IN(); - if (done) - NOPROFILER_ROUT(0); - done = 1; - - XALLOC(__FILE__, __FUNCTION__, __LINE__,initial, sizeof(revmjob_t), -1); - memset(initial, 0, sizeof(revmjob_t)); - - revm_std_io(initial); - initial->ws.active = 1; - initial->ws.createtime = time(&initial->ws.createtime); - - world.initial = world.curjob = initial; - hash_init(&world.jobs, "jobs", 11, ASPECT_TYPE_UNKNOW); - hash_add(&world.jobs, "local", initial); - initial->ws.name = strdup("local"); - - hash_init(&initial->loaded, - "initial_loaded_files", - 51, ASPECT_TYPE_UNKNOW); - hash_init(&initial->dbgloaded, - "initial_dbgloaded_files", - 11, ASPECT_TYPE_UNKNOW); - - profiler_setcolor(revm_endline, revm_colorinstr, revm_colorstr, - revm_colorfieldstr, revm_colortypestr, revm_colorend, - revm_colorwarn, revm_colorfunction, revm_colorfilename); - profiler_setmorecolor(revm_coloradv, revm_colorinstr_fmt, revm_coloraddress, - revm_colornumber, revm_colorstr_fmt, - revm_colorfieldstr_fmt, - revm_colortypestr_fmt, revm_colorwarn_fmt); - NOPROFILER_ROUT(0); -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/log.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/log.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/log.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/log.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,227 +0,0 @@ -/** - * @file log.c - * @ingroup io - * @brief Implement logging facilities. - * - * Started September 16 03:11:04 2005 jfv - * - * $Id: log.c,v 1.10 2007-11-29 14:01:56 may Exp $ - * - */ -#include "revm.h" - - -/* Strip a group of char */ -static void __strip_group_char(char *str, char s, char e) -{ - u_int len, diff, pos; - char *search, *search_end; - - NOPROFILER_IN(); - len = strlen(str) + 1; - for (search = str; (search = strchr(search, s)) != NULL;) - { - search_end = strchr(search+1, e); - /* Error !! */ - if (!search_end) - NOPROFILER_OUT(); - diff = search_end - search + 1; - pos = search - str; - /* Realign others */ - memmove(search, search_end+1, len - (pos + diff)); - len -= diff; - } - NOPROFILER_OUT(); -} - - -/** - * Log to file - */ -static void logtofile(char *str) -{ - revmexpr_t *stripexpr; - revmobj_t *stripvar; - char *tmp; - u_int len; - - NOPROFILER_IN(); - len = strlen(str); - tmp = alloca(len + 1); - - /* Do we want to log ? */ - if (!(world.curjob->ws.state & REVM_JOB_LOGGED) || len <= 0) - NOPROFILER_OUT(); - - /* We made only local modifications */ - strcpy(tmp, str); - stripexpr = revm_expr_get(REVM_VAR_STRIPLOG); - if (stripexpr) - stripvar = stripexpr->value; - - /* We strip the color part depending of $SLOG variable value */ - if (stripvar && stripvar->immed_val.word) - __strip_group_char(tmp, C_STARTCOLOR, 'm'); - - /* Strip RL_PROMPT_START_IGNORE & RL_PROMPT_END_IGNORE */ - revm_strip_char(tmp, RL_PROMPT_START_IGNORE); - revm_strip_char(tmp, RL_PROMPT_END_IGNORE); - - len = strlen(tmp); - XWRITE(world.curjob->ws.logfd, tmp, len, ); - NOPROFILER_OUT(); -} - - -/** - * Log a line - */ -void revm_log(char *str) -{ - int check = 0, size = 0; - char *tmp = NULL; - char *t_tail, *t_head, *t_end; - char buf[BUFSIZ * 4]; - - NOPROFILER_IN(); - - /* Nothing possible */ - if (!str || !*str || !world.curjob) - NOPROFILER_OUT(); - - logtofile(str); - - /* We could log before return */ - if(!world.curjob->ws.io.outcache.lines || - !world.curjob->ws.io.outcache.cols) - NOPROFILER_OUT(); - - /* Allocate the screen buffer */ - if (world.curjob->ws.screen.buf == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - world.curjob->ws.screen.buf, - world.curjob->ws.io.outcache.lines * - world.curjob->ws.io.outcache.cols + 1, ); - - world.curjob->ws.screen.x = world.curjob->ws.io.outcache.cols; - world.curjob->ws.screen.y = world.curjob->ws.io.outcache.lines; - world.curjob->ws.screen.head = world.curjob->ws.screen.tail = - world.curjob->ws.screen.buf; - } - - /* reallocate the screen buffer when term size changes */ - else if (world.curjob->ws.screen.x != world.curjob->ws.io.outcache.cols || - world.curjob->ws.screen.y != world.curjob->ws.io.outcache.lines) - { - tmp = world.curjob->ws.screen.buf; - XALLOC(__FILE__, __FUNCTION__, __LINE__,world.curjob->ws.screen.buf, - world.curjob->ws.io.outcache.lines * - world.curjob->ws.io.outcache.cols + 1, ); - - /* Save ex pointers */ - t_head = world.curjob->ws.screen.head; - t_tail = world.curjob->ws.screen.tail; - t_end = tmp + (world.curjob->ws.screen.x * world.curjob->ws.screen.y); - - /* Update screen */ - world.curjob->ws.screen.x = world.curjob->ws.io.outcache.cols; - world.curjob->ws.screen.y = world.curjob->ws.io.outcache.lines; - - /* Reset pointers */ - world.curjob->ws.screen.head = world.curjob->ws.screen.tail = - world.curjob->ws.screen.buf; - - /* Refill the screen using revm_log() */ - if (t_head < t_tail) - revm_log(t_head); - else - { - snprintf(buf, t_end - t_head, "%s", t_head); - revm_log(buf); - snprintf(buf, BUFSIZ * 4 - 1, "%s", t_tail); - revm_log(buf); - } - - /* Free at the end */ - XFREE(__FILE__, __FUNCTION__, __LINE__,tmp); - } - -#define scrsize (world.curjob->ws.io.outcache.cols * world.curjob->ws.io.outcache.lines) -#define buf world.curjob->ws.screen.buf -#define tail world.curjob->ws.screen.tail -#define head world.curjob->ws.screen.head - - //printf("BUF = %08x HEAD = %08x TAIL = %08x\n", buf, head, tail); - - /* We could have to loop many time before full fill all the buffer */ - for (size = strlen(str), check = 0; size > 0; size -= check, str += check) - { - check = 0; - /* Tail is after head or we can fill tail without change (or not a lot) the head */ - if (tail >= head || (tail + strlen(str) <= head && head < buf + scrsize)) - { - /* There is not enough space ! */ - if (tail + strlen(str) > buf + scrsize) - { - /* We can copy a part of the buffer */ - check = scrsize - (tail - buf); - snprintf(tail, check, "%s", str); - - /* Tail is know at the beginning */ - tail = buf; - - /* If head is on the beginning */ - if (tail >= head) - head = tail + 1; - } - else - { - /* We can copy the whole buffer */ - snprintf(tail, scrsize, "%s", str); - tail += strlen(str); - break; - } - } - else - { - /* What size we can use for the moment ? */ - check = buf + scrsize - tail; - - /* May be we need less */ - if (check > strlen(str)) - check = strlen(str); - - /* Adjust head pointer */ - head = buf + ((tail - buf) + check)%scrsize; - tail += check; - } - } - -#undef scrsize -#undef buf -#undef tail -#undef head - - - NOPROFILER_OUT(); -} - - -/** - * Stop logging - */ -int revm_closelog() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XCLOSE(world.curjob->ws.logfd, -1); - - if (!world.state.revm_quiet) - revm_output(" [*] Saved logging session \n\n"); - world.curjob->ws.state &= (~REVM_JOB_LOGGED); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -## -## Makefile for vm in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = color.c curjob.c input.c io.c log.c network.c output.c \ - prompt.c select.c readln.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME32 = ../revm-io.32.o -NAME64 = ../revm-io.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../libedfmt/include/ \ - -I../../elibc/include/ \ - -I../../libui/include/ -I../../libasm/include/ \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libdump/include/ $(BUILDOP) -DELFSH_INTERN \ - $(STATOPT2) $(ASMOPT) $(BITS) -DERESI32 $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include -Iinclude $(DYNOPT) \ - -I../../libelfsh/include/ -I../../libedfmt/include/ \ - -I../../elibc/include/ \ - -I../../libui/include/ -I../../libasm/include/ \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libdump/include/ -DELFSH_INTERN $(STATOPT2) \ - $(ASMOPT) $(BITS) -DERESI64 $(BUILDOP) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< - -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/network.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/network.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/network.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/network.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1266 +0,0 @@ -/** - * @file network.c - * @ingroup io - * @brief The high-level network interface. - * - * Started Wed Feb 25 22:22:35 2004 yann_malcom - * Updated Mon Mar 05 04:37:10 2007 jfv - * - * $Id: network.c,v 1.10 2007-08-17 15:38:52 heroine Exp $ - * - */ -#include "revm.h" - - -/* Number of clients connected */ -int elfsh_net_client_count = 0; - - - -/* Is net support enable ? */ -#if defined(ELFSHNET) -/** - * @brief Add a client socket to the elfsh_net_client_list. - * @ingroup io - */ -revmjob_t *revm_socket_add(int socket, struct sockaddr_in *addr) -{ - revmjob_t *new; - char logbuf[30]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If too many clients return (-1) */ - if (elfsh_net_client_count >= REVM_MAX_CLIENTS) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many clients", (NULL)); - - /* If there is already a client by that inet address return (-1) */ - if (hash_get(&world.jobs, inet_ntoa(addr->sin_addr)) != NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Already connected", NULL); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] adding client on socket %d .\n", socket); -#endif - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (revmjob_t), NULL); - - new->ws.sock.addr = *addr; - new->ws.sock.socket = socket; - new->ws.sock.recvd = NULL; - new->ws.sock.recvd_f = OLD; - elfsh_net_client_count++; - - new->ws.io.type = REVM_IO_NET; - new->ws.io.input_fd = socket; - new->ws.io.output_fd = socket; - new->ws.io.input = revm_net_input; - new->ws.io.output = revm_net_output; - new->ws.createtime = time(&new->ws.createtime); - new->ws.active = 1; - - snprintf(logbuf, sizeof(logbuf), "client-%u_loaded", elfsh_net_client_count); - hash_init(&new->loaded, logbuf, 51, ASPECT_TYPE_UNKNOW); - snprintf(logbuf, sizeof(logbuf), "client-%u_dbgloaded", elfsh_net_client_count); - hash_init(&new->dbgloaded, logbuf, 11, ASPECT_TYPE_UNKNOW); - hash_add(&world.jobs, inet_ntoa(addr->sin_addr), new); - world.curjob = new; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - - -/** - * @brief Return the number of buffer in a revmsock_t recvd - * @ingroup io - */ -int revm_socket_get_nb_recvd(char *inet) -{ - revmjob_t *tmp; - int i; - int index; - revmjob_t *old; - listent_t *actual; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Is there a socket by that name */ - tmp = hash_get(&world.jobs, inet); - - if (tmp != NULL) - { - if (!tmp->ws.active) - { - for (index = 0; index < world.jobs.size; index++) - { - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - old = world.curjob; - world.curjob = tmp; - - if (revm_own_job((revmjob_t *) actual->data) && - ((revmjob_t *) actual->data)->ws.active) - { - world.curjob = old; - tmp = (revmjob_t *) actual->data; - } - - world.curjob = old; - } - } - } - - if (tmp->ws.sock.recvd_f == OLD) - { - /* recvd data have already been read so we forget them */ - tmp->ws.sock.recvd = NULL; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - else - { - /* we have to count them */ - if (tmp->ws.sock.recvd != NULL) - { - /* There might be data */ - i = 0; - while (tmp->ws.sock.recvd[i] != NULL) - { - i++; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, i); - } - else - /* recvd is NULL so return 0 but marked as NEW */ - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Not really a consistant" - " state in a revmsock_t recvd data.\n"); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No socket by that inet addr", (-1)); - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to receive", (-1)); -} - -/** - * @brief Only close a socket - * @ingroup io -*/ -int revm_socket_close(int socket) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (shutdown(socket, SHUT_RDWR) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to shutdown socket", (-1)); - if (close(socket) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to close socket", (-1)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** -* @brief Remove a client socket from the list and close it, return (-1) if socket -* not found -* @ingroup io -*/ -int revm_socket_del(char *inet_addr) -{ - revmjob_t *tmp; - int nbargc; - int i; - listent_t *actual; - int index; - revmjob_t *old; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - tmp = hash_get(&world.jobs, inet_addr); - if (!tmp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to find INET address for socket", (-1)); - - for (index = 0; index < world.jobs.size; index++) - { - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - old = world.curjob; - world.curjob = tmp; - - if (revm_own_job((revmjob_t *) actual->data)) - { - hash_del(&world.jobs, actual->key); - } - - world.curjob = old; - - } - } - - if (revm_socket_close(tmp->ws.sock.socket) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to close socket", (-1)); - - //elfsh_net_client_count--; - if (tmp->ws.sock.recvd_f == NEW) - { - /* We assume that buffer are not referenced, and so won't be used */ - nbargc = revm_socket_get_nb_recvd(inet_ntoa(tmp->ws.sock.addr.sin_addr)); - for (i = 0 ; i < nbargc ; i++) - XFREE (__FILE__, __FUNCTION__, __LINE__, tmp->ws.sock.recvd[i]); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] We are deleting a socket struct which has" - "new received data.\n"); -#endif - } - - XFREE(__FILE__, __FUNCTION__, __LINE__,tmp->ws.sock.recvd); - hash_del(&world.jobs, inet_addr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Really send the data - * @ingroup io - */ -int revm_netsend(char *buf, unsigned int len) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (len > strlen(buf)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input length parameter", (-1)); - if (send(world.curjob->ws.io.output_fd, (void *) buf, len, 0) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to send data", (-1)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * @brief send buf on a socket - * @ingroup io -*/ -int revm_net_output(char *buf) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (strlen(buf) > REVM_MAX_SEND_SIZE) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Socket [%u] attempt to " - "send too much data.\n", - world.curjob->ws.io.output_fd); -#endif - if (revm_netsend(buf, REVM_MAX_SEND_SIZE) >= 0) - { - ret = revm_net_output((char *) (buf + REVM_MAX_SEND_SIZE)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to send on net interface", (-1)); - } - - ret = revm_netsend(buf, strlen(buf)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * @brief Create le main socket and bind it to ELFSH_LISTEN_PORT. - * @ingroup io -*/ -int revm_create_server(int *serv_sock, - struct sockaddr_in *addr, - u_int port) -{ - int reuseaddr = 1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // Let's create the main socket - if (((*serv_sock) = socket(AF_INET, SOCK_STREAM, 0)) < 0) - FATAL("socket"); - - if (setsockopt((*serv_sock), SOL_SOCKET, - SO_REUSEADDR, &reuseaddr, - sizeof (reuseaddr)) < 0) - FATAL("setsockopt"); - - //memset(addr, 0, sizeof (struct sockaddr_in)); - addr->sin_family = AF_INET; - addr->sin_port = htons(port); - inet_aton("0.0.0.0", &addr->sin_addr); - - if (bind((*serv_sock), (struct sockaddr *) addr, - sizeof (struct sockaddr_in)) < 0) - { - close((*serv_sock)); - FATAL("bind"); - } - - if (listen((*serv_sock), 5) < 0) - FATAL("listen"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * @brief Update revmsock_t recvd buffer - * @ingroup io -*/ -int revm_update_recvd(revmsock_t *socket) -{ - char *buf; - char **buf2; - int size; - int i = 0; - int bufnb; - char **oldrecvd; - char *c; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Allocating space for receiving data ... */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - buf, sizeof(char) * BUFSIZ, -1); - - size = read(socket->socket, buf, BUFSIZ - 1); - if (size < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, buf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot receive on socket", -1); - } - - /* That's ok, let's continue */ - else - { - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DBG_NETWORK] read(%d) [OK] with ret = %d \n", - socket->socket, size); -#endif - - if (size == 0) - { - -#if __DEBUG_NETWORK__ - fprintf(stderr, - "[DBG_NETWORK] connection to %s closed by remote host.\n", - inet_ntoa(socket->addr.sin_addr)); -#endif - - if (socket->recvd_f == OLD) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,buf); - revm_socket_del(inet_ntoa(socket->addr.sin_addr)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - else - { - //TODO : XFREE all buffer, if buffers are marked OLD, - //revm_net_input has been called so revm_socket_merge_recvd too. - XFREE (__FILE__, __FUNCTION__, __LINE__, buf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - else - { - buf[size] = '\0'; - /* Remove the last char in case of telnet client */ - if (size > 0) - { - /* We want a trailing \n to handle the line */ - socket->ready_f = NO; - if(buf[size-1] == 0x0a) - { - buf[size-1] = '\0'; - /* we got one \n */ - socket->ready_f = YES; - } - } - if (size > 1) - { - if(buf[size-2] == 0x0d) - { - buf[size-2] = '\0'; - /* we got a \n */ - socket->ready_f = YES; - } - } - /* In case of multiple command pasted at once, we want to - handle them at once */ - while ((c = strchr(buf, '\n'))) - (*c) = ' '; - - } - } - - if (socket->recvd_f == NEW) - { - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Select said there is something \n" - "new to read on the socket BUT there is already \n" - "data in the buffer which has not been read.\n"); -#endif - - /* Something got wrong in revm_socket_get_nb_recvd() */ - bufnb = revm_socket_get_nb_recvd(inet_ntoa(socket->addr.sin_addr)); - if (bufnb < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot receive on socket", -1); - - /* - ** We have the old number of buffer and they have not been read so - ** we have to append the new one at the end. - */ - else - { - /* +1 for the new (char *) and +1 for the NULL */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, - buf2, sizeof (char *)*(bufnb + 1 + 1), -1); - - /* Now let's copy the old buffer's pointers*/ - oldrecvd = socket->recvd; - for (i = 0; i < bufnb; i++) - buf2[i] = oldrecvd[i]; - - /* Now we append the new buffer's pointer and set the NEW flag*/ -#if __DEBUG_NETWORK__ - fprintf(stderr, "buf : %s",buf); -#endif - buf2[i++] = buf; - buf2[i++] = NULL; - socket->recvd = buf2; - socket->recvd_f = NEW; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - else - { - /* buffers have already be read so we can overwrite - recvd and set recvd_flag to NEW */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,buf2, sizeof (char *)*2, -1); -#if __DEBUG_NETWORK__ - fprintf(stderr, "buf : %s", buf); -#endif - buf2[0] = buf; - buf2[1] = NULL; - socket->recvd = buf2; - socket->recvd_f = NEW; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Never reached, just to shut gcc up */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Should never be reached", -1); -} - - - - - - -/** - * @brief send buf on a dump connection - * @ingroup io - */ -int revm_dump_output(char *buf) -{ - int ret = 0; - char *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, tmp, strlen(buf) + 1 + 1, -1); - tmp[0] = REVM_DUMP_MSG; - memcpy(tmp + 1, buf, strlen(buf) + 1); - ret = dump_send(world.curjob->ws.io.pkt->src, tmp, strlen(buf) + 1 + 1); - //XFREE (tmp); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - - - -/** - * @brief Return the first packet data - * @ingroup io -*/ -char *revm_dump_input() -{ - char *tmp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - tmp = strdup((char *)(world.curjob->ws.io.pkt->data) + 1); - world.curjob->ws.io.new = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (tmp)); -} - - - - -/** - * @brief accept a DUMP connection - * @ingroup io -*/ -int revm_dump_accept() -{ - struct sockaddr_in cli_addr; - u_int cli_len; - int new_sd; - - struct sockaddr loc; - socklen_t lloc = sizeof (struct sockaddr); - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cli_len = sizeof (cli_addr); - new_sd = accept(dump_world.sock, - (struct sockaddr *) &cli_addr, - &cli_len); - if (new_sd > 0) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[+] Connection from : %s\n", - inet_ntoa(cli_addr.sin_addr)); -#endif - - /* getsockname ()*/ - getsockname(new_sd, &loc, &lloc); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[+] add new id \n"); -#endif - - dump_add_myid(((struct sockaddr_in *) &loc)->sin_addr, new_sd); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[+] added\n"); - fprintf(stderr, "[+] my new id : %s \n", - inet_ntoa(dump_get_myid(new_sd))); - fprintf(stderr, "[+] Adding a DUMP neighbor : [%d,%s]\n", - new_sd, inet_ntoa(cli_addr.sin_addr)); -#endif - - dump_add_neighbor(new_sd, cli_addr.sin_addr); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to accept client", (-1)); -} - - - - -/** - * @brief Accept new connection if there is - * @ingroup io -*/ -int revm_net_accept() -{ - socklen_t temp_addr_len; - struct sockaddr_in *temp_addr; - int temp_sock; - int ret = 0; - revmjob_t *curjob; - revmjob_t *oldjob; - revmjob_t *init; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* There was noise on main socket */ -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] There is somebody" - " knocking at the door...\n"); -#endif - - init = hash_get(&world.jobs, "net_init"); - if (init == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to find initial net job", (-1)); - - temp_addr_len = sizeof (struct sockaddr_in); - XALLOC(__FILE__, __FUNCTION__, __LINE__, temp_addr, temp_addr_len, -1); - temp_sock = accept(init->ws.sock.socket, - (struct sockaddr *) temp_addr, &temp_addr_len); - - if (temp_sock >= 0) - { - // Somebody want to join us. We are so "attractive" ... -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Client " - "accepted on socket %d.\n",temp_sock); -#endif - - curjob = revm_socket_add(temp_sock, temp_addr); - if (curjob == NULL) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] We have " - "decided to abort the connection\n"); -#endif - close(temp_sock); - XFREE(__FILE__, __FUNCTION__, __LINE__,temp_addr); - ret = -1; - } - } - else - { - // Maybe he was afraid of us -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] He might have been afraid.\n"); -#endif - XFREE(__FILE__, __FUNCTION__, __LINE__,temp_addr); - ret = -1; - } - - /* Display a prompt on this socket */ - if (ret >= 0) - { - oldjob = world.curjob; - world.curjob = curjob; - revm_output("\n [*] Connection granted to ELFsh daemon\n\n"); - revm_display_prompt(); - world.curjob = oldjob; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - - -/** - * @brief One listening step - * @ingroup io -*/ -int revm_net_recvd(fd_set *sel_sockets) -{ - revmsock_t *temp_socket; - listent_t *actual; - int index; - revmjob_t *init; - int sd; - pkt_t *data; - revmjob_t *new; - char tmp[24]; - char logbuf[30]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - init = hash_get(&world.jobs, "net_init"); - - // Who has moved ? - for (index = 0; index < world.jobs.size; index++) - { - - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (!((revmjob_t *) actual->data)->ws.active) - continue; - - temp_socket = &((revmjob_t *) actual->data)->ws.sock; - - if (((revmjob_t *) actual->data)->ws.io.type != REVM_IO_NET) - continue; - - if (temp_socket->socket == init->ws.sock.socket || - temp_socket->socket == 0) - continue; - - if (FD_ISSET(temp_socket->socket, sel_sockets)) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Client on socket %d " - "is trying to say something...\n", - temp_socket->socket); -#endif - // Let's update the revmsock_t recvd data */ - if (revm_update_recvd(temp_socket) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot receive on socket", -1); - } - } - } - - - // scan dump - for (index = 0; index < dump_world.ports.size; index++) - { - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - //if (!((revmjob_t *) actual->data)->ws.active) - // continue; - - sd = (long) actual->data; - if (FD_ISSET(sd, sel_sockets)) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[+] Calling DUMP recv callback [%d]\n", sd); -#endif - data = dump_receive_cb(sd); - - /* connection closed by libdump */ - if (data == (void *) (-1)) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, " socket %d considered as close \n", sd); -#endif - /* XXX delete pending jobs */ - - continue; - } -#if __DEBUG_NETWORK__ - dump_print_pkt((pkt_t *) data); -#endif - - /* we have something to do */ - if (data != NULL) - { - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[+] packet type : %s\n", - (((pkt_t *) data)->type == htons(RR)) ? "RR" : - ((((pkt_t *) data)->type == htons(Rr)) ? "Rr" : - ((((pkt_t *) data)->type == htons(DATA)) ? "DATA" : - "Unknown"))); -#endif - - /* sanity check */ - if (ntohl(data->size) != 0) - { - - if (ntohl(data->size) > 0) - ((char *)data->data)[ntohl(data->size) - 1] = '\0'; - - /* XXX TODO : change it to a hash table lookup - ym */ - /* demux DUMP packets */ - - switch (((char *)((pkt_t *)data)->data)[0]) - { - - /* elfsh cmd, pass it to revm_input() */ - case REVM_DUMP_CMD: - snprintf(tmp, sizeof (tmp)-1, "DUMP_%s", - inet_ntoa(((pkt_t *)data)->src)); - - new = hash_get(&world.jobs, tmp); - if (new == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new, sizeof (revmjob_t), -1); - snprintf(logbuf, sizeof(logbuf), "%s_loaded", tmp); - hash_init(&new->loaded, logbuf, - 51, ASPECT_TYPE_UNKNOW); - snprintf(logbuf, sizeof(logbuf), "%s_dbgloaded",tmp); - hash_init(&new->dbgloaded, logbuf, - 11, ASPECT_TYPE_UNKNOW); - } - else - { - if (new->ws.io.new == 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Fatal internal DUMP error", -1); - hash_del(&world.jobs, tmp); - } - - new->ws.io.type = REVM_IO_DUMP; - new->ws.io.input_fd = (-1); - new->ws.io.output_fd = (-1); - new->ws.io.input = revm_dump_input; - new->ws.io.output = revm_dump_output; - new->ws.io.new = 1; - new->ws.io.pkt = data; - new->ws.createtime = time(&new->ws.createtime); - new->ws.active = 1; - hash_add(&world.jobs, strdup(tmp), new); - - break; - /* message, display it */ - case REVM_DUMP_MSG: - revm_output((char *)((pkt_t *) data)->data + 1); - dump_free(data); - break; - /* unknown */ - default: - revm_output("unknown ELFSH_DUMP packet type\n"); - dump_free(data); - break; - } - } - } -#if __DEBUG_NETWORK__ - else - fprintf(stderr, "[+] null (non-data packet)\n"); -#endif - } - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * @brief Merge buffers - * @ingroup io -*/ -char *revm_socket_merge_recvd(revmsock_t *socket) -{ - char *ret; - int nb_recvd; - int i; - int size = 0; - int lsize; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - nb_recvd = revm_socket_get_nb_recvd(inet_ntoa(socket->addr.sin_addr)); - if (nb_recvd < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to receive on socket", NULL); - - /* Let's calculate the length of buffer needed.*/ - for (i = 0; i < nb_recvd ; i++) - size += strlen(socket->recvd[i]); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - ret , sizeof (char) * (size + 1), NULL); - - /* And now we have to fill it */ - /* First we reset size*/ - size = 0; - lsize = 0; - for (i = 0; i < nb_recvd ; i++) - { - lsize = strlen(socket->recvd[i]); - /* Smaller by one in order to discard the '\0'*/ - strncpy((ret+size), socket->recvd[i], lsize); - size += lsize; - } - /* Important because we do not copy the last '\0'*/ - ret[size] = '\0'; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * @brief Return the first buffers - * @ingroup io - */ -char *revm_net_input() -{ - revmsock_t *temp_socket; - listent_t *actual; - int index; - char *ret; -#if __DEBUG_NETWORK__ - int i; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] revm_net_input\n"); -#endif - - for (index = 0; index < world.jobs.size; index++) - { - - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (!((revmjob_t *) actual->data)->ws.active) - continue; - - temp_socket = & ((revmjob_t *) actual->data)->ws.sock; - - - if (temp_socket->recvd_f == NEW && - temp_socket->ready_f == YES) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] revm_network_input " - "on %d -> NEW buffer\n", - temp_socket->socket); -#endif - - ret = revm_socket_merge_recvd(temp_socket); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "ret : %s\n", ret); - for (i = 0 ; i < strlen(ret) ; i++) - fprintf(stderr, "%#x\n", ret[i]); -#endif - - temp_socket->recvd_f = OLD; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - } - } - - /* No new buffer */ -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] revm_network_input no new buffer\n"); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (char *) REVM_INPUT_VOID); -} - - - - - -/** - * @brief Listening initialisation - * @ingroup io -*/ -int revm_net_init() -{ - revmjob_t *init; - struct sockaddr_in dump_sockaddr_main; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - init = hash_get(&world.jobs, "net_init"); - if (init == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find initial net job", (-1)); - - /* remote client main socket */ - if (revm_create_server(&(init->ws.sock.socket), - &(init->ws.sock.addr), REVM_PORT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to create net server", (-1)); - - /* remote elfsh main socket (DUMP) */ - if (revm_create_server(&(dump_world.sock), - &(dump_sockaddr_main), REVM_DUMP_PORT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Fail to create dump server", (-1)); - - /* initialisation of DUMP */ - if (dump_init() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to initialize DUMP", (-1)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * @brief Stopping network | not workspace compliant ... - * @ingroup io -*/ -int revm_net_stop() -{ - listent_t *actual; - int index; - revmsock_t *temp_socket; - revmjob_t *serv; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Closing all client's sockets*/ - for (index = 0; index < world.jobs.size; index++) - { - - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - temp_socket = &((revmjob_t *) actual->data)->ws.sock; - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Closing " - "socket : %d \n", temp_socket->socket); -#endif - - if (revm_socket_del(inet_ntoa(temp_socket->addr.sin_addr)) < 0) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] error on deleting a socket\n"); -#endif - } - } - } - - /* Closing serv socket */ - serv = hash_get(&world.jobs, "net_init"); - -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Closing socket : %d \n", - serv->ws.sock.socket); -#endif - - /* Closing DUMP connections */ - for (index = 0; index < dump_world.ports.size; index++) - { - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - dump_disconnect((long) actual->data); - } - } - - /* Closing DUMP main socket */ - close(dump_world.sock); - if (serv == NULL || revm_socket_close(serv->ws.sock.socket) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to close socket", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Clean jobs - * @ingroup io -*/ -int revm_clean_jobs() -{ - revmjob_t *job; - int index; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - keys = hash_get_keys(&world.jobs, &keynbr); - for (index = 0; index < keynbr; index++) - { - job = hash_get(&world.jobs, keys[index]); - switch (job->ws.io.type) - { - - case REVM_IO_DUMP: - if (job->ws.io.new == 0) - { -#if __DEBUG_NETWORK__ - printf("CLEAN : %s\n", keys[index]); -#endif - /* If we delete jobs here, we do not have - session persistence and every load must be - done through shared load */ - /* XXX can we free ws.io.pkt ?? */ - } - break; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* Case where the network is not enabled */ -#else - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_clean_jobs() -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_getmaxfd() -{ - if (world.state.revm_mode != REVM_STATE_DEBUGGER) - return (0); - if (world.state.revm_side == REVM_SIDE_CLIENT) - return (world.fifo_s2c); - else - return (world.fifo_c2s); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -revmjob_t *revm_socket_add(int socket, struct sockaddr_in *addr) -{ - return (NULL); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_socket_get_nb_recvd(char *inet) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_socket_close(int socket) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_socket_del(char *inet_addr) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_netsend(char *buf, unsigned int len) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_net_output(char *buf) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_create_server(int *serv_sock, - struct sockaddr_in *addr) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_update_recvd(revmsock_t *socket) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_net_accept_connection() -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_dump_accept_connection() -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_net_recvd(fd_set *sel_sockets) -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -char *revm_socket_merge_recvd(revmsock_t *socket) -{ - return (NULL); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -char *revm_net_input() -{ - return (NULL); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_net_init() -{ - return (0); -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -int revm_net_stop() -{ - return (0); -} - -#endif - - diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/output.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/output.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/output.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/output.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -/** - * @file output.c - * @ingroup io - * @brief The output vector interface. - * - * Started on Fri Mar 5 00:55:40 2004 jfv - * Updated on Mon Mar 5 18:47:41 2007 jfv - * - * $Id: output.c,v 1.8 2007-08-17 15:38:52 heroine Exp $ - * - */ -#include "revm.h" - - - -/** - * @brief Display str on all term - * @ingroup io - */ -int revm_output_bcast(char *str) -{ - int index; - int ret = 0; - revmjob_t *old; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Saving current output parameters */ - old = world.curjob; - - /* Net's outputs */ - if (world.state.revm_net) - { - keys = hash_get_keys(&world.jobs, &keynbr); - for (index = 0; index < keynbr; index++) - { - old = hash_get(&world.jobs, keys[index]); - if (!strcmp(keys[index], "local") || !strcmp(keys[index], "net_init") || - !strncmp(keys[index], "DUMP", 4) || !old->ws.active); - continue; - world.curjob = old; - ret |= revm_output(str); - revm_flush(); - } - } - - /* stdout */ - if (world.state.revm_mode != REVM_STATE_CMDLINE) - { - world.curjob = hash_get(&world.jobs, "local"); - ret |= revm_output(str); - } - - /* Restore */ - world.curjob = old; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * @brief OUTPUT handler for stdout - * @ingroup io - */ -int revm_output(char *str) -{ - char *tmp; - char c; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_log(str); - - /* No -- more -- in some modes */ - if ((world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) - || world.curjob->ws.io.type == REVM_IO_DUMP - || !world.curjob->ws.io.outcache.lines - || world.curjob->sourced - || !(int)config_get_data(ERESI_VMCONFIG_USE_MORE)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (world.curjob->ws.io.output(str))); - - /* Discard outputs */ - if (world.curjob->ws.io.outcache.ignore) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - /* Counts lines */ - tmp = strchr(str, '\n'); - while (tmp) - { - world.curjob->ws.io.outcache.nblines--; - if (*tmp == '\0') - break; - tmp ++; - tmp = strchr(tmp, '\n'); - } - - /* Do the output */ - ret = world.curjob->ws.io.output(str); - - /* Is there any lines remaining ? */ - if (world.curjob->ws.io.outcache.nblines < 0) - { - revm_flush(); - tmp = "-- press enter for more ('q/n' to quit / next) --\n"; - world.curjob->ws.io.output(tmp); - - /* We decided to discard further output (until next revm_flush) */ - if ((read(world.curjob->ws.io.input_fd, &c, 1) == 1) && (c == 'q' || c == 'n')) - { - if (c == 'q') - world.curjob->ws.io.outcache.ignore = 1; - world.curjob->ws.io.output("\n"); - revm_log("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (c == 'q' ? -1 : -2)); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - -/** - * @brief Output without buffering/log - * @ingroup io -*/ -int revm_output_nolog(char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - world.curjob->ws.io.output(str)); -} - - - -/** - * @brief ERR output function (stderr) - * @ingroup io -*/ -int revm_outerr(char *str) -{ - revm_log(str); - fprintf(stderr, "%s", str); - return (0); -} - - - -/** - * @brief OUTPUT handler for stdout - * @ingroup io - */ -int revm_stdoutput(char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - printf("%s", str); - fflush(stdout); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,0); -} - - -/** - * @bief Change the Output file - * @ingroup io - */ -void revm_setoutput(revmworkspace_t *ws, int fd) -{ - ws->io.output_fd = fd; -} - diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/prompt.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/prompt.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/prompt.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/prompt.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -/** - * @file prompt.c - * @ingroup io - * @brief Interface for prompt management. - * @ingroup io - * Started on Fri Nov 2 15:21:56 2001 jfv - * Updated on Mon Mar 5 17:26:11 2007 jfv - * - * $Id: prompt.c,v 1.11 2008-02-16 12:32:27 thor Exp $ - * -*/ -#include "revm.h" - - -void (*prompt_token_setup)(char *name, u_int size); -char prompt_token[512]; - - - -/** - * @brief TO COMPLETE - * @ingroup io - */ -void revm_set_prompt(void (*func) (char *name, u_int size)) -{ - prompt_token_setup = func; -} - -/** - * @brief TO COMPLETE - * @ingroup io - */ -void revm_create_default_prompt(char *name, u_int size) -{ - snprintf(name, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - (world.state.revm_mode == REVM_STATE_DEBUGGER ? - revm_colorget("%s", "psname" , E2DBG_ARGV0) : - revm_colorget("%s", "psname" , REVM_NAME)), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", REVM_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", REVM_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", REVM_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->ws.name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -/** - * @brief return the right prompt - * @ingroup io - */ -char* revm_get_prompt() -{ - if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER) - { - /* Setup prompt only once */ - if (prompt_token_setup == NULL) - revm_set_prompt(revm_create_default_prompt); - - if (prompt_token_setup) - prompt_token_setup(prompt_token, sizeof(prompt_token)); - else - snprintf(prompt_token, sizeof(prompt_token) - 1, "prompt-error"); - - /* Prompt on readline need some modifications */ - revm_prompt_update(prompt_token, sizeof(prompt_token)); - return (prompt_token); - } - - if (world.state.revm_mode == REVM_STATE_SCRIPT) - return ""; - - return "UNKNOWN MODE> "; -} - - -/** - * @brief Display the prompt - * @ingroup io - */ -int revm_display_prompt() -{ - char *buf; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - buf = ((world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER || - (world.state.revm_net && world.curjob->ws.io.type != REVM_IO_STD)) ? - revm_get_prompt() : ""); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/readln.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/readln.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/readln.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/readln.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ -/** - * @file readln.c - * @ingroup io - * @brief Interface readline with librevm. - * - * This allows us to only recompile this file - * when the user recompiles enabling/disabling readline. - * - * Started on Fri Mar 5 00:55:40 2004 jfv - * $Id: readln.c,v 1.2 2007-11-29 15:33:39 may Exp $ - */ -#include "revm.h" - -/** - * Reset lines counters and ignore output state - */ -void revm_ctrl_set(int i, char c) -{ -#if defined(USE_READLN) - readln_ctrl_set(i, c); - world.curjob->ws.io.buf = NULL; -#endif -} - -void revm_buffer_reset(u_short isnew) -{ -#if defined(USE_READLN) - if (isnew) - world.curjob->ws.io.buf = NULL; -#endif -} - -void revm_screen_change(u_short isnew, char promptdisplay) -{ -#if defined(USE_READLN) - readln_screen_change(isnew, promptdisplay); -#endif -} - -int revm_prompt_restore() -{ -#if defined(USE_READLN) - return (readln_prompt_restore()); -#else - return (0); -#endif -} - -int revm_prompt_update(char *ptr, int size) -{ -#if defined(USE_READLN) - return (readln_prompt_update(ptr, size)); -#else - return (0); -#endif -} - -char *revm_input_check() -{ -#if defined(USE_READLN) - return (readln_input_check()); -#else - return (NULL); -#endif -} - -int revm_init_history(int mode) -{ -#if defined(USE_READLN) - return (readln_init(mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY))); -#else - return (0); -#endif -} - -int revm_quit(int mode) -{ -#if defined(USE_READLN) - return (readln_quit(mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY))); -#else - return (0); -#endif -} - -void revm_completion_install(char mode, char side) -{ -#if defined(USE_READLN) - readln_completion_install(mode, side); -#endif -} - -void revm_input_log(char *str) -{ -#if defined(USE_READLN) - readln_input_log(str); -#endif -} - -void revm_completion_commands(hash_t *cmd_hash) -{ -#if defined(USE_READLN) - readln_completion_commands(cmd_hash); -#endif -} - -int revm_column_update() -{ -#if defined(USE_READLN) - return (readln_column_update()); -#else - return (0); -#endif -} - -void revm_terminal_prepare(char mode) -{ -#if defined(USE_READLN) - readln_terminal_prepare(mode); -#endif -} - -void revm_terminal_unprepare(char mode) -{ -#if defined(USE_READLN) - readln_terminal_unprepare(mode); -#endif -} - -void revm_job_preswitch() -{ -#if defined(USE_READLN) - if (world.curjob->ws.io.savebuf) - XFREE(__FILE__, __FUNCTION__, __LINE__,world.curjob->ws.io.savebuf); - world.curjob->ws.io.savebuf = strdup(rl_line_buffer); - world.curjob->ws.io.buf = NULL; - world.curjob->ws.io.rl_point = rl_point; - world.curjob->ws.io.rl_end = rl_end; -#endif -} - -void revm_job_postswitch() -{ -#if defined(USE_READLN) - rl_set_prompt(revm_get_prompt()); -#endif -} - -void revm_screen_getsize(int *lines, int *cols) -{ -#if defined(USE_READLN) - rl_get_screen_size(lines, cols); -#endif -} - - -void revm_buffer_free(char *buf) -{ -#if !defined(USE_READLN) - NOPROFILER_IN(); - XFREE(__FILE__, __FUNCTION__, __LINE__, buf); - NOPROFILER_OUT(); -#endif -} - - -/** - * @brief Strip readline escape characters from buffer - * @ingroup io - */ -void revm_strip_char(char *str, char c) -{ -#if defined(USE_READLN) && defined(RL_PROMPT_START_IGNORE) - u_int len, pos; - char *search; - - NOPROFILER_IN(); - len = strlen(str); - for (search = str; (search = strchr(search, c)) != NULL;) - { - pos = search - str; - /* Realign others */ - memmove(search, search+1, len - (pos + 1)); - len--; - } - NOPROFILER_OUT(); -#endif -} - - -void revm_prompt_postselect_restore(fd_set *sel_sockets) -{ -#if defined (USE_READLN) - if (world.state.revm_side == REVM_SIDE_CLIENT && FD_ISSET(0, sel_sockets)) - readln_prompt_restore(); -#endif -} - -void revm_callback_handler_remove() -{ -#if defined(USE_READLN) - rl_callback_handler_remove(); -#endif -} - -void revm_callback_handler_install(char *prompt, void (*fct)(char *str)) -{ -#if defined(USE_READLN) - rl_callback_handler_install(prompt, fct); -#endif -} - - - -void revm_prompt_log() -{ -#if defined (USE_READLN) - revm_log(revm_get_prompt()); -#endif -} - - -void revm_conditional_rlquit() -{ -#if defined(USE_READLN) - if (!(world.state.revm_mode == REVM_STATE_DEBUGGER - && world.state.revm_side == REVM_SIDE_SERVER)) - readln_quit(world.state.revm_mode, (char *)config_get_data(ERESI_VMCONFIG_HISTORY)); -#endif -} - -void revm_input_prelog(char *buf) -{ -#if defined(USE_READLN) - revm_input_log(buf); -#else - revm_log(buf); - revm_log("\n\n"); -#endif -} - -void revm_rlfifo_write() -{ -#if defined(USE_READLN) - write(world.fifo_c2s, "\n", 1); -#endif -} - -int revm_is_enabled() -{ -#if defined(USE_READLN) - return (1); -#else - return (0); -#endif -} - - -int revm_is_stdinput() -{ -#if defined(USE_READLN) - if (world.curjob->ws.io.type == REVM_IO_STD) - { - if (world.curjob->ws.io.buf != NULL) - { - /* On the client side, we consider that the prompt is already - returned by the server */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_CLIENT) - { - rl_on_new_line_with_prompt(); - rl_clear_message(); - //rl_redisplay(); - } - else - rl_forced_update_display(); - revm_log(revm_get_prompt()); - } - return (0); - } - else - return (1); -#else - return (1); -#endif -} - -void revm_line_handler(char *c) -{ -#if defined(USE_READLN) - readln_ln_handler(c); -#endif -} diff -Nru eresi-0.8a25/librevm/io/.svn/text-base/select.c.svn-base eresi-0.0.20110516/librevm/io/.svn/text-base/select.c.svn-base --- eresi-0.8a25/librevm/io/.svn/text-base/select.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/io/.svn/text-base/select.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,346 +0,0 @@ -/** - * @file select.c - ** @ingroup io - ** @brief The interface for I/O based on select(). - ** -** Started on Fri Mar 5 00:55:40 2004 jfv -** Updated on Mon Mar 5 18:47:41 2007 jfv -** -** $Id: select.c,v 1.15 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "revm.h" - - - -/** - * @brief Return the greatest socket from the elfsh_net_client_list and sock. - * @ingroup io - */ -#if defined(ELFSHNET) -int revm_getmaxfd() -{ - int index; - int keynbr; - char **keys; - u_long port; - int ret; - revmjob_t *serv; - - /* If the network is not UP, the biggest fd is 0 */ - ret = 0; - serv = hash_get(&world.jobs, "net_init"); - if (serv == NULL) - return (ret); - ret = serv->ws.sock.socket; - ret = (ret > dump_world.sock) ? ret : dump_world.sock; - keys = hash_get_keys(&dump_world.ports, &keynbr); - - for (index = 0; index < keynbr; index++) - { - port = (u_long) hash_get(&dump_world.ports, keys[index]); - if (port > ret) - ret = port; -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Socket (DUMP) [%u] \n", port); -#endif - } - - hash_free_keys(keys); - keys = hash_get_keys(&world.jobs, &keynbr); - - /* remote client */ - for (index = 0; index < keynbr; index++) - { - serv = hash_get(&world.jobs, keys[index]); - if (!serv->ws.active) - continue; - if (serv->ws.sock.socket > ret) - ret = serv->ws.sock.socket; -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] Socket [%u] key = %10s \n", - serv->sock.socket, keys[index]); -#endif - } - - hash_free_keys(keys); - if (world.state.revm_mode == REVM_STATE_DEBUGGER && world.fifofd > ret) - ret = world.fifofd; - return (ret); -} -#endif - - - - - - -/** - * @brief Add a main socket and client's sockets to the sockets list used by select - * and call get_max_fd to get the greatest - * @ingroup io - */ -int revm_prepare_select(fd_set *sel_sockets) -{ - int index; - char **keys; - int keynbr; - revmjob_t *job; -#if defined(ELFSHNET) - u_long port; - - keys = hash_get_keys(&dump_world.ports, &keynbr); - for (index = 0; index < keynbr; index++) - { - port = (u_long) hash_get(&dump_world.ports, keys[index]); -#if __DEBUG_NETWORK__ - fprintf(stderr, - "[DEBUG NETWORK] prepare_4_select : (DUMP) socket : %d \n", - port); -#endif - FD_SET(port, sel_sockets); - } - hash_free_keys(keys); -#endif - - /* Now get the keys for jobs */ - keys = hash_get_keys(&world.jobs, &keynbr); - - /* Remote clients */ - for (index = 0; index < keynbr; index++) - { - job = hash_get(&world.jobs, keys[index]); - if (!job->ws.active) - continue; - -#if _DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] prepare_4_select : socket : %d \n", - job->ws.sock.socket); -#endif - -#if defined(ELFSHNET) - if (job->ws.io.type == REVM_IO_DUMP) - continue; - if (job->ws.io.type == REVM_IO_NET) - FD_SET(job->ws.sock.socket, sel_sockets); -#endif - - if (job->ws.io.type == REVM_IO_STD) - FD_SET(job->ws.io.input_fd, sel_sockets); - } - - /* Also set the debugger fifo if we are in debugger mode */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - { - if (world.state.revm_side == REVM_SIDE_CLIENT) - FD_SET(world.fifo_s2c, sel_sockets); - else - FD_SET(world.fifo_c2s, sel_sockets); - } - - hash_free_keys(keys); - return (revm_getmaxfd()); -} - - - -/** - * @brief Check if we had any network event - * @ingroup io - */ -void revm_check_net_select(fd_set *sel_sockets, - int cursock) -{ -#if defined(ELFSHNET) - // Read net command if any. - if (revm_net_recvd(sel_sockets) < 0) - fprintf(stderr, "vmnet_select : revm_net_recvd() failed\n"); - - /* Check remote clients */ - if (FD_ISSET(cursock, sel_sockets)) - { - if (revm_net_accept() < 0) - fprintf(stderr, "Connection rejected\n"); - } - - /* Check the DUMP connection */ - if (FD_ISSET(dump_world.sock, sel_sockets)) - { - if (revm_dump_accept() < 0) - fprintf(stderr, "Connection rejected\n"); - } -#endif -} - - - - - -/** - * @brief Set IO to the choosen socket - * @ingroup io -*/ -int revm_socket_getnew() -{ - revmjob_t *cur; - int index; - char **keys; - int keynbr; - - keys = hash_get_keys(&world.jobs, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&world.jobs, keys[index]); - if (!cur || !cur->ws.active) - continue; - if (cur->ws.io.type == REVM_IO_DUMP && cur->ws.io.new != 0) - { - world.curjob = cur; - return (1); - } - if (cur->ws.io.type == REVM_IO_NET && - cur->ws.sock.recvd_f == NEW && cur->ws.sock.ready_f == YES) - { - world.curjob = cur; - return (1); - } - } - return (0); -} - -/*** - * @brief Print prompt depending on the current REVM mode - * @ingroup io - */ -int revm_preselect_prompt() -{ - if (world.state.revm_mode != REVM_STATE_CMDLINE || world.state.revm_net) - { - if (world.curjob->ws.io.type != REVM_IO_DUMP) - { - if (revm_is_stdinput()) - { - /* Do not display the prompt for the client side - This part can't use any READLN stuff because - we always be on server */ - if (!(world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_CLIENT)) - revm_display_prompt(); - } - } - } - return (0); -} - - -/** - * @brief Wait for all input - * @ingroup io - */ -int revm_select() -{ - fd_set sel_sockets; - int max_fd; - revmjob_t *init; - int err; - int fifofd; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* By default do only one select. */ - init = hash_get(&world.jobs, "net_init"); - - /* Flush pending outputs */ - revm_flush(); - - /* In case of not already handle data */ - if (revm_socket_getnew()) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); - - /* clean jobs hash table */ - revm_clean_jobs(); - - do - { - FD_ZERO(&sel_sockets); - -#if defined(ELFSHNET) - if (world.state.revm_net && init) - { - FD_SET(init->ws.sock.socket, &sel_sockets); - FD_SET(dump_world.sock, &sel_sockets); - } -#endif - - // Prepare for the select() call - max_fd = revm_prepare_select(&sel_sockets); - - /* Display the prompt */ - revm_preselect_prompt(); - - retry: - err = select(max_fd + 1, &sel_sockets, NULL, NULL, NULL); - - /* Retry in case of error */ - if (err < 1 && errno == EINTR) - goto retry; - - - /* Select which command will be proceded */ -#if defined(ELFSHNET) - if (world.state.revm_net) - { - if (init) - revm_check_net_select(&sel_sockets, init->ws.sock.socket); - - if (revm_socket_getnew()) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(0)); - -#if __DEBUG_NETWORK__ - fprintf(stderr, - "[DEBUG NETWORK] Select broken by a new connexion.\n"); -#endif - continue; - } -#endif - - /* Come back now if we are in command line */ - if (world.state.revm_mode == REVM_STATE_CMDLINE) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(0)); - - /* If we are in interactive mode .. */ - world.curjob = revm_localjob_get(); - if (!world.curjob) - { - //fprintf(stderr, "Entering NOCURJOB condition .. \n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (-1)); - } - - /* If the event appeared on the debugger FIFO, - change the input file descriptor for it */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - { - fifofd = (world.state.revm_side == REVM_SIDE_CLIENT ? - world.fifo_s2c : world.fifo_c2s); - - if (FD_ISSET(fifofd, &sel_sockets)) - { - world.curjob->ws.io.old_input = world.curjob->ws.io.input; - world.curjob->ws.io.input = revm_fifoinput; - -#if __DEBUG_NETWORK__ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_CLIENT) - fprintf(stderr, "(client) Event appeared on fifo \n"); - else if (world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_SERVER) - fprintf(stderr, "(server) Event appeared on fifo \n"); -#endif - - } - } - revm_prompt_postselect_restore(&sel_sockets); - } while (0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(0)); -} diff -Nru eresi-0.8a25/librevm/lang/access.c eresi-0.0.20110516/librevm/lang/access.c --- eresi-0.8a25/librevm/lang/access.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/access.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,52 +1,14 @@ /** - * @file access.c - * @ingroup librevm_lang +* @file librevm/lang/access.c + * @ingroup lang * @brief Implementation of scripting lookups for meta-language variables. * * Started Jan 23 2007 23:39:51 jfv - * $Id: access.c,v 1.32 2008-02-16 12:32:27 thor Exp $ + * $Id: access.c 1444 2011-01-31 07:41:29Z may $ * */ #include "revm.h" -/** - * @brief Get the buffered address from the real virtual address - */ -void *revm_get_raw(void *addr) -{ - elfshsect_t *sect; - elfsh_SAddr offset; -#if defined(KERNSH) - void *dataptr; -#endif - - sect = elfsh_get_parent_section(world.curjob->curfile, - (eresi_Addr) addr, &offset); - -#if defined(KERNSH) - dataptr = kernsh_revm_get_raw(addr); - if (dataptr != NULL) - return dataptr; -#endif - - /* This happens when the object is a ERESI variable */ - if (!sect) - return (addr); - - if (elfsh_is_debug_mode()) - { - if (!elfsh_section_is_runtime(sect)) - return ((void *) (sect->parent->rhdr.base + sect->shdr->sh_addr + offset)); - else if (!sect->shdr->sh_addr) - return ((void *) (char *) sect->data + offset); - else - return ((void *) (sect->shdr->sh_addr + offset)); - } - else - return ((void *) (char *) sect->data + offset); - -} - /** * @brief Return the index for an array access giving a string @@ -110,7 +72,7 @@ char *endindex; int offset; int index; - int iter; + u_int iter; int liter; u_int *dimoff; char *lfield; @@ -146,14 +108,17 @@ for (liter = 0; liter != iter; liter++) dimoff[liter] *= dims[iter]; } + else if (iter == 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); else - break; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Missing array indexes", -1); } /* Make sure we havent gone further the limit of dimensions */ if (iter != dimnbr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array dimensions", -1); + "Too many array dimensions", -1); /* Compute the final offset of element inside the array by adding offsets of all dimensions */ @@ -169,7 +134,7 @@ /** * @brief Return offset given field name */ -aspectype_t *revm_fieldoff_get(aspectype_t *parent, char *field, u_int *off) +aspectype_t *revm_fieldoff_get(aspectype_t *parent, char *field, u_int *off, u_char *array) { aspectype_t *child; int index; @@ -182,7 +147,10 @@ memcpy(fieldname, field, sizeof(fieldname) - 1); str = strchr(fieldname, '['); if (str) - *str = 0x00; + { + *str = 0x00; + *array = 1; + } /* Find the child offset, augment it in case of array */ for (child = parent->childs; child; child = child->next) @@ -192,7 +160,7 @@ /* Get offset inside the array if we are accessing an array */ index = revm_arrayoff_get(field, child->size, - child->dimnbr, child->elemnbr); + child->dimnbr, child->elemnbr); if (index < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid array access", NULL); @@ -211,7 +179,7 @@ * @brief Recursive function to lookup data from its typed data flow path */ static aspectype_t *revm_field_get(aspectype_t *type, char *param, - void **data, char translateaddr) + void **data, char translateaddr, u_char *array) { char *str; @@ -225,10 +193,14 @@ /* This is the leaf field */ if (!str) { - child = revm_fieldoff_get(type, param, &off); + child = revm_fieldoff_get(type, param, &off, array); if (off == REVM_INVALID_FIELD) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find terminal field", NULL); + { + printf("Cannot find field %s in type %s\n", param, type->name); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find terminal field", NULL); + } + *data = (char *) *data + off; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); } @@ -237,7 +209,7 @@ *str = 0x00; next = str + 1; - child = revm_fieldoff_get(type, param, &off); + child = revm_fieldoff_get(type, param, &off, array); if (off == REVM_INVALID_FIELD) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find field", NULL); @@ -246,16 +218,20 @@ /* Dereference pointer (struct.ptr->to.other.field) */ if (child->isptr && *data) { - *data = (void *) *(u_long *) *data; if (translateaddr) - *data = revm_get_raw(*data); + { + *data = (void *) *(eresi_Addr *) *data; + *data = elfsh_readmema(world.curjob->curfile, (eresi_Addr) *data, NULL, 0); + } + else + *data = (void *) *(u_long *) *data; } - if (!*data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find dereference NULL field", NULL); + //if (!*data) + //PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + // "Cannot find dereference NULL field", NULL); - child = revm_field_get(child, next, data, translateaddr); + child = revm_field_get(child, next, data, translateaddr, array); if (!child) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find requested field", NULL); @@ -268,7 +244,7 @@ /** * @brief Create the REVM object that is to be returned */ -revmobj_t *revm_object_create(aspectype_t *type, void *data, char translateaddr) +revmobj_t *revm_object_create(aspectype_t *type, void *data, char translateaddr, u_char array) { revmobj_t *path; @@ -276,54 +252,82 @@ /* Create the revmobj and fill its handlers */ XALLOC(__FILE__, __FUNCTION__, __LINE__, path, sizeof(revmobj_t), NULL); - path->root = (void *) type; + path->root = (void *) type; + + /* In case type is unknown */ + if (!type) + { + path->get_data = (void *) revm_generic_getdata; + path->set_data = (void *) revm_generic_setdata; + goto end; + } /* Lookup again in the file if we are dealing with a pointer */ - if (type->type == ASPECT_TYPE_STR || (type->isptr && *(u_long *) data)) + /* Pointer dereferencing is done differently for internal exprs + (translate = 0) and reflected exprs (translate = 1): + sizeof(eresi_Addr) might be different than sizeof(u_long) ! + */ + if (type->type == ASPECT_TYPE_STR || type->isptr) + { + if (translateaddr && *(eresi_Addr *) data) + { + data = (void *) *(eresi_Addr *) data; + data = elfsh_readmema(world.curjob->curfile, (eresi_Addr) data, NULL, 0); + } + else if (*(u_long *) data) + data = (void *) *(u_long *) data; + } + path->parent = (void *) data; + + /* In case of list or hashes */ + if (type->isptr) { - data = (void *) *(eresi_Addr *) data; - if (translateaddr) - data = revm_get_raw(data); + if (type->type == ASPECT_TYPE_LIST || type->type == ASPECT_TYPE_HASH) + path->get_obj = (void *) revm_hash_getobj; + else + { + path->get_obj = (void *) revm_long_getobj; + path->set_obj = (void *) revm_long_setobj; + } + goto end; } - /* Fill type specific object handlers */ - path->parent = (void *) data; - if (type->type == ASPECT_TYPE_STR) + /* Then put type dependent handlers */ + switch (type->type) { + case ASPECT_TYPE_BYTE: + path->get_obj = (void *) revm_byte_getobj; + path->set_obj = (void *) revm_byte_setobj; + break; + case ASPECT_TYPE_SHORT: + path->get_obj = (void *) revm_short_getobj; + path->set_obj = (void *) revm_short_setobj; + break; + case ASPECT_TYPE_INT: + case ASPECT_TYPE_OID: + path->get_obj = (void *) revm_int_getobj; + path->set_obj = (void *) revm_int_setobj; + break; + case ASPECT_TYPE_CADDR: + case ASPECT_TYPE_DADDR: + path->get_obj = (void *) revm_addr_getobj; + path->set_obj = (void *) revm_addr_setobj; + break; + case ASPECT_TYPE_LONG: + path->get_obj = (void *) revm_long_getobj; + path->set_obj = (void *) revm_long_setobj; + break; + case ASPECT_TYPE_STR: path->get_name = (void *) revm_generic_getname; path->set_name = (void *) revm_generic_setname; + default: + break; } - if (!type) - { - path->get_data = (void *) revm_generic_getdata; - path->set_data = (void *) revm_generic_setdata; - } - path->get_obj = (void *) revm_generic_getobj; - - /* This handler is size dependant */ - if (type) - switch (type->type) - { - case ASPECT_TYPE_BYTE: - path->set_obj = (void *) revm_byte_setobj; - break; - case ASPECT_TYPE_SHORT: - path->set_obj = (void *) revm_short_setobj; - break; - case ASPECT_TYPE_INT: - path->set_obj = (void *) revm_int_setobj; - break; - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - case ASPECT_TYPE_LONG: - path->set_obj = (void *) revm_long_setobj; - break; - default: - break; - } + + end: path->otype = type; - path->immed = 0; /* Value is not immediate */ - path->perm = 1; /* Do not free after use */ + path->immed = 0; /* Value is not immediate */ + path->perm = (array ? 0 : 1); /* Free (or not) after use */ /* Success */ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, path); @@ -341,14 +345,15 @@ revmannot_t *annot; void *data; revmobj_t *path; - char hashname[ELFSH_MEANING]; + char hashname[ERESI_MEANING]; hash_t *typehash; + u_char array; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if __DEBUG_EXPRS__ - fprintf(stderr, "REVMOBJ_LOOKUP_REAL (%s of type %s and wanted field %s)\n", - objname, type->name, objpath); +#if __DEBUG_EXPRS_MORE__ + fprintf(stderr, "REVMOBJ_LOOKUP_REAL (%s.%s of type %s)\n", + objname, objpath, type->name); #endif snprintf(hashname, sizeof(hashname), "type_%s", type->name); @@ -362,20 +367,21 @@ "Cannot find requested data object", NULL); data = (void *) annot->addr; if (translateaddr) - data = revm_get_raw(data); + data = elfsh_readmema(world.curjob->curfile, (eresi_Addr) data, + (void *)&data, sizeof(void *)); /* Get recursively the leaf type and data pointer */ /* If the objpath is empty, its a scalar that was requested */ if (objpath && *objpath) { - type = revm_field_get(type, objpath, (void **) &data, translateaddr); + type = revm_field_get(type, objpath, (void **) &data, translateaddr, &array); if (!type) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to lookup object", NULL); } /* Create and return the object describing the field */ - path = revm_object_create(type, data, translateaddr); + path = revm_object_create(type, data, translateaddr, array); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, path); } @@ -385,32 +391,30 @@ */ revmobj_t *revm_object_lookup(char *str) { - char filename[ELFSH_MEANING]; - char typename[ELFSH_MEANING]; - char objectname[ELFSH_MEANING]; + char objectname[ERESI_MEANING]; int ret; - elfshobj_t *obj; aspectype_t *type; + revmexpr_t *expr; revmobj_t *path; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#define LOOKUP3_IDX "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^]]]" +#define LOOKUP3_IDX "%41[^"REVM_SEP"]"REVM_SEP - ret = sscanf(str, LOOKUP3_IDX, filename, typename, objectname); - if (ret != 3) + ret = sscanf(str, LOOKUP3_IDX, objectname); + if (ret != 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to resolve manual type object", NULL); - str += strlen(filename) + strlen(typename) + strlen(objectname) + 3; + + str += strlen(objectname); if (str[0] && str[1]) str++; - /* Get parent objects */ - obj = revm_lookup_file(filename); - if (obj == NULL) + expr = revm_expr_get(objectname); + if (!expr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", NULL); - type = hash_get(&types_hash, typename); + "Cannot find requested expr", NULL); + type = expr->type; if (!type) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find requested type", NULL); @@ -421,12 +425,7 @@ - - /**************** Generic handlers *********************************/ - - - char *revm_generic_getname(void *type, void *data) { return (data); @@ -438,16 +437,50 @@ return (0); } -eresi_Addr revm_generic_getobj(void *data) +eresi_Addr revm_addr_getobj(void *data) { return (*(eresi_Addr *) data); } +eresi_Addr revm_byte_getobj(void *data) +{ + u_char byte; + + byte = *(u_char *) data; + return ((eresi_Addr) byte); +} + +eresi_Addr revm_short_getobj(void *data) +{ + u_short sh; + + sh = *(u_short *) data; + return ((eresi_Addr) sh); +} + +eresi_Addr revm_int_getobj(void *data) +{ + u_int ent; + + ent = *(u_int *) data; + return ((eresi_Addr) ent); +} + eresi_Addr revm_hash_getobj(void *data) { return ((eresi_Addr) data); } +eresi_Addr revm_long_getobj(void *data) +{ + eresi_Addr addr; + u_long l; + + l = *(long *) data; + addr = (eresi_Addr) l; + return (addr); +} + int revm_byte_setobj(void *data, eresi_Addr value) { unsigned char *byte; @@ -477,6 +510,15 @@ int revm_long_setobj(void *data, eresi_Addr value) { + long *dst; + + dst = (long *) data; + *dst = value; + return (0); +} + +int revm_addr_setobj(void *data, eresi_Addr value) +{ eresi_Addr *dst; dst = (eresi_Addr *) data; diff -Nru eresi-0.8a25/librevm/lang/arith.c eresi-0.0.20110516/librevm/lang/arith.c --- eresi-0.8a25/librevm/lang/arith.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/arith.c 2011-05-16 11:34:11.000000000 +0000 @@ -0,0 +1,290 @@ +/** +* @file librevm/lang/arith.c + * @ingroup lang + * @brief Implementation of arithmetics for expressions + * + * Started on Nov 11 2008 23:39:51 jfv + * $Id: arith.c 1444 2011-01-31 07:41:29Z may $ + */ +#include "revm.h" + + +/** + * Get an expression by its name + * @ingroup lang + */ +static revmexpr_t *revm_ename_get(char **str) +{ + char name[BUFSIZ]; + revmexpr_t *res; + u_int idx; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + bzero(name, BUFSIZ); + for (idx = 0; **str; (*str)++) + switch (**str) + { + case ',': + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid expression name", NULL); + case '+': + case '-': + case '/': + case '%': + case '*': + case '(': + case ')': + case '<': + case '>': + case '|': + goto end; + default: + name[idx++] = **str; + } + + end: + (*str)--; + res = revm_lookup_param(name, 1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); +} + +/** + * Dereference an existing address expression + * @ingroup lang + */ +static revmexpr_t *revm_deref(revmexpr_t *ref) +{ + revmexpr_t *res; + eresi_Addr addr; + char *buff; + eresi_Addr *paddr; + revmobj_t *obj; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!ref || !ref->type || !ref->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid expression to reference", NULL); + switch (ref->type->type) + { + case ASPECT_TYPE_LONG: + case ASPECT_TYPE_CADDR: + case ASPECT_TYPE_DADDR: + addr = (ref->value->immed ? ref->value->immed_val.ent : ref->value->get_obj(ref->value->parent)); + break; + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Dereference on non-pointer expression", NULL); + } + buff = alloca(sizeof(eresi_Addr)); + paddr = (eresi_Addr *) elfsh_readmema(world.curjob->curfile, addr, buff, sizeof(eresi_Addr)); + if (!paddr || (eresi_Addr) paddr == addr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Dereference of non-pointer expression", NULL); + obj = revm_create_ptr(0, *paddr, ref->type->type); + res = revm_expr_create_from_object(obj, revm_tmpvar_create(), 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); +} + + +/** + * Compute an intermediate numerical result + * @ingroup lang + */ +static revmexpr_t *revm_compute_intermediate(revmexpr_t **left, revmexpr_t *res, u_char *op) +{ + u_char quiet; + int ret; + revmexpr_t *final; + revmobj_t *ofinal; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!*left) + { + *left = res; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); + } + if (*op == REVM_OP_UNKNOW) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No operation to do ?", NULL); + quiet = world.state.revm_quiet; + world.state.revm_quiet = 1; + ofinal = revm_create_IMMED((*left)->type->type, 1, 0); + if (!ofinal) + { + world.state.revm_quiet = quiet; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for arithmetic variable", NULL); + } + final = revm_expr_create_from_object(ofinal, revm_tmpvar_create(), 0); + ret = revm_arithmetics(final, *left, res, *op); + world.state.revm_quiet = quiet; + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to compute intermediate result", NULL); + *left = final; + *op = REVM_OP_UNKNOW; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, final); +} + + +/** + * Recursive eager evaluation of arithmetic expressions in ERESI + * @ingroup lang + */ +static revmexpr_t *revm_compute_rec(char **str) +{ + revmexpr_t *res; + revmexpr_t *left; + u_char op; + u_char deref; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + op = REVM_OP_UNKNOW; + deref = 0; + for (left = res = NULL; **str; (*str)++) + switch (**str) + { + + case '(': + ++(*str); + res = revm_compute_rec(str); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid subexpression : remove spaces ?", NULL); + while (deref) + { + res = revm_deref(res); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid dereference", NULL); + deref--; + } + res = revm_compute_intermediate(&left, res, &op); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic", NULL); + break; + + case ')': + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); + + /* Operation ! */ + case '+': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_ADD; + break; + case '-': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_SUB; + break; + case '*': + if (op != REVM_OP_UNKNOW || !left) + { + deref++; + break; + } + op = REVM_OP_MUL; + break; + case '/': + if (op != REVM_OP_UNKNOW || !left || deref) + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_DIV; + break; + case '%': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_MOD; + break; + case '<': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_SHL; + break; + case '>': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_SHR; + break; + case '|': + if (op != REVM_OP_UNKNOW || !left || deref) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic syntax", NULL); + op = REVM_OP_OR; + break; + + /* Maybe we found the beginning of a variable/constant/etc name */ + default: + res = revm_ename_get(str); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown expression name", NULL); + while (deref) + { + res = revm_deref(res); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid dereference", NULL); + deref--; + } + res = revm_compute_intermediate(&left, res, &op); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid arithmetic", NULL); + break; + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); +} + + + +/** Eager evaluation of arithmetic expressions in ERESI */ +revmexpr_t *revm_compute(char *str) +{ + int open; + int close; + char *back; + revmexpr_t *res; + u_int nbr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* First round is just a quick sanity check */ + nbr = open = close = 0; + for (back = str; *back; back++) + switch (*back) + { + case '(': + nbr++; + open++; + break; + case ')': + if (!nbr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid closing parenthesis", NULL); + nbr--; + close++; + break; + default: + break; + } + if (open != close) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parenthesing in expression : remove spaces ?", NULL); + + /* This will make the real job */ + res = revm_compute_rec(&str); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid numerical expression : remove spaces ?", NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, res); +} diff -Nru eresi-0.8a25/librevm/lang/convert.c eresi-0.0.20110516/librevm/lang/convert.c --- eresi-0.8a25/librevm/lang/convert.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/convert.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,6 +1,6 @@ /** -** @file objects.c -** @ingroup librevm_lang +* @file librevm/lang/convert.c +** @ingroup lang ** @brief The implementation of the Lazy Abstract Type System (LATS). ** ** It is the first rewrite of the type-system, in order to @@ -20,7 +20,7 @@ ** Started on Tue Feb 08 12:21:12 2005 jfv ** ** -** $Id: convert.c,v 1.8 2007-12-06 05:11:58 may Exp $ +** $Id: convert.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "revm.h" @@ -43,7 +43,7 @@ { case ASPECT_TYPE_BYTE: val8 = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%02hhu", val8); + snprintf(tmp, sizeof(tmp), "%hhu", val8); obj->immed_val.byte = 0; obj->immed_val.str = strdup(tmp); @@ -54,7 +54,7 @@ break; case ASPECT_TYPE_SHORT: val16 = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%04hu", val16); + snprintf(tmp, sizeof(tmp), "%hu", val16); obj->immed_val.half = 0; obj->immed_val.str = strdup(tmp); @@ -65,7 +65,7 @@ break; case ASPECT_TYPE_INT: val32 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%08u", val32); + snprintf(tmp, sizeof(tmp), "%u", val32); obj->immed_val.word = 0; obj->immed_val.str = strdup(tmp); diff -Nru eresi-0.8a25/librevm/lang/expressions.c eresi-0.0.20110516/librevm/lang/expressions.c --- eresi-0.8a25/librevm/lang/expressions.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/expressions.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,16 +1,18 @@ -/* -** @file expressions.c -** @ingroup librevm_lang -** @brief Implementation of scripting declarations for meta-language variables. -** -** Started on Jun 23 2007 23:39:51 jfv -** $Id: expressions.c,v 1.21 2007-12-09 23:00:18 may Exp $ -*/ +/** + * @file librevm/lang/expressions.c + * @ingroup lang + * @brief Implementation of scripting declarations for meta-language variables. + * + * Started on Jun 23 2007 23:39:51 jfv + * $Id: expressions.c 1444 2011-01-31 07:41:29Z may $ + */ + #include "revm.h" /** Get the real value of the parameter string for further revmobj initialization */ /** This function set the label and strval fields of the newly created revmexpr_t */ +/* FIXME: does not return correct type name if there are trailing whitespaces */ static revmexpr_t *revm_expr_read(char **datavalue) { revmexpr_t *expr; @@ -101,7 +103,7 @@ fprintf(stderr, " [D] NEW REVMEXPR = %s ::: %s \n", expr->label, expr->strval); #endif - + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); } @@ -166,7 +168,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to read expression value", NULL); - /* If we are at the root expression, type might have been implicit */ + /* If we are at the root expression and that type was explicitly given, perform type checking */ if (toplevel && newexpr->label) { @@ -186,58 +188,23 @@ toplevel = 0; continue; } + + /* Implicit type for this expression -- no type checking */ else if (!curexpr && !newexpr->label) { toplevel = 0; datavalue = newexpr->strval; - + #if __DEBUG_EXPRS_MORE__ fprintf(stderr, " [D] No explicit top-level type, continuing with datavalue = %s \n", datavalue); #endif - + continue; } else toplevel = 0; - /* If the substructure is initialized with the value of another expression, no need to - do any additional read, init or inform on the current field */ - if (*newexpr->strval == REVM_VAR_PREFIX) - { - expr = revm_expr_get(newexpr->strval); - if (!expr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get root field or type name", NULL); - } - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] FOUND EXISTING INITIAL REVMEXPR = %s :: %s (doing copy) \n", - expr->label, expr->strval); -#endif - - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, ".%s", newexpr->label); - newexpr = revm_expr_copy(expr, recpath, 1); - bzero(recpath + pathsize, len); - if (!newexpr) - { - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy existing initial subexpression", NULL); - } - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] COPIED EXISTING INITIAL REVMEXPR = %s :: %s (new name) \n", - newexpr->label, newexpr->strval); -#endif - - goto loopend; - } - - /* Else we check if the field has children */ childtype = aspect_type_get_child(curtype, newexpr->label); if (!childtype) { @@ -247,132 +214,169 @@ "Invalid child structure for variable", NULL); } newexpr->type = childtype; - + /* Duplicate names cause they are on the stack now */ newexpr->label = (char *) strdup(newexpr->label); newexpr->strval = (char *) strdup(newexpr->strval); - + /* Non-terminal case : we will need to recurse */ if (childtype->childs && !childtype->dimnbr) - { + { + + /* If the substructure is initialized with the value of another expression, no need to + do any additional read, init or inform on the current field */ + if (*newexpr->strval == REVM_VAR_PREFIX) + { + expr = revm_expr_get(newexpr->strval); + if (!expr) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); + pathsize = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get root field or type name", NULL); + } + +#if __DEBUG_EXPRS__ + fprintf(stderr, " [D] FOUND EXISTING INITIAL REVMEXPR = %s :: %s (doing copy) \n", + expr->label, expr->strval); +#endif + + len = snprintf(recpath + pathsize, BUFSIZ - pathsize, ".%s", newexpr->label); + newexpr = revm_expr_copy(expr, recpath, 1); + bzero(recpath + pathsize, len); + if (!newexpr) + { + pathsize = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to copy existing initial subexpression", NULL); + } + +#if __DEBUG_EXPRS__ + fprintf(stderr, " [D] COPIED EXISTING INITIAL REVMEXPR = %s :: %s (new name) \n", + newexpr->label, newexpr->strval); +#endif + + goto loopend; + } + /* No initial variable value, initialize with immediates */ #if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] NOW RECORD field, recursing ! \n"); + fprintf(stderr, " [D] RECORD field -- recursing ! \n"); #endif - - childata = (char *) srcdata + childtype->off; - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, - ".%s", childtype->fieldname); - revm_inform_type_addr(childtype->name, recpath, - (eresi_Addr) childata, newexpr, 0, 0); - pathsize += len; - - /* Insert child where necessary */ - if (!revm_expr_init(recpath, newexpr, childtype, - childata, newexpr->strval)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid child tree for variable", NULL); - } - pathsize -= len; - bzero(pathbuf + pathsize, len); - } - - /* Terminal case : no recursion */ - else - { - + childata = (char *) srcdata + childtype->off; + len = snprintf(recpath + pathsize, BUFSIZ - pathsize, + ".%s", childtype->fieldname); + revm_inform_type_addr(childtype->name, recpath, + (eresi_Addr) childata, newexpr, 0, 0); + pathsize += len; + + /* Insert child where necessary */ + if (!revm_expr_init(recpath, newexpr, childtype, + childata, newexpr->strval)) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); + pathsize = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid child tree for variable", NULL); + } + + pathsize -= len; + bzero(pathbuf + pathsize, len); + } + + /* Terminal case : no recursion */ + else + { + #if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] NOW Terminal field, setting its value\n"); + fprintf(stderr, " [D] NOW Terminal field, setting its value\n"); #endif - - /* Handle RAW terminal field */ - if (childtype->type == ASPECT_TYPE_RAW) - { - //FIXME: Call hexa converter curval.datastr and set field - fprintf(stderr, " [E] Raw object initialization yet unsupported.\n"); - continue; - } - - /* Lookup scalar value and assign it to the field */ - newexpr->value = revm_object_lookup_real(curtype, recpath, - childtype->fieldname, 0); - curdata = revm_lookup_param(newexpr->strval); - if (!newexpr->value || !curdata) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup src or dst object", NULL); - } - - /* Convert source data to recipient type and set it */ - if (newexpr->type->type != curdata->type->type) - revm_convert_object(curdata, newexpr->type->type); - if (revm_object_set(newexpr, curdata) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to set destination object", NULL); - } - - /* Destroy the temporary variable we have created for the right-hand-side value */ - if (revm_variable_istemp(curdata)) - revm_expr_destroy(curdata->label); - - /* Handle terminal Array fields */ - if (childtype->dimnbr && childtype->elemnbr) - { - //FIXME: Use child->elemnbr[idx] foreach size of dim (Use previous code in loop) - fprintf(stderr, - " [E] Arrays objects initialization unsupported\n"); - continue; - } - - /* Inform the runtime system about this terminal field */ - childata = (char *) srcdata + childtype->off; - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, - ".%s", childtype->fieldname); - revm_inform_type_addr(childtype->name, recpath, - (eresi_Addr) childata, newexpr, 0, 0); - bzero(recpath + pathsize, len); - } - - /* Link next field of current structure */ + + /* Handle RAW terminal field */ + if (childtype->type == ASPECT_TYPE_RAW) + { + //FIXME: Call hexa converter curval.datastr and set field + fprintf(stderr, " [E] Raw object initialization yet unsupported.\n"); + continue; + } + + /* Lookup scalar value and assign it to the field */ + newexpr->value = revm_object_lookup_real(curtype, recpath, + childtype->fieldname, 0); + curdata = revm_compute(newexpr->strval); + if (!newexpr->value || !curdata) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); + pathsize = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup src or dst object", NULL); + } + + /* Convert source data to recipient type and set it */ + if (newexpr->type->type != curdata->type->type) + revm_convert_object(curdata, newexpr->type->type); + if (revm_object_set(newexpr, curdata) < 0) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); + pathsize = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to set destination object", NULL); + } + + /* Destroy the temporary variable we have created for the right-hand-side value */ + if (revm_variable_istemp(curdata)) + revm_expr_destroy_by_name(curdata->label); + + /* Handle terminal Array fields */ + if (childtype->dimnbr && childtype->elemnbr) + { + //FIXME: Use child->elemnbr[idx] foreach size of dim (Use previous code in loop) + fprintf(stderr, + " [E] Arrays objects initialization unsupported\n"); + continue; + } + + /* Inform the runtime system about this terminal field */ + childata = (char *) srcdata + childtype->off; + len = snprintf(recpath + pathsize, BUFSIZ - pathsize, + ".%s", childtype->fieldname); + revm_inform_type_addr(childtype->name, recpath, + (eresi_Addr) childata, newexpr, 0, 0); + bzero(recpath + pathsize, len); + } + + /* Link next field of current structure */ loopend: - newexpr->parent = curexpr; - if (curexpr) - { - rootexpr = curexpr; - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - { - curexpr->childs = newexpr; - prevexpr = newexpr; - } - } - else - { - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - rootexpr = prevexpr = newexpr; - } - - + newexpr->parent = curexpr; + if (curexpr) + { + rootexpr = curexpr; + if (prevexpr) + { + prevexpr->next = newexpr; + prevexpr = newexpr; + } + else + { + curexpr->childs = newexpr; + prevexpr = newexpr; + } + } + else + { + if (prevexpr) + { + prevexpr->next = newexpr; + prevexpr = newexpr; + } + else + rootexpr = prevexpr = newexpr; + } + + } - + /* Return success or error */ if (!rootexpr) { @@ -456,7 +460,8 @@ /* Get (and optionally print) the tree of an expression */ -static int revm_expr_printrec(revmexpr_t *expr, u_int taboff, u_int typeoff, u_int iter) +static int revm_expr_printrec(revmexpr_t *expr, u_int taboff, + u_int typeoff, u_int iter, u_char quiet) { aspectype_t *curtype; char buf[BUFSIZ]; @@ -464,9 +469,9 @@ char *size; char *typename; char offset[128]; - int idx; int sz; char *pad, *pad2; + int newtaboff; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); for (; expr; expr = (iter ? expr->next : NULL)) @@ -479,13 +484,13 @@ /* Some printing header */ revm_endline(); len = snprintf(buf, sizeof(buf), "%s%*s %*s", - (curtype->isptr ? revm_colorwarn(" *") : ""), - (iter ? 18 - (curtype->isptr * 4) : 0), - revm_colorfieldstr(typename), - (iter ? 18 : 0), - revm_colortypestr_fmt("%10s", expr->label)); + (curtype->isptr ? (quiet ? " *" : revm_colorwarn(" *")) : ""), + (iter && !quiet ? 18 - (curtype->isptr * 4) : 0), + (quiet ? "" : revm_colorfieldstr(typename)), + (iter && !quiet ? 18 : 0), + (quiet ? expr->label : revm_colortypestr_fmt("%10s", expr->label))); - sz = (taboff < 21 ? 0 : len - revm_color_size(buf) - 20); + sz = (taboff < 21 ? 0 : (len - revm_color_size(buf) - 20)); pad = alloca(taboff + sz + 1); memset(pad, ' ', taboff + sz); pad[taboff + sz] = 0x00; @@ -494,15 +499,24 @@ if (expr->childs) { revm_output(buf); - revm_output(revm_colorwarn(" {")); + if (!quiet) + revm_output(revm_colorwarn(" {")); + else + revm_output("("); revm_endline(); - revm_expr_printrec(expr->childs, - taboff + len - revm_color_size(buf) - 7, - typeoff, iter); - revm_output(revm_colorwarn("}")); + newtaboff = taboff + len - revm_color_size(buf) - 7; + revm_expr_printrec(expr->childs, (newtaboff < 0 ? 1 : newtaboff), + typeoff, iter, quiet); + if (!quiet) + revm_output(revm_colorwarn("}")); + else + revm_output(")"); if (expr->next) { - revm_output(",\n"); + if (quiet) + revm_output(","); + else + revm_output(",\n"); pad2 = alloca(taboff + 1); memset(pad2, ' ', taboff); pad2[taboff] = 0x00; @@ -512,7 +526,6 @@ /* Do not add offset if we are in union */ if (expr->next && expr->next->type->off != curtype->off) typeoff += (expr->type->isptr ? 4 : curtype->size); - continue; } @@ -529,6 +542,7 @@ // FIXME-XXX: Print up 10 elements of array ... else if (curtype->dimnbr && curtype->elemnbr) { + /* for (sz = idx = 0; idx < curtype->dimnbr; idx++) sz += 40; size = alloca(sz + 50); @@ -537,7 +551,9 @@ revm_colorwarn("["), revm_colornumber("%u", curtype->elemnbr[idx]), revm_colorwarn("]")); - sz += sprintf(size + sz, "%s", revm_colorwarn(" = {...} ")); + */ + size = alloca(50); + sprintf(size, "%s", revm_colorwarn(" = ")); } else { @@ -554,10 +570,15 @@ /* Next field ! Print offset .. */ if (iter && expr->next) { - snprintf(offset, sizeof(offset), "@ off(%s)", revm_colornumber("%u", typeoff)); - revm_output(offset); - revm_output(revm_colorwarn(",\n")); - revm_output(pad); + if (!quiet) + { + snprintf(offset, sizeof(offset), "@ off(%s)", revm_colornumber("%u", typeoff)); + revm_output(offset); + revm_output(revm_colorwarn(",\n")); + revm_output(pad); + } + else + revm_output(", "); /* Do not add size if we are in a union */ if (expr->next->type->off != curtype->off) @@ -674,6 +695,12 @@ /* First copy the data */ type = source->type; + +#if __DEBUG_EXPRS__ + fprintf(stderr, " [D] Allocating copied expression data of size %u type %s to name %s (%s)\n", + type->size, type->name, dstname, (isfield ? "field" : "struct")); +#endif + XALLOC(__FILE__, __FUNCTION__, __LINE__, copydata, type->size, NULL); /* Constants are not annotated, we might not want to do anything here */ @@ -734,8 +761,10 @@ /* Failure: no value or complex type for source expr ? */ else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy expression in impossible default case", NULL); + { + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to copy invalid expression (childs = NULL, value = NULL)", NULL); + } /* Return error or success */ if (ret < 0) @@ -746,16 +775,22 @@ /* Create an expression from an object */ -revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name) +revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name, u_char force) { revmexpr_t *dest; aspectype_t *type; void *data; - + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dest = hash_get(&exprs_hash, name); - if (dest) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); + if (!copyme) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid input parameter", NULL); + if (force) + { + dest = revm_expr_get(name); + if (dest) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); + } /* Create a new temporary variable name if necessary */ if (*name != REVM_VAR_PREFIX || @@ -782,7 +817,8 @@ "Unable to create expression from complex object", NULL); } - hash_add(&exprs_hash , (char *) strdup(name), (void *) dest); + hash_add(&world.curjob->recur[world.curjob->curscope].exprs, + (char *) strdup(name), (void *) dest); #if __DEBUG_EXPRS__ fprintf(stderr, " [D] Create_Expr_From_Object %s added with type = %s \n", @@ -791,70 +827,110 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); } - + /* Print an annotated expression */ -int revm_expr_print(char *pathname) +int revm_expr_print(revmexpr_t *expr, u_char quiet) { - revmexpr_t *expr; int ret; char buf[BUFSIZ]; int iter; + int uniq; aspectype_t *type; + char *name; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!pathname || *pathname != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - expr = hash_get(&exprs_hash, pathname); if (!expr || !expr->type) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown expression name", -1); + "Invalid NULL parameters", -1); /* Make sure we only print the subrecord if requested */ type = expr->type; + name = expr->label; + uniq = 0; if (expr->childs) { expr = expr->childs; iter = 1; + uniq = 1; } else iter = (aspect_type_simple(expr->type->type) ? 0 : 1); /* If we are printing a simple type or a subtype expression, we need to print a top level */ - if (type->next || (type->childs && type->childs->next)) + if (uniq || type->next || (type->childs && type->childs->next)) { - snprintf(buf, BUFSIZ, " %s %s \t %s", - revm_colorfunction(type->name), - revm_colorfunction(pathname), revm_colorwarn("= {")); + if (!quiet) + snprintf(buf, BUFSIZ, " %s %s \t %s", + revm_colorfunction(type->name), + revm_colorfunction(name), revm_colorwarn("= {")); + else + snprintf(buf, BUFSIZ, " %s(", + revm_colorfunction(type->name)); revm_output(buf); revm_endline(); } - revm_expr_printrec(expr, (!iter || !expr->next ? strlen(pathname) + 6 : 1), 0, iter); - if (type->next || (type->childs && type->childs->next)) + + ret = revm_expr_printrec(expr, (!iter || !expr->next ? strlen(name) + 6 : 1), 0, iter, quiet); + + if (!quiet && (uniq || type->next || (type->childs && type->childs->next))) revm_output(revm_colorwarn("}")); + else if (quiet) + revm_output(")\\l"); + revm_endline(); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } +/* Print an annotated expression */ +int revm_expr_print_by_name(char *pathname, u_char quiet) +{ + revmexpr_t *expr; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!pathname || *pathname != REVM_VAR_PREFIX) + { + fprintf(stderr, "FAILED EXPR NAME %s:\n", pathname); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid name for expression", -1); + } + expr = revm_expr_get(pathname); + if (!expr || !expr->type) + { + fprintf(stderr, "FAILED EXPR %p TYPE \n", expr); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown expression name", -1); + } + ret = revm_expr_print(expr, quiet); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} -/* Get an expression from its name */ +/** Get an expression from its name */ revmexpr_t *revm_expr_get(char *pathname) { + int index; + hash_t *curhash; revmexpr_t *expr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!pathname || *pathname != REVM_VAR_PREFIX) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid name for expression", NULL); - expr = hash_get(&exprs_hash, pathname); - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid expression name", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + + for (index = world.curjob->curscope; index >= 0; index--) + { + curhash = &world.curjob->recur[index].exprs; + expr = hash_get(curhash, pathname); + if (expr) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + } + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid expression name", NULL); } -/* Set an expression to the value of another (only if compatible) */ +/** Set an expression to the value of another (only if compatible) */ int revm_expr_set_by_name(char *dest, char *source) { revmexpr_t *adst; @@ -897,13 +973,13 @@ adst = adst->childs; /* Necessary for assignment of scalar values */ - if (adst->value && asrc->value && !asrc->next) + if (adst->value && asrc->value && (!asrc->next || !adst->next)) { /* See if object conversion is necessary and/or possible */ - if (revm_nextconds_atomics(adst, asrc) < 0) + if ((ret = revm_nextconds_atomics(adst, asrc)) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to set scalar variable", -1); - if (revm_object_set(adst, asrc) < 0) + if ((ret = revm_object_set(adst, asrc)) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to set scalar variable", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -968,7 +1044,7 @@ /* Necessary for comparison with constants without a tree/field structure */ if (orig->value && candid->value && !orig->next && !candid->next) { - if (revm_object_compare(orig, candid, val) < 0) + if ((ret = revm_object_compare(orig, candid, val)) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid name for expression", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -989,8 +1065,11 @@ } /* Return result */ + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compare expressions", ret); *val = ret; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -1035,7 +1114,7 @@ /* For simple objects */ if (orig->value && candid->value && !orig->next && !candid->next) { - if (revm_object_compare(orig, candid, val) < 0) + if ((ret = revm_object_compare(orig, candid, val)) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid name for expression", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -1113,7 +1192,8 @@ revm_inform_type_addr(datatype->name, realname, (eresi_Addr) data, expr, 0, 0); #if __DEBUG_EXPRS__ - revm_expr_print(expr->label); + revm_expr_print_by_name(expr->label, 0); + revm_output("\n"); #endif PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); @@ -1129,7 +1209,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, sizeof(revmexpr_t), NULL); if (value) - obj = revm_lookup_immed(value); + obj = revm_lookup_immed(value, 1); else obj = revm_object_lookup_real(datatype, name, NULL, 0); if (!obj) @@ -1145,7 +1225,8 @@ expr->strval = (value ? strdup(value) : NULL); expr->value = obj; expr->label = name; - hash_add(&exprs_hash , (char *) strdup(name), (void *) expr); + hash_add(&world.curjob->recur[world.curjob->curscope].exprs, + (char *) strdup(name), (void *) expr); #if __DEBUG_EXPRS__ fprintf(stderr, " [D] SimpleExpr %s added with type = %s \n", @@ -1163,11 +1244,16 @@ char *typename; u_int typenamelen; char *curexprvalue; + revmexpr_t *expr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!exprvalue) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", NULL); + expr = revm_expr_get(exprvalue); + if (expr) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr->type); + type = NULL; for (curexprvalue = exprvalue, typenamelen = 0; *curexprvalue != '('; typenamelen++) curexprvalue++; @@ -1182,52 +1268,201 @@ } - -/* Destroy an expression and remove it from the hash table */ -int revm_expr_destroy(char *e) +/** Unlink an expression */ +static int revm_expr_unlink(revmexpr_t *expr, u_char exprfree, u_char datafree) { - revmexpr_t *expr; + revmexpr_t *prevexpr; revmexpr_t *child; + revmexpr_t *next; char newname[BUFSIZ]; hash_t *thash; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - -#if __DEBUG_EXPRS__ - printf("\n [D] DestroyExpr %s \n", e); -#endif - - expr = hash_get(&exprs_hash, e); if (!expr) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown expr parameter", -1); - hash_del(&exprs_hash, e); - + "Invalid NULL parameter", -1); + + /* Update the global type hashes too by recovering a previous expression of that name, if any */ if (expr->type) { snprintf(newname, sizeof(newname), "type_%s", expr->type->name); thash = hash_find(newname); - if (thash) - hash_del(thash, e); + if (!thash) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find hash table for this expression type", -1); + hash_del(thash, expr->label); + prevexpr = revm_expr_get(expr->label); + if (prevexpr) + { +#if __DEBUG_EXPRS__ + fprintf(stderr, "\n [D] RESTORED EXPR %s (type %s) after UNSHADOWING UNLINK\n", + expr->label, expr->type->name); +#endif + hash_set(thash, expr->label, prevexpr->annot); + } + } + + /* If the expression in present in some hash table, we dont free it */ + if (expr->annot && expr->annot->inhash) + { +#if __DEBUG_EXPRS__ + fprintf(stderr, " [D] NOT FREED EXPR %s because still in hash table \n", expr->label); +#endif + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - // FIXME: fault when calling destroy_object - // An object was not copied/reallocated correctly somewhere + /* Free the object */ if (expr->value) - //revm_destroy_object(expr->value); - XFREE(__FILE__, __FUNCTION__, __LINE__, expr->value); + revm_destroy_object(expr->value, datafree); - for (child = expr->childs; child; child = child->next) + for (child = expr->childs; child; child = next) { - snprintf(newname, sizeof(newname), "%s.%s", e, child->label); - if (revm_expr_destroy(newname) < 0) + next = child->next; + snprintf(newname, sizeof(newname), "%s.%s", expr->label, child->label); + if (revm_expr_unlink_by_name(newname, exprfree, datafree) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Failed to destroy child expression", -1); } - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); + if (exprfree) + { + +#if __DEBUG_EXPRS_MORE__ + fprintf(stderr, "\n [D] UNLINK EXPR %s (exprfree = %hhu) \n", expr->label, exprfree); +#endif + + XFREE(__FILE__, __FUNCTION__, __LINE__, expr); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + + +/* Destroy an expression and remove it from the hash table */ +int revm_expr_unlink_by_name(char *e, u_char exprfree, u_char datafree) +{ + revmexpr_t *expr; + int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!e) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + + /* Find in which scope it was defined, and unregister it, possibly unshadowing previous variables */ + for (index = world.curjob->curscope; index >= 0; index--) + { + expr = hash_get(&world.curjob->recur[index].exprs, e); + if (expr) + { + hash_del(&world.curjob->recur[index].exprs, e); + break; + } + } + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown expression name", -1); + if (revm_expr_unlink(expr, exprfree, datafree) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to unlink expression by name", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Destroy an expression and remove it from the hash table : front end function */ +int revm_expr_destroy_by_name(char *ename) +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!ename || *ename != REVM_VAR_PREFIX) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + ret = revm_expr_unlink_by_name(ename, 1, 1); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to destroy expression by name", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Destroy an expression and remove it from the hash table : front end function */ +int revm_expr_destroy(revmexpr_t *expr) +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + ret = revm_expr_unlink(expr, 1, 1); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to destroy expression", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Remove expression from the hash table without destruction : front end function */ +int revm_expr_hide(char *ename) +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!ename || *ename != REVM_VAR_PREFIX) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + ret = revm_expr_unlink_by_name(ename, 0, 0); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to hide expression", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Remove expression from the hash table without data destruction : front end function */ +int revm_expr_clean(char *ename) +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!ename || *ename != REVM_VAR_PREFIX) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + ret = revm_expr_unlink_by_name(ename, 1, 0); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to clean expression", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* This function lookup an expression from an object id */ +revmexpr_t *revm_expr_lookup(u_int oid) +{ + revmexpr_t *expr; + container_t *cont; + char logbuf[BUFSIZ]; + aspectype_t *type; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (oid >= world.mjr_session.cur->next_id) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid id for container", NULL); + cont = world.mjr_session.cur->reg_containers[oid]; + type = aspect_type_get_by_id(cont->type); + if (!type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for container", NULL); + snprintf(logbuf, sizeof(logbuf), "%c%s_"AFMT, + REVM_VAR_PREFIX, type->name, *(eresi_Addr *) cont->data); + expr = revm_expr_get(logbuf); + if (!expr) + { + fprintf(stderr, "Name Expr %s \n", logbuf); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid name for expression", NULL); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); +} diff -Nru eresi-0.8a25/librevm/lang/grammar.c eresi-0.0.20110516/librevm/lang/grammar.c --- eresi-0.8a25/librevm/lang/grammar.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/grammar.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,17 +1,17 @@ /** - * @file grammar.c - * @ingroup librevm_lang + * @file librevm/lang/grammar.c + * @ingroup lang * @brief We dont use bison and have our own parser generator. * * Started on Sun Feb 9 22:57:58 2003 jfv - * $Id: grammar.c,v 1.21 2008-02-16 12:32:27 thor Exp $ + * $Id: grammar.c 1410 2010-05-14 13:45:20Z thorkill $ * */ #include "revm.h" /** - * @brief Get a va_list of parameters + * @brief Get a va_list of parameters */ static int parse_lookup_varlist(char *param, char *fmt, ...) { @@ -25,13 +25,13 @@ } -/** - * @brief Parse a vector access +/** + * @brief Parse a vector access */ revmobj_t *parse_vector(char *param, char *fmt) { u_int size; - char index[ELFSH_MEANING]; + char index[ERESI_MEANING]; vector_t *cur; int dimnbr; unsigned int *dims; @@ -56,10 +56,10 @@ /* Early sanity checks */ if (!cur) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", NULL); + "Unknown requested vector", NULL); if (revm_vector_bad_dims(cur, dims, dimnbr)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", NULL); + "Requested vector with bad dimensions", NULL); /* Get a pointer on the desired entry of the vector */ XALLOC(__FILE__, __FUNCTION__, __LINE__,ret, sizeof(revmobj_t), NULL); @@ -67,7 +67,7 @@ ret->otype = aspect_type_get_by_id(cur->type); ret->perm = 1; ret->immed = 0; - ret->get_obj = (void *) revm_generic_getobj; + ret->get_obj = (void *) revm_long_getobj; ret->set_obj = (void *) revm_long_setobj; /* Success */ @@ -75,88 +75,51 @@ } -/** - * @brief Parse a hash access +/** + * @brief Parse a hash access */ revmobj_t *parse_hash(char *param, char *fmt) { u_int size; - char index[ELFSH_MEANING]; + char index[ERESI_MEANING]; hash_t *hash; revmobj_t *ret; char *entryname; char *hashname; void *ptr; - revmexpr_t *expr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); size = parse_lookup_varlist(param, fmt, index); if (size != 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Parser handling failed", NULL); - + /* Get hash table and entry */ entryname = strchr(index, ':'); if (entryname) *entryname++ = 0x00; /* Resolve hash name without messing with variable type */ - expr = revm_expr_get(index); - if (expr) - { - if (!expr->type || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - ret = revm_copy_object(expr->value); - if (revm_convert_object(expr, ASPECT_TYPE_STR) < 0) - { - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", NULL); - } - hashname = strdup(expr->value->immed_val.str); - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - } - else - hashname = revm_lookup_string(index); - + hashname = revm_lookup_key(index); + if (!hashname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown hash table", NULL); + /* Resolve entry name without messing with variable type */ if (entryname) { - expr = revm_expr_get(entryname); - if (expr) - { - if (!expr->type || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - ret = revm_copy_object(expr->value); - if (revm_convert_object(expr, ASPECT_TYPE_STR) < 0) - { - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", NULL); - } - entryname = strdup(expr->value->immed_val.str); - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - } - else - entryname = revm_lookup_string(entryname); + entryname = revm_lookup_key(entryname); + if (!entryname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown hash table entry", NULL); } /* In case the hash table does not exist, create it empty */ hash = hash_find(hashname); if (!hash) { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - hash, sizeof(hash_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, + hash, sizeof(hash_t), NULL); hash_init(hash, strdup(hashname), 7, ASPECT_TYPE_UNKNOW); } @@ -182,13 +145,13 @@ -/** - * @brief Parse a hash access +/** + * @brief Parse a hash access */ revmobj_t *parse_list(char *param, char *fmt) { u_int size; - char index[ELFSH_MEANING]; + char index[ERESI_MEANING]; list_t *list; revmobj_t *ret; char *entryname; @@ -201,19 +164,31 @@ if (size != 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Parser handling failed", NULL); - + /* Get hash table and entry */ entryname = strchr(index, ':'); if (entryname) *entryname++ = 0x00; - listname = strdup(index); + listname = revm_lookup_key(index); + if (!listname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown list", NULL); + + /* Resolve entry name without messing with variable type */ + if (entryname) + { + entryname = revm_lookup_key(entryname); + if (!entryname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown list element", NULL); + } /* In case the hash table does not exist, create it empty */ list = elist_find(listname); if (!list) { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - list, sizeof(list_t), NULL); + XALLOC(__FILE__, __FUNCTION__, __LINE__, + list, sizeof(list_t), NULL); elist_init(list, listname, ASPECT_TYPE_UNKNOW); } @@ -236,13 +211,9 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } - - - - /** - * @brief Lookup a parameter with 3 fields, 3rd field beeing an index - * Used by GOT, CTORS, DTORS + * @brief Lookup a parameter with 3 fields, 3rd field beeing an index + * Used by GOT, CTORS, DTORS */ revmobj_t *parse_lookup3_index(char *param, char *fmt, u_int sep) { @@ -252,9 +223,9 @@ u_int size; u_int real_index; revmobj_t *pobj; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; + char obj[ERESI_MEANING]; + char L1field[ERESI_MEANING]; + char index[ERESI_MEANING]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (sep != 1) @@ -262,92 +233,89 @@ real_index = 0; - // Check if this handler is the correct one + // Check if this handler is the correct one size = parse_lookup_varlist(param, fmt, obj, L1field, index); if (size != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parser handling failed", NULL); + // Let's ask the hash table for the current working file robj = revm_lookup_file(obj); if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested file object", NULL); - // Then, we ask the Level 1 object + // Then, we ask the Level 1 object l1 = hash_get(&L1_hash, L1field); if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", NULL); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested L1 object", NULL); + else if (l1->get_entptr == NULL || l1->get_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bad object path", NULL); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Bad object path", NULL); + pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); pobj->immed = 0; - // Lookup object + // Lookup object o1 = l1->get_obj(robj, &size); - // Lookup index + // Lookup index real_index = revm_lookup_index(index); - - //printf("GOT real_index = " XFMT " unsigned: " UFMT " signed: " DFMT "\n", + + //printf("GOT real_index = " XFMT " unsigned: " UFMT " signed: " DFMT "\n", // real_index, real_index, real_index); if (((int) real_index) < 0) { - + if (l1->get_obj_nam == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid L1 index", NULL); else - { - - //printf("looking up get_obj_name in GOT ! \n"); - - pobj->parent = l1->get_obj_nam(robj, index); - - /* - printf("GOT pobjparent = %p (with name = %s) \n", pobj->parent, index); - printf("GOT sect data = %p (GOT name = %s) \n", - ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->data, - ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->name); - */ - - if (pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No entry by that name", NULL); - } + { + + //printf("looking up get_obj_name in GOT ! \n"); + + pobj->parent = l1->get_obj_nam(robj, index); + + /* + printf("GOT pobjparent = %p (with name = %s) \n", pobj->parent, index); + printf("GOT sect data = %p (GOT name = %s) \n", + ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->data, + ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->name); + */ + + if (pobj->parent == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No entry by that name", NULL); + } } - // Do index sanity + // Do index sanity if (pobj->parent == NULL) { if (size <= real_index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Index too big", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Index too big", NULL); pobj->parent = l1->get_entptr(o1, real_index); } - // Finally we fill the intermediate object format for the guessed object + // Finally we fill the intermediate object format for the guessed object pobj->get_obj = (void *) l1->get_entval; pobj->set_obj = (void *) l1->set_entval; pobj->otype = aspect_type_get_by_id(ASPECT_TYPE_CADDR); pobj = revm_check_object(pobj); if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid REVM object", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); } - - - /** - * Lookup a parameter with 3 fields, all fields beeing non indexed - * Only used by ELF header 'til now + * Lookup a parameter with 3 fields, all fields beeing non indexed + * Only used by ELF header 'til now */ revmobj_t *parse_lookup3(char *param, char *fmt, u_int sep) { @@ -356,47 +324,47 @@ void *robj; revmobj_t *pobj; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; + char obj[ERESI_MEANING]; + char L1field[ERESI_MEANING]; + char L2field[ERESI_MEANING]; int ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (sep != 2) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - // Check if this handler is the correct one + // Check if this handler is the correct one ret = parse_lookup_varlist(param, fmt, obj, L1field, L2field); if (ret != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parser handling failed", NULL); - // Let's ask the hash table for the current working file + // Let's ask the hash table for the current working file robj = revm_lookup_file(obj); if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested file object", + NULL); - // Then, we ask the Level 1 object + // Then, we ask the Level 1 object l1 = hash_get(&L1_hash, L1field); if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested L1 object", + NULL); else if (l1->get_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object path", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid object path", + NULL); - // Then the Level 2 object + // Then the Level 2 object l2 = hash_get(l1->l2list, L2field); if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L2 object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested L2 object", + NULL); - // Finally we fill the intermediate object format for the guessed object + // Finally we fill the intermediate object format for the guessed object pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); pobj->immed = 0; pobj->get_obj = (void *) l2->get_obj; @@ -406,16 +374,13 @@ pobj = revm_check_object(pobj); if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid REVM object", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); } - - - -/** - * Lookup a parameter with 4 fields, 3rd field beeing an index +/** + * Lookup a parameter with 4 fields, 3rd field beeing an index * Used by SHT, PHT, SYMTAB, DYNSYM , Sections, .dynamic * * Here need to add 1.rel[name].{L2fields} lookup @@ -426,16 +391,16 @@ revmL2_t *l2; void *robj; void *o1; - int real_index; + int real_index; int isversion; u_int size; revmobj_t *pobj; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; - char offfield[ELFSH_MEANING]; - char sizelemfield[ELFSH_MEANING]; + char obj[ERESI_MEANING] = {0x00}; + char L1field[ERESI_MEANING] = {0x00}; + char L2field[ERESI_MEANING] = {0x00}; + char index[ERESI_MEANING] = {0x00}; + char offfield[ERESI_MEANING] = {0x00}; + char sizelemfield[ERESI_MEANING] = {0x00}; u_int off; u_int sizelem; int ret; @@ -446,14 +411,14 @@ switch (sep) { case 4: - ret = parse_lookup_varlist(param, fmt, obj, L1field, - index, offfield, sizelemfield, L2field); + ret = parse_lookup_varlist(param, fmt, obj, L1field, + index, offfield, sizelemfield, L2field); sizelem = atoi(sizelemfield); off = atoi(offfield); break; case 3: - ret = parse_lookup_varlist(param, fmt, obj, L1field, - index, offfield, L2field); + ret = parse_lookup_varlist(param, fmt, obj, L1field, + index, offfield, L2field); sizelem = 1; off = atoi(offfield); break; @@ -469,89 +434,89 @@ /* Quick test to see if we matched */ if (ret - 2 != sep) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - + /* Let's ask the hash table for the current working file */ robj = revm_lookup_file(obj); if (NULL == robj) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown file object", - NULL); + NULL); - // Then, we ask the Level 1 object + // Then, we ask the Level 1 object l1 = hash_get(&L1_hash, L1field); if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L1 object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L1 object", + NULL); else if (l1->get_entptr == NULL || l1->get_obj == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incorrect object path", - NULL); + NULL); - // Then the Level 2 object + // Then the Level 2 object l2 = hash_get(l1->l2list, L2field); if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L2 object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L2 object", + NULL); - // Read object + // Read object o1 = l1->get_obj(robj, (void *) &size); if (o1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot read object", - NULL); - + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot read object", + NULL); + pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); pobj->immed = 0; - // Do lookup by index or by name + // Do lookup by index or by name real_index = (int) revm_lookup_index(index); - + #if __DEBUG_LANG__ - printf("LOOKUP4 object index = %s, real_index = %u (signed = %d) \n", - index, real_index, real_index); + printf("LOOKUP4 object index = %s, real_index = %u (signed = %d) \n", + index, real_index, real_index); #endif - // Index error handling + // Index error handling if (real_index < 0) { if (l1->get_obj_nam == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid L1 index", NULL); else - { - pobj->parent = l1->get_obj_nam(robj, index); - if (pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No L1 index by this name", NULL); - } + { + pobj->parent = l1->get_obj_nam(robj, index); + if (pobj->parent == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No L1 index by this name", NULL); + } } - - // Get L2 object by index (or type for dynamic) + + // Get L2 object by index (or type for dynamic) if (pobj->parent == NULL) { if (!strcmp(L1field, "dynamic") && !revm_isnbr(index)) - real_index = elfsh_get_dynent_by_type(robj, o1, real_index); - + real_index = elfsh_get_dynent_by_type(robj, o1, real_index); + isversion = (!strcmp(L1field, "version") || - !strcmp(L1field, "verdef") || - !strcmp(L1field, "verneed")); - + !strcmp(L1field, "verdef") || + !strcmp(L1field, "verneed")); + if (!isversion && size <= real_index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "L1 index too big", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "L1 index too big", NULL); pobj->parent = l1->get_entptr(o1, real_index); if (isversion && pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown L2 object or Invalid L1 index", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown L2 object or Invalid L1 index", + NULL); } - // Finally we fill the intermediate object format for the guessed object + // Finally we fill the intermediate object format for the guessed object pobj->get_obj = (void *) l2->get_obj; pobj->set_obj = (void *) l2->set_obj; pobj->get_name = (void *) l2->get_name; pobj->set_name = (void *) l2->set_name; - // The 2 next fields are used for 'raw' L2 of 'section' L1 + // The 2 next fields are used for 'raw' L2 of 'section' L1 pobj->get_data = (void *) l2->get_data; pobj->set_data = (void *) l2->set_data; @@ -560,20 +525,17 @@ pobj->sizelem = sizelem; pobj->root = robj; - // Error checking + // Error checking pobj = revm_check_object(pobj); if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid REVM object", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); } - - - /** - * Lookup a parameter with 5 fields, 3rd and 5th field beeing indexes - * Used for Relocation tables and GOT tables + * Lookup a parameter with 5 fields, 3rd and 5th field beeing indexes + * Used for Relocation tables and GOT tables */ revmobj_t *parse_lookup5_index(char *param, char *fmt, u_int sep) { @@ -587,11 +549,11 @@ int isversion; revmobj_t *pobj; elfshsect_t *sect; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; - char index2[ELFSH_MEANING]; + char obj[ERESI_MEANING]; + char L1field[ERESI_MEANING]; + char L2field[ERESI_MEANING]; + char index[ERESI_MEANING]; + char index2[ERESI_MEANING]; int ret; #if 0 @@ -602,95 +564,95 @@ if (sep != 2) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - // Check if this handler is the correct one + // Check if this handler is the correct one ret = parse_lookup_varlist(param, fmt, obj, L1field, index, index2, L2field); if (ret != 5) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parser handling failed", NULL); - // Let's ask the hash table for the current working file + // Let's ask the hash table for the current working file robj = revm_lookup_file(obj); if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested file object", + NULL); - // Then, we ask the Level 1 object + // Then, we ask the Level 1 object l1 = hash_get(&L1_hash, L1field); if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested L1 object", NULL); else if (l1->get_entptr == NULL || l1->get_obj_idx == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "This object needs 2 indexes", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "This object needs 2 indexes", NULL); - // Then the Level 2 object + // Then the Level 2 object l2 = hash_get(l1->l2list, L2field); if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L2 object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested L2 object", NULL); else if (l2->get_obj == NULL || l2->set_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Child object is invalid", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Child object is invalid", NULL); - // Not clean .. need to ve virtualized + // Not clean .. need to ve virtualized isversion = (!strcmp(L1field, "version") || - !strcmp(L1field, "verdef") || - !strcmp(L1field, "verneed")); + !strcmp(L1field, "verdef") || + !strcmp(L1field, "verneed")); - // Get indexes + // Get indexes real_index = (int) revm_lookup_index(index); real_index2 = (int) revm_lookup_index(index2); #if 0 - snprintf(logbuf, BUFSIZ - 1, - "[DEBUG_MODEL] Lookup5_index : index(" UFMT ") rindex(" UFMT ") \n", - real_index, real_index2); + snprintf(logbuf, BUFSIZ - 1, + "[DEBUG_MODEL] Lookup5_index : index(" UFMT ") rindex(" UFMT ") \n", + real_index, real_index2); revm_output(logbuf); #endif - // Do index sanity + // Do index sanity o1 = l1->get_obj_idx(robj, real_index, (u_int *) &size); if (!isversion && size <= real_index2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Second index too big", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Second index too big", NULL); if (isversion && o1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); - - // printf("[DEBUG_RELOCS_IDX2] o1 = %p, o1->data = %p (%s) \n", + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid L1 index", NULL); + + // printf("[DEBUG_RELOCS_IDX2] o1 = %p, o1->data = %p (%s) \n", // o1, ((elfshsect_t*)o1)->data, ((elfshsect_t*)o1)->name); - // - // This elfsh_get_reloc() returns a elfshsect_t *, - // and we need to grab the ->data pointer, to avoid rewriting a + // + // This elfsh_get_reloc() returns a elfshsect_t *, + // and we need to grab the ->data pointer, to avoid rewriting a // new handler (its not fair but it works .. ;) and its acceptable // since only relocation tables use this rule. - + sect = (elfshsect_t *) o1; - o1 = elfsh_get_raw(sect); + o1 = elfsh_readmem(sect); - // Finally we fill the intermediate object format for the guessed object + // Finally we fill the intermediate object format for the guessed object pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); pobj->immed = 0; pobj->get_obj = (void *) l2->get_obj; pobj->set_obj = (void *) l2->set_obj; pobj->otype = aspect_type_get_by_id(l2->type); - // ugly flag to put for dynamic Rel vs Rela information + // ugly flag to put for dynamic Rel vs Rela information elfsh_setrel(IS_REL(sect)); pobj->parent = l1->get_entptr(o1, real_index2); if (isversion && pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown L2 object or Invalid L2 index", - NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown L2 object or Invalid L2 index", + NULL); - // Error checking + // Error checking pobj = revm_check_object(pobj); if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid REVM object", NULL); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); } diff -Nru eresi-0.8a25/librevm/lang/lookup.c eresi-0.0.20110516/librevm/lang/lookup.c --- eresi-0.8a25/librevm/lang/lookup.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/lookup.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file lookup.c - * @ingroup librevm_lang +* @file librevm/lang/lookup.c + * @ingroup lang * @brief Various object lookup functions built in the language. * * Started Nov 21 2003 jfv - * $Id: lookup.c,v 1.20 2008-02-16 12:32:27 thor Exp $ + * $Id: lookup.c 1444 2011-01-31 07:41:29Z may $ */ #include "revm.h" @@ -115,7 +115,7 @@ /** * @brief Get immediate value */ -revmobj_t *revm_lookup_immed(char *param) +revmobj_t *revm_lookup_immed(char *param, u_char existing) { elfsh_Sym *sym; revmconst_t *actual; @@ -132,15 +132,20 @@ "Invalid NULL parameter", (NULL)); /* Lookup a known variable */ - expr = revm_lookup_var(param); - if (expr && expr->value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr->value); + if (existing) + { + expr = revm_lookup_var(param); + if (expr && expr->value) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr->value); + } + else + expr = NULL; /* Support for lazy creation of variables */ if (*param == REVM_VAR_PREFIX) { ptr = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 1, 0); - expr = revm_expr_create_from_object(ptr, param); + expr = revm_expr_create_from_object(ptr, param, existing); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ptr); } @@ -323,6 +328,75 @@ +/** @brief Lookup a hash or list key */ +char *revm_lookup_key(char *param) +{ + revmexpr_t *expr; + revmobj_t *ret; + char *key; + u_int idx; + u_int idxtmp; + char tmpkey[BUFSIZ]; + char result[BUFSIZ] = {0x00}; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + idx = 0; + while (*param) + { + + /* No special character */ + while (*param != REVM_VAR_PREFIX && *param) + { + if (idx >= BUFSIZ) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Too long key for source object", NULL); + result[idx++] = *param; + param++; + } + if (!(*param)) + goto end; + + /* Lookup the variable name found within the key */ + for (idxtmp = 0; *param != '_' && *param; param++) + { + if (idxtmp >= BUFSIZ) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Too long key for source object", NULL); + tmpkey[idxtmp++] = *param; + } + tmpkey[idxtmp] = 0x00; + + /* Try to lookup the variable name */ + expr = revm_expr_get(tmpkey); + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid key", NULL); + if (!expr->type || !expr->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parser handling failed", NULL); + ret = revm_copy_object(expr->value); + if (revm_convert_object(expr, ASPECT_TYPE_STR) < 0) + { + revm_destroy_object(expr->value, 1); + expr->value = ret; + expr->type = ret->otype; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown key for source object", NULL); + } + key = expr->value->immed_val.str; + revm_destroy_object(expr->value, 0); + expr->value = ret; + expr->type = ret->otype; + idx += snprintf(result + idx, BUFSIZ - idx, "%s", key); + } + + end: + key = strdup(result); + //printf("key = %s ! \n", key); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, key); +} + + /** * @brief Lookup the file pointed by name */ @@ -341,7 +415,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL parameter", (NULL)); expr = revm_lookup_var(param); - if (!expr || !expr->value) + if (!expr || !expr->value || !expr->type) idx = atoi(param); else { @@ -368,24 +442,30 @@ /** - * Parse the parameter and fill the revmobj_t + * Parse the parameter and fill the revmexpr_t */ -revmexpr_t *revm_lookup_param(char *param) +revmexpr_t *revm_lookup_param(char *param, u_char existing) { revmobj_t *(*funcptr)(char *param, char *fmt, u_int sepnbr); char **keys; int keynbr; char *parm; unsigned int sepnbr; - unsigned int index; + int index; revmobj_t *res; revmexpr_t *expr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - expr = revm_expr_get(param); - if (expr) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + /* If we are asked to lookup first, do so */ + if (existing) + { + expr = revm_expr_get(param); + if (expr) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + } + else + expr = NULL; /* Find the number of fields in param */ for (sepnbr = 0, parm = param; *parm; parm++) @@ -404,20 +484,23 @@ res = funcptr(param, keys[index], sepnbr); if (!res) continue; - expr = revm_expr_create_from_object(res, param); + expr = revm_expr_create_from_object(res, param, existing); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); } /* If still not found, try manually inserted types */ - res = revm_object_lookup(param); - if (res) + if (existing) { - expr = revm_expr_create_from_object(res, param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + res = revm_object_lookup(param); + if (res) + { + expr = revm_expr_create_from_object(res, param, existing); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); + } } /* If no good syntax is available, print error if we are not in probe mode */ - res = revm_lookup_immed(param); + res = revm_lookup_immed(param, existing); if (!res) { revm_badparam(param); @@ -425,6 +508,6 @@ "Unable to resolve object", NULL); } - expr = revm_expr_create_from_object(res, param); + expr = revm_expr_create_from_object(res, param, existing); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); } diff -Nru eresi-0.8a25/librevm/lang/Makefile eresi-0.0.20110516/librevm/lang/Makefile --- eresi-0.8a25/librevm/lang/Makefile 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/Makefile 2011-05-16 11:34:11.000000000 +0000 @@ -6,7 +6,7 @@ include ../../config.h SRC = access.c convert.c grammar.c lookup.c objects.c \ - options.c parser.c scanner.c variables.c expressions.c + options.c parser.c scanner.c variables.c expressions.c arith.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) CC ?= gcc @@ -15,24 +15,22 @@ NAME32 = ../revm-lang.32.o NAME64 = ../revm-lang.64.o -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ - $(KERNSHINCINC) $(KERNSH) \ -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ + $(STATOPT2) $(ASMOPT) -DERESI32 $(EXTRACFLAGS) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libaspect/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ + $(EXTRACFLAGS) -I../../libedfmt/include/ \ + $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/librevm/lang/objects.c eresi-0.0.20110516/librevm/lang/objects.c --- eresi-0.8a25/librevm/lang/objects.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/objects.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,6 +1,6 @@ /** - * @file objects.c - * @ingroup librevm_lang +* @file librevm/lang/objects.c + * @ingroup lang * @brief Methods for creation of objects. * * See lts.c for Lazy Type System implementation @@ -8,7 +8,7 @@ * Started on Mon Feb 24 12:21:12 2003 jfv * * - * $Id: objects.c,v 1.13 2007-11-28 07:56:09 may Exp $ + * $Id: objects.c 1444 2011-01-31 07:41:29Z may $ * */ #include "revm.h" @@ -24,10 +24,9 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Please use create_IMMEDSTR or create_LONG for that */ - if (type == ASPECT_TYPE_STR || type == ASPECT_TYPE_CADDR || - type == ASPECT_TYPE_CADDR) + if (type == ASPECT_TYPE_STR) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for immed", (NULL)); + "Invalid type for immed", (NULL)); XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); new->immed = 1; @@ -41,23 +40,41 @@ /** * @brief Create constant object */ -revmobj_t *revm_create_LONG(char perm, eresi_Addr val) +revmobj_t *revm_create_ptr(char perm, eresi_Addr val, u_int type) { revmobj_t *new; + aspectype_t *atype; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + atype = aspect_type_get_by_id(type); + if (!type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for constant", (NULL)); /* Please use create_IMMEDSTR for that */ XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); new->immed = 1; new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_LONG); - new->size = sizeof(val); + new->otype = atype; + new->size = atype->size; new->immed_val.ent = val; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); } +/** + * @brief Create constant object + */ +revmobj_t *revm_create_LONG(char perm, eresi_Addr val) +{ + revmobj_t *new; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + new = revm_create_ptr(perm, val, ASPECT_TYPE_LONG); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, new); +} + + /** * @brief Create constant object */ @@ -66,38 +83,20 @@ revmobj_t *new; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_CADDR); - new->size = sizeof(val); - new->immed_val.ent = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); + new = revm_create_ptr(perm, val, ASPECT_TYPE_CADDR); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, new); } /** * @brief Create constant object - * - * @param perm - * @param val - * @return */ revmobj_t *revm_create_DADDR(char perm, eresi_Addr val) { revmobj_t *new; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_DADDR); - new->size = sizeof(val); - new->immed_val.ent = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); + new = revm_create_ptr(perm, val, ASPECT_TYPE_DADDR); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, new); } @@ -355,10 +354,10 @@ /** * @brief Destroy an object */ -void revm_destroy_object(revmobj_t *pobj) +void revm_destroy_object(revmobj_t *pobj, u_char freedata) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (pobj->otype->type == ASPECT_TYPE_STR && pobj->immed) + if (pobj->otype && pobj->otype->type == ASPECT_TYPE_STR && pobj->immed && freedata) XFREE(__FILE__, __FUNCTION__, __LINE__, pobj->immed_val.str); XFREE(__FILE__, __FUNCTION__, __LINE__, pobj); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/librevm/lang/options.c eresi-0.0.20110516/librevm/lang/options.c --- eresi-0.8a25/librevm/lang/options.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/options.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,89 +1,94 @@ /** - * @file opt.c - * @ingroup librevm_lang +* @file librevm/lang/options.c + * @ingroup lang * @brief Implement the commands registration handlers. - * + * * Started on Fri Nov 2 15:17:02 2001 jfv * - * $Id: options.c,v 1.10 2007-08-07 07:13:27 may Exp $ + * $Id: options.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" -/** - * Read the input file parameter +/** + * Read the input file parameter + * @ingroup lang */ int revm_getoption(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 1 >= argc) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.curjob->curcmd->param[0] = argv[index + 1]; world.curjob->curcmd->argc = 1; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } -/** - * Read the input file parameter -*/ +/** + * Read the input file parameter + * @ingroup lang + */ int revm_getinput(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 1 >= argc) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.state.input = argv[index + 1]; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } -/** - * Read the output file parameter -*/ +/** + * Read the output file parameter + * @ingroup lang + */ int revm_getoutput(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 1 >= argc) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.state.output = argv[index + 1]; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); } -/** - * Activate a 2-non-regx-mandatory-parameters option -*/ +/** + * Activate a 2-non-regx-mandatory-parameters option + * @ingroup lang + */ int revm_getoption2(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 2 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 2 >= argc) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.curjob->curcmd->param[0] = argv[index + 1]; world.curjob->curcmd->param[1] = argv[index + 2]; world.curjob->curcmd->argc = 2; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (2)); } -/** - * Activate a 2-non-regx-mandatory-parameters option -*/ +/** + * Activate a 2-non-regx-mandatory-parameters option + * @ingroup lang + */ int revm_getoption3(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 3 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 3 >= argc) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.curjob->curcmd->param[0] = argv[index + 1]; world.curjob->curcmd->param[1] = argv[index + 2]; world.curjob->curcmd->param[2] = argv[index + 3]; @@ -92,43 +97,45 @@ } /** - * Activate a non-mandatory-regex-parameter option -*/ + * Activate a non-mandatory-regex-parameter option + * @ingroup lang + */ int revm_getregxoption(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (index + 1 < argc && argv[index + 1][0] != REVM_DASH) - { - if (regcomp(&world.curjob->curcmd->regx[0], argv[index + 1], - REG_EXTENDED) != 0 || !strcmp(argv[index + 1], "*")) - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); + if (index + 1 < argc && argv[index + 1][0] != REVM_DASH) + { + if (regcomp(&world.curjob->curcmd->regx[0], argv[index + 1], + REG_EXTENDED) != 0 || !strcmp(argv[index + 1], "*")) + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter not available", (-1)); world.curjob->curcmd->use_regx[0] = 1; PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } + } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** - * Fetch parameters until we find NULL or something starting by '-' +/** + * Fetch parameters until we find NULL or something starting by '-' + * @ingroup lang */ int revm_getvarparams(u_int index, u_int argc, char **argv) { u_int idx; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (world.curjob->curcmd->argc = idx = 0; + for (world.curjob->curcmd->argc = idx = 0; idx < 254 && index + idx + 1 < argc; idx++) { /* Add the '-' check which was not here and create bugs with cmdline */ - if ((world.state.revm_mode == REVM_STATE_CMDLINE - || world.state.revm_mode == REVM_STATE_TRACER) - && argv[index + idx + 1] && argv[index + idx + 1][0] == '-') - break; + if ((world.state.revm_mode == REVM_STATE_CMDLINE + || world.state.revm_mode == REVM_STATE_TRACER) + && argv[index + idx + 1] && argv[index + idx + 1][0] == '-') + break; world.curjob->curcmd->param[idx] = argv[index + idx + 1]; world.curjob->curcmd->argc++; @@ -137,9 +144,10 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); } -/** - * Format the input of a loop -*/ +/** + * Format the input of a loop + * @ingroup lang + */ int revm_getforparams(u_int index, u_int argc, char **argv) { char *p; @@ -154,36 +162,34 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong loop format", -1); p = argv[index + 4]; - last = argv[index + 5]; flag = 0; - + /* Intermediate checks */ if ((argc - index) == 6) { + last = argv[index + 5]; flag = (!strcmp("matching", p) ? 1 : !strcmp("until", p) ? 2 : 0); if (!flag) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong loop format", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong loop format", -1); /* Compute the regex if necessary */ if (flag == 1) - { - if (regcomp(&world.curjob->curcmd->regx[0], last, REG_EXTENDED) != 0 || - !strcmp(last, "*")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested regex", (-1)); - world.curjob->curcmd->use_regx[0] = 1; - } + { + if (regcomp(&world.curjob->curcmd->regx[0], last, REG_EXTENDED) != 0 || + !strcmp(last, "*")) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid requested regex", (-1)); + world.curjob->curcmd->use_regx[0] = 1; + } } - - /* Set the current and maximum indexes to uninitialized */ - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_getvarparams(index, argc, argv)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + revm_getvarparams(index, argc, argv)); } /** * Format the input of a case command + * @ingroup lang */ int revm_getcaseparams(u_int index, u_int argc, char **argv) { @@ -194,28 +200,28 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); curidx = curtok = 0; - for (world.curjob->curcmd->argc = idx = 0; + for (world.curjob->curcmd->argc = idx = 0; idx < 254 && index + idx + 1 < argc; idx++) { if (!strcmp(argv[index + idx + 1], REVM_CASE_ARROW)) - { - if (curtok != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for case command", (-1)); - curtok++; - curidx = 0; - continue; - } + { + if (curtok != 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for case command", (-1)); + curtok++; + curidx = 0; + continue; + } else if (!strcmp(argv[index + idx + 1], REVM_CASE_QMARK)) - { - if (curtok != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for case command", (-1)); - curtok++; - curidx = 0; - continue; - } + { + if (curtok != 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for case command", (-1)); + curtok++; + curidx = 0; + continue; + } curidx += snprintf(&tokens[curtok][curidx], BUFSIZ - curidx, "%s", argv[index + idx + 1]); } @@ -229,8 +235,9 @@ -/** +/** * Format the input of a match/rewrite command + * @ingroup lang */ int revm_getmatchparams(u_int index, u_int argc, char **argv) { @@ -239,21 +246,20 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong match format", -1); if (strcmp(argv[index + 2], CMD_PARAM_INTO)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong match format", -1); - - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_getoption2(index, argc, argv)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + revm_getoption2(index, argc, argv)); } -/** - * Add an entry to the requested dump list -*/ +/** + * Add an entry to the requested dump list + * @ingroup lang + */ static int revm_add2list(char outtype, u_int index, int argc, char **argv) { - char *off; + char *off; int idx = index; revmlist_t *cur; char *used; @@ -264,59 +270,61 @@ { cur = world.curjob->curcmd->disasm + idx - index; used = world.curjob->curcmd->use_regx + idx - index; - - if (argv[idx + 1] == NULL) - { - *used = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (idx == index ? -1 : 1)); - } + + if (argv[idx + 1] == NULL) + { + *used = 0; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + (idx == index ? -1 : 1)); + } cur->rname = argv[idx + 1]; - cur->otype = outtype; - cur->size = 0; + cur->otype = outtype; + cur->size = 0; cur->off = 0; - off = strchr(argv[idx + 1], '%'); + off = strchr(argv[idx + 1], '%'); + + if (off) + { + cur->size = atoi(off + 1); + *off = 0; + } + off = strchr(argv[idx + 1], ':'); + if (off) + { + cur->off = atoi(off + 1); + *off = 0; + } - if (off) - { - cur->size = atoi(off + 1); - *off = 0; - } - off = strchr(argv[idx + 1], ':'); - if (off) - { - cur->off = atoi(off + 1); - *off = 0; - } - if (regcomp(&cur->name, argv[idx + 1], REG_EXTENDED | REG_ICASE) != 0 || - *cur->rname == '*') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Regular computation failed", (-1)); + *cur->rname == '*') + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Regular computation failed", (-1)); *used = 1; idx++; } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (2)); } -/** - * Add an DISASM typed entry -*/ +/** + * Add an DISASM typed entry + * @ingroup lang + */ int revm_getdisasm(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_add2list(REVM_VIEW_DISASM, index, argc, argv)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + revm_add2list(REVM_VIEW_DISASM, index, argc, argv)); } -/** - * Add an HEXA typed entry -*/ +/** + * Add an HEXA typed entry + * @ingroup lang + */ int revm_gethexa(u_int index, u_int argc, char **argv) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_add2list(REVM_VIEW_HEX, index, argc, argv)); + revm_add2list(REVM_VIEW_HEX, index, argc, argv)); } diff -Nru eresi-0.8a25/librevm/lang/parser.c eresi-0.0.20110516/librevm/lang/parser.c --- eresi-0.8a25/librevm/lang/parser.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/parser.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,11 +1,12 @@ /** - * @file parse.c - * @@ingroup librevm_lang - * The top level parser of the language +* @file librevm/lang/parser.c + * @@ingroup lang + * + * The top level parser for ERESI scripting * * Started on Wed Feb 28 19:19:04 2007 jfv * - * $Id: parser.c,v 1.13 2007-11-29 14:01:56 may Exp $ + * $Id: parser.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -20,10 +21,7 @@ /* Pending label information : support labels */ static u_int pendinglabel = 0; static revmargv_t *newcmd = NULL; - -/* Global variables for rewrite/case/endwrt parsing */ static list_t *condcmdlist = NULL; -static u_char isdefault = 0; /** * Create a fresh label name @@ -37,7 +35,7 @@ idx = 0; retry: snprintf(buf, sizeof(buf), "%s_DEPTH:%u_INDEX:%u", prefix, curnest, idx); - if (hash_get(&labels_hash[world.curjob->sourced], buf)) + if (hash_get(&world.curjob->recur[world.curjob->curscope].labels, buf)) { idx++; goto retry; @@ -64,7 +62,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Too many nested construct", -1); labl = revm_label_get("foreach"); - hash_add(&labels_hash[world.curjob->sourced], labl, newcmd); + hash_add(&world.curjob->recur[world.curjob->curscope].labels, labl, newcmd); looplabels[curnest++] = labl; } @@ -79,7 +77,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incorrectly nested loop-ending statement", -1); forend = newcmd; - forend->endlabel = looplabels[--curnest]; + forend->endlabel = strdup(looplabels[--curnest]); nextlabel = 1; } @@ -91,7 +89,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Too many nested construct", -1); labl = revm_label_get("match"); - hash_add(&labels_hash[world.curjob->sourced], labl, newcmd); + hash_add(&world.curjob->recur[world.curjob->curscope].labels, labl, newcmd); looplabels[curnest++] = labl; } @@ -124,8 +122,8 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incorrectly nested match-ending statement", -1); forend = newcmd; - forend->endlabel = looplabels[--curnest]; - hash_add(&labels_hash[world.curjob->sourced], endlabl, newcmd); + forend->endlabel = strdup(looplabels[--curnest]); + hash_add(&world.curjob->recur[world.curjob->curscope].labels, endlabl, newcmd); /* Now setting the end label to all waiting case/default commands */ if (condcmdlist && condcmdlist->head) @@ -139,11 +137,6 @@ condcmdlist = NULL; } } - - /* This flag says if the command opens a new scope just for its arguments */ - isdefault = ((!strcmp(curtok, CMD_DEFAULT) || - !strcmp(curtok, CMD_PRE) || - !strcmp(curtok, CMD_POST)) ? 1 : 0); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -182,11 +175,10 @@ bzero(label, sizeof(label)); if (!pendinglabel) { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newcmd, sizeof(revmargv_t), -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__, newcmd, sizeof(revmargv_t), -1); world.curjob->curcmd = newcmd; - if (world.curjob->script[world.curjob->sourced] == NULL) - world.curjob->script[world.curjob->sourced] = newcmd; + if (world.curjob->recur[world.curjob->curscope].script == NULL) + world.curjob->recur[world.curjob->curscope].script = newcmd; } else pendinglabel = 0; @@ -201,31 +193,16 @@ /* If there is a forend/matchend label waiting, insert it here */ /* The forend label must point on the -following- command */ - /* Annotate meta-command foreach, case, and default with the "end label" */ if (nextlabel) { - hash_add(&labels_hash[world.curjob->sourced], endlabl, newcmd); - loopstart = hash_get(&labels_hash[world.curjob->sourced], looplabels[curnest]); - - /* If we are executing "default", we search for the loop start in the parent scope */ - /* - if (world.curjob->sourced && isdefault) - for (ret = 0; world.curjob->sourced >= ret; ret++) - { - loopstart = hash_get(&labels_hash[world.curjob->sourced - ret], looplabels[curnest]); - if (loopstart) - break; - } - */ - - if (!loopstart) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid nesting of language construct", -1); + hash_add(&world.curjob->recur[world.curjob->curscope].labels, strdup(endlabl), newcmd); + loopstart = hash_get(&world.curjob->recur[world.curjob->curscope].labels, + looplabels[curnest]); loopstart->endlabel = strdup(endlabl); - /* isdefault = */ nextlabel = 0; + nextlabel = 0; } - /* Dont call registration handler if there is not (0 param commands) */ + /* Dont call registration handler if there is none (0 param commands) */ if (actual->reg != NULL) { ret = actual->reg(index, argc, argv); @@ -240,6 +217,7 @@ if (revm_parse_construct(argv[index]) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid eresi program nesting construct", -1); + index += ret; } @@ -250,7 +228,7 @@ ret = sscanf(name, "%15[^:]%c", label, &c); if (ret == 2 && c == ':') { - hash_add(&labels_hash[world.curjob->sourced], + hash_add(&world.curjob->recur[world.curjob->curscope].labels, strdup(label), newcmd); pendinglabel = 1; continue; @@ -270,13 +248,13 @@ /* Put the newcmd command at the end of the list */ newcmd->name = name; newcmd->cmd = (revmcmd_t *) actual; - if (!world.curjob->lstcmd[world.curjob->sourced]) - world.curjob->lstcmd[world.curjob->sourced] = newcmd; + if (!world.curjob->recur[world.curjob->curscope].lstcmd) + world.curjob->recur[world.curjob->curscope].lstcmd = newcmd; else { - world.curjob->lstcmd[world.curjob->sourced]->next = newcmd; - newcmd->prev = world.curjob->lstcmd[world.curjob->sourced]; - world.curjob->lstcmd[world.curjob->sourced] = newcmd; + world.curjob->recur[world.curjob->curscope].lstcmd->next = newcmd; + newcmd->prev = world.curjob->recur[world.curjob->curscope].lstcmd; + world.curjob->recur[world.curjob->curscope].lstcmd = newcmd; } } diff -Nru eresi-0.8a25/librevm/lang/scanner.c eresi-0.0.20110516/librevm/lang/scanner.c --- eresi-0.8a25/librevm/lang/scanner.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/scanner.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file lexer.c - * @ingroup librevm_lang +* @file librevm/lang/scanner.c + * @ingroup lang * Started on Fri Feb 7 20:53:25 2003 jfv * Updated on Fri Mar 5 18:47:41 2007 jfv * - * $Id: scanner.c,v 1.15 2008-02-16 12:32:27 thor Exp $ + * $Id: scanner.c 1397 2009-09-13 02:19:08Z may $ * */ #include "revm.h" @@ -50,7 +50,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!str || !str[0]) + if (!in || !ac || !av || !*av || !**av) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); @@ -298,7 +298,7 @@ /* If we are in the client part of the debugger, we have a special behavior */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && + if (world.state.revm_mode == REVM_STATE_EMBEDDED && world.state.revm_side == REVM_SIDE_CLIENT) { write(world.fifo_c2s, buf, len); diff -Nru eresi-0.8a25/librevm/lang/.svn/all-wcprops eresi-0.0.20110516/librevm/lang/.svn/all-wcprops --- eresi-0.8a25/librevm/lang/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 36 -/svn/!svn/ver/950/trunk/librevm/lang -END -convert.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/librevm/lang/convert.c -END -access.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/librevm/lang/access.c -END -expressions.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/946/trunk/librevm/lang/expressions.c -END -grammar.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/lang/grammar.c -END -variables.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/906/trunk/librevm/lang/variables.c -END -lookup.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/librevm/lang/lookup.c -END -objects.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/librevm/lang/objects.c -END -scanner.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/lang/scanner.c -END -options.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/lang/options.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/950/trunk/librevm/lang/Makefile -END -parser.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/935/trunk/librevm/lang/parser.c -END diff -Nru eresi-0.8a25/librevm/lang/.svn/entries eresi-0.0.20110516/librevm/lang/.svn/entries --- eresi-0.8a25/librevm/lang/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,160 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/lang -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -convert.c -file - - - - -2008-04-06T23:15:45.082126Z -ba555f500daa0f633046a8a6e9868029 -2008-03-27T22:53:48.747992Z -946 -may - -access.c -file - - - - -2008-04-06T23:15:45.116904Z -01e7bde3ff602de92ddaa153c83f05b7 -2008-03-27T22:53:48.747992Z -946 -may - -expressions.c -file - - - - -2008-04-06T23:15:45.128202Z -bd3dbe28bffd76e8bfaa749a47886f6c -2008-03-27T22:53:48.747992Z -946 -may - -grammar.c -file - - - - -2008-04-06T23:15:45.139545Z -b6d91629c0e084358a67d31497a49a96 -2008-03-14T00:57:20.622435Z -906 -enioh - -variables.c -file - - - - -2008-04-06T23:15:45.150876Z -0d1426213eefaca00215f9d43e2ac328 -2008-03-14T00:57:20.622435Z -906 -enioh - -lookup.c -file - - - - -2008-04-06T23:15:45.162345Z -65c0f3d9b2f0fe125e182428022e10d0 -2008-03-27T22:53:48.747992Z -946 -may - -objects.c -file - - - - -2008-04-06T23:15:45.173688Z -0c659d03c669d1ea05b6a406ecb566e2 -2008-03-27T22:53:48.747992Z -946 -may - -scanner.c -file - - - - -2008-04-06T23:15:45.185000Z -448017e11cc835fd32aefd10c1376397 -2008-03-14T00:57:20.622435Z -906 -enioh - -options.c -file - - - - -2008-04-06T23:15:45.196315Z -85561bc8a18d9629fa3d7a893021dba3 -2008-03-14T00:57:20.622435Z -906 -enioh - -Makefile -file - - - - -2008-04-06T23:15:45.206900Z -6b2ac9dbe01ed80570bfcf63c61341c7 -2008-03-29T07:54:04.209482Z -950 -enioh - -parser.c -file - - - - -2008-04-06T23:15:45.219137Z -b361990cbfb20c405c3b7945c0661723 -2008-03-25T17:24:54.084701Z -935 -may - diff -Nru eresi-0.8a25/librevm/lang/.svn/format eresi-0.0.20110516/librevm/lang/.svn/format --- eresi-0.8a25/librevm/lang/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/access.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/access.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/access.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/access.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,500 +0,0 @@ -/** - * @file access.c - * @ingroup librevm_lang - * @brief Implementation of scripting lookups for meta-language variables. - * - * Started Jan 23 2007 23:39:51 jfv - * $Id: access.c,v 1.32 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "revm.h" - -/** - * @brief Get the buffered address from the real virtual address - */ -void *revm_get_raw(void *addr) -{ - elfshsect_t *sect; - elfsh_SAddr offset; -#if defined(KERNSH) - void *dataptr; -#endif - - sect = elfsh_get_parent_section(world.curjob->curfile, - (eresi_Addr) addr, &offset); - -#if defined(KERNSH) - dataptr = kernsh_revm_get_raw(addr); - if (dataptr != NULL) - return dataptr; -#endif - - /* This happens when the object is a ERESI variable */ - if (!sect) - return (addr); - - if (elfsh_is_debug_mode()) - { - if (!elfsh_section_is_runtime(sect)) - return ((void *) (sect->parent->rhdr.base + sect->shdr->sh_addr + offset)); - else if (!sect->shdr->sh_addr) - return ((void *) (char *) sect->data + offset); - else - return ((void *) (sect->shdr->sh_addr + offset)); - } - else - return ((void *) (char *) sect->data + offset); - -} - - -/** - * @brief Return the index for an array access giving a string - */ -int revm_arrayindex_get(char *strindex) -{ - revmexpr_t *expr; - revmobj_t *obj; - int index; - char *str; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First remove the ] in a copy of the string */ - str = strdup(strindex + 1); - for (idx = 0; str[idx] && str[idx] != ']'; idx++); - if (str[idx]) - str[idx] = 0x00; - - /* Lookup the value of the index string */ - expr = revm_lookup_var(str); - if (!expr || !expr->value) - { - idx = atoi(str); - XFREE(__FILE__, __FUNCTION__, __LINE__, str); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); - } - obj = expr->value; - switch (obj->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - index = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - break; - case ASPECT_TYPE_INT: - index = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - break; - case ASPECT_TYPE_SHORT: - index = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - break; - case ASPECT_TYPE_BYTE: - index = (obj->immed ? obj->immed_val.byte : obj->get_obj(obj->parent)); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid index syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, index); -} - - -/** - * @brief Return the requested projections in case of an array - */ -int revm_arrayoff_get(char *field, u_int elmsize, - u_int dimnbr, u_int *dims) -{ - char *strindex; - char *endindex; - int offset; - int index; - int iter; - int liter; - u_int *dimoff; - char *lfield; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dimoff = alloca(dimnbr * sizeof(int)); - iter = strlen(field); - lfield = alloca(iter + 1); - memcpy(lfield, field, iter); - - /* Compute offset for each dimension in the first pass */ - for (iter = 0; - lfield && *lfield && iter < dimnbr; - lfield = endindex + 1, iter++) - { - strindex = strchr(lfield, '['); - if (strindex) - { - *strindex = 0x00; - endindex = strchr(strindex + 1, ']'); - if (!endindex) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array syntax", -1); - *endindex = 0x00; - index = revm_arrayindex_get(strindex); - if (index < 0 || index >= dims[iter] || (strindex + 1) == endindex) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array index", -1); - - /* Example : [2][3][2] -> (2 * dim2 * dim3 + 3 * dim3 + 2) * sizeof(int) */ - dimoff[iter] = index * sizeof(int); - for (liter = 0; liter != iter; liter++) - dimoff[liter] *= dims[iter]; - } - else - break; - } - - /* Make sure we havent gone further the limit of dimensions */ - if (iter != dimnbr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array dimensions", -1); - - /* Compute the final offset of element inside the array by - adding offsets of all dimensions */ - for (offset = iter = 0; iter < dimnbr; iter++) - offset += dimoff[iter]; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, offset); -} - - - - -/** - * @brief Return offset given field name - */ -aspectype_t *revm_fieldoff_get(aspectype_t *parent, char *field, u_int *off) -{ - aspectype_t *child; - int index; - char fieldname[256]; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Truncate the name to keep only the field identifier */ - memcpy(fieldname, field, sizeof(fieldname) - 1); - str = strchr(fieldname, '['); - if (str) - *str = 0x00; - - /* Find the child offset, augment it in case of array */ - for (child = parent->childs; child; child = child->next) - if (!strcmp(child->fieldname, fieldname)) - { - *off = child->off; - - /* Get offset inside the array if we are accessing an array */ - index = revm_arrayoff_get(field, child->size, - child->dimnbr, child->elemnbr); - if (index < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid array access", NULL); - *off += index; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - } - - /* Failed match */ - *off = REVM_INVALID_FIELD; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested field offset", NULL); -} - - -/** - * @brief Recursive function to lookup data from its typed data flow path - */ -static aspectype_t *revm_field_get(aspectype_t *type, char *param, - void **data, char translateaddr) - -{ - char *str; - char *next; - unsigned int off; - aspectype_t *child; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - str = strchr(param, *REVM_SEP); - - /* This is the leaf field */ - if (!str) - { - child = revm_fieldoff_get(type, param, &off); - if (off == REVM_INVALID_FIELD) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find terminal field", NULL); - *data = (char *) *data + off; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - } - - /* This is a non-terminal child field */ - *str = 0x00; - next = str + 1; - - child = revm_fieldoff_get(type, param, &off); - if (off == REVM_INVALID_FIELD) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find field", NULL); - *data = (char *) *data + off; - - /* Dereference pointer (struct.ptr->to.other.field) */ - if (child->isptr && *data) - { - *data = (void *) *(u_long *) *data; - if (translateaddr) - *data = revm_get_raw(*data); - } - - if (!*data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find dereference NULL field", NULL); - - child = revm_field_get(child, next, data, translateaddr); - if (!child) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested field", NULL); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); -} - - - -/** - * @brief Create the REVM object that is to be returned - */ -revmobj_t *revm_object_create(aspectype_t *type, void *data, char translateaddr) -{ - revmobj_t *path; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Create the revmobj and fill its handlers */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, path, sizeof(revmobj_t), NULL); - path->root = (void *) type; - - /* Lookup again in the file if we are dealing with a pointer */ - if (type->type == ASPECT_TYPE_STR || (type->isptr && *(u_long *) data)) - { - data = (void *) *(eresi_Addr *) data; - if (translateaddr) - data = revm_get_raw(data); - } - - /* Fill type specific object handlers */ - path->parent = (void *) data; - if (type->type == ASPECT_TYPE_STR) - { - path->get_name = (void *) revm_generic_getname; - path->set_name = (void *) revm_generic_setname; - } - if (!type) - { - path->get_data = (void *) revm_generic_getdata; - path->set_data = (void *) revm_generic_setdata; - } - path->get_obj = (void *) revm_generic_getobj; - - /* This handler is size dependant */ - if (type) - switch (type->type) - { - case ASPECT_TYPE_BYTE: - path->set_obj = (void *) revm_byte_setobj; - break; - case ASPECT_TYPE_SHORT: - path->set_obj = (void *) revm_short_setobj; - break; - case ASPECT_TYPE_INT: - path->set_obj = (void *) revm_int_setobj; - break; - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - case ASPECT_TYPE_LONG: - path->set_obj = (void *) revm_long_setobj; - break; - default: - break; - } - path->otype = type; - path->immed = 0; /* Value is not immediate */ - path->perm = 1; /* Do not free after use */ - - /* Success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, path); -} - - -/** - * @brief Lookup _for real_ the path of a complex typed object - */ -revmobj_t *revm_object_lookup_real(aspectype_t *type, - char *objname, - char *objpath, - char translateaddr) -{ - revmannot_t *annot; - void *data; - revmobj_t *path; - char hashname[ELFSH_MEANING]; - hash_t *typehash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_EXPRS__ - fprintf(stderr, "REVMOBJ_LOOKUP_REAL (%s of type %s and wanted field %s)\n", - objname, type->name, objpath); -#endif - - snprintf(hashname, sizeof(hashname), "type_%s", type->name); - typehash = hash_get(hash_hash, hashname); - if (!typehash) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested type map", NULL); - annot = hash_get(typehash, objname); - if (!annot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested data object", NULL); - data = (void *) annot->addr; - if (translateaddr) - data = revm_get_raw(data); - - /* Get recursively the leaf type and data pointer */ - /* If the objpath is empty, its a scalar that was requested */ - if (objpath && *objpath) - { - type = revm_field_get(type, objpath, (void **) &data, translateaddr); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup object", NULL); - } - - /* Create and return the object describing the field */ - path = revm_object_create(type, data, translateaddr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, path); -} - - -/** - * @brief Lookup the path for a complex typed object (using syntactic sugar) - */ -revmobj_t *revm_object_lookup(char *str) -{ - char filename[ELFSH_MEANING]; - char typename[ELFSH_MEANING]; - char objectname[ELFSH_MEANING]; - int ret; - elfshobj_t *obj; - aspectype_t *type; - revmobj_t *path; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#define LOOKUP3_IDX "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^]]]" - - ret = sscanf(str, LOOKUP3_IDX, filename, typename, objectname); - if (ret != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve manual type object", NULL); - str += strlen(filename) + strlen(typename) + strlen(objectname) + 3; - if (str[0] && str[1]) - str++; - - /* Get parent objects */ - obj = revm_lookup_file(filename); - if (obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", NULL); - type = hash_get(&types_hash, typename); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested type", NULL); - - path = revm_object_lookup_real(type, objectname, str, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, path); -} - - - - - -/**************** Generic handlers *********************************/ - - - -char *revm_generic_getname(void *type, void *data) -{ - return (data); -} - -int revm_generic_setname(void *type, void *data, void *newdata) -{ - strcpy(data, newdata); - return (0); -} - -eresi_Addr revm_generic_getobj(void *data) -{ - return (*(eresi_Addr *) data); -} - -eresi_Addr revm_hash_getobj(void *data) -{ - return ((eresi_Addr) data); -} - -int revm_byte_setobj(void *data, eresi_Addr value) -{ - unsigned char *byte; - - byte = (unsigned char *) data; - *byte = (unsigned char) value; - return (0); -} - -int revm_short_setobj(void *data, eresi_Addr value) -{ - u_short *half; - - half = (u_short *) data; - *half = (u_short) value; - return (0); -} - -int revm_int_setobj(void *data, eresi_Addr value) -{ - unsigned int *val; - - val = (unsigned int *) data; - *val = (unsigned int) value; - return (0); -} - -int revm_long_setobj(void *data, eresi_Addr value) -{ - eresi_Addr *dst; - - dst = (eresi_Addr *) data; - *dst = value; - return (0); -} - -char *revm_generic_getdata(void *data, int off, int sizelm) -{ - return ((char *) data + (off * sizelm)); -} - -int revm_generic_setdata(void *data, int off, void *newdata, - int size, int sizelm) -{ - memcpy((char *) data + (off * sizelm), newdata, size); - return (0); -} - - -/**************** End of generic handlers *********************************/ diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/convert.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/convert.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/convert.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/convert.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,456 +0,0 @@ -/** -** @file objects.c -** @ingroup librevm_lang -** @brief The implementation of the Lazy Abstract Type System (LATS). -** -** It is the first rewrite of the type-system, in order to -** give it a really structured shape with clear type conversion -** rules. Byte, Short, and Long types are now available and all -** values and ELF fields are now encoded on their exact size -** in bits. -** -** This has also lead to more flexibility in the shell since -** more conversion are now availables and all (cross-)endianess -** is now transparent to the end-user. All of that was necessary -** for the 32/64bits support anyway. -** -** See table.c for a hint on how to use the object constructors -** objects.c for the object constructors themself -** -** Started on Tue Feb 08 12:21:12 2005 jfv -** -** -** $Id: convert.c,v 1.8 2007-12-06 05:11:58 may Exp $ -** -*/ -#include "revm.h" - - -/** - * Convert to string object - */ -int revm_convert2str(revmobj_t *obj) -{ - u_char val8; - u_short val16; - u_int val32; - eresi_Addr val64; - char tmp[30]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - val8 = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%02hhu", val8); - obj->immed_val.byte = 0; - obj->immed_val.str = strdup(tmp); - - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_STR); - obj->immed = 1; - obj->size = strlen(tmp); - obj->sizelem = 0; - break; - case ASPECT_TYPE_SHORT: - val16 = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%04hu", val16); - obj->immed_val.half = 0; - obj->immed_val.str = strdup(tmp); - - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_STR); - obj->immed = 1; - obj->size = strlen(tmp); - obj->sizelem = 0; - break; - case ASPECT_TYPE_INT: - val32 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), "%08u", val32); - obj->immed_val.word = 0; - obj->immed_val.str = strdup(tmp); - - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_STR); - obj->immed = 1; - obj->size = strlen(tmp); - obj->sizelem = 0; - break; - case ASPECT_TYPE_RAW: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Raw -> String is not a valid " - "conversion", -1); - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val64 = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - snprintf(tmp, sizeof(tmp), AFMT, val64); - obj->immed_val.ent = 0; - obj->immed_val.str = strdup(tmp); - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_STR); - obj->immed = 1; - obj->size = strlen(tmp); - obj->sizelem = 0; - case ASPECT_TYPE_STR: - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Convert to 4 bytes object - */ -int revm_convert2int(revmobj_t *obj) -{ - eresi_Addr val64; - u_int val32; - u_short val16; - u_char val8; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - val8 = (u_char) (obj->immed ? obj->immed_val.byte : - obj->get_obj(obj->parent)); - obj->immed_val.byte = 0; - obj->immed_val.word = val8; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - obj->immed = 1; - obj->size = 4; - obj->sizelem = 0; - break; - case ASPECT_TYPE_SHORT: - val16 = (u_short) (obj->immed ? obj->immed_val.half : - obj->get_obj(obj->parent)); - obj->immed_val.half = 0; - obj->immed_val.word = val16; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - obj->immed = 1; - obj->size = 4; - obj->sizelem = 0; - break; - case ASPECT_TYPE_STR: - case ASPECT_TYPE_RAW: - val32 = atoi((obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent))); - if (obj->immed && obj->immed_val.str) - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str); - obj->immed_val.str = 0; - obj->immed_val.word = val32; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - obj->immed = 1; - obj->size = 4; - obj->sizelem = 0; - break; - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val64 = (eresi_Addr) (obj->immed ? obj->immed_val.ent : - obj->get_obj(obj->parent)); - obj->immed_val.ent = 0; - obj->immed_val.word = (int) val64; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_INT); - obj->immed = 1; - obj->size = 4; - obj->sizelem = 0; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Convert to a long object - */ -int revm_convert2addr(revmobj_t *obj, u_int type) -{ - eresi_Addr val64; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - val64 = (obj->immed ? obj->immed_val.byte : - obj->get_obj(obj->parent)); - obj->immed_val.word = 0; - obj->immed_val.ent = val64; - obj->otype = aspect_type_get_by_id(type); - obj->immed = 1; - obj->size = sizeof(eresi_Addr); - obj->sizelem = 0; - break; - case ASPECT_TYPE_SHORT: - val64 = (obj->immed ? obj->immed_val.half : - obj->get_obj(obj->parent)); - obj->immed_val.half = 0; - obj->immed_val.ent = val64; - obj->otype = aspect_type_get_by_id(type); - obj->immed = 1; - obj->size = sizeof(eresi_Addr); - obj->sizelem = 0; - break; - case ASPECT_TYPE_STR: - case ASPECT_TYPE_RAW: - val64 = atol(obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent)); - if (obj->immed && obj->immed_val.str) - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str); - obj->immed_val.str = 0; - obj->immed_val.ent = val64; - obj->otype = aspect_type_get_by_id(type); - obj->immed = 1; - obj->size = sizeof(eresi_Addr); - obj->sizelem = 0; - break; - case ASPECT_TYPE_INT: - val64 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - obj->immed_val.word = 0; - obj->immed_val.ent = val64; - obj->otype = aspect_type_get_by_id(type); - obj->immed = 1; - obj->size = sizeof(eresi_Addr); - obj->sizelem = 0; - break; - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - case ASPECT_TYPE_LONG: - obj->otype = aspect_type_get_by_id(type); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Small handlers for same sized types - */ -int revm_convert2caddr(revmobj_t *obj) -{ - return (revm_convert2addr(obj, ASPECT_TYPE_CADDR)); -} - -int revm_convert2daddr(revmobj_t *obj) -{ - return (revm_convert2addr(obj, ASPECT_TYPE_DADDR)); -} - -int revm_convert2long(revmobj_t *obj) -{ - return (revm_convert2addr(obj, ASPECT_TYPE_LONG)); -} - - - - -/** - * Convert to a raw data object - */ -int revm_convert2raw(revmobj_t *obj) -{ - u_char val8; - u_short val16; - u_int val32; - eresi_Addr val64; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - val8 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, 2, -1); - *obj->immed_val.str = val8; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW); - obj->immed = 1; - obj->size = 1; - obj->sizelem = 1; - break; - case ASPECT_TYPE_STR: - str = (obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent)); - XREALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, obj->immed_val.str, obj->size, -1); - memcpy(obj->immed_val.str, str, obj->size); - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW); - obj->immed = 1; - //obj->size; No size change - obj->sizelem = 0; - break; - case ASPECT_TYPE_SHORT: - val16 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val16) + 1, -1); - memcpy(obj->immed_val.str, &val16, sizeof(val16)); // FIXME: Take care of endianess ! - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW); - obj->immed = 1; - obj->size = 2; - obj->sizelem = 0; - break; - case ASPECT_TYPE_INT: - val32 = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val32) + 1, -1); - memcpy(obj->immed_val.str, &val32, sizeof(val32)); // FIXME: Take care of endianess ! - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW); - obj->immed = 1; - obj->size = 4; - obj->sizelem = 0; - break; - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val64 = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - XALLOC(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str, sizeof(val64) + 1, -1); - memcpy(obj->immed_val.str, &val64, sizeof(val64)); // FIXME: Take care of endianess ! - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_RAW); - obj->immed = 1; - obj->size = sizeof(eresi_Addr); - obj->sizelem = 0; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Convert to a raw data object - */ -int revm_convert2byte(revmobj_t *obj) -{ - u_char val8; - u_short val16; - int val32; - eresi_Addr val64; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_SHORT: - val16 = (u_short) (obj->immed ? obj->immed_val.half : - obj->get_obj(obj->parent)); - obj->immed_val.half = 0; - obj->immed_val.byte = (u_char) val16; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_BYTE); - obj->immed = 1; - obj->size = 1; - obj->sizelem = 0; - break; - case ASPECT_TYPE_RAW: - case ASPECT_TYPE_STR: - val8 = *(obj->immed ? obj->immed_val.str : obj->get_name(obj->root, obj->parent)); - if (obj->immed && obj->immed_val.str) - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str); - obj->immed_val.str = 0; - obj->immed_val.byte = val8; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_BYTE); - obj->immed = 1; - obj->size = 1; - obj->sizelem = 0; - break; - case ASPECT_TYPE_INT: - val32 = (u_int) (obj->immed ? obj->immed_val.word : - obj->get_obj(obj->parent)); - obj->immed_val.word = 0; - obj->immed_val.byte = (u_char) val32; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_BYTE); - obj->immed = 1; - obj->size = 1; - obj->sizelem = 0; - break; - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val64 = (eresi_Addr) (obj->immed ? obj->immed_val.ent : - obj->get_obj(obj->parent)); - obj->immed_val.ent = 0; - obj->immed_val.byte = (u_char) val64; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_BYTE); - obj->immed = 1; - obj->size = 1; - obj->sizelem = 0; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Convert to a raw data object -*/ -int revm_convert2short(revmobj_t *obj) -{ - u_char val8; - u_short val16; - int val32; - eresi_Addr val64; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - val8 = (u_char) (obj->immed ? obj->immed_val.byte : - obj->get_obj(obj->parent));; - obj->immed_val.byte = 0; - obj->immed_val.half = (u_short) val8; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_SHORT); - obj->immed = 1; - obj->size = 2; - obj->sizelem = 0; - break; - case ASPECT_TYPE_RAW: - case ASPECT_TYPE_STR: - val16 = atoi((obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent))); - if (obj->immed && obj->immed_val.str) - XFREE(__FILE__, __FUNCTION__, __LINE__,obj->immed_val.str); - obj->immed_val.str = 0; - obj->immed_val.half = val16; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_SHORT); - obj->immed = 1; - obj->size = 2; - obj->sizelem = 0; - break; - case ASPECT_TYPE_INT: - val32 = (u_int) (obj->immed ? obj->immed_val.word : - obj->get_obj(obj->parent)); - obj->immed_val.word = 0; - obj->immed_val.half = (u_short) val32; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_SHORT); - obj->immed = 1; - obj->size = 2; - obj->sizelem = 0; - break; - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val64 = (eresi_Addr) (obj->immed ? obj->immed_val.ent : - obj->get_obj(obj->parent)); - obj->immed_val.ent = 0; - obj->immed_val.half = (u_short) val64; - obj->otype = aspect_type_get_by_id(ASPECT_TYPE_SHORT); - obj->immed = 1; - obj->size = 2; - obj->sizelem = 0; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source type unknown", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/expressions.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/expressions.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/expressions.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/expressions.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1233 +0,0 @@ -/* -** @file expressions.c -** @ingroup librevm_lang -** @brief Implementation of scripting declarations for meta-language variables. -** -** Started on Jun 23 2007 23:39:51 jfv -** $Id: expressions.c,v 1.21 2007-12-09 23:00:18 may Exp $ -*/ -#include "revm.h" - - -/** Get the real value of the parameter string for further revmobj initialization */ -/** This function set the label and strval fields of the newly created revmexpr_t */ -static revmexpr_t *revm_expr_read(char **datavalue) -{ - revmexpr_t *expr; - char *datastr; - u_int opening; - u_int closing; - u_int beginning; - char *namend; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - datastr = *datavalue; - XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, - sizeof(revmexpr_t), NULL); - - /* First get the field (or top-level type) name */ - expr->label = datastr; - while (*datastr && *datastr != '(' && *datastr != ':') - datastr++; - if (!*datastr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get root field or type name", NULL); - } - - /* Implicit field/type name */ - else if (expr->label == datastr) - expr->label = NULL; - - /* Eat as many '(' or a ':' */ - namend = datastr; - for (opening = 0; *datastr == '('; datastr++) - beginning = ++opening; - if (!opening && *datastr == ':') - *datastr++ = 0x00; - if (!*datastr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid field syntax", NULL); - } - - /* Get the nesting level */ - expr->strval = datastr; - for (closing = 0; *datastr; datastr++) - switch (*datastr) - { - case '(': - opening++; - break; - case ')': - closing++; - if (closing > opening) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid closing brace in field value", NULL); - } - break; - case ',': - if (opening == closing) - { - *datavalue = datastr + 1; - for (*datastr-- = 0x00; *datastr == ')' && beginning-- > 0; - *datastr-- = 0x00) - *namend++ = 0x00; - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] NEW REVMEXPR = %s :: %s \n", - expr->label, expr->strval); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - } - break; - default: - break; - } - - /* Well-bracketed end of string : OK */ - if (opening == closing) - { - for (*datavalue = datastr--; *datastr == ')' && beginning-- > 0; - *datastr-- = 0x00) - *namend++ = 0x00; - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] NEW REVMEXPR = %s ::: %s \n", - expr->label, expr->strval); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - } - - /* Default error */ - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Malformed parent field value", NULL); -} - - -/* Initialize an ERESI expression */ -static revmexpr_t *revm_expr_init(char *curpath, - revmexpr_t *curexpr, - aspectype_t *curtype, - void *srcdata, - char *datavalue) -{ - static u_int toplevel = 1; - static u_int pathsize = 0; - char pathbuf[BUFSIZ + 1] = {0x00}; - char *recpath; - revmexpr_t *newexpr, *rootexpr, *prevexpr, *expr; - void *childata; - aspectype_t *childtype; - revmexpr_t *curdata; - u_int len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!curexpr) - toplevel = 1; - newexpr = rootexpr = prevexpr = NULL; - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Entering revm_expr_init with toplevel = %u\n", toplevel); -#endif - - /* Preliminary processing */ - if (!curexpr) - { - strncpy(pathbuf, curpath, BUFSIZ); - recpath = pathbuf; - pathsize = strlen(curpath); - } - else - recpath = curpath; - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Current expr path(%s) \n", recpath); -#endif - - /* Construct the expression until end of ascii string */ - while (*datavalue) - { - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Current datavalue = (%s) \n", datavalue); -#endif - - /* Read next typed expression in string */ - newexpr = revm_expr_read(&datavalue); - if (newexpr == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read expression value", NULL); - - /* If we are at the root expression, type might have been implicit */ - if (toplevel && newexpr->label) - { - -#if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] Top level type with explicit type label = (%s) strval = (%s) \n", - newexpr->label, newexpr->strval); -#endif - - if (strcmp(newexpr->label, curtype->name)) - { - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Type checking failed during expression initialization", NULL); - } - datavalue = newexpr->strval; - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - toplevel = 0; - continue; - } - else if (!curexpr && !newexpr->label) - { - toplevel = 0; - datavalue = newexpr->strval; - -#if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] No explicit top-level type, continuing with datavalue = %s \n", - datavalue); -#endif - - continue; - } - else - toplevel = 0; - - /* If the substructure is initialized with the value of another expression, no need to - do any additional read, init or inform on the current field */ - if (*newexpr->strval == REVM_VAR_PREFIX) - { - expr = revm_expr_get(newexpr->strval); - if (!expr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get root field or type name", NULL); - } - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] FOUND EXISTING INITIAL REVMEXPR = %s :: %s (doing copy) \n", - expr->label, expr->strval); -#endif - - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, ".%s", newexpr->label); - newexpr = revm_expr_copy(expr, recpath, 1); - bzero(recpath + pathsize, len); - if (!newexpr) - { - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy existing initial subexpression", NULL); - } - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] COPIED EXISTING INITIAL REVMEXPR = %s :: %s (new name) \n", - newexpr->label, newexpr->strval); -#endif - - goto loopend; - } - - /* Else we check if the field has children */ - childtype = aspect_type_get_child(curtype, newexpr->label); - if (!childtype) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid child structure for variable", NULL); - } - newexpr->type = childtype; - - /* Duplicate names cause they are on the stack now */ - newexpr->label = (char *) strdup(newexpr->label); - newexpr->strval = (char *) strdup(newexpr->strval); - - /* Non-terminal case : we will need to recurse */ - if (childtype->childs && !childtype->dimnbr) - { - -#if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] NOW RECORD field, recursing ! \n"); -#endif - - childata = (char *) srcdata + childtype->off; - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, - ".%s", childtype->fieldname); - revm_inform_type_addr(childtype->name, recpath, - (eresi_Addr) childata, newexpr, 0, 0); - pathsize += len; - - /* Insert child where necessary */ - if (!revm_expr_init(recpath, newexpr, childtype, - childata, newexpr->strval)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid child tree for variable", NULL); - } - - pathsize -= len; - bzero(pathbuf + pathsize, len); - } - - /* Terminal case : no recursion */ - else - { - -#if __DEBUG_EXPRS_MORE__ - fprintf(stderr, " [D] NOW Terminal field, setting its value\n"); -#endif - - /* Handle RAW terminal field */ - if (childtype->type == ASPECT_TYPE_RAW) - { - //FIXME: Call hexa converter curval.datastr and set field - fprintf(stderr, " [E] Raw object initialization yet unsupported.\n"); - continue; - } - - /* Lookup scalar value and assign it to the field */ - newexpr->value = revm_object_lookup_real(curtype, recpath, - childtype->fieldname, 0); - curdata = revm_lookup_param(newexpr->strval); - if (!newexpr->value || !curdata) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup src or dst object", NULL); - } - - /* Convert source data to recipient type and set it */ - if (newexpr->type->type != curdata->type->type) - revm_convert_object(curdata, newexpr->type->type); - if (revm_object_set(newexpr, curdata) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to set destination object", NULL); - } - - /* Destroy the temporary variable we have created for the right-hand-side value */ - if (revm_variable_istemp(curdata)) - revm_expr_destroy(curdata->label); - - /* Handle terminal Array fields */ - if (childtype->dimnbr && childtype->elemnbr) - { - //FIXME: Use child->elemnbr[idx] foreach size of dim (Use previous code in loop) - fprintf(stderr, - " [E] Arrays objects initialization unsupported\n"); - continue; - } - - /* Inform the runtime system about this terminal field */ - childata = (char *) srcdata + childtype->off; - len = snprintf(recpath + pathsize, BUFSIZ - pathsize, - ".%s", childtype->fieldname); - revm_inform_type_addr(childtype->name, recpath, - (eresi_Addr) childata, newexpr, 0, 0); - bzero(recpath + pathsize, len); - } - - /* Link next field of current structure */ - loopend: - newexpr->parent = curexpr; - if (curexpr) - { - rootexpr = curexpr; - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - { - curexpr->childs = newexpr; - prevexpr = newexpr; - } - } - else - { - if (prevexpr) - { - prevexpr->next = newexpr; - prevexpr = newexpr; - } - else - rootexpr = prevexpr = newexpr; - } - - - } - - /* Return success or error */ - if (!rootexpr) - { - if (newexpr) - XFREE(__FILE__, __FUNCTION__, __LINE__, newexpr); - pathsize = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find a root expression", NULL); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, rootexpr); -} - - - -/* Compare or Set source and destination */ -/* OP = REVM_OP_SET or REVM_OP_MATCH */ -static int revm_expr_handle(revmexpr_t *dest, - revmexpr_t *source, - u_char op) -{ - int ret; - eresi_Addr cmpval; - revmexpr_t *cursource; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (!dest || !source) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - if (op != REVM_OP_SET && op != REVM_OP_MATCH) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested operation", -1); - - /* Recursive comparison or setting */ - for (cmpval = 0; dest; dest = dest->next) - { - - /* Find this field in the current hierarchy list of fields */ - for (cursource = source; cursource; cursource = cursource->next) - if (!strcmp(dest->label, cursource->label)) - break; - if (!cursource) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find expression field", -1); - - if (cursource->childs) - { - ret = revm_expr_handle(dest->childs, cursource->childs, op); - if (ret != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - continue; - } - - /* FIXME-XXX: set/match in case of array ! */ - /* FIXME-XXX: set/match in case of raw type ! */ - - /* Now realize the operation depending if we are a leaf or not */ - switch (op) - { - case REVM_OP_SET: - if ((ret = revm_object_set(dest, cursource)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression field", ret); - break; - case REVM_OP_MATCH: - if ((ret = revm_object_compare(dest, cursource, &cmpval)) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to compare expression fields", ret); - if (cmpval) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - break; - } - } - - /* Final checks and result */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Get (and optionally print) the tree of an expression */ -static int revm_expr_printrec(revmexpr_t *expr, u_int taboff, u_int typeoff, u_int iter) -{ - aspectype_t *curtype; - char buf[BUFSIZ]; - int len; - char *size; - char *typename; - char offset[128]; - int idx; - int sz; - char *pad, *pad2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (; expr; expr = (iter ? expr->next : NULL)) - { - - /* Get type of the first real top level expression */ - curtype = expr->type; - typename = curtype->name; - - /* Some printing header */ - revm_endline(); - len = snprintf(buf, sizeof(buf), "%s%*s %*s", - (curtype->isptr ? revm_colorwarn(" *") : ""), - (iter ? 18 - (curtype->isptr * 4) : 0), - revm_colorfieldstr(typename), - (iter ? 18 : 0), - revm_colortypestr_fmt("%10s", expr->label)); - - sz = (taboff < 21 ? 0 : len - revm_color_size(buf) - 20); - pad = alloca(taboff + sz + 1); - memset(pad, ' ', taboff + sz); - pad[taboff + sz] = 0x00; - - /* If the expr is a structure */ - if (expr->childs) - { - revm_output(buf); - revm_output(revm_colorwarn(" {")); - revm_endline(); - revm_expr_printrec(expr->childs, - taboff + len - revm_color_size(buf) - 7, - typeoff, iter); - revm_output(revm_colorwarn("}")); - if (expr->next) - { - revm_output(",\n"); - pad2 = alloca(taboff + 1); - memset(pad2, ' ', taboff); - pad2[taboff] = 0x00; - revm_output(pad2); - } - - /* Do not add offset if we are in union */ - if (expr->next && expr->next->type->off != curtype->off) - typeoff += (expr->type->isptr ? 4 : curtype->size); - - continue; - } - - // FIXME-XXX: Print up to 10 bytes - if (curtype->type == ASPECT_TYPE_RAW) - { - size = alloca(100); - snprintf(size, 100, "%s%s%s", - revm_colorwarn("["), - revm_colornumber("%u", curtype->size), - revm_colorwarn("] = {...} ")); - } - - // FIXME-XXX: Print up 10 elements of array ... - else if (curtype->dimnbr && curtype->elemnbr) - { - for (sz = idx = 0; idx < curtype->dimnbr; idx++) - sz += 40; - size = alloca(sz + 50); - for (sz = idx = 0; idx < curtype->dimnbr; idx++) - sz += sprintf(size + sz, "%s%s%s", - revm_colorwarn("["), - revm_colornumber("%u", curtype->elemnbr[idx]), - revm_colorwarn("]")); - sz += sprintf(size + sz, "%s", revm_colorwarn(" = {...} ")); - } - else - { - size = alloca(50); - snprintf(size, 50, "%s", revm_colorwarn(" = ")); - } - - /* Print everything in order */ - revm_output(buf); - revm_output(size); - if (expr->value) - revm_object_print(expr->value); - - /* Next field ! Print offset .. */ - if (iter && expr->next) - { - snprintf(offset, sizeof(offset), "@ off(%s)", revm_colornumber("%u", typeoff)); - revm_output(offset); - revm_output(revm_colorwarn(",\n")); - revm_output(pad); - - /* Do not add size if we are in a union */ - if (expr->next->type->off != curtype->off) - typeoff += (curtype->isptr ? 4 : curtype->size); - } - revm_endline(); - } - - /* Return success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Recursive copy of an expression */ -static int revm_expr_copyrec(revmexpr_t *parent, - revmexpr_t *dest, - revmexpr_t *source, - char *newname, - u_int namelen, - u_int nameoff, - char *data) -{ - int ret; - aspectype_t *type; - char *childata; - u_int len; - - /* Preliminary checks */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!dest || !source) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - - /* Recursive comparison or setting */ - while (source) - { - memcpy(dest, source, sizeof(revmexpr_t)); - if (source->label) - dest->label = strdup(source->label); - if (source->strval) - dest->strval = strdup(source->strval); - dest->parent = parent; - - /* Copy children structure */ - if (source->childs) - { - type = source->type; - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest->childs, sizeof(revmexpr_t), -1); - len = snprintf(newname + nameoff, namelen - nameoff, ".%s", source->label); - childata = data + type->off; - revm_inform_type_addr(type->name, strdup(newname), (eresi_Addr) childata, dest, 0, 0); - ret = revm_expr_copyrec(dest, dest->childs, source->childs, newname, - namelen, nameoff + len, childata); - if (ret != 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - bzero(newname + nameoff, len); - } - - /* FIXME-XXX: copy in case of array ! */ - /* FIXME-XXX: copy in case of raw type ! */ - - /* Copy terminal field */ - else if (source->value) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest->value, sizeof(revmobj_t), -1); - type = source->value->otype; - dest->value = revm_object_lookup_real(parent->type, newname, source->label, 0); - if (!dest->value) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, dest); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup terminal object", -1); - } - len = snprintf(newname + nameoff, namelen - nameoff, ".%s", source->label); - childata = data + type->off; - revm_inform_type_addr(type->name, strdup(newname), (eresi_Addr) childata, dest, 0, 0); - bzero(newname + nameoff, len); - if (revm_object_set(dest, source) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, dest); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy terminal object", -1); - } - } - - /* Allocate next element */ - source = source->next; - if (source) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest->next, sizeof(revmexpr_t), -1); - dest = dest->next; - } - } - - /* Final checks and result */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* Copy an expression (set $e1 $e2) */ -revmexpr_t *revm_expr_copy(revmexpr_t *source, char *dstname, u_char isfield) -{ - revmexpr_t *dest; - aspectype_t *type; - int ret; - char newname[BUFSIZ] = {0x00}; - int curoff; - char *copydata; - revmannot_t *annot; - char *str, *str2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First copy the data */ - type = source->type; - XALLOC(__FILE__, __FUNCTION__, __LINE__, copydata, type->size, NULL); - - /* Constants are not annotated, we might not want to do anything here */ - annot = revm_annot_get(source->label); - if (annot) - memcpy(copydata, (char *) annot->addr, type->size); - - /* Create a temporary variable if necessary (for constants) */ - if ((!isfield && *dstname != REVM_VAR_PREFIX) || - !strncmp(dstname, "$hash", 5) || - !strncmp(dstname, "$list", 5)) - dstname = revm_tmpvar_create(); - else - dstname = strdup(dstname); - - /* Then copy the expression meta-data */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest, sizeof(revmexpr_t), NULL); - strncpy(newname, dstname, sizeof(newname)); - curoff = strlen(newname); - if (source->strval) - dest->strval = strdup(source->strval); - - /* If we are copying a subexpression, make sure labels are copied relative */ - if (isfield) - { - for (str = newname; - str && *str && (str2 = strchr(str, '.')); - str = str2 + 1); - if (!str || !*str) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inform copy expression", NULL); - } - else - str = newname; - dest->label = strdup(str); - dest->type = type; - if (!revm_inform_type_addr(type->name, strdup(dstname), (eresi_Addr) copydata, dest, 0, 0)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to inform copy expression", NULL); - - /* Simple object copy is easier */ - if (source->value) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest->value, sizeof(revmobj_t), NULL); - dest->value->otype = dest->type; - dest->value->immed = 1; - dest->value->perm = 1; - ret = revm_object_set(dest, source); - } - - /* Some (structure) expressions have an extra top-level type, copy was done before the recursion */ - else if (source->childs) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest->childs, sizeof(revmexpr_t), NULL); - ret = revm_expr_copyrec(dest, dest->childs, source->childs, - newname, BUFSIZ, curoff, copydata); - } - - /* Failure: no value or complex type for source expr ? */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy expression in impossible default case", NULL); - - /* Return error or success */ - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to copy expression", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); -} - - -/* Create an expression from an object */ -revmexpr_t *revm_expr_create_from_object(revmobj_t *copyme, char *name) -{ - revmexpr_t *dest; - aspectype_t *type; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - dest = hash_get(&exprs_hash, name); - if (dest) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); - - /* Create a new temporary variable name if necessary */ - if (*name != REVM_VAR_PREFIX || - !strncmp(name, "$hash", 5) || - !strncmp(name, "$list", 5)) - name = revm_tmpvar_create(); - else - name = strdup(name); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, dest, sizeof(revmexpr_t), NULL); - dest->type = copyme->otype; - type = dest->type; - dest->label = name; - if (!copyme->otype || (aspect_type_simple(copyme->otype->type) && !copyme->otype->next)) - dest->value = copyme; - else - { - data = (void *) copyme->get_obj(copyme->parent); - if (!data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to dereference object", NULL); - if (!revm_inform_type_addr(type->name, name, (eresi_Addr) data, dest, 0, 1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create expression from complex object", NULL); - } - - hash_add(&exprs_hash , (char *) strdup(name), (void *) dest); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] Create_Expr_From_Object %s added with type = %s \n", - name, (type ? type->name : "UNKNOWN TYPE")); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, dest); -} - - -/* Print an annotated expression */ -int revm_expr_print(char *pathname) -{ - revmexpr_t *expr; - int ret; - char buf[BUFSIZ]; - int iter; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!pathname || *pathname != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - expr = hash_get(&exprs_hash, pathname); - if (!expr || !expr->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown expression name", -1); - - /* Make sure we only print the subrecord if requested */ - type = expr->type; - if (expr->childs) - { - expr = expr->childs; - iter = 1; - } - else - iter = (aspect_type_simple(expr->type->type) ? 0 : 1); - - /* If we are printing a simple type or a subtype expression, we need to print a top level */ - if (type->next || (type->childs && type->childs->next)) - { - snprintf(buf, BUFSIZ, " %s %s \t %s", - revm_colorfunction(type->name), - revm_colorfunction(pathname), revm_colorwarn("= {")); - revm_output(buf); - revm_endline(); - } - revm_expr_printrec(expr, (!iter || !expr->next ? strlen(pathname) + 6 : 1), 0, iter); - if (type->next || (type->childs && type->childs->next)) - revm_output(revm_colorwarn("}")); - revm_endline(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/* Get an expression from its name */ -revmexpr_t *revm_expr_get(char *pathname) -{ - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!pathname || *pathname != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", NULL); - expr = hash_get(&exprs_hash, pathname); - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid expression name", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); -} - -/* Set an expression to the value of another (only if compatible) */ -int revm_expr_set_by_name(char *dest, char *source) -{ - revmexpr_t *adst; - revmexpr_t *asrc; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!dest || !source || *dest != REVM_VAR_PREFIX || *source != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - adst = revm_expr_get(dest); - asrc = revm_expr_get(source); - if (!adst || !asrc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input parameters", -1); - - /* Return result */ - ret = revm_expr_set(adst, asrc); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression by name", ret); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Set an expression to the value of another (only if compatible) */ -int revm_expr_set(revmexpr_t *adst, revmexpr_t *asrc) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!adst || !asrc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - - /* Take care of top-level structure types */ - if (asrc->childs) - asrc = asrc->childs; - if (adst->childs) - adst = adst->childs; - - /* Necessary for assignment of scalar values */ - if (adst->value && asrc->value && !asrc->next) - { - /* See if object conversion is necessary and/or possible */ - if (revm_nextconds_atomics(adst, asrc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set scalar variable", -1); - if (revm_object_set(adst, asrc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set scalar variable", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Filter the base error case */ - else if (adst->value && !asrc->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot set scalar with complex value", ret); - else if (!adst->value && asrc->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot set structure with scalar value", ret); - - /* Set a whole structure or a substructure */ - else - ret = revm_expr_handle(adst, asrc, REVM_OP_SET); - - /* Result */ - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression", ret); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Compare 2 typed expressions */ -int revm_expr_compare_by_name(char *original, char *candidate, eresi_Addr *val) -{ - revmexpr_t *candid; - revmexpr_t *orig; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!candidate || !original || *candidate != REVM_VAR_PREFIX || *original != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - candid = revm_expr_get(candidate); - orig = revm_expr_get(original); - if (!candid || !orig) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input parameters", -1); - - ret = revm_expr_compare(orig, candid, val); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/* Compare 2 typed expressions */ -int revm_expr_compare(revmexpr_t *orig, revmexpr_t *candid, eresi_Addr *val) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Take care of top-level structure types */ - if (orig->childs) - orig = orig->childs; - if (candid->childs) - candid = candid->childs; - - /* Comparison between simple objects */ - /* Necessary for comparison with constants without a tree/field structure */ - if (orig->value && candid->value && !orig->next && !candid->next) - { - if (revm_object_compare(orig, candid, val) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Filter the base error case */ - else if ((orig->value && !candid->value) || (!orig->value && candid->value)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot compare scalar with complex expression", ret); - - /* Comparison between whole structures */ - /* A comparison is an symmetric matching of the 2 objects */ - else - { - ret = revm_expr_handle(candid, orig, REVM_OP_MATCH); - if (!ret) - ret = revm_expr_handle(orig, candid, REVM_OP_MATCH); - } - - /* Return result */ - *val = ret; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/* Match or not 2 typed expressions */ -int revm_expr_match_by_name(char *original, char *candidate) -{ - revmexpr_t *candid; - revmexpr_t *orig; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!candidate || !original || *candidate != REVM_VAR_PREFIX || *original != REVM_VAR_PREFIX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - candid = revm_expr_get(candidate); - orig = revm_expr_get(original); - if (!candid || !orig) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input parameters", -1); - ret = revm_expr_match(candid, orig); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/* Match or not 2 typed expressions */ -int revm_expr_match(revmexpr_t *candid, revmexpr_t *orig) -{ - int ret; - eresi_Addr *val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!candid || !orig) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameters", -1); - - /* Take care of top-level structure types */ - if (!orig->next && orig->childs) - orig = orig->childs; - if (!candid->next && candid->childs) - candid = candid->childs; - - /* For simple objects */ - if (orig->value && candid->value && !orig->next && !candid->next) - { - if (revm_object_compare(orig, candid, val) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Comparison between whole structures */ - /* A comparison is an symmetric matching of the 2 objects */ - else if ((orig->value && !candid->value) || (!orig->value && candid->value)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot match scalar with complex expression", ret); - - /* Comparison between substructures */ - else - ret = revm_expr_handle(candid, orig, REVM_OP_MATCH); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - -/* Create a new revm expression */ -revmexpr_t *revm_expr_create(aspectype_t *datatype, - char *dataname, - char *datavalue) -{ - revmexpr_t *expr; - revmexpr_t *source; - char *data; - char *realname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!dataname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid name for expression", NULL); - if (!datatype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for expression", NULL); - - /* Create a new temporary if necessary */ - if (*dataname != REVM_VAR_PREFIX || - !strncmp(dataname, "$hash", 5) || - !strncmp(dataname, "$list", 5)) - dataname = revm_tmpvar_create(); - else - dataname = strdup(dataname); - - /* In case the source value is an existing expression, lets find it now */ - source = revm_expr_get(datavalue); - if (source) - { - expr = revm_expr_copy(source, dataname, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - } - - /* Else we create and initialize a new expression */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, data, datatype->size, NULL); - realname = dataname; - revm_inform_type_addr(datatype->name, realname, (eresi_Addr) data, NULL, 0, 0); - - if (!datatype->next && datatype->childs) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, sizeof(revmexpr_t), NULL); - expr->strval = strdup(datavalue); - expr->label = dataname; - expr->type = datatype; - expr->childs = revm_expr_init(dataname, NULL, datatype, data, datavalue); - } - else - expr = revm_expr_init(dataname, NULL, datatype, data, datavalue); - - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create REVMEXPR", NULL); - revm_inform_type_addr(datatype->name, realname, (eresi_Addr) data, expr, 0, 0); - -#if __DEBUG_EXPRS__ - revm_expr_print(expr->label); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); -} - - -/* Simply create an expression from a constant value */ -revmexpr_t *revm_simple_expr_create(aspectype_t *datatype, char *name, char *value) -{ - revmexpr_t *expr; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, expr, sizeof(revmexpr_t), NULL); - if (value) - obj = revm_lookup_immed(value); - else - obj = revm_object_lookup_real(datatype, name, NULL, 0); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create REVMEXPR", NULL); - - if (*name != REVM_VAR_PREFIX || !strncmp(name, "$hash", 5) || !strncmp(name, "$list", 5)) - name = revm_tmpvar_create(); - else - name = strdup(name); - - expr->type = datatype; - expr->strval = (value ? strdup(value) : NULL); - expr->value = obj; - expr->label = name; - hash_add(&exprs_hash , (char *) strdup(name), (void *) expr); - -#if __DEBUG_EXPRS__ - fprintf(stderr, " [D] SimpleExpr %s added with type = %s \n", - name, (datatype ? datatype->name : "UNKNOWN TYPE")); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); -} - - -/* Read the requested type for an expression in ascii form */ -aspectype_t *revm_exprtype_get(char *exprvalue) -{ - aspectype_t *type; - char *typename; - u_int typenamelen; - char *curexprvalue; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!exprvalue) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - type = NULL; - for (curexprvalue = exprvalue, typenamelen = 0; *curexprvalue != '('; typenamelen++) - curexprvalue++; - typename = alloca(typenamelen + 1); - strncpy(typename, exprvalue, typenamelen); - typename[typenamelen] = 0x00; - type = aspect_type_get_by_name(typename); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown expression type", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, type); -} - - - -/* Destroy an expression and remove it from the hash table */ -int revm_expr_destroy(char *e) -{ - revmexpr_t *expr; - revmexpr_t *child; - char newname[BUFSIZ]; - hash_t *thash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - -#if __DEBUG_EXPRS__ - printf("\n [D] DestroyExpr %s \n", e); -#endif - - expr = hash_get(&exprs_hash, e); - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown expr parameter", -1); - hash_del(&exprs_hash, e); - - if (expr->type) - { - snprintf(newname, sizeof(newname), "type_%s", expr->type->name); - thash = hash_find(newname); - if (thash) - hash_del(thash, e); - } - - // FIXME: fault when calling destroy_object - // An object was not copied/reallocated correctly somewhere - if (expr->value) - //revm_destroy_object(expr->value); - XFREE(__FILE__, __FUNCTION__, __LINE__, expr->value); - - for (child = expr->childs; child; child = child->next) - { - snprintf(newname, sizeof(newname), "%s.%s", e, child->label); - if (revm_expr_destroy(newname) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to destroy child expression", -1); - } - - XFREE(__FILE__, __FUNCTION__, __LINE__, expr); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/grammar.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/grammar.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/grammar.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/grammar.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,696 +0,0 @@ -/** - * @file grammar.c - * @ingroup librevm_lang - * @brief We dont use bison and have our own parser generator. - * - * Started on Sun Feb 9 22:57:58 2003 jfv - * $Id: grammar.c,v 1.21 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "revm.h" - - -/** - * @brief Get a va_list of parameters - */ -static int parse_lookup_varlist(char *param, char *fmt, ...) -{ - int rc; - va_list arg_ptr; - - va_start(arg_ptr, fmt); - rc = vsscanf(param, fmt, arg_ptr); - va_end(arg_ptr); - return (rc); -} - - -/** - * @brief Parse a vector access - */ -revmobj_t *parse_vector(char *param, char *fmt) -{ - u_int size; - char index[ELFSH_MEANING]; - vector_t *cur; - int dimnbr; - unsigned int *dims; - revmobj_t *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - size = parse_lookup_varlist(param, fmt, index); - if (size != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - if (!strchr(index, ':')) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Index parser failed", NULL); - - /* Grab the vector */ - dimnbr = revm_vectors_getdimnbr(index); - dims = alloca(dimnbr * sizeof(unsigned int)); - revm_vectors_getdims(index, dims); - cur = aspect_vector_get(index); - - /* Early sanity checks */ - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", NULL); - if (revm_vector_bad_dims(cur, dims, dimnbr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", NULL); - - /* Get a pointer on the desired entry of the vector */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,ret, sizeof(revmobj_t), NULL); - ret->parent = aspect_vectors_selectptr(cur, dims); - ret->otype = aspect_type_get_by_id(cur->type); - ret->perm = 1; - ret->immed = 0; - ret->get_obj = (void *) revm_generic_getobj; - ret->set_obj = (void *) revm_long_setobj; - - /* Success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * @brief Parse a hash access - */ -revmobj_t *parse_hash(char *param, char *fmt) -{ - u_int size; - char index[ELFSH_MEANING]; - hash_t *hash; - revmobj_t *ret; - char *entryname; - char *hashname; - void *ptr; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - size = parse_lookup_varlist(param, fmt, index); - if (size != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - - /* Get hash table and entry */ - entryname = strchr(index, ':'); - if (entryname) - *entryname++ = 0x00; - - /* Resolve hash name without messing with variable type */ - expr = revm_expr_get(index); - if (expr) - { - if (!expr->type || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - ret = revm_copy_object(expr->value); - if (revm_convert_object(expr, ASPECT_TYPE_STR) < 0) - { - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", NULL); - } - hashname = strdup(expr->value->immed_val.str); - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - } - else - hashname = revm_lookup_string(index); - - /* Resolve entry name without messing with variable type */ - if (entryname) - { - expr = revm_expr_get(entryname); - if (expr) - { - if (!expr->type || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - ret = revm_copy_object(expr->value); - if (revm_convert_object(expr, ASPECT_TYPE_STR) < 0) - { - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown key for source object", NULL); - } - entryname = strdup(expr->value->immed_val.str); - revm_destroy_object(expr->value); - expr->value = ret; - expr->type = ret->otype; - } - else - entryname = revm_lookup_string(entryname); - } - - /* In case the hash table does not exist, create it empty */ - hash = hash_find(hashname); - if (!hash) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - hash, sizeof(hash_t), NULL); - hash_init(hash, strdup(hashname), 7, ASPECT_TYPE_UNKNOW); - } - - /* Now deal with the entry */ - ptr = (entryname ? hash_get(hash, entryname) : (void *) hash); - - /* Get an revm object */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,ret, sizeof(revmobj_t), NULL); - ret->parent = ptr; - ret->otype = aspect_type_get_by_id((entryname ? hash->type : ASPECT_TYPE_HASH)); - ret->hname = (hashname ? strdup(hashname) : NULL); - ret->kname = (entryname ? strdup(entryname) : NULL); - ret->contype = CONT_HASH; - ret->perm = 1; - ret->immed = 0; - ret->get_obj = revm_hash_getobj; - ret->set_obj = (void *) (entryname ? revm_long_setobj : NULL); - - /* Success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - -/** - * @brief Parse a hash access - */ -revmobj_t *parse_list(char *param, char *fmt) -{ - u_int size; - char index[ELFSH_MEANING]; - list_t *list; - revmobj_t *ret; - char *entryname; - char *listname; - void *ptr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - size = parse_lookup_varlist(param, fmt, index); - if (size != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - - /* Get hash table and entry */ - entryname = strchr(index, ':'); - if (entryname) - *entryname++ = 0x00; - listname = strdup(index); - - /* In case the hash table does not exist, create it empty */ - list = elist_find(listname); - if (!list) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - list, sizeof(list_t), NULL); - elist_init(list, listname, ASPECT_TYPE_UNKNOW); - } - - /* Now deal with the entry */ - ptr = (entryname ? elist_get(list, entryname) : (void *) list); - - /* Get an revm object */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, ret, sizeof(revmobj_t), NULL); - ret->parent = ptr; - ret->otype = aspect_type_get_by_id((entryname ? list->type : ASPECT_TYPE_LIST)); - ret->hname = (listname ? strdup(listname) : NULL); - ret->kname = (entryname ? strdup(entryname) : NULL); - ret->contype = CONT_LIST; - ret->perm = 1; - ret->immed = 0; - ret->get_obj = revm_hash_getobj; /* We can keep this one for lists too */ - ret->set_obj = (void *) (entryname ? revm_long_setobj : NULL); - - /* Success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - - -/** - * @brief Lookup a parameter with 3 fields, 3rd field beeing an index - * Used by GOT, CTORS, DTORS - */ -revmobj_t *parse_lookup3_index(char *param, char *fmt, u_int sep) -{ - revmL1_t *l1; - void *robj; - void *o1; - u_int size; - u_int real_index; - revmobj_t *pobj; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (sep != 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - real_index = 0; - - // Check if this handler is the correct one - size = parse_lookup_varlist(param, fmt, obj, L1field, index); - if (size != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - - // Let's ask the hash table for the current working file - robj = revm_lookup_file(obj); - if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", NULL); - - // Then, we ask the Level 1 object - l1 = hash_get(&L1_hash, L1field); - if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", NULL); - - else if (l1->get_entptr == NULL || l1->get_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bad object path", NULL); - - pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); - pobj->immed = 0; - - // Lookup object - o1 = l1->get_obj(robj, &size); - - // Lookup index - real_index = revm_lookup_index(index); - - //printf("GOT real_index = " XFMT " unsigned: " UFMT " signed: " DFMT "\n", - // real_index, real_index, real_index); - - if (((int) real_index) < 0) - { - - if (l1->get_obj_nam == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); - else - { - - //printf("looking up get_obj_name in GOT ! \n"); - - pobj->parent = l1->get_obj_nam(robj, index); - - /* - printf("GOT pobjparent = %p (with name = %s) \n", pobj->parent, index); - printf("GOT sect data = %p (GOT name = %s) \n", - ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->data, - ((elfshobj_t *) robj)->secthash[ELFSH_SECTION_GOT]->name); - */ - - if (pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No entry by that name", NULL); - } - } - - // Do index sanity - if (pobj->parent == NULL) - { - if (size <= real_index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Index too big", NULL); - pobj->parent = l1->get_entptr(o1, real_index); - } - - // Finally we fill the intermediate object format for the guessed object - pobj->get_obj = (void *) l1->get_entval; - pobj->set_obj = (void *) l1->set_entval; - pobj->otype = aspect_type_get_by_id(ASPECT_TYPE_CADDR); - pobj = revm_check_object(pobj); - if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); -} - - - - -/** - * Lookup a parameter with 3 fields, all fields beeing non indexed - * Only used by ELF header 'til now - */ -revmobj_t *parse_lookup3(char *param, char *fmt, u_int sep) -{ - revmL1_t *l1; - revmL2_t *l2; - void *robj; - revmobj_t *pobj; - - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (sep != 2) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - // Check if this handler is the correct one - ret = parse_lookup_varlist(param, fmt, obj, L1field, L2field); - if (ret != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - - // Let's ask the hash table for the current working file - robj = revm_lookup_file(obj); - if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", - NULL); - - // Then, we ask the Level 1 object - l1 = hash_get(&L1_hash, L1field); - if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", - NULL); - else if (l1->get_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object path", - NULL); - - // Then the Level 2 object - l2 = hash_get(l1->l2list, L2field); - if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L2 object", - NULL); - - // Finally we fill the intermediate object format for the guessed object - pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); - pobj->immed = 0; - pobj->get_obj = (void *) l2->get_obj; - pobj->set_obj = (void *) l2->set_obj; - pobj->otype = aspect_type_get_by_id(l2->type); - pobj->parent = l1->get_obj(robj, NULL); - pobj = revm_check_object(pobj); - - if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); -} - - - - -/** - * Lookup a parameter with 4 fields, 3rd field beeing an index - * Used by SHT, PHT, SYMTAB, DYNSYM , Sections, .dynamic - * - * Here need to add 1.rel[name].{L2fields} lookup - */ -revmobj_t *parse_lookup4(char *param, char *fmt, u_int sep) -{ - revmL1_t *l1; - revmL2_t *l2; - void *robj; - void *o1; - int real_index; - int isversion; - u_int size; - revmobj_t *pobj; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; - char offfield[ELFSH_MEANING]; - char sizelemfield[ELFSH_MEANING]; - u_int off; - u_int sizelem; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* This handler has 3 possibles syntax */ - switch (sep) - { - case 4: - ret = parse_lookup_varlist(param, fmt, obj, L1field, - index, offfield, sizelemfield, L2field); - sizelem = atoi(sizelemfield); - off = atoi(offfield); - break; - case 3: - ret = parse_lookup_varlist(param, fmt, obj, L1field, - index, offfield, L2field); - sizelem = 1; - off = atoi(offfield); - break; - case 2: - ret = parse_lookup_varlist(param, fmt, obj, L1field, index, L2field); - sizelem = 1; - off = 0; - break; - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - } - - /* Quick test to see if we matched */ - if (ret - 2 != sep) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - /* Let's ask the hash table for the current working file */ - robj = revm_lookup_file(obj); - if (NULL == robj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown file object", - NULL); - - // Then, we ask the Level 1 object - l1 = hash_get(&L1_hash, L1field); - if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L1 object", - NULL); - else if (l1->get_entptr == NULL || l1->get_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incorrect object path", - NULL); - - // Then the Level 2 object - l2 = hash_get(l1->l2list, L2field); - if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown L2 object", - NULL); - - // Read object - o1 = l1->get_obj(robj, (void *) &size); - if (o1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot read object", - NULL); - - pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); - pobj->immed = 0; - - // Do lookup by index or by name - real_index = (int) revm_lookup_index(index); - -#if __DEBUG_LANG__ - printf("LOOKUP4 object index = %s, real_index = %u (signed = %d) \n", - index, real_index, real_index); -#endif - - // Index error handling - if (real_index < 0) - { - if (l1->get_obj_nam == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); - else - { - pobj->parent = l1->get_obj_nam(robj, index); - if (pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No L1 index by this name", NULL); - } - } - - // Get L2 object by index (or type for dynamic) - if (pobj->parent == NULL) - { - - if (!strcmp(L1field, "dynamic") && !revm_isnbr(index)) - real_index = elfsh_get_dynent_by_type(robj, o1, real_index); - - isversion = (!strcmp(L1field, "version") || - !strcmp(L1field, "verdef") || - !strcmp(L1field, "verneed")); - - if (!isversion && size <= real_index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "L1 index too big", NULL); - - pobj->parent = l1->get_entptr(o1, real_index); - - if (isversion && pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown L2 object or Invalid L1 index", - NULL); - } - - // Finally we fill the intermediate object format for the guessed object - pobj->get_obj = (void *) l2->get_obj; - pobj->set_obj = (void *) l2->set_obj; - pobj->get_name = (void *) l2->get_name; - pobj->set_name = (void *) l2->set_name; - - // The 2 next fields are used for 'raw' L2 of 'section' L1 - pobj->get_data = (void *) l2->get_data; - pobj->set_data = (void *) l2->set_data; - - pobj->otype = aspect_type_get_by_id(l2->type); - pobj->off = off; - pobj->sizelem = sizelem; - pobj->root = robj; - - // Error checking - pobj = revm_check_object(pobj); - if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); -} - - - - -/** - * Lookup a parameter with 5 fields, 3rd and 5th field beeing indexes - * Used for Relocation tables and GOT tables - */ -revmobj_t *parse_lookup5_index(char *param, char *fmt, u_int sep) -{ - revmL1_t *l1; - revmL2_t *l2; - void *robj; - void *o1; - int real_index; - int real_index2; - u_int size; - int isversion; - revmobj_t *pobj; - elfshsect_t *sect; - char obj[ELFSH_MEANING]; - char L1field[ELFSH_MEANING]; - char L2field[ELFSH_MEANING]; - char index[ELFSH_MEANING]; - char index2[ELFSH_MEANING]; - int ret; - -#if 0 - char logbuf[BUFSIZ]; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (sep != 2) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - // Check if this handler is the correct one - ret = parse_lookup_varlist(param, fmt, obj, L1field, index, index2, L2field); - if (ret != 5) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parser handling failed", NULL); - - // Let's ask the hash table for the current working file - robj = revm_lookup_file(obj); - if (robj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested file object", - NULL); - - // Then, we ask the Level 1 object - l1 = hash_get(&L1_hash, L1field); - if (l1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L1 object", NULL); - else if (l1->get_entptr == NULL || l1->get_obj_idx == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "This object needs 2 indexes", NULL); - - // Then the Level 2 object - l2 = hash_get(l1->l2list, L2field); - if (l2 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested L2 object", NULL); - else if (l2->get_obj == NULL || l2->set_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Child object is invalid", NULL); - - // Not clean .. need to ve virtualized - isversion = (!strcmp(L1field, "version") || - !strcmp(L1field, "verdef") || - !strcmp(L1field, "verneed")); - - // Get indexes - real_index = (int) revm_lookup_index(index); - real_index2 = (int) revm_lookup_index(index2); - -#if 0 - snprintf(logbuf, BUFSIZ - 1, - "[DEBUG_MODEL] Lookup5_index : index(" UFMT ") rindex(" UFMT ") \n", - real_index, real_index2); - revm_output(logbuf); -#endif - - // Do index sanity - o1 = l1->get_obj_idx(robj, real_index, (u_int *) &size); - if (!isversion && size <= real_index2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Second index too big", NULL); - - if (isversion && o1 == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid L1 index", NULL); - - // printf("[DEBUG_RELOCS_IDX2] o1 = %p, o1->data = %p (%s) \n", - // o1, ((elfshsect_t*)o1)->data, ((elfshsect_t*)o1)->name); - - // - // This elfsh_get_reloc() returns a elfshsect_t *, - // and we need to grab the ->data pointer, to avoid rewriting a - // new handler (its not fair but it works .. ;) and its acceptable - // since only relocation tables use this rule. - - sect = (elfshsect_t *) o1; - o1 = elfsh_get_raw(sect); - - // Finally we fill the intermediate object format for the guessed object - pobj = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 0, 0); - pobj->immed = 0; - pobj->get_obj = (void *) l2->get_obj; - pobj->set_obj = (void *) l2->set_obj; - pobj->otype = aspect_type_get_by_id(l2->type); - - // ugly flag to put for dynamic Rel vs Rela information - elfsh_setrel(IS_REL(sect)); - pobj->parent = l1->get_entptr(o1, real_index2); - - if (isversion && pobj->parent == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown L2 object or Invalid L2 index", - NULL); - - // Error checking - pobj = revm_check_object(pobj); - if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid REVM object", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, pobj); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/lookup.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/lookup.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/lookup.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/lookup.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,430 +0,0 @@ -/** - * @file lookup.c - * @ingroup librevm_lang - * @brief Various object lookup functions built in the language. - * - * Started Nov 21 2003 jfv - * $Id: lookup.c,v 1.20 2008-02-16 12:32:27 thor Exp $ - */ -#include "revm.h" - - -/** - * @brief Support for double (or multiple) variables : $$name, $$$name, etc - */ -revmexpr_t *revm_lookup_var(char *param) -{ - revmexpr_t *e; - revmobj_t *ptr; - int indir; - char namebuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - - for (indir = 0; *param == REVM_VAR_PREFIX; indir++, param++); - e = NULL; - ptr = NULL; - if (!*param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - while (indir--) - { - snprintf(namebuf, sizeof(namebuf), "$%s", param); - e = revm_expr_get(namebuf); - if (!e) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown variable", NULL); - ptr = e->value; - if (indir) - { - if (!ptr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Malformed variable", (NULL)); - if (revm_convert_object(e, ASPECT_TYPE_STR) < 0 || !ptr->immed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert variable to string", (NULL)); - param = ptr->immed_val.str; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, e); -} - - -/** - * @brief Get address value - */ -eresi_Addr revm_lookup_addr(char *param) -{ - elfsh_Sym *sym; - revmconst_t *actual; - char eol; - int ret; - revmobj_t *ptr; - revmexpr_t *expr; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", 0); - - /* Lookup .symtab */ - sym = elfsh_get_symbol_by_name(world.curjob->curfile, param); - if (sym != NULL && sym->st_value > 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_value); - - /* Lookup .dynsym */ - sym = elfsh_get_dynsymbol_by_name(world.curjob->curfile, param); - if (sym != NULL && sym->st_value > 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, sym->st_value); - - /* Lookup a variable */ - expr = revm_lookup_var(param); - if (expr && expr->value) - { - ptr = expr->value; - if (ptr->otype->type == ASPECT_TYPE_LONG || - ptr->otype->type == ASPECT_TYPE_CADDR || - ptr->otype->type == ASPECT_TYPE_DADDR) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (ptr->immed ? ptr->immed_val.ent : - (eresi_Addr) ptr->get_obj(ptr->parent))); - } - - /* Lookup a constant */ - /* FIXME : Constants must be differentiated by their size ! */ - actual = hash_get(&const_hash, param); - if (actual != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, actual->val); - - /* Lookup hexadecimal numeric value */ - ret = sscanf(param, XFMT "%c", &val, &eol); - if (ret == 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, val); - - /* No match -- returns ERR */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup address object", 0); -} - - - -/** - * @brief Get immediate value - */ -revmobj_t *revm_lookup_immed(char *param) -{ - elfsh_Sym *sym; - revmconst_t *actual; - char eol; - int ret; - char lbuf[4096]; - revmobj_t *ptr; - revmexpr_t *expr; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (NULL)); - - /* Lookup a known variable */ - expr = revm_lookup_var(param); - if (expr && expr->value) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr->value); - - /* Support for lazy creation of variables */ - if (*param == REVM_VAR_PREFIX) - { - ptr = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 1, 0); - expr = revm_expr_create_from_object(ptr, param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ptr); - } - - /* Not necessary to call those functions if there is no loaded file */ - if (world.curjob->curfile) - { - - /* Lookup .symtab */ - sym = elfsh_get_symbol_by_name(world.curjob->curfile, param); - if (sym != NULL && sym->st_value) - { - ptr = revm_create_LONG(0, sym->st_value); - goto good; - } - - /* Lookup .dynsym */ - sym = elfsh_get_dynsymbol_by_name(world.curjob->curfile, param); - if (sym != NULL && sym->st_value) - { - ptr = revm_create_LONG(0, sym->st_value); - goto good; - } - } - - - /* FIXME: Constants must be differentiated by their size ! */ - actual = hash_get(&const_hash, param); - if (actual != NULL) - { - ptr = revm_create_IMMED(ASPECT_TYPE_INT, 0, actual->val); - goto good; - } - - /* Lookup hexadecimal numeric value */ - ret = sscanf(param, XFMT "%c", &val, &eol); - if (ret == 1) - { - ptr = revm_create_LONG(0, val); - goto good; - } - - /* Lookup decimal numeric value */ - ret = sscanf(param, UFMT "%c", &val, &eol); - if (ret == 1) - { - ptr = revm_create_LONG(0, val); - goto good; - } - - /* Lookup a supplied string */ - bzero(lbuf, sizeof(lbuf)); - ret = sscanf(param, "%[^\n]4095%c", lbuf, &eol); - if (ret == 1) - { - ptr = revm_create_IMMEDSTR(0, strdup(lbuf)); - - goto good; - } - - /* No match -- returns ERR */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup object", (NULL)); - - /* Match */ - good: - - /* Now replace \x00 patterns if any */ - if (ptr->otype->type == ASPECT_TYPE_STR) - revm_filter_zero(ptr->immed_val.str); - - /* We matched -- returns OK */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ptr); -} - - - -/** - * @brief Lookup an index - */ -u_int revm_lookup_index(char *param) -{ - revmconst_t *actual; - revmobj_t *ptr; - revmexpr_t *expr; - char eol; - int ret; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", 0); - - /* Support for lazy creation of variables */ - expr = revm_lookup_var(param); - if (expr && expr->value) - { - ptr = expr->value; - if (ptr->otype->type == ASPECT_TYPE_INT || - ptr->otype->type == ASPECT_TYPE_SHORT || - ptr->otype->type == ASPECT_TYPE_BYTE || - ptr->otype->type == ASPECT_TYPE_LONG || - ptr->otype->type == ASPECT_TYPE_CADDR || - ptr->otype->type == ASPECT_TYPE_DADDR) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (ptr->immed ? (u_int) ptr->immed_val.ent : - (u_int) ptr->get_obj(ptr->parent))); - - if (revm_convert_object(expr, ASPECT_TYPE_INT) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameter", 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (ptr->immed ? (u_int) ptr->immed_val.ent : - (u_int) ptr->get_obj(ptr->parent))); - } - - /* Lookup a constant */ - actual = hash_get(&const_hash, param); - if (actual != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (u_int) actual->val); - - /* Lookup hexadecimal numeric value */ - ret = sscanf(param, XFMT "%c", &val, &eol); - if (ret == 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (val)); - - /* Lookup decimal numeric value */ - ret = sscanf(param, UFMT "%c", &val, &eol); - if (ret == 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (val)); - - /* We do not match -- returns ERR */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup valid object", ((u_int) -1)); -} - - - -/** - * @brief Lookup an index - */ -char *revm_lookup_string(char *param) -{ - revmexpr_t *expr; - revmobj_t *ptr; - char *oldparam; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (NULL)); - - oldparam = param; - param = strdup(param); - - /* Support for lazy creation of variables */ - expr = revm_lookup_var(param); - if (!expr || !expr->value) - { - revm_filter_zero(param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, param); - } - ptr = expr->value; - if (ptr->otype->type != ASPECT_TYPE_STR) - { - revm_convert_object(expr, ASPECT_TYPE_STR); - if (ptr->otype->type != ASPECT_TYPE_STR) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, param); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected object type", NULL); - } - } - if (ptr->get_name) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ptr->get_name(ptr->root, ptr->parent)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (ptr->immed ? ptr->immed_val.str : - (char *) ptr->get_obj(ptr->parent))); -} - - - -/** - * @brief Lookup the file pointed by name - */ -elfshobj_t *revm_lookup_file(char *param) -{ - u_int idx; - revmobj_t *ptr; - revmexpr_t *expr; - elfshobj_t *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Support for variable file lookup */ - idx = 0; - if (!param) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (NULL)); - expr = revm_lookup_var(param); - if (!expr || !expr->value) - idx = atoi(param); - else - { - ptr = expr->value; - if (ptr->otype->type == ASPECT_TYPE_INT) - idx = ptr->immed_val.ent; - else if (ptr->otype->type == ASPECT_TYPE_STR) - param = ptr->immed_val.str; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unexpected variable type", (NULL)); - } - - /* Let's ask the hash table for the current working file */ - ret = (idx ? revm_getfile(idx) : hash_get(&file_hash, param)); - if (ret == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "File not found", (NULL)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - - - - -/** - * Parse the parameter and fill the revmobj_t - */ -revmexpr_t *revm_lookup_param(char *param) -{ - revmobj_t *(*funcptr)(char *param, char *fmt, u_int sepnbr); - char **keys; - int keynbr; - char *parm; - unsigned int sepnbr; - unsigned int index; - revmobj_t *res; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - expr = revm_expr_get(param); - if (expr) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - - /* Find the number of fields in param */ - for (sepnbr = 0, parm = param; *parm; parm++) - if (*parm == REVM_SEP[0] || *parm == ':' || *parm == '%') - { - if (parm > param && parm[-1] == '[') - continue; - sepnbr++; - } - - /* Find the correct parsing handler */ - keys = hash_get_keys(&parser_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - funcptr = hash_get(&parser_hash, keys[index]); - res = funcptr(param, keys[index], sepnbr); - if (!res) - continue; - expr = revm_expr_create_from_object(res, param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - } - - /* If still not found, try manually inserted types */ - res = revm_object_lookup(param); - if (res) - { - expr = revm_expr_create_from_object(res, param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); - } - - /* If no good syntax is available, print error if we are not in probe mode */ - res = revm_lookup_immed(param); - if (!res) - { - revm_badparam(param); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve object", NULL); - } - - expr = revm_expr_create_from_object(res, param); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, expr); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -## -## Makefile for lang in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = access.c convert.c grammar.c lookup.c objects.c \ - options.c parser.c scanner.c variables.c expressions.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME32 = ../revm-lang.32.o -NAME64 = ../revm-lang.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libaspect/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -all32: $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) - -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< - -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/objects.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/objects.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/objects.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/objects.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,387 +0,0 @@ -/** - * @file objects.c - * @ingroup librevm_lang - * @brief Methods for creation of objects. - * - * See lts.c for Lazy Type System implementation - * - * Started on Mon Feb 24 12:21:12 2003 jfv - * - * - * $Id: objects.c,v 1.13 2007-11-28 07:56:09 may Exp $ - * - */ -#include "revm.h" - - -/** - * @brief Create constant object : Perm == 1 if the object is writable - */ -revmobj_t *revm_create_IMMED(char type, char perm, u_int val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR or create_LONG for that */ - if (type == ASPECT_TYPE_STR || type == ASPECT_TYPE_CADDR || - type == ASPECT_TYPE_CADDR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for immed", (NULL)); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(type); - new->size = 4; - new->immed_val.word = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * @brief Create constant object - */ -revmobj_t *revm_create_LONG(char perm, eresi_Addr val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_LONG); - new->size = sizeof(val); - new->immed_val.ent = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/** - * @brief Create constant object - */ -revmobj_t *revm_create_CADDR(char perm, eresi_Addr val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_CADDR); - new->size = sizeof(val); - new->immed_val.ent = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * @brief Create constant object - * - * @param perm - * @param val - * @return - */ -revmobj_t *revm_create_DADDR(char perm, eresi_Addr val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_DADDR); - new->size = sizeof(val); - new->immed_val.ent = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/** - * @brief Create constant object - */ -revmobj_t *revm_create_SHORT(char perm, u_short val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("created SHORT with val = %hu \n", val); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_SHORT); - new->size = 2; - new->immed_val.half = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * @brief Create constant object - */ -revmobj_t *revm_create_BYTE(char perm, u_char val) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("created BYTE with val = %hhu \n", val); - - /* Please use create_IMMEDSTR for that */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_BYTE); - new->size = 1; - new->immed_val.byte = val; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/** - * @brief Create constant string object - */ -revmobj_t *revm_create_IMMEDSTR(char perm, char *str) -{ - revmobj_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("created STR with val = %s \n", str); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmobj_t), NULL); - new->immed = 1; - new->perm = perm; - new->otype = aspect_type_get_by_id(ASPECT_TYPE_STR); - new->immed_val.str = str; - new->size = strlen(new->immed_val.str); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * @brief Create a redirection abstract object - */ -elfshredir_t *revm_create_REDIR(u_char type, char *sname, char *dname, - eresi_Addr saddr, eresi_Addr daddr) -{ - elfshredir_t *redir; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__,redir, sizeof(elfshredir_t), NULL); - redir->type = type; - redir->name[0] = sname; - redir->name[1] = dname; - redir->addr[0] = saddr; - redir->addr[1] = daddr; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (redir)); -} - - - - -/** - * @brief Now comes Level 1 objects hash functions - */ -revmL1_t *revm_create_L1ENT(void *get_obj, - void *get_obj_idx, - void *get_obj_nam, - hash_t *l2_hash, - void *get_entptr, - void *get_entval, - void *set_entval, - u_int elem_size) -{ - revmL1_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (revmL1_t), NULL); - new->get_obj = get_obj; - new->get_obj_idx = get_obj_idx; - new->get_obj_nam = get_obj_nam; - new->get_entptr = get_entptr; - new->get_entval = get_entval; - new->set_entval = set_entval; - new->l2list = l2_hash; - new->elem_size = elem_size; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -/** - * Now comes Level 2 objects hash functions - */ -revmL2_t *revm_create_L2ENT(void *get_obj, - void *set_obj, - char type, - void *get_name, - void *set_name, - void *get_data, - void *set_data) -{ - revmL2_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof (revmL1_t), NULL); - new->get_obj = get_obj; - new->set_obj = set_obj; - new->get_name = get_name; - new->set_name = set_name; - new->type = type; - new->get_data = get_data; - new->set_data = set_data; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - - -/** - * @brief The high level function for object conversion - */ -int revm_convert_object(revmexpr_t *expr, u_int objtype) -{ - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - type = aspect_type_get_by_id(objtype); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter type", (-1)); - -#if 0 - printf("[DEBUG_OBJECT] Trying to convert type %u into type %u \n", - (expr->type ? expr->type->type : 0), objtype); -#endif - - /* Automatic conversion */ - if (!expr->type) - { - expr->type = type; - if (expr->value) - expr->value->otype = expr->type; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - if (expr->type->type == objtype) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - expr->type = type; - switch (objtype) - { - case ASPECT_TYPE_STR: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2str(expr->value)); - case ASPECT_TYPE_CADDR: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2caddr(expr->value)); - case ASPECT_TYPE_DADDR: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2daddr(expr->value)); - case ASPECT_TYPE_LONG: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2long(expr->value)); - case ASPECT_TYPE_INT: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2int(expr->value)); - case ASPECT_TYPE_BYTE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2byte(expr->value)); - case ASPECT_TYPE_SHORT: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2short(expr->value)); - case ASPECT_TYPE_RAW: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, revm_convert2raw(expr->value)); - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Destination type unknown", -1); - } -} - - - -/** - * @brief Verify an object sanity - */ -revmobj_t *revm_check_object(revmobj_t *pobj) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("checking object %p of type %u \n", pobj, pobj->type); - - switch (pobj->otype->type) - { - case ASPECT_TYPE_RAW: - if (pobj->immed == 1) - break; - if (pobj->get_data == NULL || pobj->set_data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object path", NULL); - break; - case ASPECT_TYPE_STR: - if (pobj->immed == 1) - break; - if (pobj->get_name == NULL || pobj->set_name == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object path", NULL); - break; - case ASPECT_TYPE_BYTE: - case ASPECT_TYPE_SHORT: - case ASPECT_TYPE_INT: - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - if (pobj->immed == 1) - break; - if (pobj->get_obj == NULL || pobj->set_obj == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object path", NULL); - break; - default: - snprintf(buf, BUFSIZ, "[DEBUG_OBJECT] Failed to handle unknown object type = %u \n", - pobj->otype->type); - revm_output(buf); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown object type", NULL); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (pobj)); -} - - -/** - * @brief Destroy an object - */ -void revm_destroy_object(revmobj_t *pobj) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (pobj->otype->type == ASPECT_TYPE_STR && pobj->immed) - XFREE(__FILE__, __FUNCTION__, __LINE__, pobj->immed_val.str); - XFREE(__FILE__, __FUNCTION__, __LINE__, pobj); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * @brief Destroy an object - */ -revmobj_t *revm_copy_object(revmobj_t *pobj) -{ - revmobj_t *copy; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - str = NULL; - if (!pobj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", NULL); - if (pobj->otype->type == ASPECT_TYPE_STR && pobj->immed) - str = strdup(pobj->immed_val.str); - XALLOC(__FILE__, __FUNCTION__, __LINE__, copy, sizeof(revmobj_t), NULL); - memcpy(copy, pobj, sizeof(revmobj_t)); - if (str) - copy->immed_val.str = str; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, copy); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/options.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/options.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/options.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/options.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,322 +0,0 @@ -/** - * @file opt.c - * @ingroup librevm_lang - * @brief Implement the commands registration handlers. - * - * Started on Fri Nov 2 15:17:02 2001 jfv - * - * $Id: options.c,v 1.10 2007-08-07 07:13:27 may Exp $ - * - */ -#include "revm.h" - - -/** - * Read the input file parameter - */ -int revm_getoption(u_int index, u_int argc, char **argv) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.curjob->curcmd->param[0] = argv[index + 1]; - world.curjob->curcmd->argc = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Read the input file parameter -*/ -int revm_getinput(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.state.input = argv[index + 1]; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Read the output file parameter -*/ -int revm_getoutput(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 1 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.state.output = argv[index + 1]; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Activate a 2-non-regx-mandatory-parameters option -*/ -int revm_getoption2(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 2 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.curjob->curcmd->param[0] = argv[index + 1]; - world.curjob->curcmd->param[1] = argv[index + 2]; - world.curjob->curcmd->argc = 2; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (2)); -} - -/** - * Activate a 2-non-regx-mandatory-parameters option -*/ -int revm_getoption3(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 3 >= argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.curjob->curcmd->param[0] = argv[index + 1]; - world.curjob->curcmd->param[1] = argv[index + 2]; - world.curjob->curcmd->param[2] = argv[index + 3]; - world.curjob->curcmd->argc = 3; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (3)); -} - -/** - * Activate a non-mandatory-regex-parameter option -*/ -int revm_getregxoption(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (index + 1 < argc && argv[index + 1][0] != REVM_DASH) - { - if (regcomp(&world.curjob->curcmd->regx[0], argv[index + 1], - REG_EXTENDED) != 0 || !strcmp(argv[index + 1], "*")) - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter not available", (-1)); - world.curjob->curcmd->use_regx[0] = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Fetch parameters until we find NULL or something starting by '-' - */ -int revm_getvarparams(u_int index, u_int argc, char **argv) -{ - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (world.curjob->curcmd->argc = idx = 0; - idx < 254 && index + idx + 1 < argc; - idx++) - { - /* Add the '-' check which was not here and create bugs with cmdline */ - if ((world.state.revm_mode == REVM_STATE_CMDLINE - || world.state.revm_mode == REVM_STATE_TRACER) - && argv[index + idx + 1] && argv[index + idx + 1][0] == '-') - break; - - world.curjob->curcmd->param[idx] = argv[index + idx + 1]; - world.curjob->curcmd->argc++; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); -} - -/** - * Format the input of a loop -*/ -int revm_getforparams(u_int index, u_int argc, char **argv) -{ - char *p; - char flag; - char *last; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (((argc - index != 6) && (argc - index != 4)) || - strcmp(argv[index + 2], "of")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong loop format", -1); - - p = argv[index + 4]; - last = argv[index + 5]; - flag = 0; - - /* Intermediate checks */ - if ((argc - index) == 6) - { - flag = (!strcmp("matching", p) ? 1 : !strcmp("until", p) ? 2 : 0); - if (!flag) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong loop format", -1); - - /* Compute the regex if necessary */ - if (flag == 1) - { - if (regcomp(&world.curjob->curcmd->regx[0], last, REG_EXTENDED) != 0 || - !strcmp(last, "*")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested regex", (-1)); - world.curjob->curcmd->use_regx[0] = 1; - } - } - - /* Set the current and maximum indexes to uninitialized */ - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_getvarparams(index, argc, argv)); -} - - -/** - * Format the input of a case command - */ -int revm_getcaseparams(u_int index, u_int argc, char **argv) -{ - u_int idx; - char tokens[3][BUFSIZ]; - int curtok; - int curidx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - curidx = curtok = 0; - for (world.curjob->curcmd->argc = idx = 0; - idx < 254 && index + idx + 1 < argc; - idx++) - { - if (!strcmp(argv[index + idx + 1], REVM_CASE_ARROW)) - { - if (curtok != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for case command", (-1)); - curtok++; - curidx = 0; - continue; - } - else if (!strcmp(argv[index + idx + 1], REVM_CASE_QMARK)) - { - if (curtok != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for case command", (-1)); - curtok++; - curidx = 0; - continue; - } - - curidx += snprintf(&tokens[curtok][curidx], BUFSIZ - curidx, "%s", argv[index + idx + 1]); - } - - for (idx = 0; idx < curtok + 1; idx++) - world.curjob->curcmd->param[idx] = strdup(tokens[idx]); - world.curjob->curcmd->argc = curtok + 1; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, idx); -} - - - -/** - * Format the input of a match/rewrite command - */ -int revm_getmatchparams(u_int index, u_int argc, char **argv) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (argc - index != 3) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong match format", -1); - if (strcmp(argv[index + 2], CMD_PARAM_INTO)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong match format", -1); - - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_getoption2(index, argc, argv)); -} - - - - -/** - * Add an entry to the requested dump list -*/ -static int revm_add2list(char outtype, u_int index, int argc, char **argv) -{ - char *off; - int idx = index; - revmlist_t *cur; - char *used; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - while (idx < index + 2) - { - cur = world.curjob->curcmd->disasm + idx - index; - used = world.curjob->curcmd->use_regx + idx - index; - - if (argv[idx + 1] == NULL) - { - *used = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (idx == index ? -1 : 1)); - } - - cur->rname = argv[idx + 1]; - cur->otype = outtype; - cur->size = 0; - cur->off = 0; - off = strchr(argv[idx + 1], '%'); - - if (off) - { - cur->size = atoi(off + 1); - *off = 0; - } - off = strchr(argv[idx + 1], ':'); - if (off) - { - cur->off = atoi(off + 1); - *off = 0; - } - - if (regcomp(&cur->name, argv[idx + 1], REG_EXTENDED | REG_ICASE) != 0 || - *cur->rname == '*') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Regular computation failed", (-1)); - *used = 1; - idx++; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (2)); -} - -/** - * Add an DISASM typed entry -*/ -int revm_getdisasm(u_int index, u_int argc, char **argv) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_add2list(REVM_VIEW_DISASM, index, argc, argv)); -} - -/** - * Add an HEXA typed entry -*/ -int revm_gethexa(u_int index, u_int argc, char **argv) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_add2list(REVM_VIEW_HEX, index, argc, argv)); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/parser.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/parser.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/parser.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/parser.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,287 +0,0 @@ -/** - * @file parse.c - * @@ingroup librevm_lang - * The top level parser of the language - * - * Started on Wed Feb 28 19:19:04 2007 jfv - * - * $Id: parser.c,v 1.13 2007-11-29 14:01:56 may Exp $ - * - */ -#include "revm.h" - -/* Nested loop labels memory : support foreach/forend construct */ -static u_int curnest = 0; -static char *looplabels[REVM_MAXNEST_LOOP]; -static char *endlabl = NULL; -static u_int nextlabel = 0; -static revmargv_t *forend = NULL; - -/* Pending label information : support labels */ -static u_int pendinglabel = 0; -static revmargv_t *newcmd = NULL; - -/* Global variables for rewrite/case/endwrt parsing */ -static list_t *condcmdlist = NULL; -static u_char isdefault = 0; - -/** - * Create a fresh label name - */ -char *revm_label_get(char *prefix) -{ - char buf[BUFSIZ]; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - idx = 0; - retry: - snprintf(buf, sizeof(buf), "%s_DEPTH:%u_INDEX:%u", prefix, curnest, idx); - if (hash_get(&labels_hash[world.curjob->sourced], buf)) - { - idx++; - goto retry; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, strdup(buf)); -} - - -/** - * Recognize a special command pattern - */ -int revm_parse_construct(char *curtok) -{ - char *labl; - listent_t *curcondcmd; - revmargv_t *condcmd; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If we met a foreach/forend, update the nested loop labels stack */ - if (!strcmp(curtok, CMD_FOREACH)) - { - if (curnest >= REVM_MAXNEST_LOOP) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many nested construct", -1); - labl = revm_label_get("foreach"); - hash_add(&labels_hash[world.curjob->sourced], labl, newcmd); - looplabels[curnest++] = labl; - } - - /* At forend, delay the label insertion to the next command */ - else if (!strcmp(curtok, CMD_FOREND)) - { - if (curnest == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrectly nested forend statement", -1); - endlabl = revm_label_get("forend"); - if (!strstr(looplabels[curnest - 1], "foreach")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrectly nested loop-ending statement", -1); - forend = newcmd; - forend->endlabel = looplabels[--curnest]; - nextlabel = 1; - } - - /* Here the match parser */ - /* If we met a foreach/forend, update the nested loop labels stack */ - else if (!strcmp(curtok, CMD_MATCH)) - { - if (curnest >= REVM_MAXNEST_LOOP) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many nested construct", -1); - labl = revm_label_get("match"); - hash_add(&labels_hash[world.curjob->sourced], labl, newcmd); - looplabels[curnest++] = labl; - } - - /* Maintain a list of commands that may have a conditional continuation during a rewrite */ - else if (!strcmp(curtok, CMD_DEFAULT) || !strcmp(curtok, CMD_CASE)) - { - if (curnest == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrect default or case statement", -1); - if (!strstr(looplabels[curnest - 1], "match")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrectly nested match-ending statement", -1); - if (!condcmdlist) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, condcmdlist, sizeof(list_t), -1); - elist_init(condcmdlist, "parser_condcmdlist", ASPECT_TYPE_UNKNOW); - } - elist_add(condcmdlist, strdup(curtok), newcmd); - } - - /* At forend, delay the label insertion to the next command */ - else if (!strcmp(curtok, CMD_MATCHEND)) - { - if (curnest == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrectly nested endmatch statement", -1); - endlabl = revm_label_get("matchend"); - - if (!strstr(looplabels[curnest - 1], "match")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrectly nested match-ending statement", -1); - forend = newcmd; - forend->endlabel = looplabels[--curnest]; - hash_add(&labels_hash[world.curjob->sourced], endlabl, newcmd); - - /* Now setting the end label to all waiting case/default commands */ - if (condcmdlist && condcmdlist->head) - { - for (curcondcmd = condcmdlist->head; curcondcmd; curcondcmd = curcondcmd->next) - { - condcmd = (revmargv_t *) curcondcmd->data; - condcmd->endlabel = strdup(endlabl); - } - elist_destroy(condcmdlist); - condcmdlist = NULL; - } - } - - /* This flag says if the command opens a new scope just for its arguments */ - isdefault = ((!strcmp(curtok, CMD_DEFAULT) || - !strcmp(curtok, CMD_PRE) || - !strcmp(curtok, CMD_POST)) ? 1 : 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - -/** - * Parse the commands - */ -int revm_parseopt(int argc, char **argv) -{ - u_int index; - int ret; - volatile revmcmd_t *actual; - volatile revmargv_t *loopstart; - char *name; - char label[16]; - char c; - char cmdline; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We are at command line */ - cmdline = ((world.state.revm_mode == REVM_STATE_CMDLINE - || world.state.revm_mode == REVM_STATE_TRACER) - && !world.state.revm_net); - - /* Main option reading loop : using the command hash table */ - for (index = 1; index < argc; index++) - { - - /* Allocate command descriptor */ - bzero(label, sizeof(label)); - if (!pendinglabel) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - newcmd, sizeof(revmargv_t), -1); - world.curjob->curcmd = newcmd; - if (world.curjob->script[world.curjob->sourced] == NULL) - world.curjob->script[world.curjob->sourced] = newcmd; - } - else - pendinglabel = 0; - - /* Retreive command descriptor in the hash table */ - name = argv[index] + cmdline; - actual = hash_get(&cmd_hash, name); - - /* We matched a command : call the registration handler */ - if (actual != NULL) - { - - /* If there is a forend/matchend label waiting, insert it here */ - /* The forend label must point on the -following- command */ - /* Annotate meta-command foreach, case, and default with the "end label" */ - if (nextlabel) - { - hash_add(&labels_hash[world.curjob->sourced], endlabl, newcmd); - loopstart = hash_get(&labels_hash[world.curjob->sourced], looplabels[curnest]); - - /* If we are executing "default", we search for the loop start in the parent scope */ - /* - if (world.curjob->sourced && isdefault) - for (ret = 0; world.curjob->sourced >= ret; ret++) - { - loopstart = hash_get(&labels_hash[world.curjob->sourced - ret], looplabels[curnest]); - if (loopstart) - break; - } - */ - - if (!loopstart) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid nesting of language construct", -1); - loopstart->endlabel = strdup(endlabl); - /* isdefault = */ nextlabel = 0; - } - - /* Dont call registration handler if there is not (0 param commands) */ - if (actual->reg != NULL) - { - ret = actual->reg(index, argc, argv); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command not found", - (revm_doerror(revm_badparam, argv[index]))); - } - else ret = 0; - - /* Handle control flow constructs of the eresi script */ - if (revm_parse_construct(argv[index]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid eresi program nesting construct", -1); - index += ret; - } - - /* We did -NOT- match command */ - else if (world.state.revm_mode == REVM_STATE_SCRIPT) - { - /* Try to match a label */ - ret = sscanf(name, "%15[^:]%c", label, &c); - if (ret == 2 && c == ':') - { - hash_add(&labels_hash[world.curjob->sourced], - strdup(label), newcmd); - pendinglabel = 1; - continue; - } - - /* No command matched, enable runtime lookup : module could be loaded later */ - ret = revm_getvarparams(index - 1, argc, argv); - index += ret; - } - - /* We matched nothing known, error */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown parsing error", - (revm_doerror(revm_unknown, argv[index]))); - - /* Put the newcmd command at the end of the list */ - newcmd->name = name; - newcmd->cmd = (revmcmd_t *) actual; - if (!world.curjob->lstcmd[world.curjob->sourced]) - world.curjob->lstcmd[world.curjob->sourced] = newcmd; - else - { - world.curjob->lstcmd[world.curjob->sourced]->next = newcmd; - newcmd->prev = world.curjob->lstcmd[world.curjob->sourced]; - world.curjob->lstcmd[world.curjob->sourced] = newcmd; - } - } - - /* Return success */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/scanner.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/scanner.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/scanner.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/scanner.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,320 +0,0 @@ -/** - * @file lexer.c - * @ingroup librevm_lang - * Started on Fri Feb 7 20:53:25 2003 jfv - * Updated on Fri Mar 5 18:47:41 2007 jfv - * - * $Id: scanner.c,v 1.15 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "revm.h" - - -/** - * Replace \xNUM by the value, I wished readline could have done that - */ -void revm_findhex(u_int argc, char **argv) -{ - u_int index; - char *buf; - char *ptr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* For each of the argv[] entry */ - for (index = 0; index < argc; index++) - { - if (argv[index] == NULL) - continue; - buf = argv[index]; - - /* Find "\x" sequences */ - for (ptr = strstr(buf, "\\x"); ptr != NULL; ptr = strstr(buf, "\\x")) - buf = revm_filter_param(buf, ptr); - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Translate a speblanks string - */ -int revm_trans_speblank(const char *in, char ***av, u_int *ac) -{ - char **argv; - u_int argc = 1; - u_int index; - u_int count = 0; - size_t len; - char *ptr; - char str[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!str || !str[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - snprintf(str, BUFSIZ - 1, "%s", in); - len = strlen(str); - - /* Trim the string */ - while (str[count] == ' ') - count++; - - /* Only spaces ? */ - if (count == len) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (count > 0) - { - memmove(str, str+count, len - count + 1); - len = strlen(str); - } - - /* Trim the end */ - while (str[len - 1] == ' ' && str[len - 2] != '\\') - { - str[len - 1] = 0x00; - len--; - } - - for (ptr = strchr(str, ' '); ptr != NULL; ptr = strchr(ptr+1, ' ')) - { - /* Check if its a valid space */ - if ((ptr - str) > 0 && ptr[-1] != '\\') - { - *ptr = 0x00; - argc++; - } - } - - XALLOC(__FILE__, __FUNCTION__, __LINE__, argv, sizeof(char*)*argc, -1); - - /* Copy each parts */ - for (index = 0, ptr = str; index < argc; index++, ptr += strlen(ptr)+1) - argv[index] = strdup(ptr); - - /* Replace '\ ' */ - revm_replace_speblanks(argc, argv); - - if (av) - *av = argv; - - if (ac) - *ac = argc; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Replace '\ ' by the ' ', I wished readline could have done that - */ -void revm_replace_speblanks(u_int argc, char **argv) -{ - u_int index; - char *buf; - char *ptr; - size_t len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* For each of the argv[] entry */ - for (index = 0; index < argc; index++) - { - if (argv[index] == NULL) - continue; - buf = argv[index]; - len = strlen(buf); - - /* Find "\ " sequences */ - for (ptr = strstr(buf, "\\ "); ptr != NULL; ptr = strstr(ptr+1, "\\ ")) - { - *ptr = ' '; - memmove(ptr+1, ptr+2, len - (ptr - buf + 2)); - } - } - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Count blanks, so that we can allocate argv - */ -u_int revm_findblanks(char *buf) -{ - int index; - int len; - int nbr; - char *ptr; - char *sav; -#if __DEBUG_SCANNER__ - char logbuf[BUFSIZ]; -#endif - - len = strlen(buf); - index = 0; - nbr = 1; - sav = buf; - do - { - while (IS_BLANK(*sav)) - sav++; - if (!*sav) - break; - ptr = strchr(sav, ' '); - if (!ptr) - { - ptr = strchr(sav, '\t'); - if (!ptr) - break; - } - while (IS_BLANK(*ptr)) - ptr++; - if (!*ptr) - break; - nbr++; - sav = ptr; - } - while (ptr && sav < buf + len); - -#if __DEBUG_SCANNER__ - snprintf(logbuf, BUFSIZ - 1, "[DEBUG_SCANNER:findblanks] nbr = %u \n", nbr); - revm_output(logbuf); -#endif - - return (nbr); -} - - -/** - * Cut words of the newline and create argv - */ -char **revm_doargv(u_int nbr, u_int *argc, char *buf) -{ - u_int index; - char *sav; - char **argv; - char *ptr; -#if __DEBUG_SCANNER__ - char logbuf[BUFSIZ]; -#endif - - NOPROFILER_IN(); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,argv, sizeof(char *) * (nbr + 2), NULL); - argv[0] = argv[nbr + 1] = NULL; - sav = buf; - - for (index = 1; index < nbr + 1; index++) - { - - assert(sav >= buf); - - while (IS_BLANK(*sav)) - sav++; - argv[index] = sav; - -#if __DEBUG_SCANNER__ - snprintf(logbuf, BUFSIZ - 1, - "[DEBUG_SCANNER:lexer_doargv] Adding argv[%u] = *%s* \n", - index, sav); - revm_output(logbuf); -#endif - - ptr = strchr(sav, ' '); - if (!ptr) - ptr = strchr(sav, '\t'); - if (ptr) - { - *ptr = 0; - sav = ptr + 1; - } - } - -#if __DEBUG_SCANNER__ - revm_output("\n"); - for (index = 0; index < nbr + 1; index++) - if (argv[index]) - { - snprintf(logbuf, BUFSIZ - 1, "[DEBUG_SCANNER:lexer_doargv] %u/ *%s* \n", - index, argv[index]); - revm_output(logbuf); - } - revm_output("\n"); -#endif - - *argc = nbr + 1; - - NOPROFILER_ROUT(argv); -} - - - - - - - - -/* Its lighter than flex ... */ -char **revm_input(int *argc, char *available_line) -{ - char **argv; - char *buf; - int nbr; - int len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!available_line) - buf = revm_getln(); - else - buf = available_line; - - if ((int) buf == 0 || - (int) buf == REVM_INPUT_VOID || - (int) buf == REVM_INPUT_EXIT || - (int) buf == REVM_INPUT_TRANSFERED) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (char **) buf); - - /* Log the read line */ - if (world.state.revm_mode != REVM_STATE_SCRIPT && - world.curjob->ws.io.type == REVM_IO_STD) - revm_input_prelog(buf); - - /* Save the line for future references */ - if (world.curjob->ws.oldline && *world.curjob->ws.oldline) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, - world.curjob->ws.oldline); - world.curjob->ws.oldline = NULL; - } - - len = strlen(buf); - XALLOC(__FILE__, __FUNCTION__, __LINE__, - world.curjob->ws.oldline, len + 1, NULL); - strcpy(world.curjob->ws.oldline, buf); - - /* If we are in the client part of the debugger, - we have a special behavior */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - world.state.revm_side == REVM_SIDE_CLIENT) - { - write(world.fifo_c2s, buf, len); - revm_rlfifo_write(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char **) REVM_INPUT_TRANSFERED)); - } - - /* Read, and sanitize to avoid blank lines and various special returns */ - nbr = revm_findblanks(buf); - - /* Allocate the correct pointer array for argv */ - argv = revm_doargv(nbr, (u_int *) argc, buf); - - /* Find and replace "\xXX" sequences, then return the array */ - revm_findhex(*argc, argv); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (argv)); -} diff -Nru eresi-0.8a25/librevm/lang/.svn/text-base/variables.c.svn-base eresi-0.0.20110516/librevm/lang/.svn/text-base/variables.c.svn-base --- eresi-0.8a25/librevm/lang/.svn/text-base/variables.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/.svn/text-base/variables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,216 +0,0 @@ -/** - * @defgroup librevm_lang librevm Language - */ -/** - * @file variables.c - * @ingroup librevm_lang - * @brief Contain functions for easy variables accesses. - * - * Started September 16 2005 04:01:03 jfv - * - * - * $Id: variables.c,v 1.9 2007-11-28 07:56:09 may Exp $ - * - */ -#include "revm.h" - - - -/** - * Set a variable to a string value - */ -int revm_setvar_str(char *varname, char *value) -{ - revmexpr_t *expr; - revmobj_t *var; - int len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert variable", (-1)); - var = expr->value; - if (revm_convert2str(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed string conversion", (-1)); - len = strlen(value) + 1; - if (var->size < len) - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - var->immed_val.str, var->immed_val.str, len, -1); - memcpy(var->immed_val.str, value, len - 1); - var->immed_val.str[len - 1] = '\0'; - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Set a variable to a string value - */ -int revm_setvar_raw(char *varname, char *value, u_int len) -{ - revmexpr_t *expr; - revmobj_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert variable", (-1)); - var = expr->value; - if (revm_convert2raw(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed string conversion", (-1)); - if (var->size < len) - XREALLOC(__FILE__, __FUNCTION__, __LINE__, - var->immed_val.str, var->immed_val.str, len, -1); - memcpy(var->immed_val.str, value, len - 1); - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - - -/** - * Set a variable to a string value - */ -int revm_setvar_byte(char *varname, u_char byte) -{ - revmexpr_t *expr; - revmobj_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert variable", (-1)); - var = expr->value; - if (revm_convert2byte(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed byte conversion", (-1)); - var->immed_val.byte = byte; - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Set a variable to a string value - */ -int revm_setvar_short(char *varname, u_short val) -{ - revmexpr_t *expr; - revmobj_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown variable", (-1)); - var = expr->value; - if (revm_convert2short(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed short conversion", (-1)); - var->immed_val.half = val; - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Set a variable to a string value - */ -int revm_setvar_int(char *varname, u_int val) -{ - revmexpr_t *expr; - revmobj_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown variable", (-1)); - var = expr->value; - if (revm_convert2int(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed integer conversion", (-1)); - var->immed_val.word = val; - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Set a variable to a string value - */ -int revm_setvar_long(char *varname, u_long val) -{ - revmexpr_t *expr; - revmobj_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!varname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - varname = revm_lookup_string(varname); - expr = revm_expr_get(varname); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown variable", (-1)); - var = expr->value; - if (revm_convert2long(var) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed long conversion", (-1)); - var->immed_val.ent = val; - expr->type = var->otype; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - - -/* Allocate a new temporary variable name */ -char *revm_tmpvar_create() -{ - static u_int lastid = 1; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - XALLOC(__FILE__, __FUNCTION__, __LINE__, name, 20, NULL); - snprintf(name, 20, "%s%u", REVM_TMPVAR_PREFIX, lastid); - lastid++; - - //printf(" [D] Created new temp variable %s \n", name); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, name); -} - - -/* Return 1 if variable is temporary, 0 if not */ -int revm_variable_istemp(revmexpr_t *e) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!e || strncmp(e->label, REVM_TMPVAR_PREFIX, strlen(REVM_TMPVAR_PREFIX))) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} diff -Nru eresi-0.8a25/librevm/lang/variables.c eresi-0.0.20110516/librevm/lang/variables.c --- eresi-0.8a25/librevm/lang/variables.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/lang/variables.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,16 +1,14 @@ /** - * @defgroup librevm_lang librevm Language + * @defgroup lang Librevm scripting engine API. + * @ingroup librevm */ /** - * @file variables.c - * @ingroup librevm_lang +* @file librevm/lang/variables.c + * @ingroup lang * @brief Contain functions for easy variables accesses. * * Started September 16 2005 04:01:03 jfv - * - * - * $Id: variables.c,v 1.9 2007-11-28 07:56:09 may Exp $ - * + * $Id: variables.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" diff -Nru eresi-0.8a25/librevm/Makefile eresi-0.0.20110516/librevm/Makefile --- eresi-0.8a25/librevm/Makefile 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/Makefile 2011-05-16 11:34:12.000000000 +0000 @@ -17,22 +17,18 @@ LDFLAGS32 += -L../libedfmt/ -ledfmt32 -L../libelfsh/ -lelfsh32 \ -L../libdump/ -L/usr/pkg/lib/ \ -L../libmjollnir/ -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ + -L../libasm/ -lasm32 $(LDUIOPT32) -g3 \ + -L../liballocproxy -L../libmjollnir/ \ -L../libaspect/ -laspect32 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace32 \ - $(KERNSHLIB32) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) LDFLAGS64 += -L../libedfmt/ -ledfmt64 -L../libelfsh/ -lelfsh64 \ -L../libdump/ -L/usr/pkg/lib/ \ -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ + -L../libasm/ -lasm64 $(LDUIOPT64) -g3 \ + -L../liballocproxy -L../libmjollnir/ \ -L../libaspect/ -laspect64 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace64 \ - $(KERNSHLIB64) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) @@ -46,14 +42,14 @@ $(MAKE) -C io all32 $(MAKE) -C api all32 -$(NAME32).so : +$(NAME32).so : mod32 $(CC) -shared $(OBJ32) -o $(NAME32).so $(LDFLAGS32) \ $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) ar rc ${NAME32}.a ${OBJ32} @$(RANLIB) ${NAME32}.a @echo LINKED LIBREVM32 -lib32: $(NAME32).so +lib32: $(NAME32).so mod64 : $(MAKE) -C lang all64 @@ -61,7 +57,7 @@ $(MAKE) -C io all64 $(MAKE) -C api all64 -lib64 : +lib64 : mod64 $(CC) -shared $(OBJ64) -o $(NAME64).so $(LDFLAGS64) \ $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) ar rc ${NAME64}.a ${OBJ64} diff -Nru eresi-0.8a25/librevm/.svn/all-wcprops eresi-0.0.20110516/librevm/.svn/all-wcprops --- eresi-0.8a25/librevm/.svn/all-wcprops 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 31 -/svn/!svn/ver/950/trunk/librevm -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/950/trunk/librevm/Makefile -END diff -Nru eresi-0.8a25/librevm/.svn/entries eresi-0.0.20110516/librevm/.svn/entries --- eresi-0.8a25/librevm/.svn/entries 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -lang -dir - -vm -dir - -include -dir - -doc -dir - -io -dir - -api -dir - -Makefile -file - - - - -2008-04-06T23:15:46.556901Z -2de4fbd87ea6c64552281e20c28641c8 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/librevm/.svn/format eresi-0.0.20110516/librevm/.svn/format --- eresi-0.8a25/librevm/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/librevm/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/librevm/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:46.000000000 +0000 +++ eresi-0.0.20110516/librevm/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -## -## Makefile for librevm in ERESI -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## Updated on Wed Nov 28 12:57:38 2001 jfv -## - -include ../config.h - -OBJ32 = *.32.o -OBJ64 = *.64.o -CC ?= gcc -RM = rm -f -NAME32 = librevm32 -NAME64 = librevm64 - -LDFLAGS32 += -L../libedfmt/ -ledfmt32 -L../libelfsh/ -lelfsh32 \ - -L../libdump/ -L/usr/pkg/lib/ \ - -L../libmjollnir/ -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace32 \ - $(KERNSHLIB32) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) - -LDFLAGS64 += -L../libedfmt/ -ledfmt64 -L../libelfsh/ -lelfsh64 \ - -L../libdump/ -L/usr/pkg/lib/ \ - -L../libmjollnir/ -lmjollnir64 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT64) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace64 \ - $(KERNSHLIB64) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) - -all : all32 all64 -all32 : mod32 lib32 -all64 : mod64 lib64 - -mod32 : - $(MAKE) -C lang all32 - $(MAKE) -C vm all32 - $(MAKE) -C io all32 - $(MAKE) -C api all32 - -$(NAME32).so : - $(CC) -shared $(OBJ32) -o $(NAME32).so $(LDFLAGS32) \ - $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) - ar rc ${NAME32}.a ${OBJ32} - @$(RANLIB) ${NAME32}.a - @echo LINKED LIBREVM32 - -lib32: $(NAME32).so - -mod64 : - $(MAKE) -C lang all64 - $(MAKE) -C vm all64 - $(MAKE) -C io all64 - $(MAKE) -C api all64 - -lib64 : - $(CC) -shared $(OBJ64) -o $(NAME64).so $(LDFLAGS64) \ - $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) - ar rc ${NAME64}.a ${OBJ64} - ranlib ${NAME64}.a - @echo LINKED LIBREVM64 - -clean : - $(MAKE) -C lang clean - $(MAKE) -C vm clean - $(MAKE) -C io clean - $(MAKE) -C api clean - @$(RM) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) *.o *.so *.a $(OBJ_DYN) - -docs: - doxygen doc/doxygen.conf diff -Nru eresi-0.8a25/librevm/vm/fini.c eresi-0.0.20110516/librevm/vm/fini.c --- eresi-0.8a25/librevm/vm/fini.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/fini.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,21 +1,26 @@ -/* - * @file fini.c - * @ingroup librevm_vm +/** +* @file librevm/vm/fini.c + * @ingroup vm * @brief Routines executed when leaving script mode. * * Started on Wed Nov 19 23:02:04 2003 jfv - * $Id: fini.c,v 1.1 2008-02-16 12:32:27 thor Exp $ + * $Id: fini.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" +/** Clean scripting context */ +void revm_clean() +{ + world.curjob->recur[world.curjob->curscope].script = NULL; + world.curjob->recur[world.curjob->curscope].lstcmd = NULL; +} /* Some REVM context cleanup when coming back from script to interactive mode */ void revm_cleanup() { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.curjob->script[world.curjob->sourced] = NULL; - world.curjob->lstcmd[world.curjob->sourced] = NULL; + revm_clean(); revm_conditional_rlquit(); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); } @@ -25,8 +30,6 @@ void revm_postexec(int retval) { int ret; - char *buggyfunc; - char logbuf[256]; if (!world.state.revm_quiet && world.state.revm_mode == REVM_STATE_SCRIPT) { @@ -36,32 +39,7 @@ revm_output("\n [*] Script execution ended succesfully \n\n"); } - /* Implicit unload or save if we are not in interactive mode */ - if ((world.state.revm_mode == REVM_STATE_CMDLINE - || world.state.revm_mode == REVM_STATE_TRACER) && world.curjob->curfile) - { - /* Start tracing if we are on tracer state (etrace) */ - if (world.state.revm_mode == REVM_STATE_TRACER) - { - profiler_error_reset(); - if (traces_run(world.curjob->curfile, NULL, 0) < 0) - { - buggyfunc = etrace_geterrfunc(); - - /* Not NULL if issue occurs when we iterate though functions */ - if (buggyfunc) - { - snprintf(logbuf, 255, " [!] There is an issue with the function: %s\n", - buggyfunc); - revm_output(logbuf); - } - - profiler_error(); - } - } - - ret = revm_workfiles_unload(); - } + /* Implicit unload or save if we are not in interactive mode or in tracer mode */ + if (world.state.revm_mode == REVM_STATE_CMDLINE && world.curjob->curfile) + ret = revm_workfiles_unload(); } - - diff -Nru eresi-0.8a25/librevm/vm/init.c eresi-0.0.20110516/librevm/vm/init.c --- eresi-0.8a25/librevm/vm/init.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/init.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,21 +1,18 @@ /** - * @file elfsh.c - * @ingroup librevm_vm +* @file librevm/vm/init.c + * @ingroup vm * Started on Wed Feb 21 22:02:36 2001 jfv * Updated on Tue Jun 27 23:51:04 2006 mxatone * - * $Id: init.c,v 1.37 2008-02-16 12:32:27 thor Exp $ + * $Id: init.c 1444 2011-01-31 07:41:29Z may $ * */ #include "revm.h" - /* The ELFsh world */ revmworld_t world; - - /** * Signal handler for SIGINT */ @@ -40,9 +37,10 @@ /* Set the world up */ aspect_init(); - asm_init_ia32(&world.proc); - asm_init_sparc(&world.proc_sparc); - asm_init_mips(&world.proc_mips); + asm_init_arch(&world.proc_ia32, ASM_PROC_IA32); + asm_init_arch(&world.proc_sparc, ASM_PROC_SPARC); + asm_init_arch(&world.proc_mips, ASM_PROC_MIPS); + asm_init_arch(&world.proc_arm, ASM_PROC_ARM); revm_initio(); /* setting libelfsh profile function */ @@ -59,37 +57,35 @@ /** - * Setup ELFsh/e2dbg hash tables and structures + * Setup ERESI hash tables and structures */ -int revm_setup(int ac, char **av, - char mode, char side) +int revm_setup(int ac, char **av, char mode, char side) { - char buff[BUFSIZ]; + char buff[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Detect the mode we are running in */ - if (mode == REVM_STATE_DEBUGGER) + if (mode == REVM_STATE_EMBEDDED) { /* Set the mode, side, and IO of the debugger */ world.state.revm_mode = mode; world.state.revm_side = side; revm_fifo_io(world.curjob); revm_buffer_reset(1); - elfsh_set_debug_mode(); + elfsh_set_runtime_mode(); } else if (mode == REVM_STATE_TRACER) { elfsh_set_static_mode(); - world.state.revm_mode = mode; world.state.revm_side = side; } + /* Set REVM in static mode */ else { elfsh_set_static_mode(); - if (ac == 1) world.state.revm_mode = REVM_STATE_INTERACTIVE; else if (revm_testscript(ac, av)) @@ -98,38 +94,37 @@ revm_tables_setup(); if (revm_openscript(&av[1]) < 0) QUIT_ERROR(-1); - ac = 1; av[1] = NULL; } } /* on.load. */ - config_add_item(ERESI_VMCONFIG_ONLOAD_RCONTROL, + config_add_item(ERESI_CONFIG_ONLOAD_RCONTROL, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 1); - config_add_item(ERESI_VMCONFIG_GRAPH_STORAGEPATH, + config_add_item(ERESI_CONFIG_GRAPH_STORAGEPATH, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *)"/tmp/"); - config_add_item(ERESI_VMCONFIG_GRAPH_VIEWCMD, + config_add_item(ERESI_CONFIG_GRAPH_VIEWCMD, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *)"xzgv"); - config_add_item(ERESI_VMCONFIG_GRAPH_AUTOVIEW, + config_add_item(ERESI_CONFIG_GRAPH_AUTOVIEW, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 1); - config_add_item(ERESI_VMCONFIG_GRAPH_AUTOBUILD, + config_add_item(ERESI_CONFIG_GRAPH_AUTOBUILD, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 1); - config_add_item(ERESI_VMCONFIG_USE_MORE, + config_add_item(REVM_CONFIG_USEMORE, CONFIG_TYPE_INT, CONFIG_MODE_RW, (void *) 1); @@ -142,7 +137,7 @@ memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), ERESI_DEFAULT_HISTORY); - config_add_item(ERESI_VMCONFIG_HISTORY, + config_add_item(ERESI_CONFIG_HISTORY, CONFIG_TYPE_STR, CONFIG_MODE_RW, (char *)buff); @@ -203,29 +198,46 @@ +static elfshobj_t *revm_run_main(int ac, char **av) +{ +#if __DEBUG_SIGHANDLER__ + revm_output("[elfsh:main] started !\n"); +#endif + + revm_completion_install(world.state.revm_mode, + world.state.revm_side); + revm_flush(); + revm_prompt_log(); + + /* Now run f0r3st */ + revm_loop(ac, av); + + /* Always return the current working object */ + return (world.curjob->curfile); +} + + + +elfshobj_t *revm_run_no_handler(int ac, char **av) +{ + return revm_run_main(ac, av); +} + + + /** * Interface initialisation && loop entry point */ -int revm_run(int ac, char **av) +elfshobj_t *revm_run(int ac, char **av) { /* Do not handle signals in debugger mode */ - if (world.state.revm_mode != REVM_STATE_DEBUGGER) + if (world.state.revm_mode != REVM_STATE_EMBEDDED) { signal(SIGQUIT, SIG_IGN); signal(SIGTERM, SIG_IGN); signal(SIGINT, sigint_handler); } -#if __DEBUG_SIGHANDLER__ - revm_output("[elfsh:main] started !\n"); -#endif - - revm_completion_install(world.state.revm_mode, - world.state.revm_side); - revm_flush(); - revm_prompt_log(); - - /* Now run f0r3st */ - return (revm_loop(ac, av)); + return revm_run_main(ac, av); } diff -Nru eresi-0.8a25/librevm/vm/loop.c eresi-0.0.20110516/librevm/vm/loop.c --- eresi-0.8a25/librevm/vm/loop.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/loop.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,10 +1,10 @@ -/* - * @file loop.c - * @ingroup librevm_vm +/** +* @file librevm/vm/loop.c + * @ingroup vm * @brief This file include the control flow support for scripting. * * Started on Wed Nov 19 23:02:04 2003 jfv - * $Id: loop.c,v 1.14 2008-02-16 12:32:27 thor Exp $ + * $Id: loop.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" @@ -39,7 +39,7 @@ /* If the FIFO does not exist anymore, the server has quit, so we quit too */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && + if (world.state.revm_mode == REVM_STATE_EMBEDDED && (access(REVM_FIFO_S2C, F_OK) < 0 || access(REVM_FIFO_C2S, F_OK) < 0)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -48,7 +48,7 @@ /* Take a line, execute old command if void line */ argv = revm_input(&argc, NULL); if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER || + world.state.revm_mode == REVM_STATE_EMBEDDED || world.state.revm_mode == REVM_STATE_SCRIPT || world.state.revm_net) { @@ -64,8 +64,9 @@ revm_output("\n"); /* when debugging -> back to main program */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_EMBEDDED) { + revm_callback_handler_remove(); revm_cleanup(); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -88,7 +89,7 @@ { XFREE(__FILE__, __FUNCTION__, __LINE__, argv); if (world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) + world.state.revm_mode != REVM_STATE_EMBEDDED) goto end; } else if (!world.state.revm_net) @@ -98,11 +99,12 @@ /* Just execute one command if we are not in script mode */ if (world.state.revm_mode != REVM_STATE_SCRIPT) { - world.curjob->curcmd = world.curjob->script[0]; + world.curjob->curcmd = world.curjob->recur[0].script; switch (revm_execmd()) { case REVM_SCRIPT_CONTINUE: //printf(" [*] e2dbg continue from revm_execmd \n"); + revm_callback_handler_remove(); revm_cleanup(); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); case REVM_SCRIPT_ERROR: @@ -113,10 +115,7 @@ } /* Quit parsing if necessary */ - if ((!world.curjob->curcmd && world.state.revm_mode == REVM_STATE_SCRIPT)) //|| - /*(world.curjob->curcmd && world.curjob->curcmd->name && - (!strcmp(world.curjob->curcmd->name, CMD_QUIT) || - !strcmp(world.curjob->curcmd->name, CMD_QUIT2))))*/ + if ((!world.curjob->curcmd && world.state.revm_mode == REVM_STATE_SCRIPT)) break; } while ((world.state.revm_mode != REVM_STATE_CMDLINE @@ -128,7 +127,7 @@ { fprintf(stderr, "we are in script mode from revm_loop ! \n"); - world.curjob->curcmd = world.curjob->script[0]; + world.curjob->curcmd = world.curjob->recur[0].script; ret = revm_execscript(); if (ret == REVM_SCRIPT_STOP) { @@ -143,12 +142,8 @@ end: revm_postexec(ret); revm_callback_handler_remove(); + revm_cleanup(); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - - /* Clean the script machine state when a script is over */ - //XXX: looks never called now -- world.curjob->curcmd = NULL; - //revm_cleanup(); - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); } @@ -169,13 +164,9 @@ { cur = world.context.curcmd; world.curjob->curcmd = cur; - - //fprintf(stderr, "Restored curcmd (%s) after CONTINUE \n", cur->name); - //sleep(1); - } else - cur = world.curjob->script[world.curjob->sourced]; + cur = world.curjob->recur[world.curjob->curscope].script; /* Curcmd acts like a $PC register */ for (; cur; cur = next) @@ -190,23 +181,15 @@ { REVM_CMDARGS_COUNT(cur); if (cur->cmd->reg(0, cur->argc, cur->param) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Commande parsing failed", - revm_doerror(revm_badparam, cur->param[0])); + { + revm_cleanup(); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Commande parsing failed", + revm_doerror(revm_badparam, cur->param[0])); + } } } - /* Test for e2dbg scripting */ - if (!strcmp(cur->name, CMD_CONTINUE) || !strcmp(cur->name, CMD_CONTINUE2)) - { - next = cur->next; - world.context.curcmd = next; - world.state.revm_sourcing = 1; - fprintf(stderr, "Found -continue- in script, sourcing flag now -ON- \n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - REVM_SCRIPT_CONTINUE); - } - /* Execute instruction */ if (cur->cmd != NULL && cur->cmd->exec != NULL) { @@ -219,9 +202,21 @@ if (status < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Command execution failed", -1); + + /* Test for (embedded or not) debugger scripting */ + if ((world.curjob->curfile && world.curjob->curfile->iotype != ELFSH_HOST_GDB) && + (!strcmp(cur->name, CMD_CONTINUE) || !strcmp(cur->name, CMD_CONTINUE2))) + { + next = cur->next; + world.context.curcmd = next; + world.state.revm_sourcing = 1; + fprintf(stderr, "Found -continue- in script, sourcing flag now -ON- \n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_CONTINUE); + } + } else - revm_error("Lazy evaluation failed for command", cur->param[0]); + revm_error("Unable to find command", cur->param[0]); /* Current instruction modified the script control flow ? */ if (cur == world.curjob->curcmd) @@ -255,7 +250,7 @@ /* If we had a saved context, restore it */ if (world.state.revm_sourcing) { - world.curjob->lstcmd[world.curjob->sourced] = NULL; + world.curjob->recur[world.curjob->curscope].lstcmd = NULL; revm_context_restore(world.context.savedfd, world.context.savedmode, world.context.savedcmd, @@ -275,11 +270,10 @@ /** - * Execute the current script command (only used in interactive mode) + * Execute the current script command */ int revm_execmd() { - //revmargv_t *next; revmjob_t *curjob; revmargv_t *cur; int err; @@ -290,7 +284,7 @@ curjob = world.curjob; /* Curcmd acts like a $PC register */ - for (err = 0, curjob->curcmd = cur = curjob->script[curjob->sourced]; cur; + for (err = 0, curjob->curcmd = cur = curjob->recur[curjob->curscope].script; cur; curjob->curcmd = cur = cur->next) if (cur->cmd != NULL && cur->cmd->exec != NULL) { @@ -323,23 +317,10 @@ end: - /* - ** Free the chain. We can do that in interactive mode - ** because there is no loop support - ** - for (cur = world.curjob->script[world.curjob->sourced]; cur; cur = next) - { - next = cur->next; - XFREE(__FILE__, __FUNCTION__, __LINE__,cur); - } - */ - - curjob->script[curjob->sourced] = curjob->curcmd = NULL; - curjob->lstcmd[curjob->sourced] = NULL; - + curjob->recur[curjob->curscope].script = curjob->curcmd = NULL; + curjob->recur[curjob->curscope].lstcmd = NULL; if (err < 0) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -359,7 +340,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* check if we match a label */ - next = hash_get(&labels_hash[world.curjob->sourced], param); + next = hash_get(&world.curjob->recur[world.curjob->curscope].labels, param); if (next) { if (!next->cmd) @@ -393,15 +374,3 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - - - - - - - - - - - diff -Nru eresi-0.8a25/librevm/vm/Makefile eresi-0.0.20110516/librevm/vm/Makefile --- eresi-0.8a25/librevm/vm/Makefile 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/Makefile 2011-05-16 11:34:11.000000000 +0000 @@ -16,21 +16,21 @@ NAME64 = ../revm-machine.64.o CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ + $(STATOPT2) $(ASMOPT) -DERESI32 $(EXTRACFLAGS) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libaspect/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ + -I../../libedfmt/include/ $(EXTRACFLAGS) \ + $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/librevm/vm/misc-revm.c eresi-0.0.20110516/librevm/vm/misc-revm.c --- eresi-0.8a25/librevm/vm/misc-revm.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/misc-revm.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,14 +1,13 @@ /** - * @file misc.c - * @ingroup librevm_vm - * Started on Fri Nov 2 15:21:56 2001 jfv - * Updated on Fri Sep 11 17:26:11 2005 jfv - * - * $Id: misc-revm.c,v 1.13 2007-11-29 14:01:56 may Exp $ +* @file librevm/vm/misc-revm.c + * @ingroup vm * + * Started on Fri Nov 2 15:21:56 2001 jfv + * $Id: misc-revm.c 1427 2010-07-09 20:54:05Z thorkill $ */ #include "revm.h" + /* XXX: to remove ? #if defined(USE_READLN) rl_command_func_t *rl_ctrll = NULL; @@ -34,13 +33,13 @@ snprintf(name, size - 1, "%s%s%s%s%s%s%s%s%s%s%s ", revm_colorget("%s", "pspecial", "("), - (world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER ? + (world.state.revm_mode == REVM_STATE_EMBEDDED ? revm_colorget("%s", "psname" , E2DBG_ARGV0) : revm_colorget("%s", "psname" , ELFSH_SNAME)), revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", ELFSH_VERSION), + revm_colorget("%s", "pversion", ERESI_VERSION), revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", ELFSH_RELEASE), + revm_colorget("%s", "prelease", ERESI_RELEASE), revm_colorget("%s", "pspecial", "-"), revm_colorget("%s", "pedition", ELFSH_EDITION), revm_colorget("%s", "pspecial", "@"), @@ -54,8 +53,8 @@ */ char *revm_get_prompt() { - if (world.state.revm_mode == ELFSH_VMSTATE_IMODE || - world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_INTERACT || + world.state.revm_mode == REVM_STATE_EMBEDDED) { /* Setup prompt only once */ if (prompt_token_setup == NULL) @@ -71,7 +70,7 @@ return (prompt_token); } - if (world.state.revm_mode == ELFSH_VMSTATE_SCRIPT) + if (world.state.revm_mode == REVM_STATE_SCRIPT) return ""; return "UNKNOWN MODE> "; @@ -86,7 +85,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER) + if (world.state.revm_mode == REVM_STATE_EMBEDDED) mode = E2DBG_NAME; else mode = ELFSH_NAME; @@ -108,7 +107,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (world.curjob->io.type == ELFSH_IONET) + if (world.curjob->io.type == REVM_IO_NET) snprintf(buf, BUFSIZ, "%s <&%u >&0 2>&0 ", cmd, world.curjob->io.output_fd); else snprintf(buf, BUFSIZ, "%s ", cmd); @@ -181,7 +180,6 @@ char buf[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buf, BUFSIZ, " [!] %s [%s] \n\n", label, param); revm_output(buf); PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); @@ -210,11 +208,11 @@ { snprintf(actual, sizeof(actual), "$%u", idx); new = revm_create_IMMEDSTR(1, strdup(av[idx])); - expr = revm_expr_create_from_object(new, actual); + expr = revm_expr_create_from_object(new, actual, 0); } new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - expr = revm_expr_create_from_object(new, REVM_VAR_ARGC); + expr = revm_expr_create_from_object(new, REVM_VAR_ARGC, 0); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -261,7 +259,7 @@ snprintf(logbuf, BUFSIZ - 1, "\n\n\t The %s %s (%s) .::. \n\n %s", revm_modename_get(), - ELFSH_VERSION, + ERESI_VERSION, #if defined(ERESI32) "32 bits built", #elif defined(ERESI64) @@ -283,7 +281,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buf, ELFSH_MEANING, "%s %08X", str, (u_int) type); + snprintf(buf, ERESI_MEANING, "%s %08X", str, (u_int) type); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); } @@ -377,7 +375,7 @@ int revm_setshell(char *str) { PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_setvar_str(ELFSH_SHELLVAR, str) < 0) + if (revm_setvar_str(ERESI_EXTSHELLVAR, str) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot modify shell var", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); diff -Nru eresi-0.8a25/librevm/vm/.svn/all-wcprops eresi-0.0.20110516/librevm/vm/.svn/all-wcprops --- eresi-0.8a25/librevm/vm/.svn/all-wcprops 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 34 -/svn/!svn/ver/950/trunk/librevm/vm -END -misc-revm.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/906/trunk/librevm/vm/misc-revm.c -END -init.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/916/trunk/librevm/vm/init.c -END -fini.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/906/trunk/librevm/vm/fini.c -END -loop.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/906/trunk/librevm/vm/loop.c -END -tables.c -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/946/trunk/librevm/vm/tables.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/950/trunk/librevm/vm/Makefile -END diff -Nru eresi-0.8a25/librevm/vm/.svn/entries eresi-0.0.20110516/librevm/vm/.svn/entries --- eresi-0.8a25/librevm/vm/.svn/entries 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/librevm/vm -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -misc-revm.c -file - - - - -2008-04-06T23:15:45.326153Z -f2de7df810d04bd5a279f7bfe65fdb3a -2008-03-14T00:57:20.622435Z -906 -enioh - -init.c -file - - - - -2008-04-06T23:15:45.347893Z -69a457384db0ae18eb4efaac6e175923 -2008-03-18T18:43:08.635419Z -916 -pouik - -fini.c -file - - - - -2008-04-06T23:15:45.357887Z -1b6c0d2362fc74dbd14ca550e6916d64 -2008-03-14T00:57:20.622435Z -906 -enioh - -loop.c -file - - - - -2008-04-06T23:15:45.369024Z -7f3d7803f3c4af5d8b91b0f4d9201a94 -2008-03-14T00:57:20.622435Z -906 -enioh - -tables.c -file - - - - -2008-04-06T23:15:45.380463Z -ce664cf340b70038b8f156fb7865bbb4 -2008-03-27T22:53:48.747992Z -946 -may - -Makefile -file - - - - -2008-04-06T23:15:45.391806Z -2bef5cbf74a0e486b4d396a21f46d26e -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/librevm/vm/.svn/format eresi-0.0.20110516/librevm/vm/.svn/format --- eresi-0.8a25/librevm/vm/.svn/format 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/fini.c.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/fini.c.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/fini.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/fini.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -/* - * @file fini.c - * @ingroup librevm_vm - * @brief Routines executed when leaving script mode. - * - * Started on Wed Nov 19 23:02:04 2003 jfv - * $Id: fini.c,v 1.1 2008-02-16 12:32:27 thor Exp $ - */ -#include "revm.h" - - - -/* Some REVM context cleanup when coming back from script to interactive mode */ -void revm_cleanup() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.curjob->script[world.curjob->sourced] = NULL; - world.curjob->lstcmd[world.curjob->sourced] = NULL; - revm_conditional_rlquit(); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/* Mostly for some post-execution code inside etrace */ -void revm_postexec(int retval) -{ - int ret; - char *buggyfunc; - char logbuf[256]; - - if (!world.state.revm_quiet && world.state.revm_mode == REVM_STATE_SCRIPT) - { - if (retval < 0) - revm_output("\n [E] Script execution failed \n\n"); - else - revm_output("\n [*] Script execution ended succesfully \n\n"); - } - - /* Implicit unload or save if we are not in interactive mode */ - if ((world.state.revm_mode == REVM_STATE_CMDLINE - || world.state.revm_mode == REVM_STATE_TRACER) && world.curjob->curfile) - { - /* Start tracing if we are on tracer state (etrace) */ - if (world.state.revm_mode == REVM_STATE_TRACER) - { - profiler_error_reset(); - if (traces_run(world.curjob->curfile, NULL, 0) < 0) - { - buggyfunc = etrace_geterrfunc(); - - /* Not NULL if issue occurs when we iterate though functions */ - if (buggyfunc) - { - snprintf(logbuf, 255, " [!] There is an issue with the function: %s\n", - buggyfunc); - revm_output(logbuf); - } - - profiler_error(); - } - } - - ret = revm_workfiles_unload(); - } -} - - diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/init.c.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/init.c.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/init.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/init.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,231 +0,0 @@ -/** - * @file elfsh.c - * @ingroup librevm_vm - * Started on Wed Feb 21 22:02:36 2001 jfv - * Updated on Tue Jun 27 23:51:04 2006 mxatone - * - * $Id: init.c,v 1.37 2008-02-16 12:32:27 thor Exp $ - * - */ - -#include "revm.h" - - -/* The ELFsh world */ -revmworld_t world; - - - -/** - * Signal handler for SIGINT - */ -void sigint_handler(int signum) -{ - if (world.state.revm_mode == REVM_STATE_CMDLINE) - revm_exit(0); -} - - -/** - * Only one time initialisations - * Called from CTORS - */ -int revm_init() -{ - - /* Must be here in case of script params presence */ - bzero(&world, sizeof (world)); - - aspect_called_ctors_inc(); - - /* Set the world up */ - aspect_init(); - asm_init_ia32(&world.proc); - asm_init_sparc(&world.proc_sparc); - asm_init_mips(&world.proc_mips); - revm_initio(); - - /* setting libelfsh profile function */ - /* error on stdout, profile on stderr */ - profiler_install(revm_outerr, revm_output); - - if (aspect_called_ctors_finished()) - e2dbg_presence_reset(); - - return (0); -} - - - - -/** - * Setup ELFsh/e2dbg hash tables and structures - */ -int revm_setup(int ac, char **av, - char mode, char side) -{ - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Detect the mode we are running in */ - if (mode == REVM_STATE_DEBUGGER) - { - /* Set the mode, side, and IO of the debugger */ - world.state.revm_mode = mode; - world.state.revm_side = side; - revm_fifo_io(world.curjob); - revm_buffer_reset(1); - elfsh_set_debug_mode(); - } - else if (mode == REVM_STATE_TRACER) - { - elfsh_set_static_mode(); - - world.state.revm_mode = mode; - world.state.revm_side = side; - } - /* Set REVM in static mode */ - else - { - elfsh_set_static_mode(); - - if (ac == 1) - world.state.revm_mode = REVM_STATE_INTERACTIVE; - else if (revm_testscript(ac, av)) - { - world.state.revm_mode = REVM_STATE_SCRIPT; - revm_tables_setup(); - if (revm_openscript(&av[1]) < 0) - QUIT_ERROR(-1); - ac = 1; - av[1] = NULL; - } - } - - /* on.load. */ - config_add_item(ERESI_VMCONFIG_ONLOAD_RCONTROL, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 1); - - config_add_item(ERESI_VMCONFIG_GRAPH_STORAGEPATH, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *)"/tmp/"); - - config_add_item(ERESI_VMCONFIG_GRAPH_VIEWCMD, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *)"xzgv"); - - config_add_item(ERESI_VMCONFIG_GRAPH_AUTOVIEW, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 1); - - config_add_item(ERESI_VMCONFIG_GRAPH_AUTOBUILD, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 1); - - config_add_item(ERESI_VMCONFIG_USE_MORE, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 1); - - config_add_item(CONFIG_USE_ASMDEBUG, - CONFIG_TYPE_INT, - CONFIG_MODE_RW, - (void *) 0); - - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "%s/%s", getenv("HOME"), ERESI_DEFAULT_HISTORY); - - config_add_item(ERESI_VMCONFIG_HISTORY, - CONFIG_TYPE_STR, - CONFIG_MODE_RW, - (char *)buff); - - revm_tables_setup(); - elfsh_setup_hooks(); - - if (!mjr_init_session(&world.mjr_session)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "mjollnir session can't be initialized.", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Open the .eresirc file and execute it - */ -int revm_config(char *config) -{ - char buff[BUFSIZ]; - char *home; - int ret; - static int done = 0; - revmargv_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (done) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - ret = -1; - home = getenv("HOME"); - if (home) - { - if (!config) - snprintf(buff, sizeof(buff), "%s/%s", home, REVM_CONFIG); - else - snprintf(buff, sizeof(buff), "%s/%s", home, config); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, - new, sizeof(revmargv_t), -1); - memset(new, 0, sizeof(revmargv_t)); - world.curjob->curcmd = new; - world.curjob->curcmd->param[0] = buff; - ret = revm_source(world.curjob->curcmd->param); - world.curjob->curcmd = NULL; - XFREE(__FILE__, __FUNCTION__, __LINE__,new); - } - if (ret < 0) - revm_output("\n [*] No configuration in ~/" REVM_CONFIG " \n\n"); - done = 1; - - revm_init_history(world.state.revm_mode); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Interface initialisation && loop entry point - */ -int revm_run(int ac, char **av) -{ - - /* Do not handle signals in debugger mode */ - if (world.state.revm_mode != REVM_STATE_DEBUGGER) - { - signal(SIGQUIT, SIG_IGN); - signal(SIGTERM, SIG_IGN); - signal(SIGINT, sigint_handler); - } - -#if __DEBUG_SIGHANDLER__ - revm_output("[elfsh:main] started !\n"); -#endif - - revm_completion_install(world.state.revm_mode, - world.state.revm_side); - revm_flush(); - revm_prompt_log(); - - /* Now run f0r3st */ - return (revm_loop(ac, av)); -} diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/loop.c.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/loop.c.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/loop.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/loop.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,407 +0,0 @@ -/* - * @file loop.c - * @ingroup librevm_vm - * @brief This file include the control flow support for scripting. - * - * Started on Wed Nov 19 23:02:04 2003 jfv - * $Id: loop.c,v 1.14 2008-02-16 12:32:27 thor Exp $ - */ -#include "revm.h" - - -/** - * The infinite main loop of the interactive command - */ -int revm_loop(int argc, char **argv) -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = 0; - - do { - - /* Come back to the loop if a script turns into interactive mode */ - reenter: - - /* Fill argv from stdin if we are in interactive mode */ - if ((world.state.revm_mode != REVM_STATE_CMDLINE - && world.state.revm_mode != REVM_STATE_TRACER) - || world.state.revm_net == 1) - { - if (world.state.revm_mode != REVM_STATE_SCRIPT) - { - if (revm_select() < 0) - { - fprintf(stderr,"revm_select : failed \n"); - revm_exit(-1); - } - - /* If the FIFO does not exist anymore, - the server has quit, so we quit too */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - (access(REVM_FIFO_S2C, F_OK) < 0 || - access(REVM_FIFO_C2S, F_OK) < 0)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Take a line, execute old command if void line */ - argv = revm_input(&argc, NULL); - if (world.state.revm_mode == REVM_STATE_INTERACTIVE || - world.state.revm_mode == REVM_STATE_DEBUGGER || - world.state.revm_mode == REVM_STATE_SCRIPT || - world.state.revm_net) - { - if (argv == ((char **) REVM_INPUT_VOID)) - continue; - else if (argv == ((char **) REVM_INPUT_TRANSFERED)) - continue; - } - - /* CTRL-D -> !argv */ - if (!argv) - { - revm_output("\n"); - - /* when debugging -> back to main program */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - { - revm_cleanup(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - } - - /* if net is enable but we are not in e2dbg -> ignore */ - if (world.state.revm_net) - continue; - - /* othewise exit */ - break; - - } - } - - /* Fetch the current scripting command */ - if (revm_parseopt(argc, argv) < 0) - { - if (world.state.revm_mode != REVM_STATE_CMDLINE - && world.state.revm_mode != REVM_STATE_TRACER) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, argv); - if (world.state.revm_mode != REVM_STATE_INTERACTIVE && - world.state.revm_mode != REVM_STATE_DEBUGGER) - goto end; - } - else if (!world.state.revm_net) - revm_exit(-1); - } - - /* Just execute one command if we are not in script mode */ - if (world.state.revm_mode != REVM_STATE_SCRIPT) - { - world.curjob->curcmd = world.curjob->script[0]; - switch (revm_execmd()) - { - case REVM_SCRIPT_CONTINUE: - //printf(" [*] e2dbg continue from revm_execmd \n"); - revm_cleanup(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); - case REVM_SCRIPT_ERROR: - profiler_error(); - default: - break; - } - } - - /* Quit parsing if necessary */ - if ((!world.curjob->curcmd && world.state.revm_mode == REVM_STATE_SCRIPT)) //|| - /*(world.curjob->curcmd && world.curjob->curcmd->name && - (!strcmp(world.curjob->curcmd->name, CMD_QUIT) || - !strcmp(world.curjob->curcmd->name, CMD_QUIT2))))*/ - break; - } - while ((world.state.revm_mode != REVM_STATE_CMDLINE - && world.state.revm_mode != REVM_STATE_TRACER) - || world.state.revm_net); - - /* If we are in scripting, execute commands list now */ - if (world.state.revm_mode == REVM_STATE_SCRIPT) - { - fprintf(stderr, "we are in script mode from revm_loop ! \n"); - - world.curjob->curcmd = world.curjob->script[0]; - ret = revm_execscript(); - if (ret == REVM_SCRIPT_STOP) - { - XCLOSE(world.curjob->ws.io.input_fd, -1); - world.curjob->ws.io.input_fd = 0; - goto reenter; - } - else if (ret < 0) - profiler_error(); - } - - end: - revm_postexec(ret); - revm_callback_handler_remove(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - - /* Clean the script machine state when a script is over */ - //XXX: looks never called now -- world.curjob->curcmd = NULL; - //revm_cleanup(); - //PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * Execute an ERESI script (only used in non-interactive mode or when sourcing a script) - */ -int revm_execscript() -{ - revmargv_t *cur; - revmargv_t *next; - int status; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Restore the command pointer if we used 'cont' */ - if (world.state.revm_sourcing) - { - cur = world.context.curcmd; - world.curjob->curcmd = cur; - - //fprintf(stderr, "Restored curcmd (%s) after CONTINUE \n", cur->name); - //sleep(1); - - } - else - cur = world.curjob->script[world.curjob->sourced]; - - /* Curcmd acts like a $PC register */ - for (; cur; cur = next) - { - - /* Lazy evaluation is only used for module commands called from scripts */ - /* -> We dont have to load the module for the whole script duration */ - if (cur->cmd == NULL) - { - cur->cmd = hash_get(&cmd_hash, cur->param[0]); - if (cur->cmd != NULL && cur->cmd->reg != NULL) - { - REVM_CMDARGS_COUNT(cur); - if (cur->cmd->reg(0, cur->argc, cur->param) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Commande parsing failed", - revm_doerror(revm_badparam, cur->param[0])); - } - } - - /* Test for e2dbg scripting */ - if (!strcmp(cur->name, CMD_CONTINUE) || !strcmp(cur->name, CMD_CONTINUE2)) - { - next = cur->next; - world.context.curcmd = next; - world.state.revm_sourcing = 1; - fprintf(stderr, "Found -continue- in script, sourcing flag now -ON- \n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - REVM_SCRIPT_CONTINUE); - } - - /* Execute instruction */ - if (cur->cmd != NULL && cur->cmd->exec != NULL) - { - if (!world.state.revm_quiet) - revm_print_actual(cur); - if (revm_implicit(cur->cmd) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Implicit operations failed", -1); - status = cur->cmd->exec(); - if (status < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command execution failed", -1); - } - else - revm_error("Lazy evaluation failed for command", cur->param[0]); - - /* Current instruction modified the script control flow ? */ - if (cur == world.curjob->curcmd) - { - next = cur->next; - world.curjob->curcmd = next; - } - else - next = world.curjob->curcmd; - - /* Break the flow if we switched to interactive mode */ - switch (status) - { - case REVM_SCRIPT_STOP: - case REVM_SCRIPT_QUIT: - world.context.curcmd = next; - goto end; - case REVM_SCRIPT_CONTINUE: - world.context.curcmd = next; - world.state.revm_sourcing = 1; - fprintf(stderr, "Found -start- in script, sourcing flag now -ON- \n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - REVM_SCRIPT_CONTINUE); - } - } - - - /* We finished executing the script for now */ - end: - - /* If we had a saved context, restore it */ - if (world.state.revm_sourcing) - { - world.curjob->lstcmd[world.curjob->sourced] = NULL; - revm_context_restore(world.context.savedfd, - world.context.savedmode, - world.context.savedcmd, - world.context.savedinput, - world.context.savedargv, - world.context.savedname); - world.curjob->curcmd = NULL; - world.state.revm_sourcing = 0; - } - - /* Make sure we switch to interactive mode if we issued a stop command */ - if (status == REVM_SCRIPT_STOP) - world.state.revm_mode = REVM_STATE_INTERACTIVE; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, status); -} - - - -/** - * Execute the current script command (only used in interactive mode) - */ -int revm_execmd() -{ - //revmargv_t *next; - revmjob_t *curjob; - revmargv_t *cur; - int err; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - curjob = world.curjob; - - /* Curcmd acts like a $PC register */ - for (err = 0, curjob->curcmd = cur = curjob->script[curjob->sourced]; cur; - curjob->curcmd = cur = cur->next) - if (cur->cmd != NULL && cur->cmd->exec != NULL) - { - /* Reset profiler message before anything */ - profiler_error_reset(); - - if (revm_implicit(cur->cmd) < 0) - { - profiler_error(); - err = -1; - goto end; - } - - /* Execute the command exec handler */ - ret = cur->cmd->exec(); - - /* Problem during the command */ - if (ret < 0) - { - err = -1; - goto end; - } - - /* We are executing 'cont' from e2dbg */ - else if (ret == REVM_SCRIPT_CONTINUE) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - REVM_SCRIPT_CONTINUE); - } - - - end: - - /* - ** Free the chain. We can do that in interactive mode - ** because there is no loop support - ** - for (cur = world.curjob->script[world.curjob->sourced]; cur; cur = next) - { - next = cur->next; - XFREE(__FILE__, __FUNCTION__, __LINE__,cur); - } - */ - - curjob->script[curjob->sourced] = curjob->curcmd = NULL; - curjob->lstcmd[curjob->sourced] = NULL; - - if (err < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * Take the ERESI machine control flow in charge - */ -int revm_move_pc(char *param) -{ - int index; - int jmp; - revmargv_t *next; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* check if we match a label */ - next = hash_get(&labels_hash[world.curjob->sourced], param); - if (next) - { - if (!next->cmd) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid EOF branchement", -1); - world.curjob->curcmd = next; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Use the parameter as a numerical index */ - jmp = atoi(param); - if (jmp < 0) - for (index = 0, jmp = -jmp; index != jmp; index++) - { - if (!world.curjob->curcmd->prev) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid backward branchement", -1); - world.curjob->curcmd = world.curjob->curcmd->prev; - } - else if (jmp > 0) - for (index = 0; index != jmp; index++) - { - if (!world.curjob->curcmd->next) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid forward branchement", -1); - world.curjob->curcmd = world.curjob->curcmd->next; - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid null branchement", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - - - - - - - diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -## -## Makefile for vm in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = init.c loop.c tables.c fini.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME = librevm -NAME32 = ../revm-machine.32.o -NAME64 = ../revm-machine.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libaspect/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -fclean: clean - @$(RM) *.o - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/misc-revm.c.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/misc-revm.c.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/misc-revm.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/misc-revm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,423 +0,0 @@ -/** - * @file misc.c - * @ingroup librevm_vm - * Started on Fri Nov 2 15:21:56 2001 jfv - * Updated on Fri Sep 11 17:26:11 2005 jfv - * - * $Id: misc-revm.c,v 1.13 2007-11-29 14:01:56 may Exp $ - * - */ -#include "revm.h" - -/* XXX: to remove ? -#if defined(USE_READLN) - rl_command_func_t *rl_ctrll = NULL; -#endif -*/ - -char buf[BUFSIZ]; - - -/** - * - */ -void revm_set_prompt(void (*func) (char *name, u_int size)) -{ - prompt_token_setup = func; -} - -/** - * - */ -void revm_create_default_prompt(char *name, u_int size) -{ - snprintf(name, size - 1, - "%s%s%s%s%s%s%s%s%s%s%s ", - revm_colorget("%s", "pspecial", "("), - (world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER ? - revm_colorget("%s", "psname" , E2DBG_ARGV0) : - revm_colorget("%s", "psname" , ELFSH_SNAME)), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pversion", ELFSH_VERSION), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "prelease", ELFSH_RELEASE), - revm_colorget("%s", "pspecial", "-"), - revm_colorget("%s", "pedition", ELFSH_EDITION), - revm_colorget("%s", "pspecial", "@"), - revm_colorget("%s", "psname", world.curjob->name), - revm_colorget("%s", "pspecial", ")")); - revm_endline(); -} - -/** - * return the right prompt - */ -char *revm_get_prompt() -{ - if (world.state.revm_mode == ELFSH_VMSTATE_IMODE || - world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER) - { - /* Setup prompt only once */ - if (prompt_token_setup == NULL) - revm_set_prompt(revm_create_default_prompt); - - if (prompt_token_setup) - prompt_token_setup(prompt_token, sizeof(prompt_token)); - else - snprintf(prompt_token, sizeof(prompt_token) - 1, "prompt-error"); - - /* Prompt on readline need some modifications */ - revm_prompt_update(prompt_token, sizeof(prompt_token)); - return (prompt_token); - } - - if (world.state.revm_mode == ELFSH_VMSTATE_SCRIPT) - return ""; - - return "UNKNOWN MODE> "; -} - -/** - * return the project name accordingly to mode - */ -char *revm_modename_get() -{ - char *mode; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_mode == ELFSH_VMSTATE_DEBUGGER) - mode = E2DBG_NAME; - else - mode = ELFSH_NAME; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (mode)); -} - - -/** - * Our system implementation - */ -int revm_system(char *cmd) -{ - char buf[BUFSIZ]; - int ret; - char **av; - int nbr; - int argc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->io.type == ELFSH_IONET) - snprintf(buf, BUFSIZ, "%s <&%u >&0 2>&0 ", cmd, world.curjob->io.output_fd); - else - snprintf(buf, BUFSIZ, "%s ", cmd); - - /* If the user shell is unspecified we use system */ - nbr = revm_findblanks(cmd); - av = revm_doargv(nbr, (u_int *)&argc, cmd); - av++; - if (!fork()) - ret = execvp(av[0], av); - else - wait(NULL); - - /* Report result */ - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Shell not found", 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - - -/** - * Decide what to do for exiting depending on the current input - */ -void revm_exit(int err) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - _exit(err); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Bad parameter handler - */ -void revm_badparam(char *str) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, - "\n [!] Invalid parameters for command %s .::. " - "type 'help' for command list \n\n", str); - revm_output(buf); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Unknow command handler - */ -void revm_unknown(char *str) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, "\n [!] Unknown command %s .::. " - "type 'help' for command list \n\n", str); - revm_output(buf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Generic error message handler - */ - -void revm_error(char *label, char *param) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, " [!] %s [%s] \n\n", label, param); - revm_output(buf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * Open the script file - */ -int revm_openscript(char **av) -{ - int fd; - int idx; - char actual[16]; - revmobj_t *new; - revmexpr_t *expr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Open script file */ - XOPEN(fd, av[0], O_RDONLY, 0, -1); - world.curjob->io.input_fd = fd; - - /* Add argument variables */ - for (idx = 1; av[idx]; idx++) - { - snprintf(actual, sizeof(actual), "$%u", idx); - new = revm_create_IMMEDSTR(1, strdup(av[idx])); - expr = revm_expr_create_from_object(new, actual); - } - - new = revm_create_IMMED(ASPECT_TYPE_INT, 1, idx - 1); - expr = revm_expr_create_from_object(new, REVM_VAR_ARGC); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Say if we are in script mode - */ -int revm_testscript(int ac, char **av) -{ - int fd; - char buff[30]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (ac < 2 || (av[1] && av[1][0] == ELFSH_MINUS)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - XOPEN(fd, av[1], O_RDONLY, 0, 0); - XREAD(fd, buff, 30, 0); - buff[29] = 0x00; - if (strncmp(buff, "#!", 2)) - { - XCLOSE(fd, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid script interpreter", 0); - } - if (!strstr(buff, av[0]) && !strstr(buff, "elfsh")) - { - XCLOSE(fd, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Not an ELFsh script", 0); - } - XCLOSE(fd, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} - -/** - * Print the banner - */ -void revm_banner_print() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, - "\n\n\t The %s %s (%s) .::. \n\n %s", - revm_modename_get(), - ELFSH_VERSION, -#if defined(ERESI32) - "32 bits built", -#elif defined(ERESI64) - "64 bits built", -#else - "Unknown built", -#endif - "\t .::. This software is under the General Public License V.2 \n" - "\t .::. Please visit http://www.gnu.org \n\n"); - revm_output(logbuf); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Print the Unknown buffer -*/ -char *revm_build_unknown(char *buf, const char *str, u_long type) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, ELFSH_MEANING, "%s %08X", str, (u_int) type); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (buf)); -} - - -/** - * Retreive a file object giving its unique ID - */ -elfshobj_t *revm_getfile(u_int id) -{ - elfshobj_t *cur; - elfshobj_t *subcur; - char **keys; - int idx; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check in private objects of the workspace */ - if (hash_size(&world.curjob->loaded)) - { - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (idx = 0; idx < keynbr; idx++) - { - cur = hash_get(&world.curjob->loaded, keys[idx]); - if (cur->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - - if ((subcur = revm_is_depid(cur, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (subcur)); - } - } - - /* Check in shared objects */ - if (hash_size(&world.shared_hash)) - { - keys = hash_get_keys(&world.shared_hash, &keynbr); - for (idx = 0; idx < keynbr; idx++) - { - cur = hash_get(&world.shared_hash, keys[idx]); - if (cur->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - - if ((subcur = revm_is_depid(cur, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (subcur)); - } - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find file", (NULL)); -} - -/** - * Retreive a module object giving its unique ID - */ -revmmod_t *revm_getmod(u_int index) -{ - revmmod_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (cur = world.modlist; cur; cur = cur->next) - if (cur->id == index) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (cur)); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find module", (NULL)); -} - -/** - * Print error depending on the state of the machine - */ -int revm_doerror(void (*fct)(char *str), char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_mode != ELFSH_VMSTATE_CMDLINE || world.state.revm_net) - fct(str); - else - { - cmd_help(); - exit(-1); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Bypassed error printing", (-1)); -} - - -/** - * Change the shell variable - */ -int revm_setshell(char *str) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_setvar_str(ELFSH_SHELLVAR, str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot modify shell var", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * The internal basename function - */ -char *revm_basename(char *str) -{ - char *cur; - char *ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = NULL; - cur = str; - while ((cur = strchr(cur, '/'))) - if (!*(cur + 1)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No basename", (NULL)); - else - ret = ++cur; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * Useful to differentiate 0 and a string - */ -int revm_isnbr(char *string) -{ - size_t len = strlen(string); - size_t ii; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (ii=0; ii < len; ii++) - if (!isdigit((int) string[ii])) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); -} diff -Nru eresi-0.8a25/librevm/vm/.svn/text-base/tables.c.svn-base eresi-0.0.20110516/librevm/vm/.svn/text-base/tables.c.svn-base --- eresi-0.8a25/librevm/vm/.svn/text-base/tables.c.svn-base 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/.svn/text-base/tables.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1064 +0,0 @@ -/** - * @defgroup librevm_vm librevm VM - */ -/* -** @file tables.c -** @ingroup librevm_vm -** @brief This file contains all command and objects definitions for scripting. -** -** Started on Sat Jan 25 07:48:41 2003 jfv -** -** $Id: tables.c,v 1.54 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "revm.h" - -/* Labels hash */ -hash_t labels_hash[REVM_MAXSRCNEST]; - -/* ERESI script machine frames list */ -list_t frames_list; - -/* Eresi expressions hash and expressions type hash */ -hash_t exprs_hash; - -/* The command hash table : hash the command name and returns a revmcmd_t */ -hash_t cmd_hash; - -/* The constants hash tables : ascii defines from elf.h and revm.h */ -hash_t const_hash; - -/* The ELF shell module hash tables: returns a revmmod_t */ -hash_t mod_hash; - -/* The file hash table : hash the filename and returns a elfshobj_t pointer */ -hash_t file_hash; - -/* The Level 1 object hash table : hash the object name and returns a revmL1_t pointer */ -hash_t L1_hash; - -/* The Level 2 object hash table list : hash the object name and returns a revmL2_t pointer */ -hash_t elf_L2_hash; /* For the ELF header fields */ -hash_t sht_L2_hash; /* For the Sections/SHT objects */ -hash_t pht_L2_hash; /* For the Program header table objects */ -hash_t sym_L2_hash; /* For symbol object field */ -hash_t rel_L2_hash; /* For relocation entry fields */ -hash_t dynsym_L2_hash; /* For .dynsym objects */ -hash_t dyn_L2_hash; /* For .dynamic objects */ -hash_t sct_L2_hash; /* Sections names and data */ -hash_t got_L2_hash; /* GOT objects */ -hash_t vers_L2_hash; /* For .gnu.version */ -hash_t verd_L2_hash; /* For .gnu.version_d */ -hash_t vern_L2_hash; /* For .gnu.version_r */ -hash_t hashb_L2_hash; /* For .hash (bucket) */ -hash_t hashc_L2_hash; /* For .hash (chain) */ - -/* Color hash */ -hash_t fg_color_hash; -hash_t bg_color_hash; -hash_t t_color_hash; - -/* Grammar parser hash */ -hash_t parser_hash; - -/* Trace hash */ -hash_t traces_cmd_hash; - -/* Lib path store variable */ -char elfsh_libpath[BUFSIZ]; - -/* Hash of instruction lists */ -hash_t instrlists_hash; - - -/** - * Fill all the Level 1 Objects hash tables - */ -static void setup_L1hash() -{ - hash_init(&L1_hash, "L1objects", 29, ASPECT_TYPE_HASH); - hash_add(&L1_hash, "hdr" , (void *) revm_create_L1ENT(elfsh_get_hdr, - NULL, NULL, - &elf_L2_hash, - NULL, NULL, NULL, 0)); - - hash_add(&L1_hash, "pht" , (void *) revm_create_L1ENT(elfsh_get_pht, - NULL, NULL, - &pht_L2_hash, - elfsh_get_pht_entry_by_index, - NULL, NULL, - sizeof (elfsh_Phdr))); - - hash_add(&L1_hash, "rpht" , (void *) revm_create_L1ENT(elfsh_get_rpht, - NULL, NULL, - &pht_L2_hash, - elfsh_get_pht_entry_by_index, - NULL, NULL, - sizeof (elfsh_Phdr))); - - - hash_add(&L1_hash, "symtab" , (void *) revm_create_L1ENT(elfsh_get_symtab, - NULL, - elfsh_get_symbol_by_name, - &sym_L2_hash, - elfsh_get_symbol_by_index, - NULL, NULL, - sizeof (elfsh_Sym))); - - hash_add(&L1_hash, "dynsym" , (void *) revm_create_L1ENT(elfsh_get_dynsymtab, - NULL, - elfsh_get_dynsymbol_by_name, - &dynsym_L2_hash, - elfsh_get_symbol_by_index, - NULL, NULL, - sizeof (elfsh_Sym))); - - hash_add(&L1_hash, "got" , (void *) revm_create_L1ENT(elfsh_get_got, - elfsh_get_got_by_idx, - elfsh_get_got_entry_by_name, - &got_L2_hash, - elfsh_get_got_entry_by_index, - elfsh_get_got_entry, - elfsh_set_got_entry, - sizeof (eresi_Addr))); - - - hash_add(&L1_hash, "dynamic" , (void *) revm_create_L1ENT(elfsh_get_dynamic, - NULL, NULL, - &dyn_L2_hash, - elfsh_get_dynamic_entry_by_index, - NULL, NULL, - sizeof (elfsh_Dyn))); - - hash_add(&L1_hash, "ctors" , (void *) revm_create_L1ENT(elfsh_get_ctors, - NULL, - elfsh_get_ctors_entry_by_name, - NULL, - elfsh_get_ctors_entry_by_index, - elfsh_get_ctors_entry, - elfsh_set_ctors_entry, - sizeof (eresi_Addr))); - - hash_add(&L1_hash, "dtors" , (void *) revm_create_L1ENT(elfsh_get_dtors, - NULL, - elfsh_get_dtors_entry_by_name, - NULL, - elfsh_get_dtors_entry_by_index, - elfsh_get_dtors_entry, - elfsh_set_dtors_entry, - sizeof (eresi_Addr))); - - hash_add(&L1_hash, "rel" , (void *) revm_create_L1ENT(NULL, - elfsh_get_reloc, // slot 2 - elfsh_get_relent_by_name, - &rel_L2_hash, - elfsh_get_relent_by_index, - NULL, NULL, - sizeof (elfsh_Rel))); - - hash_add(&L1_hash, "sht" , (void *) revm_create_L1ENT(elfsh_get_sht, - NULL, - elfsh_get_sht_entry_by_name, - &sht_L2_hash, - elfsh_get_sht_entry_by_index, - NULL, NULL, - sizeof (elfsh_Shdr))); - - hash_add(&L1_hash, "rsht" , (void *) revm_create_L1ENT(elfsh_get_runtime_sht, - NULL, - elfsh_get_sht_entry_by_name, - &sht_L2_hash, - elfsh_get_sht_entry_by_index, - NULL, NULL, - sizeof (elfsh_Shdr))); - - hash_add(&L1_hash, "section", (void *) revm_create_L1ENT(elfsh_get_section_list, - NULL, - elfsh_get_section_by_nam, - &sct_L2_hash, - elfsh_get_section_by_idx, - NULL, NULL, - sizeof (elfshsect_t))); - - hash_add(&L1_hash, "version", (void *) revm_create_L1ENT(elfsh_get_versymtab, - NULL, - elfsh_get_versym_by_name, - &vers_L2_hash, - elfsh_get_versym_entry_by_index, - NULL, NULL, - sizeof (elfsh_Half))); - - hash_add(&L1_hash, "verdef", (void *) revm_create_L1ENT(elfsh_get_verdeftab, - elfsh_get_verdeftab_by_idx, - NULL, - &verd_L2_hash, - elfsh_get_verdef_entry_by_index, - NULL, NULL, - sizeof (elfsh_Verdef))); - - hash_add(&L1_hash, "verneed", (void *) revm_create_L1ENT(elfsh_get_verneedtab, - NULL, - elfsh_get_verneed_by_name, - &vern_L2_hash, - elfsh_get_verneed_entry_by_index, - NULL, NULL, - sizeof (elfsh_Verneed))); - - hash_add(&L1_hash, "hashbucket", (void *) revm_create_L1ENT(elfsh_get_hashtable, - NULL, - elfsh_get_hashbucket_by_name, - &hashb_L2_hash, - elfsh_get_hashbucket_by_index, - NULL, NULL, - sizeof (int))); - - hash_add(&L1_hash, "hashchain", (void *) revm_create_L1ENT(elfsh_get_hashtable, - NULL, - elfsh_get_hashchain_by_name, - &hashc_L2_hash, - elfsh_get_hashchain_by_index, - NULL, NULL, - sizeof (int))); -} - - -/** - * Hash table for ELF header fields - */ -static void setup_elfhash() -{ - hash_init(&elf_L2_hash, "elfL2objects", 29, ASPECT_TYPE_UNKNOW); - hash_add(&elf_L2_hash, "magic" , revm_create_L2ENT(elfsh_get_magic, - elfsh_set_magic, - ASPECT_TYPE_INT, - NULL, NULL, - NULL, NULL)); - - hash_add(&elf_L2_hash, "class" , revm_create_L2ENT(elfsh_get_class, - elfsh_set_class, - ASPECT_TYPE_INT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "type" , revm_create_L2ENT(elfsh_get_objtype, - elfsh_set_objtype, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "machine" , revm_create_L2ENT(elfsh_get_arch, - elfsh_set_arch, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "version" , revm_create_L2ENT(elfsh_get_version, - elfsh_set_version, - ASPECT_TYPE_INT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "entry" , revm_create_L2ENT(elfsh_get_entrypoint, - elfsh_set_entrypoint, - ASPECT_TYPE_CADDR, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "phoff" , revm_create_L2ENT(elfsh_get_phtoff, - elfsh_set_phtoff, - ASPECT_TYPE_LONG, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "rphoff" , revm_create_L2ENT(elfsh_get_rphtoff, - elfsh_set_rphtoff, - ASPECT_TYPE_LONG, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "shoff" , revm_create_L2ENT(elfsh_get_shtoff, - elfsh_set_shtoff, - ASPECT_TYPE_LONG, - NULL, NULL, NULL, NULL)); - hash_add(&elf_L2_hash, "flags" , revm_create_L2ENT(elfsh_get_flags, - elfsh_set_flags, - ASPECT_TYPE_INT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "ehsize" , revm_create_L2ENT(elfsh_get_ehsize, - elfsh_set_ehsize, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "phentsize" , revm_create_L2ENT(elfsh_get_phentsize, - elfsh_set_phentsize, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "shentsize" , revm_create_L2ENT(elfsh_get_shentsize, - elfsh_set_shentsize, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "phnum" , revm_create_L2ENT(elfsh_get_phtnbr, - elfsh_set_phtnbr, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "shnum" , revm_create_L2ENT(elfsh_get_shtnbr, - elfsh_set_shtnbr, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "shstrndx" , revm_create_L2ENT(elfsh_get_shstrtab_index, - elfsh_set_shstrtab_index, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_pageexec" , revm_create_L2ENT(elfsh_get_pax_pageexec, - elfsh_set_pax_pageexec, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_emultramp", revm_create_L2ENT(elfsh_get_pax_emultramp, - elfsh_set_pax_emultramp, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_mprotect" , revm_create_L2ENT(elfsh_get_pax_mprotect, - elfsh_set_pax_mprotect, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_randmmap" , revm_create_L2ENT(elfsh_get_pax_randmmap, - elfsh_set_pax_randmmap, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_randexec" , revm_create_L2ENT(elfsh_get_pax_randexec, - elfsh_set_pax_randexec, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); - hash_add(&elf_L2_hash, "pax_segmexec" , revm_create_L2ENT(elfsh_get_pax_segmexec, - elfsh_set_pax_segmexec, - ASPECT_TYPE_SHORT, - NULL, NULL, - NULL, NULL)); -} - - - -/** - * Hash table for SHT fields - */ -static void setup_shthash() -{ - hash_init(&sht_L2_hash, "shtL2objects", 29, ASPECT_TYPE_UNKNOW); - hash_add(&sht_L2_hash, "type" , revm_create_L2ENT(elfsh_get_section_type, - elfsh_set_section_type, - 0, NULL, NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "addr" , revm_create_L2ENT(elfsh_get_section_addr, - elfsh_set_section_addr, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "offset" , revm_create_L2ENT(elfsh_get_section_foffset, - elfsh_set_section_foffset, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "size" , revm_create_L2ENT(elfsh_get_section_size, - elfsh_set_section_size, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "link" , revm_create_L2ENT(elfsh_get_section_link, - elfsh_set_section_link, - 0, NULL, NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "info" , revm_create_L2ENT(elfsh_get_section_info, - elfsh_set_section_info, - 0, NULL, NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "align" , revm_create_L2ENT(elfsh_get_section_align, - elfsh_set_section_align, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "entsize" , revm_create_L2ENT(elfsh_get_section_entsize, - elfsh_set_section_entsize, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "a" , revm_create_L2ENT(elfsh_get_section_allocflag, - elfsh_set_section_allocflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "w" , revm_create_L2ENT(elfsh_get_section_writableflag, - elfsh_set_section_writableflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "x" , revm_create_L2ENT(elfsh_get_section_execflag, - elfsh_set_section_execflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "s" , revm_create_L2ENT(elfsh_get_section_strflag, - elfsh_set_section_strflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "m" , revm_create_L2ENT(elfsh_get_section_mergeableflag, - elfsh_set_section_mergeableflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "l" , revm_create_L2ENT(elfsh_get_section_linkflag, - elfsh_set_section_linkflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sht_L2_hash, "o" , revm_create_L2ENT(elfsh_get_section_orderflag, - elfsh_set_section_orderflag, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - -/** - * Hash table for PHT fields - */ -static void setup_phthash() -{ - hash_init(&pht_L2_hash, "phtL2objects", 29, ASPECT_TYPE_UNKNOW); - hash_add(&pht_L2_hash, "type" , revm_create_L2ENT(elfsh_get_segment_type, - elfsh_set_segment_type, - 0, NULL, NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "offset", revm_create_L2ENT(elfsh_get_segment_offset, - elfsh_set_segment_offset, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "vaddr" , revm_create_L2ENT(elfsh_get_segment_vaddr, - elfsh_set_segment_vaddr, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "paddr" , revm_create_L2ENT(elfsh_get_segment_paddr, - elfsh_set_segment_paddr, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "filesz", revm_create_L2ENT(elfsh_get_segment_filesz, - elfsh_set_segment_filesz, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "memsz" , revm_create_L2ENT(elfsh_get_segment_memsz, - elfsh_set_segment_memsz, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "flags" , revm_create_L2ENT(elfsh_get_segment_flags, - elfsh_set_segment_flags, - 0, NULL, NULL, NULL, NULL)); - hash_add(&pht_L2_hash, "align" , revm_create_L2ENT(elfsh_get_segment_align, - elfsh_set_segment_align, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - - -/** - * Hash table for symbol table - */ -static void setup_symhash() -{ - hash_init(&sym_L2_hash, "symL2objects", 23, ASPECT_TYPE_UNKNOW); - - hash_add(&sym_L2_hash, "name" , revm_create_L2ENT(NULL, NULL, ASPECT_TYPE_STR, - elfsh_get_symbol_name, - elfsh_set_symbol_name, - NULL, NULL)); - - hash_add(&sym_L2_hash, "value", revm_create_L2ENT(elfsh_get_symbol_value, - elfsh_set_symbol_value, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sym_L2_hash, "size" , revm_create_L2ENT(elfsh_get_symbol_size, - elfsh_set_symbol_size, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&sym_L2_hash, "bind" , revm_create_L2ENT(elfsh_get_symbol_bind, - elfsh_set_symbol_bind, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - hash_add(&sym_L2_hash, "type" , revm_create_L2ENT(elfsh_get_symbol_type, - elfsh_set_symbol_type, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - hash_add(&sym_L2_hash, "other", revm_create_L2ENT(elfsh_get_symbol_visibility, - elfsh_set_symbol_visibility, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - - hash_add(&sym_L2_hash, "link", revm_create_L2ENT(elfsh_get_symbol_link, - elfsh_set_symbol_link, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); -} - - - -/** - * Hash table for dynamic symbol table - */ -static void setup_dynsymhash() -{ - hash_init(&dynsym_L2_hash, "dynsymL2objects", 23, ASPECT_TYPE_UNKNOW); - hash_add(&dynsym_L2_hash, "name" , revm_create_L2ENT(NULL, NULL, ASPECT_TYPE_STR, - elfsh_get_dynsymbol_name, - elfsh_set_dynsymbol_name, - NULL, NULL)); - hash_add(&dynsym_L2_hash, "value", revm_create_L2ENT(elfsh_get_symbol_value, - elfsh_set_symbol_value, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&dynsym_L2_hash, "size" , revm_create_L2ENT(elfsh_get_symbol_size, - elfsh_set_symbol_size, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&dynsym_L2_hash, "bind" , revm_create_L2ENT(elfsh_get_symbol_bind, - elfsh_set_symbol_bind, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - hash_add(&dynsym_L2_hash, "type" , revm_create_L2ENT(elfsh_get_symbol_type, - elfsh_set_symbol_type, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - hash_add(&dynsym_L2_hash, "other", revm_create_L2ENT(elfsh_get_symbol_visibility, - elfsh_set_symbol_visibility, - ASPECT_TYPE_BYTE, NULL, - NULL, NULL, NULL)); - hash_add(&dynsym_L2_hash, "link", revm_create_L2ENT(elfsh_get_symbol_link, - elfsh_set_symbol_link, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); -} - -/** - * Hash table for .rel sections - */ -static void setup_relhash() -{ - hash_init(&rel_L2_hash, "relL2objects", 23, ASPECT_TYPE_UNKNOW); - hash_add(&rel_L2_hash, "type" , revm_create_L2ENT(elfsh_get_reltype, - elfsh_set_reltype, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&rel_L2_hash, "sym" , revm_create_L2ENT(elfsh_get_relsym, - elfsh_set_relsym, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&rel_L2_hash, "offset", revm_create_L2ENT(elfsh_get_reloffset, - elfsh_set_reloffset, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&rel_L2_hash, "addend", revm_create_L2ENT(elfsh_get_reladdend, - elfsh_set_reladdend, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - -/** - * Hash table for .dynamic section - */ -static void setup_dynhash() -{ - hash_init(&dyn_L2_hash, "dynL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&dyn_L2_hash, "val", revm_create_L2ENT(elfsh_get_dynentry_val, - elfsh_set_dynentry_val, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&dyn_L2_hash, "tag", revm_create_L2ENT(elfsh_get_dynentry_type, - elfsh_set_dynentry_type, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - - - -/** - * Hash tables for GOT L2 objects : UNIMPLEMENTED for now, only - * the value of the entry can be changed in this version of - * the ELF shell using the got[name|idx] format without L2 field. - */ -static void setup_gothash() -{ - - hash_init(&got_L2_hash, "gotL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&got_L2_hash, "val" , revm_create_L2ENT(elfsh_get_got_val, elfsh_set_got_val, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - //hash_add(&got_L2_hash, "idx" , revm_create_L2ENT()); - hash_add(&got_L2_hash, "addr", revm_create_L2ENT(elfsh_get_got_addr, elfsh_set_got_addr, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - - - -/** - * Hash tables for sections data - */ -static void setup_scthash() -{ - hash_init(&sct_L2_hash, "sectsL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&sct_L2_hash, "name", revm_create_L2ENT(NULL, NULL, ASPECT_TYPE_STR, - elfsh_get_section_name, - elfsh_set_section_name, - NULL, NULL)); - - hash_add(&sct_L2_hash, "raw", revm_create_L2ENT(NULL, NULL, - ASPECT_TYPE_RAW, - NULL, NULL, - elfsh_get_section_data, - elfsh_write_section_data)); -} - - - -/** - * Hash table for versions sections - */ -static void setup_vershash() -{ - - /* Version symbols */ - hash_init(&vers_L2_hash, "versionL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&vers_L2_hash, "value", revm_create_L2ENT(elfsh_get_versym_val, - elfsh_set_versym_val, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - - /* Version def */ - hash_init(&verd_L2_hash, "verdefsL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&verd_L2_hash, "index", revm_create_L2ENT(elfsh_get_verdef_ndx, - elfsh_set_verdef_ndx, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - hash_add(&verd_L2_hash, "count", revm_create_L2ENT(elfsh_get_verdef_cnt, - elfsh_set_verdef_cnt, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - hash_add(&verd_L2_hash, "hash", revm_create_L2ENT(elfsh_get_verdef_hash, - elfsh_set_verdef_hash, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&verd_L2_hash, "flag", revm_create_L2ENT(elfsh_get_verdef_flags, - elfsh_set_verdef_flags, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - hash_add(&verd_L2_hash, "aux", revm_create_L2ENT(elfsh_get_verdef_aux, - elfsh_set_verdef_aux, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - - - /* Child & parent */ - hash_add(&verd_L2_hash, "next", revm_create_L2ENT(elfsh_get_verdef_next, - elfsh_set_verdef_next, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - /* Child */ - hash_add(&verd_L2_hash, "name", revm_create_L2ENT(elfsh_get_verdef_cname, - elfsh_set_verdef_cname, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - - /* Version need */ - hash_init(&vern_L2_hash, "verneedL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&vern_L2_hash, "index", revm_create_L2ENT(elfsh_get_verneed_ndx, - elfsh_set_verneed_ndx, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - - hash_add(&vern_L2_hash, "name", revm_create_L2ENT(elfsh_get_verneed_name, - elfsh_set_verneed_name, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - - hash_add(&vern_L2_hash, "hash", revm_create_L2ENT(elfsh_get_verneed_hash, - elfsh_set_verneed_hash, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&vern_L2_hash, "flag", revm_create_L2ENT(elfsh_get_verneed_flags, - elfsh_set_verneed_flags, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - /* child && parent */ - hash_add(&vern_L2_hash, "next", revm_create_L2ENT(elfsh_get_verneed_next, - elfsh_set_verneed_next, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - /* parent */ - hash_add(&vern_L2_hash, "file", revm_create_L2ENT(elfsh_get_verneed_file, - elfsh_set_verneed_file, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); - hash_add(&vern_L2_hash, "count", revm_create_L2ENT(elfsh_get_verneed_cnt, - elfsh_set_verneed_cnt, - ASPECT_TYPE_SHORT, NULL, - NULL, NULL, NULL)); - hash_add(&vern_L2_hash, "aux", revm_create_L2ENT(elfsh_get_verneed_aux, - elfsh_set_verneed_aux, - ASPECT_TYPE_LONG, NULL, - NULL, NULL, NULL)); -} - - -/** - * TO COMMENT - */ -static void setup_hashhash() -{ - - /* Hash bucket */ - hash_init(&hashb_L2_hash, "hashbucketsL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&hashb_L2_hash, "value", revm_create_L2ENT(elfsh_get_hashbucket_value, - elfsh_set_hashbucket_value, - ASPECT_TYPE_INT, NULL, - NULL, NULL, NULL)); - hash_add(&hashb_L2_hash, "nbucket", revm_create_L2ENT(elfsh_get_hashbucket_num, - elfsh_set_hashbucket_num, - ASPECT_TYPE_INT, NULL, - NULL, NULL, NULL)); - /* Hash chain */ - hash_init(&hashc_L2_hash, "hashchainL2objects", 11, ASPECT_TYPE_UNKNOW); - hash_add(&hashc_L2_hash, "value", revm_create_L2ENT(elfsh_get_hashchain_value, - elfsh_set_hashchain_value, - ASPECT_TYPE_INT, NULL, - NULL, NULL, NULL)); - hash_add(&hashc_L2_hash, "nchain", revm_create_L2ENT(elfsh_get_hashchain_num, - elfsh_set_hashchain_num, - ASPECT_TYPE_INT, NULL, - NULL, NULL, NULL)); -} - - - - -/** - * Now comes Level 2 objects hash functions - */ -static void setup_L2hash() -{ - setup_elfhash(); - setup_shthash(); - setup_phthash(); - setup_symhash(); - setup_relhash(); - setup_dynsymhash(); - setup_dynhash(); - setup_scthash(); - setup_gothash(); - setup_vershash(); - setup_hashhash(); -} - - -/** - * Mix default library path with LD_LIBRARY_PATH variable - */ -static char *get_libpath() -{ - int len; - char *ldenv; - - /* Set default value */ - strncpy(elfsh_libpath, ELFSH_LIBPATH, BUFSIZ); - elfsh_libpath[BUFSIZ - 1] = '\0'; - - len = strlen(elfsh_libpath); - - ldenv = getenv("LD_LIBRARY_PATH"); - - /* Check if we use LD_LIBRARY_PATH */ - if (ldenv != NULL && len+strlen(ldenv)+2 < BUFSIZ) - { - /* We separate each path with ; */ - if (ldenv[0] != ';' && elfsh_libpath[len - 1] != ';') - strcat(elfsh_libpath, ";"); - else if (ldenv[0] == ';' && elfsh_libpath[len - 1] == ';') - ldenv++; - - strcat(elfsh_libpath, ldenv); - } - - return elfsh_libpath; -} - - -/** - * Setup variables hash : - * - Initialize $_ (last result variable) to 0 - * - Initialize $! (last openered file) to 0 - */ -static void setup_varshash() -{ - revmobj_t *f; - revmexpr_t *expr; - char *str; - - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_RESULT); - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_LOAD); - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0xFFFFFFFF); - expr = revm_expr_create_from_object(f, REVM_VAR_ERROR); - f = revm_create_IMMEDSTR(1, ELFSH_SHELL); - expr = revm_expr_create_from_object(f, REVM_VAR_SHELL); - f = revm_create_IMMEDSTR(1, ELFSH_EDITOR); - expr = revm_expr_create_from_object(f, REVM_VAR_EDITOR); - str = get_libpath(); - f = revm_create_IMMEDSTR(1, str); - expr = revm_expr_create_from_object(f, REVM_VAR_LIBPATH); - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, ELFSH_SLOG); - expr = revm_expr_create_from_object(f, REVM_VAR_STRIPLOG); - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_ESHLEVEL); -} - - -/** - * Setup ELF constants hash tables - */ -static void setup_consthash() -{ - u_int index; - - hash_init(&const_hash, "constants", 51, ASPECT_TYPE_STR); - - for (index = 0; index < ELFSH_SEGTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_seg_type[index].name, - elfsh_seg_type + index); - - for (index = 0; index < ELFSH_EXTSEG_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_extseg_type[index].name, - elfsh_extseg_type + index); - - for (index = 0; index < ELFSH_ENCODING_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_encoding[index].name, - elfsh_encoding + index); - for (index = 0; index < ELFSH_SHTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sh_type[index].name, - elfsh_sh_type + index); - for (index = 0; index < ELFSH_OBJTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_obj_type[index].name, - elfsh_obj_type + index); - for (index = 0; index < ELFSH_SYMBIND_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sym_bind[index].name, - elfsh_sym_bind + index); - for (index = 0; index < ELFSH_SYMTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sym_type[index].name, - elfsh_sym_type + index); - for (index = 0; index < ELFSH_RELOC_i386_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_i386[index].name, - elfsh_rel_type_i386 + index); - - for (index = 0; index < ELFSH_RELOC_SPARC64_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_sparc[index].name, - elfsh_rel_type_sparc + index); - - for (index = 0; index < ELFSH_RELOC_IA64_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_ia64[index].name, - elfsh_rel_type_ia64 + index); - - for (index = 0; index < ELFSH_RELOC_ALPHA_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_alpha[index].name, - elfsh_rel_type_alpha + index); - - for (index = 0; index < ELFSH_RELOC_MIPS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_mips[index].name, - elfsh_rel_type_mips + index); - - - for (index = 0; index < ELFSH_DYNAMIC_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_dynentry_type[index].name, - elfsh_dynentry_type + index); - for (index = 0; index < ELFSH_EXTDYN_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_extdyn_type[index].name, - elfsh_extdyn_type + index); - for (index = 0; index < ELFSH_MIPSDYN_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_mipsdyn_type[index].name, - elfsh_mipsdyn_type + index); - for (index = 0; index < ELFSH_FEATURE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_feature1[index].name, - elfsh_feature1 + index); - for (index = 0; index < ELFSH_POSFLAG_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_posflag1[index].name, - elfsh_posflag1 + index); - for (index = 0; index < ELFSH_FLAGS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_flags[index].name, - elfsh_flags + index); - for (index = 0; index < ELFSH_FLAGS1_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_flags1[index].name, - elfsh_flags1 + index); - for (index = 0; index < ELFSH_MIPSFLAGS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_mipsflags[index].name, - elfsh_mipsflags + index); - - for (index = 0; index < ELFSH_INSTRTYPE_MAX; index++) - hash_add(&const_hash, - (char *) asm_instr_type[index].name, - asm_instr_type + index); - - for (index = 0; index < ELFSH_OPTYPE_MAX; index++) - hash_add(&const_hash, - (char *) asm_operand_type[index].name, - asm_operand_type + index); -} - - -/** - * Setup default grammar - * XXX: This function is temporary and we not remain in the new type system - */ -void setup_grammar() -{ - - /* Default grammar rules */ -#define LOOKUP5_IDX "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^]]][%41[^]]]"REVM_SEP"%41s" -#define LOOKUP4_A "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^:]:%41[^%%]%%%41[^]]]"REVM_SEP"%41s" -#define LOOKUP4_B "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^:]:%41[^]]]"REVM_SEP"%41s" -#define LOOKUP4_C "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^]]]"REVM_SEP"%41s" -#define LOOKUP3_IDX "%41[^"REVM_SEP"]"REVM_SEP"%41[^[][%41[^]]]" -#define LOOKUP3 "%41[^"REVM_SEP"]"REVM_SEP"%41[^"REVM_SEP"]"REVM_SEP"%41s" -#define LOOKUP_VECT "$vector[%41[^]]]" -#define LOOKUP_HASH "$hash[%41[^]]]" - //#define LOOKUP_HASH1 "$hash[%41[^]]]"REVM_SEP"%41s" -#define LOOKUP_LIST "$list[%41[^]]]" - - hash_add(&parser_hash, LOOKUP5_IDX, parse_lookup5_index); - hash_add(&parser_hash, LOOKUP4_A, parse_lookup4); - hash_add(&parser_hash, LOOKUP4_B, parse_lookup4); - hash_add(&parser_hash, LOOKUP4_C, parse_lookup4); - hash_add(&parser_hash, LOOKUP3_IDX, parse_lookup3_index); - hash_add(&parser_hash, LOOKUP3, parse_lookup3); - hash_add(&parser_hash, LOOKUP_VECT, parse_vector); - hash_add(&parser_hash, LOOKUP_HASH, parse_hash); - //hash_add(&parser_hash, LOOKUP_HASH1, parse_hash_field); - hash_add(&parser_hash, LOOKUP_LIST, parse_list); -} - - - -/** - * Setup color table - */ -void setup_color() -{ - hash_add(&fg_color_hash, "none" , (void *) COLOR_RESET); - hash_add(&fg_color_hash, "black" , (void *) COLOR_FG_BLACK); - hash_add(&fg_color_hash, "red" , (void *) COLOR_FG_RED); - hash_add(&fg_color_hash, "green" , (void *) COLOR_FG_GREEN); - hash_add(&fg_color_hash, "yellow" , (void *) COLOR_FG_YELLOW); - hash_add(&fg_color_hash, "blue" , (void *) COLOR_FG_BLUE); - hash_add(&fg_color_hash, "magenta", (void *) COLOR_FG_MAGENTA); - hash_add(&fg_color_hash, "cyan" , (void *) COLOR_FG_CYAN); - hash_add(&fg_color_hash, "white" , (void *) COLOR_FG_WHITE); - - hash_add(&bg_color_hash, "none" , (void *) COLOR_RESET); - hash_add(&bg_color_hash, "black" , (void *) COLOR_BG_BLACK); - hash_add(&bg_color_hash, "red" , (void *) COLOR_BG_RED); - hash_add(&bg_color_hash, "green" , (void *) COLOR_BG_GREEN); - hash_add(&bg_color_hash, "yellow" , (void *) COLOR_BG_YELLOW); - hash_add(&bg_color_hash, "blue" , (void *) COLOR_BG_BLUE); - hash_add(&bg_color_hash, "magenta", (void *) COLOR_BG_MAGENTA); - hash_add(&bg_color_hash, "cyan" , (void *) COLOR_BG_CYAN); - hash_add(&bg_color_hash, "white" , (void *) COLOR_BG_WHITE); -} - - -/** - * TOCOMMENT - */ -void setup_color_type() -{ - hash_add(&t_color_hash, "string" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "fieldstring", (void *) revm_colorblank()); - hash_add(&t_color_hash, "typestring" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "address" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "number" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "endstring" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "warnstring" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "pspecial" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "psname" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "pversion" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "prelease" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "pedition" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "instr" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "function" , (void *) revm_colorblank()); - hash_add(&t_color_hash, "filename" , (void *) revm_colorblank()); -} - - -/** - * Setup all used sub functions - */ -void setup_traces_table() -{ - traces_addcmd("add" , (void *) traces_add , 2, 1); - traces_addcmd("rm" , (void *) traces_rm , 2, 1); - traces_addcmd("exclude" , (void *) traces_exclude , 2, 1); - traces_addcmd("rmexclude", (void *) traces_rmexclude, 2, 1); - traces_addcmd("enable" , (void *) traces_enable , 2, 1); - traces_addcmd("disable" , (void *) traces_disable , 2, 1); - traces_addcmd("create" , (void *) traces_create , 2, 1); - traces_addcmd("delete" , (void *) traces_delete , 2, 0); - traces_addcmd("flush" , (void *) traces_flush , 2, 0); -} - - -/** - * Setup all hash tables - */ -void revm_tables_setup() -{ - static int done = 0; - - if (done) - return; - done = 1; - - hash_init(&file_hash , "files" , 251, ASPECT_TYPE_UNKNOW); - hash_init(&mod_hash , "modules" , 51, ASPECT_TYPE_UNKNOW); - hash_init(&labels_hash[0] , "labels" , 51, ASPECT_TYPE_UNKNOW); - hash_init(&fg_color_hash , "fgcolors" , 13, ASPECT_TYPE_UNKNOW); - hash_init(&bg_color_hash , "bgcolors" , 13, ASPECT_TYPE_UNKNOW); - hash_init(&t_color_hash , "tcolors" , 11, ASPECT_TYPE_UNKNOW); - hash_init(&traces_cmd_hash , "traces" , 11, ASPECT_TYPE_UNKNOW); - hash_init(&world.shared_hash, "sharedfiles", 11, ASPECT_TYPE_UNKNOW); - hash_init(&exprs_hash , "expressions", 51, ASPECT_TYPE_EXPR); - hash_init(&instrlists_hash , "instrlists" , 51, ASPECT_TYPE_LIST); - hash_init(&parser_hash , "parsers" , 11, ASPECT_TYPE_CADDR); - elist_init(&frames_list , "frames" , ASPECT_TYPE_LIST); - - if (world.cmd_init) - (*world.cmd_init)(); - else - fprintf(stderr, "world.cmd_init = NULL !!!! \n"); - - setup_varshash(); - setup_consthash(); - setup_L1hash(); - setup_L2hash(); - setup_color(); - setup_color_type(); - setup_traces_table(); - setup_grammar(); - aspect_init(); -} - - - -// XXX: frames list in source.c should not store element by -// function name -> will generate collisions for recursive functions -// -> use "world.curjob->sourced" value diff -Nru eresi-0.8a25/librevm/vm/tables.c eresi-0.0.20110516/librevm/vm/tables.c --- eresi-0.8a25/librevm/vm/tables.c 2008-04-06 23:15:45.000000000 +0000 +++ eresi-0.0.20110516/librevm/vm/tables.c 2011-05-16 11:34:11.000000000 +0000 @@ -1,33 +1,17 @@ /** - * @defgroup librevm_vm librevm VM - */ -/* -** @file tables.c -** @ingroup librevm_vm +** @defgroup vm Librevm engine. +** @ingroup librevm +*/ +/** +* @file librevm/vm/tables.c +** @ingroup vm ** @brief This file contains all command and objects definitions for scripting. ** ** Started on Sat Jan 25 07:48:41 2003 jfv -** -** $Id: tables.c,v 1.54 2008-02-16 12:32:27 thor Exp $ -** +** $Id: tables.c 1397 2009-09-13 02:19:08Z may $ */ #include "revm.h" -/* Labels hash */ -hash_t labels_hash[REVM_MAXSRCNEST]; - -/* ERESI script machine frames list */ -list_t frames_list; - -/* Eresi expressions hash and expressions type hash */ -hash_t exprs_hash; - -/* The command hash table : hash the command name and returns a revmcmd_t */ -hash_t cmd_hash; - -/* The constants hash tables : ascii defines from elf.h and revm.h */ -hash_t const_hash; - /* The ELF shell module hash tables: returns a revmmod_t */ hash_t mod_hash; @@ -61,15 +45,16 @@ /* Grammar parser hash */ hash_t parser_hash; -/* Trace hash */ -hash_t traces_cmd_hash; - /* Lib path store variable */ char elfsh_libpath[BUFSIZ]; /* Hash of instruction lists */ hash_t instrlists_hash; +/* Hashes for dataflow IN and OUT */ +hash_t inputdf; +hash_t outputdf; + /** * Fill all the Level 1 Objects hash tables @@ -350,7 +335,7 @@ hash_init(&sht_L2_hash, "shtL2objects", 29, ASPECT_TYPE_UNKNOW); hash_add(&sht_L2_hash, "type" , revm_create_L2ENT(elfsh_get_section_type, elfsh_set_section_type, - 0, NULL, NULL, NULL, NULL)); + ASPECT_TYPE_SHORT, NULL, NULL, NULL, NULL)); hash_add(&sht_L2_hash, "addr" , revm_create_L2ENT(elfsh_get_section_addr, elfsh_set_section_addr, ASPECT_TYPE_LONG, NULL, @@ -365,10 +350,10 @@ NULL, NULL, NULL)); hash_add(&sht_L2_hash, "link" , revm_create_L2ENT(elfsh_get_section_link, elfsh_set_section_link, - 0, NULL, NULL, NULL, NULL)); + ASPECT_TYPE_SHORT, NULL, NULL, NULL, NULL)); hash_add(&sht_L2_hash, "info" , revm_create_L2ENT(elfsh_get_section_info, elfsh_set_section_info, - 0, NULL, NULL, NULL, NULL)); + ASPECT_TYPE_SHORT, NULL, NULL, NULL, NULL)); hash_add(&sht_L2_hash, "align" , revm_create_L2ENT(elfsh_get_section_align, elfsh_set_section_align, ASPECT_TYPE_LONG, NULL, @@ -415,7 +400,7 @@ hash_init(&pht_L2_hash, "phtL2objects", 29, ASPECT_TYPE_UNKNOW); hash_add(&pht_L2_hash, "type" , revm_create_L2ENT(elfsh_get_segment_type, elfsh_set_segment_type, - 0, NULL, NULL, NULL, NULL)); + ASPECT_TYPE_SHORT, NULL, NULL, NULL, NULL)); hash_add(&pht_L2_hash, "offset", revm_create_L2ENT(elfsh_get_segment_offset, elfsh_set_segment_offset, ASPECT_TYPE_LONG, NULL, @@ -438,7 +423,7 @@ NULL, NULL, NULL)); hash_add(&pht_L2_hash, "flags" , revm_create_L2ENT(elfsh_get_segment_flags, elfsh_set_segment_flags, - 0, NULL, NULL, NULL, NULL)); + ASPECT_TYPE_SHORT, NULL, NULL, NULL, NULL)); hash_add(&pht_L2_hash, "align" , revm_create_L2ENT(elfsh_get_segment_align, elfsh_set_segment_align, ASPECT_TYPE_LONG, NULL, @@ -753,7 +738,7 @@ char *ldenv; /* Set default value */ - strncpy(elfsh_libpath, ELFSH_LIBPATH, BUFSIZ); + strncpy(elfsh_libpath, ERESI_LIBPATH, BUFSIZ); elfsh_libpath[BUFSIZ - 1] = '\0'; len = strlen(elfsh_libpath); @@ -788,132 +773,22 @@ char *str; f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_RESULT); + expr = revm_expr_create_from_object(f, REVM_VAR_RESULT, 1); f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_LOAD); + expr = revm_expr_create_from_object(f, REVM_VAR_LOAD, 1); f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0xFFFFFFFF); - expr = revm_expr_create_from_object(f, REVM_VAR_ERROR); - f = revm_create_IMMEDSTR(1, ELFSH_SHELL); - expr = revm_expr_create_from_object(f, REVM_VAR_SHELL); - f = revm_create_IMMEDSTR(1, ELFSH_EDITOR); - expr = revm_expr_create_from_object(f, REVM_VAR_EDITOR); + expr = revm_expr_create_from_object(f, REVM_VAR_ERROR, 1); + f = revm_create_IMMEDSTR(1, ERESI_EXTSHELL); + expr = revm_expr_create_from_object(f, REVM_VAR_SHELL, 1); + f = revm_create_IMMEDSTR(1, ERESI_EDITOR); + expr = revm_expr_create_from_object(f, REVM_VAR_EDITOR, 1); str = get_libpath(); f = revm_create_IMMEDSTR(1, str); - expr = revm_expr_create_from_object(f, REVM_VAR_LIBPATH); - f = revm_create_IMMED(ASPECT_TYPE_INT, 1, ELFSH_SLOG); - expr = revm_expr_create_from_object(f, REVM_VAR_STRIPLOG); + expr = revm_expr_create_from_object(f, REVM_VAR_LIBPATH, 1); + f = revm_create_IMMED(ASPECT_TYPE_INT, 1, ERESI_SLOG); + expr = revm_expr_create_from_object(f, REVM_VAR_STRIPLOG, 1); f = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); - expr = revm_expr_create_from_object(f, REVM_VAR_ESHLEVEL); -} - - -/** - * Setup ELF constants hash tables - */ -static void setup_consthash() -{ - u_int index; - - hash_init(&const_hash, "constants", 51, ASPECT_TYPE_STR); - - for (index = 0; index < ELFSH_SEGTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_seg_type[index].name, - elfsh_seg_type + index); - - for (index = 0; index < ELFSH_EXTSEG_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_extseg_type[index].name, - elfsh_extseg_type + index); - - for (index = 0; index < ELFSH_ENCODING_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_encoding[index].name, - elfsh_encoding + index); - for (index = 0; index < ELFSH_SHTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sh_type[index].name, - elfsh_sh_type + index); - for (index = 0; index < ELFSH_OBJTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_obj_type[index].name, - elfsh_obj_type + index); - for (index = 0; index < ELFSH_SYMBIND_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sym_bind[index].name, - elfsh_sym_bind + index); - for (index = 0; index < ELFSH_SYMTYPE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_sym_type[index].name, - elfsh_sym_type + index); - for (index = 0; index < ELFSH_RELOC_i386_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_i386[index].name, - elfsh_rel_type_i386 + index); - - for (index = 0; index < ELFSH_RELOC_SPARC64_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_sparc[index].name, - elfsh_rel_type_sparc + index); - - for (index = 0; index < ELFSH_RELOC_IA64_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_ia64[index].name, - elfsh_rel_type_ia64 + index); - - for (index = 0; index < ELFSH_RELOC_ALPHA_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_alpha[index].name, - elfsh_rel_type_alpha + index); - - for (index = 0; index < ELFSH_RELOC_MIPS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_rel_type_mips[index].name, - elfsh_rel_type_mips + index); - - - for (index = 0; index < ELFSH_DYNAMIC_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_dynentry_type[index].name, - elfsh_dynentry_type + index); - for (index = 0; index < ELFSH_EXTDYN_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_extdyn_type[index].name, - elfsh_extdyn_type + index); - for (index = 0; index < ELFSH_MIPSDYN_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_mipsdyn_type[index].name, - elfsh_mipsdyn_type + index); - for (index = 0; index < ELFSH_FEATURE_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_feature1[index].name, - elfsh_feature1 + index); - for (index = 0; index < ELFSH_POSFLAG_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_posflag1[index].name, - elfsh_posflag1 + index); - for (index = 0; index < ELFSH_FLAGS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_flags[index].name, - elfsh_flags + index); - for (index = 0; index < ELFSH_FLAGS1_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_flags1[index].name, - elfsh_flags1 + index); - for (index = 0; index < ELFSH_MIPSFLAGS_MAX; index++) - hash_add(&const_hash, - (char *) elfsh_mipsflags[index].name, - elfsh_mipsflags + index); - - for (index = 0; index < ELFSH_INSTRTYPE_MAX; index++) - hash_add(&const_hash, - (char *) asm_instr_type[index].name, - asm_instr_type + index); - - for (index = 0; index < ELFSH_OPTYPE_MAX; index++) - hash_add(&const_hash, - (char *) asm_operand_type[index].name, - asm_operand_type + index); + expr = revm_expr_create_from_object(f, REVM_VAR_ESHLEVEL, 1); } @@ -1000,21 +875,6 @@ } -/** - * Setup all used sub functions - */ -void setup_traces_table() -{ - traces_addcmd("add" , (void *) traces_add , 2, 1); - traces_addcmd("rm" , (void *) traces_rm , 2, 1); - traces_addcmd("exclude" , (void *) traces_exclude , 2, 1); - traces_addcmd("rmexclude", (void *) traces_rmexclude, 2, 1); - traces_addcmd("enable" , (void *) traces_enable , 2, 1); - traces_addcmd("disable" , (void *) traces_disable , 2, 1); - traces_addcmd("create" , (void *) traces_create , 2, 1); - traces_addcmd("delete" , (void *) traces_delete , 2, 0); - traces_addcmd("flush" , (void *) traces_flush , 2, 0); -} /** @@ -1030,35 +890,25 @@ hash_init(&file_hash , "files" , 251, ASPECT_TYPE_UNKNOW); hash_init(&mod_hash , "modules" , 51, ASPECT_TYPE_UNKNOW); - hash_init(&labels_hash[0] , "labels" , 51, ASPECT_TYPE_UNKNOW); hash_init(&fg_color_hash , "fgcolors" , 13, ASPECT_TYPE_UNKNOW); hash_init(&bg_color_hash , "bgcolors" , 13, ASPECT_TYPE_UNKNOW); hash_init(&t_color_hash , "tcolors" , 11, ASPECT_TYPE_UNKNOW); - hash_init(&traces_cmd_hash , "traces" , 11, ASPECT_TYPE_UNKNOW); hash_init(&world.shared_hash, "sharedfiles", 11, ASPECT_TYPE_UNKNOW); - hash_init(&exprs_hash , "expressions", 51, ASPECT_TYPE_EXPR); hash_init(&instrlists_hash , "instrlists" , 51, ASPECT_TYPE_LIST); + hash_init(&inputdf , "idflists" , 51, ASPECT_TYPE_LIST); + hash_init(&outputdf , "odflists" , 51, ASPECT_TYPE_LIST); hash_init(&parser_hash , "parsers" , 11, ASPECT_TYPE_CADDR); - elist_init(&frames_list , "frames" , ASPECT_TYPE_LIST); - + if (world.cmd_init) (*world.cmd_init)(); else fprintf(stderr, "world.cmd_init = NULL !!!! \n"); setup_varshash(); - setup_consthash(); setup_L1hash(); setup_L2hash(); setup_color(); setup_color_type(); - setup_traces_table(); setup_grammar(); aspect_init(); } - - - -// XXX: frames list in source.c should not store element by -// function name -> will generate collisions for recursive functions -// -> use "world.curjob->sourced" value diff -Nru eresi-0.8a25/libstderesi/analysis/argcount.c eresi-0.0.20110516/libstderesi/analysis/argcount.c --- eresi-0.8a25/libstderesi/analysis/argcount.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/argcount.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,63 @@ +/** +* @file libstderesi/analysis/argcount.c +* @ingroup analysis +* @brief Command argcount (count arguments in a function) +* +* Started Jul 2 2005 00:03:44 mxatone +* $Id: trace.c 1397 2009-09-13 02:19:08Z may $ +* +*/ +#include "libstderesi.h" + + +int cmd_argcount() +{ + elfsh_Sym *sym; + eresi_Addr addr; + int idx; + int *args; + char *name; + int off; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Resolve parameter */ + sym = elfsh_get_metasym_by_name(world.curjob->curfile, + world.curjob->curcmd->param[0]); + if (sym) + { + addr = sym->st_value; + name = world.curjob->curcmd->param[0]; + } + else + { + addr = revm_lookup_addr(world.curjob->curcmd->param[0]); + if (addr == 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid function/address request", -1); + name = elfsh_reverse_metasym(world.curjob->curfile, addr, &off); + if (!name) + name = "func-unresolved"; + } + + /* Call feature vector */ + args = elfsh_args_count(world.curjob->curfile, 0, addr); + if (args == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to count arguments", -1); + snprintf(buf, sizeof(buf), " [*] Argument counting on function <%s> ("XFMT")\n", + name, addr); + + /* Offset 8 is always first argument, at least on x86 */ + off = 8; + for (idx = 0; args[idx]; idx++) + { + snprintf(buf, sizeof(buf), " VAR %u - stack offset %d - size %u bytes \n", idx, off, args[idx]); + off += args[idx]; + revm_output(buf); + } + revm_output("\n"); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/debug.c eresi-0.0.20110516/libstderesi/analysis/debug.c --- eresi-0.8a25/libstderesi/analysis/debug.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/debug.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,322 @@ +/* +* @file libstderesi/analysis/debug.c +** @ingroup analysis +** @brief All functions dealing with libedfmt uni debugging format +** +** Started on Fev 25 2007 mxatone +** +** $Id: debug.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + +char buf[BUFSIZ]; +char tmpbuf[BUFSIZ]; +char filebuf[BUFSIZ]; + +char *file_title = NULL; +char *type_title = NULL; +char *var_title = NULL; + +int matched; + +/** + * @todo Complete doxygen tag + * @param type + * @return + */ +static char *revm_debug_typename(u_int type) +{ + char *str; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch(type) + { + case EDFMT_TYPE_UNK: + str = "?"; + break; + case EDFMT_TYPE_BASIC: + str = "basic"; + break; + case EDFMT_TYPE_ARRAY: + str = "array"; + break; + case EDFMT_TYPE_PTR: + str = "ptr"; + break; + case EDFMT_TYPE_STRUCT: + str = "struct"; + break; + case EDFMT_TYPE_UNION: + str = "union"; + break; + case EDFMT_TYPE_ATTR: + str = "attr"; + break; + case EDFMT_TYPE_VOID: + str = "void"; + break; + case EDFMT_TYPE_LINK: + str = "link"; + break; + default: + str = "?????"; + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, str); +} + +/** + * @todo Complete doxygen tags + * @param vars + * @param rx + * @return + */ +static int revm_debug_print_var(edfmtvar_t *vars, regex_t *rx) +{ + edfmtvar_t *var; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (var = vars; var != NULL; var = var->next) + { + snprintf(buf, BUFSIZ - 1, " %s%s %s%s %s%s => %s\n", + revm_colorfieldstr("scope:"), + revm_colornumber("%u", var->scope), + revm_colorfieldstr("name:"), + revm_colorstr_fmt("%-20s", var->name), + revm_colorfieldstr("addr:"), + revm_coloraddress(XFMT, var->addr), + revm_colorstr(var->type->name)); + revm_endline(); + + if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) + { + /* Print file title only once */ + if (file_title) + { + revm_output(file_title); + file_title = NULL; + } + + /* Print var title only once */ + if (var_title) + { + revm_output(var_title); + var_title = NULL; + } + + revm_output(buf); + matched++; + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * @todo Complete doxygen tags + * @param types + * @param tab + * @param rx + * @return + */ + +static int revm_debug_print_type(edfmttype_t *types, u_int tab, regex_t *rx) +{ + edfmttype_t *type; + u_int index; + u_int added = 0; + u_int bufsiz = 0; + int len; + int save_matched; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (type = types; type != NULL; type = type->next) + { + buf[0] = tmpbuf[0] = 0x00; + + len = snprintf(tmpbuf, BUFSIZ - 1, + " %s%s %s%s %s%s %s%s %s%s %s%s ", + revm_colorfieldstr("type:"), + revm_colortypestr_fmt("%-10s", revm_debug_typename(type->type)), + revm_colorfieldstr("name:"), + revm_colorstr_fmt("%-20s", type->name), + revm_colorfieldstr("offset:"), + revm_colornumber("%04u", type->start), + revm_colorfieldstr("size:"), + revm_colornumber("%04u", type->size), + revm_colorfieldstr("parsed:"), + revm_colortypestr_fmt("%-4s", type->parsed ? "yes" : "no"), + revm_colorfieldstr("valid:"), + revm_colortypestr_fmt("%-4s", type->valid ? "yes" : "no")); + revm_endline(); + + if (bufsiz + len < BUFSIZ) + { + strcat(buf, tmpbuf); + bufsiz += len; + } + + if (type->type != EDFMT_TYPE_ATTR && type->parent) + { + snprintf(tmpbuf, BUFSIZ - 1, + "%s%s ", + revm_colorfieldstr("parent:"), + revm_colorstr_fmt("%-10s", type->parent->name)); + revm_endline(); + + if (bufsiz + len < BUFSIZ) + { + strcat(buf, tmpbuf); + bufsiz += len; + } + } + + if (type->type == EDFMT_TYPE_ATTR && type->child) + { + snprintf(tmpbuf, BUFSIZ - 1, + "%s%s ", + revm_colorfieldstr("child:"), + revm_colorstr_fmt("%-10s", type->child->name)); + revm_endline(); + + if (bufsiz + len < BUFSIZ) + { + strcat(buf, tmpbuf); + bufsiz += len; + } + } + + /* Print only if it match a submited regex */ + if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) + { + /* Print file title only once */ + if (file_title) + { + revm_output(file_title); + file_title = NULL; + } + + /* Print type title only once */ + if (type_title) + { + revm_output(type_title); + type_title = NULL; + } + + if (tab > 0 && added == 0) + { + revm_output(" .: Childs\n"); + } + else if (added > 0 && type->type != EDFMT_TYPE_ATTR && type->child) + revm_output("\n"); + + added = 1; + + for (index = 0; index < tab; index++) + revm_output(" "); + + revm_output(buf); + revm_output("\n"); + matched++; + + /* We will print childs without match anything */ + save_matched = matched; + + /* Print childs if we got some (without regex) */ + if (type->type != EDFMT_TYPE_ATTR && type->child) + revm_debug_print_type(type->child, tab+1, NULL); + + matched = save_matched; + } + else + { + /* Print childs if we got some (with regex) */ + if (type->type != EDFMT_TYPE_ATTR && type->child) + revm_debug_print_type(type->child, tab+1, rx); + } + } + + if (added) + revm_output("\n"); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +static int revm_debug_unit_print_file(edfmtfile_t *files, regex_t *rx) +{ + edfmtfile_t *file; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (file = files; file != NULL; file = file->next) + { + snprintf(filebuf, BUFSIZ - 1, + "\n <: %s %s %s %s\n", + revm_colorfieldstr("File:"), + revm_colorstr_fmt("%-20s", file->name), + file->parent ? revm_colorfieldstr("Parent:") : "", + file->parent ? revm_colorstr(file->parent->name) : ""); + file_title = filebuf; + revm_endline(); + + type_title = "\n .: Types :. \n\n"; + var_title = "\n .: Vars :. \n\n"; + + revm_debug_print_type(file->types, 0, rx); + revm_debug_print_var(file->vars, rx); + + if (file->child) + revm_debug_unit_print_file(file->child, rx); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +int cmd_debug() +{ + char *regexname = NULL; + regex_t rx, *submit_rx = NULL; + edfmtinfo_t *info; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (world.curjob->curcmd->argc > 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Too many arguments for debug command", -1); + + matched = 0; + + /* Support filter by regex */ + if (world.curjob->curcmd->param[0]) + { + regexname = world.curjob->curcmd->param[0]; + + if (regcomp(&rx, regexname, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + + submit_rx = ℞ + } + + info = edfmt_get_uniinfo(world.curjob->curfile); + + if (!info) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No informations on this file", -1); + + type_title = "\n .: Global Types :. \n\n"; + var_title = "\n .: Global Vars :. \n\n"; + + revm_debug_print_type(info->types, 0, submit_rx); + revm_debug_print_var(info->vars, submit_rx); + + revm_debug_unit_print_file(info->files, submit_rx); + + snprintf(buf, BUFSIZ - 1, " [*] Matched %u entries \n\n", matched); + revm_output(buf); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/fcthijack.c eresi-0.0.20110516/libstderesi/analysis/fcthijack.c --- eresi-0.8a25/libstderesi/analysis/fcthijack.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/fcthijack.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,166 @@ +/* +* @file libstderesi/analysis/fcthijack.c +** @ingroup analysis +** Started on Thu Jun 19 17:02:55 2003 jfv +** +** $Id: fcthijack.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + + + +/* Redirect a function on a OS independant manner */ +int cmd_hijack() +{ + elfsh_Sym *dst; + eresi_Addr addr; + int err; + char *rev; + char logbuf[BUFSIZ]; + + elfshredir_t *redir; + listent_t *actual; + int idx; + int idx2; + int printed; + eresi_Addr hookedaddr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* If no parameter is given, print the redirection list */ + if (!world.curjob->curcmd->param[0]) + { + printed = 0; + + /* Simple printing */ + for (idx2 = idx = 0; idx < world.curjob->curfile->redir_hash.size; idx++) + for (actual = world.curjob->curfile->redir_hash.ent + idx; + actual != NULL && actual->key != NULL; + actual = actual->next) + { + redir = (elfshredir_t *) actual->data; + + if (!printed) + { + revm_output("\t .::. ELFsh redirection list \n\n"); + printed = 1; + } + snprintf(logbuf, BUFSIZ, + "\t [%02u] TYPE:%-6s [" AFMT "] <%s> redirected on [" AFMT "] <%s> \n", + idx2, (redir->type == ELFSH_REDIR_CFLOW ? "CFLOW" : + redir->type == ELFSH_REDIR_ALTPLT ? "ALTPLT" : + redir->type == ELFSH_REDIR_ALTGOT ? "ALTGOT" : "UNK"), + redir->addr[0], redir->name[0], redir->addr[1], redir->name[1]); + + revm_output(logbuf); + idx2++; + } + + /* End message */ + if (!printed) + revm_output("\t .::. No redirection performed on current file \n\n"); + else + revm_output("\n\n"); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Some sanity checks first */ + if (!world.curjob->curcmd->param[1]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Redirection destination needed", (-1)); + + /* Resolve destination parameter */ + dst = elfsh_get_metasym_by_name(world.curjob->curfile, + world.curjob->curcmd->param[1]); + if (!dst && elfsh_is_runtime_mode()) + { + elfsh_toggle_mode(); + dst = elfsh_get_metasym_by_name(world.curjob->curfile, + world.curjob->curcmd->param[1]); + elfsh_toggle_mode(); + } + + /* If not found */ + if (dst == NULL) + { + err = sscanf(world.curjob->curcmd->param[1], XFMT, + (eresi_Addr *) &addr); + + /* If the hook function is not supplied as an address */ + if (err != 1 && elfsh_dynamic_file(world.curjob->curfile)) + { + elfsh_setup_hooks(); + + /* First bootstrap ALTPLT if not done */ + err = elfsh_copy_plt(world.curjob->curfile, + elfsh_get_pagesize(world.curjob->curfile)); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed at copying PLT", (-1)); + + /* Request a PLT entry since we have no symbol yet */ + dst = elfsh_request_pltent(world.curjob->curfile, + world.curjob->curcmd->param[1]); + if (dst) + addr = dst->st_value; + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PLT entry request failed", (-1)); + } + + /* Insert a symbol on the requested address to avoid this */ + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need a symbol to redirect", -1); + + rev = revm_reverse(world.curjob->curfile, addr); + } + + /* The first resolution worked, we take the address */ + else + { + addr = dst->st_value; + rev = NULL; + } + +#if __DEBUG_HIJACK__ + printf("[cmd_hijack] Resolved %s as %08X \n", + world.curjob->curcmd->param[1], addr); +#endif + + /* Hijack function */ + err = elfsh_hijack_function_by_name(world.curjob->curfile, + ELFSH_HIJACK_TYPE_FLOW, + world.curjob->curcmd->param[0], + addr, &hookedaddr); + + /* Last checks */ + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Function redirection failed", (-1)); + + /* Add it to redirection hash table */ + redir = revm_create_REDIR((u_char) err, world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1], hookedaddr, addr); + hash_add(&world.curjob->curfile->redir_hash, + world.curjob->curcmd->param[0], + (void *) redir); + + /* Print final information */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + "\n [*] Function %s redirected to addr " XFMT " <%s> \n\n", + world.curjob->curcmd->param[0], (eresi_Addr) addr, + (rev == NULL ? world.curjob->curcmd->param[1] : rev)); + revm_output(logbuf); + } + if (rev != NULL) + XFREE(__FILE__, __FUNCTION__, __LINE__,rev); + + /* Everything is ok */ + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/flow.c eresi-0.0.20110516/libstderesi/analysis/flow.c --- eresi-0.8a25/libstderesi/analysis/flow.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/flow.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,64 @@ +/** + * @file libstderesi/analysis/flow.c + * @ingroup analysis + * @brief Various commands related to flow analysis + * + * $Id: flow.c 1410 2010-05-14 13:45:20Z thorkill $ + */ +#include "libstderesi.h" + + +/** + * Manually add function pointer information + */ +int cmd_addgoto(void) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL Parameters", -1); + + snprintf(buf, sizeof(buf), " [*] at %s goto %s\n", + world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1]); + revm_output(buf); + + hash_del(&world.mjr_session.cur->goto_hash, + world.curjob->curcmd->param[0]); + hash_add(&world.mjr_session.cur->goto_hash, + world.curjob->curcmd->param[0], world.curjob->curcmd->param[1]); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Print the control information + */ +int cmd_control() +{ + elfshsect_t *sect; + elfshobj_t *current; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + current = world.curjob->curfile; + sect = elfsh_get_section_by_name(current, + ELFSH_SECTION_NAME_EDFMT_BLOCKS, + 0, 0, 0); + if (!sect || !hash_size(&world.mjr_session.cur->blkhash)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No control flow section found", -1); + + mjr_blocks_display(world.mjr_session.cur, 1); + revm_output("\n [*] Control flow information dumped \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* Change the graph verbose level */ +int cmd_setgvl(void) +{ + world.state.revm_gvl = atoi(world.curjob->curcmd->param[0]); + return (0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/flowjack.c eresi-0.0.20110516/libstderesi/analysis/flowjack.c --- eresi-0.8a25/libstderesi/analysis/flowjack.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/flowjack.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,149 @@ +/** + * @file libstderesi/analysis/flowjack.c + * @ingroup analysis + * Author : + * + * December 10 2006 : merged from modflow to the ELFsh vm -may + * December 31 2006 : factored and cleaned code -may + * + * $Id: flowjack.c 1413 2010-05-21 03:41:25Z figueredo $ + * + */ + +#include "libstderesi.h" + +/* Perform hijack of basic blocks */ +int cmd_flowjack(void) +{ + container_t *cntnr_to_hijack; + mjrblock_t *to_hijack, *cal; + mjrlink_t *caller; + unsigned long addr; + elfshsect_t *sect; + elfsh_Sym *sym; + char *buffer; + char *name; + asm_instr ins; + elfsh_SAddr off; + unsigned long new_addr; + u_int value; + elfshobj_t *file; + char *param; + unsigned int foff; + list_t *linklist; + listent_t *listent; + int len; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + sect = elfsh_get_section_by_name(world.curjob->curfile, + ELFSH_SECTION_NAME_EDFMT_BLOCKS, + 0, 0, 0); + if (!sect) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Control flow section not found" + " : use analyse command", -1); + revm_proc_init(); + + /* Lookup parameters */ + file = world.curjob->curfile; + param = world.curjob->curcmd->param[0]; + sym = elfsh_get_metasym_by_name(file, param); + if (sym) + addr = sym->st_value; + else + addr = strtoul(world.curjob->curcmd->param[0], 0, 16); + + if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, + world.curjob->curcmd->param[1]))) + new_addr = sym->st_value; + else + new_addr = strtoul(world.curjob->curcmd->param[0], 0, 16); + + /* Errors cases */ + if (!addr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to resolve first parameter", -1); + if (!new_addr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to resolve second parameter", -1); + + /* Retreive bloc to be hijacked */ + printf(" [*] Patching blocks calling " XFMT " in %s \n", (int) addr, world.curjob->curfile->name); + cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, 0); + if (!cntnr_to_hijack) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to match hijacked block", -1); + + /* For each caller, modify the location beeing called */ + linklist = cntnr_to_hijack->inlinks; + for (buffer = 0, listent = linklist->head; listent; listent = listent->next) + { + caller = (mjrlink_t *) listent->data; + name = elfsh_reverse_metasym(world.curjob->curfile, addr, &off); + printf(" [*] patching block %s + " DFMT "\n", name, off); + + cal = mjr_lookup_container(world.mjr_session.cur, caller->id)->data; + + cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, cal->vaddr, 1); + to_hijack = cntnr_to_hijack->data; + + //size = to_hijack->size - (cal->vaddr - to_hijack->vaddr); + + foff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, cal->vaddr); + XREALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, buffer, cal->size, -1); + elfsh_readmemf(world.curjob->curfile, foff, buffer, cal->size); + + puts(" [*] would patch block at -> "); + name = elfsh_reverse_metasym(world.curjob->curfile, cal->vaddr, &off); + revm_instr_display(-1, cal->vaddr, 0, cal->size, name, off, buffer); + + /* Understand what is the calling instruction */ + switch (caller->type) + { + case MJR_LINK_FUNC_CALL: + len = (world.curjob->proc->type == ASM_PROC_IA32 ? 5 : 4); + asm_read_instr(&ins, (u_char *) buffer + cal->size - len, len, world.curjob->proc); + break; + case MJR_LINK_BLOCK_COND_TRUE: + case MJR_LINK_BLOCK_COND_FALSE: + case MJR_LINK_BLOCK_COND_ALWAYS: + len = asm_read_instr(&ins, (u_char *) buffer + cal->size - 2, 2, world.curjob->proc); + if (len == 2 && (ins.type & ASM_TYPE_BRANCH)) + break; + len = asm_read_instr(&ins, (u_char *) buffer + cal->size - 3, 3, world.curjob->proc); + if (len == 3 && (ins.type & ASM_TYPE_BRANCH)) + break; + len = asm_read_instr(&ins, (u_char *) buffer + cal->size - 4, 4, world.curjob->proc); + if (len == 4 && (ins.type & ASM_TYPE_BRANCH)) + break; + len = asm_read_instr(&ins, (u_char *) buffer + cal->size - 5, 5, world.curjob->proc); + if (len == 5 && (ins.type & ASM_TYPE_BRANCH)) + break; + default: + revm_output(" [D] Unable to patch flow for non-immediate CALL/JMP transfers \n"); + continue; + } + + /* Patch the immediate operand */ + asm_operand_get_immediate(&ins, 1, 0, &value); + if (ins.op[0].type == ASM_OTYPE_JUMP) + { + value = cal->vaddr + cal->size; + value = new_addr - value; + asm_operand_set_immediate(&ins, 1, 0, &value); + } + else + { + fprintf(stderr, " ! operand type %u not supported \n", ins.op[0].type); + continue; + } + + /* display for debug */ + puts(" * patched ->"); + revm_instr_display(-1, cal->vaddr, 0, cal->size, name, off, buffer); + elfsh_writememf(world.curjob->curfile, foff, buffer, cal->size); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); +} + diff -Nru eresi-0.8a25/libstderesi/analysis/graph.c eresi-0.0.20110516/libstderesi/analysis/graph.c --- eresi-0.8a25/libstderesi/analysis/graph.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/graph.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,849 @@ +/* +* @file libstderesi/analysis/graph.c +** @ingroup analysis +** @brief Dump graphviz output of call graph and control flow graph. +** +** Started : Fri Mar 7 07:18:03 2003 jfv +** $Id: graph.c 1427 2010-07-09 20:54:05Z thorkill $ +*/ +#include "libstderesi.h" + +static hash_t dumped; + + +/** + * @brief Same than system() but gives hand without waiting. + * @param cmd The command to execute. + * @return Executed (0) or Failed (-1) + */ +int revm_system_nowait(char *cmd) +{ + char **argv; + int blanks; + u_int argc; + int ret; + + blanks = revm_findblanks(cmd); + argv = revm_doargv(blanks, &argc, cmd); + argv++; + switch (fork()) + { + case 0: + setenv("LD_PRELOAD", "", 1); + ret = execvp(argv[0], argv); + printf("Failed to execute system(%s) without wait (line = %s) \n", + argv[0], cmd); + exit(ret); + break; + case -1: + return (-1); + default: + return (0); + } +} + +/** + * Generate the legend for the graph in HTML format + * @param fd + * @param fnc + * @param min + * @param max + */ +void revm_graph_legend(int fd, char *fnc) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + snprintf(buf,BUFSIZ-1, + "graph [label=<\n\ + \n \ + \\" + "\n \ + \n \ + \n \ + \n \ + \n \ +
Legend:%s
COND TRUECOND FALSE
CALLRET
DELAY
\n \ + >]\n", fnc, + LNK_COLOR_TRUE, + LNK_COLOR_FALSE, + LNK_COLOR_CALL, + LNK_COLOR_RET, + LNK_COLOR_DELAY); + + write(fd,buf,strlen(buf)); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + +/** + * @brief OUTPUT handler for graphviz file + * @ingroup analysis + */ +int eresi_graph_output(char *str) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + write(world.curjob->ws.io.output_fd, str, strlen(str)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/* Just a static handler to be used with elist_apply */ +static int revm_print_block_handler(listent_t *e, void *null) +{ + revmexpr_t *expr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + expr = (revmexpr_t *) e->data; + revm_expr_print(expr, 1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * @brief Print the content of a basic block + * @param list The expression list for that block + * @return Nothing + */ +static void revm_print_block(int fd, list_t *list) +{ + int savedfd; + void *savedhdl; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + savedfd = revm_output_get(&world.curjob->ws); + savedhdl = world.curjob->ws.io.output; + revm_setoutput(&world.curjob->ws, fd); + revm_setoutput_handler(&world.curjob->ws, eresi_graph_output); + elist_apply(list, NULL, revm_print_block_handler); + revm_setoutput(&world.curjob->ws, savedfd); + revm_setoutput_handler(&world.curjob->ws, savedhdl); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** + * Disassemble a block + * @param fd + * @param blk + */ +static void revm_disasm_block(int fd, mjrblock_t *blk) +{ + char *buffer; + char *name; + elfsh_SAddr off; + u_char revm_quiet; + int revm_colors; + int cur; + u_int reloff; + char tmpbuf[20]; + u_int len; + list_t *instrlist; + u_int totaloff; + char *bufarg; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + revm_quiet = world.state.revm_quiet; + world.state.revm_quiet = 0; + revm_colors = nocolor; + reloff = nocolor = 0; + cur = 1; + + /* Check if we have a list of expressions for this block already */ + snprintf(tmpbuf, sizeof(tmpbuf), AFMT, blk->vaddr); + instrlist = hash_get(&instrlists_hash, tmpbuf); + if (instrlist) + { + revm_print_block(fd, instrlist); + nocolor = revm_colors; + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); + } + + /* Read data to be graphed */ + if (kernsh_is_present() || kedbg_is_present()) + { + XALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, blk->size, ); + bufarg = buffer; + } + else + bufarg = NULL; + buffer = elfsh_readmema(world.curjob->curfile, blk->vaddr, bufarg, blk->size); + if (!buffer) + goto end; + + /* Graph code from block */ + name = elfsh_reverse_metasym(world.curjob->curfile, blk->vaddr, &off); + for (totaloff = 0; totaloff < blk->size; totaloff += cur) + { + len = snprintf(tmpbuf, sizeof(tmpbuf), "%3u: ", reloff); + write(fd, tmpbuf, len); + cur = revm_instr_display(fd, blk->vaddr + totaloff, 0, blk->size - totaloff, + name, off + totaloff, buffer + totaloff); + if (cur <= 0) + goto end; + reloff += cur; + write(fd, "\\l", 2); + revm_endline(); + } + + /* Cleanup and exit */ + end: + if (kernsh_is_present() || kedbg_is_present()) + XFREE(__FILE__, __FUNCTION__, __LINE__, buffer); + world.state.revm_quiet = revm_quiet; + nocolor = revm_colors; + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/** + * Create .dot -> .png files and execute the graphic viewer + * @param dotfile + */ +int revm_graph_compile_graphic(char *dotfile) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if ((int) config_get_data(ERESI_CONFIG_GRAPH_AUTOBUILD)) + { + snprintf(buf,sizeof(buf),"dot -Tpng -o %s.png %s",dotfile,dotfile); + setenv("LD_PRELOAD", "", 1); + system(buf); + + if ((int) config_get_data(ERESI_CONFIG_GRAPH_AUTOVIEW)) + { + snprintf(buf,sizeof(buf), + "%s %s.png", + (char *)config_get_data(ERESI_CONFIG_GRAPH_VIEWCMD), + dotfile); + revm_system_nowait(buf); + } + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(1)); +} + + +/** + * Returns converted path name into string without '.' + * @param path + */ +char *revm_flattern_path(char *path) +{ + char *r,*p; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + r = strdup(path); + p = r; + + while(*p != '\0') + { + if (*p == '.') + *p = '_'; + p++; + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,r); +} + + + +/** + * Prepare directory tree for graph storage + */ +int revm_prepare_storage_dir(void) +{ + mode_t omode = S_IRWXU | S_IRWXG | S_IRWXO; + char *token, *brkt; + char *sep = "/"; + char tmp[BUFSIZ], path[BUFSIZ]; + u_int cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + cur = 0; + memset(tmp,0x00, BUFSIZ); + memset(path,0x00, BUFSIZ); + + snprintf(path,BUFSIZ-1,"%s/%s",(char *)config_get_data(ERESI_CONFIG_GRAPH_STORAGEPATH), + revm_flattern_path(world.mjr_session.cur->obj->name)); + + for (token = strtok_r(path,sep,&brkt); + token; + token = strtok_r(NULL,sep,&brkt)) + { + tmp[cur++] = '/'; + strncat(tmp, token, strlen(token)); + cur += strlen(token); + + mkdir(tmp, omode); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); +} + +/** + * This function prepares a path string to .dot file + * @param opt + * @param prefix + * @return + */ +char *revm_get_dotfile_name(char *opt,char *prefix) +{ + int namelen; + char *dotfile; + char *str1; + char *str2; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!opt) + opt = "dump"; + if (!prefix) + prefix = ""; + + str1 = (char *) config_get_data(ERESI_CONFIG_GRAPH_STORAGEPATH); + str2 = revm_flattern_path(world.mjr_session.cur->obj->name); + namelen = strlen(str1) + strlen(str2) + strlen(opt) + strlen(prefix) + 32; + + XALLOC(__FILE__,__FUNCTION__,__LINE__, dotfile, namelen, NULL); + if (!revm_prepare_storage_dir()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot prepare storage directory", NULL); + + snprintf(dotfile,namelen,"%s%s/%s-%s.dot", + (char *)config_get_data(ERESI_CONFIG_GRAPH_STORAGEPATH), + revm_flattern_path(world.mjr_session.cur->obj->name), + prefix,opt); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dotfile)); +} + +/** + * Converts string to vaddr by looking up the symbol name + * or converting it to hex + * @param s + * @return + */ +u_int revm_get_vaddr(char *s) +{ + elfsh_Sym *sym; + u_int min; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Get parameters */ + if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, s))) + min = sym->st_value; + else + min = strtoul(s, 0, 16); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(min)); +} + + +/** + * Get color name for string, it does check alert + * and lookups the color name + */ +char *revm_get_colored_str(char *str,int type) +{ + color_t *t; + int idx, c; + u_int t2; + char **keys; + char *color; + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + color = FNC_COLOR_DEFAULT; + + if (world.state.revm_use_alert && + !regexec(&world.state.revm_alert, str, 0, 0, 0)) + { + t = hash_get(&t_color_hash, "warnstring"); + + keys = hash_get_keys(&fg_color_hash, &idx); + + for (c = 0; c < idx; c++) + { + t2 = (u_int) hash_get(&fg_color_hash, keys[c]); + if (t2 == t->fground) + { + snprintf(buf, sizeof(buf), "\"%s\"", keys[c]); + color = strdup(buf); + break; + } + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); + } + + switch (type) + { + case GVZ_NODE_EPOINT: + color = FNC_COLOR_EPOINT; + break; + case GVZ_NODE_MAIN: + color = FNC_COLOR_MAIN; + break; + case GVZ_NODE_INTERN: + color = FNC_COLOR_INTERN; + break; + case GVZ_NODE_EXTERN: + color = FNC_COLOR_EXTERN; + break; + case GVZ_NODE_UNKNOWN: + color = GVZ_COLOR_CORAL; + break; + default: + color = FNC_COLOR_DEFAULT; + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); +} + +int revm_graph_get_function_type(mjrfunc_t *fnc) +{ + elfshsect_t *parent; + int ftype; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + parent = elfsh_get_parent_section(world.curjob->curfile, fnc->vaddr, NULL); + + if (fnc->vaddr == elfsh_get_entrypoint(elfsh_get_hdr(world.mjr_session.cur->obj))) + ftype = GVZ_NODE_EPOINT; + else if ((parent == NULL)||(parent->name == NULL)) + ftype = GVZ_NODE_UNKNOWN; + else if (parent && parent->name && strcmp(".text",parent->name)) + ftype = GVZ_NODE_EXTERN; + else + ftype = GVZ_NODE_INTERN; + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ftype); +} + + +/* Write the header dot description for a node */ +char *revm_write_dotnode(int fd, elfshobj_t *obj, eresi_Addr addr, u_int size) +{ + char buf[BUFSIZ]; + char *name; + elfsh_SAddr offset; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + name = elfsh_reverse_metasym(obj, addr, &offset); + if (name && !offset) + snprintf(buf, sizeof(buf), + "\"%s\" [shape=\"box\" color=%s label=\"<%s@%u>:\\l", + name, "\"grey\"", name, size); + else + snprintf(buf, sizeof(buf), + "\"" AFMT "\" [shape=\"box\" color=%s label=\"<" AFMT "@%u>:\\l", + addr, "\"grey\"", addr, size); + write(fd, buf, strlen(buf)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (!offset ? name : NULL)); +} + +/* Write the footer dot description for a node */ +int revm_write_endnode(int fd) +{ + char buf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + snprintf(buf, sizeof(buf), "\"];\n"); + write(fd, buf, strlen(buf)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/* A recursive function for graphing in dot format */ +int revm_graph_blocks(container_t *cntnr, + int fd, + int dir, + int maxdepth, + int curdepth) +{ + mjrblock_t *blk,*cblk; + mjrlink_t *lnk; + char buf[BUFSIZ]; + char *vaddr_str; + char *col_arrow; + container_t *nextcnt; + mjrblock_t *nextblk; + list_t *linklist; + listent_t *curent; + char *name; + char *sname; + elfsh_SAddr soffset; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + blk = (mjrblock_t *) cntnr->data; + + vaddr_str = _vaddr2str(blk->vaddr); + + if (hash_get(&dumped, vaddr_str) || (maxdepth > 0 && curdepth >= maxdepth)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + hash_add(&dumped, vaddr_str, cntnr); + + linklist = cntnr->outlinks; + + name = revm_write_dotnode(fd, world.mjr_session.cur->obj, blk->vaddr, blk->size); + revm_disasm_block(fd, blk); + revm_write_endnode(fd); + + /* Print all links */ + for (curent = linklist->head; curent; curent = curent->next) + { + lnk = (mjrlink_t *) curent->data; + cblk = (mjrblock_t *) mjr_lookup_container(world.mjr_session.cur, lnk->id)->data; + + switch (lnk->type) + { + case MJR_LINK_BLOCK_COND_ALWAYS: + case MJR_LINK_BLOCK_COND_TRUE: + col_arrow = LNK_COLOR_TRUE; + break; + case MJR_LINK_BLOCK_COND_FALSE: + col_arrow = LNK_COLOR_FALSE; + break; + case MJR_LINK_FUNC_CALL: + col_arrow = LNK_COLOR_CALL; + break; + case MJR_LINK_FUNC_RET: + col_arrow = LNK_COLOR_RET; + break; + case MJR_LINK_TYPE_DELAY: + col_arrow = LNK_COLOR_DELAY; + break; + default: + fprintf(D_DESC, "[D] %s 1st: lnk->type:%d\n", __FUNCTION__, lnk->type); + col_arrow = "\"black\""; + break; + } + + sname = elfsh_reverse_metasym(world.mjr_session.cur->obj, cblk->vaddr, &soffset); + if (name) + { + if (sname && !soffset) + snprintf(buf, sizeof(buf), "\"%s\" -> \"%s\" [color=%s];\n", + name, sname, col_arrow); + else + snprintf(buf, sizeof(buf), "\"%s\" -> \"" AFMT "\" [color=%s];\n", + name, cblk->vaddr, col_arrow); + } + else + { + if (sname && !soffset) + snprintf(buf, sizeof(buf), "\"" AFMT "\" -> \"%s\" [color=%s];\n", + blk->vaddr, sname, col_arrow); + else + snprintf(buf, sizeof(buf), "\"" AFMT "\" -> \"" AFMT "\" [color=%s];\n", + blk->vaddr, cblk->vaddr, col_arrow); + } + +#if __DEBUG_GRAPH__ + fprintf(D_DESC,"[D] %s: " AFMT " -> " AFMT " %d\n", + __FUNCTION__, blk->vaddr, cblk->vaddr, lnk->type); +#endif + + write(fd, buf, strlen(buf)); + } + + /* Now recurse on the children */ + for (curent = linklist->head; curent; curent = curent->next) + { + lnk = (mjrlink_t *) curent->data; + if (lnk->scope == MJR_LINK_SCOPE_GLOBAL) + continue; + + nextcnt = mjr_lookup_container(world.mjr_session.cur, lnk->id); + nextblk = (mjrblock_t *) nextcnt->data; + + revm_graph_blocks(nextcnt, fd, 0, 0, curdepth + 1); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * This function does dump a function container in graphviz format + * @param fd + * @param direction input/output + * @param type 0 - we are dumping only out, 1 - we generate .dot file for + * both directions + * @param maxdepth + * @param curdepth + */ +int revm_graph_function(container_t *cntnr, + int fd, + int direction, + int type, + int maxdepth, + int curdepth) +{ + elfsh_SAddr offset; + int ftype; + mjrfunc_t *fnc, *tmpfnc; + mjrlink_t *curlnk; + char *n1, *n2, *vaddr_str; + char buf[BUFSIZ]; + list_t *linklist; + listent_t *curent; + container_t *child; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!cntnr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No container found", -1); + + fnc = (mjrfunc_t *) cntnr->data; + vaddr_str = _vaddr2str(fnc->vaddr); + + if (hash_get(&dumped, vaddr_str) || (maxdepth > 0 && curdepth >= maxdepth)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + + + n1 = elfsh_reverse_metasym(world.curjob->curfile,fnc->vaddr, &offset); + + ftype = revm_graph_get_function_type(fnc); + + snprintf(buf, sizeof(buf), "\"%s\" [color=%s];\n", + (n1 && !offset ? n1 : fnc->name), + revm_get_colored_str((n1) ? n1 : fnc->name, ftype)); + + write(fd, buf, strlen(buf)); + linklist = mjr_link_get_by_direction(cntnr,direction); + + /* Print all links of this function */ + for (curent = linklist->head; curent; curent = curent->next) + { + curlnk = (mjrlink_t *) curent->data; + tmpfnc = (mjrfunc_t *) mjr_lookup_container(world.mjr_session.cur,curlnk->id)->data; + + /* resolve the symbols */ + n2 = elfsh_reverse_metasym(world.curjob->curfile, tmpfnc->vaddr, &offset); + ftype = revm_graph_get_function_type(tmpfnc); + + if (type) + { + snprintf(buf, sizeof(buf), + "\"%s\" [color=%s];\n", + (n2) ? n2 : tmpfnc->name, + revm_get_colored_str((n2) ? n2 : tmpfnc->name, ftype)); + + write(fd,buf,strlen(buf)); + } + + if (direction == CONTAINER_LINK_OUT) + snprintf(buf,sizeof(buf), + "\"%s\" -> \"%s\";\n", + (n1) ? n1 : fnc->name, + (n2) ? n2 : tmpfnc->name); + + else if (direction == CONTAINER_LINK_IN) + { + snprintf(buf,sizeof(buf), + "\"%s\" -> \"%s\";\n", + (n2) ? n2 : tmpfnc->name, + (n1) ? n1 : fnc->name); + } + + write(fd,buf,strlen(buf)); + } + + /* Recurse on children */ + for (curent = linklist->head; curent; curent = curent->next) + { + curlnk = (mjrlink_t *) curent->data; + child = mjr_lookup_container(world.mjr_session.cur, curlnk->id); + revm_graph_function(child, fd, direction, type, maxdepth, curdepth + 1); + } + + hash_add(&dumped, vaddr_str, cntnr); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Open the file for putting the dot description + * @param dotfile + * @param fd + * @returm + */ +int revm_open_dot_file(char *dotfile, int *fd) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + printf(" [*] .dot file: %s\n\n", dotfile); + + *fd = open(dotfile, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (*fd == -1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot create graphviz file", -1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); +} + + + +eresi_Addr revm_get_min_param(void) +{ + revmexpr_t *expr; + revmobj_t *var; + eresi_Addr min; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + expr = revm_lookup_var(world.curjob->curcmd->param[1]); + if (expr && expr->value) + { + var = expr->value; + if (var->otype->type == ASPECT_TYPE_STR) + min = revm_get_vaddr(var->immed ? var->immed_val.str : + var->get_name(var->root, var->parent)); + else + min = (var->immed ? var->immed_val.ent : var->get_obj(var->parent)); + } + else + min = revm_get_vaddr(world.curjob->curcmd->param[1]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (min)); +} + + +/* Graph the binary */ +int cmd_graph(void) +{ + container_t *cntnr; + int fd; + char buf[BUFSIZ]; + eresi_Addr min; + char *dotfile; + int maxdepth; + int ret; + mjrfunc_t *func; + char *str; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + hash_init(&dumped, "dumped_containers", mjrHashVerySmall, ASPECT_TYPE_UNKNOW); + + /* Select use depending on number of arguments */ + switch (world.curjob->curcmd->argc) + { + + /* Requested a complete call graph */ + case 0: + if (!mjr_analysed(&world.mjr_session, world.curjob->curfile->hdr->e_entry)) + { + maxdepth = (int) config_get_data(CONFIG_CFGDEPTH); + ret = mjr_analyse(&world.mjr_session, world.curjob->curfile->hdr->e_entry, maxdepth, 0); + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during control flow analysis", -1); + } + + dotfile = revm_get_dotfile_name(NULL, "object"); + revm_open_dot_file(dotfile, &fd); + snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); + write(fd, buf, strlen(buf)); + printf(" [*] Dumping %d functions\n\n", world.mjr_session.cur->funchash.elmnbr); + cntnr = mjr_get_container_by_vaddr(world.mjr_session.cur, + world.mjr_session.cur->obj->hdr->e_entry, + ASPECT_TYPE_FUNC); + revm_graph_function(cntnr, fd, CONTAINER_LINK_OUT, 0, 0, 1); + write(fd, "}\n", 2); + close(fd); + revm_graph_compile_graphic(dotfile); + break; + + /* Requested a partial call graph or a control flow graph of a single function */ + case 2: + + /* A partial call graph */ + if (!strcmp("func", world.curjob->curcmd->param[0])) + { + min = revm_get_min_param(); + maxdepth = (int) config_get_data(CONFIG_CFGDEPTH); + if (!mjr_analysed(&world.mjr_session, min)) + { + ret = mjr_analyse(&world.mjr_session, min, maxdepth, 0); + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during control flow analysis", -1); + } + cntnr = hash_get(&world.mjr_session.cur->funchash, _vaddr2str(min)); + if (!cntnr) + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Function not found",-1); + dotfile = revm_get_dotfile_name(_vaddr2str(min), "function"); + revm_open_dot_file(dotfile, &fd); + snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); + write(fd,buf,strlen(buf)); + revm_graph_function(cntnr, fd, CONTAINER_LINK_IN, 1, maxdepth, 0); + func = (mjrfunc_t *) cntnr->data; + str = _vaddr2str(func->vaddr); + hash_del(&dumped, str); + XFREE(__FILE__, __FUNCTION__, __LINE__, str); + revm_graph_function(cntnr, fd, CONTAINER_LINK_OUT, 1, maxdepth, 0); + write(fd,"}\n",2); + close(fd); + revm_graph_compile_graphic(dotfile); + } + + /* A control flow graph of a single function */ + else if (!strcmp("bloc",world.curjob->curcmd->param[0])) + { + min = revm_get_min_param(); + if (!mjr_analysed(&world.mjr_session, min)) + { + maxdepth = (int) config_get_data(CONFIG_CFGDEPTH); + ret = mjr_analyse(&world.mjr_session, min, maxdepth, 0); + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during control flow analysis", -1); + } + cntnr = hash_get(&world.mjr_session.cur->blkhash, _vaddr2str(min)); + if (!cntnr) + PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, + "Block not found",-1); + dotfile = revm_get_dotfile_name(_vaddr2str(min), "block"); + revm_open_dot_file(dotfile, &fd); + snprintf(buf, sizeof(buf), "strict digraph prof {\n"); + write(fd, buf, strlen(buf)); + revm_graph_legend(fd, "DEFAULT"); + revm_graph_blocks(cntnr, fd, 0, 0, 1); + write(fd,"}\n",2); + close(fd); + revm_graph_compile_graphic(dotfile); + } + else + revm_output(" [!] Invalid syntax: help graph\n"); + break; + + /* FIXME: graph */ + case 3: + break; + + /* FIXME: graph */ + case 4: + break; + + default: + { + revm_output(" [!] INVALID SYNTAX \n"); + revm_output(HLP_GRAPH); + } + + } + + hash_destroy(&dumped); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/hammer.c eresi-0.0.20110516/libstderesi/analysis/hammer.c --- eresi-0.8a25/libstderesi/analysis/hammer.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/hammer.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,190 @@ +/* +* @file libstderesi/analysis/hammer.c +** @ingroup analysis +** @brief Contains libmjollnir commands bindings. +** +** Last update December 10 2006 may +** +** $Id: hammer.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + +/** Check if we have to re-analyse the binary */ +int revm_analysed(eresi_Addr addr) +{ + int analysed; + char logbuf[BUFSIZ]; + char c; + + /* Make sure we do what the user desires (remove previously stored analysis) */ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + analysed = mjr_analysed(&world.mjr_session, addr); + if (analysed) + { + snprintf(logbuf, sizeof(logbuf), + " [*] Address " XFMT " has already been analysed. \n" + " Analysis will remove currently stored information. Continue ? [N/y]", + addr); + revm_output(logbuf); + c = getchar(); + revm_output(""); + if (c != 'y') + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Flow analysis aborted", 0); + mjr_analyse_destroy(world.mjr_session.cur); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); +} + + +/** + * To rebuild symtab use this command + */ +int cmd_unstrip() +{ + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + memset(logbuf,0x0,BUFSIZ); + snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure started\n"); + revm_output(logbuf); + + // The analysed flag does not exist anymore since we do demand-driven analysis + //if (!world.mjr_session.cur->analysed) + //cmd_analyse(); + + memset(logbuf,0x0,BUFSIZ); + snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure %s\n", + (mjr_symtab_rebuild(&world.mjr_session)) ? "completed successfully" : "failed"); + revm_output(logbuf); + elfsh_sync_sorted_symtab(world.mjr_session.cur->obj->secthash[ELFSH_SECTION_SYMTAB]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * This command construct the call graph and the control flow graph for each function. + * Additionally, it reflects all analysed objects in the ERESI language. + */ +int cmd_analyse() +{ + char logbuf[BUFSIZ]; + int ret; + aspectype_t *curtype; + aspectype_t *linktype; + eresi_Addr addr; + revmexpr_t *expr; + revmobj_t *obj; + int maxdepth; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Resolve the parameter */ + if (world.curjob->curcmd->param[0]) + { + expr = revm_lookup_var(world.curjob->curcmd->param[0]); + if (expr) + { + obj = expr->value; + switch (obj->otype->type) + { + case ASPECT_TYPE_LONG: + case ASPECT_TYPE_CADDR: + case ASPECT_TYPE_DADDR: + addr = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); + break; + + case ASPECT_TYPE_INT: + addr = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); + break; + } + } + else + addr = revm_lookup_addr(world.curjob->curcmd->param[0]); + } + else + addr = world.curjob->curfile->hdr->e_entry; + + /* Check if we have to remove previously saved analysis section */ + if (!revm_analysed(addr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Canceled control flow analysis", -1); + + /* Analyzing object */ + snprintf(logbuf, BUFSIZ - 1, + " [*] Now performing Control Flow Analysis at " XFMT " (curfile = %s)\n", + addr, world.mjr_session.cur->obj->name); + revm_output(logbuf); + + /* Do control flow analysis */ + maxdepth = (int) config_get_data(CONFIG_CFGDEPTH); + ret = mjr_analyse(&world.mjr_session, addr, maxdepth, 0); + + /* We certainly have inserted many new symbols */ + elfsh_sync_sorted_symtab(world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB]); + + snprintf(logbuf, BUFSIZ - 1, " [*] Control Flow Analysis %s.\n", + (!ret ? "completed successfully" : "failed")); + revm_output(logbuf); + if (ret) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error during control flow analysis", -1); + + memset(logbuf, 0x0, BUFSIZ); + snprintf(logbuf, BUFSIZ - 1, + " [*] Calls seen: %d, Recognized destination: %d\n", + world.mjr_session.cur->calls_seen, + world.mjr_session.cur->calls_found); + revm_output(logbuf); + + /* Now informing about all existing blocks and functions */ + curtype = aspect_type_get_by_name("container"); + if (curtype) + { + revm_type_reflect(&world.mjr_session.cur->funchash, "func"); + revm_type_reflect(&world.mjr_session.cur->blkhash , "bloc"); + revm_output(" [*] Reflected succesfully all basic blocks and functions.\n"); + } + else + revm_output(" [*] No CONTAINER reflection was performed (type definition not found)\n"); + + /* Now informing about all existing links */ + linktype = aspect_type_get_by_name("link"); + if (linktype) + { + revm_type_reflect(&world.mjr_session.cur->linkhash, linktype->name); + revm_output(" [*] Reflected succesfully all blocks links and function links.\n\n"); + } + else + revm_output(" [*] No LINK reflection was performed (type definition not found)\n\n"); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Shortcut command to rename symbols + */ +int cmd_rename() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + mjr_symbol_rename(&world.mjr_session, + world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Remove previously done analysis + */ +int cmd_astrip() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + mjr_analyse_destroy(world.mjr_session.cur); + revm_output("[*] Removed previously stored control flow analysis\n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/inspect.c eresi-0.0.20110516/libstderesi/analysis/inspect.c --- eresi-0.8a25/libstderesi/analysis/inspect.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/inspect.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,148 @@ +/* +* @file libstderesi/analysis/inspect.c +** @ingroup analysis +** @brief Inspect the content of a basic block +** +** Original author : +** +** December 10 2006 : Merged from modflow to the ELFsh vm -may +** +** $Id: inspect.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + + + +/** + * Some API that needs to be moved in another file ! + * @param id + */ +eresi_Addr revm_get_block_vaddr_by_id(int id) +{ + container_t *container; + mjrblock_t *block; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + container = mjr_lookup_container(world.mjr_session.cur,id); + block = (mjrblock_t *) container->data; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, block->vaddr); +} + + +/** + * Inspect command for basic blocks + */ +int cmd_inspect() +{ + elfshobj_t *obj; + elfshsect_t *sect; + elfsh_Sym *sym; + mjrblock_t *blk; + container_t *cntnr; + mjrlink_t *cal; + char *name; + char *pname; + elfsh_SAddr off; + u_int vaddr; + char buflog[BUFSIZ]; + listent_t *curent; + mjrblock_t *tmpblock; + revmannot_t *annot; + revmexpr_t *expr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Preliminary checks */ + cntnr = NULL; + obj = world.curjob->curfile; + + /* Try to find block by symbol or address */ + if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, + world.curjob->curcmd->param[0]))) + vaddr = sym->st_value; + else + vaddr = strtoul(world.curjob->curcmd->param[0], 0, 16); + + if (!mjr_analysed(&world.mjr_session, vaddr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Block not found: consider analyse $blockaddr command before", -1); + + /* Try to lookup by variable name */ + if (!vaddr) + { + expr = revm_expr_get(world.curjob->curcmd->param[0]); + if (!expr || !expr->type || expr->type->type != ASPECT_TYPE_BLOC) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find block expression", -1); + annot = revm_annot_get(expr->label); + if (!annot) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find block annotation", -1); + cntnr = (container_t *) annot->addr; + if (!cntnr || !cntnr->data) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find valid container for block", -1); + name = elfsh_reverse_metasym(world.curjob->curfile, *(eresi_Addr *) cntnr->data, &off); + } + else + { + name = elfsh_reverse_metasym(world.curjob->curfile, vaddr, &off); + cntnr = mjr_block_get_by_vaddr(world.mjr_session.cur, vaddr, 1); + if (!cntnr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find block", -1); + } + + blk = cntnr->data; + + /* Dump calling information */ + snprintf(buflog, sizeof(buflog), " [*] Found block " XFMT " : %s + " DFMT "\n", + blk->vaddr, name, off); + revm_output(buflog); + + /* Iterate on the list of links */ + for (curent = cntnr->inlinks->head; curent; curent = curent->next) + { + cal = curent->data; + tmpblock = mjr_lookup_container(world.mjr_session.cur,cal->id)->data; + pname = elfsh_reverse_metasym(world.curjob->curfile, tmpblock->vaddr, &off); + + /* FIXME: we have to work out the lack of the 'type' field for blocks */ + switch (cal->type) + { + case MJR_LINK_BLOCK_COND_TRUE: + snprintf(buflog, sizeof(buflog), + " -> true jumped from " XFMT " : %s + " DFMT "\n", + revm_get_block_vaddr_by_id(cal->id), pname, off); + break; + case MJR_LINK_BLOCK_COND_FALSE: + snprintf(buflog, sizeof(buflog), + " -> false from " XFMT " : %s + " DFMT "\n", + revm_get_block_vaddr_by_id(cal->id), pname, off); + break; + case MJR_LINK_FUNC_CALL: + snprintf(buflog, sizeof(buflog), + " -> called from " XFMT " : %s + " DFMT "\n", + revm_get_block_vaddr_by_id(cal->id), pname, off); + break; + case MJR_LINK_FUNC_RET: + snprintf(buflog, sizeof(buflog), + " -> returned from " XFMT " : %s + " DFMT "\n", + revm_get_block_vaddr_by_id(cal->id), pname, off); + break; + default: + snprintf(buflog, sizeof(buflog), + " -> UNKNOW from " XFMT " : %s + " DFMT "\n", + revm_get_block_vaddr_by_id(cal->id), pname, off); + } + revm_output(buflog); + } + + /* Dump ASM */ + revm_output(" -- block disassembly --\n"); + sect = elfsh_get_parent_section(obj, blk->vaddr, NULL); + off = elfsh_get_foffset_from_vaddr(obj, blk->vaddr); + revm_object_display(sect, sym, blk->size, 0, 0, off, blk->vaddr, + name, REVM_VIEW_DISASM, 1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/Makefile eresi-0.0.20110516/libstderesi/analysis/Makefile --- eresi-0.8a25/libstderesi/analysis/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/Makefile 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,55 @@ +## +## Makefile for analyse in libstderesi for the ERESI project +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## $Id: Makefile 1398 2009-09-13 07:00:08Z may $ +## +include ../../config.h + +SRC = flow.c graph.c debug.c fcthijack.c flowjack.c hammer.c \ + inspect.c match.c trace.c argcount.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CC ?= gcc +LD ?= ld +RM = rm -f +NAME32 = ../std-analyse.32.o +NAME64 = ../std-analyse.64.o + +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ + -I../../libmjollnir/include/ -I../../libaspect/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ + $(READLNOPT) + +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libaspect/include/ \ + -I../../libui/include/ -I../../libmjollnir/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ + $(NCURSESLNOPT) $(READLNOPT) + +all : all32 all64 + +$(NAME32) : $(OBJ32) + $(LD) -r $(OBJ32) -o $(NAME32) + +$(NAME64) : $(OBJ64) + $(LD) -r $(OBJ64) -o $(NAME64) +all32: $(NAME32) +all64: $(NAME64) + +clean : + @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/analysis/match.c eresi-0.0.20110516/libstderesi/analysis/match.c --- eresi-0.8a25/libstderesi/analysis/match.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/match.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,522 @@ +/** +* @file libstderesi/analysis/match.c +** @ingroup analysis +** @brief Implementation of program transformation in ERESI +** +** Start on Wed May 23 13:55:45 2007 jfv +** +** $Id: match.c 1444 2011-01-31 07:41:29Z may $ +*/ +#include "libstderesi.h" + + +/** + * Retreive the annotation for a given expression + * @param name Expression name + * @return A pointer on the annotation, or NULL if failed. + */ +revmannot_t *revm_annot_get(char *name) +{ + revmexpr_t *expr; + aspectype_t *type; + hash_t *thash; + revmannot_t *annot; + char newname[BUFSIZ] = {0x00}; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + expr = revm_expr_get(name); + if (!expr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid input expression name", NULL); + type = expr->type; + snprintf(newname, sizeof(newname), "type_%s", type->name); + thash = hash_find(newname); + annot = hash_get(thash, name); + if (!annot) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find annotation for expression", NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, annot); +} + + +/** + * Copy a field value from one expression to another (provided destination indeed has that field) + * @param dest Destination expression to add field to + * @param source Source expression tocopy field from + * @param fname Name of field to copy from source to destination + * @return 0 for success and -1 for error + */ +static int revm_field_propagate(revmexpr_t *dest, revmexpr_t *source, char *fname) +{ + char srcname[BUFSIZ]; + char dstname[BUFSIZ]; + revmexpr_t *dst; + revmexpr_t *child; + revmannot_t *annot; + revmannot_t *dstannot; + revmannot_t *addedannot; + char *newdata; + /*eresi_Addr addr; */ + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Propagate input links */ + snprintf(srcname, sizeof(srcname), "%s.%s", source->label, fname); + child = revm_expr_get(srcname); + if (!child) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + snprintf(dstname, sizeof(dstname), "%s.%s", dest->label, fname); + dst = revm_expr_get(dstname); + + /* If destination expression has no such field, create it now */ + if (!dst) + { + annot = revm_annot_get(child->label); // annot de lexpr a copier + dstannot = revm_annot_get(dest->label); // annot de lexpr mere destination + if (!annot || !dstannot) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to lookup annotations for input expressions", -1); + + XREALLOC(__FILE__, __FUNCTION__, __LINE__, newdata, + (char *) dstannot->addr, dest->type->size + child->type->size, -1); + dstannot->addr = (eresi_Addr) newdata; + + dst = revm_expr_copy(child, dstname, 1); + dst->next = dest->childs; + dest->childs = dst; + + addedannot = revm_annot_get(dstname); + if (!addedannot) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to add annotation on new field", -1); + memcpy((char *) dstannot->addr + dest->type->size, (char *) addedannot->addr, child->type->size); + addedannot->addr = dstannot->addr + dest->type->size; + + /* XXX-FIXME: annotations needs to be updated for childs of this type too.... */ + /* + dest->type->size += child->type->size; + revm_inform_type_addr(dst->type->name, dstname, dstannot->addr + dest->type->size, dst, 0, 0); + */ + } + + /* Else assign it */ + else if (child->value && revm_object_set(dest, child) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression field", -1); + else if (revm_expr_set(dst, child) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression fields", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Propagate the link between 2 objects + * @param dest Destination expression to copy links to + * @param source Source expression to copy links from + * @return 0 for success and -1 for error + */ +static int revm_links_propagate(revmexpr_t *dest, revmexpr_t *source) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (revm_field_propagate(dest, source, "inlinks") < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression INLINKS field", -1); + if (revm_field_propagate(dest, source, "outlinks") < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression OUTLINKS field", -1); + if (revm_field_propagate(dest, source, "nbrinlinks") < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression NBRINLINKS field", -1); + if (revm_field_propagate(dest, source, "nbroutlinks") < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to copy expression NBROUTLINKS field", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Perform the transformation (can be called from case or into commands) + * @param matchme + * @param destvalue + * @return +*/ +static int revm_case_transform(revmexpr_t *matchme, char *destvalue) +{ + u_int dstnbr; + char *curptr; + char *foundptr; + u_int curidx; + list_t *exprlist; + aspectype_t *type; + char namebuf[BUFSIZ]; + char *rname; + revmexpr_t *candid; + list_t *looplist; + char *dstvalue; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* We matched : first find how many elements there is in the target (list) type */ + dstnbr = 1; + XALLOC(__FILE__, __FUNCTION__, __LINE__, exprlist, sizeof(list_t), -1); + elist_init(exprlist, "curdestlist", ASPECT_TYPE_EXPR); + for (curidx = world.curjob->iter[world.curjob->curloop].listidx - 1, curptr = destvalue; + curptr && *curptr; + curptr = foundptr + 2, curidx++, dstnbr++) + { + foundptr = strstr(curptr, "::"); + if (!foundptr && dstnbr == 1) + break; + if (foundptr) + *foundptr = 0x00; + type = revm_exprtype_get(curptr); + snprintf(namebuf, BUFSIZ, "%s-%u", world.curjob->iter[world.curjob->curloop].curkey, curidx); + rname = strdup(namebuf); + candid = revm_expr_create(type, rname, curptr); + if (!candid || !candid->annot) + { + elist_destroy(exprlist); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid target type(s) for transformation", -1); + } + candid->annot->inhash = 1; + elist_append(exprlist, rname, candid); + if (!foundptr) + break; + } + + /* UNIMPLEMENTED: Case where the rewritten element is not part of an iterated list -- unsupported */ + looplist = (list_t *) world.curjob->iter[world.curjob->curloop].list; + if (!looplist) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Rewriting of non-list element unimplemented", -1); + else if (looplist->type != ASPECT_TYPE_EXPR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Rewrite of non-expression variables unimplemented", -1); + + /* Simply replace the current list element now */ + /* The type of the list (list_t->type) does not change : it still is a list of revmexpr_t */ + + /* Just one element to swap */ + else if (dstnbr == 1) + { + elist_destroy(exprlist); + + /* No transformation, keep the original expression */ + if (!strcmp(destvalue, ".")) + candid = matchme; + else + { + + /* Case where we did not have a simple value here but a real expression */ + rname = revm_tmpvar_create(); + type = revm_exprtype_get(destvalue); + candid = revm_expr_create(type, rname, destvalue); + if (!candid || !candid->annot) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Malformed destination type", -1); + candid->annot->inhash = 1; + + /* + XXX: Disabled -- do not remove -- to renable when SSA transform is ready + if (revm_links_propagate(candid, matchme) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error while propagating dataflow links", -1); + */ + + elist_set(looplist, strdup(world.curjob->iter[world.curjob->curloop].curkey), candid); + rname = strdup(matchme->label); + revm_expr_destroy_by_name(matchme->label); + matchme = revm_expr_copy(candid, rname, 0); + world.curjob->iter[world.curjob->curloop].curind = matchme; + + //XXX: if we free it now, ->matchexpr and maybe other exprs will be dangling + //revm_expr_destroy_by_name(candid->label); + XFREE(__FILE__, __FUNCTION__, __LINE__, rname); + if (!matchme) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to write back list element", -1); + } + } + + /* Insert a list at a certain offset of the list and remove matched element */ + else + { + elist_replace(looplist, world.curjob->iter[world.curjob->curloop].curkey, elist_copy(exprlist)); + world.curjob->iter[world.curjob->curloop].listidx += exprlist->elmnbr - 1; + elist_destroy(exprlist); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Execute side-effects command at some transformation point + * @param str + */ +static int revm_case_execmd(char *str) +{ + revmargv_t *curcmd; + char actual[26]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + world.curjob->curscope++; + snprintf(actual, sizeof(actual), "job%u_rec%u_labels", world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].labels, + strdup(actual), 11, ASPECT_TYPE_STR); + snprintf(actual, sizeof(actual), "job%u_rec%u_exprs", world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].exprs, strdup(actual), 1, ASPECT_TYPE_EXPR); + + curcmd = world.curjob->curcmd; + + if (revm_exec_str(str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Side-effects preparation failed", -1); + + world.curjob->curcmd = world.curjob->recur[world.curjob->curscope].script; + if (revm_execmd() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Side-effects execution failed", -1); + world.curjob->curcmd = curcmd; + + world.curjob->recur[world.curjob->curscope].script = NULL; + hash_destroy(&world.curjob->recur[world.curjob->curscope].labels); + + hash_destroy(&world.curjob->recur[world.curjob->curscope].exprs); + + world.curjob->curscope--; + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Translate in destination type + */ +int cmd_into() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matched) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (world.curjob->recur[world.curjob->curscope].rwrt.replaced) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot transform a second time", -1); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matchexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot transform outside a rewrite", -1); + if (revm_case_transform(world.curjob->recur[world.curjob->curscope].rwrt.matchexpr, + strdup(world.curjob->curcmd->param[0])) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to transform expression", -1); + world.curjob->recur[world.curjob->curscope].rwrt.replaced = 1; + if (!world.state.revm_quiet) + revm_output(" [*] Expression transformed succesfully \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Perform pre-side-effects + */ +int cmd_pre() +{ + char *str; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matched) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (world.curjob->recur[world.curjob->curscope].rwrt.replaced) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot perform pre-side-effects after transformation", -1); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matchexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Command cannot execute outside a rewrite", -1); + str = revm_string_get(world.curjob->curcmd->param); + if (revm_case_execmd(str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "PRE side-effects command failed", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Perform pre-side-effects + */ +int cmd_post() +{ + char *str; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matched) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (!world.curjob->recur[world.curjob->curscope].rwrt.replaced) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot perform post-side-effects before transformation", -1); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matchexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Command cannot execute outside a rewrite", -1); + str = revm_string_get(world.curjob->curcmd->param); + if (revm_case_execmd(str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "POST side-effects command failed", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Check input type, translate if matching + */ +int cmd_case() +{ + aspectype_t *exprtype; + revmexpr_t *matchme; + revmexpr_t *candid; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->recur[world.curjob->curscope].rwrt.matchexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Case is not in a match", -1); + + exprtype = aspect_type_get_by_id(ASPECT_TYPE_EXPR); + if (!exprtype) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Expression type not found : lacking reflection ?", -1); + + /* If a previous case has already matched, simply end the transformation now : + We must do that here because some "post" commands can be put after a matching + "case", so we only stop rewriting at the first case -following- a matchcase */ + if (world.curjob->recur[world.curjob->curscope].rwrt.matched) + { + revm_move_pc(world.curjob->curcmd->endlabel); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Check if we match */ + matchme = (revmexpr_t *) world.curjob->recur[world.curjob->curscope].rwrt.matchexpr; + if (!matchme->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for matchme expression", -1); + candid = revm_expr_create(matchme->type, "$candid", strdup(world.curjob->curcmd->param[0])); + ret = (!candid ? 1 : revm_expr_match(candid, matchme)); + + /* No match or bad match : nothing happens */ + if (ret) + { + world.curjob->recur[world.curjob->curscope].rwrt.matched = 0; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + + /* Matched : transform and execute post side effects if any */ + world.curjob->recur[world.curjob->curscope].rwrt.matched = 1; + + /* Sometimes the case command comes directly with appended post side-effects */ + if (!world.curjob->curcmd->param[1]) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + revm_case_transform(matchme, strdup(world.curjob->curcmd->param[1])); + if (world.curjob->curcmd->param[2] && + revm_case_execmd(world.curjob->curcmd->param[2]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Post-side-effects commands failed", -1); + + /* Jump to end of the match construct */ + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Beginning of the transform command, open a transformation switch + */ +int cmd_match() +{ + list_t *list; + revmexpr_t *ind; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* The first time we enter this command, we have to fetch the params */ + list = (list_t *) world.curjob->iter[world.curjob->curloop].list; + ind = world.curjob->iter[world.curjob->curloop].curind; + if (list && ind && !strcmp(ind->label, world.curjob->curcmd->param[0])) + { + if (list->type != ASPECT_TYPE_EXPR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Match/Rewrite can only works on expressions", -1); +#if __DEBUG_REWRITE__ + fprintf(stderr, "\n [DEBUG] We -ARE- matching elements of a list *** \n"); +#endif + + world.curjob->recur[world.curjob->curscope].rwrt.matchexpr = ind; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + +#if __DEBUG_REWRITE__ + fprintf(stderr, "\n [DEBUG] We are -NOT- matching elements of a list *** \n"); +#endif + + ind = revm_lookup_param(world.curjob->curcmd->param[0], 1); + world.curjob->recur[world.curjob->curscope].rwrt.matchexpr = ind; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * End of match. Do nothing. + */ +int cmd_matchend() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + bzero(&world.curjob->recur[world.curjob->curscope].rwrt, sizeof(revmrewrite_t)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Default case of a match when nothing else has matched + */ +int cmd_default() +{ + char *str; + revmargv_t *cur; + char actual[ERESI_MEANING]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + cur = world.curjob->curcmd; + + /* Dont execute if we matched something */ + if (world.curjob->recur[world.curjob->curscope].rwrt.matched) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + /* Create new context */ + world.curjob->curscope++; + snprintf(actual, sizeof(actual), "job%u_rec%u_labels", + world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].labels, strdup(actual), 3, ASPECT_TYPE_UNKNOW); + snprintf(actual, sizeof(actual), "job%u_rec%u_exprs", + world.curjob->id, world.curjob->curscope); + hash_init(&world.curjob->recur[world.curjob->curscope].exprs, strdup(actual), 7, ASPECT_TYPE_UNKNOW); + + /* Execute parameter commands */ + str = revm_string_get(world.curjob->curcmd->param); + cur = world.curjob->curcmd; + if (revm_exec_str(str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Display execrequest failed", -1); + world.curjob->curcmd = world.curjob->recur[world.curjob->curscope].script; + if (revm_execmd() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Default command execution failed", -1); + + /* Restore previous context */ + world.curjob->curcmd = cur; + world.curjob->recur[world.curjob->curscope].script = NULL; + hash_destroy(&world.curjob->recur[world.curjob->curscope].labels); + hash_destroy(&world.curjob->recur[world.curjob->curscope].exprs); + world.curjob->curscope--; + + /* Jump to end of rewrite construct */ + revm_move_pc(world.curjob->curcmd->endlabel); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/analysis/trace.c eresi-0.0.20110516/libstderesi/analysis/trace.c --- eresi-0.8a25/libstderesi/analysis/trace.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/analysis/trace.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,188 @@ +/** +* @file libstderesi/analysis/trace.c +* @ingroup analysis +* @brief All functions that help to trace content +* +* Started Jul 2 2005 00:03:44 mxatone +* $Id: trace.c 1397 2009-09-13 02:19:08Z may $ +* +*/ +#include "libstderesi.h" + + +/* XXX: The good syntax should be : +** +** traces funcname [optional_traces_name] : add a function to a given trace +** traces funcname [optional_traces_name] : remove a function from a given trace +** traces funcname|all [optional_traces_name] : enable tracing for a function in a given trace (enabled by default after a add) +** traces funcname|all [optional_traces_name] : disable tracing for a function in a given trace +** traces tracename : create a new trace with a pool of traced functions by default +** traces tracename : delete a trace +** traces tracename : remove all functions from a given trace +** traces [optional_traces_name] : list all available traces +** +*/ + +int cmd_traces() +{ + tracecmd_t *cmd; + char *fArg; + char **sArg; + int ret = 0; + hash_t *table; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Init tracing elements */ + etrace_init_trace(); + + switch(world.curjob->curcmd->argc) + { + case 0: + traces_list(world.curjob->curfile, NULL, NULL); + break; + case 1: + table = etrace_get(world.curjob->curcmd->param[0]); + + if (!table) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown trace", -1); + + traces_list_detail(table, world.curjob->curcmd->param[0]); + break; + default: + cmd = hash_get(&traces_cmd_hash, world.curjob->curcmd->param[0]); + + if (!cmd) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown command", -1); + + fArg = NULL; + sArg = NULL; + + if (cmd->flagName > 0) + { + /* First argument is needed and doesn't submited */ + if (!world.curjob->curcmd->param[1] && cmd->flagName == 2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "First argument is needed", -1); + + fArg = world.curjob->curcmd->param[1]; + + if (cmd->flagArg > 0) + { + /* Second argument is needed and doesn't submited */ + if (!world.curjob->curcmd->param[2] && cmd->flagArg == 2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Second argument is needed", -1); + + sArg = world.curjob->curcmd->param + 2; + } + } + + ret = cmd->exec(world.curjob->curfile, fArg, sArg); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); +} + +int cmd_traceadd() +{ + u_int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Init tracing elements */ + etrace_init_trace(); + + if (world.curjob->curcmd->argc < 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need at least one function", -1); + + /* Loop on each passed functions */ + for (index = 0; index < world.curjob->curcmd->argc; index++) + { + if (traces_add(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +int cmd_traceexclude() +{ + u_int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (world.curjob->curcmd->argc < 1) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need at least one function", -1); + + /* Loop on each passed functions */ + for (index = 0; index < world.curjob->curcmd->argc; index++) + { + if (traces_exclude(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Need doxygen brief tag + */ +int cmd_tracerun() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Register binary files to work on */ + elfsh_register_working_objects(&world.curjob->loaded, + &world.shared_hash); + + if (traces_run(world.curjob->curfile, + world.curjob->curcmd->param, + world.curjob->curcmd->argc) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to run current trace", -1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Create the structure that store trace cmd informations + * @param exec function pointer + * @param flagName + * @param flagArg + */ +tracecmd_t *traces_create_CMDENT(int (*exec)(elfshobj_t *file, char *name, char **optarg), + char flagName, char flagArg) +{ + tracecmd_t *new; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + XALLOC(__FILE__, __FUNCTION__, __LINE__, new, sizeof(tracecmd_t), NULL); + new->exec = exec; + new->flagName = flagName; + new->flagArg = flagArg; + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); +} + +/** + * Add a command in sub commande hash table + * @param cmd cmd name + * @param exec function pointer + * @param flagName + * @param flagArg + * @see traces_cmd_hash + * @see traces_create_CMDENT + */ +int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + hash_add(&traces_cmd_hash, cmd, (void *) traces_create_CMDENT(exec, flagName, flagArg)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/cmd/atomic.c eresi-0.0.20110516/libstderesi/cmd/atomic.c --- eresi-0.8a25/libstderesi/cmd/atomic.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/atomic.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,530 +0,0 @@ -/** - ** @file atomic.c - ** @ingroup libstderesi - ** @brief Implement arithmetic operations - ** - ** Started on Sun Feb 9 22:43:34 2003 jfv - ** $Id: atomic.c,v 1.4 2008-02-16 12:32:27 thor Exp $ - */ -#include "libstderesi.h" - - - -/* SET command */ -int cmd_set() -{ - revmexpr_t *e1; - revmexpr_t *e2; - int error; - int errvar; - - revmexpr_t *last; - - //revmexpr_t *res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Resolve all possible case between expressions and objects */ - error = -1; - errvar = 0; - e1 = revm_expr_get(world.curjob->curcmd->param[0]); - e2 = revm_expr_get(world.curjob->curcmd->param[1]); - - /* The $_ variable is updated as well */ - last = revm_expr_get(REVM_VAR_RESULT); - if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get result variable", -2); - - /* Assignment between existing expressions */ - if (e1 && e2) - { - errvar = revm_expr_set(e1, e2); - if (errvar < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expressions", (-1)); - - revm_expr_destroy(last->label); - last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); - if (!last) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set result expression", (-1)); - - if (!world.state.revm_quiet) - revm_output(" [*] Expression set succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Fix the source expression if unresolved */ - if (!e2) - { - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create source object", (-1)); - } - - /* Fix the destination expression */ - if (!e1) - { - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1) - { - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination variable", (-1)); - } - } - - /* Set converted value */ - if (e2->value) - { - if (!e1->type && revm_convert_object(e1, e2->type->type) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert destination type expression", (-1)); - } - if (e1->type->type != e2->type->type && - revm_convert_object(e2, e1->type->type) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert source type expression", (-1)); - } - if (revm_expr_set(e1, e2) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression", (-1)); - } - } - - /* Set complex type */ - else - { - if (!e1->type) - { - revm_expr_destroy(e1->label); - e1 = revm_expr_copy(e2, world.curjob->curcmd->param[0], 0); - if (!e1) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expressions", (-1)); - } - } - else if (revm_expr_set(e1, e2) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression", (-1)); - } - } - - /* Copy the result in the last result variable */ - revm_expr_destroy(last->label); - last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); - if (!last) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set result expression", (-1)); - - /* Everything OK */ - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - - if (!world.state.revm_quiet) - revm_output(" [*] Expression set succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Comparison command */ -int cmd_cmp() -{ - revmexpr_t *e1; - revmexpr_t *e2; - char logbuf[BUFSIZ]; - int res; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First check if we are dealing with exprs */ - e1 = revm_expr_get(world.curjob->curcmd->param[0]); - e2 = revm_expr_get(world.curjob->curcmd->param[1]); - if (e1 && e2) - { - res = revm_expr_compare(e1, e2, &val); - if (res < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to compare expressions", (-1)); - goto end; - } - - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - if (!e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter has type unknown thus uncomparable", -1); - - /* Error checking */ - res = revm_expr_compare(e1, e2, &val); - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - if (res < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while setting result variable", res); - - /* Result reporting */ - end: - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Objects are %s. \n\n", (!val ? "EQUALS" : "INEQUALS")); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Bit testing command */ -int cmd_test() -{ - revmexpr_t *e1; - revmexpr_t *e2; - char logbuf[BUFSIZ]; - u_int res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - if (!e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter has type unknown thus uncomparable", -1); - - /* Perform the operation */ - if (revm_testbit(e1, e2, &res) < 0) - { - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while setting result variable", -1); - } - - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - - /* Everything was OK */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] $_ = %u \n\n", res); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/************************ Now arithmetic commands *****************/ - - - -/* ADD command */ -int cmd_add() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - o1 = e1->value; - o2 = e2->value; - - /* In case we have a hash table as parameter */ - if (o1->otype->type == ASPECT_TYPE_HASH) - { - ret = revm_hash_add(o1->parent, e2); - revm_expr_destroy(e1->label); // destroy the source alias variable - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert hash element", -1); - if (!world.state.revm_quiet) - revm_output(" [*] Element inserted succesfully\n\n"); - goto end; - } - - /* In case we have a hash table as parameter */ - else if (o1->otype->type == ASPECT_TYPE_LIST) - { - ret = revm_elist_add(o1->parent, e2); - revm_expr_destroy(e1->label); // destroy the source alias variable - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert list element", -1); - if (!world.state.revm_quiet) - revm_output(" [*] Element inserted succesfully\n\n"); - goto end; - } - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_ADD) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add elements", -1); - } - - /* Return success */ - end: - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* SUB command */ -int cmd_sub() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - o1 = e1->value; - o2 = e2->value; - - /* In case we have a hash table as parameter */ - if (o1->otype->type == ASPECT_TYPE_HASH) - { - ret = revm_hash_del(o1->parent, e2); - if (ret < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to delete hash element", -1); - } - if (!world.state.revm_quiet) - revm_output(" [*] Element deleted succesfully\n\n"); - goto end; - } - - /* In case we have a hash table as parameter */ - else if (o1->otype->type == ASPECT_TYPE_LIST) - { - ret = revm_elist_del(o1->parent, e2); - if (ret < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to delete list element", -1); - } - if (!world.state.revm_quiet) - revm_output(" [*] Element deleted succesfully\n\n"); - goto end; - } - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_SUB) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to substract elements", -1); - } - - end: - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* MUL command */ -int cmd_mul() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_MUL) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to multiply elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* DIV command */ -int cmd_div() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_DIV) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to divide elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* MOD command */ -int cmd_mod() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_MOD) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to divide elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/libstderesi/cmd/cat.c eresi-0.0.20110516/libstderesi/cmd/cat.c --- eresi-0.8a25/libstderesi/cmd/cat.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/cat.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file cat.c -** @ingroup libstderesi +* @file libstderesi/cmd/cat.c +** @ingroup cmd ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Thu Jan 04 11:26:11 2007 jfv ** -** $Id: cat.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: cat.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/color.c eresi-0.0.20110516/libstderesi/cmd/color.c --- eresi-0.8a25/libstderesi/cmd/color.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/color.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,11 +1,11 @@ /** -** @file color.c -** @ingroup libstderesi +* @file libstderesi/cmd/color.c +** @ingroup cmd ** @brief All functions about colors ** ** Started on Sept 11 2005 mxatone ** -** $Id: color.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: color.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/configure.c eresi-0.0.20110516/libstderesi/cmd/configure.c --- eresi-0.8a25/libstderesi/cmd/configure.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/configure.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file configure.c - * @ingroup libstderesi +* @file libstderesi/cmd/configure.c + * @ingroup cmd * @brief ELFsh/vm configure related code * 2006 thorkill, Asgard Labs Inc. * - * $Id: configure.c,v 1.1 2007-11-29 14:01:56 may Exp $ + * $Id: configure.c 1397 2009-09-13 02:19:08Z may $ */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/debug.c eresi-0.0.20110516/libstderesi/cmd/debug.c --- eresi-0.8a25/libstderesi/cmd/debug.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/debug.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,322 +0,0 @@ -/* -** @file debug.c -** @ingroup libstderesi -** @brief All functions dealing with libedfmt uni debugging format -** -** Started on Fev 25 2007 mxatone -** -** $Id: debug.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -char buf[BUFSIZ]; -char tmpbuf[BUFSIZ]; -char filebuf[BUFSIZ]; - -char *file_title = NULL; -char *type_title = NULL; -char *var_title = NULL; - -int matched; - -/** - * @todo Complete doxygen tag - * @param type - * @return - */ -static char *revm_debug_typename(u_int type) -{ - char *str; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch(type) - { - case EDFMT_TYPE_UNK: - str = "?"; - break; - case EDFMT_TYPE_BASIC: - str = "basic"; - break; - case EDFMT_TYPE_ARRAY: - str = "array"; - break; - case EDFMT_TYPE_PTR: - str = "ptr"; - break; - case EDFMT_TYPE_STRUCT: - str = "struct"; - break; - case EDFMT_TYPE_UNION: - str = "union"; - break; - case EDFMT_TYPE_ATTR: - str = "attr"; - break; - case EDFMT_TYPE_VOID: - str = "void"; - break; - case EDFMT_TYPE_LINK: - str = "link"; - break; - default: - str = "?????"; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, str); -} - -/** - * @todo Complete doxygen tags - * @param vars - * @param rx - * @return - */ -static int revm_debug_print_var(edfmtvar_t *vars, regex_t *rx) -{ - edfmtvar_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (var = vars; var != NULL; var = var->next) - { - snprintf(buf, BUFSIZ - 1, " %s%s %s%s %s%s => %s\n", - revm_colorfieldstr("scope:"), - revm_colornumber("%u", var->scope), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-20s", var->name), - revm_colorfieldstr("addr:"), - revm_coloraddress(XFMT, var->addr), - revm_colorstr(var->type->name)); - revm_endline(); - - if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) - { - /* Print file title only once */ - if (file_title) - { - revm_output(file_title); - file_title = NULL; - } - - /* Print var title only once */ - if (var_title) - { - revm_output(var_title); - var_title = NULL; - } - - revm_output(buf); - matched++; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @todo Complete doxygen tags - * @param types - * @param tab - * @param rx - * @return - */ - -static int revm_debug_print_type(edfmttype_t *types, u_int tab, regex_t *rx) -{ - edfmttype_t *type; - u_int index; - u_int added = 0; - u_int bufsiz = 0; - int len; - int save_matched; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (type = types; type != NULL; type = type->next) - { - buf[0] = tmpbuf[0] = 0x00; - - len = snprintf(tmpbuf, BUFSIZ - 1, - " %s%s %s%s %s%s %s%s %s%s %s%s ", - revm_colorfieldstr("type:"), - revm_colortypestr_fmt("%-10s", revm_debug_typename(type->type)), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-20s", type->name), - revm_colorfieldstr("offset:"), - revm_colornumber("%04u", type->start), - revm_colorfieldstr("size:"), - revm_colornumber("%04u", type->size), - revm_colorfieldstr("parsed:"), - revm_colortypestr_fmt("%-4s", type->parsed ? "yes" : "no"), - revm_colorfieldstr("valid:"), - revm_colortypestr_fmt("%-4s", type->valid ? "yes" : "no")); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - - if (type->type != EDFMT_TYPE_ATTR && type->parent) - { - snprintf(tmpbuf, BUFSIZ - 1, - "%s%s ", - revm_colorfieldstr("parent:"), - revm_colorstr_fmt("%-10s", type->parent->name)); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - } - - if (type->type == EDFMT_TYPE_ATTR && type->child) - { - snprintf(tmpbuf, BUFSIZ - 1, - "%s%s ", - revm_colorfieldstr("child:"), - revm_colorstr_fmt("%-10s", type->child->name)); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - } - - /* Print only if it match a submited regex */ - if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) - { - /* Print file title only once */ - if (file_title) - { - revm_output(file_title); - file_title = NULL; - } - - /* Print type title only once */ - if (type_title) - { - revm_output(type_title); - type_title = NULL; - } - - if (tab > 0 && added == 0) - { - revm_output(" .: Childs\n"); - } - else if (added > 0 && type->type != EDFMT_TYPE_ATTR && type->child) - revm_output("\n"); - - added = 1; - - for (index = 0; index < tab; index++) - revm_output(" "); - - revm_output(buf); - revm_output("\n"); - matched++; - - /* We will print childs without match anything */ - save_matched = matched; - - /* Print childs if we got some (without regex) */ - if (type->type != EDFMT_TYPE_ATTR && type->child) - revm_debug_print_type(type->child, tab+1, NULL); - - matched = save_matched; - } - else - { - /* Print childs if we got some (with regex) */ - if (type->type != EDFMT_TYPE_ATTR && type->child) - revm_debug_print_type(type->child, tab+1, rx); - } - } - - if (added) - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -static int revm_debug_unit_print_file(edfmtfile_t *files, regex_t *rx) -{ - edfmtfile_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (file = files; file != NULL; file = file->next) - { - snprintf(filebuf, BUFSIZ - 1, - "\n <: %s %s %s %s\n", - revm_colorfieldstr("File:"), - revm_colorstr_fmt("%-20s", file->name), - file->parent ? revm_colorfieldstr("Parent:") : "", - file->parent ? revm_colorstr(file->parent->name) : ""); - file_title = filebuf; - revm_endline(); - - type_title = "\n .: Types :. \n\n"; - var_title = "\n .: Vars :. \n\n"; - - revm_debug_print_type(file->types, 0, rx); - revm_debug_print_var(file->vars, rx); - - if (file->child) - revm_debug_unit_print_file(file->child, rx); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_debug() -{ - char *regexname = NULL; - regex_t rx, *submit_rx = NULL; - edfmtinfo_t *info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc > 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many arguments for debug command", -1); - - matched = 0; - - /* Support filter by regex */ - if (world.curjob->curcmd->param[0]) - { - regexname = world.curjob->curcmd->param[0]; - - if (regcomp(&rx, regexname, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - submit_rx = ℞ - } - - info = edfmt_get_uniinfo(world.curjob->curfile); - - if (!info) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No informations on this file", -1); - - type_title = "\n .: Global Types :. \n\n"; - var_title = "\n .: Global Vars :. \n\n"; - - revm_debug_print_type(info->types, 0, submit_rx); - revm_debug_print_var(info->vars, submit_rx); - - revm_debug_unit_print_file(info->files, submit_rx); - - snprintf(buf, BUFSIZ - 1, " [*] Matched %u entries \n\n", matched); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/declare.c eresi-0.0.20110516/libstderesi/cmd/declare.c --- eresi-0.8a25/libstderesi/cmd/declare.c 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/declare.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* -** @file declare.c -** @ingroup libstderesi -** @brief Command used to declare a new typed variable in the environment -** -** Started on Fri Jun 22 07:23:58 2007 jfv -** $Id: declare.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - - - -/* Declare a new typed variable */ -int cmd_declare() -{ - aspectype_t *type; - char *varname; - char buf[BUFSIZ]; - u_int curlen; - u_int curidx; - u_int curpidx; - u_int openbrace; - u_int closebrace; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (world.curjob->curcmd->argc < 3 || - strcmp(world.curjob->curcmd->param[1], "=")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for command", -1); - - /* Preliminary checks */ - type = aspect_type_get_by_name(world.curjob->curcmd->name); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown type for new variable", -1); - - /* Create the new data structure */ - bzero(buf, BUFSIZ); - - /* Create a unique string for the value of the object */ - for (openbrace = closebrace = curlen = 0, curidx = 2; - world.curjob->curcmd->param[curidx]; - curidx++, curlen += curpidx) - for (curpidx = 0; world.curjob->curcmd->param[curidx][curpidx]; - curpidx++) - switch (world.curjob->curcmd->param[curidx][curpidx]) - { - case '(': - *(buf + curlen + curpidx) = '('; - openbrace++; - break; - case ')': - *(buf + curlen + curpidx) = ')'; - closebrace++; - if (closebrace > openbrace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid closing structure for variable", -1); - break; - case ' ': - *(buf + curlen + curpidx) = ','; - break; - default: - *(buf + curlen + curpidx) = world.curjob->curcmd->param[curidx][curpidx]; - break; - } - - /* Some first checks on the value */ - if (closebrace != openbrace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid nesting structure for variable", -1); - -#if __DEBUG_EXPRS__ - fprintf(stderr, "Expression to write in variable: %s \n", buf); -#endif - - curlen = strlen(world.curjob->curcmd->param[0]); - varname = alloca(curlen + 2); - snprintf(varname, curlen + 2, "$%s", world.curjob->curcmd->param[0]); - - /* Perform the real operation now */ - if (type->childs) - { - if (!revm_expr_create(type, varname, buf)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid value for variable", -1); - } - else - { - if (!revm_simple_expr_create(type, varname, buf)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid value for variable", -1); - } - - /* Print success */ - if (!world.state.revm_quiet) - { - snprintf(buf, sizeof(buf), - " [*] Variable %s succesfully initialized \n\n", - world.curjob->curcmd->param[0]); - revm_output(buf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/define.c eresi-0.0.20110516/libstderesi/cmd/define.c --- eresi-0.8a25/libstderesi/cmd/define.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/define.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,11 +1,10 @@ /* -** @file define.c -** @ingroup libstderesi. +* @file libstderesi/cmd/define.c +** @ingroup cmd ** @brief Allow constant values to be defined on names. ** ** Start on Fri Aug 3 03:55:45 2007 jfv -** -** $Id: define.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: define.c 1397 2009-09-13 02:19:08Z may $ */ #include "libstderesi.h" @@ -25,7 +24,7 @@ if (world.curjob->curcmd->argc < 2) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid parameters", -1); - orig = revm_lookup_param(world.curjob->curcmd->param[1]); + orig = revm_lookup_param(world.curjob->curcmd->param[1], 1); if (!orig || !orig->value) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid input parameter", -1); @@ -40,19 +39,19 @@ if (world.curjob->curcmd->argc != 2) for (index = 2; index < world.curjob->curcmd->argc; index++) { - obj = revm_lookup_param(world.curjob->curcmd->param[index]); + obj = revm_lookup_param(world.curjob->curcmd->param[index], 1); if (!obj) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid input parameters", -1); - if (revm_arithmetics(orig, obj, REVM_OP_ADD) < 0) + if (revm_arithmetics(NULL, orig, obj, REVM_OP_ADD) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to add values to be defined", -1); - revm_expr_destroy(obj->label); + revm_expr_destroy_by_name(obj->label); } /* Finally put the value up */ cons->val = orig->value->immed_val.ent; - revm_expr_destroy(orig->label); + revm_expr_destroy_by_name(orig->label); hash_add(&const_hash, world.curjob->curcmd->param[0], cons); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libstderesi/cmd/eval.c eresi-0.0.20110516/libstderesi/cmd/eval.c --- eresi-0.8a25/libstderesi/cmd/eval.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/eval.c 2011-05-16 11:35:04.000000000 +0000 @@ -0,0 +1,22 @@ +/** +* @file libstderesi/cmd/eval.c +** @ingroup cmd +** +** Started on Thu Nov 13 13:03:14 2008 jfv +** $Id: eval.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + +int cmd_eval() +{ + revmexpr_t *res; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + res = revm_compute(world.curjob->curcmd->param[0]); + if (!res) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to evaluate expression", -1); + revm_expr_print(res, 0); + revm_output("\n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/cmd/exec.c eresi-0.0.20110516/libstderesi/cmd/exec.c --- eresi-0.8a25/libstderesi/cmd/exec.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/exec.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,9 +1,9 @@ /** -** @file exec.c -** @ingroup libstderesi +* @file libstderesi/cmd/exec.c +** @ingroup cmd ** Started on Tue Feb 18 13:03:14 2003 jfv ** -** $Id: exec.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: exec.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -24,6 +24,8 @@ strncat (buf, " ", BUFSIZ); strncat (buf, world.curjob->curcmd->param[i], BUFSIZ); } + + setenv("LD_PRELOAD", "", 1); switch (status = revm_system (buf)) { diff -Nru eresi-0.8a25/libstderesi/cmd/fcthijack.c eresi-0.0.20110516/libstderesi/cmd/fcthijack.c --- eresi-0.8a25/libstderesi/cmd/fcthijack.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/fcthijack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ -/* -** @file fcthijack.c -** @ingroup libstderesi -** Started on Thu Jun 19 17:02:55 2003 jfv -** -** $Id: fcthijack.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - - -/* Redirect a function on a OS independant manner */ -int cmd_hijack() -{ - elfsh_Sym *dst; - eresi_Addr addr; - int err; - char *rev; - char logbuf[BUFSIZ]; - - elfshredir_t *redir; - listent_t *actual; - int idx; - int idx2; - int printed; - eresi_Addr hookedaddr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If no parameter is given, print the redirection list */ - if (!world.curjob->curcmd->param[0]) - { - printed = 0; - - /* Simple printing */ - for (idx2 = idx = 0; idx < world.curjob->curfile->redir_hash.size; idx++) - for (actual = world.curjob->curfile->redir_hash.ent + idx; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - redir = (elfshredir_t *) actual->data; - - if (!printed) - { - revm_output("\t .::. ELFsh redirection list \n\n"); - printed = 1; - } - snprintf(logbuf, BUFSIZ, - "\t [%02u] TYPE:%-6s [" AFMT "] <%s> redirected on [" AFMT "] <%s> \n", - idx2, (redir->type == ELFSH_REDIR_CFLOW ? "CFLOW" : - redir->type == ELFSH_REDIR_ALTPLT ? "ALTPLT" : - redir->type == ELFSH_REDIR_ALTGOT ? "ALTGOT" : "UNK"), - redir->addr[0], redir->name[0], redir->addr[1], redir->name[1]); - - revm_output(logbuf); - idx2++; - } - - /* End message */ - if (!printed) - revm_output("\t .::. No redirection performed on current file \n\n"); - else - revm_output("\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Some sanity checks first */ - if (!world.curjob->curcmd->param[1]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Redirection destination needed", (-1)); - - /* Resolve destination parameter */ - dst = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]); - if (!dst) - { - elfsh_toggle_mode(); - dst = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]); - elfsh_toggle_mode(); - } - - /* If not found */ - if (dst == NULL) - { - err = sscanf(world.curjob->curcmd->param[1], XFMT, - (eresi_Addr *) &addr); - - /* If the hook function is not supplied as an address */ - if (err != 1 && elfsh_dynamic_file(world.curjob->curfile)) - { - elfsh_setup_hooks(); - - /* First bootstrap ALTPLT if not done */ - err = elfsh_copy_plt(world.curjob->curfile, - elfsh_get_pagesize(world.curjob->curfile)); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed at copying PLT", (-1)); - - /* Request a PLT entry since we have no symbol yet */ - dst = elfsh_request_pltent(world.curjob->curfile, - world.curjob->curcmd->param[1]); - if (dst) - addr = dst->st_value; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT entry request failed", (-1)); - } - - /* Insert a symbol on the requested address to avoid this */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need a symbol to redirect", -1); - - rev = revm_reverse(world.curjob->curfile, addr); - } - - /* The first resolution worked, we take the address */ - else - { - addr = dst->st_value; - rev = NULL; - } - -#if __DEBUG_HIJACK__ - printf("[cmd_hijack] Resolved %s as %08X \n", - world.curjob->curcmd->param[1], addr); -#endif - - /* Hijack function */ - err = elfsh_hijack_function_by_name(world.curjob->curfile, - ELFSH_HIJACK_TYPE_FLOW, - world.curjob->curcmd->param[0], - addr, &hookedaddr); - - /* Last checks */ - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function redirection failed", (-1)); - - /* Add it to redirection hash table */ - redir = revm_create_REDIR((u_char) err, world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], hookedaddr, addr); - hash_add(&world.curjob->curfile->redir_hash, - world.curjob->curcmd->param[0], - (void *) redir); - - /* Print final information */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [*] Function %s redirected to addr " XFMT " <%s> \n\n", - world.curjob->curcmd->param[0], (eresi_Addr) addr, - (rev == NULL ? world.curjob->curcmd->param[1] : rev)); - revm_output(logbuf); - } - if (rev != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,rev); - - /* Everything is ok */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/fileops.c eresi-0.0.20110516/libstderesi/cmd/fileops.c --- eresi-0.8a25/libstderesi/cmd/fileops.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/fileops.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,239 +0,0 @@ -/* -** @file fileops.c -** @ingroup libstderesi -** Started on Thu Feb 13 04:06:45 2003 jfv -** Last update Wed Mar 10 12:31:49 2004 jfv -** -** $Id: fileops.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - -/* Write command */ -int cmd_write() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - elfshsect_t *cur; - void *dat; - int size; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Needs 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameters must be initialized scalar objects", -1); - o1 = e1->value; - o2 = e2->value; - - /* Type checking */ - if (o1->otype->type != ASPECT_TYPE_RAW && o1->otype->type != ASPECT_TYPE_STR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameters must be STR or RAW typed", - -1); - else if (o1->immed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Dest. param. must not be a constant", -1); - - /* Convert Integers into raw data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - if (revm_convert_object(e2, ASPECT_TYPE_RAW) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert dest object to RAW", (-1)); - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - cur = o2->parent; - size = (o2->immed ? o2->size : o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : - world.curjob->curcmd->param[2] ? - revm_lookup_index(world.curjob->curcmd->param[2]) : - cur->shdr->sh_size - o2->off); - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - /* Write the destination buff */ - if (o1->set_data(o1->parent, o1->off, dat, size, o1->sizelem) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set data", (-1)); - - /* Print stuff and return */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Written %u bytes \n\n", size); - revm_output(logbuf); - } - - if (!o2->perm) - XFREE(__FILE__, __FUNCTION__, __LINE__,o2); - if (!o1->perm) - XFREE(__FILE__, __FUNCTION__, __LINE__,o1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Append command : 2 parameters, a section and the string to be appended */ -int cmd_append() -{ - elfshsect_t *sect; - revmobj_t *o2; - revmexpr_t *e2; - elfshsect_t *cur; - u_int size; - char *dat; - int index = -1; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch section using the first argument */ - if (revm_isnbr(world.curjob->curcmd->param[0])) - { - index = atoi(world.curjob->curcmd->param[0]); - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert section value !", -1); - sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); - } - else - sect = elfsh_get_section_by_name(world.curjob->curfile, world.curjob->curcmd->param[0], - NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested section", -1); - - /* Object retreive */ - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2 || !e2->value || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination object", (-1)); - o2 = e2->value; - - /* Convert Integers into string data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - { - revm_convert_object(e2, ASPECT_TYPE_RAW); - if (o2->otype->type != ASPECT_TYPE_RAW || !o2->perm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination object", (-1)); - } - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - cur = o2->parent; - size = (o2->immed ? o2->size : - o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : - cur->shdr->sh_size - o2->off); - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - /* Append the data for real */ - if (elfsh_append_data_to_section(sect, dat, size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to append data to section", (-1)); - - /* Print msg */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Appended %u bytes to section %s\n\n", size, sect->name); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Extend command : 2 parameters, a section and the extansion size */ -int cmd_extend() -{ - elfshsect_t *sect; - u_int size; - char *new_data; - int index = -1; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch section using first argument */ - if (revm_isnbr(world.curjob->curcmd->param[0])) - { - index = atoi(world.curjob->curcmd->param[0]); - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert section value", - -1); - sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); - } - else - sect = elfsh_get_section_by_name(world.curjob->curfile, - world.curjob->curcmd->param[0], - NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested section", -1); - size = atoi(world.curjob->curcmd->param[1]); - - /* Extend the section with NUL bytes */ - if (!size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Extend size cannot be 0", -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new_data, size, -1); - - if (elfsh_append_data_to_section(sect, new_data, size) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,new_data); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to append data", -1); - } - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Extended %s by %u bytes\n\n", sect->name, size); - revm_output(logbuf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Request to fixup the bss from command line */ -int cmd_fixup() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curfile == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (elfsh_fixup_bss(world.curjob->curfile) != NULL) - { - revm_output(" [*] BSS fixed up\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to fixup BSS", (-1)); -} - diff -Nru eresi-0.8a25/libstderesi/cmd/flow.c eresi-0.0.20110516/libstderesi/cmd/flow.c --- eresi-0.8a25/libstderesi/cmd/flow.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/flow.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/** -** @file flow.c -** @ingroup libstderesi -** Original author : sk for the modflow of elfsh -** -** @brief Merged in the ELFsh VM by the ELFsh crew. -** -** -** $Id: flow.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/***************************************************************************** - * High level block analysis. - * - * this function builds a linked list of function - * which each contains a list linked of blocks - * - * for each block, - * - * until a new block starting a function, current blocks - * are supposed to be part of current function - * - ************************************************************************/ - - -void elfsh_help() -{ - printf(" flow \n" - " Launch control flow analysis. \n" - " \n" - " graph {+} \n" - " Dump graph in file from starting \n" - " address min to ending address \n" - " ie: graph debfunc.gvz func +200 \n" - " ie: graph 0x805de40 0x805ff00 \n" - " \n" - " inspect \n" - " \n" - " flowjack \n" - " All relative call to oldsymbol \n" - " are hijacked to newsymbol \n" - " \n" - " addgoto \n" - " 'redirect' for functions called \n" - " trough a pointer \n" - " \n"); -} - - -/** - * Manually add function pointer information - */ -int cmd_addgoto(void) -{ - if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) - return (-1); - - printf(" [*] at %s goto %s\n", - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - - hash_del(&goto_hash, world.curjob->curcmd->param[0]); - hash_add(&goto_hash, world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - return (0); -} - -/** - * Print the control information - */ -int cmd_control() -{ - elfshsect_t *sect; - elfshobj_t *current; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - current = world.curjob->curfile; - sect = elfsh_get_section_by_name(current, - ELFSH_SECTION_NAME_EDFMT_BLOCKS, - 0, 0, 0); - if (!sect || !hash_size(&world.mjr_session.cur->blkhash)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow section found", -1); - - mjr_blocks_display(world.mjr_session.cur, 1); - revm_output("\n [*] Control flow information dumped \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Change the graph verbose level */ -int cmd_setgvl(void) -{ - world.state.revm_gvl = atoi(world.curjob->curcmd->param[0]); - return (0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/flowjack.c eresi-0.0.20110516/libstderesi/cmd/flowjack.c --- eresi-0.8a25/libstderesi/cmd/flowjack.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/flowjack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/* -** @file flowjack.c -** @ingroup libstderesi -** Author : -** -** December 10 2006 : merged from modflow to the ELFsh vm -may -** December 31 2006 : factored and cleaned code -may -** -** $Id: flowjack.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/* Perform hijack of basic blocks */ -int cmd_flowjack(void) -{ - container_t *cntnr_to_hijack; - mjrblock_t *to_hijack, *cal; - mjrlink_t *caller; - unsigned long addr; - elfshsect_t *sect; - elfsh_Sym *sym; - char *buffer; - char *name; - int index; - asm_instr ins; - elfsh_SAddr off; - unsigned long new_addr; - u_int value; - elfshobj_t *file; - char *param; - unsigned int size; - unsigned int foff; - - list_t *linklist; - listent_t *listent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_EDFMT_BLOCKS, - 0, 0, 0); - - if (!sect || !world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Lookup parameters */ - file = world.curjob->curfile; - param = world.curjob->curcmd->param[0]; - sym = elfsh_get_metasym_by_name(file, param); - if (sym) - addr = sym->st_value; - else - addr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]))) - new_addr = sym->st_value; - else - new_addr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - /* Errors cases */ - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve first parameter", -1); - if (!new_addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve second parameter", -1); - - /* Retreive bloc to be hijacked */ - printf(" * patch blocks calling %08x\n", (int) addr); - cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, 0); - if (!cntnr_to_hijack) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to match hijacked block", -1); - - /* For each caller, modify the location beeing called */ - linklist = cntnr_to_hijack->inlinks; - for (buffer = 0, listent = linklist->head; listent; listent = listent->next) - { - caller = (mjrlink_t *) listent->data; - name = elfsh_reverse_metasym(world.curjob->curfile, addr, &off); - printf(" [*] patching block %s + " DFMT "\n", name, off); - - cal = mjr_lookup_container(world.mjr_session.cur, caller->id)->data; - - cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, cal->vaddr, 1); - to_hijack = cntnr_to_hijack->data; - - size = to_hijack->size - (cal->vaddr - to_hijack->vaddr); - foff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, cal->vaddr); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, buffer, size, -1); - elfsh_raw_read(world.curjob->curfile, foff, buffer, size); - asm_read_instr(&ins, (u_char *) buffer, size, &world.proc); - - puts(" [*] would patch -> "); - name = elfsh_reverse_metasym(world.curjob->curfile, cal->vaddr, &off); - - index = cal->vaddr - to_hijack->vaddr; - revm_instr_display(-1, 0, cal->vaddr, 0, size, name, off, buffer); - - /* Patching instruction operand */ - asm_operand_get_immediate(&ins, 1, 0, &value); - if (ins.op[0].type == ASM_OTYPE_JUMP) - { - value = cal->vaddr + asm_instr_len(&ins); - value = new_addr - value; - asm_operand_set_immediate(&ins, 1, 0, &value); - } - else - { - puts(" ! operand type not supported"); - continue; - } - - /* display for debug */ - puts(" * patched ->"); - revm_instr_display(-1, 0, cal->vaddr, 0, size, name, off, buffer); - elfsh_raw_write(world.curjob->curfile, foff, buffer, size); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - diff -Nru eresi-0.8a25/libstderesi/cmd/foreach.c eresi-0.0.20110516/libstderesi/cmd/foreach.c --- eresi-0.8a25/libstderesi/cmd/foreach.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/foreach.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,300 +0,0 @@ -/* -** @file foreach.c -** @ingroup libstderesi -** @brief Implement the iteration on arrays, lists, and hash tables. -** -** Started on Wed Feb 28 19:19:04 2007 jfv -** -** $Id: foreach.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/* Start an iteration */ -int cmd_foreach() -{ - revmexpr_t *indexpr; - revmobj_t *var; - u_char flag; - char **keys; - int keynbr; - hash_t *table; - list_t *list; - int index; - void *elem; - int infbound; - int upbound; - u_int typeid; - eresi_Addr lastvalue; - char *setname; - revmexpr_t *setexpr; - revmobj_t *setobj; - char *typename; - char *indname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - table = NULL; - list = NULL; - - /* Depends the mode we are in */ - flag = (world.curjob->curcmd->argc == 3 ? 1 : - world.curjob->curcmd->use_regx[0] ? 2 : 3); - - /* Create or get the induction variable */ - indexpr = revm_lookup_var(world.curjob->curcmd->param[0]); - if (!indexpr) - { - if (world.curjob->curcmd->listidx != REVM_IDX_UNINIT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find induction variable", -1); - var = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 1, 0); - indexpr = revm_expr_create_from_object(var, world.curjob->curcmd->param[0]); - } - else - var = indexpr->value; - - /* Perform subcommand */ - switch (flag) - { - /* foreach elmvar of list/hash [as regx] */ - case 1: - case 2: - - /* First try to lookup the container name */ - setexpr = revm_lookup_param(world.curjob->curcmd->param[2]); - setobj = (setexpr && setexpr->type ? setexpr->value : NULL); - setname = NULL; - if (setobj) - { - if (setobj->otype->type == ASPECT_TYPE_STR) - setname = (setobj->immed ? setobj->immed_val.str : - setobj->get_name(setobj->root, setobj->parent)); - else if (setobj->otype->type == ASPECT_TYPE_HASH || - setobj->otype->type == ASPECT_TYPE_LIST) - { - setname = (setobj->kname ? setobj->kname : setobj->hname); - if (!setname && setobj->otype->isptr) - { - if (setobj->otype->type == ASPECT_TYPE_HASH) - { - table = (hash_t *) (setobj->immed ? setobj->immed_val.ent : - setobj->get_obj(setobj->parent)); - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find table name", -1); - setname = table->name; - } - else if (setobj->otype->type == ASPECT_TYPE_LIST) - { - list = (list_t *) (setobj->immed ? setobj->immed_val.ent : - setobj->get_obj(setobj->parent)); - if (!list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find list name", -1); - setname = list->name; - } - } - } - } - else - setname = world.curjob->curcmd->param[2]; - if (!setname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find iterator name", -1); - setname = strdup(setname); - if (setexpr) - revm_expr_destroy(setexpr->label); - - fprintf(stderr, "Found setname = %s in foreach ! \n", setname); - - /* Try to find a hash or a list out of this variable */ - table = hash_find(setname); - if (!table) - { - list = elist_find(setname); - if (!list) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find hash table", -1); - } - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT && elist_linearity_get(list)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot iterate again on linearly typed list", -1); - } - elist_linearity_set(list, 1); - keys = elist_get_keys(list, &keynbr); - world.curjob->iter.list = list; - } - else - { - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT && hash_linearity_get(table)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot iterate again on linearly typed table", -1); - } - hash_linearity_set(table, 1); - keys = hash_get_keys(table, &keynbr); - } - - /* Use the correct keys array index depending on foreach iteration nbr */ - nextelem: - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT) - { - index = 0; - world.curjob->curcmd->listidx += 2; - } - - /* The induction variable existed already : record its previous value into the parent list */ - else - { - index = world.curjob->curcmd->listidx++; - if (flag != 2 || !regexec(&world.curjob->curcmd->regx[0], keys[index - 1], 0, 0, 0)) - { - - /* No need to back-update if the data type is complex */ - if (indexpr->type && aspect_type_simple(indexpr->type->type) && !indexpr->type->next) - { - lastvalue = (var->immed ? var->immed_val.ent : var->get_obj(var->parent)); - if (table) - hash_set(table, keys[index - 1], (void *) lastvalue); - else - elist_set(list, keys[index - 1], (void *) lastvalue); - //printf("back-assignment into the list for element %s at index %u of value %X \n", - //keys[index - 1], index - 1, lastvalue); - } - } - } - - /* Export iteration information to revmjob so it can be used in other commands */ - if (!table && list) - { - world.curjob->iter.curindex = &world.curjob->curcmd->listidx; - world.curjob->iter.curkey = keys[index]; - world.curjob->iter.curname = world.curjob->curcmd->param[0]; - } - - /* Bound check : go to the loop end when necessary */ - if (index >= keynbr) - { - if (!world.curjob->curcmd->endlabel) - cmd_quit(); - if (table) - hash_linearity_set(table, 0); - else if (list) - elist_linearity_set(list, 0); - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - revm_move_pc(world.curjob->curcmd->endlabel); - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Get the next elem if the current one is not matching */ - if (flag == 2 && regexec(&world.curjob->curcmd->regx[0], - keys[index], 0, 0, 0)) - goto nextelem; - - /* The element matched, process it */ - if (table) - { - elem = hash_get(table, keys[index]); - typeid = table->type; - } - else - { - elem = elist_get(list, keys[index]); - typeid = list->type; - } - - /* If the element is already an expression, copy it to the induction variable */ - if (typeid == ASPECT_TYPE_EXPR) - { - indname = strdup(indexpr->label); - revm_expr_destroy(indexpr->label); - indexpr = revm_expr_copy((revmexpr_t *) elem, indname, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* If the element is not an expression, act depending on its type */ - if (!indexpr->type || indexpr->type->type != typeid) - revm_convert_object(indexpr, typeid); - if (indexpr->type->type != typeid) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for induction variable", -1); - } - - /* Update depending if the type is simple or complex */ - if (aspect_type_simple(indexpr->type->type) && !indexpr->type->next) - { - var->immed = 1; - var->immed_val.ent = (eresi_Addr) elem; - //fprintf(stderr, "Setting indvar->immed_val.ent = %X \n", (eresi_Addr) elem); - } - else - { - typename = indexpr->type->name; - revm_expr_destroy(world.curjob->curcmd->param[0]); - indexpr = revm_inform_type_addr(typename, world.curjob->curcmd->param[0], - (eresi_Addr) elem, NULL, 0, 1); - if (!indexpr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create expression for induction variable", -1); - } - } - break; - - /* foreach idxvar of minint until maxint */ - case 3: - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT) - { - infbound = revm_lookup_index(world.curjob->curcmd->param[2]); - world.curjob->curcmd->listidx = infbound + 1; - } - else - infbound = world.curjob->curcmd->listidx++; - - upbound = revm_lookup_index(world.curjob->curcmd->param[4]); - - /* Bound check */ - if (infbound >= upbound) - { - if (!world.curjob->curcmd->endlabel) - cmd_quit(); - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Set the induction variable */ - if (!indexpr->type || indexpr->type->type != ASPECT_TYPE_INT) - revm_convert_object(indexpr, ASPECT_TYPE_INT); - if (!indexpr->type || indexpr->type->type != ASPECT_TYPE_INT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for induction variable", -1); - - var->immed = 1; - var->immed_val.word = infbound++; - break; - } - - /* Support when until goes decreasing */ - /* Here set the induction variable (3 cases : first, iterating, last) */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - /* End an iteration */ - int cmd_forend() - { - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/graph.c eresi-0.0.20110516/libstderesi/cmd/graph.c --- eresi-0.8a25/libstderesi/cmd/graph.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/graph.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,717 +0,0 @@ -/* -** @file graph.c -** @ingroup libstderesi -** @brief Dump graphviz output -** -** Started : Fri Mar 7 07:18:03 2003 jfv -** Updated : Fri Dec 10 02:04:19 2006 jfv -** -** $Id: graph.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -static hash_t dumped; - - -/** - * Generate the legend for the graph in HTML format - * @param fd - * @param fnc - * @param min - * @param max - */ -void revm_graph_legend(int fd, char *fnc, u_int min, u_int max) -{ - char buf[BUFSIZ]; - - snprintf(buf,BUFSIZ-1,"graph [label=<\n\ - \n\ - \ - \ - \n\ - \n\ - \n\ - \n\ - \n\ -
Legend:%s
min: 0x%08Xmax: 0x%08X
COND TRUECOND FALSE
CALLRET
DELAY
\n\ - >]\n",fnc, min, max, - LNK_COLOR_TRUE, - LNK_COLOR_FALSE, - LNK_COLOR_CALL, - LNK_COLOR_RET, - LNK_COLOR_DELAY); - - write(fd,buf,strlen(buf)); - -} - - -/** - * Disassemble a block - * @param fd - * @param blk - */ -void revm_disasm_block(int fd, mjrblock_t *blk) -{ - char *buffer; - char *name; - elfsh_SAddr off; - u_int index = 0; - int revm_quiet,revm_colors; - int ret,cur; - u_int foffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_quiet = world.state.revm_quiet; - world.state.revm_quiet = 0; - revm_colors = nocolor; - nocolor = 0; - cur = 1; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, blk->size, ); - foffset = elfsh_get_foffset_from_vaddr(world.curjob->curfile, blk->vaddr); - ret = elfsh_raw_read(world.curjob->curfile, foffset, buffer, blk->size); - if (ret > 0) - { - name = elfsh_reverse_metasym(world.curjob->curfile, blk->vaddr, &off); - while ((index < blk->size) && cur) - { - cur = revm_instr_display(fd, index, blk->vaddr, 0, blk->size, - name, index + off, buffer); - if (cur <= 0) - goto end; - - index += cur; - write(fd, "\\l", 2); - revm_endline(); - } - } - end: - XFREE(__FILE__, __FUNCTION__, __LINE__,buffer); - world.state.revm_quiet = revm_quiet; - nocolor = revm_colors; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Create .dot -> .png files and execute the graphic viewer - * @param dotfile - */ -int revm_graph_compile_graphic(char *dotfile) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if ((int) config_get_data(ERESI_VMCONFIG_GRAPH_AUTOBUILD)) - { - snprintf(buf,sizeof(buf),"dot -Tpng -o %s.png %s",dotfile,dotfile); - system(buf); - - if ((int) config_get_data(ERESI_VMCONFIG_GRAPH_AUTOVIEW)) - { - snprintf(buf,sizeof(buf), - "%s %s.png", - (char *)config_get_data(ERESI_VMCONFIG_GRAPH_VIEWCMD), - dotfile); - system(buf); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(1)); -} - -/** - * Returns converted path name into string without '.' - * @param path - */ -char *revm_flattern_path(char *path) -{ - char *r,*p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - r = strdup(path); - p = r; - - while(*p != '\0') - { - if (*p == '.') - *p = '_'; - p++; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,r); -} - - - -/** - * Prepare directory tree for graph storage - */ -int revm_prepare_storage_dir(void) -{ - mode_t omode = S_IRWXU | S_IRWXG | S_IRWXO; - char *token, *brkt; - char *sep = "/"; - char tmp[BUFSIZ], path[BUFSIZ]; - u_int cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cur = 0; - memset(tmp,0x00, BUFSIZ); - memset(path,0x00, BUFSIZ); - - snprintf(path,BUFSIZ-1,"%s/%s",(char *)config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH), - revm_flattern_path(world.mjr_session.cur->obj->name)); - - for (token = strtok_r(path,sep,&brkt); - token; - token = strtok_r(NULL,sep,&brkt)) - { - tmp[cur++] = '/'; - strncat(tmp, token, strlen(token)); - cur += strlen(token); - - mkdir(tmp, omode); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - -/** - * This function prepares a path string to .dot file - * @param opt - * @param prefix - * @return - */ -char *revm_get_dotfile_name(char *opt,char *prefix) -{ - int namelen; - char *dotfile; - char *str1; - char *str2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!opt) - opt = "dump"; - if (!prefix) - prefix = ""; - - str1 = (char *) config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH); - str2 = revm_flattern_path(world.mjr_session.cur->obj->name); - namelen = strlen(str1) + strlen(str2) + strlen(opt) + strlen(prefix) + 32; - - XALLOC(__FILE__,__FUNCTION__,__LINE__, dotfile, namelen, NULL); - if (!revm_prepare_storage_dir()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot prepare storage directory", NULL); - - snprintf(dotfile,namelen,"%s%s/%s-%s.dot", - (char *)config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH), - revm_flattern_path(world.mjr_session.cur->obj->name), - prefix,opt); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dotfile)); -} - -/** - * Converts string to vaddr by looking up the symbol name - * or converting it to hex - * @param s - * @return - */ -u_int revm_get_vaddr(char *s) -{ - elfsh_Sym *sym; - u_int min; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get parameters */ - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile,s))) - min = sym->st_value; - else - min = strtoul(s, 0, 16); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(min)); -} - -/** - * Returns next function vaddress - */ -u_int revm_get_next_function_vaddr(u_int min) -{ - container_t *cntnr; - u_int max,tmp,ltmp; - char **keys; - int idx,fnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.mjr_session.cur->funchash, &fnbr); - max = ltmp = min; - - for (idx = 0; idx < fnbr; idx++) - { - cntnr = hash_get(&world.mjr_session.cur->funchash, keys[idx]); - tmp = ((mjrfunc_t *)cntnr->data)->vaddr; - - if (((max == min) || (tmp < max)) && (tmp > min)) - max = tmp; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(max)); -} - -/** - * Get color name for string, it does check alert - * and lookups the color name - */ -char *revm_get_colored_str(char *str,int type) -{ - color_t *t; - int idx,c,t2; - char **keys; - char *color; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - color = FNC_COLOR_DEFAULT; - - if (world.state.revm_use_alert && - !regexec(&world.state.revm_alert, str, 0, 0, 0)) - { - t = hash_get(&t_color_hash, "warnstring"); - - keys = hash_get_keys(&fg_color_hash, &idx); - - for (c = 0; c < idx; c++) - { - t2 = (int) hash_get(&fg_color_hash, keys[c]); - if (t2 == t->fground) - { - snprintf(buf, sizeof(buf), "\"%s\"", keys[c]); - color = strdup(buf); - break; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); - } - - switch (type) - { - case GVZ_NODE_EPOINT: - color = FNC_COLOR_EPOINT; - break; - case GVZ_NODE_MAIN: - color = FNC_COLOR_MAIN; - break; - case GVZ_NODE_INTERN: - color = FNC_COLOR_INTERN; - break; - case GVZ_NODE_EXTERN: - color = FNC_COLOR_EXTERN; - break; - case GVZ_NODE_UNKNOWN: - color = GVZ_COLOR_CORAL; - break; - default: - color = FNC_COLOR_DEFAULT; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); -} - -int revm_graph_get_function_type(mjrfunc_t *fnc) -{ - elfshsect_t *parent; - int ftype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - parent = elfsh_get_parent_section(world.curjob->curfile, fnc->vaddr, NULL); - - if (fnc->vaddr == elfsh_get_entrypoint(elfsh_get_hdr(world.mjr_session.cur->obj))) - ftype = GVZ_NODE_EPOINT; - else if ((parent == NULL)||(parent->name == NULL)) - ftype = GVZ_NODE_UNKNOWN; - else if (parent && parent->name && strcmp(".text",parent->name)) - ftype = GVZ_NODE_EXTERN; - else - ftype = GVZ_NODE_INTERN; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ftype); -} - -/* A recursive function for graphing in dot format */ -int revm_graph_blocks(container_t *cntnr, - int fd, - eresi_Addr min, - eresi_Addr max, - int dir, - int maxdepth, - int curdepth) -{ - mjrblock_t *blk,*cblk; - mjrlink_t *lnk; - char buf[BUFSIZ]; - char *vaddr_str; - char *col_arrow; - container_t *nextcnt; - mjrblock_t *nextblk; - list_t *linklist; - listent_t *curent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - blk = (mjrblock_t *) cntnr->data; - - vaddr_str =_vaddr2str(blk->vaddr); - - if (hash_get(&dumped, vaddr_str) || curdepth == maxdepth) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - hash_add(&dumped, vaddr_str, cntnr); - - linklist = cntnr->outlinks; - - snprintf(buf, sizeof(buf), - "\"" AFMT "\" [shape=\"box\" color=%s label=\"<" AFMT ">:\\l", - blk->vaddr, "\"grey\"", blk->vaddr); - - write(fd,buf,strlen(buf)); - - revm_disasm_block(fd, blk); - - snprintf(buf, sizeof(buf), "\"];\n"); - - write(fd,buf,strlen(buf)); - - /* Print all links */ - for (curent = linklist->head; curent; curent = curent->next) - { - lnk = (mjrlink_t *) curent->data; - cblk = (mjrblock_t *) mjr_lookup_container(world.mjr_session.cur, lnk->id)->data; - - switch (lnk->type) - { - case MJR_LINK_BLOCK_COND_TRUE: - col_arrow = LNK_COLOR_TRUE; - break; - case MJR_LINK_BLOCK_COND_FALSE: - col_arrow = LNK_COLOR_FALSE; - break; - case MJR_LINK_BLOCK_COND_ALWAYS: - continue; - case MJR_LINK_FUNC_CALL: - col_arrow = LNK_COLOR_CALL; - break; - case MJR_LINK_FUNC_RET: - col_arrow = LNK_COLOR_RET; - break; - case MJR_LINK_TYPE_DELAY: - col_arrow = LNK_COLOR_DELAY; - break; - default: - fprintf(D_DESC, "[D] %s 1st: lnk->type:%d\n", __FUNCTION__, lnk->type); - col_arrow = "\"black\""; - break; - } - - snprintf(buf, sizeof(buf), "\"" AFMT "\" -> \"" AFMT "\" [color=%s];\n", - blk->vaddr, cblk->vaddr, col_arrow); - -#if __DEBUG_GRAPH__ - fprintf(D_DESC,"[D] %s: " AFMT " -> " AFMT " %d\n", - __FUNCTION__, blk->vaddr, cblk->vaddr, lnk->type); -#endif - - write(fd, buf, strlen(buf)); - } - - /* Now recurse on the children */ - for (curent = linklist->head; curent; curent = curent->next) - { - lnk = (mjrlink_t *) curent->data; - if (lnk->type == MJR_LINK_BLOCK_COND_ALWAYS) - continue; - - nextcnt = mjr_lookup_container(world.mjr_session.cur, lnk->id); - nextblk = (mjrblock_t *) nextcnt->data; - - if ((nextblk->vaddr >= min) && (nextblk->vaddr <= max)) - revm_graph_blocks(nextcnt, fd, min, max, 0, 0, curdepth + 1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * This function does dump a function container in graphviz format - * @param fd - * @param direction input/output - * @param type 0 - we are dumping only out, 1 - we generate .dot file for - * both directions - * @param maxdepth - * @param curdepth - */ -int revm_graph_function(container_t *cntnr, - int fd, - int direction, - int type, - int maxdepth, - int curdepth) -{ - elfsh_SAddr offset; - int ftype; - mjrfunc_t *fnc, *tmpfnc; - mjrlink_t *curlnk; - char *n1, *n2, *vaddr_str; - char buf[BUFSIZ]; - list_t *linklist; - listent_t *curent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No container found", -1); - - fnc = (mjrfunc_t *)cntnr->data; - vaddr_str =_vaddr2str(fnc->vaddr); - - if (hash_get(&dumped, vaddr_str) || curdepth == maxdepth) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - hash_add(&dumped, vaddr_str, cntnr); - - n1 = elfsh_reverse_metasym(world.curjob->curfile,fnc->vaddr, &offset); - - ftype = revm_graph_get_function_type(fnc); - - snprintf(buf, sizeof(buf), "\"%s\" [color=%s];\n", - (n1 ? n1 : fnc->name), - revm_get_colored_str((n1) ? n1 : fnc->name, ftype)); - - write(fd,buf,strlen(buf)); - - linklist = mjr_link_get_by_direction(cntnr,direction); - - /* Print all links of this function */ - for (curent = linklist->head; curent; curent = curent->next) - { - curlnk = (mjrlink_t *) curent->data; - tmpfnc = (mjrfunc_t *) mjr_lookup_container(world.mjr_session.cur,curlnk->id)->data; - - /* resolve the symbols */ - n2 = elfsh_reverse_metasym(world.curjob->curfile, tmpfnc->vaddr, &offset); - ftype = revm_graph_get_function_type(tmpfnc); - - if (type) - { - snprintf(buf, sizeof(buf), - "\"%s\" [color=%s];\n", - (n2) ? n2 : tmpfnc->name, - revm_get_colored_str((n2) ? n2 : tmpfnc->name, ftype)); - - write(fd,buf,strlen(buf)); - } - - if (direction == CONTAINER_LINK_OUT) - snprintf(buf,sizeof(buf), - "\"%s\" -> \"%s\";\n", - (n1) ? n1 : fnc->name, - (n2) ? n2 : tmpfnc->name); - - else if (direction == CONTAINER_LINK_IN) - { - snprintf(buf,sizeof(buf), - "\"%s\" -> \"%s\";\n", - (n2) ? n2 : tmpfnc->name, - (n1) ? n1 : fnc->name); - } - - write(fd,buf,strlen(buf)); - } - - /* Recurse on children */ - for (curent = linklist->head; curent; curent = curent->next) - { - curlnk = (mjrlink_t *) curent->data; - revm_graph_function(mjr_lookup_container(world.mjr_session.cur, curlnk->id), - fd, direction, type, maxdepth, curdepth + 1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Open the file for putting the dot description - * @param dotfile - * @param fd - * @returm - */ -int revm_open_dot_file(char *dotfile, int *fd) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - printf(" [*] .dot file: %s\n", dotfile); - - *fd = open(dotfile, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (*fd == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create graphviz file", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - -u_int revm_get_min_param(void) -{ - revmexpr_t *expr; - revmobj_t *var; - u_int min; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - expr = revm_lookup_var(world.curjob->curcmd->param[1]); - if (expr && expr->value) - { - var = expr->value; - min = revm_get_vaddr(var->immed ? var->immed_val.str : - var->get_name(var->root, var->parent)); - } - else - min = revm_get_vaddr(world.curjob->curcmd->param[1]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (min)); -} - - -/* Graph the binary */ -int cmd_graph(void) -{ - container_t *cntnr; - int fd; - char buf[BUFSIZ]; - u_int min; - u_int max; - char *dotfile; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_init(&dumped, "dumped_containers", mjrHashVerySmall, ASPECT_TYPE_UNKNOW); - - /* Some preliminary checks */ - if (!world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Select use depending on number of arguments */ - switch (world.curjob->curcmd->argc) - { - case 0: - - dotfile = revm_get_dotfile_name(NULL,"object"); - - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); - write(fd,buf,strlen(buf)); - - printf(" [*] Dumping %d functions\n", - world.mjr_session.cur->funchash.elmnbr); - - cntnr = mjr_get_container_by_vaddr(world.mjr_session.cur, - world.mjr_session.cur->obj->hdr->e_entry, - ASPECT_TYPE_FUNC); - - revm_graph_function(cntnr,fd,CONTAINER_LINK_OUT,0, 0, 1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - break; - - case 2: - - if (strcmp("func",world.curjob->curcmd->param[0]) == 0) - { - /* resolve the block vaddr */ - min = revm_get_min_param(); - cntnr = hash_get(&world.mjr_session.cur->funchash, - _vaddr2str(min)); - - if (!cntnr) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Function not found",-1); - - - dotfile = revm_get_dotfile_name(_vaddr2str(min),"function"); - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); - write(fd,buf,strlen(buf)); - - revm_graph_function(cntnr,fd,CONTAINER_LINK_IN,1, 0, 1); - revm_graph_function(cntnr,fd,CONTAINER_LINK_OUT,1, 0, 1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - } - else if (strcmp("bloc",world.curjob->curcmd->param[0]) == 0) - { - min = revm_get_min_param(); - max = revm_get_next_function_vaddr(min); - - cntnr = hash_get(&world.mjr_session.cur->blkhash, - _vaddr2str(min)); - - if (!cntnr) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Function not found",-1); - - printf(" [D] MIN:%x MAX:%x\n",min,max); - - dotfile = revm_get_dotfile_name(_vaddr2str(min),"block"); - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n"); - write(fd,buf,strlen(buf)); - - revm_graph_legend(fd, "DEFAULT", min, max); - revm_graph_blocks(cntnr,fd,min,max,0,0,1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - printf(" [*] Dump function blocks\n"); - } - else - { - printf(" [!] Use help\n"); - } - - break; - - default: - printf(" [!] use help \n"); - - } - - hash_empty("dumped_containers"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/hammer.c eresi-0.0.20110516/libstderesi/cmd/hammer.c --- eresi-0.8a25/libstderesi/cmd/hammer.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/hammer.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* -** @file hammer.c -** @ingroup libstderesi -** @brief Contains libmjollnir commands bindings. -** -** Last update December 10 2006 may -** -** $Id: hammer.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * To rebuild symtab use this command - */ -int cmd_unstrip() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - memset(logbuf,0x0,BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure started\n"); - revm_output(logbuf); - if (!world.mjr_session.cur->analysed) - cmd_analyse(); - memset(logbuf,0x0,BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure %s\n", - (mjr_symtab_rebuild(&world.mjr_session)) ? "completed successfully" : "faild"); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * This command fill the blocks hash - */ -int cmd_analyse() -{ - char logbuf[BUFSIZ]; - int ret; - char **keys; - int index; - int nbr; - container_t *container; - aspectype_t *curtype; - eresi_Addr addr; - revmexpr_t *expr; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Analyzing object */ - memset(logbuf, 0x0, BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " [*] Now performing Control Flow Analysis\n"); - revm_output(logbuf); - memset(logbuf, 0x0, BUFSIZ); - - if (world.curjob->curcmd->param[0]) - { - expr = revm_lookup_var(world.curjob->curcmd->param[0]); - obj = expr->value; - - switch (obj->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - addr = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - break; - - case ASPECT_TYPE_INT: - addr = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - break; - } - } - else - addr = 0; - - ret = mjr_analyse(&world.mjr_session, 0, 0); //addr, 0); - - snprintf(logbuf, BUFSIZ - 1, " [*] Control Flow Analysis %s.\n", - (!ret ? "completed successfully" : "failed")); - revm_output(logbuf); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during control flow analysis", -1); - - memset(logbuf, 0x0, BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, - " [*] Calls seen: %d, Recognized destination: %d\n", - world.mjr_session.cur->calls_seen, - world.mjr_session.cur->calls_found); - revm_output(logbuf); - - /* Now informing about all existing blocks and functions */ - curtype = aspect_type_get_by_name("container"); - if (curtype) - { - keys = hash_get_keys(&world.mjr_session.cur->funchash, &nbr); - for (index = 1; index < nbr; index++) - { - container = hash_get(&world.mjr_session.cur->funchash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s"AFMT, - (char *) config_get_data(MJR_CONFIG_FUNC_PREFIX), - *(eresi_Addr *) container->data); - revm_inform_type_addr(curtype->name, logbuf, (eresi_Addr) container, NULL, 0, 1); - } - hash_free_keys(keys); - keys = hash_get_keys(&world.mjr_session.cur->blkhash, &nbr); - for (index = 1; index < nbr; index++) - { - container = hash_get(&world.mjr_session.cur->blkhash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s"AFMT, - (char *) config_get_data(MJR_CONFIG_BLOC_PREFIX), - *(eresi_Addr *) container->data); - revm_inform_type_addr(curtype->name, logbuf, (eresi_Addr) container, NULL, 0, 1); - } - hash_free_keys(keys); - revm_output(" [*] Reflected succesfully all basic blocks and function meta-data \n\n"); - } - else - revm_output(" [*] No reflection was performed (no container type definition found)\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Shortcut command to rename symbols - */ -int cmd_rename() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - mjr_symbol_rename(&world.mjr_session, - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/hashes.c eresi-0.0.20110516/libstderesi/cmd/hashes.c --- eresi-0.8a25/libstderesi/cmd/hashes.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/hashes.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ -/* -** @file hashes.c -** @ingroup libstderesi -** @brief Pretty printing for elfsh hash tables. -** -** Started Jan 20 2007 18:57:03 jfv -** -** -** $Id: hashes.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Display an element of a hash table - * @param h Hash table - * @param key Hash key of object to be printed - */ -int revm_table_display_element(hash_t *h, char *key, u_char inside) -{ - void *data; - char logbuf[BUFSIZ]; - revmexpr_t *newexpr; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - data = hash_get(h, key); - if (h->type == ASPECT_TYPE_UNKNOW || !inside) - { - snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", - key, (eresi_Addr) data); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - if (*key == REVM_VAR_PREFIX) - strncpy(logbuf, key, sizeof(logbuf)); - else - snprintf (logbuf, sizeof(logbuf), "$%s", key); - newexpr = revm_expr_get(logbuf); - if (newexpr) - { - revm_output("\t"); - revm_expr_print(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - revm_output("\t"); - if (h->type == ASPECT_TYPE_EXPR) - { - newexpr = (eresi_Addr) data; - revm_expr_print(newexpr->label); - } - else - { - type = aspect_type_get_by_id(h->type); - newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); - if (!newexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to reflect hash element to expression", -1); - revm_expr_print(logbuf); - } - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a hash table - * @param name Hash table name to display - */ -int revm_table_display_content(char *name) -{ - hash_t *h; - char **keys; - int keynbr; - int index; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_hash, name); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested hash parameter", -1); - - /* Empty hash */ - keys = hash_get_keys(h, &keynbr); - if (!keynbr) - { - revm_output(" [*] Hash table is empty \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Display pointers */ - for (index = 0; index < keynbr; index++) - revm_table_display_element(h, keys[index], 0); - - snprintf(logbuf, sizeof(logbuf), - "\n [*] Displayed %u entries of table %s \n\n", keynbr, name); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * Display the header of a hash table - * @param table - * @param name - */ -int revm_table_display(hash_t *table, char *name) -{ - char logbuf[BUFSIZ]; - char *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - type = revm_ascii_type(table); - snprintf(logbuf, sizeof(logbuf), - " + %-40s\t ElemType: %-15s ElemNbr: %u \n", - name, type, table->elmnbr); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Display the content of a hash table - */ -static void revm_tables_display() -{ - char **keys; - int keynbr; - int index; - hash_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_output(" .:: Registered tables \n\n"); - keys = hash_get_keys(hash_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(hash_hash, keys[index]); - revm_table_display(cur, keys[index]); - } - revm_output("\n Type 'help tables' for more table details.\n\n"); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Display the content of all hash tables that match the regex - * @param tableregx Regular expression matching table names - * @param elemregx Regular expression matching element keys - */ -static int revm_table_display_regx2(char *tableregx, char *elemregx) -{ - regex_t rx, ex; - int keynbr, keynbr2; - char **keys, **keys2; - int index, index2; - hash_t *cur; - u_int match; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_hash, &keynbr); - for (match = index = 0; index < keynbr; index++) - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - keys2 = hash_get_keys(cur, &keynbr2); - for (index2 = 0; index2 < keynbr2; index2++) - if (!regexec(&ex, keys2[index2], 0, 0, 0)) - { - match++; - revm_table_display_element(cur, keys2[index2], 1); - } - } - snprintf(logbuf, sizeof(logbuf), - "\n [*] Matched %u entries in all tables\n\n", match); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Display the content of all hash tables that match the regex - * @param regx - */ -static int revm_table_display_regx(char *regx) -{ - regex_t rx; - int keynbr; - char **keys; - int index; - int match; - char buf[50]; - char *lastmatch; - hash_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, regx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_hash, &keynbr); - for (lastmatch = NULL, match = index = 0; index < keynbr; index++) - { - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - revm_table_display(cur, keys[index]); - match++; - lastmatch = keys[index]; - } - } - - /* Print the content of the table if we had a unique match */ - if (match == 1) - revm_table_display_content(lastmatch); - else - { - snprintf(buf, sizeof(buf), "\n [*] Matched %u table%c \n\n", - match, (match > 1 ? 's' : ' ')); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -} - - -/** - * Print and modify internal hash tables - */ -int cmd_tables() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print table list */ - case 0: - revm_tables_display(); - break; - - /* Print a determined table with determined (or not) key entry */ - case 1: - if (revm_table_display_regx(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching tables", -1); - break; - - /* Print an element from a table */ - case 2: - if (revm_table_display_regx2(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching tables's elements", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid tables syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Empty a hash table - */ -int cmd_empty() -{ - char buf[BUFSIZ]; - hash_t *hash; - list_t *list; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - hash = hash_find(world.curjob->curcmd->param[index]); - if (!hash) - { - list = elist_find(world.curjob->curcmd->param[index]); - if (!list) - { - snprintf(buf, sizeof(buf), " [W] Unknown list or hash table %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - continue; - } - snprintf(buf, sizeof(buf), " .:: Empty list %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - elist_empty(world.curjob->curcmd->param[index]); - } - else - { - snprintf(buf, sizeof(buf), " .:: Empty hash table %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - hash_empty(world.curjob->curcmd->param[index]); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/help.c eresi-0.0.20110516/libstderesi/cmd/help.c --- eresi-0.8a25/libstderesi/cmd/help.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/help.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,8 +1,8 @@ /* -** @file help.c for libstderesi in ERESI -** @ingroup libstderesi +* @file libstderesi/cmd/help.c +** @ingroup cmd ** Started on Sat Jan 25 11:19:18 2003 jfv -** $Id: help.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: help.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -25,11 +25,11 @@ { if (access(world.curjob->curcmd->param[0], R_OK) != 0) { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); + snprintf(buf, sizeof(buf), "%s%s", ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) { snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); + ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find module", -1); diff -Nru eresi-0.8a25/libstderesi/cmd/info.c eresi-0.0.20110516/libstderesi/cmd/info.c --- eresi-0.8a25/libstderesi/cmd/info.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/info.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,13 +1,13 @@ /* -** @file info.c -** @ingroup libstderesi +* @file libstderesi/cmd/info.c +** @ingroup cmd ** Made by jfv ** Login ** ** Started on Tue Feb 11 03:32:46 2003 jfv ** Last update Thu Mar 11 07:59:32 2004 jfv ** -** $Id: info.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: info.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/inform.c eresi-0.0.20110516/libstderesi/cmd/inform.c --- eresi-0.8a25/libstderesi/cmd/inform.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/inform.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/* -** @file inform.c -** @ingroup libstderesi -** @brief Commands for doing annotations on program objects -** -** Started Jan 21 2007 12:57:03 jfv -** $Id: inform.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - - - -/** - * Inform a given type - */ -int cmd_inform() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - switch (world.curjob->curcmd->argc) - { - /* inform type */ - case 1: - if (revm_informed_print(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested type", -1); - break; - - /* inform type name */ - case 2: - if (revm_inform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], NULL, NULL, 1, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - - /* inform type name address */ - case 3: - if (revm_inform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], - world.curjob->curcmd->param[2], NULL, 1, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid inform syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Uninform a given type - */ -int cmd_uninform() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - switch (world.curjob->curcmd->argc) - { - /* uninform type */ - case 1: - if (revm_uninform_type(world.curjob->curcmd->param[0], NULL, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type information", -1); - break; - - /* uninform type name */ - case 2: - if (revm_uninform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid uninform syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/init.c eresi-0.0.20110516/libstderesi/cmd/init.c --- eresi-0.8a25/libstderesi/cmd/init.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/init.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,15 +1,148 @@ -/* -** @file init.c for libstderesi in ERESI -** @ingroup libstderesi -** @brief Constructors for the ERESI standard library -** -** $Id: init.c,v 1.4 2007-12-09 23:00:18 may Exp $ -*/ +/** + * @file libstderesi/cmd/init.c + * @ingroup cmd + * @brief Constructors for the ERESI standard library + * + * $Id: init.c 1444 2011-01-31 07:41:29Z may $ + */ #include +/* The command hash table : hash the command name and returns a revmcmd_t */ +hash_t cmd_hash; + +/* Tracing subcommands hash */ +hash_t traces_cmd_hash; + +/* The constants hash tables : ASCII shortcuts for ERESI */ +hash_t const_hash; + +/** + * Setup ELF constants hash tables + */ +static void eresi_constants_init() +{ + u_int index; + + hash_init(&const_hash, "constants", 51, ASPECT_TYPE_STR); + + for (index = 0; index < ELFSH_SEGTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_seg_type[index].name, + elfsh_seg_type + index); + + for (index = 0; index < ELFSH_EXTSEG_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_extseg_type[index].name, + elfsh_extseg_type + index); + + for (index = 0; index < ELFSH_ENCODING_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_encoding[index].name, + elfsh_encoding + index); + for (index = 0; index < ELFSH_SHTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_sh_type[index].name, + elfsh_sh_type + index); + for (index = 0; index < ELFSH_OBJTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_obj_type[index].name, + elfsh_obj_type + index); + for (index = 0; index < ELFSH_SYMBIND_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_sym_bind[index].name, + elfsh_sym_bind + index); + for (index = 0; index < ELFSH_SYMTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_sym_type[index].name, + elfsh_sym_type + index); + for (index = 0; index < ELFSH_RELOC_i386_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_rel_type_i386[index].name, + elfsh_rel_type_i386 + index); + + for (index = 0; index < ELFSH_RELOC_SPARC64_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_rel_type_sparc[index].name, + elfsh_rel_type_sparc + index); + + for (index = 0; index < ELFSH_RELOC_IA64_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_rel_type_ia64[index].name, + elfsh_rel_type_ia64 + index); + + for (index = 0; index < ELFSH_RELOC_ALPHA_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_rel_type_alpha[index].name, + elfsh_rel_type_alpha + index); + + for (index = 0; index < ELFSH_RELOC_MIPS_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_rel_type_mips[index].name, + elfsh_rel_type_mips + index); + + + for (index = 0; index < ELFSH_DYNAMIC_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_dynentry_type[index].name, + elfsh_dynentry_type + index); + for (index = 0; index < ELFSH_EXTDYN_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_extdyn_type[index].name, + elfsh_extdyn_type + index); + for (index = 0; index < ELFSH_MIPSDYN_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_mipsdyn_type[index].name, + elfsh_mipsdyn_type + index); + for (index = 0; index < ELFSH_FEATURE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_feature1[index].name, + elfsh_feature1 + index); + for (index = 0; index < ELFSH_POSFLAG_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_posflag1[index].name, + elfsh_posflag1 + index); + for (index = 0; index < ELFSH_FLAGS_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_flags[index].name, + elfsh_flags + index); + for (index = 0; index < ELFSH_FLAGS1_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_flags1[index].name, + elfsh_flags1 + index); + for (index = 0; index < ELFSH_MIPSFLAGS_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_mipsflags[index].name, + elfsh_mipsflags + index); + + for (index = 0; index < ELFSH_INSTRTYPE_MAX; index++) + hash_add(&const_hash, + (char *) asm_instr_type[index].name, + asm_instr_type + index); + + for (index = 0; index < ELFSH_OPTYPE_MAX; index++) + hash_add(&const_hash, + (char *) asm_operand_type[index].name, + asm_operand_type + index); + + for (index = 0; index < ELFSH_LINKTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_link_type[index].name, + elfsh_link_type + index); + + for (index = 0; index < ELFSH_LINKSCOPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_link_scope[index].name, + elfsh_link_scope + index); + + for (index = 0; index < ELFSH_ARCHTYPE_MAX; index++) + hash_add(&const_hash, + (char *) elfsh_arch_type[index].name, + elfsh_arch_type + index); +} -/** - * @brief Setup the command hash table + +/** + * @brief Setup the command hash table */ void eresi_commands_init() { @@ -18,6 +151,8 @@ unsigned int index; hash_init(&cmd_hash, "commands", 101, ASPECT_TYPE_UNKNOW); + hash_init(&traces_cmd_hash , "traces", 11, ASPECT_TYPE_UNKNOW); + eresi_constants_init(); /* Interactive mode / Scripting mode commands */ if (world.state.revm_mode != REVM_STATE_CMDLINE) @@ -62,12 +197,13 @@ revm_command_add(CMD_PRINT , (void *) cmd_print , (void *) revm_getvarparams , 0, HLP_PRINT); revm_command_add(CMD_EXEC , (void *) cmd_exec , (void *) revm_getvarparams , 0, HLP_EXEC); revm_command_add(CMD_EDIT , (void *) cmd_edit , (void *) revm_getoption , 0, HLP_EDIT); + revm_command_add(CMD_EVAL , (void *) cmd_eval , (void *) revm_getoption , 0, HLP_EVAL); revm_command_add(CMD_PHT , (void *) cmd_pht , (void *) revm_getregxoption, 1, HLP_PHT); revm_command_add(CMD_GOT , (void *) cmd_got , (void *) revm_getregxoption, 1, HLP_GOT); revm_command_add(CMD_CTORS , (void *) cmd_ctors , (void *) revm_getregxoption, 1, HLP_CTORS); revm_command_add(CMD_DTORS , (void *) cmd_dtors , (void *) revm_getregxoption, 1, HLP_DTORS); revm_command_add(CMD_NOTE , (void *) cmd_notes , (void *) revm_getregxoption, 1, HLP_NOTES); - revm_command_add(CMD_COREINFO, (void *) cmd_coreinfo, (void *) NULL , 1, HLP_COREINFO); + revm_command_add(CMD_COREINFO, (void *) cmd_coreinfo, (void *) NULL , 1, HLP_COREINFO); revm_command_add(CMD_SYM , (void *) cmd_sym , (void *) revm_getregxoption, 1, HLP_SYM); revm_command_add(CMD_DYNAMIC , (void *) cmd_dyn , (void *) revm_getregxoption, 1, HLP_DYNAMIC); revm_command_add(CMD_DYNSYM , (void *) cmd_dynsym , (void *) revm_getregxoption, 1, HLP_DYNSYM); @@ -147,13 +283,13 @@ revm_command_add(CMD_INTO , (void *) cmd_into , (void *) revm_getcaseparams , 0, HLP_INTO); revm_command_add(CMD_DEFAULT , (void *) cmd_default , (void *) revm_getvarparams , 0, HLP_DEFAULT); - revm_command_add(CMD_REFLECT , (void *) cmd_reflect , (void *) revm_getoption , 0, HLP_REFLECT); + revm_command_add(CMD_REFLECT , (void *) cmd_reflect , (void *) revm_getvarparams , 1, HLP_REFLECT); revm_command_add(CMD_SDIR , (void *) cmd_scriptsdir, (void *) revm_getoption , 0, HLP_SDIR); revm_command_add(CMD_VLIST , (void *) cmd_vlist , (void *) revm_getregxoption, 0, HLP_VLIST); revm_command_add(CMD_VARLIST , (void *) cmd_vlist , (void *) revm_getregxoption, 0, HLP_VLIST); revm_command_add(CMD_SOURCE , (void *) cmd_source , (void *) revm_getvarparams , 0, HLP_SOURCE); - revm_command_add(CMD_LSCRIPTS, (void *) cmd_lscripts, (void *) NULL , 0, HLP_LSCRIPTS); + revm_command_add(CMD_LSCRIPTS, (void *) cmd_lscripts, (void *) NULL , 0, HLP_LSCRIPTS); revm_command_add(CMD_CAT , (void *) cmd_cat , (void *) revm_getoption , 0, HLP_CAT); revm_command_add(CMD_PROFILE , (void *) cmd_profile , (void *) revm_getvarparams , 0, HLP_PROFILE); revm_command_add(CMD_LOG , (void *) cmd_log , (void *) revm_getvarparams , 0, HLP_LOG); @@ -164,6 +300,8 @@ revm_command_add(CMD_VERDEF , (void *) cmd_verdef , (void *) revm_getregxoption, 1, HLP_VERDEF); revm_command_add(CMD_HASH , (void *) cmd_hashx , (void *) revm_getregxoption, 1, HLP_HASH); revm_command_add(CMD_CONFIGURE, cmd_configure , revm_getvarparams, 0, HLP_CONFIGURE); + revm_command_add(CMD_CONFIG , cmd_configure , revm_getvarparams, 0, HLP_CONFIGURE); + revm_command_add(CMD_PROC , cmd_proc , NULL, 0, HLP_PROC); /* Type related commands */ revm_command_add(CMD_TYPE , cmd_type , revm_getvarparams, 0, HLP_TYPE); @@ -173,8 +311,11 @@ revm_command_add(CMD_UNINFORM , cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); revm_command_add(CMD_INFORM2 , cmd_inform , revm_getvarparams, 1, HLP_INFORM); revm_command_add(CMD_UNINFORM2, cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); - -#if defined(ELFSHNET) + revm_command_add(CMD_SETUNION , cmd_union , revm_getoption2, 0, HLP_SETUNION); + revm_command_add(CMD_SETINTER , cmd_inter , revm_getoption2, 0, HLP_SETINTER); + revm_command_add(CMD_SETINTER2, cmd_inter , revm_getoption2, 0, HLP_SETINTER); + +#if defined(ERESI_NET) /* DUMP network commands */ revm_command_add(CMD_NETWORK , (void *) cmd_network , (void *) NULL , 0, HLP_NETWORK); revm_command_add(CMD_NETWORK2 , (void *) cmd_network , (void *) NULL , 0, HLP_NETWORK); @@ -183,25 +324,38 @@ revm_command_add(CMD_PEERSLIST , (void *) cmd_peerslist, (void *) NULL , 0, HLP_PEERSLIST); revm_command_add(CMD_CONNECT , (void *) cmd_connect , (void *) revm_getoption , 0, HLP_CONNECT); revm_command_add(CMD_DISCON , (void *) cmd_discon , (void *) revm_getoption , 0, HLP_DISCON); - revm_command_add(CMD_RCMD , (void *) cmd_rcmd , (void *) revm_getvarparams , 0, HLP_RCMD); + revm_command_add(CMD_RCMD , (void *) cmd_rcmd , (void *) revm_getvarparams , 0, HLP_RCMD); #endif /* Flow analysis commands */ - revm_command_add(CMD_ANALYSE , cmd_analyse , NULL, 1, HLP_ANALYSE); - revm_command_add(CMD_UNSTRIP , cmd_unstrip , NULL, 1, HLP_UNSTRIP); + revm_command_add(CMD_ANALYSE , cmd_analyse , revm_getvarparams, 1, HLP_ANALYSE); + revm_command_add(CMD_UNSTRIP , cmd_unstrip , NULL, 1, HLP_UNSTRIP); revm_command_add(CMD_GRAPH , cmd_graph , revm_getvarparams, 1, HLP_GRAPH); revm_command_add(CMD_INSPECT , cmd_inspect , revm_getoption, 1, HLP_INSPECT); revm_command_add(CMD_FLOWJACK , cmd_flowjack , revm_getoption2, 1, HLP_FLOWJACK); revm_command_add(CMD_ADDGOTO , cmd_addgoto , revm_getoption2, 1, HLP_ADDGOTO); revm_command_add(CMD_SETGVL , cmd_setgvl , revm_getoption, 1, HLP_SETGVL); - revm_command_add(CMD_RENAME , cmd_rename , revm_getoption2, 1, HLP_RENAME); - revm_command_add(CMD_CONTROL , cmd_control , NULL, 1, HLP_CONTROL); + revm_command_add(CMD_RENAME , cmd_rename , revm_getoption2, 1, HLP_RENAME); + revm_command_add(CMD_ASTRIP , cmd_astrip , NULL, 1, HLP_ASTRIP); + revm_command_add(CMD_CONTROL , cmd_control , NULL, 1, HLP_CONTROL); + revm_command_add(CMD_ARGCOUNT , cmd_argcount , revm_getoption, 1, HLP_ARGCOUNT); + + /* Setup all used sub functions */ + traces_addcmd("add" , (void *) traces_add , 2, 1); + traces_addcmd("rm" , (void *) traces_rm , 2, 1); + traces_addcmd("exclude" , (void *) traces_exclude , 2, 1); + traces_addcmd("rmexclude", (void *) traces_rmexclude, 2, 1); + traces_addcmd("enable" , (void *) traces_enable , 2, 1); + traces_addcmd("disable" , (void *) traces_disable , 2, 1); + traces_addcmd("create" , (void *) traces_create , 2, 1); + traces_addcmd("delete" , (void *) traces_delete , 2, 0); + traces_addcmd("flush" , (void *) traces_flush , 2, 0); /* Base type declarations commands */ typeinfo = aspect_basetype_get(&typenbr); for (index = 0; index < typenbr; index++) - revm_command_add(typeinfo[index].name, cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); + revm_command_add(typeinfo[index].name, cmd_declare, + revm_getvarparams, 0, HLP_DECLARE); } diff -Nru eresi-0.8a25/libstderesi/cmd/insert.c eresi-0.0.20110516/libstderesi/cmd/insert.c --- eresi-0.8a25/libstderesi/cmd/insert.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/insert.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ -/* -** @file insert.c -** @ingroup libstderesi -** @brief First insert functions for easy scripting. -** -** Started Nov 22 01:26:01 2003 jfv -** -** -** $Id: insert.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * sect name maptype size align - * sym name value size - * phdr type value size - */ -int cmd_insert() -{ - elfshsect_t *sct; - revmexpr_t *expr; - revmobj_t *obj; - elfsh_Sym sym; - elfsh_Phdr phdr; - u_int size; - char *name; - char type; - elfsh_Word ptype; - eresi_Addr val; - u_int modulo; - char *param0, *param1, *param2, *param3, *param4; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - param0 = world.curjob->curcmd->param[0]; - param1 = world.curjob->curcmd->param[1]; - param2 = world.curjob->curcmd->param[2]; - param3 = world.curjob->curcmd->param[3]; - param4 = world.curjob->curcmd->param[4]; - - /* Checks (needed because the command takes variable amount of params) */ - if (!param0 || !param1 || !param2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Lookup 2nd parameter depending on first parameter */ - if (!strcmp(param0, "phdr") || !strcmp(param0, "rphdr")) - { - expr = revm_lookup_param(param1); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && - expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid phdr type", -1); - obj = expr->value; - ptype = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - name = NULL; - } - else - { - expr = revm_lookup_param(param1); - if (!expr || !expr->value || !expr->value->otype || expr->value->otype->type != ASPECT_TYPE_STR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object name", -1); - obj = expr->value; - name = (obj->immed ? obj->immed_val.str : obj->get_name(obj->root, obj->parent)); - ptype = 0; - } - - /* Lookup object size (4rth optional parameter) */ - if (param3) - { - expr = revm_lookup_param(param3); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_INT && expr->value->otype->type != ASPECT_TYPE_LONG)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object size", -1); - obj = expr->value; - size = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - } - else - size = elfsh_get_pagesize(world.curjob->curfile); - - /* Lookup object alignment (5th optional parameter) */ - if (param4) - modulo = atoi(param4); - else - modulo = 0; - - /* Insert a section after looking up injection type */ - /* Third parameter indicate injection type */ - if (!strcmp(param0, "sect")) - { - type = (!strcmp(param2, "code") ? ELFSH_CODE_INJECTION : - !strcmp(param2, "data") ? ELFSH_DATA_INJECTION : - !strcmp(param2, "unmap") ? - ELFSH_UNMAPPED_INJECTION : ELFSH_UNKNOWN_INJECTION); - if (type == ELFSH_UNKNOWN_INJECTION) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown injection type", -1); - sct = elfsh_insert_section(world.curjob->curfile, name, - NULL, type, size, modulo); - if (!sct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new section", -1); - } - - /* Insert a symbol after looking up symbol value */ - /* Third parameter indicate existing symbol name or value */ - else if (!strcmp(param0, "sym")) - { - expr = revm_lookup_param(param2); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid symbol value", -1); - obj = expr->value; - val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - if (!elfsh_get_symtab(world.curjob->curfile, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive symbol table", -1); - - sym = elfsh_create_symbol(val, size, 0, 0, 0, 0); - if (elfsh_insert_symbol(world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB], - &sym, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert symbol", -1); - - - } - - /* Insert PHT entries */ - /* Third parameter indicate symbol name or value */ - else if (!strcmp(param0, "phdr") || - !strcmp(param0, "rphdr")) - { - expr = revm_lookup_param(param2); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid PHDR base address", -1); - obj = expr->value; - val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - - // type, addr, size, alignment - phdr = elfsh_create_phdr(ptype, val, size, 0); - if (!strcmp(param0, "phdr")) - { - if (NULL == elfsh_insert_phdr(world.curjob->curfile, &phdr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new PHDR", -1); - } - else if (NULL == elfsh_insert_runtime_phdr(world.curjob->curfile, &phdr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new runtime PHDR", -1); - } - - /* Error */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown object type", -1); - - /* Report result */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Object insertion succesfull\n\n"); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} diff -Nru eresi-0.8a25/libstderesi/cmd/inspect.c eresi-0.0.20110516/libstderesi/cmd/inspect.c --- eresi-0.8a25/libstderesi/cmd/inspect.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/inspect.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* -** @file inspect.c -** @ingroup libstderesi -** @brief Inspect the content of a basic block -** -** Original author : -** -** December 10 2006 : Merged from modflow to the ELFsh vm -may -** -** $Id: inspect.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - - -/** - * Some API that needs to be moved in another file ! - * @param id - */ -eresi_Addr revm_get_block_vaddr_by_id(int id) -{ - container_t *container; - mjrblock_t *block; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - container = mjr_lookup_container(world.mjr_session.cur,id); - block = (mjrblock_t *) container->data; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, block->vaddr); -} - - -/** - * Inspect command for basic blocks - */ -int cmd_inspect() -{ - elfshobj_t *obj; - elfshsect_t *sect; - elfsh_Sym *sym; - mjrblock_t *blk; - container_t *cntnr; - mjrlink_t *cal; - char *name; - char *pname; - elfsh_SAddr off; - u_int vaddr; - char buflog[BUFSIZ]; - listent_t *curent; - mjrblock_t *tmpblock; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - cntnr = NULL; - obj = world.curjob->curfile; - if (!world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Try to find block by symbol or address */ - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[0]))) - vaddr = sym->st_value; - else - vaddr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - /* Try to lookup by variable name */ - if (!vaddr) - { - if (!strncmp(world.curjob->curcmd->param[0], "$bloc", 5)) - cntnr = hash_get(&exprs_hash, world.curjob->curcmd->param[0]); - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find block symbol or address", -1); - name = elfsh_reverse_metasym(world.curjob->curfile, *(eresi_Addr *) cntnr->data, &off); - } - else - { - name = elfsh_reverse_metasym(world.curjob->curfile, vaddr, &off); - cntnr = mjr_block_get_by_vaddr(world.mjr_session.cur, vaddr, 1); - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find block", -1); - } - - blk = cntnr->data; - - /* Dump calling information */ - snprintf(buflog, sizeof(buflog), " [*] Found block " XFMT " : %s + " DFMT "\n", - blk->vaddr, name, off); - revm_output(buflog); - - /* Iterate on the list of links */ - for (curent = cntnr->inlinks->head; curent; curent = curent->next) - { - cal = curent->data; - tmpblock = mjr_lookup_container(world.mjr_session.cur,cal->id)->data; - pname = elfsh_reverse_metasym(world.curjob->curfile, tmpblock->vaddr, &off); - - /* FIXME: we have to work out the lack of the 'type' field for blocks */ - switch (cal->type) - { - case MJR_LINK_BLOCK_COND_TRUE: - snprintf(buflog, sizeof(buflog), - " -> true jumped from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_BLOCK_COND_FALSE: - snprintf(buflog, sizeof(buflog), - " -> false from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_FUNC_CALL: - snprintf(buflog, sizeof(buflog), - " -> called from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_FUNC_RET: - snprintf(buflog, sizeof(buflog), - " -> returned from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - default: - snprintf(buflog, sizeof(buflog), - " -> UNKNOW from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - } - revm_output(buflog); - } - - /* Dump ASM */ - revm_output(" -- block disassembly --\n"); - sect = elfsh_get_parent_section(obj, blk->vaddr, NULL); - off = elfsh_get_foffset_from_vaddr(obj, blk->vaddr); - revm_object_display(sect, sym, blk->size, 0, off, blk->vaddr, - name, REVM_VIEW_DISASM); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/jmp.c eresi-0.0.20110516/libstderesi/cmd/jmp.c --- eresi-0.8a25/libstderesi/cmd/jmp.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/jmp.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -/* -** @file jmp.c -** @ingroup libstderesi -** Made by jfv -** Login -** -** Started on Thu Nov 20 05:09:43 2003 jfv -** Last update Thu Nov 20 05:10:03 2003 jfv -** -** $Id: jmp.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Handler for the jmp instruction - */ -int cmd_jmp() -{ - int ret; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * Handler for the je instruction - */ -int cmd_je() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (!res->immed_val.ent) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jne instruction - */ - -int cmd_jne() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jg instruction - */ - -int cmd_jg() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent > 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jl instruction - */ -int cmd_jl() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent < 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Handler for the jge instruction - */ -int cmd_jge() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent >= 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jle instruction - */ -int cmd_jle() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent <= 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/job.c eresi-0.0.20110516/libstderesi/cmd/job.c --- eresi-0.8a25/libstderesi/cmd/job.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/job.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,13 +1,59 @@ -/* -** @file job.c -** @ingroup libstderesi -** Started on Wed Jul 20 22:22:35 2005 yann_malcom -** -** $Id: job.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ +/** + * @file libstderesi/cmd/job.c + * @ingroup cmd + * Started on Wed Jul 20 22:22:35 2005 yann_malcom + * + * $Id: job.c 1427 2010-07-09 20:54:05Z thorkill $ + * + */ #include "libstderesi.h" + +int revm_create_new_workspace(char *ws_name) +{ + revmjob_t *job; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (!revm_valid_workspace(ws_name)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Incorrect workspace name", -1); + + job = hash_get(&world.jobs, ws_name); + + if (job == NULL) + { + /* create a new workspace */ + job = revm_clone_job(strdup(ws_name), world.curjob); + hash_add(&world.jobs, ws_name, job); + + if (revm_own_job(job)) + { + /* switch */ + snprintf(logbuf, BUFSIZ - 1, "\n [+] Workspace : %s \n\n", ws_name); + revm_output(logbuf); + revm_prompt_log(); + /* Switch to the new job */ + revm_switch_job(job); + /* Update the screen */ + revm_screen_update(TRUE, 0); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + } + else + if (job->ws.active) + { + snprintf(logbuf, BUFSIZ - 1, "\n [+] Already in workspace : %s\n\n", + ws_name); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Incorrect workspace name", -1); +} + + /** * Need doxygen comment */ @@ -16,7 +62,6 @@ revmjob_t *job; u_int idx; u_int index; - u_short new = 0; char logbuf[BUFSIZ]; char *nl; char *time; @@ -26,99 +71,55 @@ char **loadedkeys; int loadedkeynbr; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); //printf("workspace argc %u \n", world.curjob->curcmd->argc); switch (world.curjob->curcmd->argc) { - /* $ workspace */ - case 0: + case 0: revm_output(" .::. Workspaces .::. \n"); keys = hash_get_keys(&world.jobs, &keynbr); for (index = 0; index < keynbr; index++) - { - job = (revmjob_t *) hash_get(&world.jobs, keys[index]); - if (revm_own_job(job)) - { - time = ctime(&job->ws.createtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - snprintf(logbuf, BUFSIZ - 1, " [%s] %s %c \n", keys[index], - time, (job->ws.active ? '*' : ' ')); - revm_output(logbuf); - - if (hash_size(&job->loaded)) - { - loadedkeys = hash_get_keys(&job->loaded, &loadedkeynbr); - for (idx = 0; idx < loadedkeynbr; idx++) - { - obj = hash_get(&job->loaded, loadedkeys[idx]); - snprintf(logbuf, BUFSIZ - 1, " \t %c %s \n", - (job->curfile == obj ? '*' : ' '), obj->name); - revm_output(logbuf); - } - - } - else - { - snprintf(logbuf, BUFSIZ - 1, " \t No files\n"); - revm_output(logbuf); - } - } - } + { + job = (revmjob_t *) hash_get(&world.jobs, keys[index]); + if (revm_own_job(job)) + { + time = ctime(&job->ws.createtime); + nl = strchr(time, '\n'); + if (nl) + *nl = 0x00; + snprintf(logbuf, BUFSIZ - 1, " [%s] %s %c \n", keys[index], + time, (job->ws.active ? '*' : ' ')); + revm_output(logbuf); + + if (hash_size(&job->loaded)) + { + loadedkeys = hash_get_keys(&job->loaded, &loadedkeynbr); + for (idx = 0; idx < loadedkeynbr; idx++) + { + obj = hash_get(&job->loaded, loadedkeys[idx]); + snprintf(logbuf, BUFSIZ - 1, " \t %c %s \n", + (job->curfile == obj ? '*' : ' '), obj->name); + revm_output(logbuf); + } + + } + else + { + snprintf(logbuf, BUFSIZ - 1, " \t No files\n"); + revm_output(logbuf); + } + } + } revm_output("\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* $ workspace name */ - case 1: - if (!revm_valid_workspace(world.curjob->curcmd->param[0])) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrect workspace name", -1); - - job = hash_get(&world.jobs, world.curjob->curcmd->param[0]); - if (!job) - { - /* create a new workspace */ - job = revm_clone_job(strdup(world.curjob->curcmd->param[0]), - - world.curjob); - hash_add(&world.jobs, world.curjob->curcmd->param[0], (void *) job); - new = 1; - } - else - { - if (job->ws.active) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Already in workspace : %s\n\n", world.curjob->curcmd->param[0]); - revm_output(logbuf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - if (revm_own_job(job)) - { - /* switch */ - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Workspace : %s \n\n", world.curjob->curcmd->param[0]); - revm_output(logbuf); - revm_prompt_log(); - - /* Switch to the new job */ - revm_switch_job(job); - - /* Update the screen */ - revm_screen_update(new, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrect workspace name", -1); + /* $ workspace name */ + case 1: + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + revm_create_new_workspace(revm_get_cur_job_parameter(0))); /* Unknown command format */ default: @@ -126,17 +127,17 @@ } } -/** - * Switch to the next workspace +/** + * Switch to the next workspace */ int cmd_next_workspace() { int ret; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); ret = revm_workspace_next(); if (!ret) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to switch workspace", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to switch workspace", -1); } diff -Nru eresi-0.8a25/libstderesi/cmd/list.c eresi-0.0.20110516/libstderesi/cmd/list.c --- eresi-0.8a25/libstderesi/cmd/list.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/list.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/* -** @file list.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:20:20 2003 jfv -** -** $Id: list.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Print dependence - * @param obj - */ -static int revm_dolist_dep(elfshobj_t *obj) -{ - elfshobj_t *actual; - char logbuf[20]; - char **keys; - int keynbr; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - if (hash_size(&obj->child_hash)) - { - keys = hash_get_keys(&obj->child_hash, &keynbr); - revm_output("DEPS = ["); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&obj->child_hash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s%u", - (index == 0 ? "" : ","), actual->id); - revm_output(logbuf); - } - revm_output("]"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * List all the loaded objects - */ -int cmd_dolist() -{ - elfshobj_t *actual; - int index; - char *time; - char *nl; - char c; - char c2; - char logbuf[BUFSIZ]; - char optbuf[BUFSIZ]; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - index = 1; - - /* Private descriptors */ - if (hash_size(&world.curjob->loaded)) - { - revm_output(" .::. Static Working files .::. \n"); - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&world.curjob->loaded, keys[index]); - time = ctime(&actual->loadtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - c = (world.curjob->curfile == actual ? '*' : ' '); - c2 = ((actual->linkmap || actual->rhdr.base) ? 'M' : ' '); - if (elfsh_is_debug_mode()) - snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); - else - snprintf(optbuf, BUFSIZ, "%s", ""); - - snprintf(logbuf, BUFSIZ - 1, " %s %c%c %s ID: %10u %s %-31s ", - time, c, c2, optbuf, actual->id, - elfsh_get_objtype(actual->hdr) == ET_REL ? "ET_REL " : - elfsh_get_objtype(actual->hdr) == ET_DYN ? "ET_DYN " : - elfsh_get_objtype(actual->hdr) == ET_EXEC ? "ET_EXEC" : - elfsh_get_objtype(actual->hdr) == ET_CORE ? "ET_CORE" : - "UNKNOWN", actual->name); - revm_output(logbuf); - revm_dolist_dep(actual); - revm_output("\n"); - - /* printf("-> Hashes for object : PAR[%u] ROOT[%u] CHILD[%u] \n", - hash_size(&actual->parent_hash), - hash_size(&actual->root_hash), - hash_size(&actual->child_hash)); - */ - - } - } - - /* Shared descriptors */ - if (hash_size(&world.shared_hash)) - { - revm_output("\n .::. Shared Working files .::. \n"); - keys = hash_get_keys(&world.shared_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&world.shared_hash, keys[index]); - time = ctime(&actual->loadtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - c = (world.curjob->curfile == actual ? '*' : ' '); - c2 = (actual->linkmap ? 'L' : ' '); - if (elfsh_is_debug_mode()) - snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); - else - snprintf(optbuf, BUFSIZ, "%s", ""); - - snprintf(logbuf, BUFSIZ - 1, " [%02u] %s %c%c %s ID: %02u %-31s \n", - index + 1, time, c, c2, optbuf, actual->id, actual->name); - revm_output(logbuf); - } - } - - if (!hash_size(&world.curjob->loaded) && !hash_size(&world.shared_hash)) - revm_output(" [*] No loaded file\n"); - revm_output("\n"); - revm_modlist(); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/lists.c eresi-0.0.20110516/libstderesi/cmd/lists.c --- eresi-0.8a25/libstderesi/cmd/lists.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/lists.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ -/** -** @file lists.c -** @ingroup libstderesi -** @brief Pretty printing for ERESI lists -** -** Started Jul 13 2007 18:57:03 jfv -** $Id: lists.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - - -/** - * Display an element of a keyed linked list - * @param h Linked list - * @param key Key of list object to be printed - */ -int revm_list_display_element(list_t *l, char *key, u_char inside) -{ - void *data; - char logbuf[BUFSIZ]; - revmexpr_t *newexpr; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - data = elist_get(l, key); - if (l->type == ASPECT_TYPE_UNKNOW || !inside) - { - snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", - key, (eresi_Addr) data); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - if (*key == REVM_VAR_PREFIX) - strncpy(logbuf, key, sizeof(logbuf)); - else - snprintf (logbuf, sizeof(logbuf), "$%s", key); - newexpr = revm_expr_get(logbuf); - if (newexpr) - { - revm_output("\t"); - revm_expr_print(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - revm_output("\t"); - if (l->type == ASPECT_TYPE_EXPR) - { - newexpr = (eresi_Addr) data; - revm_expr_print(newexpr->label); - } - else - { - type = aspect_type_get_by_id(l->type); - newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); - if (!newexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to reflect hash element to expression", -1); - revm_expr_print(logbuf); - } - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a list - * @param name List name to display - */ -int revm_list_display_content(char *name) -{ - list_t *h; - listent_t *cur; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_lists, name); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested list parameter", -1); - if (!h->elmnbr) - { - revm_output(" [*] List is empty \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Display list entries */ - for (cur = h->head; cur; cur = cur->next) - revm_list_display_element(h, cur->key, 0); - - snprintf(logbuf, sizeof(logbuf), - "\n [*] Displayed %u entries of list %s \n\n", h->elmnbr, name); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Display the header of a list */ -int revm_list_display(list_t *list, char *name) -{ - char logbuf[BUFSIZ]; - char *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - type = revm_ascii_ltype(list); - snprintf(logbuf, sizeof(logbuf), - " + %-40s\t ElemType: %-15s ElemNbr: %u \n", - name, type, list->elmnbr); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a list - */ -static void revm_lists_display() -{ - char **keys; - int keynbr; - int index; - list_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_output(" .:: Registered lists \n\n"); - keys = hash_get_keys(hash_lists, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(hash_lists, keys[index]); - revm_list_display(cur, keys[index]); - } - revm_output("\n Type 'help lists' for more table details.\n\n"); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Display the content of all hash tables that match the regex - * @param tableregx Regular expression matching table names - * @param elemregx Regular expression matching element keys - */ -static int revm_list_display_regx2(char *tableregx, char *elemregx) -{ - regex_t rx, ex; - int keynbr; - char **keys; - int index; - list_t *cur; - listent_t *curent; - u_int match; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_lists, &keynbr); - for (match = index = 0; index < keynbr; index++) - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - for (curent = cur->head; curent; curent = curent->next) - if (!regexec(&ex, curent->key, 0, 0, 0)) - { - match++; - revm_list_display_element(cur, curent->key, 1); - } - } - snprintf(logbuf, sizeof(logbuf), - "\n [*] Matched %u entries in all lists \n\n", match); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of all hash tables that match the regex - */ -static int revm_list_display_regx(char *regx) -{ - regex_t rx; - int keynbr; - char **keys; - int index; - int match; - char buf[50]; - char *lastmatch; - list_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, regx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_lists, &keynbr); - for (lastmatch = NULL, match = index = 0; index < keynbr; index++) - { - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_lists, keys[index]); - revm_list_display(cur, keys[index]); - match++; - lastmatch = keys[index]; - } - } - - /* Print the content of the table if we had a unique match */ - if (match == 1) - revm_list_display_content(lastmatch); - else - { - snprintf(buf, sizeof(buf), "\n [*] Matched %u list%c \n\n", - match, (match > 1 ? 's' : ' ')); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -} - - -/** - * Print and modify internal lists - */ -int cmd_lists() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print the list of lists */ - case 0: - revm_lists_display(); - break; - - /* Print a determined table with determined (or not) key entry */ - case 1: - if (revm_list_display_regx(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching lists", -1); - break; - - case 2: - if (revm_list_display_regx2(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching list elements", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid lists syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/load.c eresi-0.0.20110516/libstderesi/cmd/load.c --- eresi-0.8a25/libstderesi/cmd/load.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/load.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ -/** - * @file load.c - * @ingroup libstderesi - * Started on Sat Jan 25 11:21:18 2003 jfv - * - * $Id: load.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - -/** - * return 1 if a file named 'name' is in the workspace - * @param name - */ -int revm_is_loaded(char *name) -{ - listent_t *actual; - elfshobj_t *obj; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob->curfile) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - for (index = 0; index < world.curjob->loaded.size; index++) - for (actual = &world.curjob->loaded.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - obj = actual->data; - if (!strcmp(name, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - - for (index = 0; index < world.shared_hash.size; index++) - for (actual = &world.shared_hash.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - obj = actual->data; - if (!strcmp(name, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param file - * @param name - */ -int revm_load_init_dephash(elfshobj_t *file, char *name) -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init hash dep */ - snprintf(logbuf, sizeof(logbuf), "%s_children", name); - hash_init(&file->child_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_roots", name); - hash_init(&file->root_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_parents", name); - hash_init(&file->parent_hash, strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param regex - */ -int revm_file_loads(char *regex) -{ - // split for dir/files part - // open dir - // read dir - // match against regex - // if matched load files - return (0); -} - -/** - * Load a file in elfsh - * @param name - * @param base - * @param lm - * @return - */ -int revm_file_load(char *name, eresi_Addr base, elfshlinkmap_t *lm) -{ - elfshobj_t *new; - revmexpr_t *expr; - revmobj_t *tmp; - char logbuf[BUFSIZ]; - char *timec; - hash_t *filehash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Reset the id counter in case we have unloaded all our files */ - filehash = hash_find("files"); - if (!hash_size(filehash)) - world.state.lastid = 0; - - /* Map the standard ELF object */ - new = elfsh_map_obj(name); - if (NULL == new) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load object", -1); - - /* Print a msg if not in quiet mode */ - new->loadtime = time(&new->loadtime); - if (!world.state.revm_quiet) - { - timec = ctime(&new->loadtime); - timec[strlen(timec) - 1] = '\0'; - snprintf(logbuf, BUFSIZ - 1, " [*] %s - New object loaded : %s\n", - timec , name); - revm_output(logbuf); - } - - /* Set base address */ - new->rhdr.base = base; - - /* Set linkmap address */ - if (new->hdr->e_type != ET_CORE) - new->linkmap = lm; - else - new->linkmap = NULL; - - /* Add the object to the list of opened objects */ - new->id = ++world.state.lastid; - world.curjob->curfile = new; - expr = revm_expr_get(REVM_VAR_LOAD); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "TROUBLE : Last loaded file inexistant", -1); - tmp = expr->value; - tmp->immed_val.word = new->id; - - /* Support shared objects */ - if (world.state.revm_shared) - hash_add(&world.shared_hash, new->name, new); - else - hash_add(&world.curjob->loaded, new->name, new); - - /* Add an entry into the loaded files hashtable */ - hash_add(&file_hash, new->name, (void *) new); - - /* Init hash dep */ - revm_load_init_dephash(new, name); - - if (new->hdr->e_type == ET_CORE) - { - hash_add(&new->root_hash, new->name, new); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Create libmjollnir context for this binary */ - mjr_create_context_as_current(&world.mjr_session, new); - mjr_setup_processor(&world.mjr_session); - - /* Init search hash tables */ - elfsh_init_symbol_hashtables(new); - - /* Parse debugging informations */ - revm_edfmt_parse(new); - - /* Load dependances */ - if (new->hdr->e_type == ET_EXEC) - hash_add(&new->root_hash, new->name, new); - - /* We use a different dependences technique for mapped files - in the debugger. Just load dependences here for unmapped files */ - if (!elfsh_is_debug_mode()) - revm_load_enumdep(new); - - /* Load EDFMT debug sections */ - if ((int) config_get_data(ERESI_VMCONFIG_ONLOAD_RCONTROL)) - { - if (mjr_functions_get(world.mjr_session.cur) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Analyzed functions edfmt section cannot be restored", -1); - if (mjr_blocks_get(world.mjr_session.cur) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Analyzed blocks edfmt section cannot be restored", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Insert an object in the list of opened elfsh descriptors - */ -int cmd_load() -{ - revmexpr_t *expr; - revmobj_t *tmp; - char *str; - int was_dynamic; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Make sure we are or not in the debugger */ - was_dynamic = 0; - if (elfsh_is_debug_mode()) - { - was_dynamic = 1; - elfsh_set_static_mode(); - } - - /* Find which file we need to load */ - expr = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!expr || !expr->value) - { - if (was_dynamic) - elfsh_set_debug_mode(); - world.state.revm_shared = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown file to load", (-1)); - } - tmp = expr->value; - if (tmp->otype->type != ASPECT_TYPE_STR) - { - revm_convert_object(expr, ASPECT_TYPE_STR); - if (tmp->otype->type != ASPECT_TYPE_STR) - { - revm_expr_destroy(expr->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file to load", (-1)); - } - } - str = (tmp->immed ? tmp->immed_val.str : tmp->get_name(tmp->root, tmp->parent)); - if (hash_get(&world.curjob->loaded, str) || hash_get(&world.shared_hash, str)) - { - revm_expr_destroy(expr->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load file many times in the same workspace", (-1)); - } - - /* Really load the file */ - revm_output("\n"); - ret = revm_file_load(str, 0, NULL); - revm_output("\n"); - - /* Restore dynamic mode */ - if (was_dynamic) - { - if (world.curjob->curfile && world.curjob->curfile->linkmap) - elfsh_set_debug_mode(); - else - revm_output("\n [!] Loaded file not present in linkmap" - ", switching to STATIC mode\n\n"); - } - else - elfsh_set_static_mode(); - - /* Everything was OK */ - world.state.revm_shared = 0; - revm_expr_destroy(expr->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - diff -Nru eresi-0.8a25/libstderesi/cmd/log.c eresi-0.0.20110516/libstderesi/cmd/log.c --- eresi-0.8a25/libstderesi/cmd/log.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/log.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,11 +1,11 @@ /* -** @file log.c -** @ingroup libstderesi +* @file libstderesi/cmd/log.c +** @ingroup cmd ** Implement logging facilities ** ** Started September 16 03:11:04 2005 mm ** -** $Id: log.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: log.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/Makefile eresi-0.0.20110516/libstderesi/cmd/Makefile --- eresi-0.8a25/libstderesi/cmd/Makefile 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/Makefile 2011-05-16 11:35:04.000000000 +0000 @@ -1,52 +1,49 @@ ## -## Makefile for vm in librevm for the ELF shell project +## Makefile for cmd in libstderesi for the ERESI project ## ## Started on Fri Nov 2 16:32:29 2001 jfv +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ ## include ../../config.h -SRC = cat.c flow.c graph.c help.c insert.c list.c prefixes.c \ - profile.c reladd.c save.c source.c unload.c vlist.c \ - fileops.c flowjack.c hammer.c info.c inspect.c load.c \ - net.c print.c quit.c remove.c script.c trace.c utils.c \ - vectors.c types.c hashes.c inform.c debug.c foreach.c \ - atomic.c fcthijack.c jmp.c configure.c color.c log.c \ - modules.c exec.c switch.c job.c match.c declare.c \ - lists.c reflect.c define.c init.c return.c +SRC = cat.c help.c prefixes.c profile.c source.c info.c \ + net.c print.c quit.c script.c utils.c configure.c \ + color.c log.c modules.c exec.c job.c define.c init.c \ + eval.c proc.c OBJ32 = $(SRC:.c=.32.o) OBJ64 = $(SRC:.c=.64.o) CC ?= gcc LD ?= ld RM = rm -f -NAME32 = ../revm-commands.32.o -NAME64 = ../revm-commands.64.o +NAME32 = ../std-cmd.32.o +NAME64 = ../std-cmd.64.o CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libelfsh/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../../libedfmt/include/ $(STATOPT2) \ -I../../libetrace/include -I../../librevm/include/ \ $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ - $(READLNOPT) + $(READLNOPT) $(BITS) CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ -I../../libelfsh/include/ -I../../elibc/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libaspect/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ + -I../../libedfmt/include/ $(STATOPT2) \ -I../../libetrace/include -I../../librevm/include/ \ $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ - $(NCURSESLNOPT) $(READLNOPT) + $(NCURSESLNOPT) $(READLNOPT) $(BITS) all : all32 all64 -$(NAME32) : $(OBJ32) +$(NAME32) : $(OBJ32) $(LD) -r $(OBJ32) -o $(NAME32) -$(NAME64) : $(OBJ64) +$(NAME64) : $(OBJ64) $(LD) -r $(OBJ64) -o $(NAME64) all32: $(NAME32) all64: $(NAME64) diff -Nru eresi-0.8a25/libstderesi/cmd/match.c eresi-0.0.20110516/libstderesi/cmd/match.c --- eresi-0.8a25/libstderesi/cmd/match.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/match.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,471 +0,0 @@ -/** -** @file match.c -** @ingroup libstderesi -** @brief Implementation of program transformation in ERESI -** -** Start on Wed May 23 13:55:45 2007 jfv -** -** $Id: match.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - -/** - * Retreive the annotation for a given expression - * @param name Expression name - * @return A pointer on the annotation, or NULL if failed. - */ -revmannot_t *revm_annot_get(char *name) -{ - revmexpr_t *expr; - aspectype_t *type; - hash_t *thash; - revmannot_t *annot; - char newname[BUFSIZ] = {0x00}; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - expr = revm_expr_get(name); - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input expression name", NULL); - type = expr->type; - snprintf(newname, sizeof(newname), "type_%s", type->name); - thash = hash_find(newname); - annot = hash_get(thash, name); - if (!annot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find annotation for expression", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, annot); -} - - -/** - * Copy a field value from one expression to another (provided destination indeed has that field) - * @param dest Destination expression to add field to - * @param source Source expression tocopy field from - * @param fname Name of field to copy from source to destination - * @return 0 for success and -1 for error - */ -static int revm_field_propagate(revmexpr_t *dest, revmexpr_t *source, char *fname) -{ - char srcname[BUFSIZ]; - char dstname[BUFSIZ]; - revmexpr_t *dst; - revmexpr_t *child; - revmannot_t *annot; - revmannot_t *dstannot; - revmannot_t *addedannot; - /*eresi_Addr addr; - char *newdata;*/ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Propagate input links */ - snprintf(srcname, sizeof(srcname), "%s.%s", source->label, fname); - child = revm_expr_get(srcname); - if (!child) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - snprintf(dstname, sizeof(dstname), "%s.%s", dest->label, fname); - dst = revm_expr_get(dstname); - - /* If destination expression has no such field, create it now */ - if (!dst) - { - annot = revm_annot_get(child->label); // annot de lexpr a copier - dstannot = revm_annot_get(dest->label); // annot de lexpr mere destination - if (!annot || !dstannot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup annotations for input expressions", -1); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__, dstannot->addr, - (char *) dstannot->addr, dest->type->size + child->type->size, -1); - dst = revm_expr_copy(child, dstname, 1); - dst->next = dest->childs; - dest->childs = dst; - - addedannot = revm_annot_get(dstname); - if (!addedannot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to add annotation on new field", -1); - memcpy((char *) dstannot->addr + dest->type->size, (char *) addedannot->addr, child->type->size); - addedannot->addr = dstannot->addr + dest->type->size; - - /* XXX-FIXME: annotations needs to be updated for childs of this type too.... */ - /* - dest->type->size += child->type->size; - revm_inform_type_addr(dst->type->name, dstname, dstannot->addr + dest->type->size, dst, 0, 0); - */ - } - - /* Else assign it */ - else if (child->value && revm_object_set(dest, child) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression field", -1); - else if (revm_expr_set(dst, child) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression fields", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Propagate the link between 2 objects - * @param dest Destination expression to copy links to - * @param source Source expression to copy links from - * @return 0 for success and -1 for error - */ -static int revm_links_propagate(revmexpr_t *dest, revmexpr_t *source) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_field_propagate(dest, source, "inlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression INLINKS field", -1); - if (revm_field_propagate(dest, source, "outlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression OUTLINKS field", -1); - if (revm_field_propagate(dest, source, "nbrinlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression NBRINLINKS field", -1); - if (revm_field_propagate(dest, source, "nbroutlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression NBROUTLINKS field", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Perform the transformation (can be called from case or into commands) - * @param matchme - * @param destvalue - * @return -*/ -static int revm_case_transform(revmexpr_t *matchme, char *destvalue) -{ - u_int dstnbr; - char *curptr; - char *foundptr; - u_int curidx; - list_t *exprlist; - aspectype_t *type; - char namebuf[BUFSIZ]; - char *rname; - revmexpr_t *candid; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We matched : first find how many elements there is in the target (list) type */ - dstnbr = 1; - XALLOC(__FILE__, __FUNCTION__, __LINE__, exprlist, sizeof(list_t), -1); - elist_init(exprlist, "curdestlist", ASPECT_TYPE_EXPR); - for (curidx = *world.curjob->iter.curindex - 1, curptr = destvalue; - curptr && *curptr; - curptr = foundptr + 2, curidx++, dstnbr++) - { - foundptr = strstr(curptr, "::"); - if (!foundptr) - break; - *foundptr = 0x00; - type = revm_exprtype_get(curptr); - snprintf(namebuf, BUFSIZ, "%s-%u", world.curjob->iter.curkey, curidx); - rname = strdup(namebuf); - candid = revm_expr_create(type, rname, curptr); - elist_add(exprlist, rname, candid); - } - - /* FIXME: The rewritten element is not part of any list or is part of an alien list */ - if (!world.curjob->iter.list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Rewriting of non-list element currently not supported", -1); - else if (world.curjob->iter.list->type != ASPECT_TYPE_EXPR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Rewriting is currently only supported for expression lists", -1); - - /* Simply replace the current list element now */ - /* The type of the list (list_t->type) does not change : it still is a list of revmexpr_t */ - - /* Just one element to swap */ - else if (dstnbr == 1) - { - elist_destroy(exprlist); - - /* No transformation, keep the original expression */ - if (!strcmp(destvalue, ".")) - candid = matchme; - else - { - rname = revm_tmpvar_create(); - type = revm_exprtype_get(destvalue); - candid = revm_expr_create(type, rname, destvalue); - if (!candid) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Malformed destination type", -1); - - /* - XXX: Disabled for now -- do not remove - if (revm_links_propagate(candid, matchme) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while propagating dataflow links", -1); - */ - - /* initialisation de subexpr par une autre expr est bugge ! */ - /* il nomme le field par le nom de la variable .. */ - elist_set(world.curjob->iter.list, strdup(world.curjob->iter.curkey), candid); - rname = strdup(matchme->label); - revm_expr_destroy(matchme->label); - matchme = revm_expr_copy(candid, rname, 0); - revm_expr_destroy(candid->label); - XFREE(__FILE__, __FUNCTION__, __LINE__, rname); - if (!matchme) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to write back list element", -1); - } - } - - /* Insert a list at a certain offset of the list */ - else - { - elist_replace(world.curjob->iter.list, world.curjob->iter.curkey, exprlist); - *world.curjob->iter.curindex += exprlist->elmnbr - 1; - elist_destroy(exprlist); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Execute side-effects command at some transformation point - * @param str - */ -static int revm_case_execmd(char *str) -{ - revmargv_t *curcmd; - char actual[26]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 11, ASPECT_TYPE_STR); - - curcmd = world.curjob->curcmd; - - if (revm_exec_str(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Side-effects preparation failed", -1); - - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - if (revm_execmd() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Side-effects execution failed", -1); - world.curjob->curcmd = curcmd; - - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Translate in destination type - */ -int cmd_into() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot transform a second time", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot transform outside a rewrite", -1); - if (revm_case_transform(world.curjob->rwrt.matchexpr, - strdup(world.curjob->curcmd->param[0])) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to transform expression", -1); - world.curjob->rwrt.replaced = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Expression transformed succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Perform pre-side-effects - */ -int cmd_pre() -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform pre-side-effects after transformation", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command cannot execute outside a rewrite", -1); - str = revm_string_get(world.curjob->curcmd->param); - if (revm_case_execmd(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Pre-side-effects commands failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Perform pre-side-effects - */ -int cmd_post() -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform post-side-effects before transformation", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command cannot execute outside a rewrite", -1); - str = revm_string_get(world.curjob->curcmd->param); - if (revm_case_execmd(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Post-side-effects commands failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Check input type, translate if matching - */ -int cmd_case() -{ - aspectype_t *exprtype; - revmexpr_t *matchme; - revmexpr_t *candid; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Case is not in a match", -1); - - exprtype = aspect_type_get_by_id(ASPECT_TYPE_EXPR); - if (!exprtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Expression type not found : lacking reflection ?", -1); - - /* If a previous case has already matched, simply end the transformation now : - We must do that here because some "post" commands can be put after a matching - "case", so we only stop rewriting at the first case -following- a matchcase */ - if (world.curjob->rwrt.matched) - { - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Check if we match */ - matchme = (revmexpr_t *) world.curjob->rwrt.matchexpr; - if (!matchme->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for matchme expression", -1); - candid = revm_expr_create(matchme->type, "$candid", strdup(world.curjob->curcmd->param[0])); - ret = (!candid ? 1 : revm_expr_match(candid, matchme)); - - /* No match or bad match : nothing happens */ - if (ret) - { - world.curjob->rwrt.matched = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Matched : transform and execute post side effects if any */ - world.curjob->rwrt.matched = 1; - - /* Sometimes the case command comes directly with appended post side-effects */ - if (!world.curjob->curcmd->param[1]) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - revm_case_transform(matchme, strdup(world.curjob->curcmd->param[1])); - if (world.curjob->curcmd->param[2] && - revm_case_execmd(world.curjob->curcmd->param[2]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Post-side-effects commands failed", -1); - - /* Jump to end of the match construct */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Beginning of the transform command, open a transformation switch - */ -int cmd_match() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* The first time we enter this command, we have to fetch the params */ - if (world.curjob->iter.list && !strcmp(world.curjob->iter.curname, world.curjob->curcmd->param[0])) - { - if (world.curjob->iter.list->type != ASPECT_TYPE_EXPR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Match/Rewrite can only works on expressions", -1); - fprintf(stderr, "\n *** We -ARE- matching elements of a list *** \n"); - } - else - fprintf(stderr, "\n *** We are -NOT- matching elements of a list *** \n"); - - world.curjob->rwrt.matchexpr = revm_lookup_param(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * End of match. Do nothing. - */ -int cmd_matchend() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bzero(&world.curjob->rwrt, sizeof(revmrewrite_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Default case of a match when nothing else has matched - */ -int cmd_default() -{ - char *str; - revmargv_t *cur; - char actual[26]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cur = world.curjob->curcmd; - - /* Execute parameter command */ - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 11, ASPECT_TYPE_STR); - str = revm_string_get(world.curjob->curcmd->param); - cur = world.curjob->curcmd; - if (revm_exec_str(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Display execrequest failed", -1); - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - if (revm_execmd() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Default command execution failed", -1); - - /* Restore previous context */ - world.curjob->curcmd = cur; - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; - - /* Jump to end of the match construct */ - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/modules.c eresi-0.0.20110516/libstderesi/cmd/modules.c --- eresi-0.8a25/libstderesi/cmd/modules.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/modules.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,9 +1,9 @@ /** -** @file modules.c -** @ingroup libstderesi +* @file libstderesi/cmd/modules.c +** @ingroup cmd ** Started on Wed Feb 19 04:42:47 2003 jfv ** -** $Id: modules.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: modules.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -24,11 +24,11 @@ /* Verify if the file exists */ if (access(world.curjob->curcmd->param[0], R_OK) != 0) { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); + snprintf(buf, sizeof(buf), "%s%s", ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) { snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); + ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find module", -1); @@ -118,11 +118,11 @@ { if (access(world.curjob->curcmd->param[0], R_OK) != 0) { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); + snprintf(buf, sizeof(buf), "%s%s", ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) { snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); + ERESI_MODPATH, world.curjob->curcmd->param[0]); if (access(buf, R_OK) != 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Cannot find module", -1); diff -Nru eresi-0.8a25/libstderesi/cmd/net.c eresi-0.0.20110516/libstderesi/cmd/net.c --- eresi-0.8a25/libstderesi/cmd/net.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/net.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,15 +1,14 @@ /** -** @file net.c -** @ingroup libstderesi +* @file libstderesi/cmd/net.c +** @ingroup cmd ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Thu Jan 04 11:26:11 2007 jfv ** -** $Id: net.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: net.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" - /** * Run network initialisation */ @@ -30,7 +29,7 @@ job->ws.createtime = time(&job->ws.createtime); hash_add(&world.jobs, "net_init", job); - //world.curjob = job; + //world.curjob = job; // to comment again ? world.state.revm_net = 1; if (revm_net_init() < 0) @@ -44,23 +43,19 @@ revm_command_add(CMD_UNLOAD , (void *) cmd_unload , (void *) revm_getoption, 0, HLP_UNLOAD); revm_command_add(CMD_SAVE , (void *) cmd_save , (void *) revm_getoption, 1, HLP_SAVE); revm_command_add(CMD_SWITCH , (void *) cmd_doswitch , (void *) revm_getoption, 1, HLP_SWITCH); - revm_command_add(CMD_METACMD , (void *) cmd_meta , (void *) NULL, 0, HLP_METACMD); - revm_command_add(CMD_QUIT , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); - revm_command_add(CMD_QUIT2 , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); - revm_command_add(CMD_LIST , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); - revm_command_add(CMD_LIST2 , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); - revm_command_add(CMD_STOP , (void *) cmd_stop , (void *) NULL, 0, HLP_STOP); - - // NEED A SWITCH + revm_command_add(CMD_METACMD , (void *) cmd_meta , (void *) NULL, 0, HLP_METACMD); + revm_command_add(CMD_QUIT , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); + revm_command_add(CMD_QUIT2 , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); + revm_command_add(CMD_LIST , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); + revm_command_add(CMD_LIST2 , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); + revm_command_add(CMD_STOP , (void *) cmd_stop , (void *) NULL, 0, HLP_STOP); } - revm_output(" [*] Started ELFsh network connection \n\n"); + revm_output(" [*] Started ERESI network stack\n\n"); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - /** * print the list of net-client */ @@ -70,36 +65,34 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#if defined(ELFSHNET) - listent_t *actual; +#if defined(ERESI_NET) int index; char buf[BUFSIZ]; char *addr; + revmjob_t *curjob; + char **keys; + int keynbr; revm_output(" .::. Net client list .::. \n"); - for (index = 0; index < world.jobs.size; index++) + keys = hash_get_keys(&world.jobs, &keynbr); + for (index = 0; index < keynbr; index++) { - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (!((revmjob_t *) actual->data)->active) - continue; - - if (((revmjob_t *) actual->data)->io.type == ELFSH_IONET) - { - addr = inet_ntoa(((revmjob_t *) actual->data)->sock.addr.sin_addr); - snprintf(buf, BUFSIZ - 1, " [%.3d] IP %s\n", i, addr); - revm_output(buf); - i++; - } - } + curjob = (revmjob_t *) hash_get(&world.jobs, keys[index]); + if (!curjob->ws.active) + continue; + if (curjob->ws.io.type == REVM_IO_NET) + { + addr = inet_ntoa(curjob->ws.io.sock.addr.sin_addr); + snprintf(buf, BUFSIZ - 1, " [%.3d] IP %s\n", i, addr); + revm_output(buf); + i++; + } } + hash_free_keys(keys); #endif if (i == 0) revm_output(" [*] No client\n"); - revm_output("\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -114,7 +107,7 @@ PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - tokill = world.curjob->curcmd->param[0]; + tokill = revm_get_cur_job_parameter(0); tokill = revm_lookup_string(tokill); @@ -149,7 +142,7 @@ { int i = 0; -#if defined(ELFSHNET) +#if defined(ERESI_NET) listent_t *actual; int index; char buf[BUFSIZ]; @@ -185,22 +178,22 @@ */ int cmd_connect() { -#if defined(ELFSHNET) - +#if defined(ERESI_NET) char *toconnect; char buf[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - toconnect = world.curjob->curcmd->param[0]; - + toconnect = revm_get_cur_job_parameter(0); toconnect = revm_lookup_string(toconnect); if (world.state.revm_net != 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - + { + revm_output(" [*] First enable network support.\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } - if (world.curjob->ws.io.type == ELFSH_IONET) + if (world.curjob->ws.io.type == REVM_IO_NET) { revm_output(" [*] You can't add DUMP connection.\n"); revm_output("\n"); @@ -218,11 +211,12 @@ snprintf(buf, BUFSIZ - 1, " [*] connection to %s established.\n", toconnect); revm_output(buf); revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); #else PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#endif - + revm_output(" [*] This version of ERESI was compiled without network support.\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +#endif } @@ -231,21 +225,21 @@ */ int cmd_discon() { -#if defined(ELFSHNET) +#if defined(ERESI_NET) char *todisconnect; char buf[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - todisconnect = world.curjob->curcmd->param[0]; + todisconnect = revm_get_cur_job_parameter(0); todisconnect = revm_lookup_string(todisconnect); if (world.state.revm_net != 1) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (world.curjob->ws.io.type == ELFSH_IONET) + if (world.curjob->ws.io.type == REVM_IO_NET) { revm_output(" [*] You can't remove DUMP connection.\n"); revm_output("\n"); @@ -274,7 +268,7 @@ */ int cmd_rcmd() { -#if defined(ELFSHNET) +#if defined(ERESI_NET) int idx; char *to; @@ -297,14 +291,14 @@ sz -= 2; - for (idx = 1; world.curjob->curcmd->param[idx] != NULL; idx++) + for (idx = 1; revm_get_cur_job_parameter(idx) != NULL; idx++) { strncat(data, " ", sz - 1); sz -= 1; if (sz < 2) break; - strncat(data, world.curjob->curcmd->param[idx], sz - 1); - sz -= strlen(world.curjob->curcmd->param[idx]); + strncat(data, revm_get_cur_job_parameter(idx), sz - 1); + sz -= strlen(revm_get_cur_job_parameter(idx)); if (sz < 2) break; } @@ -312,7 +306,7 @@ if (idx < 2) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid number of parameters", (-1)); - to = world.curjob->curcmd->param[0]; + to = revm_get_cur_job_parameter(idx); to = revm_lookup_string(to); diff -Nru eresi-0.8a25/libstderesi/cmd/prefixes.c eresi-0.0.20110516/libstderesi/cmd/prefixes.c --- eresi-0.8a25/libstderesi/cmd/prefixes.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/prefixes.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /** -** @file prefixes.c -** @ingroup libstderesi +* @file libstderesi/cmd/prefixes.c +** @ingroup cmd ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Thu Jan 04 11:26:11 2007 jfv ** -** $Id: prefixes.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: prefixes.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/print.c eresi-0.0.20110516/libstderesi/cmd/print.c --- eresi-0.8a25/libstderesi/cmd/print.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/print.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /** -** @file quit.c -** @ingroup libstderesi +* @file libstderesi/cmd/print.c +** @ingroup cmd ** Started on Sat Jan 25 11:19:53 2003 jfv ** ** -** $Id: print.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: print.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -33,34 +33,35 @@ /* Print a non-pointer type */ if (!obj->otype) - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_0"); + snprintf(logbuf, BUFSIZ - 1, "UNKNOW_OBJECT_TYPE_0"); else switch (obj->otype->type) { case ASPECT_TYPE_BYTE: byte = (obj->immed ? obj->immed_val.byte : obj->get_obj(obj->parent)); word = (uint32_t) byte; - snprintf(logbuf, BUFSIZ - 1, "'%s' (%s) ", + snprintf(logbuf, BUFSIZ - 1, "'%s'(%s) ", ((word > 31 && word < 127) ? revm_colornumber("%c", word) : revm_colorfieldstr("?")), revm_colornumber("%hhd", word)); break; case ASPECT_TYPE_SHORT: half = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); word = (uint32_t) half; - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", + snprintf(logbuf, BUFSIZ - 1, "%s(%s) ", revm_colornumber("%hd", word), revm_colornumber("0x%hX", word)); break; case ASPECT_TYPE_LONG: case ASPECT_TYPE_CADDR: case ASPECT_TYPE_DADDR: val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", - revm_colornumber("%d", val), revm_colornumber("0x%X", val)); + snprintf(logbuf, BUFSIZ - 1, "%s ", + revm_colornumber(RXFMT, val)); break; case ASPECT_TYPE_INT: + case ASPECT_TYPE_OID: word = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", - revm_colornumber("%d", word), revm_colornumber("0x%X", word)); + snprintf(logbuf, BUFSIZ - 1, "%s ", + revm_colornumber("%d", word)); break; case ASPECT_TYPE_STR: str = (obj->immed ? obj->immed_val.str : @@ -79,7 +80,7 @@ /* When the object type is unknown */ default: - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_%u ", obj->otype->type); + snprintf(logbuf, BUFSIZ - 1, "UNKNOW_OBJECT_TYPE_%u ", obj->otype->type); break; } revm_output(logbuf); @@ -89,7 +90,7 @@ /* Now print a pointer */ isptr: if (!obj->otype) - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_PTR_OBJECT_TYPE_0"); + snprintf(logbuf, BUFSIZ - 1, "UNKNOW_PTR_OBJECT_TYPE_0"); else switch (obj->otype->type) { @@ -103,7 +104,7 @@ case ASPECT_TYPE_RAW: default: val = (obj->immed || !obj->parent ? obj->immed_val.ent : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s ", revm_colornumber("0x%X", val)); + snprintf(logbuf, BUFSIZ - 1, "%s ", revm_colornumber(RXFMT, val)); break; } revm_output(logbuf); @@ -127,23 +128,28 @@ for (idx = 0; world.curjob->curcmd->param[idx] != NULL; idx++) { expr = revm_expr_get(world.curjob->curcmd->param[idx]); + if (!expr) + expr = revm_compute(world.curjob->curcmd->param[idx]); if (expr && expr->value && !expr->value->perm) { revm_object_print(expr->value); - revm_expr_destroy(expr->label); + revm_expr_destroy_by_name(expr->label); continue; } else if (expr) { - revm_expr_print(world.curjob->curcmd->param[idx]); + if (*expr->label == REVM_VAR_PREFIX) + revm_expr_print_by_name(expr->label, 0); + else + revm_expr_print_by_name(world.curjob->curcmd->param[idx], 0); revm_output("\n\n"); continue; } - expr = revm_lookup_param(world.curjob->curcmd->param[idx]); + expr = revm_lookup_param(world.curjob->curcmd->param[idx], 1); if (expr && expr->value && !expr->value->perm) { revm_object_print(expr->value); - revm_expr_destroy(expr->label); + revm_expr_destroy_by_name(expr->label); continue; } else if (!expr) @@ -153,7 +159,7 @@ continue; } else - revm_expr_print(expr->label); + revm_expr_print_by_name(expr->label, 0); } revm_output("\n"); diff -Nru eresi-0.8a25/libstderesi/cmd/proc.c eresi-0.0.20110516/libstderesi/cmd/proc.c --- eresi-0.8a25/libstderesi/cmd/proc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/proc.c 2011-05-16 11:35:04.000000000 +0000 @@ -0,0 +1,46 @@ +/* +* @file libstderesi/cmd/proc.c +** @ingroup cmd +** +** Made by jfv +** $Id: proc.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + +/** @brief Print information about currently analyzed processor + * + */ +int cmd_proc() +{ + char logbuf[BUFSIZ]; + int mode; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->proc) + { + revm_output(" [*] No processor initialized for this architecture (unsupported ?) \n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + switch (world.curjob->proc->type) + { + case ASM_PROC_IA32: + mode = asm_ia32_get_mode(world.curjob->proc); + snprintf(logbuf, sizeof(logbuf), " [*] INTEL processor (%s mode)\n", + (mode == INTEL_PROT ? "Protected" : "Real")); + break; + case ASM_PROC_SPARC: + snprintf(logbuf, sizeof(logbuf), " [*] SPARC processor\n"); + break; + case ASM_PROC_MIPS: + snprintf(logbuf, sizeof(logbuf), " [*] MIPS processor\n"); + break; + case ASM_PROC_ARM: + snprintf(logbuf, sizeof(logbuf), " [*] ARM processor\n"); + break; + default: + snprintf(logbuf, sizeof(logbuf), " [*] UNKNOWN processor\n"); + } + + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/cmd/profile.c eresi-0.0.20110516/libstderesi/cmd/profile.c --- eresi-0.8a25/libstderesi/cmd/profile.c 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/profile.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /** -** @file profile.c -** @ingroup libstderesi +* @file libstderesi/cmd/profile.c +** @ingroup cmd ** Started on Fri Nov 2 15:21:56 2001 jfv ** Updated on Thu Jan 04 11:26:11 2007 jfv ** -** $Id: profile.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: profile.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -34,7 +34,6 @@ char operation; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (world.curjob->curcmd->argc == 0) { revm_output(" [*] Current status of the profiler : \n\n"); diff -Nru eresi-0.8a25/libstderesi/cmd/quit.c eresi-0.0.20110516/libstderesi/cmd/quit.c --- eresi-0.8a25/libstderesi/cmd/quit.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/quit.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,9 +1,9 @@ /** -** @file quit.c -** @ingroup libstderesi +* @file libstderesi/cmd/quit.c +** @ingroup cmd ** Started on Sat Jan 25 11:19:53 2003 jfv ** -** $Id: quit.c,v 1.3 2008-02-16 12:32:27 thor Exp $ +** $Id: quit.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -77,15 +77,15 @@ revm_modename_get(), REVM_VERSION); revm_quitmsg_set(logbuf); } - if (world.curjob->sourced == 0) + if (world.curjob->curscope == 0) revm_output(quit_msg); /* Now the ugly code depending on the compilation options */ -#if defined(ELFSHNET) - if (world.curjob->ws.io.type == ELFSH_IONET && - revm_socket_del(inet_ntoa(world.curjob->ws.sock.addr.sin_addr)) < 0) +#if defined(ERESI_NET) + if (world.curjob->ws.io.type == REVM_IO_NET && + revm_socket_del(inet_ntoa(world.curjob->ws.io.sock.addr.sin_addr)) < 0) fprintf(stderr, "error on quit from client on socket %d\n", - world.curjob->ws.sock.socket); + world.curjob->ws.io.sock.socket); else #endif { diff -Nru eresi-0.8a25/libstderesi/cmd/reflect.c eresi-0.0.20110516/libstderesi/cmd/reflect.c --- eresi-0.8a25/libstderesi/cmd/reflect.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/reflect.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* -** @file match.c -** @ingroup libstderesi -** @brief Handle the match construct. -** -** Start on Wed May 23 13:55:45 2007 jfv -** -** $Id: reflect.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - -/** - * Reflect command disassemble the block cache of the parameter and create a list of instr exprs - */ -int cmd_reflect() -{ - container_t *container; - container_t *instrcontainer; - mjrblock_t *curblock; - asm_instr *cur; - elfsh_Half machine; - char logbuf[BUFSIZ]; - eresi_Addr addr; - int off; - int ret; - aspectype_t *curtype; - void *blocdata; - int fileoff; - list_t *instrlist; - revmexpr_t *expr; - int insnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - curtype = aspect_type_get_by_name("instr"); - if (!curtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed reflection : unknown type instruction", -1); - - /* Analyse the binary if not already done */ - if (!world.mjr_session.cur->analysed) - { - ret = mjr_analyse(&world.mjr_session, 0, 0); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed analyzing current object", -1); - } - - /* Init proc */ - if (!world.curjob->proc) - { - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC: - case EM_SPARC32PLUS: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - default: - snprintf(logbuf, sizeof (logbuf), - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - /* Now lookup the block by its addr or symbol */ - addr = revm_lookup_addr(world.curjob->curcmd->param[0]); - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup parameter address", -1); - container = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, MJR_BLOCK_GET_STRICT); - if (!container) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to find bloc at this virtual address", -1); - curblock = (mjrblock_t *) container->data; - - /* Load the data from the bloc */ - blocdata = alloca(curblock->size); - fileoff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, curblock->vaddr); - if (elfsh_raw_read(world.curjob->curfile, fileoff, - blocdata, curblock->size) != curblock->size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read data from bloc", -1); - - /* Create the new list of instructions in expression form */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, instrlist, sizeof(list_t), -1); - snprintf(logbuf, sizeof(logbuf), AFMT, curblock->vaddr); - elist_init(instrlist, strdup(logbuf), ASPECT_TYPE_EXPR); - - /* Reflection all instructions of the basic bloc in the list */ - for (insnbr = off = 0; off < curblock->size; off += ret, insnbr++) - { - - /* Fetch the current instruction */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, cur, sizeof(asm_instr), -1); - ret = asm_read_instr(cur, (u_char *) blocdata + off, - curblock->size - off + 10, world.curjob->proc); - if (ret < 0) - { - elist_destroy(instrlist); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to fetch code for basic bloc", -1); - } - - /* Also add the instruction to the current reflected list for this block */ - instrcontainer = container_create(curtype->type, cur, NULL, NULL); - snprintf(logbuf, sizeof (logbuf), "$instr-"XFMT, curblock->vaddr + off); - expr = revm_inform_type_addr(curtype->name, strdup(logbuf), - (eresi_Addr) instrcontainer, NULL, 0, 1); - elist_add(instrlist, strdup(logbuf), expr); - } - - /* Reverse instrlist and add it to the hash of lists */ - instrlist = elist_reverse(instrlist); - hash_add(&instrlists_hash, strdup(logbuf), instrlist); - - /* Printing message if we are not in quiet mode */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, sizeof(logbuf), - " [*] Basic bloc at address " AFMT " reflected succesfully (%u instrs) \n\n", - curblock->vaddr, insnbr); - revm_output(logbuf); - } - - /* Put the current bloc in the last result variable */ - /* - revm_expr_destroy(REVM_VAR_RESULT); - revm_expr_copy(expr, REVM_VAR_RESULT); - */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/reladd.c eresi-0.0.20110516/libstderesi/cmd/reladd.c --- eresi-0.8a25/libstderesi/cmd/reladd.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/reladd.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * @file relinject.c - * @ingroup libstderesi - * Started on Fri Mar 28 14:58:57 2003 jfv - * Last update Thu Mar 11 14:39:48 2004 jfv - * - * $Id: reladd.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Inject a .o into an executable - */ -int cmd_relinject() -{ - elfshobj_t *host; - elfshobj_t *rel; - int idx; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check to avoid non-runtime (static) injection from e2bdg the debugger - that would desynchronize the memory perspective of the program. - The debugger is not supposed to do that, it is a job for elfsh */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - elfsh_is_static_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "E2dbg must inject in memory, switch to dynamic mode.", -1); - - /* Load host file */ - idx = atoi(world.curjob->curcmd->param[0]); - host = (idx ? revm_getfile(idx) : - hash_get(&file_hash, world.curjob->curcmd->param[0])); - if (host == NULL) - { - host = elfsh_map_obj(world.curjob->curcmd->param[0]); - if (host == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot map host file", -1); - } - - /* Load relocatable file */ - idx = atoi(world.curjob->curcmd->param[1]); - rel = (idx > 0 ? revm_getfile(idx) : - hash_get(&file_hash, world.curjob->curcmd->param[1])); - if (rel == NULL) - { - rel = elfsh_map_obj(world.curjob->curcmd->param[1]); - if (rel == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot map relocatable file", -1); - } - - /* Call libelfsh relocatable object injector */ - idx = elfsh_inject_etrel_hash(host, rel, - &world.curjob->loaded, - &world.shared_hash); - - if (idx < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to inject ET_REL with workspace", (-1)); - - /* Success : put the modified object as current */ - world.curjob->curfile = host; - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [*] ET_REL %s injected succesfully in %s %s\n\n", - rel->name, - (host->hdr->e_type == ET_EXEC ? "ET_EXEC" : - host->hdr->e_type == ET_DYN ? "ET_DYN" : - "unknown host file"), - host->name); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/remove.c eresi-0.0.20110516/libstderesi/cmd/remove.c --- eresi-0.8a25/libstderesi/cmd/remove.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/remove.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/** -** @file remove.c -** @ingroup libstderesi -** @brief First remove functions for easy scripting -** -** Started on Nov 22 2003 jfv -** -** -** $Id: remove.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * sect name - * sym name - */ -int cmd_remove() -{ - elfshsect_t *symtab; - char *name; - int err; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Checks (needed because the command takes variable amount of params) */ - if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Lookup object name */ - name = revm_lookup_string(world.curjob->curcmd->param[1]); - - /* Remove a section */ - if (!strcmp(world.curjob->curcmd->param[0], "sect")) - err = elfsh_remove_section(world.curjob->curfile, name); - - /* Remove a symbol after looking up symbol value */ - else if (!strcmp(world.curjob->curcmd->param[0], "sym")) - { - symtab = elfsh_get_symtab(world.curjob->curfile, NULL); - if (!symtab) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find symbol table", -1); - symtab = world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB]; - err = elfsh_remove_symbol(symtab, name); - } - - /* Remove a segment */ - else if (!strcmp(world.curjob->curcmd->param[0], "phdr")) - err = elfsh_remove_phdr(world.curjob->curfile, atoi(name)); - - /* Error */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown object type", -1); - - /* Report result */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Object removing %s.\n\n", - (err < 0 ? "failed" : "succesfull")); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/return.c eresi-0.0.20110516/libstderesi/cmd/return.c --- eresi-0.8a25/libstderesi/cmd/return.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/return.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/** -** @file return.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:19:53 2003 jfv -** $Id: return.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - -/** - * Unload all the loaded object and exit the shell - */ -int cmd_return() -{ - elfshobj_t *cur; - int index; - char logbuf[BUFSIZ]; - int objnbr; - char **keys; - char **objkeys; - int keynbr; - int z; - revmjob_t *curjob; - revmexpr_t *retval; - revmexpr_t *lastvar; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fill return value */ - if (world.curjob->curcmd->param[0]) - { - lastvar = revm_expr_get(REVM_VAR_RESULT); - if (lastvar) - revm_expr_destroy(lastvar->label); - retval = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!retval) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid return value", -1); - revm_expr_copy(retval, REVM_VAR_RESULT, 0); - } - - /* Do not unload files if we were sourcing a script */ - if (world.curjob->sourced == 0) - { - keys = hash_get_keys(&world.jobs, &keynbr); - - /* Unload every workspace */ - for (z = 0; z < keynbr; z++) - { - curjob = hash_get(&world.jobs, keys[z]); - if (!revm_own_job(curjob)) - continue; - - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Unloading workspace : %u (%s) %c\n", - z, curjob->ws.name, (curjob->ws.active ? '*' : ' ')); - revm_output(logbuf); - - /* Unload all objects from this job */ - objkeys = hash_get_keys(&curjob->loaded, &objnbr); - for (index = 0; index < objnbr; index++) - { - cur = hash_get(&curjob->loaded, objkeys[index]); - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " \t[*] Unloading object %u (%s) %c \n", - index + 1, cur->name, - (curjob->curfile == cur ? '*' : ' ')); - revm_output(logbuf); - } - elfsh_unload_obj(cur); - } - } - - /* The quit message */ - if (quit_msg_setup == 0) - { - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - revm_modename_get(), REVM_VERSION); - revm_quitmsg_set(logbuf); - } - revm_output(quit_msg); - - /* Now the ugly code depending on the compilation options */ -#if defined(ELFSHNET) - if (world.curjob->ws.io.type == ELFSH_IONET && - revm_socket_del(inet_ntoa(world.curjob->ws.sock.addr.sin_addr)) < 0) - fprintf(stderr, "error on quit from client on socket %d\n", - world.curjob->ws.sock.socket); - else -#endif - { - revm_output_bcast("\n"); - revm_quit(world.state.revm_mode); - - /* Remove the 2 FIFO on quit : will let the client aware - about our end of execution */ - fprintf(stderr, " [*] Removing 2 FIFO from server side \n"); - unlink(REVM_FIFO_S2C); - unlink(REVM_FIFO_C2S); - revm_exit(0); - } - } - - /* We are returning from an ERESI function */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_QUIT); -} diff -Nru eresi-0.8a25/libstderesi/cmd/save.c eresi-0.0.20110516/libstderesi/cmd/save.c --- eresi-0.8a25/libstderesi/cmd/save.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/save.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** -** @file save.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:22:35 2003 jfv -** Last update Wed Mar 10 12:32:35 2004 jfv -** -** $Id: save.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Save objects which name is given as parameter - */ -int cmd_save() -{ - char logbuf[BUFSIZ]; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = world.curjob->curcmd->param[0]; - if (elfsh_save_obj(world.curjob->curfile, str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to save object", -1); - snprintf(logbuf, BUFSIZ - 1, "\n [*] Object %s saved successfully \n\n", str); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/script.c eresi-0.0.20110516/libstderesi/cmd/script.c --- eresi-0.8a25/libstderesi/cmd/script.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/script.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,11 +1,11 @@ /** - * @file script.c - * @ingroup libstderesi +* @file libstderesi/cmd/script.c + * @ingroup cmd * Started on Fri May 16 15:18:35 2005 jfv * * * - * $Id: script.c,v 1.1 2007-11-29 14:01:56 may Exp $ + * $Id: script.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -23,23 +23,23 @@ char *path; int size; revmargv_t *cmd; - int argc; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (world.scriptsdir == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No scripts dir specified", -1); cmd = world.curjob->curcmd; - for (argc = 0; cmd->param[argc] != NULL; argc++); - if (!argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", (-1)); + + /* It can happens that the command bounce to cmd_source has already been set up */ + if (!strcmp(world.curjob->curcmd->name, CMD_SOURCE)) + goto end; + /* Setup the command bouncing */ size = strlen(world.scriptsdir) + strlen(world.curjob->curcmd->name) + 6; path = alloca(size); snprintf(path, size, "%s/%s.esh", world.scriptsdir, world.curjob->curcmd->name); backup = world.curjob->curcmd->param[0]; - world.curjob->curcmd->param[0] = path; + world.curjob->curcmd->param[0] = strdup(path); for (idx = 0; idx < REVM_MAXARGC - 1 && backup; idx++) { next = world.curjob->curcmd->param[idx + 1]; @@ -47,6 +47,8 @@ backup = next; } world.curjob->curcmd->name = CMD_SOURCE; + + end: if (cmd_source() < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid ERESI source program", (-1)); @@ -55,8 +57,9 @@ /** - * Set then scriptsdir directory and add cmd corresponding to scripts - * @param dir_name + * @brief Set then scriptsdir directory and add cmd corresponding to scripts + * @param dir_name Directory path where scripts are located. + * @return Success (0) or Error (-1). */ int revm_add_script_cmd(char *dir_name) { diff -Nru eresi-0.8a25/libstderesi/cmd/source.c eresi-0.0.20110516/libstderesi/cmd/source.c --- eresi-0.8a25/libstderesi/cmd/source.c 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/source.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,8 +1,8 @@ /** -** @file source.c -** @ingroup libstderesi +* @file libstderesi/cmd/source.c +** @ingroup cmd ** Started on Fri May 16 15:18:35 2005 jfv -** $Id: source.c,v 1.1 2007-11-29 14:01:56 may Exp $ +** $Id: source.c 1397 2009-09-13 02:19:08Z may $ */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/all-wcprops eresi-0.0.20110516/libstderesi/cmd/.svn/all-wcprops --- eresi-0.8a25/libstderesi/cmd/.svn/all-wcprops 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,305 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/libstderesi/cmd -END -trace.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/trace.c -END -declare.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/declare.c -END -profile.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/profile.c -END -source.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/source.c -END -utils.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/utils.c -END -fileops.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/fileops.c -END -switch.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/switch.c -END -init.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/init.c -END -script.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/script.c -END -types.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/types.c -END -foreach.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/foreach.c -END -hammer.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/hammer.c -END -hashes.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/hashes.c -END -load.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/load.c -END -configure.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/949/trunk/libstderesi/cmd/configure.c -END -unload.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/unload.c -END -quit.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/quit.c -END -prefixes.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/949/trunk/libstderesi/cmd/prefixes.c -END -debug.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/debug.c -END -info.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/info.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/950/trunk/libstderesi/cmd/Makefile -END -match.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/match.c -END -save.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/save.c -END -lists.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/lists.c -END -flowjack.c -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/949/trunk/libstderesi/cmd/flowjack.c -END -vlist.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/vlist.c -END -graph.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/graph.c -END -insert.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/insert.c -END -inspect.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/inspect.c -END -flow.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/flow.c -END -cat.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/949/trunk/libstderesi/cmd/cat.c -END -modules.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/modules.c -END -job.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/949/trunk/libstderesi/cmd/job.c -END -list.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/list.c -END -atomic.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/atomic.c -END -color.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/color.c -END -return.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/return.c -END -log.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/949/trunk/libstderesi/cmd/log.c -END -exec.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/exec.c -END -reflect.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/reflect.c -END -vectors.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/949/trunk/libstderesi/cmd/vectors.c -END -net.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/949/trunk/libstderesi/cmd/net.c -END -jmp.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/949/trunk/libstderesi/cmd/jmp.c -END -fcthijack.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/949/trunk/libstderesi/cmd/fcthijack.c -END -help.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/949/trunk/libstderesi/cmd/help.c -END -inform.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/inform.c -END -define.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/define.c -END -reladd.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/reladd.c -END -print.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/949/trunk/libstderesi/cmd/print.c -END -remove.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/949/trunk/libstderesi/cmd/remove.c -END diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/entries eresi-0.0.20110516/libstderesi/cmd/.svn/entries --- eresi-0.8a25/libstderesi/cmd/.svn/entries 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,628 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libstderesi/cmd -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -trace.c -file - - - - -2008-04-06T23:16:26.174877Z -eecd81d42b11ad92afbe22602750f39b -2008-03-29T06:51:25.416075Z -949 -enioh - -declare.c -file - - - - -2008-04-06T23:16:26.267282Z -12f4c300d4e9a82e32f22e8984423ef7 -2008-03-29T06:51:25.416075Z -949 -enioh - -profile.c -file - - - - -2008-04-06T23:16:26.402005Z -3241d270ba1842fba24a835d984106d0 -2008-03-29T06:51:25.416075Z -949 -enioh - -source.c -file - - - - -2008-04-06T23:16:26.987900Z -fb7e50b7ac55adf1444a8d04b636d7e1 -2008-03-29T06:51:25.416075Z -949 -enioh - -utils.c -file - - - - -2008-04-06T23:16:27.817881Z -8aeb7cf18870e5da84ff405135c193c3 -2008-03-29T06:51:25.416075Z -949 -enioh - -fileops.c -file - - - - -2008-04-06T23:16:27.853221Z -0bf2fae95bb5cd6e726fb7cdd3e53dc9 -2008-03-29T06:51:25.416075Z -949 -enioh - -switch.c -file - - - - -2008-04-06T23:16:27.864893Z -38f404bffd527681b1fe3d69f17594ce -2008-03-29T06:51:25.416075Z -949 -enioh - -init.c -file - - - - -2008-04-06T23:16:27.876506Z -c2dbb2562aad91f123f2dc691e365f6d -2008-03-29T06:51:25.416075Z -949 -enioh - -script.c -file - - - - -2008-04-06T23:16:27.887908Z -a6c18fc8038aa82fa2d4236963efad52 -2008-03-29T06:51:25.416075Z -949 -enioh - -types.c -file - - - - -2008-04-06T23:16:27.898905Z -4d2d7e2089cf59b0e0a5aee79a5360ca -2008-03-29T06:51:25.416075Z -949 -enioh - -foreach.c -file - - - - -2008-04-06T23:16:27.910999Z -662c30cc7f740dbe7fa3d8df3ce80c7c -2008-03-29T06:51:25.416075Z -949 -enioh - -hammer.c -file - - - - -2008-04-06T23:16:27.921904Z -60232afcba8a0f2549518913a0313523 -2008-03-29T06:51:25.416075Z -949 -enioh - -hashes.c -file - - - - -2008-04-06T23:16:27.933915Z -65087658fb7c94ebf42ad1bad9af6d93 -2008-03-29T06:51:25.416075Z -949 -enioh - -load.c -file - - - - -2008-04-06T23:16:27.944903Z -6d27d7cecc54bff7acbe95cef93a285c -2008-03-29T06:51:25.416075Z -949 -enioh - -configure.c -file - - - - -2008-04-06T23:16:27.956877Z -597e4e57d6736af46f0edbe3f1cba0be -2008-03-29T06:51:25.416075Z -949 -enioh - -unload.c -file - - - - -2008-04-06T23:16:27.990877Z -1a95af864b981edeb815da633c919199 -2008-03-29T06:51:25.416075Z -949 -enioh - -quit.c -file - - - - -2008-04-06T23:16:27.979402Z -c4c1547b616469e3fdfcb7d19e811f37 -2008-03-29T06:51:25.416075Z -949 -enioh - -prefixes.c -file - - - - -2008-04-06T23:16:28.001988Z -ed4ae89ec0e9caa4b2e9309ef6cdd187 -2008-03-29T06:51:25.416075Z -949 -enioh - -debug.c -file - - - - -2008-04-06T23:16:28.014181Z -a3e8c28289c268aebe473bec76433a6a -2008-03-29T06:51:25.416075Z -949 -enioh - -info.c -file - - - - -2008-04-06T23:16:28.025641Z -b32a83e6d7e8499d089e7f4728d11269 -2008-03-29T06:51:25.416075Z -949 -enioh - -Makefile -file - - - - -2008-04-06T23:16:28.070876Z -688737d097288ad3b13b113446910dc2 -2008-03-29T07:54:04.209482Z -950 -enioh - -match.c -file - - - - -2008-04-06T23:16:28.036900Z -296bf59a10d678b6edfbc5c797b902c5 -2008-03-29T06:51:25.416075Z -949 -enioh - -save.c -file - - - - -2008-04-06T23:16:28.093876Z -6c6ff20a751b87785f42eb314bedd8bb -2008-03-29T06:51:25.416075Z -949 -enioh - -lists.c -file - - - - -2008-04-06T23:16:28.082239Z -6b0a737703818a9509c91973054f2078 -2008-03-29T06:51:25.416075Z -949 -enioh - -flowjack.c -file - - - - -2008-04-06T23:16:28.105213Z -81bb69ecfd10555ebd025950ddd25ba0 -2008-03-29T06:51:25.416075Z -949 -enioh - -vlist.c -file - - - - -2008-04-06T23:16:28.128210Z -7902837dd820b4fb79e1a3f3184d49f8 -2008-03-29T06:51:25.416075Z -949 -enioh - -graph.c -file - - - - -2008-04-06T23:16:28.116673Z -86ab7c9f339513c116722d8d39c5171c -2008-03-29T06:51:25.416075Z -949 -enioh - -insert.c -file - - - - -2008-04-06T23:16:28.139033Z -e6cf08597b017868c26f2e8750da76ac -2008-03-29T06:51:25.416075Z -949 -enioh - -inspect.c -file - - - - -2008-04-06T23:16:28.150905Z -588666321f01300eeb2e22968b900d0b -2008-03-29T06:51:25.416075Z -949 -enioh - -flow.c -file - - - - -2008-04-06T23:16:28.174140Z -57c6ef2a30fb68e2526b862182e23b17 -2008-03-29T06:51:25.416075Z -949 -enioh - -cat.c -file - - - - -2008-04-06T23:16:28.162623Z -145b11be6cb5e00c9c66f8fbcfc077fb -2008-03-29T06:51:25.416075Z -949 -enioh - -modules.c -file - - - - -2008-04-06T23:16:28.184900Z -fef78117d1543d7ce77df7ed950e6f74 -2008-03-29T06:51:25.416075Z -949 -enioh - -job.c -file - - - - -2008-04-06T23:16:28.196899Z -d09e91a6f7cf9ac2c9dabcbe03245d7b -2008-03-29T06:51:25.416075Z -949 -enioh - -list.c -file - - - - -2008-04-06T23:16:28.208631Z -58f935fb92c16564c9dd7f28090ee9c0 -2008-03-29T06:51:25.416075Z -949 -enioh - -atomic.c -file - - - - -2008-04-06T23:16:28.221652Z -c51fa6d383c06e8fc14e884e13cf87c1 -2008-03-29T06:51:25.416075Z -949 -enioh - -color.c -file - - - - -2008-04-06T23:16:28.233168Z -5e78885d08edf59c7f7680da40159ad3 -2008-03-29T06:51:25.416075Z -949 -enioh - -return.c -file - - - - -2008-04-06T23:16:28.244338Z -a015150d8e27739b3432ec2e7886baef -2008-03-29T06:51:25.416075Z -949 -enioh - -log.c -file - - - - -2008-04-06T23:16:28.256141Z -aef95c2661e2559f94836fd018f81915 -2008-03-29T06:51:25.416075Z -949 -enioh - -exec.c -file - - - - -2008-04-06T23:16:28.266900Z -424076a7aef55f901e877ffe58b72ebe -2008-03-29T06:51:25.416075Z -949 -enioh - -reflect.c -file - - - - -2008-04-06T23:16:28.278900Z -aec76bacfe1b70960ee0bf69b0df9ce7 -2008-03-29T06:51:25.416075Z -949 -enioh - -vectors.c -file - - - - -2008-04-06T23:16:28.290876Z -cdbfc4d70c25498d678d4e297b77d780 -2008-03-29T06:51:25.416075Z -949 -enioh - -net.c -file - - - - -2008-04-06T23:16:28.302175Z -c287347d25496cc70dc4ce20cf5789f0 -2008-03-29T06:51:25.416075Z -949 -enioh - -jmp.c -file - - - - -2008-04-06T23:16:28.313666Z -6a34e19002d1089a994f23d751503ea9 -2008-03-29T06:51:25.416075Z -949 -enioh - -fcthijack.c -file - - - - -2008-04-06T23:16:28.325183Z -642241407ebb2f4a292e4b833bd8e006 -2008-03-29T06:51:25.416075Z -949 -enioh - -help.c -file - - - - -2008-04-06T23:16:28.336876Z -b1c4298026c62b9a80eadc3348070ceb -2008-03-29T06:51:25.416075Z -949 -enioh - -inform.c -file - - - - -2008-04-06T23:16:28.347900Z -30ac1e5b3e0476a6caa6a0c56ca55d27 -2008-03-29T06:51:25.416075Z -949 -enioh - -define.c -file - - - - -2008-04-06T23:16:28.359037Z -b3114286b92be79d66b20a90535785a5 -2008-03-29T06:51:25.416075Z -949 -enioh - -reladd.c -file - - - - -2008-04-06T23:16:28.371133Z -a936de4bdb2ecff5d799881cde6bc256 -2008-03-29T06:51:25.416075Z -949 -enioh - -print.c -file - - - - -2008-04-06T23:16:28.382179Z -8d8fdd35b1729e4114dbb9d1f9a4a345 -2008-03-29T06:51:25.416075Z -949 -enioh - -remove.c -file - - - - -2008-04-06T23:16:28.394051Z -9ee40f7e40b1aa0fb694c25c777bae88 -2008-03-29T06:51:25.416075Z -949 -enioh - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/format eresi-0.0.20110516/libstderesi/cmd/.svn/format --- eresi-0.8a25/libstderesi/cmd/.svn/format 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/atomic.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/atomic.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/atomic.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/atomic.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,530 +0,0 @@ -/** - ** @file atomic.c - ** @ingroup libstderesi - ** @brief Implement arithmetic operations - ** - ** Started on Sun Feb 9 22:43:34 2003 jfv - ** $Id: atomic.c,v 1.4 2008-02-16 12:32:27 thor Exp $ - */ -#include "libstderesi.h" - - - -/* SET command */ -int cmd_set() -{ - revmexpr_t *e1; - revmexpr_t *e2; - int error; - int errvar; - - revmexpr_t *last; - - //revmexpr_t *res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Resolve all possible case between expressions and objects */ - error = -1; - errvar = 0; - e1 = revm_expr_get(world.curjob->curcmd->param[0]); - e2 = revm_expr_get(world.curjob->curcmd->param[1]); - - /* The $_ variable is updated as well */ - last = revm_expr_get(REVM_VAR_RESULT); - if (last == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get result variable", -2); - - /* Assignment between existing expressions */ - if (e1 && e2) - { - errvar = revm_expr_set(e1, e2); - if (errvar < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expressions", (-1)); - - revm_expr_destroy(last->label); - last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); - if (!last) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set result expression", (-1)); - - if (!world.state.revm_quiet) - revm_output(" [*] Expression set succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Fix the source expression if unresolved */ - if (!e2) - { - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create source object", (-1)); - } - - /* Fix the destination expression */ - if (!e1) - { - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1) - { - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination variable", (-1)); - } - } - - /* Set converted value */ - if (e2->value) - { - if (!e1->type && revm_convert_object(e1, e2->type->type) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert destination type expression", (-1)); - } - if (e1->type->type != e2->type->type && - revm_convert_object(e2, e1->type->type) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert source type expression", (-1)); - } - if (revm_expr_set(e1, e2) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression", (-1)); - } - } - - /* Set complex type */ - else - { - if (!e1->type) - { - revm_expr_destroy(e1->label); - e1 = revm_expr_copy(e2, world.curjob->curcmd->param[0], 0); - if (!e1) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expressions", (-1)); - } - } - else if (revm_expr_set(e1, e2) < 0) - { - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set expression", (-1)); - } - } - - /* Copy the result in the last result variable */ - revm_expr_destroy(last->label); - last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); - if (!last) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set result expression", (-1)); - - /* Everything OK */ - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - - if (!world.state.revm_quiet) - revm_output(" [*] Expression set succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Comparison command */ -int cmd_cmp() -{ - revmexpr_t *e1; - revmexpr_t *e2; - char logbuf[BUFSIZ]; - int res; - eresi_Addr val; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First check if we are dealing with exprs */ - e1 = revm_expr_get(world.curjob->curcmd->param[0]); - e2 = revm_expr_get(world.curjob->curcmd->param[1]); - if (e1 && e2) - { - res = revm_expr_compare(e1, e2, &val); - if (res < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to compare expressions", (-1)); - goto end; - } - - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - if (!e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter has type unknown thus uncomparable", -1); - - /* Error checking */ - res = revm_expr_compare(e1, e2, &val); - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - if (res < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while setting result variable", res); - - /* Result reporting */ - end: - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Objects are %s. \n\n", (!val ? "EQUALS" : "INEQUALS")); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Bit testing command */ -int cmd_test() -{ - revmexpr_t *e1; - revmexpr_t *e2; - char logbuf[BUFSIZ]; - u_int res; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - if (!e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameter has type unknown thus uncomparable", -1); - - /* Perform the operation */ - if (revm_testbit(e1, e2, &res) < 0) - { - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while setting result variable", -1); - } - - if (e1->value && !e1->value->perm) - revm_expr_destroy(e1->label); - if (e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - - /* Everything was OK */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] $_ = %u \n\n", res); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/************************ Now arithmetic commands *****************/ - - - -/* ADD command */ -int cmd_add() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - o1 = e1->value; - o2 = e2->value; - - /* In case we have a hash table as parameter */ - if (o1->otype->type == ASPECT_TYPE_HASH) - { - ret = revm_hash_add(o1->parent, e2); - revm_expr_destroy(e1->label); // destroy the source alias variable - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert hash element", -1); - if (!world.state.revm_quiet) - revm_output(" [*] Element inserted succesfully\n\n"); - goto end; - } - - /* In case we have a hash table as parameter */ - else if (o1->otype->type == ASPECT_TYPE_LIST) - { - ret = revm_elist_add(o1->parent, e2); - revm_expr_destroy(e1->label); // destroy the source alias variable - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert list element", -1); - if (!world.state.revm_quiet) - revm_output(" [*] Element inserted succesfully\n\n"); - goto end; - } - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_ADD) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add elements", -1); - } - - /* Return success */ - end: - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/* SUB command */ -int cmd_sub() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - o1 = e1->value; - o2 = e2->value; - - /* In case we have a hash table as parameter */ - if (o1->otype->type == ASPECT_TYPE_HASH) - { - ret = revm_hash_del(o1->parent, e2); - if (ret < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to delete hash element", -1); - } - if (!world.state.revm_quiet) - revm_output(" [*] Element deleted succesfully\n\n"); - goto end; - } - - /* In case we have a hash table as parameter */ - else if (o1->otype->type == ASPECT_TYPE_LIST) - { - ret = revm_elist_del(o1->parent, e2); - if (ret < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to delete list element", -1); - } - if (!world.state.revm_quiet) - revm_output(" [*] Element deleted succesfully\n\n"); - goto end; - } - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_SUB) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to substract elements", -1); - } - - end: - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* MUL command */ -int cmd_mul() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_MUL) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to multiply elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* DIV command */ -int cmd_div() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_DIV) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to divide elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* MOD command */ -int cmd_mod() -{ - revmexpr_t *e1; - revmexpr_t *e2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2) - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1) - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to lookup parameters", -1); - - /* Perform computation */ - if (revm_arithmetics(e1, e2, REVM_OP_MOD) < 0) - { - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to divide elements", -1); - } - - /* Everything was OK */ - if (e2 && e2->value && !e2->value->perm) - revm_expr_destroy(e2->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/cat.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/cat.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/cat.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/cat.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** @file cat.c -** @ingroup libstderesi -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Thu Jan 04 11:26:11 2007 jfv -** -** $Id: cat.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/* Simple internal cat builtin */ -int cmd_cat() -{ - char *tocat; - char buf[BUFSIZ]; - int fd; - int len = 0; - int tmplen = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - tocat = revm_lookup_string(world.curjob->curcmd->param[0]); - if ((fd = open(tocat, O_RDONLY, 0)) < 0) - { - revm_output("Can't open file\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Open failed", (-1)); - } - - while (1) - { - tmplen = read(fd, buf + len, 1); - if (tmplen < 0) - { - XCLOSE(fd,0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Read failed", (-1)); - } - if (tmplen == 0) - break; - len += tmplen; - if (len > BUFSIZ - 1) - { - XCLOSE(fd, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "File too long", (-1)); - } - } - - buf[len] = '\0'; - revm_output(buf); - revm_output("\n"); - - XCLOSE(fd, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/color.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/color.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/color.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/color.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/** -** @file color.c -** @ingroup libstderesi -** @brief All functions about colors -** -** Started on Sept 11 2005 mxatone -** -** $Id: color.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - -/* Use setcolor */ -int cmd_color() -{ - u_int fg, bg, bd, ul, f, z, icolor; - color_t *ex; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* - revmworld_t *pworld = &world; - revmjob_t *pcurjob = pworld->curjob; - revmargv_t *pcurcmd = pcurjob->curcmd; - char *param0 = pcurcmd->param[0]; - char *param1 = pcurcmd->param[1]; - char *param2 = pcurcmd->param[2]; - */ - - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL || - world.curjob->curcmd->param[2] == NULL) - { - revm_output(" [!] Need 3 paramters\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 3 parameters", -1); - } - - ex = hash_get(&t_color_hash, world.curjob->curcmd->param[0]); - if (ex == NULL) - { - revm_output(" [!] Unknown type\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown type", -1); - } - - fg = strcmp(world.curjob->curcmd->param[1], "fg"); - bg = strcmp(world.curjob->curcmd->param[1], "bg"); - bd = strcmp(world.curjob->curcmd->param[1], "bold"); - ul = strcmp(world.curjob->curcmd->param[1], "underline"); - - if (fg && bg && bd && ul) - { - revm_output(" [!] Need fg, bg, bold or underline\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need fg, bg, bold or underline", -1); - } - - if (!fg || !bg) - { - if (!fg) - icolor = (u_int) hash_get(&fg_color_hash, - world.curjob->curcmd->param[2]); - else - icolor = (u_int) hash_get(&bg_color_hash, - world.curjob->curcmd->param[2]); - - if (icolor == 0) - { - revm_output(" [!] Unknown color (see help for list)\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown color", -1); - } - - if (icolor == COLOR_RESET) - icolor = COLOR_NONE; - - if (!fg) - ex->fground = icolor; - else - ex->bground = icolor; - } - else if (!bd || !ul) - { - f = strcmp(world.curjob->curcmd->param[2], "1"); - z = strcmp(world.curjob->curcmd->param[2], "0"); - - if (f && z) - { - revm_output(" [!] Need 1 or 0 (1 = true, 0 = false)\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need 1 or 0 (1 = true, 0 = false)", -1); - } - - if (!f) - icolor = 1; - else - icolor = 0; - - if (!bd) - ex->bold = icolor; - else - ex->underline = icolor; - } - - if (!world.state.revm_quiet) - revm_output(" [*] Color modified succesfully\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_nocolor() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (nocolor == 0) - { - revm_output(" [*] Color enabled succesfully\n\n"); - nocolor = 1; - } - else - { - revm_output(" [*] Color disabled succesfully\n\n"); - nocolor = 0; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/configure.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/configure.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/configure.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/configure.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/** - * @file configure.c - * @ingroup libstderesi - * @brief ELFsh/vm configure related code - * 2006 thorkill, Asgard Labs Inc. - * - * $Id: configure.c,v 1.1 2007-11-29 14:01:56 may Exp $ - */ -#include "libstderesi.h" - -int cmd_configure() -{ - configitem_t *ci; - int cnt; - int idx; - char **tab; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We list the configuration */ - if (world.curjob->curcmd->argc < 2) - { - tab = hash_get_keys(&aspectworld.config_hash, &cnt); - - printf(" [*] Configure parameters\n\n"); - - for (idx = 0; idx < cnt; idx++) - { - ci = hash_get(&aspectworld.config_hash, tab[idx]); - - if (ci->type == CONFIG_TYPE_INT) - printf(" [+] (%2s) %-30s : %d\n", - (ci->mode == CONFIG_MODE_RW) ? "RW" : "RO", - ci->name, ci->val); - - if (ci->type == CONFIG_TYPE_STR) - printf(" [+] (%2s) %-30s : %s\n", - (ci->mode == CONFIG_MODE_RW) ? "RW" : "RO", - ci->name, (char *) ci->data); - } - printf("\n"); - } - - /* We change a configuration option */ - else - { - ci = hash_get(&aspectworld.config_hash, world.curjob->curcmd->param[0]); - - if (ci != NULL) - { - if (ci->mode == CONFIG_MODE_RO) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot update a READONLY key", (-1)); - - if (ci->type == CONFIG_TYPE_INT) - config_update_key(ci->name, - (void *) atoi(world.curjob->curcmd->param[1])); - - if (ci->type == CONFIG_TYPE_STR) - config_update_key(ci->name, - (void *) world.curjob->curcmd->param[1]); - - printf(" [*] setting new configuration value for %s to %s\n\n", - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Configuration key not found.", (-1)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/debug.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/debug.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/debug.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/debug.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,322 +0,0 @@ -/* -** @file debug.c -** @ingroup libstderesi -** @brief All functions dealing with libedfmt uni debugging format -** -** Started on Fev 25 2007 mxatone -** -** $Id: debug.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -char buf[BUFSIZ]; -char tmpbuf[BUFSIZ]; -char filebuf[BUFSIZ]; - -char *file_title = NULL; -char *type_title = NULL; -char *var_title = NULL; - -int matched; - -/** - * @todo Complete doxygen tag - * @param type - * @return - */ -static char *revm_debug_typename(u_int type) -{ - char *str; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch(type) - { - case EDFMT_TYPE_UNK: - str = "?"; - break; - case EDFMT_TYPE_BASIC: - str = "basic"; - break; - case EDFMT_TYPE_ARRAY: - str = "array"; - break; - case EDFMT_TYPE_PTR: - str = "ptr"; - break; - case EDFMT_TYPE_STRUCT: - str = "struct"; - break; - case EDFMT_TYPE_UNION: - str = "union"; - break; - case EDFMT_TYPE_ATTR: - str = "attr"; - break; - case EDFMT_TYPE_VOID: - str = "void"; - break; - case EDFMT_TYPE_LINK: - str = "link"; - break; - default: - str = "?????"; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, str); -} - -/** - * @todo Complete doxygen tags - * @param vars - * @param rx - * @return - */ -static int revm_debug_print_var(edfmtvar_t *vars, regex_t *rx) -{ - edfmtvar_t *var; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (var = vars; var != NULL; var = var->next) - { - snprintf(buf, BUFSIZ - 1, " %s%s %s%s %s%s => %s\n", - revm_colorfieldstr("scope:"), - revm_colornumber("%u", var->scope), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-20s", var->name), - revm_colorfieldstr("addr:"), - revm_coloraddress(XFMT, var->addr), - revm_colorstr(var->type->name)); - revm_endline(); - - if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) - { - /* Print file title only once */ - if (file_title) - { - revm_output(file_title); - file_title = NULL; - } - - /* Print var title only once */ - if (var_title) - { - revm_output(var_title); - var_title = NULL; - } - - revm_output(buf); - matched++; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @todo Complete doxygen tags - * @param types - * @param tab - * @param rx - * @return - */ - -static int revm_debug_print_type(edfmttype_t *types, u_int tab, regex_t *rx) -{ - edfmttype_t *type; - u_int index; - u_int added = 0; - u_int bufsiz = 0; - int len; - int save_matched; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (type = types; type != NULL; type = type->next) - { - buf[0] = tmpbuf[0] = 0x00; - - len = snprintf(tmpbuf, BUFSIZ - 1, - " %s%s %s%s %s%s %s%s %s%s %s%s ", - revm_colorfieldstr("type:"), - revm_colortypestr_fmt("%-10s", revm_debug_typename(type->type)), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-20s", type->name), - revm_colorfieldstr("offset:"), - revm_colornumber("%04u", type->start), - revm_colorfieldstr("size:"), - revm_colornumber("%04u", type->size), - revm_colorfieldstr("parsed:"), - revm_colortypestr_fmt("%-4s", type->parsed ? "yes" : "no"), - revm_colorfieldstr("valid:"), - revm_colortypestr_fmt("%-4s", type->valid ? "yes" : "no")); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - - if (type->type != EDFMT_TYPE_ATTR && type->parent) - { - snprintf(tmpbuf, BUFSIZ - 1, - "%s%s ", - revm_colorfieldstr("parent:"), - revm_colorstr_fmt("%-10s", type->parent->name)); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - } - - if (type->type == EDFMT_TYPE_ATTR && type->child) - { - snprintf(tmpbuf, BUFSIZ - 1, - "%s%s ", - revm_colorfieldstr("child:"), - revm_colorstr_fmt("%-10s", type->child->name)); - revm_endline(); - - if (bufsiz + len < BUFSIZ) - { - strcat(buf, tmpbuf); - bufsiz += len; - } - } - - /* Print only if it match a submited regex */ - if (rx == NULL || !regexec(rx, buf, 0, 0, 0)) - { - /* Print file title only once */ - if (file_title) - { - revm_output(file_title); - file_title = NULL; - } - - /* Print type title only once */ - if (type_title) - { - revm_output(type_title); - type_title = NULL; - } - - if (tab > 0 && added == 0) - { - revm_output(" .: Childs\n"); - } - else if (added > 0 && type->type != EDFMT_TYPE_ATTR && type->child) - revm_output("\n"); - - added = 1; - - for (index = 0; index < tab; index++) - revm_output(" "); - - revm_output(buf); - revm_output("\n"); - matched++; - - /* We will print childs without match anything */ - save_matched = matched; - - /* Print childs if we got some (without regex) */ - if (type->type != EDFMT_TYPE_ATTR && type->child) - revm_debug_print_type(type->child, tab+1, NULL); - - matched = save_matched; - } - else - { - /* Print childs if we got some (with regex) */ - if (type->type != EDFMT_TYPE_ATTR && type->child) - revm_debug_print_type(type->child, tab+1, rx); - } - } - - if (added) - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -static int revm_debug_unit_print_file(edfmtfile_t *files, regex_t *rx) -{ - edfmtfile_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (file = files; file != NULL; file = file->next) - { - snprintf(filebuf, BUFSIZ - 1, - "\n <: %s %s %s %s\n", - revm_colorfieldstr("File:"), - revm_colorstr_fmt("%-20s", file->name), - file->parent ? revm_colorfieldstr("Parent:") : "", - file->parent ? revm_colorstr(file->parent->name) : ""); - file_title = filebuf; - revm_endline(); - - type_title = "\n .: Types :. \n\n"; - var_title = "\n .: Vars :. \n\n"; - - revm_debug_print_type(file->types, 0, rx); - revm_debug_print_var(file->vars, rx); - - if (file->child) - revm_debug_unit_print_file(file->child, rx); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_debug() -{ - char *regexname = NULL; - regex_t rx, *submit_rx = NULL; - edfmtinfo_t *info; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc > 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Too many arguments for debug command", -1); - - matched = 0; - - /* Support filter by regex */ - if (world.curjob->curcmd->param[0]) - { - regexname = world.curjob->curcmd->param[0]; - - if (regcomp(&rx, regexname, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - submit_rx = ℞ - } - - info = edfmt_get_uniinfo(world.curjob->curfile); - - if (!info) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No informations on this file", -1); - - type_title = "\n .: Global Types :. \n\n"; - var_title = "\n .: Global Vars :. \n\n"; - - revm_debug_print_type(info->types, 0, submit_rx); - revm_debug_print_var(info->vars, submit_rx); - - revm_debug_unit_print_file(info->files, submit_rx); - - snprintf(buf, BUFSIZ - 1, " [*] Matched %u entries \n\n", matched); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/declare.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/declare.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/declare.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/declare.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,106 +0,0 @@ -/* -** @file declare.c -** @ingroup libstderesi -** @brief Command used to declare a new typed variable in the environment -** -** Started on Fri Jun 22 07:23:58 2007 jfv -** $Id: declare.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - - - -/* Declare a new typed variable */ -int cmd_declare() -{ - aspectype_t *type; - char *varname; - char buf[BUFSIZ]; - u_int curlen; - u_int curidx; - u_int curpidx; - u_int openbrace; - u_int closebrace; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (world.curjob->curcmd->argc < 3 || - strcmp(world.curjob->curcmd->param[1], "=")) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for command", -1); - - /* Preliminary checks */ - type = aspect_type_get_by_name(world.curjob->curcmd->name); - if (!type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown type for new variable", -1); - - /* Create the new data structure */ - bzero(buf, BUFSIZ); - - /* Create a unique string for the value of the object */ - for (openbrace = closebrace = curlen = 0, curidx = 2; - world.curjob->curcmd->param[curidx]; - curidx++, curlen += curpidx) - for (curpidx = 0; world.curjob->curcmd->param[curidx][curpidx]; - curpidx++) - switch (world.curjob->curcmd->param[curidx][curpidx]) - { - case '(': - *(buf + curlen + curpidx) = '('; - openbrace++; - break; - case ')': - *(buf + curlen + curpidx) = ')'; - closebrace++; - if (closebrace > openbrace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid closing structure for variable", -1); - break; - case ' ': - *(buf + curlen + curpidx) = ','; - break; - default: - *(buf + curlen + curpidx) = world.curjob->curcmd->param[curidx][curpidx]; - break; - } - - /* Some first checks on the value */ - if (closebrace != openbrace) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid nesting structure for variable", -1); - -#if __DEBUG_EXPRS__ - fprintf(stderr, "Expression to write in variable: %s \n", buf); -#endif - - curlen = strlen(world.curjob->curcmd->param[0]); - varname = alloca(curlen + 2); - snprintf(varname, curlen + 2, "$%s", world.curjob->curcmd->param[0]); - - /* Perform the real operation now */ - if (type->childs) - { - if (!revm_expr_create(type, varname, buf)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid value for variable", -1); - } - else - { - if (!revm_simple_expr_create(type, varname, buf)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid value for variable", -1); - } - - /* Print success */ - if (!world.state.revm_quiet) - { - snprintf(buf, sizeof(buf), - " [*] Variable %s succesfully initialized \n\n", - world.curjob->curcmd->param[0]); - revm_output(buf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/define.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/define.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/define.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/define.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/* -** @file define.c -** @ingroup libstderesi. -** @brief Allow constant values to be defined on names. -** -** Start on Fri Aug 3 03:55:45 2007 jfv -** -** $Id: define.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - - - -/* Define a new value as constant */ -int cmd_define() -{ - revmexpr_t *orig; - revmexpr_t *obj; - revmconst_t *cons; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - if (world.curjob->curcmd->argc < 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - orig = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!orig || !orig->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input parameter", -1); - orig->value->perm = 1; - - /* Create a new constant entry */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, cons, sizeof(revmconst_t), -1); - cons->desc = "Automatically generated constant define"; - cons->name = world.curjob->curcmd->param[0]; - - /* Add many values to create a define */ - if (world.curjob->curcmd->argc != 2) - for (index = 2; index < world.curjob->curcmd->argc; index++) - { - obj = revm_lookup_param(world.curjob->curcmd->param[index]); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input parameters", -1); - if (revm_arithmetics(orig, obj, REVM_OP_ADD) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to add values to be defined", -1); - revm_expr_destroy(obj->label); - } - - /* Finally put the value up */ - cons->val = orig->value->immed_val.ent; - revm_expr_destroy(orig->label); - hash_add(&const_hash, world.curjob->curcmd->param[0], cons); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/* Undefine a constant value */ -int cmd_undef() -{ - revmconst_t *cons; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cons = hash_get(&const_hash, world.curjob->curcmd->param[0]); - if (!cons) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown defined value", -1); - XFREE(__FILE__, __FUNCTION__, __LINE__, cons); - hash_del(&const_hash, world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/exec.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/exec.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/exec.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/exec.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -/** -** @file exec.c -** @ingroup libstderesi -** Started on Tue Feb 18 13:03:14 2003 jfv -** -** $Id: exec.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - -/* Fork and execve the stuff */ -int cmd_exec() -{ - int status; - char buf[BUFSIZ] = ""; - int i; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_terminal_unprepare(world.state.revm_mode); - - for (i = 0; world.curjob->curcmd->param[i]; i++) - { - strncat (buf, " ", BUFSIZ); - strncat (buf, world.curjob->curcmd->param[i], BUFSIZ); - } - - switch (status = revm_system (buf)) - { - case 0: - revm_output("\n [*] Command executed successfully \n\n"); - break; - default: - revm_output("\n [E] Command failed\n\n"); - } - - revm_terminal_prepare(world.state.revm_mode); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - status); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/fcthijack.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/fcthijack.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/fcthijack.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/fcthijack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,166 +0,0 @@ -/* -** @file fcthijack.c -** @ingroup libstderesi -** Started on Thu Jun 19 17:02:55 2003 jfv -** -** $Id: fcthijack.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - - -/* Redirect a function on a OS independant manner */ -int cmd_hijack() -{ - elfsh_Sym *dst; - eresi_Addr addr; - int err; - char *rev; - char logbuf[BUFSIZ]; - - elfshredir_t *redir; - listent_t *actual; - int idx; - int idx2; - int printed; - eresi_Addr hookedaddr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If no parameter is given, print the redirection list */ - if (!world.curjob->curcmd->param[0]) - { - printed = 0; - - /* Simple printing */ - for (idx2 = idx = 0; idx < world.curjob->curfile->redir_hash.size; idx++) - for (actual = world.curjob->curfile->redir_hash.ent + idx; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - redir = (elfshredir_t *) actual->data; - - if (!printed) - { - revm_output("\t .::. ELFsh redirection list \n\n"); - printed = 1; - } - snprintf(logbuf, BUFSIZ, - "\t [%02u] TYPE:%-6s [" AFMT "] <%s> redirected on [" AFMT "] <%s> \n", - idx2, (redir->type == ELFSH_REDIR_CFLOW ? "CFLOW" : - redir->type == ELFSH_REDIR_ALTPLT ? "ALTPLT" : - redir->type == ELFSH_REDIR_ALTGOT ? "ALTGOT" : "UNK"), - redir->addr[0], redir->name[0], redir->addr[1], redir->name[1]); - - revm_output(logbuf); - idx2++; - } - - /* End message */ - if (!printed) - revm_output("\t .::. No redirection performed on current file \n\n"); - else - revm_output("\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Some sanity checks first */ - if (!world.curjob->curcmd->param[1]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Redirection destination needed", (-1)); - - /* Resolve destination parameter */ - dst = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]); - if (!dst) - { - elfsh_toggle_mode(); - dst = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]); - elfsh_toggle_mode(); - } - - /* If not found */ - if (dst == NULL) - { - err = sscanf(world.curjob->curcmd->param[1], XFMT, - (eresi_Addr *) &addr); - - /* If the hook function is not supplied as an address */ - if (err != 1 && elfsh_dynamic_file(world.curjob->curfile)) - { - elfsh_setup_hooks(); - - /* First bootstrap ALTPLT if not done */ - err = elfsh_copy_plt(world.curjob->curfile, - elfsh_get_pagesize(world.curjob->curfile)); - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed at copying PLT", (-1)); - - /* Request a PLT entry since we have no symbol yet */ - dst = elfsh_request_pltent(world.curjob->curfile, - world.curjob->curcmd->param[1]); - if (dst) - addr = dst->st_value; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT entry request failed", (-1)); - } - - /* Insert a symbol on the requested address to avoid this */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need a symbol to redirect", -1); - - rev = revm_reverse(world.curjob->curfile, addr); - } - - /* The first resolution worked, we take the address */ - else - { - addr = dst->st_value; - rev = NULL; - } - -#if __DEBUG_HIJACK__ - printf("[cmd_hijack] Resolved %s as %08X \n", - world.curjob->curcmd->param[1], addr); -#endif - - /* Hijack function */ - err = elfsh_hijack_function_by_name(world.curjob->curfile, - ELFSH_HIJACK_TYPE_FLOW, - world.curjob->curcmd->param[0], - addr, &hookedaddr); - - /* Last checks */ - if (err < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function redirection failed", (-1)); - - /* Add it to redirection hash table */ - redir = revm_create_REDIR((u_char) err, world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], hookedaddr, addr); - hash_add(&world.curjob->curfile->redir_hash, - world.curjob->curcmd->param[0], - (void *) redir); - - /* Print final information */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [*] Function %s redirected to addr " XFMT " <%s> \n\n", - world.curjob->curcmd->param[0], (eresi_Addr) addr, - (rev == NULL ? world.curjob->curcmd->param[1] : rev)); - revm_output(logbuf); - } - if (rev != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,rev); - - /* Everything is ok */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/fileops.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/fileops.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/fileops.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/fileops.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,239 +0,0 @@ -/* -** @file fileops.c -** @ingroup libstderesi -** Started on Thu Feb 13 04:06:45 2003 jfv -** Last update Wed Mar 10 12:31:49 2004 jfv -** -** $Id: fileops.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - -/* Write command */ -int cmd_write() -{ - revmexpr_t *e1; - revmexpr_t *e2; - revmobj_t *o1; - revmobj_t *o2; - elfshsect_t *cur; - void *dat; - int size; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - if (world.curjob->curcmd->param[0] == NULL || - world.curjob->curcmd->param[1] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Needs 2 parameters", -1); - e1 = revm_lookup_param(world.curjob->curcmd->param[0]); - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameters must be initialized scalar objects", -1); - o1 = e1->value; - o2 = e2->value; - - /* Type checking */ - if (o1->otype->type != ASPECT_TYPE_RAW && o1->otype->type != ASPECT_TYPE_STR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Parameters must be STR or RAW typed", - -1); - else if (o1->immed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Dest. param. must not be a constant", -1); - - /* Convert Integers into raw data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - if (revm_convert_object(e2, ASPECT_TYPE_RAW) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to convert dest object to RAW", (-1)); - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - cur = o2->parent; - size = (o2->immed ? o2->size : o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : - world.curjob->curcmd->param[2] ? - revm_lookup_index(world.curjob->curcmd->param[2]) : - cur->shdr->sh_size - o2->off); - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - /* Write the destination buff */ - if (o1->set_data(o1->parent, o1->off, dat, size, o1->sizelem) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to set data", (-1)); - - /* Print stuff and return */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Written %u bytes \n\n", size); - revm_output(logbuf); - } - - if (!o2->perm) - XFREE(__FILE__, __FUNCTION__, __LINE__,o2); - if (!o1->perm) - XFREE(__FILE__, __FUNCTION__, __LINE__,o1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Append command : 2 parameters, a section and the string to be appended */ -int cmd_append() -{ - elfshsect_t *sect; - revmobj_t *o2; - revmexpr_t *e2; - elfshsect_t *cur; - u_int size; - char *dat; - int index = -1; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch section using the first argument */ - if (revm_isnbr(world.curjob->curcmd->param[0])) - { - index = atoi(world.curjob->curcmd->param[0]); - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert section value !", -1); - sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); - } - else - sect = elfsh_get_section_by_name(world.curjob->curfile, world.curjob->curcmd->param[0], - NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested section", -1); - - /* Object retreive */ - e2 = revm_lookup_param(world.curjob->curcmd->param[1]); - if (!e2 || !e2->value || !e2->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination object", (-1)); - o2 = e2->value; - - /* Convert Integers into string data */ - if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) - { - revm_convert_object(e2, ASPECT_TYPE_RAW); - if (o2->otype->type != ASPECT_TYPE_RAW || !o2->perm) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid destination object", (-1)); - } - - /* Get the source buff */ - dat = (o2->immed ? o2->immed_val.str : - o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : - o2->get_data(o2->parent, o2->off, o2->sizelem)); - - /* Set size */ - cur = o2->parent; - size = (o2->immed ? o2->size : - o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : - cur->shdr->sh_size - o2->off); - if (size <= 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Source offset too big", -1); - - /* Append the data for real */ - if (elfsh_append_data_to_section(sect, dat, size) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to append data to section", (-1)); - - /* Print msg */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Appended %u bytes to section %s\n\n", size, sect->name); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Extend command : 2 parameters, a section and the extansion size */ -int cmd_extend() -{ - elfshsect_t *sect; - u_int size; - char *new_data; - int index = -1; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch section using first argument */ - if (revm_isnbr(world.curjob->curcmd->param[0])) - { - index = atoi(world.curjob->curcmd->param[0]); - if (!index) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot convert section value", - -1); - sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); - } - else - sect = elfsh_get_section_by_name(world.curjob->curfile, - world.curjob->curcmd->param[0], - NULL, NULL, NULL); - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find requested section", -1); - size = atoi(world.curjob->curcmd->param[1]); - - /* Extend the section with NUL bytes */ - if (!size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Extend size cannot be 0", -1); - XALLOC(__FILE__, __FUNCTION__, __LINE__,new_data, size, -1); - - if (elfsh_append_data_to_section(sect, new_data, size) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,new_data); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to append data", -1); - } - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Extended %s by %u bytes\n\n", sect->name, size); - revm_output(logbuf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Request to fixup the bss from command line */ -int cmd_fixup() -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curfile == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - if (elfsh_fixup_bss(world.curjob->curfile) != NULL) - { - revm_output(" [*] BSS fixed up\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to fixup BSS", (-1)); -} - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/flow.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/flow.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/flow.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/flow.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -/** -** @file flow.c -** @ingroup libstderesi -** Original author : sk for the modflow of elfsh -** -** @brief Merged in the ELFsh VM by the ELFsh crew. -** -** -** $Id: flow.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/***************************************************************************** - * High level block analysis. - * - * this function builds a linked list of function - * which each contains a list linked of blocks - * - * for each block, - * - * until a new block starting a function, current blocks - * are supposed to be part of current function - * - ************************************************************************/ - - -void elfsh_help() -{ - printf(" flow \n" - " Launch control flow analysis. \n" - " \n" - " graph {+} \n" - " Dump graph in file from starting \n" - " address min to ending address \n" - " ie: graph debfunc.gvz func +200 \n" - " ie: graph 0x805de40 0x805ff00 \n" - " \n" - " inspect \n" - " \n" - " flowjack \n" - " All relative call to oldsymbol \n" - " are hijacked to newsymbol \n" - " \n" - " addgoto \n" - " 'redirect' for functions called \n" - " trough a pointer \n" - " \n"); -} - - -/** - * Manually add function pointer information - */ -int cmd_addgoto(void) -{ - if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) - return (-1); - - printf(" [*] at %s goto %s\n", - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - - hash_del(&goto_hash, world.curjob->curcmd->param[0]); - hash_add(&goto_hash, world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - return (0); -} - -/** - * Print the control information - */ -int cmd_control() -{ - elfshsect_t *sect; - elfshobj_t *current; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - current = world.curjob->curfile; - sect = elfsh_get_section_by_name(current, - ELFSH_SECTION_NAME_EDFMT_BLOCKS, - 0, 0, 0); - if (!sect || !hash_size(&world.mjr_session.cur->blkhash)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No control flow section found", -1); - - mjr_blocks_display(world.mjr_session.cur, 1); - revm_output("\n [*] Control flow information dumped \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* Change the graph verbose level */ -int cmd_setgvl(void) -{ - world.state.revm_gvl = atoi(world.curjob->curcmd->param[0]); - return (0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/flowjack.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/flowjack.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/flowjack.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/flowjack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -/* -** @file flowjack.c -** @ingroup libstderesi -** Author : -** -** December 10 2006 : merged from modflow to the ELFsh vm -may -** December 31 2006 : factored and cleaned code -may -** -** $Id: flowjack.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/* Perform hijack of basic blocks */ -int cmd_flowjack(void) -{ - container_t *cntnr_to_hijack; - mjrblock_t *to_hijack, *cal; - mjrlink_t *caller; - unsigned long addr; - elfshsect_t *sect; - elfsh_Sym *sym; - char *buffer; - char *name; - int index; - asm_instr ins; - elfsh_SAddr off; - unsigned long new_addr; - u_int value; - elfshobj_t *file; - char *param; - unsigned int size; - unsigned int foff; - - list_t *linklist; - listent_t *listent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sect = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_EDFMT_BLOCKS, - 0, 0, 0); - - if (!sect || !world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Lookup parameters */ - file = world.curjob->curfile; - param = world.curjob->curcmd->param[0]; - sym = elfsh_get_metasym_by_name(file, param); - if (sym) - addr = sym->st_value; - else - addr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[1]))) - new_addr = sym->st_value; - else - new_addr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - /* Errors cases */ - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve first parameter", -1); - if (!new_addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve second parameter", -1); - - /* Retreive bloc to be hijacked */ - printf(" * patch blocks calling %08x\n", (int) addr); - cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, 0); - if (!cntnr_to_hijack) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to match hijacked block", -1); - - /* For each caller, modify the location beeing called */ - linklist = cntnr_to_hijack->inlinks; - for (buffer = 0, listent = linklist->head; listent; listent = listent->next) - { - caller = (mjrlink_t *) listent->data; - name = elfsh_reverse_metasym(world.curjob->curfile, addr, &off); - printf(" [*] patching block %s + " DFMT "\n", name, off); - - cal = mjr_lookup_container(world.mjr_session.cur, caller->id)->data; - - cntnr_to_hijack = mjr_block_get_by_vaddr(world.mjr_session.cur, cal->vaddr, 1); - to_hijack = cntnr_to_hijack->data; - - size = to_hijack->size - (cal->vaddr - to_hijack->vaddr); - foff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, cal->vaddr); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, buffer, size, -1); - elfsh_raw_read(world.curjob->curfile, foff, buffer, size); - asm_read_instr(&ins, (u_char *) buffer, size, &world.proc); - - puts(" [*] would patch -> "); - name = elfsh_reverse_metasym(world.curjob->curfile, cal->vaddr, &off); - - index = cal->vaddr - to_hijack->vaddr; - revm_instr_display(-1, 0, cal->vaddr, 0, size, name, off, buffer); - - /* Patching instruction operand */ - asm_operand_get_immediate(&ins, 1, 0, &value); - if (ins.op[0].type == ASM_OTYPE_JUMP) - { - value = cal->vaddr + asm_instr_len(&ins); - value = new_addr - value; - asm_operand_set_immediate(&ins, 1, 0, &value); - } - else - { - puts(" ! operand type not supported"); - continue; - } - - /* display for debug */ - puts(" * patched ->"); - revm_instr_display(-1, 0, cal->vaddr, 0, size, name, off, buffer); - elfsh_raw_write(world.curjob->curfile, foff, buffer, size); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (0)); -} - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/foreach.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/foreach.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/foreach.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/foreach.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,300 +0,0 @@ -/* -** @file foreach.c -** @ingroup libstderesi -** @brief Implement the iteration on arrays, lists, and hash tables. -** -** Started on Wed Feb 28 19:19:04 2007 jfv -** -** $Id: foreach.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/* Start an iteration */ -int cmd_foreach() -{ - revmexpr_t *indexpr; - revmobj_t *var; - u_char flag; - char **keys; - int keynbr; - hash_t *table; - list_t *list; - int index; - void *elem; - int infbound; - int upbound; - u_int typeid; - eresi_Addr lastvalue; - char *setname; - revmexpr_t *setexpr; - revmobj_t *setobj; - char *typename; - char *indname; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - table = NULL; - list = NULL; - - /* Depends the mode we are in */ - flag = (world.curjob->curcmd->argc == 3 ? 1 : - world.curjob->curcmd->use_regx[0] ? 2 : 3); - - /* Create or get the induction variable */ - indexpr = revm_lookup_var(world.curjob->curcmd->param[0]); - if (!indexpr) - { - if (world.curjob->curcmd->listidx != REVM_IDX_UNINIT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find induction variable", -1); - var = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 1, 0); - indexpr = revm_expr_create_from_object(var, world.curjob->curcmd->param[0]); - } - else - var = indexpr->value; - - /* Perform subcommand */ - switch (flag) - { - /* foreach elmvar of list/hash [as regx] */ - case 1: - case 2: - - /* First try to lookup the container name */ - setexpr = revm_lookup_param(world.curjob->curcmd->param[2]); - setobj = (setexpr && setexpr->type ? setexpr->value : NULL); - setname = NULL; - if (setobj) - { - if (setobj->otype->type == ASPECT_TYPE_STR) - setname = (setobj->immed ? setobj->immed_val.str : - setobj->get_name(setobj->root, setobj->parent)); - else if (setobj->otype->type == ASPECT_TYPE_HASH || - setobj->otype->type == ASPECT_TYPE_LIST) - { - setname = (setobj->kname ? setobj->kname : setobj->hname); - if (!setname && setobj->otype->isptr) - { - if (setobj->otype->type == ASPECT_TYPE_HASH) - { - table = (hash_t *) (setobj->immed ? setobj->immed_val.ent : - setobj->get_obj(setobj->parent)); - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find table name", -1); - setname = table->name; - } - else if (setobj->otype->type == ASPECT_TYPE_LIST) - { - list = (list_t *) (setobj->immed ? setobj->immed_val.ent : - setobj->get_obj(setobj->parent)); - if (!list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find list name", -1); - setname = list->name; - } - } - } - } - else - setname = world.curjob->curcmd->param[2]; - if (!setname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find iterator name", -1); - setname = strdup(setname); - if (setexpr) - revm_expr_destroy(setexpr->label); - - fprintf(stderr, "Found setname = %s in foreach ! \n", setname); - - /* Try to find a hash or a list out of this variable */ - table = hash_find(setname); - if (!table) - { - list = elist_find(setname); - if (!list) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find hash table", -1); - } - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT && elist_linearity_get(list)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot iterate again on linearly typed list", -1); - } - elist_linearity_set(list, 1); - keys = elist_get_keys(list, &keynbr); - world.curjob->iter.list = list; - } - else - { - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT && hash_linearity_get(table)) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot iterate again on linearly typed table", -1); - } - hash_linearity_set(table, 1); - keys = hash_get_keys(table, &keynbr); - } - - /* Use the correct keys array index depending on foreach iteration nbr */ - nextelem: - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT) - { - index = 0; - world.curjob->curcmd->listidx += 2; - } - - /* The induction variable existed already : record its previous value into the parent list */ - else - { - index = world.curjob->curcmd->listidx++; - if (flag != 2 || !regexec(&world.curjob->curcmd->regx[0], keys[index - 1], 0, 0, 0)) - { - - /* No need to back-update if the data type is complex */ - if (indexpr->type && aspect_type_simple(indexpr->type->type) && !indexpr->type->next) - { - lastvalue = (var->immed ? var->immed_val.ent : var->get_obj(var->parent)); - if (table) - hash_set(table, keys[index - 1], (void *) lastvalue); - else - elist_set(list, keys[index - 1], (void *) lastvalue); - //printf("back-assignment into the list for element %s at index %u of value %X \n", - //keys[index - 1], index - 1, lastvalue); - } - } - } - - /* Export iteration information to revmjob so it can be used in other commands */ - if (!table && list) - { - world.curjob->iter.curindex = &world.curjob->curcmd->listidx; - world.curjob->iter.curkey = keys[index]; - world.curjob->iter.curname = world.curjob->curcmd->param[0]; - } - - /* Bound check : go to the loop end when necessary */ - if (index >= keynbr) - { - if (!world.curjob->curcmd->endlabel) - cmd_quit(); - if (table) - hash_linearity_set(table, 0); - else if (list) - elist_linearity_set(list, 0); - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - revm_move_pc(world.curjob->curcmd->endlabel); - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Get the next elem if the current one is not matching */ - if (flag == 2 && regexec(&world.curjob->curcmd->regx[0], - keys[index], 0, 0, 0)) - goto nextelem; - - /* The element matched, process it */ - if (table) - { - elem = hash_get(table, keys[index]); - typeid = table->type; - } - else - { - elem = elist_get(list, keys[index]); - typeid = list->type; - } - - /* If the element is already an expression, copy it to the induction variable */ - if (typeid == ASPECT_TYPE_EXPR) - { - indname = strdup(indexpr->label); - revm_expr_destroy(indexpr->label); - indexpr = revm_expr_copy((revmexpr_t *) elem, indname, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* If the element is not an expression, act depending on its type */ - if (!indexpr->type || indexpr->type->type != typeid) - revm_convert_object(indexpr, typeid); - if (indexpr->type->type != typeid) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for induction variable", -1); - } - - /* Update depending if the type is simple or complex */ - if (aspect_type_simple(indexpr->type->type) && !indexpr->type->next) - { - var->immed = 1; - var->immed_val.ent = (eresi_Addr) elem; - //fprintf(stderr, "Setting indvar->immed_val.ent = %X \n", (eresi_Addr) elem); - } - else - { - typename = indexpr->type->name; - revm_expr_destroy(world.curjob->curcmd->param[0]); - indexpr = revm_inform_type_addr(typename, world.curjob->curcmd->param[0], - (eresi_Addr) elem, NULL, 0, 1); - if (!indexpr) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, setname); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to create expression for induction variable", -1); - } - } - break; - - /* foreach idxvar of minint until maxint */ - case 3: - if (world.curjob->curcmd->listidx == REVM_IDX_UNINIT) - { - infbound = revm_lookup_index(world.curjob->curcmd->param[2]); - world.curjob->curcmd->listidx = infbound + 1; - } - else - infbound = world.curjob->curcmd->listidx++; - - upbound = revm_lookup_index(world.curjob->curcmd->param[4]); - - /* Bound check */ - if (infbound >= upbound) - { - if (!world.curjob->curcmd->endlabel) - cmd_quit(); - world.curjob->curcmd->listidx = REVM_IDX_UNINIT; - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Set the induction variable */ - if (!indexpr->type || indexpr->type->type != ASPECT_TYPE_INT) - revm_convert_object(indexpr, ASPECT_TYPE_INT); - if (!indexpr->type || indexpr->type->type != ASPECT_TYPE_INT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for induction variable", -1); - - var->immed = 1; - var->immed_val.word = infbound++; - break; - } - - /* Support when until goes decreasing */ - /* Here set the induction variable (3 cases : first, iterating, last) */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - /* End an iteration */ - int cmd_forend() - { - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/graph.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/graph.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/graph.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/graph.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,717 +0,0 @@ -/* -** @file graph.c -** @ingroup libstderesi -** @brief Dump graphviz output -** -** Started : Fri Mar 7 07:18:03 2003 jfv -** Updated : Fri Dec 10 02:04:19 2006 jfv -** -** $Id: graph.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -static hash_t dumped; - - -/** - * Generate the legend for the graph in HTML format - * @param fd - * @param fnc - * @param min - * @param max - */ -void revm_graph_legend(int fd, char *fnc, u_int min, u_int max) -{ - char buf[BUFSIZ]; - - snprintf(buf,BUFSIZ-1,"graph [label=<\n\ - \n\ - \ - \ - \n\ - \n\ - \n\ - \n\ - \n\ -
Legend:%s
min: 0x%08Xmax: 0x%08X
COND TRUECOND FALSE
CALLRET
DELAY
\n\ - >]\n",fnc, min, max, - LNK_COLOR_TRUE, - LNK_COLOR_FALSE, - LNK_COLOR_CALL, - LNK_COLOR_RET, - LNK_COLOR_DELAY); - - write(fd,buf,strlen(buf)); - -} - - -/** - * Disassemble a block - * @param fd - * @param blk - */ -void revm_disasm_block(int fd, mjrblock_t *blk) -{ - char *buffer; - char *name; - elfsh_SAddr off; - u_int index = 0; - int revm_quiet,revm_colors; - int ret,cur; - u_int foffset; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_quiet = world.state.revm_quiet; - world.state.revm_quiet = 0; - revm_colors = nocolor; - nocolor = 0; - cur = 1; - - XALLOC(__FILE__, __FUNCTION__, __LINE__, buffer, blk->size, ); - foffset = elfsh_get_foffset_from_vaddr(world.curjob->curfile, blk->vaddr); - ret = elfsh_raw_read(world.curjob->curfile, foffset, buffer, blk->size); - if (ret > 0) - { - name = elfsh_reverse_metasym(world.curjob->curfile, blk->vaddr, &off); - while ((index < blk->size) && cur) - { - cur = revm_instr_display(fd, index, blk->vaddr, 0, blk->size, - name, index + off, buffer); - if (cur <= 0) - goto end; - - index += cur; - write(fd, "\\l", 2); - revm_endline(); - } - } - end: - XFREE(__FILE__, __FUNCTION__, __LINE__,buffer); - world.state.revm_quiet = revm_quiet; - nocolor = revm_colors; - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Create .dot -> .png files and execute the graphic viewer - * @param dotfile - */ -int revm_graph_compile_graphic(char *dotfile) -{ - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if ((int) config_get_data(ERESI_VMCONFIG_GRAPH_AUTOBUILD)) - { - snprintf(buf,sizeof(buf),"dot -Tpng -o %s.png %s",dotfile,dotfile); - system(buf); - - if ((int) config_get_data(ERESI_VMCONFIG_GRAPH_AUTOVIEW)) - { - snprintf(buf,sizeof(buf), - "%s %s.png", - (char *)config_get_data(ERESI_VMCONFIG_GRAPH_VIEWCMD), - dotfile); - system(buf); - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(1)); -} - -/** - * Returns converted path name into string without '.' - * @param path - */ -char *revm_flattern_path(char *path) -{ - char *r,*p; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - r = strdup(path); - p = r; - - while(*p != '\0') - { - if (*p == '.') - *p = '_'; - p++; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,r); -} - - - -/** - * Prepare directory tree for graph storage - */ -int revm_prepare_storage_dir(void) -{ - mode_t omode = S_IRWXU | S_IRWXG | S_IRWXO; - char *token, *brkt; - char *sep = "/"; - char tmp[BUFSIZ], path[BUFSIZ]; - u_int cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - cur = 0; - memset(tmp,0x00, BUFSIZ); - memset(path,0x00, BUFSIZ); - - snprintf(path,BUFSIZ-1,"%s/%s",(char *)config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH), - revm_flattern_path(world.mjr_session.cur->obj->name)); - - for (token = strtok_r(path,sep,&brkt); - token; - token = strtok_r(NULL,sep,&brkt)) - { - tmp[cur++] = '/'; - strncat(tmp, token, strlen(token)); - cur += strlen(token); - - mkdir(tmp, omode); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - -/** - * This function prepares a path string to .dot file - * @param opt - * @param prefix - * @return - */ -char *revm_get_dotfile_name(char *opt,char *prefix) -{ - int namelen; - char *dotfile; - char *str1; - char *str2; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!opt) - opt = "dump"; - if (!prefix) - prefix = ""; - - str1 = (char *) config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH); - str2 = revm_flattern_path(world.mjr_session.cur->obj->name); - namelen = strlen(str1) + strlen(str2) + strlen(opt) + strlen(prefix) + 32; - - XALLOC(__FILE__,__FUNCTION__,__LINE__, dotfile, namelen, NULL); - if (!revm_prepare_storage_dir()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot prepare storage directory", NULL); - - snprintf(dotfile,namelen,"%s%s/%s-%s.dot", - (char *)config_get_data(ERESI_VMCONFIG_GRAPH_STORAGEPATH), - revm_flattern_path(world.mjr_session.cur->obj->name), - prefix,opt); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (dotfile)); -} - -/** - * Converts string to vaddr by looking up the symbol name - * or converting it to hex - * @param s - * @return - */ -u_int revm_get_vaddr(char *s) -{ - elfsh_Sym *sym; - u_int min; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get parameters */ - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile,s))) - min = sym->st_value; - else - min = strtoul(s, 0, 16); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(min)); -} - -/** - * Returns next function vaddress - */ -u_int revm_get_next_function_vaddr(u_int min) -{ - container_t *cntnr; - u_int max,tmp,ltmp; - char **keys; - int idx,fnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.mjr_session.cur->funchash, &fnbr); - max = ltmp = min; - - for (idx = 0; idx < fnbr; idx++) - { - cntnr = hash_get(&world.mjr_session.cur->funchash, keys[idx]); - tmp = ((mjrfunc_t *)cntnr->data)->vaddr; - - if (((max == min) || (tmp < max)) && (tmp > min)) - max = tmp; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__,(max)); -} - -/** - * Get color name for string, it does check alert - * and lookups the color name - */ -char *revm_get_colored_str(char *str,int type) -{ - color_t *t; - int idx,c,t2; - char **keys; - char *color; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - color = FNC_COLOR_DEFAULT; - - if (world.state.revm_use_alert && - !regexec(&world.state.revm_alert, str, 0, 0, 0)) - { - t = hash_get(&t_color_hash, "warnstring"); - - keys = hash_get_keys(&fg_color_hash, &idx); - - for (c = 0; c < idx; c++) - { - t2 = (int) hash_get(&fg_color_hash, keys[c]); - if (t2 == t->fground) - { - snprintf(buf, sizeof(buf), "\"%s\"", keys[c]); - color = strdup(buf); - break; - } - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); - } - - switch (type) - { - case GVZ_NODE_EPOINT: - color = FNC_COLOR_EPOINT; - break; - case GVZ_NODE_MAIN: - color = FNC_COLOR_MAIN; - break; - case GVZ_NODE_INTERN: - color = FNC_COLOR_INTERN; - break; - case GVZ_NODE_EXTERN: - color = FNC_COLOR_EXTERN; - break; - case GVZ_NODE_UNKNOWN: - color = GVZ_COLOR_CORAL; - break; - default: - color = FNC_COLOR_DEFAULT; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (color)); -} - -int revm_graph_get_function_type(mjrfunc_t *fnc) -{ - elfshsect_t *parent; - int ftype; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - parent = elfsh_get_parent_section(world.curjob->curfile, fnc->vaddr, NULL); - - if (fnc->vaddr == elfsh_get_entrypoint(elfsh_get_hdr(world.mjr_session.cur->obj))) - ftype = GVZ_NODE_EPOINT; - else if ((parent == NULL)||(parent->name == NULL)) - ftype = GVZ_NODE_UNKNOWN; - else if (parent && parent->name && strcmp(".text",parent->name)) - ftype = GVZ_NODE_EXTERN; - else - ftype = GVZ_NODE_INTERN; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ftype); -} - -/* A recursive function for graphing in dot format */ -int revm_graph_blocks(container_t *cntnr, - int fd, - eresi_Addr min, - eresi_Addr max, - int dir, - int maxdepth, - int curdepth) -{ - mjrblock_t *blk,*cblk; - mjrlink_t *lnk; - char buf[BUFSIZ]; - char *vaddr_str; - char *col_arrow; - container_t *nextcnt; - mjrblock_t *nextblk; - list_t *linklist; - listent_t *curent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - blk = (mjrblock_t *) cntnr->data; - - vaddr_str =_vaddr2str(blk->vaddr); - - if (hash_get(&dumped, vaddr_str) || curdepth == maxdepth) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - hash_add(&dumped, vaddr_str, cntnr); - - linklist = cntnr->outlinks; - - snprintf(buf, sizeof(buf), - "\"" AFMT "\" [shape=\"box\" color=%s label=\"<" AFMT ">:\\l", - blk->vaddr, "\"grey\"", blk->vaddr); - - write(fd,buf,strlen(buf)); - - revm_disasm_block(fd, blk); - - snprintf(buf, sizeof(buf), "\"];\n"); - - write(fd,buf,strlen(buf)); - - /* Print all links */ - for (curent = linklist->head; curent; curent = curent->next) - { - lnk = (mjrlink_t *) curent->data; - cblk = (mjrblock_t *) mjr_lookup_container(world.mjr_session.cur, lnk->id)->data; - - switch (lnk->type) - { - case MJR_LINK_BLOCK_COND_TRUE: - col_arrow = LNK_COLOR_TRUE; - break; - case MJR_LINK_BLOCK_COND_FALSE: - col_arrow = LNK_COLOR_FALSE; - break; - case MJR_LINK_BLOCK_COND_ALWAYS: - continue; - case MJR_LINK_FUNC_CALL: - col_arrow = LNK_COLOR_CALL; - break; - case MJR_LINK_FUNC_RET: - col_arrow = LNK_COLOR_RET; - break; - case MJR_LINK_TYPE_DELAY: - col_arrow = LNK_COLOR_DELAY; - break; - default: - fprintf(D_DESC, "[D] %s 1st: lnk->type:%d\n", __FUNCTION__, lnk->type); - col_arrow = "\"black\""; - break; - } - - snprintf(buf, sizeof(buf), "\"" AFMT "\" -> \"" AFMT "\" [color=%s];\n", - blk->vaddr, cblk->vaddr, col_arrow); - -#if __DEBUG_GRAPH__ - fprintf(D_DESC,"[D] %s: " AFMT " -> " AFMT " %d\n", - __FUNCTION__, blk->vaddr, cblk->vaddr, lnk->type); -#endif - - write(fd, buf, strlen(buf)); - } - - /* Now recurse on the children */ - for (curent = linklist->head; curent; curent = curent->next) - { - lnk = (mjrlink_t *) curent->data; - if (lnk->type == MJR_LINK_BLOCK_COND_ALWAYS) - continue; - - nextcnt = mjr_lookup_container(world.mjr_session.cur, lnk->id); - nextblk = (mjrblock_t *) nextcnt->data; - - if ((nextblk->vaddr >= min) && (nextblk->vaddr <= max)) - revm_graph_blocks(nextcnt, fd, min, max, 0, 0, curdepth + 1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * This function does dump a function container in graphviz format - * @param fd - * @param direction input/output - * @param type 0 - we are dumping only out, 1 - we generate .dot file for - * both directions - * @param maxdepth - * @param curdepth - */ -int revm_graph_function(container_t *cntnr, - int fd, - int direction, - int type, - int maxdepth, - int curdepth) -{ - elfsh_SAddr offset; - int ftype; - mjrfunc_t *fnc, *tmpfnc; - mjrlink_t *curlnk; - char *n1, *n2, *vaddr_str; - char buf[BUFSIZ]; - list_t *linklist; - listent_t *curent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No container found", -1); - - fnc = (mjrfunc_t *)cntnr->data; - vaddr_str =_vaddr2str(fnc->vaddr); - - if (hash_get(&dumped, vaddr_str) || curdepth == maxdepth) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - hash_add(&dumped, vaddr_str, cntnr); - - n1 = elfsh_reverse_metasym(world.curjob->curfile,fnc->vaddr, &offset); - - ftype = revm_graph_get_function_type(fnc); - - snprintf(buf, sizeof(buf), "\"%s\" [color=%s];\n", - (n1 ? n1 : fnc->name), - revm_get_colored_str((n1) ? n1 : fnc->name, ftype)); - - write(fd,buf,strlen(buf)); - - linklist = mjr_link_get_by_direction(cntnr,direction); - - /* Print all links of this function */ - for (curent = linklist->head; curent; curent = curent->next) - { - curlnk = (mjrlink_t *) curent->data; - tmpfnc = (mjrfunc_t *) mjr_lookup_container(world.mjr_session.cur,curlnk->id)->data; - - /* resolve the symbols */ - n2 = elfsh_reverse_metasym(world.curjob->curfile, tmpfnc->vaddr, &offset); - ftype = revm_graph_get_function_type(tmpfnc); - - if (type) - { - snprintf(buf, sizeof(buf), - "\"%s\" [color=%s];\n", - (n2) ? n2 : tmpfnc->name, - revm_get_colored_str((n2) ? n2 : tmpfnc->name, ftype)); - - write(fd,buf,strlen(buf)); - } - - if (direction == CONTAINER_LINK_OUT) - snprintf(buf,sizeof(buf), - "\"%s\" -> \"%s\";\n", - (n1) ? n1 : fnc->name, - (n2) ? n2 : tmpfnc->name); - - else if (direction == CONTAINER_LINK_IN) - { - snprintf(buf,sizeof(buf), - "\"%s\" -> \"%s\";\n", - (n2) ? n2 : tmpfnc->name, - (n1) ? n1 : fnc->name); - } - - write(fd,buf,strlen(buf)); - } - - /* Recurse on children */ - for (curent = linklist->head; curent; curent = curent->next) - { - curlnk = (mjrlink_t *) curent->data; - revm_graph_function(mjr_lookup_container(world.mjr_session.cur, curlnk->id), - fd, direction, type, maxdepth, curdepth + 1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Open the file for putting the dot description - * @param dotfile - * @param fd - * @returm - */ -int revm_open_dot_file(char *dotfile, int *fd) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - printf(" [*] .dot file: %s\n", dotfile); - - *fd = open(dotfile, O_RDWR | O_CREAT | O_TRUNC, 0644); - if (*fd == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create graphviz file", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} - -u_int revm_get_min_param(void) -{ - revmexpr_t *expr; - revmobj_t *var; - u_int min; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - expr = revm_lookup_var(world.curjob->curcmd->param[1]); - if (expr && expr->value) - { - var = expr->value; - min = revm_get_vaddr(var->immed ? var->immed_val.str : - var->get_name(var->root, var->parent)); - } - else - min = revm_get_vaddr(world.curjob->curcmd->param[1]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (min)); -} - - -/* Graph the binary */ -int cmd_graph(void) -{ - container_t *cntnr; - int fd; - char buf[BUFSIZ]; - u_int min; - u_int max; - char *dotfile; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_init(&dumped, "dumped_containers", mjrHashVerySmall, ASPECT_TYPE_UNKNOW); - - /* Some preliminary checks */ - if (!world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Select use depending on number of arguments */ - switch (world.curjob->curcmd->argc) - { - case 0: - - dotfile = revm_get_dotfile_name(NULL,"object"); - - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); - write(fd,buf,strlen(buf)); - - printf(" [*] Dumping %d functions\n", - world.mjr_session.cur->funchash.elmnbr); - - cntnr = mjr_get_container_by_vaddr(world.mjr_session.cur, - world.mjr_session.cur->obj->hdr->e_entry, - ASPECT_TYPE_FUNC); - - revm_graph_function(cntnr,fd,CONTAINER_LINK_OUT,0, 0, 1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - break; - - case 2: - - if (strcmp("func",world.curjob->curcmd->param[0]) == 0) - { - /* resolve the block vaddr */ - min = revm_get_min_param(); - cntnr = hash_get(&world.mjr_session.cur->funchash, - _vaddr2str(min)); - - if (!cntnr) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Function not found",-1); - - - dotfile = revm_get_dotfile_name(_vaddr2str(min),"function"); - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n ratio=fill;node [style=\"filled\"];\n"); - write(fd,buf,strlen(buf)); - - revm_graph_function(cntnr,fd,CONTAINER_LINK_IN,1, 0, 1); - revm_graph_function(cntnr,fd,CONTAINER_LINK_OUT,1, 0, 1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - } - else if (strcmp("bloc",world.curjob->curcmd->param[0]) == 0) - { - min = revm_get_min_param(); - max = revm_get_next_function_vaddr(min); - - cntnr = hash_get(&world.mjr_session.cur->blkhash, - _vaddr2str(min)); - - if (!cntnr) - PROFILER_ERR(__FILE__,__FUNCTION__,__LINE__, - "Function not found",-1); - - printf(" [D] MIN:%x MAX:%x\n",min,max); - - dotfile = revm_get_dotfile_name(_vaddr2str(min),"block"); - revm_open_dot_file(dotfile, &fd); - - snprintf(buf, sizeof(buf),"strict digraph prof {\n"); - write(fd,buf,strlen(buf)); - - revm_graph_legend(fd, "DEFAULT", min, max); - revm_graph_blocks(cntnr,fd,min,max,0,0,1); - - write(fd,"}\n",2); - close(fd); - - revm_graph_compile_graphic(dotfile); - - printf(" [*] Dump function blocks\n"); - } - else - { - printf(" [!] Use help\n"); - } - - break; - - default: - printf(" [!] use help \n"); - - } - - hash_empty("dumped_containers"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/hammer.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/hammer.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/hammer.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/hammer.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* -** @file hammer.c -** @ingroup libstderesi -** @brief Contains libmjollnir commands bindings. -** -** Last update December 10 2006 may -** -** $Id: hammer.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * To rebuild symtab use this command - */ -int cmd_unstrip() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - memset(logbuf,0x0,BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure started\n"); - revm_output(logbuf); - if (!world.mjr_session.cur->analysed) - cmd_analyse(); - memset(logbuf,0x0,BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " .: mjollnir : unstrip procedure %s\n", - (mjr_symtab_rebuild(&world.mjr_session)) ? "completed successfully" : "faild"); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * This command fill the blocks hash - */ -int cmd_analyse() -{ - char logbuf[BUFSIZ]; - int ret; - char **keys; - int index; - int nbr; - container_t *container; - aspectype_t *curtype; - eresi_Addr addr; - revmexpr_t *expr; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Analyzing object */ - memset(logbuf, 0x0, BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, " [*] Now performing Control Flow Analysis\n"); - revm_output(logbuf); - memset(logbuf, 0x0, BUFSIZ); - - if (world.curjob->curcmd->param[0]) - { - expr = revm_lookup_var(world.curjob->curcmd->param[0]); - obj = expr->value; - - switch (obj->otype->type) - { - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - addr = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - break; - - case ASPECT_TYPE_INT: - addr = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - break; - } - } - else - addr = 0; - - ret = mjr_analyse(&world.mjr_session, 0, 0); //addr, 0); - - snprintf(logbuf, BUFSIZ - 1, " [*] Control Flow Analysis %s.\n", - (!ret ? "completed successfully" : "failed")); - revm_output(logbuf); - if (ret) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error during control flow analysis", -1); - - memset(logbuf, 0x0, BUFSIZ); - snprintf(logbuf, BUFSIZ - 1, - " [*] Calls seen: %d, Recognized destination: %d\n", - world.mjr_session.cur->calls_seen, - world.mjr_session.cur->calls_found); - revm_output(logbuf); - - /* Now informing about all existing blocks and functions */ - curtype = aspect_type_get_by_name("container"); - if (curtype) - { - keys = hash_get_keys(&world.mjr_session.cur->funchash, &nbr); - for (index = 1; index < nbr; index++) - { - container = hash_get(&world.mjr_session.cur->funchash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s"AFMT, - (char *) config_get_data(MJR_CONFIG_FUNC_PREFIX), - *(eresi_Addr *) container->data); - revm_inform_type_addr(curtype->name, logbuf, (eresi_Addr) container, NULL, 0, 1); - } - hash_free_keys(keys); - keys = hash_get_keys(&world.mjr_session.cur->blkhash, &nbr); - for (index = 1; index < nbr; index++) - { - container = hash_get(&world.mjr_session.cur->blkhash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s"AFMT, - (char *) config_get_data(MJR_CONFIG_BLOC_PREFIX), - *(eresi_Addr *) container->data); - revm_inform_type_addr(curtype->name, logbuf, (eresi_Addr) container, NULL, 0, 1); - } - hash_free_keys(keys); - revm_output(" [*] Reflected succesfully all basic blocks and function meta-data \n\n"); - } - else - revm_output(" [*] No reflection was performed (no container type definition found)\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Shortcut command to rename symbols - */ -int cmd_rename() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - mjr_symbol_rename(&world.mjr_session, - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/hashes.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/hashes.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/hashes.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/hashes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,327 +0,0 @@ -/* -** @file hashes.c -** @ingroup libstderesi -** @brief Pretty printing for elfsh hash tables. -** -** Started Jan 20 2007 18:57:03 jfv -** -** -** $Id: hashes.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Display an element of a hash table - * @param h Hash table - * @param key Hash key of object to be printed - */ -int revm_table_display_element(hash_t *h, char *key, u_char inside) -{ - void *data; - char logbuf[BUFSIZ]; - revmexpr_t *newexpr; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - data = hash_get(h, key); - if (h->type == ASPECT_TYPE_UNKNOW || !inside) - { - snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", - key, (eresi_Addr) data); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - if (*key == REVM_VAR_PREFIX) - strncpy(logbuf, key, sizeof(logbuf)); - else - snprintf (logbuf, sizeof(logbuf), "$%s", key); - newexpr = revm_expr_get(logbuf); - if (newexpr) - { - revm_output("\t"); - revm_expr_print(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - revm_output("\t"); - if (h->type == ASPECT_TYPE_EXPR) - { - newexpr = (eresi_Addr) data; - revm_expr_print(newexpr->label); - } - else - { - type = aspect_type_get_by_id(h->type); - newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); - if (!newexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to reflect hash element to expression", -1); - revm_expr_print(logbuf); - } - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a hash table - * @param name Hash table name to display - */ -int revm_table_display_content(char *name) -{ - hash_t *h; - char **keys; - int keynbr; - int index; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_hash, name); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested hash parameter", -1); - - /* Empty hash */ - keys = hash_get_keys(h, &keynbr); - if (!keynbr) - { - revm_output(" [*] Hash table is empty \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Display pointers */ - for (index = 0; index < keynbr; index++) - revm_table_display_element(h, keys[index], 0); - - snprintf(logbuf, sizeof(logbuf), - "\n [*] Displayed %u entries of table %s \n\n", keynbr, name); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * Display the header of a hash table - * @param table - * @param name - */ -int revm_table_display(hash_t *table, char *name) -{ - char logbuf[BUFSIZ]; - char *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - type = revm_ascii_type(table); - snprintf(logbuf, sizeof(logbuf), - " + %-40s\t ElemType: %-15s ElemNbr: %u \n", - name, type, table->elmnbr); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Display the content of a hash table - */ -static void revm_tables_display() -{ - char **keys; - int keynbr; - int index; - hash_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_output(" .:: Registered tables \n\n"); - keys = hash_get_keys(hash_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(hash_hash, keys[index]); - revm_table_display(cur, keys[index]); - } - revm_output("\n Type 'help tables' for more table details.\n\n"); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Display the content of all hash tables that match the regex - * @param tableregx Regular expression matching table names - * @param elemregx Regular expression matching element keys - */ -static int revm_table_display_regx2(char *tableregx, char *elemregx) -{ - regex_t rx, ex; - int keynbr, keynbr2; - char **keys, **keys2; - int index, index2; - hash_t *cur; - u_int match; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_hash, &keynbr); - for (match = index = 0; index < keynbr; index++) - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - keys2 = hash_get_keys(cur, &keynbr2); - for (index2 = 0; index2 < keynbr2; index2++) - if (!regexec(&ex, keys2[index2], 0, 0, 0)) - { - match++; - revm_table_display_element(cur, keys2[index2], 1); - } - } - snprintf(logbuf, sizeof(logbuf), - "\n [*] Matched %u entries in all tables\n\n", match); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Display the content of all hash tables that match the regex - * @param regx - */ -static int revm_table_display_regx(char *regx) -{ - regex_t rx; - int keynbr; - char **keys; - int index; - int match; - char buf[50]; - char *lastmatch; - hash_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, regx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_hash, &keynbr); - for (lastmatch = NULL, match = index = 0; index < keynbr; index++) - { - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - revm_table_display(cur, keys[index]); - match++; - lastmatch = keys[index]; - } - } - - /* Print the content of the table if we had a unique match */ - if (match == 1) - revm_table_display_content(lastmatch); - else - { - snprintf(buf, sizeof(buf), "\n [*] Matched %u table%c \n\n", - match, (match > 1 ? 's' : ' ')); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -} - - -/** - * Print and modify internal hash tables - */ -int cmd_tables() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print table list */ - case 0: - revm_tables_display(); - break; - - /* Print a determined table with determined (or not) key entry */ - case 1: - if (revm_table_display_regx(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching tables", -1); - break; - - /* Print an element from a table */ - case 2: - if (revm_table_display_regx2(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching tables's elements", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid tables syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Empty a hash table - */ -int cmd_empty() -{ - char buf[BUFSIZ]; - hash_t *hash; - list_t *list; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - hash = hash_find(world.curjob->curcmd->param[index]); - if (!hash) - { - list = elist_find(world.curjob->curcmd->param[index]); - if (!list) - { - snprintf(buf, sizeof(buf), " [W] Unknown list or hash table %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - continue; - } - snprintf(buf, sizeof(buf), " .:: Empty list %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - elist_empty(world.curjob->curcmd->param[index]); - } - else - { - snprintf(buf, sizeof(buf), " .:: Empty hash table %s \n\n", - world.curjob->curcmd->param[index]); - revm_output(buf); - hash_empty(world.curjob->curcmd->param[index]); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/help.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/help.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/help.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/help.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* -** @file help.c for libstderesi in ERESI -** @ingroup libstderesi -** Started on Sat Jan 25 11:19:18 2003 jfv -** $Id: help.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * The ELFsh modules Help command - */ -int cmd_modhelp() -{ - revmmod_t *mod; - u_int id; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - mod = 0; - id = atoi(world.curjob->curcmd->param[0]); - if (!id) - { - if (access(world.curjob->curcmd->param[0], R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find module", -1); - } - mod = hash_get(&mod_hash, buf); - } - } - else - mod = revm_getmod(id); - - if (mod == NULL || mod->help == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Module unavailable", -1); - mod->help(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * The Help command - */ -int cmd_help() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = revm_help(world.curjob->curcmd->param[0]); - if (!ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to help on such command", -1); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/info.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/info.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/info.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/info.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* -** @file info.c -** @ingroup libstderesi -** Made by jfv -** Login -** -** Started on Tue Feb 11 03:32:46 2003 jfv -** Last update Thu Mar 11 07:59:32 2004 jfv -** -** $Id: info.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - -/** - * - */ -int cmd_info() -{ - char *str; - char *alt; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = (world.state.revm_sregx ? world.state.revm_sregx : "NONE"); - alt = (world.state.revm_salert ? world.state.revm_salert : "NONE"); - - snprintf(logbuf, BUFSIZ - 1, - "\t\t The Reflective ERESI Vector Machine %s [extra help screen] \n\n" - " [*] Object access path format \n\n" - " - ELF header : file{name,id}%shdr%sfield \n" - " - got/ctors/dtors tables : file{name,id}%stable[idx] \n" - " - pht/symtab/dynsym/dynamic/sht/sections : file{name,id}%stable[idx]%sfield \n" - " - Sections data : file{name,id}%ssection[idx:rva:sz]%sraw \n" - " - Relocation/got tables : file{name,id}%srel[idxtab][idxent]%sfield \n\n" - " [*] Fields list \n\n" - " - hdr [ magic class type machine version entry phoff shoff flags ehsize \n" - " phentsize shentsize phnum shnum shstrndx pax_pageexec pax_emultramp \n" - " pax_mprotect pax_randmmap pax_randexec pax_segmexec ] \n" - " - sht [ type offset addr size link info align entsize a w x s m l o ] \n" - " - pht [ type offset paddr vaddr filesz memsz flags align ] \n" - " - symtab/dynsym [ name value size bind type other ] \n" - " - dynamic [ val tag ] \n" - " - section [ name raw ] \n" - " - rel [ type sym offset ] \n" - " - version [ value ] \n" - " - verneed [ index name hash flag next file count aux ] \n" - " - verdef [ index count hash flag aux next name ] \n" - " - hashbucket [ value nbucket ] \n" - " - hashchain [ value nchain ] \n" - " - got [ value addr ] \n\n" - " [*] Current field separator : %s \n" - " [*] Current global regular expr. : %s \n" - " [*] Current alert regular expr. : %s \n" - " [*] Project page : http://www.eresi-project.org \n" - " [*] Contact point : team@eresi-project.org \n\n", - REVM_VERSION, REVM_SEP, REVM_SEP, REVM_SEP, REVM_SEP, REVM_SEP, - REVM_SEP, REVM_SEP, REVM_SEP, REVM_SEP, REVM_SEP, str, alt); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/inform.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/inform.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/inform.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/inform.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -/* -** @file inform.c -** @ingroup libstderesi -** @brief Commands for doing annotations on program objects -** -** Started Jan 21 2007 12:57:03 jfv -** $Id: inform.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - - - -/** - * Inform a given type - */ -int cmd_inform() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - switch (world.curjob->curcmd->argc) - { - /* inform type */ - case 1: - if (revm_informed_print(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested type", -1); - break; - - /* inform type name */ - case 2: - if (revm_inform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], NULL, NULL, 1, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - - /* inform type name address */ - case 3: - if (revm_inform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], - world.curjob->curcmd->param[2], NULL, 1, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid inform syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Uninform a given type - */ -int cmd_uninform() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - switch (world.curjob->curcmd->argc) - { - /* uninform type */ - case 1: - if (revm_uninform_type(world.curjob->curcmd->param[0], NULL, 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type information", -1); - break; - - /* uninform type name */ - case 2: - if (revm_uninform_type(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1], 1) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid variable information", -1); - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid uninform syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/init.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/init.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/init.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/init.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,214 +0,0 @@ -/* -** @file init.c for libstderesi in ERESI -** @ingroup libstderesi -** @brief Constructors for the ERESI standard library -** -** $Id: init.c,v 1.4 2007-12-09 23:00:18 may Exp $ -*/ -#include - - -/** - * @brief Setup the command hash table - */ -void eresi_commands_init() -{ - typeinfo_t *typeinfo; - unsigned int typenbr; - unsigned int index; - - hash_init(&cmd_hash, "commands", 101, ASPECT_TYPE_UNKNOW); - - /* Interactive mode / Scripting mode commands */ - if (world.state.revm_mode != REVM_STATE_CMDLINE) - { - revm_command_add(CMD_LOAD , (void *) cmd_load , (void *) revm_getoption , 0, HLP_LOAD); - revm_command_add(CMD_UNLOAD , (void *) cmd_unload , (void *) revm_getoption , 0, HLP_UNLOAD); - revm_command_add(CMD_SAVE , (void *) cmd_save , (void *) revm_getoption , 1, HLP_SAVE); - revm_command_add(CMD_SWITCH , (void *) cmd_doswitch , (void *) revm_getoption , 0, HLP_SWITCH); - revm_command_add(CMD_METACMD , (void *) cmd_meta , (void *) NULL , 0, HLP_METACMD); - revm_command_add(CMD_QUIT , (void *) cmd_quit , (void *) NULL , 0, HLP_QUIT); - revm_command_add(CMD_QUIT2 , (void *) cmd_quit , (void *) NULL , 0, HLP_QUIT); - revm_command_add(CMD_RETURN , (void *) cmd_return , (void *) revm_getoption , 0, HLP_RETURN); - revm_command_add(CMD_RETURN2 , (void *) cmd_return , (void *) revm_getoption , 0, HLP_RETURN); - revm_command_add(CMD_LIST , (void *) cmd_dolist , (void *) NULL , 0, HLP_LIST); - revm_command_add(CMD_LIST2 , (void *) cmd_dolist , (void *) NULL , 0, HLP_LIST); - revm_command_add(CMD_STOP , (void *) cmd_stop , (void *) NULL , 0, HLP_STOP); - revm_command_add(CMD_WORKSPACE , (void *) cmd_workspace, (void *) revm_getvarparams, 0, HLP_WORKSPACE); - revm_command_add(CMD_WORKSPACE2, (void *) cmd_workspace, (void *) revm_getvarparams, 0, HLP_WORKSPACE); - revm_command_add(CMD_WORKSPACE2, (void *) cmd_workspace, (void *) revm_getvarparams, 0, HLP_WORKSPACE); - revm_command_add(CMD_VECTORS , (void *) cmd_vectors , (void *) revm_getvarparams, 0, HLP_VECTORS); - revm_command_add(CMD_TABLES , (void *) cmd_tables , (void *) revm_getvarparams, 0, HLP_TABLES); - revm_command_add(CMD_LISTS , (void *) cmd_lists , (void *) revm_getvarparams, 0, HLP_LISTS); - revm_command_add(CMD_EMPTY , (void *) cmd_empty , (void *) revm_getvarparams, 0, HLP_EMPTY); - revm_command_add(CMD_DEFINE , (void *) cmd_define , (void *) revm_getvarparams, 0, HLP_DEFINE); - revm_command_add(CMD_UNDEF , (void *) cmd_undef , (void *) revm_getoption , 0, HLP_UNDEF); - } - - /* Command line only commands */ - else - { - revm_command_add(CMD_BINFILE_W, (void *) NULL, (void *) revm_getoutput, 0, ""); - revm_command_add(CMD_BINFILE_R, (void *) NULL, (void *) revm_getinput , 0, ""); - } - - /* General purpose command */ - revm_command_add(CMD_MODLOAD , (void *) cmd_modload , (void *) revm_getoption , 0, HLP_MODLOAD); - revm_command_add(CMD_MODULOAD, (void *) cmd_modunload, (void *) revm_getoption , 0, HLP_MODULOAD); - revm_command_add(CMD_DISASM , (void *) cmd_disasm , (void *) revm_getdisasm , 1, HLP_DISASM); - revm_command_add(CMD_DISASM2 , (void *) cmd_disasm , (void *) revm_getdisasm , 1, HLP_DISASM); - revm_command_add(CMD_HEXA , (void *) cmd_disasm , (void *) revm_gethexa , 1, HLP_HEXA); - revm_command_add(CMD_HEXA2 , (void *) cmd_disasm , (void *) revm_gethexa , 1, HLP_HEXA); - revm_command_add(CMD_PRINT , (void *) cmd_print , (void *) revm_getvarparams , 0, HLP_PRINT); - revm_command_add(CMD_EXEC , (void *) cmd_exec , (void *) revm_getvarparams , 0, HLP_EXEC); - revm_command_add(CMD_EDIT , (void *) cmd_edit , (void *) revm_getoption , 0, HLP_EDIT); - revm_command_add(CMD_PHT , (void *) cmd_pht , (void *) revm_getregxoption, 1, HLP_PHT); - revm_command_add(CMD_GOT , (void *) cmd_got , (void *) revm_getregxoption, 1, HLP_GOT); - revm_command_add(CMD_CTORS , (void *) cmd_ctors , (void *) revm_getregxoption, 1, HLP_CTORS); - revm_command_add(CMD_DTORS , (void *) cmd_dtors , (void *) revm_getregxoption, 1, HLP_DTORS); - revm_command_add(CMD_NOTE , (void *) cmd_notes , (void *) revm_getregxoption, 1, HLP_NOTES); - revm_command_add(CMD_COREINFO, (void *) cmd_coreinfo, (void *) NULL , 1, HLP_COREINFO); - revm_command_add(CMD_SYM , (void *) cmd_sym , (void *) revm_getregxoption, 1, HLP_SYM); - revm_command_add(CMD_DYNAMIC , (void *) cmd_dyn , (void *) revm_getregxoption, 1, HLP_DYNAMIC); - revm_command_add(CMD_DYNSYM , (void *) cmd_dynsym , (void *) revm_getregxoption, 1, HLP_DYNSYM); - revm_command_add(CMD_SHT , (void *) cmd_sht , (void *) revm_getregxoption, 1, HLP_SHT); - revm_command_add(CMD_DEBUG , (void *) cmd_debug , (void *) revm_getvarparams , 0, HLP_DEBUG); - revm_command_add(CMD_REL , (void *) cmd_rel , (void *) revm_getregxoption, 1, HLP_REL); - revm_command_add(CMD_COMMENT , (void *) cmd_comments, (void *) revm_getregxoption, 1, HLP_COMMENT); - revm_command_add(CMD_PHT2 , (void *) cmd_pht , (void *) revm_getregxoption, 1, HLP_PHT); - revm_command_add(CMD_GOT2 , (void *) cmd_got , (void *) revm_getregxoption, 1, HLP_GOT); - revm_command_add(CMD_CTORS2 , (void *) cmd_ctors , (void *) revm_getregxoption, 1, HLP_CTORS); - revm_command_add(CMD_DTORS2 , (void *) cmd_dtors , (void *) revm_getregxoption, 1, HLP_DTORS); - revm_command_add(CMD_NOTE2 , (void *) cmd_notes , (void *) revm_getregxoption, 1, HLP_NOTES); - revm_command_add(CMD_SYM2 , (void *) cmd_sym , (void *) revm_getregxoption, 1, HLP_SYM); - revm_command_add(CMD_DYNAMIC2, (void *) cmd_dyn , (void *) revm_getregxoption, 1, HLP_DYNAMIC); - revm_command_add(CMD_DYNSYM2 , (void *) cmd_dynsym , (void *) revm_getregxoption, 1, HLP_DYNSYM); - revm_command_add(CMD_SHT2 , (void *) cmd_sht , (void *) revm_getregxoption, 1, HLP_SHT); - revm_command_add(CMD_REL2 , (void *) cmd_rel , (void *) revm_getregxoption, 1, HLP_REL); - revm_command_add(CMD_COMMENT2, (void *) cmd_comments, (void *) revm_getregxoption, 1, HLP_COMMENT); - revm_command_add(CMD_SET , (void *) cmd_set , (void *) revm_getoption2 , 0, HLP_SET); - revm_command_add(CMD_ADD , (void *) cmd_add , (void *) revm_getoption2 , 0, HLP_ADD); - revm_command_add(CMD_SUB , (void *) cmd_sub , (void *) revm_getoption2 , 0, HLP_SUB); - revm_command_add(CMD_MUL , (void *) cmd_mul , (void *) revm_getoption2 , 0, HLP_MUL); - revm_command_add(CMD_DIV , (void *) cmd_div , (void *) revm_getoption2 , 0, HLP_DIV); - revm_command_add(CMD_MOD , (void *) cmd_mod , (void *) revm_getoption2 , 0, HLP_MOD); - revm_command_add(CMD_INFO , (void *) cmd_info , (void *) NULL , 0, HLP_INFO); - revm_command_add(CMD_FIXUP , (void *) cmd_fixup , (void *) NULL , 1, HLP_FIXUP); - revm_command_add(CMD_ELF2 , (void *) cmd_elf , (void *) NULL , 1, HLP_ELF); - revm_command_add(CMD_INTERP2 , (void *) cmd_interp , (void *) NULL , 1, HLP_INTERP); - revm_command_add(CMD_ELF , (void *) cmd_elf , (void *) NULL , 1, HLP_ELF); - revm_command_add(CMD_INTERP , (void *) cmd_interp , (void *) NULL , 1, HLP_INTERP); - revm_command_add(CMD_HELP , (void *) cmd_help , (void *) revm_getvarparams , 0, HLP_HELP); - revm_command_add(CMD_MODHELP , (void *) cmd_modhelp , (void *) revm_getoption , 0, HLP_MODHELP); - revm_command_add(CMD_QUIET , (void *) cmd_quiet , (void *) NULL , 0, HLP_QUIET); - revm_command_add(CMD_QUIET2 , (void *) cmd_quiet , (void *) NULL , 0, HLP_QUIET); - revm_command_add(CMD_FORCE , (void *) cmd_force , (void *) NULL , 0, HLP_FORCE); - revm_command_add(CMD_VERB , (void *) cmd_verb , (void *) NULL , 0, HLP_VERB); - revm_command_add(CMD_VERB2 , (void *) cmd_verb , (void *) NULL , 0, HLP_VERB); - revm_command_add(CMD_SORT , (void *) cmd_sort , (void *) revm_getoption , 0, HLP_SORT); - revm_command_add(CMD_SORT2 , (void *) cmd_sort , (void *) revm_getoption , 0, HLP_SORT); - revm_command_add(CMD_ALL , (void *) cmd_glregx , (void *) revm_getoption , 0, HLP_ALL); - revm_command_add(CMD_ALL2 , (void *) cmd_glregx , (void *) revm_getoption , 0, HLP_ALL); - revm_command_add(CMD_ALERT , (void *) cmd_alert , (void *) revm_getoption , 0, HLP_ALERT); - revm_command_add(CMD_FINDREL , (void *) cmd_findrel , (void *) NULL , 1, HLP_FINDREL); - revm_command_add(CMD_WRITE , (void *) cmd_write , (void *) revm_getvarparams , 1, HLP_WRITE); - revm_command_add(CMD_APPEND , (void *) cmd_append , (void *) revm_getoption2 , 1, HLP_APPEND); - revm_command_add(CMD_EXTEND , (void *) cmd_extend , (void *) revm_getoption2 , 1, HLP_EXTEND); - revm_command_add(CMD_RELINJCT, (void *) cmd_relinject,(void *) revm_getoption2 , 0, HLP_RELINJCT); - revm_command_add(CMD_HIJACK , (void *) cmd_hijack , (void *) revm_getvarparams , 1, HLP_HIJACK); - revm_command_add(CMD_CMP , (void *) cmd_cmp , (void *) revm_getoption2 , 0, HLP_CMP); - revm_command_add(CMD_CMP2 , (void *) cmd_cmp , (void *) revm_getoption2 , 0, HLP_CMP); - revm_command_add(CMD_TEST , (void *) cmd_test , (void *) revm_getoption2 , 0, HLP_TEST); - - revm_command_add(CMD_INSERT , (void *) cmd_insert , (void *) revm_getvarparams , 1, HLP_INSERT); - revm_command_add(CMD_INSERT2 , (void *) cmd_insert , (void *) revm_getvarparams , 1, HLP_INSERT); - revm_command_add(CMD_REMOVE , (void *) cmd_remove , (void *) revm_getoption2 , 1, HLP_REMOVE); - revm_command_add(CMD_REMOVE2 , (void *) cmd_remove , (void *) revm_getoption2 , 1, HLP_REMOVE); - revm_command_add(CMD_FLUSH , (void *) cmd_flush , (void *) NULL , 1, HLP_FLUSH); - revm_command_add(CMD_COLOR , (void *) cmd_color , (void *) revm_getoption3 , 0, HLP_COLOR); - revm_command_add(CMD_NOCOLOR , (void *) cmd_nocolor , (void *) NULL , 0, HLP_NOCOLOR); - - revm_command_add(CMD_JMP , (void *) cmd_jmp , (void *) revm_getoption , 0, HLP_JMP); - revm_command_add(CMD_JE , (void *) cmd_je , (void *) revm_getoption , 0, HLP_JE); - revm_command_add(CMD_JNE , (void *) cmd_jne , (void *) revm_getoption , 0, HLP_JNE); - revm_command_add(CMD_JG , (void *) cmd_jg , (void *) revm_getoption , 0, HLP_JG); - revm_command_add(CMD_JL , (void *) cmd_jl , (void *) revm_getoption , 0, HLP_JL); - revm_command_add(CMD_JGE , (void *) cmd_jge , (void *) revm_getoption , 0, HLP_JGE); - revm_command_add(CMD_JLE , (void *) cmd_jle , (void *) revm_getoption , 0, HLP_JLE); - - revm_command_add(CMD_FOREACH , (void *) cmd_foreach , (void *) revm_getforparams , 0, HLP_FOREACH); - revm_command_add(CMD_FOREND , (void *) cmd_forend , (void *) NULL , 0, HLP_FOREND); - revm_command_add(CMD_MATCH , (void *) cmd_match , (void *) revm_getmatchparams, 0, HLP_MATCH); - revm_command_add(CMD_MATCHEND, (void *) cmd_matchend, (void *) NULL , 0, HLP_MATCHEND); - revm_command_add(CMD_CASE , (void *) cmd_case , (void *) revm_getcaseparams , 0, HLP_CASE); - - revm_command_add(CMD_PRE , (void *) cmd_pre , (void *) revm_getvarparams , 0, HLP_PRE); - revm_command_add(CMD_POST , (void *) cmd_post , (void *) revm_getvarparams , 0, HLP_POST); - revm_command_add(CMD_INTO , (void *) cmd_into , (void *) revm_getcaseparams , 0, HLP_INTO); - - revm_command_add(CMD_DEFAULT , (void *) cmd_default , (void *) revm_getvarparams , 0, HLP_DEFAULT); - revm_command_add(CMD_REFLECT , (void *) cmd_reflect , (void *) revm_getoption , 0, HLP_REFLECT); - - revm_command_add(CMD_SDIR , (void *) cmd_scriptsdir, (void *) revm_getoption , 0, HLP_SDIR); - revm_command_add(CMD_VLIST , (void *) cmd_vlist , (void *) revm_getregxoption, 0, HLP_VLIST); - revm_command_add(CMD_VARLIST , (void *) cmd_vlist , (void *) revm_getregxoption, 0, HLP_VLIST); - revm_command_add(CMD_SOURCE , (void *) cmd_source , (void *) revm_getvarparams , 0, HLP_SOURCE); - revm_command_add(CMD_LSCRIPTS, (void *) cmd_lscripts, (void *) NULL , 0, HLP_LSCRIPTS); - revm_command_add(CMD_CAT , (void *) cmd_cat , (void *) revm_getoption , 0, HLP_CAT); - revm_command_add(CMD_PROFILE , (void *) cmd_profile , (void *) revm_getvarparams , 0, HLP_PROFILE); - revm_command_add(CMD_LOG , (void *) cmd_log , (void *) revm_getvarparams , 0, HLP_LOG); - revm_command_add(CMD_EXPORT , (void *) cmd_export , (void *) revm_getoption2 , 0, HLP_EXPORT); - revm_command_add(CMD_SHARED , (void *) cmd_shared , (void *) NULL , 0, HLP_SHARED); - revm_command_add(CMD_VERSION , (void *) cmd_version , (void *) revm_getregxoption, 1, HLP_VERSION); - revm_command_add(CMD_VERNEED , (void *) cmd_verneed , (void *) revm_getregxoption, 1, HLP_VERNEED); - revm_command_add(CMD_VERDEF , (void *) cmd_verdef , (void *) revm_getregxoption, 1, HLP_VERDEF); - revm_command_add(CMD_HASH , (void *) cmd_hashx , (void *) revm_getregxoption, 1, HLP_HASH); - revm_command_add(CMD_CONFIGURE, cmd_configure , revm_getvarparams, 0, HLP_CONFIGURE); - - /* Type related commands */ - revm_command_add(CMD_TYPE , cmd_type , revm_getvarparams, 0, HLP_TYPE); - revm_command_add(CMD_UNION , cmd_type , revm_getvarparams, 0, HLP_TYPE); - revm_command_add(CMD_TYPEDEF , cmd_typedef , revm_getvarparams, 0, HLP_TYPEDEF); - revm_command_add(CMD_INFORM , cmd_inform , revm_getvarparams, 1, HLP_INFORM); - revm_command_add(CMD_UNINFORM , cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); - revm_command_add(CMD_INFORM2 , cmd_inform , revm_getvarparams, 1, HLP_INFORM); - revm_command_add(CMD_UNINFORM2, cmd_uninform , revm_getvarparams, 0, HLP_UNINFORM); - -#if defined(ELFSHNET) - /* DUMP network commands */ - revm_command_add(CMD_NETWORK , (void *) cmd_network , (void *) NULL , 0, HLP_NETWORK); - revm_command_add(CMD_NETWORK2 , (void *) cmd_network , (void *) NULL , 0, HLP_NETWORK); - revm_command_add(CMD_NETLIST , (void *) cmd_netlist , (void *) NULL , 0, HLP_NETLIST); - revm_command_add(CMD_NETKILL , (void *) cmd_netkill , (void *) revm_getoption , 0, HLP_NETKILL); - revm_command_add(CMD_PEERSLIST , (void *) cmd_peerslist, (void *) NULL , 0, HLP_PEERSLIST); - revm_command_add(CMD_CONNECT , (void *) cmd_connect , (void *) revm_getoption , 0, HLP_CONNECT); - revm_command_add(CMD_DISCON , (void *) cmd_discon , (void *) revm_getoption , 0, HLP_DISCON); - revm_command_add(CMD_RCMD , (void *) cmd_rcmd , (void *) revm_getvarparams , 0, HLP_RCMD); -#endif - - /* Flow analysis commands */ - revm_command_add(CMD_ANALYSE , cmd_analyse , NULL, 1, HLP_ANALYSE); - revm_command_add(CMD_UNSTRIP , cmd_unstrip , NULL, 1, HLP_UNSTRIP); - revm_command_add(CMD_GRAPH , cmd_graph , revm_getvarparams, 1, HLP_GRAPH); - revm_command_add(CMD_INSPECT , cmd_inspect , revm_getoption, 1, HLP_INSPECT); - revm_command_add(CMD_FLOWJACK , cmd_flowjack , revm_getoption2, 1, HLP_FLOWJACK); - revm_command_add(CMD_ADDGOTO , cmd_addgoto , revm_getoption2, 1, HLP_ADDGOTO); - revm_command_add(CMD_SETGVL , cmd_setgvl , revm_getoption, 1, HLP_SETGVL); - revm_command_add(CMD_RENAME , cmd_rename , revm_getoption2, 1, HLP_RENAME); - revm_command_add(CMD_CONTROL , cmd_control , NULL, 1, HLP_CONTROL); - - /* Base type declarations commands */ - typeinfo = aspect_basetype_get(&typenbr); - for (index = 0; index < typenbr; index++) - revm_command_add(typeinfo[index].name, cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); -} - - -/** - * @brief Constructor for libstderesi - */ -void eresi_stdconstructor() -{ - world.cmd_init = eresi_commands_init; -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/insert.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/insert.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/insert.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/insert.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,173 +0,0 @@ -/* -** @file insert.c -** @ingroup libstderesi -** @brief First insert functions for easy scripting. -** -** Started Nov 22 01:26:01 2003 jfv -** -** -** $Id: insert.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * sect name maptype size align - * sym name value size - * phdr type value size - */ -int cmd_insert() -{ - elfshsect_t *sct; - revmexpr_t *expr; - revmobj_t *obj; - elfsh_Sym sym; - elfsh_Phdr phdr; - u_int size; - char *name; - char type; - elfsh_Word ptype; - eresi_Addr val; - u_int modulo; - char *param0, *param1, *param2, *param3, *param4; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - param0 = world.curjob->curcmd->param[0]; - param1 = world.curjob->curcmd->param[1]; - param2 = world.curjob->curcmd->param[2]; - param3 = world.curjob->curcmd->param[3]; - param4 = world.curjob->curcmd->param[4]; - - /* Checks (needed because the command takes variable amount of params) */ - if (!param0 || !param1 || !param2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Lookup 2nd parameter depending on first parameter */ - if (!strcmp(param0, "phdr") || !strcmp(param0, "rphdr")) - { - expr = revm_lookup_param(param1); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && - expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid phdr type", -1); - obj = expr->value; - ptype = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - name = NULL; - } - else - { - expr = revm_lookup_param(param1); - if (!expr || !expr->value || !expr->value->otype || expr->value->otype->type != ASPECT_TYPE_STR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object name", -1); - obj = expr->value; - name = (obj->immed ? obj->immed_val.str : obj->get_name(obj->root, obj->parent)); - ptype = 0; - } - - /* Lookup object size (4rth optional parameter) */ - if (param3) - { - expr = revm_lookup_param(param3); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_INT && expr->value->otype->type != ASPECT_TYPE_LONG)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid object size", -1); - obj = expr->value; - size = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - } - else - size = elfsh_get_pagesize(world.curjob->curfile); - - /* Lookup object alignment (5th optional parameter) */ - if (param4) - modulo = atoi(param4); - else - modulo = 0; - - /* Insert a section after looking up injection type */ - /* Third parameter indicate injection type */ - if (!strcmp(param0, "sect")) - { - type = (!strcmp(param2, "code") ? ELFSH_CODE_INJECTION : - !strcmp(param2, "data") ? ELFSH_DATA_INJECTION : - !strcmp(param2, "unmap") ? - ELFSH_UNMAPPED_INJECTION : ELFSH_UNKNOWN_INJECTION); - if (type == ELFSH_UNKNOWN_INJECTION) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown injection type", -1); - sct = elfsh_insert_section(world.curjob->curfile, name, - NULL, type, size, modulo); - if (!sct) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new section", -1); - } - - /* Insert a symbol after looking up symbol value */ - /* Third parameter indicate existing symbol name or value */ - else if (!strcmp(param0, "sym")) - { - expr = revm_lookup_param(param2); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid symbol value", -1); - obj = expr->value; - val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - if (!elfsh_get_symtab(world.curjob->curfile, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive symbol table", -1); - - sym = elfsh_create_symbol(val, size, 0, 0, 0, 0); - if (elfsh_insert_symbol(world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB], - &sym, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot insert symbol", -1); - - - } - - /* Insert PHT entries */ - /* Third parameter indicate symbol name or value */ - else if (!strcmp(param0, "phdr") || - !strcmp(param0, "rphdr")) - { - expr = revm_lookup_param(param2); - if (!expr || !expr->value || !expr->value->otype || - (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid PHDR base address", -1); - obj = expr->value; - val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - - // type, addr, size, alignment - phdr = elfsh_create_phdr(ptype, val, size, 0); - if (!strcmp(param0, "phdr")) - { - if (NULL == elfsh_insert_phdr(world.curjob->curfile, &phdr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new PHDR", -1); - } - else if (NULL == elfsh_insert_runtime_phdr(world.curjob->curfile, &phdr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to insert new runtime PHDR", -1); - } - - /* Error */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown object type", -1); - - /* Report result */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Object insertion succesfull\n\n"); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/inspect.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/inspect.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/inspect.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/inspect.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,139 +0,0 @@ -/* -** @file inspect.c -** @ingroup libstderesi -** @brief Inspect the content of a basic block -** -** Original author : -** -** December 10 2006 : Merged from modflow to the ELFsh vm -may -** -** $Id: inspect.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - - -/** - * Some API that needs to be moved in another file ! - * @param id - */ -eresi_Addr revm_get_block_vaddr_by_id(int id) -{ - container_t *container; - mjrblock_t *block; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - container = mjr_lookup_container(world.mjr_session.cur,id); - block = (mjrblock_t *) container->data; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, block->vaddr); -} - - -/** - * Inspect command for basic blocks - */ -int cmd_inspect() -{ - elfshobj_t *obj; - elfshsect_t *sect; - elfsh_Sym *sym; - mjrblock_t *blk; - container_t *cntnr; - mjrlink_t *cal; - char *name; - char *pname; - elfsh_SAddr off; - u_int vaddr; - char buflog[BUFSIZ]; - listent_t *curent; - mjrblock_t *tmpblock; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Preliminary checks */ - cntnr = NULL; - obj = world.curjob->curfile; - if (!world.mjr_session.cur->analysed) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Control flow section not found" - " : use analyse command", -1); - - /* Try to find block by symbol or address */ - if ((sym = elfsh_get_metasym_by_name(world.curjob->curfile, - world.curjob->curcmd->param[0]))) - vaddr = sym->st_value; - else - vaddr = strtoul(world.curjob->curcmd->param[0], 0, 16); - - /* Try to lookup by variable name */ - if (!vaddr) - { - if (!strncmp(world.curjob->curcmd->param[0], "$bloc", 5)) - cntnr = hash_get(&exprs_hash, world.curjob->curcmd->param[0]); - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find block symbol or address", -1); - name = elfsh_reverse_metasym(world.curjob->curfile, *(eresi_Addr *) cntnr->data, &off); - } - else - { - name = elfsh_reverse_metasym(world.curjob->curfile, vaddr, &off); - cntnr = mjr_block_get_by_vaddr(world.mjr_session.cur, vaddr, 1); - if (!cntnr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find block", -1); - } - - blk = cntnr->data; - - /* Dump calling information */ - snprintf(buflog, sizeof(buflog), " [*] Found block " XFMT " : %s + " DFMT "\n", - blk->vaddr, name, off); - revm_output(buflog); - - /* Iterate on the list of links */ - for (curent = cntnr->inlinks->head; curent; curent = curent->next) - { - cal = curent->data; - tmpblock = mjr_lookup_container(world.mjr_session.cur,cal->id)->data; - pname = elfsh_reverse_metasym(world.curjob->curfile, tmpblock->vaddr, &off); - - /* FIXME: we have to work out the lack of the 'type' field for blocks */ - switch (cal->type) - { - case MJR_LINK_BLOCK_COND_TRUE: - snprintf(buflog, sizeof(buflog), - " -> true jumped from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_BLOCK_COND_FALSE: - snprintf(buflog, sizeof(buflog), - " -> false from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_FUNC_CALL: - snprintf(buflog, sizeof(buflog), - " -> called from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - case MJR_LINK_FUNC_RET: - snprintf(buflog, sizeof(buflog), - " -> returned from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - break; - default: - snprintf(buflog, sizeof(buflog), - " -> UNKNOW from " XFMT " : %s + " DFMT "\n", - revm_get_block_vaddr_by_id(cal->id), pname, off); - } - revm_output(buflog); - } - - /* Dump ASM */ - revm_output(" -- block disassembly --\n"); - sect = elfsh_get_parent_section(obj, blk->vaddr, NULL); - off = elfsh_get_foffset_from_vaddr(obj, blk->vaddr); - revm_object_display(sect, sym, blk->size, 0, off, blk->vaddr, - name, REVM_VIEW_DISASM); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/jmp.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/jmp.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/jmp.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/jmp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -/* -** @file jmp.c -** @ingroup libstderesi -** Made by jfv -** Login -** -** Started on Thu Nov 20 05:09:43 2003 jfv -** Last update Thu Nov 20 05:10:03 2003 jfv -** -** $Id: jmp.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Handler for the jmp instruction - */ -int cmd_jmp() -{ - int ret; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -/** - * Handler for the je instruction - */ -int cmd_je() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (!res->immed_val.ent) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jne instruction - */ - -int cmd_jne() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jg instruction - */ - -int cmd_jg() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent > 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jl instruction - */ -int cmd_jl() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent < 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Handler for the jge instruction - */ -int cmd_jge() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent >= 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Handler for the jle instruction - */ -int cmd_jle() -{ - revmexpr_t *last; - revmobj_t *res; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - last = revm_expr_get(REVM_VAR_RESULT); - if (!last || !last->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot retreive last result variable", -1); - res = last->value; - if (res->immed_val.ent <= 0) - { - ret = revm_move_pc(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/job.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/job.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/job.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/job.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -/* -** @file job.c -** @ingroup libstderesi -** Started on Wed Jul 20 22:22:35 2005 yann_malcom -** -** $Id: job.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Need doxygen comment - */ -int cmd_workspace() -{ - revmjob_t *job; - u_int idx; - u_int index; - u_short new = 0; - char logbuf[BUFSIZ]; - char *nl; - char *time; - elfshobj_t *obj; - char **keys; - int keynbr; - char **loadedkeys; - int loadedkeynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - //printf("workspace argc %u \n", world.curjob->curcmd->argc); - - switch (world.curjob->curcmd->argc) - { - - /* $ workspace */ - case 0: - revm_output(" .::. Workspaces .::. \n"); - keys = hash_get_keys(&world.jobs, &keynbr); - for (index = 0; index < keynbr; index++) - { - job = (revmjob_t *) hash_get(&world.jobs, keys[index]); - if (revm_own_job(job)) - { - time = ctime(&job->ws.createtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - snprintf(logbuf, BUFSIZ - 1, " [%s] %s %c \n", keys[index], - time, (job->ws.active ? '*' : ' ')); - revm_output(logbuf); - - if (hash_size(&job->loaded)) - { - loadedkeys = hash_get_keys(&job->loaded, &loadedkeynbr); - for (idx = 0; idx < loadedkeynbr; idx++) - { - obj = hash_get(&job->loaded, loadedkeys[idx]); - snprintf(logbuf, BUFSIZ - 1, " \t %c %s \n", - (job->curfile == obj ? '*' : ' '), obj->name); - revm_output(logbuf); - } - - } - else - { - snprintf(logbuf, BUFSIZ - 1, " \t No files\n"); - revm_output(logbuf); - } - } - } - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* $ workspace name */ - case 1: - if (!revm_valid_workspace(world.curjob->curcmd->param[0])) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrect workspace name", -1); - - job = hash_get(&world.jobs, world.curjob->curcmd->param[0]); - if (!job) - { - /* create a new workspace */ - job = revm_clone_job(strdup(world.curjob->curcmd->param[0]), - - world.curjob); - hash_add(&world.jobs, world.curjob->curcmd->param[0], (void *) job); - new = 1; - } - else - { - if (job->ws.active) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Already in workspace : %s\n\n", world.curjob->curcmd->param[0]); - revm_output(logbuf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - if (revm_own_job(job)) - { - /* switch */ - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Workspace : %s \n\n", world.curjob->curcmd->param[0]); - revm_output(logbuf); - revm_prompt_log(); - - /* Switch to the new job */ - revm_switch_job(job); - - /* Update the screen */ - revm_screen_update(new, 0); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Incorrect workspace name", -1); - - /* Unknown command format */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Wrong arg number", -1); - } -} - -/** - * Switch to the next workspace - */ -int cmd_next_workspace() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = revm_workspace_next(); - if (!ret) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to switch workspace", -1); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/list.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/list.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/list.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/list.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,135 +0,0 @@ -/* -** @file list.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:20:20 2003 jfv -** -** $Id: list.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Print dependence - * @param obj - */ -static int revm_dolist_dep(elfshobj_t *obj) -{ - elfshobj_t *actual; - char logbuf[20]; - char **keys; - int keynbr; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - if (hash_size(&obj->child_hash)) - { - keys = hash_get_keys(&obj->child_hash, &keynbr); - revm_output("DEPS = ["); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&obj->child_hash, keys[index]); - snprintf(logbuf, sizeof(logbuf), "%s%u", - (index == 0 ? "" : ","), actual->id); - revm_output(logbuf); - } - revm_output("]"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * List all the loaded objects - */ -int cmd_dolist() -{ - elfshobj_t *actual; - int index; - char *time; - char *nl; - char c; - char c2; - char logbuf[BUFSIZ]; - char optbuf[BUFSIZ]; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - index = 1; - - /* Private descriptors */ - if (hash_size(&world.curjob->loaded)) - { - revm_output(" .::. Static Working files .::. \n"); - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&world.curjob->loaded, keys[index]); - time = ctime(&actual->loadtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - c = (world.curjob->curfile == actual ? '*' : ' '); - c2 = ((actual->linkmap || actual->rhdr.base) ? 'M' : ' '); - if (elfsh_is_debug_mode()) - snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); - else - snprintf(optbuf, BUFSIZ, "%s", ""); - - snprintf(logbuf, BUFSIZ - 1, " %s %c%c %s ID: %10u %s %-31s ", - time, c, c2, optbuf, actual->id, - elfsh_get_objtype(actual->hdr) == ET_REL ? "ET_REL " : - elfsh_get_objtype(actual->hdr) == ET_DYN ? "ET_DYN " : - elfsh_get_objtype(actual->hdr) == ET_EXEC ? "ET_EXEC" : - elfsh_get_objtype(actual->hdr) == ET_CORE ? "ET_CORE" : - "UNKNOWN", actual->name); - revm_output(logbuf); - revm_dolist_dep(actual); - revm_output("\n"); - - /* printf("-> Hashes for object : PAR[%u] ROOT[%u] CHILD[%u] \n", - hash_size(&actual->parent_hash), - hash_size(&actual->root_hash), - hash_size(&actual->child_hash)); - */ - - } - } - - /* Shared descriptors */ - if (hash_size(&world.shared_hash)) - { - revm_output("\n .::. Shared Working files .::. \n"); - keys = hash_get_keys(&world.shared_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - actual = hash_get(&world.shared_hash, keys[index]); - time = ctime(&actual->loadtime); - nl = strchr(time, '\n'); - if (nl) - *nl = 0x00; - c = (world.curjob->curfile == actual ? '*' : ' '); - c2 = (actual->linkmap ? 'L' : ' '); - if (elfsh_is_debug_mode()) - snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); - else - snprintf(optbuf, BUFSIZ, "%s", ""); - - snprintf(logbuf, BUFSIZ - 1, " [%02u] %s %c%c %s ID: %02u %-31s \n", - index + 1, time, c, c2, optbuf, actual->id, actual->name); - revm_output(logbuf); - } - } - - if (!hash_size(&world.curjob->loaded) && !hash_size(&world.shared_hash)) - revm_output(" [*] No loaded file\n"); - revm_output("\n"); - revm_modlist(); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/lists.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/lists.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/lists.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/lists.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,268 +0,0 @@ -/** -** @file lists.c -** @ingroup libstderesi -** @brief Pretty printing for ERESI lists -** -** Started Jul 13 2007 18:57:03 jfv -** $Id: lists.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - - -/** - * Display an element of a keyed linked list - * @param h Linked list - * @param key Key of list object to be printed - */ -int revm_list_display_element(list_t *l, char *key, u_char inside) -{ - void *data; - char logbuf[BUFSIZ]; - revmexpr_t *newexpr; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - data = elist_get(l, key); - if (l->type == ASPECT_TYPE_UNKNOW || !inside) - { - snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", - key, (eresi_Addr) data); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - if (*key == REVM_VAR_PREFIX) - strncpy(logbuf, key, sizeof(logbuf)); - else - snprintf (logbuf, sizeof(logbuf), "$%s", key); - newexpr = revm_expr_get(logbuf); - if (newexpr) - { - revm_output("\t"); - revm_expr_print(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - revm_output("\t"); - if (l->type == ASPECT_TYPE_EXPR) - { - newexpr = (eresi_Addr) data; - revm_expr_print(newexpr->label); - } - else - { - type = aspect_type_get_by_id(l->type); - newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); - if (!newexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to reflect hash element to expression", -1); - revm_expr_print(logbuf); - } - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a list - * @param name List name to display - */ -int revm_list_display_content(char *name) -{ - list_t *h; - listent_t *cur; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - h = hash_get(hash_lists, name); - if (!h) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested list parameter", -1); - if (!h->elmnbr) - { - revm_output(" [*] List is empty \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Display list entries */ - for (cur = h->head; cur; cur = cur->next) - revm_list_display_element(h, cur->key, 0); - - snprintf(logbuf, sizeof(logbuf), - "\n [*] Displayed %u entries of list %s \n\n", h->elmnbr, name); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/* Display the header of a list */ -int revm_list_display(list_t *list, char *name) -{ - char logbuf[BUFSIZ]; - char *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - type = revm_ascii_ltype(list); - snprintf(logbuf, sizeof(logbuf), - " + %-40s\t ElemType: %-15s ElemNbr: %u \n", - name, type, list->elmnbr); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of a list - */ -static void revm_lists_display() -{ - char **keys; - int keynbr; - int index; - list_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - revm_output(" .:: Registered lists \n\n"); - keys = hash_get_keys(hash_lists, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(hash_lists, keys[index]); - revm_list_display(cur, keys[index]); - } - revm_output("\n Type 'help lists' for more table details.\n\n"); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Display the content of all hash tables that match the regex - * @param tableregx Regular expression matching table names - * @param elemregx Regular expression matching element keys - */ -static int revm_list_display_regx2(char *tableregx, char *elemregx) -{ - regex_t rx, ex; - int keynbr; - char **keys; - int index; - list_t *cur; - listent_t *curent; - u_int match; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_lists, &keynbr); - for (match = index = 0; index < keynbr; index++) - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_hash, keys[index]); - for (curent = cur->head; curent; curent = curent->next) - if (!regexec(&ex, curent->key, 0, 0, 0)) - { - match++; - revm_list_display_element(cur, curent->key, 1); - } - } - snprintf(logbuf, sizeof(logbuf), - "\n [*] Matched %u entries in all lists \n\n", match); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display the content of all hash tables that match the regex - */ -static int revm_list_display_regx(char *regx) -{ - regex_t rx; - int keynbr; - char **keys; - int index; - int match; - char buf[50]; - char *lastmatch; - list_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (regcomp(&rx, regx, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - - /* Look for matching tables */ - keys = hash_get_keys(hash_lists, &keynbr); - for (lastmatch = NULL, match = index = 0; index < keynbr; index++) - { - if (!regexec(&rx, keys[index], 0, 0, 0)) - { - cur = hash_get(hash_lists, keys[index]); - revm_list_display(cur, keys[index]); - match++; - lastmatch = keys[index]; - } - } - - /* Print the content of the table if we had a unique match */ - if (match == 1) - revm_list_display_content(lastmatch); - else - { - snprintf(buf, sizeof(buf), "\n [*] Matched %u list%c \n\n", - match, (match > 1 ? 's' : ' ')); - revm_output(buf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - -} - - -/** - * Print and modify internal lists - */ -int cmd_lists() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print the list of lists */ - case 0: - revm_lists_display(); - break; - - /* Print a determined table with determined (or not) key entry */ - case 1: - if (revm_list_display_regx(world.curjob->curcmd->param[0]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching lists", -1); - break; - - case 2: - if (revm_list_display_regx2(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to print matching list elements", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid lists syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/load.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/load.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/load.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/load.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,280 +0,0 @@ -/** - * @file load.c - * @ingroup libstderesi - * Started on Sat Jan 25 11:21:18 2003 jfv - * - * $Id: load.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - -/** - * return 1 if a file named 'name' is in the workspace - * @param name - */ -int revm_is_loaded(char *name) -{ - listent_t *actual; - elfshobj_t *obj; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob->curfile) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - for (index = 0; index < world.curjob->loaded.size; index++) - for (actual = &world.curjob->loaded.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - obj = actual->data; - if (!strcmp(name, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - - for (index = 0; index < world.shared_hash.size; index++) - for (actual = &world.shared_hash.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - obj = actual->data; - if (!strcmp(name, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - } - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param file - * @param name - */ -int revm_load_init_dephash(elfshobj_t *file, char *name) -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init hash dep */ - snprintf(logbuf, sizeof(logbuf), "%s_children", name); - hash_init(&file->child_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_roots", name); - hash_init(&file->root_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_parents", name); - hash_init(&file->parent_hash, strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param regex - */ -int revm_file_loads(char *regex) -{ - // split for dir/files part - // open dir - // read dir - // match against regex - // if matched load files - return (0); -} - -/** - * Load a file in elfsh - * @param name - * @param base - * @param lm - * @return - */ -int revm_file_load(char *name, eresi_Addr base, elfshlinkmap_t *lm) -{ - elfshobj_t *new; - revmexpr_t *expr; - revmobj_t *tmp; - char logbuf[BUFSIZ]; - char *timec; - hash_t *filehash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Reset the id counter in case we have unloaded all our files */ - filehash = hash_find("files"); - if (!hash_size(filehash)) - world.state.lastid = 0; - - /* Map the standard ELF object */ - new = elfsh_map_obj(name); - if (NULL == new) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load object", -1); - - /* Print a msg if not in quiet mode */ - new->loadtime = time(&new->loadtime); - if (!world.state.revm_quiet) - { - timec = ctime(&new->loadtime); - timec[strlen(timec) - 1] = '\0'; - snprintf(logbuf, BUFSIZ - 1, " [*] %s - New object loaded : %s\n", - timec , name); - revm_output(logbuf); - } - - /* Set base address */ - new->rhdr.base = base; - - /* Set linkmap address */ - if (new->hdr->e_type != ET_CORE) - new->linkmap = lm; - else - new->linkmap = NULL; - - /* Add the object to the list of opened objects */ - new->id = ++world.state.lastid; - world.curjob->curfile = new; - expr = revm_expr_get(REVM_VAR_LOAD); - if (!expr || !expr->value) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "TROUBLE : Last loaded file inexistant", -1); - tmp = expr->value; - tmp->immed_val.word = new->id; - - /* Support shared objects */ - if (world.state.revm_shared) - hash_add(&world.shared_hash, new->name, new); - else - hash_add(&world.curjob->loaded, new->name, new); - - /* Add an entry into the loaded files hashtable */ - hash_add(&file_hash, new->name, (void *) new); - - /* Init hash dep */ - revm_load_init_dephash(new, name); - - if (new->hdr->e_type == ET_CORE) - { - hash_add(&new->root_hash, new->name, new); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Create libmjollnir context for this binary */ - mjr_create_context_as_current(&world.mjr_session, new); - mjr_setup_processor(&world.mjr_session); - - /* Init search hash tables */ - elfsh_init_symbol_hashtables(new); - - /* Parse debugging informations */ - revm_edfmt_parse(new); - - /* Load dependances */ - if (new->hdr->e_type == ET_EXEC) - hash_add(&new->root_hash, new->name, new); - - /* We use a different dependences technique for mapped files - in the debugger. Just load dependences here for unmapped files */ - if (!elfsh_is_debug_mode()) - revm_load_enumdep(new); - - /* Load EDFMT debug sections */ - if ((int) config_get_data(ERESI_VMCONFIG_ONLOAD_RCONTROL)) - { - if (mjr_functions_get(world.mjr_session.cur) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Analyzed functions edfmt section cannot be restored", -1); - if (mjr_blocks_get(world.mjr_session.cur) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Analyzed blocks edfmt section cannot be restored", -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * Insert an object in the list of opened elfsh descriptors - */ -int cmd_load() -{ - revmexpr_t *expr; - revmobj_t *tmp; - char *str; - int was_dynamic; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Make sure we are or not in the debugger */ - was_dynamic = 0; - if (elfsh_is_debug_mode()) - { - was_dynamic = 1; - elfsh_set_static_mode(); - } - - /* Find which file we need to load */ - expr = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!expr || !expr->value) - { - if (was_dynamic) - elfsh_set_debug_mode(); - world.state.revm_shared = 0; - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown file to load", (-1)); - } - tmp = expr->value; - if (tmp->otype->type != ASPECT_TYPE_STR) - { - revm_convert_object(expr, ASPECT_TYPE_STR); - if (tmp->otype->type != ASPECT_TYPE_STR) - { - revm_expr_destroy(expr->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file to load", (-1)); - } - } - str = (tmp->immed ? tmp->immed_val.str : tmp->get_name(tmp->root, tmp->parent)); - if (hash_get(&world.curjob->loaded, str) || hash_get(&world.shared_hash, str)) - { - revm_expr_destroy(expr->label); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load file many times in the same workspace", (-1)); - } - - /* Really load the file */ - revm_output("\n"); - ret = revm_file_load(str, 0, NULL); - revm_output("\n"); - - /* Restore dynamic mode */ - if (was_dynamic) - { - if (world.curjob->curfile && world.curjob->curfile->linkmap) - elfsh_set_debug_mode(); - else - revm_output("\n [!] Loaded file not present in linkmap" - ", switching to STATIC mode\n\n"); - } - else - elfsh_set_static_mode(); - - /* Everything was OK */ - world.state.revm_shared = 0; - revm_expr_destroy(expr->label); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/log.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/log.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/log.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/log.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/* -** @file log.c -** @ingroup libstderesi -** Implement logging facilities -** -** Started September 16 03:11:04 2005 mm -** -** $Id: log.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Enable logging - */ -int cmd_log() -{ - int fd; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Change logging state */ - if (world.curjob->curcmd->param[0]) - { - - /* Stop logging */ - if (!strcmp(world.curjob->curcmd->param[0], "stop")) - revm_closelog(); - - /* Log into a new file */ - else - { - XOPEN(fd, world.curjob->curcmd->param[0], - O_WRONLY | O_CREAT | O_TRUNC, 0600, -1); - world.curjob->ws.state |= REVM_JOB_LOGGED; - world.curjob->ws.logfd = fd; - if (!world.state.revm_quiet) - { - snprintf(buf, BUFSIZ, " [*] Started logging session in %s \n\n", - world.curjob->curcmd->param[0]); - revm_output(buf); - } - } - } - - /* List logging state */ - else - { - snprintf(buf, BUFSIZ, " [*] Session logging %s \n\n", - ((world.curjob->ws.state & REVM_JOB_LOGGED) ? - "enabled" : "disabled")); - revm_output(buf); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Export in environment command - */ -int cmd_export() -{ - int err; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ, "%s=%s", world.curjob->curcmd->param[0], world.curjob->curcmd->param[1]); - - err = putenv(buf); - - if (!err && !world.state.revm_quiet) - { - snprintf(buf, BUFSIZ, " [*] Exported %s to value %s \n\n", - world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - revm_output(buf); - } - if (!err) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to change environment", -1); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,60 +0,0 @@ -## -## Makefile for vm in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = cat.c flow.c graph.c help.c insert.c list.c prefixes.c \ - profile.c reladd.c save.c source.c unload.c vlist.c \ - fileops.c flowjack.c hammer.c info.c inspect.c load.c \ - net.c print.c quit.c remove.c script.c trace.c utils.c \ - vectors.c types.c hashes.c inform.c debug.c foreach.c \ - atomic.c fcthijack.c jmp.c configure.c color.c log.c \ - modules.c exec.c switch.c job.c match.c declare.c \ - lists.c reflect.c define.c init.c return.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME32 = ../revm-commands.32.o -NAME64 = ../revm-commands.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - -I../../libetrace/include -I../../librevm/include/ \ - $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ - $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libaspect/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ -DELFSH_INTERN $(STATOPT2) \ - -I../../libetrace/include -I../../librevm/include/ \ - $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ - $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/match.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/match.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/match.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/match.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,471 +0,0 @@ -/** -** @file match.c -** @ingroup libstderesi -** @brief Implementation of program transformation in ERESI -** -** Start on Wed May 23 13:55:45 2007 jfv -** -** $Id: match.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - -/** - * Retreive the annotation for a given expression - * @param name Expression name - * @return A pointer on the annotation, or NULL if failed. - */ -revmannot_t *revm_annot_get(char *name) -{ - revmexpr_t *expr; - aspectype_t *type; - hash_t *thash; - revmannot_t *annot; - char newname[BUFSIZ] = {0x00}; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - expr = revm_expr_get(name); - if (!expr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid input expression name", NULL); - type = expr->type; - snprintf(newname, sizeof(newname), "type_%s", type->name); - thash = hash_find(newname); - annot = hash_get(thash, name); - if (!annot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find annotation for expression", NULL); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, annot); -} - - -/** - * Copy a field value from one expression to another (provided destination indeed has that field) - * @param dest Destination expression to add field to - * @param source Source expression tocopy field from - * @param fname Name of field to copy from source to destination - * @return 0 for success and -1 for error - */ -static int revm_field_propagate(revmexpr_t *dest, revmexpr_t *source, char *fname) -{ - char srcname[BUFSIZ]; - char dstname[BUFSIZ]; - revmexpr_t *dst; - revmexpr_t *child; - revmannot_t *annot; - revmannot_t *dstannot; - revmannot_t *addedannot; - /*eresi_Addr addr; - char *newdata;*/ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Propagate input links */ - snprintf(srcname, sizeof(srcname), "%s.%s", source->label, fname); - child = revm_expr_get(srcname); - if (!child) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - snprintf(dstname, sizeof(dstname), "%s.%s", dest->label, fname); - dst = revm_expr_get(dstname); - - /* If destination expression has no such field, create it now */ - if (!dst) - { - annot = revm_annot_get(child->label); // annot de lexpr a copier - dstannot = revm_annot_get(dest->label); // annot de lexpr mere destination - if (!annot || !dstannot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup annotations for input expressions", -1); - - XREALLOC(__FILE__, __FUNCTION__, __LINE__, dstannot->addr, - (char *) dstannot->addr, dest->type->size + child->type->size, -1); - dst = revm_expr_copy(child, dstname, 1); - dst->next = dest->childs; - dest->childs = dst; - - addedannot = revm_annot_get(dstname); - if (!addedannot) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to add annotation on new field", -1); - memcpy((char *) dstannot->addr + dest->type->size, (char *) addedannot->addr, child->type->size); - addedannot->addr = dstannot->addr + dest->type->size; - - /* XXX-FIXME: annotations needs to be updated for childs of this type too.... */ - /* - dest->type->size += child->type->size; - revm_inform_type_addr(dst->type->name, dstname, dstannot->addr + dest->type->size, dst, 0, 0); - */ - } - - /* Else assign it */ - else if (child->value && revm_object_set(dest, child) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression field", -1); - else if (revm_expr_set(dst, child) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression fields", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Propagate the link between 2 objects - * @param dest Destination expression to copy links to - * @param source Source expression to copy links from - * @return 0 for success and -1 for error - */ -static int revm_links_propagate(revmexpr_t *dest, revmexpr_t *source) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (revm_field_propagate(dest, source, "inlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression INLINKS field", -1); - if (revm_field_propagate(dest, source, "outlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression OUTLINKS field", -1); - if (revm_field_propagate(dest, source, "nbrinlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression NBRINLINKS field", -1); - if (revm_field_propagate(dest, source, "nbroutlinks") < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to copy expression NBROUTLINKS field", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Perform the transformation (can be called from case or into commands) - * @param matchme - * @param destvalue - * @return -*/ -static int revm_case_transform(revmexpr_t *matchme, char *destvalue) -{ - u_int dstnbr; - char *curptr; - char *foundptr; - u_int curidx; - list_t *exprlist; - aspectype_t *type; - char namebuf[BUFSIZ]; - char *rname; - revmexpr_t *candid; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We matched : first find how many elements there is in the target (list) type */ - dstnbr = 1; - XALLOC(__FILE__, __FUNCTION__, __LINE__, exprlist, sizeof(list_t), -1); - elist_init(exprlist, "curdestlist", ASPECT_TYPE_EXPR); - for (curidx = *world.curjob->iter.curindex - 1, curptr = destvalue; - curptr && *curptr; - curptr = foundptr + 2, curidx++, dstnbr++) - { - foundptr = strstr(curptr, "::"); - if (!foundptr) - break; - *foundptr = 0x00; - type = revm_exprtype_get(curptr); - snprintf(namebuf, BUFSIZ, "%s-%u", world.curjob->iter.curkey, curidx); - rname = strdup(namebuf); - candid = revm_expr_create(type, rname, curptr); - elist_add(exprlist, rname, candid); - } - - /* FIXME: The rewritten element is not part of any list or is part of an alien list */ - if (!world.curjob->iter.list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Rewriting of non-list element currently not supported", -1); - else if (world.curjob->iter.list->type != ASPECT_TYPE_EXPR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Rewriting is currently only supported for expression lists", -1); - - /* Simply replace the current list element now */ - /* The type of the list (list_t->type) does not change : it still is a list of revmexpr_t */ - - /* Just one element to swap */ - else if (dstnbr == 1) - { - elist_destroy(exprlist); - - /* No transformation, keep the original expression */ - if (!strcmp(destvalue, ".")) - candid = matchme; - else - { - rname = revm_tmpvar_create(); - type = revm_exprtype_get(destvalue); - candid = revm_expr_create(type, rname, destvalue); - if (!candid) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Malformed destination type", -1); - - /* - XXX: Disabled for now -- do not remove - if (revm_links_propagate(candid, matchme) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while propagating dataflow links", -1); - */ - - /* initialisation de subexpr par une autre expr est bugge ! */ - /* il nomme le field par le nom de la variable .. */ - elist_set(world.curjob->iter.list, strdup(world.curjob->iter.curkey), candid); - rname = strdup(matchme->label); - revm_expr_destroy(matchme->label); - matchme = revm_expr_copy(candid, rname, 0); - revm_expr_destroy(candid->label); - XFREE(__FILE__, __FUNCTION__, __LINE__, rname); - if (!matchme) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to write back list element", -1); - } - } - - /* Insert a list at a certain offset of the list */ - else - { - elist_replace(world.curjob->iter.list, world.curjob->iter.curkey, exprlist); - *world.curjob->iter.curindex += exprlist->elmnbr - 1; - elist_destroy(exprlist); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Execute side-effects command at some transformation point - * @param str - */ -static int revm_case_execmd(char *str) -{ - revmargv_t *curcmd; - char actual[26]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 11, ASPECT_TYPE_STR); - - curcmd = world.curjob->curcmd; - - if (revm_exec_str(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Side-effects preparation failed", -1); - - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - if (revm_execmd() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Side-effects execution failed", -1); - world.curjob->curcmd = curcmd; - - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Translate in destination type - */ -int cmd_into() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot transform a second time", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot transform outside a rewrite", -1); - if (revm_case_transform(world.curjob->rwrt.matchexpr, - strdup(world.curjob->curcmd->param[0])) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to transform expression", -1); - world.curjob->rwrt.replaced = 1; - if (!world.state.revm_quiet) - revm_output(" [*] Expression transformed succesfully \n\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Perform pre-side-effects - */ -int cmd_pre() -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform pre-side-effects after transformation", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command cannot execute outside a rewrite", -1); - str = revm_string_get(world.curjob->curcmd->param); - if (revm_case_execmd(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Pre-side-effects commands failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Perform pre-side-effects - */ -int cmd_post() -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matched) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - if (!world.curjob->rwrt.replaced) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot perform post-side-effects before transformation", -1); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Command cannot execute outside a rewrite", -1); - str = revm_string_get(world.curjob->curcmd->param); - if (revm_case_execmd(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Post-side-effects commands failed", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Check input type, translate if matching - */ -int cmd_case() -{ - aspectype_t *exprtype; - revmexpr_t *matchme; - revmexpr_t *candid; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!world.curjob->rwrt.matchexpr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Case is not in a match", -1); - - exprtype = aspect_type_get_by_id(ASPECT_TYPE_EXPR); - if (!exprtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Expression type not found : lacking reflection ?", -1); - - /* If a previous case has already matched, simply end the transformation now : - We must do that here because some "post" commands can be put after a matching - "case", so we only stop rewriting at the first case -following- a matchcase */ - if (world.curjob->rwrt.matched) - { - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Check if we match */ - matchme = (revmexpr_t *) world.curjob->rwrt.matchexpr; - if (!matchme->type) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type for matchme expression", -1); - candid = revm_expr_create(matchme->type, "$candid", strdup(world.curjob->curcmd->param[0])); - ret = (!candid ? 1 : revm_expr_match(candid, matchme)); - - /* No match or bad match : nothing happens */ - if (ret) - { - world.curjob->rwrt.matched = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Matched : transform and execute post side effects if any */ - world.curjob->rwrt.matched = 1; - - /* Sometimes the case command comes directly with appended post side-effects */ - if (!world.curjob->curcmd->param[1]) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - revm_case_transform(matchme, strdup(world.curjob->curcmd->param[1])); - if (world.curjob->curcmd->param[2] && - revm_case_execmd(world.curjob->curcmd->param[2]) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Post-side-effects commands failed", -1); - - /* Jump to end of the match construct */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Beginning of the transform command, open a transformation switch - */ -int cmd_match() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* The first time we enter this command, we have to fetch the params */ - if (world.curjob->iter.list && !strcmp(world.curjob->iter.curname, world.curjob->curcmd->param[0])) - { - if (world.curjob->iter.list->type != ASPECT_TYPE_EXPR) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Match/Rewrite can only works on expressions", -1); - fprintf(stderr, "\n *** We -ARE- matching elements of a list *** \n"); - } - else - fprintf(stderr, "\n *** We are -NOT- matching elements of a list *** \n"); - - world.curjob->rwrt.matchexpr = revm_lookup_param(world.curjob->curcmd->param[0]); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * End of match. Do nothing. - */ -int cmd_matchend() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bzero(&world.curjob->rwrt, sizeof(revmrewrite_t)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Default case of a match when nothing else has matched - */ -int cmd_default() -{ - char *str; - revmargv_t *cur; - char actual[26]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - cur = world.curjob->curcmd; - - /* Execute parameter command */ - world.curjob->sourced++; - snprintf(actual, sizeof(actual), "job%u_labels", world.curjob->sourced); - hash_init(&labels_hash[world.curjob->sourced], strdup(actual), 11, ASPECT_TYPE_STR); - str = revm_string_get(world.curjob->curcmd->param); - cur = world.curjob->curcmd; - if (revm_exec_str(str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Display execrequest failed", -1); - world.curjob->curcmd = world.curjob->script[world.curjob->sourced]; - if (revm_execmd() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Default command execution failed", -1); - - /* Restore previous context */ - world.curjob->curcmd = cur; - world.curjob->script[world.curjob->sourced] = NULL; - hash_destroy(&labels_hash[world.curjob->sourced]); - world.curjob->sourced--; - - /* Jump to end of the match construct */ - revm_move_pc(world.curjob->curcmd->endlabel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/modules.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/modules.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/modules.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/modules.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,217 +0,0 @@ -/** -** @file modules.c -** @ingroup libstderesi -** Started on Wed Feb 19 04:42:47 2003 jfv -** -** $Id: modules.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Guess if the file is an ELFsh module or not - */ -int cmd_modload() -{ - revmmod_t *new; - char buf[BUFSIZ]; - char *errmsg; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Verify if the file exists */ - if (access(world.curjob->curcmd->param[0], R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find module", -1); - } - name = buf; - } - else - name = world.curjob->curcmd->param[0]; - - /* See if the module isnt already loaded */ - new = hash_get(&mod_hash, name); - if (new != NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Module already loaded", -1); - - /* Load the module and create revmmod_t entry */ - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, sizeof(revmmod_t), -1); -#ifdef __BEOS__ - new->handler = load_add_on(name); - if (new->handler == B_ERROR) -#else - new->handler = dlopen(name, RTLD_NOW); - if (new->handler == NULL) -#endif - { - errmsg = "[elfsh:modload] Cannot load module"; - goto err; - } - /* Find constructor and (optional) destructor */ -#ifdef __BEOS__ - if( get_image_symbol(new->handler, ELFSH_INIT, - B_SYMBOL_TYPE_TEXT, (void**)(&(new->init))) != B_OK) -#else - new->init = dlsym(new->handler, ELFSH_INIT); - if (new->init == NULL) -#endif - { - errmsg = "[elfsh:modload] Cannot find init handler"; - goto err; - } -#ifdef __BEOS__ - get_image_symbol(new->handler, ELFSH_FINI, - B_SYMBOL_TYPE_TEXT, (void**)(&(new->fini))); -#else - new->fini = dlsym(new->handler, ELFSH_FINI); - new->help = dlsym(new->handler, ELFSH_HELP); -#endif - new->id = ++world.state.lastid; - new->path = strdup(name); - - time(&new->loadtime); - new->next = world.modlist; - world.modlist = new; - hash_add(&mod_hash, new->path, new); - new->init(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - /* Error handling */ - err: - XFREE(__FILE__, __FUNCTION__, __LINE__,new); -#ifdef __BEOS__ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, errmsg, -1); -#else - snprintf(buf, sizeof(buf), "%s: %s", errmsg, dlerror()); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, buf, -1); -#endif -} - - -/** - * Unload an elfsh module - */ -int cmd_modunload() -{ - revmmod_t *cur; - revmmod_t *act; - revmmod_t *todel; - time_t unload_time; - u_int id; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - id = atoi(world.curjob->curcmd->param[0]); - cur = 0; - if (!id) - { - if (access(world.curjob->curcmd->param[0], R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s", ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - { - snprintf(buf, sizeof(buf), "%s%s.so", - ELFSH_MODPATH, world.curjob->curcmd->param[0]); - if (access(buf, R_OK) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find module", -1); - } - else - cur = hash_get(&mod_hash, buf); - } - } - else - cur = revm_getmod(id); - - /* Check if the object is in the module list */ - if (cur == NULL) - goto bad; - - /* Call the handlers */ - if (cur->fini != NULL) - cur->fini(); -#ifdef __BEOS__ - unload_add_on(cur->handler); -#else - dlclose(cur->handler); -#endif - - /* If the element is the first of the list, update the head pointer ... */ - if (world.modlist->id == cur->id) - { - todel = world.modlist; - world.modlist = world.modlist->next; - goto end; - } - - /* ... else find the object in the list */ - for (act = world.modlist; act != NULL && act->next != NULL; act = act->next) - if (act->next->id == cur->id) - { - todel = act->next; - act->next = act->next->next; - goto end; - } - - bad: - /* We didnt find the module */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Module is not loaded", -1); - - /* We found the module */ - end: - unload_time = time(&unload_time); - snprintf(buf, BUFSIZ - 1, - " [*] Module %s unloaded on %s \n", - todel->path, ctime(&unload_time)); - revm_output(buf); - hash_del(&mod_hash, todel->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel->path); - XFREE(__FILE__, __FUNCTION__, __LINE__,todel); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/* In case linked in static */ -#if USE_STATIC && !defined(__FreeBSD__) - -void * dlopen(const char *pathname, int mode) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DLOPEN unavailable in static built", (NULL)); -} - -void *dlsym(void *handle, const char *name) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DLSYM unavailable in static built", (NULL)); -} - -int dlclose(void *handle) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DLCLOSE unavailable in static built", (1)); -} - -char *dlerror(void) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "DLERROR unavailable in static built", (NULL)); -} - -#endif diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/net.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/net.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/net.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/net.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,345 +0,0 @@ -/** -** @file net.c -** @ingroup libstderesi -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Thu Jan 04 11:26:11 2007 jfv -** -** $Id: net.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Run network initialisation - */ -int cmd_network() -{ - revmjob_t *job; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_net == 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - XALLOC(__FILE__, __FUNCTION__, __LINE__,job, sizeof (revmjob_t), -1); - - /* network job setup */ - job->ws.io.type = REVM_IO_NET; - job->ws.io.input = revm_net_input; - job->ws.io.output = revm_net_output; - job->ws.createtime = time(&job->ws.createtime); - - hash_add(&world.jobs, "net_init", job); - //world.curjob = job; - world.state.revm_net = 1; - - if (revm_net_init() < 0) - fprintf (stderr,"revm_initio : Initialisation of network : Failed \n"); - else - { - if (world.state.revm_mode == REVM_STATE_CMDLINE) - { - // We had interactive mode commands which aren't load in CMDLINE mode - revm_command_add(CMD_LOAD , (void *) cmd_load , (void *) revm_getoption, 0, HLP_LOAD); - revm_command_add(CMD_UNLOAD , (void *) cmd_unload , (void *) revm_getoption, 0, HLP_UNLOAD); - revm_command_add(CMD_SAVE , (void *) cmd_save , (void *) revm_getoption, 1, HLP_SAVE); - revm_command_add(CMD_SWITCH , (void *) cmd_doswitch , (void *) revm_getoption, 1, HLP_SWITCH); - revm_command_add(CMD_METACMD , (void *) cmd_meta , (void *) NULL, 0, HLP_METACMD); - revm_command_add(CMD_QUIT , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); - revm_command_add(CMD_QUIT2 , (void *) cmd_quit , (void *) NULL, 0, HLP_QUIT); - revm_command_add(CMD_LIST , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); - revm_command_add(CMD_LIST2 , (void *) cmd_dolist , (void *) NULL, 0, HLP_LIST); - revm_command_add(CMD_STOP , (void *) cmd_stop , (void *) NULL, 0, HLP_STOP); - - // NEED A SWITCH - } - revm_output(" [*] Started ELFsh network connection \n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * print the list of net-client - */ -int cmd_netlist() -{ - int i = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if defined(ELFSHNET) - listent_t *actual; - int index; - char buf[BUFSIZ]; - char *addr; - - revm_output(" .::. Net client list .::. \n"); - for (index = 0; index < world.jobs.size; index++) - { - for (actual = &world.jobs.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (!((revmjob_t *) actual->data)->active) - continue; - - if (((revmjob_t *) actual->data)->io.type == ELFSH_IONET) - { - addr = inet_ntoa(((revmjob_t *) actual->data)->sock.addr.sin_addr); - snprintf(buf, BUFSIZ - 1, " [%.3d] IP %s\n", i, addr); - revm_output(buf); - i++; - } - } - } -#endif - - if (i == 0) - revm_output(" [*] No client\n"); - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * kill a client by its ip address - */ -int cmd_netkill() -{ - char *tokill; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - tokill = world.curjob->curcmd->param[0]; - - tokill = revm_lookup_string(tokill); - - if (world.curjob->ws.io.type == REVM_IO_NET) - { - revm_output(" [*] You can't kill connection.\n"); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (revm_socket_del(tokill) < 0) - { -#if __DEBUG_NETWORK__ - fprintf(stderr, "[DEBUG NETWORK] error on killing a client : %s\n",tokill); -#endif - snprintf(buf, BUFSIZ - 1, " [*] %s not connected.\n", tokill); - revm_output(buf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - snprintf(buf, BUFSIZ - 1, " [*] %s's connection closed.\n", tokill); - revm_output(buf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * print the list of dump neighbors - */ -int cmd_peerslist() -{ - int i = 0; - -#if defined(ELFSHNET) - listent_t *actual; - int index; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output(" .::. DUMP neighbors list .::. \n"); - for (index = 0; index < dump_world.ports.size; index++) - { - for (actual = &dump_world.ports.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - snprintf(buf, BUFSIZ - 1, " [%.3d] IP %s\n", i, actual->key); - revm_output(buf); - i++; - } - } -#else - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#endif - - if (i == 0) - revm_output(" [*] No connection\n"); - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * connect to a dump node - */ -int cmd_connect() -{ -#if defined(ELFSHNET) - - char *toconnect; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - toconnect = world.curjob->curcmd->param[0]; - - toconnect = revm_lookup_string(toconnect); - - if (world.state.revm_net != 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - - if (world.curjob->ws.io.type == ELFSH_IONET) - { - revm_output(" [*] You can't add DUMP connection.\n"); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (dump_connect_to(toconnect, REVM_DUMP_PORT) < 0) - { - snprintf(buf, BUFSIZ - 1, " [*] connection to %s failed.\n", toconnect); - revm_output(buf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - snprintf(buf, BUFSIZ - 1, " [*] connection to %s established.\n", toconnect); - revm_output(buf); - revm_output("\n"); -#else - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * disconnect from a dump node - */ -int cmd_discon() -{ -#if defined(ELFSHNET) - - char *todisconnect; - char buf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - todisconnect = world.curjob->curcmd->param[0]; - - todisconnect = revm_lookup_string(todisconnect); - - if (world.state.revm_net != 1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - if (world.curjob->ws.io.type == ELFSH_IONET) - { - revm_output(" [*] You can't remove DUMP connection.\n"); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (dump_disconnect_host(todisconnect) < 0) - { - snprintf(buf, BUFSIZ - 1, " [*] Not connected to %s.\n", todisconnect); - revm_output(buf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - snprintf(buf, BUFSIZ - 1, " [*] connection to %s closed.\n", todisconnect); - revm_output(buf); - revm_output("\n"); -#else - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * send a command to a remote elfsh node - */ -int cmd_rcmd() -{ -#if defined(ELFSHNET) - - int idx; - char *to; - char buf[BUFSIZ]; - struct hostent *h; - struct sockaddr_in serv_addr; - char data[BUFSIZ]; - u_int sz = BUFSIZ - 1; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.state.revm_net != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Not in 'net' mode", (-1)); - - - /* 1 char for the REVM_DUMP_CMD */ - data[0] = ' '; - data[1] = '\0'; - - sz -= 2; - - for (idx = 1; world.curjob->curcmd->param[idx] != NULL; idx++) - { - strncat(data, " ", sz - 1); - sz -= 1; - if (sz < 2) - break; - strncat(data, world.curjob->curcmd->param[idx], sz - 1); - sz -= strlen(world.curjob->curcmd->param[idx]); - if (sz < 2) - break; - } - - if (idx < 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid number of parameters", (-1)); - - to = world.curjob->curcmd->param[0]; - - to = revm_lookup_string(to); - - h = gethostbyname(to); - - if (h == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown host", (-1)); - - memcpy((char *) &serv_addr.sin_addr.s_addr, - h->h_addr_list[0], - h->h_length); - - snprintf(buf, BUFSIZ - 1, " [*] send command to %s : %s.\n", to, data); - - revm_output(buf); - revm_output("\n"); - - data[0] = REVM_DUMP_CMD; - - ret = dump_send(serv_addr.sin_addr, strdup(data), 1 + strlen(data + 1) + 1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -#else - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); -#endif - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/prefixes.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/prefixes.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/prefixes.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/prefixes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -/** -** @file prefixes.c -** @ingroup libstderesi -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Thu Jan 04 11:26:11 2007 jfv -** -** $Id: prefixes.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * Change the VM state as QUIET - */ -int cmd_quiet() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.state.revm_quiet = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Change the VM state as VERBOSE (default) - */ -int cmd_verb() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.state.revm_quiet = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Turn on the FORCE flag - */ -int cmd_force() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.state.revm_force = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Precise a general weak bounded regex for all options - */ -int cmd_glregx() -{ - char *str; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = strdup(world.curjob->curcmd->param[0]); - - if (regcomp(&world.state.revm_regx, str, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - world.state.revm_use_regx = 1; - if (world.state.revm_sregx) - XFREE(__FILE__, __FUNCTION__, __LINE__,world.state.revm_sregx); - world.state.revm_sregx = str; - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Changed global regex to %s \n\n", str); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Read the sorting parameter - */ -int cmd_sort() -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->param[0][0] != ELFSH_SORT_BY_ADDR && - world.curjob->curcmd->param[0][0] != ELFSH_SORT_BY_SIZE) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid sorting type", -1); - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Switched to %s sorting\n\n", - (world.curjob->curcmd->param[0][0] == ELFSH_SORT_BY_ADDR ? - "ADDR" : "SIZE")); - revm_output(logbuf); - } - - world.state.sort = world.curjob->curcmd->param[0]; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Set the share flag - */ -int cmd_shared() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.state.revm_shared = 1; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/print.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/print.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/print.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/print.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,164 +0,0 @@ -/** -** @file quit.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:19:53 2003 jfv -** -** -** $Id: print.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Print an object - * @param obj - */ -void revm_object_print(revmobj_t *obj) -{ - u_char byte; - uint16_t half; - uint32_t word; - eresi_Addr val; - char *str; - char logbuf[BUFSIZ]; - u_int idx; - aspectype_t *type; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bzero(logbuf, BUFSIZ); - type = obj->otype; - if (type && type->isptr) - goto isptr; - - /* Print a non-pointer type */ - if (!obj->otype) - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_0"); - else - switch (obj->otype->type) - { - case ASPECT_TYPE_BYTE: - byte = (obj->immed ? obj->immed_val.byte : obj->get_obj(obj->parent)); - word = (uint32_t) byte; - snprintf(logbuf, BUFSIZ - 1, "'%s' (%s) ", - ((word > 31 && word < 127) ? revm_colornumber("%c", word) : - revm_colorfieldstr("?")), revm_colornumber("%hhd", word)); - break; - case ASPECT_TYPE_SHORT: - half = (obj->immed ? obj->immed_val.half : obj->get_obj(obj->parent)); - word = (uint32_t) half; - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", - revm_colornumber("%hd", word), revm_colornumber("0x%hX", word)); - break; - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", - revm_colornumber("%d", val), revm_colornumber("0x%X", val)); - break; - case ASPECT_TYPE_INT: - word = (obj->immed ? obj->immed_val.word : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s (%s) ", - revm_colornumber("%d", word), revm_colornumber("0x%X", word)); - break; - case ASPECT_TYPE_STR: - str = (obj->immed ? obj->immed_val.str : - obj->get_name(obj->root, obj->parent)); - snprintf(logbuf, BUFSIZ, "%s ", revm_colorfieldstr(str)); - break; - - /* XXX: need a config variable to tell how many bytes we want */ - case ASPECT_TYPE_RAW: - str = (char *) (obj->immed ? obj->immed_val.str : - obj->get_name ? obj->get_name(obj->root, obj->parent) : ""); - for (idx = 0; idx < 10 && str[idx]; idx++) - snprintf(logbuf, BUFSIZ, "%02X%s", - (u_char) str[idx], (idx < 9 && str[idx + 1] ? " " : "")); - break; - - /* When the object type is unknown */ - default: - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_OBJECT_TYPE_%u ", obj->otype->type); - break; - } - revm_output(logbuf); - revm_endline(); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - /* Now print a pointer */ - isptr: - if (!obj->otype) - snprintf(logbuf, BUFSIZ - 1, "UNKKNOW_PTR_OBJECT_TYPE_0"); - else - switch (obj->otype->type) - { - case ASPECT_TYPE_STR: - case ASPECT_TYPE_BYTE: - case ASPECT_TYPE_SHORT: - case ASPECT_TYPE_LONG: - case ASPECT_TYPE_CADDR: - case ASPECT_TYPE_DADDR: - case ASPECT_TYPE_INT: - case ASPECT_TYPE_RAW: - default: - val = (obj->immed || !obj->parent ? obj->immed_val.ent : obj->get_obj(obj->parent)); - snprintf(logbuf, BUFSIZ - 1, "%s ", revm_colornumber("0x%X", val)); - break; - } - revm_output(logbuf); - revm_endline(); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Print a string - */ -int cmd_print() -{ - revmexpr_t *expr; - volatile u_int idx; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; world.curjob->curcmd->param[idx] != NULL; idx++) - { - expr = revm_expr_get(world.curjob->curcmd->param[idx]); - if (expr && expr->value && !expr->value->perm) - { - revm_object_print(expr->value); - revm_expr_destroy(expr->label); - continue; - } - else if (expr) - { - revm_expr_print(world.curjob->curcmd->param[idx]); - revm_output("\n\n"); - continue; - } - expr = revm_lookup_param(world.curjob->curcmd->param[idx]); - if (expr && expr->value && !expr->value->perm) - { - revm_object_print(expr->value); - revm_expr_destroy(expr->label); - continue; - } - else if (!expr) - { - snprintf(logbuf, BUFSIZ, "%s ", world.curjob->curcmd->param[idx]); - revm_output(logbuf); - continue; - } - else - revm_expr_print(expr->label); - } - - revm_output("\n"); - if (!world.state.revm_quiet) - revm_output("\n"); - revm_endline(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/profile.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/profile.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/profile.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/profile.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -/** -** @file profile.c -** @ingroup libstderesi -** Started on Fri Nov 2 15:21:56 2001 jfv -** Updated on Thu Jan 04 11:26:11 2007 jfv -** -** $Id: profile.c,v 1.1 2007-11-29 14:01:56 may Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Print state of a given flag - * @param mask - * @param feat - */ -void revm_profile_print(u_char mask, char *feat) -{ - char buf[BUFSIZ]; - - snprintf(buf, sizeof(buf), " [-] Profiling level %s <%s> \n", - feat, (profiler_is_enabled(mask) ? "enabled" : "disabled")); - revm_output(buf); -} - - - -/** - * Enable or Disable the profiler - */ -int cmd_profile() -{ - char operation; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc == 0) - { - revm_output(" [*] Current status of the profiler : \n\n"); - revm_profile_print(PROFILE_WARN , "warnings "); - revm_profile_print(PROFILE_FUNCS , "functrace "); - revm_profile_print(PROFILE_ALLOC , "allocations"); - revm_profile_print(PROFILE_DEBUG , "debug "); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - if (world.curjob->curcmd->argc != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid profile syntax", -1); - - /* Check subcommand */ - if (!strcmp(world.curjob->curcmd->param[0], "enable")) - operation = 1; - else if (!strcmp(world.curjob->curcmd->param[0], "disable")) - operation = 0; - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid profile subcommand", -1); - - /* Debug profiling */ - if (!strcmp(world.curjob->curcmd->param[1], "debug")) - { - if (operation) - { - profiler_enable_debug(); - revm_output("\t .:: Profiling enabled debug\n\n"); - } - else - { - profiler_disable_debug(); - revm_output("\t .:: Profiling disabled debug\n\n"); - } - } - - /* Error profiling */ - else if (!strcmp(world.curjob->curcmd->param[1], "warn")) - { - if (operation) - { - profiler_enable_err(); - revm_output("\t .:: Profiling enabled warnings\n\n"); - } - else - { - profiler_disable_err(); - revm_output("\t .:: Profiling disabled warnings\n\n"); - } - } - - /* Function tracing profiling */ - else if (!strcmp(world.curjob->curcmd->param[1], "trace")) - { - if (operation) - { - profiler_enable_out(); - revm_output("\t .:: Profiling enabled functrace\n\n"); - } - else - { - profiler_disable_out(); - revm_output("\t .:: Profiling disabled functrace\n\n"); - } - } - - /* Allocations profiling */ - else if (!strcmp(world.curjob->curcmd->param[1], "alloc")) - { - if (operation) - { - profiler_enable_alloc(); - revm_output("\t .:: Profiling enabled alloctrace\n\n"); - } - else - { - profiler_disable_alloc(); - revm_output("\t .:: Profiling disabled alloctrace\n\n"); - } - } - - /* Full profiling */ - else if (!strcmp(world.curjob->curcmd->param[1], "all")) - { - if (operation) - { - profiler_enable_all(); - revm_output("\t .:: Profiling fully enabled \n\n"); - } - else - { - profiler_disable_all(); - revm_output("\t .:: Profiling fully disabled \n\n"); - } - } - - /* Error or success */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid profile view", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/quit.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/quit.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/quit.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/quit.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/** -** @file quit.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:19:53 2003 jfv -** -** $Id: quit.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -u_char quit_msg_setup = 0; -char quit_msg[512]; - -/** - * Need doxygen tag. - * @param msg - */ -void revm_quitmsg_set(char *msg) -{ - strncpy(quit_msg, msg, sizeof(quit_msg) - 1); - quit_msg_setup = 1; -} - -/** - * Unload all the loaded object and exit the shell - */ -int cmd_quit() -{ - elfshobj_t *cur; - int index; - char logbuf[BUFSIZ]; - int objnbr; - char **keys; - char **objkeys; - int keynbr; - int z; - revmjob_t *curjob; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Unload files anyway */ - keys = hash_get_keys(&world.jobs, &keynbr); - - /* Unload every workspace */ - for (z = 0; z < keynbr; z++) - { - curjob = hash_get(&world.jobs, keys[z]); - if (!revm_own_job(curjob)) - continue; - - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Unloading workspace : %u (%s) %c\n", - z, curjob->ws.name, (curjob->ws.active ? '*' : ' ')); - revm_output(logbuf); - - /* Unload all objects from this job */ - objkeys = hash_get_keys(&curjob->loaded, &objnbr); - for (index = 0; index < objnbr; index++) - { - cur = hash_get(&curjob->loaded, objkeys[index]); - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " \t[*] Unloading object %u (%s) %c \n", - index + 1, cur->name, - (curjob->curfile == cur ? '*' : ' ')); - revm_output(logbuf); - } - elfsh_unload_obj(cur); - } - } - - /* The quit message */ - if (quit_msg_setup == 0) - { - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - revm_modename_get(), REVM_VERSION); - revm_quitmsg_set(logbuf); - } - if (world.curjob->sourced == 0) - revm_output(quit_msg); - - /* Now the ugly code depending on the compilation options */ -#if defined(ELFSHNET) - if (world.curjob->ws.io.type == ELFSH_IONET && - revm_socket_del(inet_ntoa(world.curjob->ws.sock.addr.sin_addr)) < 0) - fprintf(stderr, "error on quit from client on socket %d\n", - world.curjob->ws.sock.socket); - else -#endif - { - revm_output_bcast("\n"); - revm_quit(world.state.revm_mode); - - /* Remove the 2 FIFO on quit : will let the client aware - about our end of execution */ - fprintf(stderr, " [*] Removing 2 FIFO from server side \n"); - unlink(REVM_FIFO_S2C); - unlink(REVM_FIFO_C2S); - revm_exit(0); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_QUIT); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/reflect.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/reflect.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/reflect.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/reflect.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* -** @file match.c -** @ingroup libstderesi -** @brief Handle the match construct. -** -** Start on Wed May 23 13:55:45 2007 jfv -** -** $Id: reflect.c,v 1.3 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - -/** - * Reflect command disassemble the block cache of the parameter and create a list of instr exprs - */ -int cmd_reflect() -{ - container_t *container; - container_t *instrcontainer; - mjrblock_t *curblock; - asm_instr *cur; - elfsh_Half machine; - char logbuf[BUFSIZ]; - eresi_Addr addr; - int off; - int ret; - aspectype_t *curtype; - void *blocdata; - int fileoff; - list_t *instrlist; - revmexpr_t *expr; - int insnbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - curtype = aspect_type_get_by_name("instr"); - if (!curtype) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed reflection : unknown type instruction", -1); - - /* Analyse the binary if not already done */ - if (!world.mjr_session.cur->analysed) - { - ret = mjr_analyse(&world.mjr_session, 0, 0); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed analyzing current object", -1); - } - - /* Init proc */ - if (!world.curjob->proc) - { - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC: - case EM_SPARC32PLUS: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - default: - snprintf(logbuf, sizeof (logbuf), - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - /* Now lookup the block by its addr or symbol */ - addr = revm_lookup_addr(world.curjob->curcmd->param[0]); - if (!addr) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to lookup parameter address", -1); - container = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, MJR_BLOCK_GET_STRICT); - if (!container) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to find bloc at this virtual address", -1); - curblock = (mjrblock_t *) container->data; - - /* Load the data from the bloc */ - blocdata = alloca(curblock->size); - fileoff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, curblock->vaddr); - if (elfsh_raw_read(world.curjob->curfile, fileoff, - blocdata, curblock->size) != curblock->size) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to read data from bloc", -1); - - /* Create the new list of instructions in expression form */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, instrlist, sizeof(list_t), -1); - snprintf(logbuf, sizeof(logbuf), AFMT, curblock->vaddr); - elist_init(instrlist, strdup(logbuf), ASPECT_TYPE_EXPR); - - /* Reflection all instructions of the basic bloc in the list */ - for (insnbr = off = 0; off < curblock->size; off += ret, insnbr++) - { - - /* Fetch the current instruction */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, cur, sizeof(asm_instr), -1); - ret = asm_read_instr(cur, (u_char *) blocdata + off, - curblock->size - off + 10, world.curjob->proc); - if (ret < 0) - { - elist_destroy(instrlist); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to fetch code for basic bloc", -1); - } - - /* Also add the instruction to the current reflected list for this block */ - instrcontainer = container_create(curtype->type, cur, NULL, NULL); - snprintf(logbuf, sizeof (logbuf), "$instr-"XFMT, curblock->vaddr + off); - expr = revm_inform_type_addr(curtype->name, strdup(logbuf), - (eresi_Addr) instrcontainer, NULL, 0, 1); - elist_add(instrlist, strdup(logbuf), expr); - } - - /* Reverse instrlist and add it to the hash of lists */ - instrlist = elist_reverse(instrlist); - hash_add(&instrlists_hash, strdup(logbuf), instrlist); - - /* Printing message if we are not in quiet mode */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, sizeof(logbuf), - " [*] Basic bloc at address " AFMT " reflected succesfully (%u instrs) \n\n", - curblock->vaddr, insnbr); - revm_output(logbuf); - } - - /* Put the current bloc in the last result variable */ - /* - revm_expr_destroy(REVM_VAR_RESULT); - revm_expr_copy(expr, REVM_VAR_RESULT); - */ - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/reladd.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/reladd.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/reladd.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/reladd.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * @file relinject.c - * @ingroup libstderesi - * Started on Fri Mar 28 14:58:57 2003 jfv - * Last update Thu Mar 11 14:39:48 2004 jfv - * - * $Id: reladd.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Inject a .o into an executable - */ -int cmd_relinject() -{ - elfshobj_t *host; - elfshobj_t *rel; - int idx; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check to avoid non-runtime (static) injection from e2bdg the debugger - that would desynchronize the memory perspective of the program. - The debugger is not supposed to do that, it is a job for elfsh */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER && - elfsh_is_static_mode()) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "E2dbg must inject in memory, switch to dynamic mode.", -1); - - /* Load host file */ - idx = atoi(world.curjob->curcmd->param[0]); - host = (idx ? revm_getfile(idx) : - hash_get(&file_hash, world.curjob->curcmd->param[0])); - if (host == NULL) - { - host = elfsh_map_obj(world.curjob->curcmd->param[0]); - if (host == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot map host file", -1); - } - - /* Load relocatable file */ - idx = atoi(world.curjob->curcmd->param[1]); - rel = (idx > 0 ? revm_getfile(idx) : - hash_get(&file_hash, world.curjob->curcmd->param[1])); - if (rel == NULL) - { - rel = elfsh_map_obj(world.curjob->curcmd->param[1]); - if (rel == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot map relocatable file", -1); - } - - /* Call libelfsh relocatable object injector */ - idx = elfsh_inject_etrel_hash(host, rel, - &world.curjob->loaded, - &world.shared_hash); - - if (idx < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to inject ET_REL with workspace", (-1)); - - /* Success : put the modified object as current */ - world.curjob->curfile = host; - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [*] ET_REL %s injected succesfully in %s %s\n\n", - rel->name, - (host->hdr->e_type == ET_EXEC ? "ET_EXEC" : - host->hdr->e_type == ET_DYN ? "ET_DYN" : - "unknown host file"), - host->name); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/remove.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/remove.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/remove.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/remove.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/** -** @file remove.c -** @ingroup libstderesi -** @brief First remove functions for easy scripting -** -** Started on Nov 22 2003 jfv -** -** -** $Id: remove.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * sect name - * sym name - */ -int cmd_remove() -{ - elfshsect_t *symtab; - char *name; - int err; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Checks (needed because the command takes variable amount of params) */ - if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Lookup object name */ - name = revm_lookup_string(world.curjob->curcmd->param[1]); - - /* Remove a section */ - if (!strcmp(world.curjob->curcmd->param[0], "sect")) - err = elfsh_remove_section(world.curjob->curfile, name); - - /* Remove a symbol after looking up symbol value */ - else if (!strcmp(world.curjob->curcmd->param[0], "sym")) - { - symtab = elfsh_get_symtab(world.curjob->curfile, NULL); - if (!symtab) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find symbol table", -1); - symtab = world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB]; - err = elfsh_remove_symbol(symtab, name); - } - - /* Remove a segment */ - else if (!strcmp(world.curjob->curcmd->param[0], "phdr")) - err = elfsh_remove_phdr(world.curjob->curfile, atoi(name)); - - /* Error */ - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown object type", -1); - - /* Report result */ - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Object removing %s.\n\n", - (err < 0 ? "failed" : "succesfull")); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/return.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/return.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/return.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/return.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,108 +0,0 @@ -/** -** @file return.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:19:53 2003 jfv -** $Id: return.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -*/ -#include "libstderesi.h" - - -/** - * Unload all the loaded object and exit the shell - */ -int cmd_return() -{ - elfshobj_t *cur; - int index; - char logbuf[BUFSIZ]; - int objnbr; - char **keys; - char **objkeys; - int keynbr; - int z; - revmjob_t *curjob; - revmexpr_t *retval; - revmexpr_t *lastvar; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fill return value */ - if (world.curjob->curcmd->param[0]) - { - lastvar = revm_expr_get(REVM_VAR_RESULT); - if (lastvar) - revm_expr_destroy(lastvar->label); - retval = revm_lookup_param(world.curjob->curcmd->param[0]); - if (!retval) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid return value", -1); - revm_expr_copy(retval, REVM_VAR_RESULT, 0); - } - - /* Do not unload files if we were sourcing a script */ - if (world.curjob->sourced == 0) - { - keys = hash_get_keys(&world.jobs, &keynbr); - - /* Unload every workspace */ - for (z = 0; z < keynbr; z++) - { - curjob = hash_get(&world.jobs, keys[z]); - if (!revm_own_job(curjob)) - continue; - - snprintf(logbuf, BUFSIZ - 1, - "\n [+] Unloading workspace : %u (%s) %c\n", - z, curjob->ws.name, (curjob->ws.active ? '*' : ' ')); - revm_output(logbuf); - - /* Unload all objects from this job */ - objkeys = hash_get_keys(&curjob->loaded, &objnbr); - for (index = 0; index < objnbr; index++) - { - cur = hash_get(&curjob->loaded, objkeys[index]); - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " \t[*] Unloading object %u (%s) %c \n", - index + 1, cur->name, - (curjob->curfile == cur ? '*' : ' ')); - revm_output(logbuf); - } - elfsh_unload_obj(cur); - } - } - - /* The quit message */ - if (quit_msg_setup == 0) - { - snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", - revm_modename_get(), REVM_VERSION); - revm_quitmsg_set(logbuf); - } - revm_output(quit_msg); - - /* Now the ugly code depending on the compilation options */ -#if defined(ELFSHNET) - if (world.curjob->ws.io.type == ELFSH_IONET && - revm_socket_del(inet_ntoa(world.curjob->ws.sock.addr.sin_addr)) < 0) - fprintf(stderr, "error on quit from client on socket %d\n", - world.curjob->ws.sock.socket); - else -#endif - { - revm_output_bcast("\n"); - revm_quit(world.state.revm_mode); - - /* Remove the 2 FIFO on quit : will let the client aware - about our end of execution */ - fprintf(stderr, " [*] Removing 2 FIFO from server side \n"); - unlink(REVM_FIFO_S2C); - unlink(REVM_FIFO_C2S); - revm_exit(0); - } - } - - /* We are returning from an ERESI function */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_QUIT); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/save.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/save.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/save.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/save.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** -** @file save.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:22:35 2003 jfv -** Last update Wed Mar 10 12:32:35 2004 jfv -** -** $Id: save.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Save objects which name is given as parameter - */ -int cmd_save() -{ - char logbuf[BUFSIZ]; - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = world.curjob->curcmd->param[0]; - if (elfsh_save_obj(world.curjob->curfile, str) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to save object", -1); - snprintf(logbuf, BUFSIZ - 1, "\n [*] Object %s saved successfully \n\n", str); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/script.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/script.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/script.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/script.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ -/** - * @file script.c - * @ingroup libstderesi - * Started on Fri May 16 15:18:35 2005 jfv - * - * - * - * $Id: script.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Script used as command function. - * Note : this function does not work properly in a script ! -*/ -int cmd_script() -{ - int idx; - char *backup; - char *next; - char *path; - int size; - revmargv_t *cmd; - int argc; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (world.scriptsdir == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No scripts dir specified", -1); - cmd = world.curjob->curcmd; - for (argc = 0; cmd->param[argc] != NULL; argc++); - if (!argc) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", (-1)); - - size = strlen(world.scriptsdir) + strlen(world.curjob->curcmd->name) + 6; - path = alloca(size); - snprintf(path, size, "%s/%s.esh", world.scriptsdir, world.curjob->curcmd->name); - backup = world.curjob->curcmd->param[0]; - world.curjob->curcmd->param[0] = path; - for (idx = 0; idx < REVM_MAXARGC - 1 && backup; idx++) - { - next = world.curjob->curcmd->param[idx + 1]; - world.curjob->curcmd->param[idx + 1] = backup; - backup = next; - } - world.curjob->curcmd->name = CMD_SOURCE; - if (cmd_source() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid ERESI source program", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Set then scriptsdir directory and add cmd corresponding to scripts - * @param dir_name - */ -int revm_add_script_cmd(char *dir_name) -{ - DIR *dir; - struct dirent *dir_entry; - char cmd_name[BUFSIZ]; - int len; - char *argv[2]; - char str[BUFSIZ]; - revmcmd_t *curcmd; - int index; - int cnt = 0; - char **keys; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - argv[0] = "#!elfsh"; - dir = opendir(dir_name); - if (dir == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Opendir failed", (-1)); - - /* scripts dir already specified so cleanup command set */ - if (world.scriptsdir != NULL) - { - keys = hash_get_keys(&cmd_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - curcmd = hash_get(&cmd_hash, keys[index]); - if (curcmd->exec == cmd_script) - hash_del(&cmd_hash, keys[index]); - } - } - - - while( (dir_entry = readdir(dir))) - { - if ((len = strlen(dir_entry->d_name)) > 4) - { - if (!strncmp(".esh", &(dir_entry->d_name[len - 1 - 3]), 4)) - { - snprintf(str, BUFSIZ - 1, "%s/%s", dir_name, dir_entry->d_name); - argv[1] = str; - if (!revm_testscript(2, argv)) - continue; - - snprintf(cmd_name, BUFSIZ - 1, "%s", dir_entry->d_name); - cmd_name[len - 1 - 3] = '\0'; - revm_command_add(strdup(cmd_name), (void *) cmd_script, - (void *) revm_getvarparams, 0, "Synthetic macro command"); - if (!world.state.revm_quiet) - { - snprintf(cmd_name, BUFSIZ - 1, "\t\t+ %s added\n", - dir_entry->d_name); - revm_output(cmd_name); - } - cnt++; - } - } - } - - if (world.scriptsdir != NULL) - { - XFREE(__FILE__, __FUNCTION__, __LINE__,world.scriptsdir); - world.scriptsdir = NULL; - } - if (cnt) - world.scriptsdir = strdup(dir_name); - - else - revm_output("\t\t [!] No scripts found \n"); - - closedir(dir); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Elfsh/E2dbg command for revm_add_script_cmd() - */ -int cmd_scriptsdir() -{ - char str[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->param[0] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameter", (-1)); - - if (!world.state.revm_quiet) - { - snprintf(str, BUFSIZ - 1, "\t [Adding script commands from %s] \n", - world.curjob->curcmd->param[0]); - revm_output(str); - } - - if (revm_add_script_cmd(world.curjob->curcmd->param[0]) < 0) - { - revm_output("\t failed\n\n"); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Macro command adding failed", (-1)); - } - else - { - revm_completion_commands(&cmd_hash); - if (!world.state.revm_quiet) - revm_output("\t done\n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen tag - */ -int cmd_lscripts() -{ - char str[BUFSIZ]; - listent_t *actual; - int index; - int cnt = 1; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* scripts dir already specified so cleanup command set */ - if (world.scriptsdir != NULL) - { - revm_output(" .::. Script commands .::.\n"); - - for (index = 0; index < cmd_hash.size; index++) - for (actual = &cmd_hash.ent[index]; - actual != NULL && actual->key != NULL; - actual = actual->next) - { - if (((revmcmd_t *) actual->data)->exec == cmd_script) - { - snprintf(str, BUFSIZ - 1, " [%.3d] %s\n", cnt, actual->key); - revm_output(str); - cnt++; - - } - } - if (cnt == 1) - revm_output("[*] No script commands\n"); - revm_output("\n"); - } - else - revm_output(" [!!] No script directory specified, use sdir command.\n\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/source.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/source.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/source.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/source.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -/** -** @file source.c -** @ingroup libstderesi -** Started on Fri May 16 15:18:35 2005 jfv -** $Id: source.c,v 1.1 2007-11-29 14:01:56 may Exp $ -*/ -#include "libstderesi.h" - -/** - * @brief Sourcing of ERESI scripts - */ -int cmd_source() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - ret = revm_source(world.curjob->curcmd->param); - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to source script", (-1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/switch.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/switch.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/switch.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/switch.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/** -** @file switch.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:20:49 2003 jfv -** -** $Id: switch.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Change the current object - */ -int cmd_doswitch() -{ - char logbuf[BUFSIZ]; - int ret; - int nbr; - elfshobj_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->param[0] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - nbr = atoi(world.curjob->curcmd->param[0]); - - ret = revm_doswitch(nbr); - - if (ret < 0) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [!] Cant switch on file object %s (use 'list') (switching to a dependence need the id) \n\n", - world.curjob->curcmd->param[0]); - revm_output(logbuf); - } - else - { - cur = world.curjob->curfile; - -#if defined(USE_MJOLLNIR) - mjr_set_current_context(&world.mjr_session, cur->name); -#endif - - snprintf(logbuf, BUFSIZ - 1, "\n [*] Switched on object %u (%s) \n\n", - cur->id, cur->name); - revm_output(logbuf); - if (elfsh_is_debug_mode() && !cur->linkmap) - revm_output("\n [!!] Loaded file is not the linkmap, " - "switching to STATIC mode\n\n"); - - } - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/trace.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/trace.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/trace.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/trace.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1421 +0,0 @@ -/** -* @file trace.c -* @ingroup libstderesi -* @brief All functions that help to trace content -* -* Started Jul 2 2005 00:03:44 mxatone -* -* -* $Id: trace.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -* -*/ -#include "libstderesi.h" -#include "libetrace.h" - -char buf[BUFSIZ]; - -/* XXX: The good syntax should be : -** -** traces funcname [optional_traces_name] : add a function to a given trace -** traces funcname [optional_traces_name] : remove a function from a given trace -** traces funcname|all [optional_traces_name] : enable tracing for a function in a given trace (enabled by default after a add) -** traces funcname|all [optional_traces_name] : disable tracing for a function in a given trace -** traces tracename : create a new trace with a pool of traced functions by default -** traces tracename : delete a trace -** traces tracename : remove all functions from a given trace -** traces [optional_traces_name] : list all available traces -** -*/ - -char **last_arguments = NULL; - -#define TRACE_ADDR_TABLE "addrtable" - -#define TRACE_PRE_FUNC "func_" -#define TRACE_GET_FUNC_NAME(_buffer, _size, _addr) \ -snprintf(_buffer, _size, TRACE_PRE_FUNC "%s", _addr+2) - -#define TRACE_MATCH_ALL(_funcname) \ -!strcmp(_funcname, ".*") - -/** - * Add arguments for a futur traces_run - * @param argc arguments number - * @param argv arguments - * @see traces_run - */ -int revm_traces_add_arguments(int argc, char **argv) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (argc < 1 || argv == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Copy arguments */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, last_arguments, sizeof(char *)*(argc+1), -1); - memcpy(last_arguments, argv, sizeof(char*)*argc); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -const int match_alloc_step = 10; - -/** - * Match a function in a symbol table - * @param sect section pointer - * @param num element number - * @param preg reg structure - * @param func_list function table - * @param count counter pointer (from the table) - * @param get_symname function ptr to get symbol name - * @return 0 on success. - */ -static int revm_traces_match_in_symtable(elfshsect_t *sect, - int num, - regex_t *preg, - char ***func_list, - u_int *count, - char *(*get_symname)(elfshobj_t *f, - elfsh_Sym *s)) -{ - u_int index; - elfsh_Sym *table; - char *name; - char **f_list; - u_int cnum; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check argument before anything */ - if (!sect || !preg || !func_list || !count || !get_symname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - f_list = *func_list; - cnum = *count; - table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_get_raw(sect) : sect->data); - - /* Parse every function */ - for (index = 0; index < num; index++) - { - /* Only functions */ - if (elfsh_get_symbol_type(table + index) != STT_FUNC - || table[index].st_value == 0) - continue; - - name = get_symname(world.curjob->curfile, table + index); - - /* Check if this name is valid */ - if (name == NULL || *name == 0) - continue; - - /* We match a function */ - if (regexec(preg, name, 0, 0, 0) == 0) - { - /* Do we need to realloc ? */ - if (((cnum+1) % match_alloc_step) == 0) - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, - sizeof(char*) * (cnum + 1 + match_alloc_step), -1); - - /* Blank new elements */ - memset(&f_list[cnum], 0x00, match_alloc_step*sizeof(char*)); - - /* Update the pointer, data can move during a reallocation */ - *func_list = f_list; - } - - /* Add the function in the table */ - f_list[cnum] = name; - - *count = ++cnum; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Match functions from an addrtable - * @param func_list function list pointer - * @param count position on the list - */ -static int revm_traces_match_in_addrtable(char ***func_list, u_int *count) -{ - eresi_Addr *alist = NULL; - u_int index; - char **f_list; - u_int cnum; - char tmpstr[256]; - elfsh_Sym *sym; - char *toadd; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!func_list || !count) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - f_list = *func_list; - cnum = *count; - - /* Retrieve all called address in this binary */ - if (elfsh_addr_get_func_list(world.curjob->curfile, &alist) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get call function list", -1); - - for (index = 0; alist[index]; index++) - { - sym = elfsh_get_symbol_by_value(world.curjob->curfile, alist[index], - 0, ELFSH_EXACTSYM); - - /* Find a symbol for this address */ - if (sym) - { - toadd = elfsh_get_symbol_name(world.curjob->curfile, sym); - } - else - { - snprintf(tmpstr, 255, TRACE_PRE_FUNC "" AFMT, - alist[index]); - toadd = tmpstr; - } - - /* Do we need to realloc ? */ - if (((cnum+1) % match_alloc_step) == 0) - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, - sizeof(char*) * (cnum + 1 + match_alloc_step), -1); - - /* Blank new elements */ - memset(&f_list[cnum], 0x00, match_alloc_step*sizeof(char*)); - - /* Update the pointer, data can move during a reallocation */ - *func_list = f_list; - } - - /* If its temp string, strdup it */ - if (toadd == tmpstr) - toadd = strdup(tmpstr); - - f_list[cnum] = toadd; - - *count = ++cnum; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Match a list of function from symbol tables - * @param funcreg Function regex (or not ?) - * @param func_list the final function list - */ -static int revm_traces_match_funcname(char *funcname, char ***func_list) -{ - regex_t preg; - char **f_list; - u_int count = 0; - elfshsect_t *sect; - int num; - elfsh_Sym *symtab; - elfsh_Sym *sym; - char funcreg[256]; - char addrname[256]; - size_t len; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!funcreg || !func_list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - len = strlen(funcname); - - /* We don't want to strip some part of the submited function - but if you find a function/regex of this size (for this purpose) ... */ - if (len > 255) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function name is too long", -1); - - /* An address ? */ - if (IS_VADDR(funcname)) - { - /* Retrieve the address */ - sscanf(funcname + 2, AFMT, &addr); - - /* Prealloc the list */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); - - sym = elfsh_get_symbol_by_value(world.curjob->curfile, addr, 0, ELFSH_EXACTSYM); - - /* We have a symbol for this address */ - if (sym) - { - f_list[0] = elfsh_get_symbol_name(world.curjob->curfile, sym); - f_list[1] = NULL; - } - else - { - sym = elfsh_get_dynsymbol_by_value(world.curjob->curfile, addr, 0, ELFSH_EXACTSYM); - - /* We have a dynamic symbol for this address */ - if (sym) - { - f_list[0] = elfsh_get_dynsymbol_name(world.curjob->curfile, sym); - f_list[1] = NULL; - } - else - { - TRACE_GET_FUNC_NAME(addrname, 255, funcname); - - f_list[0] = strdup(addrname); - f_list[1] = NULL; - } - } - - goto end; - } - - /* Add ^ and $ if needed, else we will check too many things - For example, someone wanna add "main" function, if we don't - add those symbols, it will match __libc_start_main which is very - special function and that can create problems and make the tracer - useless */ - snprintf(funcreg, 255, "%s%s%s", - funcname[0] != '^' ? "^" : "", - funcname, - funcname[len-1] != '$' ? "$" : ""); - - /* Do we have a regex ? */ - if (regcomp(&preg, funcreg, 0) != 0) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); - f_list[0] = funcname; - f_list[1] = NULL; - - goto end; - } - - /* Preallocation */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, - sizeof(char*) * match_alloc_step, -1); - - - /* Total match case */ - if (TRACE_MATCH_ALL(funcname)) - { - /* Match everything we can, symbol or not ! */ - revm_traces_match_in_addrtable(&f_list, &count); - } - - /** - * Match on symbol table - */ - symtab = elfsh_get_symtab(world.curjob->curfile, &num); - - if (symtab != NULL) - { - sect = elfsh_get_section_by_type(world.curjob->curfile, - SHT_SYMTAB, 0, NULL, NULL, 0); - - /* Match function regex in the symbol table */ - revm_traces_match_in_symtable(sect, num, &preg, &f_list, &count, elfsh_get_symbol_name); - } - - /** - * Match on dynamic symbol table - */ - symtab = elfsh_get_dynsymtab(world.curjob->curfile, &num); - - if (symtab != NULL) - { - - sect = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_ALTDYNSYM, - NULL, NULL, &num); - if (!sect) - sect = elfsh_get_section_by_type(world.curjob->curfile, SHT_DYNSYM, 0, - NULL, NULL, &num); - - num /= sizeof(elfsh_Sym); - - /* Match function regex in the dynamic symbol table */ - revm_traces_match_in_symtable(sect, num, &preg, &f_list, &count, elfsh_get_dynsymbol_name); - } - - /* Do we get something ? */ - if (count == 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, f_list); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't match a single function", -1); - } - - end: - - /* Set final pointer */ - *func_list = f_list; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Research the uniform debugging format function entry on a list of files - * @param files first element of a edfmtfile_t structure - * @param name function name - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -static edfmtfunc_t *revm_traces_search_uni_file(edfmtfile_t *files, char *name) -{ - edfmtfunc_t *func; - edfmtfile_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (file = files ; file != NULL; file = file->next) - { - func = hash_get(&(file->hfunc), name); - - if (func != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); - - if (file->child) - { - func = revm_traces_search_uni_file(file->child, name); - if (func != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Research the uniform debugging format function entry - * @param file first element of a edfmtfile_t structure - * @param name function name - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -static edfmtfunc_t *revm_traces_search_uni(elfshobj_t *file, char *name) -{ - edfmtfunc_t *func; - edfmtinfo_t *uni; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - uni = edfmt_get_uniinfo(file); - - if (!uni) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No debugging informations available", NULL); - - /* Search on global scope */ - func = hash_get(&(uni->hfunc), name); - if (func == NULL) - { - /* Search on local stop if needed */ - func = revm_traces_search_uni_file(uni->files, name); - if (func == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function not found", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); -} - -/** - * Search the function entry on the uniform debugging format, and return it - * @param file first element of a edfmtfile_t structure - * @param func_name function name - * @param external indicate if we need internal or external research - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -edfmtfunc_t *revm_traces_tracable_with_type(elfshobj_t *file, char *func_name, - u_char external) -{ - elfshobj_t *sym_file; - edfmtfunc_t *func = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We have an extern symbol */ - if (external) - { - sym_file = etrace_search_sym(file, func_name); - - if (sym_file) - func = revm_traces_search_uni(sym_file, func_name); - } - else - { - /* Search in this file */ - func = revm_traces_search_uni(file, func_name); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); -} - -/** - * Construct the argument structure depending of the option we have - * @param file target file - * @param ent pointer to set - * @param func uniform debugging inforation if we got one - * @param vaddr virtual address of the function if we don't have debugging information - * @param external describe scope - * @see revm_traces_createargs - */ -static int revm_traces_build_args(elfshobj_t *file, elfshtraces_t *ent, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external) -{ - u_int index; - int *argcount; - edfmtfuncarg_t *arg; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!ent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - elfsh_setup_hooks(); - - ent->scope = external ? ELFSH_ARG_EXTERN : ELFSH_ARG_INTERN; - - /* Do we have uniform debugging information for this structure ? */ - if (func == NULL) - { - argcount = elfsh_args_count(file, 0, vaddr); - - ent->type = ELFSH_ARG_SIZE_BASED; - ent->argc = 0; - - /* If we found some argument, else its 0 */ - if (argcount) - { - /* Fill arguments */ - for (index = 0; argcount[index] > 0; index++) - ent->arguments[index].size = argcount[index]; - - ent->argc = index; - XFREE(__FILE__, __FUNCTION__, __LINE__, argcount); - } - } - else - { - ent->type = ELFSH_ARG_TYPE_BASED; - for (arg = func->arguments, index = 0; arg != NULL; arg = arg->next, index++) - { - /* We setup argument name and typename */ - ent->arguments[index].name = arg->name; - ent->arguments[index].typename = arg->type ? arg->type->name : NULL; - - /* Other information are quite the same as arg counting method */ - ent->arguments[index].size = 0; - if (arg->type->size > 0) - ent->arguments[index].size = arg->type->size; - - if (ent->arguments[index].size < sizeof(eresi_Addr)) - ent->arguments[index].size = sizeof(eresi_Addr); - } - - ent->argc = func->argc; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Allocate the traces structure and call previous - * @param file target file - * @param func uniform debugging inforation if we got one - * @param vaddr virtual address of the function if we don't have debugging information - * @param external describe scope - * @return generate trace structure - * @see revm_traces_build_args - */ -elfshtraces_t *revm_traces_createargs(elfshobj_t *file, char *name, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external) -{ - elfshtraces_t *newtrace; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // Alloc the structure - XALLOC(__FILE__, __FUNCTION__, __LINE__, newtrace, sizeof(elfshtraces_t), NULL); - snprintf(newtrace->funcname, ELFSH_TRACES_FUNC_SIZE - 1, "%s", name); - newtrace->file = file; - newtrace->enable = 1; - newtrace->vaddr = vaddr; - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] Builds args for %s\n", name); -#endif - - // We fill arguments part and check if we found the function - if (revm_traces_build_args(file, newtrace, func, vaddr, external) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newtrace); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found or impossible to trace", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtrace); -} - -/** - * Add a function on a trace (from commande line) - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_add(elfshobj_t *file, char *name, char **optarg) -{ - elfshtraces_t *traces; - edfmtfunc_t *func = NULL; - eresi_Addr vaddr = 0; - u_char external = 0; - char **func_list; - u_int index, traced = 0; - char *trace_name; - int ret; - char *current_name; - eresi_Addr addr = 0; - u_char cont = 0; - u_char multiaddr = 0; - size_t prelen; - elfshsect_t *newsymsect; - elfsh_Sym *symbol; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Try to match functions with a regex */ - if (revm_traces_match_funcname(name, &func_list) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't match a single function", -1); - - /* Address case - if the function name (always the first) will have the address in its name - else we found a symbol which correspond to the address */ - if (IS_VADDR(name) && strstr(func_list[0], name + 2) != NULL) - sscanf(name + 2, AFMT, &addr); - - trace_name = optarg ? *optarg : NULL; - - /* When we try to match everything */ - multiaddr = TRACE_MATCH_ALL(name); - - if (multiaddr) - { - prelen = strlen(TRACE_PRE_FUNC); - - snprintf(buf, BUFSIZ - 1, - "\n\t[*] Start hooking all internal/external functions ...\n\n"); - revm_output(buf); - } - - /* Try to add every function */ - for (index = 0; func_list[index] != NULL; index++) - { - external = 0; - vaddr = 0; - cont = 0; - current_name = func_list[index]; - - /* FIXME: A function name containing "." will not be compiled right with gcc */ - if (strstr(current_name, ".") || !PRINTABLE(current_name[0])) - continue; - - /* Can we trace this function */ - if (addr > 0) - ret = etrace_valid_faddr(file, addr, &vaddr, &external); - else - { - /* Multiple address tracing */ - if (multiaddr && !strncmp(TRACE_PRE_FUNC, current_name, prelen)) - { - /* Prepare for a new address function */ - sscanf(current_name + prelen, AFMT, &vaddr); - ret = 0; - } - else - ret = etrace_tracable(file, current_name, &vaddr, &external); - } - - if (ret < 0) - { - buf[0] = 0x00; - switch(ret) - { - case -2: /* Untracable function */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s is an untracable function. Some dedicated OS functions are " - "context depend and can't be traced.\n\n", - current_name); - cont = 1; - break; - - case -3: /* Not called address */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s (%s) address will be trace but we won't be able to find at least " - "one call for this function.\n\n", - current_name, name); - break; - - case -4: /* Not called address */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s (%s) address can't be found on entrypoint section.\n\n", - current_name, name); - cont = 1; - break; - } - - if (buf[0] != 0x00) - revm_output(buf); - - if (cont) - continue; - } - - /* Can we trace with libedfmt informations ? */ - if (addr > 0 || vaddr > 0) - { - func = NULL; - - /* Do we need to add the symbol right before hijacking ? */ - symbol = elfsh_get_symbol_by_name(file, current_name); - - if (!symbol) - { - newsymsect = elfsh_get_parent_section(file, addr > 0 ? addr : vaddr, NULL); - - if (!newsymsect) - continue; - - /* Add a new function symbol */ - if (elfsh_insert_funcsym(file, current_name, - addr > 0 ? addr : vaddr, - 0, newsymsect->index) < 0) - continue; - } - else if (!symbol->st_value) /* Invalid symbol */ - continue; - } - - if (!addr) - func = revm_traces_tracable_with_type(file, current_name, external); - - /* Create the structure */ - traces = revm_traces_createargs(file, current_name, func, vaddr, external); - - if (!traces) - continue; - - /* Add the function */ - if (etrace_funcadd(trace_name, current_name, traces) == NULL) - continue; - - /* To avoid flood we don't display every added function for multiaddr */ - if (!multiaddr) - { - snprintf(buf, BUFSIZ - 1, "\t[*] Added function %s successfully into trace %s\n\n", - current_name, trace_name ? trace_name : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - } - - traced++; - } - - /* Free allocated table */ - if (index > 0) - XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); - - /* Do we add at least something ? */ - if (traced == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't add any founded functions", -1); - - /* We print the sum only */ - if (multiaddr) - { - snprintf(buf, BUFSIZ - 1, "\t[*] Added %d functions successfully into trace %s\n\n", - traced, trace_name ? trace_name : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - } - - /* Free function list */ - XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_rm(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_funcrm(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Delete function failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Deleted function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Exclude functions by regexec during the last stage - * @param file target - * @param freg first reg - * @param oreg others reg list - */ -int traces_exclude(elfshobj_t *file, char *freg, char **oreg) -{ - u_int index; - const char pattern[] = "\n\t[*] Exclude function %s successfully\n\n"; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!freg || !freg[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Exclude first argument */ - if (etrace_funcexclude(freg) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - snprintf(buf, BUFSIZ - 1, pattern, freg); - revm_output(buf); - - if (oreg) - { - for (index = 0; oreg[index] != NULL; index++) - { - if (etrace_funcexclude(oreg[index]) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); - revm_output(buf); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete excluded functions by regexec during the last stage - * @param file target - * @param freg first reg - * @param oreg others reg list - */ -int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg) -{ - u_int index; - const char pattern[] = "\n\t[*] Delete excluded function %s successfully\n\n"; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!freg || !freg[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - etrace_funcrmexclude(freg); - - snprintf(buf, BUFSIZ - 1, pattern, freg); - revm_output(buf); - - if (oreg) - { - for (index = 0; oreg[index] != NULL; index++) - { - etrace_funcrmexclude(oreg[index]); - - snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); - revm_output(buf); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Enable a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_enable(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!strcmp(name, "all")) - { - if (etrace_funcenableall(optarg ? *optarg : NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Enable all functions failed", -1); - } - else - { - if (etrace_funcenable(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Enable function failed", -1); - } - - snprintf(buf, BUFSIZ - 1, "\t[*] Enabled function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Disable a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_disable(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!strcmp(name, "all")) - { - if (etrace_funcdisableall(optarg ? *optarg : NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Disable all functions failed", -1); - } - else - { - if (etrace_funcdisable(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Disable function failed", -1); - } - - snprintf(buf, BUFSIZ - 1, "\t[*] Disabled function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create a trace - * @param file target - * @param name trace name - * @param optarg list of function to directly add - */ -int traces_create(elfshobj_t *file, char *name, char **optarg) -{ - char *strarr[2]; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_createtrace(name) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Create trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Created trace %s successfully\n\n", name); - revm_output(buf); - - if (optarg && *optarg) - { - /* Add gived elements */ - for (index = 0; optarg[index]; index++) - { - strarr[0] = name; - strarr[1] = NULL; - if (traces_add(file, optarg[index], strarr) < 0) - continue; - } - - revm_output("\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete a trace - * @param file target - * @param name trace name - * @param optarg not use - */ -int traces_delete(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_deletetrace(name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Delete trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Deleted trace %s successfully\n\n", name); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Flush a whole trace - * @param name trace name - * @param optarg not use - */ -int traces_flush(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_funcrmall(name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flush trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Flushed trace %s successfully\n\n", name); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Detail listing of a trace - * @param table trace hash table - * @param name trace name - * @see traces_list - */ -static int traces_list_detail(hash_t *table, char *name) -{ - char **keys; - u_int index; - int keynbr; - elfshtraces_t *entrie; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ - 1, " ~> %s: %s\n", - revm_colorfieldstr("Trace name"), - revm_colorstr(name)); - revm_output(buf); - - keys = hash_get_keys(table, &keynbr); - - if (keys && keynbr > 0) - { - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - entrie = (elfshtraces_t *) hash_get(table, keys[index]); - - if (entrie) - { - snprintf(buf, BUFSIZ - 1, " %s: %s %s: %s\n", - revm_colorfieldstr("Function name"), - revm_colorstr_fmt("%-15s", entrie->funcname), - revm_colorfieldstr("status"), - revm_colortypestr(entrie->enable ? "enabled" : "disabled")); - revm_output(buf); - revm_endline(); - } - } - - revm_output("\n"); - - hash_free_keys(keys); - } - else - { - revm_output("\n No function in this trace\n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Enumerate each trace and detail every functions - * @param name not use - * @param optarg not use - * @see traces_list_detail - */ -int traces_list(elfshobj_t *file, char *name, char **optarg) -{ - char **keys = NULL; - u_int index; - int keynbr; - hash_t *subtable; - char funcreg[256]; - size_t len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output(" .: Trace list :.\n"); - - if (traces_table.ent) - keys = hash_get_keys(&traces_table, &keynbr); - - if (keys) - { - if (keynbr > 0) - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - subtable = hash_get(&traces_table, keys[index]); - - if (subtable) - traces_list_detail(subtable, keys[index]); - } - - hash_free_keys(keys); - } - else - { - revm_output("\n No tracing table available\n\n"); - } - - revm_output(" .: Exclude list :.\n"); - - /* Reset */ - keynbr = 0; - keys = NULL; - - /* Print exclude list */ - if (exclude_table.ent) - keys = hash_get_keys(&exclude_table, &keynbr); - - if (keys) - { - if (exclude_table.ent) - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - len = strlen(keys[index]); - snprintf(funcreg, 255, "%s%s%s", - keys[index][0] != '^' ? "^" : "", - keys[index], - keys[index][len-1] != '$' ? "$" : ""); - - snprintf(buf, BUFSIZ - 1, " %s %s %s %s %s\n", - revm_colornumber("[%02u]", index+1), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-15s", keys[index]), - revm_colorfieldstr("regex:"), - revm_colorstr(funcreg)); - revm_output(buf); - revm_endline(); - } - - hash_free_keys(keys); - } - else - { - revm_output("\n No exclude table available\n"); - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Run a trace session (used in etrace) - * @param file target - * @param argv argument list - * @param argc argument counter - */ -int traces_run(elfshobj_t *file, char **argv, int argc) -{ - char *home; - char *filename; - size_t len; - u_int index; - char *path; - char *av[argc+2]; - int ret; - struct timeval now, after; - double difftime; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We use etrace */ - if (world.state.revm_mode == REVM_STATE_TRACER) - { - argc = 0; - if (last_arguments) - { - while (last_arguments[argc] != NULL) - argc++; - argv = last_arguments; - } - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, argv, sizeof(char*), -1); - argv[0] = NULL; - } - } - - if (argc < 0 || !argv) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (!(elfsh_get_objtype(elfsh_get_hdr(file)) == ET_EXEC)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "We need a ET_EXEC binary", -1); - - home = getenv("HOME"); - - if (!home) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find home directory", -1); - - snprintf(buf, BUFSIZ - 1, "%s/%s", home, REVM_TRACE_REP); - - /* Create temp directory if needed */ - mkdir(buf, 0700); - - /* We search the filename (we have a path) */ - len = strlen(file->name); - filename = file->name; - - for (index = len; index > 0; index--) - if (file->name[index] == '/') - break; - - if (INTERVAL(0, index+1, len)) - filename = file->name + index + 1; - - /* Full path */ - snprintf(buf, BUFSIZ - 1, "%s/%s/%s", home, REVM_TRACE_REP, filename); - path = strdup(buf); - - /* Pre register working objects for ELFsh */ - elfsh_register_working_objects(&world.curjob->loaded, - &world.shared_hash); - - if (elfsh_save_obj(file, path) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to save object", -1); - - av[0] = path; - for (index = 0; index < argc; index++) - av[index+1] = argv[index]; - av[index+1] = NULL; - - gettimeofday(&now, NULL); - - /* Print start */ - revm_output("Start execution of "); - for (index = 0; index < argc+1; index++) - { - snprintf(buf, BUFSIZ - 1, "%s ", av[index]); - revm_output(buf); - } - revm_output("\n"); - - /* Start with arguments */ - if (!fork()) - ret = execv(av[0], av); - else - wait(NULL); - - gettimeofday(&after, NULL); - - difftime = (after.tv_sec - now.tv_sec) + ((double) (after.tv_usec - now.tv_usec)) * 0.000001; - - snprintf(buf, BUFSIZ - 1, "End execution (%.6f sec)\n\n", difftime); - revm_output(buf); - - XFREE(__FILE__, __FUNCTION__, __LINE__, path); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create the structure that store trace cmd informations - * @param exec function pointer - * @param flagName - * @param flagArg - */ -revmtraces_t *traces_create_CMDENT(int (*exec)(elfshobj_t *file, char *name, char **optarg), - char flagName, char flagArg) -{ - revmtraces_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, new, sizeof(revmtraces_t), NULL); - new->exec = exec; - new->flagName = flagName; - new->flagArg = flagArg; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * Add a command in sub commande hash table - * @param cmd cmd name - * @param exec function pointer - * @param flagName - * @param flagArg - * @see traces_cmd_hash - * @see traces_create_CMDENT - */ -int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_add(&traces_cmd_hash, cmd, (void *) traces_create_CMDENT(exec, flagName, flagArg)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_traces() -{ - revmtraces_t *cmd; - char *fArg; - char **sArg; - int ret = 0; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init tracing elements */ - etrace_inittrace(); - - switch(world.curjob->curcmd->argc) - { - case 0: - traces_list(world.curjob->curfile, NULL, NULL); - break; - case 1: - table = etrace_gettrace(world.curjob->curcmd->param[0]); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown trace", -1); - - traces_list_detail(table, world.curjob->curcmd->param[0]); - break; - default: - cmd = hash_get(&traces_cmd_hash, world.curjob->curcmd->param[0]); - - if (!cmd) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown command", -1); - - fArg = NULL; - sArg = NULL; - - if (cmd->flagName > 0) - { - /* First argument is needed and doesn't submited */ - if (!world.curjob->curcmd->param[1] && cmd->flagName == 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "First argument is needed", -1); - - fArg = world.curjob->curcmd->param[1]; - - if (cmd->flagArg > 0) - { - /* Second argument is needed and doesn't submited */ - if (!world.curjob->curcmd->param[2] && cmd->flagArg == 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Second argument is needed", -1); - - sArg = world.curjob->curcmd->param + 2; - } - } - - ret = cmd->exec(world.curjob->curfile, fArg, sArg); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -int cmd_traceadd() -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init tracing elements */ - etrace_inittrace(); - - if (world.curjob->curcmd->argc < 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need at least one function", -1); - - /* Loop on each passed functions */ - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - if (traces_add(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_traceexclude() -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc < 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need at least one function", -1); - - /* Loop on each passed functions */ - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - if (traces_exclude(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen brief tag - */ -int cmd_tracerun() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (traces_run(world.curjob->curfile, - world.curjob->curcmd->param, - world.curjob->curcmd->argc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to run current trace", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/types.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/types.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/types.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/types.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/** -* @file types.c -* @ingroup libstderesi -* Be able to add your own types in runtime -* -* Started on Sun Jan 9 07:23:58 2007 jfv -* $Id: types.c,v 1.2 2007-12-06 06:40:16 may Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * Types management command - */ -int cmd_type() -{ - int nocmd; - u_char isunion; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - isunion = !strcmp(world.curjob->curcmd->name, CMD_UNION); - nocmd = 0; - switch (world.curjob->curcmd->argc) - { - /* type */ - case 0: - revm_type_prints(); - break; - - /* type name */ - case 1: - revm_type_print_regex(world.curjob->curcmd->param[0]); - revm_output("\n"); - break; - - /* Those case are invalid syntaxes */ - case 2: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - default: - /* Add a type */ - if (!strcmp(world.curjob->curcmd->param[1], "=") || - !strcmp(world.curjob->curcmd->param[1], "is")) - { - - /* Dont forget to filter on command names too, as each type - will need to have its name bound on cmd_declare() */ - if (hash_get(&cmd_hash, world.curjob->curcmd->param[0])) - nocmd = 1; - if (aspect_type_register(isunion, world.curjob->curcmd->param[0], - world.curjob->curcmd->param + 2, - world.curjob->curcmd->argc - 2) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type declaration", -1); - - if (!world.state.revm_quiet) - { - revm_output("\n\t [*] Added type "); - revm_output(world.curjob->curcmd->param[0]); - revm_output(" succesfully \n\n"); - } - - /* Create the hash table for objects of that type */ - revm_type_hashcreate(world.curjob->curcmd->param[0]); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - } - - /* Register this alias as a command */ - if (!nocmd) - revm_command_add(world.curjob->curcmd->param[0], cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Typedef command function - */ -int cmd_typedef() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - ret = revm_type_copy(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - (ret == -1 ? "Type not found" : - "Failed to create a new type"), -1); - - /* Register this alias as a command */ - revm_command_add(world.curjob->curcmd->param[1], cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); - - /* Output report */ - if (!world.state.revm_quiet) - { - revm_output("\n\t [*] Copied type "); - revm_output(world.curjob->curcmd->param[0]); - revm_output(" to "); - revm_output(world.curjob->curcmd->param[1]); - revm_output(" succesfully \n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/unload.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/unload.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/unload.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/unload.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/** - * @file unload.c - * @ingroup libstderesi - * Started on Sat Jan 25 11:21:52 2003 jfv - * Last update Thu Mar 11 07:56:36 2004 jfv - * - * $Id: unload.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Unload a file from the shell - */ -int cmd_unload() -{ - hash_t *loaded; - elfshobj_t *cur; - time_t uloadt; - char logbuf[BUFSIZ]; - int ret; - u_int id; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get the file structure */ - id = atoi(world.curjob->curcmd->param[0]); - cur = revm_lookup_file(world.curjob->curcmd->param[0]); - if (cur == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object not loaded", -1); - - /* Do not unload dependences of files or objects with linkmap entry */ - if (hash_size(&cur->parent_hash)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unload parent object first", -1); - if (cur->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You cannot unload a mapped object", -1); - ret = revm_unload_dep(cur, cur); - if (!world.state.revm_quiet) - { - time(&uloadt); - snprintf(logbuf, BUFSIZ - 1, "%s [*] Object %-40s unloaded on %s \n", - (ret ? "" : "\n"), cur->name, ctime(&uloadt)); - revm_output(logbuf); - } - - /* Clean various hash tables of this binary entry and return OK */ - hash_del(&file_hash, cur->name); - if (hash_get(&world.shared_hash, cur->name)) - hash_del(&world.shared_hash, cur->name); - else - hash_del(&world.curjob->loaded, cur->name); - elfsh_unload_obj(cur); - revm_output("\n"); - - /* If the file is the current working one, swap to another one */ - if (cur == world.curjob->curfile) - { - loaded = (hash_size(&world.curjob->loaded) ? - &world.curjob->loaded : hash_size(&world.shared_hash) ? - &world.shared_hash : NULL); - if (!loaded) - world.curjob->curfile = NULL; - else - do cur = hash_get_one(loaded); - while (cur == world.curjob->curfile); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/utils.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/utils.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/utils.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/utils.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,124 +0,0 @@ -/** - * @file utils.c - * @ingroup libstderesi - * Started on Fri Nov 2 15:21:56 2001 jfv - * Updated on Thu Jan 04 11:26:11 2007 jfv - * - * $Id: utils.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Useful when you have only one terminal - */ -int cmd_meta() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!world.state.revm_quiet) - revm_output(" [*] You are still in elfsh, exit bash " - "to get back to the regular prompt \n\n"); - - revm_terminal_unprepare(world.state.revm_mode); - ret = revm_system(revm_lookup_string("$SHELL")); - revm_terminal_prepare(world.state.revm_mode); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - - -/** - * Edit a file - */ -int cmd_edit() -{ - int ret; - char buff[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_terminal_unprepare(world.state.revm_mode); - - snprintf(buff, BUFSIZ, "%s %s", - revm_lookup_string("$EDITOR"), - world.curjob->curcmd->param[0]); - - ret = revm_system(buff); - - revm_terminal_prepare(world.state.revm_mode); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * Stop the scripting and pass in interactive mode - */ -int cmd_stop() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_STOP); -} - - -/** - * Precise a general weak bounded regex for all options - */ -int cmd_alert() -{ - char *str; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = strdup(world.curjob->curcmd->param[0]); - - if (regcomp(&world.state.revm_alert, str, REG_EXTENDED) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to compute regex", -1); - world.state.revm_use_alert = 1; - if (world.state.revm_salert) - XFREE(__FILE__, __FUNCTION__, __LINE__,world.state.revm_salert); - world.state.revm_salert = str; - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Changed alert regex to %s \n\n", str); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Get ASCII string for hash table - */ -char *revm_ascii_type(hash_t *cur) -{ - return (aspect_typename_get(cur->type)); -} - -/** - * Get ASCII string for hash table - * @param cur - * @return -*/ -char *revm_ascii_ltype(list_t *cur) -{ - return (aspect_typename_get(cur->type)); -} - - -/** - * Get ASCII string for hash table - * @param cur - * @return -*/ -char *revm_ascii_vtype(vector_t *cur) -{ - return (aspect_typename_get(cur->type)); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/vectors.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/vectors.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/vectors.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/vectors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,368 +0,0 @@ -/** - * @file vectors.c - * @ingroup libstderesi - * Started on Sat Jan 06 06:43:11 2007 jfv - * - * $Id: vectors.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * - */ -#include "libstderesi.h" - -/** - * Get numbers of vector dimensions requested for the display - * @param str - */ -int revm_vectors_getdimnbr(char *str) -{ - int nbr; - - for (nbr = 0; str && *str; nbr++) - { - str = strchr(str, ':'); - if (!str) - return (nbr); - else - str++; - } - return (nbr); -} - -/** - * Get numbers of vector dimensions requested for the display - * @param str - * @param dims - */ -int revm_vectors_getdims(char *str, unsigned int *dims) -{ - revmobj_t *v; - int nbr; - char *str2; - - /* FIXME : add elfsh vectors index macros to completion */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (nbr = 0; str && *str; nbr++) - { - str = strchr(str, ':'); - if (!str) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - *str = 0x00; - str2 = strchr(++str, ':'); - if (str2) - *str2 = 0x00; - v = revm_lookup_immed(str); - if (v->otype->type != ASPECT_TYPE_LONG && v->otype->type != ASPECT_TYPE_INT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid vector indexes", -1); - dims[nbr] = (v->immed ? v->immed_val.ent : v->get_obj(v->parent)); - if (str2) - *str2 = ':'; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Check vectors dimensions - * @param vect - * @param dims - * @param dimnbr - * @return - */ -int revm_vector_bad_dims(vector_t *vect, unsigned int *dims, - unsigned int dimnbr) -{ - int idx; - - if (vect->arraysz != dimnbr) - return (1); - for (idx = 0; idx < dimnbr; idx++) - if (dims[idx] >= vect->arraydims[idx]) - return (1); - return (0); -} - - - -/** - * Modify a value inside a vector - * @return - */ -static int revm_vector_modify() -{ - vector_t *cur; - int dimnbr; - unsigned int *dims; - eresi_Addr value; - char logbuf[BUFSIZ]; - int len; - int index; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lookup value to write */ - obj = revm_lookup_immed(world.curjob->curcmd->param[1]); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid update value for vector", -1); - value = (obj->immed ? obj->immed_val.ent : - (eresi_Addr) obj->get_obj(obj->parent)); - - /* Lookup vector indexes */ - if (strchr(world.curjob->curcmd->param[0], ':')) - { - dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); - if (dimnbr < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get vector indexes values", -1); - dims = alloca(dimnbr * sizeof(unsigned int)); - revm_vectors_getdims(world.curjob->curcmd->param[0], dims); - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", -1); - if (revm_vector_bad_dims(cur, dims, dimnbr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", -1); - aspect_vectors_insert(cur, dims, value); - len = snprintf(logbuf, sizeof(logbuf), "\n [*] Modified : Vector[%s]", - world.curjob->curcmd->param[0]); - for (index = 0; index < dimnbr; index++) - len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); - snprintf(logbuf + len, sizeof(logbuf) - len, " = " XFMT "\n", value); - revm_output(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You need to supply the vector indexes to be modified", -1); -} - - - -/** - * Print a vector entry with its resolve - * @param vaddr - * @param def - */ -static void revm_vector_entry_display(eresi_Addr vaddr, eresi_Addr def) -{ - Dl_info info; - char *bsep; - char *esep; - char *print; - char log[BUFSIZ]; - - if (!dladdr((void *) ((unsigned long *) vaddr), &info)) - dlerror(); - esep = bsep = ""; - if (info.dli_sname && vaddr != def) - { - esep = ">"; - bsep = "<"; - print = (char *) info.dli_sname; - } - else if (vaddr == def) - { - esep = ")"; - bsep = "("; - print = "default handler"; - } - else - print = "Unknown function"; - snprintf(log, sizeof(log), " = " XFMT " %s%s%s\n", vaddr, bsep, print, esep); - revm_output(log); -} - - - -/** - * Display the vector recursively - * @param tab - * @param dims - * @param index - * @param depth - * @patram dimsz - * @param name - * @param def - */ -static void revm_vector_recdisplay(unsigned long *tab, unsigned int *dims, - unsigned int *index, unsigned int depth, - unsigned int dimsz, char *name, u_long def) -{ - unsigned int idx; - unsigned int idx2; - char *log; - int len; - int sz; - - /* Check if we reached the last dimension */ - if (depth == dimsz) - for (idx = 0; idx < dims[depth - 1]; idx++) - { - sz = strlen(name) + 10 * depth; - log = alloca(sz); - len = snprintf(log, sz, " %s", name); - index[depth - 1] = idx; - for (idx2 = 0; idx2 < depth; idx2++) - len += snprintf(log + len, sz - len, "[%02u]", index[idx2]); - revm_output(log); - revm_vector_entry_display((eresi_Addr) tab[idx], (eresi_Addr) def); - } - - /* Otherwise recurse more */ - else - for (idx = 0; idx < dims[depth - 1]; idx++) - { - index[depth - 1] = idx; - revm_vector_recdisplay((unsigned long *) tab[idx], dims, index, - depth + 1, dimsz, name, def); - } - return; -} - - -/** - * Display vector - * @param cur - * @param name - * - */ -static void revm_vector_print(vector_t *cur, char *name) -{ - unsigned int *idx; - char logbuf[BUFSIZ]; - - idx = alloca(cur->arraysz * sizeof(unsigned int)); - bzero(idx, cur->arraysz * sizeof(unsigned int)); - snprintf(logbuf, sizeof(logbuf), " .:: Printing vector %s \n\n", name); - revm_output(logbuf); - revm_vector_recdisplay(cur->hook, cur->arraydims, idx, - 1, cur->arraysz, name, - (unsigned long) cur->default_func); - snprintf(logbuf, sizeof(logbuf), "\n .:: Vector %s printed \n\n", name); - revm_output(logbuf); -} - - - -/** - * Display the content of a vector - */ -static void revm_vectors_display() -{ - char **keys; - int keynbr; - int index; - int index2; - vector_t *cur; - char buf[BUFSIZ]; - int len; - - revm_output(" .:: Registered vectors \n\n"); - keys = hash_get_keys(vector_hash, &keynbr); - for (len = index = 0; index < keynbr; index++) - { - cur = hash_get(vector_hash, keys[index]); - len = snprintf(buf, sizeof(buf), " + %-20s\t ElemType: %-15s Dimensions: ", - keys[index], revm_ascii_vtype(cur)); - for (index2 = 0; index2 < cur->arraysz; index2++) - len += snprintf(buf + len, sizeof(buf) - len, - "[%02u]", cur->arraydims[index2]); - len += snprintf(buf + len, sizeof(buf) - len, " Discriminated by: "); - for (index2 = 0; index2 < cur->arraysz; index2++) - len += snprintf(buf + len, sizeof(buf) - len, "%s ", cur->strdims[index2]); - snprintf(buf + len, sizeof(buf) - len, "\n"); - revm_output(buf); - } - revm_output("\n Type vector vectname for specific vector details.\n\n"); -} - - - -/** - * Display vector content - */ -static int revm_vector_display() -{ - vector_t *cur; - int dimnbr; - unsigned int *dims; - eresi_Addr value; - char logbuf[BUFSIZ]; - int len; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (strchr(world.curjob->curcmd->param[0], ':')) - { - dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); - if (dimnbr < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get vector indexes values", -1); - dims = alloca(dimnbr * sizeof(unsigned int)); - revm_vectors_getdims(world.curjob->curcmd->param[0], dims); - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", -1); - if (revm_vector_bad_dims(cur, dims, dimnbr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", -1); - value = (eresi_Addr) aspect_vectors_select(cur, dims); - len = snprintf(logbuf, sizeof(logbuf), "\n [*] Vector[%s]", - world.curjob->curcmd->param[0]); - for (index = 0; index < dimnbr; index++) - len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); - revm_output(logbuf); - revm_vector_entry_display((eresi_Addr) value, (eresi_Addr) cur->default_func); - revm_output("\n"); - } - else - { - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Vector does not exist", -1); - revm_vector_print(cur, world.curjob->curcmd->param[0]); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Simple internal cat builtin - */ -int cmd_vectors() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print vectors list */ - case 0: - revm_vectors_display(); - break; - - /* Print a determined vector with determined (or not) indexes */ - case 1: - if (revm_vector_display() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot print invalid vector element(s)", -1); - break; - - /* Write vector entry */ - case 2: - if (revm_vector_modify() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot modify vector element", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid vectors syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/.svn/text-base/vlist.c.svn-base eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/vlist.c.svn-base --- eresi-0.8a25/libstderesi/cmd/.svn/text-base/vlist.c.svn-base 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/.svn/text-base/vlist.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/** - * @defgroup libstderesi Lib Standard for eresi. - */ -/** - * @file vlist.c - * @ingroup libstderesi - * @brief List all variables currently existing. - * - * Updated Feb 07 2005 22:34:01 jfv - * - * $Id: vlist.c,v 1.1 2007-11-29 14:01:56 may Exp $ - */ -#include "libstderesi.h" - -/** - * List content of all ERESI variables and expressions - */ -int cmd_vlist() -{ - char logbuf[BUFSIZ]; - char **keys; - int keynbr; - int index; - regex_t *tmp; - int printed; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - FIRSTREGX(tmp); - snprintf(logbuf, BUFSIZ, " [*] ERESI root expressions : \n\n"); - revm_output(logbuf); - keys = hash_get_keys(&exprs_hash, &keynbr); - for (printed = index = 0; index < keynbr; index++) - if (!tmp || !regexec(tmp, keys[index], 0, 0, 0)) - { - /* Only print root expressions */ - if (strstr(keys[index], REVM_SEP)) - continue; - printed++; - revm_expr_print(keys[index]); - if (index + 1 < keynbr) - revm_output("\n\n"); - else - revm_output("\n"); - } - hash_free_keys(keys); - if (!keynbr) - revm_output(" [*] No variable found \n\n"); - else - { - snprintf(logbuf, sizeof(logbuf), " [*] Printed %d expressions \n\n", printed); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/switch.c eresi-0.0.20110516/libstderesi/cmd/switch.c --- eresi-0.8a25/libstderesi/cmd/switch.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/switch.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/** -** @file switch.c -** @ingroup libstderesi -** Started on Sat Jan 25 11:20:49 2003 jfv -** -** $Id: switch.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Change the current object - */ -int cmd_doswitch() -{ - char logbuf[BUFSIZ]; - int ret; - int nbr; - elfshobj_t *cur; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->param[0] == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", (-1)); - nbr = atoi(world.curjob->curcmd->param[0]); - - ret = revm_doswitch(nbr); - - if (ret < 0) - { - snprintf(logbuf, BUFSIZ - 1, - "\n [!] Cant switch on file object %s (use 'list') (switching to a dependence need the id) \n\n", - world.curjob->curcmd->param[0]); - revm_output(logbuf); - } - else - { - cur = world.curjob->curfile; - -#if defined(USE_MJOLLNIR) - mjr_set_current_context(&world.mjr_session, cur->name); -#endif - - snprintf(logbuf, BUFSIZ - 1, "\n [*] Switched on object %u (%s) \n\n", - cur->id, cur->name); - revm_output(logbuf); - if (elfsh_is_debug_mode() && !cur->linkmap) - revm_output("\n [!!] Loaded file is not the linkmap, " - "switching to STATIC mode\n\n"); - - } - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} diff -Nru eresi-0.8a25/libstderesi/cmd/trace.c eresi-0.0.20110516/libstderesi/cmd/trace.c --- eresi-0.8a25/libstderesi/cmd/trace.c 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/trace.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1421 +0,0 @@ -/** -* @file trace.c -* @ingroup libstderesi -* @brief All functions that help to trace content -* -* Started Jul 2 2005 00:03:44 mxatone -* -* -* $Id: trace.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -* -*/ -#include "libstderesi.h" -#include "libetrace.h" - -char buf[BUFSIZ]; - -/* XXX: The good syntax should be : -** -** traces funcname [optional_traces_name] : add a function to a given trace -** traces funcname [optional_traces_name] : remove a function from a given trace -** traces funcname|all [optional_traces_name] : enable tracing for a function in a given trace (enabled by default after a add) -** traces funcname|all [optional_traces_name] : disable tracing for a function in a given trace -** traces tracename : create a new trace with a pool of traced functions by default -** traces tracename : delete a trace -** traces tracename : remove all functions from a given trace -** traces [optional_traces_name] : list all available traces -** -*/ - -char **last_arguments = NULL; - -#define TRACE_ADDR_TABLE "addrtable" - -#define TRACE_PRE_FUNC "func_" -#define TRACE_GET_FUNC_NAME(_buffer, _size, _addr) \ -snprintf(_buffer, _size, TRACE_PRE_FUNC "%s", _addr+2) - -#define TRACE_MATCH_ALL(_funcname) \ -!strcmp(_funcname, ".*") - -/** - * Add arguments for a futur traces_run - * @param argc arguments number - * @param argv arguments - * @see traces_run - */ -int revm_traces_add_arguments(int argc, char **argv) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (argc < 1 || argv == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Copy arguments */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, last_arguments, sizeof(char *)*(argc+1), -1); - memcpy(last_arguments, argv, sizeof(char*)*argc); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -const int match_alloc_step = 10; - -/** - * Match a function in a symbol table - * @param sect section pointer - * @param num element number - * @param preg reg structure - * @param func_list function table - * @param count counter pointer (from the table) - * @param get_symname function ptr to get symbol name - * @return 0 on success. - */ -static int revm_traces_match_in_symtable(elfshsect_t *sect, - int num, - regex_t *preg, - char ***func_list, - u_int *count, - char *(*get_symname)(elfshobj_t *f, - elfsh_Sym *s)) -{ - u_int index; - elfsh_Sym *table; - char *name; - char **f_list; - u_int cnum; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Check argument before anything */ - if (!sect || !preg || !func_list || !count || !get_symname) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - f_list = *func_list; - cnum = *count; - table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_get_raw(sect) : sect->data); - - /* Parse every function */ - for (index = 0; index < num; index++) - { - /* Only functions */ - if (elfsh_get_symbol_type(table + index) != STT_FUNC - || table[index].st_value == 0) - continue; - - name = get_symname(world.curjob->curfile, table + index); - - /* Check if this name is valid */ - if (name == NULL || *name == 0) - continue; - - /* We match a function */ - if (regexec(preg, name, 0, 0, 0) == 0) - { - /* Do we need to realloc ? */ - if (((cnum+1) % match_alloc_step) == 0) - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, - sizeof(char*) * (cnum + 1 + match_alloc_step), -1); - - /* Blank new elements */ - memset(&f_list[cnum], 0x00, match_alloc_step*sizeof(char*)); - - /* Update the pointer, data can move during a reallocation */ - *func_list = f_list; - } - - /* Add the function in the table */ - f_list[cnum] = name; - - *count = ++cnum; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Match functions from an addrtable - * @param func_list function list pointer - * @param count position on the list - */ -static int revm_traces_match_in_addrtable(char ***func_list, u_int *count) -{ - eresi_Addr *alist = NULL; - u_int index; - char **f_list; - u_int cnum; - char tmpstr[256]; - elfsh_Sym *sym; - char *toadd; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!func_list || !count) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - f_list = *func_list; - cnum = *count; - - /* Retrieve all called address in this binary */ - if (elfsh_addr_get_func_list(world.curjob->curfile, &alist) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't get call function list", -1); - - for (index = 0; alist[index]; index++) - { - sym = elfsh_get_symbol_by_value(world.curjob->curfile, alist[index], - 0, ELFSH_EXACTSYM); - - /* Find a symbol for this address */ - if (sym) - { - toadd = elfsh_get_symbol_name(world.curjob->curfile, sym); - } - else - { - snprintf(tmpstr, 255, TRACE_PRE_FUNC "" AFMT, - alist[index]); - toadd = tmpstr; - } - - /* Do we need to realloc ? */ - if (((cnum+1) % match_alloc_step) == 0) - { - XREALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, f_list, - sizeof(char*) * (cnum + 1 + match_alloc_step), -1); - - /* Blank new elements */ - memset(&f_list[cnum], 0x00, match_alloc_step*sizeof(char*)); - - /* Update the pointer, data can move during a reallocation */ - *func_list = f_list; - } - - /* If its temp string, strdup it */ - if (toadd == tmpstr) - toadd = strdup(tmpstr); - - f_list[cnum] = toadd; - - *count = ++cnum; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Match a list of function from symbol tables - * @param funcreg Function regex (or not ?) - * @param func_list the final function list - */ -static int revm_traces_match_funcname(char *funcname, char ***func_list) -{ - regex_t preg; - char **f_list; - u_int count = 0; - elfshsect_t *sect; - int num; - elfsh_Sym *symtab; - elfsh_Sym *sym; - char funcreg[256]; - char addrname[256]; - size_t len; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!funcreg || !func_list) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - len = strlen(funcname); - - /* We don't want to strip some part of the submited function - but if you find a function/regex of this size (for this purpose) ... */ - if (len > 255) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function name is too long", -1); - - /* An address ? */ - if (IS_VADDR(funcname)) - { - /* Retrieve the address */ - sscanf(funcname + 2, AFMT, &addr); - - /* Prealloc the list */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); - - sym = elfsh_get_symbol_by_value(world.curjob->curfile, addr, 0, ELFSH_EXACTSYM); - - /* We have a symbol for this address */ - if (sym) - { - f_list[0] = elfsh_get_symbol_name(world.curjob->curfile, sym); - f_list[1] = NULL; - } - else - { - sym = elfsh_get_dynsymbol_by_value(world.curjob->curfile, addr, 0, ELFSH_EXACTSYM); - - /* We have a dynamic symbol for this address */ - if (sym) - { - f_list[0] = elfsh_get_dynsymbol_name(world.curjob->curfile, sym); - f_list[1] = NULL; - } - else - { - TRACE_GET_FUNC_NAME(addrname, 255, funcname); - - f_list[0] = strdup(addrname); - f_list[1] = NULL; - } - } - - goto end; - } - - /* Add ^ and $ if needed, else we will check too many things - For example, someone wanna add "main" function, if we don't - add those symbols, it will match __libc_start_main which is very - special function and that can create problems and make the tracer - useless */ - snprintf(funcreg, 255, "%s%s%s", - funcname[0] != '^' ? "^" : "", - funcname, - funcname[len-1] != '$' ? "$" : ""); - - /* Do we have a regex ? */ - if (regcomp(&preg, funcreg, 0) != 0) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, sizeof(char*)*2, -1); - f_list[0] = funcname; - f_list[1] = NULL; - - goto end; - } - - /* Preallocation */ - XALLOC(__FILE__, __FUNCTION__, __LINE__, f_list, - sizeof(char*) * match_alloc_step, -1); - - - /* Total match case */ - if (TRACE_MATCH_ALL(funcname)) - { - /* Match everything we can, symbol or not ! */ - revm_traces_match_in_addrtable(&f_list, &count); - } - - /** - * Match on symbol table - */ - symtab = elfsh_get_symtab(world.curjob->curfile, &num); - - if (symtab != NULL) - { - sect = elfsh_get_section_by_type(world.curjob->curfile, - SHT_SYMTAB, 0, NULL, NULL, 0); - - /* Match function regex in the symbol table */ - revm_traces_match_in_symtable(sect, num, &preg, &f_list, &count, elfsh_get_symbol_name); - } - - /** - * Match on dynamic symbol table - */ - symtab = elfsh_get_dynsymtab(world.curjob->curfile, &num); - - if (symtab != NULL) - { - - sect = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_ALTDYNSYM, - NULL, NULL, &num); - if (!sect) - sect = elfsh_get_section_by_type(world.curjob->curfile, SHT_DYNSYM, 0, - NULL, NULL, &num); - - num /= sizeof(elfsh_Sym); - - /* Match function regex in the dynamic symbol table */ - revm_traces_match_in_symtable(sect, num, &preg, &f_list, &count, elfsh_get_dynsymbol_name); - } - - /* Do we get something ? */ - if (count == 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, f_list); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't match a single function", -1); - } - - end: - - /* Set final pointer */ - *func_list = f_list; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Research the uniform debugging format function entry on a list of files - * @param files first element of a edfmtfile_t structure - * @param name function name - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -static edfmtfunc_t *revm_traces_search_uni_file(edfmtfile_t *files, char *name) -{ - edfmtfunc_t *func; - edfmtfile_t *file; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (file = files ; file != NULL; file = file->next) - { - func = hash_get(&(file->hfunc), name); - - if (func != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); - - if (file->child) - { - func = revm_traces_search_uni_file(file->child, name); - if (func != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Research the uniform debugging format function entry - * @param file first element of a edfmtfile_t structure - * @param name function name - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -static edfmtfunc_t *revm_traces_search_uni(elfshobj_t *file, char *name) -{ - edfmtfunc_t *func; - edfmtinfo_t *uni; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - uni = edfmt_get_uniinfo(file); - - if (!uni) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No debugging informations available", NULL); - - /* Search on global scope */ - func = hash_get(&(uni->hfunc), name); - if (func == NULL) - { - /* Search on local stop if needed */ - func = revm_traces_search_uni_file(uni->files, name); - if (func == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Function not found", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); -} - -/** - * Search the function entry on the uniform debugging format, and return it - * @param file first element of a edfmtfile_t structure - * @param func_name function name - * @param external indicate if we need internal or external research - * @return pointer on a edfmtfunc_t (represent function debugging information) - */ -edfmtfunc_t *revm_traces_tracable_with_type(elfshobj_t *file, char *func_name, - u_char external) -{ - elfshobj_t *sym_file; - edfmtfunc_t *func = NULL; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We have an extern symbol */ - if (external) - { - sym_file = etrace_search_sym(file, func_name); - - if (sym_file) - func = revm_traces_search_uni(sym_file, func_name); - } - else - { - /* Search in this file */ - func = revm_traces_search_uni(file, func_name); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, func); -} - -/** - * Construct the argument structure depending of the option we have - * @param file target file - * @param ent pointer to set - * @param func uniform debugging inforation if we got one - * @param vaddr virtual address of the function if we don't have debugging information - * @param external describe scope - * @see revm_traces_createargs - */ -static int revm_traces_build_args(elfshobj_t *file, elfshtraces_t *ent, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external) -{ - u_int index; - int *argcount; - edfmtfuncarg_t *arg; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!ent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - elfsh_setup_hooks(); - - ent->scope = external ? ELFSH_ARG_EXTERN : ELFSH_ARG_INTERN; - - /* Do we have uniform debugging information for this structure ? */ - if (func == NULL) - { - argcount = elfsh_args_count(file, 0, vaddr); - - ent->type = ELFSH_ARG_SIZE_BASED; - ent->argc = 0; - - /* If we found some argument, else its 0 */ - if (argcount) - { - /* Fill arguments */ - for (index = 0; argcount[index] > 0; index++) - ent->arguments[index].size = argcount[index]; - - ent->argc = index; - XFREE(__FILE__, __FUNCTION__, __LINE__, argcount); - } - } - else - { - ent->type = ELFSH_ARG_TYPE_BASED; - for (arg = func->arguments, index = 0; arg != NULL; arg = arg->next, index++) - { - /* We setup argument name and typename */ - ent->arguments[index].name = arg->name; - ent->arguments[index].typename = arg->type ? arg->type->name : NULL; - - /* Other information are quite the same as arg counting method */ - ent->arguments[index].size = 0; - if (arg->type->size > 0) - ent->arguments[index].size = arg->type->size; - - if (ent->arguments[index].size < sizeof(eresi_Addr)) - ent->arguments[index].size = sizeof(eresi_Addr); - } - - ent->argc = func->argc; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Allocate the traces structure and call previous - * @param file target file - * @param func uniform debugging inforation if we got one - * @param vaddr virtual address of the function if we don't have debugging information - * @param external describe scope - * @return generate trace structure - * @see revm_traces_build_args - */ -elfshtraces_t *revm_traces_createargs(elfshobj_t *file, char *name, - edfmtfunc_t *func, eresi_Addr vaddr, - u_char external) -{ - elfshtraces_t *newtrace; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - // Alloc the structure - XALLOC(__FILE__, __FUNCTION__, __LINE__, newtrace, sizeof(elfshtraces_t), NULL); - snprintf(newtrace->funcname, ELFSH_TRACES_FUNC_SIZE - 1, "%s", name); - newtrace->file = file; - newtrace->enable = 1; - newtrace->vaddr = vaddr; - -#if __DEBUG_ARG_COUNT__ - printf("[DEBUG_ARG_COUNT] Builds args for %s\n", name); -#endif - - // We fill arguments part and check if we found the function - if (revm_traces_build_args(file, newtrace, func, vaddr, external) < 0) - { - XFREE(__FILE__, __FUNCTION__, __LINE__, newtrace); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Symbol not found or impossible to trace", NULL); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, newtrace); -} - -/** - * Add a function on a trace (from commande line) - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_add(elfshobj_t *file, char *name, char **optarg) -{ - elfshtraces_t *traces; - edfmtfunc_t *func = NULL; - eresi_Addr vaddr = 0; - u_char external = 0; - char **func_list; - u_int index, traced = 0; - char *trace_name; - int ret; - char *current_name; - eresi_Addr addr = 0; - u_char cont = 0; - u_char multiaddr = 0; - size_t prelen; - elfshsect_t *newsymsect; - elfsh_Sym *symbol; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Try to match functions with a regex */ - if (revm_traces_match_funcname(name, &func_list) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't match a single function", -1); - - /* Address case - if the function name (always the first) will have the address in its name - else we found a symbol which correspond to the address */ - if (IS_VADDR(name) && strstr(func_list[0], name + 2) != NULL) - sscanf(name + 2, AFMT, &addr); - - trace_name = optarg ? *optarg : NULL; - - /* When we try to match everything */ - multiaddr = TRACE_MATCH_ALL(name); - - if (multiaddr) - { - prelen = strlen(TRACE_PRE_FUNC); - - snprintf(buf, BUFSIZ - 1, - "\n\t[*] Start hooking all internal/external functions ...\n\n"); - revm_output(buf); - } - - /* Try to add every function */ - for (index = 0; func_list[index] != NULL; index++) - { - external = 0; - vaddr = 0; - cont = 0; - current_name = func_list[index]; - - /* FIXME: A function name containing "." will not be compiled right with gcc */ - if (strstr(current_name, ".") || !PRINTABLE(current_name[0])) - continue; - - /* Can we trace this function */ - if (addr > 0) - ret = etrace_valid_faddr(file, addr, &vaddr, &external); - else - { - /* Multiple address tracing */ - if (multiaddr && !strncmp(TRACE_PRE_FUNC, current_name, prelen)) - { - /* Prepare for a new address function */ - sscanf(current_name + prelen, AFMT, &vaddr); - ret = 0; - } - else - ret = etrace_tracable(file, current_name, &vaddr, &external); - } - - if (ret < 0) - { - buf[0] = 0x00; - switch(ret) - { - case -2: /* Untracable function */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s is an untracable function. Some dedicated OS functions are " - "context depend and can't be traced.\n\n", - current_name); - cont = 1; - break; - - case -3: /* Not called address */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s (%s) address will be trace but we won't be able to find at least " - "one call for this function.\n\n", - current_name, name); - break; - - case -4: /* Not called address */ - snprintf(buf, BUFSIZ - 1, - "\t[!] %s (%s) address can't be found on entrypoint section.\n\n", - current_name, name); - cont = 1; - break; - } - - if (buf[0] != 0x00) - revm_output(buf); - - if (cont) - continue; - } - - /* Can we trace with libedfmt informations ? */ - if (addr > 0 || vaddr > 0) - { - func = NULL; - - /* Do we need to add the symbol right before hijacking ? */ - symbol = elfsh_get_symbol_by_name(file, current_name); - - if (!symbol) - { - newsymsect = elfsh_get_parent_section(file, addr > 0 ? addr : vaddr, NULL); - - if (!newsymsect) - continue; - - /* Add a new function symbol */ - if (elfsh_insert_funcsym(file, current_name, - addr > 0 ? addr : vaddr, - 0, newsymsect->index) < 0) - continue; - } - else if (!symbol->st_value) /* Invalid symbol */ - continue; - } - - if (!addr) - func = revm_traces_tracable_with_type(file, current_name, external); - - /* Create the structure */ - traces = revm_traces_createargs(file, current_name, func, vaddr, external); - - if (!traces) - continue; - - /* Add the function */ - if (etrace_funcadd(trace_name, current_name, traces) == NULL) - continue; - - /* To avoid flood we don't display every added function for multiaddr */ - if (!multiaddr) - { - snprintf(buf, BUFSIZ - 1, "\t[*] Added function %s successfully into trace %s\n\n", - current_name, trace_name ? trace_name : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - } - - traced++; - } - - /* Free allocated table */ - if (index > 0) - XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); - - /* Do we add at least something ? */ - if (traced == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't add any founded functions", -1); - - /* We print the sum only */ - if (multiaddr) - { - snprintf(buf, BUFSIZ - 1, "\t[*] Added %d functions successfully into trace %s\n\n", - traced, trace_name ? trace_name : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - } - - /* Free function list */ - XFREE(__FILE__, __FUNCTION__, __LINE__, func_list); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_rm(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_funcrm(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Delete function failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Deleted function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Exclude functions by regexec during the last stage - * @param file target - * @param freg first reg - * @param oreg others reg list - */ -int traces_exclude(elfshobj_t *file, char *freg, char **oreg) -{ - u_int index; - const char pattern[] = "\n\t[*] Exclude function %s successfully\n\n"; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!freg || !freg[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - /* Exclude first argument */ - if (etrace_funcexclude(freg) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - snprintf(buf, BUFSIZ - 1, pattern, freg); - revm_output(buf); - - if (oreg) - { - for (index = 0; oreg[index] != NULL; index++) - { - if (etrace_funcexclude(oreg[index]) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - - snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); - revm_output(buf); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete excluded functions by regexec during the last stage - * @param file target - * @param freg first reg - * @param oreg others reg list - */ -int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg) -{ - u_int index; - const char pattern[] = "\n\t[*] Delete excluded function %s successfully\n\n"; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!freg || !freg[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - etrace_funcrmexclude(freg); - - snprintf(buf, BUFSIZ - 1, pattern, freg); - revm_output(buf); - - if (oreg) - { - for (index = 0; oreg[index] != NULL; index++) - { - etrace_funcrmexclude(oreg[index]); - - snprintf(buf, BUFSIZ - 1, pattern, oreg[index]); - revm_output(buf); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Enable a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_enable(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!strcmp(name, "all")) - { - if (etrace_funcenableall(optarg ? *optarg : NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Enable all functions failed", -1); - } - else - { - if (etrace_funcenable(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Enable function failed", -1); - } - - snprintf(buf, BUFSIZ - 1, "\t[*] Enabled function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Disable a function from a trace - * @param file target - * @param name function name - * @param optarg trace name (optional) - */ -int traces_disable(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!strcmp(name, "all")) - { - if (etrace_funcdisableall(optarg ? *optarg : NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Disable all functions failed", -1); - } - else - { - if (etrace_funcdisable(optarg ? *optarg : NULL, name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Disable function failed", -1); - } - - snprintf(buf, BUFSIZ - 1, "\t[*] Disabled function %s successfully from trace %s\n\n", - name, optarg && *optarg ? *optarg : ELFSH_TRACES_TYPE_DEFAULT); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create a trace - * @param file target - * @param name trace name - * @param optarg list of function to directly add - */ -int traces_create(elfshobj_t *file, char *name, char **optarg) -{ - char *strarr[2]; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_createtrace(name) == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Create trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Created trace %s successfully\n\n", name); - revm_output(buf); - - if (optarg && *optarg) - { - /* Add gived elements */ - for (index = 0; optarg[index]; index++) - { - strarr[0] = name; - strarr[1] = NULL; - if (traces_add(file, optarg[index], strarr) < 0) - continue; - } - - revm_output("\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Delete a trace - * @param file target - * @param name trace name - * @param optarg not use - */ -int traces_delete(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_deletetrace(name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Delete trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Deleted trace %s successfully\n\n", name); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Flush a whole trace - * @param name trace name - * @param optarg not use - */ -int traces_flush(elfshobj_t *file, char *name, char **optarg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!name || !name[0]) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (etrace_funcrmall(name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Flush trace failed", -1); - - snprintf(buf, BUFSIZ - 1, "\t[*] Flushed trace %s successfully\n\n", name); - revm_output(buf); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Detail listing of a trace - * @param table trace hash table - * @param name trace name - * @see traces_list - */ -static int traces_list_detail(hash_t *table, char *name) -{ - char **keys; - u_int index; - int keynbr; - elfshtraces_t *entrie; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buf, BUFSIZ - 1, " ~> %s: %s\n", - revm_colorfieldstr("Trace name"), - revm_colorstr(name)); - revm_output(buf); - - keys = hash_get_keys(table, &keynbr); - - if (keys && keynbr > 0) - { - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - entrie = (elfshtraces_t *) hash_get(table, keys[index]); - - if (entrie) - { - snprintf(buf, BUFSIZ - 1, " %s: %s %s: %s\n", - revm_colorfieldstr("Function name"), - revm_colorstr_fmt("%-15s", entrie->funcname), - revm_colorfieldstr("status"), - revm_colortypestr(entrie->enable ? "enabled" : "disabled")); - revm_output(buf); - revm_endline(); - } - } - - revm_output("\n"); - - hash_free_keys(keys); - } - else - { - revm_output("\n No function in this trace\n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Enumerate each trace and detail every functions - * @param name not use - * @param optarg not use - * @see traces_list_detail - */ -int traces_list(elfshobj_t *file, char *name, char **optarg) -{ - char **keys = NULL; - u_int index; - int keynbr; - hash_t *subtable; - char funcreg[256]; - size_t len; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output(" .: Trace list :.\n"); - - if (traces_table.ent) - keys = hash_get_keys(&traces_table, &keynbr); - - if (keys) - { - if (keynbr > 0) - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - subtable = hash_get(&traces_table, keys[index]); - - if (subtable) - traces_list_detail(subtable, keys[index]); - } - - hash_free_keys(keys); - } - else - { - revm_output("\n No tracing table available\n\n"); - } - - revm_output(" .: Exclude list :.\n"); - - /* Reset */ - keynbr = 0; - keys = NULL; - - /* Print exclude list */ - if (exclude_table.ent) - keys = hash_get_keys(&exclude_table, &keynbr); - - if (keys) - { - if (exclude_table.ent) - revm_output("\n"); - - for (index = 0; index < keynbr; index++) - { - len = strlen(keys[index]); - snprintf(funcreg, 255, "%s%s%s", - keys[index][0] != '^' ? "^" : "", - keys[index], - keys[index][len-1] != '$' ? "$" : ""); - - snprintf(buf, BUFSIZ - 1, " %s %s %s %s %s\n", - revm_colornumber("[%02u]", index+1), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-15s", keys[index]), - revm_colorfieldstr("regex:"), - revm_colorstr(funcreg)); - revm_output(buf); - revm_endline(); - } - - hash_free_keys(keys); - } - else - { - revm_output("\n No exclude table available\n"); - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Run a trace session (used in etrace) - * @param file target - * @param argv argument list - * @param argc argument counter - */ -int traces_run(elfshobj_t *file, char **argv, int argc) -{ - char *home; - char *filename; - size_t len; - u_int index; - char *path; - char *av[argc+2]; - int ret; - struct timeval now, after; - double difftime; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* We use etrace */ - if (world.state.revm_mode == REVM_STATE_TRACER) - { - argc = 0; - if (last_arguments) - { - while (last_arguments[argc] != NULL) - argc++; - argv = last_arguments; - } - else - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, argv, sizeof(char*), -1); - argv[0] = NULL; - } - } - - if (argc < 0 || !argv) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid parameters", -1); - - if (!(elfsh_get_objtype(elfsh_get_hdr(file)) == ET_EXEC)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "We need a ET_EXEC binary", -1); - - home = getenv("HOME"); - - if (!home) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find home directory", -1); - - snprintf(buf, BUFSIZ - 1, "%s/%s", home, REVM_TRACE_REP); - - /* Create temp directory if needed */ - mkdir(buf, 0700); - - /* We search the filename (we have a path) */ - len = strlen(file->name); - filename = file->name; - - for (index = len; index > 0; index--) - if (file->name[index] == '/') - break; - - if (INTERVAL(0, index+1, len)) - filename = file->name + index + 1; - - /* Full path */ - snprintf(buf, BUFSIZ - 1, "%s/%s/%s", home, REVM_TRACE_REP, filename); - path = strdup(buf); - - /* Pre register working objects for ELFsh */ - elfsh_register_working_objects(&world.curjob->loaded, - &world.shared_hash); - - if (elfsh_save_obj(file, path) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to save object", -1); - - av[0] = path; - for (index = 0; index < argc; index++) - av[index+1] = argv[index]; - av[index+1] = NULL; - - gettimeofday(&now, NULL); - - /* Print start */ - revm_output("Start execution of "); - for (index = 0; index < argc+1; index++) - { - snprintf(buf, BUFSIZ - 1, "%s ", av[index]); - revm_output(buf); - } - revm_output("\n"); - - /* Start with arguments */ - if (!fork()) - ret = execv(av[0], av); - else - wait(NULL); - - gettimeofday(&after, NULL); - - difftime = (after.tv_sec - now.tv_sec) + ((double) (after.tv_usec - now.tv_usec)) * 0.000001; - - snprintf(buf, BUFSIZ - 1, "End execution (%.6f sec)\n\n", difftime); - revm_output(buf); - - XFREE(__FILE__, __FUNCTION__, __LINE__, path); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Create the structure that store trace cmd informations - * @param exec function pointer - * @param flagName - * @param flagArg - */ -revmtraces_t *traces_create_CMDENT(int (*exec)(elfshobj_t *file, char *name, char **optarg), - char flagName, char flagArg) -{ - revmtraces_t *new; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__, new, sizeof(revmtraces_t), NULL); - new->exec = exec; - new->flagName = flagName; - new->flagArg = flagArg; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - -/** - * Add a command in sub commande hash table - * @param cmd cmd name - * @param exec function pointer - * @param flagName - * @param flagArg - * @see traces_cmd_hash - * @see traces_create_CMDENT - */ -int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - hash_add(&traces_cmd_hash, cmd, (void *) traces_create_CMDENT(exec, flagName, flagArg)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_traces() -{ - revmtraces_t *cmd; - char *fArg; - char **sArg; - int ret = 0; - hash_t *table; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init tracing elements */ - etrace_inittrace(); - - switch(world.curjob->curcmd->argc) - { - case 0: - traces_list(world.curjob->curfile, NULL, NULL); - break; - case 1: - table = etrace_gettrace(world.curjob->curcmd->param[0]); - - if (!table) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown trace", -1); - - traces_list_detail(table, world.curjob->curcmd->param[0]); - break; - default: - cmd = hash_get(&traces_cmd_hash, world.curjob->curcmd->param[0]); - - if (!cmd) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown command", -1); - - fArg = NULL; - sArg = NULL; - - if (cmd->flagName > 0) - { - /* First argument is needed and doesn't submited */ - if (!world.curjob->curcmd->param[1] && cmd->flagName == 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "First argument is needed", -1); - - fArg = world.curjob->curcmd->param[1]; - - if (cmd->flagArg > 0) - { - /* Second argument is needed and doesn't submited */ - if (!world.curjob->curcmd->param[2] && cmd->flagArg == 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Second argument is needed", -1); - - sArg = world.curjob->curcmd->param + 2; - } - } - - ret = cmd->exec(world.curjob->curfile, fArg, sArg); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - -int cmd_traceadd() -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Init tracing elements */ - etrace_inittrace(); - - if (world.curjob->curcmd->argc < 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need at least one function", -1); - - /* Loop on each passed functions */ - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - if (traces_add(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -int cmd_traceexclude() -{ - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc < 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Need at least one function", -1); - - /* Loop on each passed functions */ - for (index = 0; index < world.curjob->curcmd->argc; index++) - { - if (traces_exclude(world.curjob->curfile, world.curjob->curcmd->param[index], NULL) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, -1); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen brief tag - */ -int cmd_tracerun() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (traces_run(world.curjob->curfile, - world.curjob->curcmd->param, - world.curjob->curcmd->argc) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to run current trace", -1); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/types.c eresi-0.0.20110516/libstderesi/cmd/types.c --- eresi-0.8a25/libstderesi/cmd/types.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/types.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,121 +0,0 @@ -/** -* @file types.c -* @ingroup libstderesi -* Be able to add your own types in runtime -* -* Started on Sun Jan 9 07:23:58 2007 jfv -* $Id: types.c,v 1.2 2007-12-06 06:40:16 may Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * Types management command - */ -int cmd_type() -{ - int nocmd; - u_char isunion; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - isunion = !strcmp(world.curjob->curcmd->name, CMD_UNION); - nocmd = 0; - switch (world.curjob->curcmd->argc) - { - /* type */ - case 0: - revm_type_prints(); - break; - - /* type name */ - case 1: - revm_type_print_regex(world.curjob->curcmd->param[0]); - revm_output("\n"); - break; - - /* Those case are invalid syntaxes */ - case 2: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - default: - /* Add a type */ - if (!strcmp(world.curjob->curcmd->param[1], "=") || - !strcmp(world.curjob->curcmd->param[1], "is")) - { - - /* Dont forget to filter on command names too, as each type - will need to have its name bound on cmd_declare() */ - if (hash_get(&cmd_hash, world.curjob->curcmd->param[0])) - nocmd = 1; - if (aspect_type_register(isunion, world.curjob->curcmd->param[0], - world.curjob->curcmd->param + 2, - world.curjob->curcmd->argc - 2) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid type declaration", -1); - - if (!world.state.revm_quiet) - { - revm_output("\n\t [*] Added type "); - revm_output(world.curjob->curcmd->param[0]); - revm_output(" succesfully \n\n"); - } - - /* Create the hash table for objects of that type */ - revm_type_hashcreate(world.curjob->curcmd->param[0]); - } - else - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - } - - /* Register this alias as a command */ - if (!nocmd) - revm_command_add(world.curjob->curcmd->param[0], cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Typedef command function - */ -int cmd_typedef() -{ - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (world.curjob->curcmd->argc != 2) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid syntax for type command", -1); - - ret = revm_type_copy(world.curjob->curcmd->param[0], - world.curjob->curcmd->param[1]); - - if (ret < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - (ret == -1 ? "Type not found" : - "Failed to create a new type"), -1); - - /* Register this alias as a command */ - revm_command_add(world.curjob->curcmd->param[1], cmd_declare, - revm_getvarparams, 0, HLP_DECLARE); - - /* Output report */ - if (!world.state.revm_quiet) - { - revm_output("\n\t [*] Copied type "); - revm_output(world.curjob->curcmd->param[0]); - revm_output(" to "); - revm_output(world.curjob->curcmd->param[1]); - revm_output(" succesfully \n\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/unload.c eresi-0.0.20110516/libstderesi/cmd/unload.c --- eresi-0.8a25/libstderesi/cmd/unload.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/unload.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/** - * @file unload.c - * @ingroup libstderesi - * Started on Sat Jan 25 11:21:52 2003 jfv - * Last update Thu Mar 11 07:56:36 2004 jfv - * - * $Id: unload.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Unload a file from the shell - */ -int cmd_unload() -{ - hash_t *loaded; - elfshobj_t *cur; - time_t uloadt; - char logbuf[BUFSIZ]; - int ret; - u_int id; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get the file structure */ - id = atoi(world.curjob->curcmd->param[0]); - cur = revm_lookup_file(world.curjob->curcmd->param[0]); - if (cur == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Object not loaded", -1); - - /* Do not unload dependences of files or objects with linkmap entry */ - if (hash_size(&cur->parent_hash)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unload parent object first", -1); - if (cur->linkmap) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You cannot unload a mapped object", -1); - ret = revm_unload_dep(cur, cur); - if (!world.state.revm_quiet) - { - time(&uloadt); - snprintf(logbuf, BUFSIZ - 1, "%s [*] Object %-40s unloaded on %s \n", - (ret ? "" : "\n"), cur->name, ctime(&uloadt)); - revm_output(logbuf); - } - - /* Clean various hash tables of this binary entry and return OK */ - hash_del(&file_hash, cur->name); - if (hash_get(&world.shared_hash, cur->name)) - hash_del(&world.shared_hash, cur->name); - else - hash_del(&world.curjob->loaded, cur->name); - elfsh_unload_obj(cur); - revm_output("\n"); - - /* If the file is the current working one, swap to another one */ - if (cur == world.curjob->curfile) - { - loaded = (hash_size(&world.curjob->loaded) ? - &world.curjob->loaded : hash_size(&world.shared_hash) ? - &world.shared_hash : NULL); - if (!loaded) - world.curjob->curfile = NULL; - else - do cur = hash_get_one(loaded); - while (cur == world.curjob->curfile); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - diff -Nru eresi-0.8a25/libstderesi/cmd/utils.c eresi-0.0.20110516/libstderesi/cmd/utils.c --- eresi-0.8a25/libstderesi/cmd/utils.c 2008-04-06 23:16:27.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/utils.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,10 @@ /** - * @file utils.c - * @ingroup libstderesi +* @file libstderesi/cmd/utils.c + * @ingroup cmd * Started on Fri Nov 2 15:21:56 2001 jfv * Updated on Thu Jan 04 11:26:11 2007 jfv * - * $Id: utils.c,v 1.1 2007-11-29 14:01:56 may Exp $ + * $Id: utils.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/cmd/vectors.c eresi-0.0.20110516/libstderesi/cmd/vectors.c --- eresi-0.8a25/libstderesi/cmd/vectors.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/vectors.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,368 +0,0 @@ -/** - * @file vectors.c - * @ingroup libstderesi - * Started on Sat Jan 06 06:43:11 2007 jfv - * - * $Id: vectors.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * - */ -#include "libstderesi.h" - -/** - * Get numbers of vector dimensions requested for the display - * @param str - */ -int revm_vectors_getdimnbr(char *str) -{ - int nbr; - - for (nbr = 0; str && *str; nbr++) - { - str = strchr(str, ':'); - if (!str) - return (nbr); - else - str++; - } - return (nbr); -} - -/** - * Get numbers of vector dimensions requested for the display - * @param str - * @param dims - */ -int revm_vectors_getdims(char *str, unsigned int *dims) -{ - revmobj_t *v; - int nbr; - char *str2; - - /* FIXME : add elfsh vectors index macros to completion */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - for (nbr = 0; str && *str; nbr++) - { - str = strchr(str, ':'); - if (!str) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - *str = 0x00; - str2 = strchr(++str, ':'); - if (str2) - *str2 = 0x00; - v = revm_lookup_immed(str); - if (v->otype->type != ASPECT_TYPE_LONG && v->otype->type != ASPECT_TYPE_INT) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid vector indexes", -1); - dims[nbr] = (v->immed ? v->immed_val.ent : v->get_obj(v->parent)); - if (str2) - *str2 = ':'; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Check vectors dimensions - * @param vect - * @param dims - * @param dimnbr - * @return - */ -int revm_vector_bad_dims(vector_t *vect, unsigned int *dims, - unsigned int dimnbr) -{ - int idx; - - if (vect->arraysz != dimnbr) - return (1); - for (idx = 0; idx < dimnbr; idx++) - if (dims[idx] >= vect->arraydims[idx]) - return (1); - return (0); -} - - - -/** - * Modify a value inside a vector - * @return - */ -static int revm_vector_modify() -{ - vector_t *cur; - int dimnbr; - unsigned int *dims; - eresi_Addr value; - char logbuf[BUFSIZ]; - int len; - int index; - revmobj_t *obj; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Lookup value to write */ - obj = revm_lookup_immed(world.curjob->curcmd->param[1]); - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid update value for vector", -1); - value = (obj->immed ? obj->immed_val.ent : - (eresi_Addr) obj->get_obj(obj->parent)); - - /* Lookup vector indexes */ - if (strchr(world.curjob->curcmd->param[0], ':')) - { - dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); - if (dimnbr < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get vector indexes values", -1); - dims = alloca(dimnbr * sizeof(unsigned int)); - revm_vectors_getdims(world.curjob->curcmd->param[0], dims); - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", -1); - if (revm_vector_bad_dims(cur, dims, dimnbr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", -1); - aspect_vectors_insert(cur, dims, value); - len = snprintf(logbuf, sizeof(logbuf), "\n [*] Modified : Vector[%s]", - world.curjob->curcmd->param[0]); - for (index = 0; index < dimnbr; index++) - len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); - snprintf(logbuf + len, sizeof(logbuf) - len, " = " XFMT "\n", value); - revm_output(logbuf); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "You need to supply the vector indexes to be modified", -1); -} - - - -/** - * Print a vector entry with its resolve - * @param vaddr - * @param def - */ -static void revm_vector_entry_display(eresi_Addr vaddr, eresi_Addr def) -{ - Dl_info info; - char *bsep; - char *esep; - char *print; - char log[BUFSIZ]; - - if (!dladdr((void *) ((unsigned long *) vaddr), &info)) - dlerror(); - esep = bsep = ""; - if (info.dli_sname && vaddr != def) - { - esep = ">"; - bsep = "<"; - print = (char *) info.dli_sname; - } - else if (vaddr == def) - { - esep = ")"; - bsep = "("; - print = "default handler"; - } - else - print = "Unknown function"; - snprintf(log, sizeof(log), " = " XFMT " %s%s%s\n", vaddr, bsep, print, esep); - revm_output(log); -} - - - -/** - * Display the vector recursively - * @param tab - * @param dims - * @param index - * @param depth - * @patram dimsz - * @param name - * @param def - */ -static void revm_vector_recdisplay(unsigned long *tab, unsigned int *dims, - unsigned int *index, unsigned int depth, - unsigned int dimsz, char *name, u_long def) -{ - unsigned int idx; - unsigned int idx2; - char *log; - int len; - int sz; - - /* Check if we reached the last dimension */ - if (depth == dimsz) - for (idx = 0; idx < dims[depth - 1]; idx++) - { - sz = strlen(name) + 10 * depth; - log = alloca(sz); - len = snprintf(log, sz, " %s", name); - index[depth - 1] = idx; - for (idx2 = 0; idx2 < depth; idx2++) - len += snprintf(log + len, sz - len, "[%02u]", index[idx2]); - revm_output(log); - revm_vector_entry_display((eresi_Addr) tab[idx], (eresi_Addr) def); - } - - /* Otherwise recurse more */ - else - for (idx = 0; idx < dims[depth - 1]; idx++) - { - index[depth - 1] = idx; - revm_vector_recdisplay((unsigned long *) tab[idx], dims, index, - depth + 1, dimsz, name, def); - } - return; -} - - -/** - * Display vector - * @param cur - * @param name - * - */ -static void revm_vector_print(vector_t *cur, char *name) -{ - unsigned int *idx; - char logbuf[BUFSIZ]; - - idx = alloca(cur->arraysz * sizeof(unsigned int)); - bzero(idx, cur->arraysz * sizeof(unsigned int)); - snprintf(logbuf, sizeof(logbuf), " .:: Printing vector %s \n\n", name); - revm_output(logbuf); - revm_vector_recdisplay(cur->hook, cur->arraydims, idx, - 1, cur->arraysz, name, - (unsigned long) cur->default_func); - snprintf(logbuf, sizeof(logbuf), "\n .:: Vector %s printed \n\n", name); - revm_output(logbuf); -} - - - -/** - * Display the content of a vector - */ -static void revm_vectors_display() -{ - char **keys; - int keynbr; - int index; - int index2; - vector_t *cur; - char buf[BUFSIZ]; - int len; - - revm_output(" .:: Registered vectors \n\n"); - keys = hash_get_keys(vector_hash, &keynbr); - for (len = index = 0; index < keynbr; index++) - { - cur = hash_get(vector_hash, keys[index]); - len = snprintf(buf, sizeof(buf), " + %-20s\t ElemType: %-15s Dimensions: ", - keys[index], revm_ascii_vtype(cur)); - for (index2 = 0; index2 < cur->arraysz; index2++) - len += snprintf(buf + len, sizeof(buf) - len, - "[%02u]", cur->arraydims[index2]); - len += snprintf(buf + len, sizeof(buf) - len, " Discriminated by: "); - for (index2 = 0; index2 < cur->arraysz; index2++) - len += snprintf(buf + len, sizeof(buf) - len, "%s ", cur->strdims[index2]); - snprintf(buf + len, sizeof(buf) - len, "\n"); - revm_output(buf); - } - revm_output("\n Type vector vectname for specific vector details.\n\n"); -} - - - -/** - * Display vector content - */ -static int revm_vector_display() -{ - vector_t *cur; - int dimnbr; - unsigned int *dims; - eresi_Addr value; - char logbuf[BUFSIZ]; - int len; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (strchr(world.curjob->curcmd->param[0], ':')) - { - dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); - if (dimnbr < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get vector indexes values", -1); - dims = alloca(dimnbr * sizeof(unsigned int)); - revm_vectors_getdims(world.curjob->curcmd->param[0], dims); - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown requested vector", -1); - if (revm_vector_bad_dims(cur, dims, dimnbr)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Requested vector with bad dimensions", -1); - value = (eresi_Addr) aspect_vectors_select(cur, dims); - len = snprintf(logbuf, sizeof(logbuf), "\n [*] Vector[%s]", - world.curjob->curcmd->param[0]); - for (index = 0; index < dimnbr; index++) - len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); - revm_output(logbuf); - revm_vector_entry_display((eresi_Addr) value, (eresi_Addr) cur->default_func); - revm_output("\n"); - } - else - { - cur = aspect_vector_get(world.curjob->curcmd->param[0]); - if (!cur) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Vector does not exist", -1); - revm_vector_print(cur, world.curjob->curcmd->param[0]); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Simple internal cat builtin - */ -int cmd_vectors() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (world.curjob->curcmd->argc) - { - /* Just print vectors list */ - case 0: - revm_vectors_display(); - break; - - /* Print a determined vector with determined (or not) indexes */ - case 1: - if (revm_vector_display() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot print invalid vector element(s)", -1); - break; - - /* Write vector entry */ - case 2: - if (revm_vector_modify() < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot modify vector element", -1); - break; - - /* Unknown mode */ - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid vectors syntax", -1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/cmd/vlist.c eresi-0.0.20110516/libstderesi/cmd/vlist.c --- eresi-0.8a25/libstderesi/cmd/vlist.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/cmd/vlist.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -/** - * @defgroup libstderesi Lib Standard for eresi. - */ -/** - * @file vlist.c - * @ingroup libstderesi - * @brief List all variables currently existing. - * - * Updated Feb 07 2005 22:34:01 jfv - * - * $Id: vlist.c,v 1.1 2007-11-29 14:01:56 may Exp $ - */ -#include "libstderesi.h" - -/** - * List content of all ERESI variables and expressions - */ -int cmd_vlist() -{ - char logbuf[BUFSIZ]; - char **keys; - int keynbr; - int index; - regex_t *tmp; - int printed; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - FIRSTREGX(tmp); - snprintf(logbuf, BUFSIZ, " [*] ERESI root expressions : \n\n"); - revm_output(logbuf); - keys = hash_get_keys(&exprs_hash, &keynbr); - for (printed = index = 0; index < keynbr; index++) - if (!tmp || !regexec(tmp, keys[index], 0, 0, 0)) - { - /* Only print root expressions */ - if (strstr(keys[index], REVM_SEP)) - continue; - printed++; - revm_expr_print(keys[index]); - if (index + 1 < keynbr) - revm_output("\n\n"); - else - revm_output("\n"); - } - hash_free_keys(keys); - if (!keynbr) - revm_output(" [*] No variable found \n\n"); - else - { - snprintf(logbuf, sizeof(logbuf), " [*] Printed %d expressions \n\n", printed); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/doc/.svn/all-wcprops eresi-0.0.20110516/libstderesi/doc/.svn/all-wcprops --- eresi-0.8a25/libstderesi/doc/.svn/all-wcprops 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/896/trunk/libstderesi/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/896/trunk/libstderesi/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libstderesi/doc/.svn/entries eresi-0.0.20110516/libstderesi/doc/.svn/entries --- eresi-0.8a25/libstderesi/doc/.svn/entries 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libstderesi/doc -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:16:28.597887Z -6997de19a4cf98ebc39769e923a54b0b -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/libstderesi/doc/.svn/format eresi-0.0.20110516/libstderesi/doc/.svn/format --- eresi-0.8a25/libstderesi/doc/.svn/format 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libstderesi/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libstderesi/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libstderesi/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libstderesi - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen/ - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = cmd/ elf/ include/ - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libstderesi - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = YES - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = YES - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = NO - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/libstderesi/elf/api.c eresi-0.0.20110516/libstderesi/elf/api.c --- eresi-0.8a25/libstderesi/elf/api.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/api.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,11 +1,15 @@ /** - * @file api.c +* @file libstderesi/elf/api.c +** @ingroup elf +*/ +/** + * * * This file contain the ELF specific vm-level API * * Started on Sat Jan 25 07:48:41 2003 jfv * - * $Id: api.c,v 1.1 2007-11-29 14:01:56 may Exp $ + * $Id: api.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/comment.c eresi-0.0.20110516/libstderesi/elf/comment.c --- eresi-0.8a25/libstderesi/elf/comment.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/comment.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,12 +1,16 @@ /** - * @file comment.c +* @file libstderesi/elf/comment.c +** @ingroup elf +*/ +/** + * * * Made by * * Started on Tue Dec 17 06:43:01 2002 jfv * * - * $Id: comment.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: comment.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/core.c eresi-0.0.20110516/libstderesi/elf/core.c --- eresi-0.8a25/libstderesi/elf/core.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/core.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** +* @file libstderesi/elf/core.c +** @ingroup elf +*/ +/** * notes.c for elfsh - * @file notes.c + * * Started on Fri Jan 26 21:00:33 BRST 2007 * * - * $Id: core.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: core.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/ctors.c eresi-0.0.20110516/libstderesi/elf/ctors.c --- eresi-0.8a25/libstderesi/elf/ctors.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/ctors.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file ctors.c +* @file libstderesi/elf/ctors.c +** @ingroup elf +*/ +/** + * * * Started on Tue Feb 26 22:07:58 2002 jfv * * - * $Id: ctors.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: ctors.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -52,10 +56,10 @@ offset = doffset; } - if (off) + if (offset) snprintf(off, sizeof(off), " %s %s", revm_colorstr((offset < 0 ? "-" : "+")), - revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); + revm_colornumber("%u", (u_int) (offset > 0 ? offset : -offset))); snprintf(buff, sizeof(buff), " %s %s \t <%s%s>\n", revm_colornumber("[%02u]", index), diff -Nru eresi-0.8a25/libstderesi/elf/data.c eresi-0.0.20110516/libstderesi/elf/data.c --- eresi-0.8a25/libstderesi/elf/data.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/data.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file data.c +* @file libstderesi/elf/data.c +** @ingroup elf +*/ +/** + * * * Started on Mon Feb 26 04:06:38 2001 jfv * Last update Wed Mar 10 12:14:24 2004 jfv * - * $Id: data.c,v 1.1 2007-11-29 14:01:56 may Exp $ + * $Id: data.c 1413 2010-05-21 03:41:25Z figueredo $ * */ #include "libstderesi.h" @@ -12,30 +16,32 @@ revmconst_t asm_instr_type[] = { - {"Undefined instruction" , "ASM_TYPE_NONE" , ASM_TYPE_NONE}, - {"Branch-always instruction" , "ASM_TYPE_IMPBRANCH" , ASM_TYPE_IMPBRANCH}, - {"Conditionnal branching instruction" , "ASM_TYPE_CONDBRANCH", ASM_TYPE_CONDBRANCH}, - {"Procedure calling instruction" , "ASM_TYPE_CALLPROC" , ASM_TYPE_CALLPROC}, - {"Return instruction" , "ASM_TYPE_RETPROC" , ASM_TYPE_RETPROC}, - {"Arithmetic (or logic) instruction" , "ASM_TYPE_ARITH" , ASM_TYPE_ARITH}, - {"Instruction that reads from memory" , "ASM_TYPE_LOAD" , ASM_TYPE_LOAD}, - {"Instruction that writes in memory" , "ASM_TYPE_STORE" , ASM_TYPE_STORE}, - {"Architecture dependent instruction" , "ASM_TYPE_ARCH" , ASM_TYPE_ARCH}, - {"Flag-modifier instruction" , "ASM_TYPE_WRITEFLAG" , ASM_TYPE_WRITEFLAG}, - {"Flag-reader instruction" , "ASM_TYPE_READFLAG" , ASM_TYPE_READFLAG}, - {"Interrupt/call-gate instruction" , "ASM_TYPE_INT" , ASM_TYPE_INT}, - {"Assignment instruction" , "ASM_TYPE_ASSIGN" , ASM_TYPE_ASSIGN}, - {"Comparison or test instruction" , "ASM_TYPE_COMPARISON", ASM_TYPE_COMPARISON}, - {"Instruction modifies control registers", "ASM_TYPE_CONTROL" , ASM_TYPE_CONTROL}, - {"Instruction that does nothing" , "ASM_TYPE_NOP" , ASM_TYPE_NOP}, - {"Type that doesn't fit the ones above" , "ASM_TYPE_OTHER" , ASM_TYPE_OTHER}, - {"Instruction modifies stack pointer" , "ASM_TYPE_TOUCHSP" , ASM_TYPE_TOUCHSP}, - {"Bit Testing Instruction" , "ASM_TYPE_BITTEST" , ASM_TYPE_BITTEST}, - {"Bit Setting Instruction" , "ASM_TYPE_BITSET" , ASM_TYPE_BITSET}, - {"Instruction increment or decrement" , "ASM_TYPE_INCDEC" , ASM_TYPE_INCDEC}, - {"Instruction creates function prolog" , "ASM_TYPE_PROLOG" , ASM_TYPE_PROLOG}, - {"Instruction creates function epilog" , "ASM_TYPE_EPILOG" , ASM_TYPE_EPILOG}, - {"Instruction stops the program" , "ASM_TYPE_STOP" , ASM_TYPE_STOP}, + {"Undefined instruction" , "ASM_TYPE_NONE" , ASM_TYPE_NONE}, + {"Branch instruction" , "ASM_TYPE_BRANCH" , ASM_TYPE_BRANCH}, + {"Procedure calling instruction" , "ASM_TYPE_CALLPROC" , ASM_TYPE_CALLPROC}, + {"Return instruction" , "ASM_TYPE_RETPROC" , ASM_TYPE_RETPROC}, + {"Arithmetic (or logic) instruction" , "ASM_TYPE_ARITH" , ASM_TYPE_ARITH}, + {"Instruction that reads from memory" , "ASM_TYPE_LOAD" , ASM_TYPE_LOAD}, + {"Instruction that writes in memory" , "ASM_TYPE_STORE" , ASM_TYPE_STORE}, + {"Architecture dependent instruction" , "ASM_TYPE_ARCH" , ASM_TYPE_ARCH}, + {"Flag-modifier instruction" , "ASM_TYPE_WRITEFLAG" , ASM_TYPE_WRITEFLAG}, + {"Flag-reader instruction" , "ASM_TYPE_READFLAG" , ASM_TYPE_READFLAG}, + {"Interrupt/call-gate instruction" , "ASM_TYPE_INT" , ASM_TYPE_INT}, + {"Assignment instruction" , "ASM_TYPE_ASSIGN" , ASM_TYPE_ASSIGN}, + {"Comparison or test instruction" , "ASM_TYPE_COMPARISON", ASM_TYPE_COMPARISON}, + {"Instruction modifies control registers" , "ASM_TYPE_CONTROL" , ASM_TYPE_CONTROL}, + {"Instruction that does nothing" , "ASM_TYPE_NOP" , ASM_TYPE_NOP}, + {"Instruction modifies stack pointer" , "ASM_TYPE_TOUCHSP" , ASM_TYPE_TOUCHSP}, + {"Bit Testing Instruction" , "ASM_TYPE_BITTEST" , ASM_TYPE_BITTEST}, + {"Bit Setting Instruction" , "ASM_TYPE_BITSET" , ASM_TYPE_BITSET}, + {"Instruction increment or decrement" , "ASM_TYPE_INCDEC" , ASM_TYPE_INCDEC}, + {"Instruction creates function prolog" , "ASM_TYPE_PROLOG" , ASM_TYPE_PROLOG}, + {"Instruction creates function epilog" , "ASM_TYPE_EPILOG" , ASM_TYPE_EPILOG}, + {"Instruction stops the program" , "ASM_TYPE_STOP" , ASM_TYPE_STOP}, + {"Instruction accesses I/O locations (e.g. ports)." , "ASM_TYPE_IO" , ASM_TYPE_IO}, + {"Instruction executes conditionally" , "ASM_TYPE_CONDCONTROL", ASM_TYPE_CONDCONTROL}, + {"Instruction changes control indirectly." , "ASM_TYPE_INDCONTROL", ASM_TYPE_INDCONTROL}, + {"Type that doesn't fit the ones above" , "ASM_TYPE_OTHER" , ASM_TYPE_OTHER}, }; @@ -663,64 +669,105 @@ /** * Architecture strings */ -char *elfsh_arch_type[] = +revmconst_t elfsh_arch_type[] = { - "No machine" , - "AT&T WE 32100" , - "SUN SPARC" , - "Intel 80386" , - "Motorola m68k family" , - "Motorola m88k family" , - "Intel 80486" , - "Intel 80860" , - "MIPS R3000 big-endian", - "IBM system 370" , - "MIPS R3000 lil-endian", - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "HPPA" , - "nCUBE" , - "Fujitsu VPP500" , - "Sun's v8plus" , - "Intel 80960" , - "PowerPC" , - "PowerPC 64 bits" , - "IBM S390" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "NEC V800 series" , - "Fujitsu FR20" , - "TRW RH32" , - "Motorola RCE" , - "ARM" , - "Digital Alpha" , - "Hitachi SH" , - "SPARC v9 64-bit" , - "Siemens Tricore" , - "Argonaut RISC Core" , - "Hitachi H8/300" , - "Hitachi H8/300H" , - "Hitachi H8S" , - "Hitachi H8/500" , - "Intel Merced" , - "Stanford MIPS-X" , - "Motorola Coldfire" , - "Motorola M68HC12" , + {"No machine" , "EM_NONE", EM_NONE}, + {"AT&T WE 32100" , "EM_M32", EM_M32}, + {"SUN SPARC" , "EM_SPARC", EM_SPARC}, + {"Intel 80386" , "EM_386", EM_386}, + {"Motorola m68k family" , "EM_68K", EM_68K}, + {"Motorola m88k family" , "EM_88K", EM_88K}, + {"Intel 80486" , "EM_486", EM_486}, + {"Intel 80860" , "EM_860", EM_860}, + {"MIPS R3000 BE" , "EM_MIPS", EM_MIPS}, + {"IBM system 370" , "EM_S370", EM_S370}, + {"MIPS R3000 LE" , "EM_MIPS_R3000", EM_MIPS_RS3_LE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"HPPA" , "EM_PARISC", EM_PARISC}, + {"nCUBE" , "EM_NCUBE", EM_NCUBE}, + {"Fujitsu VPP500" , "EM_VPP500", EM_VPP500}, + {"Sun's v8plus" , "EM_SPARC32PLUS", EM_SPARC32PLUS}, + {"Intel 80960" , "EM_960", EM_960}, + {"PowerPC" , "EM_PPC", EM_PPC}, + {"PowerPC 64 bits" , "EM_PPC64", EM_PPC64}, + {"IBM S390" , "EM_S390", EM_S390}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"NEC V800 series" , "EM_V800", EM_V800}, + {"Fujitsu FR20" , "EM_FR20", EM_FR20}, + {"TRW RH32" , "EM_RH32", EM_RH32}, + {"Motorola RCE" , "EM_RCE", EM_RCE}, + {"ARM" , "EM_ARM", EM_ARM}, + {"Digital Alpha" , "EM_FAKE_ALPHA", EM_FAKE_ALPHA}, + {"Hitachi SH" , "EM_SH", EM_SH}, + {"SPARC v9 64-bit" , "EM_SPARCV9", EM_SPARCV9}, + {"Siemens Tricore" , "EM_TRICORE", EM_TRICORE}, + {"Argonaut RISC Core" , "EM_ARC", EM_ARC}, + {"Hitachi H8/300" , "EM_H8_300", EM_H8_300}, + {"Hitachi H8/300H" , "EM_H8_300H", EM_H8_300H}, + {"Hitachi H8S" , "EM_H8S", EM_H8S}, + {"Hitachi H8/500" , "EM_H8_500", EM_H8_500}, + {"Intel Merced" , "EM_IA_64", EM_IA_64}, + {"Stanford MIPS-X" , "EM_MIPS_X", EM_MIPS_X}, + {"Motorola Coldfire" , "EM_COLDFIRE", EM_COLDFIRE}, + {"Motorola M68HC12" , "EM_68HC12", EM_68HC12}, + {"Fujitsu MMA Accelerator", "EM_MMA", EM_MMA}, + {"Siemens PCP ", "EM_PCP", EM_PCP}, + {"Sony nCPU embeeded RISC ", "EM_NCPU", EM_NCPU}, + {"Denso NDR1 microprocessor ", "EM_NDR1", EM_NDR1}, + {"Motorola Start*Core processor ", "EM_STARCORE", EM_STARCORE}, + {"Toyota ME16 processor ", "EM_ME16", EM_ME16}, + {"STMicroelectronic ST100 processor ", "EM_ST100", EM_ST100}, + {"Advanced Logic Corp. Tinyj emb.fam", "EM_TINYJ", EM_TINYJ}, + {"AMD x86-64 architecture ", "EM_X86_64", EM_X86_64}, + {"Sony DSP Processor ", "EM_PDSP", EM_PDSP}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Unknown" , "EM_NONE", EM_NONE}, + {"Siemens FX66 MCU ", "EM_FX66", EM_FX66}, + {"STMicroelectronics ST9+ 8/16 mc ", "EM_ST9PLUS", EM_ST9PLUS}, + {"STmicroelectronics ST7 8 bit mc ", "EM_ST7", EM_ST7}, + {"Motorola MC68HC16 MCU ", "EM_68HC16", EM_68HC16}, + {"Motorola MC68HC11 MCU ", "EM_68HC11", EM_68HC11}, + {"Motorola MC68HC08 MCU ", "EM_68HC08", EM_68HC08}, + {"Motorola MC68HC05 MCU ", "EM_68HC05", EM_68HC05}, + {"Silicon Graphics SVx ", "EM_SVX", EM_SVX}, + {"STMicroelectronics ST19 8 bit mc ", "EM_ST19", EM_ST19}, + {"Digital VAX ", "EM_VAX", EM_VAX}, + {"Axis Communications 32-bit embedded processor ", "EM_CRIS", EM_CRIS}, + {"Infineon Technologies 32-bit embedded processor ", "EM_JAVELIN", EM_JAVELIN}, + {"Element 14 64-bit DSP Processor ", "EM_FIREPATH", EM_FIREPATH}, + {"LSI Logic 16-bit DSP Processor ", "EM_ZSP", EM_ZSP}, + {"Donald Knuth's educational 64-bit processor ", "EM_MMIX", EM_MMIX}, + {"Harvard University machine-independent object files ", "EM_HUANY", EM_HUANY}, + {"SiTera Prism ", "EM_PRISM", EM_PRISM}, + {"Atmel AVR 8-bit MCU ", "EM_AVR", EM_AVR}, + {"Fujitsu FR30 ", "EM_FR30", EM_FR30}, + {"Mitsubishi D10V ", "EM_D10V", EM_D10V}, + {"Mitsubishi D30V ", "EM_D30V", EM_D30V}, + {"NEC v850 ", "EM_V850", EM_V850}, + {"Mitsubishi M32R ", "EM_M32R", EM_M32R}, + {"Matsushita MN10300 ", "EM_MN10300", EM_MN10300}, + {"Matsushita MN10200 ", "EM_MN10200", EM_MN10200}, + {"picoJava ", "EM_PJ", EM_PJ}, + {"OpenRISC 32-bit embedded processor ", "EM_OPENRISC", EM_OPENRISC}, + {"ARC Cores Tangent-A5 ", "EM_ARC_A5", EM_ARC_A5}, + {"Tensilica Xtensa Architecture ", "EM_XTENSA", EM_XTENSA}, }; - + /** * Stab entry type strings @@ -988,6 +1035,30 @@ +/** + * Control flow analysis link types + */ +revmconst_t elfsh_link_type[] = +{ + {"", "FUNC_CALL" , MJR_LINK_FUNC_CALL}, + {"", "FUNC_RET" , MJR_LINK_FUNC_RET}, + {"", "BLOC_TRUE" , MJR_LINK_BLOCK_COND_TRUE}, + {"", "BLOC_FALSE" , MJR_LINK_BLOCK_COND_FALSE}, + {"", "BLOC_DELAY" , MJR_LINK_TYPE_DELAY}, + {"", "BLOC_ALWAYS" , MJR_LINK_BLOCK_COND_ALWAYS}, + {"", "LINK_UNKNOW" , MJR_LINK_UNKNOWN}, +}; + + +/** + * Control flow analysis link scopes + */ +revmconst_t elfsh_link_scope[] = +{ + {"", "SCOPE_UNKNOW" , MJR_LINK_SCOPE_UNKNOWN}, + {"", "SCOPE_LOCAL" , MJR_LINK_SCOPE_LOCAL}, + {"", "SCOPE_GLOBAL" , MJR_LINK_SCOPE_GLOBAL}, +}; diff -Nru eresi-0.8a25/libstderesi/elf/deps.c eresi-0.0.20110516/libstderesi/elf/deps.c --- eresi-0.8a25/libstderesi/elf/deps.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/deps.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,19 +1,20 @@ /** -** @file deps.c -** -** @brief All functions regarding dependences support in the naming scheme and the -** loading/unloading facilities of the shell -** -** Started on Sat Nov 25 11:21:18 2006 jfv -** -** $Id: deps.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ + * @file libstderesi/elf/deps.c + * @ingroup elf + * + * @brief All functions regarding dependences support in the naming scheme and the + * loading/unloading facilities of the shell + * + * Started on Sat Nov 25 11:21:18 2006 jfv + * + * $Id: deps.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "libstderesi.h" - -/** - * Our own pow + +/** + * Our own pow * @param a * @param b * @return @@ -22,13 +23,13 @@ { double res = 1; float f; - + if (b == 0) - return 1; + return 1; if (b < 0) { for (; b < 0; b++) - res = res * a; + res = res * a; f = 1 / res; return (int) f; } @@ -38,33 +39,33 @@ } -/** - * Find a different element than 'file' in the parent hash table +/** + * Find a different element than 'file' in the parent hash table * @param hash * @param file * @return */ -static void* revm_get_another_parent(hash_t *hash, elfshobj_t *file) +static void* revm_get_another_parent(hash_t *hash, elfshobj_t *file) { char **keys; int index; int idx; - + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!hash || hash_size(hash) <= 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find another parent", NULL); + "Unable to find another parent", NULL); keys = hash_get_keys(hash, &index); for (idx = 0; idx < index; idx++) if (strcmp(keys[idx], file->name)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - hash_get(hash, keys[idx])); + hash_get(hash, keys[idx])); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find another parent", NULL); + "Unable to find another parent", NULL); } -/** +/** * Merge the root dependences information for all the children, when a new * program with dependences is (un)loaded and some dependences also depends * from other roots. @@ -74,10 +75,10 @@ * @param action * @return */ -static int revm_update_depinfo(elfshobj_t *child, - elfshobj_t *root, - hash_t *dephash, - char action) +static int revm_update_depinfo(elfshobj_t *child, + elfshobj_t *root, + hash_t *dephash, + char action) { char **key; int index; @@ -86,7 +87,7 @@ int newid; void *present; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Cut the recursion in case of circular dependencies */ present = hash_get(dephash, child->name); @@ -108,8 +109,8 @@ { cur = hash_get(&child->child_hash, key[index]); if (revm_update_depinfo(cur, root, dephash, action)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Dependence failed to perform action", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Dependence failed to perform action", -1); } /* Remove the roots after recursion, so avoid unwanted unloading */ @@ -123,8 +124,8 @@ -/** - * Enum dependences +/** + * Enum dependences * @param obj * @param rechash * @param dephash @@ -142,12 +143,12 @@ char **hashkeys; int keys_num; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Avoid invalid arguments and cut recursion when needed */ if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); if (hash_get(rechash, obj->name)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); hash_add(rechash, strdup(obj->name), (void *) 1); @@ -156,36 +157,36 @@ dyn_entrie = elfsh_get_dynamic(obj, &dyn_num); if (dyn_entrie == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No .dynamic information", -1); + "No .dynamic information", -1); /* Loop on the .dynamic section entries */ for (index = 0; index < dyn_num && dyn_entrie[index].d_tag != DT_NULL; index++) { /* Only needed entries */ if (dyn_entrie[index].d_tag != DT_NEEDED) - continue; + continue; /* Retrieve the value */ revm_dynentinfo(obj, dyn_entrie + index, nbasename); if (*nbasename == 0x00) - continue; + continue; - /* Search the path for this library */ + /* Search the path for this library */ path = revm_load_searchlib(nbasename); if (!path) - continue; + continue; child = hash_get(&world.curjob->loaded, path); if (!child) - revm_load_dep(obj, path, 0, 0, dephash); + revm_load_dep(obj, path, 0, 0, dephash); else - { - if (!hash_get(&obj->child_hash, child->name)) - hash_add(&obj->child_hash, child->name, child); - if (!hash_get(&child->parent_hash, obj->name)) - hash_add(&child->parent_hash, obj->name, obj); - revm_update_depinfo(child, obj, dephash, REVM_HASH_MERGE); - } + { + if (!hash_get(&obj->child_hash, child->name)) + hash_add(&obj->child_hash, child->name, child); + if (!hash_get(&child->parent_hash, obj->name)) + hash_add(&child->parent_hash, obj->name, obj); + revm_update_depinfo(child, obj, dephash, REVM_HASH_MERGE); + } } /* Retrieve all childs keys then load dep for each child */ @@ -194,7 +195,7 @@ { child = (elfshobj_t *) hash_get(&obj->child_hash, hashkeys[index]); if (child) - revm_load_enumdep_rec(child, rechash, dephash); + revm_load_enumdep_rec(child, rechash, dephash); } PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -202,8 +203,8 @@ -/** - * This is a front end function for the recursive function above +/** + * This is a front end function for the recursive function above * @param obj * @return */ @@ -224,30 +225,30 @@ } -/** - * Search the lib path for a specific file +/** + * Search the lib path for a specific file * @param name Filename to search * @return */ -char *revm_load_searchlib(char *name) +char *revm_load_searchlib(char *name) { int len; char *libpath; - char *retpath = NULL; - char *p; + char *retpath = NULL; + char *p; char *f, *f2; - int dlen; + int dlen; char testpath[BUFSIZ]; char tmplibpath[BUFSIZ]; FILE *fp; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); libpath = revm_lookup_string(REVM_VAR_LIBPATH); /* The variable doesn't exist */ if (libpath == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ELFSH_LIBPATH not found", NULL); + "ERESI_LIBPATH not found", NULL); /* We copy data because we will make some modifications */ strncpy(tmplibpath, libpath, BUFSIZ -1); @@ -259,45 +260,45 @@ f = strchr(p, ';'); f2 = strchr(p, ':'); if ((!f && f2) || (f2 && f - f2 > 0)) - f = f2; + f = f2; /* If a ; is found, we seperate the tree */ if (f != NULL) - f[0] = '\0'; - + f[0] = '\0'; + /* Trim ended / */ for (dlen = strlen(p); p[dlen] == '/'; dlen--) - p[dlen] = '\0'; + p[dlen] = '\0'; snprintf(testpath, BUFSIZ - 1, - "%s/%s", p, name); + "%s/%s", p, name); /* The file exists, then we set the pointer */ if ((fp = fopen(testpath, "r")) != NULL) - { - fclose(fp); - retpath = testpath; - break; - } + { + fclose(fp); + retpath = testpath; + break; + } /* If we don't found the ;, it's the last path */ if (f == NULL) - break; + break; } if (retpath != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - strdup(retpath)); - + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, + strdup(retpath)); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); } -/** - * Search a dependence from an id and a loaded object. +/** + * Search a dependence from an id and a loaded object. * @param obj * @param id - * @return + * @return */ elfshobj_t *revm_is_depid(elfshobj_t *obj, int id) { @@ -310,16 +311,16 @@ int keynums; char **keys; int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!obj) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); + "Invalid paramters", NULL); /* We don't search a dependence or we are too far */ if (id < ELFSH_CHILD_MAX || !hash_size(&obj->child_hash) || obj->id > id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); /* Count how many digits */ for (ocount = 0, oid = obj->id; oid > 0; ocount++) @@ -337,25 +338,25 @@ { keys = hash_get_keys(&obj->child_hash, &keynums); for (index = 0; index < keynums; index++) - { - child = hash_get(&obj->child_hash, keys[index]); - if (child->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - - /* Search for a child of the child ! */ - if ((subchild = revm_is_depid(child, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, subchild); - } + { + child = hash_get(&obj->child_hash, keys[index]); + if (child->id == id) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); + + /* Search for a child of the child ! */ + if ((subchild = revm_is_depid(child, id)) != NULL) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, subchild); + } } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); } -/** - * Search a dependence from a lib name and a loaded object +/** + * Search a dependence from a lib name and a loaded object * @param obj * @param path * @return @@ -367,33 +368,33 @@ elfshobj_t *child; int keys_num; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!obj || !path) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); + "Invalid paramters", NULL); hashkeys = hash_get_keys(&obj->child_hash, &keys_num); for (index = 0; hashkeys != NULL && index < keys_num; index++) { child = (elfshobj_t *) hash_get(&obj->child_hash, hashkeys[index]); - + if (child) - { - if (!strcmp(path, hashkeys[index])) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - - child = revm_is_dep(child, path); - if (child) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - } + { + if (!strcmp(path, hashkeys[index])) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); + + child = revm_is_dep(child, path); + if (child) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); + } } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); } -/** +/** * Load a dependence which is different from a normal file. * @param parent * @param name @@ -402,37 +403,37 @@ * @param dephash * @return */ -int revm_load_dep(elfshobj_t *parent, char *name, - eresi_Addr base, elfshlinkmap_t *lm, - hash_t *dephash) +int revm_load_dep(elfshobj_t *parent, char *name, + eresi_Addr base, elfshlinkmap_t *lm, + hash_t *dephash) { elfshobj_t *new; char logbuf[BUFSIZ]; - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (!parent || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); /* Map the standard ELF object */ new = elfsh_map_obj(name); if (NULL == new) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load object", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot load object", -1); if (elfsh_get_arch(new->hdr) != elfsh_get_arch(parent->hdr)) { snprintf(logbuf, sizeof (logbuf) - 1, "Parent file and dependance %s" - " architecture unmatched", name); + " architecture unmatched", name); PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - logbuf, -1); + logbuf, -1); } - + /* Print a msg if not in quiet mode */ new->loadtime = time(&new->loadtime); if (!world.state.revm_quiet) { snprintf(logbuf, BUFSIZ - 1, " [*] New object dependences loaded : %s\n", - name); + name); revm_output(logbuf); } @@ -442,8 +443,8 @@ /* Add the object of child objects */ if (parent->lastchildid >= ELFSH_CHILD_MAX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create more child", -1); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot create more child", -1); /* Generate a child id */ new->id = ELFSH_CHILD_NEW(parent); @@ -457,13 +458,13 @@ /* Initialize hash tables */ snprintf(logbuf, sizeof(logbuf), "%s_children", name); hash_init(&new->child_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - + snprintf(logbuf, sizeof(logbuf), "%s_parents", name); - hash_init(&new->parent_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - + hash_init(&new->parent_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); + snprintf(logbuf, sizeof(logbuf), "%s_roots", name); - hash_init(&new->root_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - + hash_init(&new->root_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); + /* Link with its parent */ /* Link with all the additional root files of its parent */ @@ -476,12 +477,12 @@ hash_add(&world.curjob->loaded, new->name, new); hash_add(&file_hash, new->name, new); revm_update_depinfo(new, parent, dephash, REVM_HASH_MERGE); - + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } -/** +/** * Unload all dependence for an object. * @param obj * @param root @@ -489,8 +490,8 @@ * @param dephash * @return */ -static int revm_unload_dep_rec(elfshobj_t *obj, elfshobj_t *root, - hash_t *rechash, hash_t *dephash) +static int revm_unload_dep_rec(elfshobj_t *obj, elfshobj_t *root, + hash_t *rechash, hash_t *dephash) { elfshobj_t *actual; char logbuf[BUFSIZ]; @@ -499,7 +500,7 @@ int keynbr; time_t uloadt; int ret; - + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); if (hash_get(rechash, obj->name)) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); @@ -511,56 +512,56 @@ { actual = hash_get(&obj->child_hash, keys[index]); if (!actual || !actual->name || hash_get(rechash, actual->name)) - continue; + continue; //printf("Unloading dependence %s \n", actual->name); /* Case where we should -not- unload this object and its dependences */ /* Renew the object id, if its father changes */ - if (hash_size(&actual->root_hash) > 1 || - !hash_get(&actual->root_hash, root->name)) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Object %s -NOT- unloaded\n", - actual->name); - revm_output(logbuf); - - /* - ** If the object was already unlinked from its parent at another - ** iteration of this function, do not remove the roots and change - ** its id again -may - */ - if (hash_get(&actual->root_hash, root->name)) - { - hash_del(&actual->parent_hash, obj->name); - revm_update_depinfo(actual, root, dephash, REVM_CREATE_NEWID | REVM_HASH_UNMERGE); - } - continue; - } + if (hash_size(&actual->root_hash) > 1 || + !hash_get(&actual->root_hash, root->name)) + { + snprintf(logbuf, BUFSIZ - 1, " [*] Object %s -NOT- unloaded\n", + actual->name); + revm_output(logbuf); + + /* + ** If the object was already unlinked from its parent at another + ** iteration of this function, do not remove the roots and change + ** its id again -may + */ + if (hash_get(&actual->root_hash, root->name)) + { + hash_del(&actual->parent_hash, obj->name); + revm_update_depinfo(actual, root, dephash, REVM_CREATE_NEWID | REVM_HASH_UNMERGE); + } + continue; + } /* The current pointer must be NULL if it was us */ if (world.curjob->curfile && world.curjob->curfile->id == actual->id) - { - world.curjob->curfile = hash_get_one(&world.curjob->loaded); - if (!world.curjob->curfile) - world.curjob->curfile = hash_get_one(&world.shared_hash); - } + { + world.curjob->curfile = hash_get_one(&world.curjob->loaded); + if (!world.curjob->curfile) + world.curjob->curfile = hash_get_one(&world.shared_hash); + } /* A dependence can have its own dependences */ hash_del(&file_hash, actual->name); if (hash_get(&world.shared_hash, actual->name)) - hash_del(&world.shared_hash, actual->name); + hash_del(&world.shared_hash, actual->name); else - hash_del(&world.curjob->loaded, actual->name); + hash_del(&world.curjob->loaded, actual->name); revm_unload_dep_rec(actual, root, rechash, dephash); /* Print message of removing */ if (!world.state.revm_quiet) - { - time(&uloadt); - snprintf(logbuf, BUFSIZ - 1, " [*] Object %-40s unloaded on %s", - actual->name, ctime(&uloadt)); - revm_output(logbuf); - } + { + time(&uloadt); + snprintf(logbuf, BUFSIZ - 1, " [*] Object %-40s unloaded on %s", + actual->name, ctime(&uloadt)); + revm_output(logbuf); + } elfsh_unload_obj(actual); ret++; } @@ -569,7 +570,7 @@ PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } -/** +/** * This is a front end function for the recursive function above. * @param obj * @param root diff -Nru eresi-0.8a25/libstderesi/elf/disasm.c eresi-0.0.20110516/libstderesi/elf/disasm.c --- eresi-0.8a25/libstderesi/elf/disasm.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/disasm.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,16 +1,18 @@ /** -** @file disasm.c -** -** Started on Fri Nov 2 15:41:34 2001 jfv -** -** -** $Id: disasm.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +* @file libstderesi/elf/disasm.c +** @ingroup elf +*/ +/** + * +** @brief Implement disassembling and hexadumping in ERESI ** +** Started on Fri Nov 2 15:41:34 2001 jfv +** $Id: disasm.c 1397 2009-09-13 02:19:08Z may $ */ #include "libstderesi.h" -static revmlist_t* second = NULL; +static revmlist_t *second = NULL; /** @@ -21,10 +23,8 @@ * @param roffset * @return */ -char *revm_resolve(elfshobj_t *file, eresi_Addr addr, - elfsh_SAddr *roffset) +char *revm_resolve(elfshobj_t *file, eresi_Addr addr, elfsh_SAddr *roffset) { - listent_t *ent; int index; elfshobj_t *actual; char *name = NULL; @@ -36,10 +36,10 @@ elfshobj_t *bestfile; char buf[BUFSIZ]; char *str; - + char **keys; + int keynbr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!file) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid NULL argument", NULL); @@ -48,57 +48,61 @@ name = elfsh_reverse_symbol(actual, addr, &offset); dname = elfsh_reverse_dynsymbol(actual, addr, &doffset); +#if __DEBUG_RESOLVE__ + printf("[elfsh:resolve] First found file : %s name = %s:%d / dname = %s:%d ("XFMT") \n", + actual->name, name, offset, dname, doffset, addr); +#endif + if (!name || (dname && !strcmp(name, ELFSH_SECTION_NAME_PLT)) || (offset < 0) || (dname && doffset < offset && doffset >= 0)) { name = dname; offset = doffset; } - + else if (name && dname && doffset == offset) + name = dname; + bestname = name; bestoffset = offset; bestfile = actual; - -#if __DEBUG_RESOLVE__ - printf("[elfsh:resolve] file : %s name %s %d\n", actual->name, name, offset); -#endif - /* Find the best symbol by searching in all the objects of the process */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - for (index = 0; index < world.curjob->loaded.size; index++) - for (ent = &world.curjob->loaded.ent[index]; - ent != NULL && ent->key != NULL; - ent = ent->next) - { - actual = ent->data; - if (!actual->linkmap) + if (e2dbg_presence_get()) + { + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + for (index = 0; index < keynbr; index++) + { + actual = hash_get(&world.curjob->loaded, keys[index]); + if (!actual->linkmap) continue; - - name = elfsh_reverse_symbol(actual, addr, &offset); - dname = elfsh_reverse_dynsymbol(actual, addr, &doffset); - - if (!name || (offset < 0) || - (dname && doffset < offset && doffset >= 0)) - { - name = dname; - offset = doffset; - } - - if (!bestname || - (bestoffset < 0) || (name && offset < bestoffset && offset >= 0)) - { - bestname = name; - bestoffset = offset; - bestfile = actual; - } - + + name = elfsh_reverse_symbol(actual, addr, &offset); + dname = elfsh_reverse_dynsymbol(actual, addr, &doffset); + + if (!name || (offset < 0) || + (dname && doffset < offset && doffset >= 0)) + { + name = dname; + offset = doffset; + } + + if (!bestname || + (bestoffset < 0) || (name && (offset < bestoffset) && offset >= 0)) + { + bestname = name; + bestoffset = offset; + bestfile = actual; + #if __DEBUG_RESOLVE__ - printf("[elfsh:resolve] file : %s name %s %d\n", - actual->name, name, offset); + fprintf(stderr, "[elfsh:resolve] Changed best : file %s name %s %d\n", + actual->name, name, offset); #endif - } - + + } + + } + } + #if __DEBUG_RESOLVE__ printf("[elfsh:resolve] BEST name %s %d\n", bestname, bestoffset); #endif @@ -110,7 +114,7 @@ PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to resolve best name", (NULL)); - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) { str = revm_basename(bestfile->name); snprintf(buf, BUFSIZ, "%s@%s", @@ -141,6 +145,7 @@ elfsh_SAddr off; int len; char *sep; + uint32_t addr; /* Retreive the nearest symbol */ file = data; @@ -166,17 +171,17 @@ revm_colornumber("%u", (u_int) off), revm_colorfieldstr(">")); } + + /* We currently only disassemble architecture with 32bits address space, even when 64b proc */ else - snprintf(buf, maxlen - 1, AFMT, vaddr); + { + addr = (uint32_t) vaddr; + snprintf(buf, maxlen, "0x%X", addr); + } } -/*------------------ to clean !! ******/ - - - - /** * Display An instruction. * Runtime compatible @@ -189,63 +194,35 @@ * @param nindex * @param buff */ -u_int revm_instr_display(int fd, u_int index, eresi_Addr vaddr, - u_int foffset, u_int size, char *name, - u_int nindex, char *buff) - +int revm_instr_display(int fd, eresi_Addr vaddr, u_int foffset, u_int size, + char *name, u_int symoff, char *buff) { char *s; char buf[256]; u_int idx_bytes; - u_int ret; + int ret; asm_instr ptr; char base[16] = "0123456789ABCDEF"; char logbuf[BUFSIZ]; char c1[2]; char c2[2]; u_int strsz; - elfsh_Half machine; - + int err; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!buff) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid argument", (-1)); - - /* Init proc */ - if (!world.curjob->proc) - { - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC: - case EM_SPARC32PLUS: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - world.curjob->proc = &world.proc_mips; - break; - default: - snprintf(logbuf, sizeof (logbuf) - 1, - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - + revm_proc_init(); + err = 0; + /* Print the instr. itself : vaddr and relative symbol resolution */ - ret = asm_read_instr(&ptr, (u_char *)buff + index, size - index + 10, - world.curjob->proc); + ret = asm_read_instr(&ptr, (u_char *) buff, size, world.curjob->proc); if (ret == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "asm_read_instruction faild (-1)", (ret)); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to read instruction", ESTD_DISASM_FAILED); - s = (!ret ? "(bad)" : asm_display_instr_att(&ptr, (vaddr ? vaddr + index : 0))); + s = (!ret ? "(bad)" : asm_display_instr_att(&ptr, vaddr)); /* Libasm test */ if (fd == -1) @@ -255,20 +232,20 @@ if (world.state.revm_quiet) { snprintf(buf, sizeof(buf), " %s %s + %s", - revm_coloraddress(XFMT, vaddr + index), + revm_coloraddress(XFMT, vaddr), revm_colorstr(name), - revm_colornumber("%u", nindex)); + revm_colornumber("%u", symoff)); size = snprintf(logbuf, BUFSIZ, "%-40s %-30s ", buf, revm_colorinstr(s)); } else { size = snprintf(buf, sizeof(buf), " %s [%s %s] %s + %s", - revm_coloraddress(XFMT, vaddr + index), + revm_coloraddress(XFMT, vaddr), revm_colorfieldstr("foff:"), - revm_colornumber("%u", foffset + index), + revm_colornumber("%u", foffset), revm_colorstr(name), - revm_colornumber("%u", nindex)); + revm_colornumber("%u", symoff)); strsz = strlen(s); size = snprintf(logbuf, BUFSIZ, "%-*s %-*s ", (size > 95 ? 125 : @@ -289,10 +266,10 @@ ret++; if (!world.state.revm_quiet) - for (idx_bytes = 0; idx_bytes < ret; idx_bytes++) + for (idx_bytes = 0; idx_bytes < (u_int) ret; idx_bytes++) { - c1[0] = base[(buff[index + idx_bytes] >> 4) & 0x0F]; - c2[0] = base[buff[index + idx_bytes] & 0x0F]; + c1[0] = base[(buff[idx_bytes] >> 4) & 0x0F]; + c2[0] = base[buff[idx_bytes] & 0x0F]; c1[1] = c2[1] = 0x00; size += snprintf(logbuf + size, sizeof(logbuf) - size, "%s%s ", revm_colorfieldstr(c1), @@ -302,10 +279,12 @@ if (!world.curjob->curcmd || !world.curjob->curcmd->use_regx[1] || !regexec(&second->name, logbuf, 0, 0, 0)) { - revm_output(logbuf); - revm_output("\n"); + snprintf(logbuf + size, sizeof(logbuf) - size, "\n"); + err = revm_output(logbuf); } revm_endline(); + if (err < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); } else write(fd, s, strlen(s)); @@ -313,8 +292,240 @@ } + + +/** + * @brief Display the content of an objet in hexadecimal and ascii format + * @param parent The parent section for the object + * @param name The name of the object + * @param vaddr The virtual address where the object stands + * @param index The offset where to start display + * @param size Number of bytes to display + * @param off The buffer offset be skipped at the beginning (duplicate!) + * @param sym The symbol associated to this object + * @param buff The data pointer of the object + * @param foffset The file offset where the object data stands at. + * @return Always 0. + */ +int revm_hexa_display(elfshsect_t *parent, char *name, eresi_Addr vaddr, + u_int size, u_int symoff, char *buff, u_int fileoff) + +{ + eresi_Addr vaddr2; + u_int curidx; + char buf[256]; + char logbuf[BUFSIZ]; + char tmp[BUFSIZ]; + char c1[2], c2[2]; + u_int ret; + int err; + u_int loff; + char *pStr; + char base[16] = "0123456789ABCDEF"; + u_int curoff; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (name == NULL || !*name) + name = ELFSH_NULL_STRING; + vaddr2 = vaddr; + curoff = curidx = 0; + + while (curoff < size && size > 0) + { + + /* Take care of quiet mode */ + if (world.state.revm_quiet) + { + sprintf(buf, " %s %s + %s", + revm_coloraddress(AFMT, (eresi_Addr) vaddr2), + revm_colorstr(name), + revm_colornumber("%u", symoff)); + snprintf(logbuf, BUFSIZ - 1, "%-40s ", buf); + revm_output(logbuf); + } + else + { + sprintf(buf, " %s [%s %s] %s + %s", + revm_coloraddress(AFMT, (eresi_Addr) vaddr2), + revm_colorfieldstr("foff:"), + revm_colornumber(DFMT, fileoff + curidx), + revm_colorstr(name), + revm_colornumber("%u", symoff)); + snprintf(logbuf, BUFSIZ - 1, "%-*s", 60 + revm_color_size(buf), buf); + revm_output(logbuf); + } + revm_endline(); + ret = (world.state.revm_quiet ? 8 : 16); + tmp[0] = c1[1] = c2[1] = 0x00; + + /* Print hexa */ + for (loff = 0; loff < ret; loff++) + { + c1[0] = c2[0] = ' '; + if (curoff + loff < size) + { + c1[0] = base[(buff[curidx + loff] >> 4) & 0x0F]; + c2[0] = base[(buff[curidx + loff] >> 0) & 0x0F]; + } + snprintf(logbuf, BUFSIZ - 1, "%s%s ", c1, c2); + if (strlen(tmp) + strlen(logbuf) < BUFSIZ) + strcat(tmp, logbuf); + } + + revm_output(revm_colorfieldstr(tmp)); + revm_endline(); + tmp[0] = 0x00; + + /* Print ascii */ + for (loff = 0; loff < ret; loff++) + { + c1[0] = buff[curidx + loff]; + pStr = (curoff + loff >= size ? " " : + (PRINTABLE(buff[curidx + loff]) ? c1 : ".")); + if (strlen(tmp) + 1 < BUFSIZ) + strcat(tmp, pStr); + } + + err = revm_output(revm_colorstr(tmp)); + revm_endline(); + revm_output("\n"); + symoff += ret; + vaddr2 += ret; + curidx += ret; + curoff += ret; + + /* If we have requested to stop the output */ + if (err < 0) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + +/** + * @brief Display the content of an array object + * @param parent The parent section for the array object + * @param sym The symbol associated to this array + * @param buff The data pointer of the array + * @param vaddr The virtual address where the array stands + * @param name The name of the array + * @param foffset The file offset of the array data in ELF + * @return Always 0. + */ +int revm_array_display(elfshsect_t *parent, elfsh_Sym *sym, char *buff, + eresi_Addr vaddr, char *name, u_int foffset) + +{ + char buf[256]; + char str[256]; + char logbuf[BUFSIZ]; + char *tmpbuff; + eresi_Addr vaddr2; + eresi_Addr loff; + elfshsect_t *targ; + u_int index; + u_int off; + char *s; + elfsh_SAddr idx_bytes; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + for (index = 0; index * sizeof(eresi_Addr) < sym->st_size; index++) + { + + /* Do not print more than 192 bytes at a time */ + /* Use an offset for more dumping */ + if (index * sizeof(eresi_Addr) >= ESTD_MAXREAD_SIZE) + { + revm_output("-- symbol size is bigger (use an offset) --\n"); + break; + } + + /* For each entry of the array */ + /* Dont forget the section offset at the end */ + if (!parent) + tmpbuff = buff; + else + { + tmpbuff = elfsh_readmem(parent); + tmpbuff += vaddr - (parent->parent->rhdr.base + parent->shdr->sh_addr); + } + + if (kernsh_is_present() && elfsh_is_runtime_mode()) + parent->parent->rhdr.base = 0; + + tmpbuff += index * sizeof(eresi_Addr); + loff = * (eresi_Addr *) tmpbuff; + vaddr2 = vaddr + index * sizeof(eresi_Addr); + + snprintf(buf, sizeof(buf), " " AFMT " [foff: %u] \t %s[%0*u] = " XFMT, + (elfsh_is_runtime_mode() && parent ? + parent->parent->rhdr.base + vaddr2 : vaddr2), + foffset + index * sizeof(eresi_Addr), name, + ((sym->st_size / sizeof(eresi_Addr)) < 100 ? 2 : + (sym->st_size / sizeof(eresi_Addr)) < 1000 ? 3 : 4), + index, loff); + + /* If the object was given as address, dont try to resolve array entries + -- FIXME: we could try to find if the entries are valid (mapped) on any object */ + if (!parent) + { + revm_output(buf); + continue; + } + + /* If the target pointer is not valid */ + targ = elfsh_get_parent_section(parent->parent, loff, + (elfsh_SAddr *) &off); + if (targ == NULL || strcmp(targ->name, ELFSH_SECTION_NAME_RODATA)) + { + s = elfsh_reverse_symbol(parent->parent, loff, &idx_bytes); + if (NULL == s || idx_bytes > 1000) + s = elfsh_reverse_dynsymbol(parent->parent, loff, &idx_bytes); + if (NULL == s || idx_bytes > 1000) + { + if (targ != NULL) + { + s = targ->name; + idx_bytes = off; + } + else + idx_bytes = 0; + } + if (idx_bytes) + snprintf(str, sizeof(str), "%s + %u", + (s ? s : ""), (u_int) idx_bytes); + else + snprintf(str, sizeof(str), ""); + snprintf(logbuf, BUFSIZ, "%-75s %s \n", buf, str); + } + + /* else if yes, print the pointed data too */ + else + { + s = elfsh_readmem(targ); + s += off; + memcpy(str, s, + (sizeof(str) > (targ->shdr->sh_size - off)) ? + targ->shdr->sh_size - off : sizeof(str)); + snprintf(logbuf, BUFSIZ - 1, "%-75s \"%s\" \n", buf, str); + } + + /* maybe the user asked to quit the display */ + revm_output(logbuf); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + /** - * Disassemble a function. + * @brief Display the content of a binary object (wrapper function) * @param parent * @param sym * @param size @@ -326,58 +537,86 @@ * @return */ int revm_object_display(elfshsect_t *parent, elfsh_Sym *sym, int size, - u_int off, u_int foffset, eresi_Addr vaddr, - char *name, char otype) + u_int reqoff, u_int symoff, u_int foffset, + eresi_Addr vaddr, char *name, char otype, u_char addbase) { char *buff; u_int index; elfsh_SAddr idx_bytes; - char buf[256]; - char base[16] = "0123456789ABCDEF"; - eresi_Addr loff; - char str[256]; - elfshsect_t *targ; - char *s; - u_int ret; int value; + int nbrinstr; + eresi_Addr base; + eresi_Addr wheretoread; + u_int remain; + u_int readnow; + char *bufarg; + u_int readsz; + eresi_Addr startaddr; +#if __DEBUG_DISASM__ char logbuf[BUFSIZ]; - char tmp[BUFSIZ]; - char c1[2], c2[2]; - char *pStr; - void *tmpbuff; +#endif PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!parent) + if (!parent && (elfsh_is_static_mode() || world.state.revm_mode != REVM_STATE_EMBEDDED)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "parent section is NULL", -1); + "Parent section is NULL", -1); /* Special case if the symbol is a plt entry */ - if (sym && elfsh_is_pltentry(parent->parent, sym) == 1 && + if (parent && sym && elfsh_is_pltentry(parent->parent, sym) == 1 && size > ELFSH_PLT_ENTRY_SIZE) size = ELFSH_PLT_ENTRY_SIZE; #if __DEBUG_DISASM__ snprintf(logbuf, BUFSIZ - 1, - "[debug:revm_object_display] %s off(%u) size(%u) vaddr(%08X) " + "[debug:revm_object_display] %s off(%u) size(%u) vaddr("XFMT") " "foffset(%u), parent(%p, %s) \n", - name, off, size, vaddr, foffset, parent, + name, reqoff, size, vaddr, foffset, parent, (parent ? parent->name : "UNK")); revm_output(logbuf); #endif /* Get the pointer on relevant data */ - buff = elfsh_get_raw(parent); - index = off; - buff += (vaddr - (parent->parent->rhdr.base + parent->shdr->sh_addr)); + if (parent && !parent->shdr->sh_addr) + { + buff = parent->data + reqoff; + bufarg = NULL; + readnow = parent->shdr->sh_size - reqoff; + index = reqoff; + remain = 0; + } + else if (parent) + { + wheretoread = parent->shdr->sh_addr; + wheretoread += (vaddr - parent->shdr->sh_addr); + index = reqoff; + wheretoread += reqoff; + readnow = MJR_MIN(size, ESTD_MAXREAD_SIZE); + bufarg = NULL; + if (elfsh_is_runtime_mode() && (kernsh_is_present() || kedbg_is_present())) + { + XALLOC(__FILE__, __FUNCTION__, __LINE__, buff, readnow, -1); + bufarg = buff; + } + buff = elfsh_readmema(parent->parent, wheretoread, bufarg, readnow); + remain = (size > ESTD_MAXREAD_SIZE ? size - ESTD_MAXREAD_SIZE : 0); + } + else + { + wheretoread = vaddr; + buff = (char *) vaddr; + bufarg = NULL; + readnow = size; + remain = 0; + index = 0; + } -#if defined(KERNSH) - if (kernsh_is_mem_mode()) + /* If we are in the kernel shell, it will do its own base address management */ + if (kernsh_is_present() && elfsh_is_runtime_mode()) parent->parent->rhdr.base = 0; -#endif /* Filter requests on void sections (ex: bss when not inserted in file) */ - if (!parent || !parent->data) + if (elfsh_is_static_mode() && (!parent || !parent->data)) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No data at this address", -1); @@ -387,178 +626,82 @@ elfsh_get_symbol_type(sym) == STT_COMMON) && !(sym->st_size % sizeof(eresi_Addr))) { - - for (index = 0; index * sizeof(eresi_Addr) < sym->st_size; index++) - { - - /* Do not print more than 250 entries at a time */ - /* Use an offset for more dumping */ - if (index >= 250) - { - revm_output("-- symbol size is bigger (use an offset) --\n"); - break; - } - - /* For each entry of the array */ - /* Dont forget the section offset at the end */ - tmpbuff = elfsh_get_raw(parent); - tmpbuff += vaddr - (parent->parent->rhdr.base + parent->shdr->sh_addr); - -#if defined(KERNSH) - if (kernsh_is_mem_mode()) - parent->parent->rhdr.base = 0; -#endif - - tmpbuff += index * sizeof(eresi_Addr); - loff = * (eresi_Addr *) tmpbuff; - - snprintf(buf, sizeof(buf), " " AFMT " [foff: %u] \t %s[%0*u] = " XFMT, - elfsh_is_debug_mode() ? - parent->parent->rhdr.base + vaddr + index * sizeof(eresi_Addr) : - vaddr + index * sizeof(eresi_Addr), - foffset + index * sizeof(eresi_Addr), - name, - ((sym->st_size / sizeof(eresi_Addr)) < 100 ? 2 : - (sym->st_size / sizeof(eresi_Addr)) < 1000 ? 3 : 4), - index, - loff); - - /* If the target pointer is not valid */ - targ = elfsh_get_parent_section(parent->parent, loff, - (elfsh_SAddr *) &off); - if (targ == NULL || strcmp(targ->name, ELFSH_SECTION_NAME_RODATA)) - { - s = elfsh_reverse_symbol(parent->parent, loff, &idx_bytes); - if (NULL == s || idx_bytes > 1000) - s = elfsh_reverse_dynsymbol(parent->parent, loff, &idx_bytes); - if (NULL == s || idx_bytes > 1000) - { - if (targ != NULL) - { - s = targ->name; - idx_bytes = off; - } - else - idx_bytes = 0; - } - if (idx_bytes) - snprintf(str, sizeof(str), "%s + %u", - (s ? s : ""), (u_int) idx_bytes); - else - snprintf(str, sizeof(str), ""); - snprintf(logbuf, BUFSIZ, "%-75s %s \n", buf, str); - } - - /* else if yes, print the pointed data too */ - else - { - s = elfsh_get_raw(targ); - s += off; - memcpy(str, s, - (sizeof(str) > (targ->shdr->sh_size - off)) ? - targ->shdr->sh_size - off : sizeof(str)); - snprintf(logbuf, BUFSIZ - 1, "%-75s \"%s\" \n", buf, str); - } - - /* maybe the user asked to quit the display */ - revm_output(logbuf); - } + revm_array_display(parent, sym, buff, vaddr, name, foffset); + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } - - - /* We want asm + hexa output of the code */ - else if (otype == REVM_VIEW_DISASM) + /* We want assembly + hexa, or only hexa + ascii ? */ + switch (otype) { -#if defined(KERNSH) - if (!kernsh_is_present() && elfsh_is_debug_mode()) - vaddr += parent->parent->rhdr.base; -#else - if (elfsh_is_debug_mode()) + + /* We want assembly and hexa */ + case REVM_VIEW_DISASM: + + if (!kernsh_is_present() && elfsh_is_runtime_mode() && addbase) vaddr += parent->parent->rhdr.base; -#endif - idx_bytes = (sym ? vaddr + index - sym->st_value : index); - - while (index < size && size > 0) + base = (elfsh_is_runtime_mode() ? parent->parent->rhdr.base : 0); + idx_bytes = symoff + index; + vaddr += index; + foffset += index; + + do { - value = revm_instr_display(-1, index, vaddr, - foffset, size, name, - idx_bytes, buff); - if (value <= 0) + value = 0; + if (!size) break; - index += value; - idx_bytes += value; + for (startaddr = vaddr, readsz = nbrinstr = 0; + nbrinstr < size && (vaddr - startaddr) < readnow - 20; + nbrinstr++) + { + value = revm_instr_display(-1, vaddr, foffset, readnow, name, idx_bytes, buff + readsz); + if (value <= 0) + break; + readsz += value; + vaddr += value; + index += value; + idx_bytes += value; + foffset += value; + } + if (value <= 0 || !remain) + break; + wheretoread += readsz; + readnow = MJR_MIN(remain, ESTD_MAXREAD_SIZE); + buff = elfsh_readmema(parent->parent, wheretoread, bufarg, readnow); + remain -= readsz; } - } + while (1); + break; /* We want hexa + ascii output of the data */ - else if (REVM_VIEW_HEX == otype) - { - if (name == NULL || !*name) - name = ELFSH_NULL_STRING; - - while (index < size && size > 0) + case REVM_VIEW_HEX: + vaddr += index; + foffset += index; + do { - /* Take care of quiet mode */ - if (world.state.revm_quiet) - { - sprintf(buf, " %s %s + %s", - revm_coloraddress(AFMT, (eresi_Addr) vaddr + index), - revm_colorstr(name), revm_colornumber("%u", index)); - snprintf(logbuf, BUFSIZ - 1, "%-40s ", buf); - revm_output(logbuf); - } - else - { - sprintf(buf, " %s [%s %s] %s + %s", - revm_coloraddress(AFMT, (eresi_Addr) vaddr + index), - revm_colorfieldstr("foff:"), - revm_colornumber(DFMT, foffset + index), - revm_colorstr(name), revm_colornumber("%u", index)); - snprintf(logbuf, BUFSIZ - 1, "%-*s", 60 + revm_color_size(buf), buf); - revm_output(logbuf); - } - revm_endline(); - ret = (world.state.revm_quiet ? 8 : 16); - tmp[0] = c1[1] = c2[1] = 0x00; - - /* Print hexa */ - for (loff = 0; loff < ret; loff++) - { - c1[0] = c2[0] = ' '; - if (index + loff < size) - { - c1[0] = base[(buff[index + loff] >> 4) & 0x0F]; - c2[0] = base[(buff[index + loff] >> 0) & 0x0F]; - } - snprintf(logbuf, BUFSIZ - 1, "%s%s ", c1, c2); - if (strlen(tmp) + strlen(logbuf) < BUFSIZ) - strcat(tmp, logbuf); - } - - revm_output(revm_colorfieldstr(tmp)); - revm_endline(); - tmp[0] = 0x00; - - /* Print ascii */ - for (loff = 0; loff < ret; loff++) - { - c1[0] = buff[index + loff]; - pStr = (index + loff >= size ? " " : - (PRINTABLE(buff[index + loff]) ? c1 : ".")); - if (strlen(tmp) + 1 < BUFSIZ) - strcat(tmp, pStr); - } - - revm_output(revm_colorstr(tmp)); - revm_endline(); - revm_output("\n"); - index += ret; + value = revm_hexa_display(parent, name, vaddr, readnow, symoff + index, buff, foffset); + if (value < 0 || !remain) + break; + wheretoread += readnow; + readnow = MJR_MIN(remain, ESTD_MAXREAD_SIZE); + buff = elfsh_readmema(parent->parent, wheretoread, bufarg, readnow); + remain -= readnow; + vaddr += readnow; + index += readnow; + foffset += readnow; } - } + while (1); + } + if (parent && elfsh_is_runtime_mode() && (kernsh_is_present() || kedbg_is_present())) + XFREE(__FILE__, __FUNCTION__, __LINE__, buff); revm_output("\n"); + + if (value == ESTD_DISASM_FAILED) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to disassemble", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -575,8 +718,8 @@ * @return */ int revm_section_display(elfshsect_t *s, - char *name, - revmlist_t *re) + char *name, + revmlist_t *re) { elfsh_Sym *actual; int size, symtab_size; @@ -586,25 +729,27 @@ char *symname; char logbuf[BUFSIZ]; int err; - eresi_Addr addr; + u_int foff; + eresi_Addr base; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); /* Hello message ;) */ - snprintf(logbuf, BUFSIZ - 1, " [*] Analysing section %s [*] \n\n", name); + snprintf(logbuf, BUFSIZ - 1, "\n [*] Analysing section %s [*] \n\n", name); revm_output(logbuf); actual = elfsh_get_symtab(s->parent, &symtab_size); tot = 0; - if (s && !elfsh_get_raw(s)) + if (s && !s->data) elfsh_get_anonymous_section(s->parent, s); - if (!actual) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Section has no symbol associated", -1); + base = (elfsh_is_runtime_mode() ? s->parent->rhdr.base : 0); /* Display all symbols data pointing in the section */ for (index = 0; index < symtab_size; index++) - if (elfsh_get_parent_section(s->parent, actual[index].st_value, &offset) == s) + if (elfsh_get_parent_section(s->parent, base + actual[index].st_value, + &offset) == s) { if (re->size) size = ((re->size + re->off) > actual[index].st_size ? @@ -613,9 +758,10 @@ size = actual[index].st_size; symname = elfsh_get_symbol_name(s->parent, actual + index); - addr = s->shdr->sh_offset + actual[index].st_value - s->shdr->sh_addr; - err = revm_object_display(s, actual + index, size, re->off, addr, - actual[index].st_value, symname, re->otype); + foff = s->shdr->sh_offset + actual[index].st_value - s->shdr->sh_addr; + err = revm_object_display(s, actual + index, size, re->off, 0, foff, + base + actual[index].st_value, symname, + re->otype, 0); if (err == -1) PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); @@ -631,8 +777,8 @@ else size = s->shdr->sh_size; actual = elfsh_get_symbol_by_name(s->parent, name); - if (revm_object_display(s, actual, size, re->off, s->shdr->sh_offset, - s->shdr->sh_addr, name, re->otype) < 0) + if (revm_object_display(s, actual, size, re->off, 0, s->shdr->sh_offset, + s->shdr->sh_addr, name, re->otype, 1) < 0) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unable to display section data", -1); } @@ -652,7 +798,7 @@ * @param actual * @return */ -int revm_match_sht(elfshobj_t *file, elfshsect_t *l, revmlist_t *actual) +int revm_match_sht(elfshsect_t *l, revmlist_t *actual) { elfshsect_t *s; char *name; @@ -697,15 +843,16 @@ * @return */ int revm_match_symtab(elfshobj_t *file, elfshsect_t *symtab, - revmlist_t *actual, int flag) + revmlist_t *actual, int flag) { elfshsect_t *s; char *name; int matchs = 0; u_int saved_size; elfsh_Sym *sym; - eresi_Addr addr; - int index; + u_int foff; + u_int index; + eresi_Addr base; #if __DEBUG_DISASM__ char logbuf[BUFSIZ]; #endif @@ -718,7 +865,10 @@ saved_size = actual->size; /* Iterate on symbols */ - sym = (flag ? elfsh_get_raw(symtab) : (elfsh_Sym *) symtab->altdata); + sym = (flag ? elfsh_readmem(symtab) : (elfsh_Sym *) symtab->altdata); + if (!sym) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to read existing symtab", -1); for (index = 0; index < symtab->shdr->sh_size / sizeof(elfsh_Sym); index++) { @@ -749,19 +899,17 @@ if (flag && !elfsh_get_symbol_value(sym + index)) { elfsh_toggle_mode(); - sym = elfsh_get_raw(symtab); + sym = elfsh_readmem(symtab); elfsh_toggle_mode(); - s = elfsh_get_parent_section(file, - file->rhdr.base + sym[index].st_value, - NULL); } - else - s = elfsh_get_parent_section(file, sym[index].st_value, NULL); + + base = (elfsh_is_runtime_mode() ? file->rhdr.base : 0); + s = elfsh_get_parent_section(file, base + sym[index].st_value, NULL); /* Display matched object */ - addr = elfsh_get_foffset_from_vaddr(file, sym[index].st_value); - if (revm_object_display(s, sym + index, actual->size, actual->off, addr, - sym[index].st_value, name, actual->otype) == -1) + foff = elfsh_get_foffset_from_vaddr(file, sym[index].st_value); + if (revm_object_display(s, sym + index, actual->size, actual->off, 0, foff, + base + sym[index].st_value, name, actual->otype, 0) == -1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Error while displaying matched object", -1); @@ -789,10 +937,14 @@ revmlist_t *actual) { elfsh_Sym *sym; + elfsh_Sym *dynsym; char *name; int off; + int doff; u_int matchs; elfshsect_t *s; + u_int foff; + int err; #if __DEBUG_DISASM__ char logbuf[BUFSIZ]; @@ -806,21 +958,33 @@ revm_output(logbuf); #endif - if (file->hdr->e_type == ET_DYN && elfsh_is_debug_mode()) + /* Find symbol for address */ + if (file->hdr->e_type == ET_DYN && elfsh_is_runtime_mode()) vaddr -= file->rhdr.base; - sym = elfsh_get_symbol_by_value(file, vaddr, &off, ELFSH_LOWSYM); - if (file->hdr->e_type == ET_DYN && elfsh_is_debug_mode()) + sym = elfsh_get_symbol_by_value(file, vaddr, &off, ELFSH_LOWSYM); + dynsym = elfsh_get_dynsymbol_by_value(file, vaddr, &doff, ELFSH_LOWSYM); + if (!sym || (dynsym && doff < off)) + { + sym = dynsym; + off = doff; + name = elfsh_get_dynsymbol_name(file, sym); + } + else + name = elfsh_get_symbol_name(file, sym); + foff = elfsh_get_foffset_from_vaddr(file, vaddr); + if (file->hdr->e_type == ET_DYN && elfsh_is_runtime_mode()) vaddr += file->rhdr.base; - if (sym == NULL) + if (sym == NULL || name == NULL) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "No matching symbol for offset", -1); - actual->off += off; + + //actual->off += off; + if (!actual->size) actual->size = elfsh_get_symbol_size(sym); else actual->size = ((actual->size + actual->off) > elfsh_get_symbol_size(sym) ? elfsh_get_symbol_size(sym) : actual->size + actual->off); - name = elfsh_get_symbol_name(file, sym); matchs++; #if __DEBUG_DISASM__ @@ -829,70 +993,49 @@ revm_output(logbuf); #endif - s = elfsh_get_parent_section(file, vaddr, NULL); - if (!s) + s = elfsh_get_parent_section(file, + (elfsh_is_runtime_mode() ? vaddr : + vaddr - file->rhdr.base), NULL); + if (!s && !elfsh_is_runtime_mode()) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No matching section for address", -1); + "No matching section for address", -1); - if (!actual->size) + if (!s) + actual->size = sizeof(eresi_Addr); + else if (!actual->size) actual->size = s->shdr->sh_size; - revm_object_display(s, sym, actual->size, actual->off, - elfsh_get_foffset_from_vaddr(file, vaddr), - vaddr, name, actual->otype); + + err = revm_object_display(s, sym, actual->size, actual->off, off, + foff, vaddr, name, actual->otype, 0); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to display object", -1); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /** - * Display ASM code for a given function, or every functions of a section + * Find what to match in the file given in parameter */ -int cmd_disasm() +int revm_match_find(elfshobj_t *file) { revmlist_t *actual; - elfshobj_t *file; revmexpr_t *expr; int matchs; + int res; eresi_Addr vaddr; - char logbuf[BUFSIZ]; - elfsh_Half machine; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First check the architecture */ - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC32PLUS: - case EM_SPARC: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - world.curjob->proc = &world.proc_mips; - break; - default: - snprintf(logbuf, sizeof (logbuf) - 1, - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } + int err; - /* Make sure we get symtabs of current object */ - elfsh_get_symtab(world.curjob->curfile, NULL); - elfsh_get_dynsymtab(world.curjob->curfile, NULL); - revm_output("\n"); + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__);\ /* now walk the regex list for this option */ actual = world.curjob->curcmd->disasm + 0; second = world.curjob->curcmd->disasm + 1; + + elfsh_get_symtab(file, NULL); + elfsh_get_dynsymtab(file, NULL); matchs = vaddr = 0; - file = world.curjob->curfile; /* If the regex contains a vaddr instead of a symbol name */ if (actual->rname) @@ -903,16 +1046,25 @@ if (!expr || !expr->value || !expr->value->immed_val.ent) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid requested address expression", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, expr->value->immed_val.ent, actual)); + + err = revm_match_special(file, expr->value->immed_val.ent, actual); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed analyzing address from eresi variable", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + else if (IS_VADDR(actual->rname)) { if (sscanf(actual->rname + 2, AFMT, &vaddr) != 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid virtual address requested", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, vaddr, actual)); + + err = revm_match_special(file, vaddr, actual); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to analyze at virtual address", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } /* else if it contains a file offset */ @@ -922,29 +1074,73 @@ if (vaddr == 0xFFFFFFFF && sscanf(actual->rname + 2, AFMT, &vaddr) != 1) PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file offset requested", - -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, vaddr, actual)); + "Invalid requested file offset", -1); + err = revm_match_special(file, vaddr, actual); + if (err < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to analyze at file offset", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } } /* Try to match in the sectlist and runtime sectlist */ - matchs += revm_match_sht(file, file->sectlist, actual); - matchs += revm_match_sht(file, file->rsectlist, actual); - + res = revm_match_sht(file->sectlist, actual); + if (res > 0) + matchs += res; + res = revm_match_sht(file->rsectlist, actual); + if (res > 0) + matchs += res; + /* Now find matches in the symbol table .symtab */ /* Last parameter says if we are in symtab or dynsymtab */ - matchs += revm_match_symtab(file, file->secthash[ELFSH_SECTION_SYMTAB], actual, 0); - matchs += revm_match_symtab(file, file->secthash[ELFSH_SECTION_DYNSYM], actual, 1); + res = revm_match_symtab(file, file->secthash[ELFSH_SECTION_SYMTAB], actual, 0); + if (res > 0) + matchs += res; + res = revm_match_symtab(file, file->secthash[ELFSH_SECTION_DYNSYM], actual, 1); + if (res > 0) + matchs += res; /* Printing a warning message if we have no match */ - if (!world.state.revm_quiet && !matchs) + if (!matchs) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "No match within curfile", -1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Display ASM code for a given function, or every functions of a section + */ +int cmd_disasm() +{ + int keynbr; + char **keys; + int index; + elfshobj_t *actual; + int res; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* First try to match in current file */ + res = revm_match_find(world.curjob->curfile); + if (!res) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + /* Else try to find in other loaded objects */ + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + for (index = 0; index < keynbr; index++) { - snprintf(logbuf, BUFSIZ - 1, " [E] No match for request %s\n\n", - actual->rname); - revm_output(logbuf); + actual = hash_get(&world.curjob->loaded, keys[index]); + res = revm_match_find(actual); + if (!res) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } + hash_free_keys(keys); + + /* Else print a message */ + revm_output(" [E] Failed to disassemble\n\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } diff -Nru eresi-0.8a25/libstderesi/elf/dtors.c eresi-0.0.20110516/libstderesi/elf/dtors.c --- eresi-0.8a25/libstderesi/elf/dtors.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/dtors.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** -** @file dtors.c +* @file libstderesi/elf/dtors.c +** @ingroup elf +*/ +/** + * ** ** Started on Tue Feb 26 22:08:20 2002 jfv ** ** -** $Id: dtors.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +** $Id: dtors.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -52,10 +56,10 @@ offset = doffset; } - if (off) + if (offset) snprintf(off, sizeof(off), " %s %s", revm_colorstr((offset < 0 ? "-" : "+")), - revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); + revm_colornumber("%u", (u_int) (offset > 0 ? offset : -offset))); snprintf(buff, sizeof(buff), " %s %s \t <%s%s>\n", revm_colornumber("[%02u]", index), diff -Nru eresi-0.8a25/libstderesi/elf/dyn.c eresi-0.0.20110516/libstderesi/elf/dyn.c --- eresi-0.8a25/libstderesi/elf/dyn.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/dyn.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file dyn.c +* @file libstderesi/elf/dyn.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:17:36 2001 jfv * * - * $Id: dyn.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: dyn.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -370,7 +374,7 @@ char *p; regex_t *tmp; char buff[256]; - char type_unk[ELFSH_MEANING + 1]; + char type_unk[ERESI_MEANING + 1]; char info[BUFSIZ]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/libstderesi/elf/findrel.c eresi-0.0.20110516/libstderesi/elf/findrel.c --- eresi-0.8a25/libstderesi/elf/findrel.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/findrel.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** -** @file findrel.c +* @file libstderesi/elf/findrel.c +** @ingroup elf +*/ +/** + * ** ** Started on Sat Feb 22 17:06:17 2003 jfv ** ** -** $Id: findrel.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +** $Id: findrel.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -151,7 +155,7 @@ { /* Do not look for cross references on unmapped or void sections */ - data = elfsh_get_raw(cur); + data = elfsh_readmem(cur); if (data == NULL) { if (!world.state.revm_quiet) diff -Nru eresi-0.8a25/libstderesi/elf/flush.c eresi-0.0.20110516/libstderesi/elf/flush.c --- eresi-0.8a25/libstderesi/elf/flush.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/flush.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,5 +1,9 @@ /** -** @file flush.c +* @file libstderesi/elf/flush.c +** @ingroup elf +*/ +/** + * ** ** @brief Flush the binary of any injected section ** Restore the original PLT @@ -8,7 +12,7 @@ ** Started on Nov 24 2003 jfv ** ** -** $Id: flush.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +** $Id: flush.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" @@ -32,7 +36,7 @@ plt = elfsh_get_plt(world.curjob->curfile, NULL); origplt = world.curjob->curfile->secthash[ELFSH_SECTION_ALTPLT]; if (origplt && plt) - memcpy(elfsh_get_raw(plt), elfsh_get_raw(origplt), plt->shdr->sh_size); + memcpy(elfsh_readmem(plt), elfsh_readmem(origplt), plt->shdr->sh_size); /* Remove pre-interp injected sections */ interp = elfsh_get_segment_by_type(world.curjob->curfile, PT_INTERP, 0); diff -Nru eresi-0.8a25/libstderesi/elf/got.c eresi-0.0.20110516/libstderesi/elf/got.c --- eresi-0.8a25/libstderesi/elf/got.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/got.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,17 +1,15 @@ /** -** @file got.c -** -** Started on Fri Nov 2 15:20:18 2001 jfv -** -** -** $Id: got.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ + * @file libstderesi/elf/got.c + * @ingroup elf + * + * Started on Fri Nov 2 15:20:18 2001 jfv + * + * $Id: got.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ #include "libstderesi.h" - - -/** +/** * Command handler for GOT command */ int cmd_got() @@ -42,7 +40,7 @@ for (index2 = 0; got; index2++) { - data = elfsh_get_raw(got); + data = elfsh_readmem(got); snprintf(logbuf, BUFSIZ - 1, " [Global Offset Table .::. GOT : %s ]\n [Object %s]\n\n", elfsh_get_section_name(world.curjob->curfile, got), @@ -61,7 +59,6 @@ revm_colorstr((offset < 0 ? "-" : "+")), revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); - snprintf(buff, sizeof(buff), "%s : %s %s \t <%s%s>\n", revm_coloraddress(XFMT, got->shdr->sh_addr + (index * sizeof(eresi_Addr))), revm_colornumber("[%02u]", index), diff -Nru eresi-0.8a25/libstderesi/elf/hash.c eresi-0.0.20110516/libstderesi/elf/hash.c --- eresi-0.8a25/libstderesi/elf/hash.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/hash.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,11 +1,15 @@ /** - * @file version.c +* @file libstderesi/elf/hash.c +** @ingroup elf +*/ +/** + * * * @brief Hash features * * Started on Sun Oct 07 10:20:18 2005 mxatone * - * $Id: hash.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: hash.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/hdr.c eresi-0.0.20110516/libstderesi/elf/hdr.c --- eresi-0.8a25/libstderesi/elf/hdr.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/hdr.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file elf.c for elfsh +* @file libstderesi/elf/hdr.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:21:14 2001 jfv * Last update Thu Mar 11 15:02:24 2004 jfv * - * $Id: hdr.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: hdr.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -90,9 +94,9 @@ char *enco; char *name; elfsh_SAddr offset; - char enco_unk[ELFSH_MEANING + 1]; - char type_unk[ELFSH_MEANING + 1]; - char arch_unk[ELFSH_MEANING + 1]; + char enco_unk[ERESI_MEANING + 1]; + char type_unk[ERESI_MEANING + 1]; + char arch_unk[ERESI_MEANING + 1]; u_int magic; char buf[BUFSIZ]; char logbuf[BUFSIZ]; @@ -134,7 +138,7 @@ enconum = elfsh_get_encoding(header); arch = (char *) (archnum >= ELFSH_ARCHTYPE_MAX ? revm_build_unknown(arch_unk, "type", archnum) : - elfsh_arch_type[archnum]); + elfsh_arch_type[archnum].desc); type = (char *) (typenum >= ELFSH_OBJTYPE_MAX ? revm_build_unknown(type_unk, "type", typenum) : elfsh_obj_type[typenum].desc); diff -Nru eresi-0.8a25/libstderesi/elf/interp.c eresi-0.0.20110516/libstderesi/elf/interp.c --- eresi-0.8a25/libstderesi/elf/interp.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/interp.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,14 @@ /** -** @file interp.c +* @file libstderesi/elf/interp.c +** @ingroup elf +*/ +/** + * ** ** Started on Fri Nov 2 15:20:41 2001 jfv ** Last update Wed Mar 10 12:21:34 2004 jfv ** -** $Id: interp.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +** $Id: interp.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/Makefile eresi-0.0.20110516/libstderesi/elf/Makefile --- eresi-0.8a25/libstderesi/elf/Makefile 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/Makefile 2011-05-16 11:35:05.000000000 +0000 @@ -13,27 +13,25 @@ CC ?= gcc LD ?= ld RM = rm -f -NAME32 = ../revm-elf.32.o -NAME64 = ../revm-elf.64.o +NAME32 = ../std-elf.32.o +NAME64 = ../std-elf.64.o -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../libetrace/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ -I../../libmjollnir/include/ -I../../libaspect/include/ \ -I../../libedfmt/include/ -I../../librevm/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ + $(STATOPT2) $(ASMOPT) -DERESI32 \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../libetrace/include/ \ -I../../libdump/include/ -I../../libasm/include/ \ -I/usr/pkg/include/ -I../../libaspect/include/ \ -I../../libui/include/ -I../../libmjollnir/include/ \ -I../../libedfmt/include/ -I../../librevm/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ + $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) all : all32 all64 diff -Nru eresi-0.8a25/libstderesi/elf/notes.c eresi-0.0.20110516/libstderesi/elf/notes.c --- eresi-0.8a25/libstderesi/elf/notes.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/notes.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** -** @file notes.c +* @file libstderesi/elf/notes.c +** @ingroup elf +*/ +/** + * ** ** Started on Fri Nov 2 15:20:58 2001 jfv ** ** -** $Id: notes.c,v 1.2 2008-02-16 12:32:27 thor Exp $ +** $Id: notes.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/libstderesi/elf/pht.c eresi-0.0.20110516/libstderesi/elf/pht.c --- eresi-0.8a25/libstderesi/elf/pht.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/pht.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file pht.c +* @file libstderesi/elf/pht.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:18:35 2001 jfv * * - * $Id: pht.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: pht.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -18,7 +22,7 @@ char *revm_display_pdesc(u_int type) { u_int idx; - char type_unk[ELFSH_MEANING + 1]; + char type_unk[ERESI_MEANING + 1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -90,7 +94,7 @@ addr = phdr[index].p_vaddr; addr_end = phdr[index].p_vaddr + phdr[index].p_memsz; - if (elfsh_is_debug_mode()) + if (elfsh_is_runtime_mode()) { addr_end += base; addr += base; diff -Nru eresi-0.8a25/libstderesi/elf/rel.c eresi-0.0.20110516/libstderesi/elf/rel.c --- eresi-0.8a25/libstderesi/elf/rel.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/rel.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file rel.c +* @file libstderesi/elf/rel.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:19:19 2001 jfv * * - * $Id: rel.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: rel.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -128,7 +132,7 @@ revm_output(logbuf); /* Iterate on the .rel entries array for each .rel section */ - data = elfsh_get_raw(sect); + data = elfsh_readmem(sect); for (index = 0; index < size; index++) { diff -Nru eresi-0.8a25/libstderesi/elf/sht.c eresi-0.0.20110516/libstderesi/elf/sht.c --- eresi-0.8a25/libstderesi/elf/sht.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/sht.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,10 +1,14 @@ /** - * @file sht.c +* @file libstderesi/elf/sht.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:17:58 2001 jfv * * - * $Id: sht.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: sht.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -49,7 +53,7 @@ char buff[BUFSIZ]; u_int index; elfsh_Word typenum; - char type_unk[ELFSH_MEANING + 1]; + char type_unk[ERESI_MEANING + 1]; eresi_Addr addr; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -82,7 +86,7 @@ /* Compute section address */ /* Base for ET_EXEC is always 0 */ - addr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(cur) ? + addr = (elfsh_is_runtime_mode() && !elfsh_section_is_runtime(cur) ? world.curjob->curfile->rhdr.base + elfsh_get_section_addr(shdr + index) : elfsh_get_section_addr(shdr + index)); diff -Nru eresi-0.8a25/libstderesi/elf/.svn/all-wcprops eresi-0.0.20110516/libstderesi/elf/.svn/all-wcprops --- eresi-0.8a25/libstderesi/elf/.svn/all-wcprops 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/950/trunk/libstderesi/elf -END -sht.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libstderesi/elf/sht.c -END -interp.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/843/trunk/libstderesi/elf/interp.c -END -comment.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/843/trunk/libstderesi/elf/comment.c -END -sym.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libstderesi/elf/sym.c -END -api.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libstderesi/elf/api.c -END -data.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/830/trunk/libstderesi/elf/data.c -END -hdr.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/888/trunk/libstderesi/elf/hdr.c -END -disasm.c -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/946/trunk/libstderesi/elf/disasm.c -END -flush.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/888/trunk/libstderesi/elf/flush.c -END -rel.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/888/trunk/libstderesi/elf/rel.c -END -findrel.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/888/trunk/libstderesi/elf/findrel.c -END -hash.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libstderesi/elf/hash.c -END -version.c -K 25 -svn:wc:ra_dav:version-url -V 49 -/svn/!svn/ver/888/trunk/libstderesi/elf/version.c -END -notes.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/843/trunk/libstderesi/elf/notes.c -END -core.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/888/trunk/libstderesi/elf/core.c -END -got.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libstderesi/elf/got.c -END -dyn.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/888/trunk/libstderesi/elf/dyn.c -END -ctors.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libstderesi/elf/ctors.c -END -dtors.c -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/946/trunk/libstderesi/elf/dtors.c -END -deps.c -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/946/trunk/libstderesi/elf/deps.c -END -pht.c -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/946/trunk/libstderesi/elf/pht.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/950/trunk/libstderesi/elf/Makefile -END diff -Nru eresi-0.8a25/libstderesi/elf/.svn/entries eresi-0.0.20110516/libstderesi/elf/.svn/entries --- eresi-0.8a25/libstderesi/elf/.svn/entries 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,292 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libstderesi/elf -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -sht.c -file - - - - -2008-04-06T23:16:28.668137Z -033abdbd2ffa122d6998b868cce449ff -2008-03-27T22:53:48.747992Z -946 -may - -interp.c -file - - - - -2008-04-06T23:16:28.709913Z -57d94f5f4f8bc2881c447ba7c677d919 -2008-02-16T12:32:28.000000Z -843 -thor - -comment.c -file - - - - -2008-04-06T23:16:28.721255Z -4a78b8090b3df28e04adc53aea262f38 -2008-02-16T12:32:28.000000Z -843 -thor - -sym.c -file - - - - -2008-04-06T23:16:28.732541Z -63b9c1a732deb60f04444234f1003381 -2008-03-27T22:53:48.747992Z -946 -may - -api.c -file - - - - -2008-04-06T23:16:28.754899Z -2754cc8ea8eb69ea8a5a81ff5740f8dc -2008-03-27T22:53:48.747992Z -946 -may - -data.c -file - - - - -2008-04-06T23:16:28.743881Z -7e4fd3ad72247935c6f59b738bc584d3 -2007-11-29T14:01:56.000000Z -830 -may - -hdr.c -file - - - - -2008-04-06T23:16:28.765999Z -88a17866be72bcfa7ff32c194f43ef65 -2008-03-05T10:52:59.732613Z -888 -enioh - -disasm.c -file - - - - -2008-04-06T23:16:28.778027Z -3d27af94603de3beddde41be50b684b6 -2008-03-27T22:53:48.747992Z -946 -may - -flush.c -file - - - - -2008-04-06T23:16:28.789333Z -fd020ef01fab8c52563a1a242ec2a00c -2008-03-05T10:52:59.732613Z -888 -enioh - -rel.c -file - - - - -2008-04-06T23:16:28.800173Z -5dea85d79ff5c260750da7ebf69e833f -2008-03-05T10:52:59.732613Z -888 -enioh - -findrel.c -file - - - - -2008-04-06T23:16:28.824899Z -342427b54fd45c199709cca343355094 -2008-03-05T10:52:59.732613Z -888 -enioh - -hash.c -file - - - - -2008-04-06T23:16:28.813561Z -8ca553eb8aff10564cabd6f7396165ba -2008-03-27T22:53:48.747992Z -946 -may - -version.c -file - - - - -2008-04-06T23:16:28.836304Z -7c68888ac7e0c728c4d88f7c51a7e415 -2008-03-05T10:52:59.732613Z -888 -enioh - -notes.c -file - - - - -2008-04-06T23:16:28.858988Z -ac2a5d7373d7c9833d6084af3d3e87cf -2008-02-16T12:32:28.000000Z -843 -thor - -core.c -file - - - - -2008-04-06T23:16:28.847645Z -b0e28e0fc4e92798f5df9800bdeb32d5 -2008-03-05T10:52:59.732613Z -888 -enioh - -got.c -file - - - - -2008-04-06T23:16:28.870331Z -f061f6dc3726ae2fbc1f21083abfddd8 -2008-03-27T22:53:48.747992Z -946 -may - -dyn.c -file - - - - -2008-04-06T23:16:28.881733Z -72db2f7ec0aed2760e1d9162010c4b6f -2008-03-05T10:52:59.732613Z -888 -enioh - -ctors.c -file - - - - -2008-04-06T23:16:28.892899Z -7633c7abff5041e94c075ecab419e0f2 -2008-03-27T22:53:48.747992Z -946 -may - -dtors.c -file - - - - -2008-04-06T23:16:28.904361Z -b6a6f9d608ff878a542fa238fe746cf9 -2008-03-27T22:53:48.747992Z -946 -may - -deps.c -file - - - - -2008-04-06T23:16:28.914883Z -c33cbb593d9f4882d4ceccefddd1cd26 -2008-03-27T22:53:48.747992Z -946 -may - -pht.c -file - - - - -2008-04-06T23:16:28.927045Z -1767281b5e8b6da050d503f36d78ee34 -2008-03-27T22:53:48.747992Z -946 -may - -Makefile -file - - - - -2008-04-06T23:16:28.938142Z -2262fa5b5a8276eb1bf9cd5bb9285e96 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/format eresi-0.0.20110516/libstderesi/elf/.svn/format --- eresi-0.8a25/libstderesi/elf/.svn/format 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/api.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/api.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/api.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/api.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * @file api.c - * - * This file contain the ELF specific vm-level API - * - * Started on Sat Jan 25 07:48:41 2003 jfv - * - * $Id: api.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * -*/ -#include "libstderesi.h" - -/** - * Get the parent object of a breakpoint - * Thats needed for the mprotect stuff inside the breakpoint handler - * @param addr - */ -elfshobj_t *revm_get_parent_object(eresi_Addr addr) -{ - elfsh_Phdr *cur; - elfshobj_t *curfile; - elfshsect_t *cursect; - char **keys; - int index; - int keynbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - keys = hash_get_keys(&world.curjob->loaded, &keynbr); - for (index = 0; index < keynbr; index++) - { - curfile = hash_get(&world.curjob->loaded, keys[index]); - cursect = elfsh_get_parent_section(curfile, addr, NULL); - if (cursect) - { - cur = elfsh_get_parent_segment(curfile, cursect); - if (cur) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, curfile); - } - } - - /* Parent object not found */ - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get parent object addr", (NULL)); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/comment.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/comment.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/comment.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/comment.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * @file comment.c - * - * Made by - * - * Started on Tue Dec 17 06:43:01 2002 jfv - * - * - * $Id: comment.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * @brief Display the note section - */ -int cmd_comments() -{ - elfshsect_t *sect; - regex_t *tmp; - int range; - char buff[256]; - char *ent; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - revm_output("\n [SHT_COMMENT]\n"); - sect = elfsh_get_comments(world.curjob->curfile); - if (!sect) - RET(-1); - FIRSTREGX(tmp); - - ent = elfsh_get_comments_entry(world.curjob->curfile, 0); - for (range = 0; ent != NULL; range++) - { - snprintf(buff, sizeof(buff), - " [%02u] \t COMMENT ENTRY: %s\n", range, ent); - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - ent = elfsh_get_comments_entry(world.curjob->curfile, range + 1); - } - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/core.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/core.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/core.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/core.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,127 +0,0 @@ -/** - * notes.c for elfsh - * @file notes.c - * Started on Fri Jan 26 21:00:33 BRST 2007 - * - * - * $Id: core.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - -/** - * Return string associated to a signal - * @param sig - * @return A string describing a signal. - */ -char *get_signal(int sig) -{ - switch(sig) - { - case 1: return "SIGHUP"; case 2: return "SIGINT"; - case 3: return "SIGQUIT"; case 4: return "SIGILL"; - case 5: return "SIGTRAP"; case 6: return "SIGABRT"; - case 7: return "SIGBUS"; case 8: return "SIGFPE"; - case 9: return "SIGKILL"; case 10: return "SIGUSR1"; - case 11: return "SIGSEGV"; case 12: return "SIGUSR2"; - case 13: return "SIGPIPE"; case 14: return "SIGALRM"; - case 15: return "SIGTERM"; case 16: return "SIGSTKFLT"; - case 17: return "SIGCHLD"; case 18: return "SIGCONT"; - case 19: return "SIGSTOP"; case 20: return "SIGTSTP"; - case 21: return "SIGTTIN"; case 22: return "SIGTTOU"; - case 23: return "SUGURG"; case 24: return "SIGXCPU"; - case 25: return "SIGXFSZ"; case 26: return "SIGVTALRM"; - case 27: return "SIGPROF"; case 28: return "SIGWINCH"; - case 29: return "SIGIO"; case 30: return "SIGPWR"; - case 31: return "SIGSYS"; default: return "SIG_UNKNOWN"; - } - return NULL; -} - -/** - * display info about the core file - */ -int cmd_coreinfo() -{ - char buff[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - snprintf(buff,sizeof(buff)," [CORE FILE NOTES_ENTRY]\n [Object %s | %s]\n\n", - world.curjob->curfile->name, - world.curjob->curfile->coretype == ELFSH_CORE_LINUX ? - "Linux":"FreeBSD"); - - revm_output(buff); - - switch(world.curjob->curfile->coretype) - { - case ELFSH_CORE_LINUX: - { - elfsh_prstatus_t *ps; - elfsh_prpsinfo_t *pr; - elfsh_uregset_t regs; - - ps = &world.curjob->curfile->core.prstatus; - pr = &world.curjob->curfile->core.prpsinfo; - - snprintf(buff, sizeof(buff), " Received Signal: %d (%s)\n\n", - ps->pr_cursig, get_signal(ps->pr_cursig)); - revm_output(buff); - - regs = *((elfsh_uregset_t *)(&ps->pr_reg)); - - snprintf(buff, sizeof(buff), " [ FILE INFO ]\n"); - revm_output(buff); - - snprintf(buff, sizeof(buff), - " Executable filename: %s\n UID: %d\tGID: %d\n PID: %d\n\n", - pr->pr_fname, pr->pr_uid, pr->pr_gid, ps->pr_pid); - revm_output(buff); - - snprintf(buff, sizeof(buff), " [ REGISTERS INFO ]\n"); - revm_output(buff); - - snprintf(buff, sizeof(buff), - " EAX: %08x\n EBX: %08x\n ECX: %08x\n EDX: %08x\n", - (u_int)regs.eax, (u_int)regs.ebx, (u_int)regs.ecx, - (u_int)regs.edx); - revm_output(buff); - - snprintf(buff, sizeof(buff), - " ESP: %08x\n ESI: %08x\n EDI: %08x\n EIP: %08x\n" - " EFLAGS: %08x\n\n", - (u_int)regs.esp, (u_int)regs.esi, (u_int)regs.edi, - (u_int)regs.eip, (u_int)regs.eflags); - - revm_output(buff); - } - break; - - case ELFSH_CORE_FREEBSD: - { - elfsh_bsdprstatus_t *ps; - elfsh_bsdprpsinfo_t *pr; - elfsh_bsduregset_t regs; - - ps = &world.curjob->curfile->bsdcore.prstatus; - pr = &world.curjob->curfile->bsdcore.prpsinfo; - - snprintf(buff, sizeof(buff), " Received Signal: %d (%s)\n\n", - ps->pr_cursig, get_signal(ps->pr_cursig)); - revm_output(buff); - - regs = *((elfsh_bsduregset_t *)(&ps->pr_reg)); - snprintf(buff, sizeof(buff), " [ FILE INFO ]\n"); - revm_output(buff); - - snprintf(buff, sizeof(buff), " Executable filename: %s\n PID: %d\n\n", - pr->pr_fname, ps->pr_pid); - revm_output(buff); - - snprintf(buff, sizeof(buff), " [ REGISTERS INFO ]\n"); - revm_output(buff); - } - break; - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/ctors.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/ctors.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/ctors.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/ctors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/** - * @file ctors.c - * - * Started on Tue Feb 26 22:07:58 2002 jfv - * - * - * $Id: ctors.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * -*/ -#include "libstderesi.h" - - - - -/** - * Display the constructor section - */ -int cmd_ctors() -{ - regex_t *tmp; - eresi_Addr *ctors; - int size; - int index; - elfsh_SAddr offset; - elfsh_SAddr doffset; - char *name; - char *dname; - char off[50]; - char buff[256]; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - ctors = elfsh_get_ctors(world.curjob->curfile, &size); - if (ctors == NULL) - RET(-1); - FIRSTREGX(tmp); - snprintf(logbuf, BUFSIZ - 1, - " [Constructors array .::. CTORS]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - off[0] = 0; - - for (index = 0; index < size; index++) - { - - name = elfsh_reverse_symbol(world.curjob->curfile, ctors[index], &offset); - dname = elfsh_reverse_dynsymbol(world.curjob->curfile, ctors[index], &doffset); - if (dname && doffset < offset) - { - name = dname; - offset = doffset; - } - - if (off) - snprintf(off, sizeof(off), " %s %s", - revm_colorstr((offset < 0 ? "-" : "+")), - revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); - - snprintf(buff, sizeof(buff), " %s %s \t <%s%s>\n", - revm_colornumber("[%02u]", index), - revm_coloraddress(XFMT, (eresi_Addr) ctors[index]), - (name ? revm_colorstr(name) : revm_colorwarn("?")), - (name && offset ? off : "")); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - - revm_endline(); - } - - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/data.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/data.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/data.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/data.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,998 +0,0 @@ -/** - * @file data.c - * - * Started on Mon Feb 26 04:06:38 2001 jfv - * Last update Wed Mar 10 12:14:24 2004 jfv - * - * $Id: data.c,v 1.1 2007-11-29 14:01:56 may Exp $ - * - */ -#include "libstderesi.h" - - -revmconst_t asm_instr_type[] = - { - {"Undefined instruction" , "ASM_TYPE_NONE" , ASM_TYPE_NONE}, - {"Branch-always instruction" , "ASM_TYPE_IMPBRANCH" , ASM_TYPE_IMPBRANCH}, - {"Conditionnal branching instruction" , "ASM_TYPE_CONDBRANCH", ASM_TYPE_CONDBRANCH}, - {"Procedure calling instruction" , "ASM_TYPE_CALLPROC" , ASM_TYPE_CALLPROC}, - {"Return instruction" , "ASM_TYPE_RETPROC" , ASM_TYPE_RETPROC}, - {"Arithmetic (or logic) instruction" , "ASM_TYPE_ARITH" , ASM_TYPE_ARITH}, - {"Instruction that reads from memory" , "ASM_TYPE_LOAD" , ASM_TYPE_LOAD}, - {"Instruction that writes in memory" , "ASM_TYPE_STORE" , ASM_TYPE_STORE}, - {"Architecture dependent instruction" , "ASM_TYPE_ARCH" , ASM_TYPE_ARCH}, - {"Flag-modifier instruction" , "ASM_TYPE_WRITEFLAG" , ASM_TYPE_WRITEFLAG}, - {"Flag-reader instruction" , "ASM_TYPE_READFLAG" , ASM_TYPE_READFLAG}, - {"Interrupt/call-gate instruction" , "ASM_TYPE_INT" , ASM_TYPE_INT}, - {"Assignment instruction" , "ASM_TYPE_ASSIGN" , ASM_TYPE_ASSIGN}, - {"Comparison or test instruction" , "ASM_TYPE_COMPARISON", ASM_TYPE_COMPARISON}, - {"Instruction modifies control registers", "ASM_TYPE_CONTROL" , ASM_TYPE_CONTROL}, - {"Instruction that does nothing" , "ASM_TYPE_NOP" , ASM_TYPE_NOP}, - {"Type that doesn't fit the ones above" , "ASM_TYPE_OTHER" , ASM_TYPE_OTHER}, - {"Instruction modifies stack pointer" , "ASM_TYPE_TOUCHSP" , ASM_TYPE_TOUCHSP}, - {"Bit Testing Instruction" , "ASM_TYPE_BITTEST" , ASM_TYPE_BITTEST}, - {"Bit Setting Instruction" , "ASM_TYPE_BITSET" , ASM_TYPE_BITSET}, - {"Instruction increment or decrement" , "ASM_TYPE_INCDEC" , ASM_TYPE_INCDEC}, - {"Instruction creates function prolog" , "ASM_TYPE_PROLOG" , ASM_TYPE_PROLOG}, - {"Instruction creates function epilog" , "ASM_TYPE_EPILOG" , ASM_TYPE_EPILOG}, - {"Instruction stops the program" , "ASM_TYPE_STOP" , ASM_TYPE_STOP}, - }; - - -/** - * Architecture-independant operand types - * - */ -revmconst_t asm_operand_type[] = - { - {"Undefined operand type" , "ASM_OPTYPE_NONE", ASM_OPTYPE_NONE}, - {"Immediate operand type" , "ASM_OPTYPE_IMM", ASM_OPTYPE_IMM}, - {"Register operand type" , "ASM_OPTYPE_REG", ASM_OPTYPE_REG}, - {"Memory access operand type", "ASM_OPTYPE_MEM", ASM_OPTYPE_MEM}, - }; - - -/** - * Program header (segment) entry strings - */ -revmconst_t elfsh_seg_type[] = -{ - {"NULL segment" , "PT_NULL" , PT_NULL}, - {"Loadable segment" , "PT_LOAD" , PT_LOAD}, - {"Dynamic linking info" , "PT_DYNAMIC", PT_DYNAMIC}, - {"Program interpreter" , "PT_INTERP" , PT_INTERP}, - {"Auxiliary information", "PT_NOTE" , PT_NOTE}, - {"Reserved" , "PT_SHLIB" , PT_SHLIB}, - {"Program header table" , "PT_PHDR" , PT_PHDR}, -}; - -/** - * Extended program header types - */ -revmconst_t elfsh_extseg_type[] = -{ - {"Stack flags" , "PT_GNU_STACK" , PT_GNU_STACK}, - {"Read-only after relocation", "PT_GNU_RELRO" , PT_GNU_RELRO}, - {"New PaX flags" , "PT_PAX_FLAGS" , PT_PAX_FLAGS}, - {"GCC .eh_frame_hdr" , "PT_GNU_EH_FRAME", PT_GNU_EH_FRAME}, - {"MIPS Registers informations" , "PT_MIPS_REGINFO", PT_MIPS_REGINFO}, -}; - - - - -/** - * Encoding type in ELF header - */ -revmconst_t elfsh_encoding[] = -{ - {"Invalid encoding", "ELFDATANONE", ELFDATANONE}, - {"Little endian" , "ELFDATA2LSB", ELFDATA2LSB}, - {"Big endian" , "ELFDATA2MSB", ELFDATA2MSB}, -}; - - -/** - * Section type strings - */ -revmconst_t elfsh_sh_type[] = -{ - {"NULL section" , "SHT_NULL" , SHT_NULL}, - {"Program data" , "SHT_PROGBITS", SHT_PROGBITS}, - {"Symbol table" , "SHT_SYMTAB" , SHT_SYMTAB}, - {"String table" , "SHT_STRTAB" , SHT_STRTAB}, - {"Reloc. ent. w/ addends" , "SHT_RELA" , SHT_RELA}, - {"Symbol hash table" , "SHT_HASH" , SHT_HASH}, - {"Dynamic linking info" , "SHT_DYNAMIC" , SHT_DYNAMIC}, - {"Notes" , "SHT_NOTES" , SHT_NOTE}, - {"BSS" , "SHT_NOBITS" , SHT_NOBITS}, - {"Reloc. ent. w/o addends", "SHT_REL" , SHT_REL}, - {"Reserved" , "SHT_SHLIB" , SHT_SHLIB}, - {"Dynamic linker symtab" , "SHT_DYNSYM" , SHT_DYNSYM}, - {"MIPS Registers Information", "SHT_MIPS_REGINFO", SHT_MIPS_REGINFO}, - {"Version definition section", "SHT_GNU_verdef", SHT_GNU_verdef}, - {"Version needs section" , "SHT_GNU_verneed", SHT_GNU_verneed}, - {"Version symbol table" , "SHT_GNU_versym" , SHT_GNU_versym}, -}; - - -/** - * ELF object type strings - */ -revmconst_t elfsh_obj_type[] = -{ - {"Unknown" , "ET_NONE", ET_NONE}, - {"Relocatable object" , "ET_REL" , ET_REL}, - {"Executable object" , "ET_EXEC", ET_EXEC}, - {"Shared object" , "ET_DYN" , ET_DYN}, - {"Core file" , "ET_CORE", ET_CORE}, -}; - -/** - * Symbol Binding strings - */ -revmconst_t elfsh_sym_bind[] = -{ - {"Local" , "STB_LOCAL" , STB_LOCAL}, - {"Global" , "STB_GLOBAL" , STB_GLOBAL}, - {"Weak" , "STB_WEAK" , STB_WEAK}, -}; - - -/** - * Symbol Type strings - */ -revmconst_t elfsh_sym_type[] = -{ - {"NOTYPE" , "STT_NOTYPE" , STT_NOTYPE}, - {"VARIABLE", "STT_OBJECT" , STT_OBJECT}, - {"FUNCTION", "STT_FUNC" , STT_FUNC}, - {"SECTION" , "STT_SECTION", STT_SECTION}, - {"FILENAME", "STT_FILE" , STT_FILE}, - {"COMMON" , "STT_COMMON" , STT_COMMON}, - {"TLS" , "STT_TLS" , STT_TLS}, - {"BLOCK" , "STT_BLOCK" , STT_BLOCK}, -}; - - -/** - * Version entry type strings -*/ -revmconst_t elfsh_verentry_type[] = -{ - {"NONE" , "ELFSH_VERTYPE_NONE" , ELFSH_VERTYPE_NONE}, - {"UNKNOWN" , "ELFSH_VERTYPE_UNK" , ELFSH_VERTYPE_UNK}, - {"NEED" , "ELFSH_VERTYPE_NEED" , ELFSH_VERTYPE_NEED}, - {"DEF" , "ELFSH_VERTYPE_DEF" , ELFSH_VERTYPE_DEF}, -}; - - -/** - * Dynamic section entry type strings - */ -revmconst_t elfsh_dynentry_type[] = -{ - {"END OF DYNAMIC SECTION" , "DT_NULL" , DT_NULL}, - {"Name of needed library" , "DT_NEEDED" , DT_NEEDED}, - {"Size in bytes for .rel.plt" , "DT_PLTRELSZ" , DT_PLTRELSZ}, - {"Processor defined value" , "DT_PLTGOT" , DT_PLTGOT}, - {"Address of symbol hash table" , "DT_HASH" , DT_HASH}, - {"Address of dynamic string table" , "DT_STRTAB" , DT_STRTAB}, - {"Address of dynamic symbol table" , "DT_SYMTAB" , DT_SYMTAB}, - {"Address of relocs info w/ add-end", "DT_RELA" , DT_RELA}, - {"Totsize of relocs info w/ add-end", "DT_RELASZ" , DT_RELASZ}, - {"Size of RELA entry" , "DT_RELAENT" , DT_RELAENT}, - {"Size of string table" , "DT_STRSZ" , DT_STRSZ}, - {"Size of symbol table entry" , "DT_SYMENT" , DT_SYMENT}, - {"Address of init function" , "DT_INIT" , DT_INIT}, - {"Address of fini function" , "DT_FINI" , DT_FINI}, - {"Name of shared object" , "DT_SONAME" , DT_SONAME}, - {"Library search path" , "DT_RPATH" , DT_RPATH}, - {"Start symbol search here" , "DT_SYMBOLIC" , DT_SYMBOLIC}, - {"Address of .rel.got section" , "DT_REL" , DT_REL}, - {"Total size of .rel section" , "DT_RELSZ" , DT_RELSZ}, - {"Size of a REL entry" , "DT_RELENT" , DT_RELENT}, - {"Type of reloc in PLT" , "DT_PLTREL" , DT_PLTREL}, - {"Debugging entry (unknown)" , "DT_DEBUG" , DT_DEBUG}, - {"Reloc might modify .text" , "DT_TEXTREL" , DT_TEXTREL}, - {"Address of .rel.plt" , "DT_JMPREL" , DT_JMPREL}, - {"Process relocations of object" , "DT_BIND_NOW" , DT_BIND_NOW}, - {"Array with addresses of init fct" , "DT_INIT_ARRAY" , DT_INIT_ARRAY}, - {"Array with addresses of fini fct" , "DT_FINI_ARRAY" , DT_FINI_ARRAY}, - {"Size in bytes of DT_INIT_ARRAY" , "DT_INIT_ARRAYSZ", DT_INIT_ARRAYSZ}, - {"Size in bytes of DT_FINI_ARRAY" , "DT_FINI_ARRAYSZ", DT_FINI_ARRAYSZ}, - {"Library search path" , "DT_RUNPATH" , DT_RUNPATH}, - {"Flags for the object being loaded", "DT_FLAGS" , DT_FLAGS}, - {"Start of encoded range" , "DT_ENCODING" , DT_ENCODING}, - {"Pre-init function addresses array", "DT_PREINIT_ARRAY", DT_PREINIT_ARRAY}, - {"Size in bytes of DT_PREINIT_ARRAY", "DT_PREINIT_ARRAYSZ", DT_PREINIT_ARRAYSZ}, - {"Number used" , "DT_NUM" , DT_NUM}, -}; - - -/** - * Extended dynamic types - */ -revmconst_t elfsh_extdyn_type[] = -{ - {"Feature selection" , "DT_FEATURE_1" , DT_FEATURE_1}, - {"DT entries flags" , "DT_POSFLAG_1" , DT_POSFLAG_1}, - {"Syminfo table size" , "DT_SYMINSZ" , DT_SYMINSZ}, - {"Syminfo entry size" , "DT_SYMINENT" , DT_SYMINENT}, - {"Syminfo table" , "DT_SYMINFO" , DT_SYMINFO}, - {"GNU version VERSYM" , "DT_VERSYM" , DT_VERSYM}, - {"GNU version RELACCOUNT" , "DT_RELACOUNT" , DT_RELACOUNT}, - {"GNU version RELCOUNT" , "DT_RELCOUNT" , DT_RELCOUNT}, - {"State flags" , "DT_FLAGS_1" , DT_FLAGS_1}, - {"SUN version table address" , "DT_VERDEF" , DT_VERDEF}, - {"SUN version table number" , "DT_VERDEFNUM" , DT_VERDEFNUM}, - {"SUN needed version table" , "DT_VERNEED" , DT_VERNEED}, - {"SUN needed version number" , "DT_VERNEEDNUM", DT_VERNEEDNUM}, - {"Shared object to load before self", "DT_AUXILIARY" , DT_AUXILIARY}, - {"Shared object to get values from" , "DT_FILTER" , DT_FILTER}, - {"[?]" , "DT_CHECKSUM" , DT_CHECKSUM}, - {"[?]" , "DT_PLTPADSZ" , DT_PLTPADSZ}, - {"[?]" , "DT_MOVEENT" , DT_MOVEENT}, - {"[?]" , "DT_MOVESZ" , DT_MOVESZ}, -}; - -/** - * MIPS dynamic types - */ -revmconst_t elfsh_mipsdyn_type[] = -{ - {"Runtime linker interface version" , "DT_MIPS_RLD_VERSION" , DT_MIPS_RLD_VERSION}, - {"Timestamp" , "DT_MIPS_TIME_STAMP" , DT_MIPS_TIME_STAMP}, - {"Checksum" , "DT_MIPS_ICHECKSUM" , DT_MIPS_ICHECKSUM}, - {"Version string (string tbl index)", "DT_MIPS_IVERSION" , DT_MIPS_IVERSION}, - {"Flags" , "DT_MIPS_FLAGS" , DT_MIPS_FLAGS}, - {"Base address" , "DT_MIPS_BASE_ADDRESS" , DT_MIPS_BASE_ADDRESS}, - {"[?]" , "DT_MIPS_MSYM" , DT_MIPS_MSYM}, - {"Address of CONFLICT section" , "DT_MIPS_CONFLICT" , DT_MIPS_CONFLICT}, - {"Address of LIBLIST section" , "DT_MIPS_LIBLIST" , DT_MIPS_LIBLIST}, - {"Number of local GOT entries" , "DT_MIPS_LOCAL_GOTNO" , DT_MIPS_LOCAL_GOTNO}, - {"Number of CONFLICT entries" , "DT_MIPS_CONFLICTNO" , DT_MIPS_CONFLICTNO}, - {"Number of LIBLIST entries" , "DT_MIPS_LIBLISTNO" , DT_MIPS_LIBLISTNO}, - {"Number of DYNSYM entries" , "DT_MIPS_SYMTABNO" , DT_MIPS_SYMTABNO}, - {"First external DYNSYM" , "DT_MIPS_UNREFEXTNO" , DT_MIPS_UNREFEXTNO}, - {"First GOT entry in DYNSYM" , "DT_MIPS_GOTSYM" , DT_MIPS_GOTSYM}, - {"Number of GOT page table entries" , "DT_MIPS_HIPAGENO" , DT_MIPS_HIPAGENO}, - {"Address of run time loader map." , "DT_MIPS_RLD_MAP" , DT_MIPS_RLD_MAP}, - {"Delta C++ class definition" , "DT_MIPS_DELTA_CLASS" , DT_MIPS_DELTA_CLASS}, - {"Number of entries in DT_MIPS_DELTA_CLASS" - , "DT_MIPS_DELTA_CLASS_NO", DT_MIPS_DELTA_CLASS_NO}, - {"Delta C++ class instances" , "DT_MIPS_DELTA_INSTANCE", DT_MIPS_DELTA_INSTANCE}, - {"Number of entries in DT_MIPS_DELTA_INSTANCE" - , "DT_MIPS_DELTA_INSTANCE_NO" - , DT_MIPS_DELTA_INSTANCE_NO}, - {"Delta relocations", "DT_MIPS_DELTA_RELOC" , DT_MIPS_DELTA_RELOC}, - {"Number of entries in DT_MIPS_DELTA_RELOC", "DT_MIPS_DELTA_RELOC_NO" - , DT_MIPS_DELTA_RELOC_NO}, - {"Delta symbols that Delta relocations refer to" - , "DT_MIPS_DELTA_SYM" , DT_MIPS_DELTA_SYM}, - {"Number of entries in DT_MIPS_DELTA_SYM" - , "DT_MIPS_DELTA_SYM_NO" , DT_MIPS_DELTA_SYM_NO}, - {"Delta symbols that hold the class declaration" - , "DT_MIPS_DELTA_CLASSSYM", DT_MIPS_DELTA_CLASSSYM}, - {"Number of entries in DT_MIPS_DELTA_CLASSSYM" - , "DT_MIPS_DELTA_CLASSSYM_NO" - , DT_MIPS_DELTA_CLASSSYM_NO}, - {"Flags indicating for C++ flavor" , "DT_MIPS_CXX_FLAGS" , DT_MIPS_CXX_FLAGS}, - {"[?]" , "DT_MIPS_PIXIE_INIT" , DT_MIPS_PIXIE_INIT}, - {"[?]" , "DT_MIPS_SYMBOL_LIB" , DT_MIPS_SYMBOL_LIB}, - {"[?]" , "DT_MIPS_LOCALPAGE_GOTIDX" - , DT_MIPS_LOCALPAGE_GOTIDX}, - {"[?]" , "DT_MIPS_LOCAL_GOTIDX" , DT_MIPS_LOCAL_GOTIDX}, - {"[?]" , "DT_MIPS_HIDDEN_GOTIDX" , DT_MIPS_HIDDEN_GOTIDX}, - {"[?]" , "DT_MIPS_PROTECTED_GOTIDX" - , DT_MIPS_PROTECTED_GOTIDX}, - {"Address of .options" , "DT_MIPS_OPTIONS" , DT_MIPS_OPTIONS}, - {"Address of .interface" , "DT_MIPS_INTERFACE" , DT_MIPS_INTERFACE}, - {"[?]" , "DT_MIPS_DYNSTR_ALIGN" , DT_MIPS_DYNSTR_ALIGN}, - {"Size of the .interface section" , "DT_MIPS_INTERFACE_SIZE", DT_MIPS_INTERFACE_SIZE}, - {"Address of rld_text_rsolve function stored in GOT" - , "DT_MIPS_RLD_TEXT_RESOLVE_ADDR" - , DT_MIPS_RLD_TEXT_RESOLVE_ADDR}, - {"Default suffix of dso to be added by rld on dlopen() calls" - , "DT_MIPS_PERF_SUFFIX" , DT_MIPS_PERF_SUFFIX}, - {"(O32)Size of compact rel section" , "DT_MIPS_COMPACT_SIZE" , DT_MIPS_COMPACT_SIZE}, - {"GP value for aux GOTs" , "DT_MIPS_GP_VALUE" , DT_MIPS_GP_VALUE}, - {"Address of aux .dynamic" , "DT_MIPS_AUX_DYNAMIC" , DT_MIPS_AUX_DYNAMIC}, -}; - - -/** - * The next 4 arrays are special flag based DT entries - */ -/** - * Enumeration of '<< 1' increment - */ -revmconst_t elfsh_feature1[] = -{ - {"Option 1: PARINIT(?)", "DTF_1_PARINIT", DTF_1_PARINIT}, - {"Option 2: CONFEXP(?)", "DTF_1_CONFEXP", DTF_1_CONFEXP}, -}; - - -revmconst_t elfsh_posflag1[] = -{ - {"Lazyload following object" , "DF_P1_LAZYLOAD" , DF_P1_LAZYLOAD}, - {"Next object symbols maybe not available", "DF_P1_GROUPPERM", DF_P1_GROUPPERM}, -}; - -revmconst_t elfsh_flags[] = -{ - {"Object may use DF_ORIGIN" , "DF_ORIGIN" , DF_ORIGIN}, - {"Symbol resolutions starts here" , "DF_SYMBOLIC", DF_SYMBOLIC}, - {"Object contains text relocations", "DF_TEXTREL" , DF_TEXTREL}, - {"No lazy binding for this object" , "DF_BIND_NOW", DF_BIND_NOW}, -}; - -revmconst_t elfsh_flags1[] = -{ - {"Set RTLD_NOW for this object" , "DF_1_NOW" , DF_1_NOW}, - {"Set RTLD_GLOBAL for this object" , "DF_1_GLOBAL" , DF_1_GLOBAL}, - {"Set RTLD_GROUP for this object" , "DF_1_GROUP" , DF_1_GROUP}, - {"Set RTLD_NODELETE for this object" , "DF_1_NODELETE" , DF_1_NODELETE}, - {"Trigger filtee loading at runtime" , "DF_1_LOADFLTR" , DF_1_LOADFLTR}, - {"Set RTLD_INITFIRST for this object", "DF_1_INITFIRST", DF_1_INITFIRST}, - {"Set RTLD_NOOPEN for this object" , "DF_1_NOOPEN" , DF_1_NOOPEN}, - {"$ORIGIN must be handled" , "DF_1_ORIGIN" , DF_1_ORIGIN}, - {"Direct binding enabled" , "DF_1_DIRECT" , DF_1_DIRECT}, - {"Option 200: TRANS(?)" , "DF_1_TRANS" , DF_1_TRANS}, - {"Object is used to interpose" , "DF_1_INTERPOSE", DF_1_INTERPOSE}, - {"Ignore default lib search path" , "DF_1_NODEFLIB" , DF_1_NODEFLIB}, - {"Option 1000: NODUMP(?)" , "DF_1_NODUMP" , DF_1_NODUMP}, - {"Option 2000: CONFALT(?)" , "DF_1_CONFALT" , DF_1_CONFALT}, - {"Option 4000: ENDFILTEE(?)" , "DF_1_ENDFILTEE", DF_1_ENDFILTEE}, -}; - -/* mips DT_MIPSFLAGS flags */ -revmconst_t elfsh_mipsflags[] = -{ - {"No flags" , "RHF_NONE" , RHF_NONE}, - {"Use quickstart" , "RHF_QUICKSTART", RHF_QUICKSTART}, - {"Hash size not power of 2" , "RHF_NOTPOT" , RHF_NOTPOT}, - {"Ignore LD_LIBRARY_PATH" , "RHF_NO_LIBRARY_REPLACEMENT" - , RHF_NO_LIBRARY_REPLACEMENT}, - {"[?]" , "RHF_NO_MOVE" , RHF_NO_MOVE}, - {"[?]" , "RHF_SGI_ONLY" , RHF_SGI_ONLY}, - {"[?]" , "RHF_GUARANTEE_INIT" - , RHF_GUARANTEE_INIT}, - {"[?]" , "RHF_DELTA_C_PLUS_PLUS" - , RHF_DELTA_C_PLUS_PLUS}, - {"[?]" , "RHF_GUARANTEE_START_INIT" - , RHF_GUARANTEE_START_INIT}, - {"[?]" , "RHF_PIXIE" , RHF_PIXIE}, - {"[?]" , "RHF_DEFAULT_DELAY_LOAD" - , RHF_DEFAULT_DELAY_LOAD}, - {"[?]" , "RHF_REQUICKSTART" - , RHF_REQUICKSTART}, - {"[?]" , "RHF_REQUICKSTARTED" - , RHF_REQUICKSTARTED}, - {"[?]" , "RHF_CORD" , RHF_CORD}, - {"[?]" , "RHF_NO_UNRES_UNDEF" - , RHF_NO_UNRES_UNDEF}, - {"[?]" , "RHF_RLD_ORDER_SAFE" - , RHF_RLD_ORDER_SAFE}, - /* - // from http://www.iagu.net/docs/dec/AA-PS31D-TET1_html/asm10.html - - {"Object may be quickstarted by loader" , "RHF_QUICKSTART" , RHF_QUICKSTART}, - {"Hash size not a power of two " , "RHF_NOTPOT" , RHF_NOTPOT}, - {"[?]" , "RHF_NO_LIBRARY_", RHF_NO_LIBRARY_}, - {"Use default system libraries only" , "REPLACEMENT" , REPLACEMENT}, - {"Do not relocate" , "RHF_NO_MOVE" , RHF_NO_MOVE}, - {"Symbol resolution same as DT_SYMBOLIC", "RHF_RING_SEARCH", RHF_RING_SEARCH}, - {"Depth first symbol resolution " , "RHF_DEPTH_FIRST", RHF_DEPTH_FIRST}, - {"[?]" , "RHF_USE_31BIT_" , RHF_USE_31BIT_}, - {"TASO (Truncated Address Support Option) objects" - , "ADDRESSES" , ADDRESSES}, - */ -}; - -/** - * Relocation types strings - */ -revmconst_t elfsh_rel_type_i386[] = - { - {"No relocation" , "R_386_NONE" , R_386_NONE}, - {"Direct 32 bit" , "R_386_32" , R_386_32}, - {"Relative 32 bit" , "R_386_PC32" , R_386_PC32}, - {"32 bit GOT entry" , "R_386_GOT32" , R_386_GOT32}, - {"32 bit PLT entry" , "R_386_PLT32" , R_386_PLT32}, - {"Copy symbol at runtime" , "R_386_COPY" , R_386_COPY}, - {"Create GOT entry" , "R_386_GLOB_DAT", R_386_GLOB_DAT}, - {"Create PLT entry" , "R_386_JMP_SLOT", R_386_JMP_SLOT}, - {"Adjust by program base address" , "R_386_RELATIVE", R_386_RELATIVE}, - {"32 bit offset to GOT" , "R_386_GOTOFF" , R_386_GOTOFF}, - {"32 bit PC relative offset to GOT", "R_386_GOTPC" , R_386_GOTPC}, - }; - -/** - * Relocation types for itanium - */ -revmconst_t elfsh_rel_type_ia64[] = - { - {"none" , "R_IA64_NONE" , R_IA64_NONE}, - {"symbol + addend, add imm14" , "R_IA64_IMM14" , R_IA64_IMM14}, - {"symbol + addend, add imm22" , "R_IA64_IMM22" , R_IA64_IMM22}, - {"symbol + addend, mov imm64" , "R_IA64_IMM64" , R_IA64_IMM64}, - {"symbol + addend, data4 MSB" , "R_IA64_DIR32MSB" , R_IA64_DIR32MSB}, - {"symbol + addend, data4 LSB" , "R_IA64_DIR32LSB" , R_IA64_DIR32LSB}, - {"symbol + addend, data8 MSB" , "R_IA64_DIR64MSB" , R_IA64_DIR64MSB}, - {"symbol + addend, data8 LSB" , "R_IA64_DIR64LSB" , R_IA64_DIR64LSB}, - {"@gprel(sym + add), add imm22" , "R_IA64_GPREL22" , R_IA64_GPREL22}, - {"@gprel(sym + add), mov imm64" , "R_IA64_GPREL64I" , R_IA64_GPREL64I}, - {"@gprel(sym + add), data4 MSB" , "R_IA64_GPREL32MSB" , R_IA64_GPREL32MSB}, - {"@gprel(sym + add), data4 LSB" , "R_IA64_GPREL32LSB" , R_IA64_GPREL32LSB}, - {"@gprel(sym + add), data8 MSB" , "R_IA64_GPREL64MSB" , R_IA64_GPREL64MSB}, - {"@gprel(sym + add), data8 LSB" , "R_IA64_GPREL64LSB" , R_IA64_GPREL64LSB}, - {"@ltoff(sym + add), add imm22" , "R_IA64_LTOFF22" , R_IA64_LTOFF22}, - {"@ltoff(sym + add), mov imm64" , "R_IA64_LTOFF64I" , R_IA64_LTOFF64I}, - {"@pltoff(sym + add), add imm22" , "R_IA64_PLTOFF22" , R_IA64_PLTOFF22}, - {"@pltoff(sym + add), mov imm64" , "R_IA64_PLTOFF64I" , R_IA64_PLTOFF64I}, - {"@pltoff(sym + add), data8 MSB" , "R_IA64_PLTOFF64MSB" , R_IA64_PLTOFF64MSB}, - {"@pltoff(sym + add), data8 LSB" , "R_IA64_PLTOFF64LSB" , R_IA64_PLTOFF64LSB}, - {"@fptr(sym + add), mov imm64" , "R_IA64_FPTR64I" , R_IA64_FPTR64I}, - {"@fptr(sym + add), data4 MSB" , "R_IA64_FPTR32MSB" , R_IA64_FPTR32MSB}, - {"@fptr(sym + add), data4 LSB" , "R_IA64_FPTR32LSB" , R_IA64_FPTR32LSB}, - {"@fptr(sym + add), data8 MSB" , "R_IA64_FPTR64MSB" , R_IA64_FPTR64MSB}, - {"@fptr(sym + add), data8 LSB" , "R_IA64_FPTR64LSB" , R_IA64_FPTR64LSB}, - {"@pcrel(sym + add), brl" , "R_IA64_PCREL60B" , R_IA64_PCREL60B}, - {"@pcrel(sym + add), ptb, call" , "R_IA64_PCREL21B" , R_IA64_PCREL21B}, - {"@pcrel(sym + add), chk.s" , "R_IA64_PCREL21M" , R_IA64_PCREL21M}, - {"@pcrel(sym + add), fchkf" , "R_IA64_PCREL21F" , R_IA64_PCREL21F}, - {"@pcrel(sym + add), data4 MSB" , "R_IA64_PCREL32MSB" , R_IA64_PCREL32MSB}, - {"@pcrel(sym + add), data4 LSB" , "R_IA64_PCREL32LSB" , R_IA64_PCREL32LSB}, - {"@pcrel(sym + add), data8 MSB" , "R_IA64_PCREL64MSB" , R_IA64_PCREL64MSB}, - {"@pcrel(sym + add), data8 LSB" , "R_IA64_PCREL64LSB" , R_IA64_PCREL64LSB}, - {"@ltoff(@fptr(s+a)), imm22" , "R_IA64_LTOFF_FPTR22" , R_IA64_LTOFF_FPTR22}, - {"@ltoff(@fptr(s+a)), imm64" , "R_IA64_LTOFF_FPTR64I", R_IA64_LTOFF_FPTR64I}, - {"@ltoff(@fptr(s+a)), data4 MSB" , "R_IA64_LTOFF_FPTR32MSB", R_IA64_LTOFF_FPTR32MSB}, - {"@ltoff(@fptr(s+a)), data4 LSB" , "R_IA64_LTOFF_FPTR32LSB", R_IA64_LTOFF_FPTR32LSB}, - {"@ltoff(@fptr(s+a)), data8 MSB" , "R_IA64_LTOFF_FPTR64MSB", R_IA64_LTOFF_FPTR64MSB}, - {"@ltoff(@fptr(s+a)), data8 LSB" , "R_IA64_LTOFF_FPTR64LSB", R_IA64_LTOFF_FPTR64LSB}, - {"@segrel(sym + add), data4 MSB" , "R_IA64_SEGREL32MSB" , R_IA64_SEGREL32MSB}, - {"@segrel(sym + add), data4 LSB" , "R_IA64_SEGREL32LSB" , R_IA64_SEGREL32LSB}, - {"@segrel(sym + add), data8 MSB" , "R_IA64_SEGREL64MSB" , R_IA64_SEGREL64MSB}, - {"@segrel(sym + add), data8 LSB" , "R_IA64_SEGREL64LSB" , R_IA64_SEGREL64LSB}, - {"@secrel(sym + add), data4 MSB" , "R_IA64_SECREL32MSB" , R_IA64_SECREL32MSB}, - {"@secrel(sym + add), data4 LSB" , "R_IA64_SECREL32LSB" , R_IA64_SECREL32LSB}, - {"@secrel(sym + add), data8 MSB" , "R_IA64_SECREL64MSB" , R_IA64_SECREL64MSB}, - {"@secrel(sym + add), data8 LSB" , "R_IA64_SECREL64LSB" , R_IA64_SECREL64LSB}, - {"data 4 + REL" , "R_IA64_REL32MSB" , R_IA64_REL32MSB}, - {"data 4 + REL" , "R_IA64_REL32LSB" , R_IA64_REL32LSB}, - {"data 8 + REL" , "R_IA64_REL64MSB" , R_IA64_REL64MSB}, - {"data 8 + REL" , "R_IA64_REL64LSB" , R_IA64_REL64LSB}, - {"symbol + addend, data4 MSB" , "R_IA64_LTV32MSB" , R_IA64_LTV32MSB}, - {"symbol + addend, data4 LSB" , "R_IA64_LTV32LSB" , R_IA64_LTV32LSB}, - {"symbol + addend, data8 MSB" , "R_IA64_LTV64MSB" , R_IA64_LTV64MSB}, - {"symbol + addend, data8 LSB" , "R_IA64_LTV64LSB" , R_IA64_LTV64LSB}, - {"@pcrel(sym + add), 21bit inst" , "R_IA64_PCREL21BI" , R_IA64_PCREL21BI}, - {"@pcrel(sym + add), 22bit inst" , "R_IA64_PCREL22" , R_IA64_PCREL22}, - {"@pcrel(sym + add), 64bit inst" , "R_IA64_PCREL64I" , R_IA64_PCREL64I}, - {"dynamic reloc, imported PLT, MSB" , "R_IA64_IPLTMSB" , R_IA64_IPLTMSB}, - {"dynamic reloc, imported PLT, LSB" , "R_IA64_IPLTLSB" , R_IA64_IPLTLSB}, - {"copy relocation" , "R_IA64_COPY" , R_IA64_COPY}, - {"Addend and symbol difference" , "R_IA64_SUB" , R_IA64_SUB}, - {"LTOFF22, relaxable" , "R_IA64_LTOFF22X" , R_IA64_LTOFF22X}, - {"Use of LTOFF22X" , "R_IA64_LDXMOV" , R_IA64_LDXMOV}, - {"@tprel(sym + add), imm14" , "R_IA64_TPREL14" , R_IA64_TPREL14}, - {"@tprel(sym + add), imm22" , "R_IA64_TPREL22" , R_IA64_TPREL22}, - {"@tprel(sym + add), imm64" , "R_IA64_TPREL64I" , R_IA64_TPREL64I}, - {"@tprel(sym + add), data8 MSB" , "R_IA64_TPREL64MSB" , R_IA64_TPREL64MSB}, - {"@tprel(sym + add), data8 LSB" , "R_IA64_TPREL64LSB" , R_IA64_TPREL64LSB}, - {"@ltoff(@tprel(s+a)), imm2" , "R_IA64_LTOFF_TPREL22", R_IA64_LTOFF_TPREL22}, - {"@dtpmod(sym + add), data8 MSB" , "R_IA64_DTPMOD64MSB" , R_IA64_DTPMOD64MSB}, - {"@dtpmod(sym + add), data8 LSB" , "R_IA64_DTPMOD64LSB" , R_IA64_DTPMOD64LSB}, - {"@ltoff(@dtpmod(sym + add)), imm22", "R_IA64_LTOFF_DTPMOD22", R_IA64_LTOFF_DTPMOD22}, - {"@dtprel(sym + add), imm14" , "R_IA64_DTPREL14" , R_IA64_DTPREL14}, - {"@dtprel(sym + add), imm22" , "R_IA64_DTPREL22" , R_IA64_DTPREL22}, - {"@dtprel(sym + add), imm64" , "R_IA64_DTPREL64I" , R_IA64_DTPREL64I}, - {"@dtprel(sym + add), data4 MSB" , "R_IA64_DTPREL32MSB" , R_IA64_DTPREL32MSB}, - {"@dtprel(sym + add), data4 LSB" , "R_IA64_DTPREL32LSB" , R_IA64_DTPREL32LSB}, - {"@dtprel(sym + add), data8 MSB" , "R_IA64_DTPREL64MSB" , R_IA64_DTPREL64MSB}, - {"@dtprel(sym + add), data8 LSB" , "R_IA64_DTPREL64LSB" , R_IA64_DTPREL64LSB}, - {"@ltoff(@dtprel(s+a)), imm22" , "R_IA64_LTOFF_DTPREL22", R_IA64_LTOFF_DTPREL22}, - }; - - -/** - * MIPS relocs - */ -revmconst_t elfsh_rel_type_mips[] = - { - - {"No reloc" , "R_MIPS_NONE" , R_MIPS_NONE}, - {"Direct 16 bit" , "R_MIPS_16" , R_MIPS_16}, - {"Direct 32 bit" , "R_MIPS_32" , R_MIPS_32}, - {"PC relative 32 bit" , "R_MIPS_REL32" , R_MIPS_REL32}, - {"Direct 26 bit shifted" , "R_MIPS_26" , R_MIPS_26}, - {"High 16 bit" , "R_MIPS_HI16" , R_MIPS_HI16}, - {"Low 16 bit" , "R_MIPS_LO16" , R_MIPS_LO16}, - {"GP relative 16 bit" , "R_MIPS_GPREL16" , R_MIPS_GPREL16}, - {"16 bit literal entry" , "R_MIPS_LITERAL" , R_MIPS_LITERAL}, - {"16 bit GOT entry" , "R_MIPS_GOT16" , R_MIPS_GOT16}, - {"PC relative 16 bit" , "R_MIPS_PC16" , R_MIPS_PC16}, - {"16 bit GOT entry for function", "R_MIPS_CALL16" , R_MIPS_CALL16}, - {"GP relative 32 bit" , "R_MIPS_GPREL32" , R_MIPS_GPREL32}, - {"" , "R_MIPS_SHIFT5" , R_MIPS_SHIFT5}, - {"" , "R_MIPS_SHIFT6" , R_MIPS_SHIFT6}, - {"" , "R_MIPS_64" , R_MIPS_64}, - {"" , "R_MIPS_GOT_DISP" , R_MIPS_GOT_DISP}, - {"" , "R_MIPS_GOT_PAGE" , R_MIPS_GOT_PAGE}, - {"" , "R_MIPS_GOT_OFST" , R_MIPS_GOT_OFST}, - {"" , "R_MIPS_GOT_HI16" , R_MIPS_GOT_HI16}, - {"" , "R_MIPS_GOT_LO16" , R_MIPS_GOT_LO16}, - {"" , "R_MIPS_SUB" , R_MIPS_SUB}, - {"" , "R_MIPS_INSERT_A" , R_MIPS_INSERT_A}, - {"" , "R_MIPS_INSERT_B" , R_MIPS_INSERT_B}, - {"" , "R_MIPS_DELETE" , R_MIPS_DELETE}, - {"" , "R_MIPS_HIGHER" , R_MIPS_HIGHER}, - {"" , "R_MIPS_HIGHEST" , R_MIPS_HIGHEST}, - {"" , "R_MIPS_CALL_HI16" , R_MIPS_CALL_HI16}, - {"" , "R_MIPS_CALL_LO16" , R_MIPS_CALL_LO16}, - {"" , "R_MIPS_SCN_DISP" , R_MIPS_SCN_DISP}, - {"" , "R_MIPS_REL16" , R_MIPS_REL16}, - {"" , "R_MIPS_ADD_IMMEDIATE", R_MIPS_ADD_IMMEDIATE}, - {"" , "R_MIPS_PJUMP" , R_MIPS_PJUMP}, - {"" , "R_MIPS_RELGOT" , R_MIPS_RELGOT}, - {"" , "R_MIPS_JALR" , R_MIPS_JALR}, - - }; - - -/** - * Alpha relocs. - */ -revmconst_t elfsh_rel_type_alpha[] = - { - {"No reloc" , "R_ALPHA_NONE" , R_ALPHA_NONE}, - {"Direct 32 bit" , "R_ALPHA_REFLONG" , R_ALPHA_REFLONG}, - {"Direct 64 bit" , "R_ALPHA_REFQUAD" , R_ALPHA_REFQUAD}, - {"GP relative 32 bit" , "R_ALPHA_GPREL32" , R_ALPHA_GPREL32}, - {"GP relative 16 bit w/optimization", "R_ALPHA_LITERAL" , R_ALPHA_LITERAL}, - {"Optimization hint for LITERAL" , "R_ALPHA_LITUSE" , R_ALPHA_LITUSE}, - {"Add displacement to GP" , "R_ALPHA_GPDISP" , R_ALPHA_GPDISP}, - {"PC+4 relative 23 bit shifted" , "R_ALPHA_BRADDR" , R_ALPHA_BRADDR}, - {"PC+4 relative 16 bit shifted" , "R_ALPHA_HINT" , R_ALPHA_HINT}, - {"PC relative 16 bit" , "R_ALPHA_SREL16" , R_ALPHA_SREL16}, - {"PC relative 32 bit" , "R_ALPHA_SREL32" , R_ALPHA_SREL32}, - {"PC relative 64 bit" , "R_ALPHA_SREL64" , R_ALPHA_SREL64}, - {"OP stack push" , "R_ALPHA_OP_PUSH" , R_ALPHA_OP_PUSH}, - {"OP stack pop and store" , "R_ALPHA_OP_STORE" , R_ALPHA_OP_STORE}, - {"OP stack subtract" , "R_ALPHA_OP_PSUB" , R_ALPHA_OP_PSUB}, - {"OP stack right shift" , "R_ALPHA_OP_PRSHIFT" , R_ALPHA_OP_PRSHIFT}, - {"Unknown" , "R_ALPHA_GPVALUE" , R_ALPHA_GPVALUE}, - {"GP relative 32 bit, high 16 bits" , "R_ALPHA_GPRELHIGH" , R_ALPHA_GPRELHIGH}, - {"GP relative 32 bit, low 16 bits" , "R_ALPHA_GPRELLOW" , R_ALPHA_GPRELLOW}, - {"GP relative 16 bit" , "R_ALPHA_GPREL16" , R_ALPHA_GPREL16}, - {"Unknown" , "R_ALPHA_IMMED_GP_16" , R_ALPHA_IMMED_GP_16}, - {"Unknown" , "R_ALPHA_IMMED_GP_HI32" , R_ALPHA_IMMED_GP_HI32}, - {"Unknown" , "R_ALPHA_IMMED_SCN_HI32", R_ALPHA_IMMED_SCN_HI32}, - {"Unknown" , "R_ALPHA_IMMED_BR_HI32" , R_ALPHA_IMMED_BR_HI32}, - {"Unknown" , "R_ALPHA_IMMED_LO32" , R_ALPHA_IMMED_LO32}, - {"Copy symbol at runtime" , "R_ALPHA_COPY" , R_ALPHA_COPY}, - {"Create GOT entry" , "R_ALPHA_GLOB_DAT" , R_ALPHA_GLOB_DAT}, - {"Create PLT entry" , "R_ALPHA_JMP_SLOT" , R_ALPHA_JMP_SLOT}, - {"Adjust by program base" , "R_ALPHA_RELATIVE" , R_ALPHA_RELATIVE}, - {"Unknown" , "R_ALPHA_TLS_GD_HI" , R_ALPHA_TLS_GD_HI}, - {"Unknown" , "R_ALPHA_TLSGD" , R_ALPHA_TLSGD}, - {"Unknown" , "R_ALPHA_TLS_LDM" , R_ALPHA_TLS_LDM}, - {"Unknown" , "R_ALPHA_DTPMOD64" , R_ALPHA_DTPMOD64}, - {"Unknown" , "R_ALPHA_GOTDTPREL" , R_ALPHA_GOTDTPREL}, - {"Unknown" , "R_ALPHA_DTPREL64" , R_ALPHA_DTPREL64}, - {"Unknown" , "R_ALPHA_DTPRELHI" , R_ALPHA_DTPRELHI}, - {"Unknown" , "R_ALPHA_DTPRELLO" , R_ALPHA_DTPRELLO}, - {"Unknown" , "R_ALPHA_DTPREL16" , R_ALPHA_DTPREL16}, - {"Unknown" , "R_ALPHA_GOTTPREL" , R_ALPHA_GOTTPREL}, - {"Unknown" , "R_ALPHA_TPREL64" , R_ALPHA_TPREL64}, - {"Unknown" , "R_ALPHA_TPRELHI" , R_ALPHA_TPRELHI}, - {"Unknown" , "R_ALPHA_TPRELLO" , R_ALPHA_TPRELLO}, - {"Unknown" , "R_ALPHA_TPREL16" , R_ALPHA_TPREL16}, - }; - - - -/** - * Relocation types strings for SPARC - */ -revmconst_t elfsh_rel_type_sparc[] = -{ - {"No relocation" , "R_SPARC_NONE" , R_SPARC_NONE}, - {"Direct 8 bit" , "R_SPARC_8" , R_SPARC_8}, - {"Direct 16 bit" , "R_SPARC_16" , R_SPARC_16}, - {"Direct 32 bit" , "R_SPARC_32" , R_SPARC_32}, - {"PC relative 8 bit" , "R_SPARC_DISP8" , R_SPARC_DISP8}, - {"PC relative 16 bit" , "R_SPARC_DISP16" , R_SPARC_DISP16}, - {"PC relative 32 bit" , "R_SPARC_DISP32" , R_SPARC_DISP32}, - {"PC relative 30 bit shifted" , "R_SPARC_WDISP30" , R_SPARC_WDISP30}, - {"PC relative 22 bit shifted" , "R_SPARC_WDISP22" , R_SPARC_WDISP22}, - {"High 22 bit" , "R_SPARC_HI22" , R_SPARC_HI22}, - {"Direct 22 bit" , "R_SPARC_22" , R_SPARC_22}, - {"Direct 13 bit" , "R_SPARC_13" , R_SPARC_13}, - {"Truncated 10 bit" , "R_SPARC_LO10" , R_SPARC_LO10}, - {"Truncated 10 bit GOT entry" , "R_SPARC_GOT10" , R_SPARC_GOT10}, - {"13 bit GOT entry" , "R_SPARC_GOT13" , R_SPARC_GOT13}, - {"22 bit GOT entry shifted" , "R_SPARC_GOT22" , R_SPARC_GOT22}, - {"PC relative 10 bit truncated" , "R_SPARC_PC10" , R_SPARC_PC10}, - {"PC relative 22 bit shifted" , "R_SPARC_PC22" , R_SPARC_PC22}, - {"30 bit PC relative PLT address" , "R_SPARC_WPLT30" , R_SPARC_WPLT30}, - {"Copy symbol at runtime" , "R_SPARC_COPY" , R_SPARC_COPY}, - {"Create GOT entry" , "R_SPARC_GLOB_DAT" , R_SPARC_GLOB_DAT}, - {"Create PLT entry" , "R_SPARC_JMP_SLOT" , R_SPARC_JMP_SLOT}, - {"Adjust by program base" , "R_SPARC_RELATIVE" , R_SPARC_RELATIVE}, - {"Direct 32 bit unaligned" , "R_SPARC_UA32" , R_SPARC_UA32}, - {"Direct 32 bits ref to PLT entry" , "R_SPARC_PLT32" , R_SPARC_PLT32}, - {"High 22 bits PLT entry" , "R_SPARC_HIPLT22" , R_SPARC_HIPLT22}, - {"Truncated 10 bits PLT entry" , "R_SPARC_LOPLT10" , R_SPARC_LOPLT10}, - {"PC rel 32 bits ref to PLT entry" , "R_SPARC_PCPLT32" , R_SPARC_PCPLT32}, - {"PC rel high 22 bits PLT entry" , "R_SPARC_PCPLT22" , R_SPARC_PCPLT22}, - {"PC rel trunc 10 bits PLT entry" , "R_SPARC_PCPLT10" , R_SPARC_PCPLT10}, - {"Direct 10 bits" , "R_SPARC_10" , R_SPARC_10}, - {"Direct 11 bits" , "R_SPARC_11" , R_SPARC_11}, - {"Direct 64 bits" , "R_SPARC_64" , R_SPARC_64}, - {"10bit with secondary 13 bits addend", "R_SPARC_OLO10" , R_SPARC_OLO10}, - {"Top 22 bits of direct 64 bits" , "R_SPARC_HH22" , R_SPARC_HH22}, - {"High middle 10 bits" , "R_SPARC_HM10" , R_SPARC_HM10}, - {"Low middle 22 bits" , "R_SPARC_LM22" , R_SPARC_LM22}, - {"Top 22 bits of pc rel 64 bits" , "R_SPARC_PC_HH22" , R_SPARC_PC_HH22}, - {"High middle 10 bits" , "R_SPARC_PC_HM10" , R_SPARC_PC_HM10}, - {"Low miggle 22 bits" , "R_SPARC_PC_LM22" , R_SPARC_PC_LM22}, - {"PC relative 16 bits shifted" , "R_SPARC_WDISP16" , R_SPARC_WDISP16}, - {"PC relative 19 bits shifted" , "R_SPARC_WDISP19" , R_SPARC_WDISP19}, - {"Direct 7 bits" , "R_SPARC_7" , R_SPARC_7}, - {"Direct 5 bits" , "R_SPARC_5" , R_SPARC_5}, - {"Direct 6 bits" , "R_SPARC_6" , R_SPARC_6}, - {"PC relative 64 bits" , "R_SPARC_DISP64" , R_SPARC_DISP64}, - {"Direct 64 bits ref to PLT entry" , "R_SPARC_PLT64" , R_SPARC_PLT64}, - {"High 22 bits complemented" , "R_SPARC_HIX22" , R_SPARC_HIX22}, - {"Truncated 11 bits complemented" , "R_SPARC_LOX10" , R_SPARC_LOX10}, - {"Direct high 12 of 44 bits" , "R_SPARC_H44" , R_SPARC_H44}, - {"Direct mid 22 of 44 bits" , "R_SPARC_M44" , R_SPARC_M44}, - {"Direct low 10 of 44 bits" , "R_SPARC_L44" , R_SPARC_L44}, - {"Global register usage" , "R_SPARC_REGISTER", R_SPARC_REGISTER}, - {"Direct 64 bits unaligned" , "R_SPARC_UA64" , R_SPARC_UA64}, - {"Direct 16 bits unaligned" , "R_SPARC_UA16" , R_SPARC_UA16}, -}; - - - - -/** - * Architecture strings - */ -char *elfsh_arch_type[] = -{ - "No machine" , - "AT&T WE 32100" , - "SUN SPARC" , - "Intel 80386" , - "Motorola m68k family" , - "Motorola m88k family" , - "Intel 80486" , - "Intel 80860" , - "MIPS R3000 big-endian", - "IBM system 370" , - "MIPS R3000 lil-endian", - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "HPPA" , - "nCUBE" , - "Fujitsu VPP500" , - "Sun's v8plus" , - "Intel 80960" , - "PowerPC" , - "PowerPC 64 bits" , - "IBM S390" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "Unknown" , - "NEC V800 series" , - "Fujitsu FR20" , - "TRW RH32" , - "Motorola RCE" , - "ARM" , - "Digital Alpha" , - "Hitachi SH" , - "SPARC v9 64-bit" , - "Siemens Tricore" , - "Argonaut RISC Core" , - "Hitachi H8/300" , - "Hitachi H8/300H" , - "Hitachi H8S" , - "Hitachi H8/500" , - "Intel Merced" , - "Stanford MIPS-X" , - "Motorola Coldfire" , - "Motorola M68HC12" , -}; - - -/** - * Stab entry type strings - */ -char *elfsh_stab_type[] = -{ - "Undefined symbol", - "Unknown", - "File scope absolute symbol", - "External absolute symbol", - "File scope text symbol", - "External text symbol", - "File scope data symbol", - "External data symbol", - "File scope BSS symbol", - "External BSS symbol", - "Symbol is indirected to another symbol", - "Unknown", - "Same as N_FN, for Sequent compilers", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Common--visible after shared library dynamic link", - "Unknown", - "Unknown", - "Absolute set element", - "Unknown", - "Text segment set element", - "Unknown", - "Data segment set element", - "Unknown", - "BSS segment set element", - "Unknown", - "Pointer to set vector", - "Print a warning message during linking", - "File name of a module", - "Global symbol", - "Unknown", - "Function name (for BSD Fortran)", - "Unknown", - "Function name (see section 2.5 Procedures) or text segment variable", - "Unknown", - "Data segment file-scope variable", - "Unknown", - "BSS segment file-scope variable", - "Unknown", - "Name of main routine", - "Unknown", - "Variable in .rodata section", - "Unknown", - "Unknown", - "Unknown", - "Global symbol (for Pascal)", - "Unknown", - "Number of symbols (according to Ultrix V4.0)", - "Unknown", - "No DST map", - "Unknown", - "Unknown", - "Unknown", - "Object file (Solaris2)", - "Unknown", - "Unknown", - "Unknown", - "Debugger options (Solaris2)", - "Unknown", - "Unknown", - "Unknown", - "Register variable", - "Unknown", - "Modula-2 compilation unit", - "Unknown", - "Line number in text segment", - "Unknown", - "Line number in data segment", - "Unknown", - "Line number in bss segment", - "Unknown", - "GNU Modula2 definition module dependency", - "Unknown", - "Function start/body/end line numbers (Solaris2)", - "Unknown", - "Unknown", - "Unknown", - "GNU C++ exception variable", - "Unknown", - "Unknown", - "Unknown", - "GNU C++ catch clause", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Structure of union element", - "Unknown", - "Last stab for module (Solaris2)", - "Unknown", - "Path and name of source file", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Stack variable", - "Unknown", - "Beginning of an include file (Sun only)", - "Unknown", - "Name of include file", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Parameter variable", - "Unknown", - "End of an include file", - "Unknown", - "Alternate entry point", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Beginning of a lexical block", - "Unknown", - "Place holder for a deleted include file", - "Unknown", - "Modula2 scope information (Sun linker)", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "End of a lexical block", - "Unknown", - "Begin named common block", - "Unknown", - "End named common block", - "Unknown", - "Unknown", - "Unknown", - "Member of a common block", - "Unknown", - "Pascal with statement: type,,0,0,offset (Solaris2)", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Gould non-base registers", - "Unknown", - "Gould non-base registers", - "Unknown", - "Gould non-base registers", - "Unknown", - "Gould non-base registers", - "Unknown", - "Gould non-base registers", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", - "Unknown", -}; - - - - - - - - - - - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/deps.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/deps.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/deps.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/deps.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,592 +0,0 @@ -/** -** @file deps.c -** -** @brief All functions regarding dependences support in the naming scheme and the -** loading/unloading facilities of the shell -** -** Started on Sat Nov 25 11:21:18 2006 jfv -** -** $Id: deps.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * Our own pow - * @param a - * @param b - * @return - */ -static int __eint_pow(int a, int b) -{ - double res = 1; - float f; - - if (b == 0) - return 1; - if (b < 0) - { - for (; b < 0; b++) - res = res * a; - f = 1 / res; - return (int) f; - } - for (; b > 0; b--) - res = res * a; - return (int) res; -} - - -/** - * Find a different element than 'file' in the parent hash table - * @param hash - * @param file - * @return - */ -static void* revm_get_another_parent(hash_t *hash, elfshobj_t *file) -{ - char **keys; - int index; - int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!hash || hash_size(hash) <= 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find another parent", NULL); - keys = hash_get_keys(hash, &index); - for (idx = 0; idx < index; idx++) - if (strcmp(keys[idx], file->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - hash_get(hash, keys[idx])); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find another parent", NULL); -} - - -/** - * Merge the root dependences information for all the children, when a new - * program with dependences is (un)loaded and some dependences also depends - * from other roots. - * @param child - * @param root - * @param dephash - * @param action - * @return - */ -static int revm_update_depinfo(elfshobj_t *child, - elfshobj_t *root, - hash_t *dephash, - char action) -{ - char **key; - int index; - int keynbr; - elfshobj_t *cur; - int newid; - void *present; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Cut the recursion in case of circular dependencies */ - present = hash_get(dephash, child->name); - if (present) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - hash_add(dephash, strdup(child->name), (void *) 1); - - /* Change ID of object before recursing */ - if (action & REVM_CREATE_NEWID) - { - cur = revm_get_another_parent(&child->root_hash, root); - newid = ELFSH_CHILD_NEW(cur); - child->id = newid; - } - - /* ... including on the child objects */ - key = hash_get_keys(&child->child_hash, &keynbr); - for (index = 0; index < keynbr; index++) - { - cur = hash_get(&child->child_hash, key[index]); - if (revm_update_depinfo(cur, root, dephash, action)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Dependence failed to perform action", -1); - } - - /* Remove the roots after recursion, so avoid unwanted unloading */ - if (action & REVM_HASH_MERGE) - hash_merge(&child->root_hash, &root->root_hash); - else if (action & REVM_HASH_UNMERGE) - hash_unmerge(&child->root_hash, &root->root_hash); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Enum dependences - * @param obj - * @param rechash - * @param dephash - * @return - * - */ -static int revm_load_enumdep_rec(elfshobj_t *obj, hash_t *rechash, hash_t *dephash) -{ - elfsh_Dyn *dyn_entrie; - u_int dyn_num; - u_int index; - char nbasename[BUFSIZ]; - char *path; - elfshobj_t *child; - char **hashkeys; - int keys_num; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Avoid invalid arguments and cut recursion when needed */ - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - if (hash_get(rechash, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - hash_add(rechash, strdup(obj->name), (void *) 1); - - /* Retrieve .dynamic table for DT_NEEDED entries */ - dyn_entrie = elfsh_get_dynamic(obj, &dyn_num); - if (dyn_entrie == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No .dynamic information", -1); - - /* Loop on the .dynamic section entries */ - for (index = 0; index < dyn_num && dyn_entrie[index].d_tag != DT_NULL; index++) - { - /* Only needed entries */ - if (dyn_entrie[index].d_tag != DT_NEEDED) - continue; - - /* Retrieve the value */ - revm_dynentinfo(obj, dyn_entrie + index, nbasename); - if (*nbasename == 0x00) - continue; - - /* Search the path for this library */ - path = revm_load_searchlib(nbasename); - if (!path) - continue; - - child = hash_get(&world.curjob->loaded, path); - if (!child) - revm_load_dep(obj, path, 0, 0, dephash); - else - { - if (!hash_get(&obj->child_hash, child->name)) - hash_add(&obj->child_hash, child->name, child); - if (!hash_get(&child->parent_hash, obj->name)) - hash_add(&child->parent_hash, obj->name, obj); - revm_update_depinfo(child, obj, dephash, REVM_HASH_MERGE); - } - } - - /* Retrieve all childs keys then load dep for each child */ - hashkeys = hash_get_keys(&obj->child_hash, &keys_num); - for (index = 0; hashkeys != NULL && index < keys_num; index++) - { - child = (elfshobj_t *) hash_get(&obj->child_hash, hashkeys[index]); - if (child) - revm_load_enumdep_rec(child, rechash, dephash); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * This is a front end function for the recursive function above - * @param obj - * @return - */ -int revm_load_enumdep(elfshobj_t *obj) -{ - hash_t rechash; - hash_t dephash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bzero(&rechash, sizeof(rechash)); - bzero(&dephash, sizeof(dephash)); - hash_init(&rechash, "loaded_dependences_files", 20, ASPECT_TYPE_UNKNOW); - hash_init(&dephash, "recursed_dependences_files", 20, ASPECT_TYPE_UNKNOW); - revm_load_enumdep_rec(obj, &rechash, &dephash); - hash_destroy(&rechash); - hash_destroy(&dephash); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Search the lib path for a specific file - * @param name Filename to search - * @return - */ -char *revm_load_searchlib(char *name) -{ - int len; - char *libpath; - char *retpath = NULL; - char *p; - char *f, *f2; - int dlen; - char testpath[BUFSIZ]; - char tmplibpath[BUFSIZ]; - FILE *fp; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - libpath = revm_lookup_string(REVM_VAR_LIBPATH); - - /* The variable doesn't exist */ - if (libpath == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ELFSH_LIBPATH not found", NULL); - - /* We copy data because we will make some modifications */ - strncpy(tmplibpath, libpath, BUFSIZ -1); - tmplibpath[BUFSIZ - 1] = '\0'; - - len = strlen(tmplibpath); - for (p = tmplibpath; p != NULL && p[0] != '\0'; p = f + 1) - { - f = strchr(p, ';'); - f2 = strchr(p, ':'); - if ((!f && f2) || (f2 && f - f2 > 0)) - f = f2; - - /* If a ; is found, we seperate the tree */ - if (f != NULL) - f[0] = '\0'; - - /* Trim ended / */ - for (dlen = strlen(p); p[dlen] == '/'; dlen--) - p[dlen] = '\0'; - - snprintf(testpath, BUFSIZ - 1, - "%s/%s", p, name); - - /* The file exists, then we set the pointer */ - if ((fp = fopen(testpath, "r")) != NULL) - { - fclose(fp); - retpath = testpath; - break; - } - - /* If we don't found the ;, it's the last path */ - if (f == NULL) - break; - } - - if (retpath != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - strdup(retpath)); - - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Search a dependence from an id and a loaded object. - * @param obj - * @param id - * @return - */ -elfshobj_t *revm_is_depid(elfshobj_t *obj, int id) -{ - elfshobj_t *child; - elfshobj_t *subchild; - int tid; - int oid; - int tcount; - int ocount; - int keynums; - char **keys; - int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!obj) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - /* We don't search a dependence or we are too far */ - if (id < ELFSH_CHILD_MAX || !hash_size(&obj->child_hash) || obj->id > id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - /* Count how many digits */ - for (ocount = 0, oid = obj->id; oid > 0; ocount++) - oid /= 10; - - /* Count how many digits */ - for (tcount = 0, tid = id; tid > 0; tcount++) - tid /= 10; - - oid = obj->id; - tid = id; - - /* That a small check to gain time, it won't work on any case */ - if (oid == tid / __eint_pow(10, tcount - ocount)) - { - keys = hash_get_keys(&obj->child_hash, &keynums); - for (index = 0; index < keynums; index++) - { - child = hash_get(&obj->child_hash, keys[index]); - if (child->id == id) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - - /* Search for a child of the child ! */ - if ((subchild = revm_is_depid(child, id)) != NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, subchild); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - - - - -/** - * Search a dependence from a lib name and a loaded object - * @param obj - * @param path - * @return - */ -elfshobj_t *revm_is_dep(elfshobj_t *obj, char *path) -{ - char **hashkeys; - int index; - elfshobj_t *child; - int keys_num; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!obj || !path) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid paramters", NULL); - - hashkeys = hash_get_keys(&obj->child_hash, &keys_num); - - for (index = 0; hashkeys != NULL && index < keys_num; index++) - { - child = (elfshobj_t *) hash_get(&obj->child_hash, hashkeys[index]); - - if (child) - { - if (!strcmp(path, hashkeys[index])) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - - child = revm_is_dep(child, path); - if (child) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, child); - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); -} - -/** - * Load a dependence which is different from a normal file. - * @param parent - * @param name - * @param base - * @param lm - * @param dephash - * @return - */ -int revm_load_dep(elfshobj_t *parent, char *name, - eresi_Addr base, elfshlinkmap_t *lm, - hash_t *dephash) -{ - elfshobj_t *new; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!parent || !name) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", -1); - - /* Map the standard ELF object */ - new = elfsh_map_obj(name); - if (NULL == new) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot load object", -1); - if (elfsh_get_arch(new->hdr) != elfsh_get_arch(parent->hdr)) - { - snprintf(logbuf, sizeof (logbuf) - 1, "Parent file and dependance %s" - " architecture unmatched", name); - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - logbuf, -1); - } - - /* Print a msg if not in quiet mode */ - new->loadtime = time(&new->loadtime); - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, " [*] New object dependences loaded : %s\n", - name); - revm_output(logbuf); - } - - /* Set base address and linkmap addr */ - new->rhdr.base = base; - new->linkmap = lm; - - /* Add the object of child objects */ - if (parent->lastchildid >= ELFSH_CHILD_MAX) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot create more child", -1); - - /* Generate a child id */ - new->id = ELFSH_CHILD_NEW(parent); - - /* Init search hash tables */ - elfsh_init_symbol_hashtables(new); - - /* Parse debugging informations */ - revm_edfmt_parse(new); - - /* Initialize hash tables */ - snprintf(logbuf, sizeof(logbuf), "%s_children", name); - hash_init(&new->child_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_parents", name); - hash_init(&new->parent_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - - snprintf(logbuf, sizeof(logbuf), "%s_roots", name); - hash_init(&new->root_hash, strdup(logbuf), 11, ASPECT_TYPE_UNKNOW); - - - /* Link with its parent */ - /* Link with all the additional root files of its parent */ - /* Add reference to the private (or shared) list */ - hash_add(&new->parent_hash, parent->name, parent); - hash_add(&parent->child_hash, new->name, new); - if (world.state.revm_shared) - hash_add(&world.shared_hash, new->name, new); - else - hash_add(&world.curjob->loaded, new->name, new); - hash_add(&file_hash, new->name, new); - revm_update_depinfo(new, parent, dephash, REVM_HASH_MERGE); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Unload all dependence for an object. - * @param obj - * @param root - * @param rechash - * @param dephash - * @return - */ -static int revm_unload_dep_rec(elfshobj_t *obj, elfshobj_t *root, - hash_t *rechash, hash_t *dephash) -{ - elfshobj_t *actual; - char logbuf[BUFSIZ]; - char **keys; - int index; - int keynbr; - time_t uloadt; - int ret; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (hash_get(rechash, obj->name)) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - hash_add(rechash, strdup(obj->name), (void *) 1); - - /* Unload each dependence */ - keys = hash_get_keys(&obj->child_hash, &keynbr); - for (ret = index = 0; index < keynbr; index++) - { - actual = hash_get(&obj->child_hash, keys[index]); - if (!actual || !actual->name || hash_get(rechash, actual->name)) - continue; - - //printf("Unloading dependence %s \n", actual->name); - - /* Case where we should -not- unload this object and its dependences */ - /* Renew the object id, if its father changes */ - if (hash_size(&actual->root_hash) > 1 || - !hash_get(&actual->root_hash, root->name)) - { - snprintf(logbuf, BUFSIZ - 1, " [*] Object %s -NOT- unloaded\n", - actual->name); - revm_output(logbuf); - - /* - ** If the object was already unlinked from its parent at another - ** iteration of this function, do not remove the roots and change - ** its id again -may - */ - if (hash_get(&actual->root_hash, root->name)) - { - hash_del(&actual->parent_hash, obj->name); - revm_update_depinfo(actual, root, dephash, REVM_CREATE_NEWID | REVM_HASH_UNMERGE); - } - continue; - } - - /* The current pointer must be NULL if it was us */ - if (world.curjob->curfile && world.curjob->curfile->id == actual->id) - { - world.curjob->curfile = hash_get_one(&world.curjob->loaded); - if (!world.curjob->curfile) - world.curjob->curfile = hash_get_one(&world.shared_hash); - } - - /* A dependence can have its own dependences */ - hash_del(&file_hash, actual->name); - if (hash_get(&world.shared_hash, actual->name)) - hash_del(&world.shared_hash, actual->name); - else - hash_del(&world.curjob->loaded, actual->name); - revm_unload_dep_rec(actual, root, rechash, dephash); - - /* Print message of removing */ - if (!world.state.revm_quiet) - { - time(&uloadt); - snprintf(logbuf, BUFSIZ - 1, " [*] Object %-40s unloaded on %s", - actual->name, ctime(&uloadt)); - revm_output(logbuf); - } - elfsh_unload_obj(actual); - ret++; - } - - /* Disable the force flag and return OK */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - -/** - * This is a front end function for the recursive function above. - * @param obj - * @param root - * @return Always 0 - */ -int revm_unload_dep(elfshobj_t *obj, elfshobj_t *root) -{ - hash_t rechash; - hash_t dephash; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - bzero(&rechash, sizeof(rechash)); - bzero(&dephash, sizeof(dephash)); - hash_init(&rechash, "unloaded_dependences_files", 20, ASPECT_TYPE_UNKNOW); - hash_init(&dephash, "unrecursed_dependences_files", 20, ASPECT_TYPE_UNKNOW); - revm_unload_dep_rec(obj, root, &rechash, &dephash); - hash_destroy(&rechash); - hash_destroy(&dephash); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/disasm.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/disasm.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/disasm.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/disasm.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,952 +0,0 @@ -/** -** @file disasm.c -** -** Started on Fri Nov 2 15:41:34 2001 jfv -** -** -** $Id: disasm.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -static revmlist_t* second = NULL; - - -/** - * Resolve symbol in one file or all (mapped) if we are in e2dbg - * Runtime compatible. - * @param file - * @param addr - * @param roffset - * @return -*/ -char *revm_resolve(elfshobj_t *file, eresi_Addr addr, - elfsh_SAddr *roffset) -{ - listent_t *ent; - int index; - elfshobj_t *actual; - char *name = NULL; - char *dname = NULL; - elfsh_SAddr offset = 0; - elfsh_SAddr doffset = 0; - char *bestname = NULL; - elfsh_SAddr bestoffset; - elfshobj_t *bestfile; - char buf[BUFSIZ]; - char *str; - - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!file) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL argument", NULL); - - actual = file; - name = elfsh_reverse_symbol(actual, addr, &offset); - dname = elfsh_reverse_dynsymbol(actual, addr, &doffset); - - if (!name || (dname && !strcmp(name, ELFSH_SECTION_NAME_PLT)) || - (offset < 0) || (dname && doffset < offset && doffset >= 0)) - { - name = dname; - offset = doffset; - } - - bestname = name; - bestoffset = offset; - bestfile = actual; - - -#if __DEBUG_RESOLVE__ - printf("[elfsh:resolve] file : %s name %s %d\n", actual->name, name, offset); -#endif - - /* Find the best symbol by searching in all the objects of the process */ - if (world.state.revm_mode == REVM_STATE_DEBUGGER) - for (index = 0; index < world.curjob->loaded.size; index++) - for (ent = &world.curjob->loaded.ent[index]; - ent != NULL && ent->key != NULL; - ent = ent->next) - { - actual = ent->data; - if (!actual->linkmap) - continue; - - name = elfsh_reverse_symbol(actual, addr, &offset); - dname = elfsh_reverse_dynsymbol(actual, addr, &doffset); - - if (!name || (offset < 0) || - (dname && doffset < offset && doffset >= 0)) - { - name = dname; - offset = doffset; - } - - if (!bestname || - (bestoffset < 0) || (name && offset < bestoffset && offset >= 0)) - { - bestname = name; - bestoffset = offset; - bestfile = actual; - } - -#if __DEBUG_RESOLVE__ - printf("[elfsh:resolve] file : %s name %s %d\n", - actual->name, name, offset); -#endif - } - -#if __DEBUG_RESOLVE__ - printf("[elfsh:resolve] BEST name %s %d\n", bestname, bestoffset); -#endif - - if (roffset) - *roffset = bestoffset; - - if (bestname == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to resolve best name", (NULL)); - - if (elfsh_is_debug_mode()) - { - str = revm_basename(bestfile->name); - snprintf(buf, BUFSIZ, "%s@%s", - bestname, (str ? str : "CORRUPTED")); - } - else - snprintf(buf, BUFSIZ, "%s", bestname); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, strdup(buf)); - -} - - -/** - * Symbol resolving handler for libasm. - * Runtime compatible - * @param data - * @param vaddr - * @param buf - * @param maxlen - */ -void asm_do_resolve(void *data, eresi_Addr vaddr, - char *buf, u_int maxlen) -{ - elfshobj_t *file; - elfshsect_t *parent; - char *name; - elfsh_SAddr off; - int len; - char *sep; - - /* Retreive the nearest symbol */ - file = data; - parent = elfsh_get_parent_section(file, vaddr, 0); - if (NULL != parent && parent->shdr->sh_addr) - name = revm_resolve(file, vaddr, &off); - else - name = NULL; - - /* Print the symbol name in 'buf' so that libasm can print it */ - len = (NULL == name ? 10 : strlen(name) + 25); - if (name != NULL && *name != 0x00) - { - sep = (off > 0 ? " + " : off < 0 ? " - " : ""); - len = snprintf(buf, maxlen - 1, "%s%s%s%s", - revm_colorfieldstr("<"), - revm_colortypestr(name), - (off ? revm_colorfieldstr(sep) : ""), - (off ? "" : revm_colorfieldstr(">"))); - - if (off) - snprintf(buf + len, maxlen - len - 1, "%s%s", - revm_colornumber("%u", (u_int) off), - revm_colorfieldstr(">")); - } - else - snprintf(buf, maxlen - 1, AFMT, vaddr); -} - - - -/*------------------ to clean !! ******/ - - - - -/** - * Display An instruction. - * Runtime compatible - * @param fd - * @param index - * @param vaddr - * @param foffset - * @param size - * @param name - * @param nindex - * @param buff - */ -u_int revm_instr_display(int fd, u_int index, eresi_Addr vaddr, - u_int foffset, u_int size, char *name, - u_int nindex, char *buff) - -{ - char *s; - char buf[256]; - u_int idx_bytes; - u_int ret; - asm_instr ptr; - char base[16] = "0123456789ABCDEF"; - char logbuf[BUFSIZ]; - char c1[2]; - char c2[2]; - u_int strsz; - elfsh_Half machine; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!buff) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid argument", (-1)); - - /* Init proc */ - if (!world.curjob->proc) - { - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC: - case EM_SPARC32PLUS: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - world.curjob->proc = &world.proc_mips; - break; - default: - snprintf(logbuf, sizeof (logbuf) - 1, - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - } - - /* Print the instr. itself : vaddr and relative symbol resolution */ - ret = asm_read_instr(&ptr, (u_char *)buff + index, size - index + 10, - world.curjob->proc); - if (ret == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "asm_read_instruction faild (-1)", (ret)); - - s = (!ret ? "(bad)" : asm_display_instr_att(&ptr, (vaddr ? vaddr + index : 0))); - - /* Libasm test */ - if (fd == -1) - { - - /* Are we in quiet mode ? */ - if (world.state.revm_quiet) - { - snprintf(buf, sizeof(buf), " %s %s + %s", - revm_coloraddress(XFMT, vaddr + index), - revm_colorstr(name), - revm_colornumber("%u", nindex)); - size = snprintf(logbuf, BUFSIZ, "%-40s %-30s ", - buf, revm_colorinstr(s)); - } - else - { - size = snprintf(buf, sizeof(buf), " %s [%s %s] %s + %s", - revm_coloraddress(XFMT, vaddr + index), - revm_colorfieldstr("foff:"), - revm_colornumber("%u", foffset + index), - revm_colorstr(name), - revm_colornumber("%u", nindex)); - strsz = strlen(s); - size = snprintf(logbuf, BUFSIZ, "%-*s %-*s ", - (size > 95 ? 125 : - size > 87 ? 100 : - size > 75 ? 108 : - size > 50 ? 88 : 55), - buf, - (strsz > 95 ? 125 : - strsz > 87 ? 100 : - strsz > 75 ? 108 : - strsz > 50 ? 88 : 55), - revm_colorinstr(s)); - } - - /* Print bytes in hexa for this instruction */ - ret = asm_instr_len(&ptr); - if (!ret) - ret++; - - if (!world.state.revm_quiet) - for (idx_bytes = 0; idx_bytes < ret; idx_bytes++) - { - c1[0] = base[(buff[index + idx_bytes] >> 4) & 0x0F]; - c2[0] = base[buff[index + idx_bytes] & 0x0F]; - c1[1] = c2[1] = 0x00; - size += snprintf(logbuf + size, sizeof(logbuf) - size, "%s%s ", - revm_colorfieldstr(c1), - revm_colorfieldstr(c2)); - } - - if (!world.curjob->curcmd || !world.curjob->curcmd->use_regx[1] || - !regexec(&second->name, logbuf, 0, 0, 0)) - { - revm_output(logbuf); - revm_output("\n"); - } - revm_endline(); - } - else - write(fd, s, strlen(s)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); -} - - -/** - * Disassemble a function. - * @param parent - * @param sym - * @param size - * @param off - * @param foffset - * @param vaddr - * @param name - * @param otype - * @return - */ -int revm_object_display(elfshsect_t *parent, elfsh_Sym *sym, int size, - u_int off, u_int foffset, eresi_Addr vaddr, - char *name, char otype) -{ - char *buff; - u_int index; - elfsh_SAddr idx_bytes; - char buf[256]; - char base[16] = "0123456789ABCDEF"; - eresi_Addr loff; - char str[256]; - elfshsect_t *targ; - char *s; - u_int ret; - int value; - char logbuf[BUFSIZ]; - char tmp[BUFSIZ]; - char c1[2], c2[2]; - char *pStr; - void *tmpbuff; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (!parent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "parent section is NULL", -1); - - /* Special case if the symbol is a plt entry */ - if (sym && elfsh_is_pltentry(parent->parent, sym) == 1 && - size > ELFSH_PLT_ENTRY_SIZE) - size = ELFSH_PLT_ENTRY_SIZE; - -#if __DEBUG_DISASM__ - snprintf(logbuf, BUFSIZ - 1, - "[debug:revm_object_display] %s off(%u) size(%u) vaddr(%08X) " - "foffset(%u), parent(%p, %s) \n", - name, off, size, vaddr, foffset, parent, - (parent ? parent->name : "UNK")); - revm_output(logbuf); -#endif - - /* Get the pointer on relevant data */ - buff = elfsh_get_raw(parent); - index = off; - buff += (vaddr - (parent->parent->rhdr.base + parent->shdr->sh_addr)); - -#if defined(KERNSH) - if (kernsh_is_mem_mode()) - parent->parent->rhdr.base = 0; -#endif - - /* Filter requests on void sections (ex: bss when not inserted in file) */ - if (!parent || !parent->data) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No data at this address", -1); - - /* If the regex match a pointers array, print the pointed elements too */ - if (sym && - (elfsh_get_symbol_type(sym) == STT_OBJECT || - elfsh_get_symbol_type(sym) == STT_COMMON) && - !(sym->st_size % sizeof(eresi_Addr))) - { - - for (index = 0; index * sizeof(eresi_Addr) < sym->st_size; index++) - { - - /* Do not print more than 250 entries at a time */ - /* Use an offset for more dumping */ - if (index >= 250) - { - revm_output("-- symbol size is bigger (use an offset) --\n"); - break; - } - - /* For each entry of the array */ - /* Dont forget the section offset at the end */ - tmpbuff = elfsh_get_raw(parent); - tmpbuff += vaddr - (parent->parent->rhdr.base + parent->shdr->sh_addr); - -#if defined(KERNSH) - if (kernsh_is_mem_mode()) - parent->parent->rhdr.base = 0; -#endif - - tmpbuff += index * sizeof(eresi_Addr); - loff = * (eresi_Addr *) tmpbuff; - - snprintf(buf, sizeof(buf), " " AFMT " [foff: %u] \t %s[%0*u] = " XFMT, - elfsh_is_debug_mode() ? - parent->parent->rhdr.base + vaddr + index * sizeof(eresi_Addr) : - vaddr + index * sizeof(eresi_Addr), - foffset + index * sizeof(eresi_Addr), - name, - ((sym->st_size / sizeof(eresi_Addr)) < 100 ? 2 : - (sym->st_size / sizeof(eresi_Addr)) < 1000 ? 3 : 4), - index, - loff); - - /* If the target pointer is not valid */ - targ = elfsh_get_parent_section(parent->parent, loff, - (elfsh_SAddr *) &off); - if (targ == NULL || strcmp(targ->name, ELFSH_SECTION_NAME_RODATA)) - { - s = elfsh_reverse_symbol(parent->parent, loff, &idx_bytes); - if (NULL == s || idx_bytes > 1000) - s = elfsh_reverse_dynsymbol(parent->parent, loff, &idx_bytes); - if (NULL == s || idx_bytes > 1000) - { - if (targ != NULL) - { - s = targ->name; - idx_bytes = off; - } - else - idx_bytes = 0; - } - if (idx_bytes) - snprintf(str, sizeof(str), "%s + %u", - (s ? s : ""), (u_int) idx_bytes); - else - snprintf(str, sizeof(str), ""); - snprintf(logbuf, BUFSIZ, "%-75s %s \n", buf, str); - } - - /* else if yes, print the pointed data too */ - else - { - s = elfsh_get_raw(targ); - s += off; - memcpy(str, s, - (sizeof(str) > (targ->shdr->sh_size - off)) ? - targ->shdr->sh_size - off : sizeof(str)); - snprintf(logbuf, BUFSIZ - 1, "%-75s \"%s\" \n", buf, str); - } - - /* maybe the user asked to quit the display */ - revm_output(logbuf); - } - } - - - - /* We want asm + hexa output of the code */ - else if (otype == REVM_VIEW_DISASM) - { -#if defined(KERNSH) - if (!kernsh_is_present() && elfsh_is_debug_mode()) - vaddr += parent->parent->rhdr.base; -#else - if (elfsh_is_debug_mode()) - vaddr += parent->parent->rhdr.base; -#endif - - idx_bytes = (sym ? vaddr + index - sym->st_value : index); - - while (index < size && size > 0) - { - value = revm_instr_display(-1, index, vaddr, - foffset, size, name, - idx_bytes, buff); - if (value <= 0) - break; - index += value; - idx_bytes += value; - } - } - - /* We want hexa + ascii output of the data */ - else if (REVM_VIEW_HEX == otype) - { - if (name == NULL || !*name) - name = ELFSH_NULL_STRING; - - while (index < size && size > 0) - { - /* Take care of quiet mode */ - if (world.state.revm_quiet) - { - sprintf(buf, " %s %s + %s", - revm_coloraddress(AFMT, (eresi_Addr) vaddr + index), - revm_colorstr(name), revm_colornumber("%u", index)); - snprintf(logbuf, BUFSIZ - 1, "%-40s ", buf); - revm_output(logbuf); - } - else - { - sprintf(buf, " %s [%s %s] %s + %s", - revm_coloraddress(AFMT, (eresi_Addr) vaddr + index), - revm_colorfieldstr("foff:"), - revm_colornumber(DFMT, foffset + index), - revm_colorstr(name), revm_colornumber("%u", index)); - snprintf(logbuf, BUFSIZ - 1, "%-*s", 60 + revm_color_size(buf), buf); - revm_output(logbuf); - } - revm_endline(); - ret = (world.state.revm_quiet ? 8 : 16); - tmp[0] = c1[1] = c2[1] = 0x00; - - /* Print hexa */ - for (loff = 0; loff < ret; loff++) - { - c1[0] = c2[0] = ' '; - if (index + loff < size) - { - c1[0] = base[(buff[index + loff] >> 4) & 0x0F]; - c2[0] = base[(buff[index + loff] >> 0) & 0x0F]; - } - snprintf(logbuf, BUFSIZ - 1, "%s%s ", c1, c2); - if (strlen(tmp) + strlen(logbuf) < BUFSIZ) - strcat(tmp, logbuf); - } - - revm_output(revm_colorfieldstr(tmp)); - revm_endline(); - tmp[0] = 0x00; - - /* Print ascii */ - for (loff = 0; loff < ret; loff++) - { - c1[0] = buff[index + loff]; - pStr = (index + loff >= size ? " " : - (PRINTABLE(buff[index + loff]) ? c1 : ".")); - if (strlen(tmp) + 1 < BUFSIZ) - strcat(tmp, pStr); - } - - revm_output(revm_colorstr(tmp)); - revm_endline(); - revm_output("\n"); - index += ret; - } - } - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - -/** - * Print all variables and functions of the section. - * @param s - * @param name - * @param re - * @return - */ -int revm_section_display(elfshsect_t *s, - char *name, - revmlist_t *re) -{ - elfsh_Sym *actual; - int size, symtab_size; - int index; - elfsh_SAddr offset; - int tot; - char *symname; - char logbuf[BUFSIZ]; - int err; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Hello message ;) */ - snprintf(logbuf, BUFSIZ - 1, " [*] Analysing section %s [*] \n\n", name); - revm_output(logbuf); - actual = elfsh_get_symtab(s->parent, &symtab_size); - tot = 0; - if (s && !elfsh_get_raw(s)) - elfsh_get_anonymous_section(s->parent, s); - - if (!actual) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section has no symbol associated", -1); - - /* Display all symbols data pointing in the section */ - for (index = 0; index < symtab_size; index++) - if (elfsh_get_parent_section(s->parent, actual[index].st_value, &offset) == s) - { - if (re->size) - size = ((re->size + re->off) > actual[index].st_size ? - actual[index].st_size : re->size + re->off); - else - size = actual[index].st_size; - - symname = elfsh_get_symbol_name(s->parent, actual + index); - addr = s->shdr->sh_offset + actual[index].st_value - s->shdr->sh_addr; - err = revm_object_display(s, actual + index, size, re->off, addr, - actual[index].st_value, symname, re->otype); - - if (err == -1) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, err); - tot++; - } - - /* If no symbol points to our section, we display it as a whole */ - if (!tot) - { - if (re->size) - size = ((re->size + re->off) > s->shdr->sh_size ? s->shdr->sh_size : - re->size + re->off); - else - size = s->shdr->sh_size; - actual = elfsh_get_symbol_by_name(s->parent, name); - if (revm_object_display(s, actual, size, re->off, s->shdr->sh_offset, - s->shdr->sh_addr, name, re->otype) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to display section data", -1); - } - - /* Everything went ok */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * Match regular expressions in a SHT (SHT or RSHT). - * @param file - * @param l - * @param actual - * @return - */ -int revm_match_sht(elfshobj_t *file, elfshsect_t *l, revmlist_t *actual) -{ - elfshsect_t *s; - char *name; - int matchs = 0; -#if __DEBUG_DISASM__ - char logbuf[BUFSIZ]; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Now find matches in the list of section */ - for (s = l; s != NULL; s = s->next) - { - name = s->name; - if (name == NULL || !*name || regexec(&actual->name, name, 0, 0, 0)) - continue; - matchs++; - -#if __DEBUG_DISASM__ - snprintf(logbuf, BUFSIZ - 1, - "[debug_disasm:cmd_disasm] Found section regx (%s) \n", name); - revm_output(logbuf); -#endif - - if (revm_section_display(s, name, actual) < 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, matchs); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, matchs); -} - - - - - -/** - * Match regular expressions in the symbol tables - * @param file - * @param symtab - * @param actual - * @param flag - * @return - */ -int revm_match_symtab(elfshobj_t *file, elfshsect_t *symtab, - revmlist_t *actual, int flag) -{ - elfshsect_t *s; - char *name; - int matchs = 0; - u_int saved_size; - elfsh_Sym *sym; - eresi_Addr addr; - int index; -#if __DEBUG_DISASM__ - char logbuf[BUFSIZ]; -#endif - - /* Natural checks */ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - if (!file || !symtab || !actual) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid NULL parameter", -1); - saved_size = actual->size; - - /* Iterate on symbols */ - sym = (flag ? elfsh_get_raw(symtab) : (elfsh_Sym *) symtab->altdata); - for (index = 0; index < symtab->shdr->sh_size / sizeof(elfsh_Sym); index++) - { - - /* Match ? */ - name = (flag ? elfsh_get_dynsymbol_name(file, sym + index) : - elfsh_get_symbol_name(file, sym + index)); - if (name == NULL || *name == 0x00 || !DUMPABLE(sym + index) || - elfsh_get_symbol_type(sym + index) == STT_SECTION || - regexec(&actual->name, name, 0, 0, 0)) - continue; - matchs++; - if (!actual->size) - actual->size = elfsh_get_symbol_size(sym + index); - else - actual->size = ((actual->size + actual->off) > - elfsh_get_symbol_size(sym + index) ? - elfsh_get_symbol_size(sym + index) : - actual->size + actual->off); - -#if __DEBUG_DISASM__ - snprintf(logbuf, BUFSIZ - 1, - "[debug_disasm:cmd_disasm] Found dynsym regx (%s) (" AFMT ")\n", - name, elfsh_get_symbol_value(sym + index)); - revm_output(logbuf); -#endif - - /* Only use toggle mode when inspecting .dynsym */ - if (flag && !elfsh_get_symbol_value(sym + index)) - { - elfsh_toggle_mode(); - sym = elfsh_get_raw(symtab); - elfsh_toggle_mode(); - s = elfsh_get_parent_section(file, - file->rhdr.base + sym[index].st_value, - NULL); - } - else - s = elfsh_get_parent_section(file, sym[index].st_value, NULL); - - /* Display matched object */ - addr = elfsh_get_foffset_from_vaddr(file, sym[index].st_value); - if (revm_object_display(s, sym + index, actual->size, actual->off, addr, - sym[index].st_value, name, actual->otype) == -1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Error while displaying matched object", -1); - - if (!flag) - actual->size = saved_size; - } - - /* Everything went ok */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, matchs); -} - - - - - - -/** - * Match a special regular expression. - * @param file - * @param vaddr - * @param actual - * @return - */ -int revm_match_special(elfshobj_t *file, eresi_Addr vaddr, - revmlist_t *actual) -{ - elfsh_Sym *sym; - char *name; - int off; - u_int matchs; - elfshsect_t *s; - -#if __DEBUG_DISASM__ - char logbuf[BUFSIZ]; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_DISASM__ - snprintf(logbuf, BUFSIZ - 1, - "[debug:cmd_disasm] SPECIAL with vaddr(" AFMT ") \n", vaddr); - revm_output(logbuf); -#endif - - if (file->hdr->e_type == ET_DYN && elfsh_is_debug_mode()) - vaddr -= file->rhdr.base; - sym = elfsh_get_symbol_by_value(file, vaddr, &off, ELFSH_LOWSYM); - if (file->hdr->e_type == ET_DYN && elfsh_is_debug_mode()) - vaddr += file->rhdr.base; - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No matching symbol for offset", -1); - actual->off += off; - if (!actual->size) - actual->size = elfsh_get_symbol_size(sym); - else - actual->size = ((actual->size + actual->off) > elfsh_get_symbol_size(sym) ? - elfsh_get_symbol_size(sym) : actual->size + actual->off); - name = elfsh_get_symbol_name(file, sym); - matchs++; - -#if __DEBUG_DISASM__ - snprintf(logbuf, BUFSIZ - 1, "[debug_disasm:cmd_disasm] Found special regx " - "(%s with off %d) sym = " AFMT "\n", name, off, sym->st_value); - revm_output(logbuf); -#endif - - s = elfsh_get_parent_section(file, vaddr, NULL); - if (!s) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "No matching section for address", -1); - - if (!actual->size) - actual->size = s->shdr->sh_size; - revm_object_display(s, sym, actual->size, actual->off, - elfsh_get_foffset_from_vaddr(file, vaddr), - vaddr, name, actual->otype); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Display ASM code for a given function, or every functions of a section - */ -int cmd_disasm() -{ - revmlist_t *actual; - elfshobj_t *file; - revmexpr_t *expr; - int matchs; - eresi_Addr vaddr; - char logbuf[BUFSIZ]; - elfsh_Half machine; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* First check the architecture */ - switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) - { - case EM_386: - world.curjob->proc = &world.proc; - break; - case EM_SPARC32PLUS: - case EM_SPARC: - case EM_SPARCV9: - world.curjob->proc = &world.proc_sparc; - break; - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_MIPS_X: - world.curjob->proc = &world.proc_mips; - break; - default: - snprintf(logbuf, sizeof (logbuf) - 1, - "Architecture %s not supported. No disassembly available\n", - elfsh_get_machine_string(machine)); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - - /* Make sure we get symtabs of current object */ - elfsh_get_symtab(world.curjob->curfile, NULL); - elfsh_get_dynsymtab(world.curjob->curfile, NULL); - revm_output("\n"); - - /* now walk the regex list for this option */ - actual = world.curjob->curcmd->disasm + 0; - second = world.curjob->curcmd->disasm + 1; - matchs = vaddr = 0; - file = world.curjob->curfile; - - /* If the regex contains a vaddr instead of a symbol name */ - if (actual->rname) - { - if (*actual->rname == REVM_VAR_PREFIX) - { - expr = revm_expr_get(actual->rname); - if (!expr || !expr->value || !expr->value->immed_val.ent) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid requested address expression", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, expr->value->immed_val.ent, actual)); - } - else if (IS_VADDR(actual->rname)) - { - if (sscanf(actual->rname + 2, AFMT, &vaddr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid virtual address requested", -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, vaddr, actual)); - } - - /* else if it contains a file offset */ - else if (isdigit((int) *actual->rname)) - { - vaddr = elfsh_get_vaddr_from_foffset(file, atoi(actual->rname)); - if (vaddr == 0xFFFFFFFF && - sscanf(actual->rname + 2, AFMT, &vaddr) != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid file offset requested", - -1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_match_special(file, vaddr, actual)); - } - } - - /* Try to match in the sectlist and runtime sectlist */ - matchs += revm_match_sht(file, file->sectlist, actual); - matchs += revm_match_sht(file, file->rsectlist, actual); - - /* Now find matches in the symbol table .symtab */ - /* Last parameter says if we are in symtab or dynsymtab */ - matchs += revm_match_symtab(file, file->secthash[ELFSH_SECTION_SYMTAB], actual, 0); - matchs += revm_match_symtab(file, file->secthash[ELFSH_SECTION_DYNSYM], actual, 1); - - /* Printing a warning message if we have no match */ - if (!world.state.revm_quiet && !matchs) - { - snprintf(logbuf, BUFSIZ - 1, " [E] No match for request %s\n\n", - actual->rname); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/dtors.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/dtors.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/dtors.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/dtors.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,75 +0,0 @@ -/** -** @file dtors.c -** -** Started on Tue Feb 26 22:08:20 2002 jfv -** -** -** $Id: dtors.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - - -/** - * Display the destructor section - */ -int cmd_dtors() -{ - regex_t *tmp; - eresi_Addr *dtors; - int size; - int index; - elfsh_SAddr offset; - elfsh_SAddr doffset; - char *name; - char *dname; - char off[50]; - char buff[256]; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dtors = elfsh_get_dtors(world.curjob->curfile, &size); - if (dtors == NULL) - RET(-1); - FIRSTREGX(tmp); - snprintf(logbuf, BUFSIZ - 1, - " [Destructors array .::. DTORS]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - off[0] = 0; - - for (index = 0; index < size; index++) - { - - name = elfsh_reverse_symbol(world.curjob->curfile, dtors[index], &offset); - dname = elfsh_reverse_dynsymbol(world.curjob->curfile, dtors[index], &doffset); - if (dname && doffset < offset) - { - name = dname; - offset = doffset; - } - - if (off) - snprintf(off, sizeof(off), " %s %s", - revm_colorstr((offset < 0 ? "-" : "+")), - revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); - - snprintf(buff, sizeof(buff), " %s %s \t <%s%s>\n", - revm_colornumber("[%02u]", index), - revm_coloraddress(XFMT, (eresi_Addr) dtors[index]), - (name ? revm_colorstr(name) : revm_colorwarn("?")), - (name && offset ? off : "")); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - - revm_endline(); - } - - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/dyn.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/dyn.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/dyn.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/dyn.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,441 +0,0 @@ -/** - * @file dyn.c - * - * Started on Fri Nov 2 15:17:36 2001 jfv - * - * - * $Id: dyn.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * Handlers for value for special tags - */ -void revm_do_feature1(elfshobj_t *file, elfsh_Dyn *entry, char *info) -{ - u_int cnt; - u_int idx; - char buff[45]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - *buff = '\n'; - memset(buff + 1, REVM_SPACE, sizeof(buff) - 2); - buff[44] = 0x00; - for (cnt = idx = 0; idx < ELFSH_FEATURE_MAX; idx++) - if (entry->d_un.d_val & elfsh_feature1[idx].val) - cnt += snprintf(info + cnt, BUFSIZ, "%s%s", - (cnt ? buff : ""), - elfsh_feature1[idx].desc); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Need doxygen comment. - * @param file - * @param entry - * @param info - * @return - */ -void revm_do_posflag1(elfshobj_t *file, elfsh_Dyn *entry, char *info) -{ - u_int cnt; - u_int idx; - char buff[45]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - *buff = '\n'; - memset(buff + 1, REVM_SPACE, sizeof(buff) - 2); - buff[44] = 0x00; - for (cnt = idx = 0; idx < ELFSH_POSFLAG_MAX; idx++) - if (entry->d_un.d_val & elfsh_posflag1[idx].val) - cnt += snprintf(info + cnt, BUFSIZ, "%s%s", - (cnt ? buff : ""), - elfsh_posflag1[idx].desc); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Need doxygen comment. - * @param file - * @param entry - * @param info - */ -void revm_do_flags(elfshobj_t *file, elfsh_Dyn *entry, char *info) -{ - u_int cnt; - u_int idx; - char buff[45]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - *buff = '\n'; - memset(buff + 1, REVM_SPACE, sizeof(buff) - 2); - buff[44] = 0x00; - for (cnt = idx = 0; idx < ELFSH_FLAGS_MAX; idx++) - if (entry->d_un.d_val & elfsh_flags[idx].val) - cnt += snprintf(info + cnt, BUFSIZ, "%s%s", - (cnt ? buff : ""), - elfsh_flags[idx].desc); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Need doxygen comment. - * @param file - * @param entry - * @param info - */ -void revm_do_flags1(elfshobj_t *file, elfsh_Dyn *entry, char *info) -{ - u_int cnt; - u_int idx; - char buff[45]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - *buff = '\n'; - memset(buff + 1, REVM_SPACE, sizeof(buff) - 2); - buff[44] = 0x00; - for (cnt = idx = 0; idx < ELFSH_FLAGS1_MAX; idx++) - if (entry->d_un.d_val & elfsh_flags1[idx].val) - cnt += snprintf(info + cnt, BUFSIZ, "%s%s", - (cnt ? buff : ""), - elfsh_flags1[idx].desc); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - -/** - * Need doxygen comment. - * @param file - * @param entry - * @param info - */ -void revm_do_mipsflags(elfshobj_t *file, elfsh_Dyn *entry, char *info) -{ - u_int cnt; - u_int idx; - char buff[45]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - *buff = '\n'; - memset(buff + 1, REVM_SPACE, sizeof(buff) - 2); - buff[44] = 0x00; - for (cnt = idx = 0; idx < ELFSH_MIPSFLAGS_MAX; idx++) - if (entry->d_un.d_val & elfsh_mipsflags[idx].val) - cnt += snprintf(info + cnt, BUFSIZ, "%s%s", - (cnt ? buff : ""), - elfsh_mipsflags[idx].desc); - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Provide human readable output for .dynamic entries. - * @param file - * @param entry - * @param info - */ -void revm_dynentinfo(elfshobj_t *file, - elfsh_Dyn *entry, - char *info) -{ - char *str; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (entry->d_tag) - { - case DT_NEEDED: - case DT_SONAME: - case DT_RPATH: - case DT_AUXILIARY: - case DT_FILTER: - str = elfsh_get_dynentry_string(file, entry); - snprintf(info, 99, "%s", (str != NULL ? str : ELFSH_NULL_STRING)); - break; - case DT_SYMBOLIC: - sprintf(info, "Current object first checked during symbol resolving"); - break; - case DT_TEXTREL: - sprintf(info, "Relocation can overwrite .text"); - break; - case DT_BIND_NOW: - sprintf(info, "Symbol binding is now completed before execution"); - break; - case DT_PLTREL: - case DT_MOVEENT: - case DT_SYMINENT: - case DT_RELACOUNT: - case DT_RELCOUNT: - case DT_VERDEFNUM: - case DT_VERNEEDNUM: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_PLTRELSZ: - case DT_RELASZ: - case DT_RELAENT: - case DT_STRSZ: - case DT_RELSZ: - case DT_RELENT: - case DT_SYMENT: - case DT_SYMINSZ: - case DT_PLTPADSZ: - case DT_MOVESZ: - sprintf(info, UFMT " bytes", entry->d_un.d_val); - break; - case DT_PLTGOT: - case DT_STRTAB: - case DT_SYMTAB: - case DT_HASH: - case DT_RELA: - case DT_INIT: - case DT_FINI: - case DT_REL: - case DT_DEBUG: - case DT_JMPREL: - case DT_CHECKSUM: - case DT_VERSYM: - case DT_VERDEF: - case DT_VERNEED: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_FEATURE_1: - revm_do_feature1(file, entry, info); - break; - case DT_POSFLAG_1: - revm_do_posflag1(file, entry, info); - break; - case DT_FLAGS: - revm_do_flags(file, entry, info); - break; - case DT_FLAGS_1: - revm_do_flags1(file, entry, info); - break; - case DT_NULL: - sprintf(info, "END OF SECTION"); - break; - /* MIPS dynamic entry type */ - case DT_MIPS_RLD_VERSION: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_TIME_STAMP: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_ICHECKSUM: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_IVERSION: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_FLAGS: - revm_do_mipsflags(file, entry, info); - break; - case DT_MIPS_BASE_ADDRESS: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_MIPS_MSYM: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_MIPS_CONFLICT: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_MIPS_LIBLIST: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_MIPS_LOCAL_GOTNO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_CONFLICTNO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_LIBLISTNO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_SYMTABNO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_UNREFEXTNO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_GOTSYM: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_HIPAGENO: - sprintf(info, UFMT, entry->d_un.d_val); - break; - case DT_MIPS_RLD_MAP: - sprintf(info, XFMT, entry->d_un.d_ptr); - break; - case DT_MIPS_DELTA_CLASS: - case DT_MIPS_DELTA_CLASS_NO: - case DT_MIPS_DELTA_INSTANCE: - case DT_MIPS_DELTA_INSTANCE_NO: - case DT_MIPS_DELTA_RELOC: - case DT_MIPS_DELTA_RELOC_NO: - case DT_MIPS_DELTA_SYM: - case DT_MIPS_DELTA_SYM_NO: - case DT_MIPS_DELTA_CLASSSYM: - case DT_MIPS_DELTA_CLASSSYM_NO: - case DT_MIPS_CXX_FLAGS: - case DT_MIPS_PIXIE_INIT: - case DT_MIPS_SYMBOL_LIB: - case DT_MIPS_LOCALPAGE_GOTIDX: - case DT_MIPS_LOCAL_GOTIDX: - case DT_MIPS_HIDDEN_GOTIDX: - case DT_MIPS_PROTECTED_GOTIDX: - case DT_MIPS_OPTIONS: - case DT_MIPS_INTERFACE: - case DT_MIPS_DYNSTR_ALIGN: - case DT_MIPS_INTERFACE_SIZE: - case DT_MIPS_RLD_TEXT_RESOLVE_ADDR: - case DT_MIPS_PERF_SUFFIX: - case DT_MIPS_COMPACT_SIZE: - case DT_MIPS_GP_VALUE: - case DT_MIPS_AUX_DYNAMIC: - default: - sprintf(info, "[?]"); - break; - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - -/** - * GNU and SUN extensions for the dynamic section. - * @param type - */ -char *revm_getdyntype(u_int type) -{ - u_int idx; - - for (idx = 0; idx < ELFSH_EXTDYN_MAX; idx++) - if (elfsh_extdyn_type[idx].val == type) - return ((char *) elfsh_extdyn_type[idx].desc); - for (idx = 0; idx < ELFSH_MIPSDYN_MAX; idx++) - if (elfsh_mipsdyn_type[idx].val == type) - return ((char *) elfsh_mipsdyn_type[idx].desc); - return ("[?]"); -} - - -/** - * GNU and Sun extensions for the dynamic section. - * @param type - */ -char *revm_getdyntype_short(u_int type) -{ - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; idx < ELFSH_EXTDYN_MAX; idx++) - if (elfsh_extdyn_type[idx].val == type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) elfsh_extdyn_type[idx].name)); - - for (idx = 0; idx < ELFSH_MIPSDYN_MAX; idx++) - if (elfsh_mipsdyn_type[idx].val == type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) elfsh_mipsdyn_type[idx].name)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, "[?]"); -} - - - - -/** - * Display the .dynamic section entries - */ -int cmd_dyn() -{ - elfsh_Dyn *actual; - u_int num; - int index; - int typenum; - char *type; - char *type_short; - char *p; - regex_t *tmp; - char buff[256]; - char type_unk[ELFSH_MEANING + 1]; - char info[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch the section and init the regex */ - if ((actual = elfsh_get_dynamic(world.curjob->curfile, &num)) == NULL) - RET(-1); - FIRSTREGX(tmp); - snprintf(info, BUFSIZ - 1, - " [SHT_DYNAMIC]\n [Object %s]\n\n", world.curjob->curfile->name); - revm_output(info); - - /* Loop on the section */ - for (index = 0; index < num && actual[index].d_tag != DT_NULL; index++) - { - - /* Get the data to be printed */ - typenum = elfsh_get_dynentry_type(actual + index); - if (typenum >= ELFSH_DYNAMIC_MAX) - { - type = revm_getdyntype(typenum); - type_short = revm_getdyntype_short(typenum); - if (type == NULL) - type = type_short = revm_build_unknown(type_unk, "UNK", typenum); - } - else - { - type = (char *) elfsh_dynentry_type[typenum].desc; - type_short = (char *) elfsh_dynentry_type[typenum].name; - } - - bzero(info, sizeof(info)); - revm_dynentinfo(world.curjob->curfile, actual + index, info); - - p = NULL; - if (strlen(info) == 14) - p = info+10; - - if (IS_VADDR(info)) - revm_coloradv("address", "%19s", info); - else if ((p != NULL && !strcmp(p, "bytes")) || info[0] == '0') - revm_coloradv("number", "%19s", info); - else - revm_coloradv("string", "%19s", info); - - /* Print if the regex match */ - snprintf(buff, sizeof(buff), " %s %s => %s {%s}\n", /* +43 */ - revm_colornumber("[%02u]", index), - revm_colortypestr_fmt("%-33s", type), - info, - revm_colortypestr(type_short)); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - - revm_endline(); - } - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/findrel.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/findrel.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/findrel.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/findrel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,234 +0,0 @@ -/** -** @file findrel.c -** -** Started on Sat Feb 22 17:06:17 2003 jfv -** -** -** $Id: findrel.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * @brief Print a buffer with a resolved virtual address and offset - * to a symbol name. - * @param file - * @param vaddr - * @return - */ -char *revm_reverse(elfshobj_t *file, u_int vaddr) -{ - char *str; - char *new; - elfsh_SAddr off; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - str = elfsh_reverse_metasym(file, vaddr, &off); - if (str == NULL) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, 8, NULL); - sprintf(new, "?"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); - } - if (off) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__,new, strlen(str) + 20, NULL); - sprintf(new, "%s + %u", str, (u_int) off); - } - else - new = strdup(str); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (new)); -} - - -#if 0 /* WIP */ -/** - * Return 1 if relocation entry is a false positive - * If one of these checks are not honored, we conclude to a FP : - * - dword is not part of only 1 instruction - * - dword is not part of only 1 operand - * - dword do not point to a referenced place - */ -static int revm_catch_fp(asm_instr *i, u_int begin, u_int len, u_int dword) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - -#if __DEBUG_ASLR__ - snprintf(logbuf, BUFSIZ - 1, "[elfsh:revm_catch_fp] begin: %08X, totlen: %u, op1: %08X/%u, " - "op2: %08X/%u, op3: %08X/%u, dword: %08X \n", - begin, len, - (i->op1 != NULL ? (u_int) i->op1->ptr : 0), (i->op1 != NULL ? i->op1->len : 0), - (i->op2 != NULL ? (u_int) i->op2->ptr : 0), (i->op2 != NULL ? i->op2->len : 0), - (i->op3 != NULL ? (u_int) i->op3->ptr : 0), (i->op3 != NULL ? i->op3->len : 0), - dword); - asm_display_instr_att(i, 0); -#endif - - if (begin + len < dword + 4) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Say wether or not this entry is a false positive. - * We are using architecture dependant heuristics : - * - Instruction alignement - * - Operand alignement - * @param dat - * @param dword - */ -static int revm_catch_relocfp(char *dat, u_int dword) -{ - asm_instr ptr; - u_int ret; - u_int begin; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - while (1) - { - begin = (u_int) dat; - ret = asm_read_instr(&ptr, dat, 10, &world.proc); - if (!ret) - { -#if __DEBUG_ASLR__ - snprintf(logbuf, BUFSIZ - 1, "[elfsh:catch_relocfp] Libasm bad fetching..\n"); -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - } - dat += ret; - - /* Detect a false positive if the dword overlap many instructions */ - if (begin <= dword && begin + ret >= dword) - return (revm_catch_fp(&ptr, begin, ret, dword)); - } -} -#else -static __inline__ int revm_catch_relocfp(char *dat, u_int word) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} -#endif - - -/** - * Find the missing relocation table for an ET_EXEC object - */ -int cmd_findrel() -{ - elfshobj_t *file; - elfshsect_t *cur; - elfshsect_t *dst; - u_int index; - char soff[30]; - char doff[30]; - u_int count; - u_int dword; - char *reloc_type; - char logbuf[BUFSIZ]; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - file = world.curjob->curfile; - if (file == NULL) - RETERR("[elfsh:findrel] Invalid NULL parameter\n"); - if (elfsh_read_obj(file) < 0) - RETERR("[elfsh:findrel] Cannot read object\n"); - - snprintf(logbuf, BUFSIZ - 1, - " [*] EXTRA relocs for %s \n\n", file->name); - revm_output(logbuf); - - /* For all sections of the current object */ - for (count = 0, cur = file->sectlist; cur; cur = cur->next) - { - - /* Do not look for cross references on unmapped or void sections */ - data = elfsh_get_raw(cur); - if (data == NULL) - { - if (!world.state.revm_quiet) - snprintf(logbuf, BUFSIZ - 1, " [*] Passing %-20s {NO DATA}\n", cur->name); - continue; - } - if (cur->shdr->sh_addr == 0) - { - if (!world.state.revm_quiet) - snprintf(logbuf, BUFSIZ - 1, " [*] Passing %-20s {UNMAPPED}\n", cur->name); - continue; - } - - /* Find the relocation entries, and print it */ - elfsh_find_rel(cur); - if (cur->rel == NULL || cur->srcref == 0) - { - if (!world.state.revm_quiet) - snprintf(logbuf, BUFSIZ - 1, " [*] Passing %-20s {NO RELOC ENTRY}\n", cur->name); - continue; - } - - /* Print the relocs for this section */ - revm_output("\n"); - for (index = 0; index < cur->srcref; index++) - { - - /* Detect false positives */ - if (elfsh_get_section_execflag(cur->shdr)) - { - dword = (u_int) data + cur->rel[index].off_src; - - /* Must be done here so that libelfsh stay libasm dependant */ - if (revm_catch_relocfp(data, dword)) - cur->rel[index].type = ELFSH_RELOC_FP; - } - - /* Print the offset buffers */ - if (cur->rel[index].off_src) - snprintf(soff, sizeof(soff), "+ %u", cur->rel[index].off_src); - else - *soff = 0x00; - if (cur->rel[index].off_dst) - snprintf(doff, sizeof(doff), "+ %u", cur->rel[index].off_dst); - else - *doff = 0x00; - - /* Get relocation type string */ - reloc_type = (cur->rel[index].type == ELFSH_RELOC_FP ? "FP" : - cur->rel[index].type == ELFSH_RELOC_SECTBASE ? "SB" : - "UK"); - - /* Print to stdout the current rel ent */ - dst = elfsh_get_section_by_index(file, - cur->rel[index].idx_dst, - NULL, - NULL); - snprintf(logbuf, BUFSIZ - 1, " [%03u] FROM %15s %12s TO %15s %12s [ %08X -> %08X ] {%s} \n", - index, cur->name, soff, dst->name, doff, - (u_int) cur->shdr->sh_addr + cur->rel[index].off_src, - (u_int) dst->shdr->sh_addr + cur->rel[index].off_dst, - reloc_type); - count++; - } - revm_output("\n"); - } - - /* Print final banner */ - snprintf(logbuf, BUFSIZ - 1, "\n [*] ET_EXEC relocation entries number : %u\n\n", count); - for (cur = world.curjob->curfile->sectlist; cur; cur = cur->next) - snprintf(logbuf, BUFSIZ - 1, " [*] Section %-20s srcref[%010u] dstref[%010u] \n", - cur->name, cur->srcref, cur->dstref); - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/flush.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/flush.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/flush.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/flush.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,85 +0,0 @@ -/** -** @file flush.c -** -** @brief Flush the binary of any injected section -** Restore the original PLT -** Flush the excedentary BSS zones -** -** Started on Nov 24 2003 jfv -** -** -** $Id: flush.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - -/** - * Need doxygen comment. - * - */ -int cmd_flush() -{ - elfshsect_t *plt; - elfshsect_t *origplt; - elfshsect_t *act; - elfshsect_t *next; - elfsh_Phdr *interp; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Restore original PLT if any */ - plt = elfsh_get_plt(world.curjob->curfile, NULL); - origplt = world.curjob->curfile->secthash[ELFSH_SECTION_ALTPLT]; - if (origplt && plt) - memcpy(elfsh_get_raw(plt), elfsh_get_raw(origplt), plt->shdr->sh_size); - - /* Remove pre-interp injected sections */ - interp = elfsh_get_segment_by_type(world.curjob->curfile, PT_INTERP, 0); - if (!interp) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot find PT_INTERP", -1); - for (act = world.curjob->curfile->sectlist; act; act = next) - { - if (act->shdr->sh_addr >= interp->p_vaddr) - break; - next = act->next; - - /* Avoid removin the NULL section */ - if (*act->name && - elfsh_remove_section(world.curjob->curfile, act->name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Failed to remove section", (-1)); - } - - /* Remove post-bss injected sections */ - plt = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_BSS, - NULL, NULL, NULL); - if (!plt) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "PLT section not found", -1); - - act = plt->next; - while (act && act->shdr->sh_addr) - { - next = act->next; - if (elfsh_remove_section(world.curjob->curfile, act->name) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Section removal failed", -1); - } - - /* Remove excedentary BSS zones */ - if (elfsh_flush_bss(world.curjob->curfile) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to flush BSS", -1); - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " [*] Object %s flushed succesfully.\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/got.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/got.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/got.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/got.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -/** -** @file got.c -** -** Started on Fri Nov 2 15:20:18 2001 jfv -** -** -** $Id: got.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - -/** - * Command handler for GOT command - */ -int cmd_got() -{ - regex_t *tmp; - elfshsect_t *got; - int size; - int index; - int index2; - elfsh_SAddr offset; - char *name; - char off[50]; - char buff[256]; - char logbuf[BUFSIZ]; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Get the regx and fetch the GOT data */ - FIRSTREGX(tmp); - - index2 = 0; - if ((got = elfsh_get_got_by_idx(world.curjob->curfile, index2, (u_int *)&size)) - == NULL) - RET(-1); - - /* Loop on all .got */ - for (index2 = 0; got; index2++) - { - - data = elfsh_get_raw(got); - - snprintf(logbuf, BUFSIZ - 1, " [Global Offset Table .::. GOT : %s ]\n [Object %s]\n\n", - elfsh_get_section_name(world.curjob->curfile, got), - world.curjob->curfile->name); - revm_output(logbuf); - off[0] = 0; - - /* Loop and print all entry and their resolve */ - for (index = 0; index < size; index++) - { - - name = revm_resolve(world.curjob->curfile, *((eresi_Addr *) data + index), &offset); - - if (off != NULL) - snprintf(off, sizeof(off), " %s %s", - revm_colorstr((offset < 0 ? "-" : "+")), - revm_colornumber("%u", (u_int) (offset > 0 ? offset : offset - offset - offset))); - - - snprintf(buff, sizeof(buff), "%s : %s %s \t <%s%s>\n", - revm_coloraddress(XFMT, got->shdr->sh_addr + (index * sizeof(eresi_Addr))), - revm_colornumber("[%02u]", index), - revm_coloraddress(XFMT, (eresi_Addr) ((eresi_Addr *) data)[index]), - (name != NULL ? revm_colorstr(name) : revm_colorwarn("?")), - (off[0] && name && offset ? off : "")); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - switch (revm_output(buff)) - { - case -1: - revm_endline(); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - case -2: - revm_endline(); - goto next; - } - - revm_endline(); - } - - next: - got = elfsh_get_got_by_idx(world.curjob->curfile, index2 + 1, (u_int *)&size); - revm_output("\n"); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/hash.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/hash.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/hash.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/hash.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,254 +0,0 @@ -/** - * @file version.c - * - * @brief Hash features - * - * Started on Sun Oct 07 10:20:18 2005 mxatone - * - * $Id: hash.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -* -*/ -#include "libstderesi.h" - -/** - * Need doxygen comment - * @param index - * @return - */ -int revm_hashunk(int index) -{ - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ -1, - " %s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr("STN_UNDEF")); - revm_output(logbuf); - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param type - * @param index - * @param symid - * @param name - * @param rhash - * @param hash - * @param check - * @return - */ - -int revm_hashbucket_print(int type, int index, int symid, - char *name, int rhash, int hash, int check) -{ - char logbuf[BUFSIZ]; - char ipattern[16]; - int quiet; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(ipattern, 15, - (type == 0 ? "[%%03u]" : "~>%%03u")); - - quiet = world.state.revm_quiet; - - snprintf(logbuf, BUFSIZ - 1, - " %s %s%s %s%s %s%s %s%s %s%s\n", - revm_colornumber(ipattern, index), - revm_colorfieldstr("sym:"), - revm_colornumber("%03u", symid), - revm_colorfieldstr("name:"), - revm_colorstr_fmt((!quiet ? "%-40s" : "%-15s"), name), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", rhash), - revm_colorfieldstr("hashm:"), - revm_colornumber("%02u", hash), - revm_colorfieldstr("check:"), - (check ? "ok" : "bad")); - - revm_output(logbuf); - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * @param index - * @param symid - * @param name - * @param rhash - * @param hash - * @return - */ -int revm_hashchain_print(int index, int symid, char *name, - int rhash, int hash) -{ - char logbuf[BUFSIZ]; - int quiet; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - quiet = world.state.revm_quiet; - - snprintf(logbuf, BUFSIZ - 1, - " %s %s%s %s%s %s%s %s%s\n", - revm_colornumber("[%03u]", index), - revm_colorfieldstr("sym:"), - revm_colornumber("%03u", symid), - revm_colorfieldstr("name:"), - revm_colorstr_fmt((!quiet ? "%-40s" : "%-15s"), name), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", rhash), - revm_colorfieldstr("hashm:"), - revm_colornumber("%02u", hash)); - - revm_output(logbuf); - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment - * @param sect - * @param sym - * @param nbr - * @return - */ -int revm_hashprint(elfshsect_t *sect, elfsh_Sym *sym, int nbr) -{ - void *data; - elfsh_Word hash, chash; - elfsh_Word rhash, rchash; - elfsh_Word nbucket; - elfsh_Word nchain; - elfsh_Word *chain; - elfsh_Word *bucket; - elfsh_Word index, cindex; - elfsh_Word symid; - char logbuf[BUFSIZ]; - char *name; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = sect->data; - - nbucket = elfsh_get_hashnbucket(data); - nchain = elfsh_get_hashnchain(data); - bucket = elfsh_get_hashbucket(data); - chain = elfsh_get_hashchain(data); - - snprintf(logbuf, BUFSIZ - 1, - " {Section %s}\n" - " {nbucket: %u nchain: %u}\n\n", - sect->name, nbucket, nchain); - - revm_output(logbuf); - revm_endline(); - - revm_output(" [bucket]\n"); - - for (index = 0; index < nbucket; index++) - { - symid = bucket[index]; - name = elfsh_get_dynsymbol_name(world.curjob->curfile, - sym + symid); - - rhash = elfsh_get_symbol_hash(name); - hash = rhash % nbucket; - - if (symid == STN_UNDEF) - { - revm_hashunk(index); - continue; - } - - revm_hashbucket_print(0, index, symid, name, rhash, hash, (index == hash)); - - for (cindex = symid; cindex < nchain; cindex = symid) - { - symid = chain[cindex]; - - if (symid == STN_UNDEF) - break; - - name = elfsh_get_dynsymbol_name(world.curjob->curfile, - sym + symid); - rchash = elfsh_get_symbol_hash(name); - chash = rchash % nbucket; - - revm_hashbucket_print(1, cindex, symid, name, rchash, chash, (hash == chash)); - } - } - - revm_output("\n [chain]\n"); - - for(index = 0; index < nchain; index++) - { - symid = chain[index]; - name = elfsh_get_dynsymbol_name(world.curjob->curfile, - sym + symid); - - rhash = elfsh_get_symbol_hash(name); - hash = rhash % nbucket; - - if (symid == STN_UNDEF) - { - revm_hashunk(index); - continue; - } - - revm_hashchain_print(index, symid, name, rhash, hash); - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment. - * - * - */ -int cmd_hashx() -{ - elfshsect_t *sect; - elfsh_Sym *sym; - char logbuf[BUFSIZ]; - eresi_Addr range = 0; - int nbr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - sym = elfsh_get_dynsymtab(world.curjob->curfile, NULL); - if (sym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get DYNSYM", 0); - if (!elfsh_get_hashtable(world.curjob->curfile, NULL)) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Cannot get .hash section", 0); - - snprintf(logbuf, BUFSIZ - 1, - " [HASH SYMBOL TABLE]\n [Object %s]\n\n", - world.curjob->curfile->name); - - revm_output(logbuf); - revm_endline(); - - sect = elfsh_get_hashtable_by_range(world.curjob->curfile, range, &nbr); - - while (sect != NULL) - { - revm_hashprint(sect, sym, nbr); - sect = elfsh_get_hashtable_by_range(world.curjob->curfile, ++range, &nbr); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/hdr.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/hdr.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/hdr.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/hdr.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,211 +0,0 @@ -/** - * @file elf.c for elfsh - * - * Started on Fri Nov 2 15:21:14 2001 jfv - * Last update Thu Mar 11 15:02:24 2004 jfv - * - * $Id: hdr.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - - -/** - * Change ELFCLASS and ELFMAGIC if necessary - * @param header - */ -static void *revm_hdrfixup(elfsh_Ehdr *header) -{ - char c; - char *h; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - h = (char *) header; - if (world.state.revm_mode != REVM_STATE_SCRIPT) - { - snprintf(logbuf, BUFSIZ - 1, " [!] ELFsh has detected a bogus or unsupported " - "header in this object\n" - " [!] Next input may be erroneous data\n"); - revm_output(logbuf); - again: - snprintf(logbuf, BUFSIZ - 1, " [!] Fixup header and continue ? (y/n) "); - revm_output(logbuf); - c = getc(stdin); - if (c != 'y' && c != 'n') - goto again; - else if (c == 'n') - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "ELF header remained unfixed", (NULL)); - } - elfsh_set_magic(header, *(u_int *) ELFMAG); - h[EI_CLASS] = ELFCLASS32; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (h)); -} - -/** - * Need doxygen comment - * @param file - * @return - */ - -static char *revm_printostype(elfshobj_t *file) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_ostype(file)) - { - case ELFSH_OS_LINUX: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("Linux")); - case ELFSH_OS_NETBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("NetBSD")); - case ELFSH_OS_FREEBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("FreeBSD")); - case ELFSH_OS_OPENBSD: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("OpenBSD")); - case ELFSH_OS_SOLARIS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("Solaris")); - case ELFSH_OS_BEOS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("Beos")); - case ELFSH_OS_ERROR: - default: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ("Unknown")); - } -} - - -/** - * Display the elf header - */ -int cmd_elf() -{ - elfsh_Ehdr *header; - u_int archnum; - u_int typenum; - u_int enconum; - char *type; - char *arch; - char *enco; - char *name; - elfsh_SAddr offset; - char enco_unk[ELFSH_MEANING + 1]; - char type_unk[ELFSH_MEANING + 1]; - char arch_unk[ELFSH_MEANING + 1]; - u_int magic; - char buf[BUFSIZ]; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch ELF header */ - header = elfsh_get_hdr(world.curjob->curfile); - if (header == NULL) - RET(-1); - - /* Fixup the header and print it again if requested */ - if (elfsh_get_magic(header) != *(u_int *) ELFMAG || - (elfsh_get_class(header) != ELFCLASS32 && - elfsh_get_class(header) != ELFCLASS64)) - { - header = revm_hdrfixup(header); - if (header == NULL) - RET(-1); - } - - /* Resolve entry point */ - magic = elfsh_get_magic(header); - - //name = elfsh_reverse_metasym(world.curjob->curfile, header->e_entry, &offset); - name = NULL; - if (name != NULL) - { - if (offset != 0) - snprintf(buf, sizeof(buf), "%s + %u", name, (u_int) offset); - else - snprintf(buf, sizeof(buf), "%s", name); - } - - - /* Retreive names from the ELF header */ - archnum = elfsh_get_arch(header); - typenum = elfsh_get_objtype(header); - enconum = elfsh_get_encoding(header); - arch = (char *) (archnum >= ELFSH_ARCHTYPE_MAX ? - revm_build_unknown(arch_unk, "type", archnum) : - elfsh_arch_type[archnum]); - type = (char *) (typenum >= ELFSH_OBJTYPE_MAX ? - revm_build_unknown(type_unk, "type", typenum) : - elfsh_obj_type[typenum].desc); - enco = (char *) (enconum >= ELFSH_ENCODING_MAX ? - revm_build_unknown(enco_unk, "type", enconum) : - elfsh_encoding[enconum].desc); - - snprintf(logbuf, BUFSIZ - 1, - "\n [ELF HEADER]\n [Object %s, MAGIC 0x%08X]\n\n", - world.curjob->curfile->name, magic); - revm_output(logbuf); - - snprintf(logbuf, BUFSIZ, - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s\n" - " {%s = %s}\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n" - " %s : %s %s : %s\n\n", - revm_colorfieldstr_fmt("%-20s", "Architecture"), - revm_colorstr_fmt("%18s", arch), - revm_colorfieldstr_fmt("%-20s", "ELF Version"), - revm_colornumber("%14u", (u_int) header->e_version), - revm_colorfieldstr_fmt("%-20s", "Object type"), - revm_colorstr_fmt("%18s", type), - revm_colorfieldstr_fmt("%-20s", "SHT strtab index"), - revm_colornumber("%14u", header->e_shstrndx), - revm_colorfieldstr_fmt("%-20s", "Data encoding"), - revm_colorstr_fmt("%18s", enco), - revm_colorfieldstr_fmt("%-20s", "SHT foffset"), - revm_colornumber(UFMT14, header->e_shoff), - revm_colorfieldstr_fmt("%-20s", "PHT foffset"), - revm_colornumber(UFMT18, header->e_phoff), - revm_colorfieldstr_fmt("%-20s", "SHT entries number"), - revm_colornumber("%14u", header->e_shnum), - revm_colorfieldstr_fmt("%-20s", "PHT entries number"), - revm_colornumber("%18u", header->e_phnum), - revm_colorfieldstr_fmt("%-20s", "SHT entry size"), - revm_colornumber("%14u", header->e_shentsize), - revm_colorfieldstr_fmt("%-20s", "PHT entry size"), - revm_colornumber("%18u", header->e_phentsize), - revm_colorfieldstr_fmt("%-20s", "ELF header size"), - revm_colornumber("%14u", header->e_ehsize), - revm_colorfieldstr_fmt("%-20s", "Runtime PHT offset"), - revm_colornumber("%18u", elfsh_get_rphtoff(header)), - revm_colorfieldstr_fmt("%-20s", "Fingerprinted OS"), - revm_colorstr_fmt("%14s", revm_printostype(world.curjob->curfile)), - revm_colorfieldstr_fmt("%-20s", "Entry point"), - revm_coloraddress(XFMT18, header->e_entry), - (name != NULL ? revm_colorstr_fmt("[%s]", buf) : revm_colorwarn("[?]")), - revm_colorstr("OLD PAX FLAGS"), - revm_coloraddress("0x%X", header->e_flags), - revm_colorfieldstr_fmt("%-20s", "PAX_PAGEEXEC"), - revm_colorstr_fmt("%18s", (elfsh_get_pax_pageexec(header) ? "Enabled" : "Disabled")), - revm_colorfieldstr_fmt("%-20s", "PAX_EMULTRAMP"), - revm_colorstr_fmt("%14s", (elfsh_get_pax_emultramp(header) ? "Emulated" : "Not emulated")), - revm_colorfieldstr_fmt("%-20s", "PAX_MPROTECT"), - revm_colorstr_fmt("%18s", (elfsh_get_pax_mprotect(header) ? "Restricted" : "Not restricted")), - revm_colorfieldstr_fmt("%-20s", "PAX_RANDMAP"), - revm_colorstr_fmt("%14s", (elfsh_get_pax_randmmap(header) ? "Randomized" : "Not randomized")), - revm_colorfieldstr_fmt("%-20s", "PAX_RANDEXEC"), - revm_colorstr_fmt("%18s", (elfsh_get_pax_randexec(header) ? "Randomized" : "Not randomized")), - revm_colorfieldstr_fmt("%-20s", "PAX_SEGMEXEC"), - revm_colorstr_fmt("%14s", (elfsh_get_pax_segmexec(header) ? "Enabled" : "Disabled"))); - revm_output(logbuf); - revm_endline(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/interp.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/interp.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/interp.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/interp.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/** -** @file interp.c -** -** Started on Fri Nov 2 15:20:41 2001 jfv -** Last update Wed Mar 10 12:21:34 2004 jfv -** -** $Id: interp.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - - - -/** - * @brief Display the interpretor (.interp) section - */ -int cmd_interp() -{ - char *name; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if ((name = elfsh_get_interp(world.curjob->curfile)) == NULL) - RET(-1); - snprintf(logbuf, BUFSIZ - 1, "\n [SHT_INTERP] : %s \n\n", name); - revm_output(logbuf); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -## -## Makefile for elf in librevm for the ELF shell project -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## -include ../../config.h - -SRC = comment.c ctors.c core.c data.c deps.c disasm.c dtors.c dyn.c \ - findrel.c flush.c got.c hash.c hdr.c interp.c notes.c \ - pht.c rel.c sht.c sym.c version.c -OBJ32 = $(SRC:.c=.32.o) -OBJ64 = $(SRC:.c=.64.o) -CC ?= gcc -LD ?= ld -RM = rm -f -NAME32 = ../revm-elf.32.o -NAME64 = ../revm-elf.64.o - -CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ - -I../../libmjollnir/include/ -I../../libaspect/include/ \ - -I../../libedfmt/include/ -I../../librevm/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI32 \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ - -I../../libelfsh/include/ -I../../elibc/include/ \ - -I../../libdump/include/ -I../../libasm/include/ \ - -I/usr/pkg/include/ -I../../libaspect/include/ \ - -I../../libui/include/ -I../../libmjollnir/include/ \ - -I../../libedfmt/include/ -I../../librevm/include/ \ - $(KERNSHINCINC) $(KERNSH) \ - -DELFSH_INTERN $(STATOPT2) $(ASMOPT) -DERESI64 $(BUILDOP) \ - -I../../e2dbg/include/ $(NCURSESLNOPT) $(READLNOPT) - -all : all32 all64 - -$(NAME32) : $(OBJ32) - $(LD) -r $(OBJ32) -o $(NAME32) - -$(NAME64) : $(OBJ64) - $(LD) -r $(OBJ64) -o $(NAME64) - -all32: $(NAME32) -all64: $(NAME64) - -clean : - @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/notes.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/notes.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/notes.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/notes.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/** -** @file notes.c -** -** Started on Fri Nov 2 15:20:58 2001 jfv -** -** -** $Id: notes.c,v 1.2 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/** - * @brief Display the note section - */ -int cmd_notes() -{ - elfshsect_t *sect; - elfshnotent_t *e; - regex_t *tmp; - int index; - int range; - char buff[256]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - snprintf(buff, sizeof(buff), - " [SHT_NOTES]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(buff); - - FIRSTREGX(tmp); - range = 0; - sect = elfsh_get_notes(world.curjob->curfile, range); - if (!sect) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get notes", (-1)); - - while (sect) - { - snprintf(buff, sizeof(buff), - " {Section %s} \n", elfsh_get_section_name(world.curjob->curfile, sect)); - revm_output(buff); - for (index = 0, e = sect->altdata; e; e = e->next, index++) - { - snprintf(buff, sizeof(buff), " [%02u] \t NOTES_ENTRY(%s)\n", - index, e->note); - if (!tmp || (tmp && e->note && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - } - revm_output("\n"); - range++; - sect = elfsh_get_notes(world.curjob->curfile, range); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/pht.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/pht.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/pht.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/pht.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,279 +0,0 @@ -/** - * @file pht.c - * - * Started on Fri Nov 2 15:18:35 2001 jfv - * - * - * $Id: pht.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - - -/** - * @brief Display description for extended PHT types - * @param type - */ -char *revm_display_pdesc(u_int type) -{ - u_int idx; - char type_unk[ELFSH_MEANING + 1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; idx < ELFSH_EXTSEG_MAX; idx++) - if (elfsh_extseg_type[idx].val == type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) elfsh_extseg_type[idx].desc)); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - revm_build_unknown(type_unk, "type", type)); -} - - -/** - * @brief Display name for extended PHT types - * @param type - */ -char *revm_display_pname(u_int type) -{ - u_int idx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (idx = 0; idx < ELFSH_EXTSEG_MAX; idx++) - if (elfsh_extseg_type[idx].val == type) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) elfsh_extseg_type[idx].name)); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - "Unknown"); -} - - -/** - * @brief Display a PHT - * @param phdr - * @param num - * @param base - */ -void revm_pht_print(elfsh_Phdr *phdr, uint16_t num, eresi_Addr base) -{ - elfsh_Shdr *shdr; - int shtnum; - int index; - int index2; - char *type; - u_int typenum; - elfshsect_t *list; - regex_t *tmp; - char buff[512]; - char warnmsg[256]; - char logbuf[BUFSIZ]; - int check; - - eresi_Addr addr; - eresi_Addr addr_end; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - FIRSTREGX(tmp); - - /* Primary view (2 modes, depending on the quiet flag) */ - for (index = 0; index < num; index++) - { - - typenum = elfsh_get_segment_type(phdr + index); - type = (char *) (typenum >= ELFSH_SEGTYPE_MAX ? - revm_display_pdesc(typenum) : - elfsh_seg_type[typenum].desc); - - addr = phdr[index].p_vaddr; - addr_end = phdr[index].p_vaddr + phdr[index].p_memsz; - if (elfsh_is_debug_mode()) - { - addr_end += base; - addr += base; - } - - /* We check if we have a correct alignment */ - check = (addr - phdr[index].p_offset) & (phdr[index].p_align - 1); - - if (check != 0) - snprintf(warnmsg, 255, "Wrong alignment (%d)", check); - - if (!world.state.revm_quiet) - snprintf(buff, sizeof(buff), - " %s %s -> %s %c%c%c %s%s%s " - "%s%s%s %s%s%s %s%s%s => %s %s\n", - revm_colornumber("[%02u]", index), - revm_coloraddress(XFMT, addr), - revm_coloraddress(XFMT, addr_end), - (elfsh_segment_is_readable(&phdr[index]) ? 'r' : '-'), - (elfsh_segment_is_writable(&phdr[index]) ? 'w' : '-'), - (elfsh_segment_is_executable(&phdr[index]) ? 'x' : '-'), - revm_colorfieldstr("memsz("), - revm_colornumber(UFMT, phdr[index].p_memsz), - revm_colorfieldstr(")"), - revm_colorfieldstr("foffset("), - revm_colornumber(UFMT, phdr[index].p_offset), - revm_colorfieldstr(")"), - revm_colorfieldstr("filesz("), - revm_colornumber(UFMT, phdr[index].p_filesz), - revm_colorfieldstr(")"), - revm_colorfieldstr("align("), - revm_colornumber(UFMT, phdr[index].p_align), - revm_colorfieldstr(")"), - revm_colortypestr(type), - check != 0 ? revm_colorwarn(warnmsg) : "" - ); - - else - snprintf(buff, sizeof(buff), - " %s %s -> %s %c%c%c %s%s%s " - "%s%s%s %s%s%s\n", - revm_colornumber("[%02u]", index), - revm_coloraddress(XFMT, addr), - revm_coloraddress(XFMT, addr_end), - (elfsh_segment_is_readable(&phdr[index]) ? 'r' : '-'), - (elfsh_segment_is_writable(&phdr[index]) ? 'w' : '-'), - (elfsh_segment_is_executable(&phdr[index]) ? 'x' : '-'), - revm_colorfieldstr("memsz("), - revm_colornumber(UFMT, phdr[index].p_memsz), - revm_colorfieldstr(")"), - revm_colorfieldstr("foffset("), - revm_colornumber(UFMT, phdr[index].p_offset), - revm_colorfieldstr(")"), - revm_colorfieldstr("filesz("), - revm_colornumber(UFMT, phdr[index].p_filesz), - revm_colorfieldstr(")")); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - - revm_endline(); - - } - - snprintf(logbuf, BUFSIZ - 1, - "\n [SHT correlation]" - "\n [Object %s]\n\n", world.curjob->curfile->name); - revm_output(logbuf); - - /* Retreive the sht */ - if ((shdr = elfsh_get_sht(world.curjob->curfile, &shtnum)) == 0) - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); - - snprintf(logbuf, BUFSIZ - 1, " [*] SHT %s \n", - (world.curjob->curfile->shtrb ? - "has been rebuilt \n" : - "is not stripped \n")); - revm_output(logbuf); - - /* Alternate View */ - for (index = 0; index < num; index++, index2 = 0) - { - typenum = elfsh_get_segment_type(phdr + index); - type = (char *) (typenum >= ELFSH_SEGTYPE_MAX ? - revm_display_pname(typenum) : - elfsh_seg_type[typenum].name); - - snprintf(logbuf, BUFSIZ - 1, " %s %s \t", - revm_colornumber("[%02u]", index), - revm_colortypestr_fmt("%-10s", type)); - revm_output(logbuf); - - revm_endline(); - - /* In SHT */ - for (index2 = 0, list = world.curjob->curfile->sectlist; - list; list = list->next) - if (elfsh_segment_is_parent(list, phdr + index)) - { - index2++; - snprintf(logbuf, BUFSIZ - 1, "%s%s ", - (list->shdr->sh_offset + list->shdr->sh_size > - phdr[index].p_offset + phdr[index].p_filesz ? "|" : ""), - revm_colorstr(elfsh_get_section_name(world.curjob->curfile, list))); - revm_output(logbuf); - - revm_endline(); - } - - /* In RSHT */ - for (index2 = 0, list = world.curjob->curfile->rsectlist; - list; list = list->next) - if (elfsh_segment_is_parent(list, phdr + index)) - { - index2++; - snprintf(logbuf, BUFSIZ - 1, "%s%s ", - (list->shdr->sh_addr + list->shdr->sh_size > - phdr[index].p_vaddr + phdr[index].p_memsz ? "|" : ""), - revm_colorstr(elfsh_get_section_name(world.curjob->curfile, list))); - revm_output(logbuf); - - revm_endline(); - } - - revm_output("\n"); - } - - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * @brief Display the program header table (PHT) - */ -int cmd_pht() -{ - elfsh_Phdr *phdr; - char logbuf[BUFSIZ]; - int num; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch and Print PHT */ - if ((phdr = elfsh_get_pht(world.curjob->curfile, &num)) == 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to get PHT", -1); - - snprintf(logbuf, BUFSIZ - 1, - " [Program Header Table .::. PHT]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - revm_pht_print(phdr, num, world.curjob->curfile->rhdr.base); - - /* End */ - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief Print the runtime PHT - */ -int cmd_rpht() -{ - elfsh_Phdr *phdr; - char logbuf[BUFSIZ]; - int num; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch and Print Runtime (alternative) PHT */ - if ((phdr = elfsh_get_rpht(world.curjob->curfile, &num)) == 0) - RET(-1); - snprintf(logbuf, BUFSIZ, - "\n [Runtime Program Header Table .::. RPHT]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - revm_pht_print(phdr, num, world.curjob->curfile->rhdr.base); - - /* End */ - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/rel.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/rel.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/rel.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,208 +0,0 @@ -/** - * @file rel.c - * - * Started on Fri Nov 2 15:19:19 2001 jfv - * - * - * $Id: rel.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - -/** - * @brief Choose relocation tables strings array giving the architecture - * @param file - */ -revmconst_t *revm_getrelascii(elfshobj_t *file) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - /* XXX: case EM_486: */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_rel_type_i386)); - case EM_SPARC: - case EM_SPARC32PLUS: - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_rel_type_sparc)); - case EM_ALPHA: -#if EM_ALPHA != EM_ALPHA_EXP - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_rel_type_alpha)); - case EM_IA_64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_rel_type_ia64)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (elfsh_rel_type_mips)); - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Relocations ASCII tables not available", (NULL)); - } -} - - -/** - * @brief Return the max number of relocation type for this architecture - * @param file - */ -int revm_getmaxrelnbr(elfshobj_t *file) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - switch (elfsh_get_arch(file->hdr)) - { - case EM_386: - /* XXX: case EM_486: */ - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_i386_MAX)); - case EM_SPARC: - case EM_SPARC32PLUS: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_SPARC_MAX)); - case EM_SPARCV9: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_SPARC64_MAX)); - case EM_ALPHA: -#if EM_ALPHA != EM_ALPHA_EXP - case EM_ALPHA_EXP: -#endif - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_ALPHA_MAX)); - case EM_IA_64: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_IA64_MAX)); - case EM_MIPS: - case EM_MIPS_RS3_LE: - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ELFSH_RELOC_MIPS_MAX)); - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Unknown architecture", (-1)); - } -} - - -/** - * @brief Display relocation entries - */ -int cmd_rel() -{ - elfshsect_t *sect; - elfsh_Rel *rel; - regex_t *tmp; - char *type; - char *typeshort; - char *name; - u_int index; - u_int index2; - u_int typenum; - char buff[256]; - u_int size; - revmconst_t *types; - char addstr[32]; - char logbuf[BUFSIZ]; - void *data; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - sect = elfsh_get_reloc(world.curjob->curfile, 0, &size); - if (sect == NULL) - RET(-1); - - /* Choose between global or local regx */ - FIRSTREGX(tmp); - snprintf(logbuf, BUFSIZ - 1, " [RELOCATION TABLES]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - - /* We need to iterate as much as there is .rel* sections */ - for (index2 = 0; sect; index2++) - { - - snprintf(logbuf, BUFSIZ - 1, - " {Section %s} \n", elfsh_get_section_name(world.curjob->curfile, sect)); - revm_output(logbuf); - - /* Iterate on the .rel entries array for each .rel section */ - data = elfsh_get_raw(sect); - for (index = 0; index < size; index++) - { - - /* Get the current relocation entry */ - if (sect->shdr->sh_type == SHT_RELA) - { - - rel = (void *) ((elfsh_Rela *) data + index); - snprintf(addstr, sizeof(addstr), "add[%s]", - revm_colornumber("%08u", (unsigned int) ((elfsh_Rela *) rel)->r_addend)); - } - else - { - rel = (elfsh_Rel *) data + index; - addstr[0] = 0x00; - } - - - /* Get linked symbol name */ - name = elfsh_get_symname_from_reloc(world.curjob->curfile, rel); - typenum = elfsh_get_reltype(rel); - types = revm_getrelascii(world.curjob->curfile); - - type = (char *) (typenum > ELFSH_RELOC_MAX(world.curjob->curfile) ? NULL : - types[typenum].desc); - typeshort = (char *) (typenum > ELFSH_RELOC_MAX(world.curjob->curfile) ? NULL : - types[typenum].name); - - /* Output is different depending on the quiet flag */ - if (!world.state.revm_quiet) - snprintf(buff, sizeof(buff), - " [%s] %s %s %s%s%s : %s %s => %s\n", - revm_colornumber("%03u", index), - revm_colortypestr_fmt("%-15s", typeshort), - revm_coloraddress(XFMT, elfsh_get_reloffset(rel)), - revm_colorfieldstr("sym["), - revm_colornumber("%03u", elfsh_get_relsym(rel)), - revm_colorfieldstr("]"), - (name != NULL ? revm_colorstr_fmt("%-30s", name) : revm_colorwarn_fmt("%-30s", "")), addstr, - revm_colortypestr(type)); - else - snprintf(buff, sizeof(buff), - " [%s] %s %s %s%s%s : %s %s\n", - revm_colornumber("%03u", index), - revm_colortypestr_fmt("%-15s", typeshort), - revm_coloraddress(XFMT, elfsh_get_reloffset(rel)), - revm_colorfieldstr("sym["), - revm_colornumber("%03u", elfsh_get_relsym(rel)), - revm_colorfieldstr("]"), - (name != NULL ? revm_colorstr_fmt("%-22s", name) : revm_colorwarn_fmt("%-22s", "")), - addstr); - - /* Print it if it matchs the regex */ - if (NULL == tmp || (tmp != NULL && name != NULL && - 0 == regexec(tmp, buff, 0, 0, 0))) - switch (revm_output(buff)) - { - case -1: - revm_endline(); - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - case -2: - revm_endline(); - goto next; - } - - revm_endline(); - } - - next: - sect = elfsh_get_reloc(world.curjob->curfile, index2 + 1, &size); - revm_output("\n"); - } - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/sht.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/sht.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/sht.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/sht.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,196 +0,0 @@ -/** - * @file sht.c - * - * Started on Fri Nov 2 15:17:58 2001 jfv - * - * - * $Id: sht.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - -/** - * Find the right sht type name - * @param typenum - */ -char *revm_fetch_sht_typedesc(elfsh_Word typenum) -{ - char *ret = NULL; - u_int index; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < ELFSH_SHTYPE_MAX; index++) - { - if (elfsh_sh_type[index].val == (eresi_Addr) typenum) - { - ret = (char *) elfsh_sh_type[index].desc; - break; - } - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); -} - - -/** - * Display The Section header table (SHT) - * @param shdr - * @param num - * @param rtflag - * @return - */ -int revm_sht_print(elfsh_Shdr *shdr, u_int num, char rtflag) -{ - elfshsect_t *cur; - regex_t *tmp; - char *name; - char *type; - char buff[BUFSIZ]; - u_int index; - elfsh_Word typenum; - char type_unk[ELFSH_MEANING + 1]; - eresi_Addr addr; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch SHT and choose regex */ - FIRSTREGX(tmp); - - /* Iterate as much as there is entries in SHT */ - for (index = 0; index < num; index++) - { - - /* Get section type */ - typenum = elfsh_get_section_type(shdr + index); - type = revm_fetch_sht_typedesc(typenum); - - if (!type) - type = revm_build_unknown(type_unk, "type", (u_long) typenum); - - if (!type) - type = ELFSH_NULL_STRING; - - /* Get section name */ - if (!rtflag) - cur = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); - else - cur = elfsh_get_rsection_by_index(world.curjob->curfile, index, NULL, NULL); - name = elfsh_get_section_name(world.curjob->curfile, cur); - if (name == NULL) - name = ELFSH_NULL_STRING; - - /* Compute section address */ - /* Base for ET_EXEC is always 0 */ - addr = (elfsh_is_debug_mode() && !elfsh_section_is_runtime(cur) ? - world.curjob->curfile->rhdr.base + elfsh_get_section_addr(shdr + index) : - elfsh_get_section_addr(shdr + index)); - - /* Output is different depending on the quiet flag */ - if (!world.state.revm_quiet) - snprintf(buff, sizeof(buff), - " %s %s %c%c%c%c%c%c%c %s " - "%s%s %s%s %s%s %s%s " - "%s%s %s%s => %s\n", - revm_colornumber("[%03u]", index), revm_coloraddress(XFMT, addr), - (elfsh_get_section_allocflag(shdr + index) ? 'a' : '-'), - (elfsh_get_section_writableflag(shdr + index) ? 'w' : '-'), - (elfsh_get_section_execflag(shdr + index) ? 'x' : '-'), - (elfsh_get_section_mergeableflag(shdr + index) ? 'm' : '-'), - (elfsh_get_section_strflag(shdr + index) ? 's' : '-'), - (elfsh_get_section_linkflag(shdr + index) ? 'l' : '-'), - (elfsh_get_section_orderflag(shdr + index) ? 'o' : '-'), - (name != NULL ? revm_colorstr_fmt("%-30s", name) : ELFSH_NULL_STRING), - revm_colorfieldstr("foffset:"), - revm_colornumber(UFMT, elfsh_get_section_foffset(shdr + index)), - revm_colorfieldstr("size:"), - revm_colornumber("%08u", elfsh_get_section_size(shdr + index)), - revm_colorfieldstr("link:"), - revm_colornumber("%02u", elfsh_get_section_link(shdr + index)), - revm_colorfieldstr("info:"), - revm_colornumber("%04u", elfsh_get_section_info(shdr + index)), - revm_colorfieldstr("entsize:"), - revm_colornumber("%04u", elfsh_get_section_entsize(shdr + index)), - revm_colorfieldstr("align:"), - revm_colornumber("%04u", elfsh_get_section_align(shdr + index)), - revm_colortypestr(type)); - else - snprintf(buff, sizeof(buff), - " %s %s %c%c%c%c%c%c%c %s %s%s %s%s %s%s\n", - revm_colornumber("[%03u]", index), revm_coloraddress(XFMT, addr), - (elfsh_get_section_allocflag(shdr + index) ? 'a' : '-'), - (elfsh_get_section_writableflag(shdr + index) ? 'w' : '-'), - (elfsh_get_section_execflag(shdr + index) ? 'x' : '-'), - (elfsh_get_section_mergeableflag(shdr + index) ? 'm' : '-'), - (elfsh_get_section_strflag(shdr + index) ? 's' : '-'), - (elfsh_get_section_linkflag(shdr + index) ? 'l' : '-'), - (elfsh_get_section_orderflag(shdr + index) ? 'o' : '-'), - (name != NULL ? revm_colorstr_fmt("%-15s", name) : ELFSH_NULL_STRING), - revm_colorfieldstr("foff:"), - revm_colornumber(UFMT, elfsh_get_section_foffset(shdr + index)), - revm_colorfieldstr("sz:"), - revm_colornumber("%08u", elfsh_get_section_size(shdr + index)), - revm_colorfieldstr("link:"), - revm_colornumber("%02u", elfsh_get_section_link(shdr + index))); - - if (!tmp || (tmp && !regexec(tmp, buff, 0, 0, 0))) - revm_output(buff); - revm_endline(); - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Print section header table - */ -int cmd_sht() -{ - elfsh_Shdr *shdr; - int num; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch SHT and choose regex */ - shdr = elfsh_get_sht(world.curjob->curfile, &num); - if (shdr == NULL) - QUIT_ERROR(-1); - snprintf(logbuf, BUFSIZ - 1, " [SECTION HEADER TABLE .::. SHT %s]\n" - " [Object %s]\n\n", - (world.curjob->curfile->shtrb ? "has been rebuilt" : "is not stripped"), - world.curjob->curfile->name); - revm_output(logbuf); - revm_sht_print(shdr, num, 0); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Print runtime section header table - */ -int cmd_rsht() -{ - elfsh_Shdr *shdr; - int num; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Fetch RSHT */ - shdr = elfsh_get_runtime_sht(world.curjob->curfile, &num); - if (shdr == NULL) - QUIT_ERROR(-1); - - snprintf(logbuf, BUFSIZ - 1, - " [RUNTIME SECTION HEADER TABLE .::. RSHT resides in memory only]\n" - " [Object %s]\n\n", world.curjob->curfile->name); - revm_output(logbuf); - revm_sht_print(shdr, num, 1); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/sym.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/sym.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/sym.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/sym.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,252 +0,0 @@ -/** - * @file sym.c - * - * Started on Fri Nov 2 15:19:38 2001 jfv - * - * - * $Id: sym.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - - - - -/** - * Print the chosen symbol table - * @param file - * @param sect - * @param tab - * @param num - * @param regx - * @param get_symname - * @return - */ -int ds(elfshobj_t *file, - elfshsect_t *sect, - elfsh_Sym *tab, - u_int num, - regex_t *regx, - char *(*get_symname)(elfshobj_t *f, elfsh_Sym *s)) -{ - elfsh_Sym *table; - char *name; - char *type; - char *bind; - u_int typenum; - u_int bindnum; - u_int foff; - int index; - char *sect_name; - char buff[512]; - char off[20]; - char type_unk[ELFSH_MEANING + 1]; - char bind_unk[ELFSH_MEANING + 1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sort the table if necessary */ - if (world.state.sort != NULL) - switch (*world.state.sort) - { - case ELFSH_SORT_BY_ADDR: - table = sect->altdata; - break; - case ELFSH_SORT_BY_SIZE: - table = sect->terdata; - break; - default: - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unknown sort mode", -1); - } - - /* Avoid reading inexistant memory in the process for .symtab */ - else - table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_get_raw(sect) : sect->data); - - /* Browse symtab */ - for (index = 0; index < num; index++) - { - - /* Retreive names */ - typenum = elfsh_get_symbol_type(table + index); - bindnum = elfsh_get_symbol_bind(table + index); - type = (char *) (typenum > ELFSH_SYMTYPE_MAX ? - revm_build_unknown(type_unk, "type", typenum) : - elfsh_sym_type[typenum].desc); - bind = (char *) (bindnum >= ELFSH_SYMBIND_MAX ? - revm_build_unknown(bind_unk, "type", bindnum) : - elfsh_sym_bind[bindnum].desc); - name = get_symname(world.curjob->curfile, table + index); - sect_name = NULL; - sect = elfsh_get_parent_section(world.curjob->curfile, - table[index].st_value, - NULL); - if (sect == NULL && table[index].st_shndx) - sect = elfsh_get_section_by_index(world.curjob->curfile, - table[index].st_shndx, - NULL, NULL); - if (sect != NULL) - sect_name = elfsh_get_section_name(world.curjob->curfile, sect); - - /* Fixup names */ - if (name == NULL || *name == 0) - name = ELFSH_NULL_STRING; - if (type == NULL || *type == 0) - type = ELFSH_NULL_STRING; - if (bind == NULL || *bind == 0) - bind = ELFSH_NULL_STRING; - if (sect_name == NULL) - sect_name = ELFSH_NULL_STRING; - foff = (!table[index].st_value ? 0 : - elfsh_get_foffset_from_vaddr(world.curjob->curfile, - table[index].st_value)); - - if (sect && sect->shdr->sh_addr != table[index].st_value) - sprintf(off, " + %s", revm_colornumber("%u", - (u_int) (table[index].st_value - sect->shdr->sh_addr))); - else - *off = '\0'; - - /* Different output depending on the quiet flag */ - if (!world.state.revm_quiet) - { - snprintf(buff, sizeof(buff), - " %s %s %s %s %s%s " - "%s%s %s%s %s%s => %s%s\n", - revm_colornumber("[%03u]", index), - revm_coloraddress(XFMT, (eresi_Addr) elfsh_get_symbol_value(table + index) + file->rhdr.base), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-40s", name), - revm_colorfieldstr("size:"), - revm_colornumber("%010u", elfsh_get_symbol_size(table + index)), - revm_colorfieldstr("foffset:"), - revm_colornumber("%06u", foff), - revm_colorfieldstr("scope:"), - revm_colortypestr_fmt("%-6s", bind), - revm_colorfieldstr("sctndx:"), - revm_colornumber("%02u", elfsh_get_symbol_link(table + index)), - revm_colorstr(sect_name), off); - } - - else - { - snprintf(buff, sizeof(buff), - " %s %s %s %s %s%s %s%s %s%-6s\n", - revm_colornumber("[%03u]", index), - revm_coloraddress(XFMT, (eresi_Addr) elfsh_get_symbol_value(table + index) + file->rhdr.base), - revm_colortypestr_fmt("%-8s", type), revm_colorstr_fmt("%-15s", name), - revm_colorfieldstr("sz:"), - revm_colornumber("%06u", elfsh_get_symbol_size(table + index)), - revm_colorfieldstr("foff:"), - revm_colornumber("%06u", foff), - revm_colorfieldstr("scop:"), - revm_colortypestr_fmt("%-6s", bind)); - } - - if (regx == NULL || - (regx != NULL && regexec(regx, buff, 0, 0, 0) == 0)) - { - /* If the user ask quit, we just break */ - if (revm_output(buff) == -1) - break; - } - - revm_endline(); - - } - - revm_endline(); - - revm_output("\n"); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - - -/** - * Display the symbol table - */ -int cmd_sym() -{ - elfshsect_t *sct; - elfsh_Sym *symtab; - regex_t *tmp; - int num; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - symtab = elfsh_get_symtab(world.curjob->curfile, &num); - if (symtab == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Can't retrieve symtab", -1); - - sct = elfsh_get_section_by_type(world.curjob->curfile, - SHT_SYMTAB, 0, NULL, NULL, 0); - snprintf(logbuf, BUFSIZ - 1, " [SYMBOL TABLE]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - FIRSTREGX(tmp); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ds(world.curjob->curfile, sct, symtab, - num, tmp, elfsh_get_symbol_name)); -} - - - - -/** - * Display the dynamic symbol table - */ -int cmd_dynsym() -{ - elfshsect_t *sct; - elfsh_Sym *dynsym; - regex_t *tmp; - int num; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dynsym = elfsh_get_dynsymtab(world.curjob->curfile, &num); - if (dynsym == NULL) - RET(-1); - else - { - sct = elfsh_get_section_by_name(world.curjob->curfile, - ELFSH_SECTION_NAME_ALTDYNSYM, - NULL, NULL, &num); - if (!sct) - sct = elfsh_get_section_by_type(world.curjob->curfile, SHT_DYNSYM, 0, - NULL, NULL, &num); - - if (!sct) - RET(-1); - num = num / sizeof(elfsh_Sym); - } - - snprintf(logbuf, BUFSIZ - 1, - " [DYNAMIC SYMBOL TABLE]\n [Object %s]\n [Section %s]\n", - world.curjob->curfile->name, sct->name); - - revm_output(logbuf); - FIRSTREGX(tmp); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ds(world.curjob->curfile, sct, dynsym, - num, tmp, elfsh_get_dynsymbol_name)); -} - - - - - - - - - - - - diff -Nru eresi-0.8a25/libstderesi/elf/.svn/text-base/version.c.svn-base eresi-0.0.20110516/libstderesi/elf/.svn/text-base/version.c.svn-base --- eresi-0.8a25/libstderesi/elf/.svn/text-base/version.c.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/.svn/text-base/version.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,604 +0,0 @@ -/** - * @file version.c - * - * Version feature - * - * Started on Sun Sep 25 15:20:18 2005 mxatone - * - * $Id: version.c,v 1.2 2008-02-16 12:32:27 thor Exp $ - * - */ -#include "libstderesi.h" - -/** - * Need doxygen comment. - * @param pneed - * @param pdef - * @param auxid - * @param index - * @param id - * @param name - * @param type - * @param regx - * @return - */ - -int revm_version_punk(hashneed_t *pneed, hashdef_t *pdef, - u_int auxid, u_int index, char *id, - char *name, char *type, regex_t *regx) -{ - char *svtype; - u_int vtype; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - vtype = (auxid <= STB_GLOBAL ? ELFSH_VERTYPE_NONE : ELFSH_VERTYPE_UNK); - svtype = (char*) elfsh_verentry_type[vtype].desc; - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-40s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("index:"), - id, - (pneed != NULL && pdef != NULL ? - revm_colorwarn("Conflict between need and def") : "")); - } - else - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-24s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("id:"), - id, - (pneed != NULL && pdef != NULL ? - revm_colorwarn("Conflict") : "")); - } - - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - revm_output(logbuf); - - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - -/** - * Need doxygen comment. - * @param pdef - * @param auxid - * @param index - * @param id - * @param name - * @param type - * @param regx - */ -int revm_version_pdef(hashdef_t *pdef, u_int auxid, - u_int index, char *id, char *name, - char *type, regex_t *regx) -{ - char *dauxnames[3]; - u_int vtype; - char *svtype; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - dauxnames[0] = dauxnames[1] = dauxnames[2] = NULL; - - elfsh_get_verdauxnamelist(world.curjob->curfile, - pdef, dauxnames, 2); - - vtype = (auxid <= STB_GLOBAL ? ELFSH_VERTYPE_NONE : ELFSH_VERTYPE_DEF); - svtype = (char*) elfsh_verentry_type[vtype].desc; - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s%s %s%s %s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-40s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("index:"), - id, - revm_colorfieldstr("nume:"), - revm_colornumber("%02u", pdef->def->vd_cnt), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", pdef->def->vd_hash), - (dauxnames && dauxnames[0] != NULL ? - revm_colorstr_fmt("%-14s", dauxnames[0]) : ""), - (dauxnames[1] != NULL ? - revm_colorstr(dauxnames[1]) : "")); - } - else - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s%s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-24s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("id:"), - id, - revm_colorfieldstr("nume:"), - revm_colornumber("%02u", pdef->def->vd_cnt), - (dauxnames && dauxnames[0] != NULL ? - revm_colorstr_fmt("%-10s", dauxnames[0]) : "")); - } - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - revm_output(logbuf); - - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment - * @param pneed - * @param auxid - * @param index - * @param id - * @param name - * @param type - * @param regx - * @return - */ -int revm_version_pneed(hashneed_t *pneed, u_int auxid, - u_int index, char *id, char *name, - char *type, regex_t *regx) -{ - char *file; - char *auxname; - char *svtype; - char logbuf[BUFSIZ]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - file = elfsh_get_verneedfile(world.curjob->curfile, - pneed->need); - auxname = elfsh_get_vernauxname(world.curjob->curfile, - pneed->aux); - svtype = (char*) elfsh_verentry_type[ELFSH_VERTYPE_NEED].desc; - - if (!world.state.revm_quiet) - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s%s %s%s %s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-40s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("index:"), - id, - revm_colorfieldstr("flag:"), - revm_colornumber("%02u", pneed->aux->vna_flags), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", pneed->aux->vna_hash), - revm_colorstr_fmt("%-14s", auxname), - revm_colorstr_fmt("%s", file)); - } - else - { - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s %s %s%s %s %s\n", - revm_colornumber("[%03u]", index), - revm_colortypestr_fmt("%-8s", type), - revm_colorstr_fmt("%-24s", name), - revm_colortypestr_fmt("%-7s", svtype), - revm_colorfieldstr("id:"), - id, - revm_colorstr_fmt("%-10s", auxname), - revm_colorstr_fmt("%s", file)); - } - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - revm_output(logbuf); - - revm_endline(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comments - * @param sym_table - * @param dsym_table - * @param symsize - * @param t_need - * @param t_def - * @param tmp - * @return - */ -int revm_version_print(elfsh_Half *sym_table, elfsh_Sym *dsym_table, - u_int symsize, hash_t *t_need, hash_t *t_def, - regex_t *tmp) -{ - elfshsect_t *dsym_sect; - u_int index; - char s_temp[9]; - u_int typenum; - char *name; - char *type; - u_int auxid; - hashneed_t *pneed; - hashdef_t *pdef; - char *id; - char type_unk[ELFSH_MEANING + 1]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - for (index = 0; index < symsize; index++) - { - /* Load tables */ - auxid = (u_int) *(sym_table + index); - snprintf(s_temp, 8, "%u", auxid); - pneed = hash_get(t_need, s_temp); - pdef = hash_get(t_def, s_temp); - - /* dynsym informations */ - typenum = elfsh_get_symbol_type(dsym_table + index); - type = (char *) (typenum >= ELFSH_SYMTYPE_MAX ? - revm_build_unknown(type_unk, "type", typenum) : - elfsh_sym_type[typenum].desc); - name = elfsh_get_dynsymbol_name(world.curjob->curfile, dsym_table + index); - - dsym_sect = elfsh_get_parent_section(world.curjob->curfile, - dsym_table[index].st_value, - NULL); - if (dsym_sect == NULL && dsym_table[index].st_shndx) - dsym_sect = elfsh_get_section_by_index(world.curjob->curfile, - dsym_table[index].st_shndx, - NULL, NULL); - - /* Set id numer/type */ - id = (auxid <= STB_GLOBAL ? - revm_colortypestr((char*) elfsh_sym_bind[auxid].desc) : - revm_colornumber("%02u", auxid)); - - /* Fixup names */ - if (name == NULL || *name == 0) - name = ELFSH_NULL_STRING; - if (type == NULL || *type == 0) - type = ELFSH_NULL_STRING; - - - if (pdef != NULL && pneed == NULL) - revm_version_pdef(pdef, auxid, index, id, name, type, tmp); - else if (pneed != NULL && pdef == NULL) - revm_version_pneed(pneed, auxid, index, id, name, type, tmp); - else - revm_version_punk(pneed, pdef, auxid, index, id, name, type, tmp); - - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, index > 0 ? 0 : -1); -} - -/** - * Need doxygen comment - */ -int cmd_version() -{ - elfshsect_t *sect; - void *need, *dynsym, *def; - int symsize, needsize, dsymsize, defsize; - int index, knum; - char logbuf[BUFSIZ]; - hash_t t_need, t_def; - char **keys; - regex_t *tmp; - u_int range = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Load dynsym table */ - dynsym = elfsh_get_dynsymtab(world.curjob->curfile, &dsymsize); - if (dynsym == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load dynsym section", -1); - - hash_init(&t_need, "versions_need", dsymsize, ASPECT_TYPE_UNKNOW); - hash_init(&t_def , "versions_defs", dsymsize, ASPECT_TYPE_UNKNOW); - - /* Load need table */ - need = elfsh_get_verneedtab(world.curjob->curfile, &needsize); - if (need == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load version need section", -1); - - if (elfsh_load_needtable(&t_need, need, needsize*sizeof(elfsh_Verneed)) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load version need section", -1); - - /* Load def table (we wanna know if a sym is for def or need) */ - def = elfsh_get_verdeftab(world.curjob->curfile, &defsize); - if (def != NULL) - { - if (elfsh_load_deftable(&t_def, def, defsize*sizeof(elfsh_Verdef)) != 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load version def section", -1); - } - - /* Load sym table */ - sect = elfsh_get_versymtab_by_range(world.curjob->curfile, 0, &symsize); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Version Symbol table", -1); - - snprintf(logbuf, BUFSIZ - 1, - " [VERSION SYMBOL TABLE]\n [Object %s]\n\n", - world.curjob->curfile->name); - revm_output(logbuf); - - FIRSTREGX(tmp); - - do { - snprintf(logbuf, BUFSIZ - 1, " {Section %s}\n", - elfsh_get_section_name(world.curjob->curfile, sect)); - revm_output(logbuf); - - if (revm_version_print(sect->data, dynsym, symsize, &t_need, &t_def, tmp) < 0) - revm_output("No entry found\n"); - - revm_output("\n"); - - sect = elfsh_get_versymtab_by_range(world.curjob->curfile, ++range, &symsize); - } while (sect != NULL); - - /* free need table */ - keys = hash_get_keys(&t_need, &knum); - - for (index = 0; keys[index] != NULL; index++) - hash_del(&t_need, keys[index]); - hash_destroy(&t_need); - - if (keys != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,keys); - - /* free def table */ - keys = hash_get_keys(&t_def, &knum); - for (index = 0; keys[index] != NULL; index++) - hash_del(&t_def, keys[index]); - hash_destroy(&t_def); - - if (keys != NULL) - XFREE(__FILE__, __FUNCTION__, __LINE__,keys); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment - */ -int cmd_verneed() -{ - elfshsect_t *sect; - void *data; - elfsh_Verneed *table; - elfsh_Vernaux *tableaux; - u_int offset; - u_int auxset; - int size; - u_int index; - u_int aux; - int strindex; - int nbr; - char logbuf[BUFSIZ]; - char *file; - char *auxname; - regex_t *regx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Load need table */ - data = elfsh_get_verneedtab(world.curjob->curfile, &size); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load Version Need table", -1); - - sect = elfsh_get_section_by_type(world.curjob->curfile, SHT_GNU_verneed, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Version Need section", 0); - - snprintf(logbuf, BUFSIZ - 1, - " [VERSION NEED TABLE]\n [Object %s]\n" - " [Section %s]\n\n", - world.curjob->curfile->name, sect->name); - - revm_output(logbuf); - - FIRSTREGX(regx); - - for (index = 0, offset = 0; offset < sect->shdr->sh_size; index++) - { - table = data + offset; - - file = elfsh_get_verneedfile(world.curjob->curfile, - table); - - snprintf(logbuf, BUFSIZ - 1, - " %s %s %s%s %s%s %s%s\n", - revm_colornumber("[%02u]", index), - revm_colorstr_fmt("%-11s", file), - revm_colorfieldstr("cnt:"), - revm_colornumber("%02u", table->vn_cnt), - revm_colorfieldstr("aux:"), - revm_colornumber("%02x", table->vn_aux), - revm_colorfieldstr("next:"), - revm_colornumber("%02x", table->vn_next)); - - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - { - if (index > 0) - revm_output("\n"); - - revm_output(logbuf); - revm_endline(); - } - - auxset = offset + table->vn_aux; - for (aux = 0; aux < table->vn_cnt; aux++) - { - tableaux = data + auxset; - - auxname = elfsh_get_vernauxname(world.curjob->curfile, - tableaux); - - snprintf(logbuf, BUFSIZ - 1, - " \t %s%s %s%s %s%s %s%s %s%s\n", - revm_colorfieldstr("index:"), - revm_colornumber("%02u", tableaux->vna_other), - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-20s", auxname), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", tableaux->vna_hash), - revm_colorfieldstr("flags:"), - revm_colornumber("%02u", tableaux->vna_flags), - revm_colorfieldstr("next:"), - revm_colornumber("%02x", tableaux->vna_next)); - - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - revm_output(logbuf); - - revm_endline(); - - if (tableaux->vna_next == 0) - break; - - auxset += tableaux->vna_next; - } - - if (table->vn_next == 0) - break; - - offset += table->vn_next; - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * Need doxygen comment - */ -int cmd_verdef() -{ - elfshsect_t *sect; - void *data; - elfsh_Verdef *table; - elfsh_Verdaux *tableaux; - int index, offset, num, aux, auxset; - int strindex; - int nbr; - char *auxname; - char logbuf[BUFSIZ]; - regex_t *regx; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - data = elfsh_get_verdeftab(world.curjob->curfile, &num); - if (data == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to load Version Def table", -1); - - sect = elfsh_get_section_by_type(world.curjob->curfile, SHT_GNU_verdef, 0, - NULL, &strindex, &nbr); - - if (sect == NULL) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to find Definition Version section", 0); - - snprintf(logbuf, BUFSIZ - 1, - " [VERSION DEFINITION TABLE]\n [Object %s]\n" - " [Section %s]\n\n", - world.curjob->curfile->name, sect->name); - - revm_output(logbuf); - - FIRSTREGX(regx); - - for (index = 0, offset = 0; offset < sect->shdr->sh_size; index++) - { - table = data + offset; - snprintf(logbuf, BUFSIZ - 1, - " %s %s%s %s%s %s%s %s%s %s%s %s%s\n", - revm_colornumber("[%02u]", index), - revm_colorfieldstr("index:"), - revm_colornumber("%02u", table->vd_ndx), - revm_colorfieldstr("cnt:"), - revm_colornumber("%02u", table->vd_cnt), - revm_colorfieldstr("hash:"), - revm_colornumber("%08x", table->vd_hash), - revm_colorfieldstr("flags:"), - revm_colornumber("%02u", table->vd_flags), - revm_colorfieldstr("aux:"), - revm_colornumber("%02x", table->vd_aux), - revm_colorfieldstr("next:"), - revm_colornumber("%02x", table->vd_next)); - - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - { - if (index > 0) - revm_output("\n"); - - revm_output(logbuf); - revm_endline(); - } - - auxset = offset + table->vd_aux; - for (aux = 0; aux < table->vd_cnt; aux++) - { - tableaux = data + auxset; - - auxname = elfsh_get_verdauxname(world.curjob->curfile, tableaux); - - snprintf(logbuf, BUFSIZ - 1, - " \t %s%s %s%s\n", - revm_colorfieldstr("name:"), - revm_colorstr_fmt("%-15s", auxname), - revm_colorfieldstr("next:"), - revm_colornumber("%02x", tableaux->vda_next)); - - if (regx == NULL || - (regx != NULL && regexec(regx, logbuf, 0, 0, 0) == 0)) - revm_output(logbuf); - - revm_endline(); - - if (tableaux->vda_next == 0) - break; - - auxset += tableaux->vda_next; - } - - if (table->vd_next == 0) - break; - - offset += table->vd_next; - } - - revm_output("\n"); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} diff -Nru eresi-0.8a25/libstderesi/elf/sym.c eresi-0.0.20110516/libstderesi/elf/sym.c --- eresi-0.8a25/libstderesi/elf/sym.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/sym.c 2011-05-16 11:35:04.000000000 +0000 @@ -1,17 +1,19 @@ /** - * @file sym.c +* @file libstderesi/elf/sym.c +** @ingroup elf +*/ +/** + * * * Started on Fri Nov 2 15:19:38 2001 jfv * * - * $Id: sym.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: sym.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" - - /** * Print the chosen symbol table * @param file @@ -24,7 +26,6 @@ */ int ds(elfshobj_t *file, elfshsect_t *sect, - elfsh_Sym *tab, u_int num, regex_t *regx, char *(*get_symname)(elfshobj_t *f, elfsh_Sym *s)) @@ -36,12 +37,12 @@ u_int typenum; u_int bindnum; u_int foff; - int index; + u_int index; char *sect_name; char buff[512]; - char off[20]; - char type_unk[ELFSH_MEANING + 1]; - char bind_unk[ELFSH_MEANING + 1]; + char off[50]; + char type_unk[ERESI_MEANING + 1]; + char bind_unk[ERESI_MEANING + 1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -62,7 +63,7 @@ /* Avoid reading inexistant memory in the process for .symtab */ else - table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_get_raw(sect) : sect->data); + table = (elfsh_Sym *) (sect->shdr->sh_addr ? elfsh_readmem(sect) : sect->data); /* Browse symtab */ for (index = 0; index < num; index++) @@ -103,11 +104,13 @@ table[index].st_value)); if (sect && sect->shdr->sh_addr != table[index].st_value) - sprintf(off, " + %s", revm_colornumber("%u", - (u_int) (table[index].st_value - sect->shdr->sh_addr))); + snprintf(off, sizeof(off), " + %s", + revm_colornumber("%u", (u_int) (table[index].st_value - sect->shdr->sh_addr))); else *off = '\0'; + + /* Different output depending on the quiet flag */ if (!world.state.revm_quiet) { @@ -153,11 +156,9 @@ } revm_endline(); - } revm_endline(); - revm_output("\n"); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); } @@ -176,6 +177,7 @@ regex_t *tmp; int num; char logbuf[BUFSIZ]; + int ret; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); @@ -186,13 +188,15 @@ sct = elfsh_get_section_by_type(world.curjob->curfile, SHT_SYMTAB, 0, NULL, NULL, 0); - snprintf(logbuf, BUFSIZ - 1, " [SYMBOL TABLE]\n [Object %s]\n\n", + snprintf(logbuf, BUFSIZ, " [SYMBOL TABLE]\n [Object %s]\n\n", world.curjob->curfile->name); revm_output(logbuf); FIRSTREGX(tmp); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ds(world.curjob->curfile, sct, symtab, - num, tmp, elfsh_get_symbol_name)); + + ret = ds(world.curjob->curfile, sct, + num, tmp, elfsh_get_symbol_name); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); } @@ -235,7 +239,7 @@ revm_output(logbuf); FIRSTREGX(tmp); PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ds(world.curjob->curfile, sct, dynsym, + ds(world.curjob->curfile, sct, num, tmp, elfsh_get_dynsymbol_name)); } diff -Nru eresi-0.8a25/libstderesi/elf/version.c eresi-0.0.20110516/libstderesi/elf/version.c --- eresi-0.8a25/libstderesi/elf/version.c 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/elf/version.c 2011-05-16 11:35:05.000000000 +0000 @@ -1,11 +1,15 @@ /** - * @file version.c +* @file libstderesi/elf/version.c +** @ingroup elf +*/ +/** + * * * Version feature * * Started on Sun Sep 25 15:20:18 2005 mxatone * - * $Id: version.c,v 1.2 2008-02-16 12:32:27 thor Exp $ + * $Id: version.c 1397 2009-09-13 02:19:08Z may $ * */ #include "libstderesi.h" @@ -116,7 +120,7 @@ revm_colornumber("%02u", pdef->def->vd_cnt), revm_colorfieldstr("hash:"), revm_colornumber("%08x", pdef->def->vd_hash), - (dauxnames && dauxnames[0] != NULL ? + (dauxnames[0] != NULL ? revm_colorstr_fmt("%-14s", dauxnames[0]) : ""), (dauxnames[1] != NULL ? revm_colorstr(dauxnames[1]) : "")); @@ -133,7 +137,7 @@ id, revm_colorfieldstr("nume:"), revm_colornumber("%02u", pdef->def->vd_cnt), - (dauxnames && dauxnames[0] != NULL ? + (dauxnames[0] != NULL ? revm_colorstr_fmt("%-10s", dauxnames[0]) : "")); } if (regx == NULL || @@ -236,7 +240,7 @@ hashneed_t *pneed; hashdef_t *pdef; char *id; - char type_unk[ELFSH_MEANING + 1]; + char type_unk[ERESI_MEANING + 1]; PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); diff -Nru eresi-0.8a25/libstderesi/files/fileops.c eresi-0.0.20110516/libstderesi/files/fileops.c --- eresi-0.8a25/libstderesi/files/fileops.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/fileops.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,275 @@ +/* +* @file libstderesi/files/fileops.c +** @ingroup files +** Started on Thu Feb 13 04:06:45 2003 jfv +** Last update Wed Mar 10 12:31:49 2004 jfv +** +** $Id: fileops.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + + +/* Write command */ +int cmd_write() +{ + revmexpr_t *e1; + revmexpr_t *e2; + revmobj_t *o1; + revmobj_t *o2; + elfshsect_t *cur; + void *dat; + //void *sdata; + int size; + char logbuf[BUFSIZ]; + elfsh_SAddr off; + eresi_Addr addr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Needs 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameters must be initialized scalar objects", -1); + o1 = e1->value; + o2 = e2->value; + off = 0; + //sdata = NULL; + addr = 0; + + /* If first parameter is an address */ + if (o1->otype->type == ASPECT_TYPE_LONG || + o1->otype->type == ASPECT_TYPE_CADDR || + o1->otype->type == ASPECT_TYPE_DADDR) + { + /* + cur = elfsh_get_parent_section(world.curjob->curfile, o1->immed_val.ent, &off); + if (cur) + { + sdata = elfsh_readmem(cur); + sdata += off; + } + else if (e2dbg_presence_get()) + sdata = (void *) o1->immed_val.ent; + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid destination address", -1); + */ + addr = o1->immed_val.ent; + } + + /* Type checking */ + else if (o1->otype->type != ASPECT_TYPE_RAW && o1->otype->type != ASPECT_TYPE_STR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameters must be STR or RAW typed", + -1); + else if (o1->immed) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Destination param must not be a constant", + -1); + + /* Convert Integers into raw data */ + if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) + if (revm_convert_object(e2, ASPECT_TYPE_RAW) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to convert dest object to RAW", (-1)); + + /* Get the source buff */ + dat = (o2->immed ? o2->immed_val.str : + o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : + o2->get_data(o2->parent, o2->off, o2->sizelem)); + + /* Set size */ + cur = o2->parent; + size = (o2->immed ? o2->size : o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : + world.curjob->curcmd->param[2] ? + revm_lookup_index(world.curjob->curcmd->param[2]) : + cur->shdr->sh_size - o2->off); + if (size <= 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Source offset too big", -1); + + /* Write raw ondisk or in memory */ + /* FIXME: Mapped test should be done */ + if (addr) + { + //memcpy(sdata, dat, size); + elfsh_writemem(world.curjob->curfile, addr, dat, size); + } + + /* Write in the destination section */ + else if (o1->set_data(o1->parent, o1->off, dat, size, o1->sizelem) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set data", (-1)); + + /* Print stuff and return */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, " [*] Written %u bytes \n\n", size); + revm_output(logbuf); + } + + if (!o2->perm) + XFREE(__FILE__, __FUNCTION__, __LINE__,o2); + if (!o1->perm) + XFREE(__FILE__, __FUNCTION__, __LINE__,o1); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* Append command : 2 parameters, a section and the string to be appended */ +int cmd_append() +{ + elfshsect_t *sect; + revmobj_t *o2; + revmexpr_t *e2; + elfshsect_t *cur; + u_int size; + char *dat; + int index = -1; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Fetch section using the first argument */ + if (revm_isnbr(world.curjob->curcmd->param[0])) + { + index = atoi(world.curjob->curcmd->param[0]); + if (!index) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot convert section value !", -1); + sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); + } + else + sect = elfsh_get_section_by_name(world.curjob->curfile, world.curjob->curcmd->param[0], + NULL, NULL, NULL); + if (sect == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested section", -1); + + /* Object retreive */ + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e2 || !e2->value || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid destination object", (-1)); + o2 = e2->value; + + /* Convert Integers into string data */ + if (o2->otype->type != ASPECT_TYPE_RAW && o2->otype->type != ASPECT_TYPE_STR) + { + revm_convert_object(e2, ASPECT_TYPE_RAW); + if (o2->otype->type != ASPECT_TYPE_RAW || !o2->perm) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid destination object", (-1)); + } + + /* Get the source buff */ + dat = (o2->immed ? o2->immed_val.str : + o2->otype->type == ASPECT_TYPE_STR ? o2->get_name(o2->root, o2->parent) : + o2->get_data(o2->parent, o2->off, o2->sizelem)); + + /* Set size */ + cur = o2->parent; + size = (o2->immed ? o2->size : + o2->otype->type == ASPECT_TYPE_STR ? strlen(dat) : + cur->shdr->sh_size - o2->off); + if (size <= 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Source offset too big", -1); + + /* Append the data for real */ + if (elfsh_append_data_to_section(sect, dat, size) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to append data to section", (-1)); + + /* Print msg */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + " [*] Appended %u bytes to section %s\n\n", size, sect->name); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* Extend command : 2 parameters, a section and the extansion size */ +int cmd_extend() +{ + elfshsect_t *sect; + u_int size; + char *new_data; + int index = -1; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Fetch section using first argument */ + if (revm_isnbr(world.curjob->curcmd->param[0])) + { + index = atoi(world.curjob->curcmd->param[0]); + if (!index) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot convert section value", + -1); + sect = elfsh_get_section_by_index(world.curjob->curfile, index, NULL, NULL); + } + else + sect = elfsh_get_section_by_name(world.curjob->curfile, + world.curjob->curcmd->param[0], + NULL, NULL, NULL); + if (sect == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find requested section", -1); + size = atoi(world.curjob->curcmd->param[1]); + + /* Extend the section with NUL bytes */ + if (!size) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Extend size cannot be 0", -1); + XALLOC(__FILE__, __FUNCTION__, __LINE__,new_data, size, -1); + + if (elfsh_append_data_to_section(sect, new_data, size) < 0) + { + XFREE(__FILE__, __FUNCTION__, __LINE__,new_data); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to append data", -1); + } + + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + " [*] Extended %s by %u bytes\n\n", sect->name, size); + revm_output(logbuf); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* Request to fixup the bss from command line */ +int cmd_fixup() +{ + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (world.curjob->curfile == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + if (elfsh_fixup_bss(world.curjob->curfile) != NULL) + { + revm_output(" [*] BSS fixed up\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to fixup BSS", (-1)); +} + diff -Nru eresi-0.8a25/libstderesi/files/insert.c eresi-0.0.20110516/libstderesi/files/insert.c --- eresi-0.8a25/libstderesi/files/insert.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/insert.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,172 @@ +/* +* @file libstderesi/files/insert.c +** @ingroup files +** @brief First insert functions for easy scripting. +** +** Started Nov 22 01:26:01 2003 jfv +** +** +** $Id: insert.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + + +/** + * sect name maptype size align + * sym name value size + * phdr type value size + */ +int cmd_insert() +{ + elfshsect_t *sct; + revmexpr_t *expr; + revmobj_t *obj; + elfsh_Sym sym; + elfsh_Phdr phdr; + u_int size; + char *name; + char type; + elfsh_Word ptype; + eresi_Addr val; + u_int modulo; + char *param0, *param1, *param2, *param3, *param4; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + param0 = world.curjob->curcmd->param[0]; + param1 = world.curjob->curcmd->param[1]; + param2 = world.curjob->curcmd->param[2]; + param3 = world.curjob->curcmd->param[3]; + param4 = world.curjob->curcmd->param[4]; + + /* Checks (needed because the command takes variable amount of params) */ + if (!param0 || !param1 || !param2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Lookup 2nd parameter depending on first parameter */ + if (!strcmp(param0, "phdr") || !strcmp(param0, "rphdr")) + { + expr = revm_lookup_param(param1, 1); + if (!expr || !expr->value || !expr->value->otype || + (expr->value->otype->type != ASPECT_TYPE_LONG && + expr->value->otype->type != ASPECT_TYPE_INT)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid phdr type", -1); + obj = expr->value; + ptype = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); + name = NULL; + } + else + { + expr = revm_lookup_param(param1, 1); + if (!expr || !expr->value || !expr->value->otype || expr->value->otype->type != ASPECT_TYPE_STR) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid object name", -1); + obj = expr->value; + name = (obj->immed ? obj->immed_val.str : obj->get_name(obj->root, obj->parent)); + ptype = 0; + } + + /* Lookup object size (4rth optional parameter) */ + if (param3) + { + expr = revm_lookup_param(param3, 1); + if (!expr || !expr->value || !expr->value->otype || + (expr->value->otype->type != ASPECT_TYPE_INT && expr->value->otype->type != ASPECT_TYPE_LONG)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid object size", -1); + obj = expr->value; + size = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); + } + else + size = elfsh_get_pagesize(world.curjob->curfile); + + /* Lookup object alignment (5th optional parameter) */ + if (param4) + modulo = atoi(param4); + else + modulo = 0; + + /* Insert a section after looking up injection type */ + /* Third parameter indicate injection type */ + if (!strcmp(param0, "sect")) + { + type = (!strcmp(param2, "code") ? ELFSH_CODE_INJECTION : + !strcmp(param2, "data") ? ELFSH_DATA_INJECTION : + !strcmp(param2, "unmap") ? + ELFSH_UNMAPPED_INJECTION : ELFSH_UNKNOWN_INJECTION); + if (type == ELFSH_UNKNOWN_INJECTION) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown injection type", -1); + sct = elfsh_insert_section(world.curjob->curfile, name, + NULL, type, size, modulo); + if (!sct) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to insert new section", -1); + } + + /* Insert a symbol after looking up symbol value */ + /* Third parameter indicate existing symbol name or value */ + else if (!strcmp(param0, "sym")) + { + expr = revm_lookup_param(param2, 1); + if (!expr || !expr->value || !expr->value->otype || + (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid symbol value", -1); + obj = expr->value; + val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); + if (!elfsh_get_symtab(world.curjob->curfile, NULL)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive symbol table", -1); + + sym = elfsh_create_symbol(val, size, 0, 0, 0, 0); + if (elfsh_insert_symbol(world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB], + &sym, name) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot insert symbol", -1); + elfsh_sync_sorted_symtab(world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB]); + } + + /* Insert PHT entries */ + /* Third parameter indicate symbol name or value */ + else if (!strcmp(param0, "phdr") || + !strcmp(param0, "rphdr")) + { + expr = revm_lookup_param(param2, 1); + if (!expr || !expr->value || !expr->value->otype || + (expr->value->otype->type != ASPECT_TYPE_LONG && expr->value->otype->type != ASPECT_TYPE_INT)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid PHDR base address", -1); + obj = expr->value; + val = (obj->immed ? obj->immed_val.ent : obj->get_obj(obj->parent)); + + // type, addr, size, alignment + phdr = elfsh_create_phdr(ptype, val, size, 0); + if (!strcmp(param0, "phdr")) + { + if (NULL == elfsh_insert_phdr(world.curjob->curfile, &phdr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to insert new PHDR", -1); + } + else if (NULL == elfsh_insert_runtime_phdr(world.curjob->curfile, &phdr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to insert new runtime PHDR", -1); + } + + /* Error */ + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown object type", -1); + + /* Report result */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, " [*] Object insertion succesfull\n\n"); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/files/list.c eresi-0.0.20110516/libstderesi/files/list.c --- eresi-0.8a25/libstderesi/files/list.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/list.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,135 @@ +/* +* @file libstderesi/files/list.c +** @ingroup files +** Started on Sat Jan 25 11:20:20 2003 jfv +** +** $Id: list.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + +/** + * Print dependence + * @param obj + */ +static int revm_dolist_dep(elfshobj_t *obj) +{ + elfshobj_t *actual; + char logbuf[20]; + char **keys; + int keynbr; + int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!obj) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); + + if (hash_size(&obj->child_hash)) + { + keys = hash_get_keys(&obj->child_hash, &keynbr); + revm_output("DEPS = ["); + for (index = 0; index < keynbr; index++) + { + actual = hash_get(&obj->child_hash, keys[index]); + snprintf(logbuf, sizeof(logbuf), "%s%u", + (index == 0 ? "" : ","), actual->id); + revm_output(logbuf); + } + revm_output("]"); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * List all the loaded objects + */ +int cmd_dolist() +{ + elfshobj_t *actual; + int index; + char *time; + char *nl; + char c; + char c2; + char logbuf[BUFSIZ]; + char optbuf[BUFSIZ]; + char **keys; + int keynbr; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + index = 1; + + /* Private descriptors */ + if (hash_size(&world.curjob->loaded)) + { + revm_output(" .::. Static Working files .::. \n"); + keys = hash_get_keys(&world.curjob->loaded, &keynbr); + for (index = 0; index < keynbr; index++) + { + actual = hash_get(&world.curjob->loaded, keys[index]); + time = ctime(&actual->loadtime); + nl = strchr(time, '\n'); + if (nl) + *nl = 0x00; + c = (world.curjob->curfile == actual ? '*' : ' '); + c2 = ((actual->linkmap || actual->rhdr.base) ? 'M' : ' '); + if (elfsh_is_runtime_mode()) + snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); + else + snprintf(optbuf, BUFSIZ, "%s", ""); + + snprintf(logbuf, BUFSIZ - 1, " %s %c%c %s ID: %10u %s %-31s ", + time, c, c2, optbuf, actual->id, + elfsh_get_objtype(actual->hdr) == ET_REL ? "ET_REL " : + elfsh_get_objtype(actual->hdr) == ET_DYN ? "ET_DYN " : + elfsh_get_objtype(actual->hdr) == ET_EXEC ? "ET_EXEC" : + elfsh_get_objtype(actual->hdr) == ET_CORE ? "ET_CORE" : + "UNKNOWN", actual->name); + revm_output(logbuf); + revm_dolist_dep(actual); + revm_output("\n"); + + /* printf("-> Hashes for object : PAR[%u] ROOT[%u] CHILD[%u] \n", + hash_size(&actual->parent_hash), + hash_size(&actual->root_hash), + hash_size(&actual->child_hash)); + */ + + } + } + + /* Shared descriptors */ + if (hash_size(&world.shared_hash)) + { + revm_output("\n .::. Shared Working files .::. \n"); + keys = hash_get_keys(&world.shared_hash, &keynbr); + for (index = 0; index < keynbr; index++) + { + actual = hash_get(&world.shared_hash, keys[index]); + time = ctime(&actual->loadtime); + nl = strchr(time, '\n'); + if (nl) + *nl = 0x00; + c = (world.curjob->curfile == actual ? '*' : ' '); + c2 = (actual->linkmap ? 'L' : ' '); + if (elfsh_is_runtime_mode()) + snprintf(optbuf, BUFSIZ, "(" XFMT ")", actual->rhdr.base); + else + snprintf(optbuf, BUFSIZ, "%s", ""); + + snprintf(logbuf, BUFSIZ - 1, " [%02u] %s %c%c %s ID: %02u %-31s \n", + index + 1, time, c, c2, optbuf, actual->id, actual->name); + revm_output(logbuf); + } + } + + if (!hash_size(&world.curjob->loaded) && !hash_size(&world.shared_hash)) + revm_output(" [*] No loaded file\n"); + revm_output("\n"); + revm_modlist(); + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/files/load.c eresi-0.0.20110516/libstderesi/files/load.c --- eresi-0.8a25/libstderesi/files/load.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/load.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,290 @@ +/** + * @file libstderesi/files/load.c + * @ingroup files + * Started on Sat Jan 25 11:21:18 2003 jfv + * + * $Id: load.c 1440 2010-12-29 02:22:03Z may $ + * + */ +#include "libstderesi.h" + +/** + * return 1 if a file named 'name' is in the workspace + * @param name + */ +int revm_is_loaded(char *name) +{ + listent_t *actual; + elfshobj_t *obj; + int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!name) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (!world.curjob) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + if (!world.curjob->curfile) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + for (index = 0; index < world.curjob->loaded.size; index++) + for (actual = &world.curjob->loaded.ent[index]; + actual != NULL && actual->key != NULL; + actual = actual->next) + { + obj = actual->data; + if (!strcmp(name, obj->name)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); + } + + for (index = 0; index < world.shared_hash.size; index++) + for (actual = &world.shared_hash.ent[index]; + actual != NULL && actual->key != NULL; + actual = actual->next) + { + obj = actual->data; + if (!strcmp(name, obj->name)) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (1)); + } + + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Need doxygen comment. + * @param file + * @param name + */ +int revm_load_init_dephash(elfshobj_t *file, char *name) +{ + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Init hash dep */ + snprintf(logbuf, sizeof(logbuf), "%s_children", name); + hash_init(&file->child_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); + + snprintf(logbuf, sizeof(logbuf), "%s_roots", name); + hash_init(&file->root_hash , strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); + + snprintf(logbuf, sizeof(logbuf), "%s_parents", name); + hash_init(&file->parent_hash, strdup(logbuf), 20, ASPECT_TYPE_UNKNOW); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Need doxygen comment. + * @param regex + */ +int revm_file_loads(char *regex) +{ + // split for dir/files part + // open dir + // read dir + // match against regex + // if matched load files + return (0); +} + + +/** + * @brief Load a file in e2dbg. + * @param name File path. + * @param base Object memory base address. + * @param lm Linkmap entry for that object. + * @return Success (0) or Error (-1). + */ +int revm_file_load(char *name, eresi_Addr base, elfshlinkmap_t *lm) +{ + elfshobj_t *new; + revmexpr_t *expr; + revmobj_t *tmp; + char logbuf[BUFSIZ]; + char *timec; + hash_t *filehash; + u_char arch; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!name) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid argument", -1); + + /* Reset the id counter in case we have unloaded all our files */ + filehash = hash_find("files"); + if (!hash_size(filehash)) + world.state.lastid = 0; + + /* Map the standard ELF object */ + new = elfsh_map_obj(name); + if (NULL == new) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot load object", -1); + + /* Print a msg if not in quiet mode */ + new->loadtime = time(&new->loadtime); + if (!world.state.revm_quiet) + { + timec = ctime(&new->loadtime); + timec[strlen(timec) - 1] = '\0'; + snprintf(logbuf, BUFSIZ - 1, " [*] %s - New object loaded : %s\n", + timec , name); + revm_output(logbuf); + } + + /* Set base address */ + new->rhdr.base = base; + + /* Set linkmap address */ + if (new->hdr->e_type != ET_CORE) + new->linkmap = lm; + else + new->linkmap = NULL; + + /* Add the object to the list of opened objects */ + new->id = ++world.state.lastid; + world.curjob->curfile = new; + revm_proc_init(); + expr = revm_expr_get(REVM_VAR_LOAD); + if (!expr || !expr->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "TROUBLE : Last loaded file inexistant", -1); + tmp = expr->value; + tmp->immed_val.word = new->id; + + /* Support shared objects */ + if (world.state.revm_shared) + hash_add(&world.shared_hash, new->name, new); + else + hash_add(&world.curjob->loaded, new->name, new); + + /* Add an entry into the loaded files hashtable */ + hash_add(&file_hash, new->name, (void *) new); + + /* Init hash dep */ + revm_load_init_dephash(new, name); + + if (new->hdr->e_type == ET_CORE) + { + hash_add(&new->root_hash, new->name, new); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Create libmjollnir context for this binary */ + mjr_create_context_as_current(&world.mjr_session, new); + mjr_setup_processor(&world.mjr_session, world.curjob->proc); + + /* Init search hash tables */ + elfsh_init_symbol_hashtables(new); + + /* Parse debugging informations */ + arch = elfsh_get_archtype(world.curjob->curfile); + if (arch == ELFSH_ARCH_IA32 || + arch == ELFSH_ARCH_SPARC32 || + arch == ELFSH_ARCH_SPARC64) + revm_edfmt_parse(new); + + /* Load dependances */ + if (new->hdr->e_type == ET_EXEC) + hash_add(&new->root_hash, new->name, new); + + /* We use a different dependences technique for mapped files + in the debugger. Just load dependences here for unmapped files */ + if (!elfsh_is_runtime_mode()) + revm_load_enumdep(new); + + /* Load EDFMT debug sections */ + if ((int) config_get_data(ERESI_CONFIG_ONLOAD_RCONTROL)) + { + if (mjr_functions_get(world.mjr_session.cur) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Analyzed functions edfmt section cannot be restored", -1); + if (mjr_blocks_get(world.mjr_session.cur) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Analyzed blocks edfmt section cannot be restored", -1); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Insert an object in the list of opened elfsh descriptors + */ +int cmd_load() +{ + revmexpr_t *expr; + revmobj_t *tmp; + char *str; + int was_dynamic; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Make sure we are or not in the debugger */ + was_dynamic = 0; + if (elfsh_is_runtime_mode()) + { + was_dynamic = 1; + elfsh_set_static_mode(); + } + + /* Find which file we need to load */ + expr = revm_lookup_param(world.curjob->curcmd->param[0], 1); + if (!expr || !expr->value) + { + if (was_dynamic) + elfsh_set_runtime_mode(); + world.state.revm_shared = 0; + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown file to load", (-1)); + } + tmp = expr->value; + if (!tmp->otype) + { + revm_expr_destroy_by_name(expr->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Missing parameter", (-1)); + } + + if (tmp->otype->type != ASPECT_TYPE_STR) + { + revm_convert_object(expr, ASPECT_TYPE_STR); + if (tmp->otype->type != ASPECT_TYPE_STR) + { + revm_expr_destroy_by_name(expr->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid file to load", (-1)); + } + } + str = (tmp->immed ? tmp->immed_val.str : tmp->get_name(tmp->root, tmp->parent)); + if (hash_get(&world.curjob->loaded, str) || hash_get(&world.shared_hash, str)) + { + revm_expr_destroy_by_name(expr->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot load file many times in the same workspace", (-1)); + } + + /* Really load the file */ + revm_output("\n"); + ret = revm_file_load(str, 0, NULL); + revm_output("\n"); + + /* Restore dynamic mode */ + if (was_dynamic) + { + if (world.curjob->curfile && world.curjob->curfile->linkmap) + elfsh_set_runtime_mode(); + else + revm_output("\n [!] Loaded file not present in linkmap" + ", switching to STATIC mode\n\n"); + } + else + elfsh_set_static_mode(); + + /* Everything was OK */ + world.state.revm_shared = 0; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ret); +} diff -Nru eresi-0.8a25/libstderesi/files/Makefile eresi-0.0.20110516/libstderesi/files/Makefile --- eresi-0.8a25/libstderesi/files/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/Makefile 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,55 @@ +## +## Makefile for files in libstderesi for the ERESI project +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ +## +include ../../config.h + +SRC = fileops.c load.c unload.c save.c insert.c list.c \ + reladd.c remove.c switch.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CC ?= gcc +LD ?= ld +RM = rm -f +NAME32 = ../std-files.32.o +NAME64 = ../std-files.64.o + +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ + -I../../libmjollnir/include/ -I../../libaspect/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ + $(READLNOPT) + +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libaspect/include/ \ + -I../../libui/include/ -I../../libmjollnir/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ + $(NCURSESLNOPT) $(READLNOPT) + +all : all32 all64 + +$(NAME32) : $(OBJ32) + $(LD) -r $(OBJ32) -o $(NAME32) + +$(NAME64) : $(OBJ64) + $(LD) -r $(OBJ64) -o $(NAME64) +all32: $(NAME32) +all64: $(NAME64) + +clean : + @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/files/reladd.c eresi-0.0.20110516/libstderesi/files/reladd.c --- eresi-0.8a25/libstderesi/files/reladd.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/reladd.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,80 @@ +/** +* @file libstderesi/files/reladd.c + * @ingroup files + * Started on Fri Mar 28 14:58:57 2003 jfv + * Last update Thu Mar 11 14:39:48 2004 jfv + * + * $Id: reladd.c 1397 2009-09-13 02:19:08Z may $ + * + */ +#include "libstderesi.h" + + +/** + * Inject a .o into an executable + */ +int cmd_relinject() +{ + elfshobj_t *host; + elfshobj_t *rel; + int idx; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Check to avoid non-runtime (static) injection from e2bdg the debugger + that would desynchronize the memory perspective of the program. + The debugger is not supposed to do that, it is a job for elfsh */ + if (world.state.revm_mode == REVM_STATE_EMBEDDED && + elfsh_is_static_mode()) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "E2dbg must inject in memory, switch to dynamic mode.", -1); + + /* Load host file */ + idx = atoi(world.curjob->curcmd->param[0]); + host = (idx ? revm_getfile(idx) : + hash_get(&file_hash, world.curjob->curcmd->param[0])); + if (host == NULL) + { + host = elfsh_map_obj(world.curjob->curcmd->param[0]); + if (host == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot map host file", -1); + } + + /* Load relocatable file */ + idx = atoi(world.curjob->curcmd->param[1]); + rel = (idx > 0 ? revm_getfile(idx) : + hash_get(&file_hash, world.curjob->curcmd->param[1])); + if (rel == NULL) + { + rel = elfsh_map_obj(world.curjob->curcmd->param[1]); + if (rel == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot map relocatable file", -1); + } + + /* Call libelfsh relocatable object injector */ + idx = elfsh_inject_etrel_hash(host, rel, + &world.curjob->loaded, + &world.shared_hash); + + if (idx < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to inject ET_REL with workspace", (-1)); + + /* Success : put the modified object as current */ + world.curjob->curfile = host; + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + "\n [*] ET_REL %s injected succesfully in %s %s\n\n", + rel->name, + (host->hdr->e_type == ET_EXEC ? "ET_EXEC" : + host->hdr->e_type == ET_DYN ? "ET_DYN" : + "unknown host file"), + host->name); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/files/remove.c eresi-0.0.20110516/libstderesi/files/remove.c --- eresi-0.8a25/libstderesi/files/remove.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/remove.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,69 @@ +/** +* @file libstderesi/files/remove.c +** @ingroup files +** @brief First remove functions for easy scripting +** +** Started on Nov 22 2003 jfv +** +** +** $Id: remove.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + +/** + * sect name + * sym name + */ +int cmd_remove() +{ + elfshsect_t *symtab; + char *name; + int err; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Checks (needed because the command takes variable amount of params) */ + if (!world.curjob->curcmd->param[0] || !world.curjob->curcmd->param[1]) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid parameters", -1); + + /* Lookup object name */ + name = revm_lookup_string(world.curjob->curcmd->param[1]); + + /* Remove a section */ + if (!strcmp(world.curjob->curcmd->param[0], "sect")) + err = elfsh_remove_section(world.curjob->curfile, name); + + /* Remove a symbol after looking up symbol value */ + else if (!strcmp(world.curjob->curcmd->param[0], "sym")) + { + symtab = elfsh_get_symtab(world.curjob->curfile, NULL); + if (!symtab) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot find symbol table", -1); + symtab = world.curjob->curfile->secthash[ELFSH_SECTION_SYMTAB]; + err = elfsh_remove_symbol(symtab, name); + } + + /* Remove a segment */ + else if (!strcmp(world.curjob->curcmd->param[0], "phdr")) + err = elfsh_remove_phdr(world.curjob->curfile, atoi(name)); + + /* Error */ + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown object type", -1); + + /* Report result */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + " [*] Object removing %s.\n\n", + (err < 0 ? "failed" : "succesfull")); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/files/save.c eresi-0.0.20110516/libstderesi/files/save.c --- eresi-0.8a25/libstderesi/files/save.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/save.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,42 @@ +/** +* @file libstderesi/files/save.c +** @ingroup files +** +** Started on Sat Jan 25 11:22:35 2003 jfv +** $Id: save.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + +/** + * @brief Command handler : save object which name is given in parameter to the command. + * @return Success (0) or Error (-1). + */ +int cmd_save() +{ + char logbuf[BUFSIZ]; + char *str; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + str = world.curjob->curcmd->param[0]; + + /* We save more things if we are in the tracer */ + switch (world.state.revm_mode) + { + case REVM_STATE_TRACER: + if (elfsh_save_obj(world.curjob->curfile, str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to save object", -1); + break; + default: + if (elfsh_save_obj(world.curjob->curfile, str) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to save object", -1); + break; + } + + snprintf(logbuf, BUFSIZ - 1, "\n [*] Object %s saved successfully \n\n", str); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/files/switch.c eresi-0.0.20110516/libstderesi/files/switch.c --- eresi-0.8a25/libstderesi/files/switch.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/switch.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,38 @@ +/** +* @file libstderesi/files/switch.c +** @ingroup files +** +** Started on Sat Jan 25 11:20:49 2003 jfv +** $Id: switch.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + + +/** + * Change the current object + */ +int cmd_doswitch() +{ + char logbuf[BUFSIZ]; + int ret; + int nbr; + elfshobj_t *cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (world.curjob->curcmd->param[0] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + nbr = atoi(world.curjob->curcmd->param[0]); + ret = revm_doswitch(nbr); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to switch on object", -1); + cur = world.curjob->curfile; + mjr_set_current_context(&world.mjr_session, cur->name); + snprintf(logbuf, BUFSIZ, "\n [*] Switched on object %u (%s) \n\n", cur->id, cur->name); + revm_output(logbuf); + if (elfsh_is_runtime_mode() && !cur->linkmap) + revm_output("\n [!] Loaded file is not the linkmap, switching to STATIC mode\n\n"); + revm_proc_init(); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); +} diff -Nru eresi-0.8a25/libstderesi/files/unload.c eresi-0.0.20110516/libstderesi/files/unload.c --- eresi-0.8a25/libstderesi/files/unload.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/files/unload.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,80 @@ +/** +* @file libstderesi/files/unload.c + * @ingroup files + * Started on Sat Jan 25 11:21:52 2003 jfv + * Last update Thu Mar 11 07:56:36 2004 jfv + * + * $Id: unload.c 1410 2010-05-14 13:45:20Z thorkill $ + * + */ +#include "libstderesi.h" + + +/** + * Unload a file from the shell + */ +int cmd_unload() +{ + hash_t *loaded; + elfshobj_t *cur; + time_t uloadt; + char logbuf[BUFSIZ]; + int ret; + u_int id; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Get the file structure */ + id = atoi(world.curjob->curcmd->param[0]); + cur = revm_lookup_file(world.curjob->curcmd->param[0]); + if (cur == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Object not loaded", -1); + + /* Do not unload dependences of files or objects with linkmap entry */ + if (hash_size(&cur->parent_hash)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unload parent object first", -1); + if (cur->linkmap) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "You cannot unload a mapped object", -1); + ret = revm_unload_dep(cur, cur); + if (!world.state.revm_quiet) + { + time(&uloadt); + snprintf(logbuf, BUFSIZ - 1, "%s [*] Object %-40s unloaded on %s \n", + (ret ? "" : "\n"), cur->name, ctime(&uloadt)); + revm_output(logbuf); + } + + /* Clean various hash tables of this binary entry and return OK */ + hash_del(&file_hash, cur->name); + if (hash_get(&world.shared_hash, cur->name)) + hash_del(&world.shared_hash, cur->name); + else + hash_del(&world.curjob->loaded, cur->name); + + /* Cleanup libmjollnir context */ + mjr_del_context(&world.mjr_session, cur->name); + + elfsh_unload_obj(cur); + revm_output("\n"); + + /* If the file is the current working one, swap to another one */ + if (cur == world.curjob->curfile) + { + loaded = (hash_size(&world.curjob->loaded) ? + &world.curjob->loaded : hash_size(&world.shared_hash) ? + &world.shared_hash : NULL); + if (!loaded) + world.curjob->curfile = NULL; + else + do cur = hash_get_one(loaded); + while (cur == world.curjob->curfile); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + diff -Nru eresi-0.8a25/libstderesi/include/libstderesi.h eresi-0.0.20110516/libstderesi/include/libstderesi.h --- eresi-0.8a25/libstderesi/include/libstderesi.h 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/libstderesi.h 2011-05-16 11:35:04.000000000 +0000 @@ -1,14 +1,49 @@ /** -** @file libstderesi.h +* @file libstderesi/include/libstderesi.h +** @ingroup libstderesi ** ** Started on Thu Feb 22 07:19:04 2001 jfv -** $Id: libstderesi.h,v 1.5 2008-02-16 12:32:27 thor Exp $ +** $Id: libstderesi.h 1444 2011-01-31 07:41:29Z may $ */ #ifndef __LIBSTDERESI_H_ #define __LIBSTDERESI_H_ +/** + * @defgroup libstderesi libstderesi: The ERESI standard library. + * @ingroup ERESI + */ +/** + * @defgroup analysis Program analysis commands. + * @ingroup libstderesi + */ +/** + * @defgroup cmd General purpose commands. + * @ingroup libstderesi + */ +/** + * @defgroup elf ELF format related commands. + * @ingroup libstderesi + */ +/** + * @defgroup files File handling commands. + * @ingroup libstderesi + */ +/** + * @defgroup type Datatypes management commands. + * @ingroup libstderesi + */ + +/* Debug flags for libstderesi */ +#define __DEBUG_REWRITE__ 0 +#define __DEBUG_FOREACH__ 0 +#define __DEBUG_DISASM__ 0 +#define __DEBUG_HIJACK__ 0 +#define __DEBUG_GRAPH__ 0 + /* User defined configuration */ #include "revm.h" +#include "libetrace.h" +#include "libmjollnir.h" /* Help strings */ #include "libstderesi-help.h" @@ -104,6 +139,8 @@ #define CMD_LOG "log" #define CMD_EXPORT "export" #define CMD_EDIT "edit" +#define CMD_EVAL "eval" +#define CMD_PROC "proc" /* Type related commands */ #define CMD_INFORM "inform" @@ -114,6 +151,10 @@ /* Debugging format commands */ #define CMD_DEBUG "debug" +/* Debugger command -- FIXME should be in e2dbg only */ +#define CMD_RSHT "rsht" +#define CMD_RPHT "rpht" + /* ELF Version commands */ #define CMD_VERSION "version" #define CMD_VERNEED "verneed" @@ -160,14 +201,19 @@ #define CMD_UNLOAD "unload" #define CMD_SAVE "save" #define CMD_SWITCH "switch" -#define CMD_LIST "list" +#define CMD_LIST "flist" #define CMD_LIST2 "l" #define CMD_WORKSPACE "workspace" #define CMD_WORKSPACE2 "w" + +/* Type related commands */ #define CMD_VECTORS "vectors" #define CMD_TABLES "tables" #define CMD_LISTS "lists" #define CMD_EMPTY "empty" +#define CMD_SETUNION "U" +#define CMD_SETINTER "I" +#define CMD_SETINTER2 "inter" /* Code analysis commands */ #define CMD_FLOWJACK "flowjack" @@ -178,19 +224,94 @@ #define CMD_UNSTRIP "unstrip" #define CMD_RENAME "rename" #define CMD_CONTROL "control" +#define CMD_ARGCOUNT "argcount" #define CMD_ANALYSE "analyse" +#define CMD_ASTRIP "astrip" /* config commands */ #define CMD_CONFIGURE "configure" +#define CMD_CONFIG "config" -#define CMD_RSHT "rsht" -#define CMD_RPHT "rpht" +/* Structures for subcommands provided by libetrace */ + +/* Sub-commands, for now only used by the tracer */ +typedef struct s_revmtraces +{ + int (*exec)(elfshobj_t*, char *, char **); /* Function used */ + + /* Unexistant (0), optional (1), needed (2) */ + char flagName; /* Need a first argument */ + char flagArg; /* Need a second argument */ +} tracecmd_t; /* Extern variables */ extern char quit_msg[512]; extern void (*prompt_token_setup)(char *name, u_int size); extern char prompt_token[512]; -extern u_char quit_msg_setup; +extern u_char quit_msg_setup; + +/* Used to store ascii description for different structures types in data.c */ +#define ELFSH_INSTRTYPE_MAX 26 +#define ELFSH_OPTYPE_MAX 4 +#define ELFSH_SEGTYPE_MAX 7 +#define ELFSH_SHTYPE_MAX 16 +#define ELFSH_OBJTYPE_MAX 5 +#define ELFSH_SYMBIND_MAX 3 +#define ELFSH_SYMTYPE_MAX STT_NUM + 1 +#define ELFSH_ENCODING_MAX 3 +#define ELFSH_DYNAMIC_MAX 35 +#define ELFSH_EXTDYN_MAX 19 +#define ELFSH_MIPSDYN_MAX 43 +#define ELFSH_ARCHTYPE_MAX 95 +#define ELFSH_EXTSEG_MAX 5 +#define ELFSH_RELOC_i386_MAX 11 +#define ELFSH_RELOC_IA64_MAX 81 +#define ELFSH_RELOC_SPARC_MAX 55 +#define ELFSH_RELOC_SPARC64_MAX 55 +#define ELFSH_RELOC_ALPHA_MAX 43 +#define ELFSH_RELOC_MIPS_MAX 35 + +#define ELFSH_FEATURE_MAX 2 +#define ELFSH_POSFLAG_MAX 2 +#define ELFSH_FLAGS_MAX 4 +#define ELFSH_FLAGS1_MAX 15 +#define ELFSH_MIPSFLAGS_MAX 16 + +#define ELFSH_LINKTYPE_MAX 7 +#define ELFSH_LINKSCOPE_MAX 3 + +/* Maximum size of a single read -- useful when targets are remote */ +/* Better keep it a multiple of 16 */ +#define ESTD_MAXREAD_SIZE 192 +#define ESTD_DISASM_FAILED (-3) + +/* Data value/string/description arrays */ +extern revmconst_t asm_instr_type[ELFSH_INSTRTYPE_MAX]; +extern revmconst_t asm_operand_type[ELFSH_OPTYPE_MAX]; +extern revmconst_t elfsh_extseg_type[ELFSH_EXTSEG_MAX]; +extern revmconst_t elfsh_seg_type[ELFSH_SEGTYPE_MAX]; +extern revmconst_t elfsh_sh_type[ELFSH_SHTYPE_MAX]; +extern revmconst_t elfsh_obj_type[ELFSH_OBJTYPE_MAX]; +extern revmconst_t elfsh_sym_bind[ELFSH_SYMBIND_MAX]; +extern revmconst_t elfsh_sym_type[ELFSH_SYMTYPE_MAX]; +extern revmconst_t elfsh_dynentry_type[ELFSH_DYNAMIC_MAX]; +extern revmconst_t elfsh_encoding[ELFSH_ENCODING_MAX]; +extern revmconst_t elfsh_extdyn_type[ELFSH_EXTDYN_MAX]; +extern revmconst_t elfsh_mipsdyn_type[ELFSH_MIPSDYN_MAX]; +extern revmconst_t elfsh_arch_type[ELFSH_ARCHTYPE_MAX]; +extern revmconst_t elfsh_feature1[ELFSH_FEATURE_MAX]; +extern revmconst_t elfsh_posflag1[ELFSH_POSFLAG_MAX]; +extern revmconst_t elfsh_flags[ELFSH_FLAGS_MAX]; +extern revmconst_t elfsh_flags1[ELFSH_FLAGS1_MAX]; +extern revmconst_t elfsh_mipsflags[ELFSH_MIPSFLAGS_MAX]; +extern revmconst_t elfsh_rel_type_i386[ELFSH_RELOC_i386_MAX]; +extern revmconst_t elfsh_rel_type_ia64[ELFSH_RELOC_IA64_MAX]; +extern revmconst_t elfsh_rel_type_sparc[ELFSH_RELOC_SPARC64_MAX]; +extern revmconst_t elfsh_rel_type_alpha[ELFSH_RELOC_ALPHA_MAX]; +extern revmconst_t elfsh_rel_type_mips[ELFSH_RELOC_MIPS_MAX]; +extern revmconst_t elfsh_verentry_type[ELFSH_VERENTRY_MAX]; +extern revmconst_t elfsh_link_type[ELFSH_LINKTYPE_MAX]; +extern revmconst_t elfsh_link_scope[ELFSH_LINKSCOPE_MAX]; /* Constructors */ void eresi_commands_init(); @@ -235,6 +356,7 @@ int cmd_get(); int cmd_print(); int cmd_info(); +int cmd_proc(); int cmd_add(); int cmd_sub(); int cmd_mul(); @@ -251,6 +373,7 @@ int cmd_force(); int cmd_verb(); int cmd_exec(); +int cmd_eval(); int cmd_findrel(); int cmd_modload(); int cmd_modunload(); @@ -298,6 +421,8 @@ int cmd_empty(); int cmd_inform(); int cmd_uninform(); +int cmd_union(); +int cmd_inter(); /* Scripting only commands */ int cmd_jmp(); @@ -334,6 +459,8 @@ int cmd_unstrip(); int cmd_rename(); int cmd_control(); +int cmd_argcount(); +int cmd_astrip(); /* Workspaces commands */ int cmd_workspace(); @@ -351,9 +478,24 @@ int cmd_step(); int cmd_display(); int cmd_undisplay(); +char *get_signal(int sig); /* Debug format functions */ int cmd_debug(); +/* Trace functions */ +int traces_addcmd(char *cmd, void *exec, char flagName, char flagArg); +int traces_add(elfshobj_t *file, char *name, char **optarg); +int traces_rm(elfshobj_t *file, char *name, char **optarg); +int traces_exclude(elfshobj_t *file, char *freg, char **oreg); +int traces_rmexclude(elfshobj_t *file, char *freg, char **oreg); +int traces_enable(elfshobj_t *file, char *name, char **optarg); +int traces_disable(elfshobj_t *file, char *name, char **optarg); +int traces_create(elfshobj_t *file, char *name, char **optarg); +int traces_delete(elfshobj_t *file, char *name, char **optarg); +int traces_flush(elfshobj_t *file, char *name, char **optarg); +int traces_list(elfshobj_t *file, char *name, char **optarg); +int traces_run(elfshobj_t *file, char **argv, int argc); + #endif /* __LIBSTDERESI_H_ */ diff -Nru eresi-0.8a25/libstderesi/include/libstderesi-help.h eresi-0.0.20110516/libstderesi/include/libstderesi-help.h --- eresi-0.8a25/libstderesi/include/libstderesi-help.h 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/libstderesi-help.h 2011-05-16 11:35:04.000000000 +0000 @@ -3,7 +3,7 @@ ** ** Started on Wed Jan 03 19:19:04 2007 jfv ** -** $Id: libstderesi-help.h,v 1.3 2007-12-09 23:00:18 may Exp $ +** $Id: libstderesi-help.h 1444 2011-01-31 07:41:29Z may $ ** */ #ifndef __REVM_HELP_H_ @@ -57,14 +57,18 @@ #define HLP_SET "Set parameter object value" #define HLP_PRINT "Print list of resolved values of parameters" #define HLP_EXEC "Fork and execute parameter command (with args)" +#define HLP_EVAL "Evaluate the arithmetic expression given in first parameter" #define HLP_ADD "Add the 2 parameters" #define HLP_SUB "Substract 2nd parameter to the first one" #define HLP_MUL "Multiply the 2 parameters" #define HLP_DIV "Divide first param by second one" #define HLP_MOD "Modulo operation between 2 parameters" #define HLP_INFO "Print ELF objects usage for scripting" +#define HLP_PROC "Print information about currently used processor" #define HLP_METACMD "Execute a UNIX shell" -#define HLP_WRITE "Write raw data to ELF section" +#define HLP_WRITE "\t Write raw data to ELF section. \n\n" \ + " Syntax: write addr|section string|data \n" + #define HLP_APPEND "Append raw data to ELF section" #define HLP_EXTEND "Extend ELF section with zeros" #define HLP_FIXUP "Mark BSS section to be included in disk file" @@ -146,10 +150,12 @@ #define HLP_RCMD "Execute a command on a remote machine" /* Flow analysis commands */ -#define HLP_GRAPH "Generate GVZ files:\n\n\t" \ - CMD_GRAPH " - will plot a function dependency graph\n\t" \ - CMD_GRAPH " func - will plot dependency graph of given function\n\t" \ - CMD_GRAPH " bloc - will plot control flow graph of given function\n" +#define HLP_GRAPH "Explore program graphs:\n\n\t" \ + CMD_GRAPH " - Plot entire functions call graph\n\t" \ + CMD_GRAPH " func [vaddr|symbol] - Plot call " \ + "graph of ancestors/successors of a given function \n\t" \ + CMD_GRAPH " bloc [vaddr|symbol] - Plot control " \ + "flow graph of ancestors/successors of a given basic bloc\n" #define HLP_SETGVL "Set graph verbosity level \n\n\t"CMD_SETGVL" <0-5> \n" #define HLP_INSPECT "Disassemble block at symbol/address\n" @@ -159,8 +165,10 @@ #define HLP_FLOWTEST "Test command for graph analysis features" #define HLP_ANALYSE "Perform libmjollnir analysis" #define HLP_CONTROL "Print stored control flow information" +#define HLP_ARGCOUNT "Count local variables in a function" #define HLP_UNSTRIP "Unstrip the current working binary" #define HLP_RENAME "Symbol rename: rename " +#define HLP_ASTRIP "Remove stored sections of control flow analysis results" /* Scripting only commands */ #define HLP_CMP "Compare 2 parameters (modify $_ variable)" @@ -229,9 +237,8 @@ #define HLP_PROFILE "Change the ELFsh profiling behavior \n\n\t" \ CMD_PROFILE" enable|disable warn|trace|alloc|debug|all" -#define HLP_DECLARE "Declare a new typed named variable \n\n\t" \ - " = field1val ... fieldNval\n" - +#define HLP_DECLARE "Declare a new variable of this type \n\n\t" \ + " = field1:val1 <...> fieldN:valN\n" /* Interactive only command */ #define HLP_LOAD "Load a new ELF file" @@ -252,6 +259,11 @@ CMD_LISTS" regx : Print matching lists \n\n\t" \ "If a single list matches, its content is printed" + +#define HLP_SETUNION "Compute union of all input set/hash/tables parameters" +#define HLP_SETINTER "Compute intersection of all input set/hash/tables parameters" + + #define HLP_VECTORS "Act on reflective objects \n\n\t" \ "vectors \t List existing vectors\n\t" \ "vectors name \t List vector content\n\t" \ @@ -268,7 +280,8 @@ #define HLP_DBGSTACK "Dump N words on debugger stack" #define HLP_DUMPREGS "Dump registers of debuggee at breakpoint or step" #define HLP_STEP "Enable stepping of debuggee program" -#define HLP_ITRACE "Enable tracing of debuggee program until next event" +#define HLP_ITRACE "Enable tracing of debuggee program until next event \n" \ + "\t If given parameters, perform memory tracing of them" #define HLP_START "Start the debuggee program" #define HLP_DELETE "Delete breakpoint by symbol, addr, or ID" #define HLP_CONTINUE "Continue executing debuggee program after break" diff -Nru eresi-0.8a25/libstderesi/include/.svn/all-wcprops eresi-0.0.20110516/libstderesi/include/.svn/all-wcprops --- eresi-0.8a25/libstderesi/include/.svn/all-wcprops 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 43 -/svn/!svn/ver/945/trunk/libstderesi/include -END -libstderesi.h -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/945/trunk/libstderesi/include/libstderesi.h -END -libstderesi-help.h -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/839/trunk/libstderesi/include/libstderesi-help.h -END diff -Nru eresi-0.8a25/libstderesi/include/.svn/entries eresi-0.0.20110516/libstderesi/include/.svn/entries --- eresi-0.8a25/libstderesi/include/.svn/entries 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libstderesi/include -http://svn.eresi-project.org/svn - - - -2008-03-27T22:24:43.639027Z -945 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libstderesi.h -file - - - - -2008-04-06T23:16:28.538881Z -c97fdbe5ffd88351f24ca39bef7d405e -2008-03-27T22:24:43.639027Z -945 -may - -libstderesi-help.h -file - - - - -2008-04-06T23:16:28.548149Z -083d04dc51f343ab96502bfe0a76903c -2007-12-09T23:00:18.000000Z -839 -may - diff -Nru eresi-0.8a25/libstderesi/include/.svn/format eresi-0.0.20110516/libstderesi/include/.svn/format --- eresi-0.8a25/libstderesi/include/.svn/format 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libstderesi/include/.svn/text-base/libstderesi-help.h.svn-base eresi-0.0.20110516/libstderesi/include/.svn/text-base/libstderesi-help.h.svn-base --- eresi-0.8a25/libstderesi/include/.svn/text-base/libstderesi-help.h.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/.svn/text-base/libstderesi-help.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,281 +0,0 @@ -/* -** libstderesi.help.h for elfsh -** -** Started on Wed Jan 03 19:19:04 2007 jfv -** -** $Id: libstderesi-help.h,v 1.3 2007-12-09 23:00:18 may Exp $ -** -*/ -#ifndef __REVM_HELP_H_ - #define __REVM_HELP_H_ - -/* Commands */ -#define HLP_DISASM "Disassemble matching binary objects in current file\n\n" \ - "disasm parameter\n\n" \ - "Parameter format : regx, regx:rva, regx:rva%size, regx%size\n" \ - " - regx : Regular expression (mandatory) \n" \ - " - rva : Byte offset from the beginning (optional) \n" \ - " - size : Bytes number limit (optional) \n\n" \ - -#define HLP_HEXA "Dump matching binary objects in current file\n\n" \ - "X parameter\n\n" \ - "Parameter format : regx, regx:rva, regx:rva%size, regx%size\n" \ - " - regx : Regular expression (mandatory) \n" \ - " - rva : Byte offset from the beginning (optional) \n" \ - " - size : Bytes number limit (optional) \n\n" \ - -#define HLP_INSERT "Inject new object in current working file \n\n" \ - "insert sect name code|data|unmap [sz] [align] \n" \ - " sym name value [sz] \n" \ - " phdr type vaddr [sz] " - -#define HLP_REMOVE "Remove ELF object from current working file\n\n" \ - "remove params \n\n" \ - " Parameter format : sect name \n" \ - " sym name \n" \ - " phdr index " - -#define HLP_REL "Print all relocation tables from current file" -#define HLP_DYNAMIC "Print the ELF dynamic section" -#define HLP_SYM "Print symbol table (.symtab)" -#define HLP_COREINFO "Print information about the core file" -#define HLP_DYNSYM "Print dynamic symbol table (.dynsym)" -#define HLP_SHT "Print Section Header Table (SHT)" -#define HLP_RSHT "Print the runtime Section Header Table (RSHT)" -#define HLP_PHT "Print Program Header Table (PHT)" -#define HLP_RPHT "Print the runtime Program Header Table (RPHT)" -#define HLP_DEBUG "Print uni format debugging information" -#define HLP_DWARF "Print raw dwarf debugging information" -#define HLP_ELF "Print ELF header" -#define HLP_INTERP "Print ELF interpreter path" -#define HLP_NOTES "Print the NOTES section content" -#define HLP_GOT "Print the Global Offset Table (GOT) section" -#define HLP_CTORS "Print CTORS section content" -#define HLP_DTORS "Print DTORS section content" -#define HLP_SHTRM "Mark Section Header Table as removed" -#define HLP_COMMENT "Print comment section content" -#define HLP_SET "Set parameter object value" -#define HLP_PRINT "Print list of resolved values of parameters" -#define HLP_EXEC "Fork and execute parameter command (with args)" -#define HLP_ADD "Add the 2 parameters" -#define HLP_SUB "Substract 2nd parameter to the first one" -#define HLP_MUL "Multiply the 2 parameters" -#define HLP_DIV "Divide first param by second one" -#define HLP_MOD "Modulo operation between 2 parameters" -#define HLP_INFO "Print ELF objects usage for scripting" -#define HLP_METACMD "Execute a UNIX shell" -#define HLP_WRITE "Write raw data to ELF section" -#define HLP_APPEND "Append raw data to ELF section" -#define HLP_EXTEND "Extend ELF section with zeros" -#define HLP_FIXUP "Mark BSS section to be included in disk file" -#define HLP_FINDREL "Try to find back stripped relocation information" -#define HLP_MODLOAD "Load an ELFsh/E2dbg module" -#define HLP_MODULOAD "Unload an ELFsh/E2dbg module" -#define HLP_MODHELP "Print the ELFsh/E2dbg modules help information" -#define HLP_HELP "Print the help summary" -#define HLP_RELINJCT "Relocate a new .o file inside the current file or process" -#define HLP_STOP "Stop executing a script and switch to interactive mode" -#define HLP_TRACES "\t Trace some functions\n\n\t Trace command options: \n\n" \ - " add funcreg [optional_traces_name] : add a function to a given trace\n" \ - " rm funcname [optional_traces_name] : remove a function from a given trace\n" \ - " exclude funcreg : add a list of regex to exclude at the end\n" \ - " rmexclude funcreg : delete a regex from the exclude list\n" \ - " enable funcname|all [optional_traces_name] : enable tracing for a function in a given trace (enabled by default after a add)\n" \ - " disable funcname|all [optional_traces_name] : disable tracing for a function in a given trace\n" \ - " create tracename : create a new trace with a pool of traced functions by default\n" \ - " delete tracename : delete a trace\n" \ - " flush tracename : remove all functions from a given trace\n" \ - " [optional_traces_name] : list all available traces\n\n" - -#define HLP_TRACEADD "\t Add all submited functions on global traces scope.\n\n" -#define HLP_TRACEEXCLUDE "\t Add all submited functions to exclude list.\n\n" -#define HLP_TRACERUN "\t Run a traced binary directly.\n\n" - -#define HLP_COLOR "Associates data types to colors \n\n\t" \ - CMD_COLOR" type [bg,fg] color \n\n\t" \ - CMD_COLOR" type [underline,bold] (1=on,0=off)\n\n\t" \ - "Available types : address, number, string, endstring, warnstring \n\t" \ - " typestring, fieldstring, instr, pspecial, psname \n\t" \ - " pspecial, pversion, prelease, pedition, function \n\t" \ - " filename \n\t" \ - "Available colors : " \ - "\033[00;01;30mblack " \ - "\033[00;01;31mred " \ - "\033[00;901;32mgreen " \ - "\033[00;01;33myellow " \ - "\033[00;01;34mblue " \ - "\033[00;01;35mmagenta " \ - "\033[00;01;36mcyan " \ - "\033[00mwhite" - -#define HLP_NOCOLOR "Toggle color status" -#define HLP_VERSION "Print the version table with symbol information" -#define HLP_VERDEF "Print the defined versions table" -#define HLP_VERNEED "Print the needed versions table" -#define HLP_HASH "Print the dynsymbols ELF hash table (.hash)" - -#define HLP_DEFINE "Define a given name (param 1) to a constant value (param 2)" -#define HLP_UNDEF "Undefine a given name to its value" - -/* Configuration commands */ -#define HLP_HIJACK "Redirect a function to another function \n\n\t" \ - CMD_HIJACK" [hooked funcname|addr] [hooking funcname|addr]" - -#define HLP_FLUSH "Flush all injected .o files from current file" -#define HLP_VLIST "List current used internal ELFsh/E2dbg variables" -#define HLP_SOURCE "Source a script file in current session" -#define HLP_SDIR "Change the script directory" -#define HLP_LSCRIPTS "List macro commands" -#define HLP_CAT "Print the file argument" -#define HLP_LOG "Enable logging of work session \n\n\t" \ - CMD_LOG" [outputfile|stop]" - -#define HLP_EXPORT "Export an environment variable \n\n\t" \ - CMD_EXPORT" variable value" - -#define HLP_EDIT "Edit the file given in parameter" - -/* Network commands */ -#define HLP_NETWORK "Activate networking capabilities" -#define HLP_NETLIST "List connected network clients" -#define HLP_NETKILL "Kill a network client by IP" -#define HLP_SHARED "Shared prefix : allow opened file to be shared between users" -#define HLP_CONNECT "Add an DUMP connection to given host" -#define HLP_DISCON "Kill the DUMP connection from IP" -#define HLP_PEERSLIST "List connected DUMP peers" -#define HLP_RCMD "Execute a command on a remote machine" - -/* Flow analysis commands */ -#define HLP_GRAPH "Generate GVZ files:\n\n\t" \ - CMD_GRAPH " - will plot a function dependency graph\n\t" \ - CMD_GRAPH " func - will plot dependency graph of given function\n\t" \ - CMD_GRAPH " bloc - will plot control flow graph of given function\n" - -#define HLP_SETGVL "Set graph verbosity level \n\n\t"CMD_SETGVL" <0-5> \n" -#define HLP_INSPECT "Disassemble block at symbol/address\n" -#define HLP_FLOWJACK "Hijack basic block reference from sym1 to sym2\n" -#define HLP_ADDGOTO "\t"CMD_ADDGOTO" \n\n\t" \ - "Inform elfsh about the location and value of a function pointer\n" -#define HLP_FLOWTEST "Test command for graph analysis features" -#define HLP_ANALYSE "Perform libmjollnir analysis" -#define HLP_CONTROL "Print stored control flow information" -#define HLP_UNSTRIP "Unstrip the current working binary" -#define HLP_RENAME "Symbol rename: rename " - -/* Scripting only commands */ -#define HLP_CMP "Compare 2 parameters (modify $_ variable)" -#define HLP_TEST "Test enabled bits in first parameter (modify $_ variable)" -#define HLP_JMP "Inconditional jump to script label" -#define HLP_JE "Jump on label if equal (use last cmp result)" -#define HLP_JNE "Jump on label if nont equal (use last cmp result)" -#define HLP_JL "Jump on label if lower (use last cmp result)" -#define HLP_JG "Jump on label if greater (use last cmp result)" -#define HLP_JLE "Jump on label if lower or equal (use last cmp result)" -#define HLP_JGE "Jump on label if greater or equal (use last cmp result)" - -#define HLP_FOREACH "Iterate on hash tables or arrays \n\n\t" \ - "foreach idxvar of minint until maxint \n\t" \ - "(...) \n\t" \ - "forend \n\n\t" \ - "foreach elmvar of hashobj [as regx] \n\t" \ - "(...) \n\t" \ - "forend \n\n" -#define HLP_FOREND HLP_FOREACH - -#define HLP_MATCH "Conditional program transformation using rewriting \n\n\t" \ - "rewrite $variable into \n\n\t" \ - " case CandidateType1(fieldname:value, ...) -> ProducedType1(...)::ProducedType2(...)::... \n\t" \ - " case CandidateType2(fieldname:value, ...) -> ProducedType2(...)::ProducedType2(...)::... \\n\t" \ - " .... \n\t" \ - " default print No match; other eresi commands \n\n\t" \ - "endmatch \n" -#define HLP_MATCHEND HLP_MATCH -#define HLP_CASE HLP_MATCH -#define HLP_DEFAULT HLP_MATCH -#define HLP_PRE "Execute side-effects ERESI commands before transformation (see rewrite)" -#define HLP_POST "Execute side-effects ERESI commands after transformation (see rewrite)" -#define HLP_INTO "Transform a matching expression (see rewrite command)" - -#define HLP_REFLECT "Reflect instruction list for a given basic block \n\n\t" \ - "reflect <$block|0xaddr> \n\n\t" \ - "Instruction list is then accessible from fileid.instrlist[0xaddr] \n" - -/* Prefixes */ -#define HLP_SORT "Sorting prefix (use a -addr- or s -size-)" -#define HLP_QUIET "Toggle quiet flag (do not print executed commands)" -#define HLP_VERB "Toggle verbose flag (undo the quiet flag)" -#define HLP_ALL "All prefix : set global regular expression" -#define HLP_ALERT "Alert prefix : change alert regular expression" -#define HLP_FORCE "Force sanity checks to be disabled for the command" - -/* Type commands */ -#define HLP_INFORM "Inform a type about a variable \n\n\t" \ - "inform type \t List all variables of a given type \n\t" \ - "inform type name [address] \t Inform type about variable \n" - -#define HLP_UNINFORM "Uninform a type about a variable \n\n\t" \ - "uninform type \t Remove all variables associated to type \n\t" \ - "uninform type name \t Remove a given variable from type information\n" - -#define HLP_TYPE "Create or list ERESI types\n\n\t" \ - "type \t List all existing types \n\t" \ - "type regx \t Print matching types \n\t" \ - "type name = field1:type1 ... fieldN:typeN \t Create a new type \n\n\t" \ - "Fields and types can be named using scripting variables \n" - -#define HLP_TYPEDEF "Copy and rename a type \n\n\t" \ - "typedef name newname" - -#define HLP_PROFILE "Change the ELFsh profiling behavior \n\n\t" \ - CMD_PROFILE" enable|disable warn|trace|alloc|debug|all" - -#define HLP_DECLARE "Declare a new typed named variable \n\n\t" \ - " = field1val ... fieldNval\n" - - -/* Interactive only command */ -#define HLP_LOAD "Load a new ELF file" -#define HLP_UNLOAD "Unload file (id or name)" -#define HLP_SAVE "Dump output file at parameter location" -#define HLP_QUIT "Quit current session or script" -#define HLP_RETURN "Return from current ERESI script (put retval in $_)" -#define HLP_SWITCH "Change the current working object" -#define HLP_LIST "List loaded ELF objects" -#define HLP_WORKSPACE "Syntax: workspace [name] : List or switch workspaces" -#define HLP_EMPTY "Empty hash tables given as parameters" -#define HLP_TABLES "Print hash tables list and content \n\n\t" \ - CMD_TABLES" : Print all tables \n\t" \ - CMD_TABLES" regx : Print matching tables \n\n\t" \ - "If a single hash matches, its content is printed" -#define HLP_LISTS "Print linked lists and content \n\n\t" \ - CMD_LISTS" : Print all lists \n\t" \ - CMD_LISTS" regx : Print matching lists \n\n\t" \ - "If a single list matches, its content is printed" - -#define HLP_VECTORS "Act on reflective objects \n\n\t" \ - "vectors \t List existing vectors\n\t" \ - "vectors name \t List vector content\n\t" \ - "vectors name:idx1:...:idxN \t Print vector entry\n\t" \ - "vectors name:idx1:...:idxN symbol|addr \t Modify vector entry\n\n\t" \ - "Vector objects indexes can be given by scripting variables \n" -/* Debugger commands */ -#define HLP_MODE "Print or change to debugger (d) or static (s) mode" -#define HLP_LINKMAP "Print Linkmap list for this process" -#define HLP_BT "Print backtrace (needs frame pointer)" -#define HLP_BP "Put a breakpoint on symbol or address (0xADDR)" -#define HLP_WATCH "Put a watchpoint on symbol or address (0xADDR)" -#define HLP_STACK "Dump N words on debuggee stack" -#define HLP_DBGSTACK "Dump N words on debugger stack" -#define HLP_DUMPREGS "Dump registers of debuggee at breakpoint or step" -#define HLP_STEP "Enable stepping of debuggee program" -#define HLP_ITRACE "Enable tracing of debuggee program until next event" -#define HLP_START "Start the debuggee program" -#define HLP_DELETE "Delete breakpoint by symbol, addr, or ID" -#define HLP_CONTINUE "Continue executing debuggee program after break" -#define HLP_DISPLAY "List or add displayed commands on breakpoints hits or step" -#define HLP_UNDISPLAY "UNIMPLEMENTED : Remove a display command" -#define HLP_THREADS "Print existing threads list or switch to a given thread view" - -#define HLP_CONFIGURE "Configure internal elfsh behavior." - -#endif diff -Nru eresi-0.8a25/libstderesi/include/.svn/text-base/libstderesi.h.svn-base eresi-0.0.20110516/libstderesi/include/.svn/text-base/libstderesi.h.svn-base --- eresi-0.8a25/libstderesi/include/.svn/text-base/libstderesi.h.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/include/.svn/text-base/libstderesi.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,359 +0,0 @@ -/** -** @file libstderesi.h -** -** Started on Thu Feb 22 07:19:04 2001 jfv -** $Id: libstderesi.h,v 1.5 2008-02-16 12:32:27 thor Exp $ -*/ -#ifndef __LIBSTDERESI_H_ - #define __LIBSTDERESI_H_ - -/* User defined configuration */ -#include "revm.h" - -/* Help strings */ -#include "libstderesi-help.h" - -/* Commands */ -#define CMD_DEFINE "define" -#define CMD_UNDEF "undef" -#define CMD_DISASM "disasm" -#define CMD_DISASM2 "D" -#define CMD_HEXA "hexa" -#define CMD_HEXA2 "X" -#define CMD_REL "rel" -#define CMD_REL2 "r" -#define CMD_DYNAMIC "dyn" -#define CMD_DYNAMIC2 "d" -#define CMD_SYM "sym" -#define CMD_SYM2 "syms" -#define CMD_DYNSYM "dynsym" -#define CMD_DYNSYM2 "ds" -#define CMD_SHT "sht" -#define CMD_SHT2 "s" -#define CMD_PHT "pht" -#define CMD_PHT2 "p" -#define CMD_DWARF "dwarf" -#define CMD_DWARF2 "dw" -#define CMD_ELF "elf" -#define CMD_ELF2 "e" -#define CMD_INTERP "interp" -#define CMD_INTERP2 "i" -#define CMD_NOTE "notes" -#define CMD_NOTE2 "n" -#define CMD_COREINFO "coreinfo" -#define CMD_GOT "got" -#define CMD_GOT2 "g" -#define CMD_CTORS "ctors" -#define CMD_CTORS2 "ct" -#define CMD_DTORS "dtors" -#define CMD_DTORS2 "dt" -#define CMD_SHTRM "shtrm" -#define CMD_COMMENT "comments" -#define CMD_COMMENT2 "c" -#define CMD_BINFILE_R "f" -#define CMD_BINFILE_W "w" -#define CMD_SET "set" -#define CMD_PRINT "print" -#define CMD_EXEC "exec" -#define CMD_ADD "add" -#define CMD_SUB "sub" -#define CMD_MUL "mul" -#define CMD_DIV "div" -#define CMD_TEST "test" -#define CMD_MOD "mod" -#define CMD_INFO "info" -#define CMD_METACMD "!" -#define CMD_WRITE "write" -#define CMD_APPEND "append" -#define CMD_EXTEND "extend" -#define CMD_FIXUP "fixup" -#define CMD_FINDREL "findrel" -#define CMD_MODLOAD "modload" -#define CMD_MODULOAD "modunload" -#define CMD_MODHELP "modhelp" -#define CMD_HELP "help" -#define CMD_RELINJCT "reladd" -#define CMD_STOP "stop" -#define CMD_HIJACK "redir" -#define CMD_COLOR "setcolor" -#define CMD_NOCOLOR "nocolor" -#define CMD_TRACES "traces" -#define CMD_TRACEADD "traceadd" -#define CMD_TRACEEXCLUDE "traceexclude" -#define CMD_TRACERUN "tracerun" -#define CMD_TRACEADD_CMDLINE "t" -#define CMD_TRACEEXCL_CMDLINE "u" -#define CMD_TYPE "type" -#define CMD_UNION "union" -#define CMD_TYPEDEF "typedef" -#define CMD_INTO "into" - -#define CMD_INSERT "insert" -#define CMD_INSERT2 "ins" -#define CMD_REMOVE "remove" -#define CMD_REMOVE2 "rm" -#define CMD_FLUSH "flush" -#define CMD_VLIST "vlist" -#define CMD_VARLIST "varlist" -#define CMD_SOURCE "source" -#define CMD_SDIR "sdir" -#define CMD_CLEANUP "cleanup" -#define CMD_LSCRIPTS "lscripts" -#define CMD_CAT "cat" -#define CMD_PROFILE "profile" -#define CMD_LOG "log" -#define CMD_EXPORT "export" -#define CMD_EDIT "edit" - -/* Type related commands */ -#define CMD_INFORM "inform" -#define CMD_UNINFORM "uninform" -#define CMD_INFORM2 "annotate" -#define CMD_UNINFORM2 "unannotate" - -/* Debugging format commands */ -#define CMD_DEBUG "debug" - -/* ELF Version commands */ -#define CMD_VERSION "version" -#define CMD_VERNEED "verneed" -#define CMD_VERDEF "verdef" -#define CMD_HASH "hash" - -/* Network commands */ -#define CMD_NETWORK "net" -#define CMD_NETWORK2 "network" -#define CMD_NETLIST "netlist" -#define CMD_NETKILL "netkill" -#define CMD_SHARED "shared" -#define CMD_CONNECT "connect" -#define CMD_DISCON "disconnect" -#define CMD_PEERSLIST "peerslist" -#define CMD_RCMD "rcmd" - -/* Scripting only commands */ -#define CMD_CMP "cmp" -#define CMD_CMP2 "compare" -#define CMD_JMP "jmp" -#define CMD_JE "je" -#define CMD_JNE "jne" -#define CMD_JL "jl" -#define CMD_JG "jg" -#define CMD_JLE "jle" -#define CMD_JGE "jge" -#define CMD_REFLECT "reflect" - -/* Prefixes */ -#define CMD_SORT "sort" -#define CMD_SORT2 "sr" -#define CMD_QUIET "q" -#define CMD_QUIET2 "quiet" -#define CMD_VERB "verb" -#define CMD_VERB2 "v" -#define CMD_ALL "all" -#define CMD_ALL2 "a" -#define CMD_ALERT "alert" -#define CMD_FORCE "force" - -/* Interactive only command */ -#define CMD_LOAD "load" -#define CMD_UNLOAD "unload" -#define CMD_SAVE "save" -#define CMD_SWITCH "switch" -#define CMD_LIST "list" -#define CMD_LIST2 "l" -#define CMD_WORKSPACE "workspace" -#define CMD_WORKSPACE2 "w" -#define CMD_VECTORS "vectors" -#define CMD_TABLES "tables" -#define CMD_LISTS "lists" -#define CMD_EMPTY "empty" - -/* Code analysis commands */ -#define CMD_FLOWJACK "flowjack" -#define CMD_GRAPH "graph" -#define CMD_INSPECT "inspect" -#define CMD_ADDGOTO "addgoto" -#define CMD_SETGVL "setgvl" -#define CMD_UNSTRIP "unstrip" -#define CMD_RENAME "rename" -#define CMD_CONTROL "control" -#define CMD_ANALYSE "analyse" - -/* config commands */ -#define CMD_CONFIGURE "configure" - -#define CMD_RSHT "rsht" -#define CMD_RPHT "rpht" - -/* Extern variables */ -extern char quit_msg[512]; -extern void (*prompt_token_setup)(char *name, u_int size); -extern char prompt_token[512]; -extern u_char quit_msg_setup; - -/* Constructors */ -void eresi_commands_init(); -void eresi_stdconstructor() __attribute__((constructor)); - -/* Commands execution handlers, each in their respective file */ -int cmd_configure(); -int cmd_type(); -int cmd_declare(); -int cmd_typedef(); -int cmd_dyn(); -int cmd_sht(); -int cmd_rsht(); -int cmd_rpht(); -int cmd_rel(); -int cmd_dynsym(); -int cmd_symtab(); -int cmd_pht(); -int cmd_got(); -int cmd_dtors(); -int cmd_ctors(); -int cmd_elf(); -int cmd_interp(); -int cmd_list(); -int cmd_notes(); -int cmd_coreinfo(); -int cmd_sym(); -int cmd_hexa(); -int cmd_disasm(); -int cmd_shtrm(); -int cmd_comments(); -int cmd_modhelp(); -int cmd_help(); -int cmd_quit(); -int cmd_return(); -int cmd_load(); -int cmd_unload(); -int cmd_save(); -int cmd_dolist(); -int cmd_doswitch(); -int cmd_set(); -int cmd_get(); -int cmd_print(); -int cmd_info(); -int cmd_add(); -int cmd_sub(); -int cmd_mul(); -int cmd_div(); -int cmd_mod(); -int cmd_cmp(); -int cmd_test(); -int cmd_meta(); -int cmd_write(); -int cmd_append(); -int cmd_extend(); -int cmd_fixup(); -int cmd_quiet(); -int cmd_force(); -int cmd_verb(); -int cmd_exec(); -int cmd_findrel(); -int cmd_modload(); -int cmd_modunload(); -int cmd_relinject(); -int cmd_stop(); -int cmd_hijack(); -int cmd_insert(); -int cmd_remove(); -int cmd_sort(); -int cmd_glregx(); -int cmd_alert(); -int cmd_flush(); -int cmd_vlist(); -int cmd_source(); -int cmd_scriptsdir(); -int cmd_script(); -int cmd_lscripts(); -int cmd_cat(); -int cmd_color(); -int cmd_nocolor(); -int cmd_phtend(); -int cmd_network(); -int cmd_netlist(); -int cmd_netkill(); -int cmd_discon(); -int cmd_connect(); -int cmd_peerslist(); -int cmd_rcmd(); -int cmd_profile(); -int cmd_log(); -int cmd_export(); -int cmd_edit(); -int cmd_traces(); -int cmd_traceadd(); -int cmd_traceexclude(); -int cmd_tracerun(); -int cmd_shared(); -int cmd_verneed(); -int cmd_verdef(); -int cmd_version(); -int cmd_hashx(); -int cmd_vectors(); -int cmd_tables(); -int cmd_lists(); -int cmd_empty(); -int cmd_inform(); -int cmd_uninform(); - -/* Scripting only commands */ -int cmd_jmp(); -int cmd_je(); -int cmd_jne(); -int cmd_jg(); -int cmd_jl(); -int cmd_jge(); -int cmd_jle(); -int cmd_foreach(); -int cmd_forend(); -int cmd_match(); -int cmd_matchend(); -int cmd_case(); -int cmd_into(); -int cmd_pre(); -int cmd_post(); -int cmd_reflect(); -int cmd_default(); -int cmd_define(); -int cmd_undef(); - -/* Flow analysis commands */ -int cmd_flowload(void); -int cmd_flowsave(void); -int cmd_graph(void); -int cmd_inspect(void); -int cmd_flow(void); -int cmd_testflow(void); -int cmd_flowjack(void); -int cmd_addgoto(void); -int cmd_setgvl(void); -int cmd_analyse(); -int cmd_unstrip(); -int cmd_rename(); -int cmd_control(); - -/* Workspaces commands */ -int cmd_workspace(); -int cmd_next_workspace(); - -/* Debugging functions */ -int cmd_mode(); -int cmd_linkmap(); -int cmd_bt(); -int cmd_bp(); -int cmd_watch(); -int cmd_stack(); -int cmd_dbgstack(); -int cmd_delete(); -int cmd_step(); -int cmd_display(); -int cmd_undisplay(); - -/* Debug format functions */ -int cmd_debug(); - -#endif /* __LIBSTDERESI_H_ */ - diff -Nru eresi-0.8a25/libstderesi/lang/atomic.c eresi-0.0.20110516/libstderesi/lang/atomic.c --- eresi-0.8a25/libstderesi/lang/atomic.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/atomic.c 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,543 @@ +/** +* @file libstderesi/lang/atomic.c + ** @ingroup lang + ** @brief Implement arithmetic operations + ** + ** Started on Sun Feb 9 22:43:34 2003 jfv + ** $Id: atomic.c 1397 2009-09-13 02:19:08Z may $ + */ +#include "libstderesi.h" + + + +/* SET command */ +int cmd_set() +{ + revmexpr_t *e1; + revmexpr_t *e2; + int error; + int errvar; + revmexpr_t *last; + u_int oid; + revmobj_t *obj; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Resolve all possible case between expressions and objects */ + error = -1; + errvar = 0; + + /* The destination of a set must be defined in the -current- scope */ + if (hash_get(&world.curjob->recur[world.curjob->curscope].exprs, world.curjob->curcmd->param[0])) + e1 = revm_expr_get(world.curjob->curcmd->param[0]); + else + e1 = NULL; + + e2 = revm_expr_get(world.curjob->curcmd->param[1]); + + /* The $_ variable is updated as well */ + last = revm_expr_get(REVM_VAR_RESULT); + if (last == NULL) + { + obj = revm_create_IMMED(ASPECT_TYPE_INT, 1, 0); + last = revm_expr_create_from_object(obj, REVM_VAR_RESULT, 1); + if (!last) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to create result variable", -1); + } + + /* Make sure we lookup an expression with container if given by ID */ + if (e2 && e2->value && e2->type->type == ASPECT_TYPE_OID) + { + oid = (e2->value->immed ? e2->value->immed_val.word : e2->value->get_obj(e2->value->parent)); + e2 = revm_expr_lookup(oid); + if (!e2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get expression from id", -1); + } + + /* Assignment between existing expressions */ + if (e1 && e2) + { + errvar = revm_expr_set(e1, e2); + if (errvar < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set expressions", (-1)); + + /* Dont copy the result variable over itself if we use $_ as a source variable */ + if (strcmp(e2->label, REVM_VAR_RESULT)) + { + revm_expr_destroy_by_name(last->label); + last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); + if (!last) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set result expression", (-1)); + } + + if (!world.state.revm_quiet) + revm_output(" [*] Expression set succesfully \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Fix the source expression if unresolved */ + if (!e2) + { + e2 = revm_compute(world.curjob->curcmd->param[1]); + if (!e2) + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 0); + if (!e2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to create source object", (-1)); + } + + /* Fix the destination expression */ + if (!e1) + { + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 0); + if (!e1) + { + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid destination variable", (-1)); + } + } + + /* Set converted value */ + if (e2->value) + { + if (!e1->type && revm_convert_object(e1, e2->type->type) < 0) + { + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to convert destination type expression", (-1)); + } + if (e1->type->type != e2->type->type && + revm_convert_object(e2, e1->type->type) < 0) + { + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to convert source type expression", (-1)); + } + if (revm_expr_set(e1, e2) < 0) + { + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set expression", (-1)); + } + } + + /* Set complex type */ + else + { + if (!e1->type) + { + revm_expr_destroy_by_name(e1->label); + e1 = revm_expr_copy(e2, world.curjob->curcmd->param[0], 0); + if (!e1) + { + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set expressions", (-1)); + } + } + else if (revm_expr_set(e1, e2) < 0) + { + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set expression", (-1)); + } + } + + /* Copy the result in the last result variable */ + if (e2->type->type != ASPECT_TYPE_HASH && e2->type->type != ASPECT_TYPE_LIST) + { + revm_expr_destroy_by_name(last->label); + last = revm_expr_copy(e2, REVM_VAR_RESULT, 0); + if (!last) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to set result expression", (-1)); + } + + /* Everything OK */ + if (e1->value && !e1->value->perm) + revm_expr_destroy_by_name(e1->label); + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + + if (!world.state.revm_quiet) + revm_output(" [*] Expression set succesfully \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/* Comparison command */ +int cmd_cmp() +{ + revmexpr_t *e1; + revmexpr_t *e2; + char logbuf[BUFSIZ]; + int res; + eresi_Addr val; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* First check if we are dealing with exprs */ + e1 = revm_expr_get(world.curjob->curcmd->param[0]); + e2 = revm_expr_get(world.curjob->curcmd->param[1]); + if (e1 && e2) + { + res = revm_expr_compare(e1, e2, &val); + if (res < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to compare expressions", (-1)); + goto end; + } + + if (!e2) + { + e2 = revm_compute(world.curjob->curcmd->param[1]); + if (!e2) + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 0); + } + if (!e1) + { + e1 = revm_compute(world.curjob->curcmd->param[0]); + if (!e1) + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 0); + } + if (!e1 || !e2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + if (!e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter has type unknown thus uncomparable", -1); + + /* Error checking */ + res = revm_expr_compare(e1, e2, &val); + if (e1->value && !e1->value->perm) + revm_expr_destroy_by_name(e1->label); + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + if (res < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error while setting result variable", res); + + /* Result reporting */ + end: + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + " [*] Objects are %s. \n\n", (!val ? "EQUALS" : "INEQUALS")); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + + +/* Bit testing command */ +int cmd_test() +{ + revmexpr_t *e1; + revmexpr_t *e2; + char logbuf[BUFSIZ]; + u_int res; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + if (!e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameter has type unknown thus uncomparable", -1); + + /* Perform the operation */ + if (revm_testbit(e1, e2, &res) < 0) + { + if (e1->value && !e1->value->perm) + revm_expr_destroy_by_name(e1->label); + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Error while setting result variable", -1); + } + + if (e1->value && !e1->value->perm) + revm_expr_destroy_by_name(e1->label); + if (e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + + /* Everything was OK */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, " [*] $_ = %u \n\n", res); + revm_output(logbuf); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/************************ Now arithmetic commands *****************/ + + + +/* ADD command */ +int cmd_add() +{ + revmexpr_t *e1; + revmexpr_t *e2; + revmobj_t *o1; + revmobj_t *o2; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + o1 = e1->value; + o2 = e2->value; + + /* In case we have a hash table as parameter */ + if (o1->otype->type == ASPECT_TYPE_HASH) + { + ret = revm_hash_add(o1->parent, e2); + revm_expr_destroy_by_name(e1->label); // destroy the source alias variable + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to insert hash element", -1); + if (!world.state.revm_quiet) + revm_output(" [*] Element inserted succesfully\n\n"); + goto end; + } + + /* In case we have a hash table as parameter */ + else if (o1->otype->type == ASPECT_TYPE_LIST) + { + ret = revm_elist_add(o1->parent, e2); + revm_expr_destroy_by_name(e1->label); // destroy the source alias variable + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to insert list element", -1); + if (!world.state.revm_quiet) + revm_output(" [*] Element inserted succesfully\n\n"); + goto end; + } + + /* Perform computation */ + if (revm_arithmetics(NULL, e1, e2, REVM_OP_ADD) < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to add elements", -1); + } + + /* Return success */ + end: + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + +/* SUB command */ +int cmd_sub() +{ + revmexpr_t *e1; + revmexpr_t *e2; + revmobj_t *o1; + revmobj_t *o2; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + o1 = e1->value; + o2 = e2->value; + + /* In case we have a hash table as parameter */ + if (o1->otype->type == ASPECT_TYPE_HASH) + { + ret = revm_hash_del(o1->parent, e2); + if (ret < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to delete hash element", -1); + } + if (!world.state.revm_quiet) + revm_output(" [*] Element deleted succesfully\n\n"); + goto end; + } + + /* In case we have a hash table as parameter */ + else if (o1->otype->type == ASPECT_TYPE_LIST) + { + ret = revm_elist_del(o1->parent, e2); + if (ret < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to delete list element", -1); + } + if (!world.state.revm_quiet) + revm_output(" [*] Element deleted succesfully\n\n"); + goto end; + } + + /* Perform computation */ + if (revm_arithmetics(NULL, e1, e2, REVM_OP_SUB) < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to substract elements", -1); + } + + end: + /* Everything was OK */ + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* MUL command */ +int cmd_mul() +{ + revmexpr_t *e1; + revmexpr_t *e2; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + + /* Perform computation */ + if (revm_arithmetics(NULL, e1, e2, REVM_OP_MUL) < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to multiply elements", -1); + } + + /* Everything was OK */ + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* DIV command */ +int cmd_div() +{ + revmexpr_t *e1; + revmexpr_t *e2; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + + /* Perform computation */ + if (revm_arithmetics(NULL, e1, e2, REVM_OP_DIV) < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to divide elements", -1); + } + + /* Everything was OK */ + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/* MOD command */ +int cmd_mod() +{ + revmexpr_t *e1; + revmexpr_t *e2; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + + /* Perform computation */ + if (revm_arithmetics(NULL, e1, e2, REVM_OP_MOD) < 0) + { + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to divide elements", -1); + } + + /* Everything was OK */ + if (e2 && e2->value && !e2->value->perm) + revm_expr_destroy_by_name(e2->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + diff -Nru eresi-0.8a25/libstderesi/lang/foreach.c eresi-0.0.20110516/libstderesi/lang/foreach.c --- eresi-0.8a25/libstderesi/lang/foreach.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/foreach.c 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,518 @@ +/** + * @file libstderesi/lang/foreach.c + * @ingroup lang + * @brief Implement the iteration on arrays, lists, and hash tables. + * + * Started on Wed Feb 28 19:19:04 2007 jfv + * $Id: foreach.c 1438 2010-12-13 07:18:00Z may $ + */ +#include "libstderesi.h" + + +/** Effectively create a new induction variable */ +static revmexpr_t *revm_induction_load(char *name) +{ + revmexpr_t *induction; + revmobj_t *var; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* We are starting a new foreach, induction variable cannot be initialized */ + assert(world.curjob->iter[world.curjob->curloop].listidx == REVM_IDX_UNINIT); + + var = revm_create_IMMED(ASPECT_TYPE_UNKNOW, 1, 0); + induction = revm_expr_create_from_object(var, name, 1); + world.curjob->iter[world.curjob->curloop].curind = induction; + + world.curjob->iter[world.curjob->curloop].reclevel = world.curjob->curscope; + world.curjob->iter[world.curjob->curloop].end = world.curjob->curcmd->endlabel; + +#if __DEBUG_FOREACH__ + fprintf(stderr, "INDUCTION_LOAD: curcmd->end = %s and iter[cur].end = %s \n", + world.curjob->curcmd->endlabel, world.curjob->iter[world.curjob->curloop].end); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, induction); +} + + + +/** Top-evel for getting the induction variable from its name */ +static revmexpr_t *revm_induction_get(char *name) +{ + revmexpr_t *induction; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* If the induction variable name has changed, we entered a new foreach construct */ + if (!world.curjob->iter[world.curjob->curloop].curind) + induction = revm_induction_load(name); + + /* If we are reusing the same name for the induction variable */ + else if (!strcmp(name, world.curjob->iter[world.curjob->curloop].curind->label)) + { + if (world.curjob->curloop + 1 == REVM_MAXSRCNEST) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Maximum foreach depth reached, increase REVM_MAXSRCNEST value !", NULL); + if (NULL != world.curjob->iter[world.curjob->curloop].end && + NULL != world.curjob->curcmd->endlabel && + strcmp(world.curjob->iter[world.curjob->curloop].end, world.curjob->curcmd->endlabel)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "An existing induction variable already has this name", NULL); + + /* We are executing a deeper instance of the same foreach structure */ + if (world.curjob->iter[world.curjob->curloop].reclevel != world.curjob->curscope) + { + world.curjob->curloop++; + induction = revm_induction_load(name); + } + else + induction = world.curjob->iter[world.curjob->curloop].curind; + } + + /* If we are executing another foreach command in a current or deeper context */ + else if (world.curjob->iter[world.curjob->curloop].reclevel != world.curjob->curscope || + world.curjob->iter[world.curjob->curloop].end != world.curjob->curcmd->endlabel) + { + world.curjob->curloop++; + induction = revm_induction_load(name); + } + else + { + revm_expr_print(world.curjob->iter[world.curjob->curloop].curind, 0); + +#if __DEBUG_FOREACH__ + fprintf(stderr, "name = %s curind->label = %s reclevel = %u curscope = %u " + "end = %s endlabel = %s \n", + name, world.curjob->iter[world.curjob->curloop].curind->label, + world.curjob->iter[world.curjob->curloop].reclevel, + world.curjob->curscope, world.curjob->iter[world.curjob->curloop].end, + world.curjob->curcmd->endlabel); +#endif + + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Inconsistent foreach induction variable", NULL); + } + +#if __DEBUG_FOREACH__ + fprintf(stderr, "INDUCTION_GET: Induction variable name = %s listidx = %u \n", name, + world.curjob->iter[world.curjob->curloop].listidx); +#endif + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, induction); +} + + + +/** Record the induction variable if we have changed its state since the last iteration */ +static void revm_induction_record(char flag, revmexpr_t *induction, char *curkey, + hash_t *table, list_t *list) +{ + eresi_Addr lastvalue; + revmobj_t *var; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + var = induction->value; + if (flag != 2 || !regexec(&world.curjob->curcmd->regx[0], curkey, 0, 0, 0)) + { + + /* No need to back-update if the data type is complex */ + if (induction->type && aspect_type_simple(induction->type->type) && + !induction->type->next) + { + lastvalue = (var->immed ? var->immed_val.ent : var->get_obj(var->parent)); + if (table) + hash_set(table, curkey, (void *) lastvalue); + else + elist_set(list, curkey, (void *) lastvalue); + +#if __DEBUG_FOREACH__ + fprintf(stderr, "INDUCTION_RECORD: back-assignment in list for elem %s of value %X \n", + curkey, lastvalue); +#endif + + } + } + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** Iterate on an array */ +static int revm_loop_array(revmexpr_t *induction, char *infstr, char *supstr) +{ + int infbound; + int upbound; + revmobj_t *var; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Do we have to open a new iteration scope ? */ + if (world.curjob->iter[world.curjob->curloop].reclevel != world.curjob->curscope || + world.curjob->iter[world.curjob->curloop].end != world.curjob->curcmd->endlabel) + world.curjob->curloop++; + + /* Find lower and upper bounds for this iteration */ + var = induction->value; + if (world.curjob->iter[world.curjob->curloop].listidx == REVM_IDX_UNINIT) + { + infbound = revm_lookup_index(infstr); + world.curjob->iter[world.curjob->curloop].listidx = infbound + 1; + } + else + infbound = world.curjob->iter[world.curjob->curloop].listidx++; + + upbound = revm_lookup_index(supstr); + + /* Bound check */ + if (infbound >= upbound) + { + if (!world.curjob->curcmd->endlabel) + cmd_quit(); + world.curjob->iter[world.curjob->curloop].listidx = REVM_IDX_UNINIT; + revm_move_pc(world.curjob->curcmd->endlabel); + if (world.curjob->curloop) + world.curjob->curloop--; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Set the induction variable */ + if (!induction->type || induction->type->type != ASPECT_TYPE_INT) + revm_convert_object(induction, ASPECT_TYPE_INT); + if (!induction->type || induction->type->type != ASPECT_TYPE_INT) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for induction variable", -1); + + var->immed = 1; + var->immed_val.word = infbound++; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); +} + + +/** Retreive the iteration object */ +static void *revm_iterator_get(char *itername, char ***keys, int *keynbr, char *tableorlist) +{ + char *setname; + revmexpr_t *setexpr; + revmobj_t *setobj; + hash_t *table; + list_t *list; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* First try to lookup the container name */ + table = NULL; + list = NULL; + setname = NULL; + setexpr = revm_lookup_param(itername, 1); + setobj = (setexpr && setexpr->type ? setexpr->value : NULL); + if (setobj) + { + if (setobj->otype->type == ASPECT_TYPE_STR) + setname = (setobj->immed ? setobj->immed_val.str : + setobj->get_name(setobj->root, setobj->parent)); + else if (setobj->otype->type == ASPECT_TYPE_HASH || + setobj->otype->type == ASPECT_TYPE_LIST) + { + setname = (setobj->kname ? setobj->kname : setobj->hname); + if (!setname && setobj->otype->isptr) + { + if (setobj->otype->type == ASPECT_TYPE_HASH) + { + table = (hash_t *) (setobj->immed ? setobj->immed_val.ent : + setobj->get_obj(setobj->parent)); + if (!table) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find table name", NULL); + setname = table->name; + } + else if (setobj->otype->type == ASPECT_TYPE_LIST) + { + list = (list_t *) (setobj->immed ? setobj->immed_val.ent : + setobj->get_obj(setobj->parent)); + if (!list) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find list name", NULL); + setname = list->name; + } + } + } + } + else + setname = itername; + if (!setname) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find iterator name", NULL); + setname = strdup(setname); + if (setexpr) + revm_expr_destroy_by_name(setexpr->label); + +#if __DEBUG_FOREACH__ + fprintf(stderr, "ITERATOR_GET: Found setname = %s in foreach ! \n", setname); +#endif + + /* Try to find a hash or a list out of this variable, if not already found */ + if (!table && !list) + { + table = hash_find(setname); + if (!table) + { + list = elist_find(setname); + if (!list) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, setname); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to find hash table", NULL); + } + } + } + + /* See if the list or hash is already being iterated */ + if (list) + { + if (world.curjob->iter[world.curjob->curloop].listidx == REVM_IDX_UNINIT && + elist_linearity_get(list)) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, setname); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot iterate again on linearly typed list", NULL); + } + elist_linearity_set(list, 1); + *keys = elist_get_keys(list, keynbr); + world.curjob->iter[world.curjob->curloop].list = (void *) list; + *tableorlist = 0; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, list); + } + + /* Else we know that we deal with a hash table */ + if (world.curjob->iter[world.curjob->curloop].listidx == REVM_IDX_UNINIT && + hash_linearity_get(table)) + { + XFREE(__FILE__, __FUNCTION__, __LINE__, setname); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot iterate again on linearly typed table", NULL); + } + hash_linearity_set(table, 1); + *keys = hash_get_keys(table, keynbr); + world.curjob->iter[world.curjob->curloop].list = (void *) table; + *tableorlist = 1; + + // To test + //XFREE(__FILE__, __FUNCTION__, __LINE__, setname); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, table); +} + + +/** Free the current iterator */ +static void revm_iterator_free(hash_t *table, list_t *list, char *indname) +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!world.curjob->curcmd->endlabel) + cmd_quit(); + if (table) + hash_linearity_set(table, 0); + else if (list) + elist_linearity_set(list, 0); + +#if __DEBUG_FOREACH__ + fprintf(stderr, "ITERATOR_FREE: Cleaning induction %s and decrementing curloop ! \n", indname); +#endif + + revm_expr_hide(indname); + + /* Decrease iteration depth */ + bzero(&world.curjob->iter[world.curjob->curloop], sizeof(revmiter_t)); + world.curjob->iter[world.curjob->curloop].listidx = REVM_IDX_UNINIT; + world.curjob->iter[world.curjob->curloop].curind = NULL; + if (world.curjob->curloop) + world.curjob->curloop--; + revm_move_pc(world.curjob->curcmd->endlabel); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + +/** Process the current induction variable */ +static int revm_induction_process(hash_t *table, list_t *list, char *curkey, + revmexpr_t *induction, char *paramname) + +{ + void *elem; + u_int typeid; + char *indname; + char *typename; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (table) + { + elem = hash_get(table, curkey); + typeid = table->type; + } + else + { + elem = elist_get(list, curkey); + typeid = list->type; + } + +#if __DEBUG_FOREACH__ + printf("INDUCTION_PROCESS: Got elem = %p (%s) for key = %s \n", elem, elem, curkey); +#endif + + /* If the element is already an expression, copy it to the induction variable */ + if (typeid == ASPECT_TYPE_EXPR) + { + indname = strdup(induction->label); + revm_expr_clean(induction->label); + induction = revm_expr_copy((revmexpr_t *) elem, indname, 0); + world.curjob->iter[world.curjob->curloop].curind = induction; + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* If the element is not an expression, act depending on its type */ + if (!induction->type || induction->type->type != typeid) + revm_convert_object(induction, typeid); + if (induction->type->type != typeid) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type for induction variable", -1); + + /* Update depending on simple or complex expr type */ + if (aspect_type_simple(induction->type->type) && !induction->type->next) + { + induction->value->immed = 1; + induction->value->immed_val.ent = (eresi_Addr) elem; +#if __DEBUG_FOREACH__ + fprintf(stderr, "Setting indvar->immed_val.ent = %X \n", (eresi_Addr) elem); +#endif + } + else + { + typename = induction->type->name; + revm_expr_hide(paramname); // + induction = revm_inform_type_addr(typename, paramname, (eresi_Addr) elem, NULL, 0, 1); + if (!induction) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to create expression for induction variable", -1); + world.curjob->iter[world.curjob->curloop].curind = induction; + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** Perform iteration on a container or an array of integers */ +int cmd_foreach() +{ + revmexpr_t *induction; + u_char flag; + char **keys; + int keynbr; + hash_t *table; + list_t *list; + void *container; + int index; + char tableorlist; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + tableorlist = 0; + +#if __DEBUG_FOREACH__ + fprintf(stderr, + "Beginning CMD_FOREACH : curcmd->name = %s curcmd->end = %s " + "iter[cur].end = %s curloop = %u curscope = %u\n", + world.curjob->curcmd->name, + world.curjob->curcmd->endlabel, + world.curjob->iter[world.curjob->curloop].end, + world.curjob->curloop, world.curjob->curscope); +#endif + + /* Depends the mode we are in */ + flag = (world.curjob->curcmd->argc == 3 ? 1 : + world.curjob->curcmd->use_regx[0] ? 2 : 3); + + /* Create or get the induction variable */ + induction = revm_induction_get(world.curjob->curcmd->param[0]); + if (!induction) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to initialize induction variable", -1); + + /* Perform subcommand */ + switch (flag) + { + /* Syntax: foreach elmvar of list/hash [as regx] */ + case 1: + case 2: + container = revm_iterator_get(world.curjob->curcmd->param[2], &keys, &keynbr, &tableorlist); + if (!container) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get iterator for container", -1); + switch (tableorlist) + { + case 0: + list = (list_t *) container; + table = NULL; + break; + case 1: + table = (hash_t *) container; + list = NULL; + break; + } + + /* Use the correct keys array index depending on foreach iteration nbr */ + nextelem: + if (world.curjob->iter[world.curjob->curloop].listidx == REVM_IDX_UNINIT) + { + index = 0; + world.curjob->iter[world.curjob->curloop].listidx += 2; + } + + /* The induction variable existed already : record its previous modification in container */ + else + { + index = world.curjob->iter[world.curjob->curloop].listidx++; + revm_induction_record(flag, induction, keys[index - 1], table, list); + } + + /* Bound check : go to the loop end when we finished to iterate on the whole list/hash */ + if (index >= keynbr) + { + revm_iterator_free(table, list, induction->label); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + world.curjob->iter[world.curjob->curloop].curkey = keys[index]; + + /* Get the next elem if the current one is not matching */ + if (flag == 2 && regexec(&world.curjob->curcmd->regx[0], + keys[index], 0, 0, 0)) + goto nextelem; + + /* Process the current element */ + if (revm_induction_process(table, list, keys[index], induction, + world.curjob->curcmd->param[0]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to iterate on induction variable", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + /* Syntax: foreach idxvar of minint until maxint */ + case 3: + if (revm_loop_array(induction, + world.curjob->curcmd->param[2], + world.curjob->curcmd->param[4]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to iterate on array", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + + /* default case: syntax error */ + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid foreach parameters", -1); + } + + /* Support when until goes decreasing */ + /* Here set the induction variable (3 cases : first, iterating, last) */ + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** End an iteration */ +int cmd_forend() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + revm_move_pc(world.curjob->curcmd->endlabel); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/lang/jmp.c eresi-0.0.20110516/libstderesi/lang/jmp.c --- eresi-0.8a25/libstderesi/lang/jmp.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/jmp.c 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,179 @@ +/* +* @file libstderesi/lang/jmp.c +** @ingroup lang +** Made by jfv +** Login +** +** Started on Thu Nov 20 05:09:43 2003 jfv +** Last update Thu Nov 20 05:10:03 2003 jfv +** +** $Id: jmp.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + +/** + * Handler for the jmp instruction + */ +int cmd_jmp() +{ + int ret; + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); +} + +/** + * Handler for the je instruction + */ +int cmd_je() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (!res->immed_val.ent) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Handler for the jne instruction + */ + +int cmd_jne() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (res->immed_val.ent) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Handler for the jg instruction + */ + +int cmd_jg() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (res->immed_val.ent > 0) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Handler for the jl instruction + */ +int cmd_jl() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (res->immed_val.ent < 0) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Handler for the jge instruction + */ +int cmd_jge() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (res->immed_val.ent >= 0) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** + * Handler for the jle instruction + */ +int cmd_jle() +{ + revmexpr_t *last; + revmobj_t *res; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + last = revm_expr_get(REVM_VAR_RESULT); + if (!last || !last->value) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot retreive last result variable", -1); + res = last->value; + if (res->immed_val.ent <= 0) + { + ret = revm_move_pc(world.curjob->curcmd->param[0]); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (ret)); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/lang/Makefile eresi-0.0.20110516/libstderesi/lang/Makefile --- eresi-0.8a25/libstderesi/lang/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/Makefile 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,54 @@ +## +## Makefile for lang in libstderesi for the ERESI project +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ +## +include ../../config.h + +SRC = atomic.c foreach.c jmp.c return.c vlist.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CC ?= gcc +LD ?= ld +RM = rm -f +NAME32 = ../std-lang.32.o +NAME64 = ../std-lang.64.o + +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ + -I../../libmjollnir/include/ -I../../libaspect/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ + $(READLNOPT) $(BITS) + +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libaspect/include/ \ + -I../../libui/include/ -I../../libmjollnir/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ + $(NCURSESLNOPT) $(READLNOPT) $(BITS) + +all : all32 all64 + +$(NAME32) : $(OBJ32) + $(LD) -r $(OBJ32) -o $(NAME32) + +$(NAME64) : $(OBJ64) + $(LD) -r $(OBJ64) -o $(NAME64) +all32: $(NAME32) +all64: $(NAME64) + +clean : + @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/lang/return.c eresi-0.0.20110516/libstderesi/lang/return.c --- eresi-0.8a25/libstderesi/lang/return.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/return.c 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,108 @@ +/** +* @file libstderesi/lang/return.c +** @ingroup lang +** Started on Sat Jan 25 11:19:53 2003 jfv +** $Id: return.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + + +/** + * Unload all the loaded object and exit the shell + */ +int cmd_return() +{ + elfshobj_t *cur; + int index; + char logbuf[BUFSIZ]; + int objnbr; + char **keys; + char **objkeys; + int keynbr; + int z; + revmjob_t *curjob; + revmexpr_t *retval; + revmexpr_t *lastvar; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Fill return value */ + if (world.curjob->curcmd->param[0]) + { + lastvar = revm_expr_get(REVM_VAR_RESULT); + if (lastvar) + revm_expr_destroy_by_name(lastvar->label); + retval = revm_lookup_param(world.curjob->curcmd->param[0], 1); + if (!retval) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid return value", -1); + revm_expr_copy(retval, REVM_VAR_RESULT, 0); + } + + /* Do not unload files if we were sourcing a script */ + if (world.curjob->curscope == 0) + { + keys = hash_get_keys(&world.jobs, &keynbr); + + /* Unload every workspace */ + for (z = 0; z < keynbr; z++) + { + curjob = hash_get(&world.jobs, keys[z]); + if (!revm_own_job(curjob)) + continue; + + snprintf(logbuf, BUFSIZ - 1, + "\n [+] Unloading workspace : %u (%s) %c\n", + z, curjob->ws.name, (curjob->ws.active ? '*' : ' ')); + revm_output(logbuf); + + /* Unload all objects from this job */ + objkeys = hash_get_keys(&curjob->loaded, &objnbr); + for (index = 0; index < objnbr; index++) + { + cur = hash_get(&curjob->loaded, objkeys[index]); + if (!world.state.revm_quiet) + { + snprintf(logbuf, BUFSIZ - 1, + " \t[*] Unloading object %u (%s) %c \n", + index + 1, cur->name, + (curjob->curfile == cur ? '*' : ' ')); + revm_output(logbuf); + } + elfsh_unload_obj(cur); + } + } + + /* The quit message */ + if (quit_msg_setup == 0) + { + snprintf(logbuf, BUFSIZ - 1, "\t .:: Bye -:: The %s %s \n", + revm_modename_get(), REVM_VERSION); + revm_quitmsg_set(logbuf); + } + revm_output(quit_msg); + + /* Now the ugly code depending on the compilation options */ +#if defined(ERESI_NET) + if (world.curjob->ws.io.type == REVM_IO_NET && + revm_socket_del(inet_ntoa(world.curjob->ws.io.sock.addr.sin_addr)) < 0) + fprintf(stderr, "error on quit from client on socket %d\n", + world.curjob->ws.io.sock.socket); + else +#endif + { + revm_output_bcast("\n"); + revm_quit(world.state.revm_mode); + + /* Remove the 2 FIFO on quit : will let the client aware + about our end of execution */ + fprintf(stderr, " [*] Removing 2 FIFO from server side \n"); + unlink(REVM_FIFO_S2C); + unlink(REVM_FIFO_C2S); + revm_exit(0); + } + } + + /* We are returning from an ERESI function */ + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, REVM_SCRIPT_QUIT); +} diff -Nru eresi-0.8a25/libstderesi/lang/vlist.c eresi-0.0.20110516/libstderesi/lang/vlist.c --- eresi-0.8a25/libstderesi/lang/vlist.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/lang/vlist.c 2011-05-16 11:35:02.000000000 +0000 @@ -0,0 +1,64 @@ +/** +* @file libstderesi/lang/vlist.c + * @ingroup lang + * @brief List all variables currently existing. + * + * $Id: vlist.c 1397 2009-09-13 02:19:08Z may $ + */ +#include "libstderesi.h" + +/** + * List content of all ERESI variables and expressions + */ +int cmd_vlist() +{ + char logbuf[BUFSIZ]; + char **keys; + int keynbr; + int index; + regex_t *tmp; + int printed; + int eindex; + hash_t *hash; + u_char header; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + FIRSTREGX(tmp); + + for (printed = 0, eindex = world.curjob->curscope; eindex >= 0; eindex--, header = 0) + { + hash = &world.curjob->recur[eindex].exprs; + keys = hash_get_keys(hash, &keynbr); + for (header = index = 0; index < keynbr; index++) + if (!tmp || !regexec(tmp, keys[index], 0, 0, 0)) + { + /* Only print root expressions */ + if (strstr(keys[index], REVM_SEP)) + continue; + printed++; + if (!header) + { + snprintf(logbuf, BUFSIZ, "\n [*] %s expressions: \n\n", + world.curjob->recur[eindex].funcname); + revm_output(logbuf); + header++; + } + revm_expr_print_by_name(keys[index], 0); + if (index + 1 < keynbr) + revm_output("\n\n"); + else + revm_output("\n"); + } + hash_free_keys(keys); + } + + if (!printed) + revm_output(" [*] No variable found \n\n"); + else + { + snprintf(logbuf, sizeof(logbuf), "\n [*] Printed %d expressions \n\n", printed); + revm_output(logbuf); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/Makefile eresi-0.0.20110516/libstderesi/Makefile --- eresi-0.8a25/libstderesi/Makefile 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/Makefile 2011-05-16 11:35:05.000000000 +0000 @@ -2,7 +2,7 @@ ## Makefile for libstderesi in ERESI ## ## Started on Fri Nov 2 16:32:29 2001 jfv -## $Id +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ ## include ../config.h @@ -17,21 +17,21 @@ LDFLAGS32 += -L../libedfmt/ -ledfmt32 -L../libelfsh/ -lelfsh32 \ -L../libdump/ -L/usr/pkg/lib/ \ -L../libmjollnir/ -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ + -L../libasm/ -lasm32 $(LDUIOPT32) -g3 \ + -L../liballocproxy -L../libmjollnir/ \ -L../libaspect/ -laspect32 -lallocproxy $(LDMJOLLNIR) \ -L../libetrace/ -letrace32 -L../librevm -lrevm32 \ - $(KERNSHLIB32) \ + $(STATOPT) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) LDFLAGS64 += -L../libedfmt/ -ledfmt64 -L../libelfsh/ -lelfsh64 \ -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir64 $(LPTHREAD) -L../libasm/ -lasm $(LDUIOPT64) \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ + -lmjollnir64 $(LPTHREAD) -L../libasm/ -lasm64 \ + -L../liballocproxy -L../libmjollnir/ $(LDUIOPT64) \ -L../libaspect/ -laspect64 -lallocproxy $(LDMJOLLNIR) \ -L../libetrace/ -letrace64 -L../librevm -lrevm64 \ - $(KERNSHLIB64) -g3 \ + -g3 $(STATOPT) \ -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) @@ -42,10 +42,14 @@ mod32 : $(MAKE) -C elf all32 $(MAKE) -C cmd all32 + $(MAKE) -C type all32 + $(MAKE) -C lang all32 + $(MAKE) -C analysis all32 + $(MAKE) -C files all32 -$(NAME32).so : +$(NAME32).so : mod32 $(CC) -shared $(OBJ32) -o $(NAME32).so $(LDFLAGS32) \ - $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) + $(NCURSESLNOPT) $(READLNOPT) ar rc ${NAME32}.a ${OBJ32} @$(RANLIB) ${NAME32}.a $(LD) -r $(OBJ32) -o $(NAME32).o @@ -57,8 +61,12 @@ mod64 : $(MAKE) -C elf all64 $(MAKE) -C cmd all64 + $(MAKE) -C type all64 + $(MAKE) -C lang all64 + $(MAKE) -C analysis all64 + $(MAKE) -C files all64 -$(NAME64).so : +$(NAME64).so : mod64 $(CC) -shared $(OBJ64) -o $(NAME64).so $(LDFLAGS64) \ $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) ar rc ${NAME64}.a ${OBJ64} @@ -69,6 +77,10 @@ clean : $(MAKE) -C elf clean $(MAKE) -C cmd clean + $(MAKE) -C type clean + $(MAKE) -C lang clean + $(MAKE) -C files clean + $(MAKE) -C analysis clean @$(RM) *~ \#* *\# .\#* @$(RM) include/*~ include/\#* include/*\# include/.\#* diff -Nru eresi-0.8a25/libstderesi/.svn/all-wcprops eresi-0.0.20110516/libstderesi/.svn/all-wcprops --- eresi-0.8a25/libstderesi/.svn/all-wcprops 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 35 -/svn/!svn/ver/955/trunk/libstderesi -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/955/trunk/libstderesi/Makefile -END diff -Nru eresi-0.8a25/libstderesi/.svn/entries eresi-0.0.20110516/libstderesi/.svn/entries --- eresi-0.8a25/libstderesi/.svn/entries 2008-04-06 23:16:29.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libstderesi -http://svn.eresi-project.org/svn - - - -2008-04-03T09:52:16.107416Z -955 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -cmd -dir - -include -dir - -doc -dir - -elf -dir - -Makefile -file - - - - -2008-04-06T23:16:28.996887Z -386634c830ea6edd49c5297494d54606 -2008-04-03T09:52:16.107416Z -955 -thorkill - diff -Nru eresi-0.8a25/libstderesi/.svn/format eresi-0.0.20110516/libstderesi/.svn/format --- eresi-0.8a25/libstderesi/.svn/format 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libstderesi/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libstderesi/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libstderesi/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:28.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -## -## Makefile for libstderesi in ERESI -## -## Started on Fri Nov 2 16:32:29 2001 jfv -## $Id -## - -include ../config.h - -OBJ32 = *.32.o -OBJ64 = *.64.o -CC ?= gcc -RM = rm -f -NAME32 = libstderesi32 -NAME64 = libstderesi64 - -LDFLAGS32 += -L../libedfmt/ -ledfmt32 -L../libelfsh/ -lelfsh32 \ - -L../libdump/ -L/usr/pkg/lib/ \ - -L../libmjollnir/ -lmjollnir32 $(LPTHREAD) \ - -L../libasm/ -lasm $(LDUIOPT32) -g3 \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect32 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace32 -L../librevm -lrevm32 \ - $(KERNSHLIB32) \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) - -LDFLAGS64 += -L../libedfmt/ -ledfmt64 -L../libelfsh/ -lelfsh64 \ - -L../libdump/ -L/usr/pkg/lib/ -L../libmjollnir/ \ - -lmjollnir64 $(LPTHREAD) -L../libasm/ -lasm $(LDUIOPT64) \ - $(LDASMOPT) -L../liballocproxy -L../libmjollnir/ \ - -L../libaspect/ -laspect64 -lallocproxy $(LDMJOLLNIR) \ - -L../libetrace/ -letrace64 -L../librevm -lrevm64 \ - $(KERNSHLIB64) -g3 \ - -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) $(DLOPT) - -all : all32 all64 -all32 : mod32 lib32 -all64 : mod64 lib64 - -mod32 : - $(MAKE) -C elf all32 - $(MAKE) -C cmd all32 - -$(NAME32).so : - $(CC) -shared $(OBJ32) -o $(NAME32).so $(LDFLAGS32) \ - $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) - ar rc ${NAME32}.a ${OBJ32} - @$(RANLIB) ${NAME32}.a - $(LD) -r $(OBJ32) -o $(NAME32).o - @echo LINKED LIBSTDERESI32 - -lib32: $(NAME32).so -lib64: $(NAME64).so - -mod64 : - $(MAKE) -C elf all64 - $(MAKE) -C cmd all64 - -$(NAME64).so : - $(CC) -shared $(OBJ64) -o $(NAME64).so $(LDFLAGS64) \ - $(STATOPT) $(NCURSESLNOPT) $(READLNOPT) - ar rc ${NAME64}.a ${OBJ64} - ranlib ${NAME64}.a - $(LD) -r $(OBJ64) -o $(NAME64).o - @echo LINKED LIBSTDERESI64 - -clean : - $(MAKE) -C elf clean - $(MAKE) -C cmd clean - @$(RM) *~ \#* *\# .\#* - @$(RM) include/*~ include/\#* include/*\# include/.\#* - -fclean : clean - @$(RM) *.o *.so *.a $(OBJ_DYN) - -docs: - doxygen doc/doxygen.conf diff -Nru eresi-0.8a25/libstderesi/type/declare.c eresi-0.0.20110516/libstderesi/type/declare.c --- eresi-0.8a25/libstderesi/type/declare.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/declare.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,106 @@ +/* +* @file libstderesi/type/declare.c +** @ingroup type +** @brief Command used to declare a new typed variable in the environment +** +** Started on Fri Jun 22 07:23:58 2007 jfv +** $Id: declare.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + + + +/* Declare a new typed variable */ +int cmd_declare() +{ + aspectype_t *type; + char *varname; + char buf[BUFSIZ]; + u_int curlen; + u_int curidx; + u_int curpidx; + u_int openbrace; + u_int closebrace; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Preliminary checks */ + if (world.curjob->curcmd->argc < 3 || + strcmp(world.curjob->curcmd->param[1], "=")) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for command", -1); + + /* Preliminary checks */ + type = aspect_type_get_by_name(world.curjob->curcmd->name); + if (!type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown type for new variable", -1); + + /* Create the new data structure */ + bzero(buf, BUFSIZ); + + /* Create a unique string for the value of the object */ + for (openbrace = closebrace = curlen = 0, curidx = 2; + world.curjob->curcmd->param[curidx]; + curidx++, curlen += curpidx) + for (curpidx = 0; world.curjob->curcmd->param[curidx][curpidx]; + curpidx++) + switch (world.curjob->curcmd->param[curidx][curpidx]) + { + case '(': + *(buf + curlen + curpidx) = '('; + openbrace++; + break; + case ')': + *(buf + curlen + curpidx) = ')'; + closebrace++; + if (closebrace > openbrace) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid closing structure for variable", -1); + break; + case ' ': + *(buf + curlen + curpidx) = ','; + break; + default: + *(buf + curlen + curpidx) = world.curjob->curcmd->param[curidx][curpidx]; + break; + } + + /* Some first checks on the value */ + if (closebrace != openbrace) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid nesting structure for variable", -1); + +#if __DEBUG_EXPRS__ + fprintf(stderr, "Expression to write in variable: %s \n", buf); +#endif + + curlen = strlen(world.curjob->curcmd->param[0]); + varname = alloca(curlen + 2); + snprintf(varname, curlen + 2, "$%s", world.curjob->curcmd->param[0]); + + /* Perform the real operation now */ + if (type->childs) + { + if (!revm_expr_create(type, varname, buf)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid value for variable", -1); + } + else + { + if (!revm_simple_expr_create(type, varname, buf)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid value for variable", -1); + } + + /* Print success */ + if (!world.state.revm_quiet) + { + snprintf(buf, sizeof(buf), + " [*] Variable %s succesfully initialized \n\n", + world.curjob->curcmd->param[0]); + revm_output(buf); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/hashes.c eresi-0.0.20110516/libstderesi/type/hashes.c --- eresi-0.8a25/libstderesi/type/hashes.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/hashes.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,343 @@ +/* +* @file libstderesi/type/hashes.c +** @ingroup type +** @brief Pretty printing for elfsh hash tables. +** +** Started Jan 20 2007 18:57:03 jfv +** +** +** $Id: hashes.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + +/** + * Display an element of a hash table + * @param h Hash table. + * @param key Hash key of object to be printed. + * @param inside Print the content of the object in case it is a pointer. + * @return Success (0) or Error (-1). + */ +int revm_table_display_element(hash_t *h, char *key, u_char inside) +{ + void *data; + char logbuf[BUFSIZ]; + revmexpr_t *newexpr; + aspectype_t *type; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + data = hash_get(h, key); + + if (h->type == ASPECT_TYPE_UNKNOW || !inside) + { + snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", + key, (eresi_Addr) data); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + if (*key == REVM_VAR_PREFIX) + strncpy(logbuf, key, sizeof(logbuf)); + else + snprintf (logbuf, sizeof(logbuf), "$%s", key); + newexpr = revm_expr_get(logbuf); + + if (newexpr) + { + revm_output("\t"); + revm_expr_print_by_name(logbuf, 0); + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + revm_output("\t"); + if (h->type == ASPECT_TYPE_EXPR) + { + newexpr = (revmexpr_t *) data; + revm_expr_print_by_name(newexpr->label, 0); + } + else + { + type = aspect_type_get_by_id(h->type); + newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); + if (!newexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to reflect hash element to expression", -1); + revm_expr_print_by_name(logbuf, 0); + } + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Display the content of a hash table + * @param name Hash table name to display + */ +int revm_table_display_content(char *name) +{ + hash_t *h; + char **keys; + int keynbr; + int index; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + h = hash_get(hash_hash, name); + if (!h) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid requested hash parameter", -1); + + /* Empty hash */ + keys = hash_get_keys(h, &keynbr); + if (!keynbr) + { + revm_output(" [*] Hash table is empty \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Display pointers */ + for (index = 0; index < keynbr; index++) + revm_table_display_element(h, keys[index], 0); + + snprintf(logbuf, sizeof(logbuf), + "\n [*] Displayed %u entries of table %s \n\n", keynbr, name); + revm_output(logbuf); + + hash_free_keys(keys); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + + +/** + * Display the header of a hash table + * @param table + * @param name + */ +int revm_table_display(hash_t *table, char *name) +{ + char logbuf[BUFSIZ]; + char *type; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!table) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + type = revm_ascii_type(table); + snprintf(logbuf, sizeof(logbuf), + " + %-40s\t ElemType: %-15s ElemNbr: %u \n", + name, type, table->elmnbr); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Display the content of a hash table + */ +static void revm_tables_display() +{ + char **keys; + int keynbr; + int index; + hash_t *cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + revm_output(" .:: Registered tables \n\n"); + keys = hash_get_keys(hash_hash, &keynbr); + for (index = 0; index < keynbr; index++) + { + cur = hash_get(hash_hash, keys[index]); + revm_table_display(cur, keys[index]); + } + hash_free_keys(keys); + revm_output("\n Type 'help tables' for more table details.\n\n"); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/** + * Display the content of all hash tables that match the regex + * @param tableregx Regular expression matching table names + * @param elemregx Regular expression matching element keys + */ +static int revm_table_display_regx2(char *tableregx, char *elemregx) +{ + regex_t rx, ex; + int keynbr, keynbr2; + char **keys, **keys2; + int index, index2; + hash_t *cur; + u_int match; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + + /* Look for matching tables */ + keys = hash_get_keys(hash_hash, &keynbr); + for (match = index = 0; index < keynbr; index++) + if (!regexec(&rx, keys[index], 0, 0, 0)) + { + cur = hash_get(hash_hash, keys[index]); + //fprintf(stderr, "MATCHED TABLE %s of %u elems \n", cur->name, cur->elmnbr); + keys2 = hash_get_keys(cur, &keynbr2); + for (index2 = 0; index2 < keynbr2; index2++) + if (!regexec(&ex, keys2[index2], 0, 0, 0)) + { + match++; + revm_table_display_element(cur, keys2[index2], 1); + } + } + hash_free_keys(keys); + hash_free_keys(keys2); + snprintf(logbuf, sizeof(logbuf), + "\n [*] Matched %u entries in all tables\n\n", match); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + +/** + * Display the content of all hash tables that match the regex + * @param regx + */ +static int revm_table_display_regx(char *regx) +{ + regex_t rx; + int keynbr; + char **keys; + int index; + int match; + char buf[50]; + char *lastmatch; + hash_t *cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (regcomp(&rx, regx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + + /* Look for matching tables */ + keys = hash_get_keys(hash_hash, &keynbr); + for (lastmatch = NULL, match = index = 0; index < keynbr; index++) + if (!regexec(&rx, keys[index], 0, 0, 0)) + { + cur = hash_get(hash_hash, keys[index]); + revm_table_display(cur, keys[index]); + match++; + lastmatch = keys[index]; + } + + /* Print the content of the table if we had a unique match */ + if (match == 1) + revm_table_display_content(lastmatch); + else + { + snprintf(buf, sizeof(buf), "\n [*] Matched %u table%c \n\n", + match, (match > 1 ? 's' : ' ')); + revm_output(buf); + } + + hash_free_keys(keys); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + +} + + +/** + * Print and modify internal hash tables + */ +int cmd_tables() +{ + char *hname; + char *kname; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (world.curjob->curcmd->argc) + { + /* Just print table list */ + case 0: + revm_tables_display(); + break; + + /* Print a determined table with determined (or not) key entry */ + case 1: + hname = revm_lookup_key(world.curjob->curcmd->param[0]); + if (revm_table_display_regx(hname) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to print matching tables", -1); + break; + + /* Print an element from a table */ + case 2: + hname = revm_lookup_key(world.curjob->curcmd->param[0]); + kname = revm_lookup_key(world.curjob->curcmd->param[1]); + if (revm_table_display_regx2(hname, kname) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to print matching tables's elements", -1); + break; + + /* Unknown mode */ + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid tables syntax", -1); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + +/** + * Empty a hash table + */ +int cmd_empty() +{ + char buf[BUFSIZ]; + hash_t *hash; + list_t *list; + int index; + char *name; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + for (index = 0; index < world.curjob->curcmd->argc; index++) + { + name = revm_lookup_key(world.curjob->curcmd->param[index]); + hash = hash_find(name); + if (!hash) + { + list = elist_find(name); + if (!list) + { + snprintf(buf, sizeof(buf), " [W] Unknown list or hash table %s \n\n", name); + revm_output(buf); + continue; + } + snprintf(buf, sizeof(buf), " .:: Empty list %s \n\n", name); + revm_output(buf); + elist_empty(name); + } + else + { + snprintf(buf, sizeof(buf), " .:: Empty hash table %s \n\n", name); + revm_output(buf); + hash_empty(name); + } + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/inform.c eresi-0.0.20110516/libstderesi/type/inform.c --- eresi-0.8a25/libstderesi/type/inform.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/inform.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,84 @@ +/* +* @file libstderesi/type/inform.c +** @ingroup type +** @brief Commands for doing annotations on program objects +** +** Started Jan 21 2007 12:57:03 jfv +** $Id: inform.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + + + +/** + * Inform a given type + */ +int cmd_inform() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + switch (world.curjob->curcmd->argc) + { + /* inform type */ + case 1: + if (revm_informed_print(world.curjob->curcmd->param[0]) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid requested type", -1); + break; + + /* inform type name */ + case 2: + if (revm_inform_toplevel(world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1], + NULL, NULL, 1, 1) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid variable information", -1); + break; + + /* inform type name address */ + case 3: + if (revm_inform_toplevel(world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1], + world.curjob->curcmd->param[2], NULL, 1, 1) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid variable information", -1); + break; + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid inform syntax", -1); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + +/** + * Uninform a given type + */ +int cmd_uninform() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + switch (world.curjob->curcmd->argc) + { + /* uninform type */ + case 1: + if (revm_uninform_type(world.curjob->curcmd->param[0], NULL, 1) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type information", -1); + break; + + /* uninform type name */ + case 2: + if (revm_uninform_type(world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1], 1) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid variable information", -1); + break; + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid uninform syntax", -1); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/lists.c eresi-0.0.20110516/libstderesi/type/lists.c --- eresi-0.8a25/libstderesi/type/lists.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/lists.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,277 @@ +/** +* @file libstderesi/type/lists.c +** @ingroup type +** @brief Pretty printing for ERESI lists +** +** Started Jul 13 2007 18:57:03 jfv +** $Id: lists.c 1397 2009-09-13 02:19:08Z may $ +*/ +#include "libstderesi.h" + + +/** + * Display an element of a keyed linked list + * @param h Linked list + * @param key Key of list object to be printed + */ +int revm_list_display_element(list_t *l, char *key, u_char inside) +{ + void *data; + char logbuf[BUFSIZ]; + revmexpr_t *newexpr; + aspectype_t *type; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + data = elist_get(l, key); + if (l->type == ASPECT_TYPE_UNKNOW || !inside) + { + snprintf(logbuf, sizeof(logbuf), " { %-40s = <"XFMT"> } \n", + key, (eresi_Addr) data); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + if (*key == REVM_VAR_PREFIX) + strncpy(logbuf, key, sizeof(logbuf)); + else + snprintf (logbuf, sizeof(logbuf), "$%s", key); + newexpr = revm_expr_get(logbuf); + if (newexpr) + { + revm_output("\t"); + revm_expr_print_by_name(logbuf, 0); + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + revm_output("\t"); + if (l->type == ASPECT_TYPE_EXPR) + { + newexpr = (revmexpr_t *) data; + revm_expr_print_by_name(newexpr->label, 0); + } + else + { + type = aspect_type_get_by_id(l->type); + newexpr = revm_inform_type_addr(type->name, strdup(logbuf), (eresi_Addr) data, NULL, 0, 1); + if (!newexpr) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to reflect hash element to expression", -1); + revm_expr_print_by_name(logbuf, 0); + } + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Display the content of a list + * @param name List name to display + */ +int revm_list_display_content(char *name) +{ + list_t *h; + listent_t *cur; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + h = hash_get(hash_lists, name); + if (!h) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid requested list parameter", -1); + if (!h->elmnbr) + { + revm_output(" [*] List is empty \n\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + + /* Display list entries */ + for (cur = h->head; cur; cur = cur->next) + revm_list_display_element(h, cur->key, 0); + + snprintf(logbuf, sizeof(logbuf), + "\n [*] Displayed %u entries of list %s \n\n", h->elmnbr, name); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + + + + +/* Display the header of a list */ +int revm_list_display(list_t *list, char *name) +{ + char logbuf[BUFSIZ]; + char *type; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (!list) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid NULL parameter", -1); + type = revm_ascii_ltype(list); + snprintf(logbuf, sizeof(logbuf), + " + %-40s\t ElemType: %-15s ElemNbr: %u \n", + name, type, list->elmnbr); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Display the content of a list + */ +static void revm_lists_display() +{ + char **keys; + int keynbr; + int index; + list_t *cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + revm_output(" .:: Registered lists \n\n"); + keys = hash_get_keys(hash_lists, &keynbr); + for (index = 0; index < keynbr; index++) + { + cur = hash_get(hash_lists, keys[index]); + revm_list_display(cur, keys[index]); + } + hash_free_keys(keys); + revm_output("\n Type 'help lists' for more table details.\n\n"); + PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); +} + + + +/** + * Display the content of all hash tables that match the regex + * @param tableregx Regular expression matching table names + * @param elemregx Regular expression matching element keys + */ +static int revm_list_display_regx2(char *tableregx, char *elemregx) +{ + regex_t rx, ex; + int keynbr; + char **keys; + int index; + list_t *cur; + listent_t *curent; + u_int match; + char logbuf[BUFSIZ]; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (regcomp(&rx, tableregx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + if (regcomp(&ex, elemregx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + + /* Look for matching tables */ + keys = hash_get_keys(hash_lists, &keynbr); + for (match = index = 0; index < keynbr; index++) + if (!regexec(&rx, keys[index], 0, 0, 0)) + { + cur = hash_get(hash_lists, keys[index]); + for (curent = cur->head; curent; curent = curent->next) + if (!regexec(&ex, curent->key, 0, 0, 0)) + { + match++; + revm_list_display_element(cur, curent->key, 1); + } + } + + hash_free_keys(keys); + snprintf(logbuf, sizeof(logbuf), + "\n [*] Matched %u entries in all lists \n\n", match); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Display the content of all hash tables that match the regex + */ +static int revm_list_display_regx(char *regx) +{ + regex_t rx; + int keynbr; + char **keys; + int index; + int match; + char buf[50]; + char *lastmatch; + list_t *cur; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + if (regcomp(&rx, regx, REG_EXTENDED) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute regex", -1); + + /* Look for matching tables */ + keys = hash_get_keys(hash_lists, &keynbr); + for (lastmatch = NULL, match = index = 0; index < keynbr; index++) + { + if (!regexec(&rx, keys[index], 0, 0, 0)) + { + cur = hash_get(hash_lists, keys[index]); + revm_list_display(cur, keys[index]); + match++; + lastmatch = keys[index]; + } + } + + /* Print the content of the table if we had a unique match */ + if (match == 1) + revm_list_display_content(lastmatch); + else + { + snprintf(buf, sizeof(buf), "\n [*] Matched %u list%c \n\n", + match, (match > 1 ? 's' : ' ')); + revm_output(buf); + } + + hash_free_keys(keys); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Print and modify internal lists + */ +int cmd_lists() +{ + char *hname; + char *kname; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (world.curjob->curcmd->argc) + { + /* Just print the list of lists */ + case 0: + revm_lists_display(); + break; + + /* Print a determined table with determined (or not) key entry */ + case 1: + hname = revm_lookup_key(world.curjob->curcmd->param[0]); + if (revm_list_display_regx(hname) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to print matching lists", -1); + break; + + case 2: + hname = revm_lookup_key(world.curjob->curcmd->param[0]); + kname = revm_lookup_key(world.curjob->curcmd->param[1]); + if (revm_list_display_regx2(hname, kname) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to print matching list elements", -1); + break; + + /* Unknown mode */ + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid lists syntax", -1); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/Makefile eresi-0.0.20110516/libstderesi/type/Makefile --- eresi-0.8a25/libstderesi/type/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/Makefile 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,55 @@ +## +## Makefile for types in libstderesi for the ERESI project +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## $Id: Makefile 1444 2011-01-31 07:41:29Z may $ +## +include ../../config.h + +SRC = declare.c hashes.c lists.c inform.c reflect.c types.c \ + vectors.c sets.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CC ?= gcc +LD ?= ld +RM = rm -f +NAME32 = ../std-types.32.o +NAME64 = ../std-types.64.o + +CFLAGS32 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libui/include/ $(BUILDOP) \ + -I../../libmjollnir/include/ -I../../libaspect/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI32 -I../../e2dbg/include/ $(NCURSESLNOPT) \ + $(READLNOPT) + +CFLAGS64 += -fPIC -g3 -Wall -I../include $(DYNOPT) \ + -I../../libelfsh/include/ -I../../elibc/include/ \ + -I../../libdump/include/ -I../../libasm/include/ \ + -I/usr/pkg/include/ -I../../libaspect/include/ \ + -I../../libui/include/ -I../../libmjollnir/include/ \ + -I../../libedfmt/include/ $(STATOPT2) \ + -I../../libetrace/include -I../../librevm/include/ \ + $(ASMOPT) -DERESI64 $(BUILDOP) -I../../e2dbg/include/ \ + $(NCURSESLNOPT) $(READLNOPT) + +all : all32 all64 + +$(NAME32) : $(OBJ32) + $(LD) -r $(OBJ32) -o $(NAME32) + +$(NAME64) : $(OBJ64) + $(LD) -r $(OBJ64) -o $(NAME64) +all32: $(NAME32) +all64: $(NAME64) + +clean : + @$(RM) $(OBJ) $(OBJ32) $(OBJ64) *~ \#* *\# .\#* + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libstderesi/type/reflect.c eresi-0.0.20110516/libstderesi/type/reflect.c --- eresi-0.8a25/libstderesi/type/reflect.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/reflect.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,193 @@ +/** + * @file libstderesi/type/reflect.c + * @ingroup type + * @brief Handle the match construct. + * + * Start on Wed May 23 13:55:45 2007 jfv + * + * $Id: reflect.c 1444 2011-01-31 07:41:29Z may $ + */ + +#include "libstderesi.h" + +/** + * Reflect command disassemble the block cache of the parameter and create a list of instr exprs + */ +int cmd_reflect() +{ + container_t *container; + container_t *instrcontainer; + mjrblock_t *curblock; + asm_instr cur; + elfsh_Half machine; + char logbuf[BUFSIZ]; + char logbuf2[BUFSIZ]; + eresi_Addr addr; + eresi_Addr daddr; + u_int off; + int ret; + aspectype_t *curtype; + void *blocdata; + int fileoff; + list_t *instrlist; + revmexpr_t *expr; + u_int insnbr; + u_int reqnbr; + u_int readsize; + revmexpr_t *immed; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + curtype = aspect_type_get_by_name("instr"); + if (!curtype) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed reflection : unknown type : instr", -1); + + /* Validate parameters */ + if (world.curjob->curcmd->argc != 1 && world.curjob->curcmd->argc != 2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Command expect one or two parameters \n", -1); + + /* Init proc */ + if (!world.curjob->proc) + { + switch (machine = elfsh_get_arch(world.curjob->curfile->hdr)) + { + case EM_386: + world.curjob->proc = &world.proc_ia32; + break; + case EM_SPARC: + case EM_SPARC32PLUS: + case EM_SPARCV9: + world.curjob->proc = &world.proc_sparc; + break; + case EM_ARM: + world.curjob->proc = &world.proc_arm; + break; + case EM_MIPS: + case EM_MIPS_RS3_LE: + world.curjob->proc = &world.proc_mips; + break; + default: + snprintf(logbuf, sizeof (logbuf), + "Architecture %s not supported. No disassembly available\n", + elfsh_get_machine_string(machine)); + revm_output(logbuf); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + } + + /* Now lookup the block by its addr or symbol */ + immed = revm_lookup_param(world.curjob->curcmd->param[0], 1); + if (!immed) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to lookup parameter address expr", -1); + if (revm_convert_object(immed, ASPECT_TYPE_CADDR) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid address parameter", 0); + addr = (immed->value->immed ? immed->value->immed_val.ent : + immed->value->get_obj(immed->value->parent)); + + /* Analyse the binary if not already done */ + /* + if (!world.mjr_session.cur->analysed) + { + maxdepth = (int) config_get_data(CONFIG_CFGDEPTH); + ret = mjr_analyse(&world.mjr_session, + world.curjob->curfile->hdr->e_entry, + maxdepth, 0); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed analyzing current object", -1); + } + */ + + printf("REFLECT ARGC = %u \n", world.curjob->curcmd->argc); + + /* One more param enables lightweight mode: lookup data from a binary file section - no CFG needed */ + if (world.curjob->curcmd->argc == 2) + { + immed = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (revm_convert_object(immed, ASPECT_TYPE_INT) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, "Invalid size parameter", 0); + reqnbr = (immed->value->immed ? (u_int) immed->value->immed_val.ent : + (u_int) immed->value->get_obj(immed->value->parent)); + if (reqnbr <= 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid instruction number to reflect", -1); + readsize = 16 * reqnbr; + blocdata = alloca(readsize); + } + + /* Only one param (an addr/symbol) --> Lookup data from a basic block on the CFG */ + else + { + container = mjr_block_get_by_vaddr(world.mjr_session.cur, addr, MJR_BLOCK_GET_STRICT); + if (!container) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to find bloc at this virtual address", -1); + curblock = (mjrblock_t *) container->data; + readsize = curblock->size; + + printf("REFLECT DEBUG: Curblock size = %u \n", readsize); + + blocdata = alloca(readsize); + reqnbr = 0; + } + + /* Read data -- could be imported from a remote process, so needs to copy buffer */ + fileoff = elfsh_get_foffset_from_vaddr(world.curjob->curfile, addr); + if (elfsh_readmemf(world.curjob->curfile, fileoff, blocdata, readsize) != readsize) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to read data to reflect", -1); + + /* Create the new list of instructions in expression form */ + XALLOC(__FILE__, __FUNCTION__, __LINE__, instrlist, sizeof(list_t), -1); + snprintf(logbuf2, sizeof(logbuf2), AFMT, addr); + elist_init(instrlist, strdup(logbuf2), ASPECT_TYPE_EXPR); + + /* Reflection all instructions of the basic bloc in the list */ + for (insnbr = off = 0; off < readsize; off += ret, insnbr++) + { + + /* If reached the number of requested instruction, stop now even without reaching buffer end */ + if (reqnbr && insnbr == reqnbr) + break; + + /* Fetch the current instruction */ + ret = asm_read_instr(&cur, (u_char *) blocdata + off, + readsize - off + 10, world.curjob->proc); + if (ret < 0) + { + elist_destroy(instrlist); + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to fetch code for basic bloc", -1); + } + + /* Also add the instruction to the current reflected list for this block */ + instrcontainer = container_create(curtype->type, (void *) &cur, NULL, NULL, 0); + snprintf(logbuf, sizeof (logbuf), "$instr-"XFMT, addr + off); + daddr = (eresi_Addr) instrcontainer; + expr = revm_inform_type_addr(curtype->name, strdup(logbuf), daddr, NULL, 0, 1); + elist_add(instrlist, strdup(logbuf), expr); + } + + /* Reverse instrlist and add it to the hash of lists */ + instrlist = elist_reverse(instrlist); + hash_add(&instrlists_hash, strdup(logbuf2), instrlist); + + /* Printing message if we are not in quiet mode */ + if (!world.state.revm_quiet) + { + snprintf(logbuf, sizeof(logbuf), + " [*] Code at address " AFMT " reflected succesfully (%u instrs) \n\n", + addr, insnbr); + revm_output(logbuf); + } + + /* Put the current bloc in the last result variable */ + /* + revm_expr_destroy_by_name(REVM_VAR_RESULT); + revm_expr_copy(expr, REVM_VAR_RESULT); + */ + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/sets.c eresi-0.0.20110516/libstderesi/type/sets.c --- eresi-0.8a25/libstderesi/type/sets.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/sets.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,93 @@ +/* +* @file libstderesi/type/sets.c +** @ingroup cmd +** @brief Primitives for manipulating sets +** +** Started Dec 29 2010 18:57:03 jfv +** $Id$ +*/ +#include "libstderesi.h" + +/** Compute union of sets */ +int cmd_union() +{ + hash_t *src; + hash_t *dst; + revmexpr_t *e1; + revmexpr_t *e2; + revmobj_t *o1; + revmobj_t *o2; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + o1 = e1->value; + o2 = e2->value; + + /* In case we have a hash table as parameter */ + if (o1->otype->type != ASPECT_TYPE_HASH || + o2->otype->type != ASPECT_TYPE_HASH) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameters must be set/hash/tables objects", -1); + + dst = (hash_t *) o1->parent; + src = (hash_t *) o2->parent; + + ret = hash_merge(dst, src); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute union", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + +/** Compute intesection of sets */ +int cmd_inter() +{ + hash_t *src; + hash_t *dst; + revmexpr_t *e1; + revmexpr_t *e2; + revmobj_t *o1; + revmobj_t *o2; + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Sanity checks */ + if (world.curjob->curcmd->param[0] == NULL || + world.curjob->curcmd->param[1] == NULL) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Need 2 parameters", -1); + e1 = revm_lookup_param(world.curjob->curcmd->param[0], 1); + e2 = revm_lookup_param(world.curjob->curcmd->param[1], 1); + if (!e1 || !e2 || !e1->value || !e2->value || !e1->type || !e2->type) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to lookup parameters", -1); + o1 = e1->value; + o2 = e2->value; + + /* In case we have a hash table as parameter */ + if (o1->otype->type != ASPECT_TYPE_HASH || + o2->otype->type != ASPECT_TYPE_HASH) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Parameters must be set/hash/tables objects", -1); + + dst = (hash_t *) o1->parent; + src = (hash_t *) o2->parent; + + ret = hash_inter(dst, src); + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Failed to compute intersection", -1); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/types.c eresi-0.0.20110516/libstderesi/type/types.c --- eresi-0.8a25/libstderesi/type/types.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/types.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,121 @@ +/** +* @file libstderesi/type/types.c +* @ingroup type +* Be able to add your own types in runtime +* +* Started on Sun Jan 9 07:23:58 2007 jfv +* $Id: types.c 1397 2009-09-13 02:19:08Z may $ +** +*/ +#include "libstderesi.h" + + + +/** + * Types management command + */ +int cmd_type() +{ + int nocmd; + u_char isunion; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + isunion = !strcmp(world.curjob->curcmd->name, CMD_UNION); + nocmd = 0; + switch (world.curjob->curcmd->argc) + { + /* type */ + case 0: + revm_type_prints(); + break; + + /* type name */ + case 1: + revm_type_print_regex(world.curjob->curcmd->param[0]); + revm_output("\n"); + break; + + /* Those case are invalid syntaxes */ + case 2: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for type command", -1); + + default: + /* Add a type */ + if (!strcmp(world.curjob->curcmd->param[1], "=") || + !strcmp(world.curjob->curcmd->param[1], "is")) + { + + /* Dont forget to filter on command names too, as each type + will need to have its name bound on cmd_declare() */ + if (hash_get(&cmd_hash, world.curjob->curcmd->param[0])) + nocmd = 1; + if (aspect_type_register(isunion, world.curjob->curcmd->param[0], + world.curjob->curcmd->param + 2, + world.curjob->curcmd->argc - 2) < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid type declaration", -1); + + if (!world.state.revm_quiet) + { + revm_output("\n\t [*] Added type "); + revm_output(world.curjob->curcmd->param[0]); + revm_output(" succesfully \n\n"); + } + + /* Create the hash table for objects of that type */ + revm_type_hashcreate(world.curjob->curcmd->param[0]); + } + else + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for type command", -1); + + } + + /* Register this alias as a command */ + if (!nocmd) + revm_command_add(world.curjob->curcmd->param[0], cmd_declare, + revm_getvarparams, 0, HLP_DECLARE); + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Typedef command function + */ +int cmd_typedef() +{ + int ret; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (world.curjob->curcmd->argc != 2) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid syntax for type command", -1); + + ret = revm_type_copy(world.curjob->curcmd->param[0], + world.curjob->curcmd->param[1]); + + if (ret < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + (ret == -1 ? "Type not found" : + "Failed to create a new type"), -1); + + /* Register this alias as a command */ + revm_command_add(world.curjob->curcmd->param[1], cmd_declare, + revm_getvarparams, 0, HLP_DECLARE); + + /* Output report */ + if (!world.state.revm_quiet) + { + revm_output("\n\t [*] Copied type "); + revm_output(world.curjob->curcmd->param[0]); + revm_output(" to "); + revm_output(world.curjob->curcmd->param[1]); + revm_output(" succesfully \n\n"); + } + + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libstderesi/type/vectors.c eresi-0.0.20110516/libstderesi/type/vectors.c --- eresi-0.8a25/libstderesi/type/vectors.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/libstderesi/type/vectors.c 2011-05-16 11:35:03.000000000 +0000 @@ -0,0 +1,368 @@ +/** +* @file libstderesi/type/vectors.c + * @ingroup type + * Started on Sat Jan 06 06:43:11 2007 jfv + * + * $Id: vectors.c 1397 2009-09-13 02:19:08Z may $ + * + */ +#include "libstderesi.h" + +/** + * Get numbers of vector dimensions requested for the display + * @param str + */ +int revm_vectors_getdimnbr(char *str) +{ + int nbr; + + for (nbr = 0; str && *str; nbr++) + { + str = strchr(str, ':'); + if (!str) + return (nbr); + else + str++; + } + return (nbr); +} + +/** + * Get numbers of vector dimensions requested for the display + * @param str + * @param dims + */ +int revm_vectors_getdims(char *str, unsigned int *dims) +{ + revmobj_t *v; + int nbr; + char *str2; + + /* FIXME : add elfsh vectors index macros to completion */ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + for (nbr = 0; str && *str; nbr++) + { + str = strchr(str, ':'); + if (!str) + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + *str = 0x00; + str2 = strchr(++str, ':'); + if (str2) + *str2 = 0x00; + v = revm_lookup_immed(str, 1); + if (v->otype->type != ASPECT_TYPE_LONG && v->otype->type != ASPECT_TYPE_INT) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid vector indexes", -1); + dims[nbr] = (v->immed ? v->immed_val.ent : v->get_obj(v->parent)); + if (str2) + *str2 = ':'; + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Check vectors dimensions + * @param vect + * @param dims + * @param dimnbr + * @return + */ +int revm_vector_bad_dims(vector_t *vect, unsigned int *dims, + unsigned int dimnbr) +{ + int idx; + + if (vect->arraysz != dimnbr) + return (1); + for (idx = 0; idx < dimnbr; idx++) + if (dims[idx] >= vect->arraydims[idx]) + return (1); + return (0); +} + + + +/** + * Modify a value inside a vector + * @return + */ +static int revm_vector_modify() +{ + vector_t *cur; + int dimnbr; + unsigned int *dims; + eresi_Addr value; + char logbuf[BUFSIZ]; + int len; + int index; + revmobj_t *obj; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + /* Lookup value to write */ + obj = revm_lookup_immed(world.curjob->curcmd->param[1], 1); + if (!obj) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid update value for vector", -1); + value = (obj->immed ? obj->immed_val.ent : + (eresi_Addr) obj->get_obj(obj->parent)); + + /* Lookup vector indexes */ + if (strchr(world.curjob->curcmd->param[0], ':')) + { + dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); + if (dimnbr < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get vector indexes values", -1); + dims = alloca(dimnbr * sizeof(unsigned int)); + revm_vectors_getdims(world.curjob->curcmd->param[0], dims); + cur = aspect_vector_get(world.curjob->curcmd->param[0]); + if (!cur) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown requested vector", -1); + if (revm_vector_bad_dims(cur, dims, dimnbr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Requested vector with bad dimensions", -1); + aspect_vectors_insert(cur, dims, value); + len = snprintf(logbuf, sizeof(logbuf), "\n [*] Modified : Vector[%s]", + world.curjob->curcmd->param[0]); + for (index = 0; index < dimnbr; index++) + len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); + snprintf(logbuf + len, sizeof(logbuf) - len, " = " XFMT "\n", value); + revm_output(logbuf); + revm_output("\n"); + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); + } + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "You need to supply the vector indexes to be modified", -1); +} + + + +/** + * Print a vector entry with its resolve + * @param vaddr + * @param def + */ +static void revm_vector_entry_display(eresi_Addr vaddr, eresi_Addr def) +{ + Dl_info info; + char *bsep; + char *esep; + char *print; + char log[BUFSIZ]; + + if (!dladdr((void *) ((unsigned long *) vaddr), &info)) + dlerror(); + esep = bsep = ""; + if (info.dli_sname && vaddr != def) + { + esep = ">"; + bsep = "<"; + print = (char *) info.dli_sname; + } + else if (vaddr == def) + { + esep = ")"; + bsep = "("; + print = "default handler"; + } + else + print = "Unknown function"; + snprintf(log, sizeof(log), " = " XFMT " %s%s%s\n", vaddr, bsep, print, esep); + revm_output(log); +} + + + +/** + * Display the vector recursively + * @param tab + * @param dims + * @param index + * @param depth + * @patram dimsz + * @param name + * @param def + */ +static void revm_vector_recdisplay(unsigned long *tab, unsigned int *dims, + unsigned int *index, unsigned int depth, + unsigned int dimsz, char *name, u_long def) +{ + unsigned int idx; + unsigned int idx2; + char *log; + int len; + int sz; + + /* Check if we reached the last dimension */ + if (depth == dimsz) + for (idx = 0; idx < dims[depth - 1]; idx++) + { + sz = strlen(name) + 10 * depth; + log = alloca(sz); + len = snprintf(log, sz, " %s", name); + index[depth - 1] = idx; + for (idx2 = 0; idx2 < depth; idx2++) + len += snprintf(log + len, sz - len, "[%02u]", index[idx2]); + revm_output(log); + revm_vector_entry_display((eresi_Addr) tab[idx], (eresi_Addr) def); + } + + /* Otherwise recurse more */ + else + for (idx = 0; idx < dims[depth - 1]; idx++) + { + index[depth - 1] = idx; + revm_vector_recdisplay((unsigned long *) tab[idx], dims, index, + depth + 1, dimsz, name, def); + } + return; +} + + +/** + * Display vector + * @param cur + * @param name + * + */ +static void revm_vector_print(vector_t *cur, char *name) +{ + unsigned int *idx; + char logbuf[BUFSIZ]; + + idx = alloca(cur->arraysz * sizeof(unsigned int)); + bzero(idx, cur->arraysz * sizeof(unsigned int)); + snprintf(logbuf, sizeof(logbuf), " .:: Printing vector %s \n\n", name); + revm_output(logbuf); + revm_vector_recdisplay(cur->hook, cur->arraydims, idx, + 1, cur->arraysz, name, + (unsigned long) cur->default_func); + snprintf(logbuf, sizeof(logbuf), "\n .:: Vector %s printed \n\n", name); + revm_output(logbuf); +} + + + +/** + * Display the content of a vector + */ +static void revm_vectors_display() +{ + char **keys; + int keynbr; + int index; + int index2; + vector_t *cur; + char buf[BUFSIZ]; + int len; + + revm_output(" .:: Registered vectors \n\n"); + keys = hash_get_keys(vector_hash, &keynbr); + for (len = index = 0; index < keynbr; index++) + { + cur = hash_get(vector_hash, keys[index]); + len = snprintf(buf, sizeof(buf), " + %-20s\t ElemType: %-15s Dimensions: ", + keys[index], revm_ascii_vtype(cur)); + for (index2 = 0; index2 < cur->arraysz; index2++) + len += snprintf(buf + len, sizeof(buf) - len, + "[%02u]", cur->arraydims[index2]); + len += snprintf(buf + len, sizeof(buf) - len, " Discriminated by: "); + for (index2 = 0; index2 < cur->arraysz; index2++) + len += snprintf(buf + len, sizeof(buf) - len, "%s ", cur->strdims[index2]); + snprintf(buf + len, sizeof(buf) - len, "\n"); + revm_output(buf); + } + revm_output("\n Type vector vectname for specific vector details.\n\n"); +} + + + +/** + * Display vector content + */ +static int revm_vector_display() +{ + vector_t *cur; + int dimnbr; + unsigned int *dims; + eresi_Addr value; + char logbuf[BUFSIZ]; + int len; + int index; + + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + if (strchr(world.curjob->curcmd->param[0], ':')) + { + dimnbr = revm_vectors_getdimnbr(world.curjob->curcmd->param[0]); + if (dimnbr < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unable to get vector indexes values", -1); + dims = alloca(dimnbr * sizeof(unsigned int)); + revm_vectors_getdims(world.curjob->curcmd->param[0], dims); + cur = aspect_vector_get(world.curjob->curcmd->param[0]); + if (!cur) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Unknown requested vector", -1); + if (revm_vector_bad_dims(cur, dims, dimnbr)) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Requested vector with bad dimensions", -1); + value = (eresi_Addr) aspect_vectors_select(cur, dims); + len = snprintf(logbuf, sizeof(logbuf), "\n [*] Vector[%s]", + world.curjob->curcmd->param[0]); + for (index = 0; index < dimnbr; index++) + len += snprintf(logbuf + len, sizeof(logbuf) - len, "[%u]", dims[index]); + revm_output(logbuf); + revm_vector_entry_display((eresi_Addr) value, (eresi_Addr) cur->default_func); + revm_output("\n"); + } + else + { + cur = aspect_vector_get(world.curjob->curcmd->param[0]); + if (!cur) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Vector does not exist", -1); + revm_vector_print(cur, world.curjob->curcmd->param[0]); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} + + +/** + * Simple internal cat builtin + */ +int cmd_vectors() +{ + PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); + + switch (world.curjob->curcmd->argc) + { + /* Just print vectors list */ + case 0: + revm_vectors_display(); + break; + + /* Print a determined vector with determined (or not) indexes */ + case 1: + if (revm_vector_display() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot print invalid vector element(s)", -1); + break; + + /* Write vector entry */ + case 2: + if (revm_vector_modify() < 0) + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Cannot modify vector element", -1); + break; + + /* Unknown mode */ + default: + PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, + "Invalid vectors syntax", -1); + } + PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); +} diff -Nru eresi-0.8a25/libui/color.c eresi-0.0.20110516/libui/color.c --- eresi-0.8a25/libui/color.c 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/color.c 2011-05-16 11:34:13.000000000 +0000 @@ -1,11 +1,11 @@ /* -** @file color.c +* @file libui/color.c ** ** @brief All functions about colors ** ** Started on Sept 11 2005 mxatone ** -** $Id: color.c,v 1.16 2007-08-03 11:51:00 heroine Exp $ +** $Id: color.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libui.h" diff -Nru eresi-0.8a25/libui/doc/.svn/all-wcprops eresi-0.0.20110516/libui/doc/.svn/all-wcprops --- eresi-0.8a25/libui/doc/.svn/all-wcprops 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/doc/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 33 -/svn/!svn/ver/896/trunk/libui/doc -END -doxygen.conf -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/896/trunk/libui/doc/doxygen.conf -END diff -Nru eresi-0.8a25/libui/doc/.svn/entries eresi-0.0.20110516/libui/doc/.svn/entries --- eresi-0.8a25/libui/doc/.svn/entries 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/doc/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libui/doc -http://svn.eresi-project.org/svn - - - -2008-03-07T17:49:34.750118Z -896 -thorkill - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -doxygen.conf -file - - - - -2008-04-06T23:15:49.120153Z -d3ed4973886def476e271730be91c026 -2008-03-07T17:49:34.750118Z -896 -thorkill - diff -Nru eresi-0.8a25/libui/doc/.svn/format eresi-0.0.20110516/libui/doc/.svn/format --- eresi-0.8a25/libui/doc/.svn/format 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/doc/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libui/doc/.svn/text-base/doxygen.conf.svn-base eresi-0.0.20110516/libui/doc/.svn/text-base/doxygen.conf.svn-base --- eresi-0.8a25/libui/doc/.svn/text-base/doxygen.conf.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/doc/.svn/text-base/doxygen.conf.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,1257 +0,0 @@ -# Doxyfile 1.5.2 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# This tag specifies the encoding used for all characters in the config file that -# follow. The default is UTF-8 which is also the encoding used for all text before -# the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into -# libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of -# possible encodings. - -DOXYFILE_ENCODING = UTF-8 - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = libui - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = ../doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = YES - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, -# Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, -# Italian, Japanese, Japanese-en (Japanese with English messages), Korean, -# Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, -# Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 8 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = NO - -# If you use Microsoft's C++/CLI language, you should set this option to YES to -# enable parsing support. - -CPP_CLI_SUPPORT = NO - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = NO - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = ./ include - -# This tag can be used to specify the character encoding of the source files that -# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default -# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. -# See http://www.gnu.org/software/libiconv for the list of possible encodings. - -INPUT_ENCODING = UTF-8 - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names -# (namespaces, classes, functions, etc.) that should be excluded from the output. -# The symbol name can be a fully qualified name, a word, or if the wildcard * is used, -# a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test - -EXCLUDE_SYMBOLS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) -# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from -# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will -# link to the source code. Otherwise they will link to the documentstion. - -REFERENCES_LINK_SOURCE = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = NO - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = libui - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# You can define message sequence charts within doxygen comments using the \msc -# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to -# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to -# specify the directory where the mscgen tool resides. If left empty the tool is assumed to -# be found in the default search path. - -MSCGEN_PATH = - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a caller dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable caller graphs for selected -# functions only using the \callergraph command. - -CALLER_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of -# nodes that will be shown in the graph. If the number of nodes in a graph -# becomes larger than this value, doxygen will truncate the graph, which is -# visualized by representing a node as a red box. Note that doxygen will always -# show the root nodes and its direct children regardless of this setting. - -DOT_GRAPH_MAX_NODES = 50 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff -Nru eresi-0.8a25/libui/include/libui.h eresi-0.0.20110516/libui/include/libui.h --- eresi-0.8a25/libui/include/libui.h 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/include/libui.h 2011-05-16 11:34:13.000000000 +0000 @@ -1,10 +1,10 @@ /* -** @file libui.h +* @file libui/include/libui.h ** ** Started on Sun Jan 22 19:04:04 2006 mxatone ** Updated on Tue Mar 6 08:42:17 2007 jfv ** -** $Id: libui.h,v 1.16 2007-11-29 15:33:39 may Exp $ +** $Id: libui.h 1397 2009-09-13 02:19:08Z may $ ** */ @@ -29,8 +29,8 @@ */ typedef struct s_comp { -#define ELFSH_COMPMAX 16 - char **cmds[ELFSH_COMPMAX]; /* !< @brief Matchs list for readline */ +#define LIBUI_COMPMAX 16 + char **cmds[LIBUI_COMPMAX]; /* !< @brief Matchs list for readline */ } rlcomp_t; /* Prototypes for readline functions */ diff -Nru eresi-0.8a25/libui/include/.svn/all-wcprops eresi-0.0.20110516/libui/include/.svn/all-wcprops --- eresi-0.8a25/libui/include/.svn/all-wcprops 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/include/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/916/trunk/libui/include -END -libui.h -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/916/trunk/libui/include/libui.h -END diff -Nru eresi-0.8a25/libui/include/.svn/entries eresi-0.0.20110516/libui/include/.svn/entries --- eresi-0.8a25/libui/include/.svn/entries 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/include/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libui/include -http://svn.eresi-project.org/svn - - - -2008-03-18T18:43:08.635419Z -916 -pouik - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -libui.h -file - - - - -2008-04-06T23:15:49.004939Z -867eda1e6e3099330e18fad206b60044 -2008-03-18T18:43:08.635419Z -916 -pouik - diff -Nru eresi-0.8a25/libui/include/.svn/format eresi-0.0.20110516/libui/include/.svn/format --- eresi-0.8a25/libui/include/.svn/format 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libui/include/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libui/include/.svn/text-base/libui.h.svn-base eresi-0.0.20110516/libui/include/.svn/text-base/libui.h.svn-base --- eresi-0.8a25/libui/include/.svn/text-base/libui.h.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libui/include/.svn/text-base/libui.h.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** @file libui.h -** -** Started on Sun Jan 22 19:04:04 2006 mxatone -** Updated on Tue Mar 6 08:42:17 2007 jfv -** -** $Id: libui.h,v 1.16 2007-11-29 15:33:39 may Exp $ -** -*/ - -#ifndef __LIBUI_H__ -#define __LIBUI_H__ - -#include - -/* Thanks to GNU we have readline */ -#if defined(USE_READLN) -#include -#include -#endif - -#include "revm.h" -#include "libaspect.h" - -//extern int (*rl_getc)(FILE*); - -/** - * @brief Completion structure - */ -typedef struct s_comp -{ -#define ELFSH_COMPMAX 16 - char **cmds[ELFSH_COMPMAX]; /* !< @brief Matchs list for readline */ -} rlcomp_t; - -/* Prototypes for readline functions */ -int readln_init(int mode, char *history); -int readln_quit(int mode, char *history); -void readln_ctrl_set(int i, char c); -char *readln_match(const char *text, int state); -void readln_completion_install(char mode, char side); -void readln_completion_commands(hash_t *cmd_hash); -char **readln_completion(const char* text, int start, int end); -int readln_column_update(); -int readln_prompt_update(char *ptr, int size); -int readln_prompt_restore(); -char *readln_input_check(); -void readln_input_log(char *str); -void readln_install_clearscreen(); -void readln_screen_change(u_short isnew, char promptdisplay); -void readln_history_dump(char mode, char *history); -void readln_terminal_prepare(char mode); -void readln_terminal_unprepare(char mode); -void readln_ln_handler(char *c); - -#endif diff -Nru eresi-0.8a25/libui/Makefile eresi-0.0.20110516/libui/Makefile --- eresi-0.8a25/libui/Makefile 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/Makefile 2011-05-16 11:34:13.000000000 +0000 @@ -18,7 +18,7 @@ -I../libelfsh/include/ -I../libdump/include/ \ -I../libasm/include/ -I../e2dbg/include/ -I /usr/pkg/include/ \ -I../elfsh/include/ -I../libmjollnir/include/ \ - -I../libetrace/include/ -I../libedfmt/include/ -DELFSH_INTERN \ + -I../libetrace/include/ -I../libedfmt/include/ \ -I../libaspect/include/ $(STATOPT2) $(ASMOPT) -DERESI32 \ -I../librevm/include/ $(NCURSESLNOPT) $(READLNOPT) @@ -26,21 +26,19 @@ -I../libelfsh/include/ -I../libdump/include/ \ -I../libasm/include/ -I../e2dbg/include/ -I /usr/pkg/include/ \ -I../elfsh/include/ -I../libmjollnir/include/ \ - -I../libetrace/include/ -I../libedfmt/include/ -DELFSH_INTERN \ + -I../libetrace/include/ -I../libedfmt/include/ \ -I../libaspect/include/ $(STATOPT2) $(ASMOPT) -DERESI64 \ -I../librevm/include/ $(NCURSESLNOPT) $(READLNOPT) LDFLAGS32 += -L../libelfsh/ -lelfsh32 -L../libdump/ -L/usr/pkg/lib/ \ - $(LPTHREAD) -L../libasm/ -lasm \ - -L../liballocproxy -lallocproxy -g3 $(LDASMOPT) \ + $(LPTHREAD) -L../liballocproxy -lallocproxy -g3 \ $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + $(LDDUMPOPT32) $(LDNCURSESLNOPT) $(LDREADLNOPT) LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - $(LPTHREAD) -L../libasm/ -lasm \ - -L../liballocproxy -lallocproxy -g3 $(LDASMOPT) \ + $(LPTHREAD) -L../liballocproxy -lallocproxy -g3 \ $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) + $(LDDUMPOPT64) $(LDNCURSESLNOPT) $(LDREADLNOPT) RM = rm -f ETAGS = etags diff -Nru eresi-0.8a25/libui/readln.c eresi-0.0.20110516/libui/readln.c --- eresi-0.8a25/libui/readln.c 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/readln.c 2011-05-16 11:34:13.000000000 +0000 @@ -1,11 +1,11 @@ /* -** @file readln.c +* @file libui/readln.c ** ** Started on Tue Feb 18 06:24:42 2003 emsi ** Updated on Fri Feb 18 23:59:25 2006 thorkill ** Updated on Tue Jun 27 23:51:04 2006 mxatone ** -** $Id: readln.c,v 1.22 2007-11-29 15:33:39 may Exp $ +** $Id: readln.c 1397 2009-09-13 02:19:08Z may $ ** */ #include "libui.h" @@ -88,7 +88,7 @@ i++; /* Return the next name which partially matches any hash tables keys */ - for (; tab < ELFSH_COMPMAX; i = 0, tab++) + for (; tab < LIBUI_COMPMAX; i = 0, tab++) if (comp.cmds[tab] != NULL) for (; comp.cmds[tab][i] != NULL; i++) { @@ -128,7 +128,8 @@ //fprintf(stderr, "Installing completion now \n"); comp.cmds[0] = hash_get_keys(&cmd_hash , NULL); - comp.cmds[1] = hash_get_keys(&exprs_hash , NULL); + //comp.cmds[1] = hash_get_keys(&exprs_hash , NULL); + comp.cmds[1] = NULL; // FIXME: completion on all hierarchy of expressions scope comp.cmds[2] = hash_get_keys(&const_hash , NULL); comp.cmds[3] = hash_get_keys(&mod_hash , NULL); comp.cmds[4] = hash_get_keys(&L1_hash , NULL); @@ -148,7 +149,7 @@ rl_attempted_completion_function = readln_completion; str = ""; - if (mode != REVM_STATE_DEBUGGER && mode != REVM_STATE_CMDLINE + if (mode != REVM_STATE_EMBEDDED && mode != REVM_STATE_CMDLINE && mode != REVM_STATE_SCRIPT && mode != REVM_STATE_TRACER) str = revm_get_prompt(); @@ -156,7 +157,7 @@ /* We setup prompt after installation because we don't want it directly */ - if (mode == REVM_STATE_DEBUGGER && side == REVM_SIDE_CLIENT) + if (mode == REVM_STATE_EMBEDDED && side == REVM_SIDE_CLIENT) { rl_on_new_line_with_prompt(); rl_prompt = revm_get_prompt(); @@ -535,7 +536,7 @@ { char buff[BUFSIZ]; - if (mode == REVM_STATE_INTERACTIVE || mode == REVM_STATE_DEBUGGER) + if (mode == REVM_STATE_INTERACTIVE || mode == REVM_STATE_EMBEDDED) { memset(buff, '\0', sizeof(buff)); snprintf(buff, sizeof(buff), "[*] Writting history (%s) \n", history); @@ -551,7 +552,7 @@ */ void readln_terminal_prepare(char mode) { - if (mode == REVM_STATE_DEBUGGER || mode == REVM_STATE_INTERACTIVE) + if (mode == REVM_STATE_EMBEDDED || mode == REVM_STATE_INTERACTIVE) rl_prep_terminal(1); } @@ -560,7 +561,7 @@ */ void readln_terminal_unprepare(char mode) { - if (mode == REVM_STATE_DEBUGGER || mode == REVM_STATE_INTERACTIVE) + if (mode == REVM_STATE_EMBEDDED || mode == REVM_STATE_INTERACTIVE) rl_deprep_terminal(); } diff -Nru eresi-0.8a25/libui/.svn/all-wcprops eresi-0.0.20110516/libui/.svn/all-wcprops --- eresi-0.8a25/libui/.svn/all-wcprops 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 29 -/svn/!svn/ver/950/trunk/libui -END -color.c -K 25 -svn:wc:ra_dav:version-url -V 37 -/svn/!svn/ver/946/trunk/libui/color.c -END -readln.c -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/916/trunk/libui/readln.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 38 -/svn/!svn/ver/950/trunk/libui/Makefile -END diff -Nru eresi-0.8a25/libui/.svn/entries eresi-0.0.20110516/libui/.svn/entries --- eresi-0.8a25/libui/.svn/entries 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/libui -http://svn.eresi-project.org/svn - - - -2008-03-29T07:54:04.209482Z -950 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -color.c -file - - - - -2008-04-06T23:15:49.201892Z -093c95be4e0e3106cf1fe626bb8e6f05 -2008-03-27T22:53:48.747992Z -946 -may - -include -dir - -doc -dir - -readln.c -file - - - - -2008-04-06T23:15:49.216144Z -2f84d60195f68a6a75b93009e1d18ff1 -2008-03-18T18:43:08.635419Z -916 -pouik - -Makefile -file - - - - -2008-04-06T23:15:49.227512Z -38aa0d70993f541eac20756626bbe114 -2008-03-29T07:54:04.209482Z -950 -enioh - diff -Nru eresi-0.8a25/libui/.svn/format eresi-0.0.20110516/libui/.svn/format --- eresi-0.8a25/libui/.svn/format 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/libui/.svn/text-base/color.c.svn-base eresi-0.0.20110516/libui/.svn/text-base/color.c.svn-base --- eresi-0.8a25/libui/.svn/text-base/color.c.svn-base 2008-04-06 23:15:48.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/text-base/color.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,370 +0,0 @@ -/* -** @file color.c -** -** @brief All functions about colors -** -** Started on Sept 11 2005 mxatone -** -** $Id: color.c,v 1.16 2007-08-03 11:51:00 heroine Exp $ -** -*/ -#include "libui.h" - - -/* Token system */ -static char tokens[COLOR_TOKENS][COLOR_TOKEN_LEN]; -static u_int curtok = 0; - -/** - * @brief Indicate if we print color - * 0 = color, 1 = without color - */ -u_int nocolor = 1; - -/** - * @brief Init color structure - * @return an allocated color structure - */ -color_t *revm_colorblank() -{ - color_t *c; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - XALLOC(__FILE__, __FUNCTION__, __LINE__,c, sizeof(color_t), NULL); - - c->fground = COLOR_NONE; - c->bground = COLOR_NONE; - c->bold = COLOR_NONE; - c->underline = COLOR_NONE; - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, (c)); -} - -/** - * @brief Retrieve a color information structure from a color type - * @param type color type - * @param text text to color to filter for warnstring type - * @return color structure - */ -color_t *revm_colortable(char *type, char *text) -{ - NOPROFILER_IN(); - - /* Override color by warning color if we match the alert regex */ - if (world.state.revm_use_alert && - !regexec(&world.state.revm_alert, text, 0, 0, 0)) - NOPROFILER_ROUT(hash_get(&t_color_hash, "warnstring")); - - NOPROFILER_ROUT(hash_get(&t_color_hash, type)); -} - -/* Speed setup code*/ -#define COLOR_SET_ELEMENT(_c, _v, _z) \ -do { \ -if (_c > 0) { \ -snprintf(_v, 15, "%s%u", (!set ? S_STARTCOLOR : COLOR_SEPARE), _z); \ -set = 1; } \ -} while(0) - -/** - * @brief Generate the color pattern for a given color structure - * @param t color structure - * @param text text to color (not used on this function) - * @param pattern pattern will be save on this buffer - */ -int revm_colorpattern(color_t *t, char *text, char *pattern) -{ - char bo[16], ul[16], fg[16], bg[16]; - u_short set = 0; - - NOPROFILER_IN(); - - if (t == NULL || (!t->bground && !t->fground && !t->bold && !t->underline)) - NOPROFILER_ROUT(-1); - - /* Set every element */ - COLOR_SET_ELEMENT(t->bold, bo, COLOR_BOLD); - COLOR_SET_ELEMENT(t->underline, ul, COLOR_UNDERLINE); - COLOR_SET_ELEMENT(t->fground, fg, t->fground); - COLOR_SET_ELEMENT(t->bground, bg, t->bground); - - snprintf(pattern, COLOR_TOKEN_LEN - 1, - "%%s%s%s%s%sm%%s%s%um%%s", - (t->bold > 0 ? bo : ""), - (t->underline > 0 ? ul : ""), - (t->fground > 0 ? fg : ""), - (t->bground > 0 ? bg : ""), - S_STARTCOLOR, - COLOR_NONE); - - NOPROFILER_ROUT(0); -} - -/** - * @brief Return without color - * @param sp given string (pattern like %s or %d etc ..) - * @param object objet to print using the string - * @return generate string - */ -static char *revm_colornothing(char *sp, void *object) -{ - NOPROFILER_IN(); - - if (!strcmp(sp, "%s")) - NOPROFILER_ROUT((char *) object); - - if (strchr(sp, 's') == NULL) - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, sp, *(long *) object); - else - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, sp, object); - - NOPROFILER_ROUT(tokens[curtok++]); -} - -/** - * @brief Trim a string from blank char and copy it on to argument - * @param from source - * @param to destination - * @param size buffer size - * @param start saved starting blank chars (for replace in another place) - * @param end saved ending blank chars (for replace in another place) - */ -static int trim(char *from, char *to, u_int size, char *start, char *end) -{ - u_int len, istart, iend; - - NOPROFILER_IN(); - - if (size == 0 || size > COLOR_TOKEN_LEN || from == NULL || to == NULL) - NOPROFILER_ROUT(-1); - - len = strlen(from); - - /* Speed check */ - if (!IS_BLANK(from[0]) && !IS_BLANK(from[len])) - NOPROFILER_ROUT(-1); - - /* Before */ - for (istart = 0; istart < len && IS_BLANK(from[istart]); istart++); - - /* All blank, no modifications */ - if (istart == len) - NOPROFILER_ROUT(-1); - - /* After */ - for (iend = len; iend > 0 && IS_BLANK(from[iend]); iend--); - - iend = len - iend; - - /* Copy the right char on to argument */ - strncpy(to, from + istart, len - istart - iend); - to[len - istart - iend] = 0x00; - - if (start) - { - strncpy(start, from, istart); - start[istart] = 0x00; - } - - if (end) - { - strncpy(end, from + len - iend, iend); - end[iend] = 0x00; - } - - NOPROFILER_ROUT(0); -} - -/** - * @brief Build color text - * @param sp - * @param type - * @param object - */ -char *revm_colorget(char *sp, char *type, void *object) -{ - color_t *t; - char pattern[COLOR_TOKEN_LEN]; - char text[COLOR_TOKEN_LEN]; - char trim_text[COLOR_TOKEN_LEN]; - char white_s[COLOR_TOKEN_LEN]; - char white_e[COLOR_TOKEN_LEN]; - char *pText; - - NOPROFILER_IN(); - - if (curtok >= COLOR_TOKENS) - { - printf("[E] %s:%d %s: WARNING !!!! Token overflow (val:%u)\n", - __FILE__, __LINE__, __FUNCTION__, curtok); - NOPROFILER_ROUT(NULL); - } - - //snprintf(text, COLOR_TOKEN_LEN - 1, sp, object); - if (strchr(sp, 's') == NULL) - snprintf(text, COLOR_TOKEN_LEN - 1, sp, *(long *) object); - else - snprintf(text, COLOR_TOKEN_LEN - 1, sp, object); - - /* Color isn't activated */ - if (!nocolor) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - t = revm_colortable(type, text); - - /* Color not found */ - if (t == NULL) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - /* Invalid pattern */ - if (revm_colorpattern(t, text, pattern) != 0) - NOPROFILER_ROUT(revm_colornothing(sp, object)); - - pText = text; - - memset(white_s, 0x00, COLOR_TOKEN_LEN); - memset(white_e, 0x00, COLOR_TOKEN_LEN); - - /* Trim the string from blank char */ - if (!trim(text, trim_text, COLOR_TOKEN_LEN, white_s, white_e)) - pText = trim_text; - - snprintf(tokens[curtok], COLOR_TOKEN_LEN - 1, - pattern, white_s, pText, white_e); - - NOPROFILER_ROUT(tokens[curtok++]); -} - -/** - * @brief Reset token - */ -void revm_endline() -{ - curtok = 0; -} - -/* Simple functions */ -char *revm_colorinstr(char *text) { return revm_colorget("%s", "instr" , text); } -char *revm_colorstr(char *text) { return revm_colorget("%s", "string" , text); } -char *revm_colorfieldstr(char *text) { return revm_colorget("%s", "fieldstring", text); } -char *revm_colortypestr(char *text) { return revm_colorget("%s", "typestring" , text); } -char *revm_colorend(char *text) { return revm_colorget("%s", "endstring" , text); } -char *revm_colorwarn(char *text) { return revm_colorget("%s", "warnstring" , text); } -char *revm_colorfunction(char *text) { return revm_colorget("%s", "function" , text); } -char *revm_colorfilename(char *text) { return revm_colorget("%s", "filename" , text); } - -/** - * @brief Special functions - */ -char *revm_coloradv(char *type, char *pattern, char *text) -{ - char *p; - - NOPROFILER_IN(); - - p = revm_colorget(pattern, type, text); - - strncpy(text, p, BUFSIZ); - text[BUFSIZ-1] = 0; - curtok--; - - NOPROFILER_ROUT(text); -} - -/** - * Advanced functions - */ -char *revm_colorinstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "instr", text); -} - -char *revm_colorstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "string", text); -} -char *revm_colorfieldstr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "fieldstring", text); -} - -char *revm_colortypestr_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "typestring", text); -} - -char *revm_colorend_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "endstring", text); -} - -char *revm_colorwarn_fmt(char *pattern, char *text) -{ - return revm_colorget(pattern, "warnstring", text); -} - -char *revm_coloraddress(char *pattern, eresi_Addr addr) -{ - return revm_colorget(pattern, "address", &addr); -} - -char *revm_colornumber(char *pattern, u_int numb) -{ - return revm_colorget(pattern, "number", &numb); -} - -/* Misc functions */ - -/** - * @brief Return number of color chars (not total size) - */ -int revm_color_count(char *string) -{ - int count = 0; - int len; - int i; - - NOPROFILER_IN(); - - len = strlen(string); - for (i = 0; i < len; i++) - { - if (string[i] == C_STARTCOLOR) - { - count++; - while (i < len && string[i] != 'm') - i++; - } - } - - NOPROFILER_ROUT(count); -} - -/** - * @brief Return total size of colors on a string - */ -int revm_color_size(char *string) -{ - int size = 0; - int len; - int i; - - NOPROFILER_IN(); - - len = strlen(string); - for (i = 0; i < len; i++) - { - if (string[i] == C_STARTCOLOR) - { - //size++; - while (i < len && string[i] != 'm') - { - size++; - i++; - } - } - } - - NOPROFILER_ROUT(size); -} diff -Nru eresi-0.8a25/libui/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/libui/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/libui/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,84 +0,0 @@ -## -## Makefile for libui -## -## Started on Sun Jan 22 18:12:29 2006 mxatone -## - -include ../config.h - -SRC = readln.c -OBJ = ${SRC:.c=.o} -OBJ32 = ${SRC:.c=.32.o} -OBJ64 = ${SRC:.c=.64.o} -NAME = libui -NAME32 = libui32 -NAME64 = libui64 - -CFLAGS32 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../libdump/include/ \ - -I../libasm/include/ -I../e2dbg/include/ -I /usr/pkg/include/ \ - -I../elfsh/include/ -I../libmjollnir/include/ \ - -I../libetrace/include/ -I../libedfmt/include/ -DELFSH_INTERN \ - -I../libaspect/include/ $(STATOPT2) $(ASMOPT) -DERESI32 \ - -I../librevm/include/ $(NCURSESLNOPT) $(READLNOPT) - -CFLAGS64 += -fPIC -g3 $(GSTABS) -Wall -Iinclude $(DYNOPT) $(BUILDOP) \ - -I../libelfsh/include/ -I../libdump/include/ \ - -I../libasm/include/ -I../e2dbg/include/ -I /usr/pkg/include/ \ - -I../elfsh/include/ -I../libmjollnir/include/ \ - -I../libetrace/include/ -I../libedfmt/include/ -DELFSH_INTERN \ - -I../libaspect/include/ $(STATOPT2) $(ASMOPT) -DERESI64 \ - -I../librevm/include/ $(NCURSESLNOPT) $(READLNOPT) - -LDFLAGS32 += -L../libelfsh/ -lelfsh32 -L../libdump/ -L/usr/pkg/lib/ \ - $(LPTHREAD) -L../libasm/ -lasm \ - -L../liballocproxy -lallocproxy -g3 $(LDASMOPT) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -LDFLAGS64 += -L../libelfsh/ -lelfsh64 -L../libdump/ -L/usr/pkg/lib/ \ - $(LPTHREAD) -L../libasm/ -lasm \ - -L../liballocproxy -lallocproxy -g3 $(LDASMOPT) \ - $(DLOPT) -L/usr/freeware/lib32/ $(DYNOPT) $(BITS) $(EXTRAOPT) \ - $(LDDUMPOPT) $(LDNCURSESLNOPT) $(LDREADLNOPT) - -RM = rm -f -ETAGS = etags -AR = ar rc -LD = gcc - -all : all32 all64 - -$(NAME32).so : $(OBJ32) - @$(LD) $(LDFLAGS32) $(BITS) -shared $(OBJ32) -o $(NAME32).so - @$(AR) $(NAME32).a $(OBJ32) - @$(RANLIB) $(NAME32).a - -all32: $(NAME32).so - - -$(NAME64).so : $(OBJ64) - @$(LD) $(LDFLAGS64) $(BITS) -shared $(OBJ64) -o $(NAME64).so - @$(AR) $(NAME64).a $(OBJ64) - @$(RANLIB) $(NAME64).a - -all64: $(NAME64).so - -clean : - @$(RM) \#* *\# *~ .\#* include/\#* include/*\# \ - $(OBJ) $(OBJ32) $(OBJ64) include/*~ include/.\#* - -docs: - @doxygen doc/doxygen.conf - -tags : - @$(ETAGS) -a *.c include/*.h *.c - @echo TAGS generated succesfully - -fclean : clean - @$(RM) *.so *.a *.o - -%.32.o : %.c - $(CC) $(CFLAGS32) -c -o $@ $< -%.64.o : %.c - $(CC) $(CFLAGS64) -c -o $@ $< diff -Nru eresi-0.8a25/libui/.svn/text-base/readln.c.svn-base eresi-0.0.20110516/libui/.svn/text-base/readln.c.svn-base --- eresi-0.8a25/libui/.svn/text-base/readln.c.svn-base 2008-04-06 23:15:49.000000000 +0000 +++ eresi-0.0.20110516/libui/.svn/text-base/readln.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,568 +0,0 @@ -/* -** @file readln.c -** -** Started on Tue Feb 18 06:24:42 2003 emsi -** Updated on Fri Feb 18 23:59:25 2006 thorkill -** Updated on Tue Jun 27 23:51:04 2006 mxatone -** -** $Id: readln.c,v 1.22 2007-11-29 15:33:39 may Exp $ -** -*/ -#include "libui.h" - -#if defined(USE_READLN) - -rlcomp_t comp; /* Completion strings */ -rl_command_func_t *rl_ctrll = NULL; -char readln_exited = 0; - -int readln_init(int mode, char *history) -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (mode >= 0) - read_history(history); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -/** - * @brief Clean readline - */ -int readln_quit(int mode, char *history) -{ - int exited = readln_exited; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - if (readln_exited == 0) - { - if (mode >= 0) - readln_history_dump(mode, history); - - rl_callback_handler_remove(); - readln_exited = 1; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, exited); -} - - -/** - * @brief Set rl_ctrl - */ -void readln_ctrl_set(int i, char c) -{ - if (rl_ctrll) - rl_ctrll(i, c); -} - -/** - * @brief Completion fonction for the command list - */ -char *readln_match(const char *text, int state) -{ - static int i, len, tab; - char *name, *name2; - const char *baq; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - baq = text; - for (name = strchr(baq, '.'); name; name = strchr(baq, '.')) - { - baq = name; - baq++; - } - text = baq; - - //printf("\n trying to match %s\n", text); - - if (!state) - { - tab = 0; - i = 0; - len = strlen(text); - } - else - i++; - - /* Return the next name which partially matches any hash tables keys */ - for (; tab < ELFSH_COMPMAX; i = 0, tab++) - if (comp.cmds[tab] != NULL) - for (; comp.cmds[tab][i] != NULL; i++) - { - name = comp.cmds[tab][i]; - if (!strncmp(name, text, len)) - { - XALLOC(__FILE__, __FUNCTION__, __LINE__, - name2, strlen(name) + 1, NULL); - strcpy(name2, name); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, name2); - } - } - - /* If no names matched, then return NULL. */ - i = tab = len = 0; - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, ((char *) NULL)); -} - - - -/** - * @brief Add commands to completion - */ -void readln_completion_commands(hash_t *cmd_hash) -{ - comp.cmds[0] = hash_get_keys(cmd_hash, NULL); -} - - -/** - * @brief Install the completion strings - */ -void readln_completion_install(char mode, char side) -{ - char *str; - - //fprintf(stderr, "Installing completion now \n"); - - comp.cmds[0] = hash_get_keys(&cmd_hash , NULL); - comp.cmds[1] = hash_get_keys(&exprs_hash , NULL); - comp.cmds[2] = hash_get_keys(&const_hash , NULL); - comp.cmds[3] = hash_get_keys(&mod_hash , NULL); - comp.cmds[4] = hash_get_keys(&L1_hash , NULL); - comp.cmds[5] = hash_get_keys(&elf_L2_hash , NULL); - comp.cmds[6] = hash_get_keys(&sht_L2_hash , NULL); - comp.cmds[7] = hash_get_keys(&pht_L2_hash , NULL); - comp.cmds[8] = hash_get_keys(&sym_L2_hash , NULL); - comp.cmds[9] = hash_get_keys(&rel_L2_hash , NULL); - comp.cmds[10] = hash_get_keys(&dynsym_L2_hash, NULL); - comp.cmds[11] = hash_get_keys(&dyn_L2_hash , NULL); - comp.cmds[12] = hash_get_keys(&sct_L2_hash , NULL); - comp.cmds[13] = hash_get_keys(&fg_color_hash, NULL); - comp.cmds[14] = hash_get_keys(&t_color_hash, NULL); - comp.cmds[15] = NULL; - - using_history(); - rl_attempted_completion_function = readln_completion; - - str = ""; - if (mode != REVM_STATE_DEBUGGER && mode != REVM_STATE_CMDLINE - && mode != REVM_STATE_SCRIPT && mode != REVM_STATE_TRACER) - str = revm_get_prompt(); - - rl_callback_handler_install(str, readln_ln_handler); - - /* We setup prompt after installation because we - don't want it directly */ - if (mode == REVM_STATE_DEBUGGER && side == REVM_SIDE_CLIENT) - { - rl_on_new_line_with_prompt(); - rl_prompt = revm_get_prompt(); - } - - rl_bind_key(CTRL('x'), revm_screen_switch); - readln_install_clearscreen(); - readln_column_update(); - signal(SIGWINCH, (void *) readln_column_update); - rl_catch_sigwinch = 0; - rl_set_signals(); -} - - - -/** - * @brief Perform completion - */ -char **readln_completion(const char* text, int start, int end) -{ - char **matches = (char**) NULL; - char *baq, *baq2; - char buf[50]; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* - fprintf(stderr, "Calling completion on %s \n", text); - prevent freeing of unitialized memory on FreeBSD - XXX: check this !! - */ - - if (strlen(text) == 0) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - -#if defined(__OpenBSD__) - matches = completion_matches(text, readln_match); -#else - matches = rl_completion_matches(text, readln_match); -#endif - - if (!matches) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, NULL); - - baq2 = NULL; - baq = strchr(text, '.'); - while (baq) - { - baq2 = baq + 1; - baq = strchr(baq2, '.'); - } - - if (baq2 && *baq2) - { - memcpy(buf, text, baq2 - text); - strcpy(buf + (baq2 - text), matches[0]); - //seems not to be free - //XFREE(__FILE__, __FUNCTION__, __LINE__,matches[0]); - matches[0] = strdup(buf); - - } - - switch (rl_completion_append_character) - { - case ' ': - if (baq2 && *baq2) - rl_completion_append_character = '['; - break; - case '[': - rl_completion_append_character = ']'; - break; - case ']': - rl_completion_append_character = ' '; - default: - break; - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, matches); -} - - -/** - * This function was used to update columns on a readline colored prompt - * another solution has been found that work well (see readln_prompt_update). - * We keep this function because it can be useful later. - */ -int readln_column_update() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Ask readline to retrieve console size */ - rl_resize_terminal(); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * @brief A prompt need some update to fit correctly on readline (with color) - */ -int readln_prompt_update(char *ptr, int size) -{ - int i, tmpi; - char tmp[size]; -#if defined(RL_PROMPT_START_IGNORE) - int open = 0; -#endif - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* If no color on the prompt */ - if (strchr(ptr, C_STARTCOLOR) == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); - - tmp[0] = '\0'; - - /* Parse every char */ - for (i = 0, tmpi = 0; i < size && tmpi < size && ptr[i]; i++) - { - /* A color will always start with C_STARTCOLOR */ - if (ptr[i] == C_STARTCOLOR) - { -#if defined(RL_PROMPT_START_IGNORE) - /* This work only with readline >= 4.x, damn you if you don't have it !! - We will use RL_PROMPT_START_IGNORE & RL_PROMPT_END_IGNORE that indicate - to readline that chars (here color) must be ignored in count procedure */ - tmp[tmpi++] = RL_PROMPT_START_IGNORE; - open++; - - while(ptr[i] != 'm' && i < size && tmpi < size) - tmp[tmpi++] = ptr[i++]; - - if (i < size && ptr[i]) - { - tmp[tmpi++] = ptr[i++]; - tmp[tmpi++] = RL_PROMPT_END_IGNORE; - open--; - } -#else - /* If you don't have the right version, I strip ! */ - while(ptr[i] != 'm' && i < size) - i++; - - if (i < size) - i++; -#endif - - if (i >= size || ptr[i] == '\0') - break; - - /* Support followed tags */ - if (ptr[i] == C_STARTCOLOR) - { - i--; - continue; - } - } - - tmp[tmpi++] = ptr[i]; - } - -#if defined(RL_PROMPT_START_IGNORE) - /* We didn't close an ignore sign */ - if (open > 0) - tmp[(tmpi < size ? tmpi : size - 1)] = RL_PROMPT_END_IGNORE; -#endif - - /* Add the last char */ - tmp[(tmpi < size ? tmpi : size)] = '\0'; - - /* Update the submited variable */ - memcpy(ptr, tmp, size); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - - -/** - * @brief readline line handler - */ -void readln_ln_handler(char *c) -{ - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - world.curjob->ws.io.buf = c; - - /* save (remove) prompt if a complete line was typed - * so that the line is not displayed on return */ - if (c != NULL) - { - if (!c[0]) - revm_log("\n"); - } - - /* special to enable exit on CTRL-D */ - else - world.curjob->ws.io.buf = (char *) REVM_INPUT_EXIT; - - rl_save_prompt(); - PROFILER_OUT(__FILE__, __FUNCTION__, __LINE__); -} - - - -/** - * Restore readline prompt that will be display on next - * rl_forced_update_display() or rl_callback_read_char() - */ -int readln_prompt_restore() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - world.curjob->ws.io.buf = NULL; - rl_callback_read_char(); - - if (world.curjob->ws.io.buf != NULL) - { - rl_restore_prompt(); - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 1); - } - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - - - -/** - * Perform some checks on the input given by readline - */ -char *readln_input_check() -{ - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* input in progress */ - if (world.curjob->ws.io.buf == NULL) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) REVM_INPUT_VOID)); - - /* CTRL-D case */ - if (world.curjob->ws.io.buf == (char *) REVM_INPUT_EXIT) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (NULL)); - - /* empty string */ - if (strlen(world.curjob->ws.io.buf) == 0) - { - /* XXX memory leak, this dup will never be freed */ - if (world.curjob->ws.oldline) - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (strdup(world.curjob->ws.oldline))); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - ((char *) REVM_INPUT_VOID)); - } - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, - (strdup(world.curjob->ws.io.buf))); -} - - -/** - * Log the input of readline - */ -void readln_input_log(char *str) -{ -#if 0 - HISTORY_STATE *state; - HIST_ENTRY *entry; - int i; -#endif - - //if (world.curjob->io.buf[0] != '\0') - if (*str) - { - revm_log(str); - revm_log("\n\n"); - } - else - revm_log("\n"); - -#if 0 - printf ("[READLN] history : [%s]\n", buf); - state = history_get_history_state(); - printf("== HISTORY STATE ==\n"); - printf(" offset : %d\n", state->offset); - printf(" length : %d\n", state->length); - printf(" size : %d\n", state->size); - printf("===================\n"); -#endif - - add_history(str); - using_history(); - -#if 0 - state = history_get_history_state(); - printf("== HISTORY STATE ==\n"); - printf(" offset : %d\n", state->offset); - printf(" length : %d\n", state->length); - printf(" size : %d\n", state->size); - printf("===================\n"); - printf("-- entries --\n"); - for (i = 0; i <= state->length + 1; i++) - { - entry = history_get(i); - if (entry) - printf("-- entry %d [%s] (%x) \n", i, entry->line, entry->line); - else - printf("-- entry %d NULL \n", i); - } - printf("-------------\n\n"); -#endif - -} - - - - -/** - * @brief Install the shortcut for clearing the screen - */ -void readln_install_clearscreen() -{ - Keymap map; - char keyseq[2]; - - map = rl_get_keymap(); - keyseq[0] = CTRL('l'); - keyseq[1] = '\0'; - rl_ctrll = rl_function_of_keyseq(keyseq, map, NULL); - rl_bind_key(CTRL('l'), (rl_command_func_t *) revm_screen_clear); -} - - -/** - * @brief Change the screen content - */ -void readln_screen_change(u_short isnew, char prompt_display) -{ - /* Setup on new screen */ - if (isnew) - { - revm_log(revm_get_prompt()); - rl_on_new_line(); - world.curjob->ws.io.savebuf = NULL; - } - - /* Prompt already here */ - else - { - if (!prompt_display) - rl_on_new_line_with_prompt(); - rl_refresh_line(0, 0); - } - - rl_clear_message(); - - /* Restore the buffer */ - if (!isnew) - { - if (world.curjob->ws.io.savebuf) - strcpy(rl_line_buffer, world.curjob->ws.io.savebuf); - rl_point = world.curjob->ws.io.rl_point; - rl_end = world.curjob->ws.io.rl_end; - } - - rl_redisplay(); -} - - -/** - * @brief Write readline history on quit - */ -void readln_history_dump(char mode, char *history) -{ - char buff[BUFSIZ]; - - if (mode == REVM_STATE_INTERACTIVE || mode == REVM_STATE_DEBUGGER) - { - memset(buff, '\0', sizeof(buff)); - snprintf(buff, sizeof(buff), "[*] Writting history (%s) \n", history); - revm_output(buff); - write_history(history); - } - - rl_callback_handler_remove(); -} - -/** - * @brief Prepare readline terminal - */ -void readln_terminal_prepare(char mode) -{ - if (mode == REVM_STATE_DEBUGGER || mode == REVM_STATE_INTERACTIVE) - rl_prep_terminal(1); -} - -/** - * @brief Prepare readline terminal - */ -void readln_terminal_unprepare(char mode) -{ - if (mode == REVM_STATE_DEBUGGER || mode == REVM_STATE_INTERACTIVE) - rl_deprep_terminal(); -} - -#endif - diff -Nru eresi-0.8a25/MANIFEST eresi-0.0.20110516/MANIFEST --- eresi-0.8a25/MANIFEST 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/MANIFEST 2011-05-16 11:46:21.000000000 +0000 @@ -0,0 +1,1709 @@ +INSTALL +README.FIRST +build/defs/dep-rules.def +configure +doc/AUTHOR +doc/CREDITS +doc/Changelog +doc/ERESI-coding_style-README.txt +doc/ERESI.NEWHOOKS +doc/HOWTO-port-ERESI-0.8.txt +doc/HOWTO-port-elfsh-0.7a2.txt +doc/KERNSH.bugs +doc/LICENSE +doc/TODO +doc/VERSION +doc/cerberus2.txt +doc/doxygen.conf +doc/elfsh-draft.txt +doc/elfsh-network-0.3.txt +doc/elfsh-ref.txt +doc/eresi.1 +doc/eresirc.example +doc/footer.html +doc/graphers.txt +doc/header.html +doc/libasm_TODO.txt +doc/libelfsh-ref.txt +doc/libelfsh.i +doc/rtld-multiarch.txt +doxygen.conf +e2dbg/Makefile +e2dbg/include/e2dbg.h +e2dbg/main.c +elfsh/Makefile +elfsh/cleanup.c +elfsh/include/elfsh-help.h +elfsh/include/elfsh.h +elfsh/main.c +elfsh/misc.c +elfsh/rlheap.c +elfsh/run.c +elfsh/tables.c +env.sh +eresi-config32 +eresi-config64 +etrace/Makefile +etrace/cleanup.c +etrace/include/etrace-help.h +etrace/include/etrace.h +etrace/main.c +etrace/misc.c +etrace/rlheap.c +etrace/run.c +etrace/tables.c +evarista/Makefile +evarista/bin2lir.esh +evarista/callgraph-walk.esh +evarista/cfg-walk.esh +evarista/eva-run32.esh +evarista/eva-run64.esh +evarista/eva-typedecl.esh +evarista/include/evarista-help.h +evarista/include/evarista.h +evarista/intel2lir.esh +evarista/lir-dataflow.esh +evarista/lir-definition.esh +evarista/lir2ssi.esh +evarista/main.c +evarista/mips2lir.esh +evarista/sparc2lir.esh +evarista/ssi-definition.esh +evarista/tables.c +kedbg/Makefile +kedbg/cmd.c +kedbg/handlers.c +kedbg/include/interface.h +kedbg/include/kedbg.h +kedbg/main.c +kedbg/misc.c +kedbg/register.c +kedbg/test.c +kernsh/Makefile +kernsh/README +kernsh/README.configure +kernsh/README.vectors +kernsh/alloc.c +kernsh/autotypes.c +kernsh/close.c +kernsh/doc/kernshrc-2.4.example +kernsh/doc/kernshrc-2.6.example +kernsh/doc/types/kernel_2_6_types +kernsh/dump.c +kernsh/examples/kmodules/example1.ksh +kernsh/examples/kmodules/example2.ksh +kernsh/examples/md5/example1.ksh +kernsh/examples/modules/linux2_6/Makefile +kernsh/examples/modules/linux2_6/lkm-inject.c +kernsh/examples/modules/linux2_6/lkm-original.c +kernsh/examples/modules/linux2_6/lkm-sys_setdomainname.c +kernsh/examples/redir/example1.ksh +kernsh/hash.c +kernsh/include/kernsh-help.h +kernsh/include/kernsh.h +kernsh/main.c +kernsh/mem.c +kernsh/misc.c +kernsh/mode.c +kernsh/open.c +kernsh/tables.c +kernsh/virtm.c +liballocproxy/Makefile +liballocproxy/README +liballocproxy/aproxy_arena.c +liballocproxy/aproxy_hooks.c +liballocproxy/aproxy_malloc.c +liballocproxy/aproxy_strdup.c +liballocproxy/elfsh_hooks.c +liballocproxy/include/aproxy-machine.h +liballocproxy/include/aproxy.h +libasm/Makefile +libasm/README.FIRST +libasm/configure +libasm/doc/doxygen.conf +libasm/doc/footer.html +libasm/doc/header.html +libasm/include/libasm-arm-decode.h +libasm/include/libasm-arm.h +libasm/include/libasm-i386.h +libasm/include/libasm-ia32-hdl.h +libasm/include/libasm-int.h +libasm/include/libasm-mips-structs.h +libasm/include/libasm-mips.h +libasm/include/libasm-sparc-decode.h +libasm/include/libasm-sparc.h +libasm/include/libasm-structs.h +libasm/include/libasm.h +libasm/src/arch/arm/arm_convert.c +libasm/src/arch/arm/decode_arm.c +libasm/src/arch/arm/handlers/asm_arm_adc.c +libasm/src/arch/arm/handlers/asm_arm_add.c +libasm/src/arch/arm/handlers/asm_arm_and.c +libasm/src/arch/arm/handlers/asm_arm_b.c +libasm/src/arch/arm/handlers/asm_arm_bic.c +libasm/src/arch/arm/handlers/asm_arm_bkpt.c +libasm/src/arch/arm/handlers/asm_arm_bl.c +libasm/src/arch/arm/handlers/asm_arm_blx1.c +libasm/src/arch/arm/handlers/asm_arm_blx2.c +libasm/src/arch/arm/handlers/asm_arm_bx.c +libasm/src/arch/arm/handlers/asm_arm_cdp.c +libasm/src/arch/arm/handlers/asm_arm_clz.c +libasm/src/arch/arm/handlers/asm_arm_cmn.c +libasm/src/arch/arm/handlers/asm_arm_cmp.c +libasm/src/arch/arm/handlers/asm_arm_eor.c +libasm/src/arch/arm/handlers/asm_arm_illegal.c +libasm/src/arch/arm/handlers/asm_arm_ldc.c +libasm/src/arch/arm/handlers/asm_arm_ldm1.c +libasm/src/arch/arm/handlers/asm_arm_ldm2.c +libasm/src/arch/arm/handlers/asm_arm_ldm3.c +libasm/src/arch/arm/handlers/asm_arm_ldr.c +libasm/src/arch/arm/handlers/asm_arm_ldrb.c +libasm/src/arch/arm/handlers/asm_arm_ldrbt.c +libasm/src/arch/arm/handlers/asm_arm_ldrd.c +libasm/src/arch/arm/handlers/asm_arm_ldrh.c +libasm/src/arch/arm/handlers/asm_arm_ldrsb.c +libasm/src/arch/arm/handlers/asm_arm_ldrsh.c +libasm/src/arch/arm/handlers/asm_arm_ldrt.c +libasm/src/arch/arm/handlers/asm_arm_mcr.c +libasm/src/arch/arm/handlers/asm_arm_mcrr.c +libasm/src/arch/arm/handlers/asm_arm_mla.c +libasm/src/arch/arm/handlers/asm_arm_mov.c +libasm/src/arch/arm/handlers/asm_arm_mrc.c +libasm/src/arch/arm/handlers/asm_arm_mrrc.c +libasm/src/arch/arm/handlers/asm_arm_mrs.c +libasm/src/arch/arm/handlers/asm_arm_msr.c +libasm/src/arch/arm/handlers/asm_arm_mul.c +libasm/src/arch/arm/handlers/asm_arm_mvn.c +libasm/src/arch/arm/handlers/asm_arm_orr.c +libasm/src/arch/arm/handlers/asm_arm_pld.c +libasm/src/arch/arm/handlers/asm_arm_qadd.c +libasm/src/arch/arm/handlers/asm_arm_qdadd.c +libasm/src/arch/arm/handlers/asm_arm_qdsub.c +libasm/src/arch/arm/handlers/asm_arm_qsub.c +libasm/src/arch/arm/handlers/asm_arm_rsb.c +libasm/src/arch/arm/handlers/asm_arm_rsc.c +libasm/src/arch/arm/handlers/asm_arm_sbc.c +libasm/src/arch/arm/handlers/asm_arm_smlal.c +libasm/src/arch/arm/handlers/asm_arm_smlalxy.c +libasm/src/arch/arm/handlers/asm_arm_smlawy.c +libasm/src/arch/arm/handlers/asm_arm_smlaxy.c +libasm/src/arch/arm/handlers/asm_arm_smull.c +libasm/src/arch/arm/handlers/asm_arm_smulwy.c +libasm/src/arch/arm/handlers/asm_arm_smulxy.c +libasm/src/arch/arm/handlers/asm_arm_stc.c +libasm/src/arch/arm/handlers/asm_arm_stm1.c +libasm/src/arch/arm/handlers/asm_arm_stm2.c +libasm/src/arch/arm/handlers/asm_arm_str.c +libasm/src/arch/arm/handlers/asm_arm_strb.c +libasm/src/arch/arm/handlers/asm_arm_strbt.c +libasm/src/arch/arm/handlers/asm_arm_strd.c +libasm/src/arch/arm/handlers/asm_arm_strh.c +libasm/src/arch/arm/handlers/asm_arm_strt.c +libasm/src/arch/arm/handlers/asm_arm_sub.c +libasm/src/arch/arm/handlers/asm_arm_swi.c +libasm/src/arch/arm/handlers/asm_arm_swp.c +libasm/src/arch/arm/handlers/asm_arm_swpb.c +libasm/src/arch/arm/handlers/asm_arm_teq.c +libasm/src/arch/arm/handlers/asm_arm_tst.c +libasm/src/arch/arm/handlers/asm_arm_umlal.c +libasm/src/arch/arm/handlers/asm_arm_umull.c +libasm/src/arch/arm/handlers/asm_arm_undef.c +libasm/src/arch/arm/init_arm.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_coprocessor_register.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_disp_half.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_immediate.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_list.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_offset.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_reg_scaled.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_fetch_register.c +libasm/src/arch/arm/operand_handlers/asm_arm_op_name.c +libasm/src/arch/arm/output_arm.c +libasm/src/arch/arm/register_arm.c +libasm/src/arch/arm/tables_arm.c +libasm/src/arch/ia32/handlers/i386_bsf.c +libasm/src/arch/ia32/handlers/i386_bsr_rv_rmb.c +libasm/src/arch/ia32/handlers/i386_bswap.c +libasm/src/arch/ia32/handlers/i386_bt_rm_r.c +libasm/src/arch/ia32/handlers/i386_btrl.c +libasm/src/arch/ia32/handlers/i386_bts.c +libasm/src/arch/ia32/handlers/i386_cmova.c +libasm/src/arch/ia32/handlers/i386_cmovae.c +libasm/src/arch/ia32/handlers/i386_cmovb.c +libasm/src/arch/ia32/handlers/i386_cmovbe.c +libasm/src/arch/ia32/handlers/i386_cmove.c +libasm/src/arch/ia32/handlers/i386_cmovl.c +libasm/src/arch/ia32/handlers/i386_cmovle.c +libasm/src/arch/ia32/handlers/i386_cmovne.c +libasm/src/arch/ia32/handlers/i386_cmovnl.c +libasm/src/arch/ia32/handlers/i386_cmovnle.c +libasm/src/arch/ia32/handlers/i386_cmovno.c +libasm/src/arch/ia32/handlers/i386_cmovnp.c +libasm/src/arch/ia32/handlers/i386_cmovns.c +libasm/src/arch/ia32/handlers/i386_cmovo.c +libasm/src/arch/ia32/handlers/i386_cmovp.c +libasm/src/arch/ia32/handlers/i386_cmovs.c +libasm/src/arch/ia32/handlers/i386_cpuid.c +libasm/src/arch/ia32/handlers/i386_emms.c +libasm/src/arch/ia32/handlers/i386_group12.c +libasm/src/arch/ia32/handlers/i386_group14.c +libasm/src/arch/ia32/handlers/i386_group15.c +libasm/src/arch/ia32/handlers/i386_group16.c +libasm/src/arch/ia32/handlers/i386_imul_rv_rmv.c +libasm/src/arch/ia32/handlers/i386_ja.c +libasm/src/arch/ia32/handlers/i386_jae.c +libasm/src/arch/ia32/handlers/i386_jb.c +libasm/src/arch/ia32/handlers/i386_jbe.c +libasm/src/arch/ia32/handlers/i386_je.c +libasm/src/arch/ia32/handlers/i386_jg.c +libasm/src/arch/ia32/handlers/i386_jge.c +libasm/src/arch/ia32/handlers/i386_jl.c +libasm/src/arch/ia32/handlers/i386_jle.c +libasm/src/arch/ia32/handlers/i386_jne.c +libasm/src/arch/ia32/handlers/i386_jnp.c +libasm/src/arch/ia32/handlers/i386_jns.c +libasm/src/arch/ia32/handlers/i386_jp.c +libasm/src/arch/ia32/handlers/i386_js.c +libasm/src/arch/ia32/handlers/i386_mov_cr_rm.c +libasm/src/arch/ia32/handlers/i386_mov_dr_rm.c +libasm/src/arch/ia32/handlers/i386_mov_rm_cr.c +libasm/src/arch/ia32/handlers/i386_movd_pd_qd.c +libasm/src/arch/ia32/handlers/i386_movq_pq_qq.c +libasm/src/arch/ia32/handlers/i386_movq_qq_pq.c +libasm/src/arch/ia32/handlers/i386_movsbl_rv_rmb.c +libasm/src/arch/ia32/handlers/i386_movswl_rv_rm2.c +libasm/src/arch/ia32/handlers/i386_movzbl_rv_rmb.c +libasm/src/arch/ia32/handlers/i386_movzwl_rv_rm2.c +libasm/src/arch/ia32/handlers/i386_packuswb_pq_qq.c +libasm/src/arch/ia32/handlers/i386_paddusb_pq_qq.c +libasm/src/arch/ia32/handlers/i386_paddusw_pq_qq.c +libasm/src/arch/ia32/handlers/i386_pand_pq_qq.c +libasm/src/arch/ia32/handlers/i386_pmullw_pq_qq.c +libasm/src/arch/ia32/handlers/i386_pop_fs.c +libasm/src/arch/ia32/handlers/i386_por_pq_qq.c +libasm/src/arch/ia32/handlers/i386_punpckhbw_pq_qq.c +libasm/src/arch/ia32/handlers/i386_punpcklbw_pq_qd.c +libasm/src/arch/ia32/handlers/i386_push_fs.c +libasm/src/arch/ia32/handlers/i386_pxor_pq_qq.c +libasm/src/arch/ia32/handlers/i386_rdmsr.c +libasm/src/arch/ia32/handlers/i386_rdtsc.c +libasm/src/arch/ia32/handlers/i386_shld.c +libasm/src/arch/ia32/handlers/i386_shld_rmv_rv_cl.c +libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_cl.c +libasm/src/arch/ia32/handlers/i386_shrd_rmv_rv_ib.c +libasm/src/arch/ia32/handlers/i386_wbinvd.c +libasm/src/arch/ia32/handlers/i386_xadd.c +libasm/src/arch/ia32/handlers/i386_xstorenrg.c +libasm/src/arch/ia32/handlers/op_386sp.c +libasm/src/arch/ia32/handlers/op_aaa.c +libasm/src/arch/ia32/handlers/op_aad.c +libasm/src/arch/ia32/handlers/op_aam.c +libasm/src/arch/ia32/handlers/op_aas.c +libasm/src/arch/ia32/handlers/op_adc_al_ib.c +libasm/src/arch/ia32/handlers/op_adc_eax_iv.c +libasm/src/arch/ia32/handlers/op_adc_rb_rmb.c +libasm/src/arch/ia32/handlers/op_adc_rmb_rb.c +libasm/src/arch/ia32/handlers/op_adc_rmv_rv.c +libasm/src/arch/ia32/handlers/op_adc_rv_rmv.c +libasm/src/arch/ia32/handlers/op_add_al_ib.c +libasm/src/arch/ia32/handlers/op_add_eax_iv.c +libasm/src/arch/ia32/handlers/op_add_rb_rmb.c +libasm/src/arch/ia32/handlers/op_add_rmb_rb.c +libasm/src/arch/ia32/handlers/op_add_rmv_rv.c +libasm/src/arch/ia32/handlers/op_add_rv_rmv.c +libasm/src/arch/ia32/handlers/op_addsize.c +libasm/src/arch/ia32/handlers/op_and_al_ib.c +libasm/src/arch/ia32/handlers/op_and_eax_iv.c +libasm/src/arch/ia32/handlers/op_and_rb_rmb.c +libasm/src/arch/ia32/handlers/op_and_rmb_rb.c +libasm/src/arch/ia32/handlers/op_and_rmv_rv.c +libasm/src/arch/ia32/handlers/op_and_rv_rmv.c +libasm/src/arch/ia32/handlers/op_arpl_ew_rw.c +libasm/src/arch/ia32/handlers/op_bound_gv_ma.c +libasm/src/arch/ia32/handlers/op_btr_rmv_rv.c +libasm/src/arch/ia32/handlers/op_call_iv.c +libasm/src/arch/ia32/handlers/op_clc.c +libasm/src/arch/ia32/handlers/op_cld.c +libasm/src/arch/ia32/handlers/op_cli.c +libasm/src/arch/ia32/handlers/op_cltd.c +libasm/src/arch/ia32/handlers/op_cmc.c +libasm/src/arch/ia32/handlers/op_cmp_al_ib.c +libasm/src/arch/ia32/handlers/op_cmp_eax_iv.c +libasm/src/arch/ia32/handlers/op_cmp_rb_rmb.c +libasm/src/arch/ia32/handlers/op_cmp_rmb_rb.c +libasm/src/arch/ia32/handlers/op_cmp_rmv_rv.c +libasm/src/arch/ia32/handlers/op_cmp_rv_rmv.c +libasm/src/arch/ia32/handlers/op_cmp_xchg.c +libasm/src/arch/ia32/handlers/op_cmpsb.c +libasm/src/arch/ia32/handlers/op_cmpsd.c +libasm/src/arch/ia32/handlers/op_cwtl.c +libasm/src/arch/ia32/handlers/op_daa.c +libasm/src/arch/ia32/handlers/op_das.c +libasm/src/arch/ia32/handlers/op_dec_reg.c +libasm/src/arch/ia32/handlers/op_enter.c +libasm/src/arch/ia32/handlers/op_esc0.c +libasm/src/arch/ia32/handlers/op_esc1.c +libasm/src/arch/ia32/handlers/op_esc2.c +libasm/src/arch/ia32/handlers/op_esc3.c +libasm/src/arch/ia32/handlers/op_esc4.c +libasm/src/arch/ia32/handlers/op_esc5.c +libasm/src/arch/ia32/handlers/op_esc6.c +libasm/src/arch/ia32/handlers/op_esc7.c +libasm/src/arch/ia32/handlers/op_fwait.c +libasm/src/arch/ia32/handlers/op_group6.c +libasm/src/arch/ia32/handlers/op_group7.c +libasm/src/arch/ia32/handlers/op_hlt.c +libasm/src/arch/ia32/handlers/op_immed_rmb_ib.c +libasm/src/arch/ia32/handlers/op_immed_rmv_ib.c +libasm/src/arch/ia32/handlers/op_immed_rmv_iv.c +libasm/src/arch/ia32/handlers/op_imul_gv_ev_ib.c +libasm/src/arch/ia32/handlers/op_imul_rv_rmv_iv.c +libasm/src/arch/ia32/handlers/op_in_al_dx.c +libasm/src/arch/ia32/handlers/op_in_al_ref_ib.c +libasm/src/arch/ia32/handlers/op_in_eax_dx.c +libasm/src/arch/ia32/handlers/op_in_eax_ref_ib.c +libasm/src/arch/ia32/handlers/op_inc_reg.c +libasm/src/arch/ia32/handlers/op_incdec_rmb.c +libasm/src/arch/ia32/handlers/op_indir_rmv.c +libasm/src/arch/ia32/handlers/op_insb.c +libasm/src/arch/ia32/handlers/op_insw.c +libasm/src/arch/ia32/handlers/op_int1.c +libasm/src/arch/ia32/handlers/op_int_3.c +libasm/src/arch/ia32/handlers/op_int_ib.c +libasm/src/arch/ia32/handlers/op_into.c +libasm/src/arch/ia32/handlers/op_iret.c +libasm/src/arch/ia32/handlers/op_ja.c +libasm/src/arch/ia32/handlers/op_jae.c +libasm/src/arch/ia32/handlers/op_jb.c +libasm/src/arch/ia32/handlers/op_jbe.c +libasm/src/arch/ia32/handlers/op_je.c +libasm/src/arch/ia32/handlers/op_je_cxz.c +libasm/src/arch/ia32/handlers/op_jg.c +libasm/src/arch/ia32/handlers/op_jge.c +libasm/src/arch/ia32/handlers/op_jl.c +libasm/src/arch/ia32/handlers/op_jle.c +libasm/src/arch/ia32/handlers/op_jmp_ap.c +libasm/src/arch/ia32/handlers/op_jmp_ib.c +libasm/src/arch/ia32/handlers/op_jmp_iv.c +libasm/src/arch/ia32/handlers/op_jne.c +libasm/src/arch/ia32/handlers/op_jno.c +libasm/src/arch/ia32/handlers/op_jnp.c +libasm/src/arch/ia32/handlers/op_jns.c +libasm/src/arch/ia32/handlers/op_jo.c +libasm/src/arch/ia32/handlers/op_jp.c +libasm/src/arch/ia32/handlers/op_js.c +libasm/src/arch/ia32/handlers/op_lahf.c +libasm/src/arch/ia32/handlers/op_lds_rm_rmp.c +libasm/src/arch/ia32/handlers/op_lea_rv_m.c +libasm/src/arch/ia32/handlers/op_leave.c +libasm/src/arch/ia32/handlers/op_les_rm_rmp.c +libasm/src/arch/ia32/handlers/op_lock.c +libasm/src/arch/ia32/handlers/op_lodsb.c +libasm/src/arch/ia32/handlers/op_lodsd.c +libasm/src/arch/ia32/handlers/op_loop.c +libasm/src/arch/ia32/handlers/op_loope.c +libasm/src/arch/ia32/handlers/op_loopne.c +libasm/src/arch/ia32/handlers/op_lss_rv_rmv.c +libasm/src/arch/ia32/handlers/op_mov_al_ref_iv.c +libasm/src/arch/ia32/handlers/op_mov_eax_ref_iv.c +libasm/src/arch/ia32/handlers/op_mov_rb_rmb.c +libasm/src/arch/ia32/handlers/op_mov_ref_iv_al.c +libasm/src/arch/ia32/handlers/op_mov_ref_iv_eax.c +libasm/src/arch/ia32/handlers/op_mov_reg_iv.c +libasm/src/arch/ia32/handlers/op_mov_rm_segr.c +libasm/src/arch/ia32/handlers/op_mov_rmb_ib.c +libasm/src/arch/ia32/handlers/op_mov_rmb_rb.c +libasm/src/arch/ia32/handlers/op_mov_rmv_iv.c +libasm/src/arch/ia32/handlers/op_mov_rmv_rv.c +libasm/src/arch/ia32/handlers/op_mov_rv_rmv.c +libasm/src/arch/ia32/handlers/op_mov_segr_rm.c +libasm/src/arch/ia32/handlers/op_mov_subreg_ib.c +libasm/src/arch/ia32/handlers/op_movsb.c +libasm/src/arch/ia32/handlers/op_movsd.c +libasm/src/arch/ia32/handlers/op_nop.c +libasm/src/arch/ia32/handlers/op_opsize.c +libasm/src/arch/ia32/handlers/op_or_al_ib.c +libasm/src/arch/ia32/handlers/op_or_eax_iv.c +libasm/src/arch/ia32/handlers/op_or_rb_rmb.c +libasm/src/arch/ia32/handlers/op_or_rmb_rb.c +libasm/src/arch/ia32/handlers/op_or_rmv_rv.c +libasm/src/arch/ia32/handlers/op_or_rv_rmv.c +libasm/src/arch/ia32/handlers/op_out_dx_al.c +libasm/src/arch/ia32/handlers/op_out_dx_eax.c +libasm/src/arch/ia32/handlers/op_out_ref_ib_al.c +libasm/src/arch/ia32/handlers/op_out_ref_ib_eax.c +libasm/src/arch/ia32/handlers/op_outsb.c +libasm/src/arch/ia32/handlers/op_outsw.c +libasm/src/arch/ia32/handlers/op_pop_ds.c +libasm/src/arch/ia32/handlers/op_pop_es.c +libasm/src/arch/ia32/handlers/op_pop_reg.c +libasm/src/arch/ia32/handlers/op_pop_rmv.c +libasm/src/arch/ia32/handlers/op_pop_ss.c +libasm/src/arch/ia32/handlers/op_popa.c +libasm/src/arch/ia32/handlers/op_popf.c +libasm/src/arch/ia32/handlers/op_prefix_cs.c +libasm/src/arch/ia32/handlers/op_prefix_ds.c +libasm/src/arch/ia32/handlers/op_prefix_es.c +libasm/src/arch/ia32/handlers/op_prefix_fs.c +libasm/src/arch/ia32/handlers/op_prefix_gs.c +libasm/src/arch/ia32/handlers/op_prefix_ss.c +libasm/src/arch/ia32/handlers/op_push_cs.c +libasm/src/arch/ia32/handlers/op_push_ds.c +libasm/src/arch/ia32/handlers/op_push_es.c +libasm/src/arch/ia32/handlers/op_push_ib.c +libasm/src/arch/ia32/handlers/op_push_iv.c +libasm/src/arch/ia32/handlers/op_push_reg.c +libasm/src/arch/ia32/handlers/op_push_ss.c +libasm/src/arch/ia32/handlers/op_pusha.c +libasm/src/arch/ia32/handlers/op_pushf.c +libasm/src/arch/ia32/handlers/op_repnz.c +libasm/src/arch/ia32/handlers/op_repz.c +libasm/src/arch/ia32/handlers/op_ret.c +libasm/src/arch/ia32/handlers/op_ret_i2.c +libasm/src/arch/ia32/handlers/op_retf.c +libasm/src/arch/ia32/handlers/op_retf_i2.c +libasm/src/arch/ia32/handlers/op_sahf.c +libasm/src/arch/ia32/handlers/op_sbb_al_ib.c +libasm/src/arch/ia32/handlers/op_sbb_eax_iv.c +libasm/src/arch/ia32/handlers/op_sbb_rb_rmb.c +libasm/src/arch/ia32/handlers/op_sbb_rmb_rb.c +libasm/src/arch/ia32/handlers/op_sbb_rmv_rv.c +libasm/src/arch/ia32/handlers/op_sbb_rv_rmv.c +libasm/src/arch/ia32/handlers/op_scasb.c +libasm/src/arch/ia32/handlers/op_scasd.c +libasm/src/arch/ia32/handlers/op_seta_rmb.c +libasm/src/arch/ia32/handlers/op_setae_rmb.c +libasm/src/arch/ia32/handlers/op_setb_rmb.c +libasm/src/arch/ia32/handlers/op_setbe_rmb.c +libasm/src/arch/ia32/handlers/op_sete_rmb.c +libasm/src/arch/ia32/handlers/op_setg_rmb.c +libasm/src/arch/ia32/handlers/op_setge_rmb.c +libasm/src/arch/ia32/handlers/op_setl_rmb.c +libasm/src/arch/ia32/handlers/op_setle_rmb.c +libasm/src/arch/ia32/handlers/op_setne_rmb.c +libasm/src/arch/ia32/handlers/op_setno_rmb.c +libasm/src/arch/ia32/handlers/op_setnp_rmb.c +libasm/src/arch/ia32/handlers/op_setns_rmb.c +libasm/src/arch/ia32/handlers/op_seto_rmb.c +libasm/src/arch/ia32/handlers/op_setp_rmb.c +libasm/src/arch/ia32/handlers/op_sets_rmb.c +libasm/src/arch/ia32/handlers/op_shift_rmb_1.c +libasm/src/arch/ia32/handlers/op_shift_rmb_cl.c +libasm/src/arch/ia32/handlers/op_shift_rmv_1.c +libasm/src/arch/ia32/handlers/op_shift_rmv_cl.c +libasm/src/arch/ia32/handlers/op_shr_rmb_ib.c +libasm/src/arch/ia32/handlers/op_shr_rmv_ib.c +libasm/src/arch/ia32/handlers/op_stc.c +libasm/src/arch/ia32/handlers/op_std.c +libasm/src/arch/ia32/handlers/op_sti.c +libasm/src/arch/ia32/handlers/op_stosb.c +libasm/src/arch/ia32/handlers/op_stosd.c +libasm/src/arch/ia32/handlers/op_sub_al_ib.c +libasm/src/arch/ia32/handlers/op_sub_eax_iv.c +libasm/src/arch/ia32/handlers/op_sub_rb_rmb.c +libasm/src/arch/ia32/handlers/op_sub_rmb_rb.c +libasm/src/arch/ia32/handlers/op_sub_rmv_rv.c +libasm/src/arch/ia32/handlers/op_sub_rv_rmv.c +libasm/src/arch/ia32/handlers/op_test_al_rb.c +libasm/src/arch/ia32/handlers/op_test_eax_iv.c +libasm/src/arch/ia32/handlers/op_test_rmb_rb.c +libasm/src/arch/ia32/handlers/op_test_rmv_rv.c +libasm/src/arch/ia32/handlers/op_ud2a.c +libasm/src/arch/ia32/handlers/op_unary_rmb.c +libasm/src/arch/ia32/handlers/op_unary_rmv.c +libasm/src/arch/ia32/handlers/op_xchg_eax_reg.c +libasm/src/arch/ia32/handlers/op_xchg_rmb_rb.c +libasm/src/arch/ia32/handlers/op_xchg_rmv_rv.c +libasm/src/arch/ia32/handlers/op_xlatb.c +libasm/src/arch/ia32/handlers/op_xor_al_ib.c +libasm/src/arch/ia32/handlers/op_xor_eax_iv.c +libasm/src/arch/ia32/handlers/op_xor_rb_rmb.c +libasm/src/arch/ia32/handlers/op_xor_rmb_rb.c +libasm/src/arch/ia32/handlers/op_xor_rmv_rv.c +libasm/src/arch/ia32/handlers/op_xor_rv_rmv.c +libasm/src/arch/ia32/init_i386.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_address.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_control.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_debug.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encoded.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_encodedbyte.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_fixed.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_general.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_generalbyte.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediate.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediatebyte.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_immediateword.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_jump.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_memory.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_offset.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_opmod.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_pmmx.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_register.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_segment.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_shortjump.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_xsrc.c +libasm/src/arch/ia32/operand_handlers/asm_operand_fetch_ydest.c +libasm/src/arch/ia32/operand_ia32.c +libasm/src/arch/ia32/output_ia32.c +libasm/src/arch/ia32/register.c +libasm/src/arch/ia32/tables_i386.c +libasm/src/arch/mips/handlers/asm_mips_abs_d.c +libasm/src/arch/mips/handlers/asm_mips_abs_ps.c +libasm/src/arch/mips/handlers/asm_mips_abs_s.c +libasm/src/arch/mips/handlers/asm_mips_add.c +libasm/src/arch/mips/handlers/asm_mips_add_d.c +libasm/src/arch/mips/handlers/asm_mips_add_ps.c +libasm/src/arch/mips/handlers/asm_mips_add_s.c +libasm/src/arch/mips/handlers/asm_mips_addi.c +libasm/src/arch/mips/handlers/asm_mips_addiu.c +libasm/src/arch/mips/handlers/asm_mips_addu.c +libasm/src/arch/mips/handlers/asm_mips_alnv_ps.c +libasm/src/arch/mips/handlers/asm_mips_and.c +libasm/src/arch/mips/handlers/asm_mips_andi.c +libasm/src/arch/mips/handlers/asm_mips_b.c +libasm/src/arch/mips/handlers/asm_mips_bal.c +libasm/src/arch/mips/handlers/asm_mips_bc1f.c +libasm/src/arch/mips/handlers/asm_mips_bc1fl.c +libasm/src/arch/mips/handlers/asm_mips_bc1t.c +libasm/src/arch/mips/handlers/asm_mips_bc1tl.c +libasm/src/arch/mips/handlers/asm_mips_bc2f.c +libasm/src/arch/mips/handlers/asm_mips_bc2fl.c +libasm/src/arch/mips/handlers/asm_mips_bc2t.c +libasm/src/arch/mips/handlers/asm_mips_bc2tl.c +libasm/src/arch/mips/handlers/asm_mips_beq.c +libasm/src/arch/mips/handlers/asm_mips_beql.c +libasm/src/arch/mips/handlers/asm_mips_bgez.c +libasm/src/arch/mips/handlers/asm_mips_bgezal.c +libasm/src/arch/mips/handlers/asm_mips_bgezall.c +libasm/src/arch/mips/handlers/asm_mips_bgezl.c +libasm/src/arch/mips/handlers/asm_mips_bgtz.c +libasm/src/arch/mips/handlers/asm_mips_bgtzl.c +libasm/src/arch/mips/handlers/asm_mips_blez.c +libasm/src/arch/mips/handlers/asm_mips_blezl.c +libasm/src/arch/mips/handlers/asm_mips_bltz.c +libasm/src/arch/mips/handlers/asm_mips_bltzal.c +libasm/src/arch/mips/handlers/asm_mips_bltzall.c +libasm/src/arch/mips/handlers/asm_mips_bltzl.c +libasm/src/arch/mips/handlers/asm_mips_bne.c +libasm/src/arch/mips/handlers/asm_mips_bnel.c +libasm/src/arch/mips/handlers/asm_mips_break.c +libasm/src/arch/mips/handlers/asm_mips_c_eq_d.c +libasm/src/arch/mips/handlers/asm_mips_c_eq_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_eq_s.c +libasm/src/arch/mips/handlers/asm_mips_c_f_d.c +libasm/src/arch/mips/handlers/asm_mips_c_f_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_f_s.c +libasm/src/arch/mips/handlers/asm_mips_c_le_d.c +libasm/src/arch/mips/handlers/asm_mips_c_le_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_le_s.c +libasm/src/arch/mips/handlers/asm_mips_c_lt_d.c +libasm/src/arch/mips/handlers/asm_mips_c_lt_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_lt_s.c +libasm/src/arch/mips/handlers/asm_mips_c_nge_d.c +libasm/src/arch/mips/handlers/asm_mips_c_nge_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_nge_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ngl_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ngl_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ngl_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ngle_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ngle_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ngle_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ngt_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ngt_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ngt_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ole_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ole_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ole_s.c +libasm/src/arch/mips/handlers/asm_mips_c_olt_d.c +libasm/src/arch/mips/handlers/asm_mips_c_olt_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_olt_s.c +libasm/src/arch/mips/handlers/asm_mips_c_seq_d.c +libasm/src/arch/mips/handlers/asm_mips_c_seq_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_seq_s.c +libasm/src/arch/mips/handlers/asm_mips_c_sf_d.c +libasm/src/arch/mips/handlers/asm_mips_c_sf_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_sf_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ueq_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ueq_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ueq_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ule_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ule_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ule_s.c +libasm/src/arch/mips/handlers/asm_mips_c_ult_d.c +libasm/src/arch/mips/handlers/asm_mips_c_ult_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_ult_s.c +libasm/src/arch/mips/handlers/asm_mips_c_un_d.c +libasm/src/arch/mips/handlers/asm_mips_c_un_ps.c +libasm/src/arch/mips/handlers/asm_mips_c_un_s.c +libasm/src/arch/mips/handlers/asm_mips_ceil_l_d.c +libasm/src/arch/mips/handlers/asm_mips_ceil_l_s.c +libasm/src/arch/mips/handlers/asm_mips_ceil_w_d.c +libasm/src/arch/mips/handlers/asm_mips_ceil_w_s.c +libasm/src/arch/mips/handlers/asm_mips_cfc1.c +libasm/src/arch/mips/handlers/asm_mips_cfc2.c +libasm/src/arch/mips/handlers/asm_mips_clo.c +libasm/src/arch/mips/handlers/asm_mips_clz.c +libasm/src/arch/mips/handlers/asm_mips_cop2.c +libasm/src/arch/mips/handlers/asm_mips_ctc1.c +libasm/src/arch/mips/handlers/asm_mips_ctc2.c +libasm/src/arch/mips/handlers/asm_mips_cvt_d_l.c +libasm/src/arch/mips/handlers/asm_mips_cvt_d_s.c +libasm/src/arch/mips/handlers/asm_mips_cvt_d_w.c +libasm/src/arch/mips/handlers/asm_mips_cvt_l_d.c +libasm/src/arch/mips/handlers/asm_mips_cvt_l_s.c +libasm/src/arch/mips/handlers/asm_mips_cvt_ps_s.c +libasm/src/arch/mips/handlers/asm_mips_cvt_s_d.c +libasm/src/arch/mips/handlers/asm_mips_cvt_s_l.c +libasm/src/arch/mips/handlers/asm_mips_cvt_s_pl.c +libasm/src/arch/mips/handlers/asm_mips_cvt_s_pu.c +libasm/src/arch/mips/handlers/asm_mips_cvt_s_w.c +libasm/src/arch/mips/handlers/asm_mips_cvt_w_d.c +libasm/src/arch/mips/handlers/asm_mips_cvt_w_s.c +libasm/src/arch/mips/handlers/asm_mips_dadd.c +libasm/src/arch/mips/handlers/asm_mips_daddi.c +libasm/src/arch/mips/handlers/asm_mips_daddiu.c +libasm/src/arch/mips/handlers/asm_mips_daddu.c +libasm/src/arch/mips/handlers/asm_mips_dclo.c +libasm/src/arch/mips/handlers/asm_mips_dclz.c +libasm/src/arch/mips/handlers/asm_mips_ddiv.c +libasm/src/arch/mips/handlers/asm_mips_ddivu.c +libasm/src/arch/mips/handlers/asm_mips_deret.c +libasm/src/arch/mips/handlers/asm_mips_div.c +libasm/src/arch/mips/handlers/asm_mips_div_d.c +libasm/src/arch/mips/handlers/asm_mips_div_s.c +libasm/src/arch/mips/handlers/asm_mips_divu.c +libasm/src/arch/mips/handlers/asm_mips_dmfc0.c +libasm/src/arch/mips/handlers/asm_mips_dmfc1.c +libasm/src/arch/mips/handlers/asm_mips_dmfc2.c +libasm/src/arch/mips/handlers/asm_mips_dmtc0.c +libasm/src/arch/mips/handlers/asm_mips_dmtc1.c +libasm/src/arch/mips/handlers/asm_mips_dmtc2.c +libasm/src/arch/mips/handlers/asm_mips_dmult.c +libasm/src/arch/mips/handlers/asm_mips_dmultu.c +libasm/src/arch/mips/handlers/asm_mips_dsll.c +libasm/src/arch/mips/handlers/asm_mips_dsll32.c +libasm/src/arch/mips/handlers/asm_mips_dsllv.c +libasm/src/arch/mips/handlers/asm_mips_dsra.c +libasm/src/arch/mips/handlers/asm_mips_dsra32.c +libasm/src/arch/mips/handlers/asm_mips_dsrav.c +libasm/src/arch/mips/handlers/asm_mips_dsrl.c +libasm/src/arch/mips/handlers/asm_mips_dsrl32.c +libasm/src/arch/mips/handlers/asm_mips_dsrlv.c +libasm/src/arch/mips/handlers/asm_mips_dsub.c +libasm/src/arch/mips/handlers/asm_mips_dsubu.c +libasm/src/arch/mips/handlers/asm_mips_ehb.c +libasm/src/arch/mips/handlers/asm_mips_eret.c +libasm/src/arch/mips/handlers/asm_mips_ext.c +libasm/src/arch/mips/handlers/asm_mips_floor_l_d.c +libasm/src/arch/mips/handlers/asm_mips_floor_l_s.c +libasm/src/arch/mips/handlers/asm_mips_floor_w_d.c +libasm/src/arch/mips/handlers/asm_mips_floor_w_s.c +libasm/src/arch/mips/handlers/asm_mips_ins.c +libasm/src/arch/mips/handlers/asm_mips_j.c +libasm/src/arch/mips/handlers/asm_mips_jal.c +libasm/src/arch/mips/handlers/asm_mips_jalr.c +libasm/src/arch/mips/handlers/asm_mips_jalr.hb.c +libasm/src/arch/mips/handlers/asm_mips_jr.c +libasm/src/arch/mips/handlers/asm_mips_jr.hb.c +libasm/src/arch/mips/handlers/asm_mips_lb.c +libasm/src/arch/mips/handlers/asm_mips_lbu.c +libasm/src/arch/mips/handlers/asm_mips_ld.c +libasm/src/arch/mips/handlers/asm_mips_ldc1.c +libasm/src/arch/mips/handlers/asm_mips_ldc2.c +libasm/src/arch/mips/handlers/asm_mips_ldl.c +libasm/src/arch/mips/handlers/asm_mips_ldr.c +libasm/src/arch/mips/handlers/asm_mips_ldxc1.c +libasm/src/arch/mips/handlers/asm_mips_lh.c +libasm/src/arch/mips/handlers/asm_mips_lhu.c +libasm/src/arch/mips/handlers/asm_mips_ll.c +libasm/src/arch/mips/handlers/asm_mips_lld.c +libasm/src/arch/mips/handlers/asm_mips_lui.c +libasm/src/arch/mips/handlers/asm_mips_luxc1.c +libasm/src/arch/mips/handlers/asm_mips_lw.c +libasm/src/arch/mips/handlers/asm_mips_lwc1.c +libasm/src/arch/mips/handlers/asm_mips_lwc2.c +libasm/src/arch/mips/handlers/asm_mips_lwl.c +libasm/src/arch/mips/handlers/asm_mips_lwr.c +libasm/src/arch/mips/handlers/asm_mips_lwu.c +libasm/src/arch/mips/handlers/asm_mips_lwxc1.c +libasm/src/arch/mips/handlers/asm_mips_madd.c +libasm/src/arch/mips/handlers/asm_mips_madd_d.c +libasm/src/arch/mips/handlers/asm_mips_madd_ps.c +libasm/src/arch/mips/handlers/asm_mips_madd_s.c +libasm/src/arch/mips/handlers/asm_mips_maddu.c +libasm/src/arch/mips/handlers/asm_mips_mfc0.c +libasm/src/arch/mips/handlers/asm_mips_mfc1.c +libasm/src/arch/mips/handlers/asm_mips_mfc2.c +libasm/src/arch/mips/handlers/asm_mips_mfhi.c +libasm/src/arch/mips/handlers/asm_mips_mflo.c +libasm/src/arch/mips/handlers/asm_mips_mov_d.c +libasm/src/arch/mips/handlers/asm_mips_mov_ps.c +libasm/src/arch/mips/handlers/asm_mips_mov_s.c +libasm/src/arch/mips/handlers/asm_mips_movcf_d.c +libasm/src/arch/mips/handlers/asm_mips_movcf_ps.c +libasm/src/arch/mips/handlers/asm_mips_movcf_s.c +libasm/src/arch/mips/handlers/asm_mips_movf.c +libasm/src/arch/mips/handlers/asm_mips_movn.c +libasm/src/arch/mips/handlers/asm_mips_movn_d.c +libasm/src/arch/mips/handlers/asm_mips_movn_ps.c +libasm/src/arch/mips/handlers/asm_mips_movn_s.c +libasm/src/arch/mips/handlers/asm_mips_movt.c +libasm/src/arch/mips/handlers/asm_mips_movz.c +libasm/src/arch/mips/handlers/asm_mips_movz_d.c +libasm/src/arch/mips/handlers/asm_mips_movz_ps.c +libasm/src/arch/mips/handlers/asm_mips_movz_s.c +libasm/src/arch/mips/handlers/asm_mips_msub.c +libasm/src/arch/mips/handlers/asm_mips_msub_d.c +libasm/src/arch/mips/handlers/asm_mips_msub_ps.c +libasm/src/arch/mips/handlers/asm_mips_msub_s.c +libasm/src/arch/mips/handlers/asm_mips_msubu.c +libasm/src/arch/mips/handlers/asm_mips_mtc0.c +libasm/src/arch/mips/handlers/asm_mips_mtc1.c +libasm/src/arch/mips/handlers/asm_mips_mtc2.c +libasm/src/arch/mips/handlers/asm_mips_mthi.c +libasm/src/arch/mips/handlers/asm_mips_mtlo.c +libasm/src/arch/mips/handlers/asm_mips_mul.c +libasm/src/arch/mips/handlers/asm_mips_mul_d.c +libasm/src/arch/mips/handlers/asm_mips_mul_ps.c +libasm/src/arch/mips/handlers/asm_mips_mul_s.c +libasm/src/arch/mips/handlers/asm_mips_mult.c +libasm/src/arch/mips/handlers/asm_mips_multu.c +libasm/src/arch/mips/handlers/asm_mips_neg_d.c +libasm/src/arch/mips/handlers/asm_mips_neg_ps.c +libasm/src/arch/mips/handlers/asm_mips_neg_s.c +libasm/src/arch/mips/handlers/asm_mips_nmadd_d.c +libasm/src/arch/mips/handlers/asm_mips_nmadd_ps.c +libasm/src/arch/mips/handlers/asm_mips_nmadd_s.c +libasm/src/arch/mips/handlers/asm_mips_nmsub_d.c +libasm/src/arch/mips/handlers/asm_mips_nmsub_ps.c +libasm/src/arch/mips/handlers/asm_mips_nmsub_s.c +libasm/src/arch/mips/handlers/asm_mips_nop.c +libasm/src/arch/mips/handlers/asm_mips_nor.c +libasm/src/arch/mips/handlers/asm_mips_or.c +libasm/src/arch/mips/handlers/asm_mips_ori.c +libasm/src/arch/mips/handlers/asm_mips_pref.c +libasm/src/arch/mips/handlers/asm_mips_prefx.c +libasm/src/arch/mips/handlers/asm_mips_rdhwr.c +libasm/src/arch/mips/handlers/asm_mips_recip_d.c +libasm/src/arch/mips/handlers/asm_mips_recip_s.c +libasm/src/arch/mips/handlers/asm_mips_rotr.c +libasm/src/arch/mips/handlers/asm_mips_rotrv.c +libasm/src/arch/mips/handlers/asm_mips_round_l_d.c +libasm/src/arch/mips/handlers/asm_mips_round_l_s.c +libasm/src/arch/mips/handlers/asm_mips_round_w_d.c +libasm/src/arch/mips/handlers/asm_mips_round_w_s.c +libasm/src/arch/mips/handlers/asm_mips_rsqrt_d.c +libasm/src/arch/mips/handlers/asm_mips_rsqrt_s.c +libasm/src/arch/mips/handlers/asm_mips_sb.c +libasm/src/arch/mips/handlers/asm_mips_sc.c +libasm/src/arch/mips/handlers/asm_mips_scd.c +libasm/src/arch/mips/handlers/asm_mips_sd.c +libasm/src/arch/mips/handlers/asm_mips_sdbbp.c +libasm/src/arch/mips/handlers/asm_mips_sdc1.c +libasm/src/arch/mips/handlers/asm_mips_sdc2.c +libasm/src/arch/mips/handlers/asm_mips_sdl.c +libasm/src/arch/mips/handlers/asm_mips_sdr.c +libasm/src/arch/mips/handlers/asm_mips_sdxc1.c +libasm/src/arch/mips/handlers/asm_mips_seb.c +libasm/src/arch/mips/handlers/asm_mips_seh.c +libasm/src/arch/mips/handlers/asm_mips_sh.c +libasm/src/arch/mips/handlers/asm_mips_sll.c +libasm/src/arch/mips/handlers/asm_mips_sllv.c +libasm/src/arch/mips/handlers/asm_mips_slt.c +libasm/src/arch/mips/handlers/asm_mips_slti.c +libasm/src/arch/mips/handlers/asm_mips_sltiu.c +libasm/src/arch/mips/handlers/asm_mips_sltu.c +libasm/src/arch/mips/handlers/asm_mips_sqrt_d.c +libasm/src/arch/mips/handlers/asm_mips_sqrt_s.c +libasm/src/arch/mips/handlers/asm_mips_sra.c +libasm/src/arch/mips/handlers/asm_mips_srav.c +libasm/src/arch/mips/handlers/asm_mips_srl.c +libasm/src/arch/mips/handlers/asm_mips_srlv.c +libasm/src/arch/mips/handlers/asm_mips_ssnop.c +libasm/src/arch/mips/handlers/asm_mips_sub.c +libasm/src/arch/mips/handlers/asm_mips_sub_d.c +libasm/src/arch/mips/handlers/asm_mips_sub_ps.c +libasm/src/arch/mips/handlers/asm_mips_sub_s.c +libasm/src/arch/mips/handlers/asm_mips_subu.c +libasm/src/arch/mips/handlers/asm_mips_suxc1.c +libasm/src/arch/mips/handlers/asm_mips_sw.c +libasm/src/arch/mips/handlers/asm_mips_swc1.c +libasm/src/arch/mips/handlers/asm_mips_swc2.c +libasm/src/arch/mips/handlers/asm_mips_swl.c +libasm/src/arch/mips/handlers/asm_mips_swr.c +libasm/src/arch/mips/handlers/asm_mips_swxc1.c +libasm/src/arch/mips/handlers/asm_mips_sync.c +libasm/src/arch/mips/handlers/asm_mips_synci.c +libasm/src/arch/mips/handlers/asm_mips_syscall.c +libasm/src/arch/mips/handlers/asm_mips_teq.c +libasm/src/arch/mips/handlers/asm_mips_teqi.c +libasm/src/arch/mips/handlers/asm_mips_tge.c +libasm/src/arch/mips/handlers/asm_mips_tgei.c +libasm/src/arch/mips/handlers/asm_mips_tgeiu.c +libasm/src/arch/mips/handlers/asm_mips_tgeu.c +libasm/src/arch/mips/handlers/asm_mips_tlbp.c +libasm/src/arch/mips/handlers/asm_mips_tlbr.c +libasm/src/arch/mips/handlers/asm_mips_tlbwi.c +libasm/src/arch/mips/handlers/asm_mips_tlbwr.c +libasm/src/arch/mips/handlers/asm_mips_tlt.c +libasm/src/arch/mips/handlers/asm_mips_tlti.c +libasm/src/arch/mips/handlers/asm_mips_tltiu.c +libasm/src/arch/mips/handlers/asm_mips_tltu.c +libasm/src/arch/mips/handlers/asm_mips_tne.c +libasm/src/arch/mips/handlers/asm_mips_tnei.c +libasm/src/arch/mips/handlers/asm_mips_trunc_l_d.c +libasm/src/arch/mips/handlers/asm_mips_trunc_l_s.c +libasm/src/arch/mips/handlers/asm_mips_trunc_w_d.c +libasm/src/arch/mips/handlers/asm_mips_trunc_w_s.c +libasm/src/arch/mips/handlers/asm_mips_wait.c +libasm/src/arch/mips/handlers/asm_mips_wsbh.c +libasm/src/arch/mips/handlers/asm_mips_xor.c +libasm/src/arch/mips/handlers/asm_mips_xori.c +libasm/src/arch/mips/handlers/cpuinsns.txt +libasm/src/arch/mips/handlers/fpuinsns.txt +libasm/src/arch/mips/handlers/generate.sh +libasm/src/arch/mips/handlers/template.txt +libasm/src/arch/mips/init_mips.c +libasm/src/arch/mips/mips_convert.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_branch.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_fetch.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_i.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_j.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_none.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_noop.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_r.c +libasm/src/arch/mips/operand_handlers/asm_mips_operand_regbase.c +libasm/src/arch/mips/output_mips.c +libasm/src/arch/mips/register_mips.c +libasm/src/arch/mips/tables_mips.c +libasm/src/arch/sparc/handlers/asm_sparc_add.c +libasm/src/arch/sparc/handlers/asm_sparc_addc.c +libasm/src/arch/sparc/handlers/asm_sparc_addcc.c +libasm/src/arch/sparc/handlers/asm_sparc_addccc.c +libasm/src/arch/sparc/handlers/asm_sparc_and.c +libasm/src/arch/sparc/handlers/asm_sparc_andcc.c +libasm/src/arch/sparc/handlers/asm_sparc_andn.c +libasm/src/arch/sparc/handlers/asm_sparc_andncc.c +libasm/src/arch/sparc/handlers/asm_sparc_bicc.c +libasm/src/arch/sparc/handlers/asm_sparc_bpcc.c +libasm/src/arch/sparc/handlers/asm_sparc_bpr.c +libasm/src/arch/sparc/handlers/asm_sparc_call.c +libasm/src/arch/sparc/handlers/asm_sparc_casa.c +libasm/src/arch/sparc/handlers/asm_sparc_casxa.c +libasm/src/arch/sparc/handlers/asm_sparc_done.c +libasm/src/arch/sparc/handlers/asm_sparc_fbfcc.c +libasm/src/arch/sparc/handlers/asm_sparc_fbpfcc.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmpd.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmped.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmpeq.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmpes.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmpq.c +libasm/src/arch/sparc/handlers/asm_sparc_fcmps.c +libasm/src/arch/sparc/handlers/asm_sparc_flush.c +libasm/src/arch/sparc/handlers/asm_sparc_flushw.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovdcc.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovdr.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovqcc.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovqr.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovscc.c +libasm/src/arch/sparc/handlers/asm_sparc_fmovsr.c +libasm/src/arch/sparc/handlers/asm_sparc_fpop1.c +libasm/src/arch/sparc/handlers/asm_sparc_illegal.c +libasm/src/arch/sparc/handlers/asm_sparc_illtrap.c +libasm/src/arch/sparc/handlers/asm_sparc_impdep1.c +libasm/src/arch/sparc/handlers/asm_sparc_impdep2.c +libasm/src/arch/sparc/handlers/asm_sparc_jmpl.c +libasm/src/arch/sparc/handlers/asm_sparc_ldd.c +libasm/src/arch/sparc/handlers/asm_sparc_ldda.c +libasm/src/arch/sparc/handlers/asm_sparc_lddf.c +libasm/src/arch/sparc/handlers/asm_sparc_lddfa.c +libasm/src/arch/sparc/handlers/asm_sparc_ldf.c +libasm/src/arch/sparc/handlers/asm_sparc_ldfa.c +libasm/src/arch/sparc/handlers/asm_sparc_ldfsr.c +libasm/src/arch/sparc/handlers/asm_sparc_ldqf.c +libasm/src/arch/sparc/handlers/asm_sparc_ldqfa.c +libasm/src/arch/sparc/handlers/asm_sparc_ldsb.c +libasm/src/arch/sparc/handlers/asm_sparc_ldsba.c +libasm/src/arch/sparc/handlers/asm_sparc_ldsh.c +libasm/src/arch/sparc/handlers/asm_sparc_ldsha.c +libasm/src/arch/sparc/handlers/asm_sparc_ldstub.c +libasm/src/arch/sparc/handlers/asm_sparc_ldstuba.c +libasm/src/arch/sparc/handlers/asm_sparc_ldsw.c +libasm/src/arch/sparc/handlers/asm_sparc_ldswa.c +libasm/src/arch/sparc/handlers/asm_sparc_ldub.c +libasm/src/arch/sparc/handlers/asm_sparc_lduba.c +libasm/src/arch/sparc/handlers/asm_sparc_lduh.c +libasm/src/arch/sparc/handlers/asm_sparc_lduha.c +libasm/src/arch/sparc/handlers/asm_sparc_lduw.c +libasm/src/arch/sparc/handlers/asm_sparc_lduwa.c +libasm/src/arch/sparc/handlers/asm_sparc_ldx.c +libasm/src/arch/sparc/handlers/asm_sparc_ldxa.c +libasm/src/arch/sparc/handlers/asm_sparc_movcc.c +libasm/src/arch/sparc/handlers/asm_sparc_movr.c +libasm/src/arch/sparc/handlers/asm_sparc_mulscc.c +libasm/src/arch/sparc/handlers/asm_sparc_mulx.c +libasm/src/arch/sparc/handlers/asm_sparc_or.c +libasm/src/arch/sparc/handlers/asm_sparc_orcc.c +libasm/src/arch/sparc/handlers/asm_sparc_orn.c +libasm/src/arch/sparc/handlers/asm_sparc_orncc.c +libasm/src/arch/sparc/handlers/asm_sparc_popc.c +libasm/src/arch/sparc/handlers/asm_sparc_prefetch.c +libasm/src/arch/sparc/handlers/asm_sparc_prefetcha.c +libasm/src/arch/sparc/handlers/asm_sparc_rd.c +libasm/src/arch/sparc/handlers/asm_sparc_rdpr.c +libasm/src/arch/sparc/handlers/asm_sparc_restore.c +libasm/src/arch/sparc/handlers/asm_sparc_return.c +libasm/src/arch/sparc/handlers/asm_sparc_save.c +libasm/src/arch/sparc/handlers/asm_sparc_saved.c +libasm/src/arch/sparc/handlers/asm_sparc_sdiv.c +libasm/src/arch/sparc/handlers/asm_sparc_sdivcc.c +libasm/src/arch/sparc/handlers/asm_sparc_sdivx.c +libasm/src/arch/sparc/handlers/asm_sparc_sethi.c +libasm/src/arch/sparc/handlers/asm_sparc_sll.c +libasm/src/arch/sparc/handlers/asm_sparc_smul.c +libasm/src/arch/sparc/handlers/asm_sparc_smulcc.c +libasm/src/arch/sparc/handlers/asm_sparc_sra.c +libasm/src/arch/sparc/handlers/asm_sparc_srl.c +libasm/src/arch/sparc/handlers/asm_sparc_stb.c +libasm/src/arch/sparc/handlers/asm_sparc_stba.c +libasm/src/arch/sparc/handlers/asm_sparc_std.c +libasm/src/arch/sparc/handlers/asm_sparc_stda.c +libasm/src/arch/sparc/handlers/asm_sparc_stdf.c +libasm/src/arch/sparc/handlers/asm_sparc_stdfa.c +libasm/src/arch/sparc/handlers/asm_sparc_stf.c +libasm/src/arch/sparc/handlers/asm_sparc_stfa.c +libasm/src/arch/sparc/handlers/asm_sparc_stfsr.c +libasm/src/arch/sparc/handlers/asm_sparc_sth.c +libasm/src/arch/sparc/handlers/asm_sparc_stha.c +libasm/src/arch/sparc/handlers/asm_sparc_stqf.c +libasm/src/arch/sparc/handlers/asm_sparc_stqfa.c +libasm/src/arch/sparc/handlers/asm_sparc_stw.c +libasm/src/arch/sparc/handlers/asm_sparc_stwa.c +libasm/src/arch/sparc/handlers/asm_sparc_stx.c +libasm/src/arch/sparc/handlers/asm_sparc_stxa.c +libasm/src/arch/sparc/handlers/asm_sparc_sub.c +libasm/src/arch/sparc/handlers/asm_sparc_subc.c +libasm/src/arch/sparc/handlers/asm_sparc_subcc.c +libasm/src/arch/sparc/handlers/asm_sparc_subccc.c +libasm/src/arch/sparc/handlers/asm_sparc_swap.c +libasm/src/arch/sparc/handlers/asm_sparc_swapa.c +libasm/src/arch/sparc/handlers/asm_sparc_taddcc.c +libasm/src/arch/sparc/handlers/asm_sparc_taddcctv.c +libasm/src/arch/sparc/handlers/asm_sparc_tcc.c +libasm/src/arch/sparc/handlers/asm_sparc_tsubcc.c +libasm/src/arch/sparc/handlers/asm_sparc_tsubcctv.c +libasm/src/arch/sparc/handlers/asm_sparc_udiv.c +libasm/src/arch/sparc/handlers/asm_sparc_udivcc.c +libasm/src/arch/sparc/handlers/asm_sparc_udivx.c +libasm/src/arch/sparc/handlers/asm_sparc_umul.c +libasm/src/arch/sparc/handlers/asm_sparc_umulcc.c +libasm/src/arch/sparc/handlers/asm_sparc_wr.c +libasm/src/arch/sparc/handlers/asm_sparc_wrpr.c +libasm/src/arch/sparc/handlers/asm_sparc_xnor.c +libasm/src/arch/sparc/handlers/asm_sparc_xnorcc.c +libasm/src/arch/sparc/handlers/asm_sparc_xor.c +libasm/src/arch/sparc/handlers/asm_sparc_xorcc.c +libasm/src/arch/sparc/init_sparc.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_cc.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_disp30.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_displacement.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_fregister.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_imm_address.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_immediate.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_pregister.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_reg_address.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_register.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sethi.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_fetch_sregister.c +libasm/src/arch/sparc/operand_handlers/asm_sparc_op_name.c +libasm/src/arch/sparc/output_sparc.c +libasm/src/arch/sparc/register.c +libasm/src/arch/sparc/sparc_convert.c +libasm/src/arch/sparc/tables_sparc.c +libasm/src/build.c +libasm/src/error.c +libasm/src/generic.c +libasm/src/instruction.c +libasm/src/operand.c +libasm/src/output.c +libasm/src/register.c +libasm/src/vectors.c +libasm/testsuite/api/Makefile +libasm/testsuite/api/test_instr_name.c +libasm/testsuite/arm/build.sh +libasm/testsuite/arm/disasm.esh +libasm/testsuite/arm/sanity_big.s +libasm/testsuite/arm/sanity_small.s +libasm/testsuite/ia32/ae.asm +libasm/testsuite/ia32/bugs.asm +libasm/testsuite/ia32/fwait.asm +libasm/testsuite/ia32/ja.asm +libasm/testsuite/ia32/launch_test.sh +libasm/testsuite/ia32/memory.asm +libasm/testsuite/ia32/mov.asm +libasm/testsuite/ia32/seta.asm +libasm/testsuite/ia32/shl.asm +libasm/testsuite/parse.py +libasm/testsuite/sparc/build.sh +libasm/testsuite/sparc/test.as +libasm/testsuite/tools/get_assembly.sh +libasm/testsuite/unittest/build.sh +libasm/testsuite/unittest/test_call16.c +libasm/testsuite/unittest/test_groups.c +libasm/testsuite/unittest/test_libasm_support.c +libasm/testsuite/unittest/test_op_mov_reg_iv.c +libasm/tools/libasm-config.template +libasm/tools/modrm.c +libasm/tools/mydisasm.c +libaspect/Makefile +libaspect/config.c +libaspect/containers.c +libaspect/doc/doxygen.conf +libaspect/include/aproxy.h +libaspect/include/libaspect-btree.h +libaspect/include/libaspect-hash.h +libaspect/include/libaspect-list.h +libaspect/include/libaspect-profiler.h +libaspect/include/libaspect.h +libaspect/init.c +libaspect/libbtree.c +libaspect/libhash.c +libaspect/liblist.c +libaspect/profiler.c +libaspect/types.c +libaspect/vectors.c +libdump/Makefile +libdump/doc/DUMP-draft +libdump/doc/TODO +libdump/dump.c +libdump/dump_main.c +libdump/include/libdump.h +libdump/recv.c +libdump/send.c +libe2dbg/Makefile +libe2dbg/common/Makefile +libe2dbg/common/backtrace.c +libe2dbg/common/breakpoints.c +libe2dbg/common/common.c +libe2dbg/common/dbghooks.c +libe2dbg/common/delete.c +libe2dbg/common/display.c +libe2dbg/common/dumpregs.c +libe2dbg/common/linkmap.c +libe2dbg/common/mode.c +libe2dbg/common/mutex.c +libe2dbg/common/stack.c +libe2dbg/include/libe2dbg.h +libe2dbg/kernel/Makefile +libe2dbg/kernel/buffering.c +libe2dbg/kernel/commands.c +libe2dbg/kernel/idt.c +libe2dbg/kernel/include/ke2dbg-config.h +libe2dbg/kernel/include/ke2dbg-font256.h +libe2dbg/kernel/include/ke2dbg-keyb.h +libe2dbg/kernel/include/ke2dbg-pci.h +libe2dbg/kernel/include/ke2dbg-pcidata.h +libe2dbg/kernel/include/ke2dbg-syscalls.h +libe2dbg/kernel/include/ke2dbg-vars.h +libe2dbg/kernel/include/ke2dbg.h +libe2dbg/kernel/interrupts.c +libe2dbg/kernel/kentry.c +libe2dbg/kernel/kern-bp.c +libe2dbg/kernel/keyboard.c +libe2dbg/kernel/libasm-enums.err +libe2dbg/kernel/libc-wrapper.c +libe2dbg/kernel/page.c +libe2dbg/kernel/pci.c +libe2dbg/kernel/ports.c +libe2dbg/kernel/strings.c +libe2dbg/kernel/syscalls.c +libe2dbg/kernel/utils.c +libe2dbg/kernel/video.c +libe2dbg/user/Makefile +libe2dbg/user/alloc-proxy.c +libe2dbg/user/continue.c +libe2dbg/user/dbg-amd64.c +libe2dbg/user/dbg-ia32.c +libe2dbg/user/dbg-mips.c +libe2dbg/user/dbg-sparc32.c +libe2dbg/user/delbreak.c +libe2dbg/user/e2dbg-misc.c +libe2dbg/user/e2dbg.c +libe2dbg/user/entry.c +libe2dbg/user/init.c +libe2dbg/user/linkmap.c +libe2dbg/user/register.c +libe2dbg/user/resolv.c +libe2dbg/user/signal.c +libe2dbg/user/step.c +libe2dbg/user/threads.c +libedfmt/Makefile +libedfmt/api.c +libedfmt/doc/doxygen.conf +libedfmt/dwarf2-abbrev.c +libedfmt/dwarf2-cfa.c +libedfmt/dwarf2-trans.c +libedfmt/dwarf2-utils.c +libedfmt/dwarf2.c +libedfmt/edfmt-utils.c +libedfmt/edfmt.c +libedfmt/include/libedfmt-api.h +libedfmt/include/libedfmt-dwarf2.h +libedfmt/include/libedfmt-stabs.h +libedfmt/include/libedfmt.h +libedfmt/stabs-trans.c +libedfmt/stabs-utils.c +libedfmt/stabs.c +libelfsh/Makefile +libelfsh/alpha64.c +libelfsh/altgot.c +libelfsh/altplt.c +libelfsh/bp.c +libelfsh/bss.c +libelfsh/bt.c +libelfsh/comment.c +libelfsh/copy.c +libelfsh/ctors.c +libelfsh/debug.c +libelfsh/doc/doxygen.conf +libelfsh/dtors.c +libelfsh/dumpregs.c +libelfsh/dwarf.c +libelfsh/dynamic.c +libelfsh/dynsym.c +libelfsh/elf.c +libelfsh/extplt.c +libelfsh/fixup.c +libelfsh/got.c +libelfsh/hash.c +libelfsh/hijack.c +libelfsh/hooks.c +libelfsh/ia32.c +libelfsh/ia64.c +libelfsh/include/libelfsh.h +libelfsh/include/libelfsh/libelfsh-alpha.h +libelfsh/include/libelfsh/libelfsh-bsd.h +libelfsh/include/libelfsh/libelfsh-compat.h +libelfsh/include/libelfsh/libelfsh-cray.h +libelfsh/include/libelfsh/libelfsh-hppa.h +libelfsh/include/libelfsh/libelfsh-ia32.h +libelfsh/include/libelfsh/libelfsh-ia64.h +libelfsh/include/libelfsh/libelfsh-irix.h +libelfsh/include/libelfsh/libelfsh-mips.h +libelfsh/include/libelfsh/libelfsh-ppc.h +libelfsh/include/libelfsh/libelfsh-sparc.h +libelfsh/include/libelfsh/libelfsh-sunos.h +libelfsh/include/libelfsh/libelfsh-versions.h +libelfsh/inject.c +libelfsh/interp.c +libelfsh/linkmap.c +libelfsh/map.c +libelfsh/mips32.c +libelfsh/mips64.c +libelfsh/notes.c +libelfsh/obj.c +libelfsh/pax.c +libelfsh/pht.c +libelfsh/plt.c +libelfsh/raw.c +libelfsh/reginfo.c +libelfsh/relinject.c +libelfsh/reloc.c +libelfsh/remap.c +libelfsh/rpht.c +libelfsh/runtime.c +libelfsh/sanitize.c +libelfsh/save.c +libelfsh/search.c +libelfsh/section.c +libelfsh/sht.c +libelfsh/sht_rebuild.c +libelfsh/sort.c +libelfsh/sparc32.c +libelfsh/sparc64.c +libelfsh/stab.c +libelfsh/state.c +libelfsh/strip.c +libelfsh/strtab.c +libelfsh/sym_common.c +libelfsh/symbol.c +libelfsh/vectors_call.c +libelfsh/vectors_default.c +libelfsh/vectors_fetch.c +libelfsh/vectors_register.c +libelfsh/version.c +libetrace/Makefile +libetrace/check.c +libetrace/check_untracable.c +libetrace/delete.c +libetrace/errfunc.c +libetrace/func_add.c +libetrace/func_disable.c +libetrace/func_enable.c +libetrace/func_exclude.c +libetrace/func_match.c +libetrace/func_remove.c +libetrace/func_run.c +libetrace/func_search.c +libetrace/func_status.c +libetrace/include/libetrace-intvars.h +libetrace/include/libetrace.h +libetrace/save.c +libetrace/search.c +libetrace/search_addr.c +libetrace/trace_create.c +libetrace/trace_flush.c +libetrace/trace_list.c +libetrace/trace_run.c +libgdbwrap/Makefile +libgdbwrap/client.c +libgdbwrap/doc/HOWTO.txt +libgdbwrap/doc/_gdbremote.c +libgdbwrap/doc/gdbserialproto.txt +libgdbwrap/gdbwrapper.c +libgdbwrap/include/gdbwrapper-internals.h +libgdbwrap/include/gdbwrapper.h +libgdbwrap/interface.c +libkernsh/Makefile +libkernsh/TODO +libkernsh/common/Makefile +libkernsh/common/autotypes.c +libkernsh/common/dump.c +libkernsh/common/gdt.c +libkernsh/common/hash.c +libkernsh/common/idt.c +libkernsh/common/memory.c +libkernsh/common/sct.c +libkernsh/common/vectors.c +libkernsh/common/vectors_default.c +libkernsh/common/vectors_register.c +libkernsh/doc/doxygen.conf +libkernsh/include/libkernsh-virtm.h +libkernsh/include/libkernsh.h +libkernsh/kernel/Makefile +libkernsh/kernel/arch/x86/Makefile +libkernsh/kernel/arch/x86/linux/Makefile +libkernsh/kernel/arch/x86/linux/mem.c +libkernsh/kernel/arch/x86/linux/misc.c +libkernsh/kernel/arch/x86/linux/page.c +libkernsh/kernel/arch/x86/linux/virtm.c +libkernsh/kernel/include/libkernsh-kernel-linux.h +libkernsh/kernel/include/libkernsh-kernel.h +libkernsh/modules/Makefile +libkernsh/modules/arch/x86/Makefile +libkernsh/modules/arch/x86/linux/Makefile +libkernsh/modules/arch/x86/linux/kernsh-virtm.c +libkernsh/user/Makefile +libkernsh/user/alloc.c +libkernsh/user/kcore.c +libkernsh/user/kernimage.c +libkernsh/user/kernsh.c +libkernsh/user/kmem.c +libkernsh/user/kvirtm.c +libkernsh/user/mem.c +libkernsh/user/misc.c +libkernsh/user/module.c +libkernsh/user/symbols/Makefile +libkernsh/user/symbols/bin2hex.pl +libkernsh/user/symbols/kfree.c +libkernsh/user/symbols/kmalloc.c +libkernsh/user/symbols/vfree.c +libkernsh/user/symbols/vmalloc.c +libkernsh/user/symbs.c +libmjollnir/Makefile +libmjollnir/bin/Makefile +libmjollnir/bin/elfThor.c +libmjollnir/doc/doxygen.conf +libmjollnir/include/libmjollnir-int.h +libmjollnir/include/libmjollnir-objects.h +libmjollnir/include/libmjollnir.h +libmjollnir/src/blocks.c +libmjollnir/src/cfg.c +libmjollnir/src/container.c +libmjollnir/src/core.c +libmjollnir/src/destroy.c +libmjollnir/src/display.c +libmjollnir/src/findentry.c +libmjollnir/src/fingerprint.c +libmjollnir/src/function.c +libmjollnir/src/history.c +libmjollnir/src/init.c +libmjollnir/src/links.c +libmjollnir/src/ondisk.c +libmjollnir/src/symtab.c +libmjollnir/tools/desDiff.pl +libmjollnir/tools/mjollnirUnitTest.c +libmjollnir/tools/mkDb.sh +libmjollnir/tools/tests/makeit.sh +libmjollnir/tools/tests/system.inc +libmjollnir/tools/tests/test-1.asm +libmjollnir/tools/tests/test-calls.asm +libmjollnir/tools/tests/test-calls.esh +libmjollnir/tools/tests/test-calls.gdb +libmjollnir/tools/tests/test-jumps.asm +libmjollnir/tools/tests/test-jumps.esh +libregex/Makefile +libregex/regcomp.c +libregex/regex.c +libregex/regex.h +libregex/regex_internal.c +libregex/regex_internal.h +libregex/regexec.c +librevm/Makefile +librevm/api/Makefile +librevm/api/asmproc.c +librevm/api/atomic.c +librevm/api/commands.c +librevm/api/doswitch.c +librevm/api/edfmt.c +librevm/api/filter.c +librevm/api/helping.c +librevm/api/implicit.c +librevm/api/inform.c +librevm/api/job.c +librevm/api/misc.c +librevm/api/modlist.c +librevm/api/printing.c +librevm/api/screen.c +librevm/api/sourcing.c +librevm/api/stringtable.c +librevm/api/typing.c +librevm/doc/doxygen.conf +librevm/include/librevm-color.h +librevm/include/revm-debug.h +librevm/include/revm-io.h +librevm/include/revm-objects.h +librevm/include/revm.h +librevm/io/Makefile +librevm/io/color.c +librevm/io/curjob.c +librevm/io/input.c +librevm/io/io.c +librevm/io/log.c +librevm/io/network.c +librevm/io/output.c +librevm/io/prompt.c +librevm/io/readln.c +librevm/io/select.c +librevm/lang/Makefile +librevm/lang/access.c +librevm/lang/arith.c +librevm/lang/convert.c +librevm/lang/expressions.c +librevm/lang/grammar.c +librevm/lang/lookup.c +librevm/lang/objects.c +librevm/lang/options.c +librevm/lang/parser.c +librevm/lang/scanner.c +librevm/lang/variables.c +librevm/vm/Makefile +librevm/vm/fini.c +librevm/vm/init.c +librevm/vm/loop.c +librevm/vm/misc-revm.c +librevm/vm/tables.c +libstderesi/Makefile +libstderesi/analysis/Makefile +libstderesi/analysis/argcount.c +libstderesi/analysis/debug.c +libstderesi/analysis/fcthijack.c +libstderesi/analysis/flow.c +libstderesi/analysis/flowjack.c +libstderesi/analysis/graph.c +libstderesi/analysis/hammer.c +libstderesi/analysis/inspect.c +libstderesi/analysis/match.c +libstderesi/analysis/trace.c +libstderesi/cmd/Makefile +libstderesi/cmd/cat.c +libstderesi/cmd/color.c +libstderesi/cmd/configure.c +libstderesi/cmd/define.c +libstderesi/cmd/eval.c +libstderesi/cmd/exec.c +libstderesi/cmd/help.c +libstderesi/cmd/info.c +libstderesi/cmd/init.c +libstderesi/cmd/job.c +libstderesi/cmd/log.c +libstderesi/cmd/modules.c +libstderesi/cmd/net.c +libstderesi/cmd/prefixes.c +libstderesi/cmd/print.c +libstderesi/cmd/proc.c +libstderesi/cmd/profile.c +libstderesi/cmd/quit.c +libstderesi/cmd/script.c +libstderesi/cmd/source.c +libstderesi/cmd/utils.c +libstderesi/doc/doxygen.conf +libstderesi/elf/Makefile +libstderesi/elf/api.c +libstderesi/elf/comment.c +libstderesi/elf/core.c +libstderesi/elf/ctors.c +libstderesi/elf/data.c +libstderesi/elf/deps.c +libstderesi/elf/disasm.c +libstderesi/elf/dtors.c +libstderesi/elf/dyn.c +libstderesi/elf/findrel.c +libstderesi/elf/flush.c +libstderesi/elf/got.c +libstderesi/elf/hash.c +libstderesi/elf/hdr.c +libstderesi/elf/interp.c +libstderesi/elf/notes.c +libstderesi/elf/pht.c +libstderesi/elf/rel.c +libstderesi/elf/sht.c +libstderesi/elf/sym.c +libstderesi/elf/version.c +libstderesi/files/Makefile +libstderesi/files/fileops.c +libstderesi/files/insert.c +libstderesi/files/list.c +libstderesi/files/load.c +libstderesi/files/reladd.c +libstderesi/files/remove.c +libstderesi/files/save.c +libstderesi/files/switch.c +libstderesi/files/unload.c +libstderesi/include/libstderesi-help.h +libstderesi/include/libstderesi.h +libstderesi/lang/Makefile +libstderesi/lang/atomic.c +libstderesi/lang/foreach.c +libstderesi/lang/jmp.c +libstderesi/lang/return.c +libstderesi/lang/vlist.c +libstderesi/type/Makefile +libstderesi/type/declare.c +libstderesi/type/hashes.c +libstderesi/type/inform.c +libstderesi/type/lists.c +libstderesi/type/reflect.c +libstderesi/type/sets.c +libstderesi/type/types.c +libstderesi/type/vectors.c +libui/Makefile +libui/color.c +libui/doc/doxygen.conf +libui/include/libui.h +libui/readln.c +modules/Makefile +modules/modremap.c +modules/modtest.c +testsuite/Makefile +testsuite/README +testsuite/debugging/Makefile +testsuite/debugging/backtrace.esh +testsuite/debugging/binaries-multithreads/Makefile +testsuite/debugging/binaries-multithreads/libtest.c +testsuite/debugging/binaries-multithreads/test-threads.c +testsuite/debugging/binaries-multithreads/test2.c +testsuite/debugging/binaries-multithreads/test3.c +testsuite/debugging/breakpoints.esh +testsuite/debugging/display.esh +testsuite/debugging/etrel_memory/Makefile +testsuite/debugging/etrel_memory/etrelmem.esh +testsuite/debugging/etrel_memory/host.c +testsuite/debugging/etrel_memory/myputs.c +testsuite/debugging/etrel_memory/script.sh +testsuite/debugging/itrace.esh +testsuite/debugging/libedfmt/Makefile +testsuite/debugging/libedfmt/load/Makefile +testsuite/debugging/libedfmt/load/test_usage.c +testsuite/debugging/libedfmt/srcline/Makefile +testsuite/debugging/libedfmt/srcline/test_usage.c +testsuite/debugging/libedfmt/stackframes/Makefile +testsuite/debugging/libedfmt/stackframes/test_usage.c +testsuite/debugging/mem.esh +testsuite/debugging/regs.esh +testsuite/debugging/stack.esh +testsuite/debugging/step.esh +testsuite/debugging/threads.esh +testsuite/elf/Makefile +testsuite/elf/ctors_hijack/Makefile +testsuite/elf/ctors_hijack/ctors_hijack.c +testsuite/elf/ctors_hijack/hijacked.c +testsuite/elf/dtors_hijack/Makefile +testsuite/elf/dtors_hijack/dtors_hijack.c +testsuite/elf/dtors_hijack/hijacked.c +testsuite/elf/elf-tests.esh +testsuite/elf/etrel_inject/Makefile +testsuite/elf/etrel_inject/etrel_extplt/Makefile +testsuite/elf/etrel_inject/etrel_extplt/debug.esh +testsuite/elf/etrel_inject/etrel_extplt/etrel_inject.c +testsuite/elf/etrel_inject/etrel_extplt/gdb.script +testsuite/elf/etrel_inject/etrel_extplt/host.c +testsuite/elf/etrel_inject/etrel_extplt/rel.c +testsuite/elf/etrel_inject/etrel_extplt/relinject32.esh +testsuite/elf/etrel_inject/etrel_extplt/relinject64.esh +testsuite/elf/etrel_inject/etrel_extstatic/Makefile +testsuite/elf/etrel_inject/etrel_extstatic/host.c +testsuite/elf/etrel_inject/etrel_extstatic/rel2.c +testsuite/elf/etrel_inject/etrel_extstatic/relinject.esh +testsuite/elf/etrel_inject/etrel_original/Makefile +testsuite/elf/etrel_inject/etrel_original/alphabins/gdb.script +testsuite/elf/etrel_inject/etrel_original/alphabins/host1.c +testsuite/elf/etrel_inject/etrel_original/alphabins/host2.c +testsuite/elf/etrel_inject/etrel_original/alphabins/host3.c +testsuite/elf/etrel_inject/etrel_original/debug.esh +testsuite/elf/etrel_inject/etrel_original/etrel_inject.c +testsuite/elf/etrel_inject/etrel_original/gdb.script +testsuite/elf/etrel_inject/etrel_original/host.c +testsuite/elf/etrel_inject/etrel_original/rel.c +testsuite/elf/etrel_inject/etrel_original/relinject32.esh +testsuite/elf/etrel_inject/etrel_original/relinject64.esh +testsuite/elf/etrel_inject/etrel_original/session +testsuite/elf/etrel_inject/etrel_pie-ssp/Makefile +testsuite/elf/etrel_inject/etrel_pie-ssp/host.c +testsuite/elf/etrel_inject/etrel_pie-ssp/relinject.esh +testsuite/elf/etrel_inject/etrel_pie-ssp/simple.c +testsuite/elf/etrel_inject/etrel_static/Makefile +testsuite/elf/etrel_inject/etrel_static/host.c +testsuite/elf/etrel_inject/etrel_static/rel.c +testsuite/elf/etrel_inject/etrel_static/relinject32.esh +testsuite/elf/etrel_inject/etrel_static/relinject64.esh +testsuite/elf/extract_raw_data/Makefile +testsuite/elf/extract_raw_data/load.c +testsuite/elf/got_hijack/Makefile +testsuite/elf/got_hijack/got_hijack.c +testsuite/elf/got_hijack/hijacked.c +testsuite/elf/hash_retreive/Makefile +testsuite/elf/hash_retreive/hash_read.c +testsuite/elf/hash_retreive/main.c +testsuite/elf/insert_tests.esh +testsuite/elf/remap_script.esh +testsuite/elf/sct_fillbss_injection/Makefile +testsuite/elf/sct_fillbss_injection/main.c +testsuite/elf/sct_fillbss_injection/section_inject.c +testsuite/elf/sct_index_injection/Makefile +testsuite/elf/sct_index_injection/main.c +testsuite/elf/sct_index_injection/section_inject.c +testsuite/elf/sct_top_injection/Makefile +testsuite/elf/sct_top_injection/main.c +testsuite/elf/sct_top_injection/section_inject.c +testsuite/elf/sct_unmapped_injection/Makefile +testsuite/elf/sct_unmapped_injection/main.c +testsuite/elf/sct_unmapped_injection/section_inject.c +testsuite/elf/sections_flush.esh +testsuite/elf/sht_rebuild/Makefile +testsuite/elf/sht_rebuild/sht_rebuild.c +testsuite/elf/sht_stripping/Makefile +testsuite/elf/sht_stripping/main.c +testsuite/elf/sht_stripping/sht_removing.c +testsuite/elf/symtab_extend/Makefile +testsuite/elf/symtab_extend/execve.s +testsuite/elf/symtab_extend/main.c +testsuite/elf/symtab_extend/symtab_extend.c +testsuite/interface/alert.esh +testsuite/interface/workspace.esh +testsuite/kernel_instrumentation/kernsh-script.esh +testsuite/kernel_instrumentation/print_syscalltable.esh +testsuite/scripting/declare-bitfields.esh +testsuite/scripting/declare-unions.esh +testsuite/scripting/declare.esh +testsuite/scripting/defines.esh +testsuite/scripting/doublevar.esh +testsuite/scripting/dynamic-naming-list.esh +testsuite/scripting/dynamic-naming.esh +testsuite/scripting/endian.esh +testsuite/scripting/expr-arith.esh +testsuite/scripting/factorial-withret.esh +testsuite/scripting/factorial.esh +testsuite/scripting/foreach-ending.esh +testsuite/scripting/foreach-hashes.esh +testsuite/scripting/foreach-linearity.esh +testsuite/scripting/foreach-list-simple.esh +testsuite/scripting/foreach-lists.esh +testsuite/scripting/foreach-nested.esh +testsuite/scripting/foreach-reference.esh +testsuite/scripting/foreach-shadow.esh +testsuite/scripting/loop.esh +testsuite/scripting/myparams.esh +testsuite/scripting/params.esh +testsuite/scripting/params2.esh +testsuite/scripting/rewrite-simple.esh +testsuite/scripting/script-lists.esh +testsuite/scripting/script-tables.esh +testsuite/scripting/script-types.esh +testsuite/scripting/strings_tests.esh +testsuite/scripting/subtyping.esh +testsuite/scripting/test-set.esh +testsuite/static_analysis/Makefile +testsuite/static_analysis/binaries/Makefile +testsuite/static_analysis/binaries/bin.c +testsuite/static_analysis/binaries/libfunc.c +testsuite/static_analysis/binaries/pRel.py +testsuite/static_analysis/evarista/1.simple_appel_de_methode.cpp +testsuite/static_analysis/evarista/10.modification_de_champ_dans_une_methode.cpp +testsuite/static_analysis/evarista/11.appel_force_de_methode_mere_surchargee.cpp +testsuite/static_analysis/evarista/12.heritage_simple_avec_appel_de_methode.cpp +testsuite/static_analysis/evarista/13.heritage_simple_avec_appel_methode_de_classe_mere.cpp +testsuite/static_analysis/evarista/14.heritage_simple_avec_appel_methode_virtuelle.cpp +testsuite/static_analysis/evarista/15.heritage_simple_avec_parent_field_modif.cpp +testsuite/static_analysis/evarista/16.signature_new_delete.cpp +testsuite/static_analysis/evarista/17.template_simple.cpp +testsuite/static_analysis/evarista/18.signature_stdio.cpp +testsuite/static_analysis/evarista/19.signature_vector.cpp +testsuite/static_analysis/evarista/2.simple_utilisation_de_champ_public.cpp +testsuite/static_analysis/evarista/20.signature_list.cpp +testsuite/static_analysis/evarista/21.signature_iterator.cpp +testsuite/static_analysis/evarista/22.signature_map.cpp +testsuite/static_analysis/evarista/23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp +testsuite/static_analysis/evarista/24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp +testsuite/static_analysis/evarista/25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp +testsuite/static_analysis/evarista/26.heritage_multiple_avec_appel_de_methodes_parentes.cpp +testsuite/static_analysis/evarista/27.heritage_de_classe_template.cpp +testsuite/static_analysis/evarista/28.interprocedural_loop_array_copy.cpp +testsuite/static_analysis/evarista/29.loop_3conds_with_dowhile.cpp +testsuite/static_analysis/evarista/3.simple_utilisation_de_pointeur.cpp +testsuite/static_analysis/evarista/30.compounds_with_gotos_and_loop.cpp +testsuite/static_analysis/evarista/31.simple_types_recovery.cpp +testsuite/static_analysis/evarista/32.n-dimentional-objects-arrays.cpp +testsuite/static_analysis/evarista/33.interprocedural_struct_access.cpp +testsuite/static_analysis/evarista/34.interprocedural_heap_corruption_static.c +testsuite/static_analysis/evarista/35.simple-heap-corruption.c +testsuite/static_analysis/evarista/36.simple-global-heap-corruption.c +testsuite/static_analysis/evarista/4.simple_utilisation_de_reference.cpp +testsuite/static_analysis/evarista/5.simple_interprocedural.cpp +testsuite/static_analysis/evarista/6.utilisation_pointeur_interprocedural.cpp +testsuite/static_analysis/evarista/7.interprocedural_reference.cpp +testsuite/static_analysis/evarista/8.interprocedural_reference_2.cpp +testsuite/static_analysis/evarista/9.heritage_multiple_avec_appel_de_methodes_filles.cpp +testsuite/static_analysis/evarista/Makefile +testsuite/static_analysis/evarista/eva-test.esh +testsuite/static_analysis/graph-tests.esh +testsuite/static_analysis/mjollnir/Makefile +testsuite/static_analysis/mjollnir/eva-test.esh +testsuite/static_analysis/mjollnir/simple-test.esh +testsuite/static_analysis/mjollnir/test-moredepth.c +testsuite/static_analysis/mjollnir/test-ptrfn1.c +testsuite/static_analysis/mjollnir/test-ptrfn2.c +testsuite/static_analysis/mjollnir/test-ptrfn3.c +testsuite/static_analysis/mjollnir/test-recur.c +testsuite/static_instrumentation/Makefile +testsuite/static_instrumentation/flowjack/Makefile +testsuite/static_instrumentation/flowjack/infected.c +testsuite/static_instrumentation/flowjack/patch-both32.esh +testsuite/static_instrumentation/flowjack/patch-both64.esh +testsuite/static_instrumentation/flowjack/patch-rec32.esh +testsuite/static_instrumentation/flowjack/patch-rec64.esh +testsuite/static_instrumentation/flowjack/patch32.esh +testsuite/static_instrumentation/flowjack/patch64.esh +testsuite/static_instrumentation/flowjack/recursivite.c +testsuite/static_instrumentation/flowjack/target.c +testsuite/static_instrumentation/printarrays/print_array.esh +testsuite/static_instrumentation/printarrays/test-multidim-arrays.c +testsuite/tracing/Makefile +testsuite/tracing/host.c +testsuite/tracing/trace.esh +testsuite/tracing/tracer.c +wordswap diff -Nru eresi-0.8a25/modules/Makefile eresi-0.0.20110516/modules/Makefile --- eresi-0.8a25/modules/Makefile 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/modules/Makefile 2011-05-16 11:34:46.000000000 +0000 @@ -1,40 +1,61 @@ ## -## Makefile for modules in elfsh +## Makefile for modules in ERESI ## ## Started on Wed Feb 19 08:20:54 2003 jfv -## Last update Wed Dec 10 14:47:58 2006 jfv +## $Id: Makefile 1309 2009-01-14 18:41:02Z may $ ## include ../config.h SRC = modtest.c -OBJ = $(SRC:.c=.o) -NAM = modtest.so +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +NAM32 = modtest32.so +NAM64 = modtest64.so + +RSRC = modremap.c +ROBJ32 = $(RSRC:.c=.32.o) +RNAM32 = modremap32.so +ROBJ64 = $(RSRC:.c=.64.o) +RNAM64 = modremap64.so + +CFLAGS = -I../librevm/include/ -I../libhash/include/ -I../libui/include/ \ + -I../libdump/include/ -I../libelfsh/include/ -I../libaspect/include \ + -I../libasm/include/ -I../e2dbg/include/ -I../libc/include/ \ + -I../libmjollnir/include/ -I../libedfmt/include/ -I../libstderesi/include/ \ + -I../libetrace/include/ -Wall -g3 -O2 -fPIC $(DYNOPT) \ + $(BITS) $(NCURSESLNOPT) $(READLNOPT) $(BUILDOP) -SRC3 = modremap.c -OBJ3 = $(SRC3:.c=.o) -NAM3 = modremap.so - -CFLAGS = -I../librevm/include/ -I../libhash/include/ -I../libui/include/ \ - -I../libdump/include/ -I../libelfsh/include/ -I../libaspect/include \ - -I../libasm/include/ -I../e2dbg/include/ -I../libc/include/ \ - -I../libmjollnir/include/ -I../libedfmt/include/ -I../libstderesi/include/ \ - -Wall -g3 -O2 -fPIC -DELFSH_INTERN $(DYNOPT) $(BITS) $(NCURSESLNOPT) \ - $(READLNOPT) $(BUILDOP) +CFLAGS32=$(CFLAGS) -DERESI32 +CFLAGS64=$(CFLAGS) -DERESI64 CC = gcc LD = gcc -all : test remap +all64 : test64 remap64 +all32 : test32 remap32 +all : all32 all64 -test : $(OBJ) - @$(LD) $(BITS) -shared $(OBJ) -o $(NAM) +test32 : $(OBJ32) + @$(LD) $(BITS) -shared $(OBJ32) -o $(NAM32) -remap : $(OBJ3) - @$(LD) $(BITS) -shared $(OBJ3) -o $(NAM3) +remap32 : $(ROBJ32) + @$(LD) $(BITS) -shared $(ROBJ32) -o $(RNAM32) + +test64 : $(OBJ64) + @$(LD) $(BITS) -shared $(OBJ64) -o $(NAM64) + +remap64 : $(ROBJ64) + @$(LD) $(BITS) -shared $(ROBJ64) -o $(RNAM64) clean : - @rm -f $(OBJ) $(OBJ3) *~ *\# \#* .\#* + @rm -f $(OBJ32) $(ROBJ32) $(OBJ64) $(ROBJ64) *~ *\# \#* .\#* fclean : clean @rm -f *.so + +%.32.o : %.c + $(CC) $(CFLAGS32) -c -o $@ $< + +%.64.o : %.c + $(CC) $(CFLAGS64) -c -o $@ $< \ No newline at end of file diff -Nru eresi-0.8a25/modules/modremap.c eresi-0.0.20110516/modules/modremap.c --- eresi-0.8a25/modules/modremap.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/modremap.c 2011-05-16 11:34:46.000000000 +0000 @@ -11,7 +11,7 @@ ** ** Fixed by ELFsh crew for the ELFsh project ** -** $Id: modremap.c,v 1.5 2008-02-16 12:32:27 thor Exp $ +** $Id: modremap.c 1311 2009-01-14 20:36:48Z may $ ** */ #include "libstderesi.h" diff -Nru eresi-0.8a25/modules/modtest.c eresi-0.0.20110516/modules/modtest.c --- eresi-0.8a25/modules/modtest.c 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/modtest.c 2011-05-16 11:34:46.000000000 +0000 @@ -4,7 +4,7 @@ ** Started on Wed Feb 19 08:20:07 2003 jfv ** Last update Thu Mar 4 20:21:56 2004 jfv ** -** $Id: modtest.c,v 1.5 2008-02-16 12:32:27 thor Exp $ +** $Id: modtest.c 1311 2009-01-14 20:36:48Z may $ ** */ #include "libstderesi.h" @@ -36,14 +36,14 @@ void elfsh_init() { puts(" [*] ELFsh modtest init -OK- \n"); - revm_command_set(CMD_PRINT, mod_print, ELFSH_ORIG, (u_int) ELFSH_ORIG); + revm_command_set(CMD_PRINT, mod_print, ERESI_ORIG, (u_int) ERESI_ORIG); revm_command_add(CMD_MYTEST, mod_newcmd, NULL, 0, "Simple example command"); } void elfsh_fini() { puts(" [*] ELFsh modtest fini -OK- \n"); - revm_command_set(CMD_PRINT, cmd_print, ELFSH_ORIG, (u_int) ELFSH_ORIG); + revm_command_set(CMD_PRINT, cmd_print, ERESI_ORIG, (u_int) ERESI_ORIG); revm_command_del(CMD_MYTEST); } diff -Nru eresi-0.8a25/modules/.svn/all-wcprops eresi-0.0.20110516/modules/.svn/all-wcprops --- eresi-0.8a25/modules/.svn/all-wcprops 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 31 -/svn/!svn/ver/843/trunk/modules -END -modtest.c -K 25 -svn:wc:ra_dav:version-url -V 41 -/svn/!svn/ver/843/trunk/modules/modtest.c -END -modremap.c -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/843/trunk/modules/modremap.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 40 -/svn/!svn/ver/843/trunk/modules/Makefile -END diff -Nru eresi-0.8a25/modules/.svn/entries eresi-0.0.20110516/modules/.svn/entries --- eresi-0.8a25/modules/.svn/entries 2008-04-06 23:16:26.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/modules -http://svn.eresi-project.org/svn - - - -2008-02-16T12:32:28.000000Z -843 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -modtest.c -file - - - - -2008-04-06T23:16:25.987881Z -75280ccfd8c134acafd8b2beb945b5cb -2008-02-16T12:32:28.000000Z -843 -thor - -modremap.c -file - - - - -2008-04-06T23:16:25.998237Z -740a3a265cd182a341d672dd82b0bd21 -2008-02-16T12:32:28.000000Z -843 -thor - -Makefile -file - - - - -2008-04-06T23:16:26.008899Z -de4d2419c4b158533b8ca4aa32e4dca4 -2008-02-16T12:32:28.000000Z -843 -thor - diff -Nru eresi-0.8a25/modules/.svn/format eresi-0.0.20110516/modules/.svn/format --- eresi-0.8a25/modules/.svn/format 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/modules/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/modules/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/modules/.svn/text-base/Makefile.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,40 +0,0 @@ -## -## Makefile for modules in elfsh -## -## Started on Wed Feb 19 08:20:54 2003 jfv -## Last update Wed Dec 10 14:47:58 2006 jfv -## - -include ../config.h - -SRC = modtest.c -OBJ = $(SRC:.c=.o) -NAM = modtest.so - -SRC3 = modremap.c -OBJ3 = $(SRC3:.c=.o) -NAM3 = modremap.so - -CFLAGS = -I../librevm/include/ -I../libhash/include/ -I../libui/include/ \ - -I../libdump/include/ -I../libelfsh/include/ -I../libaspect/include \ - -I../libasm/include/ -I../e2dbg/include/ -I../libc/include/ \ - -I../libmjollnir/include/ -I../libedfmt/include/ -I../libstderesi/include/ \ - -Wall -g3 -O2 -fPIC -DELFSH_INTERN $(DYNOPT) $(BITS) $(NCURSESLNOPT) \ - $(READLNOPT) $(BUILDOP) - -CC = gcc -LD = gcc - -all : test remap - -test : $(OBJ) - @$(LD) $(BITS) -shared $(OBJ) -o $(NAM) - -remap : $(OBJ3) - @$(LD) $(BITS) -shared $(OBJ3) -o $(NAM3) - -clean : - @rm -f $(OBJ) $(OBJ3) *~ *\# \#* .\#* - -fclean : clean - @rm -f *.so diff -Nru eresi-0.8a25/modules/.svn/text-base/modremap.c.svn-base eresi-0.0.20110516/modules/.svn/text-base/modremap.c.svn-base --- eresi-0.8a25/modules/.svn/text-base/modremap.c.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/text-base/modremap.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,120 +0,0 @@ -/* -** modremap.c for elfsh -** -** Coded by spacewalker, grace day of 14th March 2003 -** -** THIS CODE IS EXPERIMENTAL ! -** -** It cannot remap some binaries because of existing false -** positives in the ET_EXEC relocation code . Finally -** merged in libelfsh/mapped.c -** -** Fixed by ELFsh crew for the ELFsh project -** -** $Id: modremap.c,v 1.5 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -#define CMD_REMAP "remap" - - -int remap_cmd() -{ - elfshobj_t *file; - elfshsect_t *cur; - u_int new_base; - u_int real_base = 0xffffffff; - int diff; - int i; - int cnt; - u_int count_raw = 0; - u_int count_pht = 0; - u_int count_sht = 0; - u_int count_ent = 0; - - PROFILER_IN(__FILE__, __FUNCTION__, __LINE__); - - /* Sanity checks */ - i = sscanf(world.curjob->curcmd->param[0], "0x%X", &new_base); - if (new_base == 0 || i != 1) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Invalid new base address", -1); - file = world.curjob->curfile; - - if (elfsh_read_obj(file) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to read object file", -1); - - if (elfsh_get_symtab(file, NULL) < 0) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Unable to read symbol table", -1); - - /* Calculate delta */ - real_base = elfsh_get_object_baseaddr(file); - if (real_base == 0xffffffff) - PROFILER_ERR(__FILE__, __FUNCTION__, __LINE__, - "Base address not found", -1); - - if (new_base & 0xfff) - { - revm_output(" [*] Base address adapted to be congruent pagesize \n"); - new_base &= 0xfffff000; - } - diff = new_base - real_base; - printf(" [*] Delta is %08X \n", diff); - - /* Update entry point */ - if (file->hdr->e_entry > real_base) - { - file->hdr->e_entry += diff; - count_ent++; - } - - /* For all sections of the current object */ - for (cur = file->sectlist; cur != NULL; cur = cur->next) - { - cnt = elfsh_relocate_section(cur, diff); - if (cnt < 0) - { - printf(" [*] MODREMAP : Section %s wont be relocated\n", cur->name); - continue; - } - count_raw += cnt; - } - - /* Fixup SHT */ - count_sht += elfsh_reloc_sht(file, diff); - - /* Fixup PHT */ - count_pht += elfsh_reloc_pht(file, diff); - - /* Print msg */ - printf(" [*] Total number of modified references : %u \n" - "\t PHT relocation : %u \n" - "\t SHT relocation : %u \n" - "\t ENT relocation : %u \n" - "\t RAW relocation : %u \n", - count_pht + count_sht + count_ent + count_raw, - count_pht , count_sht , count_ent , count_raw); - printf(" [*] Remapping at base %08X -OK-\n\n", new_base); - - PROFILER_ROUT(__FILE__, __FUNCTION__, __LINE__, 0); -} - -void elfsh_init() -{ - revm_output(" [*] ELFsh modremap init -OK- \n"); - revm_command_add(CMD_REMAP, remap_cmd, revm_getoption, 1, - "Try to remap a non-relocatable file"); -} - -void elfsh_fini() -{ - revm_output(" [*] ELFsh modremap fini -OK- \n"); - revm_command_del(CMD_REMAP); -} - - - diff -Nru eresi-0.8a25/modules/.svn/text-base/modtest.c.svn-base eresi-0.0.20110516/modules/.svn/text-base/modtest.c.svn-base --- eresi-0.8a25/modules/.svn/text-base/modtest.c.svn-base 2008-04-06 23:16:25.000000000 +0000 +++ eresi-0.0.20110516/modules/.svn/text-base/modtest.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/* -** modtest.c for elfsh -** -** Started on Wed Feb 19 08:20:07 2003 jfv -** Last update Thu Mar 4 20:21:56 2004 jfv -** -** $Id: modtest.c,v 1.5 2008-02-16 12:32:27 thor Exp $ -** -*/ -#include "libstderesi.h" - - -/* ELFSH_DECMD(mod_newcmd); */ - - -#define CMD_MYTEST "cmdtest" - -int mod_print() -{ - puts("\n [*] I do control the print command and you wont use it :P \n"); - return (0); -} - -int mod_newcmd() -{ - puts("\n [*] This is a new command, oh no ! \n"); - return (0); -} - - -void elfsh_help() -{ - printf("Simple help handler for modtest ...\n"); -} - -void elfsh_init() -{ - puts(" [*] ELFsh modtest init -OK- \n"); - revm_command_set(CMD_PRINT, mod_print, ELFSH_ORIG, (u_int) ELFSH_ORIG); - revm_command_add(CMD_MYTEST, mod_newcmd, NULL, 0, "Simple example command"); -} - -void elfsh_fini() -{ - puts(" [*] ELFsh modtest fini -OK- \n"); - revm_command_set(CMD_PRINT, cmd_print, ELFSH_ORIG, (u_int) ELFSH_ORIG); - revm_command_del(CMD_MYTEST); -} - diff -Nru eresi-0.8a25/README.FIRST eresi-0.0.20110516/README.FIRST --- eresi-0.8a25/README.FIRST 2008-04-06 23:16:31.000000000 +0000 +++ eresi-0.0.20110516/README.FIRST 2011-05-16 11:35:08.000000000 +0000 @@ -1,5 +1,5 @@ -FIXME: This file is not updated to ERESI ! TO DO ASAP +FIXME: This file is not updated to ERESI 0.8 ! TO DO ASAP ------------------- ELFSH 0.65rc2-linux diff -Nru eresi-0.8a25/testsuite/ctors_hijack/ctors_hijack.c eresi-0.0.20110516/testsuite/ctors_hijack/ctors_hijack.c --- eresi-0.8a25/testsuite/ctors_hijack/ctors_hijack.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/ctors_hijack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:47:22 2002 jfv -** -** $Id: ctors_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_ctors; - int ret; - - - file = elfsh_map_obj(TROJANED_FILE); - new_ctors = elfsh_get_symbol_by_name(file, "new_ctors"); - if (!file || !new_ctors) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR CTORS HIJACKING *****************/ - /***********************************************************/ - - //ret = elfsh_set_ctors_entry_by_index(file, 1, new_ctors->st_value); - ret = elfsh_set_ctors_entry_by_name(file, "my_ctors", new_ctors->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/ctors_hijack/hijacked.c eresi-0.0.20110516/testsuite/ctors_hijack/hijacked.c --- eresi-0.8a25/testsuite/ctors_hijack/hijacked.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** hijacked.c for elfsh -** -** Started on Sun Mar 10 02:41:10 2002 jfv -** Last update Sun Mar 10 02:54:44 2002 jfv -** -** $Id: hijacked.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include - - -void my_ctors() __attribute__ ((constructor)); - - -void new_ctors() -{ - printf("hijacked ctors ! \n"); -} - - -void my_ctors() -{ - printf("My ctors ! \n"); - -} - -int main() -{ - printf("Main ! \n"); -} diff -Nru eresi-0.8a25/testsuite/ctors_hijack/Makefile eresi-0.0.20110516/testsuite/ctors_hijack/Makefile --- eresi-0.8a25/testsuite/ctors_hijack/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:54:50 2002 jfv -## - -include ../../config.h - -SRC = ctors_hijack.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace/ -letrace32 -NAM = ctors_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) -o $(NAM) $(LIB) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/all-wcprops eresi-0.0.20110516/testsuite/ctors_hijack/.svn/all-wcprops --- eresi-0.8a25/testsuite/ctors_hijack/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/871/trunk/testsuite/ctors_hijack -END -hijacked.c -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/749/trunk/testsuite/ctors_hijack/hijacked.c -END -ctors_hijack.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/749/trunk/testsuite/ctors_hijack/ctors_hijack.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/871/trunk/testsuite/ctors_hijack/Makefile -END diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/entries eresi-0.0.20110516/testsuite/ctors_hijack/.svn/entries --- eresi-0.8a25/testsuite/ctors_hijack/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/ctors_hijack -http://svn.eresi-project.org/svn - - - -2008-02-29T09:29:49.203930Z -871 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -hijacked.c -file - - - - -2008-04-06T23:15:40.258131Z -e598c5697808e25895339254b22b764b -2007-07-31T03:28:48.000000Z -749 -may - -ctors_hijack.c -file - - - - -2008-04-06T23:15:40.267903Z -839355f29aedc8e6d08991b25bb2689b -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:40.279899Z -a593acb7d3c0af6ff9a046deedc5dccf -2008-02-29T09:29:49.203930Z -871 -enioh -has-props - diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/format eresi-0.0.20110516/testsuite/ctors_hijack/.svn/format --- eresi-0.8a25/testsuite/ctors_hijack/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/ctors_hijack/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/ctors_hijack/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/ctors_hijack.c.svn-base eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/ctors_hijack.c.svn-base --- eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/ctors_hijack.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/ctors_hijack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,57 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:47:22 2002 jfv -** -** $Id: ctors_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_ctors; - int ret; - - - file = elfsh_map_obj(TROJANED_FILE); - new_ctors = elfsh_get_symbol_by_name(file, "new_ctors"); - if (!file || !new_ctors) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR CTORS HIJACKING *****************/ - /***********************************************************/ - - //ret = elfsh_set_ctors_entry_by_index(file, 1, new_ctors->st_value); - ret = elfsh_set_ctors_entry_by_name(file, "my_ctors", new_ctors->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/hijacked.c.svn-base eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/hijacked.c.svn-base --- eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/hijacked.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/hijacked.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/* -** hijacked.c for elfsh -** -** Started on Sun Mar 10 02:41:10 2002 jfv -** Last update Sun Mar 10 02:54:44 2002 jfv -** -** $Id: hijacked.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include - - -void my_ctors() __attribute__ ((constructor)); - - -void new_ctors() -{ - printf("hijacked ctors ! \n"); -} - - -void my_ctors() -{ - printf("My ctors ! \n"); - -} - -int main() -{ - printf("Main ! \n"); -} diff -Nru eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/ctors_hijack/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/ctors_hijack/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:54:50 2002 jfv -## - -include ../../config.h - -SRC = ctors_hijack.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace/ -letrace32 -NAM = ctors_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) -o $(NAM) $(LIB) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/debugging/backtrace.esh eresi-0.0.20110516/testsuite/debugging/backtrace.esh --- eresi-0.8a25/testsuite/debugging/backtrace.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/backtrace.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,16 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +linkmap +bt +cont +linkmap +bt +delete free +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/binaries-multithreads/libtest.c eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/libtest.c --- eresi-0.8a25/testsuite/debugging/binaries-multithreads/libtest.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/libtest.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,45 @@ +/* +** +** $Id: libtest.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +void *print_message_function_lib( void *ptr ) +{ + char *message; + int idx; + + for (idx = 0; 1; idx++) + { + message = (char *) malloc(42); + fprintf(stderr, "%s: (thread id = %u LIBTHREAD) new chunk addr %08X stack var addr %08X\n", + ptr, pthread_self(), message, &message); + sleep(1); + } +} + + +void print_lib() +{ + while (1) + { + fprintf(stderr, "coucou print_lib (thread id = %u) no malloc here \n", + pthread_self()); + sleep(1); + } +} + + +void test_lib() +{ + pthread_t thread4; + + fprintf(stderr, "begin test_lib\n"); + pthread_create( &thread4, NULL, (void *) print_lib, NULL); + pthread_join( thread4, NULL); + fprintf(stderr, "end test_lib\n"); +} diff -Nru eresi-0.8a25/testsuite/debugging/binaries-multithreads/Makefile eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/Makefile --- eresi-0.8a25/testsuite/debugging/binaries-multithreads/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,28 @@ +# +# +# + +CC ?= gcc +NAME = allocproxy +BINAME32 = debugme-mt +BINAME64 = debugme-mt64 + +all32: all + +all: + $(CC) -fPIC libtest.c -Iinclude -c + $(CC) -g3 libtest.o -L. -shared -o libtest.so -L../../../liballocproxy/ -l$(NAME) + $(CC) -g3 -fPIC test-threads.c -Iinclude -L. -ltest -lpthread -L../../../liballocproxy \ + -l$(NAME) -o $(BINAME32) + +all64: + $(CC) -fPIC libtest.c -Iinclude -c -m64 + $(CC) -g3 libtest.o -L. -shared -o libtest.so -L../../../liballocproxy/ -l$(NAME) -m64 + $(CC) -g3 -fPIC test-threads.c -Iinclude -L. -ltest -lpthread -L../../../liballocproxy \ + -l$(NAME) -o $(BINAME64) -m64 + +clean: + rm -f *.o *~ + +fclean: clean + rm -f *.so $(BINAME32) $(BINAME64) diff -Nru eresi-0.8a25/testsuite/debugging/binaries-multithreads/test2.c eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test2.c --- eresi-0.8a25/testsuite/debugging/binaries-multithreads/test2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test2.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,76 @@ +/* +** +** $Id: test2.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include +#include + +pthread_t thread1, thread2; +char *message1 = "T1"; +char *message2 = "T2"; + +typedef void (*sighandler_t)(int); + + +int sigtrap_handler(int signum) +{ + int tid; + + tid = pthread_self(); + fprintf(stderr, "Received SIGTRAP in thread %u \n", tid); + if (tid == thread1) + pthread_kill(thread2, SIGUSR2); + else + pthread_kill(thread1, SIGUSR2); + usleep(50000); + fprintf(stderr, "<---- outside sigtrap handler for %u \n", tid); + return (0); +} + +int sigusr2_handler(int signum) +{ + int tid; + + tid = pthread_self(); + fprintf(stderr, "Received SIGUSR2 in thread %u \n", tid); + usleep(50000); + fprintf(stderr, "<---- outside sigusr2 handler for %u \n", tid); + return (0); +} + +void* thread_func(void *str) +{ + while (1) + { + if (!strcmp((char *) str, message2)) + pthread_kill(thread1, SIGTRAP); + else + pthread_kill(thread2, SIGTRAP); + fprintf(stderr, "%s\n", (char *) str); + sleep(1); + } +} + +int main(int argc, char **argv) +{ + int iret1, iret2; + struct sigaction ac; + + bzero((void *) &ac, sizeof(ac)); + ac.sa_sigaction = (void *) sigtrap_handler; + sigaction(SIGTRAP, &ac, NULL); + ac.sa_sigaction = (void *) sigusr2_handler; + sigaction(SIGUSR2, &ac, NULL); + + iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); + iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); + retry: + fprintf(stderr, "Now sleeping\n"); + sleep(30); + goto retry; + return (0); +} diff -Nru eresi-0.8a25/testsuite/debugging/binaries-multithreads/test3.c eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test3.c --- eresi-0.8a25/testsuite/debugging/binaries-multithreads/test3.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test3.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,58 @@ +/* +** +** $Id: test3.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +pthread_t thread1, thread2; +char *message1 = "T1"; +char *message2 = "T2"; + +typedef void (*sighandler_t)(int); + + +int sigtrap_handler(int signum) +{ + fprintf(stderr, "Received SIGTRAP in thread %u ! \n", pthread_self()); + pthread_kill(thread2, SIGSTOP); + sleep(2); + fprintf(stderr, "<---- outside sigtrap handler \n"); + return (0); +} + +int sigstop_handler(int signum) +{ + fprintf(stderr, "Received SIGSTOP in thread %u ! \n", pthread_self()); + fprintf(stderr, "<---- outside sigstop handler \n"); + return (0); +} + +void* thread_func(void *str) +{ + while (1) + { + if (!strcmp((char *) str, message2)) + pthread_kill(thread1, SIGTRAP); + fprintf(stderr, "%s\n", (char *) str); + sleep(1); + } +} + +int main(int argc, char **argv) +{ + int iret1, iret2; + + signal(SIGTRAP, (sighandler_t) sigtrap_handler); + signal(SIGSTOP, (sighandler_t) sigstop_handler); + iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); + iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); + retry: + fprintf(stderr, "Now sleeping\n"); + sleep(30); + goto retry; + return (0); +} diff -Nru eresi-0.8a25/testsuite/debugging/binaries-multithreads/test-threads.c eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test-threads.c --- eresi-0.8a25/testsuite/debugging/binaries-multithreads/test-threads.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/binaries-multithreads/test-threads.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,79 @@ +/* +** +** $Id: test-threads.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +void *print_message_function(void *ptr); + +extern void *print_message_function_lib(void *); + +typedef void (*sighandler_t)(int); + + +void sigtrap_handler(int num) +{ + printf("Received a SIGTRAP ! Waiting 5 secondes and continue ... \n"); + sleep(5); +} + +void sigstop_handler(int num) +{ + printf("Received a SIGSTOP ! \n"); +} + +void sigusr2_handler(int num) +{ + printf("Received a SIGUSR2 ! \n"); +} + +main() +{ + pthread_t thread1, thread2, thread3; + char *message1 = "Thread 1"; + char *message2 = "Thread 2"; + char *message3 = "Thread 3"; + int iret1, iret2, iret3; + + //signal(SIGTRAP, (sighandler_t) sigtrap_handler); + //signal(SIGSTOP, (sighandler_t) sigstop_handler); + //signal(SIGUSR2, (sighandler_t) sigusr2_handler); + + iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1); + iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2); + iret3 = pthread_create( &thread3, NULL, print_message_function_lib, (void*) message3); + + test_lib(); + + /* Wait till threads are complete before main continues. Unless we */ + /* wait we run the risk of executing an exit which will terminate */ + /* the process and all threads before the threads have completed. */ + pthread_join( thread1, NULL); + pthread_join( thread2, NULL); + pthread_join( thread3, NULL); + + fprintf(stderr, "Thread 1 returns: %d\n",iret1); + fprintf(stderr, "Thread 2 returns: %d\n",iret2); + fprintf(stderr, "Thread 3 returns: %d\n",iret3); + exit(0); +} + + + + +void *print_message_function( void *ptr ) +{ + char *message; + + while (1) + { + message = malloc(42); + printf("%s: (thread id = %u LIBTHREAD) message addr %08X message var: %08X\n", + ptr, pthread_self(), message, &message); + sleep(1); + } +} diff -Nru eresi-0.8a25/testsuite/debugging/breakpoints.esh eresi-0.0.20110516/testsuite/debugging/breakpoints.esh --- eresi-0.8a25/testsuite/debugging/breakpoints.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/breakpoints.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +cont +delete free +cont +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/display.esh eresi-0.0.20110516/testsuite/debugging/display.esh --- eresi-0.8a25/testsuite/debugging/display.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/display.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,15 @@ +#!../../e2dbg/e2dbg32 + +b malloc +display 1 got malloc +b free +display 2 got free +start +cont +delete free +cont +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/etrel_memory/etrelmem.esh eresi-0.0.20110516/testsuite/debugging/etrel_memory/etrelmem.esh --- eresi-0.8a25/testsuite/debugging/etrel_memory/etrelmem.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/etrel_memory/etrelmem.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,11 @@ +#!e2dbg + +load myputs.o +switch a.out +mode dynamic +reladd a.out muputs.o +profile enable warn +redir puts myputs +profile disable warn + + diff -Nru eresi-0.8a25/testsuite/debugging/etrel_memory/host.c eresi-0.0.20110516/testsuite/debugging/etrel_memory/host.c --- eresi-0.8a25/testsuite/debugging/etrel_memory/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/etrel_memory/host.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,53 @@ +/* +** +** $Id: host.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + char buff[BUFSIZ]; + + snprintf(buff, BUFSIZ, "coucou %s\n", str); + printf("LEGIT FUNC\n"); + printf("legit func (%s) !\n", str); + return (0); +} + +int main(int argc, char **argv) +{ + char *str; + char buff[BUFSIZ]; + + printf ("[host] main argc %d\n", argc); + printf("[host] argv[0] is : %s\n", argv[0]); + + if (argc == 2) + printf("[host] argv[1] is : %s\n", argv[1]); + + //read(0, buff, BUFSIZ-1); + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf %s\n", str); + + free(str); + + puts("Second_puts"); + + fflush(stdout); + legit_func("test"); + return (0); + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/debugging/etrel_memory/Makefile eresi-0.0.20110516/testsuite/debugging/etrel_memory/Makefile --- eresi-0.8a25/testsuite/debugging/etrel_memory/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/etrel_memory/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,35 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## +## + +include ../../../config.h + +CC ?= gcc +RM = rm -f + +HOSTSRC = host.c +RELSRC = rel.c +RELOBJ = rel.o +RTSRC = myputs.c +RTOBJ = myputs.o +PIEBIN = pie-test + +OPT = -fPIC -g3 -O2 -I../../../libelfsh/include/ -I../../../libmjollnir/include/ \ + -I../../../libaspect/include/ $(BITS) -DERESI32 +CFLAGS = $(OPT) + +all32: all +all : $(OBJ) + $(CC) $(OPT) $(HOSTSRC) + $(CC) $(OPT) $(HOSTSRC) -pie -o $(PIEBIN) + $(CC) $(OPT) $(RTSRC) -o $(RTOBJ) -c + @echo Now run etrelmem.esh inside e2dbg + +clean : + $(RM) $(RTOBJ) $(OBJ) *~ \#* *\# $(RELOBJ) + +fclean : clean + $(RM) $(NAM) a.out $(PIEBIN) diff -Nru eresi-0.8a25/testsuite/debugging/etrel_memory/myputs.c eresi-0.0.20110516/testsuite/debugging/etrel_memory/myputs.c --- eresi-0.8a25/testsuite/debugging/etrel_memory/myputs.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/etrel_memory/myputs.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,26 @@ +/* +** $Id: myputs.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +int myputs(char *str) +{ + printf("Hijacked puts !!! arg = %s \n", str); + putchar('e'); + putchar('x'); + putchar('t'); + putchar('c'); + putchar('a'); + putchar('l'); + putchar('l'); + putchar('!'); + putchar('\n'); + return (old_puts(str)); +} + +int new_legit_func(char *str) +{ + printf("Hijacked legit_func !!! (param = %s) \n", str); + return (old_legit_func(str)); +} diff -Nru eresi-0.8a25/testsuite/debugging/etrel_memory/script.sh eresi-0.0.20110516/testsuite/debugging/etrel_memory/script.sh --- eresi-0.8a25/testsuite/debugging/etrel_memory/script.sh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/etrel_memory/script.sh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,38 @@ +#!/bin/sh + +test $# -ne 1 && echo "usage : "$0" file" && exit 0 + +DT=`../../../vm/elfsh -f $1 -d | grep DT_DEBUG | awk -F"[][]" '{ print $2;}'` + +PRG=$1 + +echo "#!../../../vm/elfsh" > inject_e2dbg.esh +echo "load "$1 >> inject_e2dbg.esh +echo "set 1.dynamic["$DT"].val 0x2" >> inject_e2dbg.esh +echo "set 1.dynamic["$DT"].tag DT_NEEDED" >> inject_e2dbg.esh +echo "redir main e2dbg_run" >> inject_e2dbg.esh +echo "save "$1"_e2dbg" >> inject_e2dbg.esh +echo "" >> inject_e2dbg.esh + +echo "#!../../../vm/elfsh" > etrelmem.esh +echo "load myputs.o" >> etrelmem.esh +echo "switch 1" >> etrelmem.esh +echo "mode dynamic" >> etrelmem.esh +echo "reladd 1 10" >> etrelmem.esh +#echo "quiet s" >> etrelmem.esh +echo "profile" >> etrelmem.esh +echo "redir puts myputs" >> etrelmem.esh +#echo "redir printf e2dbg_sigint_handler" >> etrelmem.esh +echo "profile" >> etrelmem.esh +echo "" >> etrelmem.esh + +chmod ugo+x inject_e2dbg.esh + +./inject_e2dbg.esh > inject_e2dbg.out + +/sbin/paxctl -p -m -s -r -x $PRG"_e2dbg" + +./$PRG"_e2dbg" + + + diff -Nru eresi-0.8a25/testsuite/debugging/itrace.esh eresi-0.0.20110516/testsuite/debugging/itrace.esh --- eresi-0.8a25/testsuite/debugging/itrace.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/itrace.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +itrace +delete free +itrace +delete malloc +itrace +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/load/Makefile eresi-0.0.20110516/testsuite/debugging/libedfmt/load/Makefile --- eresi-0.8a25/testsuite/debugging/libedfmt/load/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/load/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,28 @@ +SRCS = test_usage.c +OBJS = test_usage.o +NAME = main + +CFLAGS = -I../../../../libedfmt/include \ + -I../../../../libaspect/include \ + -I../../../../libelfsh/include \ + -DERESI32 \ + -gdwarf-2 + +LDFLAGS = -L../../../../libedfmt/ -ledfmt32 \ + -L../../../../libelfsh -lelfsh32 \ + -L../../../../libaspect -laspect32 \ + -L../../../../libasm/ -lasm32 \ + -L../../../../libetrace -letrace32 -g-dwarf2 + +RM = rm -fr +CC ?= gcc + +all32: all +all: ${OBJS} + ${CC} -o $(NAME) ${OBJS} ${LDFLAGS} + +clean: + rm -f ${OBJS} + +fclean: clean + $(RM) $(NAME) \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/load/test_usage.c eresi-0.0.20110516/testsuite/debugging/libedfmt/load/test_usage.c --- eresi-0.8a25/testsuite/debugging/libedfmt/load/test_usage.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/load/test_usage.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,29 @@ +#include +#include + + +int main(int ac, char **av) +{ + + elfshobj_t *obj; + edfmtdw2info_t *info; + int to_ret; + + obj = elfsh_map_obj(av[0]); + if (!obj) + { + printf("failed loading %s\n", av[0]); + to_ret = -1; + goto error_label; + } + edfmt_format(obj); + edfmt_dwarf2_parse(obj); + if (info = edfmt_dwarf2_getinfo(obj)) + printf("Succesfully loaded DWARF2 format information\n"); + else + printf("Failed to load DWARF2 format information\n"); + + to_ret = 0; + error_label: + return (to_ret); +} diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/Makefile eresi-0.0.20110516/testsuite/debugging/libedfmt/Makefile --- eresi-0.8a25/testsuite/debugging/libedfmt/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,28 @@ +## +## Makefile for libedfmt testsuite in ERESI +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +all : all32 all64 + +all32 : + $(MAKE) -C load all32 + $(MAKE) -C srcline all32 + $(MAKE) -C stackframes all32 + +all64 : + $(MAKE) -C load all64 + $(MAKE) -C srcline all64 + $(MAKE) -C stackframes all64 + +clean : + $(MAKE) -C load clean + $(MAKE) -C srcline clean + $(MAKE) -C stackframes clean + +fclean : clean + $(MAKE) -C load fclean + $(MAKE) -C srcline fclean + $(MAKE) -C stackframes fclean diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/srcline/Makefile eresi-0.0.20110516/testsuite/debugging/libedfmt/srcline/Makefile --- eresi-0.8a25/testsuite/debugging/libedfmt/srcline/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/srcline/Makefile 2011-05-16 11:35:00.000000000 +0000 @@ -0,0 +1,28 @@ +SRCS = test_usage.c +OBJS = test_usage.o +NAME = main + +CFLAGS = -I../../../../libedfmt/include \ + -I../../../../libaspect/include \ + -I../../../../libelfsh/include \ + -DERESI32 \ + -gdwarf-2 + +LDFLAGS = -L../../../../libedfmt/ -ledfmt32 \ + -L../../../../libelfsh -lelfsh32 \ + -L../../../../libaspect -laspect32 \ + -L../../../../libasm/ -lasm32 \ + -L../../../../libetrace -letrace32 -g-dwarf2 + +RM = rm -fr +CC ?= gcc + +all32: all +all: ${OBJS} + ${CC} -o $(NAME) ${OBJS} ${LDFLAGS} + +clean: + rm -f ${OBJS} + +fclean: clean + $(RM) $(NAME) \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/srcline/test_usage.c eresi-0.0.20110516/testsuite/debugging/libedfmt/srcline/test_usage.c --- eresi-0.8a25/testsuite/debugging/libedfmt/srcline/test_usage.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/srcline/test_usage.c 2011-05-16 11:35:00.000000000 +0000 @@ -0,0 +1,59 @@ +/* +** test_usage.c for source level debugging tests in ERESI +** +** Initial version by Eduardo Franklin - 2009 +** $Id$ +*/ +#include +#include + + +int main(int ac, char **av) +{ + elfshobj_t *obj; + edfmtdw2info_t *info; + int to_ret; + hash_t *htable; + char **keys; + int keynbr; + edfmtfunc_t *lfunc; + int index; + + obj = elfsh_map_obj(av[1]); + if (!obj) + { + printf("failed loading %s\n", av[1]); + to_ret = -1; + goto error_label; + } + edfmt_format(obj); + edfmt_dwarf2_parse(obj); + if (info = edfmt_dwarf2_getinfo(obj)) + printf("Succesfully loaded DWARF2 format information\n"); + else + printf("Failed to load DWARF2 format information\n"); + + htable = edfmt_hfuncs_get(); + keys = hash_get_keys(&htable, &keynbr); + printf("keynbr = %d\n", &keynbr); + if (keys) + { + for (index = 0; index < keynbr; index++) + { + if (htable == NULL || keys[index] == NULL) + { + if(htable == NULL) + { + printf("htable == NULL\n"); + } + return (NULL); + } + lfunc = (edfmtfunc_t *)hash_get(&htable, keys[index]); + printf("here edfmt_srcline_get will be called\n"); + } + } + + to_ret = 0; + error_label: + return (to_ret); +} diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/stackframes/Makefile eresi-0.0.20110516/testsuite/debugging/libedfmt/stackframes/Makefile --- eresi-0.8a25/testsuite/debugging/libedfmt/stackframes/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/stackframes/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,28 @@ +SRCS = test_usage.c +OBJS = test_usage.o +NAME = main + +CFLAGS = -I../../../../libedfmt/include \ + -I../../../../libaspect/include \ + -I../../../../libelfsh/include \ + -DERESI32 \ + -gdwarf-2 + +LDFLAGS = -L../../../../libedfmt/ -ledfmt32 \ + -L../../../../libelfsh -lelfsh32 \ + -L../../../../libaspect -laspect32 \ + -L../../../../libasm/ -lasm32 \ + -L../../../../libetrace -letrace32 -g-dwarf2 + +RM = rm -fr +CC ?= gcc + +all32: all +all: ${OBJS} + ${CC} -o $(NAME) ${OBJS} ${LDFLAGS} + +clean: + rm -f ${OBJS} + +fclean: clean + $(RM) $(NAME) \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/debugging/libedfmt/stackframes/test_usage.c eresi-0.0.20110516/testsuite/debugging/libedfmt/stackframes/test_usage.c --- eresi-0.8a25/testsuite/debugging/libedfmt/stackframes/test_usage.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/libedfmt/stackframes/test_usage.c 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,29 @@ +#include +#include + + +int main(int ac, char **av) +{ + + elfshobj_t *obj; + edfmtdw2info_t *info; + int to_ret; + + obj = elfsh_map_obj(av[0]); + if (!obj) + { + printf("failed loading %s\n", av[0]); + to_ret = -1; + goto error_label; + } + edfmt_format(obj); + edfmt_dwarf2_parse(obj); + if (info = edfmt_dwarf2_getinfo(obj)) + printf("Succesfully loaded DWARF2 format information\n"); + else + printf("Failed to load DWARF2 format information\n"); + + to_ret = 0; + error_label: + return (to_ret); +} diff -Nru eresi-0.8a25/testsuite/debugging/Makefile eresi-0.0.20110516/testsuite/debugging/Makefile --- eresi-0.8a25/testsuite/debugging/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,28 @@ +## +## Makefile for librevm in ERESI +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +all : all32 all64 + +all32 : + $(MAKE) -C binaries-multithreads all32 + $(MAKE) -C libedfmt all32 + $(MAKE) -C etrel_memory all32 + +all64 : + $(MAKE) -C binaries-multithreads all64 + $(MAKE) -C libedfmt all64 + $(MAKE) -C etrel_memory all64 + +clean : + $(MAKE) -C binaries-multithreads clean + $(MAKE) -C libedfmt clean + $(MAKE) -C etrel_memory clean + +fclean : clean + $(MAKE) -C binaries-multithreads fclean + $(MAKE) -C libedfmt fclean + $(MAKE) -C etrel_memory fclean diff -Nru eresi-0.8a25/testsuite/debugging/mem.esh eresi-0.0.20110516/testsuite/debugging/mem.esh --- eresi-0.8a25/testsuite/debugging/mem.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/mem.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,21 @@ +#!/usr/bin/elfsh + +set $addr 1.sht[.data].addr +D $addr%20 +X $addr%20 +write $addr \x90\x90\x90\x90 +D $addr%20 +X $addr%20 + +set $addr 1.sht[.bss].addr +add $addr 1.sht[.bss].size +add $addr 4 + +D $addr%20 +X $addr%20 +write $addr \x90\x90\x90\x90 +D $addr%20 +X $addr%20 + +quit + diff -Nru eresi-0.8a25/testsuite/debugging/regs.esh eresi-0.0.20110516/testsuite/debugging/regs.esh --- eresi-0.8a25/testsuite/debugging/regs.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/regs.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,16 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +dumpregs +set $EAX 0x42424242 +dumpregs +cont +delete free +cont +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/stack.esh eresi-0.0.20110516/testsuite/debugging/stack.esh --- eresi-0.8a25/testsuite/debugging/stack.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/stack.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,15 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +profile enable warn +stack 20 +cont +dbgstack 15 +cont +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/debugging/step.esh eresi-0.0.20110516/testsuite/debugging/step.esh --- eresi-0.8a25/testsuite/debugging/step.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/step.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,28 @@ +#!/usr/bin/elfsh + +#print Number of parameters : $# +#print Param 1 : $1 +#cmp 1 $# +#jne bad +#print Parameter 1 = $1 +#profile enable warn + +b malloc +display 1 got malloc +display 1 print Reached breakpoint at malloc ! + +start +step + +foreach $idx of 0 until 5 + cont +forend + +print Stepped 5 instructions ! +delete 1 +step +quit + +bad: +print You need a parameter +quit diff -Nru eresi-0.8a25/testsuite/debugging/threads.esh eresi-0.0.20110516/testsuite/debugging/threads.esh --- eresi-0.8a25/testsuite/debugging/threads.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/debugging/threads.esh 2011-05-16 11:35:01.000000000 +0000 @@ -0,0 +1,16 @@ +#!../../e2dbg/e2dbg32 + +b malloc +b free +start +threads +cont +dumpregs +threads 2 +dumpregs +delete free +delete malloc +cont +quit + + diff -Nru eresi-0.8a25/testsuite/dtors_hijack/dtors_hijack.c eresi-0.0.20110516/testsuite/dtors_hijack/dtors_hijack.c --- eresi-0.8a25/testsuite/dtors_hijack/dtors_hijack.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/dtors_hijack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:56:20 2002 jfv -** -** $Id: dtors_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_dtors; - int ret; - - - file = elfsh_map_obj(TROJANED_FILE); - new_dtors = elfsh_get_symbol_by_name(file, "new_dtors"); - - if (!file || !new_dtors) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR DTORS HIJACKING *****************/ - /***********************************************************/ - - - //ret = elfsh_set_dtors_entry_by_index(file, 1, new_dtors->st_value); - ret = elfsh_set_dtors_entry_by_name(file, "my_dtors", new_dtors->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - - /* RELINKING THE FILE */ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/dtors_hijack/hijacked.c eresi-0.0.20110516/testsuite/dtors_hijack/hijacked.c --- eresi-0.8a25/testsuite/dtors_hijack/hijacked.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** -** $Id: hijacked.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - - -void my_dtors() __attribute__ ((destructor)); - - -void new_dtors() -{ - printf("hijacked dtors ! \n"); -} - -void my_dtors() -{ - printf("My dtors ! \n"); -} - - -int main() -{ - printf("Main ! Sleeping 5 secs ... \n"); - sleep(5); -} diff -Nru eresi-0.8a25/testsuite/dtors_hijack/Makefile eresi-0.0.20110516/testsuite/dtors_hijack/Makefile --- eresi-0.8a25/testsuite/dtors_hijack/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -## -## Makefile for in -## -## Made by jfv -## Login -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:25 2002 jfv -## - -include ../../config.h - -SRC = dtors_hijack.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = dtors_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ -I../../libaspect/include $(BITS) - -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/all-wcprops eresi-0.0.20110516/testsuite/dtors_hijack/.svn/all-wcprops --- eresi-0.8a25/testsuite/dtors_hijack/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/872/trunk/testsuite/dtors_hijack -END -hijacked.c -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/616/trunk/testsuite/dtors_hijack/hijacked.c -END -dtors_hijack.c -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/749/trunk/testsuite/dtors_hijack/dtors_hijack.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/872/trunk/testsuite/dtors_hijack/Makefile -END diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/entries eresi-0.0.20110516/testsuite/dtors_hijack/.svn/entries --- eresi-0.8a25/testsuite/dtors_hijack/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/dtors_hijack -http://svn.eresi-project.org/svn - - - -2008-02-29T09:30:34.168857Z -872 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -hijacked.c -file - - - - -2008-04-06T23:15:40.427152Z -98ea30d4fbef7430401249297b63480e -2007-05-16T23:36:38.000000Z -616 -may - -dtors_hijack.c -file - - - - -2008-04-06T23:15:40.472132Z -2c03939e0396e5e9369b2392e0a6266c -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:40.484083Z -f6afc14e467db466deca913a406441ea -2008-02-29T09:30:34.168857Z -872 -enioh -has-props - diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/format eresi-0.0.20110516/testsuite/dtors_hijack/.svn/format --- eresi-0.8a25/testsuite/dtors_hijack/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/dtors_hijack/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/dtors_hijack/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/dtors_hijack.c.svn-base eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/dtors_hijack.c.svn-base --- eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/dtors_hijack.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/dtors_hijack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:56:20 2002 jfv -** -** $Id: dtors_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_dtors; - int ret; - - - file = elfsh_map_obj(TROJANED_FILE); - new_dtors = elfsh_get_symbol_by_name(file, "new_dtors"); - - if (!file || !new_dtors) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR DTORS HIJACKING *****************/ - /***********************************************************/ - - - //ret = elfsh_set_dtors_entry_by_index(file, 1, new_dtors->st_value); - ret = elfsh_set_dtors_entry_by_name(file, "my_dtors", new_dtors->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - - /* RELINKING THE FILE */ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/hijacked.c.svn-base eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/hijacked.c.svn-base --- eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/hijacked.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/hijacked.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -/* -** -** $Id: hijacked.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - - -void my_dtors() __attribute__ ((destructor)); - - -void new_dtors() -{ - printf("hijacked dtors ! \n"); -} - -void my_dtors() -{ - printf("My dtors ! \n"); -} - - -int main() -{ - printf("Main ! Sleeping 5 secs ... \n"); - sleep(5); -} diff -Nru eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/dtors_hijack/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/dtors_hijack/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -## -## Makefile for in -## -## Made by jfv -## Login -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:25 2002 jfv -## - -include ../../config.h - -SRC = dtors_hijack.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = dtors_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ -I../../libaspect/include $(BITS) - -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/libtest.c eresi-0.0.20110516/testsuite/e2dbg_multithreads/libtest.c --- eresi-0.8a25/testsuite/e2dbg_multithreads/libtest.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/libtest.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: libtest.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -void *print_message_function_lib( void *ptr ) -{ - char *message; - int idx; - - for (idx = 0; 1; idx++) - { - message = (char *) malloc(42); - fprintf(stderr, "%s: (thread id = %u LIBTHREAD) new chunk addr %08X stack var addr %08X\n", - ptr, pthread_self(), message, &message); - sleep(1); - } -} - - -void print_lib() -{ - while (1) - { - fprintf(stderr, "coucou print_lib (thread id = %u) no malloc here \n", - pthread_self()); - sleep(1); - } -} - - -void test_lib() -{ - pthread_t thread4; - - fprintf(stderr, "begin test_lib\n"); - pthread_create( &thread4, NULL, (void *) print_lib, NULL); - pthread_join( thread4, NULL); - fprintf(stderr, "end test_lib\n"); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/Makefile eresi-0.0.20110516/testsuite/e2dbg_multithreads/Makefile --- eresi-0.8a25/testsuite/e2dbg_multithreads/Makefile 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -# -# -# -# -# -# - -include ../../config.h - -CC ?= gcc -NAME = allocproxy -BINAME = debugme-mt - -all: - $(CC) -fPIC libtest.c -Iinclude -c - $(CC) -g3 libtest.o -L. -shared -o libtest.so -L../../liballocproxy/ -l$(NAME) - $(CC) -g3 -fPIC test-threads.c -Iinclude -L. -ltest -lpthread -L../../liballocproxy -l$(NAME) -o $(BINAME) - -clean: - rm -f *.o *~ - -fclean: clean - rm -f *.so $(BINAME) diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/all-wcprops eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/all-wcprops --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 52 -/svn/!svn/ver/585/trunk/testsuite/e2dbg_multithreads -END -test2.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/512/trunk/testsuite/e2dbg_multithreads/test2.c -END -test3.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/512/trunk/testsuite/e2dbg_multithreads/test3.c -END -libtest.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/512/trunk/testsuite/e2dbg_multithreads/libtest.c -END -test-threads.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/512/trunk/testsuite/e2dbg_multithreads/test-threads.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/585/trunk/testsuite/e2dbg_multithreads/Makefile -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/entries eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/entries --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/e2dbg_multithreads -http://svn.eresi-project.org/svn - - - -2007-04-22T22:58:14.000000Z -585 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -test2.c -file - - - - -2008-04-06T23:15:42.039127Z -9c48e35e3e175ec52795b6f4352a95da -2007-03-17T13:05:31.000000Z -512 -may -has-props - -test3.c -file - - - - -2008-04-06T23:15:42.184899Z -febee745d738fcd2f166424c49afc230 -2007-03-17T13:05:31.000000Z -512 -may -has-props - -libtest.c -file - - - - -2008-04-06T23:15:42.196876Z -ec9ed5876529397086148d078f21ef8c -2007-03-17T13:05:31.000000Z -512 -may -has-props - -test-threads.c -file - - - - -2008-04-06T23:15:42.208248Z -af1f54d4b27eef91f48257239e36fb01 -2007-03-17T13:05:31.000000Z -512 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:42.219706Z -1b478a2249b0cc92eed0a88d0d5dc881 -2007-04-22T22:58:14.000000Z -585 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/format eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/format --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/libtest.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/libtest.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/libtest.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/libtest.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test2.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test2.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test2.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test3.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test3.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test3.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test-threads.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test-threads.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/prop-base/test-threads.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/prop-base/test-threads.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/libtest.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/libtest.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/libtest.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/libtest.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/* -** -** $Id: libtest.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -void *print_message_function_lib( void *ptr ) -{ - char *message; - int idx; - - for (idx = 0; 1; idx++) - { - message = (char *) malloc(42); - fprintf(stderr, "%s: (thread id = %u LIBTHREAD) new chunk addr %08X stack var addr %08X\n", - ptr, pthread_self(), message, &message); - sleep(1); - } -} - - -void print_lib() -{ - while (1) - { - fprintf(stderr, "coucou print_lib (thread id = %u) no malloc here \n", - pthread_self()); - sleep(1); - } -} - - -void test_lib() -{ - pthread_t thread4; - - fprintf(stderr, "begin test_lib\n"); - pthread_create( &thread4, NULL, (void *) print_lib, NULL); - pthread_join( thread4, NULL); - fprintf(stderr, "end test_lib\n"); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -# -# -# -# -# -# - -include ../../config.h - -CC ?= gcc -NAME = allocproxy -BINAME = debugme-mt - -all: - $(CC) -fPIC libtest.c -Iinclude -c - $(CC) -g3 libtest.o -L. -shared -o libtest.so -L../../liballocproxy/ -l$(NAME) - $(CC) -g3 -fPIC test-threads.c -Iinclude -L. -ltest -lpthread -L../../liballocproxy -l$(NAME) -o $(BINAME) - -clean: - rm -f *.o *~ - -fclean: clean - rm -f *.so $(BINAME) diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test2.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test2.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test2.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* -** -** $Id: test2.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include -#include - -pthread_t thread1, thread2; -char *message1 = "T1"; -char *message2 = "T2"; - -typedef void (*sighandler_t)(int); - - -int sigtrap_handler(int signum) -{ - int tid; - - tid = pthread_self(); - fprintf(stderr, "Received SIGTRAP in thread %u \n", tid); - if (tid == thread1) - pthread_kill(thread2, SIGUSR2); - else - pthread_kill(thread1, SIGUSR2); - usleep(50000); - fprintf(stderr, "<---- outside sigtrap handler for %u \n", tid); - return (0); -} - -int sigusr2_handler(int signum) -{ - int tid; - - tid = pthread_self(); - fprintf(stderr, "Received SIGUSR2 in thread %u \n", tid); - usleep(50000); - fprintf(stderr, "<---- outside sigusr2 handler for %u \n", tid); - return (0); -} - -void* thread_func(void *str) -{ - while (1) - { - if (!strcmp((char *) str, message2)) - pthread_kill(thread1, SIGTRAP); - else - pthread_kill(thread2, SIGTRAP); - fprintf(stderr, "%s\n", (char *) str); - sleep(1); - } -} - -int main(int argc, char **argv) -{ - int iret1, iret2; - struct sigaction ac; - - bzero((void *) &ac, sizeof(ac)); - ac.sa_sigaction = (void *) sigtrap_handler; - sigaction(SIGTRAP, &ac, NULL); - ac.sa_sigaction = (void *) sigusr2_handler; - sigaction(SIGUSR2, &ac, NULL); - - iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); - iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); - retry: - fprintf(stderr, "Now sleeping\n"); - sleep(30); - goto retry; - return (0); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test3.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test3.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test3.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* -** -** $Id: test3.c,v 1.1 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -pthread_t thread1, thread2; -char *message1 = "T1"; -char *message2 = "T2"; - -typedef void (*sighandler_t)(int); - - -int sigtrap_handler(int signum) -{ - fprintf(stderr, "Received SIGTRAP in thread %u ! \n", pthread_self()); - pthread_kill(thread2, SIGSTOP); - sleep(2); - fprintf(stderr, "<---- outside sigtrap handler \n"); - return (0); -} - -int sigstop_handler(int signum) -{ - fprintf(stderr, "Received SIGSTOP in thread %u ! \n", pthread_self()); - fprintf(stderr, "<---- outside sigstop handler \n"); - return (0); -} - -void* thread_func(void *str) -{ - while (1) - { - if (!strcmp((char *) str, message2)) - pthread_kill(thread1, SIGTRAP); - fprintf(stderr, "%s\n", (char *) str); - sleep(1); - } -} - -int main(int argc, char **argv) -{ - int iret1, iret2; - - signal(SIGTRAP, (sighandler_t) sigtrap_handler); - signal(SIGSTOP, (sighandler_t) sigstop_handler); - iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); - iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); - retry: - fprintf(stderr, "Now sleeping\n"); - sleep(30); - goto retry; - return (0); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test-threads.c.svn-base eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test-threads.c.svn-base --- eresi-0.8a25/testsuite/e2dbg_multithreads/.svn/text-base/test-threads.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/.svn/text-base/test-threads.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* -** -** $Id: test-threads.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -void *print_message_function(void *ptr); - -extern void *print_message_function_lib(void *); - -typedef void (*sighandler_t)(int); - - -void sigtrap_handler(int num) -{ - printf("Received a SIGTRAP ! Waiting 5 secondes and continue ... \n"); - sleep(5); -} - -void sigstop_handler(int num) -{ - printf("Received a SIGSTOP ! \n"); -} - -void sigusr2_handler(int num) -{ - printf("Received a SIGUSR2 ! \n"); -} - -main() -{ - pthread_t thread1, thread2, thread3; - char *message1 = "Thread 1"; - char *message2 = "Thread 2"; - char *message3 = "Thread 3"; - int iret1, iret2, iret3; - - //signal(SIGTRAP, (sighandler_t) sigtrap_handler); - //signal(SIGSTOP, (sighandler_t) sigstop_handler); - //signal(SIGUSR2, (sighandler_t) sigusr2_handler); - - iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1); - iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2); - iret3 = pthread_create( &thread3, NULL, print_message_function_lib, (void*) message3); - - test_lib(); - - /* Wait till threads are complete before main continues. Unless we */ - /* wait we run the risk of executing an exit which will terminate */ - /* the process and all threads before the threads have completed. */ - pthread_join( thread1, NULL); - pthread_join( thread2, NULL); - pthread_join( thread3, NULL); - - fprintf(stderr, "Thread 1 returns: %d\n",iret1); - fprintf(stderr, "Thread 2 returns: %d\n",iret2); - fprintf(stderr, "Thread 3 returns: %d\n",iret3); - exit(0); -} - - - - -void *print_message_function( void *ptr ) -{ - char *message; - - while (1) - { - message = malloc(42); - printf("%s: (thread id = %u LIBTHREAD) message addr %08X message var: %08X\n", - ptr, pthread_self(), message, &message); - sleep(1); - } -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/test2.c eresi-0.0.20110516/testsuite/e2dbg_multithreads/test2.c --- eresi-0.8a25/testsuite/e2dbg_multithreads/test2.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/test2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -/* -** -** $Id: test2.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include -#include - -pthread_t thread1, thread2; -char *message1 = "T1"; -char *message2 = "T2"; - -typedef void (*sighandler_t)(int); - - -int sigtrap_handler(int signum) -{ - int tid; - - tid = pthread_self(); - fprintf(stderr, "Received SIGTRAP in thread %u \n", tid); - if (tid == thread1) - pthread_kill(thread2, SIGUSR2); - else - pthread_kill(thread1, SIGUSR2); - usleep(50000); - fprintf(stderr, "<---- outside sigtrap handler for %u \n", tid); - return (0); -} - -int sigusr2_handler(int signum) -{ - int tid; - - tid = pthread_self(); - fprintf(stderr, "Received SIGUSR2 in thread %u \n", tid); - usleep(50000); - fprintf(stderr, "<---- outside sigusr2 handler for %u \n", tid); - return (0); -} - -void* thread_func(void *str) -{ - while (1) - { - if (!strcmp((char *) str, message2)) - pthread_kill(thread1, SIGTRAP); - else - pthread_kill(thread2, SIGTRAP); - fprintf(stderr, "%s\n", (char *) str); - sleep(1); - } -} - -int main(int argc, char **argv) -{ - int iret1, iret2; - struct sigaction ac; - - bzero((void *) &ac, sizeof(ac)); - ac.sa_sigaction = (void *) sigtrap_handler; - sigaction(SIGTRAP, &ac, NULL); - ac.sa_sigaction = (void *) sigusr2_handler; - sigaction(SIGUSR2, &ac, NULL); - - iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); - iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); - retry: - fprintf(stderr, "Now sleeping\n"); - sleep(30); - goto retry; - return (0); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/test3.c eresi-0.0.20110516/testsuite/e2dbg_multithreads/test3.c --- eresi-0.8a25/testsuite/e2dbg_multithreads/test3.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/test3.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/* -** -** $Id: test3.c,v 1.1 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -pthread_t thread1, thread2; -char *message1 = "T1"; -char *message2 = "T2"; - -typedef void (*sighandler_t)(int); - - -int sigtrap_handler(int signum) -{ - fprintf(stderr, "Received SIGTRAP in thread %u ! \n", pthread_self()); - pthread_kill(thread2, SIGSTOP); - sleep(2); - fprintf(stderr, "<---- outside sigtrap handler \n"); - return (0); -} - -int sigstop_handler(int signum) -{ - fprintf(stderr, "Received SIGSTOP in thread %u ! \n", pthread_self()); - fprintf(stderr, "<---- outside sigstop handler \n"); - return (0); -} - -void* thread_func(void *str) -{ - while (1) - { - if (!strcmp((char *) str, message2)) - pthread_kill(thread1, SIGTRAP); - fprintf(stderr, "%s\n", (char *) str); - sleep(1); - } -} - -int main(int argc, char **argv) -{ - int iret1, iret2; - - signal(SIGTRAP, (sighandler_t) sigtrap_handler); - signal(SIGSTOP, (sighandler_t) sigstop_handler); - iret1 = pthread_create( &thread1, NULL, thread_func, (void*) message1); - iret2 = pthread_create( &thread2, NULL, thread_func, (void*) message2); - retry: - fprintf(stderr, "Now sleeping\n"); - sleep(30); - goto retry; - return (0); -} diff -Nru eresi-0.8a25/testsuite/e2dbg_multithreads/test-threads.c eresi-0.0.20110516/testsuite/e2dbg_multithreads/test-threads.c --- eresi-0.8a25/testsuite/e2dbg_multithreads/test-threads.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/e2dbg_multithreads/test-threads.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -/* -** -** $Id: test-threads.c,v 1.3 2007-03-17 13:05:31 may Exp $ -** -*/ -#include -#include -#include -#include - -void *print_message_function(void *ptr); - -extern void *print_message_function_lib(void *); - -typedef void (*sighandler_t)(int); - - -void sigtrap_handler(int num) -{ - printf("Received a SIGTRAP ! Waiting 5 secondes and continue ... \n"); - sleep(5); -} - -void sigstop_handler(int num) -{ - printf("Received a SIGSTOP ! \n"); -} - -void sigusr2_handler(int num) -{ - printf("Received a SIGUSR2 ! \n"); -} - -main() -{ - pthread_t thread1, thread2, thread3; - char *message1 = "Thread 1"; - char *message2 = "Thread 2"; - char *message3 = "Thread 3"; - int iret1, iret2, iret3; - - //signal(SIGTRAP, (sighandler_t) sigtrap_handler); - //signal(SIGSTOP, (sighandler_t) sigstop_handler); - //signal(SIGUSR2, (sighandler_t) sigusr2_handler); - - iret1 = pthread_create( &thread1, NULL, print_message_function, (void*) message1); - iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2); - iret3 = pthread_create( &thread3, NULL, print_message_function_lib, (void*) message3); - - test_lib(); - - /* Wait till threads are complete before main continues. Unless we */ - /* wait we run the risk of executing an exit which will terminate */ - /* the process and all threads before the threads have completed. */ - pthread_join( thread1, NULL); - pthread_join( thread2, NULL); - pthread_join( thread3, NULL); - - fprintf(stderr, "Thread 1 returns: %d\n",iret1); - fprintf(stderr, "Thread 2 returns: %d\n",iret2); - fprintf(stderr, "Thread 3 returns: %d\n",iret3); - exit(0); -} - - - - -void *print_message_function( void *ptr ) -{ - char *message; - - while (1) - { - message = malloc(42); - printf("%s: (thread id = %u LIBTHREAD) message addr %08X message var: %08X\n", - ptr, pthread_self(), message, &message); - sleep(1); - } -} diff -Nru eresi-0.8a25/testsuite/elf/ctors_hijack/ctors_hijack.c eresi-0.0.20110516/testsuite/elf/ctors_hijack/ctors_hijack.c --- eresi-0.8a25/testsuite/elf/ctors_hijack/ctors_hijack.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/ctors_hijack/ctors_hijack.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,57 @@ +/* +** ctors_hijack.c for testsuite in ERESI +** +** Started on Sun Mar 10 01:18:51 2002 jfv +** $Id: ctors_hijack.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Sym *new_ctors; + int ret; + + + file = elfsh_map_obj(TROJANED_FILE); + new_ctors = elfsh_get_symbol_by_name(file, "new_ctors"); + if (!file || !new_ctors) + { + elfsh_error(); + exit(-1); + } + + + /***********************************************************/ + /**************** TEST FOR CTORS HIJACKING *****************/ + /***********************************************************/ + + //ret = elfsh_set_ctors_entry_by_index(file, 1, new_ctors->st_value); + ret = elfsh_set_ctors_entry_by_name(file, "my_ctors", new_ctors->st_value); + if (ret < 0) + { + elfsh_error(); + exit(-1); + } + + + /***********************************************************/ + /************************ RELINKING ************************/ + /***********************************************************/ + + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); +} + diff -Nru eresi-0.8a25/testsuite/elf/ctors_hijack/hijacked.c eresi-0.0.20110516/testsuite/elf/ctors_hijack/hijacked.c --- eresi-0.8a25/testsuite/elf/ctors_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/ctors_hijack/hijacked.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,31 @@ +/* +** hijacked.c for elfsh +** +** Started on Sun Mar 10 02:41:10 2002 jfv +** Last update Sun Mar 10 02:54:44 2002 jfv +** +** $Id: hijacked.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + + +void my_ctors() __attribute__ ((constructor)); + + +void new_ctors() +{ + printf("hijacked ctors ! \n"); +} + + +void my_ctors() +{ + printf("My ctors ! \n"); + +} + +int main() +{ + printf("Main ! \n"); +} diff -Nru eresi-0.8a25/testsuite/elf/ctors_hijack/Makefile eresi-0.0.20110516/testsuite/elf/ctors_hijack/Makefile --- eresi-0.8a25/testsuite/elf/ctors_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/ctors_hijack/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for ctors_hijack in ERESI testsuite +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:54:50 2002 jfv +## + +include ../../../config.h + +SRC = ctors_hijack.c +CC = gcc +RM = rm -f +VULN = hijacked.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = ctors_hijacker32 +NAME64 = ctors_hijacker64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/dtors_hijack/dtors_hijack.c eresi-0.0.20110516/testsuite/elf/dtors_hijack/dtors_hijack.c --- eresi-0.8a25/testsuite/elf/dtors_hijack/dtors_hijack.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/dtors_hijack/dtors_hijack.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,60 @@ +/* +** unlink.c for unlinked +** +** Started on Sun Mar 10 01:18:51 2002 jfv +** Last update Sun Mar 10 02:56:20 2002 jfv +** +** $Id: dtors_hijack.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + + +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Sym *new_dtors; + int ret; + + file = elfsh_map_obj(TROJANED_FILE); + new_dtors = elfsh_get_symbol_by_name(file, "new_dtors"); + + if (!file || !new_dtors) + { + elfsh_error(); + exit(-1); + } + + + /***********************************************************/ + /**************** TEST FOR DTORS HIJACKING *****************/ + /***********************************************************/ + + + //ret = elfsh_set_dtors_entry_by_index(file, 1, new_dtors->st_value); + ret = elfsh_set_dtors_entry_by_name(file, "my_dtors", new_dtors->st_value); + if (ret < 0) + { + elfsh_error(); + exit(-1); + } + + + /* RELINKING THE FILE */ + + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); +} + diff -Nru eresi-0.8a25/testsuite/elf/dtors_hijack/hijacked.c eresi-0.0.20110516/testsuite/elf/dtors_hijack/hijacked.c --- eresi-0.8a25/testsuite/elf/dtors_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/dtors_hijack/hijacked.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,27 @@ +/* +** +** $Id: hijacked.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + + +void my_dtors() __attribute__ ((destructor)); + + +void new_dtors() +{ + printf("hijacked dtors ! \n"); +} + +void my_dtors() +{ + printf("My dtors ! \n"); +} + + +int main() +{ + printf("Main ! Sleeping 5 secs ... \n"); + sleep(5); +} diff -Nru eresi-0.8a25/testsuite/elf/dtors_hijack/Makefile eresi-0.0.20110516/testsuite/elf/dtors_hijack/Makefile --- eresi-0.8a25/testsuite/elf/dtors_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/dtors_hijack/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for dtors_hijack in ERESI testsuite +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:55:25 2002 jfv +## + +include ../../../config.h + +SRC = dtors_hijack.c +CC = gcc +RM = rm -f +VULN = hijacked.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = dtors_hijacker32 +NAME64 = dtors_hijacker64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/elf-tests.esh eresi-0.0.20110516/testsuite/elf/elf-tests.esh --- eresi-0.8a25/testsuite/elf/elf-tests.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/elf-tests.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,263 @@ +#!../../elfsh/elfsh32 +# +# Additional tests suite for shell commands . +# +# This does nothing really, just checking that all commands +# do their job. The output file is completely useless. +# +# And please dont ask -why- 42 +# + + +# Start printing the help screens +help +info + + +# Uncomment me for a quiet output log +# quiet +# Uncomment me for a very verbose output +#profile enable warn + +# Now load the files +load /bin/ls +list +switch 1 + +exec ls -la + +# Playing with print and exec commands +print phnum is 1.hdr.phnum and got[21] is 1.got[21] +print 11th section is 1.section[11].name + + +# Play with arithmetic ops +print phnum = 1.hdr.phnum +add 1.hdr.phnum 42 +print phnum = 1.hdr.phnum +sub 1.hdr.phnum 41 +print phnum = 1.hdr.phnum +div 1.hdr.phnum 2 +print phnum = 1.hdr.phnum +mod 1.hdr.phnum 2 +print phnum = 1.hdr.phnum +mul 1.hdr.phnum 5 +print phnum = 1.hdr.phnum + +# Playing a bit with the modules +cmdtest +modload ../../modules/modtest.so +print hehe +cmdtest +list + +profile enable all +modunload ../../modules/modtest.so +print hehe + +# ELF header tests +# Illustrate the object affectations between files + +e +print 1.hdr.magic +set 1.hdr.magic 0x42424242 +print 1.hdr.magic +e + +set 1.hdr.type 2.hdr.type +set 1.hdr.machine 0x43 +set 1.hdr.version 0x44 +set 1.hdr.entry .data + +# Dont do those or you wont be able to see the change in the output file +#set 1.hdr.shoff 0x46 +#set 1.hdr.phoff 0x47 + +set 1.hdr.ehsize 0x48 +set 1.hdr.shentsize 2.hdr.shentsize +set 1.hdr.phentsize 2.hdr.shentsize +set 1.hdr.phnum 3 +set 1.hdr.shnum 30 +set 1.hdr.shstrndx 31 + +# PAX flags tests + +set 1.hdr.pax_pageexec 0 +set 1.hdr.pax_segmexec 1 +set 1.hdr.pax_emultramp 0 +set 1.hdr.pax_mprotect 1 +set 1.hdr.pax_randmmap 0 +set 1.hdr.pax_randexec 1 + +e + +print 1.hdr.magic +print 1.hdr.type +print 1.hdr.machine +print 1.hdr.version +print 1.hdr.entry +print 1.hdr.phoff +print 1.hdr.shoff +print 1.hdr.ehsize +print 1.hdr.shentsize +print 1.hdr.phentsize +print 1.hdr.phnum +print 1.hdr.shnum +print 1.hdr.shstrndx + + +# PHT tests +# Illustrate elf.h constants resolving as immediate value + +p +set 1.pht[0].type ET_DYN +set 1.pht[0].offset 0x55 +set 1.pht[0].vaddr 0x56 +set 1.pht[0].paddr 0x57 +set 1.pht[0].filesz 0x58 +set 1.pht[0].memsz 0x59 +set 1.pht[0].flags 0x60 +set 1.pht[0].align 0x61 +p + +print 1.pht[0].type +print 1.pht[0].offset +print 1.pht[0].vaddr +print 1.pht[0].paddr +print 1.pht[0].filesz +print 1.pht[0].memsz +print 1.pht[0].flags +print 1.pht[0].align + + + +# SHT tests + +s 01 +set 1.sht[1].type 0x54 +set 1.sht[1].addr 0x55 +set 1.sht[1].offset 0x56 +set 1.sht[1].size 0x57 +set 1.sht[1].link 0x58 +set 1.sht[1].info 0x59 +set 1.sht[1].align 0x60 +set 1.sht[1].entsize 0x61 +set 1.sht[1].a 1 +set 1.sht[1].w 1 +set 1.sht[1].x 1 +set 1.sht[1].s 1 +set 1.sht[1].m 1 +set 1.sht[1].l 1 +set 1.sht[1].o 1 +s + +print 1.sht[1].type +print 1.sht[1].addr +print 1.sht[1].offset +print 1.sht[1].size +print 1.sht[1].link +print 1.sht[1].info +print 1.sht[1].align +print 1.sht[1].entsize +print 1.sht[1].a +print 1.sht[1].w +print 1.sht[1].x +print 1.sht[1].s +print 1.sht[1].m +print 1.sht[1].l +print 1.sht[1].o + + + + +# SYMTAB tests + +sym 03] +set 1.symtab[3].value 0x62 +set 1.symtab[3].size 0x63 +set 1.symtab[3].bind 1 +set 1.symtab[3].type 4 +set 1.symtab[3].other 2 +sym 03] + +print 1.symtab[3].value +print 1.symtab[3].size +print 1.symtab[3].bind +print 1.symtab[3].type +print 1.symtab[3].other + + +# DYNSYMTAB tests + +dynsym 12] +set 1.dynsym[12].value 0x67 +set 1.dynsym[12].size 0x68 +set 1.dynsym[12].bind 1 +set 1.dynsym[12].type 6 +set 1.dynsym[12].other 2 +dynsym 12] + +print 1.dynsym[12].value +print 1.dynsym[12].size +print 1.dynsym[12].bind +print 1.dynsym[12].type +print 1.dynsym[12].other + + +# .DYNAMIC tests + +dyn 07] +set 1.dynamic[7].val 0x72 +set 1.dynamic[7].tag 0x73 +dyn 07] + +print 1.dynamic[7].val +print 1.dynamic[7].tag + + +# .GOT tests : you can also use filepath instead of their index + +got 05]|13] +print 1.got[5] +set 1.got[5] /usr/local/bin/elfsh.got[13] +print 1.got[5] +got 05]|13] + + +# CTORS and DTORS tests +# Illustrate the (dyn)symbol resolving as immediate value + +ctors +set 1.ctors[0] 0x41424344 +set 1.ctors[1] malloc +ctors + +dtors +set 1.dtors[1] 0x4546 +set 1.dtors[0] free +dtors + + +# RELOCATION TABLE TESTS + +rel 062] +set 1.rel[1][62].sym 22 +set 1.rel[1][62].offset 0x08044800 +set 1.rel[1][62].type R_386_GOTPC +rel 062] + +# Now leave, unloaded files are closed without saving +save /tmp/test-save +unload /bin/ls +exec rm /tmp/test-save +quit + + + + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/debug.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/debug.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/debug.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/debug.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,7 @@ +#!/bin/sh + +../../../../elfsh/elfsh32 -f fake_aout32 -sym 'legit|hook' +./relinject32.esh > ./relinject.out +grep CFLOW relinject.out +../../../../elfsh/elfsh32 -f fake_aout32 -D legit_func%5 +exit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/etrel_inject.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/etrel_inject.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/etrel_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/etrel_inject.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,73 @@ +/* +** etrel_inject.c for elf testsuite in ERESI +** +** Started on Sat May 10 07:01:59 2003 jfv +** $Id: etrel_inject.c 1325 2009-01-26 12:12:21Z may $ +*/ +#include "libelfsh.h" + + +#if ERESI32 + #define TROJANED_FILE "hijackme32" + #define RELOC_FILE "rel.32.o" + #define OUTPUT_FILE "fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "hijackme64" + #define RELOC_FILE "rel.64.o" + #define OUTPUT_FILE "fake_aout64" +#endif + +int main(int argc, char **argv) +{ + elfshobj_t *host; + elfshobj_t *rel; + elfshsect_t *txtsect; + elfsh_Sym *puts_troj; + elfsh_Sym *hook_func; + int idx; + u_long addr; + + /* Map host file and relocatable file */ + rel = elfsh_map_obj(RELOC_FILE); + if (NULL == rel) + goto err; + host = elfsh_map_obj(TROJANED_FILE); + if (NULL == host) + goto err; + + /* Inject etrel */ + idx = elfsh_inject_etrel(host, rel); + if (idx < 0) + goto err; + + /* Get injected's section info */ + txtsect = elfsh_get_section_by_name(host, RELOC_FILE".text", NULL, NULL, NULL); + if (txtsect == NULL) + goto err; + + puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); + idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, + "puts", puts_troj->st_value, + NULL); + if (idx < 0) + goto err; + + hook_func = elfsh_get_symbol_by_name(host, "hook_func"); + idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_FLOW, + "legit_func", hook_func->st_value, + NULL); + if (idx < 0) + goto err; + + + /* Save it */ + idx = elfsh_save_obj(host, OUTPUT_FILE); + if (idx < 0) + goto err; + + puts("[*] ET_REL injected"); + return (0); + err: + elfsh_error(); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/gdb.script eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/gdb.script --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/gdb.script 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/gdb.script 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,12 @@ + +file main +directory ~/glibc-2.3.4/elf/ +directory ~/glibc-2.3.4/sysdeps/i386/ +b *0x4000660 +r +display/1x $pc +while 1 +stepi +end + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/host.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/host.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/host.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,43 @@ +/* +** +** $Id: host.c 1325 2009-01-26 12:12:21Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + printf("LEGIT FUNC\n"); + printf("legit func (%s) !\n", str); + return (0); +} + +int main() +{ + char *str; + char buff[BUFSIZ]; + + read(0, buff, BUFSIZ-1); + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf %s\n", str); + free(str); + puts("Second_puts"); + + fflush(stdout); + legit_func("test"); + return (0); + + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,47 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## +## + +include ../../../../config.h + +SRC = etrel_inject.c +CC = gcc +RM = rm -f +VULN = host.c +RELSRC = rel.c + +RELOBJ32 = $(RELSRC:.c=.32.o) +RELOBJ64 = $(RELSRC:.c=.64.o) +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = relinject32 +NAME64 = relinject64 + +all: all32 all64 + +all32: $(OBJ32) $(RELOBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) $(RELOBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) $(RELOBJ32) $(RELOBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/rel.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/rel.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/rel.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/rel.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,71 @@ +/* +** rel.c for elfsh +** +** Contain all tests for ET_REL injection +** +** Started on Mon Jun 23 06:56:04 2003 jfv +** Last update Sun Aug 17 17:41:48 2003 jfv +** +** $Id: rel.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + +int glvar_testreloc = 42; + +int glvar_testreloc_bss; +char glvar_testreloc_bss2; +short glvar_testreloc_bss3; + + +int hook_func(char *str) +{ + printf("HOOK FUNC %s !\n", str); + return (old_legit_func(str)); +} + + +int puts_troj(char *str) +{ + int local = 1; + char *str2; + + str2 = malloc(10); + *str2 = 'Z'; + *(str2 + 1) = 0x00; + + glvar_testreloc_bss = 43; + glvar_testreloc_bss2 = 44; + glvar_testreloc_bss3 = 45; + + printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", + str2, str, + glvar_testreloc, + glvar_testreloc_bss, + glvar_testreloc_bss2, + glvar_testreloc_bss3, + local); + + free(str2); + putchar('e'); + putchar('x'); + putchar('t'); + putchar('c'); + putchar('a'); + putchar('l'); + putchar('l'); + putchar('!'); + putchar('\n'); + old_puts(str); + write(1, "calling write\n", 14); + fflush(stdout); + return (0); +} + +int func2() +{ + return (42); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/relinject32.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/relinject32.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/relinject32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/relinject32.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,14 @@ +#!../../../../elfsh/elfsh32 + +load hijackme32 +load rel.32.o + +reladd 1 2 +#reladd 1 3 + +redir puts puts_troj +redir legit_func hook_func + +save fake_aout32 + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/relinject64.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/relinject64.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extplt/relinject64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extplt/relinject64.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,12 @@ +#!../../../../elfsh/elfsh64 + +load hijackme64 +load rel.64.o + +reladd 1 2 + +redir puts puts_troj +redir legit_func hook_func + +save fake_aout64 +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/host.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/host.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/host.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,33 @@ +/* +** +** $Id: host.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + puts("legit func !"); + return (0); +} + +int main() +{ + char *str; + char buff[BUFSIZ]; + + read(0, buff, BUFSIZ-1); + + puts("First_puts"); + + puts("Second_puts"); + + fflush(stdout); + + legit_func("test"); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,43 @@ +# +# Simple Makefile for generating ET_REL list from archive files. +# +# The ELFsh project 2005 +# + +.PHONY: libc libcnonshared libpthread libpthreadnonshared libnsl + + +all64: all +all32: all +all: libc libcnonshared libpthread libpthreadnonshared libnsl + rm -f load_lib.esh + echo "#!../../../vm/elfsh" > load_lib.esh + find libc libnsl libcnonshared libpthread libpthreadnonshared -name "*.o*" | xargs \ + -ibou echo load bou >> load_lib.esh + +libnsl: + mkdir -p libnsl + cd libnsl && ar x /usr/lib/libnsl.a + +libc: + mkdir -p libc + cd libc && ar x /usr/lib/libc.a + +libcnonshared: + mkdir -p libcnonshared + cd libcnonshared && ar x /usr/lib/libc_nonshared.a + +libpthread: + mkdir -p libpthread + cd libpthread && ar x /usr/lib/libpthread.a + +libpthreadnonshared: + mkdir -p libpthreadnonshared + cd libpthreadnonshared && ar x /usr/lib/libpthread_nonshared.a + +clean: + rm -f core a.out fake_aout *.o *~ *\#* +fclean: clean + rm -f *~ \#* load_lib.esh libc/*.o* libcnonshared/*.o* \ + libpthread/*.o* libpthreadnonshared/*.o* libnsl/*.o* + rm -fr libc libnsl libpthread libcnonshared libpthreadnonshared diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/rel2.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/rel2.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/rel2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/rel2.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,104 @@ +/* +** rel.c for elfsh +** +** Contain all tests for ET_REL injection +** +** Started on Mon Jun 23 06:56:04 2003 jfv +** Last update Sun Aug 17 17:41:48 2003 jfv +** +** $Id: rel2.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int glvar_testreloc = 42; + +int glvar_testreloc_bss; +char glvar_testreloc_bss2; +short glvar_testreloc_bss3; + + +int hook_func(char *str) +{ + int sd; + + printf("hook func %s !\n", str); + + return (old_legit_func(str)); +} + + +int puts_troj(char *str) +{ + int local = 1; + char *str2; + int fd; + char name[16]; + void *a; + + str2 = malloc(10); + *str2 = 'Z'; + *(str2 + 1) = 0x00; + + glvar_testreloc_bss = 43; + glvar_testreloc_bss2 = 44; + glvar_testreloc_bss3 = 45; + + memset(name, 0, 16); + + printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", + str2, str, + glvar_testreloc, + glvar_testreloc_bss, + glvar_testreloc_bss2, + glvar_testreloc_bss3, + local); + + free(str2); + + gethostname(name, 15); + printf("hostname : %s\n", name); + + printf("printf called from puts_troj [%s] \n", str); + + + fd = open("/etc/services", 0, O_RDONLY); + + if (fd) + { + if ((a = mmap(0, 100, PROT_READ, MAP_PRIVATE, fd, 0)) == (void *) -1) + { + perror("mmap"); + close(fd); + printf("mmap failed : fd: %d\n", fd); + return (-1); + } + printf("-=-=-=-=-=- BEGIN /etc/services %d -=-=-=-=-=\n", fd); + printf("host : %.60s\n", (char *) a); + printf("-=-=-=-=-=- END /etc/services %d -=-=-=-=-=\n", fd); + printf("mmap succeed fd : %d\n", fd); + close(fd); + } + + + old_puts(str); + fflush(stdout); + return (0); +} + +int func2() +{ + return (42); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/relinject.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/relinject.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_extstatic/relinject.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_extstatic/relinject.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,22 @@ +#!../../../../elfsh/elfsh32 + +exec gcc -g3 -static host.c +exec gcc -g3 -static rel2.c -c + +load a.out +load rel2.o + +source ./load_lib.esh +#list + +reladd 1 2 + +profile +profile + +redir puts puts_troj +redir legit_func hook_func + +save fake_aout + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/gdb.script eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/gdb.script --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/gdb.script 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/gdb.script 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,18 @@ + +file ./fake_aout +directory ~/glibc-2.3.4/elf/ +directory ~/glibc-2.3.4/sysdeps/mips/ +b main +r +display/1x $pc +while 1 +stepi +end + +#echo Printing relative offset from real GP value +#x/26x $gp-0x8000+0x10 +#echo Printing original GOT +#x/26x 0x10000050 +#echo Printing ALTGOT +#x/26x 0x10000170 +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host1.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host1.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host1.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,30 @@ +/* +** +** $Id: host1.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + +int main() +{ + char *str; + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + free(str); + printf("Second_printf %u\n", 42); + puts("Second_puts"); + fflush(stdout); + printf("End of main %s \n", "hehe"); + return (0); + err: + printf("Malloc problem %u\n", 42); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host2.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host2.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host2.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,36 @@ +/* +** +** $Id: host2.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + + +int new_puts(char *str) +{ + printf("hijacked puts !\n"); + return (0); +} + +int main() +{ + char *str; + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf\n"); + puts("Second_puts"); + fflush(stdout); + return (0); + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host3.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host3.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/alphabins/host3.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/alphabins/host3.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,42 @@ +/* +** +** $Id: host3.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + +int hook_func(char *str) +{ + printf("hook func %s !\n", str); + return (0); +} + +int legit_func(char *str) +{ + printf("legit func (%s) !\n", str); + return (0); +} + +int main() +{ + char *str; + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf\n"); + puts("Second_puts"); + fflush(stdout); + legit_func("test"); + return (0); + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/debug.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/debug.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/debug.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/debug.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,7 @@ +#!/bin/sh + +../../../vm/elfsh -f fake_aout -sym 'legit|hook' +./relinject.esh > ./relinject.out +grep CFLOW relinject.out +../../../vm/elfsh -f fake_aout -D legit_func%5 +exit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/etrel_inject.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/etrel_inject.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/etrel_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/etrel_inject.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,73 @@ +/* +** etrel_inject.c for testsuite in ERESI +** +** Started on Sat May 10 07:01:59 2003 jfv +** $Id: etrel_inject.c 1309 2009-01-14 18:41:02Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "hijackme32" + #define RELOC_FILE "rel.32.o" + #define OUTPUT_FILE "fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "hijackme64" + #define RELOC_FILE "rel.64.o" + #define OUTPUT_FILE "fake_aout64" +#endif + +int main(int argc, char **argv) +{ + elfshobj_t *host; + elfshobj_t *rel; + elfshsect_t *txtsect; + elfsh_Sym *puts_troj; + elfsh_Sym *hook_func; + int idx; + u_long addr; + + /* Map host file and relocatable file */ + rel = elfsh_map_obj(RELOC_FILE); + if (NULL == rel) + goto err; + host = elfsh_map_obj(TROJANED_FILE); + if (NULL == host) + goto err; + + /* Inject etrel */ + idx = elfsh_inject_etrel(host, rel); + if (idx < 0) + goto err; + + /* Get injected's section info */ + txtsect = elfsh_get_section_by_name(host, RELOC_FILE".text", NULL, NULL, NULL); + if (txtsect == NULL) + goto err; + + /* hijack functions */ + puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); + idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, + "puts", puts_troj->st_value, + NULL); + if (idx < 0) + goto err; + + hook_func = elfsh_get_symbol_by_name(host, "hook_func"); + idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_FLOW, + "legit_func", hook_func->st_value, + NULL); + if (idx < 0) + goto err; + + /* Save it */ + idx = elfsh_save_obj(host, OUTPUT_FILE); + if (idx < 0) + goto err; + + puts("[*] ET_REL injected"); + return (0); + err: + profiler_enable_err(); + elfsh_error(); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/gdb.script eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/gdb.script --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/gdb.script 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/gdb.script 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,12 @@ + +file main +directory ~/glibc-2.3.4/elf/ +directory ~/glibc-2.3.4/sysdeps/i386/ +b *0x4000660 +r +display/1x $pc +while 1 +stepi +end + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/host.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/host.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/host.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,45 @@ +/* +** +** $Id: host.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + printf("LEGIT FUNC\n"); + printf("legit func (%s) !\n", str); + return (0); +} + +int main() +{ + char *str; + char buff[BUFSIZ]; + + read(0, buff, BUFSIZ-1); + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf %s\n", str); + + free(str); + + puts("Second_puts"); + + fflush(stdout); + legit_func("test"); + return (0); + err: + perror("malloc"); + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,48 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## +## + +include ../../../../config.h + + +SRC = etrel_inject.c +CC = gcc +RM = rm -f +VULN = host.c +RELSRC = rel.c + +RELOBJ32 = $(RELSRC:.c=.32.o) +RELOBJ64 = $(RELSRC:.c=.64.o) +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = relinject32 +NAME64 = relinject64 + +all: all32 all64 + +all32: $(OBJ32) $(RELOBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) $(RELOBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) $(RELOBJ32) $(RELOBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/rel.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/rel.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/rel.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/rel.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,61 @@ +/* +** rel.c for elfsh +** +** Contain all tests for ET_REL injection +** +** Started on Mon Jun 23 06:56:04 2003 jfv +** Last update Sun Aug 17 17:41:48 2003 jfv +** +** $Id: rel.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + +int glvar_testreloc = 42; + +int glvar_testreloc_bss; +char glvar_testreloc_bss2; +short glvar_testreloc_bss3; + + +int hook_func(char *str) +{ + printf("HOOK FUNC %s !\n", str); + return (old_legit_func(str)); +} + + +int puts_troj(char *str) +{ + int local = 1; + char *str2; + + str2 = malloc(10); + *str2 = 'Z'; + *(str2 + 1) = 0x00; + + glvar_testreloc_bss = 43; + glvar_testreloc_bss2 = 44; + glvar_testreloc_bss3 = 45; + + printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", + str2, str, + glvar_testreloc, + glvar_testreloc_bss, + glvar_testreloc_bss2, + glvar_testreloc_bss3, + local); + + free(str2); + old_puts(str); + fflush(stdout); + return (0); +} + +int func2() +{ + return (42); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/relinject32.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/relinject32.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/relinject32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/relinject32.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../../../elfsh/elfsh32 + +load hijackme32 +load rel.32.o + +reladd 1 2 +redir puts puts_troj +redir legit_func hook_func + +sym old +save fake_aout32 + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/relinject64.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/relinject64.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/relinject64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/relinject64.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,19 @@ +#!../../../../elfsh/elfsh32 + +#profile enable warn +load hijackme64 +load rel.64.o + +#profile enable warn +#log session + +reladd 1 2 +#redir puts puts_troj +redir legit_func hook_func + +#sym old +save fake_aout64 + +#log stop + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/session eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/session --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_original/session 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_original/session 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,123 @@ + [*] Started logging session in session + +~reladd 1 2 [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found + [W] <elfsh_get_section_by_name@section.c:276> Section not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_sym_by_value@sym_common.c:263> No exact symbol matching + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found + [W] <elfsh_get_section_by_name@section.c:276> Section not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found + [W] <elfsh_get_section_by_name@section.c:276> Section not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found + [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found + [W] <elfsh_get_section_by_name@section.c:276> Section not found + [W] <elfsh_relocate_etrel_section@relinject.c:305> Cant find inserted section in ET_EXEC + [W] <elfsh_relocate_object@relinject.c:376> Unable to relocate section + [W] <elfsh_inject_etrel_hash@relinject.c:688> Unable to inject ET_REL with list + [W] <cmd_relinject@reladd.c:62> Failed to inject ET_REL with workspace + [W] <vm_execscript@loop.c:126> Command execution failed + [E] Command execution failed + + + [E] Script execution failed + diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/host.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/host.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/host.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,44 @@ +/* +** +** $Id: host.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + printf("LEGIT FUNC\n"); + printf("legit func (%s) !\n", str); + return (0); +} + +int main() +{ + char *str; + char buff[BUFSIZ]; + + //read(0, buff, BUFSIZ-1); + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf %s\n", str); + + free(str); + + puts("Second_puts"); + + fflush(stdout); + legit_func("test"); + return (0); + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,29 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## +## + +include ../../../../config.h + +PAXCTL = /sbin/paxctl +CC = gcc +RELSRC = simple.c +RELOBJ = simple.o +PIESRC = host.c +PIEOBJ = host.o + +RM = rm -f +CFLAGS = -fPIC + +all32: all +all : $(PIEOBJ) $(RELOBJ) + $(CC) -g3 $(PIEOBJ) -pie + +clean : + $(RM) *~ \#* *\# $(RELOBJ) $(PIEOBJ) + +fclean : clean + $(RM) a.out fake_aout + diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/relinject.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/relinject.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/relinject.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/relinject.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,22 @@ +#!../../../../elfsh/elfsh32 + +load a.out +load simple.o + +reladd 1 2 + +#redir main fake_main +#redir __stack_smash_handler fake_stack_smash_handler +#redir __libc_start_main fake_libc_start_main +#redir strcpy fake_strcpy + +redir puts fake_puts +redir legit_func fake_legit_func + +save fake_aout + +# uncomment just for development purpose made easier +#exec /sbin/paxctl -c fake_aout +#exec /sbin/paxctl -permxs fake_aout + +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/simple.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/simple.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_pie-ssp/simple.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_pie-ssp/simple.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,92 @@ +/* +** rel.c for elfsh +** +** Contain all tests for ET_REL injection +** +** Started on Mon Jun 23 06:56:04 2003 jfv +** Last update Sun Aug 17 17:41:48 2003 jfv +** +** $Id: simple.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + +//int glvar_testreloc = 42; + +/* +int glvar_testreloc_bss; +char glvar_testreloc_bss2; +short glvar_testreloc_bss3; +*/ + +/* +int fake_main(int argc, char **argv) +{ + + glvar_testreloc_bss = 1; + glvar_testreloc_bss2 = 'Z'; + glvar_testreloc_bss3 = 42; + + old_printf("I am the main function, I have %d argc and my argv is %08X yupeelala \n", + argc, argv); //, glvar_testreloc); + + write(1, "fake_main is calling write ! \n", 30); + + old_main(argc, argv); + + old_printf("Last printf in hook_main [%08X:%08X:%c:%04X] \n", + glvar_testreloc, glvar_testreloc_bss, + glvar_testreloc_bss2, glvar_testreloc_bss3); + + return (0); +} +*/ + + + +/* +void fake_stack_smash_handler(char func[], int damaged) +{ + static int i = 0; + printf("calling printf from stack smashing handler %u\n", i++); + if (i>3) + old___stack_smash_handler(func, damaged); + else + printf("Same player play again [damaged = %08X] \n", damaged); + printf("A second (%d) printf from the handler \n", 2); +} +*/ + + +/* +int fake_libc_start_main(void *one, void *two, void *three, void *four, void *five, void *six, void *seven) +{ + static int i = 0; + + old_printf("fake_libc_start_main \n"); + printf("start_main has been run %u \n", i++); + return (old___libc_start_main(one, two, three, four, five, six, seven)); +} +*/ + +/* +char* fake_strcpy(char *dst, char *src) +{ + printf("The binary wants to copy %s at address %08X \n", src, dst); + return ((char *) old_strcpy(dst, src)); +} +*/ + +int fake_puts(char *str) +{ + return (old_puts("Hijacked puts\n")); +} + +int fake_legit_func(char *str) +{ + printf("Hijacked legit func %s ! \n", str); + return (old_legit_func(str)); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/host.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/host.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/host.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,44 @@ +/* +** +** $Id: host.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include +#include + +int legit_func(char *str) +{ + printf("LEGIT FUNC\n"); + printf("legit func (%s) !\n", str); + return (0); +} + +int main() +{ + char *str; + char buff[BUFSIZ]; + + read(0, buff, BUFSIZ-1); + + str = malloc(10); + if (str == NULL) + goto err; + strcpy(str, "test"); + printf("First_printf %s\n", str); + fflush(stdout); + puts("First_puts"); + printf("Second_printf %s\n", str); + + free(str); + + puts("Second_puts"); + + fflush(stdout); + legit_func("test"); + return (0); + err: + printf("Malloc problem\n"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,42 @@ +## +## Makefile for etrel_static in ERESI +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## $Id: Makefile 1381 2009-06-21 08:11:42Z may $ +## + +include ../../../../config.h + +CC = gcc +RM = rm -f +VULN = host.c +RELSRC = rel.c + +RELOBJ32 = $(RELSRC:.c=.32.o) +RELOBJ64 = $(RELSRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = relinject32 +NAME64 = relinject64 + +all: all32 all64 + +all32: $(RELOBJ32) + $(CC) $(VULN) -o hijackme32 + +all64: $(RELOBJ64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(RELOBJ32) $(RELOBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/rel.c eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/rel.c --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/rel.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/rel.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,71 @@ +/* +** rel.c for elfsh +** +** Contain all tests for ET_REL injection +** +** Started on Mon Jun 23 06:56:04 2003 jfv +** Last update Sun Aug 17 17:41:48 2003 jfv +** +** $Id: rel.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + + +int glvar_testreloc = 42; + +int glvar_testreloc_bss; +char glvar_testreloc_bss2; +short glvar_testreloc_bss3; + + + + +int hook_func(char *str) +{ + printf("HOOK FUNC %s !\n", str); + return (old_legit_func(str)); +} + + + +int puts_troj(char *str) +{ + int local = 1; + char *str2; + + int glvar_testreloc = 42; + + int glvar_testreloc_bss; + char glvar_testreloc_bss2; + short glvar_testreloc_bss3; + + + str2 = malloc(10); + *str2 = 'Z'; + *(str2 + 1) = 0x00; + + glvar_testreloc_bss = 43; + glvar_testreloc_bss2 = 44; + glvar_testreloc_bss3 = 45; + + printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", + str2, str, + glvar_testreloc, + glvar_testreloc_bss, + glvar_testreloc_bss2, + glvar_testreloc_bss3, + local); + + free(str2); + old_puts(str); + fflush(stdout); + return (0); +} + +int func2() +{ + return (42); +} diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/relinject32.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/relinject32.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/relinject32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/relinject32.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,9 @@ +#!../../../../elfsh/elfsh32 + +load hijackme32 +load rel.32.o +reladd 1 2 +redir puts puts_troj +redir legit_func hook_func +save fake_aout32 +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/relinject64.esh eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/relinject64.esh --- eresi-0.8a25/testsuite/elf/etrel_inject/etrel_static/relinject64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/etrel_static/relinject64.esh 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,9 @@ +#!../../../../elfsh/elfsh32 + +load hijackme64 +load rel.64.o +reladd 1 2 +redir puts puts_troj +redir legit_func hook_func +save fake_aout64 +quit diff -Nru eresi-0.8a25/testsuite/elf/etrel_inject/Makefile eresi-0.0.20110516/testsuite/elf/etrel_inject/Makefile --- eresi-0.8a25/testsuite/elf/etrel_inject/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/etrel_inject/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,37 @@ +## +## Makefile for ELF testsuite in ERESI +## +## Started on Sun Dec 15 01:34:42 2002 jfv +## $Id: Makefile 1310 2009-01-14 19:36:16Z may $ +## + +all: all32 all64 + +all32 : + @cd etrel_original && $(MAKE) all32 + @cd etrel_pie-ssp && $(MAKE) all32 + @cd etrel_static && $(MAKE) all32 + @cd etrel_extplt && $(MAKE) all32 + @cd etrel_extstatic && $(MAKE) all32 + +all64 : + @cd etrel_original && $(MAKE) all64 + @cd etrel_pie-ssp && $(MAKE) all64 + @cd etrel_static && $(MAKE) all64 + @cd etrel_extplt && $(MAKE) all64 + @cd etrel_extstatic && $(MAKE) all64 + +clean : + @cd etrel_original && $(MAKE) clean + @cd etrel_pie-ssp && $(MAKE) clean + @cd etrel_static && $(MAKE) clean + @cd etrel_extplt && $(MAKE) clean + @cd etrel_extstatic && $(MAKE) clean + +fclean : clean + @cd etrel_original && $(MAKE) fclean + @cd etrel_pie-ssp && $(MAKE) fclean + @cd etrel_static && $(MAKE) fclean + @cd etrel_extplt && $(MAKE) fclean + @cd etrel_extstatic && $(MAKE) fclean + diff -Nru eresi-0.8a25/testsuite/elf/extract_raw_data/load.c eresi-0.0.20110516/testsuite/elf/extract_raw_data/load.c --- eresi-0.8a25/testsuite/elf/extract_raw_data/load.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/extract_raw_data/load.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,86 @@ +#include +#include "libelfsh.h" + +int test = 42; + +/** + * + * + */ +int main(int ac, char **av) +{ + int idx; + + char *targets[] = + { +#if ERESI32 + "load32", + "load.32.o", +#elif ERESI64 + "load.64.o.64", +#endif + NULL + }; + + if (ac > 1) + test_binary(av[1]); + else + { + for (idx = 0; targets[idx] != NULL; idx++) + { + if (!(test_binary(targets[idx]))) + printf("ERR on %s\n", targets[idx]); + } + } +} + + +int test_binary(char *binary) +{ + elfshobj_t *obj; + void *ptr; + eresi_Addr start; + unsigned long len; + int ret; + int foffset; + int to_ret; + elfshsect_t *sect; + char *sym_name = ".data"; + + /** Load elfsh objet */ + obj = elfsh_load_obj(binary); + if (!obj) + { + printf("ERR failed loading object %s \n", binary); + return(0); + } + + /** Get file offset from that symbol */ + sect = elfsh_get_section_by_name(obj, sym_name, NULL, NULL, NULL); + if (!sect) + { + printf("ERR failed loading section %s", sym_name); + return (-1); + } + + foffset = sect->shdr->sh_offset; + len = sect->shdr->sh_size; + printf("INFO file offset of %s = %u len = %u\n", sym_name, foffset, len); + + ptr = malloc(len); + ret = elfsh_readmemf(obj, foffset, ptr, len); + printf("INFO raw_read returned %i\n", ret); + if (len != ret) + { + printf("ERR error : read only %i bytes on %i\n", ret, len); + profiler_error(); + to_ret = 0; + goto leave; + } + + to_ret = 1; + leave: + elfsh_unload_obj(obj); + return (to_ret); +} + diff -Nru eresi-0.8a25/testsuite/elf/extract_raw_data/Makefile eresi-0.0.20110516/testsuite/elf/extract_raw_data/Makefile --- eresi-0.8a25/testsuite/elf/extract_raw_data/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/extract_raw_data/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,34 @@ +SRCS = load.c +RM = rm -fr + +OBJ32 = $(SRCS:.c=.32.o) +OBJ64 = $(SRCS:.c=.64.o) +OBJ6464 = $(SRCS:.c=.64.o.64) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = load32 +NAME64 = load64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) -o $(NAME32) $(OBJ32) $(LDFLAGS32) + +all64: $(OBJ64) $(OBJ6464) + $(CC) -o $(NAME64) $(OBJ64) $(LDFLAGS64) + +fclean: clean + $(RM) $(NAME32) $(NAME64) +clean: + $(RM) $(OBJ32) $(OBJ64) $(OBJ6464) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g + +%.64.o.64: %.c + $(CC) -m64 -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/got_hijack/got_hijack.c eresi-0.0.20110516/testsuite/elf/got_hijack/got_hijack.c --- eresi-0.8a25/testsuite/elf/got_hijack/got_hijack.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/got_hijack/got_hijack.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,52 @@ +/* +** unlink.c for unlinked +** +** Started on Sun Mar 10 01:18:51 2002 jfv +** Last update Sun Mar 10 02:46:18 2002 jfv +** +** $Id: got_hijack.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include "libelfsh.h" + + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Sym *new_sleep; + int ret; + + file = elfsh_map_obj(TROJANED_FILE); + new_sleep = elfsh_get_symbol_by_name(file, "new_sleep"); + if (!file || !new_sleep) + { + elfsh_error(); + exit(-1); + } + + /* Try this to hijack got by index or the second one to hijack by name */ + //ret = elfsh_set_got_entry_by_index(file, 5, new_sleep->st_value); + ret = elfsh_set_got_entry_by_name(file, "sleep", new_sleep->st_value); + if (ret < 0) + { + elfsh_error(); + exit(-1); + } + + /* RELINKING THE FILE */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); +} + diff -Nru eresi-0.8a25/testsuite/elf/got_hijack/hijacked.c eresi-0.0.20110516/testsuite/elf/got_hijack/hijacked.c --- eresi-0.8a25/testsuite/elf/got_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/got_hijack/hijacked.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,18 @@ +/* +** +** $Id: hijacked.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +void new_sleep() +{ + printf("hijacked sleep ! \n"); +} + + +int main() +{ + printf("Main ! \n"); + sleep(5); +} diff -Nru eresi-0.8a25/testsuite/elf/got_hijack/Makefile eresi-0.0.20110516/testsuite/elf/got_hijack/Makefile --- eresi-0.8a25/testsuite/elf/got_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/got_hijack/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:55:43 2002 jfv +## + +include ../../../config.h + +SRC = got_hijack.c +CC = gcc +RM = rm -f +VULN = hijacked.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = got_hijacker32 +NAME64 = got_hijacker64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/hash_retreive/hash_read.c eresi-0.0.20110516/testsuite/elf/hash_retreive/hash_read.c --- eresi-0.8a25/testsuite/elf/hash_retreive/hash_read.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/hash_retreive/hash_read.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,36 @@ +/* +** hash_read.c for testsuite in ERESI +** +** Started on Sun Mar 10 01:18:51 2002 jfv +** $Id: hash_read.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./readme32" +#elif ERESI64 + #define TROJANED_FILE "./readme64" +#endif + +#define HASHED_SYMBOL "printf" + +int main(int argc, char **argv) +{ + elfshobj_t *file; + int ret; + char *name; + elfsh_Sym *sym; + + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + printf("Value for %s retreived from .hash: %8p \n", HASHED_SYMBOL, + elfsh_get_dynsymbol_by_hash(file, HASHED_SYMBOL)); + + return (0); +} + diff -Nru eresi-0.8a25/testsuite/elf/hash_retreive/main.c eresi-0.0.20110516/testsuite/elf/hash_retreive/main.c --- eresi-0.8a25/testsuite/elf/hash_retreive/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/hash_retreive/main.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,15 @@ +/* +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + + +int main() +{ + int a = (42 * 4 / 2 / 2); + + printf("Example program %u\n", a); + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/hash_retreive/Makefile eresi-0.0.20110516/testsuite/elf/hash_retreive/Makefile --- eresi-0.8a25/testsuite/elf/hash_retreive/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/hash_retreive/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:55:59 2002 jfv +## + +include ../../../config.h + +SRC = hash_read.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = hash_reader32 +NAME64 = hash_reader64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o readme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o readme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) readme* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/insert_tests.esh eresi-0.0.20110516/testsuite/elf/insert_tests.esh --- eresi-0.8a25/testsuite/elf/insert_tests.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/insert_tests.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,14 @@ +#!/usr/local/bin/elfsh + +exec rm /tmp/ls.new +load /bin/ls +e +sht +pht +insert phdr PT_GNU_STACK .dynamic 1.sht[.dynamic].size +e +sht +pht +save /tmp/ls.new +exec /tmp/ls.new +quit diff -Nru eresi-0.8a25/testsuite/elf/Makefile eresi-0.0.20110516/testsuite/elf/Makefile --- eresi-0.8a25/testsuite/elf/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,70 @@ +## +## Makefile for librevm in ERESI +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +include ../../config.h + +all : all32 all64 + +all32 : + $(MAKE) -C ctors_hijack all32 + $(MAKE) -C dtors_hijack all32 + $(MAKE) -C extract_raw_data all32 + $(MAKE) -C etrel_inject all32 + $(MAKE) -C hash_retreive all32 + $(MAKE) -C got_hijack all32 + $(MAKE) -C sct_index_injection all32 + $(MAKE) -C sct_fillbss_injection all32 + $(MAKE) -C sct_top_injection all32 + $(MAKE) -C sct_unmapped_injection all32 + $(MAKE) -C sht_stripping all32 + $(MAKE) -C sht_rebuild all32 + $(MAKE) -C symtab_extend all32 + +all64 : + $(MAKE) -C ctors_hijack all64 + $(MAKE) -C dtors_hijack all64 + $(MAKE) -C extract_raw_data all64 + $(MAKE) -C etrel_inject all64 + $(MAKE) -C hash_retreive all64 + $(MAKE) -C got_hijack all64 + $(MAKE) -C sct_index_injection all64 + $(MAKE) -C sct_fillbss_injection all64 + $(MAKE) -C sct_top_injection all64 + $(MAKE) -C sct_unmapped_injection all64 + $(MAKE) -C sht_stripping all64 + $(MAKE) -C sht_rebuild all64 + $(MAKE) -C symtab_extend all64 + +clean : + $(MAKE) -C ctors_hijack clean + $(MAKE) -C dtors_hijack clean + $(MAKE) -C extract_raw_data clean + $(MAKE) -C etrel_inject clean + $(MAKE) -C hash_retreive clean + $(MAKE) -C got_hijack clean + $(MAKE) -C sct_index_injection clean + $(MAKE) -C sct_fillbss_injection clean + $(MAKE) -C sct_top_injection clean + $(MAKE) -C sct_unmapped_injection clean + $(MAKE) -C sht_stripping clean + $(MAKE) -C sht_rebuild clean + $(MAKE) -C symtab_extend clean + +fclean : clean + $(MAKE) -C ctors_hijack fclean + $(MAKE) -C dtors_hijack fclean + $(MAKE) -C extract_raw_data fclean + $(MAKE) -C etrel_inject fclean + $(MAKE) -C hash_retreive fclean + $(MAKE) -C got_hijack fclean + $(MAKE) -C sct_index_injection fclean + $(MAKE) -C sct_fillbss_injection fclean + $(MAKE) -C sct_top_injection fclean + $(MAKE) -C sct_unmapped_injection fclean + $(MAKE) -C sht_stripping fclean + $(MAKE) -C sht_rebuild fclean + $(MAKE) -C symtab_extend fclean \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/elf/remap_script.esh eresi-0.0.20110516/testsuite/elf/remap_script.esh --- eresi-0.8a25/testsuite/elf/remap_script.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/remap_script.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,9 @@ +#!/usr/bin/elfsh + +load /bin/ls +modload modremap +findrel +remap 0x11223344 +save /tmp/ls.remapped +exec /tmp/ls.remapped +quit diff -Nru eresi-0.8a25/testsuite/elf/sct_fillbss_injection/main.c eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/main.c --- eresi-0.8a25/testsuite/elf/sct_fillbss_injection/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/main.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,29 @@ +/* +** main.c +** +** Started on Sun Mar 17 06:38:49 2002 jfv +** Last update Sat Mar 23 11:00:10 2002 jfv +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include + +int main() +{ + char *str; + int index; + + for (index = 0; index < 10; index++) + { + str = (char *) malloc(256); + memcpy(str, "test_heap", 9); + printf("%s [%u] \n", str, index); + } + + puts("End !"); + printf("Hijackme"); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/sct_fillbss_injection/Makefile eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/Makefile --- eresi-0.8a25/testsuite/elf/sct_fillbss_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for sinjectbss in testsuite of ERESI +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:56:15 2002 jfv +## + +include ../../../config.h + +SRC = section_inject.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = sinjectbss32 +NAME64 = sinjectbss64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/sct_fillbss_injection/section_inject.c eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/section_inject.c --- eresi-0.8a25/testsuite/elf/sct_fillbss_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_fillbss_injection/section_inject.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,129 @@ +/* +** sht_extend.c +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** Last update Mon May 19 13:11:32 2003 jfv +** +** $Id: section_inject.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + +/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ +#if defined(__linux__) + +char sc[] = +"\x31\xd2\x52\x68" +"\x6E\x2f\x73\x68" +"\x68\x2f\x2f\x62" +"\x69\x89\xe3\x52" +"\x53\x89\xe1\x8D" +"\x42\x0b\xcd\x80" +"\x31\xC0\x40\xcd\x80"; + +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) + +char sc[] = +"\xeb\x22" /* jmp end */ +"\x5e" /* beg: pop %esi */ +"\x31\xc0" /* xorl %eax, %eax */ +"\x88\x46\x07" /* movb %al , 0x7(%esi) */ +"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ +"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ +"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ +"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ +"\x52" /* push %edx */ +"\x51" /* push %ecx */ +"\x56" /* push %esi */ +"\x50" /* push %eax */ +"\xb0\x3b" /* movb $0x3b, %al */ +"\xcd\x80" /* int $0x80 */ +"\x31\xdb" /* xorl %ebx, %ebx */ +"\x89\xd8" /* movl %ebx, %eax */ +"\xfe\xc0" /* inc %al */ +"\xcd\x80" /* int $0x80 */ +"\xe8\xd9\xff\xff\xff" /* end: call beg */ +"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ + +#elif defined(sun) + +char sc[] = +"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" +"\x2b\x0b\xda\xdc\xae\x15\x63\x68" +"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" +"\x94\x10\x20\x10\x94\x22\xa0\x10" +"\x9c\x03\xa0\x14" +"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" +"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" +"\x91\xd0\x20\x08" ; + +#endif + + + +/* test for non-mapped data */ +char *str = "stop looking at me ! \n"; + + + +/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + elfsh_Sym *puts_troj; + + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + goto err; + + printf(" => Injection section and adding section header table entry ... \n"); + new = elfsh_create_section(".devhell"); + if (!new) + goto err; + + /* Create a section header for the mapped section */ + hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); + + /* Insert the section */ + if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_DATA_INJECTION, 0) < 0) + goto err; + + /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ + new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); + if (!new) + goto err; + + /* Hijack puts */ + elfsh_hijack_function_by_name(file, ELFSH_HIJACK_TYPE_GOT, + "puts", new->shdr->sh_addr, NULL); + + /* and finally save the object */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + + printf("Relinking *OK*\n"); + return (0); + + err: + elfsh_error(); + return (-1); +} + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/sct_index_injection/main.c eresi-0.0.20110516/testsuite/elf/sct_index_injection/main.c --- eresi-0.8a25/testsuite/elf/sct_index_injection/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_index_injection/main.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,9 @@ +/* +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +main() +{ +return (42); +} diff -Nru eresi-0.8a25/testsuite/elf/sct_index_injection/Makefile eresi-0.0.20110516/testsuite/elf/sct_index_injection/Makefile --- eresi-0.8a25/testsuite/elf/sct_index_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_index_injection/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Mon Jun 30 11:01:15 2003 jfv +## + +include ../../../config.h + +SRC = section_inject.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = sinjectidx32 +NAME64 = sinjectidx64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/sct_index_injection/section_inject.c eresi-0.0.20110516/testsuite/elf/sct_index_injection/section_inject.c --- eresi-0.8a25/testsuite/elf/sct_index_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_index_injection/section_inject.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,132 @@ +/* +** section_inject.c for testsuite in ERESI +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** $Id: section_inject.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + + +/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ +#if defined(__linux__) + +char sc[] = +"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" +"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" +"\xcd\x80\x31\xC0\x40\xcd\x80"; + +#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) + +char sc[] = +"\xeb\x22" /* jmp end */ +"\x5e" /* beg: pop %esi */ +"\x31\xc0" /* xorl %eax, %eax */ +"\x88\x46\x07" /* movb %al , 0x7(%esi) */ +"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ +"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ +"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ +"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ +"\x52" /* push %edx */ +"\x51" /* push %ecx */ +"\x56" /* push %esi */ +"\x50" /* push %eax */ +"\xb0\x3b" /* movb $0x3b, %al */ +"\xcd\x80" /* int $0x80 */ +"\x31\xdb" /* xorl %ebx, %ebx */ +"\x89\xd8" /* movl %ebx, %eax */ +"\xfe\xc0" /* inc %al */ +"\xcd\x80" /* int $0x80 */ +"\xe8\xd9\xff\xff\xff" /* end: call beg */ +"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ + +#elif defined(sun) + +char sc[] = +"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" +"\x2b\x0b\xda\xdc\xae\x15\x63\x68" +"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" +"\x94\x10\x20\x10\x94\x22\xa0\x10" +"\x9c\x03\xa0\x14" +"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" +"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" +"\x91\xd0\x20\x08" ; + +#endif + + + + +/* test for non-mapped data */ +char *str = "stop looking at me ! \n"; + + + +/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + + /* Create the ELFsh binary descriptor EBD */ + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + printf(" => Injection section and adding section header table entry ... \n"); + + /* Create the section descriptor (ESD) */ + new = elfsh_create_section(".devhell"); + if (!new) + { + elfsh_error(); + exit(-1); + } + + /* Create a section header for the mapped section */ + hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); + + /* Insert the section at index 20 */ + if (elfsh_insert_section_idx(file, new, hdr, sc, 24) < 0) + { + elfsh_error(); + exit(-1); + } + + /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ + new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); + if (!new) + { + elfsh_error(); + exit(-1); + } + + /* Now we save */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); + return (ret); +} + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/sct_top_injection/main.c eresi-0.0.20110516/testsuite/elf/sct_top_injection/main.c --- eresi-0.8a25/testsuite/elf/sct_top_injection/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_top_injection/main.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,33 @@ +/* +** main.c +** +** Started on Sun Mar 17 06:38:49 2002 jfv +** Last update Sat Mar 23 11:00:10 2002 jfv +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include +#include + +int main() +{ + char *str; + int index; + + for (index = 0; index < 10; index++) + { + str = (char *) malloc(10); + if (str == NULL) + goto err; + memcpy(str, "test_heap", 9); + printf("%s [%u] \n", str, index); + } + + puts("End !"); + return (0); + err: + puts("Malloc error"); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/sct_top_injection/Makefile eresi-0.0.20110516/testsuite/elf/sct_top_injection/Makefile --- eresi-0.8a25/testsuite/elf/sct_top_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_top_injection/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,50 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:56:15 2002 jfv +## + +include ../../../config.h + +SRC = section_inject.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = stopinject32 +NAME64 = stopinject64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/sct_top_injection/section_inject.c eresi-0.0.20110516/testsuite/elf/sct_top_injection/section_inject.c --- eresi-0.8a25/testsuite/elf/sct_top_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_top_injection/section_inject.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,109 @@ +/* +** section_inject.c for ERESI testsuite +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** $Id: section_inject.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + +/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ +#if defined(__linux__) + +char sc[] = +"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" +"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" +"\xcd\x80\x31\xC0\x40\xcd\x80"; + +#elif defined(__NetBSD__) + +char sc[] = +"\xeb\x0d\x5f\x31\xc0\x50\x89\xe2" +"\x52\x57\x54\xb0\x3b\xcd\x80\xe8" +"\xee\xff\xff\xff/bin/sh"; + +#elif defined(sun) + +char sc[] = +"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" +"\x2b\x0b\xda\xdc\xae\x15\x63\x68" +"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" +"\x94\x10\x20\x10\x94\x22\xa0\x10" +"\x9c\x03\xa0\x14" +"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" +"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" +"\x91\xd0\x20\x08" ; + +#else + #error "This feature is not available on this OS" +#endif + + + + +/* test for non-mapped data */ +char *str = "stop looking at me ! \n"; + + + +/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + + /* Create the ELFsh binary descriptor (EBD) */ + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + goto err; + + printf(" => Injection section and adding section header table entry ... \n"); + + /* Create the section descriptor (ESD) */ + new = elfsh_create_section(".devhell"); + if (!new) + goto err; + + /* Create a section header for the mapped section */ + hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); + + /* Insert the section */ + if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_CODE_INJECTION, + elfsh_get_pagesize(file)) < 0) + goto err; + + /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ + new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); + if (!new) + goto err; + + /* Hijack puts */ + ret = elfsh_hijack_function_by_name(file, + ELFSH_HIJACK_TYPE_PLT, + "puts", new->shdr->sh_addr, NULL); + if (ret < 0) + goto err; + + /* Now we save */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + goto err; + + printf("Relinking *OK*\n"); + return (0); + + err: + elfsh_error(); + return (-1); +} diff -Nru eresi-0.8a25/testsuite/elf/sct_unmapped_injection/main.c eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/main.c --- eresi-0.8a25/testsuite/elf/sct_unmapped_injection/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/main.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,28 @@ +/* +** main.c +** +** Started on Sun Mar 17 06:38:49 2002 jfv +** Last update Sat Mar 23 11:00:10 2002 jfv +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include + +int main() +{ + char *str; + int index; + + for (index = 0; index < 10; index++) + { + str = (char *) malloc(256); + memcpy(str, "test_heap", 9); + printf("%s [%u] \n", str, index); + } + + puts("End !"); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/sct_unmapped_injection/Makefile eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/Makefile --- eresi-0.8a25/testsuite/elf/sct_unmapped_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:56:15 2002 jfv +## + +include ../../../config.h + +SRC = section_inject.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = sinjectunmapped32 +NAME64 = sinjectunmapped64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/sct_unmapped_injection/section_inject.c eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/section_inject.c --- eresi-0.8a25/testsuite/elf/sct_unmapped_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sct_unmapped_injection/section_inject.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,73 @@ +/* +** section_injection.c +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** Last update Mon May 19 13:12:23 2003 jfv +** +** $Id: section_inject.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define TROJANED_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + + +/* test for non-mapped data */ +char *str = "stop looking at me ! \n"; + +/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + printf(" => Injection section and adding section header table entry ... \n"); + + /* Create a new unmapped section */ + unmapped_new = elfsh_create_section(".dhstrtab"); + if (!unmapped_new) + { + elfsh_error(); + exit(-1); + } + + /* Create a new section header */ + unmapped_hdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, strlen(str), 0, 0, 0, 0); + if (elfsh_insert_unmapped_section(file, unmapped_new, unmapped_hdr, str) < 0) + { + elfsh_error(); + exit(-1); + } + + /* Finally save the object */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); + return (ret); +} + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/sections_flush.esh eresi-0.0.20110516/testsuite/elf/sections_flush.esh --- eresi-0.8a25/testsuite/elf/sections_flush.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sections_flush.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,10 @@ +#!/usr/bin/elfsh + +load fake_aout +remove sect .orig.plt +remove sect rel.o.rodata.str1.1 +remove sect rel.o.rodata.str1.32 +remove sect rel.o.text +remove sect rel.o.data +save new_aout +quit diff -Nru eresi-0.8a25/testsuite/elf/sht_rebuild/Makefile eresi-0.0.20110516/testsuite/elf/sht_rebuild/Makefile --- eresi-0.8a25/testsuite/elf/sht_rebuild/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sht_rebuild/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,41 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:56:29 2002 jfv +## + +include ../../../config.h + +SRC = sht_rebuild.c +CC = gcc +RM = rm -f + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = shtrebuild32 +NAME64 = shtrebuild64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + +fclean: clean + $(RM) $(NAME32) $(NAME64) + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/sht_rebuild/sht_rebuild.c eresi-0.0.20110516/testsuite/elf/sht_rebuild/sht_rebuild.c --- eresi-0.8a25/testsuite/elf/sht_rebuild/sht_rebuild.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sht_rebuild/sht_rebuild.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,55 @@ +/* +** sht_rebuild.c for testsuite in ERESI +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** $Id: sht_rebuild.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" +#include + +#if ERESI32 + #define TROJANED_FILE "./shtstripped32" + #define OUTPUT_FILE "./shtrebuilt32" +#elif ERESI64 + #define TROJANED_FILE "./shtstripped64" + #define OUTPUT_FILE "./shtrebuilt64" +#endif + +/* We just map and save the object since ELFsh automatically rebuid SHT */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + + /* map the object */ + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + /* Get (and reconstruct if unexistant) SHT and SYMTAB */ + elfsh_get_sht(file, NULL); + elfsh_get_symtab(file, NULL); + + /* Save the object */ + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); + +} + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/sht_stripping/main.c eresi-0.0.20110516/testsuite/elf/sht_stripping/main.c --- eresi-0.8a25/testsuite/elf/sht_stripping/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sht_stripping/main.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,28 @@ +/* +** main.c +** +** Started on Sun Mar 17 06:38:49 2002 jfv +** Last update Sat Mar 23 11:00:10 2002 jfv +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include +#include + +int main() +{ + char *str; + int index; + + for (index = 0; index < 10; index++) + { + str = (char *) malloc(256); + memcpy(str, "test_heap", 9); + printf("%s [%u] \n", str, index); + } + + puts("End !"); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/sht_stripping/Makefile eresi-0.0.20110516/testsuite/elf/sht_stripping/Makefile --- eresi-0.8a25/testsuite/elf/sht_stripping/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sht_stripping/Makefile 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,44 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun Dec 15 01:56:52 2002 jfv +## + +include ../../../config.h + +SRC = sht_removing.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = shtstripper32 +NAME64 = shtstripper64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o shtstripme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o shtstripme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) shtstripme* shtstripped* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/sht_stripping/sht_removing.c eresi-0.0.20110516/testsuite/elf/sht_stripping/sht_removing.c --- eresi-0.8a25/testsuite/elf/sht_stripping/sht_removing.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/sht_stripping/sht_removing.c 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,55 @@ +/* +** sht_removing.c for testsuite in ERESI +** +** Started on Sun Mar 17 05:57:23 2002 jfv +** $Id: sht_removing.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + +#if ERESI32 + #define TROJANED_FILE "./shtstripme32" + #define OUTPUT_FILE "./shtstripped32" +#elif ERESI64 + #define TROJANED_FILE "./shtstripme64" + #define OUTPUT_FILE "./shtstripped64" +#endif + +/* Here we map, remove sht, and save the binary */ +int main(int argc, char **argv) +{ + elfshobj_t *file; + elfsh_Shdr hdr; + elfsh_Shdr unmapped_hdr; + elfshsect_t *new; + elfshsect_t *unmapped_new; + int ret; + + file = elfsh_map_obj(TROJANED_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + printf("=> Removing the Section header table \n"); + elfsh_remove_sht(file); + + /***********************************************************/ + /************************ RELINKING ************************/ + /***********************************************************/ + + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); + +} + + + + + + + diff -Nru eresi-0.8a25/testsuite/elf/symtab_extend/execve.s eresi-0.0.20110516/testsuite/elf/symtab_extend/execve.s --- eresi-0.8a25/testsuite/elf/symtab_extend/execve.s 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/symtab_extend/execve.s 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,31 @@ +; lame execve() shell / spoty +section .text + +global _start + +_start: +jmp short L1 +L0: + mov ebx,[esp] ;get /bin/sh + xor edx,edx + push dword edx ;here we need argv[0] + push dword ebx + push dword edx ;push dword 0 + push esp + push dword ebx ;/bin/sh + mov al,59 ;#define SYS_execve 59 + push eax + + int 0x80 + + push dword edx ;push dword 0 + push dword ebx ;/bin/sh + xor eax,eax + inc eax ;mov eax,1 + push eax + int 0x80 + +L1: + call L0 + shell db "/bin/sh",0x0 + arg db "-i",0x0 diff -Nru eresi-0.8a25/testsuite/elf/symtab_extend/main.c eresi-0.0.20110516/testsuite/elf/symtab_extend/main.c --- eresi-0.8a25/testsuite/elf/symtab_extend/main.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/symtab_extend/main.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,12 @@ +/* +** +** $Id: main.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +int main() +{ + printf("Example program . \n"); + return (0); +} diff -Nru eresi-0.8a25/testsuite/elf/symtab_extend/Makefile eresi-0.0.20110516/testsuite/elf/symtab_extend/Makefile --- eresi-0.8a25/testsuite/elf/symtab_extend/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/symtab_extend/Makefile 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,45 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun May 25 18:04:33 2003 jfv +## + +include ../../../config.h + + +SRC = symtab_extend.c +CC = gcc +RM = rm -f +VULN = main.c + +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +CFLAGS32 =$(shell eresi-config32 libelfsh --cflags) +LDFLAGS32 =$(shell eresi-config32 libelfsh --libs) +CFLAGS64 =$(shell eresi-config64 libelfsh --cflags) +LDFLAGS64 =$(shell eresi-config64 libelfsh --libs) +NAME32 = symtabextend32 +NAME64 = symtabextend64 + +all: all32 all64 + +all32: $(OBJ32) + $(CC) $(LDFLAGS32) $(OBJ32) -o $(NAME32) + $(CC) $(VULN) -o hijackme32 + +all64: $(OBJ64) + $(CC) $(LDFLAGS64) $(OBJ64) -o $(NAME64) + $(CC) -m64 $(VULN) -o hijackme64 + +fclean: clean + $(RM) $(NAME32) $(NAME64) hijackme* fake_aout* + +clean: + $(RM) $(OBJ32) $(OBJ64) *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g diff -Nru eresi-0.8a25/testsuite/elf/symtab_extend/symtab_extend.c eresi-0.0.20110516/testsuite/elf/symtab_extend/symtab_extend.c --- eresi-0.8a25/testsuite/elf/symtab_extend/symtab_extend.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/elf/symtab_extend/symtab_extend.c 2011-05-16 11:34:57.000000000 +0000 @@ -0,0 +1,63 @@ +/* +** symtab_extend.c for ERESI testsuite +** +** Started on Sun Mar 10 01:18:51 2002 jfv +** $Id: symtab_extend.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include "libelfsh.h" + + +#if ERESI32 + #define INPUT_FILE "./hijackme32" + #define OUTPUT_FILE "./fake_aout32" +#elif ERESI64 + #define INPUT_FILE "./hijackme64" + #define OUTPUT_FILE "./fake_aout64" +#endif + +int main(int argc, char **argv) +{ + elfshobj_t *file; + int ret; + elfsh_Sym sym; + char name[256]; + u_int idx; + + file = elfsh_map_obj(INPUT_FILE); + if (!file) + { + elfsh_error(); + exit(-1); + } + + /***********************************************************/ + /**************** TEST FOR SYMTAB + STRTAB INJECTION *******/ + /***********************************************************/ + + printf("Writing string in .strtab and adding symbol in .symtab \n"); + + for (idx = 0; idx < 50; idx++) + { + snprintf(name, sizeof(name), "%s_%u", "DH0WNZ", idx); + sym = elfsh_create_symbol(0x42424242, 21, STT_FUNC, 0, 0, 0); + ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &sym, name); + if (ret < 0) + { + elfsh_error(); + exit(-1); + } + } + + + /***********************************************************/ + /************************ RELINKING ************************/ + /***********************************************************/ + + ret = elfsh_save_obj(file, OUTPUT_FILE); + if (ret < 0) + elfsh_error(); + + printf("Relinking *%s* \n", ret ? "Error" : "OK"); + return (0); +} + diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/host.c eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/host.c --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/host.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/Makefile eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/Makefile --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -CC = gcc -LIB = -L../../../libelfsh/ -lelfsh -L../../../libhash/ -lhashelfsh -L../../../libasm -lasm - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -OPT = -g3 -O2 -I../../../libelfsh/include/ $(BITS) -RM = rm -f -CFLAGS = $(OPT) -I../../../libhash/include/ - -all : - $(MAKE) -C ../../../ - @/sbin/paxctl -m ../../../vm/elfsh - $(CC) $(OPT) $(HOSTSRC) -static - #@strip a.out - - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout core diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/rel.c eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/rel.c --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/rel.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/rel.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - int glvar_testreloc = 42; - - int glvar_testreloc_bss; - char glvar_testreloc_bss2; - short glvar_testreloc_bss3; - - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - - old_puts(str); - - - write(1, "calling write\n", 14); - - - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/relinject.esh eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/relinject.esh --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/relinject.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/relinject.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../../vm/elfsh - -load a.out -load rel.o - -#profile -reladd 1 2 -#profile -redir puts puts_troj -redir legit_func hook_func - -# redir hook_func old_legit_func - -save fake_aout - -exec /sbin/paxctl -p -e -m -r -x -s ./fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/et_rel2static -END -rel.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/et_rel2static/rel.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/et_rel2static/Makefile -END -relinject.esh -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/12/trunk/testsuite/etrel_inject/et_rel2static/relinject.esh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/et_rel2static/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/et_rel2static -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -rel.c -file - - - - -2008-04-06T23:15:41.387147Z -849e08e4e4f01d7be9c2873a82d3be83 -2007-07-31T03:28:48.000000Z -749 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:41.408310Z -c56fec80ad5ff6fdb7688aa0a2f5d14a -2007-07-31T03:28:48.000000Z -749 -may -has-props - -relinject.esh -file - - - - -2008-04-06T23:15:41.420137Z -d52d8aef51917472156348b66492e015 -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -host.c -file - - - - -2008-04-06T23:15:41.431146Z -f4e14bb002a69a71b42190bfbfaac9fd -2007-03-07T16:45:36.000000Z -502 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/rel.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/prop-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/prop-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ - -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -CC = gcc -LIB = -L../../../libelfsh/ -lelfsh -L../../../libhash/ -lhashelfsh -L../../../libasm -lasm - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -OPT = -g3 -O2 -I../../../libelfsh/include/ $(BITS) -RM = rm -f -CFLAGS = $(OPT) -I../../../libhash/include/ - -all : - $(MAKE) -C ../../../ - @/sbin/paxctl -m ../../../vm/elfsh - $(CC) $(OPT) $(HOSTSRC) -static - #@strip a.out - - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout core diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/rel.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - int glvar_testreloc = 42; - - int glvar_testreloc_bss; - char glvar_testreloc_bss2; - short glvar_testreloc_bss3; - - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - - old_puts(str); - - - write(1, "calling write\n", 14); - - - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/et_rel2static/.svn/text-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/et_rel2static/.svn/text-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../../vm/elfsh - -load a.out -load rel.o - -#profile -reladd 1 2 -#profile -redir puts puts_troj -redir legit_func hook_func - -# redir hook_func old_legit_func - -save fake_aout - -exec /sbin/paxctl -p -e -m -r -x -s ./fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/gdb.script eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/gdb.script --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/gdb.script 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/gdb.script 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - -file ./fake_aout -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/mips/ -b main -r -display/1x $pc -while 1 -stepi -end - -#echo Printing relative offset from real GP value -#x/26x $gp-0x8000+0x10 -#echo Printing original GOT -#x/26x 0x10000050 -#echo Printing ALTGOT -#x/26x 0x10000170 -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host1.c eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host1.c --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host1.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host1.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* -** -** $Id: host1.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - free(str); - printf("Second_printf %u\n", 42); - puts("Second_puts"); - fflush(stdout); - printf("End of main %s \n", "hehe"); - return (0); - err: - printf("Malloc problem %u\n", 42); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host2.c eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host2.c --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host2.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: host2.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - - - -int new_puts(char *str) -{ - printf("hijacked puts !\n"); - return (0); -} - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf\n"); - puts("Second_puts"); - fflush(stdout); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host3.c eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host3.c --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/host3.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/host3.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** -** $Id: host3.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - - -int hook_func(char *str) -{ - printf("hook func %s !\n", str); - return (0); -} - -int legit_func(char *str) -{ - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf\n"); - puts("Second_puts"); - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel4alpha -END -gdb.script -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/12/trunk/testsuite/etrel_inject/etrel4alpha/gdb.script -END -host1.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel4alpha/host1.c -END -host2.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel4alpha/host2.c -END -host3.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel4alpha/host3.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel4alpha -http://svn.eresi-project.org/svn - - - -2007-03-07T16:45:36.000000Z -502 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -gdb.script -file - - - - -2008-04-06T23:15:41.585881Z -a8d0fc06b9bead8bdf239ded143abd7c -2005-08-02T06:43:53.000000Z -12 -thor - -host1.c -file - - - - -2008-04-06T23:15:41.633901Z -00ad3f2174b37f49f29549347a2f9318 -2007-03-07T16:45:36.000000Z -502 -thor -has-props - -host2.c -file - - - - -2008-04-06T23:15:41.646052Z -f46bcf13c981803d90104d0fa9955fbc -2007-03-07T16:45:36.000000Z -502 -thor -has-props - -host3.c -file - - - - -2008-04-06T23:15:41.657427Z -dd814fe687db28d4c35fd610cb3a21f1 -2007-03-07T16:45:36.000000Z -502 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host1.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host1.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host1.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host2.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host2.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host2.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host3.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host3.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host3.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/prop-base/host3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/gdb.script.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/gdb.script.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/gdb.script.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/gdb.script.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ - -file ./fake_aout -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/mips/ -b main -r -display/1x $pc -while 1 -stepi -end - -#echo Printing relative offset from real GP value -#x/26x $gp-0x8000+0x10 -#echo Printing original GOT -#x/26x 0x10000050 -#echo Printing ALTGOT -#x/26x 0x10000170 -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host1.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host1.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host1.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -/* -** -** $Id: host1.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - free(str); - printf("Second_printf %u\n", 42); - puts("Second_puts"); - fflush(stdout); - printf("End of main %s \n", "hehe"); - return (0); - err: - printf("Malloc problem %u\n", 42); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host2.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host2.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host2.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -/* -** -** $Id: host2.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - - - -int new_puts(char *str) -{ - printf("hijacked puts !\n"); - return (0); -} - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf\n"); - puts("Second_puts"); - fflush(stdout); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host3.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host3.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host3.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel4alpha/.svn/text-base/host3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** -** $Id: host3.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - - -int hook_func(char *str) -{ - printf("hook func %s !\n", str); - return (0); -} - -int legit_func(char *str) -{ - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf\n"); - puts("Second_puts"); - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/debug.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/debug.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/debug.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/debug.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/bin/sh - -../../../vm/elfsh -f fake_aout -sym 'legit|hook' -./relinject.esh > ./relinject.out -grep CFLOW relinject.out -../../../vm/elfsh -f fake_aout -D legit_func%5 -exit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/etrel_inject.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/etrel_inject.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/etrel_inject.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/etrel_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** etrel_inject.c for testsuite in elfsh -** -** Started on Sat May 10 07:01:59 2003 jfv -** Last update Mon Jun 30 07:38:12 2003 jfv -** -** $Id: etrel_inject.c,v 1.4 2007-11-28 07:56:09 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "a.out" -#define RELOC_FILE "rel.o" -#define OUTPUT_FILE "fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *host; - elfshobj_t *rel; - elfshsect_t *txtsect; - elfsh_Sym *puts_troj; - int idx; - u_long addr; - - /* Map host file and relocatable file */ - rel = elfsh_map_obj(RELOC_FILE); - if (NULL == rel) - goto err; - host = elfsh_map_obj(TROJANED_FILE); - if (NULL == host) - goto err; - - /* Inject etrel */ - idx = elfsh_inject_etrel(host, rel); - if (idx < 0) - goto err; - - /* Get injected's section info */ - txtsect = elfsh_get_section_by_name(host, "rel.o.text", NULL, NULL, NULL); - if (txtsect == NULL) - goto err; - - puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); - idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, - "puts", puts_troj->st_value, - NULL); - - /* Save it */ - idx = elfsh_save_obj(host, OUTPUT_FILE); - if (idx < 0) - goto err; - - puts("[*] ET_REL injected"); - return (0); - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/gdb.script eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/gdb.script --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/gdb.script 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/gdb.script 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - -file main -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/i386/ -b *0x4000660 -r -display/1x $pc -while 1 -stepi -end - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/host.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/host.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/host.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/Makefile eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/Makefile --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -SRC = etrel_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc - -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm \ - -L../../../liballocproxy -lallocproxy -L../../../libaspect/ \ - -laspect32 -lpthread -L../../../libetrace -letrace32 -OPT = -O2 -I../../../libelfsh/include/ -I../../../libmjollnir/include/ \ - -I../../../libaspect/include/ $(BITS) -g3 - -NAM = etrel_injecter -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -RM = rm -f -CFLAGS = $(OPT) -PAXCTL = /sbin/paxctl - -all : $(OBJ) - $(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - $(CC) $(OPT) $(HOSTSRC) #-m64 - #@strip a.out - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - - @$(PAXCTL) -m -s -p -r -x ../../../vm/elfsh 2>/dev/null || \ - echo Test compiled succesfully. You can also install paxctl for pax tests. - @$(PAXCTL) -v ../../../vm/elfsh 2>/dev/null || true - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/rel.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/rel.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/rel.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/rel.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - putchar('e'); - putchar('x'); - putchar('t'); - putchar('c'); - putchar('a'); - putchar('l'); - putchar('l'); - putchar('!'); - putchar('\n'); - old_puts(str); - write(1, "calling write\n", 14); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/relinject.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/relinject.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/relinject.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/relinject.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../../elfsh/elfsh32 - -load a.out -load rel.o - -#stop -#profile enable warn -#profile enable trace -quiet - -reladd 1 2 - -dynsym puts -sym puts -#profile enable warn -redir puts puts_troj -redir legit_func hook_func - -save fake_aout -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,47 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/830/trunk/testsuite/etrel_inject/etrel_extplt -END -gdb.script -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/21/trunk/testsuite/etrel_inject/etrel_extplt/gdb.script -END -rel.c -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_extplt/rel.c -END -debug.esh -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/21/trunk/testsuite/etrel_inject/etrel_extplt/debug.esh -END -etrel_inject.c -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/823/trunk/testsuite/etrel_inject/etrel_extplt/etrel_inject.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/830/trunk/testsuite/etrel_inject/etrel_extplt/Makefile -END -relinject.esh -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/823/trunk/testsuite/etrel_inject/etrel_extplt/relinject.esh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel_extplt/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,118 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel_extplt -http://svn.eresi-project.org/svn - - - -2007-11-29T14:01:56.000000Z -830 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -gdb.script -file - - - - -2008-04-06T23:15:41.720132Z -73746d73796f0ab727ec750701d16639 -2005-10-02T22:30:24.000000Z -21 -thor - -rel.c -file - - - - -2008-04-06T23:15:41.751136Z -2eb542e454822eea0c69b035e4e6320c -2007-07-31T03:28:48.000000Z -749 -may -has-props - -debug.esh -file - - - - -2008-04-06T23:15:41.763274Z -86a57f196be35ec0f9527fe1b1050e66 -2005-10-02T22:30:24.000000Z -21 -thor -has-props - -etrel_inject.c -file - - - - -2008-04-06T23:15:41.773904Z -40128804393283fa3e0f696d86f7019c -2007-11-28T07:56:09.000000Z -823 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:41.785903Z -6d89bb029379f419ca84c82b2ad438d1 -2007-11-29T14:01:56.000000Z -830 -may -has-props - -relinject.esh -file - - - - -2008-04-06T23:15:41.797246Z -6c6a116750aea477f5f53a71ddb33c23 -2007-11-28T07:56:09.000000Z -823 -may -has-props - -host.c -file - - - - -2008-04-06T23:15:41.808877Z -f4e14bb002a69a71b42190bfbfaac9fd -2007-03-07T16:45:36.000000Z -502 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/debug.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/debug.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/debug.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/debug.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/etrel_inject.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/etrel_inject.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/etrel_inject.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/etrel_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/rel.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/prop-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/debug.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/debug.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/debug.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/debug.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/bin/sh - -../../../vm/elfsh -f fake_aout -sym 'legit|hook' -./relinject.esh > ./relinject.out -grep CFLOW relinject.out -../../../vm/elfsh -f fake_aout -D legit_func%5 -exit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/etrel_inject.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/etrel_inject.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/etrel_inject.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/etrel_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** etrel_inject.c for testsuite in elfsh -** -** Started on Sat May 10 07:01:59 2003 jfv -** Last update Mon Jun 30 07:38:12 2003 jfv -** -** $Id: etrel_inject.c,v 1.4 2007-11-28 07:56:09 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "a.out" -#define RELOC_FILE "rel.o" -#define OUTPUT_FILE "fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *host; - elfshobj_t *rel; - elfshsect_t *txtsect; - elfsh_Sym *puts_troj; - int idx; - u_long addr; - - /* Map host file and relocatable file */ - rel = elfsh_map_obj(RELOC_FILE); - if (NULL == rel) - goto err; - host = elfsh_map_obj(TROJANED_FILE); - if (NULL == host) - goto err; - - /* Inject etrel */ - idx = elfsh_inject_etrel(host, rel); - if (idx < 0) - goto err; - - /* Get injected's section info */ - txtsect = elfsh_get_section_by_name(host, "rel.o.text", NULL, NULL, NULL); - if (txtsect == NULL) - goto err; - - puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); - idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, - "puts", puts_troj->st_value, - NULL); - - /* Save it */ - idx = elfsh_save_obj(host, OUTPUT_FILE); - if (idx < 0) - goto err; - - puts("[*] ET_REL injected"); - return (0); - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/gdb.script.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/gdb.script.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/gdb.script.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/gdb.script.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - -file main -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/i386/ -b *0x4000660 -r -display/1x $pc -while 1 -stepi -end - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -SRC = etrel_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc - -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm \ - -L../../../liballocproxy -lallocproxy -L../../../libaspect/ \ - -laspect32 -lpthread -L../../../libetrace -letrace32 -OPT = -O2 -I../../../libelfsh/include/ -I../../../libmjollnir/include/ \ - -I../../../libaspect/include/ $(BITS) -g3 - -NAM = etrel_injecter -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -RM = rm -f -CFLAGS = $(OPT) -PAXCTL = /sbin/paxctl - -all : $(OBJ) - $(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - $(CC) $(OPT) $(HOSTSRC) #-m64 - #@strip a.out - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - - @$(PAXCTL) -m -s -p -r -x ../../../vm/elfsh 2>/dev/null || \ - echo Test compiled succesfully. You can also install paxctl for pax tests. - @$(PAXCTL) -v ../../../vm/elfsh 2>/dev/null || true - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/rel.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - putchar('e'); - putchar('x'); - putchar('t'); - putchar('c'); - putchar('a'); - putchar('l'); - putchar('l'); - putchar('!'); - putchar('\n'); - old_puts(str); - write(1, "calling write\n", 14); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_extplt/.svn/text-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_extplt/.svn/text-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../../elfsh/elfsh32 - -load a.out -load rel.o - -#stop -#profile enable warn -#profile enable trace -quiet - -reladd 1 2 - -dynsym puts -sym puts -#profile enable warn -redir puts puts_troj -redir legit_func hook_func - -save fake_aout -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.elfsh_history eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.elfsh_history --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.elfsh_history 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.elfsh_history 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -source etrelmem.esh diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/etrelmem.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/etrelmem.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/etrelmem.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/etrelmem.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../../elfsh/elfsh32 - -load myputs.o -switch 1 -mode dynamic - -#dynsym -#sym - -#profile enable warn - -reladd 1 myputs.o - -redir puts myputs -redir legit_func new_legit_func -D new_legit_func -start - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/host.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/host.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/host.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** -** $Id: host.c,v 1.4 2007-08-03 18:05:03 may Exp $ -** -*/ -#include -#include -#include -#include - -int legit_func(char *str) -{ - char buff[BUFSIZ]; - - snprintf(buff, BUFSIZ, "coucou %s\n", str); - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main(int argc, char **argv) -{ - char *str; - char buff[BUFSIZ]; - - printf ("[host] main argc %d\n", argc); - printf("[host] argv[0] is : %s\n", argv[0]); - - if (argc == 2) - printf("[host] argv[1] is : %s\n", argv[1]); - - //read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/Makefile eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/Makefile --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -CC = gcc -RM = rm -f - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o -RTSRC = myputs.c -RTOBJ = myputs.o -PIEBIN = pie-test - -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm -L../../../elibc \ - -lcelfsh32 -L../../../liballocproxy -lallocproxy -L../../../libaspect/ \ - -laspect32 -lpthread -OPT = -g3 -O2 -I../../../libelfsh/include/ -I../../../libmjollnir/include/ \ - -I../../../libaspect/include/ $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - $(CC) $(OPT) $(HOSTSRC) - #@strip a.out - $(CC) $(OPT) $(HOSTSRC) -pie -o $(PIEBIN) - #@strip $(PIEBIN) - $(CC) $(OPT) $(RTSRC) -o $(RTOBJ) -c - @echo Now run etrelmem.esh inside e2dbg - -clean : - $(RM) $(RTOBJ) $(OBJ) *~ \#* *\# $(RELOBJ) - -fclean : clean - $(RM) $(NAM) a.out $(PIEBIN) diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/myputs.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/myputs.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/myputs.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/myputs.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: myputs.c,v 1.3 2007-08-03 18:05:03 may Exp $ -** -*/ -#include - -int myputs(char *str) -{ - printf("Hijacked puts !!! arg = %s \n", str); - putchar('e'); - putchar('x'); - putchar('t'); - putchar('c'); - putchar('a'); - putchar('l'); - putchar('l'); - putchar('!'); - putchar('\n'); - return (old_puts(str)); -} - -int new_legit_func(char *str) -{ - printf("Hijacked legit_func !!! (param = %s) \n", str); - return (old_legit_func(str)); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/script.sh eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/script.sh --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/script.sh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/script.sh 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!/bin/sh - -test $# -ne 1 && echo "usage : "$0" file" && exit 0 - -DT=`../../../vm/elfsh -f $1 -d | grep DT_DEBUG | awk -F"[][]" '{ print $2;}'` - -PRG=$1 - -echo "#!../../../vm/elfsh" > inject_e2dbg.esh -echo "load "$1 >> inject_e2dbg.esh -echo "set 1.dynamic["$DT"].val 0x2" >> inject_e2dbg.esh -echo "set 1.dynamic["$DT"].tag DT_NEEDED" >> inject_e2dbg.esh -echo "redir main e2dbg_run" >> inject_e2dbg.esh -echo "save "$1"_e2dbg" >> inject_e2dbg.esh -echo "" >> inject_e2dbg.esh - -echo "#!../../../vm/elfsh" > etrelmem.esh -echo "load myputs.o" >> etrelmem.esh -echo "switch 1" >> etrelmem.esh -echo "mode dynamic" >> etrelmem.esh -echo "reladd 1 10" >> etrelmem.esh -#echo "quiet s" >> etrelmem.esh -echo "profile" >> etrelmem.esh -echo "redir puts myputs" >> etrelmem.esh -#echo "redir printf e2dbg_sigint_handler" >> etrelmem.esh -echo "profile" >> etrelmem.esh -echo "" >> etrelmem.esh - -chmod ugo+x inject_e2dbg.esh - -./inject_e2dbg.esh > inject_e2dbg.out - -/sbin/paxctl -p -m -s -r -x $PRG"_e2dbg" - -./$PRG"_e2dbg" - - - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/780/trunk/testsuite/etrel_inject/etrel_memory -END -.elfsh_history -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/780/trunk/testsuite/etrel_inject/etrel_memory/.elfsh_history -END -myputs.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/762/trunk/testsuite/etrel_inject/etrel_memory/myputs.c -END -etrelmem.esh -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/780/trunk/testsuite/etrel_inject/etrel_memory/etrelmem.esh -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/762/trunk/testsuite/etrel_inject/etrel_memory/Makefile -END -script.sh -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/12/trunk/testsuite/etrel_inject/etrel_memory/script.sh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/762/trunk/testsuite/etrel_inject/etrel_memory/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel_memory -http://svn.eresi-project.org/svn - - - -2007-08-25T17:13:05.000000Z -780 -mxatone - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -.elfsh_history -file - - - - -2008-04-06T23:15:41.248147Z -c4a50aa59e34f01579a5e4ab70a3a9c3 -2007-08-25T17:13:05.000000Z -780 -mxatone - -myputs.c -file - - - - -2008-04-06T23:15:41.281901Z -38a0fc70f8021419358f909221a2a277 -2007-08-03T18:05:03.000000Z -762 -may - -etrelmem.esh -file - - - - -2008-04-06T23:15:41.292899Z -301927982b83441dfe4e202287d092f4 -2007-08-25T17:13:05.000000Z -780 -mxatone -has-props - -Makefile -file - - - - -2008-04-06T23:15:41.305163Z -f51669f6122aced918db0f877ca7a4ad -2007-08-03T18:05:03.000000Z -762 -may -has-props - -script.sh -file - - - - -2008-04-06T23:15:41.316564Z -b91c54b4f26c4cfacfcb0de8fba078c1 -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -host.c -file - - - - -2008-04-06T23:15:41.327909Z -8c0e01d2070cff3c2686e820bdc514f0 -2007-08-03T18:05:03.000000Z -762 -may -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/etrelmem.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/etrelmem.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/etrelmem.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/etrelmem.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/script.sh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/script.sh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/prop-base/script.sh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/prop-base/script.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/.elfsh_history.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/.elfsh_history.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/.elfsh_history.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/.elfsh_history.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -source etrelmem.esh diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/etrelmem.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/etrelmem.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/etrelmem.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/etrelmem.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../../elfsh/elfsh32 - -load myputs.o -switch 1 -mode dynamic - -#dynsym -#sym - -#profile enable warn - -reladd 1 myputs.o - -redir puts myputs -redir legit_func new_legit_func -D new_legit_func -start - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** -** $Id: host.c,v 1.4 2007-08-03 18:05:03 may Exp $ -** -*/ -#include -#include -#include -#include - -int legit_func(char *str) -{ - char buff[BUFSIZ]; - - snprintf(buff, BUFSIZ, "coucou %s\n", str); - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main(int argc, char **argv) -{ - char *str; - char buff[BUFSIZ]; - - printf ("[host] main argc %d\n", argc); - printf("[host] argv[0] is : %s\n", argv[0]); - - if (argc == 2) - printf("[host] argv[1] is : %s\n", argv[1]); - - //read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -CC = gcc -RM = rm -f - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o -RTSRC = myputs.c -RTOBJ = myputs.o -PIEBIN = pie-test - -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm -L../../../elibc \ - -lcelfsh32 -L../../../liballocproxy -lallocproxy -L../../../libaspect/ \ - -laspect32 -lpthread -OPT = -g3 -O2 -I../../../libelfsh/include/ -I../../../libmjollnir/include/ \ - -I../../../libaspect/include/ $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - $(CC) $(OPT) $(HOSTSRC) - #@strip a.out - $(CC) $(OPT) $(HOSTSRC) -pie -o $(PIEBIN) - #@strip $(PIEBIN) - $(CC) $(OPT) $(RTSRC) -o $(RTOBJ) -c - @echo Now run etrelmem.esh inside e2dbg - -clean : - $(RM) $(RTOBJ) $(OBJ) *~ \#* *\# $(RELOBJ) - -fclean : clean - $(RM) $(NAM) a.out $(PIEBIN) diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/myputs.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/myputs.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/myputs.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/myputs.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** $Id: myputs.c,v 1.3 2007-08-03 18:05:03 may Exp $ -** -*/ -#include - -int myputs(char *str) -{ - printf("Hijacked puts !!! arg = %s \n", str); - putchar('e'); - putchar('x'); - putchar('t'); - putchar('c'); - putchar('a'); - putchar('l'); - putchar('l'); - putchar('!'); - putchar('\n'); - return (old_puts(str)); -} - -int new_legit_func(char *str) -{ - printf("Hijacked legit_func !!! (param = %s) \n", str); - return (old_legit_func(str)); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/script.sh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/script.sh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_memory/.svn/text-base/script.sh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_memory/.svn/text-base/script.sh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!/bin/sh - -test $# -ne 1 && echo "usage : "$0" file" && exit 0 - -DT=`../../../vm/elfsh -f $1 -d | grep DT_DEBUG | awk -F"[][]" '{ print $2;}'` - -PRG=$1 - -echo "#!../../../vm/elfsh" > inject_e2dbg.esh -echo "load "$1 >> inject_e2dbg.esh -echo "set 1.dynamic["$DT"].val 0x2" >> inject_e2dbg.esh -echo "set 1.dynamic["$DT"].tag DT_NEEDED" >> inject_e2dbg.esh -echo "redir main e2dbg_run" >> inject_e2dbg.esh -echo "save "$1"_e2dbg" >> inject_e2dbg.esh -echo "" >> inject_e2dbg.esh - -echo "#!../../../vm/elfsh" > etrelmem.esh -echo "load myputs.o" >> etrelmem.esh -echo "switch 1" >> etrelmem.esh -echo "mode dynamic" >> etrelmem.esh -echo "reladd 1 10" >> etrelmem.esh -#echo "quiet s" >> etrelmem.esh -echo "profile" >> etrelmem.esh -echo "redir puts myputs" >> etrelmem.esh -#echo "redir printf e2dbg_sigint_handler" >> etrelmem.esh -echo "profile" >> etrelmem.esh -echo "" >> etrelmem.esh - -chmod ugo+x inject_e2dbg.esh - -./inject_e2dbg.esh > inject_e2dbg.out - -/sbin/paxctl -p -m -s -r -x $PRG"_e2dbg" - -./$PRG"_e2dbg" - - - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/debug.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/debug.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/debug.esh 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/debug.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/bin/sh - -../../../vm/elfsh -f fake_aout -sym 'legit|hook' -./relinject.esh > ./relinject.out -grep CFLOW relinject.out -../../../vm/elfsh -f fake_aout -D legit_func%5 -exit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.elfsh_history eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.elfsh_history --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.elfsh_history 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.elfsh_history 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -start diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/etrel_inject.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/etrel_inject.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/etrel_inject.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/etrel_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** etrel_inject.c for testsuite in elfsh -** -** Started on Sat May 10 07:01:59 2003 jfv -** Last update Mon Jun 30 07:38:12 2003 jfv -** -** $Id: etrel_inject.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "a.out" -#define RELOC_FILE "rel.o" -#define OUTPUT_FILE "fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *host; - elfshobj_t *rel; - elfshsect_t *txtsect; - elfsh_Sym *puts_troj; - int idx; - u_long addr; - - /* Map host file and relocatable file */ - rel = elfsh_map_obj(RELOC_FILE); - if (NULL == rel) - goto err; - host = elfsh_map_obj(TROJANED_FILE); - if (NULL == host) - goto err; - - /* Inject etrel */ - idx = elfsh_inject_etrel(host, rel); - if (idx < 0) - goto err; - - /* Get injected's section info */ - txtsect = elfsh_get_section_by_name(host, "rel.o.text", NULL, NULL, NULL); - if (txtsect == NULL) - goto err; - - puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); - idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, - "puts", puts_troj->st_value, - NULL); - - /* Save it */ - idx = elfsh_save_obj(host, OUTPUT_FILE); - if (idx < 0) - goto err; - - puts("[*] ET_REL injected"); - return (0); - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/gdb.script eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/gdb.script --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/gdb.script 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/gdb.script 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - -file main -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/i386/ -b *0x4000660 -r -display/1x $pc -while 1 -stepi -end - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/host.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/host.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/host.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - perror("malloc"); - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/Makefile eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/Makefile --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -SRC = etrel_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm \ - -L../../../libaspect/ -laspect32 -L../../../liballocproxy \ - -lallocproxy -L../../../libetrace/ -letrace32 -NAM = etrel_injecter - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -OPT = -O2 -I../../../libelfsh/include/ \ - -I../../../libaspect/include $(BITS) -RM = rm -f -CFLAGS = $(OPT) - -all : $(OBJ) - $(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - $(CC) $(OPT) $(HOSTSRC) #-m64 - #@strip a.out - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - -# /sbin/paxctl -m -s -p -r -x ../../../vm/elfsh -# /sbin/paxctl -v ../../../vm/elfsh - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/rel.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/rel.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/rel.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/rel.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.5 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - old_puts(str); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/relinject.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/relinject.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/relinject.esh 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/relinject.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#!../../../elfsh/elfsh32 - -profile enable warn -load a.out -load rel.o - -#profile enable warn -#log session - -reladd 1 2 -#redir puts puts_troj -redir legit_func hook_func - -#sym old -save fake_aout - -#log stop - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/session eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/session --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/session 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/session 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ - [*] Started logging session in session - -~reladd 1 2 [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_sym_by_value@sym_common.c:263> No exact symbol matching - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_relocate_etrel_section@relinject.c:305> Cant find inserted section in ET_EXEC - [W] <elfsh_relocate_object@relinject.c:376> Unable to relocate section - [W] <elfsh_inject_etrel_hash@relinject.c:688> Unable to inject ET_REL with list - [W] <cmd_relinject@reladd.c:62> Failed to inject ET_REL with workspace - [W] <vm_execscript@loop.c:126> Command execution failed - [E] Command execution failed - - - [E] Script execution failed - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/894/trunk/testsuite/etrel_inject/etrel_original -END -gdb.script -K 25 -svn:wc:ra_dav:version-url -V 71 -/svn/!svn/ver/12/trunk/testsuite/etrel_inject/etrel_original/gdb.script -END -.elfsh_history -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/!svn/ver/780/trunk/testsuite/etrel_inject/etrel_original/.elfsh_history -END -rel.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_original/rel.c -END -session -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/638/trunk/testsuite/etrel_inject/etrel_original/session -END -debug.esh -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/12/trunk/testsuite/etrel_inject/etrel_original/debug.esh -END -etrel_inject.c -K 25 -svn:wc:ra_dav:version-url -V 76 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_original/etrel_inject.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/894/trunk/testsuite/etrel_inject/etrel_original/Makefile -END -relinject.esh -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/894/trunk/testsuite/etrel_inject/etrel_original/relinject.esh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel_original/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,142 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel_original -http://svn.eresi-project.org/svn - - - -2008-03-07T08:34:57.578111Z -894 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -gdb.script -file - - - - -2008-04-06T23:15:40.836877Z -73746d73796f0ab727ec750701d16639 -2005-08-02T06:43:53.000000Z -12 -thor - -.elfsh_history -file - - - - -2008-04-06T23:15:40.881876Z -889e0d7343405c079195e7b8903c8c9e -2007-08-25T17:13:05.000000Z -780 -mxatone - -rel.c -file - - - - -2008-04-06T23:15:40.893293Z -2eb24fa3eb050311348dafb469c430a8 -2007-07-31T03:28:48.000000Z -749 -may -has-props - -session -file - - - - -2008-04-06T23:15:40.904578Z -9f70a0f6dd5471bf09887710235bbf8d -2007-05-23T16:05:39.000000Z -638 -may - -debug.esh -file - - - - -2008-04-06T23:15:40.915903Z -86a57f196be35ec0f9527fe1b1050e66 -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -etrel_inject.c -file - - - - -2008-04-06T23:15:40.927669Z -b0887638dac4b4da16a32e51de29df33 -2007-07-31T03:28:48.000000Z -749 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:40.939028Z -b86c2b1f0248545fb678f979cec897ce -2008-03-07T08:34:57.578111Z -894 -may -has-props - -relinject.esh -file - - - - -2008-04-06T23:15:40.950702Z -aee5ec15819a30eb55b50ab3b20f9bb7 -2008-03-07T08:34:57.578111Z -894 -may -has-props - -host.c -file - - - - -2008-04-06T23:15:40.961899Z -055c8a676975d48da18166ef2bcf4da6 -2007-03-07T16:45:36.000000Z -502 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/debug.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/debug.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/debug.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/debug.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/etrel_inject.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/etrel_inject.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/etrel_inject.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/etrel_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/rel.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/prop-base/relinject.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/prop-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/debug.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/debug.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/debug.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/debug.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +0,0 @@ -#!/bin/sh - -../../../vm/elfsh -f fake_aout -sym 'legit|hook' -./relinject.esh > ./relinject.out -grep CFLOW relinject.out -../../../vm/elfsh -f fake_aout -D legit_func%5 -exit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/.elfsh_history.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/.elfsh_history.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/.elfsh_history.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/.elfsh_history.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -start diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/etrel_inject.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/etrel_inject.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/etrel_inject.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/etrel_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** etrel_inject.c for testsuite in elfsh -** -** Started on Sat May 10 07:01:59 2003 jfv -** Last update Mon Jun 30 07:38:12 2003 jfv -** -** $Id: etrel_inject.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "a.out" -#define RELOC_FILE "rel.o" -#define OUTPUT_FILE "fake_aout" - - -int main(int argc, char **argv) -{ - elfshobj_t *host; - elfshobj_t *rel; - elfshsect_t *txtsect; - elfsh_Sym *puts_troj; - int idx; - u_long addr; - - /* Map host file and relocatable file */ - rel = elfsh_map_obj(RELOC_FILE); - if (NULL == rel) - goto err; - host = elfsh_map_obj(TROJANED_FILE); - if (NULL == host) - goto err; - - /* Inject etrel */ - idx = elfsh_inject_etrel(host, rel); - if (idx < 0) - goto err; - - /* Get injected's section info */ - txtsect = elfsh_get_section_by_name(host, "rel.o.text", NULL, NULL, NULL); - if (txtsect == NULL) - goto err; - - puts_troj = elfsh_get_symbol_by_name(host, "puts_troj"); - idx = elfsh_hijack_function_by_name(host, ELFSH_HIJACK_TYPE_PLT, - "puts", puts_troj->st_value, - NULL); - - /* Save it */ - idx = elfsh_save_obj(host, OUTPUT_FILE); - if (idx < 0) - goto err; - - puts("[*] ET_REL injected"); - return (0); - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/gdb.script.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/gdb.script.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/gdb.script.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/gdb.script.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ - -file main -directory ~/glibc-2.3.4/elf/ -directory ~/glibc-2.3.4/sysdeps/i386/ -b *0x4000660 -r -display/1x $pc -while 1 -stepi -end - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/host.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - perror("malloc"); - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -SRC = etrel_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../../libelfsh/ -lelfsh32 -L../../../libasm -lasm \ - -L../../../libaspect/ -laspect32 -L../../../liballocproxy \ - -lallocproxy -L../../../libetrace/ -letrace32 -NAM = etrel_injecter - -HOSTSRC = host.c -RELSRC = rel.c -RELOBJ = rel.o - -OPT = -O2 -I../../../libelfsh/include/ \ - -I../../../libaspect/include $(BITS) -RM = rm -f -CFLAGS = $(OPT) - -all : $(OBJ) - $(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - $(CC) $(OPT) $(HOSTSRC) #-m64 - #@strip a.out - $(CC) $(OPT) $(RELSRC) -o $(RELOBJ) -c #-m64 - -# /sbin/paxctl -m -s -p -r -x ../../../vm/elfsh -# /sbin/paxctl -v ../../../vm/elfsh - -clean : - $(RM) $(OBJ) *~ \#* *\# $(RELOBJ) - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/rel.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/rel.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/rel.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/rel.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,61 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel.c,v 1.5 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - printf("HOOK FUNC %s !\n", str); - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - old_puts(str); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/relinject.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#!../../../elfsh/elfsh32 - -profile enable warn -load a.out -load rel.o - -#profile enable warn -#log session - -reladd 1 2 -#redir puts puts_troj -redir legit_func hook_func - -#sym old -save fake_aout - -#log stop - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/session.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/session.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_original/.svn/text-base/session.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_original/.svn/text-base/session.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ - [*] Started logging session in session - -~reladd 1 2 [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_sym_by_value@sym_common.c:263> No exact symbol matching - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_segment_by_type@pht.c:290> Unable to find PHDR by type - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_symbol_by_name@symbol.c:256> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_dynsymbol_by_name@dynsym.c:304> Symbol not found - [W] <elfsh_get_section_by_name_withlist@section.c:244> Section not found - [W] <elfsh_get_section_by_name@section.c:276> Section not found - [W] <elfsh_relocate_etrel_section@relinject.c:305> Cant find inserted section in ET_EXEC - [W] <elfsh_relocate_object@relinject.c:376> Unable to relocate section - [W] <elfsh_inject_etrel_hash@relinject.c:688> Unable to inject ET_REL with list - [W] <cmd_relinject@reladd.c:62> Failed to inject ET_REL with workspace - [W] <vm_execscript@loop.c:126> Command execution failed - [E] Command execution failed - - - [E] Script execution failed - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/host.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/host.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/host.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.3 2007-05-07 13:24:01 may Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - //read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/Makefile eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/Makefile --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -PAXCTL = /sbin/paxctl -CC = gcc -RELSRC = simple.c -RELOBJ = simple.o -PIESRC = host.c -PIEOBJ = host.o - -RM = rm -f -CFLAGS = -fPIC -I../../libhash/include/ - -all : $(PIEOBJ) $(RELOBJ) - $(CC) -g3 $(PIEOBJ) -pie - -clean : - $(RM) *~ \#* *\# $(RELOBJ) $(PIEOBJ) - -fclean : clean - $(RM) a.out fake_aout - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/relinject.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/relinject.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/relinject.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/relinject.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!../../../elfsh/elfsh32 - -load a.out -load simple.o - -reladd 1 2 - -#redir main fake_main -#redir __stack_smash_handler fake_stack_smash_handler -#redir __libc_start_main fake_libc_start_main -#redir strcpy fake_strcpy - -redir puts fake_puts -redir legit_func fake_legit_func - -save fake_aout - -# uncomment just for development purpose made easier -#exec /sbin/paxctl -c fake_aout -#exec /sbin/paxctl -permxs fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/simple.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/simple.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/simple.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/simple.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: simple.c,v 1.7 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -//int glvar_testreloc = 42; - -/* -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; -*/ - -/* -int fake_main(int argc, char **argv) -{ - - glvar_testreloc_bss = 1; - glvar_testreloc_bss2 = 'Z'; - glvar_testreloc_bss3 = 42; - - old_printf("I am the main function, I have %d argc and my argv is %08X yupeelala \n", - argc, argv); //, glvar_testreloc); - - write(1, "fake_main is calling write ! \n", 30); - - old_main(argc, argv); - - old_printf("Last printf in hook_main [%08X:%08X:%c:%04X] \n", - glvar_testreloc, glvar_testreloc_bss, - glvar_testreloc_bss2, glvar_testreloc_bss3); - - return (0); -} -*/ - - - -/* -void fake_stack_smash_handler(char func[], int damaged) -{ - static int i = 0; - printf("calling printf from stack smashing handler %u\n", i++); - if (i>3) - old___stack_smash_handler(func, damaged); - else - printf("Same player play again [damaged = %08X] \n", damaged); - printf("A second (%d) printf from the handler \n", 2); -} -*/ - - -/* -int fake_libc_start_main(void *one, void *two, void *three, void *four, void *five, void *six, void *seven) -{ - static int i = 0; - - old_printf("fake_libc_start_main \n"); - printf("start_main has been run %u \n", i++); - return (old___libc_start_main(one, two, three, four, five, six, seven)); -} -*/ - -/* -char* fake_strcpy(char *dst, char *src) -{ - printf("The binary wants to copy %s at address %08X \n", src, dst); - return ((char *) old_strcpy(dst, src)); -} -*/ - -int fake_puts(char *str) -{ - return (old_puts("Hijacked puts\n")); -} - -int fake_legit_func(char *str) -{ - printf("Hijacked legit func %s ! \n", str); - return (old_legit_func(str)); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_pie-ssp -END -simple.c -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_pie-ssp/simple.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_pie-ssp/Makefile -END -relinject.esh -K 25 -svn:wc:ra_dav:version-url -V 74 -/svn/!svn/ver/610/trunk/testsuite/etrel_inject/etrel_pie-ssp/relinject.esh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/594/trunk/testsuite/etrel_inject/etrel_pie-ssp/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel_pie-ssp -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -simple.c -file - - - - -2008-04-06T23:15:41.879902Z -1059a8bb2e0bfe9808f1148b7b25b96e -2007-07-31T03:28:48.000000Z -749 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:41.900876Z -a795d900bde5c58c343fc138a0830217 -2007-07-31T03:28:48.000000Z -749 -may -has-props - -relinject.esh -file - - - - -2008-04-06T23:15:41.911879Z -3e7859fca978e9c5fb32e5fed07acbbb -2007-05-16T13:33:47.000000Z -610 -may -has-props - -host.c -file - - - - -2008-04-06T23:15:41.923877Z -7fe85e256b70c472d776d6b70894bc53 -2007-05-07T13:24:01.000000Z -594 -may -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/simple.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/simple.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/simple.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/prop-base/simple.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/* -** -** $Id: host.c,v 1.3 2007-05-07 13:24:01 may Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - printf("LEGIT FUNC\n"); - printf("legit func (%s) !\n", str); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - //read(0, buff, BUFSIZ-1); - - str = malloc(10); - if (str == NULL) - goto err; - strcpy(str, "test"); - printf("First_printf %s\n", str); - fflush(stdout); - puts("First_puts"); - printf("Second_printf %s\n", str); - - free(str); - - puts("Second_puts"); - - fflush(stdout); - legit_func("test"); - return (0); - err: - printf("Malloc problem\n"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## -## - -include ../../../config.h - -PAXCTL = /sbin/paxctl -CC = gcc -RELSRC = simple.c -RELOBJ = simple.o -PIESRC = host.c -PIEOBJ = host.o - -RM = rm -f -CFLAGS = -fPIC -I../../libhash/include/ - -all : $(PIEOBJ) $(RELOBJ) - $(CC) -g3 $(PIEOBJ) -pie - -clean : - $(RM) *~ \#* *\# $(RELOBJ) $(PIEOBJ) - -fclean : clean - $(RM) a.out fake_aout - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!../../../elfsh/elfsh32 - -load a.out -load simple.o - -reladd 1 2 - -#redir main fake_main -#redir __stack_smash_handler fake_stack_smash_handler -#redir __libc_start_main fake_libc_start_main -#redir strcpy fake_strcpy - -redir puts fake_puts -redir legit_func fake_legit_func - -save fake_aout - -# uncomment just for development purpose made easier -#exec /sbin/paxctl -c fake_aout -#exec /sbin/paxctl -permxs fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/simple.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/simple.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/simple.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_pie-ssp/.svn/text-base/simple.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,92 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: simple.c,v 1.7 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - - -//int glvar_testreloc = 42; - -/* -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; -*/ - -/* -int fake_main(int argc, char **argv) -{ - - glvar_testreloc_bss = 1; - glvar_testreloc_bss2 = 'Z'; - glvar_testreloc_bss3 = 42; - - old_printf("I am the main function, I have %d argc and my argv is %08X yupeelala \n", - argc, argv); //, glvar_testreloc); - - write(1, "fake_main is calling write ! \n", 30); - - old_main(argc, argv); - - old_printf("Last printf in hook_main [%08X:%08X:%c:%04X] \n", - glvar_testreloc, glvar_testreloc_bss, - glvar_testreloc_bss2, glvar_testreloc_bss3); - - return (0); -} -*/ - - - -/* -void fake_stack_smash_handler(char func[], int damaged) -{ - static int i = 0; - printf("calling printf from stack smashing handler %u\n", i++); - if (i>3) - old___stack_smash_handler(func, damaged); - else - printf("Same player play again [damaged = %08X] \n", damaged); - printf("A second (%d) printf from the handler \n", 2); -} -*/ - - -/* -int fake_libc_start_main(void *one, void *two, void *three, void *four, void *five, void *six, void *seven) -{ - static int i = 0; - - old_printf("fake_libc_start_main \n"); - printf("start_main has been run %u \n", i++); - return (old___libc_start_main(one, two, three, four, five, six, seven)); -} -*/ - -/* -char* fake_strcpy(char *dst, char *src) -{ - printf("The binary wants to copy %s at address %08X \n", src, dst); - return ((char *) old_strcpy(dst, src)); -} -*/ - -int fake_puts(char *str) -{ - return (old_puts("Hijacked puts\n")); -} - -int fake_legit_func(char *str) -{ - printf("Hijacked legit func %s ! \n", str); - return (old_legit_func(str)); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/host.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/host.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/host.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - puts("legit func !"); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - puts("First_puts"); - - puts("Second_puts"); - - fflush(stdout); - - legit_func("test"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/Makefile eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/Makefile --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -# -# Simple Makefile for generating ET_REL list from archive files. -# -# The ELFsh project 2005 -# - -.PHONY: libc libcnonshared libpthread libpthreadnonshared libnsl - - -all: libc libcnonshared libpthread libpthreadnonshared libnsl - rm -f load_lib.esh - echo "#!../../../vm/elfsh" > load_lib.esh - find libc libnsl libcnonshared libpthread libpthreadnonshared -name "*.o*" | xargs \ - -ibou echo load bou >> load_lib.esh - -libnsl: - mkdir -p libnsl - cd libnsl && ar x /usr/lib/libnsl.a - -libc: - mkdir -p libc - cd libc && ar x /usr/lib/libc.a - -libcnonshared: - mkdir -p libcnonshared - cd libcnonshared && ar x /usr/lib/libc_nonshared.a - -libpthread: - mkdir -p libpthread - cd libpthread && ar x /usr/lib/libpthread.a - -libpthreadnonshared: - mkdir -p libpthreadnonshared - cd libpthreadnonshared && ar x /usr/lib/libpthread_nonshared.a - -clean: - rm -f core a.out fake_aout *.o *~ *\#* -fclean: clean - rm -f *~ \#* load_lib.esh libc/*.o* libcnonshared/*.o* \ - libpthread/*.o* libpthreadnonshared/*.o* libnsl/*.o* - rm -fr libc libnsl libpthread libcnonshared libpthreadnonshared diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/rel2.c eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/rel2.c --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/rel2.c 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/rel2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel2.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - int sd; - - printf("hook func %s !\n", str); - - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - int fd; - char name[16]; - void *a; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - memset(name, 0, 16); - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - gethostname(name, 15); - printf("hostname : %s\n", name); - - printf("printf called from puts_troj [%s] \n", str); - - - fd = open("/etc/services", 0, O_RDONLY); - - if (fd) - { - if ((a = mmap(0, 100, PROT_READ, MAP_PRIVATE, fd, 0)) == (void *) -1) - { - perror("mmap"); - close(fd); - printf("mmap failed : fd: %d\n", fd); - return (-1); - } - printf("-=-=-=-=-=- BEGIN /etc/services %d -=-=-=-=-=\n", fd); - printf("host : %.60s\n", (char *) a); - printf("-=-=-=-=-=- END /etc/services %d -=-=-=-=-=\n", fd); - printf("mmap succeed fd : %d\n", fd); - close(fd); - } - - - old_puts(str); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/relinject.esh eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/relinject.esh --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/relinject.esh 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/relinject.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!../../../elfsh/elfsh32 - -exec gcc -g3 -static host.c -exec gcc -g3 -static rel2.c -c - -load a.out -load rel2.o - -source ./load_lib.esh -#list - -reladd 1 2 - -profile -profile - -redir puts puts_troj -redir legit_func hook_func - -save fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_static -END -rel2.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/etrel_static/rel2.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/21/trunk/testsuite/etrel_inject/etrel_static/Makefile -END -relinject.esh -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/580/trunk/testsuite/etrel_inject/etrel_static/relinject.esh -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/502/trunk/testsuite/etrel_inject/etrel_static/host.c -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,79 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject/etrel_static -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -rel2.c -file - - - - -2008-04-06T23:15:41.043891Z -5528db5c8aaba928c9c8ae48c2c1315c -2007-07-31T03:28:48.000000Z -749 -may -has-props - -Makefile -file - - - - -2008-04-06T23:15:41.120958Z -aca34aff7968032f979f2e43b91b6e69 -2005-10-02T22:30:24.000000Z -21 -thor - -relinject.esh -file - - - - -2008-04-06T23:15:41.131909Z -06c503f533c3af3061a8f1062f41c2c9 -2007-04-20T12:37:10.000000Z -580 -may -has-props - -host.c -file - - - - -2008-04-06T23:15:41.142882Z -fc1832b2c7123f2498a7e733a8085d4b -2007-03-07T16:45:36.000000Z -502 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/format 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/rel2.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/rel2.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/rel2.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/rel2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/prop-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/prop-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/host.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -/* -** -** $Id: host.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include -#include -#include - -int legit_func(char *str) -{ - puts("legit func !"); - return (0); -} - -int main() -{ - char *str; - char buff[BUFSIZ]; - - read(0, buff, BUFSIZ-1); - - puts("First_puts"); - - puts("Second_puts"); - - fflush(stdout); - - legit_func("test"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -# -# Simple Makefile for generating ET_REL list from archive files. -# -# The ELFsh project 2005 -# - -.PHONY: libc libcnonshared libpthread libpthreadnonshared libnsl - - -all: libc libcnonshared libpthread libpthreadnonshared libnsl - rm -f load_lib.esh - echo "#!../../../vm/elfsh" > load_lib.esh - find libc libnsl libcnonshared libpthread libpthreadnonshared -name "*.o*" | xargs \ - -ibou echo load bou >> load_lib.esh - -libnsl: - mkdir -p libnsl - cd libnsl && ar x /usr/lib/libnsl.a - -libc: - mkdir -p libc - cd libc && ar x /usr/lib/libc.a - -libcnonshared: - mkdir -p libcnonshared - cd libcnonshared && ar x /usr/lib/libc_nonshared.a - -libpthread: - mkdir -p libpthread - cd libpthread && ar x /usr/lib/libpthread.a - -libpthreadnonshared: - mkdir -p libpthreadnonshared - cd libpthreadnonshared && ar x /usr/lib/libpthread_nonshared.a - -clean: - rm -f core a.out fake_aout *.o *~ *\#* -fclean: clean - rm -f *~ \#* load_lib.esh libc/*.o* libcnonshared/*.o* \ - libpthread/*.o* libpthreadnonshared/*.o* libnsl/*.o* - rm -fr libc libnsl libpthread libcnonshared libpthreadnonshared diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/rel2.c.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/rel2.c.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/rel2.c.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/rel2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* -** rel.c for elfsh -** -** Contain all tests for ET_REL injection -** -** Started on Mon Jun 23 06:56:04 2003 jfv -** Last update Sun Aug 17 17:41:48 2003 jfv -** -** $Id: rel2.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int glvar_testreloc = 42; - -int glvar_testreloc_bss; -char glvar_testreloc_bss2; -short glvar_testreloc_bss3; - - -int hook_func(char *str) -{ - int sd; - - printf("hook func %s !\n", str); - - return (old_legit_func(str)); -} - - -int puts_troj(char *str) -{ - int local = 1; - char *str2; - int fd; - char name[16]; - void *a; - - str2 = malloc(10); - *str2 = 'Z'; - *(str2 + 1) = 0x00; - - glvar_testreloc_bss = 43; - glvar_testreloc_bss2 = 44; - glvar_testreloc_bss3 = 45; - - memset(name, 0, 16); - - printf("Trojan injected ET_REL takes control now [%s:%s:%u:%u:%hhu:%hu:%u] \n", - str2, str, - glvar_testreloc, - glvar_testreloc_bss, - glvar_testreloc_bss2, - glvar_testreloc_bss3, - local); - - free(str2); - - gethostname(name, 15); - printf("hostname : %s\n", name); - - printf("printf called from puts_troj [%s] \n", str); - - - fd = open("/etc/services", 0, O_RDONLY); - - if (fd) - { - if ((a = mmap(0, 100, PROT_READ, MAP_PRIVATE, fd, 0)) == (void *) -1) - { - perror("mmap"); - close(fd); - printf("mmap failed : fd: %d\n", fd); - return (-1); - } - printf("-=-=-=-=-=- BEGIN /etc/services %d -=-=-=-=-=\n", fd); - printf("host : %.60s\n", (char *) a); - printf("-=-=-=-=-=- END /etc/services %d -=-=-=-=-=\n", fd); - printf("mmap succeed fd : %d\n", fd); - close(fd); - } - - - old_puts(str); - fflush(stdout); - return (0); -} - -int func2() -{ - return (42); -} diff -Nru eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/relinject.esh.svn-base eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/relinject.esh.svn-base --- eresi-0.8a25/testsuite/etrel_inject/etrel_static/.svn/text-base/relinject.esh.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/etrel_static/.svn/text-base/relinject.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,22 +0,0 @@ -#!../../../elfsh/elfsh32 - -exec gcc -g3 -static host.c -exec gcc -g3 -static rel2.c -c - -load a.out -load rel2.o - -source ./load_lib.esh -#list - -reladd 1 2 - -profile -profile - -redir puts puts_troj -redir legit_func hook_func - -save fake_aout - -quit diff -Nru eresi-0.8a25/testsuite/etrel_inject/Makefile eresi-0.0.20110516/testsuite/etrel_inject/Makefile --- eresi-0.8a25/testsuite/etrel_inject/Makefile 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -## -## Makefile for elfsh testsuite/etrel_inject -## -## Made by jfv -## Login -## -## Started on Sun Dec 15 01:34:42 2002 jfv -## Last update Sat May 24 17:45:46 2003 jfv -## - -all : - @cd et_rel2static && $(MAKE) - @cd etrel_memory && $(MAKE) - @cd etrel_original && $(MAKE) - @cd etrel_pie-ssp && $(MAKE) - @cd etrel_static && $(MAKE) - @cd etrel_extplt && $(MAKE) - -clean : - @cd et_rel2static && $(MAKE) clean - @cd etrel_memory && $(MAKE) clean - @cd etrel_original && $(MAKE) clean - @cd etrel_pie-ssp && $(MAKE) clean - @cd etrel_static && $(MAKE) clean - @cd etrel_extplt && $(MAKE) clean - -fclean : clean - @cd et_rel2static && $(MAKE) fclean - @cd etrel_memory && $(MAKE) fclean - @cd etrel_original && $(MAKE) fclean - @cd etrel_pie-ssp && $(MAKE) fclean - @cd etrel_static && $(MAKE) fclean - @cd etrel_extplt && $(MAKE) fclean diff -Nru eresi-0.8a25/testsuite/etrel_inject/.svn/all-wcprops eresi-0.0.20110516/testsuite/etrel_inject/.svn/all-wcprops --- eresi-0.8a25/testsuite/etrel_inject/.svn/all-wcprops 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 46 -/svn/!svn/ver/894/trunk/testsuite/etrel_inject -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/749/trunk/testsuite/etrel_inject/Makefile -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/.svn/entries eresi-0.0.20110516/testsuite/etrel_inject/.svn/entries --- eresi-0.8a25/testsuite/etrel_inject/.svn/entries 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/etrel_inject -http://svn.eresi-project.org/svn - - - -2008-03-07T08:34:57.578111Z -894 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -etrel_original -dir - -etrel_static -dir - -etrel_memory -dir - -et_rel2static -dir - -etrel4alpha -dir - -etrel_extplt -dir - -etrel_pie-ssp -dir - -Makefile -file - - - - -2008-04-06T23:15:41.962904Z -b54e2f875f4a5e4db959ee9ff9f45ced -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/etrel_inject/.svn/format eresi-0.0.20110516/testsuite/etrel_inject/.svn/format --- eresi-0.8a25/testsuite/etrel_inject/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/etrel_inject/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/etrel_inject/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/etrel_inject/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/etrel_inject/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:41.000000000 +0000 +++ eresi-0.0.20110516/testsuite/etrel_inject/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -## -## Makefile for elfsh testsuite/etrel_inject -## -## Made by jfv -## Login -## -## Started on Sun Dec 15 01:34:42 2002 jfv -## Last update Sat May 24 17:45:46 2003 jfv -## - -all : - @cd et_rel2static && $(MAKE) - @cd etrel_memory && $(MAKE) - @cd etrel_original && $(MAKE) - @cd etrel_pie-ssp && $(MAKE) - @cd etrel_static && $(MAKE) - @cd etrel_extplt && $(MAKE) - -clean : - @cd et_rel2static && $(MAKE) clean - @cd etrel_memory && $(MAKE) clean - @cd etrel_original && $(MAKE) clean - @cd etrel_pie-ssp && $(MAKE) clean - @cd etrel_static && $(MAKE) clean - @cd etrel_extplt && $(MAKE) clean - -fclean : clean - @cd et_rel2static && $(MAKE) fclean - @cd etrel_memory && $(MAKE) fclean - @cd etrel_original && $(MAKE) fclean - @cd etrel_pie-ssp && $(MAKE) fclean - @cd etrel_static && $(MAKE) fclean - @cd etrel_extplt && $(MAKE) fclean diff -Nru eresi-0.8a25/testsuite/flowjack/infected.c eresi-0.0.20110516/testsuite/flowjack/infected.c --- eresi-0.8a25/testsuite/flowjack/infected.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/infected.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/* -** -** infected.c in -** -** Author : -** Started : Tue Oct 7 02:05:18 2003 -** Updated : Tue Oct 7 02:35:00 2003 -** -** $Id: infected.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ - -void hijacked(int arg) -{ - printf("arg %i hijacked\n", arg); - subfunc(arg); -} diff -Nru eresi-0.8a25/testsuite/flowjack/patch.esh eresi-0.0.20110516/testsuite/flowjack/patch.esh --- eresi-0.8a25/testsuite/flowjack/patch.esh 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/patch.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#! /usr/bin/elfsh -## -## patch.esh in -## -## Author : -## Started : Tue Oct 7 02:32:30 2003 -## Updated : Tue Oct 7 02:39:15 2003 -## - -exec gcc -c infected.c -exec gcc -o target target.c -load target -load infected.o -modload modflow -switch 1 -flow -reladd 1 2 -flowjack subfunc hijacked -save target.hijacked -quit diff -Nru eresi-0.8a25/testsuite/flowjack/recursivite.c eresi-0.0.20110516/testsuite/flowjack/recursivite.c --- eresi-0.8a25/testsuite/flowjack/recursivite.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/recursivite.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** -** recursivite.c in -** -** Author : -** Started : Tue Oct 7 01:48:14 2003 -** Updated : Tue Oct 7 19:43:29 2003 -** -** $Id: recursivite.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - -void subfunc(arg) -{ - if (arg) - subfunc(arg - 1); - printf("i = %i\n", arg) -; -} - - -int main(int ac, char **av) -{ - subfunc(10); -} diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/all-wcprops eresi-0.0.20110516/testsuite/flowjack/.svn/all-wcprops --- eresi-0.8a25/testsuite/flowjack/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/502/trunk/testsuite/flowjack -END -infected.c -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/502/trunk/testsuite/flowjack/infected.c -END -recursivite.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/502/trunk/testsuite/flowjack/recursivite.c -END -target -K 25 -svn:wc:ra_dav:version-url -V 48 -/svn/!svn/ver/12/trunk/testsuite/flowjack/target -END -target.c -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/502/trunk/testsuite/flowjack/target.c -END -patch.esh -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/12/trunk/testsuite/flowjack/patch.esh -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/entries eresi-0.0.20110516/testsuite/flowjack/.svn/entries --- eresi-0.8a25/testsuite/flowjack/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,93 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/flowjack -http://svn.eresi-project.org/svn - - - -2007-03-07T16:45:36.000000Z -502 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -infected.c -file - - - - -2008-04-06T23:15:40.008887Z -7b567428c5f1a2714375d46e4a78d6dc -2007-03-07T16:45:36.000000Z -502 -thor -has-props - -recursivite.c -file - - - - -2008-04-06T23:15:40.058327Z -788a989a8277f1e50455c6a52ee5f09c -2007-03-07T16:45:36.000000Z -502 -thor -has-props - -target -file - - - - -2008-04-06T23:15:40.068899Z -96754f23f846881fe09ac44ce0ec975b -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -target.c -file - - - - -2008-04-06T23:15:40.081013Z -a29b36cadeca9c5b0d2ecafdb343eade -2007-03-07T16:45:36.000000Z -502 -thor -has-props - -patch.esh -file - - - - -2008-04-06T23:15:40.092411Z -8107f14d4a59e5fdff1fe2ccbb6fd0e8 -2005-08-02T06:43:53.000000Z -12 -thor -has-props - diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/format eresi-0.0.20110516/testsuite/flowjack/.svn/format --- eresi-0.8a25/testsuite/flowjack/.svn/format 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/prop-base/infected.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/infected.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/prop-base/infected.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/infected.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/prop-base/patch.esh.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/patch.esh.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/prop-base/patch.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/patch.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/prop-base/recursivite.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/recursivite.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/prop-base/recursivite.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/recursivite.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/prop-base/target.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/target.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/prop-base/target.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/target.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/prop-base/target.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/target.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/prop-base/target.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/prop-base/target.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/text-base/infected.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/infected.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/text-base/infected.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/infected.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -/* -** -** infected.c in -** -** Author : -** Started : Tue Oct 7 02:05:18 2003 -** Updated : Tue Oct 7 02:35:00 2003 -** -** $Id: infected.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ - -void hijacked(int arg) -{ - printf("arg %i hijacked\n", arg); - subfunc(arg); -} diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/text-base/patch.esh.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/patch.esh.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/text-base/patch.esh.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/patch.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#! /usr/bin/elfsh -## -## patch.esh in -## -## Author : -## Started : Tue Oct 7 02:32:30 2003 -## Updated : Tue Oct 7 02:39:15 2003 -## - -exec gcc -c infected.c -exec gcc -o target target.c -load target -load infected.o -modload modflow -switch 1 -flow -reladd 1 2 -flowjack subfunc hijacked -save target.hijacked -quit diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/text-base/recursivite.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/recursivite.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/text-base/recursivite.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/recursivite.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -/* -** -** recursivite.c in -** -** Author : -** Started : Tue Oct 7 01:48:14 2003 -** Updated : Tue Oct 7 19:43:29 2003 -** -** $Id: recursivite.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - -void subfunc(arg) -{ - if (arg) - subfunc(arg - 1); - printf("i = %i\n", arg) -; -} - - -int main(int ac, char **av) -{ - subfunc(10); -} diff -Nru eresi-0.8a25/testsuite/flowjack/.svn/text-base/target.c.svn-base eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/target.c.svn-base --- eresi-0.8a25/testsuite/flowjack/.svn/text-base/target.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/target.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** -** target.c in -** -** Author : -** Started : Tue Oct 7 01:45:28 2003 -** Updated : Tue Oct 7 02:06:29 2003 -** -** $Id: target.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - -void subfunc(int arg) -{ - printf("i = %i\n", arg); -} - -int func1(void) -{ - subfunc(1); -} - -int func2(void) -{ - - subfunc(2); -} - -int func3(void) -{ - subfunc(3); - return (3); -} - -int main() -{ - func1(); - func2(); - func3(); - return (0); -} Binary files /tmp/ItVmkfb9fO/eresi-0.8a25/testsuite/flowjack/.svn/text-base/target.svn-base and /tmp/NXmgpNsCf_/eresi-0.0.20110516/testsuite/flowjack/.svn/text-base/target.svn-base differ Binary files /tmp/ItVmkfb9fO/eresi-0.8a25/testsuite/flowjack/target and /tmp/NXmgpNsCf_/eresi-0.0.20110516/testsuite/flowjack/target differ diff -Nru eresi-0.8a25/testsuite/flowjack/target.c eresi-0.0.20110516/testsuite/flowjack/target.c --- eresi-0.8a25/testsuite/flowjack/target.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/flowjack/target.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -/* -** -** target.c in -** -** Author : -** Started : Tue Oct 7 01:45:28 2003 -** Updated : Tue Oct 7 02:06:29 2003 -** -** $Id: target.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - -void subfunc(int arg) -{ - printf("i = %i\n", arg); -} - -int func1(void) -{ - subfunc(1); -} - -int func2(void) -{ - - subfunc(2); -} - -int func3(void) -{ - subfunc(3); - return (3); -} - -int main() -{ - func1(); - func2(); - func3(); - return (0); -} diff -Nru eresi-0.8a25/testsuite/got_hijack/got_hijack.c eresi-0.0.20110516/testsuite/got_hijack/got_hijack.c --- eresi-0.8a25/testsuite/got_hijack/got_hijack.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/got_hijack.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:46:18 2002 jfv -** -** $Id: got_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_sleep; - int ret; - - file = elfsh_map_obj(TROJANED_FILE); - new_sleep = elfsh_get_symbol_by_name(file, "new_sleep"); - if (!file || !new_sleep) - { - elfsh_error(); - exit(-1); - } - - /* Try this to hijack got by index or the second one to hijack by name */ - //ret = elfsh_set_got_entry_by_index(file, 5, new_sleep->st_value); - ret = elfsh_set_got_entry_by_name(file, "sleep", new_sleep->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - /* RELINKING THE FILE */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/got_hijack/hijacked.c eresi-0.0.20110516/testsuite/got_hijack/hijacked.c --- eresi-0.8a25/testsuite/got_hijack/hijacked.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/hijacked.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** -** $Id: hijacked.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - -void new_sleep() -{ - printf("hijacked sleep ! \n"); -} - - -int main() -{ - printf("Main ! \n"); - sleep(5); -} diff -Nru eresi-0.8a25/testsuite/got_hijack/Makefile eresi-0.0.20110516/testsuite/got_hijack/Makefile --- eresi-0.8a25/testsuite/got_hijack/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:43 2002 jfv -## - -include ../../config.h - -SRC = got_hijack.c -OBJ = $(SRC:.c=.o) -CC ?= gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = got_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/all-wcprops eresi-0.0.20110516/testsuite/got_hijack/.svn/all-wcprops --- eresi-0.8a25/testsuite/got_hijack/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 44 -/svn/!svn/ver/749/trunk/testsuite/got_hijack -END -got_hijack.c -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/749/trunk/testsuite/got_hijack/got_hijack.c -END -hijacked.c -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/616/trunk/testsuite/got_hijack/hijacked.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/749/trunk/testsuite/got_hijack/Makefile -END diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/entries eresi-0.0.20110516/testsuite/got_hijack/.svn/entries --- eresi-0.8a25/testsuite/got_hijack/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/got_hijack -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -got_hijack.c -file - - - - -2008-04-06T23:15:40.139882Z -dc668fe49376dbe4033ffefcbbd2b444 -2007-07-31T03:28:48.000000Z -749 -may - -hijacked.c -file - - - - -2008-04-06T23:15:40.173886Z -468833afec0f43b52d4fbd4beb4a1412 -2007-05-16T23:36:38.000000Z -616 -may - -Makefile -file - - - - -2008-04-06T23:15:40.185297Z -cf8bc06c281ea898ed0106d4a2ef44e9 -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/format eresi-0.0.20110516/testsuite/got_hijack/.svn/format --- eresi-0.8a25/testsuite/got_hijack/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/got_hijack/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/got_hijack/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/text-base/got_hijack.c.svn-base eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/got_hijack.c.svn-base --- eresi-0.8a25/testsuite/got_hijack/.svn/text-base/got_hijack.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/got_hijack.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Sun Mar 10 02:46:18 2002 jfv -** -** $Id: got_hijack.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Sym *new_sleep; - int ret; - - file = elfsh_map_obj(TROJANED_FILE); - new_sleep = elfsh_get_symbol_by_name(file, "new_sleep"); - if (!file || !new_sleep) - { - elfsh_error(); - exit(-1); - } - - /* Try this to hijack got by index or the second one to hijack by name */ - //ret = elfsh_set_got_entry_by_index(file, 5, new_sleep->st_value); - ret = elfsh_set_got_entry_by_name(file, "sleep", new_sleep->st_value); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - - /* RELINKING THE FILE */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/text-base/hijacked.c.svn-base eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/hijacked.c.svn-base --- eresi-0.8a25/testsuite/got_hijack/.svn/text-base/hijacked.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/hijacked.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -/* -** -** $Id: hijacked.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - -void new_sleep() -{ - printf("hijacked sleep ! \n"); -} - - -int main() -{ - printf("Main ! \n"); - sleep(5); -} diff -Nru eresi-0.8a25/testsuite/got_hijack/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/got_hijack/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/got_hijack/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:43 2002 jfv -## - -include ../../config.h - -SRC = got_hijack.c -OBJ = $(SRC:.c=.o) -CC ?= gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = got_hijacker -RM = rm -f -VULN = hijacked.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/hash_retreive/hash_read.c eresi-0.0.20110516/testsuite/hash_retreive/hash_read.c --- eresi-0.8a25/testsuite/hash_retreive/hash_read.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/hash_read.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Mon Mar 25 10:49:20 2002 jfv -** -** $Id: hash_read.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" -#define HASHED_SYMBOL "printf" - - - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - int ret; - char *name; - elfsh_Sym *sym; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf("Value for %s retreived from .hash: %8p \n", HASHED_SYMBOL, - elfsh_get_dynsymbol_by_hash(file, HASHED_SYMBOL)); - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/hash_retreive/main.c eresi-0.0.20110516/testsuite/hash_retreive/main.c --- eresi-0.8a25/testsuite/hash_retreive/main.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* -** -** $Id: main.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - - -int main() -{ - printf("Example program . \n"); - return (0); -} diff -Nru eresi-0.8a25/testsuite/hash_retreive/Makefile eresi-0.0.20110516/testsuite/hash_retreive/Makefile --- eresi-0.8a25/testsuite/hash_retreive/Makefile 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:59 2002 jfv -## - -include ../../config.h - -SRC = hash_read.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = hash_reader -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/all-wcprops eresi-0.0.20110516/testsuite/hash_retreive/.svn/all-wcprops --- eresi-0.8a25/testsuite/hash_retreive/.svn/all-wcprops 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/749/trunk/testsuite/hash_retreive -END -hash_read.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/749/trunk/testsuite/hash_retreive/hash_read.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/616/trunk/testsuite/hash_retreive/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/749/trunk/testsuite/hash_retreive/Makefile -END diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/entries eresi-0.0.20110516/testsuite/hash_retreive/.svn/entries --- eresi-0.8a25/testsuite/hash_retreive/.svn/entries 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/hash_retreive -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -hash_read.c -file - - - - -2008-04-06T23:15:39.692913Z -80642c7f0fc9644b6107530c93912616 -2007-07-31T03:28:48.000000Z -749 -may - -main.c -file - - - - -2008-04-06T23:15:39.702901Z -6a85b53765fa8173288bbefdf2dd0c4f -2007-05-16T23:36:38.000000Z -616 -may - -Makefile -file - - - - -2008-04-06T23:15:39.714597Z -a2bcee685b76d9329d43b96295084c31 -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/format eresi-0.0.20110516/testsuite/hash_retreive/.svn/format --- eresi-0.8a25/testsuite/hash_retreive/.svn/format 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/hash_retreive/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/hash_retreive/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/hash_read.c.svn-base eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/hash_read.c.svn-base --- eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/hash_read.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/hash_read.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/* -** unlink.c for unlinked -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Mon Mar 25 10:49:20 2002 jfv -** -** $Id: hash_read.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" -#define HASHED_SYMBOL "printf" - - - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - int ret; - char *name; - elfsh_Sym *sym; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf("Value for %s retreived from .hash: %8p \n", HASHED_SYMBOL, - elfsh_get_dynsymbol_by_hash(file, HASHED_SYMBOL)); - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/main.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -/* -** -** $Id: main.c,v 1.3 2007-05-16 23:36:37 may Exp $ -** -*/ -#include - - -int main() -{ - printf("Example program . \n"); - return (0); -} diff -Nru eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/hash_retreive/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/hash_retreive/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:55:59 2002 jfv -## - -include ../../config.h - -SRC = hash_read.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = hash_reader -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/interface/alert.esh eresi-0.0.20110516/testsuite/interface/alert.esh --- eresi-0.8a25/testsuite/interface/alert.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/interface/alert.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,11 @@ +#!../../elfsh/elfsh32 + + +load /bin/ls +setcolor warnstring fg red +alert gnu +s +alert sym +s +quit + diff -Nru eresi-0.8a25/testsuite/interface/workspace.esh eresi-0.0.20110516/testsuite/interface/workspace.esh --- eresi-0.8a25/testsuite/interface/workspace.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/interface/workspace.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,22 @@ +#!../../elfsh/elfsh32 +# +# +# The workspace is an interactive command. See help workspace. +# + +profile enable all + +load /bin/ls +e +workspace +workspace second +exec sleep 3 +workspace +p +exec sleep 3 +workspace local +exec sleep 3 +workspace second +exec sleep 3 +quit + diff -Nru eresi-0.8a25/testsuite/kernel_instrumentation/kernsh-script.esh eresi-0.0.20110516/testsuite/kernel_instrumentation/kernsh-script.esh --- eresi-0.8a25/testsuite/kernel_instrumentation/kernsh-script.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/kernel_instrumentation/kernsh-script.esh 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,11 @@ +#!../../kernsh/kernsh32 + +openmem +mode d + +type thread_info = task:*long +type task_struct = state:long thread_info:*thread_info +inform task_struct init_task + +print $init_task.thread_info.task +print $init_task.thread_info diff -Nru eresi-0.8a25/testsuite/kernel_instrumentation/print_syscalltable.esh eresi-0.0.20110516/testsuite/kernel_instrumentation/print_syscalltable.esh --- eresi-0.8a25/testsuite/kernel_instrumentation/print_syscalltable.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/kernel_instrumentation/print_syscalltable.esh 2011-05-16 11:34:56.000000000 +0000 @@ -0,0 +1,22 @@ +#!../../kernsh/kernsh32 + +openmem +mode d + +type example1 = sys:int[320] +inform example1 toto sys_call_table + +print $toto.sys[0] + +set $i 0 + +boucle: + +cmp $i 2 +je end +print $toto.sys[$i] +add $i 1 +jmp boucle + +end: +print "Bye !" \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/libedfmt/Makefile eresi-0.0.20110516/testsuite/libedfmt/Makefile --- eresi-0.8a25/testsuite/libedfmt/Makefile 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -SRCS = test_usage.c - -OBJS = test_usage.o - -CFLAGS = -I../../libedfmt/include \ - -I../../libaspect/include \ - -I../../libelfsh/include \ - -DERESI32 \ - -ggdb - -LDFLAGS = -L../../libedfmt/ -ledfmt32 \ - -L../../libelfsh -lelfsh32 \ - -L../../libaspect -laspect32 \ - -L../../libasm/ -lasm \ - -L../../libetrace -letrace32 - -all: ${OBJS} - ${CC} -o main ${OBJS} ${LDFLAGS} - -clean: - rm -f ${OBJS} diff -Nru eresi-0.8a25/testsuite/libedfmt/.svn/all-wcprops eresi-0.0.20110516/testsuite/libedfmt/.svn/all-wcprops --- eresi-0.8a25/testsuite/libedfmt/.svn/all-wcprops 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/909/trunk/testsuite/libedfmt -END -test_usage.c -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/909/trunk/testsuite/libedfmt/test_usage.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/909/trunk/testsuite/libedfmt/Makefile -END diff -Nru eresi-0.8a25/testsuite/libedfmt/.svn/entries eresi-0.0.20110516/testsuite/libedfmt/.svn/entries --- eresi-0.8a25/testsuite/libedfmt/.svn/entries 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/libedfmt -http://svn.eresi-project.org/svn - - - -2008-03-14T09:48:44.987521Z -909 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -test_usage.c -file - - - - -2008-04-06T23:15:38.701913Z -d1d3f3e6bf4a4bb82c079dce43bf7f50 -2008-03-14T09:48:44.987521Z -909 -enioh - -Makefile -file - - - - -2008-04-06T23:15:38.712068Z -9f3a5d71556bc1ab7c0ac21591131963 -2008-03-14T09:48:44.987521Z -909 -enioh - diff -Nru eresi-0.8a25/testsuite/libedfmt/.svn/format eresi-0.0.20110516/testsuite/libedfmt/.svn/format --- eresi-0.8a25/testsuite/libedfmt/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/libedfmt/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/libedfmt/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/libedfmt/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -SRCS = test_usage.c - -OBJS = test_usage.o - -CFLAGS = -I../../libedfmt/include \ - -I../../libaspect/include \ - -I../../libelfsh/include \ - -DERESI32 \ - -ggdb - -LDFLAGS = -L../../libedfmt/ -ledfmt32 \ - -L../../libelfsh -lelfsh32 \ - -L../../libaspect -laspect32 \ - -L../../libasm/ -lasm \ - -L../../libetrace -letrace32 - -all: ${OBJS} - ${CC} -o main ${OBJS} ${LDFLAGS} - -clean: - rm -f ${OBJS} diff -Nru eresi-0.8a25/testsuite/libedfmt/.svn/text-base/test_usage.c.svn-base eresi-0.0.20110516/testsuite/libedfmt/.svn/text-base/test_usage.c.svn-base --- eresi-0.8a25/testsuite/libedfmt/.svn/text-base/test_usage.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/.svn/text-base/test_usage.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#include -#include - - -int main(int ac, char **av) -{ - - elfshobj_t *obj; - edfmtdw2info_t *info; - int to_ret; - - obj = elfsh_load_obj(av[0]); - if (!obj) - { - printf("failed loading %s\n", av[0]); - to_ret = -1; - goto error_label; - } - edfmt_format(obj); - edfmt_dwarf2_parse(obj); - if (info = edfmt_dwarf2_getinfo(obj)) - { - printf("information found\n"); - printf("dwarf2 compil unit : %p\n", info->cu_list); - printf("dwarf2 sections : %p\n", info->sections); - } - - - to_ret = 0; - error_label: - return (to_ret); -} diff -Nru eresi-0.8a25/testsuite/libedfmt/test_usage.c eresi-0.0.20110516/testsuite/libedfmt/test_usage.c --- eresi-0.8a25/testsuite/libedfmt/test_usage.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/libedfmt/test_usage.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#include -#include - - -int main(int ac, char **av) -{ - - elfshobj_t *obj; - edfmtdw2info_t *info; - int to_ret; - - obj = elfsh_load_obj(av[0]); - if (!obj) - { - printf("failed loading %s\n", av[0]); - to_ret = -1; - goto error_label; - } - edfmt_format(obj); - edfmt_dwarf2_parse(obj); - if (info = edfmt_dwarf2_getinfo(obj)) - { - printf("information found\n"); - printf("dwarf2 compil unit : %p\n", info->cu_list); - printf("dwarf2 sections : %p\n", info->sections); - } - - - to_ret = 0; - error_label: - return (to_ret); -} diff -Nru eresi-0.8a25/testsuite/Makefile eresi-0.0.20110516/testsuite/Makefile --- eresi-0.8a25/testsuite/Makefile 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/Makefile 2011-05-16 11:35:01.000000000 +0000 @@ -1,54 +1,39 @@ ## -## Makefile for elfsh testsuite in -## -## Made by jfv -## Login -## -## Started on Sun Dec 15 01:34:42 2002 jfv -## Last update Sat May 24 17:45:46 2003 jfv +## Makefile for librevm in ERESI ## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +include ../config.h + +all : all32 all64 + +all32 : + $(MAKE) -C debugging all32 + $(MAKE) -C elf all32 + $(MAKE) -C tracing all32 + $(MAKE) -C static_analysis all32 + $(MAKE) -C static_instrumentation all32 + +all64 : + echo "Testsuite needs to be ported on 64 bits ! FIXME !" + #$(MAKE) -C debugging all64 + #$(MAKE) -C elf all64 + #$(MAKE) -C tracing all64 + #$(MAKE) -C static_analysis all64 + #$(MAKE) -C static_instrumentation all64 -all : - @cd ctors_hijack && $(MAKE) - @cd dtors_hijack && $(MAKE) - @cd got_hijack && $(MAKE) - @cd hash_retreive && $(MAKE) - @cd sct_fillbss_injection && $(MAKE) - @cd sct_top_injection && $(MAKE) - @cd sct_unmapped_injection && $(MAKE) - @cd sht_rebuild && $(MAKE) - @cd sht_stripping && $(MAKE) - @cd symtab_extend && $(MAKE) - @cd etrel_inject && $(MAKE) - @cd e2dbg_multithreads && $(MAKE) - -clean : - @echo -n 'Cleaning testsuite ...' - @cd ctors_hijack && $(MAKE) clean - @cd dtors_hijack && $(MAKE) clean - @cd got_hijack && $(MAKE) clean - @cd hash_retreive && $(MAKE) clean - @cd sct_fillbss_injection && $(MAKE) clean - @cd sct_top_injection && $(MAKE) clean - @cd sct_unmapped_injection && $(MAKE) clean - @cd sht_rebuild && $(MAKE) clean - @cd sht_stripping && $(MAKE) clean - @cd symtab_extend && $(MAKE) clean - @cd etrel_inject && $(MAKE) clean - @cd e2dbg_multithreads && $(MAKE) clean - @echo 'Testsuite cleaned .' - -fclean : clean - @cd ctors_hijack && $(MAKE) fclean - @cd dtors_hijack && $(MAKE) fclean - @cd got_hijack && $(MAKE) fclean - @cd hash_retreive && $(MAKE) fclean - @cd sct_fillbss_injection && $(MAKE) fclean - @cd sct_top_injection && $(MAKE) fclean - @cd sct_unmapped_injection && $(MAKE) fclean - @cd sht_rebuild && $(MAKE) fclean - @cd sht_stripping && $(MAKE) fclean - @cd symtab_extend && $(MAKE) fclean - @cd etrel_inject && $(MAKE) fclean - @cd e2dbg_multithreads && $(MAKE) fclean +clean : + $(MAKE) -C debugging clean + $(MAKE) -C elf clean + $(MAKE) -C tracing clean + $(MAKE) -C static_analysis clean + $(MAKE) -C static_instrumentation clean +fclean : clean + $(MAKE) -C debugging fclean + $(MAKE) -C elf fclean + $(MAKE) -C tracing fclean + $(MAKE) -C static_analysis fclean + $(MAKE) -C static_instrumentation fclean diff -Nru eresi-0.8a25/testsuite/mjollnir/simple-test.esh eresi-0.0.20110516/testsuite/mjollnir/simple-test.esh --- eresi-0.8a25/testsuite/mjollnir/simple-test.esh 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/simple-test.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../elfsh/elfsh32 - -# Created: Tue Jan 2 22:44:33 CET 2007 - -# Load all types -load ../../elfsh/elfsh32 -unload ../../elfsh/elfsh32 - -# Analyse -load /bin/ls -analyse -exec sleep 10 - -save ls.saved -load ls.saved - -quit - diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/all-wcprops eresi-0.0.20110516/testsuite/mjollnir/.svn/all-wcprops --- eresi-0.8a25/testsuite/mjollnir/.svn/all-wcprops 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/754/trunk/testsuite/mjollnir -END -simple-test.esh -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/754/trunk/testsuite/mjollnir/simple-test.esh -END -test-ptrfn1.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/752/trunk/testsuite/mjollnir/test-ptrfn1.c -END -test-ptrfn2.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/752/trunk/testsuite/mjollnir/test-ptrfn2.c -END -test-ptrfn3.c -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/752/trunk/testsuite/mjollnir/test-ptrfn3.c -END -test-recur.c -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/752/trunk/testsuite/mjollnir/test-recur.c -END diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/entries eresi-0.0.20110516/testsuite/mjollnir/.svn/entries --- eresi-0.8a25/testsuite/mjollnir/.svn/entries 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/mjollnir -http://svn.eresi-project.org/svn - - - -2007-08-01T00:38:43.000000Z -754 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -simple-test.esh -file - - - - -2008-04-06T23:15:38.588133Z -f5fd3a1f8abcbbd4fa179f91cf206b9d -2007-08-01T00:38:43.000000Z -754 -may -has-props - -test-ptrfn1.c -file - - - - -2008-04-06T23:15:38.608899Z -2d74a0fb4b22982c876c9b6e850654b3 -2007-07-31T17:03:08.000000Z -752 -thor - -test-ptrfn2.c -file - - - - -2008-04-06T23:15:38.620137Z -11386fea6244aedac97e802b7977e5f2 -2007-07-31T17:03:08.000000Z -752 -thor - -test-ptrfn3.c -file - - - - -2008-04-06T23:15:38.632033Z -2120317eb0551f89a3f4da65d81a66b2 -2007-07-31T17:03:08.000000Z -752 -thor - -test-recur.c -file - - - - -2008-04-06T23:15:38.643149Z -98f71f1b993881c7ca678dcea36124e0 -2007-07-31T17:03:08.000000Z -752 -thor - diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/format eresi-0.0.20110516/testsuite/mjollnir/.svn/format --- eresi-0.8a25/testsuite/mjollnir/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/prop-base/simple-test.esh.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/prop-base/simple-test.esh.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/prop-base/simple-test.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/prop-base/simple-test.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/text-base/simple-test.esh.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/simple-test.esh.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/text-base/simple-test.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/simple-test.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../elfsh/elfsh32 - -# Created: Tue Jan 2 22:44:33 CET 2007 - -# Load all types -load ../../elfsh/elfsh32 -unload ../../elfsh/elfsh32 - -# Analyse -load /bin/ls -analyse -exec sleep 10 - -save ls.saved -load ls.saved - -quit - diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn1.c.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn1.c.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn1.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn1.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Test pointer-follow function calls detection. - -innafunkcja() {printf("dupa\n"); } - -main() { - int (*fn)(); - fn=innafunkcja; - fn(); -} diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn2.c.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn2.c.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn2.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn2.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Test pointer-follow function calls detection. - -f1() {printf("dupa\n"); } -f2() {printf("dupa2\n");} - -main() { - int (*fn)(); - int (*fn2)(); - fn=f1; - fn2=f2; - fn(fn2()); -} diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn3.c.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn3.c.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-ptrfn3.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-ptrfn3.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#include - -int f1() {f4();} -int f2(){f4();} -int f3(){f4();} -int f4() {printf("dupa\n");} - -int main(void) { - int x; - int a[3] = {(int)f1,(int)f2,(int)f3}; - int (*f) (); - for(x=0;x<3;x++) { - f=(int(*)())a[x]; - f(); - } -return 0; -} - - diff -Nru eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-recur.c.svn-base eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-recur.c.svn-base --- eresi-0.8a25/testsuite/mjollnir/.svn/text-base/test-recur.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/.svn/text-base/test-recur.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -#include -#include -#include -#include -#include - -int funk1(int a){printf("%d\n",a);return 0;} -int funk2(int a){printf("%d\n",a);funk1(a-1);return 1;} -int funk3(int b){printf("%d\n",b);funk2(b+1);funk1(666);return 0;} - -int main(void) -{ - int x=0; - char *z; - - z = NULL; - - if (z == NULL) { - printf("z == null\n"); - } - if (z == 0x0) { - printf("z == 0x0\n"); - } - - if (x == 0) { - printf("is zero\n"); - } else { - printf("is not zero\n"); - } - - funk1(333); - funk2(666); - funk3(777); - - z = malloc(1024); - memset(z,0x0,1024); - read(1,z,1023); - - return 0; -} - diff -Nru eresi-0.8a25/testsuite/mjollnir/test-ptrfn1.c eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn1.c --- eresi-0.8a25/testsuite/mjollnir/test-ptrfn1.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn1.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// Test pointer-follow function calls detection. - -innafunkcja() {printf("dupa\n"); } - -main() { - int (*fn)(); - fn=innafunkcja; - fn(); -} diff -Nru eresi-0.8a25/testsuite/mjollnir/test-ptrfn2.c eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn2.c --- eresi-0.8a25/testsuite/mjollnir/test-ptrfn2.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn2.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -// Test pointer-follow function calls detection. - -f1() {printf("dupa\n"); } -f2() {printf("dupa2\n");} - -main() { - int (*fn)(); - int (*fn2)(); - fn=f1; - fn2=f2; - fn(fn2()); -} diff -Nru eresi-0.8a25/testsuite/mjollnir/test-ptrfn3.c eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn3.c --- eresi-0.8a25/testsuite/mjollnir/test-ptrfn3.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/test-ptrfn3.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,19 +0,0 @@ -#include - -int f1() {f4();} -int f2(){f4();} -int f3(){f4();} -int f4() {printf("dupa\n");} - -int main(void) { - int x; - int a[3] = {(int)f1,(int)f2,(int)f3}; - int (*f) (); - for(x=0;x<3;x++) { - f=(int(*)())a[x]; - f(); - } -return 0; -} - - diff -Nru eresi-0.8a25/testsuite/mjollnir/test-recur.c eresi-0.0.20110516/testsuite/mjollnir/test-recur.c --- eresi-0.8a25/testsuite/mjollnir/test-recur.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/mjollnir/test-recur.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,41 +0,0 @@ -#include -#include -#include -#include -#include - -int funk1(int a){printf("%d\n",a);return 0;} -int funk2(int a){printf("%d\n",a);funk1(a-1);return 1;} -int funk3(int b){printf("%d\n",b);funk2(b+1);funk1(666);return 0;} - -int main(void) -{ - int x=0; - char *z; - - z = NULL; - - if (z == NULL) { - printf("z == null\n"); - } - if (z == 0x0) { - printf("z == 0x0\n"); - } - - if (x == 0) { - printf("is zero\n"); - } else { - printf("is not zero\n"); - } - - funk1(333); - funk2(666); - funk3(777); - - z = malloc(1024); - memset(z,0x0,1024); - read(1,z,1023); - - return 0; -} - diff -Nru eresi-0.8a25/testsuite/scripting/declare-bitfields.esh eresi-0.0.20110516/testsuite/scripting/declare-bitfields.esh --- eresi-0.8a25/testsuite/scripting/declare-bitfields.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/declare-bitfields.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,17 @@ +#!../../evarista/evarista32 + +#profile enable warn + +print ************ Now declarations of bitfields types ***************** + +type struct1 = field1:long field2:bit[31] field3:byte +type + +print ************ Now declarations of variables ***************** + +struct1 test1 = (field1:0x12345678, field2:0x00FF00FF, field3:A) + +print $test1 + +quit + diff -Nru eresi-0.8a25/testsuite/scripting/declare.esh eresi-0.0.20110516/testsuite/scripting/declare.esh --- eresi-0.8a25/testsuite/scripting/declare.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/declare.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,133 @@ +#!../../evarista/evarista32 + +#profile enable warn +verb +nocolor + +print ************ Now declarations of record types ***************** + +type struct0 = field0:long +type struct1 = field1:byte field2:long +type struct2 = field3:struct1 field4:long field5:struct1 + +print ************ Now declarations of variables ***************** + +#profile enable trace + +long mylong = 42 +vlist + +struct0 mystruct0 = (field0:42) +struct0 mystruct0b = struct0(field0:42) +struct0 mystruct0c = struct0(field0:43) + +struct1 mystruct1 = (field1:42,field2:43) + +struct1 mystruct1b = $mystruct1 +#struct1 mystruct1b = (field1:42,field2:43) + +struct1 mystruct1c = (field1:43,field2:42) +struct1 mystruct1d = (field2:42,field1:43) + +tables expressions + +#struct2 mystruct2 = (field3:$mystruct1, field4:44, field5(field1:45, field2:46)) +struct2 mystruct2 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) + +print $mystruct2 + +tables expressions + +struct2 mystruct2b = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) + +tables expressions + +print $mystruct2b + +struct2 mystruct2c = (field3(field1:42, field2:43), field4:44, field5(field1:46, field2:45)) + +print $mystruct2c + +# Wrong typing test -OK- +#struct0 mystruct0b = struct1(field0:42) + +print ************ Now testing printing of types ***************** + +type + +print ************ Now testing printing of expressions ***************** +print $mystruct0 +print $mystruct0b +print $mystruct0c +print $mystruct1b +print $mystruct1 +print $mystruct1c +print $mystruct1d +print $mystruct2 +print $mystruct2b +print $mystruct2c + +print *********** Now testing basic whole-expression comparison **************** + +verb +cmp $mystruct0 $mystruct0 +cmp $mystruct0 $mystruct0b +cmp $mystruct0b $mystruct0c +cmp $mystruct1 $mystruct1b +cmp $mystruct1b $mystruct1c +cmp $mystruct2 $mystruct2b +cmp $mystruct2b $mystruct2c + +print *********** Now testing field-order insensitive comparison **************** + +cmp $mystruct1c $mystruct1d + +# Set works all very well +print $mystruct0b $mystruct0c +set $mystruct0c $mystruct0b +print $mystruct0b $mystruct0c +cmp $mystruct0b $mystruct0c + +print $mystruct1b $mystruct1c +set $mystruct1c $mystruct1b +print $mystruct1b $mystruct1c +cmp $mystruct1b $mystruct1c + +print $mystruct2c $mystruct2b +set $mystruct2c $mystruct2b +print $mystruct2c $mystruct2b +cmp $mystruct2b $mystruct2c + + +print *********** Now testing subexpressions comparisons ************** + +print $mystruct2c.field3 +print $mystruct2c.field5 +print $mystruct1b + +cmp $mystruct2c.field3 $mystruct2c.field5 +cmp $mystruct2c.field3 $mystruct2b.field3 +cmp $mystruct2c.field3 $mystruct1b +cmp $mystruct1b $mystruct2c.field5 + +print *********** Now testing setting subexpressions ********* + +print $mystruct2c.field5 $mystruct1 +cmp $mystruct2c.field5 $mystruct1 +set $mystructbackup $mystruct2c.field5 +print $mystructbackup $mystruct2c.field5 $mystruct1 +set $mystruct2c.field5 $mystruct1 +print $mystructbackup $mystruct2c.field5 $mystruct1 +cmp $mystruct2c.field5 $mystruct1 + +print ********** Now testing terminal subexpression printing ********* + +print $mystruct2c.field3.field1 +print $mystruct2c.field3.field2 +print $mystruct2c.field5.field1 +print $mystruct2c.field5.field2 + +set $val $mystruct2c.field3.field1 +print $val + +quit diff -Nru eresi-0.8a25/testsuite/scripting/declare-unions.esh eresi-0.0.20110516/testsuite/scripting/declare-unions.esh --- eresi-0.8a25/testsuite/scripting/declare-unions.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/declare-unions.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,27 @@ +#!../../evarista/evarista32 + +#profile enable warn + +print ************ Now declarations of record types ***************** + +type struct1 = field1:long field2:byte +union union1 = field3:struct1 field4:long field5:struct1 +type +type union1 + +print ************ Now declarations of variables ***************** + +union1 myunion1 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) +print $myunion1 + +tables expressions +#profile enable warn +set $myunion1.field4 42 + +print $myunion1 +set $myunion1.field3.field1 31337 +print $myunion1 +set $myunion1.field5.field2 A +print $myunion1 + +quit diff -Nru eresi-0.8a25/testsuite/scripting/defines.esh eresi-0.0.20110516/testsuite/scripting/defines.esh --- eresi-0.8a25/testsuite/scripting/defines.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/defines.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,45 @@ +#!../../evarista/evarista32 + +#profile enable warn + +# Attributes for instructions +define b ASM_TYPE_BRANCH +define c ASM_TYPE_CALLPROC +define i ASM_TYPE_INT +define r ASM_TYPE_RETPROC +define p ASM_TYPE_PROLOG +define cmp ASM_TYPE_COMPARISON +define bs ASM_TYPE_BITSET +define a ASM_TYPE_ASSIGN +define wm ASM_TYPE_STORE +define rm ASM_TYPE_LOAD +define e ASM_TYPE_EPILOG +define s ASM_TYPE_STOP +define n ASM_TYPE_NOP +define ar ASM_TYPE_ARITH +define wf ASM_TYPE_WRITEFLAG +define cnd ASM_TYPE_CONDCONTROL + +define b-cnd b cnd +define i-r i r +define ar-wf ar wf +define ar-wm ar wm +define a-rm a rm +define a-wm a wm + +#define id ASM_TYPE_INCDEC +#define ar-id ar id +#define ar-id-wm ar id wm + +# Attributes for operands +define reg ASM_OPTYPE_REG +define imm ASM_OPTYPE_IMM +define mem ASM_OPTYPE_MEM + +# Printing to see if it worked +print b c i r p cmp bs a wm +print rm e s n ar wf + +print i-r ar-wf ar-wm a-rm a-wm b-cnd + +print reg imm mem diff -Nru eresi-0.8a25/testsuite/scripting/doublevar.esh eresi-0.0.20110516/testsuite/scripting/doublevar.esh --- eresi-0.8a25/testsuite/scripting/doublevar.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/doublevar.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,21 @@ +#!../../elfsh/elfsh32 + +#quiet + +print Parameters : $1 $2 $3 +print + +set $index 1 + +loop: +#profile enable warn +cmp $index $# +jl end +load $$index +dynsym printf +unload $$index +add $index 1 +jmp loop + +end: +quit diff -Nru eresi-0.8a25/testsuite/scripting/dynamic-naming.esh eresi-0.0.20110516/testsuite/scripting/dynamic-naming.esh --- eresi-0.8a25/testsuite/scripting/dynamic-naming.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/dynamic-naming.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,35 @@ +#!../../elfsh/elfsh32 + +#quiet + +set $name test + +add $hash[$name_2] Intel +add $hash[$name_2] Alpha +add $hash[$name_2] Sparc32 +add $hash[$name_2] Mips + +set $name test_2 + +add $hash[$name] Sparc64 +add $hash[$name] AMD +add $hash[$name] Pa-risc + +tables test_2 + +print Starting first foreach + +foreach $elem of test_2 matching Sparc + print Regex Matched $elem +forend + +print Starting second foreach +tables test_2 + +foreach $element of test_2 + print Table contains element : $element +forend + +empty test_2 +tables test_2 +quit diff -Nru eresi-0.8a25/testsuite/scripting/dynamic-naming-list.esh eresi-0.0.20110516/testsuite/scripting/dynamic-naming-list.esh --- eresi-0.8a25/testsuite/scripting/dynamic-naming-list.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/dynamic-naming-list.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,35 @@ +#!../../elfsh/elfsh32 + +#quiet + +set $name test + +add $list[$name_2] Intel +add $list[$name_2] Alpha +add $list[$name_2] Sparc32 +add $list[$name_2] Mips + +set $name test_2 + +add $list[$name] Sparc64 +add $list[$name] AMD +add $list[$name] Pa-risc + +lists test_2 + +print Starting first foreach + +foreach $elem of test_2 matching Sparc + print Regex Matched $elem +forend + +print Starting second foreach +lists test_2 + +foreach $element of test_2 + print List contains element : $element +forend + +empty test_2 +lists test_2 +quit diff -Nru eresi-0.8a25/testsuite/scripting/endian.esh eresi-0.0.20110516/testsuite/scripting/endian.esh --- eresi-0.8a25/testsuite/scripting/endian.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/endian.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,12 @@ +#!../../elfsh/elfsh32 + +load /bin/ls + +got 00 +set 1.got[0] .plt +got 00 + +save ls.test +load ls.test +got 00 + diff -Nru eresi-0.8a25/testsuite/scripting/expr-arith.esh eresi-0.0.20110516/testsuite/scripting/expr-arith.esh --- eresi-0.8a25/testsuite/scripting/expr-arith.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/expr-arith.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,33 @@ +#!../../elfsh/elfsh32 + +load /bin/ls +analyse +print main +exec sleep 10 + +set $a 1 +set $b 3 +set $c 5 +set $d 7 +set $e ($a+$c-$b)*$d/2 +print $a $b $c $d $e + +cmp $b $d +cmp $b $d-$a +cmp $b-$a+$c $d +cmp $b+$c $d-$a +cmp $b*2 $d-$a + +set $f 0xFF<4 +print $f + +set $f 0xFF0>4 +print $f + +quiet +foreach $i of 0 until 10 +print At $i : main+$i contains byte value *(main+$i) +forend +verb + +quit diff -Nru eresi-0.8a25/testsuite/scripting/factorial.esh eresi-0.0.20110516/testsuite/scripting/factorial.esh --- eresi-0.8a25/testsuite/scripting/factorial.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/factorial.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,33 @@ +#!../../evarista/evarista32 + +sdir . +#quiet +#profile enable warn + +vlist + +cmp $# 2 + +vlist +jne end + +print Fact with params : +print $1 $2 +mul $2 $1 +set $2 $_ +sub $1 1 +cmp $1 1 +je result +print Variables at current iteration : +print $1 $2 $_ +factorial $1 $2 +quit + +end: +print This program needs 2 parameters +quit + +result: +print Factorial result: +print $2 +quit diff -Nru eresi-0.8a25/testsuite/scripting/factorial-withret.esh eresi-0.0.20110516/testsuite/scripting/factorial-withret.esh --- eresi-0.8a25/testsuite/scripting/factorial-withret.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/factorial-withret.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,35 @@ +#!../../evarista/evarista32 + +print $ESHLVL +cmp $ESHLVL 0 +jne factstart +sdir . + +factstart: +cmp $# 2 +jne end +mul $2 $1 +sub $1 1 +cmp $1 1 +je result + +factorial-withret $1 $2 +print $_ +set $2 $_ + +result: +print $ESHLVL +cmp $ESHLVL 0 +je printres +print $2 + +return $2 + +printres: +print Factorial result: +print $2 +quit + +end: +print This program needs 2 parameters +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-ending.esh eresi-0.0.20110516/testsuite/scripting/foreach-ending.esh --- eresi-0.8a25/testsuite/scripting/foreach-ending.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-ending.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,26 @@ +#!../../elfsh/elfsh32 + +#quiet + +add $hash[test2] Intel +add $hash[test2] Alpha +add $hash[test2] Sparc32 +add $hash[test2] Mips +add $hash[test2] Sparc64 +add $hash[test2] AMD +add $hash[test2] Pa-risc +tables test2 + +beginning: +print Starting first foreach + +#profile enable warn + +foreach $elem of test2 matching Sparc + print Regex Matched $elem +forend + +empty test2 +tables test2 + +# Special case where nothing is after the forend diff -Nru eresi-0.8a25/testsuite/scripting/foreach-hashes.esh eresi-0.0.20110516/testsuite/scripting/foreach-hashes.esh --- eresi-0.8a25/testsuite/scripting/foreach-hashes.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-hashes.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,29 @@ +#!../../elfsh/elfsh32 + +#quiet + +add $hash[test2] Intel +add $hash[test2] Alpha +add $hash[test2] Sparc32 +add $hash[test2] Mips +add $hash[test2] Sparc64 +add $hash[test2] AMD +add $hash[test2] Pa-risc +tables test2 + +print Starting first foreach + +foreach $elem of test2 matching Sparc + print Regex Matched $elem +forend + +print Starting second foreach +tables test2 + +foreach $element of test2 + print Table contains element : $element +forend + +empty test2 +tables test2 +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-linearity.esh eresi-0.0.20110516/testsuite/scripting/foreach-linearity.esh --- eresi-0.8a25/testsuite/scripting/foreach-linearity.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-linearity.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,31 @@ +#!../../elfsh/elfsh32 + +add $list[test] Intel +add $list[test] Alpha +add $list[test] Sparc32 +add $list[test] Mips +add $list[test] Sparc64 +add $list[test] AMD +add $list[test] Pa-risc + +add $list[test2] HEHEHE + +lists test +lists test2 + +#profile enable warn +#quiet + + +foreach $element of test + + # Should print an error + foreach $element2 of test + print List2 contains element : $element2 + forend + + print List contains element : $element + +forend + +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-lists.esh eresi-0.0.20110516/testsuite/scripting/foreach-lists.esh --- eresi-0.8a25/testsuite/scripting/foreach-lists.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-lists.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,39 @@ +#!../../elfsh/elfsh32 + +#quiet + +vlist + +add $list[test2] Intel +add $list[test2] Alpha +add $list[test2] Sparc32 +add $list[test2] Mips +add $list[test2] Sparc64 +add $list[test2] AMD +add $list[test2] Pa-risc +lists test2 + +# We need a parameter +vlist +cmp $# 0 +jne error + +beginning: +print Starting first foreach + +foreach $elem of test2 matching Sparc + print Regex Matched $elem +forend + +print Starting second foreach +lists test2 + +foreach $element of test2 + print List contains element : $element +forend + +quit + +error: +print This script needs one parameter (a file name) +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-list-simple.esh eresi-0.0.20110516/testsuite/scripting/foreach-list-simple.esh --- eresi-0.8a25/testsuite/scripting/foreach-list-simple.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-list-simple.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,30 @@ +#!../../elfsh/elfsh32 + +#quiet + +add $list[test2] Intel +add $list[test2] Alpha +add $list[test2] Sparc32 +add $list[test2] Mips +add $list[test2] Sparc64 +add $list[test2] AMD +add $list[test2] Pa-risc + +# We need a parameter +cmp $# 0 +jne error + +beginning: +print Starting first foreach + +#profile enable warn +#profile enable trace + +foreach $elem of test2 matching Sparc + print Regex Matched $elem +forend +quit + +error: +print This script needs one parameter (a file name) +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-nested.esh eresi-0.0.20110516/testsuite/scripting/foreach-nested.esh --- eresi-0.8a25/testsuite/scripting/foreach-nested.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-nested.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,26 @@ +#!../../elfsh/elfsh32 + +#profile enable warn +#quiet + +add $list[test1] Intel +add $list[test1] Alpha +add $list[test1] Mips + +add $list[test2] HEHE +add $list[test2] HOHO + +lists test1 +lists test2 + +foreach $element of test1 + + print List contains element : $element + + foreach $element2 of test2 + print List2 contains element : $element2 + forend + +forend + +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-reference.esh eresi-0.0.20110516/testsuite/scripting/foreach-reference.esh --- eresi-0.8a25/testsuite/scripting/foreach-reference.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-reference.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,29 @@ +#!../../elfsh/elfsh32 + +add $list[test] 1 +add $list[test] 2 +add $list[test] 3 +lists test + +#quiet +#profile enable warn + +foreach $element of test + add $element 3 +forend + +print +lists test + +foreach $elem of test + print List contains element : $elem +forend + +print +lists test + +foreach $elem of test + print List contains element : $elem +forend + +quit diff -Nru eresi-0.8a25/testsuite/scripting/foreach-shadow.esh eresi-0.0.20110516/testsuite/scripting/foreach-shadow.esh --- eresi-0.8a25/testsuite/scripting/foreach-shadow.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/foreach-shadow.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,26 @@ +#!../../elfsh/elfsh32 + +profile enable warn +#quiet + +add $list[test] Intel +add $list[test] Alpha +add $list[test] Mips + +add $list[test2] HEHE +add $list[test2] HOHO + +lists test +lists test2 + +foreach $element of test + + foreach $element of test2 + print List2 contains element : $element + forend + + print List contains element : $element + +forend + +quit diff -Nru eresi-0.8a25/testsuite/scripting/loop.esh eresi-0.0.20110516/testsuite/scripting/loop.esh --- eresi-0.8a25/testsuite/scripting/loop.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/loop.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,38 @@ +#!../../elfsh/elfsh32 + +# comment it for enabling trace mode +quiet + +load /bin/ls +set $index 0 +print Now try to find symbols with 4 bytes size : + +loop: +cmp $index 1.hdr.shnum +je endloop +print Passing section 1.section[$index].name at addr 1.sht[$index].addr with index $index +add $index 1 +jmp loop + +endloop: +set $index 0 +set $lastsym 1.sht[.dynsym].size +div $lastsym 1.sht[.dynsym].entsize +print Now try to find symbols with 4 bytes size ( dynsymtab contains $lastsym entries ) : + +loop2: +cmp $index $lastsym +je end +cmp 1.dynsym[$index].size 4 +jne rec +print Found dword sized symbol : 1.dynsym[$index].name at addr 1.dynsym[$index].value +rec: +add $index 1 +jmp loop2 + +end: +vlist +quit + + + diff -Nru eresi-0.8a25/testsuite/scripting/myparams.esh eresi-0.0.20110516/testsuite/scripting/myparams.esh --- eresi-0.8a25/testsuite/scripting/myparams.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/myparams.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,25 @@ +#!../../elfsh/elfsh32 + +cmp $# 1 +jne paramerr + +load /bin/ls +print Parameter 1 : $1 +set $full 1.sht[.dynsym].size +div $full 1.sht[.dynsym].entsize +print Dynamic symtab contains $full entries +cmp $full $1 +jle err +print Entry $1 is 1.dynsym[$1].value with name 1.dynsym[$1].name +jmp end + +err: +print Table is too small +paramerr: +print Script must take one parameter +end: +print End of scripts, listing variables : +vlist +quit + + diff -Nru eresi-0.8a25/testsuite/scripting/params2.esh eresi-0.0.20110516/testsuite/scripting/params2.esh --- eresi-0.8a25/testsuite/scripting/params2.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/params2.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,12 @@ +#!../../elfsh/elfsh32 + +print TWO = $2 +print ONE = $1 +cmp $1 $2 +je err +print DIFF +jmp end +err: +print EQU +end: +quit diff -Nru eresi-0.8a25/testsuite/scripting/params.esh eresi-0.0.20110516/testsuite/scripting/params.esh --- eresi-0.8a25/testsuite/scripting/params.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/params.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,17 @@ +#!../../elfsh/elfsh32 + +load /bin/ls +print Parameter 1 : $1 +set $full 1.sht[.dynsym].size +div $full 1.sht[.dynsym].entsize +print Dynamic symbol table contains $full entries +print FULL = $full +print ONE = $1 +cmp $1 $full +jle err +print Symbol $1 is 1.dynsym[$1].name +jmp end +err: +print Table is too small +end: +quit diff -Nru eresi-0.8a25/testsuite/scripting/rewrite-simple.esh eresi-0.0.20110516/testsuite/scripting/rewrite-simple.esh --- eresi-0.8a25/testsuite/scripting/rewrite-simple.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/rewrite-simple.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,50 @@ +#!../../evarista/evarista32 + +#quiet + +# Declare some basic types to work with +type listent = key:string data:long next:*listent +type list = head:*listent elmnbr:int type:int linearity:byte name:string +type hash = ent:*listent size:int elmnbr:int type:int linearity:byte name:string +type container = id:int type:int nbrinlinks:int nbroutlinks:int inlinks:*list outlinks:*list data:long +type op = len:int ptr:*byte sem:int name:string size:int content:int regset:int prefix:int imm:int baser:int indexr:int sbaser:string sindex:string isdst:int aspace:int scale:int st:int it:int oa:int +type instr::container = ptrins:long proc:long name:string icode:int sem:long prefix:int spdiff:int wflags:int rflags:int ptr_prefix:long annul:int prediction:int nb_op:int op1:op op2:op op3:op op4:op op5:op op6:op len:int aop:int +type bloc::container = vaddr:caddr size:int symoff:int seen:byte +type func::container = vaddr:caddr size:int name:byte[64] first:*bloc md5:byte[34] +type link = id:oid type:byte scope:byte + +load /bin/ls + +write 1.section[.text].raw 0x50515253 +hexa ^.text$%5 +disasm ^.text$%5 + +set $curaddr 1.sht[.text].addr +print 1.sht[.text].addr + +#profile enable warn +reflect 1.sht[.text].addr 4 + +#lists 08048B50 +#print $instr-0x08048B50 +#print $instr-0x08048B51 +#print $instr-0x08048B52 +#print $instr-0x08048B53 + +set $first "first" +set $second "second" +set $off 1 + +foreach $instr of $hash[instrlists:$curaddr] +rewrite $instr into +case instr(sem:0x4020) +into instr(name:$first, sem:0xFE+$off, icode:$off+254, nb_op:$off+$instr.op1.sem, op1:$instr.op1) +rwtend +forend + +#this confirms that translation from 1 to 2 works! +foreach $instr of $hash[instrlists:$curaddr] +print $instr +forend + +quit diff -Nru eresi-0.8a25/testsuite/scripting/script-lists.esh eresi-0.0.20110516/testsuite/scripting/script-lists.esh --- eresi-0.8a25/testsuite/scripting/script-lists.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/script-lists.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,44 @@ +#!../../elfsh/elfsh32 + +set $list[test1:key] 42 +lists test1 + +set $list[test2] $list[test1] +lists test + +set $list[test1:key2] 43 +lists test +lists test1 +lists test2 + +add $list[test2] $list[test1:key2] +lists test2 + +sub $list[test2] key2 +lists test2 + +# test error checking +sub $list[test2] key2 +lists test2 + +#profile enable warn + +add $list[test2] 42 +add $list[test2] 43 +add $list[test2] 44 +add $list[test2] 45 +add $list[test2] 46 +add $list[test2] 47 +add $list[test2] 48 + +lists test2 +lists test1 + +sub $list[test2] $list[test1] +lists test2 +lists test1 +add $list[test2] $list[test1] +lists test2 +lists test1 + +quit diff -Nru eresi-0.8a25/testsuite/scripting/script-tables.esh eresi-0.0.20110516/testsuite/scripting/script-tables.esh --- eresi-0.8a25/testsuite/scripting/script-tables.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/script-tables.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,42 @@ +#!../../elfsh/elfsh32 +set $hash[test1:key] 42 +tables test1 + +set $hash[test2] $hash[test1] +tables test + +set $hash[test1:key2] 43 +tables test +tables test1 +tables test2 + +add $hash[test2] $hash[test1:key2] +tables test2 + +sub $hash[test2] key2 +tables test2 + +# test error checking +sub $hash[test2] key2 +tables test2 + +#profile enable warn + +add $hash[test2] 42 +add $hash[test2] 43 +add $hash[test2] 44 +add $hash[test2] 45 +add $hash[test2] 46 +add $hash[test2] 47 +add $hash[test2] 48 + +tables test2 +tables test1 +sub $hash[test2] $hash[test1] +tables test2 +tables test1 +add $hash[test2] $hash[test1] +tables test2 +tables test1 + +quit diff -Nru eresi-0.8a25/testsuite/scripting/script-types.esh eresi-0.0.20110516/testsuite/scripting/script-types.esh --- eresi-0.8a25/testsuite/scripting/script-types.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/script-types.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,55 @@ +#!../../elfsh/elfsh32 + +load ../../elfsh/elfsh32 +switch libstderesi + +# Just some examples of type that can be used to map internal framework structures +type context = savedfd:int savedmode:byte savedcmd:*long savedinput:*long savedargv:*long savedname:*long curcmd:*long +type state = flags:byte[4] glregex%32 sregx:*long alertf:byte alertregex%32 strs:*long[4] moreflags:byte[5] lastid:int +type world = state:state ctxt:context + +# Lets see an example of printing of real variables arrays of the framework + +type archtypes = types:string[55] +inform archtypes elfsh_arch_type +type archaddr = types:long[55] +inform archaddr elfsh_arch_type + +inform archtypes +print elfsh_arch_type +exec sleep 30 +quiet + +print Now print Strings +print +print 107.archtypes[elfsh_arch_type].types[0] +print 107.archtypes[elfsh_arch_type].types[1] +print 107.archtypes[elfsh_arch_type].types[2] +print 107.archtypes[elfsh_arch_type].types[3] +print + +print Now print addresses +print +print Entry 1 : 107.archaddr[elfsh_arch_type].types[0] +print Entry 2 : 107.archaddr[elfsh_arch_type].types[1] +print Entry 3 : 107.archaddr[elfsh_arch_type].types[2] +print Entry 4 : 107.archaddr[elfsh_arch_type].types[3] +print + +verb +#profile enable warn + +set 107.archaddr[elfsh_arch_type].types[0] 0x41414141 +set 107.archaddr[elfsh_arch_type].types[1] 0x42424242 +set 107.archaddr[elfsh_arch_type].types[2] 0x43434343 +set 107.archaddr[elfsh_arch_type].types[3] 0x44444444 + +print 107.archaddr[elfsh_arch_type].types[0] +print 107.archaddr[elfsh_arch_type].types[1] +print 107.archaddr[elfsh_arch_type].types[2] +print 107.archaddr[elfsh_arch_type].types[3] + +quit + + + diff -Nru eresi-0.8a25/testsuite/scripting/strings_tests.esh eresi-0.0.20110516/testsuite/scripting/strings_tests.esh --- eresi-0.8a25/testsuite/scripting/strings_tests.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/strings_tests.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,49 @@ +#!../../elfsh/elfsh32 +# +# Second regression test script +# + +#quiet + +load /bin/ls + +print SHT entries 1 and 13: +s 01]|13] + +print The interpretor section: +X interp + +print Change section name: +print 1.section[1].name +set 1.section[1].name .pffffffffffff +print 1.section[1].name + +print 20 first bytes of .text: +X ^\.text%20 + +print Change 5 first byte of section .text : +write 1.section[.text].raw hehe\x42 +X ^\.text%20 + +print Write 9 bytes in section .text, starting at byte 5: +write 1.section[.text:5].raw \x43\x44\huhu\x00\x48 +X ^\.text%20 + +print Write the value of printf symbol (4 bytes) at offset 10 (2 * 5) +write 1.section[.text:2%5].raw printf +X ^\.text%20 + +s 01]|13] + +print Change a symbol name +print 1.symtab[1].name +set 1.symtab[1].name heh +print 1.symtab[1].name + +print Change a dynamic symbol name +print 1.dynsym[2].name +set 1.dynsym[2].name test_big_string_oh_yeah +print 1.dynsym[2].name + +save /tmp/elfsh.modifs +quit diff -Nru eresi-0.8a25/testsuite/scripting/subtyping.esh eresi-0.0.20110516/testsuite/scripting/subtyping.esh --- eresi-0.8a25/testsuite/scripting/subtyping.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/subtyping.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,18 @@ +#!../../evarista/evarista32 + +print ************ Now declarations of subtypes ***************** + +type struct0 = field0:long +type +type struct1::struct0 = field1:byte field2:long +type +type struct2::struct1 = field3:struct1 field4:long field5:struct1 +type + +# This is not allowed (collision in field names) +#verb +#type struct3::struct0 = field0:string +#type +#type struct4 = field0:string field0:int +#type + diff -Nru eresi-0.8a25/testsuite/scripting/test-set.esh eresi-0.0.20110516/testsuite/scripting/test-set.esh --- eresi-0.8a25/testsuite/scripting/test-set.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/scripting/test-set.esh 2011-05-16 11:34:54.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../elfsh/elfsh32 + +info +vlist +load /bin/ls +vlist +e +vlist +set 1.hdr.shnum 42 +vlist +e +vlist +quit diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/main.c eresi-0.0.20110516/testsuite/sct_fillbss_injection/main.c --- eresi-0.8a25/testsuite/sct_fillbss_injection/main.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - printf("Hijackme"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/Makefile eresi-0.0.20110516/testsuite/sct_fillbss_injection/Makefile --- eresi-0.8a25/testsuite/sct_fillbss_injection/Makefile 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/section_inject.c eresi-0.0.20110516/testsuite/sct_fillbss_injection/section_inject.c --- eresi-0.8a25/testsuite/sct_fillbss_injection/section_inject.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon May 19 13:11:32 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68" -"\x6E\x2f\x73\x68" -"\x68\x2f\x2f\x62" -"\x69\x89\xe3\x52" -"\x53\x89\xe1\x8D" -"\x42\x0b\xcd\x80" -"\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) - -char sc[] = -"\xeb\x22" /* jmp end */ -"\x5e" /* beg: pop %esi */ -"\x31\xc0" /* xorl %eax, %eax */ -"\x88\x46\x07" /* movb %al , 0x7(%esi) */ -"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ -"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ -"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ -"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ -"\x52" /* push %edx */ -"\x51" /* push %ecx */ -"\x56" /* push %esi */ -"\x50" /* push %eax */ -"\xb0\x3b" /* movb $0x3b, %al */ -"\xcd\x80" /* int $0x80 */ -"\x31\xdb" /* xorl %ebx, %ebx */ -"\x89\xd8" /* movl %ebx, %eax */ -"\xfe\xc0" /* inc %al */ -"\xcd\x80" /* int $0x80 */ -"\xe8\xd9\xff\xff\xff" /* end: call beg */ -"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#endif - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - elfsh_Sym *puts_troj; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - goto err; - - printf(" => Injection section and adding section header table entry ... \n"); - new = elfsh_create_section(".devhell"); - if (!new) - goto err; - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section */ - if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_DATA_INJECTION, 0) < 0) - goto err; - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - goto err; - - /* Hijack puts */ - elfsh_hijack_function_by_name(file, ELFSH_HIJACK_TYPE_GOT, - "puts", new->shdr->sh_addr, NULL); - - /* and finally save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - - printf("Relinking *OK*\n"); - return (0); - - err: - elfsh_error(); - return (-1); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/all-wcprops eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/all-wcprops --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/749/trunk/testsuite/sct_fillbss_injection -END -section_inject.c -K 25 -svn:wc:ra_dav:version-url -V 72 -/svn/!svn/ver/749/trunk/testsuite/sct_fillbss_injection/section_inject.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/749/trunk/testsuite/sct_fillbss_injection/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/749/trunk/testsuite/sct_fillbss_injection/Makefile -END diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/entries eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/entries --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sct_fillbss_injection -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -section_inject.c -file - - - - -2008-04-06T23:15:42.294903Z -bd9d2089370b2dd16278fe2a5b2e24fa -2007-07-31T03:28:48.000000Z -749 -may - -main.c -file - - - - -2008-04-06T23:15:42.321899Z -2ab1b1fe18e7f73411a41f3728be1b54 -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:42.334005Z -92c5317c3c145f172785a716c72fa147 -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/format eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/format --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/main.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - printf("Hijackme"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/section_inject.c.svn-base eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/section_inject.c.svn-base --- eresi-0.8a25/testsuite/sct_fillbss_injection/.svn/text-base/section_inject.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_fillbss_injection/.svn/text-base/section_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon May 19 13:11:32 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68" -"\x6E\x2f\x73\x68" -"\x68\x2f\x2f\x62" -"\x69\x89\xe3\x52" -"\x53\x89\xe1\x8D" -"\x42\x0b\xcd\x80" -"\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) - -char sc[] = -"\xeb\x22" /* jmp end */ -"\x5e" /* beg: pop %esi */ -"\x31\xc0" /* xorl %eax, %eax */ -"\x88\x46\x07" /* movb %al , 0x7(%esi) */ -"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ -"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ -"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ -"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ -"\x52" /* push %edx */ -"\x51" /* push %ecx */ -"\x56" /* push %esi */ -"\x50" /* push %eax */ -"\xb0\x3b" /* movb $0x3b, %al */ -"\xcd\x80" /* int $0x80 */ -"\x31\xdb" /* xorl %ebx, %ebx */ -"\x89\xd8" /* movl %ebx, %eax */ -"\xfe\xc0" /* inc %al */ -"\xcd\x80" /* int $0x80 */ -"\xe8\xd9\xff\xff\xff" /* end: call beg */ -"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#endif - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - elfsh_Sym *puts_troj; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - goto err; - - printf(" => Injection section and adding section header table entry ... \n"); - new = elfsh_create_section(".devhell"); - if (!new) - goto err; - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section */ - if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_DATA_INJECTION, 0) < 0) - goto err; - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - goto err; - - /* Hijack puts */ - elfsh_hijack_function_by_name(file, ELFSH_HIJACK_TYPE_GOT, - "puts", new->shdr->sh_addr, NULL); - - /* and finally save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - - printf("Relinking *OK*\n"); - return (0); - - err: - elfsh_error(); - return (-1); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_index_injection/main.c eresi-0.0.20110516/testsuite/sct_index_injection/main.c --- eresi-0.8a25/testsuite/sct_index_injection/main.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -/* -** -** $Id: main.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -main() -{ -return (42); -} diff -Nru eresi-0.8a25/testsuite/sct_index_injection/Makefile eresi-0.0.20110516/testsuite/sct_index_injection/Makefile --- eresi-0.8a25/testsuite/sct_index_injection/Makefile 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Mon Jun 30 11:01:15 2003 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - @echo WARNING: The output file is not intended to be used in this example - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sct_index_injection/section_inject.c eresi-0.0.20110516/testsuite/sct_index_injection/section_inject.c --- eresi-0.8a25/testsuite/sct_index_injection/section_inject.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* -** sht_inject.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Thu Mar 20 06:36:23 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" -"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" -"\xcd\x80\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) - -char sc[] = -"\xeb\x22" /* jmp end */ -"\x5e" /* beg: pop %esi */ -"\x31\xc0" /* xorl %eax, %eax */ -"\x88\x46\x07" /* movb %al , 0x7(%esi) */ -"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ -"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ -"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ -"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ -"\x52" /* push %edx */ -"\x51" /* push %ecx */ -"\x56" /* push %esi */ -"\x50" /* push %eax */ -"\xb0\x3b" /* movb $0x3b, %al */ -"\xcd\x80" /* int $0x80 */ -"\x31\xdb" /* xorl %ebx, %ebx */ -"\x89\xd8" /* movl %ebx, %eax */ -"\xfe\xc0" /* inc %al */ -"\xcd\x80" /* int $0x80 */ -"\xe8\xd9\xff\xff\xff" /* end: call beg */ -"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#endif - - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* Create the ELFsh binary descriptor EBD */ - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create the section descriptor (ESD) */ - new = elfsh_create_section(".devhell"); - if (!new) - { - elfsh_error(); - exit(-1); - } - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section at index 20 */ - if (elfsh_insert_section_idx(file, new, hdr, sc, 20) < 0) - { - elfsh_error(); - exit(-1); - } - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - { - elfsh_error(); - exit(-1); - } - - - /* choose if u want to hijack "puts" using .got (default) or using the entry point */ - //file->hdr->e_entry = new->shdr->sh_addr; - /* if (elfsh_set_got_entry_by_name(file, "puts", new->shdr->sh_addr) < 0) - { - elfsh_error(); - exit(-1); - } - */ - - /* Now we save */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); - return (ret); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/all-wcprops eresi-0.0.20110516/testsuite/sct_index_injection/.svn/all-wcprops --- eresi-0.8a25/testsuite/sct_index_injection/.svn/all-wcprops 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 53 -/svn/!svn/ver/749/trunk/testsuite/sct_index_injection -END -section_inject.c -K 25 -svn:wc:ra_dav:version-url -V 70 -/svn/!svn/ver/749/trunk/testsuite/sct_index_injection/section_inject.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/502/trunk/testsuite/sct_index_injection/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/749/trunk/testsuite/sct_index_injection/Makefile -END diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/entries eresi-0.0.20110516/testsuite/sct_index_injection/.svn/entries --- eresi-0.8a25/testsuite/sct_index_injection/.svn/entries 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sct_index_injection -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -section_inject.c -file - - - - -2008-04-06T23:15:38.337898Z -d3dcad211e253c233c3b5df0817ce16e -2007-07-31T03:28:48.000000Z -749 -may - -main.c -file - - - - -2008-04-06T23:15:38.348464Z -81556393848485145c993dbed999c2d3 -2007-03-07T16:45:36.000000Z -502 -thor - -Makefile -file - - - - -2008-04-06T23:15:38.361893Z -1ec6edffc601945592e5515fd502ff30 -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/format eresi-0.0.20110516/testsuite/sct_index_injection/.svn/format --- eresi-0.8a25/testsuite/sct_index_injection/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_index_injection/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_index_injection/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/main.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -/* -** -** $Id: main.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -main() -{ -return (42); -} diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Mon Jun 30 11:01:15 2003 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - @echo WARNING: The output file is not intended to be used in this example - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/section_inject.c.svn-base eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/section_inject.c.svn-base --- eresi-0.8a25/testsuite/sct_index_injection/.svn/text-base/section_inject.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_index_injection/.svn/text-base/section_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,140 +0,0 @@ -/* -** sht_inject.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Thu Mar 20 06:36:23 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" -"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" -"\xcd\x80\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) - -char sc[] = -"\xeb\x22" /* jmp end */ -"\x5e" /* beg: pop %esi */ -"\x31\xc0" /* xorl %eax, %eax */ -"\x88\x46\x07" /* movb %al , 0x7(%esi) */ -"\x89\x76\x08" /* movl %esi, 0x8(%esi) */ -"\x89\x46\x0c" /* movl %eax, 0xc(%esi) */ -"\x8d\x56\x0c" /* leal 0xc(%esi), %edx */ -"\x8d\x4e\x08" /* leal 0x8(%esi), %ecx */ -"\x52" /* push %edx */ -"\x51" /* push %ecx */ -"\x56" /* push %esi */ -"\x50" /* push %eax */ -"\xb0\x3b" /* movb $0x3b, %al */ -"\xcd\x80" /* int $0x80 */ -"\x31\xdb" /* xorl %ebx, %ebx */ -"\x89\xd8" /* movl %ebx, %eax */ -"\xfe\xc0" /* inc %al */ -"\xcd\x80" /* int $0x80 */ -"\xe8\xd9\xff\xff\xff" /* end: call beg */ -"\x2f\x62\x69\x6e\x2f\x73\x68"; /* "/bin/sh" */ - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#endif - - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* Create the ELFsh binary descriptor EBD */ - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create the section descriptor (ESD) */ - new = elfsh_create_section(".devhell"); - if (!new) - { - elfsh_error(); - exit(-1); - } - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section at index 20 */ - if (elfsh_insert_section_idx(file, new, hdr, sc, 20) < 0) - { - elfsh_error(); - exit(-1); - } - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - { - elfsh_error(); - exit(-1); - } - - - /* choose if u want to hijack "puts" using .got (default) or using the entry point */ - //file->hdr->e_entry = new->shdr->sh_addr; - /* if (elfsh_set_got_entry_by_name(file, "puts", new->shdr->sh_addr) < 0) - { - elfsh_error(); - exit(-1); - } - */ - - /* Now we save */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); - return (ret); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_top_injection/main.c eresi-0.0.20110516/testsuite/sct_top_injection/main.c --- eresi-0.8a25/testsuite/sct_top_injection/main.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(10); - if (str == NULL) - goto err; - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - return (0); - err: - puts("Malloc error"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/sct_top_injection/Makefile eresi-0.0.20110516/testsuite/sct_top_injection/Makefile --- eresi-0.8a25/testsuite/sct_top_injection/Makefile 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout - - - - - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_top_injection/section_inject.c eresi-0.0.20110516/testsuite/sct_top_injection/section_inject.c --- eresi-0.8a25/testsuite/sct_top_injection/section_inject.c 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon Jun 30 11:54:57 2003 jv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" -"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" -"\xcd\x80\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) - -char sc[] = -"\xeb\x0d\x5f\x31\xc0\x50\x89\xe2" -"\x52\x57\x54\xb0\x3b\xcd\x80\xe8" -"\xee\xff\xff\xff/bin/sh"; - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#else - #error "This feature is not available on this OS" -#endif - - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* Create the ELFsh binary descriptor (EBD) */ - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - goto err; - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create the section descriptor (ESD) */ - new = elfsh_create_section(".devhell"); - if (!new) - goto err; - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section */ - if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_CODE_INJECTION, - elfsh_get_pagesize(file)) < 0) - goto err; - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - goto err; - - /* Hijack puts */ - ret = elfsh_hijack_function_by_name(file, - ELFSH_HIJACK_TYPE_PLT, - "puts", new->shdr->sh_addr, NULL); - if (ret < 0) - goto err; - - /* Now we save */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - goto err; - - printf("Relinking *OK*\n"); - return (0); - - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/all-wcprops eresi-0.0.20110516/testsuite/sct_top_injection/.svn/all-wcprops --- eresi-0.8a25/testsuite/sct_top_injection/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 51 -/svn/!svn/ver/873/trunk/testsuite/sct_top_injection -END -section_inject.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/749/trunk/testsuite/sct_top_injection/section_inject.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/749/trunk/testsuite/sct_top_injection/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/873/trunk/testsuite/sct_top_injection/Makefile -END diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/entries eresi-0.0.20110516/testsuite/sct_top_injection/.svn/entries --- eresi-0.8a25/testsuite/sct_top_injection/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sct_top_injection -http://svn.eresi-project.org/svn - - - -2008-02-29T14:10:34.941201Z -873 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -section_inject.c -file - - - - -2008-04-06T23:15:42.392902Z -1ebae05e87f898494e4439cdc129fc9a -2007-07-31T03:28:48.000000Z -749 -may - -main.c -file - - - - -2008-04-06T23:15:42.420905Z -1ab747a95912c007f2566296d4b578b8 -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:42.458876Z -9caea8afa28511bfebc21519215a97fe -2008-02-29T14:10:34.941201Z -873 -enioh -has-props - diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/format eresi-0.0.20110516/testsuite/sct_top_injection/.svn/format --- eresi-0.8a25/testsuite/sct_top_injection/.svn/format 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_top_injection/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_top_injection/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/main.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(10); - if (str == NULL) - goto err; - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - return (0); - err: - puts("Malloc error"); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout - - - - - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/section_inject.c.svn-base eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/section_inject.c.svn-base --- eresi-0.8a25/testsuite/sct_top_injection/.svn/text-base/section_inject.c.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_top_injection/.svn/text-base/section_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,109 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon Jun 30 11:54:57 2003 jv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -/* the first execve + exit shellcode I found in my tree, not a very short one ;) */ -#if defined(__linux__) - -char sc[] = -"\x31\xd2\x52\x68\x6E\x2f\x73\x68\x68\x2f\x2f" -"\x62\x69\x89\xe3\x52\x53\x89\xe1\x8D\x42\x0b" -"\xcd\x80\x31\xC0\x40\xcd\x80"; - -#elif defined(__NetBSD__) - -char sc[] = -"\xeb\x0d\x5f\x31\xc0\x50\x89\xe2" -"\x52\x57\x54\xb0\x3b\xcd\x80\xe8" -"\xee\xff\xff\xff/bin/sh"; - -#elif defined(sun) - -char sc[] = -"\x2d\x0b\xd8\x9a\xac\x15\xa1\x6e" -"\x2b\x0b\xda\xdc\xae\x15\x63\x68" -"\x90\x0b\x80\x0e\x92\x03\xa0\x0c" -"\x94\x10\x20\x10\x94\x22\xa0\x10" -"\x9c\x03\xa0\x14" -"\xec\x3b\xbf\xec\xc0\x23\xbf\xf4\xdc\x23\xbf\xf8\xc0\x23\xbf\xfc" -"\x82\x10\x20\x3b\x91\xd0\x20\x08\x90\x1b\xc0\x0f\x82\x10\x20\x01" -"\x91\xd0\x20\x08" ; - -#else - #error "This feature is not available on this OS" -#endif - - - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - - - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* Create the ELFsh binary descriptor (EBD) */ - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - goto err; - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create the section descriptor (ESD) */ - new = elfsh_create_section(".devhell"); - if (!new) - goto err; - - /* Create a section header for the mapped section */ - hdr = elfsh_create_shdr(0, SHT_PROGBITS, SHF_EXECINSTR | SHF_ALLOC, 0, 0, sizeof(sc), 0, 0, 0, 0); - - /* Insert the section */ - if (elfsh_insert_mapped_section(file, new, hdr, sc, ELFSH_CODE_INJECTION, - elfsh_get_pagesize(file)) < 0) - goto err; - - /* Retreive it again since the file offset and the vaddr may have been updated during insertion */ - new = elfsh_get_section_by_name(file, ".devhell", NULL, NULL, NULL); - if (!new) - goto err; - - /* Hijack puts */ - ret = elfsh_hijack_function_by_name(file, - ELFSH_HIJACK_TYPE_PLT, - "puts", new->shdr->sh_addr, NULL); - if (ret < 0) - goto err; - - /* Now we save */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - goto err; - - printf("Relinking *OK*\n"); - return (0); - - err: - elfsh_error(); - return (-1); -} diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/main.c eresi-0.0.20110516/testsuite/sct_unmapped_injection/main.c --- eresi-0.8a25/testsuite/sct_unmapped_injection/main.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/Makefile eresi-0.0.20110516/testsuite/sct_unmapped_injection/Makefile --- eresi-0.8a25/testsuite/sct_unmapped_injection/Makefile 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/section_inject.c eresi-0.0.20110516/testsuite/sct_unmapped_injection/section_inject.c --- eresi-0.8a25/testsuite/sct_unmapped_injection/section_inject.c 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/section_inject.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* -** section_injection.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon May 19 13:12:23 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create a new unmapped section */ - unmapped_new = elfsh_create_section(".dhstrtab"); - if (!unmapped_new) - { - elfsh_error(); - exit(-1); - } - - /* Create a new section header */ - unmapped_hdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, strlen(str), 0, 0, 0, 0); - if (elfsh_insert_unmapped_section(file, unmapped_new, unmapped_hdr, str) < 0) - { - elfsh_error(); - exit(-1); - } - - /* Finally save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); - return (ret); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/all-wcprops eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/all-wcprops --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/all-wcprops 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/874/trunk/testsuite/sct_unmapped_injection -END -section_inject.c -K 25 -svn:wc:ra_dav:version-url -V 73 -/svn/!svn/ver/749/trunk/testsuite/sct_unmapped_injection/section_inject.c -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/749/trunk/testsuite/sct_unmapped_injection/main.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 65 -/svn/!svn/ver/874/trunk/testsuite/sct_unmapped_injection/Makefile -END diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/entries eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/entries --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/entries 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sct_unmapped_injection -http://svn.eresi-project.org/svn - - - -2008-02-29T14:11:19.122323Z -874 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -section_inject.c -file - - - - -2008-04-06T23:15:38.441899Z -5250642f03db4f4c4bb4849eac6c45a7 -2007-07-31T03:28:48.000000Z -749 -may - -main.c -file - - - - -2008-04-06T23:15:38.484136Z -b312789822afb63a5fa0905e8f8c0fa8 -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:38.495876Z -4bcc7c4d2add77833dd602d2e76e368c -2008-02-29T14:11:19.122323Z -874 -enioh -has-props - diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/format eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/format --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/main.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:15 2002 jfv -## - -include ../../config.h - -SRC = section_inject.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace -letrace32 -NAM = sct_injecter -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/section_inject.c.svn-base eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/section_inject.c.svn-base --- eresi-0.8a25/testsuite/sct_unmapped_injection/.svn/text-base/section_inject.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sct_unmapped_injection/.svn/text-base/section_inject.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -/* -** section_injection.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Mon May 19 13:12:23 2003 jfv -** -** $Id: section_inject.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define TROJANED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - -/* test for non-mapped data */ -char *str = "stop looking at me ! \n"; - -/* Here we map the shellcode in a newly inserted mapped section (.devhell) and modify the entry point */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - file = elfsh_map_obj(TROJANED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - printf(" => Injection section and adding section header table entry ... \n"); - - /* Create a new unmapped section */ - unmapped_new = elfsh_create_section(".dhstrtab"); - if (!unmapped_new) - { - elfsh_error(); - exit(-1); - } - - /* Create a new section header */ - unmapped_hdr = elfsh_create_shdr(0, SHT_PROGBITS, 0, 0, 0, strlen(str), 0, 0, 0, 0); - if (elfsh_insert_unmapped_section(file, unmapped_new, unmapped_hdr, str) < 0) - { - elfsh_error(); - exit(-1); - } - - /* Finally save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", (ret < 0 ? "Error" : "OK")); - return (ret); -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sht_rebuild/Makefile eresi-0.0.20110516/testsuite/sht_rebuild/Makefile --- eresi-0.8a25/testsuite/sht_rebuild/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:29 2002 jfv -## - -include ../../config.h - -SRC = sht_rebuild.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sht_rebuilder -RM = rm -f -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) sht_rebuilt_file diff -Nru eresi-0.8a25/testsuite/sht_rebuild/sht_rebuild.c eresi-0.0.20110516/testsuite/sht_rebuild/sht_rebuild.c --- eresi-0.8a25/testsuite/sht_rebuild/sht_rebuild.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/sht_rebuild.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Fri Jan 24 12:56:13 2003 jfv -** -** $Id: sht_rebuild.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" -#include - -#define STRIPPED_FILE "./sht_stripped_file" -#define OUTPUT_FILE "./sht_rebuilt_file" - -/* We just map and save the object since ELFsh automatically rebuid SHT */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* map the object */ - file = elfsh_map_obj(STRIPPED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - /* Get (and reconstruct if unexistant) SHT and SYMTAB */ - elfsh_get_sht(file, NULL); - elfsh_get_symtab(file, NULL); - - /* Save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); - -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/all-wcprops eresi-0.0.20110516/testsuite/sht_rebuild/.svn/all-wcprops --- eresi-0.8a25/testsuite/sht_rebuild/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/749/trunk/testsuite/sht_rebuild -END -sht_rebuild.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/749/trunk/testsuite/sht_rebuild/sht_rebuild.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/749/trunk/testsuite/sht_rebuild/Makefile -END diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/entries eresi-0.0.20110516/testsuite/sht_rebuild/.svn/entries --- eresi-0.8a25/testsuite/sht_rebuild/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sht_rebuild -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -sht_rebuild.c -file - - - - -2008-04-06T23:15:40.327137Z -96b53d72cac1a238b5118649ed4fc618 -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:40.336875Z -4809caf1b749ffdfba77140dd44230c6 -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/format eresi-0.0.20110516/testsuite/sht_rebuild/.svn/format --- eresi-0.8a25/testsuite/sht_rebuild/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sht_rebuild/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sht_rebuild/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sht_rebuild/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sht_rebuild/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:29 2002 jfv -## - -include ../../config.h - -SRC = sht_rebuild.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sht_rebuilder -RM = rm -f -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) sht_rebuilt_file diff -Nru eresi-0.8a25/testsuite/sht_rebuild/.svn/text-base/sht_rebuild.c.svn-base eresi-0.0.20110516/testsuite/sht_rebuild/.svn/text-base/sht_rebuild.c.svn-base --- eresi-0.8a25/testsuite/sht_rebuild/.svn/text-base/sht_rebuild.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_rebuild/.svn/text-base/sht_rebuild.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Fri Jan 24 12:56:13 2003 jfv -** -** $Id: sht_rebuild.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" -#include - -#define STRIPPED_FILE "./sht_stripped_file" -#define OUTPUT_FILE "./sht_rebuilt_file" - -/* We just map and save the object since ELFsh automatically rebuid SHT */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - /* map the object */ - file = elfsh_map_obj(STRIPPED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - /* Get (and reconstruct if unexistant) SHT and SYMTAB */ - elfsh_get_sht(file, NULL); - elfsh_get_symtab(file, NULL); - - /* Save the object */ - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); - -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sht_stripping/main.c eresi-0.0.20110516/testsuite/sht_stripping/main.c --- eresi-0.8a25/testsuite/sht_stripping/main.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sht_stripping/Makefile eresi-0.0.20110516/testsuite/sht_stripping/Makefile --- eresi-0.8a25/testsuite/sht_stripping/Makefile 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:52 2002 jfv -## - -include ../../config.h - -SRC = sht_removing.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sht_remover -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sht_stripping/sht_removing.c eresi-0.0.20110516/testsuite/sht_stripping/sht_removing.c --- eresi-0.8a25/testsuite/sht_stripping/sht_removing.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/sht_removing.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Thu Jun 6 04:46:18 2002 jfv -** -** $Id: sht_removing.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define STRIPPED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - - -/* Here we map, remove sht, and save the binary */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - file = elfsh_map_obj(STRIPPED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - - printf("=> Removing the Section header table \n"); - elfsh_remove_sht(file); - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); - -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/all-wcprops eresi-0.0.20110516/testsuite/sht_stripping/.svn/all-wcprops --- eresi-0.8a25/testsuite/sht_stripping/.svn/all-wcprops 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/749/trunk/testsuite/sht_stripping -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/749/trunk/testsuite/sht_stripping/main.c -END -sht_removing.c -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/749/trunk/testsuite/sht_stripping/sht_removing.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/749/trunk/testsuite/sht_stripping/Makefile -END diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/entries eresi-0.0.20110516/testsuite/sht_stripping/.svn/entries --- eresi-0.8a25/testsuite/sht_stripping/.svn/entries 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,65 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/sht_stripping -http://svn.eresi-project.org/svn - - - -2007-07-31T03:28:48.000000Z -749 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -main.c -file - - - - -2008-04-06T23:15:39.910887Z -b312789822afb63a5fa0905e8f8c0fa8 -2007-07-31T03:28:48.000000Z -749 -may - -sht_removing.c -file - - - - -2008-04-06T23:15:39.921889Z -2dccdf23f77ee2c8e38a4c13ef3813da -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:39.933152Z -c785b33b0805e694d604d71eeb2d93fc -2007-07-31T03:28:48.000000Z -749 -may -has-props - diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/format eresi-0.0.20110516/testsuite/sht_stripping/.svn/format --- eresi-0.8a25/testsuite/sht_stripping/.svn/format 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sht_stripping/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sht_stripping/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/main.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -/* -** main.c -** -** Started on Sun Mar 17 06:38:49 2002 jfv -** Last update Sat Mar 23 11:00:10 2002 jfv -** -** $Id: main.c,v 1.4 2007-07-31 03:28:48 may Exp $ -** -*/ -#include -#include - -int main() -{ - char *str; - int index; - - for (index = 0; index < 10; index++) - { - str = (char *) malloc(256); - memcpy(str, "test_heap", 9); - printf("%s [%u] \n", str, index); - } - - puts("End !"); - - return (0); -} diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun Dec 15 01:56:52 2002 jfv -## - -include ../../config.h - -SRC = sht_removing.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 -NAM = sht_remover -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - @$(CC) $(OPT) $(VULN) - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/sht_removing.c.svn-base eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/sht_removing.c.svn-base --- eresi-0.8a25/testsuite/sht_stripping/.svn/text-base/sht_removing.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/sht_stripping/.svn/text-base/sht_removing.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/* -** sht_extend.c -** -** Started on Sun Mar 17 05:57:23 2002 jfv -** Last update Thu Jun 6 04:46:18 2002 jfv -** -** $Id: sht_removing.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - -#define STRIPPED_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - - -/* Here we map, remove sht, and save the binary */ -int main(int argc, char **argv) -{ - elfshobj_t *file; - elfsh_Shdr hdr; - elfsh_Shdr unmapped_hdr; - elfshsect_t *new; - elfshsect_t *unmapped_new; - int ret; - - file = elfsh_map_obj(STRIPPED_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - - printf("=> Removing the Section header table \n"); - elfsh_remove_sht(file); - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); - -} - - - - - - - diff -Nru eresi-0.8a25/testsuite/static_analysis/binaries/bin.c eresi-0.0.20110516/testsuite/static_analysis/binaries/bin.c --- eresi-0.8a25/testsuite/static_analysis/binaries/bin.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/binaries/bin.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,7 @@ + +int main() +{ + myfunc1(); + myfunc2(); + myfunc3(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/binaries/libfunc.c eresi-0.0.20110516/testsuite/static_analysis/binaries/libfunc.c --- eresi-0.8a25/testsuite/static_analysis/binaries/libfunc.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/binaries/libfunc.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,15 @@ +int myfunc1() +{ + return (1); +} + +int myfunc2() +{ + return (2); + +} + +int myfunc3() +{ + return (3); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/binaries/Makefile eresi-0.0.20110516/testsuite/static_analysis/binaries/Makefile --- eresi-0.8a25/testsuite/static_analysis/binaries/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/binaries/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,20 @@ +ELFSH=../../../elfsh/elfsh32 + +all: all32 +all32: test +test: bin + @ echo =================================== + @ echo ========== OBJDUMP ================ + @objdump -R bin | tee tRel.objdump.log + @ echo =================================== + @ echo ========== ELFSH ================== + @${ELFSH} -f bin -rel | tee tRel.elfsh.log + +bin: + cc -c bin.c + cc -fPIC -shared -o libfunc.so libfunc.c + cc -o bin bin.o -L. -lfunc + +fclean: +clean: + rm -f libfunc.so bin.o bin *~ diff -Nru eresi-0.8a25/testsuite/static_analysis/binaries/pRel.py eresi-0.0.20110516/testsuite/static_analysis/binaries/pRel.py --- eresi-0.8a25/testsuite/static_analysis/binaries/pRel.py 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/binaries/pRel.py 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,50 @@ +#!/usr/bin/python + +import re +from StringIO import StringIO + +logElfsh = open("tRel.elfsh.log") +logObjdump = open("tRel.objdump.log") + +reElfsh = re.compile("[^\]]+ ([^ ]+)") +reObjdump = re.compile('(?P
[^ ]+) (?PR_[^ ]+)[ ]+(?P[^ ]+)') + +ioElfsh = StringIO( +""" + [*] Object bin has been loaded (O_RDONLY) + [RELOCATION TABLES] + [000] R_386_GLOB_DAT 0x0804969C sym[002] : __gmon_start__ => Create GOT entry + [000] R_386_JMP_SLOT 0x080496AC sym[001] : myfunc2 => Create PLT entry + [001] R_386_JMP_SLOT 0x080496B0 sym[002] : __gmon_start__ => Create PLT entry + [002] R_386_JMP_SLOT 0x080496B4 sym[004] : __libc_start_main => Create PLT entry + [003] R_386_JMP_SLOT 0x080496B8 sym[005] : myfunc3 => Create PLT entry + [004] R_386_JMP_SLOT 0x080496BC sym[006] : myfunc1 => Create PLT entry +""") +ioObjdump = StringIO(""" +DYNAMIC RELOCATION RECORDS +0804969c R_386_GLOB_DAT __gmon_start__ +080496ac R_386_JUMP_SLOT myfunc2 +080496b0 R_386_JUMP_SLOT __gmon_start__ +080496b4 R_386_JUMP_SLOT __libc_start_main +080496b8 R_386_JUMP_SLOT myfunc3 +080496bc R_386_JUMP_SLOT myfunc1 +""") + +def parseRelObjdump(lines): + to_ret = [] + for line in lines: + #print line.strip() + m = reObjdump.match(line.strip()) + if m != None: + dir(m) + to_ret.append(m.groups()) + return to_ret + +def parseRelElfsh(lines): + to_ret = [] + + return to_ret + + +lines = ioObjdump.readlines() +print parseRelObjdump(lines) diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/10.modification_de_champ_dans_une_methode.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/10.modification_de_champ_dans_une_methode.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/10.modification_de_champ_dans_une_methode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/10.modification_de_champ_dans_une_methode.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,28 @@ + + + +class A +{ +public: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + + void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + + + +int main() +{ + A a; + + a.A_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/11.appel_force_de_methode_mere_surchargee.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/11.appel_force_de_methode_mere_surchargee.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/11.appel_force_de_methode_mere_surchargee.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/11.appel_force_de_methode_mere_surchargee.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,44 @@ + + + +class A +{ + +protected: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + +public: + virtual void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + +class B : public A +{ + +public: + void A_M_a() { + A_a = 'a'; + A_b = 24; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + + +}; + + + +int main() +{ + B b; + + b.A::A_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/12.heritage_simple_avec_appel_de_methode.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/12.heritage_simple_avec_appel_de_methode.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/12.heritage_simple_avec_appel_de_methode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/12.heritage_simple_avec_appel_de_methode.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,50 @@ + + + +class A +{ + +protected: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + +public: + void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + +class B : public A +{ + + +public: + char B_a; + short B_b; + int B_c; + unsigned long B_d; + + void B_M_a() { + B_a = 'a'; + B_b = 24; + B_c = 0xdeadbeef; + B_d = 0xbadc0de; + }; + + +}; + + + +int main() +{ + B b; + + b.B_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/13.heritage_simple_avec_appel_methode_de_classe_mere.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/13.heritage_simple_avec_appel_methode_de_classe_mere.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/13.heritage_simple_avec_appel_methode_de_classe_mere.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/13.heritage_simple_avec_appel_methode_de_classe_mere.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,44 @@ + + + +class A +{ + +protected: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + +public: + void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + +class B : public A +{ + +public: + void B_M_a() { + A_a = 'a'; + A_b = 24; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + + +}; + + + +int main() +{ + B b; + + b.A_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/14.heritage_simple_avec_appel_methode_virtuelle.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/14.heritage_simple_avec_appel_methode_virtuelle.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/14.heritage_simple_avec_appel_methode_virtuelle.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/14.heritage_simple_avec_appel_methode_virtuelle.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,44 @@ + + + +class A +{ + +protected: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + +public: + virtual void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + +class B : public A +{ + +public: + void A_M_a() { + A_a = 'a'; + A_b = 24; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + + +}; + + + +int main() +{ + B b; + + b.A_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/15.heritage_simple_avec_parent_field_modif.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/15.heritage_simple_avec_parent_field_modif.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/15.heritage_simple_avec_parent_field_modif.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/15.heritage_simple_avec_parent_field_modif.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,44 @@ + + + +class A +{ + +protected: + char A_a; + short A_b; + int A_c; + unsigned long A_d; + +public: + void A_M_a() { + A_a = 'z'; + A_b = 42; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + +}; + +class B : public A +{ + +public: + void B_M_a() { + A_a = 'a'; + A_b = 24; + A_c = 0xdeadbeef; + A_d = 0xbadc0de; + }; + + +}; + + + +int main() +{ + B b; + + b.B_M_a(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/16.signature_new_delete.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/16.signature_new_delete.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/16.signature_new_delete.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/16.signature_new_delete.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,29 @@ + + + +class A +{ +public: + char A_a; + short A_b; + int A_c; + unsigned long A_d; +}; + + + +int main() +{ + A *a; + + a = new A(); + + a->A_a = 'z'; + a->A_b = 42; + a->A_c = 0xdeadbeef; + a->A_d = 0xbadc0de; + + delete(a); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/17.template_simple.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/17.template_simple.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/17.template_simple.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/17.template_simple.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,24 @@ + + + +template < typename T > +class A +{ +public: + T a; + + T A_M_a(T b) + { + a = b; + }; + +}; + + +int main() +{ + A a; + + a.A_M_a(42); + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/18.signature_stdio.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/18.signature_stdio.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/18.signature_stdio.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/18.signature_stdio.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,41 @@ + +#include + +using namespace std; + + +class A +{ +public: + char A_a; + short A_b; + int A_c; + unsigned long A_d; +}; + + + +int main() +{ + A a; + + a.A_a = 'z'; + a.A_b = 42; + a.A_c = 42434445; + a.A_d = 46474849; + + std::cout << a.A_a << " " << a.A_b << " " << a.A_c << " " << a.A_d << std::endl; + + std::cin >> a.A_a; + std::cin.get(); + std::cin >> a.A_b; + std::cin.get(); + std::cin >> a.A_c; + std::cin.get(); + std::cin >> a.A_d; + std::cin.get(); + + std::cout << a.A_a << " " << a.A_b << " " << a.A_c << " " << a.A_d << std::endl; + + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/19.signature_vector.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/19.signature_vector.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/19.signature_vector.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/19.signature_vector.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,13 @@ +#include + +int main() +{ + std::vector list; + + list.push_back(1); + list.push_back(2); + + list.pop_back(); + + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/1.simple_appel_de_methode.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/1.simple_appel_de_methode.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/1.simple_appel_de_methode.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/1.simple_appel_de_methode.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,26 @@ +/* +** appel simple d une methode. +*/ + +class C_A +{ +private: + int a_; + +public: + C_A () { a_ = 0;}; + ~C_A () {}; + +public: + void A_M_a() { a_++; }; + void A_M_b() { a_--; }; +}; + +int main() +{ + C_A ptr; + + ptr.A_M_a(); + ptr.A_M_b(); + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/20.signature_list.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/20.signature_list.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/20.signature_list.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/20.signature_list.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,16 @@ + +#include +#include + + +int main() +{ + std::list a; + + a.push_front(42); + a.push_front(68); + a.push_front(72); + a.remove(68); + + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/21.signature_iterator.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/21.signature_iterator.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/21.signature_iterator.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/21.signature_iterator.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,19 @@ + +#include +#include + + +int main() +{ + std::list a; + + a.push_front(42); + a.push_front(68); + a.push_front(72); + a.remove(68); + + for (std::list::iterator i = a.begin(); i != a.end(); i++) + std::cout << *i << std::endl; + + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/22.signature_map.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/22.signature_map.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/22.signature_map.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/22.signature_map.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,11 @@ +#include +#include + +int main() +{ + std::map table; + + table['a'] = 10; + + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,31 @@ +class C_A +{ +public: + int a_; + +public: + C_A() { a_ = 0; }; + void A_M_a () { a_++; }; +}; + +class C_B : public C_A +{ +public: + void B_M_a() { A_M_a (); }; +}; + +class C_C : public C_B +{ +public: + void C_M_a() { B_M_a(); }; +}; + +int main() +{ + + C_C val; + + val.C_M_a(); + + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,31 @@ +class C_A +{ +private: + int a_; + +public: + C_A() { a_ = 0; }; + void A_M_a () { a_++; }; +}; + +class C_B : public C_A +{ +public: + void B_M_a() { A_M_a (); }; +}; + +class C_C : public C_B +{ +public: + void C_M_a() { B_M_a(); }; +}; + +int main() +{ + + C_C val; + + val.A_M_a(); + + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,34 @@ +class C_A +{ +public: + int a_; + +public: + C_A() { a_ = 0; }; + void A_M_a () { a_++; }; +}; + +class C_B : public C_A +{ +public: + void B_M_a() { A_M_a (); }; +}; + +class C_C : public C_B +{ +public: + void C_M_a() { B_M_a(); }; +}; + +int main() +{ + + C_C val; + + val.a_++; + val.a_--; + val.a_++; + val.a_--; + + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/26.heritage_multiple_avec_appel_de_methodes_parentes.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/26.heritage_multiple_avec_appel_de_methodes_parentes.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/26.heritage_multiple_avec_appel_de_methodes_parentes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/26.heritage_multiple_avec_appel_de_methodes_parentes.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,35 @@ + +class C_A { +private: + int a_; + +public: + C_A() { a_ = 0; }; + + void A_M_a () { a_++; }; +}; + +class C_B { + private: + int b_; + + public: + C_B() { b_ = 0; }; + void B_M_a () { b_++; }; +}; + +class C_C : public C_A, public C_B +{ + public: + void C_M_a() { A_M_a(); B_M_a(); }; +}; + + +int main() +{ + C_C val; + + val.C_M_a(); + + return 1; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/27.heritage_de_classe_template.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/27.heritage_de_classe_template.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/27.heritage_de_classe_template.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/27.heritage_de_classe_template.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,35 @@ + + + +template +class Somme +{ +private: + T a_; + T b_; +public: + Somme(T a, T b) { a_ = a; b_ = b; }; + + T addition() { return a_ + b_; } ; +}; + +class Operation : public Somme +{ +public: + Operation() : Somme(2, 3) {} ; + + int resultat() + { + return addition(); + }; +}; + +int main () +{ + Operation op; + int a; + + a = op.addition(); + a = op.resultat(); + return 0; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/28.interprocedural_loop_array_copy.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/28.interprocedural_loop_array_copy.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/28.interprocedural_loop_array_copy.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/28.interprocedural_loop_array_copy.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,32 @@ + +#include + + +void func1(int *a, int b) +{ + *a = b; +} + + + +int func2(int init) +{ + int a[20]; + int i; + + for (i = 0; i < sizeof(a); i++, init++) + { + if (i % 2) + init -= 0x30303030; + else if (i % 3) + func1(a + i, init); + } + return (42); +} + + +int main() +{ + printf("Testsuite 28 Triosigma project \n"); + return (func2(0x41414141)); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/29.loop_3conds_with_dowhile.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/29.loop_3conds_with_dowhile.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/29.loop_3conds_with_dowhile.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/29.loop_3conds_with_dowhile.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,42 @@ + +#include + + +void func1(int *a, int b) +{ + short idx = 0; + + do + { + if (idx % 2) + *a |= ((b >> idx) & 0x01); + idx++; + } + while (idx < 16); +} + + + +int func2(int init) +{ + int a[20]; + int i; + + for (i = 0; i < sizeof(a); i++, init++) + { + if (i % 2) + init -= 0x30303030; + else if (i % 3) + func1(a + i, init); + else + init += 0x10; + } + return (42); +} + + +int main() +{ + printf("Testsuite 29 Triosigma project \n"); + return (func2(0x41414141)); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/2.simple_utilisation_de_champ_public.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/2.simple_utilisation_de_champ_public.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/2.simple_utilisation_de_champ_public.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/2.simple_utilisation_de_champ_public.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,25 @@ + + + +class A +{ +public: + char A_a; + short A_b; + int A_c; + unsigned long A_d; +}; + + + +int main() +{ + A a; + + a.A_a = 'z'; + a.A_b = 42; + a.A_c = 0xdeadbeef; + a.A_d = 0xbadc0de; + + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/30.compounds_with_gotos_and_loop.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/30.compounds_with_gotos_and_loop.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/30.compounds_with_gotos_and_loop.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/30.compounds_with_gotos_and_loop.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,51 @@ + +#include + + +void func1(int b) +{ + short idx = 0; + + begin: + idx++; + do + { + switch (idx % 11) + { + case 1: + goto begin; + break; + default: + idx++; + } + } + while (idx < 16); +} + + + +int loop_on_prime(int init) +{ + char a[20]; + int i; + + for (i = 0; i < sizeof(a); i++, init++) + { + if (i % 2 && i % 5) + init -= 0x30303030; + else if (i % 3 && i % 7) + func1(init); + else + goto end; + } + + end: + return (42); +} + + +int main() +{ + printf("Testsuite 30 Triosigma project \n"); + return (loop_on_prime(0x41414141)); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/31.simple_types_recovery.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/31.simple_types_recovery.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/31.simple_types_recovery.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/31.simple_types_recovery.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,29 @@ + + +int main(int argc, char **argv) +{ + char a = 1; + short b = 2; + int c = 3; + long d = 4; + long long e = 5; + + unsigned char f = 6; + unsigned short g = 7; + unsigned int h = 8; + unsigned long i = 9; + unsigned long long j = 10; + + a = f * argc; + b = h + a; + c = j % g; + d = i ^ f; + e = g; + + j = a - b; + i = !j; + h = g + 1; + f = (c * g) + (d - e); + + return (f); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/32.n-dimentional-objects-arrays.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/32.n-dimentional-objects-arrays.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/32.n-dimentional-objects-arrays.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/32.n-dimentional-objects-arrays.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,44 @@ + +#include +#include + +class B +{ +public: + unsigned char f; + B() { f = 'Z'; }; +}; + + +class A +{ +private: + int c; +public: + int d; + B *t; + + A() { c = 42; t = new B(); }; + void print() { std::cout << c << " " << d << " " << t->f << std::endl; }; +}; + + + +int main(int argc, char **argv) +{ + A array[2][atoi(argv[1])][3]; + int idx, idx2, idx3; + + for (idx = 0; idx < 2; idx++) + { + for (idx2 = 0; idx2 < atoi(argv[1]); idx2++) + { + for (idx3 = 0; idx3 < 3; idx3++) + { + array[idx][idx2][idx3].d = idx + idx2 + idx3; + array[idx][idx2][idx3].print(); + } + } + } + return (-42); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/33.interprocedural_struct_access.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/33.interprocedural_struct_access.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/33.interprocedural_struct_access.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/33.interprocedural_struct_access.cpp 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,21 @@ + + +struct mystruct { int a; int b; }; + + +int proc(int *c) +{ + (*c)++; +} + + +int main() +{ + struct mystruct c; + int b = 42; + + proc(&b); + proc(&c.a); + proc(&c.b); + return (c.b); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/34.interprocedural_heap_corruption_static.c eresi-0.0.20110516/testsuite/static_analysis/evarista/34.interprocedural_heap_corruption_static.c --- eresi-0.8a25/testsuite/static_analysis/evarista/34.interprocedural_heap_corruption_static.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/34.interprocedural_heap_corruption_static.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,81 @@ +#include +#include +#include + +int func1(char *str) +{ + puts(str); + return 0; +} + +// Potential double free in that function +int func2(char *str) +{ + puts(str); + free(str); + return 0; +} + + +// Potential Memory leak in that function +int func3(char **str) +{ + puts(*str); + *str = (char *) malloc(BUFSIZ + 5); + return 0; +} + + +int mystrncmp(char *one, char *two, unsigned int n) +{ + int idx; + + for (idx = 0; idx < n; idx++) + if (one[idx] != two[idx]) + return (one[idx] - two[idx]); + return (0); +} + + +// This example is interresting, it contains many kind of +// incorrect heap manipulations or corruptions +int main() +{ + char *buf; + char *buf2; + char *swp; + int ret; + + buf = (char *) malloc(BUFSIZ); + while (1) + { + buf2 = (char *) malloc(BUFSIZ); + buf[0] = '\0'; + + if ((ret = read(0, buf, BUFSIZ - 1)) < 0) + exit(-1); + buf[ret - 1] = '\0'; + if ((ret = read(0, buf2, BUFSIZ - 1)) < 0) + exit(-1); + if (ret == 0) + exit(0); + + buf2[ret - 1] = '\0'; + + if (ret > 5 && buf[5] == 's') + { + swp = buf; + buf = buf2; + buf2 = swp; + } + + if (!mystrncmp(buf, "func1", 5)) + func1(buf); + else if (!mystrncmp(buf, "func2", 5)) + func2(buf); + else if (!mystrncmp(buf, "func3", 5)) + func3(&buf); + + free(buf2); + } +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/35.simple-heap-corruption.c eresi-0.0.20110516/testsuite/static_analysis/evarista/35.simple-heap-corruption.c --- eresi-0.8a25/testsuite/static_analysis/evarista/35.simple-heap-corruption.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/35.simple-heap-corruption.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,15 @@ + + +int main() +{ + char *a; + //char *b; + + a = malloc(42); + a = malloc(30); + if (a == 0) + return (0); + free(a); + free(a); + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/36.simple-global-heap-corruption.c eresi-0.0.20110516/testsuite/static_analysis/evarista/36.simple-global-heap-corruption.c --- eresi-0.8a25/testsuite/static_analysis/evarista/36.simple-global-heap-corruption.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/36.simple-global-heap-corruption.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,14 @@ + + +char *a; + +int main() +{ + a = malloc(42); + a = malloc(30); + if (a == 0) + return (0); + free(a); + free(a); + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/3.simple_utilisation_de_pointeur.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/3.simple_utilisation_de_pointeur.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/3.simple_utilisation_de_pointeur.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/3.simple_utilisation_de_pointeur.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,14 @@ + + + +int main() +{ + int b; + int *a; + + b = 42; + a = &b; + *a = 43; + + return (*a); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/4.simple_utilisation_de_reference.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/4.simple_utilisation_de_reference.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/4.simple_utilisation_de_reference.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/4.simple_utilisation_de_reference.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,13 @@ + + + +int main() +{ + int b; + int &a = b; + + b = 42; + a = 43; + + return (a); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/5.simple_interprocedural.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/5.simple_interprocedural.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/5.simple_interprocedural.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/5.simple_interprocedural.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,18 @@ + + +void val(int c) +{ + c = 43; +} + + + +int main() +{ + int b; + + b = 42; + val(b); + + return (b); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/6.utilisation_pointeur_interprocedural.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/6.utilisation_pointeur_interprocedural.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/6.utilisation_pointeur_interprocedural.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/6.utilisation_pointeur_interprocedural.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,20 @@ + + +void val(int *c) +{ + *c = 43; +} + + + +int main() +{ + int b; + int *a; + + b = 42; + a = &b; + val(a); + + return (*a); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/7.interprocedural_reference.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/7.interprocedural_reference.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/7.interprocedural_reference.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/7.interprocedural_reference.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,19 @@ + + + +int proc(int &c) +{ + c = 44; +} + + +int main() +{ + int b; + int &a = b; + + b = 42; + proc(a); + + return (a); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/8.interprocedural_reference_2.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/8.interprocedural_reference_2.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/8.interprocedural_reference_2.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/8.interprocedural_reference_2.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,19 @@ + + + +int proc(int c) +{ + c = 44; +} + + +int main() +{ + int b; + int &a = b; + + b = 42; + proc(a); + + return (a); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/9.heritage_multiple_avec_appel_de_methodes_filles.cpp eresi-0.0.20110516/testsuite/static_analysis/evarista/9.heritage_multiple_avec_appel_de_methodes_filles.cpp --- eresi-0.8a25/testsuite/static_analysis/evarista/9.heritage_multiple_avec_appel_de_methodes_filles.cpp 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/9.heritage_multiple_avec_appel_de_methodes_filles.cpp 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,34 @@ + +class C_A { + private: + int a_; + + + public: + C_A() { a_ = 0; }; + void A_M_a () { a_++; }; +}; + +class C_B { + private: + int b_; + + public: + C_B() { b_ = 0; }; + void B_M_a () { b_++; }; +}; + +class C_C : public C_A, public C_B +{ + +}; + + +int main() +{ + C_C val; + + val.A_M_a(); + val.B_M_a(); + return 1; +} diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/eva-test.esh eresi-0.0.20110516/testsuite/static_analysis/evarista/eva-test.esh --- eresi-0.8a25/testsuite/static_analysis/evarista/eva-test.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/eva-test.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,7 @@ +#!../../../evarista/evarista32 + +load $1 +analyse +graph +graph bloc main + diff -Nru eresi-0.8a25/testsuite/static_analysis/evarista/Makefile eresi-0.0.20110516/testsuite/static_analysis/evarista/Makefile --- eresi-0.8a25/testsuite/static_analysis/evarista/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/evarista/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,59 @@ +# Evarista testsuite 2008 -- The ERESI project +# Julien Vanegue + +SRC = 1.simple_appel_de_methode.cpp \ + 2.simple_utilisation_de_champ_public.cpp \ + 3.simple_utilisation_de_pointeur.cpp \ + 4.simple_utilisation_de_reference.cpp \ + 5.simple_interprocedural.cpp \ + 6.utilisation_pointeur_interprocedural.cpp \ + 7.interprocedural_reference.cpp \ + 8.interprocedural_reference_2.cpp \ + 9.heritage_multiple_avec_appel_de_methodes_filles.cpp \ + 10.modification_de_champ_dans_une_methode.cpp \ + 11.appel_force_de_methode_mere_surchargee.cpp \ + 12.heritage_simple_avec_appel_de_methode.cpp \ + 13.heritage_simple_avec_appel_methode_de_classe_mere.cpp \ + 14.heritage_simple_avec_appel_methode_virtuelle.cpp \ + 15.heritage_simple_avec_parent_field_modif.cpp \ + 16.signature_new_delete.cpp \ + 17.template_simple.cpp \ + 18.signature_stdio.cpp \ + 19.signature_vector.cpp \ + 20.signature_list.cpp \ + 21.signature_iterator.cpp \ + 22.signature_map.cpp \ + 23.heritage_de_profondeur_2_avec_appel_methodes_filles.cpp \ + 24.heritage_de_profondeur_2_avec_appel_methodes_parents.cpp \ + 25.heritage_de_profondeur_2_avec_modifications_des_champs_public.cpp \ + 26.heritage_multiple_avec_appel_de_methodes_parentes.cpp \ + 27.heritage_de_classe_template.cpp \ + 28.interprocedural_loop_array_copy.cpp \ + 29.loop_3conds_with_dowhile.cpp \ + 30.compounds_with_gotos_and_loop.cpp \ + 31.simple_types_recovery.cpp \ + 32.n-dimentional-objects-arrays.cpp \ + 33.interprocedural_struct_access.cpp \ + 34.interprocedural_heap_corruption_static.c + +OBJ = $(SRC:.cpp=.o) +CC = g++ +LD = g++ +CXX = g++ +CFLAGS = +CXXFLAGS = +LDFLAGS = + +all : ${OBJ} + + for file in ${OBJ}; \ + do \ + echo "Linking Evarista test $$file"; \ + ${LD} ${LDFLAGS} $$file -o `echo $$file | cut -f1 -d'.'`.`uname -m` || break; \ + done; + +clean : + rm -fr *.o *~ + +fclean : clean + rm -fr *.`uname -m` diff -Nru eresi-0.8a25/testsuite/static_analysis/graph-tests.esh eresi-0.0.20110516/testsuite/static_analysis/graph-tests.esh --- eresi-0.8a25/testsuite/static_analysis/graph-tests.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/graph-tests.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,34 @@ +#!../../elfsh/elfsh32 + +# $Id: graph-tests.esh,v 1.3 2007-05-19 18:28:10 thor Exp $ + +#quiet + +# don't popup any windows, just generate .png files +configure graph.autoview 0 +configure libasm.output.att.margin 5 + +nocolor + +load $1 + +# analyse the object and graph function dependecies +analyse +graph + +# get number of symbols in symtab +set $entnbr 1.sht[.symtab].size +div $entnbr 1.sht[.symtab].entsize + +print $entnbr + +# walk it and dump all functions +foreach $idx of 0 until $entnbr + cmp 1.symtab[$idx].type 2 + jne skip + print $idx is 1.symtab[$idx].name + set $fname 1.symtab[$idx].name + graph bloc $fname +skip: +forend + diff -Nru eresi-0.8a25/testsuite/static_analysis/Makefile eresi-0.0.20110516/testsuite/static_analysis/Makefile --- eresi-0.8a25/testsuite/static_analysis/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,26 @@ +## +## Makefile for librevm in ERESI +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +include ../../config.h + +all : all32 all64 + +all32 : + $(MAKE) -C mjollnir all32 + $(MAKE) -C binaries all32 + +all64 : + $(MAKE) -C mjollnir all64 + $(MAKE) -C binaries all64 + +clean : + $(MAKE) -C mjollnir clean + $(MAKE) -C binaries clean + +fclean : clean + $(MAKE) -C mjollnir fclean + $(MAKE) -C binaries fclean diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/eva-test.esh eresi-0.0.20110516/testsuite/static_analysis/mjollnir/eva-test.esh --- eresi-0.8a25/testsuite/static_analysis/mjollnir/eva-test.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/eva-test.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,10 @@ +#!../../../evarista/evarista32 + +config graph.autoview 0 + +load $1 +#config mjr.cfg_depth 0 +analyse +graph +graph bloc main + diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/Makefile eresi-0.0.20110516/testsuite/static_analysis/mjollnir/Makefile --- eresi-0.8a25/testsuite/static_analysis/mjollnir/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,27 @@ + +SRC = test-ptrfn1.c test-ptrfn2.c test-ptrfn3.c test-recur.c test-moredepth.c +OBJ = $(SRC:.c=.o) +CC ?= gcc +RM = rm -fr + +all32: all +all: $(OBJ) + +test-ptrfn1.o: + $(CC) test-ptrfn1.c -o test-ptrfn1.elf + +test-ptrfn2.o: + $(CC) test-ptrfn2.c -o test-ptrfn2.elf + +test-ptrfn3.o: + $(CC) test-ptrfn3.c -o test-ptrfn3.elf + +test-recur.o: + $(CC) test-recur.c -o test-recur.elf + +test-moredepth.o: + $(CC) test-moredepth.c -o test-moredepth.elf + +fclean: clean +clean: + $(RM) $(OBJ) test*.o test*elf *~ diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/simple-test.esh eresi-0.0.20110516/testsuite/static_analysis/mjollnir/simple-test.esh --- eresi-0.8a25/testsuite/static_analysis/mjollnir/simple-test.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/simple-test.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,16 @@ +#!../../../elfsh/elfsh32 + +# Created: Tue Jan 2 22:44:33 CET 2007 + +# Load all types +load ../../../elfsh/elfsh32 +unload ../../../elfsh/elfsh32 + +# Analyse +load /bin/ls +analyse + +save ls.saved +load ls.saved + +quit diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/test-moredepth.c eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-moredepth.c --- eresi-0.8a25/testsuite/static_analysis/mjollnir/test-moredepth.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-moredepth.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include +#include + +int funk1(int a){printf("%d\n",a);return 0;} +int funk2(int a){printf("%d\n",a);funk1(a-1);return 1;} +int funk3(int b){printf("%d\n",b);funk2(b+1);funk1(666);return 0;} + +int main(void) +{ + int x=0; + char *z; + + z = NULL; + + if (z == NULL) { + printf("z == null\n"); + } + if (z == 0x0) { + printf("z == 0x0\n"); + } + + if (x == 0) { + printf("is zero\n"); + } else { + printf("is not zero\n"); + } + + funk1(333); + funk2(666); + funk3(777); + + z = malloc(1024); + memset(z,0x0,1024); + read(1,z,1023); + + return 0; +} + diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn1.c eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn1.c --- eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn1.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn1.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,11 @@ +// Test pointer-follow function calls detection. +#include + + +innafunkcja() { printf("dupa\n"); } + +main() { + int (*fn)(); + fn=innafunkcja; + fn(); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn2.c eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn2.c --- eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn2.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn2.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,13 @@ +// Test pointer-follow function calls detection. +#include + +f1() {printf("dupa\n"); } +f2() {printf("dupa2\n");} + +main() { + int (*fn)(); + int (*fn2)(); + fn=f1; + fn2=f2; + fn(fn2()); +} diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn3.c eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn3.c --- eresi-0.8a25/testsuite/static_analysis/mjollnir/test-ptrfn3.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-ptrfn3.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,19 @@ +#include + +int f1() {f4();} +int f2(){f4();} +int f3(){f4();} +int f4() {printf("dupa\n");} + +int main(void) { + int x; + int a[3] = {(int)f1,(int)f2,(int)f3}; + int (*f) (); + for(x=0;x<3;x++) { + f=(int(*)())a[x]; + f(); + } +return 0; +} + + diff -Nru eresi-0.8a25/testsuite/static_analysis/mjollnir/test-recur.c eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-recur.c --- eresi-0.8a25/testsuite/static_analysis/mjollnir/test-recur.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_analysis/mjollnir/test-recur.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +int funk3(int b); + +int funk1(int a){printf("%d\n",a); funk3(a + 2); return 0;} +int funk2(int a){printf("%d\n",a);funk1(a-1);return 1;} +int funk3(int b){printf("%d\n",b);funk2(b+1);funk1(666);return 0;} + +int main(void) +{ + int x=0; + char *z; + + z = NULL; + + if (z == NULL) { + printf("z == null\n"); + } + if (z == 0x0) { + printf("z == 0x0\n"); + } + + if (x == 0) { + printf("is zero\n"); + } else { + printf("is not zero\n"); + } + + funk1(333); + funk2(666); + funk3(777); + + z = malloc(1024); + memset(z,0x0,1024); + read(1,z,1023); + + return 0; +} + diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/infected.c eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/infected.c --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/infected.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/infected.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,18 @@ +/* +** +** infected.c in +** +** Author : +** Started : Tue Oct 7 02:05:18 2003 +** Updated : Tue Oct 7 02:35:00 2003 +** +** $Id: infected.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +void hijacked(int arg) +{ + printf("arg %i hijacked\n", arg); + subfunc(arg); +} diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/Makefile eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/Makefile --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,36 @@ +## +## Makefile for static instrumentation flowjack entry in the ERESI testsuite +## +## Made by vanegue at eresi-project dot org +## June 21st 2009 +## + +CC = gcc +RM = rm -fr +TNAM32 = target32 +RNAM32 = recur32 +TNAM64 = target64 +RNAM64 = recur64 + +all: all32 all64 + +all32: infected.32.o target.32.o recursivite.32.o + $(CC) -o $(TNAM32) target.32.o + $(CC) -o $(RNAM32) recursivite.32.o + +all64: infected.64.o target.64.o recursivite.64.o + $(CC) -o $(TNAM64) target.64.o + $(CC) -o $(RNAM64) recursivite.64.o + +fclean: clean + $(RM) $(TNAM32) $(RNAM32) $(TNAM64) $(RNAM64) *.hijacked + +clean: + $(RM) *.o *~ + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g + diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch32.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch32.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch32.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../../elfsh/elfsh32 +## +## patch32.esh in flowjack testsuite for ERESI +## + +load target32 +analyse +load infected.32.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save target32.hijacked +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch64.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch64.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch64.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,13 @@ +#!../../../elfsh/elfsh32 +## +## patch.esh in testsuite for ERESI +## + +load target64 +analyse +load infected.64.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save target64.hijacked +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-both32.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-both32.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-both32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-both32.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,20 @@ +#!../../../elfsh/elfsh32 +## +## patch-both32.esh in testsuite for ERESI +## + +load recur32 +analyse +load infected.32.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save recur32.hijacked + +load target32 +analyse +reladd 3 2 +flowjack subfunc hijacked +save target32.hijacked + +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-both64.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-both64.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-both64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-both64.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,20 @@ +#!../../../elfsh/elfsh32 +## +## patch-both64.esh in testsuite for ERESI +## + +load recur64 +analyse +load infected.64.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save recur64.hijacked + +load target64 +analyse +reladd 3 2 +flowjack subfunc hijacked +save target64.hijacked + +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-rec32.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-rec32.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-rec32.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-rec32.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,14 @@ +#!../../../elfsh/elfsh32 +## +## patch.esh in testsuite for ERESI +## + +load recur32 +analyse +load infected.32.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save recur32.hijacked + +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-rec64.esh eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-rec64.esh --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/patch-rec64.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/patch-rec64.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,14 @@ +#!../../../elfsh/elfsh32 +## +## patch.esh in testsuite for ERESI +## + +load recur64 +analyse +load infected.64.o +switch 1 +reladd 1 2 +flowjack subfunc hijacked +save recur64.hijacked + +quit diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/recursivite.c eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/recursivite.c --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/recursivite.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/recursivite.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,26 @@ +/* +** +** recursivite.c in +** +** Author : +** Started : Tue Oct 7 01:48:14 2003 +** Updated : Tue Oct 7 19:43:29 2003 +** +** $Id: recursivite.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +void subfunc(int arg) +{ + if (arg > 0) + subfunc(arg - 1); + printf("i = %i\n", arg) +; +} + + +int main(int ac, char **av) +{ + subfunc(10); +} diff -Nru eresi-0.8a25/testsuite/static_instrumentation/flowjack/target.c eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/target.c --- eresi-0.8a25/testsuite/static_instrumentation/flowjack/target.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/flowjack/target.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,42 @@ +/* +** +** target.c in +** +** Author : +** Started : Tue Oct 7 01:45:28 2003 +** Updated : Tue Oct 7 02:06:29 2003 +** +** $Id: target.c 1311 2009-01-14 20:36:48Z may $ +** +*/ +#include + +void subfunc(int arg) +{ + printf("i = %i\n", arg); +} + +int func1(void) +{ + subfunc(1); +} + +int func2(void) +{ + + subfunc(2); +} + +int func3(void) +{ + subfunc(3); + return (3); +} + +int main() +{ + func1(); + func2(); + func3(); + return (0); +} diff -Nru eresi-0.8a25/testsuite/static_instrumentation/Makefile eresi-0.0.20110516/testsuite/static_instrumentation/Makefile --- eresi-0.8a25/testsuite/static_instrumentation/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/Makefile 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,22 @@ +## +## Makefile for librevm in ERESI +## +## Started on Fri Nov 2 16:32:29 2001 jfv +## Updated on Wed Nov 28 12:57:38 2001 jfv +## + +include ../../config.h + +all : all32 all64 + +all32 : + $(MAKE) -C flowjack all32 + +all64 : + $(MAKE) -C flowjack all64 + +clean : + $(MAKE) -C flowjack clean + +fclean : clean + $(MAKE) -C flowjack fclean diff -Nru eresi-0.8a25/testsuite/static_instrumentation/printarrays/print_array.esh eresi-0.0.20110516/testsuite/static_instrumentation/printarrays/print_array.esh --- eresi-0.8a25/testsuite/static_instrumentation/printarrays/print_array.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/printarrays/print_array.esh 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,60 @@ +#!../../../elfsh/elfsh32 + +quiet + +load a.out + +type bint = sys:int[2][3] + +inform bint toto biarray + +print 1th test +print $toto.sys[0][0] +print $toto.sys[0][1] +print $toto.sys[0][2] +print $toto.sys[1][0] +print $toto.sys[1][1] +print $toto.sys[1][2] + +print 2th test + +set $idx 0 +set $idx2 0 +print $toto.sys[$idx][$idx2] + +add $idx2 1 +print $toto.sys[$idx][$idx2] +add $idx2 1 +print $toto.sys[$idx][$idx2] +set $idx 1 +set $idx2 0 +print $toto.sys[$idx][$idx2] +add $idx2 1 +print $toto.sys[$idx][$idx2] +add $idx2 1 +print $toto.sys[$idx][$idx2] + +print 3th test + +foreach $i of 0 until 2 +print $toto.sys[$i][0] +print $toto.sys[$i][1] +print $toto.sys[$i][2] +forend + +print 4th test + +foreach $j of 0 until 3 + print $toto.sys[0][$j] + print $toto.sys[1][$j] +forend + +print 5th test + +foreach $j of 0 until 2 +foreach $k of 0 until 3 + print $toto.sys[$j][$k] +forend +forend + +print Bye ! diff -Nru eresi-0.8a25/testsuite/static_instrumentation/printarrays/test-multidim-arrays.c eresi-0.0.20110516/testsuite/static_instrumentation/printarrays/test-multidim-arrays.c --- eresi-0.8a25/testsuite/static_instrumentation/printarrays/test-multidim-arrays.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/static_instrumentation/printarrays/test-multidim-arrays.c 2011-05-16 11:34:59.000000000 +0000 @@ -0,0 +1,16 @@ +/* +** Testsuite for reflection in ERESI +** +** $Id: test-multidim-arrays.c 1311 2009-01-14 20:36:48Z may $ +*/ +#include + +int biarray[2][3] = {{1, 2, 3}, {4, 5, 6}}; + +int triarray[2][3][2] = {{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {11, 12}}}; + +int main() +{ + printf("biarray = %p, triarray = %p \n", biarray, triarray); + return (0); +} diff -Nru eresi-0.8a25/testsuite/.svn/all-wcprops eresi-0.0.20110516/testsuite/.svn/all-wcprops --- eresi-0.8a25/testsuite/.svn/all-wcprops 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 33 -/svn/!svn/ver/915/trunk/testsuite -END -README -K 25 -svn:wc:ra_dav:version-url -V 39 -/svn/!svn/ver/12/trunk/testsuite/README -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 42 -/svn/!svn/ver/749/trunk/testsuite/Makefile -END diff -Nru eresi-0.8a25/testsuite/.svn/entries eresi-0.0.20110516/testsuite/.svn/entries --- eresi-0.8a25/testsuite/.svn/entries 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,107 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite -http://svn.eresi-project.org/svn - - - -2008-03-18T17:48:47.427281Z -915 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -sct_index_injection -dir - -sct_unmapped_injection -dir - -libedfmt -dir - -mjollnir -dir - -testscripts -dir - -symbolic_tracing -dir - -hash_retreive -dir - -sht_stripping -dir - -README -file - - - - -2008-04-06T23:15:42.493887Z -d2be1fb932d1bc870456bd8aa170d440 -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -flowjack -dir - -got_hijack -dir - -ctors_hijack -dir - -dtors_hijack -dir - -sht_rebuild -dir - -symtab_extend -dir - -etrel_inject -dir - -e2dbg_multithreads -dir - -sct_fillbss_injection -dir - -sct_top_injection -dir - -Makefile -file - - - - -2008-04-06T23:15:42.504876Z -84eafdd4a94add3cfb3402d0e994e6c8 -2007-07-31T03:28:48.000000Z -749 -may - diff -Nru eresi-0.8a25/testsuite/.svn/format eresi-0.0.20110516/testsuite/.svn/format --- eresi-0.8a25/testsuite/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/.svn/prop-base/README.svn-base eresi-0.0.20110516/testsuite/.svn/prop-base/README.svn-base --- eresi-0.8a25/testsuite/.svn/prop-base/README.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/prop-base/README.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:42.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,54 +0,0 @@ -## -## Makefile for elfsh testsuite in -## -## Made by jfv -## Login -## -## Started on Sun Dec 15 01:34:42 2002 jfv -## Last update Sat May 24 17:45:46 2003 jfv -## - -all : - @cd ctors_hijack && $(MAKE) - @cd dtors_hijack && $(MAKE) - @cd got_hijack && $(MAKE) - @cd hash_retreive && $(MAKE) - @cd sct_fillbss_injection && $(MAKE) - @cd sct_top_injection && $(MAKE) - @cd sct_unmapped_injection && $(MAKE) - @cd sht_rebuild && $(MAKE) - @cd sht_stripping && $(MAKE) - @cd symtab_extend && $(MAKE) - @cd etrel_inject && $(MAKE) - @cd e2dbg_multithreads && $(MAKE) - -clean : - @echo -n 'Cleaning testsuite ...' - @cd ctors_hijack && $(MAKE) clean - @cd dtors_hijack && $(MAKE) clean - @cd got_hijack && $(MAKE) clean - @cd hash_retreive && $(MAKE) clean - @cd sct_fillbss_injection && $(MAKE) clean - @cd sct_top_injection && $(MAKE) clean - @cd sct_unmapped_injection && $(MAKE) clean - @cd sht_rebuild && $(MAKE) clean - @cd sht_stripping && $(MAKE) clean - @cd symtab_extend && $(MAKE) clean - @cd etrel_inject && $(MAKE) clean - @cd e2dbg_multithreads && $(MAKE) clean - @echo 'Testsuite cleaned .' - -fclean : clean - @cd ctors_hijack && $(MAKE) fclean - @cd dtors_hijack && $(MAKE) fclean - @cd got_hijack && $(MAKE) fclean - @cd hash_retreive && $(MAKE) fclean - @cd sct_fillbss_injection && $(MAKE) fclean - @cd sct_top_injection && $(MAKE) fclean - @cd sct_unmapped_injection && $(MAKE) fclean - @cd sht_rebuild && $(MAKE) fclean - @cd sht_stripping && $(MAKE) fclean - @cd symtab_extend && $(MAKE) fclean - @cd etrel_inject && $(MAKE) fclean - @cd e2dbg_multithreads && $(MAKE) fclean - diff -Nru eresi-0.8a25/testsuite/.svn/text-base/README.svn-base eresi-0.0.20110516/testsuite/.svn/text-base/README.svn-base --- eresi-0.8a25/testsuite/.svn/text-base/README.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/.svn/text-base/README.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ - - - THE TESTSUITE IS NOT UP2DATE FOR 0.65 ! Except : - - etrel_inject/ for various ET_REL injection stuff - - e2dbg/ for the embedded ELF debugger - - -If you get the other tests compiling then it will probably -works. However I doubt they will compile because of the -absence of elfsh_error(). Will be fixed very soon. - - - -------------------------- - ELFSH 0.5 TESTSUITE README - -------------------------- - - -1) You have to compile and install libelfsh before compiling the testsuite . -Everything is compiled automatically if you do make in the root directory . - -2) Each test has a Makefile procuding 2 executables, one of them is using -libelfsh and modify the other one (a.out) which is just provided as a host -binary to illustrate the libelfsh API . - -3) The modified executable is produced in the current directory , and -called 'fake_aout' . Just launch a.out, then fake_aout, and spot the -differences . Watch them using elfsh to understand the exact modifications . - - -List of tests : -############### - - -ctors_hijack : - => hijack the flow using .ctors entry modification . - => $ elfsh -f a.out -ctors - => $ elfsh -f fake_aout -ctors - -dtors_hijack : - => hijack the flow using .dtors entry modification . - => $ elfsh -f a.out -dtors - => $ elfsh -f fake_aout -dtors - -got_hijack : - => hijack sleep() using .got entry modification . - => $ elfsh -f a.out -got - => $ elfsh -f fake_aout -got - -hash_retreive : - => resolve a dynamic symbol name using .hash . - -sct_fillbss_injection: - => inject a mapped section after .bss - => filling .bss physically in the file - => The entry point is modified to point on .devhell . - => $ elfsh -f a.out -s -e (retreive SHT and ELF header) - => $ elfsh -f fake_aout -s -e - -sct_top_injection: - => inject a mapped section before .interp - => Move the PHT to the beginning of the file - => The entry point is modified to point on .devhell . - => $ elfsh -f a.out -s -e (retreive SHT and ELF header) - => $ elfsh -f fake_aout -s -e - -section_unmapped_injection: - => inject a mapped section at the end of the binary - => $ elfsh -f a.out -s -e (retreive SHT and ELF header) - => $ elfsh -f fake_aout -s -e - -sht_stripping : - => remove the section header table in a.out - => $ elfsh -f a.out -s -e - => $ elfsh -f fake_aout -s -e - -symtab_extend : - => Add a symbol in .symtab (also add name in .strtab) - => $ elfsh -f a.out -sym DH - => $ elfsh -f fake_aout -sym DH - - -sht_rebuild : - => rebuild section header in a SHT stripped ELF object - => $ objdump -D sht_stripped_file (see the error) - => $ sht_rebuilder - => $ objdump -D sht_rebuilt_file (see it work :) - - - - - - - - - - - - - - diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/host.c eresi-0.0.20110516/testsuite/symbolic_tracing/host.c --- eresi-0.8a25/testsuite/symbolic_tracing/host.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/host.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -#define _XOPEN_SOURCE -#include -#include - -int testcrypt() -{ - crypt("password", "salt"); - return 5; -} - -int firstfunc(int num, char *value) -{ - char *monptr; - monptr = (value + 3 % 1); - testcrypt(); - return 1; -} - -int secondfunc(char *justastring) -{ - puts(justastring); -} - -int main(int argc, char **argv) -{ - unsigned int index; - for (index = 0; index < argc; index++) - { - printf("arg[%d] %s\n", index, argv[index]); - } - char path[256]; - getcwd(path, 255); - printf("BEFORE ! %s\n", path); - firstfunc(3, "this is the text"); - return 0; -} diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/Makefile eresi-0.0.20110516/testsuite/symbolic_tracing/Makefile --- eresi-0.8a25/testsuite/symbolic_tracing/Makefile 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun March 21 23:15:15 2007 mxatone -## -include ../../config.h - -SRC = tracer.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L/usr/pkg/lib -L../../librevm/ -lrevm32 -L../../libelfsh/ -lelfsh32 -NAM = tracer -RM = rm -f -OPT = -gdwarf-2 -g3 -O2 -I../../librevm/include/ -I../../libelfsh/include/ \ - -I../../libasm/include/ -I../../elibc/include/ -I../../libaspect/include/ \ - -I../../libmjollnir/include/ -I../../libedfmt/include/ $(BITS) -CFLAGS = $(OPT) - -HOSTSRC = host.c -HOSTOBJ = host.o -HOSTLIB = -lcrypt - -all : $(OBJ) - @$(CC) $(OPT) $(HOSTLIB) $(HOSTSRC) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - -clean : - $(RM) $(OBJ) $(HOSTOBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/all-wcprops eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/all-wcprops --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/all-wcprops 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 50 -/svn/!svn/ver/843/trunk/testsuite/symbolic_tracing -END -tracer.c -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/843/trunk/testsuite/symbolic_tracing/tracer.c -END -trace.esh -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/591/trunk/testsuite/symbolic_tracing/trace.esh -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/749/trunk/testsuite/symbolic_tracing/Makefile -END -host.c -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/591/trunk/testsuite/symbolic_tracing/host.c -END diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/entries eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/entries --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/entries 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/symbolic_tracing -http://svn.eresi-project.org/svn - - - -2008-02-16T12:32:28.000000Z -843 -thor - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -tracer.c -file - - - - -2008-04-06T23:15:39.792899Z -9e82c1a52a0f11323832bb11b8c7a321 -2008-02-16T12:32:28.000000Z -843 -thor - -trace.esh -file - - - - -2008-04-06T23:15:39.838899Z -f04e5424c60be0f0ceeb146867aeb857 -2007-05-03T14:47:14.000000Z -591 -mxatone -has-props - -Makefile -file - - - - -2008-04-06T23:15:39.851089Z -20bbe00291b431fbdbd914e960c7d403 -2007-07-31T03:28:48.000000Z -749 -may -has-props - -host.c -file - - - - -2008-04-06T23:15:39.862491Z -9037fae106c9a62067cde3ed96b287f9 -2007-05-03T14:47:14.000000Z -591 -mxatone - diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/format eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/format --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/format 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/prop-base/trace.esh.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/prop-base/trace.esh.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/prop-base/trace.esh.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/prop-base/trace.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/host.c.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/host.c.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/host.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/host.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -#define _XOPEN_SOURCE -#include -#include - -int testcrypt() -{ - crypt("password", "salt"); - return 5; -} - -int firstfunc(int num, char *value) -{ - char *monptr; - monptr = (value + 3 % 1); - testcrypt(); - return 1; -} - -int secondfunc(char *justastring) -{ - puts(justastring); -} - -int main(int argc, char **argv) -{ - unsigned int index; - for (index = 0; index < argc; index++) - { - printf("arg[%d] %s\n", index, argv[index]); - } - char path[256]; - getcwd(path, 255); - printf("BEFORE ! %s\n", path); - firstfunc(3, "this is the text"); - return 0; -} diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun March 21 23:15:15 2007 mxatone -## -include ../../config.h - -SRC = tracer.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L/usr/pkg/lib -L../../librevm/ -lrevm32 -L../../libelfsh/ -lelfsh32 -NAM = tracer -RM = rm -f -OPT = -gdwarf-2 -g3 -O2 -I../../librevm/include/ -I../../libelfsh/include/ \ - -I../../libasm/include/ -I../../elibc/include/ -I../../libaspect/include/ \ - -I../../libmjollnir/include/ -I../../libedfmt/include/ $(BITS) -CFLAGS = $(OPT) - -HOSTSRC = host.c -HOSTOBJ = host.o -HOSTLIB = -lcrypt - -all : $(OBJ) - @$(CC) $(OPT) $(HOSTLIB) $(HOSTSRC) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) - -clean : - $(RM) $(OBJ) $(HOSTOBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/trace.esh.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/trace.esh.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/trace.esh.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/trace.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#!../../etrace/etrace32 -load ./a.out -traces add main -traces create critical -traces add crypt critical -traces create mainnodes -traces add .*func mainnodes -traces add testcrypt mainnodes -#profile enable warn -save fake_aout diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/tracer.c.svn-base eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/tracer.c.svn-base --- eresi-0.8a25/testsuite/symbolic_tracing/.svn/text-base/tracer.c.svn-base 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/.svn/text-base/tracer.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* -** tracer.c for testsuite in elfsh -** -** Started on Sat March 21 22:49:23 2007 mxatone -** -** -*/ -#include "revm.h" - -#define HOST_FILE "a.out" -#define TRACED_FILE "fake_aout" - -int main(int argc, char **argv) -{ - elfshobj_t *host; - char *critical[] = {"critical", NULL}; - char *mainnode[] = {"mainnodes", NULL}; - char logbuf[BUFSIZ]; - - revm_tables_setup(); - - /* Map host file */ - host = elfsh_map_obj(HOST_FILE); - if (NULL == host) - goto err; - - /* Setup world current */ - world.curjob->curfile = host; - - /* Parse debugging informations */ - revm_edfmt_parse(host); - - /* Init hash dep */ - revm_load_init_dephash(host, host->name); - - /* Load dependences */ - revm_load_enumdep(host); - - /* global scope */ - traces_add(host, "main", NULL); - - /* critical scope */ - traces_create(host, critical[0], NULL); - traces_add(host, "crypt", critical); - - /* mainnodes scope */ - traces_create(host, mainnode[0], NULL); - traces_add(host, "firstfunc", mainnode); - traces_add(host, "testcrypt", mainnode); - - /* Save it */ - if (elfsh_save_obj(host, TRACED_FILE) < 0) - goto err; - - printf("[*] %s traced into %s\n", HOST_FILE, TRACED_FILE); - - return 0; - - err: - printf("[!] Failed to trace %s into %s\n", HOST_FILE, TRACED_FILE); - return -1; -} diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/trace.esh eresi-0.0.20110516/testsuite/symbolic_tracing/trace.esh --- eresi-0.8a25/testsuite/symbolic_tracing/trace.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/trace.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#!../../etrace/etrace32 -load ./a.out -traces add main -traces create critical -traces add crypt critical -traces create mainnodes -traces add .*func mainnodes -traces add testcrypt mainnodes -#profile enable warn -save fake_aout diff -Nru eresi-0.8a25/testsuite/symbolic_tracing/tracer.c eresi-0.0.20110516/testsuite/symbolic_tracing/tracer.c --- eresi-0.8a25/testsuite/symbolic_tracing/tracer.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symbolic_tracing/tracer.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/* -** tracer.c for testsuite in elfsh -** -** Started on Sat March 21 22:49:23 2007 mxatone -** -** -*/ -#include "revm.h" - -#define HOST_FILE "a.out" -#define TRACED_FILE "fake_aout" - -int main(int argc, char **argv) -{ - elfshobj_t *host; - char *critical[] = {"critical", NULL}; - char *mainnode[] = {"mainnodes", NULL}; - char logbuf[BUFSIZ]; - - revm_tables_setup(); - - /* Map host file */ - host = elfsh_map_obj(HOST_FILE); - if (NULL == host) - goto err; - - /* Setup world current */ - world.curjob->curfile = host; - - /* Parse debugging informations */ - revm_edfmt_parse(host); - - /* Init hash dep */ - revm_load_init_dephash(host, host->name); - - /* Load dependences */ - revm_load_enumdep(host); - - /* global scope */ - traces_add(host, "main", NULL); - - /* critical scope */ - traces_create(host, critical[0], NULL); - traces_add(host, "crypt", critical); - - /* mainnodes scope */ - traces_create(host, mainnode[0], NULL); - traces_add(host, "firstfunc", mainnode); - traces_add(host, "testcrypt", mainnode); - - /* Save it */ - if (elfsh_save_obj(host, TRACED_FILE) < 0) - goto err; - - printf("[*] %s traced into %s\n", HOST_FILE, TRACED_FILE); - - return 0; - - err: - printf("[!] Failed to trace %s into %s\n", HOST_FILE, TRACED_FILE); - return -1; -} diff -Nru eresi-0.8a25/testsuite/symtab_extend/execve.s eresi-0.0.20110516/testsuite/symtab_extend/execve.s --- eresi-0.8a25/testsuite/symtab_extend/execve.s 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/execve.s 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -; lame execve() shell / spoty -section .text - -global _start - -_start: -jmp short L1 -L0: - mov ebx,[esp] ;get /bin/sh - xor edx,edx - push dword edx ;here we need argv[0] - push dword ebx - push dword edx ;push dword 0 - push esp - push dword ebx ;/bin/sh - mov al,59 ;#define SYS_execve 59 - push eax - - int 0x80 - - push dword edx ;push dword 0 - push dword ebx ;/bin/sh - xor eax,eax - inc eax ;mov eax,1 - push eax - int 0x80 - -L1: - call L0 - shell db "/bin/sh",0x0 - arg db "-i",0x0 diff -Nru eresi-0.8a25/testsuite/symtab_extend/main.c eresi-0.0.20110516/testsuite/symtab_extend/main.c --- eresi-0.8a25/testsuite/symtab_extend/main.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/main.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -/* -** -** $Id: main.c,v 1.3 2007-05-16 23:36:38 may Exp $ -** -*/ -#include - -int main() -{ - printf("Example program . \n"); - return (0); -} diff -Nru eresi-0.8a25/testsuite/symtab_extend/Makefile eresi-0.0.20110516/testsuite/symtab_extend/Makefile --- eresi-0.8a25/testsuite/symtab_extend/Makefile 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/Makefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun May 25 18:04:33 2003 jfv -## - -include ../../config.h - -SRC = symtab_extend.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace/ -letrace32 -NAM = symtab_extend -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) -static - @$(CC) $(OPT) $(VULN) -static - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/all-wcprops eresi-0.0.20110516/testsuite/symtab_extend/.svn/all-wcprops --- eresi-0.8a25/testsuite/symtab_extend/.svn/all-wcprops 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 47 -/svn/!svn/ver/909/trunk/testsuite/symtab_extend -END -execve.s -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/3/trunk/testsuite/symtab_extend/execve.s -END -main.c -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/616/trunk/testsuite/symtab_extend/main.c -END -symtab_extend.c -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/749/trunk/testsuite/symtab_extend/symtab_extend.c -END -Makefile -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/909/trunk/testsuite/symtab_extend/Makefile -END diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/entries eresi-0.0.20110516/testsuite/symtab_extend/.svn/entries --- eresi-0.8a25/testsuite/symtab_extend/.svn/entries 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,77 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/symtab_extend -http://svn.eresi-project.org/svn - - - -2008-03-14T09:48:44.987521Z -909 -enioh - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -execve.s -file - - - - -2008-04-06T23:15:40.543897Z -9063702039df218c6c045d1e6bfeaf96 -2003-08-21T01:13:15.000000Z -3 -thor - -main.c -file - - - - -2008-04-06T23:15:40.564876Z -4f35ac2b27f28469eb2b630493dbfc55 -2007-05-16T23:36:38.000000Z -616 -may - -symtab_extend.c -file - - - - -2008-04-06T23:15:40.577892Z -23f18668312cfe7eab0090d2a2e942ca -2007-07-31T03:28:48.000000Z -749 -may - -Makefile -file - - - - -2008-04-06T23:15:40.587881Z -b50161f9a4c823bfb739fcb75e79a222 -2008-03-14T09:48:44.987521Z -909 -enioh -has-props - diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/format eresi-0.0.20110516/testsuite/symtab_extend/.svn/format --- eresi-0.8a25/testsuite/symtab_extend/.svn/format 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/prop-base/Makefile.svn-base eresi-0.0.20110516/testsuite/symtab_extend/.svn/prop-base/Makefile.svn-base --- eresi-0.8a25/testsuite/symtab_extend/.svn/prop-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/prop-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/execve.s.svn-base eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/execve.s.svn-base --- eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/execve.s.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/execve.s.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -; lame execve() shell / spoty -section .text - -global _start - -_start: -jmp short L1 -L0: - mov ebx,[esp] ;get /bin/sh - xor edx,edx - push dword edx ;here we need argv[0] - push dword ebx - push dword edx ;push dword 0 - push esp - push dword ebx ;/bin/sh - mov al,59 ;#define SYS_execve 59 - push eax - - int 0x80 - - push dword edx ;push dword 0 - push dword ebx ;/bin/sh - xor eax,eax - inc eax ;mov eax,1 - push eax - int 0x80 - -L1: - call L0 - shell db "/bin/sh",0x0 - arg db "-i",0x0 diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/main.c.svn-base eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/main.c.svn-base --- eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/main.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/main.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -/* -** -** $Id: main.c,v 1.3 2007-05-16 23:36:38 may Exp $ -** -*/ -#include - -int main() -{ - printf("Example program . \n"); - return (0); -} diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/Makefile.svn-base eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/Makefile.svn-base --- eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/Makefile.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/Makefile.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -## -## Makefile for elfsh -## -## Started on Sun Mar 10 01:19:24 2002 jfv -## Last update Sun May 25 18:04:33 2003 jfv -## - -include ../../config.h - -SRC = symtab_extend.c -OBJ = $(SRC:.c=.o) -CC = gcc -LIB = -L../../libelfsh/ -lelfsh32 -L../../libasm -lasm \ - -L../../libaspect/ -laspect32 \ - -L../../libetrace/ -letrace32 -NAM = symtab_extend -RM = rm -f -VULN = main.c -OPT = -O2 -I../../libelfsh/include/ \ - -I../../libaspect/include $(BITS) -CFLAGS = $(OPT) - -all : $(OBJ) - @$(CC) $(OPT) $(OBJ) $(LIB) -o $(NAM) -static - @$(CC) $(OPT) $(VULN) -static - -clean : - $(RM) $(OBJ) *~ \#* *\# - - -fclean : clean - $(RM) $(NAM) a.out fake_aout diff -Nru eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/symtab_extend.c.svn-base eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/symtab_extend.c.svn-base --- eresi-0.8a25/testsuite/symtab_extend/.svn/text-base/symtab_extend.c.svn-base 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/.svn/text-base/symtab_extend.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* -** symtab_extend.c for elfsh testsuite -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Mon Jun 30 11:13:50 2003 jfv -** -** $Id: symtab_extend.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define INPUT_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - int ret; - elfsh_Sym sym; - char name[256]; - u_int idx; - - file = elfsh_map_obj(INPUT_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR SYMTAB + STRTAB INJECTION *******/ - /***********************************************************/ - - printf("Writing string in .strtab and adding symbol in .symtab \n"); - - for (idx = 0; idx < 50; idx++) - { - snprintf(name, sizeof(name), "%s_%u", "DH0WNZ", idx); - sym = elfsh_create_symbol(0x42424242, 21, STT_FUNC, 0, 0, 0); - ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &sym, name); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - } - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/symtab_extend/symtab_extend.c eresi-0.0.20110516/testsuite/symtab_extend/symtab_extend.c --- eresi-0.8a25/testsuite/symtab_extend/symtab_extend.c 2008-04-06 23:15:40.000000000 +0000 +++ eresi-0.0.20110516/testsuite/symtab_extend/symtab_extend.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* -** symtab_extend.c for elfsh testsuite -** -** Started on Sun Mar 10 01:18:51 2002 jfv -** Last update Mon Jun 30 11:13:50 2003 jfv -** -** $Id: symtab_extend.c,v 1.3 2007-07-31 03:28:48 may Exp $ -** -*/ -#include "libelfsh.h" - - -#define INPUT_FILE "./a.out" -#define OUTPUT_FILE "./fake_aout" - - - -int main(int argc, char **argv) -{ - elfshobj_t *file; - int ret; - elfsh_Sym sym; - char name[256]; - u_int idx; - - file = elfsh_map_obj(INPUT_FILE); - if (!file) - { - elfsh_error(); - exit(-1); - } - - - /***********************************************************/ - /**************** TEST FOR SYMTAB + STRTAB INJECTION *******/ - /***********************************************************/ - - printf("Writing string in .strtab and adding symbol in .symtab \n"); - - for (idx = 0; idx < 50; idx++) - { - snprintf(name, sizeof(name), "%s_%u", "DH0WNZ", idx); - sym = elfsh_create_symbol(0x42424242, 21, STT_FUNC, 0, 0, 0); - ret = elfsh_insert_symbol(file->secthash[ELFSH_SECTION_SYMTAB], &sym, name); - if (ret < 0) - { - elfsh_error(); - exit(-1); - } - } - - - /***********************************************************/ - /************************ RELINKING ************************/ - /***********************************************************/ - - ret = elfsh_save_obj(file, OUTPUT_FILE); - if (ret < 0) - elfsh_error(); - - printf("Relinking *%s* \n", ret ? "Error" : "OK"); - return (0); -} - diff -Nru eresi-0.8a25/testsuite/testscripts/declare-bitfields.esh eresi-0.0.20110516/testsuite/testscripts/declare-bitfields.esh --- eresi-0.8a25/testsuite/testscripts/declare-bitfields.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/declare-bitfields.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -print ************ Now declarations of bitfields types ***************** - -type struct1 = field1:long field2:bit[7] field3:byte -union union1 = field4:struct1 field5:long field6:struct1 -type -type struct1 -type union1 - -print ************ Now declarations of variables ***************** - -union1 myunion1 = (field4(field1:42, field3:43), field5:44, field6(field1:45, field3:46)) -print $myunion1 - -set $myunion1.field5 42 -print $myunion1 -set $myunion1.field4.field1 31337 -print $myunion1 -set $myunion1.field6.field3 A -print $myunion1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/declare.esh eresi-0.0.20110516/testsuite/testscripts/declare.esh --- eresi-0.8a25/testsuite/testscripts/declare.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/declare.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -#!../../evarista/evarista64 - -#profile enable warn - -print ************ Now declarations of record types ***************** - -type struct0 = field0:long -type struct1 = field1:byte field2:long -type struct2 = field3:struct1 field4:long field5:struct1 - -print ************ Now declarations of variables ***************** - -#profile enable trace - -long mylong = 42 -vlist - -struct0 mystruct0 = (field0:42) -struct0 mystruct0b = struct0(field0:42) -struct0 mystruct0c = struct0(field0:43) - -struct1 mystruct1 = (field1:42,field2:43) - -struct1 mystruct1b = $mystruct1 -#struct1 mystruct1b = (field1:42,field2:43) - -struct1 mystruct1c = (field1:43,field2:42) -struct1 mystruct1d = (field2:42,field1:43) - -tables expressions - -#struct2 mystruct2 = (field3:$mystruct1, field4:44, field5(field1:45, field2:46)) -struct2 mystruct2 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) - -print $mystruct2 - -tables expressions - -struct2 mystruct2b = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) - -tables expressions - -print $mystruct2b - -struct2 mystruct2c = (field3(field1:42, field2:43), field4:44, field5(field1:46, field2:45)) - -print $mystruct2c - -# List all existing expressions at this state -#tables expressions - -# Test de mauvais typage -OK- -#struct0 mystruct0b = struct1(field0:42) - -print ************ Now testing printing of types ***************** - -type - -print ************ Now testing printing of expressions ***************** -print $mystruct0 -print $mystruct0b -print $mystruct0c -print $mystruct1b -print $mystruct1 -print $mystruct1c -print $mystruct1d -print $mystruct2 -print $mystruct2b -print $mystruct2c - -print *********** Now testing basic whole-expression comparison **************** - -#profile enable warn - -cmp $mystruct0 $mystruct0 -cmp $mystruct0 $mystruct0b -cmp $mystruct0b $mystruct0c -cmp $mystruct1 $mystruct1b -cmp $mystruct1b $mystruct1c -cmp $mystruct2 $mystruct2b -cmp $mystruct2b $mystruct2c - -print *********** Now testing field-order insensitive comparison **************** - -cmp $mystruct1c $mystruct1d - -# Set works all very well -print $mystruct0b $mystruct0c -set $mystruct0c $mystruct0b -print $mystruct0b $mystruct0c -cmp $mystruct0b $mystruct0c - -print $mystruct1b $mystruct1c -set $mystruct1c $mystruct1b -print $mystruct1b $mystruct1c -cmp $mystruct1b $mystruct1c - -print $mystruct2c $mystruct2b -set $mystruct2c $mystruct2b -print $mystruct2c $mystruct2b -cmp $mystruct2b $mystruct2c - - -print *********** Now testing subexpressions comparisons ************** - -print $mystruct2c.field3 -print $mystruct2c.field5 -print $mystruct1b - -cmp $mystruct2c.field3 $mystruct2c.field5 -cmp $mystruct2c.field3 $mystruct2b.field3 -cmp $mystruct2c.field3 $mystruct1b -cmp $mystruct1b $mystruct2c.field5 - -print *********** Now testing setting subexpressions ********* - -print $mystruct2c.field5 $mystruct1 -cmp $mystruct2c.field5 $mystruct1 -set $mystructbackup $mystruct2c.field5 -print $mystructbackup $mystruct2c.field5 $mystruct1 -set $mystruct2c.field5 $mystruct1 -print $mystructbackup $mystruct2c.field5 $mystruct1 -cmp $mystruct2c.field5 $mystruct1 - -print ********** Now testing terminal subexpression printing ********* - -print $mystruct2c.field3.field1 -print $mystruct2c.field3.field2 -print $mystruct2c.field5.field1 -print $mystruct2c.field5.field2 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/declare-unions.esh eresi-0.0.20110516/testsuite/testscripts/declare-unions.esh --- eresi-0.8a25/testsuite/testscripts/declare-unions.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/declare-unions.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -print ************ Now declarations of record types ***************** - -type struct1 = field1:long field2:byte -union union1 = field3:struct1 field4:long field5:struct1 -type -type union1 - -print ************ Now declarations of variables ***************** - -union1 myunion1 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) -print $myunion1 - -tables expressions -profile enable warn -set $myunion1.field4 42 - -print $myunion1 -set $myunion1.field3.field1 31337 -print $myunion1 -set $myunion1.field5.field2 A -print $myunion1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/defines.esh eresi-0.0.20110516/testsuite/testscripts/defines.esh --- eresi-0.8a25/testsuite/testscripts/defines.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/defines.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -# Attributes for instructions -define b ASM_TYPE_IMPBRANCH -define cb ASM_TYPE_CONDBRANCH -define c ASM_TYPE_CALLPROC -define i ASM_TYPE_INT -define r ASM_TYPE_RETPROC -define p ASM_TYPE_PROLOG -define cmp ASM_TYPE_COMPARISON -define bs ASM_TYPE_BITSET -define a ASM_TYPE_ASSIGN -define wm ASM_TYPE_STORE -define rm ASM_TYPE_LOAD -define e ASM_TYPE_EPILOG -define s ASM_TYPE_STOP -define n ASM_TYPE_NOP -define ar ASM_TYPE_ARITH -define wf ASM_TYPE_WRITEFLAG -define i-r i r -define ar-wf ar wf -define ar-wm ar wm -define a-rm a rm -define a-wm a wm - -#define id ASM_TYPE_INCDEC -#define ar-id ar id -#define ar-id-wm ar id wm - -# Attributes for operands -define reg ASM_OPTYPE_REG -define imm ASM_OPTYPE_IMM -define mem ASM_OPTYPE_MEM - -# Printing to see if it worked -print b cb c i r p cmp bs a wm -print rm e s n ar wf - -print i-r ar-wf ar-wm a-rm a-wm - -print reg imm mem diff -Nru eresi-0.8a25/testsuite/testscripts/doublevar.esh eresi-0.0.20110516/testsuite/testscripts/doublevar.esh --- eresi-0.8a25/testsuite/testscripts/doublevar.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/doublevar.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -#!/usr/local/bin/elfsh - -#quiet - -print Parameters : $1 $2 $3 -print - -set $index 1 - -loop: -#profile enable warn -cmp $index $# -jl end -load $$index -dynsym printf -unload $$index -add $index 1 -jmp loop - -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/endian.esh eresi-0.0.20110516/testsuite/testscripts/endian.esh --- eresi-0.8a25/testsuite/testscripts/endian.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/endian.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -#!/usr/bin/elfsh - -load MISC/top64 -quiet -p -verb -set 1.got[0] .plt -save /tmp/top64new -quiet -p -verb -load /tmp/top64new -quiet -p -verb -quit diff -Nru eresi-0.8a25/testsuite/testscripts/factorial.esh eresi-0.0.20110516/testsuite/testscripts/factorial.esh --- eresi-0.8a25/testsuite/testscripts/factorial.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/factorial.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../evarista/evarista32 - -sdir . -quiet - -cmp $# 2 -jne end -print Fact with params : -print $1 $2 -mul $2 $1 -set $2 $_ -sub $1 1 -cmp $1 1 -je result -print Variables at current iteration : -print $1 $2 $_ -factorial $1 $2 -quit - -end: -print This program needs 2 parameters -quit - -result: -print Factorial result: -print $2 -quit diff -Nru eresi-0.8a25/testsuite/testscripts/factorial-withret.esh eresi-0.0.20110516/testsuite/testscripts/factorial-withret.esh --- eresi-0.8a25/testsuite/testscripts/factorial-withret.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/factorial-withret.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -#!../../evarista/evarista32 - -cmp $ESHLVL 0 -jne factstart -sdir . -quiet - -factstart: -cmp $# 2 -jne end -mul $2 $1 -sub $1 1 -cmp $1 1 -je result - -factorial-withret $1 $2 -set $2 $_ - -result: -cmp $ESHLVL 0 -je printres -return $2 - -printres: -print Factorial result: -print $2 -quit - -end: -print This program needs 2 parameters -quit diff -Nru eresi-0.8a25/testsuite/testscripts/flush.esh eresi-0.0.20110516/testsuite/testscripts/flush.esh --- eresi-0.8a25/testsuite/testscripts/flush.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/flush.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#!/usr/bin/elfsh - -load fake_aout -remove sect .orig.plt -remove sect rel.o.rodata.str1.1 -remove sect rel.o.rodata.str1.32 -remove sect rel.o.text -remove sect rel.o.data -save new_aout -quit diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-ending.esh eresi-0.0.20110516/testsuite/testscripts/foreach-ending.esh --- eresi-0.8a25/testsuite/testscripts/foreach-ending.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-ending.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -#!../../elfsh/elfsh32 - -quiet - -add $hash[test2] Intel -add $hash[test2] Alpha -add $hash[test2] Sparc32 -add $hash[test2] Mips -add $hash[test2] Sparc64 -add $hash[test2] AMD -add $hash[test2] Pa-risc -tables test2 - -beginning: -print Starting first foreach - -#profile enable warn - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -empty test2 -tables test2 - -# Special case where nothing is after the forend diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-hashes.esh eresi-0.0.20110516/testsuite/testscripts/foreach-hashes.esh --- eresi-0.8a25/testsuite/testscripts/foreach-hashes.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-hashes.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -add $hash[test2] Intel -add $hash[test2] Alpha -add $hash[test2] Sparc32 -add $hash[test2] Mips -add $hash[test2] Sparc64 -add $hash[test2] AMD -add $hash[test2] Pa-risc -tables test2 - -vlist -type - -# We need a parameter -cmp $# 1 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -print Starting second foreach -tables test2 - -foreach $element of test2 - print Table contains element : $element -forend - -load /usr/bin/ssh - -vlist -set $entnbr 1.sht[.dynsym].size -div $entnbr 1.sht[.dynsym].entsize -vlist - -print Third loop until $entnbr : -print - -foreach $idx of 0 until $entnbr - print Symbol $idx is 1.dynsym[$idx].name -forend - -unload /usr/bin/ssh -print Program finished -empty test2 -tables test2 -quit - -error: -print This script needs one parameter (a file name) diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-linearity.esh eresi-0.0.20110516/testsuite/testscripts/foreach-linearity.esh --- eresi-0.8a25/testsuite/testscripts/foreach-linearity.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-linearity.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -#!../../elfsh/elfsh32 - -add $list[test] Intel -add $list[test] Alpha -add $list[test] Sparc32 -add $list[test] Mips -add $list[test] Sparc64 -add $list[test] AMD -add $list[test] Pa-risc - -add $list[test2] HEHEHE - -lists test -lists test2 - -#profile enable warn -#quiet - -foreach $element of test - - # Should print an error - foreach $element2 of test - print List2 contains element : $element2 - forend - - print List contains element : $element - -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-lists.esh eresi-0.0.20110516/testsuite/testscripts/foreach-lists.esh --- eresi-0.8a25/testsuite/testscripts/foreach-lists.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-lists.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -vlist - -add $list[test2] Intel -add $list[test2] Alpha -add $list[test2] Sparc32 -add $list[test2] Mips -add $list[test2] Sparc64 -add $list[test2] AMD -add $list[test2] Pa-risc -lists test2 - -# We need a parameter -vlist -cmp $# 0 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -print Starting second foreach -lists test2 - -foreach $element of test2 - print List contains element : $element -forend - -quit - -error: -print This script needs one parameter (a file name) -quit diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-list-simple.esh eresi-0.0.20110516/testsuite/testscripts/foreach-list-simple.esh --- eresi-0.8a25/testsuite/testscripts/foreach-list-simple.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-list-simple.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -add $list[test2] Intel -add $list[test2] Alpha -add $list[test2] Sparc32 -add $list[test2] Mips -add $list[test2] Sparc64 -add $list[test2] AMD -add $list[test2] Pa-risc - -# We need a parameter -cmp $# 0 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend -quit - -error: -print This script needs one parameter (a file name) -quit diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-nested.esh eresi-0.0.20110516/testsuite/testscripts/foreach-nested.esh --- eresi-0.8a25/testsuite/testscripts/foreach-nested.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-nested.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -#!../../elfsh/elfsh32 - -#profile enable warn -#quiet - -add $list[test] Intel -add $list[test] Alpha -add $list[test] Mips - -add $list[test2] HEHE -add $list[test2] HOHO - -lists test -lists test2 - -foreach $element of test - - foreach $element3 of test2 - print List2 contains element : $element3 - forend - - print List contains element : $element - -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/foreach-reference.esh eresi-0.0.20110516/testsuite/testscripts/foreach-reference.esh --- eresi-0.8a25/testsuite/testscripts/foreach-reference.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/foreach-reference.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -#!../../elfsh/elfsh32 - -add $list[test] 1 -add $list[test] 2 -add $list[test] 3 -lists test - -#quiet -#profile enable warn - -foreach $element of test - add $element 3 -forend - -print -lists test - -foreach $elem of test - print List contains element : $elem -forend - -print -lists test - -foreach $elem of test - print List contains element : $elem -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/graph-tests.esh eresi-0.0.20110516/testsuite/testscripts/graph-tests.esh --- eresi-0.8a25/testsuite/testscripts/graph-tests.esh 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/graph-tests.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#!/usr/local/bin/elfsh32 - -# $Id: graph-tests.esh,v 1.3 2007-05-19 18:28:10 thor Exp $ - -#quiet - -# don't popup any windows, just generate .png files -configure graph.autoview 0 -configure libasm.output.att.margin 5 - -nocolor - -load $1 - -# analyse the object and graph function dependecies -analyse -graph - -# get number of symbols in symtab -set $entnbr 1.sht[.symtab].size -div $entnbr 1.sht[.symtab].entsize - -# walk it and dump all functions -foreach $idx of 0 until $entnbr - cmp 1.symtab[$idx].type 2 - jne skip - print $idx is 1.symtab[$idx].name - set $fname 1.symtab[$idx].name - graph bloc $fname -skip: -forend - diff -Nru eresi-0.8a25/testsuite/testscripts/insert_tests.esh eresi-0.0.20110516/testsuite/testscripts/insert_tests.esh --- eresi-0.8a25/testsuite/testscripts/insert_tests.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/insert_tests.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -#!/usr/local/bin/elfsh - -exec rm /tmp/ls.new -load /bin/ls -e -sht -pht -insert phdr PT_GNU_STACK .dynamic 1.sht[.dynamic].size -e -sht -pht -save /tmp/ls.new -exec /tmp/ls.new -quit diff -Nru eresi-0.8a25/testsuite/testscripts/kernsh-script.esh eresi-0.0.20110516/testsuite/testscripts/kernsh-script.esh --- eresi-0.8a25/testsuite/testscripts/kernsh-script.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/kernsh-script.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -#!elfsh/elfsh32 - -load vmlinux -type thread_info = task:*long -type task_struct = state:long thread_info:*thread_info -inform task_struct init_task - -print 1.task_struct[init_task].thread_info.task -print 1.task_struct[init_task].thread_info diff -Nru eresi-0.8a25/testsuite/testscripts/loop.esh eresi-0.0.20110516/testsuite/testscripts/loop.esh --- eresi-0.8a25/testsuite/testscripts/loop.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/loop.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!../../elfsh/elfsh32 - -# comment it for enabling trace mode -quiet - -load /bin/ls -set $index 0 -print Now try to find symbols with 4 bytes size : - -loop: -cmp $index 1.hdr.shnum -je endloop -print Passing section 1.section[$index].name at addr 1.sht[$index].addr with index $index -add $index 1 -jmp loop - -endloop: -set $index 0 -set $lastsym 1.sht[.dynsym].size -div $lastsym 1.sht[.dynsym].entsize -print Now try to find symbols with 4 bytes size ( dynsymtab contains $lastsym entries ) : - -loop2: -cmp $index $lastsym -je end -cmp 1.dynsym[$index].size 4 -jne rec -print Found dword sized symbol : 1.dynsym[$index].name at addr 1.dynsym[$index].value -rec: -add $index 1 -jmp loop2 - -end: -vlist -quit - - - diff -Nru eresi-0.8a25/testsuite/testscripts/myparams.esh eresi-0.0.20110516/testsuite/testscripts/myparams.esh --- eresi-0.8a25/testsuite/testscripts/myparams.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/myparams.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#!../../elfsh/elfsh32 - -cmp $# 1 -jne paramerr - -load /bin/ls -print Parameter 1 : $1 -set $full 1.sht[.dynsym].size -div $full 1.sht[.dynsym].entsize -print Dynamic symtab contains $full entries -cmp $full $1 -jle err -print Entry $1 is 1.dynsym[$1].value with name 1.dynsym[$1].name -jmp end - -err: -print Table is too small -paramerr: -print Script must take one parameter -end: -print End of scripts, listing variables : -vlist -quit - - diff -Nru eresi-0.8a25/testsuite/testscripts/params2.esh eresi-0.0.20110516/testsuite/testscripts/params2.esh --- eresi-0.8a25/testsuite/testscripts/params2.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/params2.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -#!/usr/local/bin/elfsh - -print TWO = $2 -print ONE = $1 -cmp $1 $2 -je err -print DIFF -jmp end -err: -print EQU -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/params.esh eresi-0.0.20110516/testsuite/testscripts/params.esh --- eresi-0.8a25/testsuite/testscripts/params.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/params.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -#!/usr/local/bin/elfsh - -load /bin/ls -print Parameter 1 : $1 -set $full 1.sht[.dynsym].size -div $full 1.sht[.dynsym].entsize -print Dynamic symbol table contains $full entries -print FULL = $full -print ONE = $1 -cmp $1 $full -jle err -print Symbol $1 is 1.dynsym[$1].name -jmp end -err: -print Table is too small -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/print_array.esh eresi-0.0.20110516/testsuite/testscripts/print_array.esh --- eresi-0.8a25/testsuite/testscripts/print_array.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/print_array.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../elfsh/elfsh32 - -load ../../a.out -type example1 = sys:string[3] -inform example1 toto array - -print 1.example1[toto].sys[0] - -set $i 0 - -boucle: - -cmp $i 3 -je end -print INDEX $i = 1.example1[toto].sys[$i] -add $i 1 -jmp boucle - -end: -print "Bye !" diff -Nru eresi-0.8a25/testsuite/testscripts/print_syscalltable.esh eresi-0.0.20110516/testsuite/testscripts/print_syscalltable.esh --- eresi-0.8a25/testsuite/testscripts/print_syscalltable.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/print_syscalltable.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../elfsh/elfsh32 - -load /usr/src/linux/vmlinux -type example1 = sys:int[320] -inform example1 toto sys_call_table - -print 1.example1[toto].sys[0] - -set $i 0 - -boucle: - -cmp $i 2 -je end -print 1.example1[toto].sys[$i] -add $i 1 -jmp boucle - -end: -print "Bye !" \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/testscripts/regression-tests.esh eresi-0.0.20110516/testsuite/testscripts/regression-tests.esh --- eresi-0.8a25/testsuite/testscripts/regression-tests.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/regression-tests.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ -#!../../elfsh/elfsh32 -# -# Additional tests suite for shell commands . -# -# This does nothing really, just checking that all commands -# do their job. The output file is completely useless. -# -# And please dont ask -why- 42 -# - - -# Start printing the help screens -help -info - - -# Uncomment me for a quiet output log -# quiet -# Uncomment me for a very verbose output -#profile enable warn - -# Now load the files -load /bin/ls -list -switch 1 - -exec ls -la - -# Playing with print and exec commands -print phnum is 1.hdr.phnum and got[21] is 1.got[21] -print 11th section is 1.section[11].name - - -# Play with arithmetic ops -print phnum = 1.hdr.phnum -add 1.hdr.phnum 42 -print phnum = 1.hdr.phnum -sub 1.hdr.phnum 41 -print phnum = 1.hdr.phnum -div 1.hdr.phnum 2 -print phnum = 1.hdr.phnum -mod 1.hdr.phnum 2 -print phnum = 1.hdr.phnum -mul 1.hdr.phnum 5 -print phnum = 1.hdr.phnum - -# Playing a bit with the modules -cmdtest -modload ../../modules/modtest.so -print hehe -cmdtest -list - -profile enable all -modunload ../../modules/modtest.so -print hehe - -# ELF header tests -# Illustrate the object affectations between files - -e -print 1.hdr.magic -set 1.hdr.magic 0x42424242 -print 1.hdr.magic -e - -set 1.hdr.type 2.hdr.type -set 1.hdr.machine 0x43 -set 1.hdr.version 0x44 -set 1.hdr.entry .data - -# Dont do those or you wont be able to see the change in the output file -#set 1.hdr.shoff 0x46 -#set 1.hdr.phoff 0x47 - -set 1.hdr.ehsize 0x48 -set 1.hdr.shentsize 2.hdr.shentsize -set 1.hdr.phentsize 2.hdr.shentsize -set 1.hdr.phnum 3 -set 1.hdr.shnum 30 -set 1.hdr.shstrndx 31 - -# PAX flags tests - -set 1.hdr.pax_pageexec 0 -set 1.hdr.pax_segmexec 1 -set 1.hdr.pax_emultramp 0 -set 1.hdr.pax_mprotect 1 -set 1.hdr.pax_randmmap 0 -set 1.hdr.pax_randexec 1 - -e - -print 1.hdr.magic -print 1.hdr.type -print 1.hdr.machine -print 1.hdr.version -print 1.hdr.entry -print 1.hdr.phoff -print 1.hdr.shoff -print 1.hdr.ehsize -print 1.hdr.shentsize -print 1.hdr.phentsize -print 1.hdr.phnum -print 1.hdr.shnum -print 1.hdr.shstrndx - - -# PHT tests -# Illustrate elf.h constants resolving as immediate value - -p -set 1.pht[0].type ET_DYN -set 1.pht[0].offset 0x55 -set 1.pht[0].vaddr 0x56 -set 1.pht[0].paddr 0x57 -set 1.pht[0].filesz 0x58 -set 1.pht[0].memsz 0x59 -set 1.pht[0].flags 0x60 -set 1.pht[0].align 0x61 -p - -print 1.pht[0].type -print 1.pht[0].offset -print 1.pht[0].vaddr -print 1.pht[0].paddr -print 1.pht[0].filesz -print 1.pht[0].memsz -print 1.pht[0].flags -print 1.pht[0].align - - - -# SHT tests - -s 01 -set 1.sht[1].type 0x54 -set 1.sht[1].addr 0x55 -set 1.sht[1].offset 0x56 -set 1.sht[1].size 0x57 -set 1.sht[1].link 0x58 -set 1.sht[1].info 0x59 -set 1.sht[1].align 0x60 -set 1.sht[1].entsize 0x61 -set 1.sht[1].a 1 -set 1.sht[1].w 1 -set 1.sht[1].x 1 -set 1.sht[1].s 1 -set 1.sht[1].m 1 -set 1.sht[1].l 1 -set 1.sht[1].o 1 -s - -print 1.sht[1].type -print 1.sht[1].addr -print 1.sht[1].offset -print 1.sht[1].size -print 1.sht[1].link -print 1.sht[1].info -print 1.sht[1].align -print 1.sht[1].entsize -print 1.sht[1].a -print 1.sht[1].w -print 1.sht[1].x -print 1.sht[1].s -print 1.sht[1].m -print 1.sht[1].l -print 1.sht[1].o - - - - -# SYMTAB tests - -sym 03] -set 1.symtab[3].value 0x62 -set 1.symtab[3].size 0x63 -set 1.symtab[3].bind 1 -set 1.symtab[3].type 4 -set 1.symtab[3].other 2 -sym 03] - -print 1.symtab[3].value -print 1.symtab[3].size -print 1.symtab[3].bind -print 1.symtab[3].type -print 1.symtab[3].other - - -# DYNSYMTAB tests - -dynsym 12] -set 1.dynsym[12].value 0x67 -set 1.dynsym[12].size 0x68 -set 1.dynsym[12].bind 1 -set 1.dynsym[12].type 6 -set 1.dynsym[12].other 2 -dynsym 12] - -print 1.dynsym[12].value -print 1.dynsym[12].size -print 1.dynsym[12].bind -print 1.dynsym[12].type -print 1.dynsym[12].other - - -# .DYNAMIC tests - -dyn 07] -set 1.dynamic[7].val 0x72 -set 1.dynamic[7].tag 0x73 -dyn 07] - -print 1.dynamic[7].val -print 1.dynamic[7].tag - - -# .GOT tests : you can also use filepath instead of their index - -got 05]|13] -print 1.got[5] -set 1.got[5] /usr/local/bin/elfsh.got[13] -print 1.got[5] -got 05]|13] - - -# CTORS and DTORS tests -# Illustrate the (dyn)symbol resolving as immediate value - -ctors -set 1.ctors[0] 0x41424344 -set 1.ctors[1] malloc -ctors - -dtors -set 1.dtors[1] 0x4546 -set 1.dtors[0] free -dtors - - -# RELOCATION TABLE TESTS - -rel 062] -set 1.rel[1][62].sym 22 -set 1.rel[1][62].offset 0x08044800 -set 1.rel[1][62].type R_386_GOTPC -rel 062] - -# Now leave, unloaded files are closed without saving -save /tmp/test-save -unload /bin/ls -exec rm /tmp/test-save -quit - - - - - - - - - - diff -Nru eresi-0.8a25/testsuite/testscripts/remap_script.esh eresi-0.0.20110516/testsuite/testscripts/remap_script.esh --- eresi-0.8a25/testsuite/testscripts/remap_script.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/remap_script.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -#!/usr/bin/elfsh - -load /bin/ls -modload modremap -findrel -remap 0x11223344 -save /tmp/ls.remapped -exec /tmp/ls.remapped -quit diff -Nru eresi-0.8a25/testsuite/testscripts/script-lists.esh eresi-0.0.20110516/testsuite/testscripts/script-lists.esh --- eresi-0.8a25/testsuite/testscripts/script-lists.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/script-lists.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -#!../../elfsh/elfsh32 - -set $list[test1:key] 42 -lists test1 - -set $list[test2] $list[test1] -lists test - -set $list[test1:key2] 43 -lists test -lists test1 -lists test2 - -add $list[test2] $list[test1:key2] -lists test2 - -sub $list[test2] key2 -lists test2 - -# test error checking -sub $list[test2] key2 -lists test2 - -#profile enable warn - -add $list[test2] 42 -add $list[test2] 43 -add $list[test2] 44 -add $list[test2] 45 -add $list[test2] 46 -add $list[test2] 47 -add $list[test2] 48 - -lists test2 -lists test1 - -sub $list[test2] $list[test1] -lists test2 -lists test1 -add $list[test2] $list[test1] -lists test2 -lists test1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/script-tables.esh eresi-0.0.20110516/testsuite/testscripts/script-tables.esh --- eresi-0.8a25/testsuite/testscripts/script-tables.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/script-tables.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -#!../../elfsh/elfsh32 -set $hash[test1:key] 42 -tables test1 - -set $hash[test2] $hash[test1] -tables test - -set $hash[test1:key2] 43 -tables test -tables test1 -tables test2 - -add $hash[test2] $hash[test1:key2] -tables test2 - -sub $hash[test2] key2 -tables test2 - -# test error checking -sub $hash[test2] key2 -tables test2 - -#profile enable warn - -add $hash[test2] 42 -add $hash[test2] 43 -add $hash[test2] 44 -add $hash[test2] 45 -add $hash[test2] 46 -add $hash[test2] 47 -add $hash[test2] 48 - -tables test2 -tables test1 -sub $hash[test2] $hash[test1] -tables test2 -tables test1 -add $hash[test2] $hash[test1] -tables test2 -tables test1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/script-types.esh eresi-0.0.20110516/testsuite/testscripts/script-types.esh --- eresi-0.8a25/testsuite/testscripts/script-types.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/script-types.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -#!../../elfsh/elfsh32 - -load ../../elfsh/elfsh32 -switch 107 - -# Just some examples of type that can be used to map internal framework structures -type context = savedfd:int savedmode:byte savedcmd:*long savedinput:*long savedargv:*long savedname:*long curcmd:*long -type state = flags:byte[4] glregex%32 sregx:*long alertf:byte alertregex%32 strs:*long[4] moreflags:byte[5] lastid:int -type world = state:state ctxt:context - -# Lets see an example of printing of real variables arrays of the framework - -type archtypes = types:string[55] -inform archtypes elfsh_arch_type -type archaddr = types:long[55] -inform archaddr elfsh_arch_type - -inform archtypes -quiet - -print Now print Strings -print -print 107.archtypes[elfsh_arch_type].types[0] -print 107.archtypes[elfsh_arch_type].types[1] -print 107.archtypes[elfsh_arch_type].types[2] -print 107.archtypes[elfsh_arch_type].types[3] -print - -print Now print addresses -print -print Entry 1 : 107.archaddr[elfsh_arch_type].types[0] -print Entry 2 : 107.archaddr[elfsh_arch_type].types[1] -print Entry 3 : 107.archaddr[elfsh_arch_type].types[2] -print Entry 4 : 107.archaddr[elfsh_arch_type].types[3] -print - -verb -#profile enable warn - -set 107.archaddr[elfsh_arch_type].types[0] 0x41414141 -set 107.archaddr[elfsh_arch_type].types[1] 0x42424242 -set 107.archaddr[elfsh_arch_type].types[2] 0x43434343 -set 107.archaddr[elfsh_arch_type].types[3] 0x44444444 - -print 107.archaddr[elfsh_arch_type].types[0] -print 107.archaddr[elfsh_arch_type].types[1] -print 107.archaddr[elfsh_arch_type].types[2] -print 107.archaddr[elfsh_arch_type].types[3] - -quit - - - diff -Nru eresi-0.8a25/testsuite/testscripts/strings_tests.esh eresi-0.0.20110516/testsuite/testscripts/strings_tests.esh --- eresi-0.8a25/testsuite/testscripts/strings_tests.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/strings_tests.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -#!/usr/local/bin/elfsh -# -# Second regression test script -# - -#quiet - -load /bin/ls - -print SHT entries 1 and 13: -s 01]|13] - -print The interpretor section: -X interp - -print Change section name: -print 1.section[1].name -set 1.section[1].name .pffffffffffff -print 1.section[1].name - -print 20 first bytes of .text: -X ^\.text%20 - -print Change 5 first byte of section .text : -write 1.section[.text].raw hehe\x42 -X ^\.text%20 - -print Write 9 bytes in section .text, starting at byte 5: -write 1.section[.text:5].raw \x43\x44\huhu\x00\x48 -X ^\.text%20 - -print Write the value of printf symbol (4 bytes) at offset 10 (2 * 5) -write 1.section[.text:2%5].raw printf -X ^\.text%20 - -s 01]|13] - -print Change a symbol name -print 1.symtab[1].name -set 1.symtab[1].name heh -print 1.symtab[1].name - -print Change a dynamic symbol name -print 1.dynsym[2].name -set 1.dynsym[2].name test_big_string_oh_yeah -print 1.dynsym[2].name - -save /tmp/elfsh.modifs -quit diff -Nru eresi-0.8a25/testsuite/testscripts/subtyping.esh eresi-0.0.20110516/testsuite/testscripts/subtyping.esh --- eresi-0.8a25/testsuite/testscripts/subtyping.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/subtyping.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../evarista/evarista32 - -print ************ Now declarations of subtypes ***************** - -type struct0 = field0:long -type -type struct1::struct0 = field1:byte field2:long -type -type struct2::struct1 = field3:struct1 field4:long field5:struct1 -type - -# This is not allowed (collision in field names) -#verb -#type struct3::struct0 = field0:string -#type -#type struct4 = field0:string field0:int -#type - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/all-wcprops eresi-0.0.20110516/testsuite/testscripts/.svn/all-wcprops --- eresi-0.8a25/testsuite/testscripts/.svn/all-wcprops 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/all-wcprops 1970-01-01 00:00:00.000000000 +0000 @@ -1,215 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 45 -/svn/!svn/ver/915/trunk/testsuite/testscripts -END -graph-tests.esh -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/622/trunk/testsuite/testscripts/graph-tests.esh -END -declare-bitfields.esh -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/837/trunk/testsuite/testscripts/declare-bitfields.esh -END -foreach-reference.esh -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/823/trunk/testsuite/testscripts/foreach-reference.esh -END -factorial.esh -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/834/trunk/testsuite/testscripts/factorial.esh -END -script-types.esh -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/823/trunk/testsuite/testscripts/script-types.esh -END -declare-unions.esh -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/835/trunk/testsuite/testscripts/declare-unions.esh -END -foreach-ending.esh -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/823/trunk/testsuite/testscripts/foreach-ending.esh -END -defines.esh -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/823/trunk/testsuite/testscripts/defines.esh -END -flush.esh -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/12/trunk/testsuite/testscripts/flush.esh -END -subtyping.esh -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/831/trunk/testsuite/testscripts/subtyping.esh -END -remap_script.esh -K 25 -svn:wc:ra_dav:version-url -V 60 -/svn/!svn/ver/3/trunk/testsuite/testscripts/remap_script.esh -END -factorial-withret.esh -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/834/trunk/testsuite/testscripts/factorial-withret.esh -END -kernsh-script.esh -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/740/trunk/testsuite/testscripts/kernsh-script.esh -END -script-lists.esh -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/823/trunk/testsuite/testscripts/script-lists.esh -END -foreach-lists.esh -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/823/trunk/testsuite/testscripts/foreach-lists.esh -END -test-multidim-arrays.c -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/502/trunk/testsuite/testscripts/test-multidim-arrays.c -END -foreach-linearity.esh -K 25 -svn:wc:ra_dav:version-url -V 67 -/svn/!svn/ver/762/trunk/testsuite/testscripts/foreach-linearity.esh -END -params2.esh -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/475/trunk/testsuite/testscripts/params2.esh -END -foreach-list-simple.esh -K 25 -svn:wc:ra_dav:version-url -V 69 -/svn/!svn/ver/831/trunk/testsuite/testscripts/foreach-list-simple.esh -END -test-set.esh -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/843/trunk/testsuite/testscripts/test-set.esh -END -loop.esh -K 25 -svn:wc:ra_dav:version-url -V 54 -/svn/!svn/ver/740/trunk/testsuite/testscripts/loop.esh -END -strings_tests.esh -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/475/trunk/testsuite/testscripts/strings_tests.esh -END -script-tables.esh -K 25 -svn:wc:ra_dav:version-url -V 63 -/svn/!svn/ver/823/trunk/testsuite/testscripts/script-tables.esh -END -foreach-hashes.esh -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/823/trunk/testsuite/testscripts/foreach-hashes.esh -END -regression-tests.esh -K 25 -svn:wc:ra_dav:version-url -V 66 -/svn/!svn/ver/843/trunk/testsuite/testscripts/regression-tests.esh -END -doublevar.esh -K 25 -svn:wc:ra_dav:version-url -V 59 -/svn/!svn/ver/475/trunk/testsuite/testscripts/doublevar.esh -END -params.esh -K 25 -svn:wc:ra_dav:version-url -V 56 -/svn/!svn/ver/475/trunk/testsuite/testscripts/params.esh -END -insert_tests.esh -K 25 -svn:wc:ra_dav:version-url -V 62 -/svn/!svn/ver/475/trunk/testsuite/testscripts/insert_tests.esh -END -foreach-nested.esh -K 25 -svn:wc:ra_dav:version-url -V 64 -/svn/!svn/ver/786/trunk/testsuite/testscripts/foreach-nested.esh -END -myparams.esh -K 25 -svn:wc:ra_dav:version-url -V 58 -/svn/!svn/ver/823/trunk/testsuite/testscripts/myparams.esh -END -print_array.esh -K 25 -svn:wc:ra_dav:version-url -V 61 -/svn/!svn/ver/831/trunk/testsuite/testscripts/print_array.esh -END -print_syscalltable.esh -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/788/trunk/testsuite/testscripts/print_syscalltable.esh -END -endian.esh -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/12/trunk/testsuite/testscripts/endian.esh -END -trace.esh -K 25 -svn:wc:ra_dav:version-url -V 55 -/svn/!svn/ver/575/trunk/testsuite/testscripts/trace.esh -END -declare.esh -K 25 -svn:wc:ra_dav:version-url -V 57 -/svn/!svn/ver/915/trunk/testsuite/testscripts/declare.esh -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/entries eresi-0.0.20110516/testsuite/testscripts/.svn/entries --- eresi-0.8a25/testsuite/testscripts/.svn/entries 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/entries 1970-01-01 00:00:00.000000000 +0000 @@ -1,479 +0,0 @@ -8 - -dir -958 -http://svn.eresi-project.org/svn/trunk/testsuite/testscripts -http://svn.eresi-project.org/svn - - - -2008-03-18T17:48:47.427281Z -915 -may - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -cfe96d8e-f5de-dc11-b1ed-0017314a9460 - -graph-tests.esh -file - - - - -2008-04-06T23:15:38.909131Z -0b6535aec106aa9687a716d402f7510b -2007-05-19T18:28:10.000000Z -622 -thor -has-props - -declare-bitfields.esh -file - - - - -2008-04-06T23:15:39.005475Z -0ce4ee0f8b5a655b1e9097ae215065e0 -2007-12-06T20:59:11.000000Z -837 -may -has-props - -foreach-reference.esh -file - - - - -2008-04-06T23:15:39.017108Z -d3671db2a8f5bd4481fe58907d3c0842 -2007-11-28T07:56:09.000000Z -823 -may -has-props - -factorial.esh -file - - - - -2008-04-06T23:15:39.027975Z -e9237c88bd02ab5797c42e199294deec -2007-12-06T05:11:58.000000Z -834 -may -has-props - -script-types.esh -file - - - - -2008-04-06T23:15:39.040313Z -7c67ceb199cbcd33dfd918fc76f60846 -2007-11-28T07:56:09.000000Z -823 -may - -declare-unions.esh -file - - - - -2008-04-06T23:15:39.163234Z -a140ad2defb130cd5c4ddcc2f0b60f2e -2007-12-06T06:40:16.000000Z -835 -may -has-props - -foreach-ending.esh -file - - - - -2008-04-06T23:15:39.174982Z -19457f3981515d0478084df02d82e35a -2007-11-28T07:56:09.000000Z -823 -may -has-props - -defines.esh -file - - - - -2008-04-06T23:15:39.186693Z -f38ead932fd037168b74f5818903382d -2007-11-28T07:56:09.000000Z -823 -may -has-props - -flush.esh -file - - - - -2008-04-06T23:15:39.198303Z -783b5875e6d6f94e09e154b9c620862b -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -subtyping.esh -file - - - - -2008-04-06T23:15:39.209991Z -dbe6dc2b51a33076fd2f6a46e494a474 -2007-11-29T14:08:47.000000Z -831 -may -has-props - -remap_script.esh -file - - - - -2008-04-06T23:15:39.221682Z -b713a3c4719642e351988afa7a0aaad5 -2003-08-21T01:13:15.000000Z -3 -thor -has-props - -factorial-withret.esh -file - - - - -2008-04-06T23:15:39.233371Z -cf313f74d925f730da820805105a79f3 -2007-12-06T05:11:58.000000Z -834 -may -has-props - -kernsh-script.esh -file - - - - -2008-04-06T23:15:39.245005Z -eff8807206eaed90b5c344545ec26b07 -2007-07-25T16:39:45.000000Z -740 -may -has-props - -script-lists.esh -file - - - - -2008-04-06T23:15:39.256695Z -650167aacdd7733335de3b92d5a3cd42 -2007-11-28T07:56:09.000000Z -823 -may -has-props - -test-multidim-arrays.c -file - - - - -2008-04-06T23:15:39.280017Z -28aeccd17bde715d5d52b0b3914b2468 -2007-03-07T16:45:36.000000Z -502 -thor - -foreach-lists.esh -file - - - - -2008-04-06T23:15:39.268442Z -8b778fc597816d3050761d34799e6ce5 -2007-11-28T07:56:09.000000Z -823 -may -has-props - -foreach-linearity.esh -file - - - - -2008-04-06T23:15:39.303260Z -fb1bdee69d96c75627c5968685695f2e -2007-08-03T18:05:03.000000Z -762 -may -has-props - -params2.esh -file - - - - -2008-04-06T23:15:39.291706Z -f2219d7bda29a70bcac9a7d79955dc4e -2007-03-02T10:56:10.000000Z -475 -may -has-props - -foreach-list-simple.esh -file - - - - -2008-04-06T23:15:39.315014Z -75d3e070b371806c4963f3ff8d61b0d5 -2007-11-29T14:08:47.000000Z -831 -may -has-props - -test-set.esh -file - - - - -2008-04-06T23:15:39.326876Z -b42d8d803db0def72223f0a5bcf893d9 -2008-02-16T12:32:28.000000Z -843 -thor -has-props - -loop.esh -file - - - - -2008-04-06T23:15:39.339920Z -a1a887565e03640ad5bd7bd20751ee63 -2007-07-25T16:39:45.000000Z -740 -may -has-props - -strings_tests.esh -file - - - - -2008-04-06T23:15:39.351876Z -3489949cd62c36560a7f28e6752c000b -2007-03-02T10:56:10.000000Z -475 -may -has-props - -script-tables.esh -file - - - - -2008-04-06T23:15:39.362971Z -0236351b39b57dd056e0b362a174bd7c -2007-11-28T07:56:09.000000Z -823 -may -has-props - -foreach-hashes.esh -file - - - - -2008-04-06T23:15:39.386961Z -904989e2ff49032c3a9f073a0a86122a -2007-11-28T07:56:09.000000Z -823 -may -has-props - -regression-tests.esh -file - - - - -2008-04-06T23:15:39.375271Z -ed5dffae436ba993a70efe8662115354 -2008-02-16T12:32:28.000000Z -843 -thor -has-props - -doublevar.esh -file - - - - -2008-04-06T23:15:39.410352Z -fd6f97a5cd78a0b84b1458246d002b3e -2007-03-02T10:56:10.000000Z -475 -may -has-props - -params.esh -file - - - - -2008-04-06T23:15:39.398709Z -21e31360ca8744fc820882811918fea4 -2007-03-02T10:56:10.000000Z -475 -may -has-props - -insert_tests.esh -file - - - - -2008-04-06T23:15:39.422205Z -965c66cd0c3478c0e266134e1572da2a -2007-03-02T10:56:10.000000Z -475 -may -has-props - -foreach-nested.esh -file - - - - -2008-04-06T23:15:39.433895Z -0f29ad6fdd287fb6a7118ceb8772a030 -2007-09-17T22:58:18.000000Z -786 -may -has-props - -myparams.esh -file - - - - -2008-04-06T23:15:39.445585Z -1d9715db798b3c50e40ecc39ccdb23a1 -2007-11-28T07:56:09.000000Z -823 -may -has-props - -print_array.esh -file - - - - -2008-04-06T23:15:39.457108Z -89fe3888c086a5633956990022f5e2a7 -2007-11-29T14:08:47.000000Z -831 -may -has-props - -print_syscalltable.esh -file - - - - -2008-04-06T23:15:39.468876Z -f1ef30d4b676581b0d549dbb2516d232 -2007-09-18T21:41:13.000000Z -788 -may - -endian.esh -file - - - - -2008-04-06T23:15:39.480540Z -e46dff7f81b37eb888aaa39ddc75bb9c -2005-08-02T06:43:53.000000Z -12 -thor -has-props - -trace.esh -file - - - - -2008-04-06T23:15:39.492115Z -f63dd576960840e993d63af9e434ff5c -2007-04-16T16:29:17.000000Z -575 -may - -declare.esh -file - - - - -2008-04-06T23:15:39.503604Z -5a179f744d6c580621262c3f78cf1781 -2008-03-18T17:48:47.427281Z -915 -may -has-props - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/format eresi-0.0.20110516/testsuite/testscripts/.svn/format --- eresi-0.8a25/testsuite/testscripts/.svn/format 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -8 diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare-bitfields.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare-bitfields.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare-bitfields.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare-bitfields.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare-unions.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare-unions.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/declare-unions.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/declare-unions.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/defines.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/defines.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/defines.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/defines.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/doublevar.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/doublevar.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/doublevar.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/doublevar.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/endian.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/endian.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/endian.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/endian.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/factorial.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/factorial.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/factorial.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/factorial.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/factorial-withret.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/factorial-withret.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/factorial-withret.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/factorial-withret.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/flush.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/flush.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/flush.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/flush.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-ending.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-ending.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-ending.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-ending.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-hashes.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-hashes.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-hashes.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-hashes.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-linearity.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-linearity.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-linearity.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-linearity.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-lists.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-lists.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-lists.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-lists.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-list-simple.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-list-simple.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-list-simple.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-list-simple.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-nested.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-nested.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-nested.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-nested.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-reference.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-reference.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/foreach-reference.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/foreach-reference.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/graph-tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/graph-tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/graph-tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/graph-tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/insert_tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/insert_tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/insert_tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/insert_tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/kernsh-script.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/kernsh-script.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/kernsh-script.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/kernsh-script.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/loop.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/loop.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/loop.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/loop.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/myparams.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/myparams.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/myparams.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/myparams.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/params2.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/params2.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/params2.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/params2.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/params.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/params.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/params.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/params.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/print_array.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/print_array.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/print_array.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/print_array.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/regression-tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/regression-tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/regression-tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/regression-tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/remap_script.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/remap_script.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/remap_script.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/remap_script.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/script-lists.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/script-lists.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/script-lists.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/script-lists.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/script-tables.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/script-tables.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/script-tables.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/script-tables.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/strings_tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/strings_tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/strings_tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/strings_tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/subtyping.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/subtyping.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/subtyping.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/subtyping.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/prop-base/test-set.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/test-set.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/prop-base/test-set.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/prop-base/test-set.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -K 14 -svn:executable -V 1 -* -END diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare-bitfields.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare-bitfields.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare-bitfields.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare-bitfields.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -print ************ Now declarations of bitfields types ***************** - -type struct1 = field1:long field2:bit[7] field3:byte -union union1 = field4:struct1 field5:long field6:struct1 -type -type struct1 -type union1 - -print ************ Now declarations of variables ***************** - -union1 myunion1 = (field4(field1:42, field3:43), field5:44, field6(field1:45, field3:46)) -print $myunion1 - -set $myunion1.field5 42 -print $myunion1 -set $myunion1.field4.field1 31337 -print $myunion1 -set $myunion1.field6.field3 A -print $myunion1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,132 +0,0 @@ -#!../../evarista/evarista64 - -#profile enable warn - -print ************ Now declarations of record types ***************** - -type struct0 = field0:long -type struct1 = field1:byte field2:long -type struct2 = field3:struct1 field4:long field5:struct1 - -print ************ Now declarations of variables ***************** - -#profile enable trace - -long mylong = 42 -vlist - -struct0 mystruct0 = (field0:42) -struct0 mystruct0b = struct0(field0:42) -struct0 mystruct0c = struct0(field0:43) - -struct1 mystruct1 = (field1:42,field2:43) - -struct1 mystruct1b = $mystruct1 -#struct1 mystruct1b = (field1:42,field2:43) - -struct1 mystruct1c = (field1:43,field2:42) -struct1 mystruct1d = (field2:42,field1:43) - -tables expressions - -#struct2 mystruct2 = (field3:$mystruct1, field4:44, field5(field1:45, field2:46)) -struct2 mystruct2 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) - -print $mystruct2 - -tables expressions - -struct2 mystruct2b = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) - -tables expressions - -print $mystruct2b - -struct2 mystruct2c = (field3(field1:42, field2:43), field4:44, field5(field1:46, field2:45)) - -print $mystruct2c - -# List all existing expressions at this state -#tables expressions - -# Test de mauvais typage -OK- -#struct0 mystruct0b = struct1(field0:42) - -print ************ Now testing printing of types ***************** - -type - -print ************ Now testing printing of expressions ***************** -print $mystruct0 -print $mystruct0b -print $mystruct0c -print $mystruct1b -print $mystruct1 -print $mystruct1c -print $mystruct1d -print $mystruct2 -print $mystruct2b -print $mystruct2c - -print *********** Now testing basic whole-expression comparison **************** - -#profile enable warn - -cmp $mystruct0 $mystruct0 -cmp $mystruct0 $mystruct0b -cmp $mystruct0b $mystruct0c -cmp $mystruct1 $mystruct1b -cmp $mystruct1b $mystruct1c -cmp $mystruct2 $mystruct2b -cmp $mystruct2b $mystruct2c - -print *********** Now testing field-order insensitive comparison **************** - -cmp $mystruct1c $mystruct1d - -# Set works all very well -print $mystruct0b $mystruct0c -set $mystruct0c $mystruct0b -print $mystruct0b $mystruct0c -cmp $mystruct0b $mystruct0c - -print $mystruct1b $mystruct1c -set $mystruct1c $mystruct1b -print $mystruct1b $mystruct1c -cmp $mystruct1b $mystruct1c - -print $mystruct2c $mystruct2b -set $mystruct2c $mystruct2b -print $mystruct2c $mystruct2b -cmp $mystruct2b $mystruct2c - - -print *********** Now testing subexpressions comparisons ************** - -print $mystruct2c.field3 -print $mystruct2c.field5 -print $mystruct1b - -cmp $mystruct2c.field3 $mystruct2c.field5 -cmp $mystruct2c.field3 $mystruct2b.field3 -cmp $mystruct2c.field3 $mystruct1b -cmp $mystruct1b $mystruct2c.field5 - -print *********** Now testing setting subexpressions ********* - -print $mystruct2c.field5 $mystruct1 -cmp $mystruct2c.field5 $mystruct1 -set $mystructbackup $mystruct2c.field5 -print $mystructbackup $mystruct2c.field5 $mystruct1 -set $mystruct2c.field5 $mystruct1 -print $mystructbackup $mystruct2c.field5 $mystruct1 -cmp $mystruct2c.field5 $mystruct1 - -print ********** Now testing terminal subexpression printing ********* - -print $mystruct2c.field3.field1 -print $mystruct2c.field3.field2 -print $mystruct2c.field5.field1 -print $mystruct2c.field5.field2 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare-unions.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare-unions.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/declare-unions.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/declare-unions.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -print ************ Now declarations of record types ***************** - -type struct1 = field1:long field2:byte -union union1 = field3:struct1 field4:long field5:struct1 -type -type union1 - -print ************ Now declarations of variables ***************** - -union1 myunion1 = (field3(field1:42, field2:43), field4:44, field5(field1:45, field2:46)) -print $myunion1 - -tables expressions -profile enable warn -set $myunion1.field4 42 - -print $myunion1 -set $myunion1.field3.field1 31337 -print $myunion1 -set $myunion1.field5.field2 A -print $myunion1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/defines.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/defines.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/defines.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/defines.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -#!../../evarista/evarista32 - -#profile enable warn - -# Attributes for instructions -define b ASM_TYPE_IMPBRANCH -define cb ASM_TYPE_CONDBRANCH -define c ASM_TYPE_CALLPROC -define i ASM_TYPE_INT -define r ASM_TYPE_RETPROC -define p ASM_TYPE_PROLOG -define cmp ASM_TYPE_COMPARISON -define bs ASM_TYPE_BITSET -define a ASM_TYPE_ASSIGN -define wm ASM_TYPE_STORE -define rm ASM_TYPE_LOAD -define e ASM_TYPE_EPILOG -define s ASM_TYPE_STOP -define n ASM_TYPE_NOP -define ar ASM_TYPE_ARITH -define wf ASM_TYPE_WRITEFLAG -define i-r i r -define ar-wf ar wf -define ar-wm ar wm -define a-rm a rm -define a-wm a wm - -#define id ASM_TYPE_INCDEC -#define ar-id ar id -#define ar-id-wm ar id wm - -# Attributes for operands -define reg ASM_OPTYPE_REG -define imm ASM_OPTYPE_IMM -define mem ASM_OPTYPE_MEM - -# Printing to see if it worked -print b cb c i r p cmp bs a wm -print rm e s n ar wf - -print i-r ar-wf ar-wm a-rm a-wm - -print reg imm mem diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/doublevar.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/doublevar.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/doublevar.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/doublevar.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,21 +0,0 @@ -#!/usr/local/bin/elfsh - -#quiet - -print Parameters : $1 $2 $3 -print - -set $index 1 - -loop: -#profile enable warn -cmp $index $# -jl end -load $$index -dynsym printf -unload $$index -add $index 1 -jmp loop - -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/endian.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/endian.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/endian.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/endian.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -#!/usr/bin/elfsh - -load MISC/top64 -quiet -p -verb -set 1.got[0] .plt -save /tmp/top64new -quiet -p -verb -load /tmp/top64new -quiet -p -verb -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/factorial.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/factorial.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/factorial.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/factorial.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../evarista/evarista32 - -sdir . -quiet - -cmp $# 2 -jne end -print Fact with params : -print $1 $2 -mul $2 $1 -set $2 $_ -sub $1 1 -cmp $1 1 -je result -print Variables at current iteration : -print $1 $2 $_ -factorial $1 $2 -quit - -end: -print This program needs 2 parameters -quit - -result: -print Factorial result: -print $2 -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/factorial-withret.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/factorial-withret.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/factorial-withret.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/factorial-withret.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -#!../../evarista/evarista32 - -cmp $ESHLVL 0 -jne factstart -sdir . -quiet - -factstart: -cmp $# 2 -jne end -mul $2 $1 -sub $1 1 -cmp $1 1 -je result - -factorial-withret $1 $2 -set $2 $_ - -result: -cmp $ESHLVL 0 -je printres -return $2 - -printres: -print Factorial result: -print $2 -quit - -end: -print This program needs 2 parameters -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/flush.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/flush.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/flush.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/flush.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -#!/usr/bin/elfsh - -load fake_aout -remove sect .orig.plt -remove sect rel.o.rodata.str1.1 -remove sect rel.o.rodata.str1.32 -remove sect rel.o.text -remove sect rel.o.data -save new_aout -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-ending.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-ending.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-ending.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-ending.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -#!../../elfsh/elfsh32 - -quiet - -add $hash[test2] Intel -add $hash[test2] Alpha -add $hash[test2] Sparc32 -add $hash[test2] Mips -add $hash[test2] Sparc64 -add $hash[test2] AMD -add $hash[test2] Pa-risc -tables test2 - -beginning: -print Starting first foreach - -#profile enable warn - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -empty test2 -tables test2 - -# Special case where nothing is after the forend diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-hashes.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-hashes.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-hashes.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-hashes.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -add $hash[test2] Intel -add $hash[test2] Alpha -add $hash[test2] Sparc32 -add $hash[test2] Mips -add $hash[test2] Sparc64 -add $hash[test2] AMD -add $hash[test2] Pa-risc -tables test2 - -vlist -type - -# We need a parameter -cmp $# 1 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -print Starting second foreach -tables test2 - -foreach $element of test2 - print Table contains element : $element -forend - -load /usr/bin/ssh - -vlist -set $entnbr 1.sht[.dynsym].size -div $entnbr 1.sht[.dynsym].entsize -vlist - -print Third loop until $entnbr : -print - -foreach $idx of 0 until $entnbr - print Symbol $idx is 1.dynsym[$idx].name -forend - -unload /usr/bin/ssh -print Program finished -empty test2 -tables test2 -quit - -error: -print This script needs one parameter (a file name) diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-linearity.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-linearity.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-linearity.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-linearity.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,30 +0,0 @@ -#!../../elfsh/elfsh32 - -add $list[test] Intel -add $list[test] Alpha -add $list[test] Sparc32 -add $list[test] Mips -add $list[test] Sparc64 -add $list[test] AMD -add $list[test] Pa-risc - -add $list[test2] HEHEHE - -lists test -lists test2 - -#profile enable warn -#quiet - -foreach $element of test - - # Should print an error - foreach $element2 of test - print List2 contains element : $element2 - forend - - print List contains element : $element - -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-lists.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-lists.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-lists.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-lists.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -vlist - -add $list[test2] Intel -add $list[test2] Alpha -add $list[test2] Sparc32 -add $list[test2] Mips -add $list[test2] Sparc64 -add $list[test2] AMD -add $list[test2] Pa-risc -lists test2 - -# We need a parameter -vlist -cmp $# 0 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend - -print Starting second foreach -lists test2 - -foreach $element of test2 - print List contains element : $element -forend - -quit - -error: -print This script needs one parameter (a file name) -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-list-simple.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-list-simple.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-list-simple.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-list-simple.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!../../elfsh/elfsh32 - -#quiet - -add $list[test2] Intel -add $list[test2] Alpha -add $list[test2] Sparc32 -add $list[test2] Mips -add $list[test2] Sparc64 -add $list[test2] AMD -add $list[test2] Pa-risc - -# We need a parameter -cmp $# 0 -jne error - -beginning: -print Starting first foreach - -foreach $elem of test2 matching Sparc - print Regex Matched $elem -forend -quit - -error: -print This script needs one parameter (a file name) -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-nested.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-nested.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-nested.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-nested.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -#!../../elfsh/elfsh32 - -#profile enable warn -#quiet - -add $list[test] Intel -add $list[test] Alpha -add $list[test] Mips - -add $list[test2] HEHE -add $list[test2] HOHO - -lists test -lists test2 - -foreach $element of test - - foreach $element3 of test2 - print List2 contains element : $element3 - forend - - print List contains element : $element - -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-reference.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-reference.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/foreach-reference.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/foreach-reference.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,29 +0,0 @@ -#!../../elfsh/elfsh32 - -add $list[test] 1 -add $list[test] 2 -add $list[test] 3 -lists test - -#quiet -#profile enable warn - -foreach $element of test - add $element 3 -forend - -print -lists test - -foreach $elem of test - print List contains element : $elem -forend - -print -lists test - -foreach $elem of test - print List contains element : $elem -forend - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/graph-tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/graph-tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/graph-tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/graph-tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -#!/usr/local/bin/elfsh32 - -# $Id: graph-tests.esh,v 1.3 2007-05-19 18:28:10 thor Exp $ - -#quiet - -# don't popup any windows, just generate .png files -configure graph.autoview 0 -configure libasm.output.att.margin 5 - -nocolor - -load $1 - -# analyse the object and graph function dependecies -analyse -graph - -# get number of symbols in symtab -set $entnbr 1.sht[.symtab].size -div $entnbr 1.sht[.symtab].entsize - -# walk it and dump all functions -foreach $idx of 0 until $entnbr - cmp 1.symtab[$idx].type 2 - jne skip - print $idx is 1.symtab[$idx].name - set $fname 1.symtab[$idx].name - graph bloc $fname -skip: -forend - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/insert_tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/insert_tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/insert_tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/insert_tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -#!/usr/local/bin/elfsh - -exec rm /tmp/ls.new -load /bin/ls -e -sht -pht -insert phdr PT_GNU_STACK .dynamic 1.sht[.dynamic].size -e -sht -pht -save /tmp/ls.new -exec /tmp/ls.new -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/kernsh-script.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/kernsh-script.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/kernsh-script.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/kernsh-script.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -#!elfsh/elfsh32 - -load vmlinux -type thread_info = task:*long -type task_struct = state:long thread_info:*thread_info -inform task_struct init_task - -print 1.task_struct[init_task].thread_info.task -print 1.task_struct[init_task].thread_info diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/loop.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/loop.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/loop.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/loop.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -#!../../elfsh/elfsh32 - -# comment it for enabling trace mode -quiet - -load /bin/ls -set $index 0 -print Now try to find symbols with 4 bytes size : - -loop: -cmp $index 1.hdr.shnum -je endloop -print Passing section 1.section[$index].name at addr 1.sht[$index].addr with index $index -add $index 1 -jmp loop - -endloop: -set $index 0 -set $lastsym 1.sht[.dynsym].size -div $lastsym 1.sht[.dynsym].entsize -print Now try to find symbols with 4 bytes size ( dynsymtab contains $lastsym entries ) : - -loop2: -cmp $index $lastsym -je end -cmp 1.dynsym[$index].size 4 -jne rec -print Found dword sized symbol : 1.dynsym[$index].name at addr 1.dynsym[$index].value -rec: -add $index 1 -jmp loop2 - -end: -vlist -quit - - - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/myparams.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/myparams.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/myparams.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/myparams.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,25 +0,0 @@ -#!../../elfsh/elfsh32 - -cmp $# 1 -jne paramerr - -load /bin/ls -print Parameter 1 : $1 -set $full 1.sht[.dynsym].size -div $full 1.sht[.dynsym].entsize -print Dynamic symtab contains $full entries -cmp $full $1 -jle err -print Entry $1 is 1.dynsym[$1].value with name 1.dynsym[$1].name -jmp end - -err: -print Table is too small -paramerr: -print Script must take one parameter -end: -print End of scripts, listing variables : -vlist -quit - - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/params2.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/params2.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/params2.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/params2.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -#!/usr/local/bin/elfsh - -print TWO = $2 -print ONE = $1 -cmp $1 $2 -je err -print DIFF -jmp end -err: -print EQU -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/params.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/params.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/params.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/params.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,17 +0,0 @@ -#!/usr/local/bin/elfsh - -load /bin/ls -print Parameter 1 : $1 -set $full 1.sht[.dynsym].size -div $full 1.sht[.dynsym].entsize -print Dynamic symbol table contains $full entries -print FULL = $full -print ONE = $1 -cmp $1 $full -jle err -print Symbol $1 is 1.dynsym[$1].name -jmp end -err: -print Table is too small -end: -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/print_array.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/print_array.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/print_array.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/print_array.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../elfsh/elfsh32 - -load ../../a.out -type example1 = sys:string[3] -inform example1 toto array - -print 1.example1[toto].sys[0] - -set $i 0 - -boucle: - -cmp $i 3 -je end -print INDEX $i = 1.example1[toto].sys[$i] -add $i 1 -jmp boucle - -end: -print "Bye !" diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/print_syscalltable.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/print_syscalltable.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/print_syscalltable.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/print_syscalltable.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -#!../../elfsh/elfsh32 - -load /usr/src/linux/vmlinux -type example1 = sys:int[320] -inform example1 toto sys_call_table - -print 1.example1[toto].sys[0] - -set $i 0 - -boucle: - -cmp $i 2 -je end -print 1.example1[toto].sys[$i] -add $i 1 -jmp boucle - -end: -print "Bye !" \ No newline at end of file diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/regression-tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/regression-tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/regression-tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/regression-tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,263 +0,0 @@ -#!../../elfsh/elfsh32 -# -# Additional tests suite for shell commands . -# -# This does nothing really, just checking that all commands -# do their job. The output file is completely useless. -# -# And please dont ask -why- 42 -# - - -# Start printing the help screens -help -info - - -# Uncomment me for a quiet output log -# quiet -# Uncomment me for a very verbose output -#profile enable warn - -# Now load the files -load /bin/ls -list -switch 1 - -exec ls -la - -# Playing with print and exec commands -print phnum is 1.hdr.phnum and got[21] is 1.got[21] -print 11th section is 1.section[11].name - - -# Play with arithmetic ops -print phnum = 1.hdr.phnum -add 1.hdr.phnum 42 -print phnum = 1.hdr.phnum -sub 1.hdr.phnum 41 -print phnum = 1.hdr.phnum -div 1.hdr.phnum 2 -print phnum = 1.hdr.phnum -mod 1.hdr.phnum 2 -print phnum = 1.hdr.phnum -mul 1.hdr.phnum 5 -print phnum = 1.hdr.phnum - -# Playing a bit with the modules -cmdtest -modload ../../modules/modtest.so -print hehe -cmdtest -list - -profile enable all -modunload ../../modules/modtest.so -print hehe - -# ELF header tests -# Illustrate the object affectations between files - -e -print 1.hdr.magic -set 1.hdr.magic 0x42424242 -print 1.hdr.magic -e - -set 1.hdr.type 2.hdr.type -set 1.hdr.machine 0x43 -set 1.hdr.version 0x44 -set 1.hdr.entry .data - -# Dont do those or you wont be able to see the change in the output file -#set 1.hdr.shoff 0x46 -#set 1.hdr.phoff 0x47 - -set 1.hdr.ehsize 0x48 -set 1.hdr.shentsize 2.hdr.shentsize -set 1.hdr.phentsize 2.hdr.shentsize -set 1.hdr.phnum 3 -set 1.hdr.shnum 30 -set 1.hdr.shstrndx 31 - -# PAX flags tests - -set 1.hdr.pax_pageexec 0 -set 1.hdr.pax_segmexec 1 -set 1.hdr.pax_emultramp 0 -set 1.hdr.pax_mprotect 1 -set 1.hdr.pax_randmmap 0 -set 1.hdr.pax_randexec 1 - -e - -print 1.hdr.magic -print 1.hdr.type -print 1.hdr.machine -print 1.hdr.version -print 1.hdr.entry -print 1.hdr.phoff -print 1.hdr.shoff -print 1.hdr.ehsize -print 1.hdr.shentsize -print 1.hdr.phentsize -print 1.hdr.phnum -print 1.hdr.shnum -print 1.hdr.shstrndx - - -# PHT tests -# Illustrate elf.h constants resolving as immediate value - -p -set 1.pht[0].type ET_DYN -set 1.pht[0].offset 0x55 -set 1.pht[0].vaddr 0x56 -set 1.pht[0].paddr 0x57 -set 1.pht[0].filesz 0x58 -set 1.pht[0].memsz 0x59 -set 1.pht[0].flags 0x60 -set 1.pht[0].align 0x61 -p - -print 1.pht[0].type -print 1.pht[0].offset -print 1.pht[0].vaddr -print 1.pht[0].paddr -print 1.pht[0].filesz -print 1.pht[0].memsz -print 1.pht[0].flags -print 1.pht[0].align - - - -# SHT tests - -s 01 -set 1.sht[1].type 0x54 -set 1.sht[1].addr 0x55 -set 1.sht[1].offset 0x56 -set 1.sht[1].size 0x57 -set 1.sht[1].link 0x58 -set 1.sht[1].info 0x59 -set 1.sht[1].align 0x60 -set 1.sht[1].entsize 0x61 -set 1.sht[1].a 1 -set 1.sht[1].w 1 -set 1.sht[1].x 1 -set 1.sht[1].s 1 -set 1.sht[1].m 1 -set 1.sht[1].l 1 -set 1.sht[1].o 1 -s - -print 1.sht[1].type -print 1.sht[1].addr -print 1.sht[1].offset -print 1.sht[1].size -print 1.sht[1].link -print 1.sht[1].info -print 1.sht[1].align -print 1.sht[1].entsize -print 1.sht[1].a -print 1.sht[1].w -print 1.sht[1].x -print 1.sht[1].s -print 1.sht[1].m -print 1.sht[1].l -print 1.sht[1].o - - - - -# SYMTAB tests - -sym 03] -set 1.symtab[3].value 0x62 -set 1.symtab[3].size 0x63 -set 1.symtab[3].bind 1 -set 1.symtab[3].type 4 -set 1.symtab[3].other 2 -sym 03] - -print 1.symtab[3].value -print 1.symtab[3].size -print 1.symtab[3].bind -print 1.symtab[3].type -print 1.symtab[3].other - - -# DYNSYMTAB tests - -dynsym 12] -set 1.dynsym[12].value 0x67 -set 1.dynsym[12].size 0x68 -set 1.dynsym[12].bind 1 -set 1.dynsym[12].type 6 -set 1.dynsym[12].other 2 -dynsym 12] - -print 1.dynsym[12].value -print 1.dynsym[12].size -print 1.dynsym[12].bind -print 1.dynsym[12].type -print 1.dynsym[12].other - - -# .DYNAMIC tests - -dyn 07] -set 1.dynamic[7].val 0x72 -set 1.dynamic[7].tag 0x73 -dyn 07] - -print 1.dynamic[7].val -print 1.dynamic[7].tag - - -# .GOT tests : you can also use filepath instead of their index - -got 05]|13] -print 1.got[5] -set 1.got[5] /usr/local/bin/elfsh.got[13] -print 1.got[5] -got 05]|13] - - -# CTORS and DTORS tests -# Illustrate the (dyn)symbol resolving as immediate value - -ctors -set 1.ctors[0] 0x41424344 -set 1.ctors[1] malloc -ctors - -dtors -set 1.dtors[1] 0x4546 -set 1.dtors[0] free -dtors - - -# RELOCATION TABLE TESTS - -rel 062] -set 1.rel[1][62].sym 22 -set 1.rel[1][62].offset 0x08044800 -set 1.rel[1][62].type R_386_GOTPC -rel 062] - -# Now leave, unloaded files are closed without saving -save /tmp/test-save -unload /bin/ls -exec rm /tmp/test-save -quit - - - - - - - - - - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/remap_script.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/remap_script.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/remap_script.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/remap_script.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -#!/usr/bin/elfsh - -load /bin/ls -modload modremap -findrel -remap 0x11223344 -save /tmp/ls.remapped -exec /tmp/ls.remapped -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-lists.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-lists.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-lists.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-lists.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -#!../../elfsh/elfsh32 - -set $list[test1:key] 42 -lists test1 - -set $list[test2] $list[test1] -lists test - -set $list[test1:key2] 43 -lists test -lists test1 -lists test2 - -add $list[test2] $list[test1:key2] -lists test2 - -sub $list[test2] key2 -lists test2 - -# test error checking -sub $list[test2] key2 -lists test2 - -#profile enable warn - -add $list[test2] 42 -add $list[test2] 43 -add $list[test2] 44 -add $list[test2] 45 -add $list[test2] 46 -add $list[test2] 47 -add $list[test2] 48 - -lists test2 -lists test1 - -sub $list[test2] $list[test1] -lists test2 -lists test1 -add $list[test2] $list[test1] -lists test2 -lists test1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-tables.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-tables.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-tables.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-tables.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,42 +0,0 @@ -#!../../elfsh/elfsh32 -set $hash[test1:key] 42 -tables test1 - -set $hash[test2] $hash[test1] -tables test - -set $hash[test1:key2] 43 -tables test -tables test1 -tables test2 - -add $hash[test2] $hash[test1:key2] -tables test2 - -sub $hash[test2] key2 -tables test2 - -# test error checking -sub $hash[test2] key2 -tables test2 - -#profile enable warn - -add $hash[test2] 42 -add $hash[test2] 43 -add $hash[test2] 44 -add $hash[test2] 45 -add $hash[test2] 46 -add $hash[test2] 47 -add $hash[test2] 48 - -tables test2 -tables test1 -sub $hash[test2] $hash[test1] -tables test2 -tables test1 -add $hash[test2] $hash[test1] -tables test2 -tables test1 - -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-types.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-types.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/script-types.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/script-types.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,53 +0,0 @@ -#!../../elfsh/elfsh32 - -load ../../elfsh/elfsh32 -switch 107 - -# Just some examples of type that can be used to map internal framework structures -type context = savedfd:int savedmode:byte savedcmd:*long savedinput:*long savedargv:*long savedname:*long curcmd:*long -type state = flags:byte[4] glregex%32 sregx:*long alertf:byte alertregex%32 strs:*long[4] moreflags:byte[5] lastid:int -type world = state:state ctxt:context - -# Lets see an example of printing of real variables arrays of the framework - -type archtypes = types:string[55] -inform archtypes elfsh_arch_type -type archaddr = types:long[55] -inform archaddr elfsh_arch_type - -inform archtypes -quiet - -print Now print Strings -print -print 107.archtypes[elfsh_arch_type].types[0] -print 107.archtypes[elfsh_arch_type].types[1] -print 107.archtypes[elfsh_arch_type].types[2] -print 107.archtypes[elfsh_arch_type].types[3] -print - -print Now print addresses -print -print Entry 1 : 107.archaddr[elfsh_arch_type].types[0] -print Entry 2 : 107.archaddr[elfsh_arch_type].types[1] -print Entry 3 : 107.archaddr[elfsh_arch_type].types[2] -print Entry 4 : 107.archaddr[elfsh_arch_type].types[3] -print - -verb -#profile enable warn - -set 107.archaddr[elfsh_arch_type].types[0] 0x41414141 -set 107.archaddr[elfsh_arch_type].types[1] 0x42424242 -set 107.archaddr[elfsh_arch_type].types[2] 0x43434343 -set 107.archaddr[elfsh_arch_type].types[3] 0x44444444 - -print 107.archaddr[elfsh_arch_type].types[0] -print 107.archaddr[elfsh_arch_type].types[1] -print 107.archaddr[elfsh_arch_type].types[2] -print 107.archaddr[elfsh_arch_type].types[3] - -quit - - - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/strings_tests.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/strings_tests.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/strings_tests.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/strings_tests.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -#!/usr/local/bin/elfsh -# -# Second regression test script -# - -#quiet - -load /bin/ls - -print SHT entries 1 and 13: -s 01]|13] - -print The interpretor section: -X interp - -print Change section name: -print 1.section[1].name -set 1.section[1].name .pffffffffffff -print 1.section[1].name - -print 20 first bytes of .text: -X ^\.text%20 - -print Change 5 first byte of section .text : -write 1.section[.text].raw hehe\x42 -X ^\.text%20 - -print Write 9 bytes in section .text, starting at byte 5: -write 1.section[.text:5].raw \x43\x44\huhu\x00\x48 -X ^\.text%20 - -print Write the value of printf symbol (4 bytes) at offset 10 (2 * 5) -write 1.section[.text:2%5].raw printf -X ^\.text%20 - -s 01]|13] - -print Change a symbol name -print 1.symtab[1].name -set 1.symtab[1].name heh -print 1.symtab[1].name - -print Change a dynamic symbol name -print 1.dynsym[2].name -set 1.dynsym[2].name test_big_string_oh_yeah -print 1.dynsym[2].name - -save /tmp/elfsh.modifs -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/subtyping.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/subtyping.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/subtyping.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/subtyping.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -#!../../evarista/evarista32 - -print ************ Now declarations of subtypes ***************** - -type struct0 = field0:long -type -type struct1::struct0 = field1:byte field2:long -type -type struct2::struct1 = field3:struct1 field4:long field5:struct1 -type - -# This is not allowed (collision in field names) -#verb -#type struct3::struct0 = field0:string -#type -#type struct4 = field0:string field0:int -#type - diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/test-multidim-arrays.c.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/test-multidim-arrays.c.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/test-multidim-arrays.c.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/test-multidim-arrays.c.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* -** biarray[2][3] = {{1, 2, 3}, {4, 5, 6}}; -** -** triarray[2][3][2] = {{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {11, 12}}}; -** -** main() -** -** %08X\n", biarray, triarray); -** (0); -** -** -** -** $Id: test-multidim-arrays.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - - - -int main() -{ - printf("stack = %08X \n", _estack); - -} diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/test-set.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/test-set.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/test-set.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/test-set.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -#!../../elfsh/elfsh32 - -info -vlist -load /bin/ls -vlist -e -vlist -set 1.hdr.shnum 42 -vlist -e -vlist -quit diff -Nru eresi-0.8a25/testsuite/testscripts/.svn/text-base/trace.esh.svn-base eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/trace.esh.svn-base --- eresi-0.8a25/testsuite/testscripts/.svn/text-base/trace.esh.svn-base 2008-04-06 23:15:38.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/.svn/text-base/trace.esh.svn-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -#!/usr/bin/elfsh - -print Number of parameters : $# -print Param 1 : $1 - -cmp 2 $# -jne bad - -print Parameter 1 = $1 - -b $1 -display 1 got $1 -display 1 print Reached breakpoint ! - -start -set $idx 0 -step - -loop: -cont -add $idx 1 -cmp $idx 5 -je end -jmp loop - -end: -print Stepped 5 instructions ! -#delete 1 -step -quit - -bad: -print You need a parameter -quit diff -Nru eresi-0.8a25/testsuite/testscripts/test-multidim-arrays.c eresi-0.0.20110516/testsuite/testscripts/test-multidim-arrays.c --- eresi-0.8a25/testsuite/testscripts/test-multidim-arrays.c 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/test-multidim-arrays.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -/* -** biarray[2][3] = {{1, 2, 3}, {4, 5, 6}}; -** -** triarray[2][3][2] = {{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {11, 12}}}; -** -** main() -** -** %08X\n", biarray, triarray); -** (0); -** -** -** -** $Id: test-multidim-arrays.c,v 1.2 2007-03-07 16:45:36 thor Exp $ -** -*/ -#include - - - -int main() -{ - printf("stack = %08X \n", _estack); - -} diff -Nru eresi-0.8a25/testsuite/testscripts/test-set.esh eresi-0.0.20110516/testsuite/testscripts/test-set.esh --- eresi-0.8a25/testsuite/testscripts/test-set.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/test-set.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -#!../../elfsh/elfsh32 - -info -vlist -load /bin/ls -vlist -e -vlist -set 1.hdr.shnum 42 -vlist -e -vlist -quit diff -Nru eresi-0.8a25/testsuite/testscripts/trace.esh eresi-0.0.20110516/testsuite/testscripts/trace.esh --- eresi-0.8a25/testsuite/testscripts/trace.esh 2008-04-06 23:15:39.000000000 +0000 +++ eresi-0.0.20110516/testsuite/testscripts/trace.esh 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -#!/usr/bin/elfsh - -print Number of parameters : $# -print Param 1 : $1 - -cmp 2 $# -jne bad - -print Parameter 1 = $1 - -b $1 -display 1 got $1 -display 1 print Reached breakpoint ! - -start -set $idx 0 -step - -loop: -cont -add $idx 1 -cmp $idx 5 -je end -jmp loop - -end: -print Stepped 5 instructions ! -#delete 1 -step -quit - -bad: -print You need a parameter -quit diff -Nru eresi-0.8a25/testsuite/tracing/host.c eresi-0.0.20110516/testsuite/tracing/host.c --- eresi-0.8a25/testsuite/tracing/host.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/tracing/host.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,36 @@ +#define _XOPEN_SOURCE +#include +#include + +int testcrypt() +{ + crypt("password", "salt"); + return 5; +} + +int firstfunc(int num, char *value) +{ + char *monptr; + monptr = (value + 3 % 1); + testcrypt(); + return 1; +} + +int secondfunc(char *justastring) +{ + puts(justastring); +} + +int main(int argc, char **argv) +{ + unsigned int index; + for (index = 0; index < argc; index++) + { + printf("arg[%d] %s\n", index, argv[index]); + } + char path[256]; + getcwd(path, 255); + printf("BEFORE ! %s\n", path); + firstfunc(3, "this is the text"); + return 0; +} diff -Nru eresi-0.8a25/testsuite/tracing/Makefile eresi-0.0.20110516/testsuite/tracing/Makefile --- eresi-0.8a25/testsuite/tracing/Makefile 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/tracing/Makefile 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,49 @@ +## +## Makefile for elfsh +## +## Started on Sun Mar 10 01:19:24 2002 jfv +## Last update Sun March 21 23:15:15 2007 mxatone +## +include ../../config.h + +SRC = tracer.c +OBJ32 = $(SRC:.c=.32.o) +OBJ64 = $(SRC:.c=.64.o) +HOSTSRC = host.c +HOSTOBJ32 = host.32.o +HOSTNAM32 = host32 +HOSTOBJ64 = host.64.o +HOSTNAM64 = host64 +HOSTLIB = -lcrypt +NAM32 = tracer32 +NAM64 = tracer64 +RM = rm -f +CC = gcc + +LIB32 =$(shell eresi-config32 libstderesi --libs) +LIB64 =$(shell eresi-config64 libstderesi --libs) +CFLAGS32 =$(shell eresi-config32 libstderesi --cflags) #-gdwarf-2 +CFLAGS64 =$(shell eresi-config64 libstderesi --cflags) #-gdwarf-2 + +all: all32 all64 + +all32 : $(OBJ32) + $(CC) $(HOSTLIB) $(HOSTSRC) -o $(HOSTNAM32) + $(CC) $(OBJ32) $(LIB32) -o $(NAM32) + +all64 : $(OBJ64) + $(CC) $(HOSTLIB) $(HOSTSRC) -o $(HOSTNAM64) + $(CC) $(OBJ64) $(LIB64) -o $(NAM64) + +clean : + $(RM) $(OBJ32) $(HOSTOBJ32) $(OBJ64) $(HOSTOBJ64) *~ \#* *\# + +fclean : clean + $(RM) $(NAM32) $(NAM64) $(HOSTNAM32) $(HOSTNAM64) + +%.32.o: %.c + $(CC) -c $< -o $@ $(CFLAGS32) -g + +%.64.o: %.c + $(CC) -c $< -o $@ $(CFLAGS64) -g + diff -Nru eresi-0.8a25/testsuite/tracing/trace.esh eresi-0.0.20110516/testsuite/tracing/trace.esh --- eresi-0.8a25/testsuite/tracing/trace.esh 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/tracing/trace.esh 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,10 @@ +#!../../etrace/etrace32 +load ./host32 +traces add main +traces create critical +traces add crypt critical +traces create mainnodes +traces add .*func mainnodes +traces add testcrypt mainnodes +#profile enable warn +save fake_aout diff -Nru eresi-0.8a25/testsuite/tracing/tracer.c eresi-0.0.20110516/testsuite/tracing/tracer.c --- eresi-0.8a25/testsuite/tracing/tracer.c 1970-01-01 00:00:00.000000000 +0000 +++ eresi-0.0.20110516/testsuite/tracing/tracer.c 2011-05-16 11:34:58.000000000 +0000 @@ -0,0 +1,62 @@ +/* +** tracer.c for testsuite in elfsh +** +** Started on Sat March 21 22:49:23 2007 mxatone +** +** +*/ +#include "revm.h" + +#define HOST_FILE "a.out" +#define TRACED_FILE "fake_aout" + +int main(int argc, char **argv) +{ + elfshobj_t *host; + char *critical[] = {"critical", NULL}; + char *mainnode[] = {"mainnodes", NULL}; + char logbuf[BUFSIZ]; + + revm_tables_setup(); + + /* Map host file */ + host = elfsh_map_obj(HOST_FILE); + if (NULL == host) + goto err; + + /* Setup world current */ + world.curjob->curfile = host; + + /* Parse debugging informations */ + revm_edfmt_parse(host); + + /* Init hash dep */ + revm_load_init_dephash(host, host->name); + + /* Load dependences */ + revm_load_enumdep(host); + + /* global scope */ + traces_add(host, "main", NULL); + + /* critical scope */ + traces_create(host, critical[0], NULL); + traces_add(host, "crypt", critical); + + /* mainnodes scope */ + traces_create(host, mainnode[0], NULL); + traces_add(host, "firstfunc", mainnode); + traces_add(host, "testcrypt", mainnode); + + /* Save it */ + if (etrace_save_obj(host, TRACED_FILE) < 0) + goto err; + + printf("[*] %s traced into %s\n", HOST_FILE, TRACED_FILE); + + return 0; + + err: + printf("[!] Failed to trace %s into %s\n", HOST_FILE, TRACED_FILE); + return -1; +}